p-elements-core 1.2.32-rc8 → 1.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/.editorconfig +17 -17
  2. package/.gitlab-ci.yml +18 -18
  3. package/CHANGELOG.md +201 -201
  4. package/demo/sample.js +1 -1
  5. package/demo/screen.css +16 -16
  6. package/dist/p-elements-core-modern.js +1 -1
  7. package/dist/p-elements-core.js +1 -1
  8. package/docs/package-lock.json +6897 -6897
  9. package/docs/package.json +27 -27
  10. package/docs/src/404.md +8 -8
  11. package/docs/src/_data/demos/hello-world/hello-world.tsx +35 -35
  12. package/docs/src/_data/demos/hello-world/index.html +10 -10
  13. package/docs/src/_data/demos/hello-world/project.json +7 -7
  14. package/docs/src/_data/demos/timer/demo-timer.tsx +120 -120
  15. package/docs/src/_data/demos/timer/icons.tsx +62 -62
  16. package/docs/src/_data/demos/timer/index.html +12 -12
  17. package/docs/src/_data/demos/timer/project.json +8 -8
  18. package/docs/src/_data/global.js +13 -13
  19. package/docs/src/_data/helpers.js +19 -19
  20. package/docs/src/_includes/layouts/base.njk +30 -30
  21. package/docs/src/_includes/layouts/playground.njk +40 -40
  22. package/docs/src/_includes/partials/app-header.njk +8 -8
  23. package/docs/src/_includes/partials/head.njk +14 -14
  24. package/docs/src/_includes/partials/nav.njk +19 -19
  25. package/docs/src/_includes/partials/top-nav.njk +51 -51
  26. package/docs/src/documentation/custom-element.md +221 -221
  27. package/docs/src/documentation/decorators/bind.md +71 -71
  28. package/docs/src/documentation/decorators/custom-element-config.md +63 -63
  29. package/docs/src/documentation/decorators/property.md +83 -83
  30. package/docs/src/documentation/decorators/query.md +66 -66
  31. package/docs/src/documentation/decorators/render-property-on-set.md +60 -60
  32. package/docs/src/documentation/decorators.md +9 -9
  33. package/docs/src/documentation/reactive-properties.md +53 -53
  34. package/docs/src/index.d.ts +25 -25
  35. package/docs/src/index.md +3 -3
  36. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +78 -78
  37. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +166 -166
  38. package/docs/src/scripts/components/app-playground/app-playground.tsx +189 -189
  39. package/docs/tsconfig.json +22 -22
  40. package/index.html +10 -2
  41. package/package.json +1 -1
  42. package/readme.md +206 -206
  43. package/src/custom-element-controller.ts +31 -31
  44. package/src/custom-element.test.ts +906 -906
  45. package/src/custom-element.ts +3 -8
  46. package/src/decorators/bind.test.ts +163 -163
  47. package/src/decorators/bind.ts +46 -46
  48. package/src/decorators/custom-element-config.ts +17 -17
  49. package/src/decorators/property.test.ts +279 -279
  50. package/src/decorators/query.test.ts +146 -146
  51. package/src/decorators/query.ts +12 -12
  52. package/src/decorators/render-property-on-set.ts +3 -3
  53. package/src/helpers/css.ts +71 -71
  54. package/src/maquette/cache.ts +35 -35
  55. package/src/maquette/dom.ts +115 -115
  56. package/src/maquette/h.ts +100 -100
  57. package/src/maquette/index.ts +12 -12
  58. package/src/maquette/interfaces.ts +536 -536
  59. package/src/maquette/jsx.ts +61 -61
  60. package/src/maquette/mapping.ts +56 -56
  61. package/src/maquette/projection.ts +666 -666
  62. package/src/maquette/projector.ts +205 -205
  63. package/src/sample/mixin/highlight.tsx +33 -33
  64. package/src/sample/sample.tsx +98 -0
