@ea-lab/reactive-json-docs 0.8.0 → 1.0.0

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 (104) hide show
  1. package/package.json +7 -5
  2. package/public/rjbuild/docs/advanced-concepts/attribute-transformers.md +168 -0
  3. package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
  4. package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
  5. package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
  6. package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
  7. package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
  8. package/public/rjbuild/docs/advanced-concepts/forward-update.md +2 -2
  9. package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +2 -2
  10. package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
  11. package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
  12. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
  13. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
  14. package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +48 -2
  15. package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +54 -2
  16. package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
  17. package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
  18. package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
  19. package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
  20. package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
  21. package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
  22. package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
  23. package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
  24. package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
  25. package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
  26. package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
  27. package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
  28. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
  29. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
  30. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
  31. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
  32. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
  33. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
  34. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
  35. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
  36. package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +14 -4
  37. package/public/rjbuild/docs/core/element/form/Input.md +307 -0
  38. package/public/rjbuild/docs/core/element/form/Input.yaml +572 -0
  39. package/public/rjbuild/docs/core/element/special/Count.yaml +99 -31
  40. package/public/rjbuild/docs/core/element/special/DataFilter.yaml +118 -38
  41. package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +154 -34
  42. package/public/rjbuild/docs/core/element/special/Switch.md +5 -5
  43. package/public/rjbuild/docs/core/element/special/Switch.yaml +9 -18
  44. package/public/rjbuild/docs/core/example/html.md +2 -2
  45. package/public/rjbuild/docs/core/example/html.yaml +2 -3
  46. package/public/rjbuild/docs/core/example/native-html-forms.md +245 -0
  47. package/public/rjbuild/docs/core/example/native-html-forms.yaml +393 -0
  48. package/public/rjbuild/docs/core/hook/index.md +38 -0
  49. package/public/rjbuild/docs/core/hook/index.yaml +44 -0
  50. package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
  51. package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
  52. package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
  53. package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
  54. package/public/rjbuild/docs/core/reaction/addData.md +17 -3
  55. package/public/rjbuild/docs/core/reaction/addData.yaml +53 -9
  56. package/public/rjbuild/docs/core/reaction/fetchData.yaml +44 -8
  57. package/public/rjbuild/docs/core/reaction/setData.md +18 -4
  58. package/public/rjbuild/docs/core/reaction/setData.yaml +18 -4
  59. package/public/rjbuild/docs/docs-components/Mermaid.md +254 -0
  60. package/public/rjbuild/docs/docs-components/Mermaid.yaml +339 -0
  61. package/public/rjbuild/docs/docs-components/index.yaml +1 -0
  62. package/public/rjbuild/docs/getting-started/actions.md +1 -1
  63. package/public/rjbuild/docs/index.yaml +2 -1
  64. package/public/rjbuild/docs/install.md +2 -5
  65. package/public/rjbuild/docs/install.yaml +4 -10
  66. package/public/rjbuild/docs/{core → integration/bootstrap}/action/Popover.md +1 -1
  67. package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.md +1 -1
  68. package/public/rjbuild/docs/integration/bootstrap/element/html/AccordionItem.md +69 -0
  69. package/public/rjbuild/docs/integration/bootstrap/element/html/Modal.md +127 -0
  70. package/public/rjbuild/docs/integration/bootstrap/element/html/Tabs.md +150 -0
  71. package/public/rjbuild/docs/integration/bootstrap/element/html/index.md +13 -0
  72. package/public/rjbuild/docs/integration/bootstrap/element/special/index.md +19 -0
  73. package/public/rjbuild/docs/integration/bootstrap/example/website.md +41 -0
  74. package/public/rjbuild/docs/integration/bootstrap/overview.md +69 -0
  75. package/public/rjbuild/docs/integration/bootstrap/overview.yaml +87 -0
  76. /package/public/rjbuild/docs/{core → integration/bootstrap}/action/Popover.yaml +0 -0
  77. /package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.yaml +0 -0
  78. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.md +0 -0
  79. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.yaml +0 -0
  80. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.md +0 -0
  81. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.yaml +0 -0
  82. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.md +0 -0
  83. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.yaml +0 -0
  84. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.md +0 -0
  85. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.yaml +0 -0
  86. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.md +0 -0
  87. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.yaml +0 -0
  88. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.md +0 -0
  89. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.yaml +0 -0
  90. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/formElementsCommon.md +0 -0
  91. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.md +0 -0
  92. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.yaml +0 -0
  93. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/AccordionItem.yaml +0 -0
  94. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Modal.yaml +0 -0
  95. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Tabs.yaml +0 -0
  96. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/special/BootstrapElement.md +0 -0
  97. /package/public/rjbuild/docs/{core → integration/bootstrap}/element/special/BootstrapElement.yaml +0 -0
  98. /package/public/rjbuild/docs/{core → integration/bootstrap}/example/accordion.md +0 -0
  99. /package/public/rjbuild/docs/{core → integration/bootstrap}/example/accordion.yaml +0 -0
  100. /package/public/rjbuild/docs/{core → integration/bootstrap}/example/dynamic-content.md +0 -0
  101. /package/public/rjbuild/docs/{core → integration/bootstrap}/example/dynamic-content.yaml +0 -0
  102. /package/public/rjbuild/docs/{core → integration/bootstrap}/example/website.yaml +0 -0
  103. /package/public/rjbuild/docs/{chartjs → integration/chartjs}/components.yaml +0 -0
  104. /package/public/rjbuild/docs/{chartjs → integration/chartjs}/overview.yaml +0 -0
