@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
@@ -0,0 +1,269 @@
1
+ # toggleAttributeValue
2
+
3
+ > **Alternative**: For post-render DOM modification, see the [ToggleAttributeValue action](../action/Attribute/ToggleAttributeValue.md).
4
+
5
+ Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values. This attribute transformer allows you to conditionally toggle values before rendering.
6
+
7
+ ## Important Notes
8
+
9
+ ### Pre-render Behavior
10
+ `toggleAttributeValue` is an **attribute transformer** that operates during the attribute evaluation phase, before the component renders. It works based on data state and conditional evaluation, allowing you to toggle attribute values based on current data.
11
+
12
+ ### Base Attribute Detection
13
+ `toggleAttributeValue` determines what to toggle by examining the **current attributes** being processed in the evaluation pipeline. This means:
14
+
15
+ - ✅ **Predictable behavior**: The toggle always works relative to the current attribute state in the pipeline
16
+ - ✅ **No DOM dependencies**: Changes are applied before rendering, affecting child components
17
+ - ✅ **Integration**: Can work with other attribute transformers applied before it in the pipeline
18
+
19
+ **Example**: If your component has `class="base"` and a previous transformer adds `"dynamic"`, the toggle will work with the current state `"base dynamic"`.
20
+
21
+ ## Basic Syntax
22
+
23
+ ```yaml
24
+ attributeTransforms:
25
+ # Toggle CSS class.
26
+ - what: toggleAttributeValue
27
+ name: "class"
28
+ value: "active"
29
+
30
+ # Cyclic toggle with array.
31
+ - what: toggleAttributeValue
32
+ name: "class"
33
+ value: ["theme-light", "theme-dark", "theme-auto", ""]
34
+
35
+ # Keep attribute when empty.
36
+ - what: toggleAttributeValue
37
+ name: "data-optional"
38
+ value: "enabled"
39
+ keepAttributeWhenEmpty: true
40
+
41
+ # Conditional toggle.
42
+ - what: toggleAttributeValue
43
+ name: "data-features"
44
+ value: ~.featureName
45
+ when: ~.shouldToggle
46
+ is: true
47
+ ```
48
+
49
+ ## Properties
50
+
51
+ - **keepAttributeWhenEmpty** *(boolean, optional)*: Whether to keep the attribute when it becomes empty. If `false`, the attribute is removed when no values remain. Default: `false`.
52
+ - **name** *(string, required)*: The name of the attribute to modify.
53
+ - **separator** *(string, optional)*: The separator used between values. Default: `" "` (space).
54
+ - **value** *(string|array, required)*: The value(s) to toggle in the attribute. Can be a single string or an array of strings for cyclic toggling. Supports template evaluation (e.g., `~.dynamicValue`, `~~.globalValue`). Automatically converted to string if not already.
55
+
56
+ ## Behavior
57
+
58
+ ### Simple Toggle (string value)
59
+ - **Smart toggle**: Automatically adds the value if missing, removes it if present.
60
+ - **Preservation**: Other values in the attribute remain intact.
61
+ - **Empty handling**: By default, removes the entire attribute if no values remain. Set `keepAttributeWhenEmpty` to `true` to preserve empty attributes.
62
+
63
+ #### Common Examples
64
+ ```yaml
65
+ # Toggle CSS class.
66
+ - what: toggleAttributeValue
67
+ name: "class"
68
+ value: "active"
69
+
70
+ # Toggle readonly attribute.
71
+ - what: toggleAttributeValue
72
+ name: "readonly"
73
+ value: "readonly"
74
+
75
+ # Toggle checked attribute.
76
+ - what: toggleAttributeValue
77
+ name: "checked"
78
+ value: "checked"
79
+ ```
80
+
81
+ ### Cyclic Toggle (array value)
82
+ - **Cyclic behavior**: When `value` is an array, the action cycles through the values in order.
83
+ - **Sequential rotation**: Each toggle moves to the next value in the array.
84
+ - **Empty values handling**: Empty strings (`""`) in the array represent the absence of the value.
85
+ - **Clean detection**: Values are split by separator and empty values (from double separators) are filtered out during detection.
86
+ - **First match priority**: If multiple array values are already present, only the first detected value is replaced.
87
+ - **Default fallback**: If no array values are present, the first array value is applied.
88
+ - **Empty value filtering**: Attributes with empty values from double separators (e.g., `"val1,,val2,"`) are cleaned during detection, treating them as `"val1 val2"`.
89
+ - **Single value arrays**: Arrays with one value behave identically to string values (toggle between value and empty).
90
+ - **Empty string inclusion**: Including `""` in arrays explicitly defines an "empty state" in the cycle.
91
+
92
+ #### Array Behavior Examples
93
+
94
+ ##### Four-step cycle with empty state
95
+ ```yaml
96
+ # Starting with class="theme-light"
97
+ # Clicks will progress: theme-light → theme-dark → theme-auto → "" → theme-light → ...
98
+ value: ["theme-light", "theme-dark", "theme-auto", ""]
99
+ ```
100
+
101
+ ##### Simple alternation
102
+ ```yaml
103
+ # Starting with class="size-small"
104
+ # Clicks will alternate: size-small → size-large → size-small → ...
105
+ value: ["size-small", "size-large"]
106
+ ```
107
+
108
+ ##### Single value array (equivalent to string)
109
+ ```yaml
110
+ # Equivalent to value: "highlight"
111
+ # Toggles: highlight → "" → highlight → ...
112
+ value: ["highlight"]
113
+ ```
114
+
115
+ ## Common Use Cases
116
+
117
+ - **CSS class toggling**: Adding/removing CSS classes based on state changes.
118
+ - **Data attribute management**: Toggling specific values in space-separated data attributes.
119
+ - **Interactive styling**: Toggle styling classes for user interactions.
120
+ - **Feature flags**: Toggle feature-related classes or data attributes.
121
+ - **State cycling**: Cycle through multiple states (e.g., theme variants, size options).
122
+ - **Multi-step processes**: Progress through sequential steps with visual indicators.
123
+
124
+ ## Examples
125
+
126
+ ### Simple Toggle (string value)
127
+ ```yaml
128
+ renderView:
129
+ - type: button
130
+ content: "Toggle 'active' class"
131
+ actions:
132
+ - what: setData
133
+ on: click
134
+ path: ~.toggleActive
135
+ value: "yes"
136
+ when: ~.toggleActive
137
+ is: "no"
138
+ - what: setData
139
+ on: click
140
+ path: ~.toggleActive
141
+ value: "no"
142
+ when: ~.toggleActive
143
+ is: "yes"
144
+
145
+ - type: div
146
+ content: "Element that toggles classes based on state"
147
+ attributes:
148
+ class: "base-class"
149
+ style:
150
+ padding: "10px"
151
+ border: "1px solid #ccc"
152
+ margin: "10px 0"
153
+ actions:
154
+ - what: toggleAttributeValue
155
+ name: "class"
156
+ value: "active"
157
+ when: ~.toggleActive
158
+ is: "yes"
159
+
160
+ data:
161
+ toggleActive: "no"
162
+ ```
163
+
164
+ ### Keep Attribute When Empty
165
+ ```yaml
166
+ renderView:
167
+ - type: button
168
+ content: "Toggle data attribute (keeps when empty)"
169
+ actions:
170
+ - what: setData
171
+ on: click
172
+ path: ~.toggleFeature
173
+ value: "yes"
174
+ when: ~.toggleFeature
175
+ is: "no"
176
+ - what: setData
177
+ on: click
178
+ path: ~.toggleFeature
179
+ value: "no"
180
+ when: ~.toggleFeature
181
+ is: "yes"
182
+
183
+ - type: div
184
+ content: "Element with preserved attribute"
185
+ attributes:
186
+ data-feature: "enabled"
187
+ style:
188
+ padding: "10px"
189
+ border: "1px solid #999"
190
+ margin: "10px 0"
191
+ actions:
192
+ - what: toggleAttributeValue
193
+ name: "data-feature"
194
+ value: "enabled"
195
+ keepAttributeWhenEmpty: true
196
+ when: ~.toggleFeature
197
+ is: "yes"
198
+
199
+ data:
200
+ toggleFeature: "no"
201
+ ```
202
+
203
+ ### Cyclic Toggle (array value)
204
+ ```yaml
205
+ renderView:
206
+ - type: button
207
+ content: "Cycle through themes"
208
+ actions:
209
+ - what: setData
210
+ on: click
211
+ path: ~.cycleThemes
212
+ value: "yes"
213
+ when: ~.cycleThemes
214
+ is: "no"
215
+ - what: setData
216
+ on: click
217
+ path: ~.cycleThemes
218
+ value: "no"
219
+ when: ~.cycleThemes
220
+ is: "yes"
221
+
222
+ - type: div
223
+ content: "Element that cycles through theme classes"
224
+ attributes:
225
+ class: "theme-light"
226
+ actions:
227
+ - what: toggleAttributeValue
228
+ name: "class"
229
+ value: ["theme-light", "theme-dark", "theme-auto", ""]
230
+ when: ~.cycleThemes
231
+ is: "yes"
232
+
233
+ - type: button
234
+ content: "Alternate between sizes"
235
+ actions:
236
+ - what: setData
237
+ on: click
238
+ path: ~.alternateSizes
239
+ value: "yes"
240
+ when: ~.alternateSizes
241
+ is: "no"
242
+ - what: setData
243
+ on: click
244
+ path: ~.alternateSizes
245
+ value: "no"
246
+ when: ~.alternateSizes
247
+ is: "yes"
248
+
249
+ - type: div
250
+ content: "Element that alternates between size classes"
251
+ attributes:
252
+ class: "size-small"
253
+ actions:
254
+ - what: toggleAttributeValue
255
+ name: "class"
256
+ value: ["size-small", "size-large"]
257
+ when: ~.alternateSizes
258
+ is: "yes"
259
+
260
+ data:
261
+ cycleThemes: "no"
262
+ alternateSizes: "no"
263
+ ```
264
+
265
+ ## Notes
266
+
267
+ - The `value` property supports full template evaluation including `~.localData`, `~~.globalData`, `~>nearestKey`, and `~~>globalKey` patterns.
268
+ - More efficient than separate SetAttributeValue/UnsetAttributeValue actions for toggle scenarios.
269
+ - Works with any space-separated attribute values (class, data attributes, etc.).
@@ -0,0 +1,247 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # toggleAttributeValue
5
+
6
+ > **Alternative**: For post-render DOM modification, see the [ToggleAttributeValue action](../action/Attribute/ToggleAttributeValue).
7
+
8
+ Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values.
9
+
10
+ ## Important Notes
11
+
12
+ ### Action-Based Behavior
13
+ `ToggleAttributeValue` is an **action component** that operates based on data state changes, not direct event triggers. It requires a state variable in your data to activate the toggle behavior. This means you cannot directly use `on: click` with `ToggleAttributeValue` - instead, you must use `setData` with `on: click` to change a state variable, then use `when/is` conditions on the toggle action to respond to that state change.
14
+
15
+ ### Base Attribute Detection
16
+ `ToggleAttributeValue` determines what to toggle by examining the **original attributes** defined in your component's props, not the current DOM state. This means:
17
+
18
+ - ✅ **Stable behavior**: The toggle always works relative to the initial attribute values
19
+ - ✅ **No infinite loops**: Changes don't trigger recursive re-evaluation
20
+ - ⚠️ **Limitation**: The toggle cannot detect or work with values that were dynamically added by other attribute actions (`SetAttributeValue`, `UnsetAttributeValue`)
21
+
22
+ **Example**: If your component initially has `class="base"` and another action adds `"dynamic"`, the toggle will only work with `"base"` and won't see `"dynamic"`.
23
+
24
+ ## Basic Syntax
25
+
26
+ - type: TabbedSerializer
27
+ yamlSerializedContent: |
28
+ attributeTransforms:
29
+ # Toggle CSS class.
30
+ - what: toggleAttributeValue
31
+ name: "class"
32
+ value: "active"
33
+
34
+ # Cyclic toggle with array.
35
+ - what: toggleAttributeValue
36
+ name: "class"
37
+ value: ["theme-light", "theme-dark", "theme-auto", ""]
38
+
39
+ # Keep attribute when empty.
40
+ - what: toggleAttributeValue
41
+ name: "data-optional"
42
+ value: "enabled"
43
+ keepAttributeWhenEmpty: true
44
+
45
+ # Conditional toggle.
46
+ - what: toggleAttributeValue
47
+ name: "data-features"
48
+ value: ~.featureName
49
+ when: ~.shouldToggle
50
+ is: true
51
+
52
+ - type: Markdown
53
+ content: |
54
+ ## Properties
55
+
56
+ - type: DefinitionList
57
+ content:
58
+ - term:
59
+ code: keepAttributeWhenEmpty
60
+ after: "(boolean, optional)"
61
+ details:
62
+ type: Markdown
63
+ content: |
64
+ Whether to keep the attribute when it becomes empty. If `false`, the attribute is removed when no values remain. Default: `false`.
65
+ - term:
66
+ code: name
67
+ after: "(string, required)"
68
+ details: The name of the attribute to modify.
69
+ - term:
70
+ code: separator
71
+ after: "(string, optional)"
72
+ details:
73
+ type: Markdown
74
+ content: |
75
+ The separator used between values. Default: `" "` (space).
76
+ - term:
77
+ code: value
78
+ after: "(string|array, required)"
79
+ details:
80
+ type: Markdown
81
+ content: |
82
+ The value(s) to toggle in the attribute. Can be a single string or an array of strings for cyclic toggling. Supports template evaluation (e.g., `~.dynamicValue`, `~~.globalValue`). Automatically converted to string if not already.
83
+
84
+ - type: Markdown
85
+ content: |
86
+
87
+ ## Behavior
88
+
89
+ ### Simple Toggle (string value)
90
+ - **Smart toggle**: Automatically adds the value if missing, removes it if present.
91
+ - **Preservation**: Other values in the attribute remain intact.
92
+ - **Empty handling**: By default, removes the entire attribute if no values remain. Set `keepAttributeWhenEmpty` to `true` to preserve empty attributes.
93
+
94
+ #### Common Examples
95
+
96
+ - type: TabbedSerializer
97
+ yamlSerializedContent: |
98
+ # Toggle CSS class.
99
+ - what: toggleAttributeValue
100
+ name: "class"
101
+ value: "active"
102
+
103
+ # Toggle readonly attribute.
104
+ - what: toggleAttributeValue
105
+ name: "readonly"
106
+ value: "readonly"
107
+
108
+ # Toggle checked attribute.
109
+ - what: toggleAttributeValue
110
+ name: "checked"
111
+ value: "checked"
112
+
113
+ - type: Markdown
114
+ content: |
115
+
116
+ ### Cyclic Toggle (array value)
117
+ - **Cyclic behavior**: When `value` is an array, the action cycles through the values in order.
118
+ - **Sequential rotation**: Each toggle moves to the next value in the array.
119
+ - **Empty values handling**: Empty strings (`""`) in the array represent the absence of the value.
120
+ - **Clean detection**: Values are split by separator and empty values (from double separators) are filtered out during detection.
121
+ - **First match priority**: If multiple array values are already present, only the first detected value is replaced.
122
+ - **Default fallback**: If no array values are present, the first array value is applied.
123
+ - **Empty value filtering**: Attributes with empty values from double separators (e.g., `"val1,,val2,"`) are cleaned during detection, treating them as `"val1 val2"`.
124
+ - **Single value arrays**: Arrays with one value behave identically to string values (toggle between value and empty).
125
+ - **Empty string inclusion**: Including `""` in arrays explicitly defines an "empty state" in the cycle.
126
+
127
+ #### Array Behavior Examples
128
+
129
+ ##### Four-step cycle with empty state
130
+ ```yaml
131
+ # Starting with class="theme-light"
132
+ # Clicks will progress: theme-light → theme-dark → theme-auto → "" → theme-light → ...
133
+ value: ["theme-light", "theme-dark", "theme-auto", ""]
134
+ ```
135
+
136
+ ##### Simple alternation
137
+ ```yaml
138
+ # Starting with class="size-small"
139
+ # Clicks will alternate: size-small → size-large → size-small → ...
140
+ value: ["size-small", "size-large"]
141
+ ```
142
+
143
+ ##### Single value array (equivalent to string)
144
+ ```yaml
145
+ # Equivalent to value: "highlight"
146
+ # Toggles: highlight → "" → highlight → ...
147
+ value: ["highlight"]
148
+ ```
149
+
150
+ ## Common Use Cases
151
+
152
+ - **CSS class toggling**: Adding/removing CSS classes based on state changes.
153
+ - **Data attribute management**: Toggling specific values in space-separated data attributes.
154
+ - **Interactive styling**: Toggle styling classes for user interactions.
155
+ - **Feature flags**: Toggle feature-related classes or data attributes.
156
+ - **State cycling**: Cycle through multiple states (e.g., theme variants, size options).
157
+ - **Multi-step processes**: Progress through sequential steps with visual indicators.
158
+
159
+ - type: RjBuildDescriber
160
+ title: "ToggleAttributeValue Action Examples"
161
+ description:
162
+ - type: Markdown
163
+ content: |
164
+ This example demonstrates how to toggle the readonly attribute using the `ToggleAttributeValue` action.
165
+
166
+ **Expected behavior:**
167
+ - Initially, the input field is editable (normal appearance)
168
+ - Click "Toggle readonly" to make the input readonly (you cannot type in it + visual changes)
169
+ - Click "Toggle readonly" again to make it editable again
170
+ - Click "Reset" to return to the initial state (editable)
171
+ - The toggle action automatically adds/removes the 'readonly' value from the class attribute
172
+
173
+ Try interacting with the buttons to see how the readonly state toggles.
174
+
175
+ toDescribe:
176
+ renderView:
177
+ - type: button
178
+ content: "Toggle readonly"
179
+ actions:
180
+ - what: setData
181
+ on: click
182
+ path: ~.shouldToggle
183
+ value: "yes"
184
+ when: ~.shouldToggle
185
+ is: "no"
186
+ stopPropagation: true
187
+ - what: setData
188
+ on: click
189
+ path: ~.shouldToggle
190
+ value: "no"
191
+ when: ~.shouldToggle
192
+ is: "yes"
193
+ stopPropagation: true
194
+
195
+ - type: button
196
+ content: "Reset"
197
+ actions:
198
+ - what: setData
199
+ on: click
200
+ path: ~.shouldToggle
201
+ value: "no"
202
+ stopPropagation: true
203
+
204
+ - type: input
205
+ attributes:
206
+ type: "text"
207
+ placeholder: "Try typing here when readonly is removed..."
208
+ value: ~.input_value
209
+ class: "tav-demo-input"
210
+ style:
211
+ padding: "10px"
212
+ border: "2px solid #007bff"
213
+ borderRadius: "4px"
214
+ fontSize: "16px"
215
+ margin: "10px 0"
216
+ width: "300px"
217
+ display: "block"
218
+ attributeTransforms:
219
+ - what: toggleAttributeValue
220
+ name: "class"
221
+ value: "tav-readonly"
222
+ when: ~.shouldToggle
223
+ is: "yes"
224
+ actions:
225
+ - what: setData
226
+ on: change
227
+ path: ~.input_value
228
+ value: <reactive-json:event-new-value>
229
+ - type: style
230
+ content: |
231
+ .tav-readonly {
232
+ cursor: not-allowed !important;
233
+ opacity: 0.7 !important;
234
+ border-color: #6c757d !important;
235
+ pointer-events: none !important;
236
+ }
237
+
238
+ data:
239
+ shouldToggle: "no"
240
+ input_value: ""
241
+ - type: Markdown
242
+ content: |
243
+ ## Notes
244
+
245
+ - The `value` property supports full template evaluation including `~.localData`, `~~.globalData`, `~>nearestKey`, and `~~>globalKey` patterns.
246
+ - More efficient than separate SetAttributeValue/UnsetAttributeValue actions for toggle scenarios.
247
+ - Works with any space-separated attribute values (class, data attributes, etc.).
@@ -0,0 +1,114 @@
1
+ # unsetAttribute
2
+
3
+ Completely removes an HTML attribute from an element before rendering. This attribute transformer allows you to conditionally remove entire attributes based on data state during the evaluation phase.
4
+
5
+ ## Basic Syntax
6
+
7
+ ```yaml
8
+ attributeTransforms:
9
+ # Remove entire attribute
10
+ - what: unsetAttribute
11
+ name: "class"
12
+
13
+ # Conditional removal
14
+ - what: unsetAttribute
15
+ name: "style"
16
+ when: ~.useDefaultStyling
17
+ is: true
18
+ ```
19
+
20
+ ## Properties
21
+
22
+ - **name** *(string, required)*: The name of the attribute to remove completely.
23
+
24
+ ## Behavior
25
+
26
+ - **Complete removal**: Removes the entire attribute and all its values from the DOM element.
27
+ - **Attribute deletion**: The attribute is completely deleted, not just emptied.
28
+ - **Irreversible**: Once removed, the attribute must be explicitly set again to restore it.
29
+
30
+ ## Common Use Cases
31
+
32
+ - **Conditional attribute presence**: Removing attributes entirely based on conditions.
33
+ - **Accessibility cleanup**: Removing ARIA attributes when not needed.
34
+ - **Data attribute management**: Completely removing data-* attributes.
35
+ - **Style reset**: Removing inline style attributes to fall back to CSS.
36
+
37
+ ## Example
38
+
39
+ ```yaml
40
+ renderView:
41
+ - type: button
42
+ content: "Toggle editable state"
43
+ actions:
44
+ - what: setData
45
+ on: click
46
+ path: ~.makeEditable
47
+ value: true
48
+ when: ~.makeEditable
49
+ is: false
50
+ stopPropagation: true
51
+ - what: setData
52
+ on: click
53
+ path: ~.makeEditable
54
+ value: false
55
+ when: ~.makeEditable
56
+ is: true
57
+ stopPropagation: true
58
+
59
+ - type: input
60
+ attributes:
61
+ type: "text"
62
+ value: ~.input_value
63
+ placeholder: "Input field with conditional readonly..."
64
+ class: "demo-input"
65
+ readonly: "readonly"
66
+ style:
67
+ padding: "10px"
68
+ border: "2px solid #007bff"
69
+ borderRadius: "4px"
70
+ fontSize: "16px"
71
+ margin: "10px 0"
72
+ width: "300px"
73
+ display: "block"
74
+ attributeTransforms:
75
+ - what: unsetAttribute
76
+ name: "readonly"
77
+ when: ~.makeEditable
78
+ is: true
79
+ actions:
80
+ - what: setData
81
+ on: change
82
+ path: ~.input_value
83
+ value: <reactive-json:event-new-value>
84
+
85
+ - type: div
86
+ content: ["Editable: ", ~.makeEditable, ", Value: ", ~.input_value]
87
+
88
+ - type: style
89
+ content: |
90
+ .demo-input[readonly] {
91
+ cursor: not-allowed !important;
92
+ opacity: 0.7 !important;
93
+ border-color: #6c757d !important;
94
+ }
95
+ .demo-input:not([readonly]) {
96
+ border-color: #28a745 !important;
97
+ outline: 2px solid #28a745 !important;
98
+ outline-offset: 2px !important;
99
+ }
100
+
101
+ data:
102
+ makeEditable: false
103
+ input_value: ""
104
+ ```
105
+
106
+ ## Notes
107
+
108
+ - **Pre-render execution**: This transformer removes attributes before the component renders, ensuring child components receive the transformed attributes.
109
+ - **Complete removal**: This transformer **completely removes the entire attribute**, not just specific values.
110
+ - **Alternative transformers**: Use `unsetAttributeValue` if you only want to remove specific values.
111
+ - **Restoration**: The attribute can be restored using `setAttributeValue` if needed.
112
+ - **Empty attributes**: To set an empty attribute (not remove it), use `setAttributeValue` with an empty string value.
113
+ - **Use case**: Useful for conditional attribute presence rather than conditional values.
114
+ - **Conditional execution**: Supports the same condition system as actions (`when`, `is`, `isEmpty`, `isNotEmpty`, etc.).