Skip to content

Commit e1c0693

Browse files
Merge pull request #57 from zeixcom/feature/dom-refactor
Feature/dom refactor
2 parents 1b1fdfb + e07b08a commit e1c0693

File tree

207 files changed

+6753
-3902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+6753
-3902
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UIElement
22

3-
Version 0.13.1
3+
Version 0.13.2
44

55
**UIElement** - a HTML-first library for reactive Web Components
66

docs-src/components/form-combobox/form-combobox.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {
22
type Component,
3+
type Computed,
34
RESET,
45
UNSET,
56
batch,
67
component,
78
effect,
9+
fromSelector,
810
on,
9-
selection,
1011
setAttribute,
1112
setProperty,
1213
setText,
@@ -43,10 +44,9 @@ export default component<FormComboboxProps>(
4344
const focusIndex = state(-1)
4445
const filterText = state('')
4546
const showPopup = state(false)
46-
const options = selection<HTMLLIElement>(
47-
el,
47+
const options = fromSelector<HTMLLIElement>(
4848
'[role="option"]:not([hidden])',
49-
)
49+
)(el) as Computed<HTMLLIElement[]>
5050
const isExpanded = () => mode.get() === 'editing' && showPopup.get()
5151

5252
// Internal function

docs-src/components/input-field/input-field.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
type AttributeParser,
33
type Component,
4-
type FxFunction,
4+
type Effect,
55
UNSET,
66
component,
77
computed,
@@ -74,8 +74,7 @@ export default component(
7474
},
7575
},
7676
(el: Component<InputFieldProps>, { first }) => {
77-
const fns: FxFunction<InputFieldProps, Component<InputFieldProps>>[] =
78-
[]
77+
const fns: Effect<InputFieldProps, Component<InputFieldProps>>[] = []
7978
const input = el.querySelector('input')
8079
if (!input) throw new Error('No input element found')
8180
const typeNumber = input.type === 'number'

docs-src/components/module-catalog/module-catalog.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Component, component, fromDescendants, pass } from '../../..'
2+
import { BasicButtonProps } from '../basic-button/basic-button'
23

34
export type ModuleCatalogProps = {
45
total: number
@@ -7,7 +8,7 @@ export type ModuleCatalogProps = {
78
export default component(
89
'module-catalog',
910
{
10-
total: fromDescendants<number, HTMLElement & { value: number }>(
11+
total: fromDescendants(
1112
'form-spinbutton',
1213
(sum, item) => sum + item.value,
1314
0,
@@ -16,7 +17,7 @@ export default component(
1617
(el, { first }) => [
1718
first(
1819
'basic-button',
19-
pass({
20+
pass<ModuleCatalogProps, Component<BasicButtonProps>>({
2021
badge: () => (el.total > 0 ? String(el.total) : ''),
2122
disabled: () => !el.total,
2223
}),

docs-src/components/module-todo/module-todo.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {
22
type Component,
33
component,
4+
fromDescendant,
45
fromSelector,
56
on,
6-
read,
77
setAttribute,
88
setProperty,
99
setText,
1010
show,
1111
} from '../../..'
1212
import type { BasicButtonProps } from '../basic-button/basic-button'
1313
import type { FormCheckboxProps } from '../form-checkbox/form-checkbox'
14-
import type { FormRadiogroupProps } from '../form-radiogroup/form-radiogroup'
14+
import '../form-radiogroup/form-radiogroup'
1515
import type { FormTextboxProps } from '../form-textbox/form-textbox'
1616

1717
export type ModuleTodoProps = {
@@ -34,12 +34,12 @@ export default component(
3434
const list = el.querySelector('ol')
3535
if (!list) throw new Error('No list found')
3636

37-
const inputLength = read(input, 'length', 0)
38-
const filterValue = read(
39-
el.querySelector<Component<FormRadiogroupProps>>('form-radiogroup'),
37+
const inputLength = fromDescendant('form-textbox', 'length', 0)(el)
38+
const filterValue = fromDescendant(
39+
'form-radiogroup',
4040
'value',
4141
'all',
42-
)
42+
)(el)
4343

4444
return [
4545
// Control todo input form

docs-src/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<context-router>
1313
<header class="content-grid">
1414
<h1 class="content">
15-
UIElement Docs <small>Version 0.13.1</small>
15+
UIElement Docs <small>Version 0.13.2</small>
1616
</h1>
1717
{{ include 'menu.html' }}
1818
<card-callout class="content danger" hidden>

docs-src/pages/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ A copy of the license can be found in the [LICENSE](https://github.com/zeixcom/u
5252

5353
## Version History
5454

55-
### Current Version: 0.13.0
55+
### Current Version: 0.13.2
5656

5757
<card-callout class="caution">
5858

docs-src/pages/api.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ description: 'Functions, types, and constants'
2121

2222
Create a Web Component of type [Component](api/type-aliases/Component.html) with reactive properties that extend [ComponentProps](api/type-aliases/ComponentProps.html).
2323

24-
- [component](api/functions/component.html)
24+
- [component](api/functions/component.html) defines a custom element with reactive properties and declarative effects
2525

2626
</section>
2727

@@ -32,8 +32,6 @@ Create a Web Component of type [Component](api/type-aliases/Component.html) with
3232
Create a signal of type [Signal](api/type-aliases/Signal.html).
3333

3434
- [computed](api/functions/computed.html) creates a [Computed](api/type-aliases/Computed.html) signal derived from other signals
35-
- [selection](api/functions/selection.html) creates a [Computed](api/type-aliases/Computed.html) signal that updates according to a dynamic CSS selector
36-
- [sensor](api/functions/sensor.html) creates a [Computed](api/type-aliases/Computed.html) signal that updates according to events
3735
- [state](api/functions/state.html) creates a [State](api/type-aliases/State.html) signal
3836

3937
Helper functions:
@@ -50,20 +48,20 @@ Helper functions:
5048

5149
Declare how attributes are parsed. Functions returning [AttributeParser](api/type-aliases/AttributeParser.html) that will be used to create [State](api/type-aliases/State.html) signals as reactive properties on the component.
5250

53-
- [asBoolean](api/functions/asBoolean.html)
54-
- [asEnum](api/functions/asEnum.html)
55-
- [asInteger](api/functions/asInteger.html)
56-
- [asJSON](api/functions/asJSON.html)
57-
- [asNumber](api/functions/asNumber.html)
58-
- [asString](api/functions/asString.html)
51+
- [asBoolean](api/functions/asBoolean.html) parses boolean attributes (presence indicates true)
52+
- [asEnum](api/functions/asEnum.html) parses string attributes constrained to specific values
53+
- [asInteger](api/functions/asInteger.html) parses integer attributes with validation
54+
- [asJSON](api/functions/asJSON.html) parses JSON attributes into JavaScript objects
55+
- [asNumber](api/functions/asNumber.html) parses numeric attributes as floating-point numbers
56+
- [asString](api/functions/asString.html) parses string attributes
5957

6058
</section>
6159

6260
<section>
6361

64-
## Signal Initializers
62+
## Signal Producers
6563

66-
Declare how signals are initialized. Variable of type or function returning [SignalInitializer](api/type-aliases/SignalInitializer.html):
64+
Declare how signals are initialized. Variable of type or function returning [SignalProducer](api/type-aliases/SignalProducer.html):
6765

6866
- [fromContext](api/functions/fromContext.html) consumes a context value from nearest ancestor context provider component
6967
- [fromDescendant](api/functions/fromDescendant.html) gets a reactive property of a descendant component
@@ -79,19 +77,19 @@ Declare how signals are initialized. Variable of type or function returning [Sig
7977

8078
Declare effects of type [FxFunction](api/type-aliases/FxFunction.html) to be applied when signals change:
8179

82-
- [dangerouslySetInnerHTML](api/functions/dangerouslySetInnerHTML.html)
83-
- [emit](api/functions/emit.html)
84-
- [insertOrRemoveElement](api/functions/insertOrRemoveElement.html)
85-
- [on](api/functions/on.html)
86-
- [pass](api/functions/pass.html)
87-
- [provide](api/functions/provide.html)
88-
- [setAttribute](api/functions/setAttribute.html)
89-
- [setProperty](api/functions/setProperty.html)
90-
- [setStyle](api/functions/setStyle.html)
91-
- [setText](api/functions/setText.html)
92-
- [show](api/functions/show.html)
93-
- [toggleAttribute](api/functions/toggleAttribute.html)
94-
- [toggleClass](api/functions/toggleClass.html)
95-
- [updateElement](api/functions/updateElement.html)
80+
- [dangerouslySetInnerHTML](api/functions/dangerouslySetInnerHTML.html) sets inner HTML content from a signal
81+
- [emit](api/functions/emit.html) dispatches custom events when signals change
82+
- [insertOrRemoveElement](api/functions/insertOrRemoveElement.html) conditionally inserts or removes elements
83+
- [on](api/functions/on.html) attaches event listeners to elements
84+
- [pass](api/functions/pass.html) passes signal values to descendant component properties
85+
- [provide](api/functions/provide.html) provides context values to descendant components
86+
- [setAttribute](api/functions/setAttribute.html) sets element attributes from signals
87+
- [setProperty](api/functions/setProperty.html) sets element properties from signals
88+
- [setStyle](api/functions/setStyle.html) sets CSS styles from signals
89+
- [setText](api/functions/setText.html) sets text content from signals
90+
- [show](api/functions/show.html) conditionally shows or hides elements
91+
- [toggleAttribute](api/functions/toggleAttribute.html) toggles attributes based on signal values
92+
- [toggleClass](api/functions/toggleClass.html) toggles CSS classes based on signal values
93+
- [updateElement](api/functions/updateElement.html) base function for updating elements, used for [setText](api/functions/setText.html), [show](api/functions/show.html), [toggleClass](api/functions/toggleClass.html), [toggleAttribute](api/functions/toggleAttribute.html), [setAttribute](api/functions/setAttribute.html), [setProperty](api/functions/setProperty.html), [setStyle](api/functions/setStyle.html)
9694

9795
</section>

docs-src/pages/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# UIElement
66

7-
Version 0.13.1
7+
Version 0.13.2
88

99
**UIElement** - a HTML-first library for reactive Web Components
1010

docs-src/pages/api/functions/asBoolean.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **asBoolean**(): [`AttributeParser`](../type-aliases/AttributeParser.md)\<`boolean`\>
1010
11-
Defined in: [src/lib/parsers.ts:23](https://github.com/zeixcom/ui-element/blob/051e9e1bc23b455abad71bf33880530a33e32030/src/lib/parsers.ts#L23)
11+
Defined in: [src/lib/parsers.ts:23](https://github.com/zeixcom/ui-element/blob/d13febaf363936558771161c1c4f66e2034f5ec3/src/lib/parsers.ts#L23)
1212

1313
Parse a boolean attribute as an actual boolean value
1414

0 commit comments

Comments
 (0)