@@ -1,7 +1,7 @@
1
1
  renderView:
2
2
  - type: Markdown
3
3
  content: |
4
- # Plugin System Guide
4
+ # Plugin system guide
5
5
 
6
6
  ## Overview
7
7
 
@@ -124,6 +124,57 @@ renderView:
124
124
 
125
125
  - type: Markdown
126
126
  content: |
127
+ ### Component Override Behavior
128
+
129
+ When using `mergeComponentCollections` with multiple plugins, **the last component with a given name takes precedence**. This allows you to override default components with custom implementations.
130
+
131
+ - type: SyntaxHighlighter
132
+ language: jsx
133
+ content: |
134
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
135
+ import { defaultComponents } from "@ea-lab/reactive-json";
136
+ import { customComponents } from "./plugins/customComponents.js";
137
+
138
+ const plugins = mergeComponentCollections([
139
+ defaultComponents, // Contains a "Button" component
140
+ customComponents // Also contains a "Button" component - this one will be used
141
+ ]);
142
+
143
+ - type: Markdown
144
+ content: |
145
+ This override mechanism is particularly useful for:
146
+
147
+ - **Customizing default components**: Replace built-in components with your own implementations
148
+ - **Theme customization**: Override components to match your design system
149
+ - **Feature enhancement**: Add functionality to existing components
150
+ - **Third-party integration**: Replace components with versions from external libraries
151
+
152
+ **Example: Overriding a Default Button**
153
+
154
+ - type: SyntaxHighlighter
155
+ language: jsx
156
+ content: |
157
+ // Default plugin has a basic Button
158
+ const defaultPlugin = {
159
+ element: {
160
+ Button: BasicButton // Simple button implementation
161
+ }
162
+ };
163
+
164
+ // Your custom plugin overrides it
165
+ const customPlugin = {
166
+ element: {
167
+ Button: EnhancedButton // Button with animations and custom styling
168
+ }
169
+ };
170
+
171
+ // EnhancedButton will be used everywhere "Button" is referenced
172
+ const plugins = mergeComponentCollections([defaultPlugin, customPlugin]);
173
+
174
+ - type: Markdown
175
+ content: |
176
+ **⚠️ Important**: Component names must match exactly (case-sensitive) for the override to work. The order in the `mergeComponentCollections` array determines precedence.
177
+
127
178
  ### Custom ReactiveJsonRoot Wrapper
128
179
 
