@ea-lab/reactive-json-docs 1.0.0-alpha.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.
- package/package.json +2 -2
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.md +168 -0
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/forward-update.md +2 -2
- package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +2 -2
- package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +1 -1
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
- package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
- package/public/rjbuild/docs/core/hook/index.md +38 -0
- package/public/rjbuild/docs/core/hook/index.yaml +44 -0
- package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
- package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
|
@@ -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.
|