@@ -1,63 +1,63 @@
1
- ---
2
- title: "customElementConfig"
3
- layout: "base.njk"
4
- description: "Documentation for @CustomElementConfig decorator"
5
- permalink: "/documentation/decorators/custom-element-config.html"
6
- eleventyNavigation:
7
- parent: Decorators
8
- key: CustomElementConfigDecorator
9
- title: CustomElementConfig
10
- order: 1
11
- ---
12
-
13
- # CustomElementConfig decorator
14
-
15
- The `@CustomElementConfig` decorator simplifies the process of defining a custom element (Web Component).
16
-
17
- ## Usage
18
-
19
- Apply the `@CustomElementConfig` decorator to a class that extends `HTMLElement` or a related base class. Pass a configuration object with the `tagName` for the custom element.
20
-
21
- ```typescript
22
-
23
- @CustomElementConfig({ tagName: 'my-element' })
24
- class MyElement extends HTMLElement {
25
- connectedCallback() {
26
- this.innerHTML = `<h1>Hello from My Element!</h1>`;
27
- }
28
- }
29
- ```
30
-
31
- This code is equivalent to:
32
-
33
- ```typescript
34
- class MyElement extends HTMLElement {
35
- connectedCallback() {
36
- this.innerHTML = `<h1>Hello from My Element!</h1>`;
37
- }
38
- }
39
- customElements.define('my-element', MyElement);
40
- ```
41
-
42
- ## Configuration Options
43
-
44
- - `tagName` (required): The tag name for the custom element. Must contain a hyphen (`-`).
45
- - `options`: An optional object passed to `customElements.define`. Currently supports:
46
- - `extends`: Specifies the tag name of a built-in element to extend (e.g., `'button'` for a customized button). Requires using the `is` attribute in HTML (`<button is="my-button">`).
47
-
48
- ```typescript
49
- // Example extending a built-in button
50
- @CustomElementConfig({ tagName: 'my-custom-button', options: { extends: 'button' } })
51
- class MyCustomButton extends HTMLButtonElement {
52
- // ... custom button logic
53
- }
54
-
55
- // Usage in HTML:
56
- // <button is="my-custom-button">Click Me</button>
57
- ```
58
-
59
- ## Benefits
60
-
61
- - **Declarative:** Clearly defines the custom element's tag name alongside the class definition.
62
- - **Concise:** Reduces boilerplate code compared to calling `customElements.define` manually.
63
- - **Readability:** Improves code organization by keeping the element definition and its tag name together.
1
+ ---
2
+ title: "customElementConfig"
3
+ layout: "base.njk"
4
+ description: "Documentation for @CustomElementConfig decorator"
5
+ permalink: "/documentation/decorators/custom-element-config.html"
6
+ eleventyNavigation:
7
+ parent: Decorators
8
+ key: CustomElementConfigDecorator
9
+ title: CustomElementConfig
10
+ order: 1
11
+ ---
12
+
13
+ # CustomElementConfig decorator
14
+
15
+ The `@CustomElementConfig` decorator simplifies the process of defining a custom element (Web Component).
16
+
17
+ ## Usage
18
+
19
+ Apply the `@CustomElementConfig` decorator to a class that extends `HTMLElement` or a related base class. Pass a configuration object with the `tagName` for the custom element.
20
+
21
+ ```typescript
22
+
23
+ @CustomElementConfig({ tagName: 'my-element' })
24
+ class MyElement extends HTMLElement {
25
+ connectedCallback() {
26
+ this.innerHTML = `<h1>Hello from My Element!</h1>`;
27
+ }
28
+ }
29
+ ```
30
+
31
+ This code is equivalent to:
32
+
33
+ ```typescript
34
+ class MyElement extends HTMLElement {
35
+ connectedCallback() {
36
+ this.innerHTML = `<h1>Hello from My Element!</h1>`;
37
+ }
38
+ }
39
+ customElements.define('my-element', MyElement);
40
+ ```
41
+
42
+ ## Configuration Options
43
+
44
+ - `tagName` (required): The tag name for the custom element. Must contain a hyphen (`-`).
45
+ - `options`: An optional object passed to `customElements.define`. Currently supports:
46
+ - `extends`: Specifies the tag name of a built-in element to extend (e.g., `'button'` for a customized button). Requires using the `is` attribute in HTML (`<button is="my-button">`).
47
+
48
+ ```typescript
49
+ // Example extending a built-in button
50
+ @CustomElementConfig({ tagName: 'my-custom-button', options: { extends: 'button' } })
51
+ class MyCustomButton extends HTMLButtonElement {
52
+ // ... custom button logic
53
+ }
54
+
55
+ // Usage in HTML:
56
+ // <button is="my-custom-button">Click Me</button>
57
+ ```
58
+
59
+ ## Benefits
60
+
61
+ - **Declarative:** Clearly defines the custom element's tag name alongside the class definition.
62
+ - **Concise:** Reduces boilerplate code compared to calling `customElements.define` manually.
63
+ - **Readability:** Improves code organization by keeping the element definition and its tag name together.
@@ -1,83 +1,83 @@
1
- ---
2
- title: "Property decorator"
3
- layout: "base.njk"
4
- description: "Documentation for @Property decorator"
5
- permalink: "/documentation/decorators/property.html"
6
- eleventyNavigation:
7
- parent: Decorators
8
- key: PropertyDecorator
9
- title: Property
10
- order: 2
11
- ---
12
-
13
- # Property decorator
14
-
15
- The `@Property` decorator is used within custom element classes to declare reactive properties. These properties can automatically reflect their state to corresponding HTML attributes, trigger re-renders when changed, and handle type conversions.
16
-
17
- ## Usage
18
-
19
- Apply the `@Property` decorator to a class field.
20
-
21
- ```typescript
22
- @CustomElementConfig({ tagName: 'my-greeting' })
23
- class MyGreeting extends CustomElement {
24
-
25
- static readonly style = `...`;
26
-
27
- @Property({ type: 'string', reflect: true, attribute: 'name' })
28
- name = 'World';
29
-
30
- render() : VNode {
31
- return <h1>Hello, ${this.name}!</h1>;
32
- }
33
- }
34
- ```
35
-
36
- In this example:
37
- - A property `name` is declared.
38
- - `type: 'string'` specifies the expected data type.
39
- - `reflect: true` means changes to the `name` property will update the `name` attribute on the `<my-greeting>` element in the DOM.
40
- - `attribute: 'name'` explicitly links the property to the `name` HTML attribute (defaults to the lowercase property name if omitted).
41
-
42
- ## Configuration Options (`PropertyOptions`)
43
-
44
- - `type: 'string' | 'number' | 'boolean' | 'object'`:
45
- - Specifies the property's data type.
46
- - Used for automatic attribute-to-property conversion (when an attribute changes) and property-to-attribute conversion (when `reflect: true`).
47
- - For `boolean`, the attribute's presence means `true`, and absence means `false`.
48
- - For `object`, JSON serialization/deserialization is used for attribute reflection.
49
- - `reflect?: boolean`:
50
- - If `true`, changes to the property will update the corresponding attribute in the HTML.
51
- - Default: `false`.
52
- - `attribute?: string`:
53
- - The name of the HTML attribute to associate with the property.
54
- - If omitted, it defaults to the property name converted to lowercase (e.g., `myProperty` becomes `myproperty`).
55
- - Set to `false` to prevent attribute association entirely.
56
- - `readonly?: boolean`:
57
- - If `true`, the property can only be set once. Subsequent attempts to set it will throw an error.
58
- - Useful for properties that should be initialized but not changed later.
59
- - Default: `false`.
60
- - `converter?: AttributeConverter<any>`:
61
- - An object with optional `fromAttribute` and `toAttribute` functions for custom attribute/property conversion logic.
62
- - `fromAttribute(value: string | null): T`: Converts the attribute string value to the property type `T`.
63
- - `toAttribute(value: T): string`: Converts the property value `T` to its string representation for the attribute.
64
-
65
- ```typescript
66
- // Example with a custom converter for Date
67
- const dateConverter: AttributeConverter<Date> = {
68
- fromAttribute: (value) => value ? new Date(value) : null,
69
- toAttribute: (value) => value ? value.toISOString() : null
70
- };
71
-
72
- // ... inside class ...
73
- @property({ type: "object", attribute: "start-date", converter: dateConverter, reflect: true })
74
- startDate: Date;
75
- ```
76
-
77
- ## Reactivity
78
-
79
- When a property decorated with `@Property` changes:
80
- 1. If `reflect: true`, the corresponding attribute is updated.
81
- 2. The component's `scheduleRender()` method (if available, typically provided by a base class like `CustomElement`) is called, queueing a re-render.
82
- 3. The component's `updated(propertyName, oldValue, newValue)` method (if available) is called after the value has been set.
83
- 4. The component's `shouldUpdate(propertyName, oldValue, newValue)` method (if available) is called *before* the value is set. If it returns `false`, the property update and subsequent rendering/updated calls are skipped.
1
+ ---
2
+ title: "Property decorator"
3
+ layout: "base.njk"
4
+ description: "Documentation for @Property decorator"
5
+ permalink: "/documentation/decorators/property.html"
6
+ eleventyNavigation:
7
+ parent: Decorators
8
+ key: PropertyDecorator
9
+ title: Property
10
+ order: 2
11
+ ---
12
+
13
+ # Property decorator
14
+
15
+ The `@Property` decorator is used within custom element classes to declare reactive properties. These properties can automatically reflect their state to corresponding HTML attributes, trigger re-renders when changed, and handle type conversions.
16
+
17
+ ## Usage
18
+
19
+ Apply the `@Property` decorator to a class field.
20
+
21
+ ```typescript
22
+ @CustomElementConfig({ tagName: 'my-greeting' })
23
+ class MyGreeting extends CustomElement {
24
+
25
+ static readonly style = `...`;
26
+
27
+ @Property({ type: 'string', reflect: true, attribute: 'name' })
28
+ name = 'World';
29
+
30
+ render() : VNode {
31
+ return <h1>Hello, ${this.name}!</h1>;
32
+ }
33
+ }
34
+ ```
35
+
36
+ In this example:
37
+ - A property `name` is declared.
38
+ - `type: 'string'` specifies the expected data type.
39
+ - `reflect: true` means changes to the `name` property will update the `name` attribute on the `<my-greeting>` element in the DOM.
40
+ - `attribute: 'name'` explicitly links the property to the `name` HTML attribute (defaults to the lowercase property name if omitted).
41
+
42
+ ## Configuration Options (`PropertyOptions`)
43
+
44
+ - `type: 'string' | 'number' | 'boolean' | 'object'`:
45
+ - Specifies the property's data type.
46
+ - Used for automatic attribute-to-property conversion (when an attribute changes) and property-to-attribute conversion (when `reflect: true`).
47
+ - For `boolean`, the attribute's presence means `true`, and absence means `false`.
48
+ - For `object`, JSON serialization/deserialization is used for attribute reflection.
49
+ - `reflect?: boolean`:
50
+ - If `true`, changes to the property will update the corresponding attribute in the HTML.
51
+ - Default: `false`.
52
+ - `attribute?: string`:
53
+ - The name of the HTML attribute to associate with the property.
54
+ - If omitted, it defaults to the property name converted to lowercase (e.g., `myProperty` becomes `myproperty`).
55
+ - Set to `false` to prevent attribute association entirely.
56
+ - `readonly?: boolean`:
57
+ - If `true`, the property can only be set once. Subsequent attempts to set it will throw an error.
58
+ - Useful for properties that should be initialized but not changed later.
59
+ - Default: `false`.
60
+ - `converter?: AttributeConverter<any>`:
61
+ - An object with optional `fromAttribute` and `toAttribute` functions for custom attribute/property conversion logic.
62
+ - `fromAttribute(value: string | null): T`: Converts the attribute string value to the property type `T`.
63
+ - `toAttribute(value: T): string`: Converts the property value `T` to its string representation for the attribute.
64
+
65
+ ```typescript
66
+ // Example with a custom converter for Date
67
+ const dateConverter: AttributeConverter<Date> = {
68
+ fromAttribute: (value) => value ? new Date(value) : null,
69
+ toAttribute: (value) => value ? value.toISOString() : null
70
+ };
71
+
72
+ // ... inside class ...
73
+ @property({ type: "object", attribute: "start-date", converter: dateConverter, reflect: true })
74
+ startDate: Date;
75
+ ```
76
+
77
+ ## Reactivity
78
+
79
+ When a property decorated with `@Property` changes:
80
+ 1. If `reflect: true`, the corresponding attribute is updated.
81
+ 2. The component's `scheduleRender()` method (if available, typically provided by a base class like `CustomElement`) is called, queueing a re-render.
82
+ 3. The component's `updated(propertyName, oldValue, newValue)` method (if available) is called after the value has been set.
83
+ 4. The component's `shouldUpdate(propertyName, oldValue, newValue)` method (if available) is called *before* the value is set. If it returns `false`, the property update and subsequent rendering/updated calls are skipped.
@@ -1,66 +1,66 @@
1
- ---
2
- title: "Query decorator"
3
- layout: "base.njk"
4
- description: "Documentation for @Query decortator"
5
- permalink: "/documentation/decorators/query.html"
6
- eleventyNavigation:
7
- parent: Decorators
8
- key: QueryDecorator
9
- title: Query
10
- order: 4
11
- ---
12
-
13
- # Query decorator
14
-
15
- The `@Query` decorator provides a convenient way to get a reference to an element within your custom element's template (either its shadow DOM or light DOM).
16
-
17
- ## Usage
18
-
19
- Apply the `@Query` decorator to a class field. Pass the CSS selector for the target element as an argument.
20
-
21
- ```typescript
22
-
23
- @CustomElementConfig({ tagName: 'my-input-element' })
24
- class MyInputElement extends CustomElement {
25
-
26
- static readonly style = "...";
27
-
28
- @Query('#myInput')
29
- inputElement: HTMLInputElement;
30
-
31
- @Query('#MessageArea')
32
- messageArea: HTMLDivElement;
33
-
34
- private onChange = () => {
35
- this.messageArea = this.inputElement.value;
36
- }
37
-
38
- render(): VNode {
39
- return <div>
40
- <input type="text" id="myInput" onchange={this.onChange} placeholder="Enter text">
41
- <div id="messageArea"></div>
42
- </div>;
43
- }
44
-
45
- }
46
- ```
47
-
48
- ## How it Works
49
-
50
- The decorator defines a getter for the decorated property. When you access the property (e.g., `this.inputElement`):
51
- 1. It runs `this.shadowRoot.querySelector(selector)` by default.
52
- 2. If the optional second argument `useShadowRoot` is set to `false`, it runs `this.querySelector(selector)` instead, searching the element's light DOM.
53
- 3. It returns the first matching element or `null` if no element is found.
54
-
55
- ## Parameters
56
-
57
- - `selector` (required): A string containing a CSS selector to identify the target element.
58
- - `useShadowRoot?: boolean`:
59
- - If `true` (the default), queries within the element's `shadowRoot`.
60
- - If `false`, queries within the element's light DOM (using `this.querySelector`).
61
-
62
- ## Benefits
63
-
64
- - **Declarative:** Clearly indicates which elements the component interacts with directly within the class definition.
65
- - **Concise:** Reduces the boilerplate of repeatedly writing `this.shadowRoot.querySelector(...)`.
66
- - **Readability:** Makes it easier to understand the component's structure and dependencies.
1
+ ---
2
+ title: "Query decorator"
3
+ layout: "base.njk"
4
+ description: "Documentation for @Query decortator"
5
+ permalink: "/documentation/decorators/query.html"
6
+ eleventyNavigation:
7
+ parent: Decorators
8
+ key: QueryDecorator
9
+ title: Query
10
+ order: 4
11
+ ---
12
+
13
+ # Query decorator
14
+
15
+ The `@Query` decorator provides a convenient way to get a reference to an element within your custom element's template (either its shadow DOM or light DOM).
16
+
17
+ ## Usage
18
+
19
+ Apply the `@Query` decorator to a class field. Pass the CSS selector for the target element as an argument.
20
+
21
+ ```typescript
22
+
23
+ @CustomElementConfig({ tagName: 'my-input-element' })
24
+ class MyInputElement extends CustomElement {
25
+
26
+ static readonly style = "...";
27
+
28
+ @Query('#myInput')
29
+ inputElement: HTMLInputElement;
30
+
31
+ @Query('#MessageArea')
32
+ messageArea: HTMLDivElement;
33
+
34
+ private onChange = () => {
35
+ this.messageArea = this.inputElement.value;
36
+ }
37
+
38
+ render(): VNode {
39
+ return <div>
40
+ <input type="text" id="myInput" onchange={this.onChange} placeholder="Enter text">
41
+ <div id="messageArea"></div>
42
+ </div>;
43
+ }
44
+
45
+ }
46
+ ```
47
+
48
+ ## How it Works
49
+
50
+ The decorator defines a getter for the decorated property. When you access the property (e.g., `this.inputElement`):
51
+ 1. It runs `this.shadowRoot.querySelector(selector)` by default.
52
+ 2. If the optional second argument `useShadowRoot` is set to `false`, it runs `this.querySelector(selector)` instead, searching the element's light DOM.
53
+ 3. It returns the first matching element or `null` if no element is found.
54
+
55
+ ## Parameters
56
+
57
+ - `selector` (required): A string containing a CSS selector to identify the target element.
58
+ - `useShadowRoot?: boolean`:
59
+ - If `true` (the default), queries within the element's `shadowRoot`.
60
+ - If `false`, queries within the element's light DOM (using `this.querySelector`).
61
+
62
+ ## Benefits
63
+
64
+ - **Declarative:** Clearly indicates which elements the component interacts with directly within the class definition.
65
+ - **Concise:** Reduces the boilerplate of repeatedly writing `this.shadowRoot.querySelector(...)`.
66
+ - **Readability:** Makes it easier to understand the component's structure and dependencies.
@@ -1,60 +1,60 @@
1
- ---
2
- title: "PropertyRenderOnSet decorator"
3
- layout: "base.njk"
4
- description: "documentation for @PropertyRenderOnSet decorator"
5
- permalink: "/documentation/decorators/property-render-on-set.html"
6
- eleventyNavigation:
7
- parent: Decorators
8
- key: PropertyRenderOnSet
9
- title: PropertyRenderOnSet
10
- order: 3
11
- ---
12
-
13
- # PropertyRenderOnSet decorator
14
-
15
- The `@PropertyRenderOnSet` decorator is essentially a pre-configured alias for the `@property` decorator.
16
-
17
- It simplifies the common use case of creating a property that should trigger a re-render whenever its value is set, but without needing attribute reflection or specific type handling by default.
18
-
19
- ## Usage
20
-
21
- Apply the `@PropertyRenderOnSet` decorator to a class field.
22
-
23
- ```typescript
24
-
25
- @CustomElementConfig({ tagName: 'my-counter' })
26
- class MyCounter extends CustomElement {
27
-
28
- @PropertyRenderOnSet
29
- private count = 0;
30
-
31
- private onButtonClick = () => {
32
- this.count++;
33
- }
34
-
35
- render(): VNode {
36
- return <div>
37
- <p>Count: {this.count}</p>
38
- <button id="increment" onclick={this.onButtonClick}>Increment</button>
39
- </div>;
40
- }
41
- }
42
- ```
43
-
44
- ## How it Works
45
-
46
- `@propertyRenderOnSet` is equivalent to calling `@property({})`. This means:
47
-
48
- - It sets up a getter and setter for the property.
49
- - When the property is set:
50
- - The component's `scheduleRender()` method (if available) is called.
51
- - The component's `updated()` method (if available) is called.
52
- - The component's `shouldUpdate()` method (if available) is checked beforehand.
53
- - It does **not** configure attribute reflection (`reflect: false` by default).
54
- - It does **not** enforce a specific `type` by default.
55
-
56
- ## When to Use
57
-
58
- Use `@PropertyRenderOnSet` when you need internal state within your component that should trigger a re-render when it changes, but you don't need that state to be reflected as an HTML attribute or configured via an attribute.
59
-
60
- If you need attribute reflection or type conversion, use the more explicit `@Property` decorator with the appropriate options.
1
+ ---
2
+ title: "PropertyRenderOnSet decorator"
3
+ layout: "base.njk"
4
+ description: "documentation for @PropertyRenderOnSet decorator"
5
+ permalink: "/documentation/decorators/property-render-on-set.html"
6
+ eleventyNavigation:
7
+ parent: Decorators
8
+ key: PropertyRenderOnSet
9
+ title: PropertyRenderOnSet
10
+ order: 3
11
+ ---
12
+
13
+ # PropertyRenderOnSet decorator
14
+
15
+ The `@PropertyRenderOnSet` decorator is essentially a pre-configured alias for the `@property` decorator.
16
+
17
+ It simplifies the common use case of creating a property that should trigger a re-render whenever its value is set, but without needing attribute reflection or specific type handling by default.
18
+
19
+ ## Usage
20
+
21
+ Apply the `@PropertyRenderOnSet` decorator to a class field.
22
+
23
+ ```typescript
24
+
25
+ @CustomElementConfig({ tagName: 'my-counter' })
26
+ class MyCounter extends CustomElement {
27
+
28
+ @PropertyRenderOnSet
29
+ private count = 0;
30
+
31
+ private onButtonClick = () => {
32
+ this.count++;
33
+ }
34
+
35
+ render(): VNode {
36
+ return <div>
37
+ <p>Count: {this.count}</p>
38
+ <button id="increment" onclick={this.onButtonClick}>Increment</button>
39
+ </div>;
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## How it Works
45
+
46
+ `@propertyRenderOnSet` is equivalent to calling `@property({})`. This means:
47
+
48
+ - It sets up a getter and setter for the property.
49
+ - When the property is set:
50
+ - The component's `scheduleRender()` method (if available) is called.
51
+ - The component's `updated()` method (if available) is called.
52
+ - The component's `shouldUpdate()` method (if available) is checked beforehand.
53
+ - It does **not** configure attribute reflection (`reflect: false` by default).
54
+ - It does **not** enforce a specific `type` by default.
55
+
56
+ ## When to Use
57
+
58
+ Use `@PropertyRenderOnSet` when you need internal state within your component that should trigger a re-render when it changes, but you don't need that state to be reflected as an HTML attribute or configured via an attribute.
59
+
60
+ If you need attribute reflection or type conversion, use the more explicit `@Property` decorator with the appropriate options.
@@ -1,9 +1,9 @@
1
- ---
2
- eleventyNavigation:
3
- key: Decorators
4
- title: Decorators
5
- order: 10
6
- ---
7
- <script>
8
- document.location.href="./custom-element-config.html";
9
- </script>
1
+ ---
2
+ eleventyNavigation:
3
+ key: Decorators
4
+ title: Decorators
5
+ order: 10
6
+ ---
7
+ <script>
8
+ document.location.href="./custom-element-config.html";
9
+ </script>