129
180
  Creating a custom wrapper allows you to **centralize plugin inclusion** across your entire application. Instead of manually importing and merging plugins in every component that uses Reactive-JSON, you define them once in a wrapper component.
@@ -193,6 +244,7 @@ renderView:
193
244
  2. **Use descriptive names** for components and plugins
194
245
  3. **Document component props** and usage patterns
195
246
  4. **Provide examples** for complex components
196
- 5. **Choose non-conflicting names** with existing components
247
+ 5. **Be intentional with component names** - use unique names unless you specifically want to override existing components
248
+ 6. **Document overrides** when replacing default components to help other developers understand the customization
197
249
 
198
250
  templates:
@@ -1,5 +1,7 @@
1
1
  # SetAttributeValue
2
2
 
3
+ > **Alternative**: For pre-render attribute modification, see the [setAttributeValue transformer](../../attributeTransformer/setAttributeValue.md).
4
+
3
5
  Dynamically sets or modifies the value of an HTML attribute on an element.
4
6
 
5
7
  ## Basic Syntax
@@ -3,6 +3,8 @@ renderView:
3
3
  content: |
4
4
  # SetAttributeValue
5
5
 
6
+ > **Alternative**: For pre-render attribute modification, see the [setAttributeValue transformer](../../attributeTransformer/setAttributeValue).
7
+
6
8
  Dynamically sets or modifies the value of an HTML attribute on an element.
7
9
 
8
10
  ## Basic Syntax
@@ -1,5 +1,7 @@
1
1
  # ToggleAttributeValue
2
2
 
3
+ > **Alternative**: For pre-render attribute modification, see the [toggleAttributeValue transformer](../../attributeTransformer/toggleAttributeValue.md).
4
+
3
5
  Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values.
4
6
 
5
7
  ## Important Notes
@@ -3,6 +3,8 @@ renderView:
3
3
  content: |
4
4
  # ToggleAttributeValue
5
5
 
6
+ > **Alternative**: For pre-render attribute modification, see the [toggleAttributeValue transformer](../../attributeTransformer/toggleAttributeValue).
7
+
6
8
  Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values.
7
9
 
8
10
  ## Important Notes
@@ -1,5 +1,7 @@
1
1
  # UnsetAttribute
2
2
 
3
+ > **Alternative**: For pre-render attribute modification, see the [unsetAttribute transformer](../../attributeTransformer/unsetAttribute.md).
4
+
3
5
  Completely removes an HTML attribute from an element.
4
6
 
5
7
  ## Basic Syntax
@@ -3,6 +3,8 @@ renderView:
3
3
  content: |
4
4
  # UnsetAttribute
5
5
 
6
+ > **Alternative**: For pre-render attribute modification, see the [unsetAttribute transformer](../../attributeTransformer/unsetAttribute).
7
+
6
8
  Completely removes an HTML attribute from an element.
7
9
 
8
10
  ## Basic Syntax
@@ -1,5 +1,7 @@
1
1
  # UnsetAttributeValue
2
2
 
3
+ > **Alternative**: For pre-render attribute modification, see the [unsetAttributeValue transformer](../../attributeTransformer/unsetAttributeValue.md).
4
+
3
5
  Removes a specific value from an HTML attribute while preserving other values.
4
6
 
5
7
  ## Basic Syntax
@@ -3,6 +3,8 @@ renderView:
3
3
  content: |
4
4
  # UnsetAttributeValue
5
5
 
6
+ > **Alternative**: For pre-render attribute modification, see the [unsetAttributeValue transformer](../../attributeTransformer/unsetAttributeValue).
7
+
6
8
  Removes a specific value from an HTML attribute while preserving other values.
7
9
 
8
10
  ## Basic Syntax
