@ea-lab/reactive-json-docs 1.0.0-alpha.0 → 1.1.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 (55) hide show
  1. package/package.json +2 -2
  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 +82 -9
  9. package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +83 -13
  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 +1 -1
  15. package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +1 -1
  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/action/CustomEventListener.md +150 -0
  27. package/public/rjbuild/docs/core/action/CustomEventListener.yaml +158 -0
  28. package/public/rjbuild/docs/core/action/HashChangeListener.md +1 -1
  29. package/public/rjbuild/docs/core/action/HashChangeListener.yaml +1 -1
  30. package/public/rjbuild/docs/core/action/MessageListener.md +1 -1
  31. package/public/rjbuild/docs/core/action/MessageListener.yaml +1 -1
  32. package/public/rjbuild/docs/core/action/ReactOnEvent.md +3 -3
  33. package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +3 -3
  34. package/public/rjbuild/docs/core/action/index.md +2 -1
  35. package/public/rjbuild/docs/core/action/index.yaml +2 -1
  36. package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
  37. package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
  38. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
  39. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
  40. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
  41. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
  42. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
  43. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
  44. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
  45. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
  46. package/public/rjbuild/docs/core/hook/index.md +38 -0
  47. package/public/rjbuild/docs/core/hook/index.yaml +44 -0
  48. package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
  49. package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
  50. package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
  51. package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
  52. package/public/rjbuild/docs/core/reaction/fetchData.md +25 -0
  53. package/public/rjbuild/docs/core/reaction/fetchData.yaml +30 -2
  54. package/public/rjbuild/docs/core/reaction/submitData.md +28 -0
  55. package/public/rjbuild/docs/core/reaction/submitData.yaml +32 -1