@@ -0,0 +1,121 @@
1
+ # Attribute Actions
2
+
3
+ > **Note**: Reactive-JSON provides two systems for attribute modification:
4
+ >
5
+ > - **Attribute Actions** (this section): Execute **after rendering**, modify DOM attributes directly
6
+ > - **[Attribute Transformers](../../attributeTransformer/index.md)**: Execute **before rendering**, modify attributes for child components
7
+ >
8
+ > Choose actions for post-render DOM manipulation and transformers for pre-render attribute conditioning.
9
+
10
+ Attribute Actions in Reactive-JSON allow you to modify element attributes after rendering based on dynamic conditions. They are evaluated continuously based on data state and provide direct DOM manipulation capabilities.
11
+
12
+ ## Key Differences from Transformers
13
+
14
+ - **Timing**: Attribute actions execute **after rendering**, while transformers execute **before rendering**
15
+ - **Impact**: Actions modify the DOM directly, transformers affect attributes passed to child components
16
+ - **Use case**: Actions are ideal for imperative DOM updates that don't need to affect child component props
17
+
18
+ ## Available Attribute Actions
19
+
20
+ ### Value Management
21
+ - **[SetAttributeValue](./SetAttributeValue.md)**: Sets or modifies HTML attribute values dynamically after rendering
22
+ - **[UnsetAttributeValue](./UnsetAttributeValue.md)**: Removes specific values from HTML attributes while preserving others
23
+ - **[ToggleAttributeValue](./ToggleAttributeValue.md)**: Toggles the presence of specific values in HTML attributes, supports cyclic toggling
24
+
25
+ ### Attribute Management
26
+ - **[UnsetAttribute](./UnsetAttribute.md)**: Completely removes HTML attributes after rendering
27
+
28
+ ## Basic Usage
29
+
30
+ Attribute actions are defined in the `actions` array on any element:
31
+
32
+ ```yaml
33
+ renderView:
34
+ - type: div
35
+ attributes:
36
+ class: "base-class"
37
+ data-status: "default"
38
+ actions:
39
+ # Add class conditionally
40
+ - what: SetAttributeValue
41
+ name: "class"
42
+ value: "active"
43
+ when: ~~.isActive
44
+ is: true
45
+
46
+ # Remove attribute entirely
47
+ - what: UnsetAttribute
48
+ name: "data-status"
49
+ when: ~~.hideStatus
50
+ is: true
51
+
52
+ # Toggle between states
53
+ - what: ToggleAttributeValue
54
+ name: "class"
55
+ value: ["theme-light", "theme-dark"]
56
+ when: ~~.toggleTheme
57
+ isNotEmpty:
58
+ ```
59
+
60
+ ## Execution Order
61
+
62
+ Attribute actions are applied based on data changes and re-evaluated when dependencies change:
63
+
64
+ 1. Component renders with base attributes
65
+ 2. Actions are evaluated based on current data state
66
+ 3. DOM attributes are modified directly
67
+ 4. Changes are applied to the live DOM element
68
+
69
+ ## Conditional Execution
70
+
71
+ All attribute actions support the same conditional system as other actions:
72
+
73
+ - **`when`**: Specifies the data value to evaluate
74
+ - **`is`**: Exact value comparison
75
+ - **`isEmpty`/`isNotEmpty`**: Empty/non-empty checks
76
+ - **Template evaluation**: Full support for `~.`, `~~.`, `~>`, `~~>` patterns
77
+
78
+ ## Common Patterns
79
+
80
+ ### Conditional Styling
81
+ ```yaml
82
+ actions:
83
+ - what: SetAttributeValue
84
+ name: "class"
85
+ value: "error"
86
+ when: ~~.validation.hasErrors
87
+ is: true
88
+ ```
89
+
90
+ ### State-based Attributes
91
+ ```yaml
92
+ actions:
93
+ - what: ToggleAttributeValue
94
+ name: "aria-expanded"
95
+ value: "true"
96
+ when: ~~.menu.isOpen
97
+ is: true
98
+ ```
99
+
100
+ ### Dynamic Data Attributes
101
+ ```yaml
102
+ actions:
103
+ - what: SetAttributeValue
104
+ name: "data-user-role"
105
+ value: ~~.currentUser.role
106
+ mode: "replace"
107
+ ```
108
+
109
+ ## When to Use Actions vs Transformers
110
+
111
+ ### Use Attribute Actions when:
112
+ - You need to modify DOM attributes after the component has rendered
113
+ - You're working with imperative DOM updates
114
+ - You need to interact with external libraries that read DOM attributes
115
+ - The attribute changes don't need to affect child component behavior
116
+
117
+ ### Use Attribute Transformers when:
118
+ - You need attributes to be available to child components
119
+ - You're doing conditional attribute setup before rendering
120
+ - You want predictable attribute values during the render phase
121
+ - You're building reusable components that depend on specific attributes
@@ -0,0 +1,77 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # Attribute Actions
5
+
6
+ > **Note**: Reactive-JSON provides two systems for attribute modification:
7
+ >
8
+ > - **Attribute Actions** (this section): Execute **after rendering**, modify DOM attributes directly
9
+ > - **[Attribute Transformers](../../attributeTransformer/index)**: Execute **before rendering**, modify attributes for child components
10
+ >
11
+ > Choose actions for post-render DOM manipulation and transformers for pre-render attribute conditioning.
12
+
13
+ Attribute Actions in Reactive-JSON allow you to modify element attributes after rendering based on dynamic conditions. They are evaluated continuously based on data state and provide direct DOM manipulation capabilities.
14
+
15
+ - type: TabbedSerializer
16
+ yamlSerializedContent: |
17
+ renderView:
18
+ - type: div
19
+ attributes:
20
+ class: "base-class"
21
+ data-status: "default"
22
+ actions:
23
+ # Add class conditionally
24
+ - what: SetAttributeValue
25
+ name: "class"
26
+ value: "active"
27
+ when: ~~.isActive
28
+ is: true
29
+
30
+ # Remove attribute entirely
31
+ - what: UnsetAttribute
32
+ name: "data-status"
33
+ when: ~~.hideStatus
34
+ is: true
35
+
36
+ # Toggle between states
37
+ - what: ToggleAttributeValue
38
+ name: "class"
39
+ value: ["theme-light", "theme-dark"]
40
+ when: ~~.toggleTheme
41
+ isNotEmpty:
42
+
43
+ - type: Markdown
44
+ content: |
45
+ ## Key Differences from Transformers
46
+
47
+ - **Timing**: Attribute actions execute **after rendering**, while transformers execute **before rendering**
48
+ - **Impact**: Actions modify the DOM directly, transformers affect attributes passed to child components
49
+ - **Use case**: Actions are ideal for imperative DOM updates that don't need to affect child component props
50
+
51
+ ## Available Attribute Actions
52
+
53
+ ### Value Management
54
+ - **[SetAttributeValue](./SetAttributeValue)**: Sets or modifies HTML attribute values dynamically after rendering
55
+ - **[UnsetAttributeValue](./UnsetAttributeValue)**: Removes specific values from HTML attributes while preserving others
56
+ - **[ToggleAttributeValue](./ToggleAttributeValue)**: Toggles the presence of specific values in HTML attributes, supports cyclic toggling
57
+
58
+ ### Attribute Management
59
+ - **[UnsetAttribute](./UnsetAttribute)**: Completely removes HTML attributes after rendering
60
+
61
+ ## Execution Order
62
+
63
+ Attribute actions are applied based on data changes and re-evaluated when dependencies change:
64
+
65
+ 1. Component renders with base attributes
66
+ 2. Actions are evaluated based on current data state
67
+ 3. DOM attributes are modified directly
68
+ 4. Changes are applied to the live DOM element
69
+
70
+ ## Conditional Execution
71
+
72
+ All attribute actions support the same conditional system as other actions:
73
+
74
+ - **`when`**: Specifies the data value to evaluate
75
+ - **`is`**: Exact value comparison
76
+ - **`isEmpty`/`isNotEmpty`**: Empty/non-empty checks
77
+ - **Template evaluation**: Full support for `~.`, `~~.`, `~>`, `~~>` patterns
@@ -0,0 +1,17 @@
1
+ # Attribute Transformers
2
+
3
+ > **Note**: Don't confuse with [Attribute Actions](../action/Attribute/index.md). Attribute Transformers execute **before rendering** and modify attributes for child components, while Attribute Actions execute **after rendering** and modify the DOM directly.
4
+
5
+ Attribute Transformers allow you to dynamically modify element attributes before rendering, based on conditions from the application state.
6
+
7
+ > **For detailed usage, examples, and extensibility information**, see **[Attribute Transformers Advanced Guide](../../advanced-concepts/attribute-transformers.md)**.
8
+
9
+ ## Available Attribute Transformers
10
+
11
+ ### Value Management
12
+ - **[setAttributeValue](./setAttributeValue.md)**: Sets or modifies HTML attribute values dynamically before rendering
13
+ - **[unsetAttributeValue](./unsetAttributeValue.md)**: Removes specific values from HTML attributes while preserving others
14
+ - **[toggleAttributeValue](./toggleAttributeValue.md)**: Toggles the presence of specific values in HTML attributes, supports cyclic toggling
15
+
16
+ ### Attribute Management
17
+ - **[unsetAttribute](./unsetAttribute.md)**: Completely removes HTML attributes before rendering
@@ -0,0 +1,24 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # Attribute Transformers
5
+
6
+ > **Note**: Don't confuse with [Attribute Actions](../action/Attribute/index). Attribute Transformers execute **before rendering** and modify attributes for child components, while Attribute Actions execute **after rendering** and modify the DOM directly.
7
+
8
+ Attribute Transformers allow you to dynamically modify element attributes before rendering, based on conditions from the application state.
9
+
10
+ > **For detailed usage, examples, and extensibility information**, see **[Attribute Transformers Advanced Guide](../../advanced-concepts/attribute-transformers)**.
11
+
12
+ ## Available Attribute Transformers
13
+
14
+ ### Value Management
15
+ - **[setAttributeValue](./setAttributeValue)**: Sets or modifies HTML attribute values dynamically before rendering
16
+ - **[unsetAttributeValue](./unsetAttributeValue)**: Removes specific values from HTML attributes while preserving others
17
+ - **[toggleAttributeValue](./toggleAttributeValue)**: Toggles the presence of specific values in HTML attributes, supports cyclic toggling
18
+
19
+ ### Attribute Management
20
+ - **[unsetAttribute](./unsetAttribute)**: Completely removes HTML attributes before rendering
21
+
22
+ data:
23
+ page_title: "Attribute Transformers - Reactive-JSON Documentation"
24
+
@@ -0,0 +1,101 @@
1
+ # setAttributeValue
2
+
3
+ > **Alternative**: For post-render DOM modification, see the [SetAttributeValue action](../action/Attribute/SetAttributeValue.md).
4
+
5
+ Dynamically sets or modifies the value of an HTML attribute before rendering. This attribute transformer allows you to conditionally modify attributes based on data state during the evaluation phase.
6
+
7
+ ## Basic Syntax
8
+
9
+ ```yaml
10
+ attributeTransforms:
11
+ # Add CSS class
12
+ - what: setAttributeValue
13
+ name: "class"
14
+ value: "active"
15
+
16
+ # Replace attribute value
17
+ - what: setAttributeValue
18
+ name: "data-status"
19
+ mode: "replace"
20
+ value: ~.currentStatus
21
+ ```
22
+
23
+ ## Properties
24
+
25
+ - **name** *(string, required)*: The name of the attribute to modify.
26
+ - **mode** *(string, optional)*: The modification mode. Default: `"append"`.
27
+ - `"append"`: Adds the value to the existing attribute value (space-separated).
28
+ - `"replace"`: Completely replaces the existing attribute value.
29
+ - **value** *(string, required)*: The value to set or append. Supports template evaluation (e.g., `~.dynamicValue`, `~~.globalValue`). Automatically converted to string if not already. Special characters are handled safely.
30
+ - **preventDuplicateValues** *(boolean, optional)*: When `true` (default), prevents duplicate values when using append mode.
31
+ - **separator** *(string, optional)*: The separator used between values. Default: `" "` (space).
32
+
33
+ ## Behavior
34
+
35
+ - **Append mode**: Adds the new value to the existing attribute, separated by the specified separator.
36
+ - **Replace mode**: Completely overwrites the existing attribute value.
37
+ - **Duplicate prevention**: In append mode, prevents adding duplicate values when enabled.
38
+
39
+ ## Common Use Cases
40
+
41
+ - **Dynamic CSS classes**: Adding/removing CSS classes based on state.
42
+ - **Data attributes**: Setting data-* attributes for JavaScript integration.
43
+ - **ARIA attributes**: Dynamically updating accessibility attributes.
44
+ - **Style attributes**: Modifying inline styles conditionally.
45
+
46
+ ## Example
47
+
48
+ ```yaml
49
+ renderView:
50
+ - type: input
51
+ attributes:
52
+ type: "text"
53
+ placeholder: "Type to see conditional styling..."
54
+ class: "base-input"
55
+ value: ~.input_data
56
+ style:
57
+ padding: "10px"
58
+ border: "2px solid #007bff"
59
+ borderRadius: "4px"
60
+ fontSize: "16px"
61
+ margin: "10px 0"
62
+ width: "300px"
63
+ display: "block"
64
+ attributeTransforms:
65
+ - what: setAttributeValue
66
+ name: "class"
67
+ value: "highlighted"
68
+ when: ~.input_data
69
+ isNotEmpty:
70
+ actions:
71
+ - what: setData
72
+ on: change
73
+ path: ~.input_data
74
+ value: <reactive-json:event-new-value>
75
+
76
+ - type: div
77
+ content: ["Current value: ", ~.input_data]
78
+
79
+ - type: style
80
+ content: |
81
+ .base-input {
82
+ transition: border-color 0.3s ease;
83
+ }
84
+ .highlighted {
85
+ border-color: #28a745 !important;
86
+ outline: 2px solid #28a745 !important;
87
+ outline-offset: 2px !important;
88
+ }
89
+
90
+ data:
91
+ input_data: ""
92
+ ```
93
+
94
+ ## Notes
95
+
96
+ - **Pre-render execution**: This transformer modifies attributes before the component renders, ensuring child components receive the transformed attributes.
97
+ - **Append mode behavior**: Respects existing attribute values when using append mode.
98
+ - **Replace mode**: Use when you need complete control over the attribute value.
99
+ - **Duplicate prevention**: Only applies to append mode.
100
+ - **Template evaluation**: The value property supports full template evaluation including `~.localData`, `~~.globalData`, `~>nearestKey`, and `~~>globalKey` patterns.
101
+ - **Conditional execution**: Supports the same condition system as actions (`when`, `is`, `isEmpty`, `isNotEmpty`, etc.).
@@ -0,0 +1,144 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # setAttributeValue
5
+
6
+ > **Alternative**: For post-render DOM modification, see the [SetAttributeValue action](../action/Attribute/SetAttributeValue).
7
+
8
+ Dynamically sets or modifies the value of an HTML attribute on an element.
9
+
10
+ ## Basic Syntax
11
+
12
+ - type: TabbedSerializer
13
+ yamlSerializedContent: |
14
+ attributeTransforms:
15
+ # Add CSS class
16
+ - what: setAttributeValue
17
+ name: "class"
18
+ value: "active"
19
+
20
+ # Replace attribute value
21
+ - what: setAttributeValue
22
+ name: "data-status"
23
+ mode: "replace"
24
+ value: ~.currentStatus
25
+
26
+ - type: Markdown
27
+ content: |
28
+ ## Properties
29
+
30
+ - type: DefinitionList
31
+ content:
32
+ - term:
33
+ code: name
34
+ after: "(string, required)"
35
+ details: The name of the attribute to modify.
36
+ - term:
37
+ code: mode
38
+ after: "(string, optional)"
39
+ details:
40
+ type: Markdown
41
+ content: |
42
+ The modification mode. Default: `"append"`
43
+ - `"append"`: Adds the value to the existing attribute value (space-separated)
44
+ - `"replace"`: Completely replaces the existing attribute value
45
+ - term:
46
+ code: value
47
+ after: "(string, required)"
48
+ details: The value to set or append. Supports template evaluation (e.g., `~.dynamicValue`, `~~.globalValue`). Automatically converted to string if not already. Special characters are handled safely.
49
+ - term:
50
+ code: preventDuplicateValues
51
+ after: "(boolean, optional)"
52
+ details:
53
+ type: Markdown
54
+ content: When `true` (default), prevents duplicate values when using append mode.
55
+ - term:
56
+ code: separator
57
+ after: "(string, optional)"
58
+ details:
59
+ type: Markdown
60
+ content: |
61
+ The separator used between values. Default: `" "` (space).
62
+
63
+ - type: Markdown
64
+ content: |
65
+
66
+ ## Behavior
67
+
68
+ - **Append mode**: Adds the new value to the existing attribute, separated by the specified separator.
69
+ - **Replace mode**: Completely overwrites the existing attribute value.
70
+ - **Duplicate prevention**: In append mode, prevents adding duplicate values when enabled.
71
+
72
+ ## Common Use Cases
73
+
74
+ - **Dynamic CSS classes**: Adding/removing CSS classes based on state.
75
+ - **Data attributes**: Setting data-* attributes for JavaScript integration.
76
+ - **ARIA attributes**: Dynamically updating accessibility attributes.
77
+ - **Style attributes**: Modifying inline styles conditionally.
78
+
79
+ - type: RjBuildDescriber
80
+ title: "SetAttributeValue Action Examples"
81
+ description:
82
+ - type: Markdown
83
+ content: |
84
+ This example demonstrates how to use the `SetAttributeValue` action to dynamically add CSS classes based on input content.
85
+
86
+ **Expected behavior:**
87
+ - Initially, the input field has normal appearance (base styling)
88
+ - Start typing in the input field
89
+ - When the field is not empty, the 'sav-highlighted' class is automatically added (visual highlighting)
90
+ - Clear the field to remove the highlighting
91
+ - The action uses append mode and responds to the `isNotEmpty` condition
92
+
93
+ Try typing and clearing the input to see how the class attribute changes automatically.
94
+
95
+ toDescribe:
96
+ renderView:
97
+ - type: input
98
+ attributes:
99
+ type: "text"
100
+ placeholder: "Start typing to see the highlighting..."
101
+ class: "sav-demo-input"
102
+ value: ~.input_data
103
+ style:
104
+ padding: "10px"
105
+ border: "2px solid #007bff"
106
+ borderRadius: "4px"
107
+ fontSize: "16px"
108
+ margin: "10px 0"
109
+ width: "300px"
110
+ display: "block"
111
+ actions:
112
+ - what: setData
113
+ on: change
114
+ path: ~.input_data
115
+ value: <reactive-json:event-new-value>
116
+ attributeTransforms:
117
+ - what: setAttributeValue
118
+ name: "class"
119
+ value: "sav-highlighted"
120
+ when: ~.input_data
121
+ isNotEmpty:
122
+
123
+ - type: div
124
+ content: ~.input_data
125
+
126
+ - type: style
127
+ content: |
128
+ .sav-highlighted {
129
+ border-color: #28a745 !important;
130
+ outline: 2px solid #28a745 !important;
131
+ outline-offset: 2px !important;
132
+ }
133
+
134
+ data:
135
+ input_data: ""
136
+
137
+ - type: Markdown
138
+ content: |
139
+ ## Notes
140
+
141
+ - The action respects existing attribute values when using append mode.
142
+ - Use replace mode when you need complete control over the attribute value.
143
+ - Duplicate prevention only applies to append mode.
144
+ - The value property supports full template evaluation including `~.localData`, `~~.globalData`, `~>nearestKey`, and `~~>globalKey` patterns.