@@ -0,0 +1,158 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # CustomEventListener
5
+
6
+ Executes a reaction when receiving custom events dispatched on DOM elements. This is an internal action component that is automatically used when you specify custom event names (like `on: "response"`) in your actions.
7
+
8
+ ## Usage
9
+
10
+ CustomEventListener should **not** be used directly in the RjBuild. The Reactive-JSON engine will use it automatically when you specify custom event names (not standard DOM events) in any action. The system automatically adds this component to listen for custom events on the specific element that triggered the action.
11
+
12
+ > **Technical requirement**: The element component must provide an `attributesHolderRef` for the listener to attach its event handler to the DOM element.
13
+
14
+ ## Properties
15
+
16
+ When using custom event names in actions, you can specify:
17
+
18
+ - type: DefinitionList
19
+ content:
20
+ - term:
21
+ code: what
22
+ after: "(required)"
23
+ details: "Name of the reaction function to execute (e.g., `setData`, `fetchData`, `submitData`, etc.)."
24
+ - term:
25
+ code: on
26
+ after: "(required)"
27
+ details: 'Name of the custom event to listen for (e.g., `"response"`, `"customUpdate"`, etc.).'
28
+ - term: "All other properties"
29
+ details:
30
+ type: Markdown
31
+ content: "Are passed as arguments to the reaction function and support [forward update placeholders](../../../advanced-concepts/forward-update)."
32
+
33
+ - type: Markdown
34
+ content: |
35
+ ## Behavior
36
+
37
+ When you use a custom event name in an action (like `on: "response"`):
38
+
39
+ 1. The system automatically adds a CustomEventListener component
40
+ 2. It attaches an event listener directly on the element that triggered the action
41
+ 3. When the custom event is dispatched on that element:
42
+ - Receives the event object with its custom data
43
+ - Processes any [event placeholders](../../../advanced-concepts/forward-update) in the action properties
44
+ - Executes the reaction function specified in `what`
45
+
46
+ ## How Custom Events Are Triggered
47
+
48
+ Custom events are typically triggered by reactions like `fetchData` or `submitData`:
49
+
50
+ - type: SyntaxHighlighter
51
+ language: yaml
52
+ content: |
53
+ # fetchData automatically dispatches a "response" event when the request completes
54
+ actions:
55
+ - what: fetchData
56
+ on: click
57
+ url: "/api/data.json"
58
+ # When this completes, it dispatches a "response" event on the same element
59
+
60
+ - type: Markdown
61
+ content: |
62
+ ## Event Data Access
63
+
64
+ CustomEventListener provides full access to the custom event data through the [forward update system](../../../advanced-concepts/forward-update):
65
+
66
+ - `<reactive-json:event-new-value>` - Accesses `event.detail.value` for CustomEvent objects
67
+ - `<reactive-json:event>.detail.someProperty` - Direct access to event details
68
+ - `<reactive-json:event>.data.someValue` - For events with data property
69
+
70
+ - type: RjBuildDescriber
71
+ title: "Process HTTP Response Data"
72
+ description:
73
+ type: Markdown
74
+ content: |
75
+ This example shows how CustomEventListener automatically handles the `response` event from `fetchData`. The response data can be extracted and stored in different locations using event placeholders.
76
+ toDescribe:
77
+ renderView:
78
+ - type: button
79
+ content: "Load User Profile"
80
+ actions:
81
+ - what: fetchData
82
+ on: click
83
+ url: "/mockup-api/fetchData/example.json"
84
+ updateOnlyData: true
85
+ updateDataAtLocation: ~~.userProfile
86
+ - what: setData
87
+ on: response # CustomEventListener handles this automatically
88
+ path: ~~.userTheme
89
+ value: <reactive-json:event-new-value>.preferences.theme
90
+ - what: setData
91
+ on: response
92
+ path: ~~.lastUpdateTime
93
+ value: <reactive-json:event-new-value>.metadata.timestamp
94
+ - type: div
95
+ content:
96
+ - "User Theme: "
97
+ - type: code
98
+ content: ~~.userTheme
99
+ - type: div
100
+ content:
101
+ - "Last Update: "
102
+ - type: code
103
+ content: ~~.lastUpdateTime
104
+ data:
105
+ userTheme: "not-loaded"
106
+ lastUpdateTime: "not-loaded"
107
+
108
+ - type: SyntaxHighlighter
109
+ language: yaml
110
+ title: "Custom Event Handling"
111
+ content: |
112
+ renderView:
113
+ - type: div
114
+ content: "Custom event handler"
115
+ actions:
116
+ - what: setData
117
+ on: customUpdate # Any custom event name works
118
+ path: ~~.customData
119
+ value: <reactive-json:event-new-value>
120
+
121
+ - type: Markdown
122
+ content: |
123
+ ## Differences from Standard Events
124
+
125
+ | Aspect | Standard DOM Events | Custom Events |
126
+ |--------|-------------------|---------------|
127
+ | **Handler** | ReactOnEvent | CustomEventListener |
128
+ | **Event Names** | `click`, `change`, `submit`, etc. | `response`, `customUpdate`, etc. |
129
+ | **Target** | Element (via React event system) | Element (via DOM addEventListener) |
130
+ | **Event Data** | Standard DOM event properties | Custom data in `event.detail` |
131
+ | **Triggering** | User interactions | Programmatic dispatch |
132
+
133
+ ## Built-in Custom Events
134
+
135
+ Some reactions automatically dispatch custom events:
136
+
137
+ - **`response`**: Dispatched by `fetchData` and `submitData` when HTTP requests complete successfully
138
+ - **Custom events**: Can be triggered by `triggerEvent` reaction or external JavaScript
139
+
140
+ ## Limitations
141
+
142
+ - Only works with custom event names in actions (not as a standalone element)
143
+ - Requires the element component to provide an `attributesHolderRef` for DOM attachment
144
+ - Listens only on the specific element that triggered the original action
145
+ - Custom events must be dispatched on the correct element to be received
146
+ - Event data structure depends on how the custom event was created
147
+ - Automatic cleanup when the component unmounts
148
+
149
+ ## Related Components
150
+
151
+ - **[ReactOnEvent](ReactOnEvent)**: Handles standard DOM events (`click`, `change`, etc.)
152
+ - **[MessageListener](MessageListener)**: Handles `on: "message"` events
153
+ - **[Forward Update System](../../../advanced-concepts/forward-update)**: Event data access patterns
154
+ - **[Reactions System](../../getting-started/reactions)**: The actual reaction functions that CustomEventListener executes
155
+
156
+ templates:
157
+
158
+ data: {}
@@ -4,7 +4,7 @@ Listens to hash changes (URL fragment) in the window and executes a reaction fun
4
4
 
5
5
  ## Usage
6
6
 
7
- HashChangeListener is **not** used directly as an element type. Instead, it is automatically triggered when you use `on: "hashchange"` in any action. The system automatically adds this component to listen for hash changes globally.
7
+ HashChangeListener should **not** be used directly in the RjBuild. The Reactive-JSON engine will use it automatically when you use `on: "hashchange"` in any action. The system automatically adds this component to listen for hash changes globally.
8
8
 
9
9
  ## Properties
10
10
 
@@ -7,7 +7,7 @@ renderView:
7
7
 
8
8
  ## Usage
9
9
 
10
- HashChangeListener is **not** used directly as an element type. Instead, it is automatically triggered when you use `on: "hashchange"` in any action. The system automatically adds this component to listen for hash changes globally.
10
+ HashChangeListener should **not** be used directly in the RjBuild. The Reactive-JSON engine will use it automatically when you use `on: "hashchange"` in any action. The system automatically adds this component to listen for hash changes globally.
11
11
 
12
12
  ## Properties
13
13
 
@@ -4,7 +4,7 @@ Executes a reaction when receiving a message via `window.postMessage`. This is a
4
4
 
5
5
  ## Usage
6
6
 
7
- MessageListener is **not** used directly as an element type. Instead, it is automatically triggered when you use `on: "message"` in any action. The system automatically adds this component to listen for messages globally on the window object.
7
+ MessageListener should **not** be used directly in the RjBuild. The Reactive-JSON engine will use it automatically when you use `on: "message"` in any action. The system automatically adds this component to listen for messages globally on the window object.
8
8
 
9
9
  ## Properties
10
10
 
@@ -7,7 +7,7 @@ renderView:
7
7
 
8
8
  ## Usage
9
9
 
10
- MessageListener is **not** used directly as an element type. Instead, it is automatically triggered when you use `on: "message"` in any action. The system automatically adds this component to listen for messages globally on the window object.
10
+ MessageListener should **not** be used directly in the RjBuild. The Reactive-JSON engine will use it automatically when you use `on: "message"` in any action. The system automatically adds this component to listen for messages globally on the window object.
11
11
 
12
12
  ## Properties
13
13
 
@@ -1,6 +1,6 @@
1
1
  # ReactOnEvent
2
2
 
3
- ReactOnEvent is an internal action component that is automatically instantiated by the Actions system when reactions with event handlers (`on: "eventName"`) are detected. It should **not** be used directly as an element type.
3
+ ReactOnEvent is an internal action component that is automatically instantiated by the Actions system when reactions with event handlers (`on: "eventName"`) are detected. It should **not** be used directly in the RjBuild.
4
4
 
5
5
  > **Important**: It should **not** be used directly as an element type. The Reactive-JSON engine will automatically instantiate it when needed.
6
6
 
@@ -69,9 +69,9 @@ actions:
69
69
 
70
70
  ## Important Notes
71
71
 
72
- - **Never use `type: ReactOnEvent`** in your renderView - it's an internal component
72
+ - **Never use `type: ReactOnEvent`** in your RjBuild - it's an internal component
73
73
  - **Use `actions` with `on: "eventName"`** - this is the correct way to handle events
74
- - **ReactOnEvent is automatically instantiated** by the Actions system when needed
74
+ - **The Reactive-JSON engine will use ReactOnEvent automatically** when needed
75
75
  - **Event propagation is stopped by default** - use `stopPropagation: false` to change this
76
76
 
77
77
  ## Related Components
@@ -5,7 +5,7 @@ renderView:
5
5
 
6
6
  ReactOnEvent is an internal action component that is automatically instantiated by the Actions system when reactions with event handlers (`on: "eventName"`) are detected.
7
7
 
8
- > **Important**: It should **not** be used directly as an element type. The Reactive-JSON engine will automatically instantiate it when needed.
8
+ > **Important**: It should **not** be used directly in the RjBuild. The Reactive-JSON engine will automatically instantiate it when needed.
9
9
 
10
10
  ## How it Works
11
11
 
@@ -81,9 +81,9 @@ renderView:
81
81
  content: |
82
82
  ## Important Notes
83
83
 
84
- - **Never use `type: ReactOnEvent`** in your renderView - it's an internal component
84
+ - **Never use `type: ReactOnEvent`** in your RjBuild - it's an internal component
85
85
  - **Use `actions` with `on: "eventName"`** - this is the correct way to handle events
86
- - **ReactOnEvent is automatically instantiated** by the Actions system when needed
86
+ - **The Reactive-JSON engine will use ReactOnEvent automatically** when needed
87
87
  - **Event propagation is stopped by default** - use `stopPropagation: false` to change this
88
88
 
89
89
  ## Related Components
@@ -30,6 +30,7 @@ when the user requests a [reaction](../../getting-started/reactions.md) on a giv
30
30
 
31
31
  As a user, you won't need to work with them directly.
32
32
 
33
+ - **[CustomEventListener](./CustomEventListener.md)**: Reacts to custom events
33
34
  - **[HashChangeListener](./HashChangeListener.md)**: Listens for URL hash changes
34
35
  - **[MessageListener](./MessageListener.md)**: Listens for window messages
35
- - **[ReactOnEvent](./ReactOnEvent.md)**: Reacts to custom events
36
+ - **[ReactOnEvent](./ReactOnEvent.md)**: Reacts to DOM events
@@ -33,7 +33,8 @@ renderView:
33
33
 
34
34
  As a user, you won't need to work with them directly.
35
35
 
36
+ - **[CustomEventListener](./CustomEventListener)**: Reacts to custom events
36
37
  - **[HashChangeListener](./HashChangeListener)**: Listens for URL hash changes
37
38
  - **[MessageListener](./MessageListener)**: Listens for window messages
38
- - **[ReactOnEvent](./ReactOnEvent)**: Reacts to custom events
39
+ - **[ReactOnEvent](./ReactOnEvent)**: Reacts to DOM events
39
40
 
@@ -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.