@ea-lab/reactive-json-docs 0.3.0 → 0.5.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/data-mapping.md +76 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +140 -0
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +373 -0
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +309 -0
- package/public/rjbuild/docs/advanced-concepts/index.md +10 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +16 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development-guide-llm.md +2 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.md +1 -1
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.yaml +1 -1
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.md +2 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.yaml +2 -0
- package/public/rjbuild/docs/core/action/Hide.md +1 -1
- package/public/rjbuild/docs/core/action/Hide.yaml +10 -10
- package/public/rjbuild/docs/core/action/ReactOnEvent.md +12 -12
- package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +61 -101
- package/public/rjbuild/docs/core/action/Redirect.md +10 -2
- package/public/rjbuild/docs/core/action/Redirect.yaml +18 -51
- package/public/rjbuild/docs/core/action/VisuallyHide.yaml +10 -12
- package/public/rjbuild/docs/core/action/index.md +19 -204
- package/public/rjbuild/docs/core/action/index.yaml +19 -264
- package/public/rjbuild/docs/core/dataMapping/index.md +31 -0
- package/public/rjbuild/docs/core/dataMapping/index.yaml +24 -0
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.md +131 -0
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +376 -0
- package/public/rjbuild/docs/core/element/form/DateField.md +1 -1
- package/public/rjbuild/docs/core/element/form/DateField.yaml +4 -4
- package/public/rjbuild/docs/core/element/form/SelectField.yaml +2 -2
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.md +4 -3
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +114 -6
- package/public/rjbuild/docs/core/example/website.yaml +10 -10
- package/public/rjbuild/docs/core/reaction/index.md +17 -229
- package/public/rjbuild/docs/core/reaction/index.yaml +14 -242
- package/public/rjbuild/docs/core/reaction/setData.md +1 -1
- package/public/rjbuild/docs/core/reaction/setData.yaml +1 -1
- package/public/rjbuild/docs/docs-components/index.md +0 -2
- package/public/rjbuild/docs/docs-components/index.yaml +0 -2
- package/public/rjbuild/docs/getting-started/actions.md +294 -0
- package/public/rjbuild/docs/getting-started/actions.yaml +403 -0
- package/public/rjbuild/docs/{getting-started.md → getting-started/index.md} +30 -6
- package/public/rjbuild/docs/{getting-started.yaml → getting-started/index.yaml} +22 -6
- package/public/rjbuild/docs/getting-started/reactions.md +301 -0
- package/public/rjbuild/docs/getting-started/reactions.yaml +300 -0
- package/public/rjbuild/docs/getting-started/rjbuild-structure.md +358 -0
- package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +421 -0
- package/public/rjbuild/docs/{template.md → getting-started/template-contexts-data-binding.md} +16 -12
- package/public/rjbuild/docs/{template.yaml → getting-started/template-contexts-data-binding.yaml} +28 -14
- package/public/rjbuild/docs/install.yaml +682 -681
- /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.md +0 -0
- /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.yaml +0 -0
- /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.md +0 -0
- /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.yaml +0 -0
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
- `to`: destination URL
|
|
7
7
|
|
|
8
8
|
## Example
|
|
9
|
+
|
|
10
|
+
The following example will redirect the current page when the user clicks on the button.
|
|
11
|
+
|
|
9
12
|
```yaml
|
|
10
13
|
renderView:
|
|
11
14
|
- type: button
|
|
12
|
-
content: "Go to
|
|
15
|
+
content: "Go to EA Lab"
|
|
13
16
|
actions:
|
|
14
17
|
- what: redirect
|
|
15
|
-
to: "https://
|
|
18
|
+
to: "https://ea-lab.io"
|
|
19
|
+
when: ~~.allowRedirect
|
|
20
|
+
is: "true"
|
|
21
|
+
- what: setData
|
|
16
22
|
on: click
|
|
23
|
+
path: ~~.allowRedirect
|
|
24
|
+
value: "true"
|
|
17
25
|
```
|
|
18
26
|
|
|
19
27
|
## Limitation
|
|
@@ -8,59 +8,26 @@ renderView:
|
|
|
8
8
|
## Properties
|
|
9
9
|
- `to`: destination URL
|
|
10
10
|
|
|
11
|
-
- type:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- type: Markdown
|
|
15
|
-
content: |
|
|
16
|
-
This example demonstrates the `redirect` action. **Warning**: clicking the button below will actually redirect you!
|
|
17
|
-
|
|
18
|
-
For demonstration purposes, this redirects to a safe page (the current page), but in real usage you would specify any URL.
|
|
19
|
-
|
|
20
|
-
toDescribe:
|
|
21
|
-
renderView:
|
|
22
|
-
- type: div
|
|
23
|
-
content:
|
|
24
|
-
- type: button
|
|
25
|
-
content: "Redirect to Current Page (Safe Demo)"
|
|
26
|
-
actions:
|
|
27
|
-
- what: redirect
|
|
28
|
-
on: click
|
|
29
|
-
to: "."
|
|
30
|
-
|
|
31
|
-
- type: div
|
|
32
|
-
content: "↑ Click the button above to see the redirect in action"
|
|
33
|
-
|
|
34
|
-
- type: button
|
|
35
|
-
content: "Conditional Redirect (Google)"
|
|
36
|
-
actions:
|
|
37
|
-
- what: redirect
|
|
38
|
-
on: click
|
|
39
|
-
to: "https://www.google.com"
|
|
40
|
-
when: ~.allowRedirect
|
|
41
|
-
is: true
|
|
42
|
-
|
|
43
|
-
- type: button
|
|
44
|
-
content: "Toggle Redirect Permission"
|
|
45
|
-
actions:
|
|
46
|
-
- what: setData
|
|
47
|
-
on: click
|
|
48
|
-
path: "allowRedirect"
|
|
49
|
-
value: ~.allowRedirect
|
|
50
|
-
is: false
|
|
51
|
-
- what: setData
|
|
52
|
-
on: click
|
|
53
|
-
path: "allowRedirect"
|
|
54
|
-
value: ~.allowRedirect
|
|
55
|
-
is: true
|
|
56
|
-
when: ~.allowRedirect
|
|
57
|
-
is: false
|
|
11
|
+
- type: Markdown
|
|
12
|
+
content: |
|
|
13
|
+
## Example
|
|
58
14
|
|
|
59
|
-
|
|
60
|
-
content: ["Redirect allowed: ", ~.allowRedirect]
|
|
15
|
+
The following example will redirect the current page when the user clicks on the button.
|
|
61
16
|
|
|
62
|
-
|
|
63
|
-
|
|
17
|
+
```yaml
|
|
18
|
+
renderView:
|
|
19
|
+
- type: button
|
|
20
|
+
content: "Go to EA Lab"
|
|
21
|
+
actions:
|
|
22
|
+
- what: redirect
|
|
23
|
+
to: "https://ea-lab.io"
|
|
24
|
+
when: ~~.allowRedirect
|
|
25
|
+
is: "true"
|
|
26
|
+
- what: setData
|
|
27
|
+
on: click
|
|
28
|
+
path: ~~.allowRedirect
|
|
29
|
+
value: "true"
|
|
30
|
+
```
|
|
64
31
|
|
|
65
32
|
- type: Markdown
|
|
66
33
|
content: |
|
|
@@ -29,32 +29,30 @@ renderView:
|
|
|
29
29
|
actions:
|
|
30
30
|
- what: setData
|
|
31
31
|
on: click
|
|
32
|
-
path:
|
|
33
|
-
value:
|
|
34
|
-
|
|
32
|
+
path: ~.shouldVisuallyHide
|
|
33
|
+
value: "false"
|
|
34
|
+
when: ~.shouldVisuallyHide
|
|
35
|
+
is: "true"
|
|
36
|
+
stopPropagation: true
|
|
35
37
|
- what: setData
|
|
36
38
|
on: click
|
|
37
|
-
path:
|
|
38
|
-
value:
|
|
39
|
-
is: true
|
|
39
|
+
path: ~.shouldVisuallyHide
|
|
40
|
+
value: "true"
|
|
40
41
|
when: ~.shouldVisuallyHide
|
|
41
|
-
is: false
|
|
42
|
+
is: "false"
|
|
42
43
|
|
|
43
44
|
- type: div
|
|
44
45
|
content: "This text will be visually hidden but remains in the DOM."
|
|
45
46
|
actions:
|
|
46
47
|
- what: visuallyHide
|
|
47
48
|
when: ~.shouldVisuallyHide
|
|
48
|
-
is: true
|
|
49
|
+
is: "true"
|
|
49
50
|
|
|
50
51
|
- type: div
|
|
51
52
|
content: ["Current state: shouldVisuallyHide = ", ~.shouldVisuallyHide]
|
|
52
53
|
|
|
53
|
-
- type: div
|
|
54
|
-
content: "↑ Notice the space is preserved even when hidden"
|
|
55
|
-
|
|
56
54
|
data:
|
|
57
|
-
shouldVisuallyHide: false
|
|
55
|
+
shouldVisuallyHide: "false"
|
|
58
56
|
|
|
59
57
|
- type: Markdown
|
|
60
58
|
content: |
|
|
@@ -1,214 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Actions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> For an introduction to the actions system and detailed examples, see [Getting Started: Actions](../../getting-started/actions.md).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Actions in Reactive-JSON allow you to modify element behavior and appearance based on dynamic conditions. They are evaluated continuously based on data state and provide state-driven UI adaptation.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Available Action Components
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Visibility Control
|
|
10
|
+
- **[Hide](./Hide.md)**: Completely hides the element and its children
|
|
11
|
+
- **[VisuallyHide](./VisuallyHide.md)**: Visually hides the element while keeping it accessible to screen readers
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
content: "My content"
|
|
15
|
-
actions:
|
|
16
|
-
- what: hide # Action type
|
|
17
|
-
when: ~.my_condition # Condition to evaluate
|
|
18
|
-
is: true # Expected value
|
|
19
|
-
```
|
|
13
|
+
### User Interaction
|
|
14
|
+
- **[Tooltip](./Tooltip.md)**: Displays a tooltip on hover
|
|
15
|
+
- **[Popover](./Popover.md)**: Shows a more complex popover on click
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
### Navigation
|
|
18
|
+
- **[Redirect](./Redirect.md)**: Redirects to a specified URL
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
### Event Management
|
|
24
21
|
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
- **Conditional properties**: Define when the action should be executed (optional)
|
|
22
|
+
Those actions have a special handling in Reactive-JSON. The engine transparently load them
|
|
23
|
+
when the user requests a [reaction](../../getting-started/reactions.md) on a given element component.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
As a user, you won't need to work with them directly.
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- **[
|
|
34
|
-
- **[visuallyHide](VisuallyHide.md)**: Visually hides the element while keeping it accessible to screen readers
|
|
35
|
-
- **[tooltip](Tooltip.md)**: Displays a tooltip on hover
|
|
36
|
-
- **[popover](Popover.md)**: Shows a more complex popover on click
|
|
37
|
-
- **[redirect](Redirect.md)**: Redirects to a specified URL
|
|
38
|
-
|
|
39
|
-
For detailed documentation of each action, including properties and examples, see their respective documentation pages.
|
|
40
|
-
|
|
41
|
-
## Conditional Execution
|
|
42
|
-
|
|
43
|
-
Actions can be made conditional using various comparison operators. If no conditions are specified, the action will always execute.
|
|
44
|
-
|
|
45
|
-
### Basic Comparisons
|
|
46
|
-
- `is`: Value equals exactly
|
|
47
|
-
- `isNot`: Value is different from
|
|
48
|
-
|
|
49
|
-
```yaml
|
|
50
|
-
actions:
|
|
51
|
-
- what: hide
|
|
52
|
-
when: ~.status
|
|
53
|
-
is: "inactive"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Empty Value Tests
|
|
57
|
-
- `isEmpty: true`: Value is empty (null, undefined, "", [], {})
|
|
58
|
-
- `isEmpty: "not"`: Value is not empty
|
|
59
|
-
|
|
60
|
-
```yaml
|
|
61
|
-
actions:
|
|
62
|
-
- what: hide
|
|
63
|
-
when: ~.user.name
|
|
64
|
-
isEmpty: true
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Content Search
|
|
68
|
-
- `contains`: Contains a substring or element
|
|
69
|
-
- `containsNot`: Does not contain a substring or element
|
|
70
|
-
- `containedBy`: Value is contained within another value
|
|
71
|
-
- `containedByNot`: Value is not contained within another value
|
|
72
|
-
|
|
73
|
-
```yaml
|
|
74
|
-
actions:
|
|
75
|
-
- what: hide
|
|
76
|
-
when: ~.user.roles
|
|
77
|
-
contains: "admin"
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Numeric and Date Comparisons
|
|
81
|
-
- `">"`: Greater than
|
|
82
|
-
- `"<"`: Less than
|
|
83
|
-
- `">="`: Greater than or equal to
|
|
84
|
-
- `"<="`: Less than or equal to
|
|
85
|
-
- `compareAsDates: true`: Compare values as dates
|
|
86
|
-
|
|
87
|
-
```yaml
|
|
88
|
-
actions:
|
|
89
|
-
- what: hide
|
|
90
|
-
when: ~.user.age
|
|
91
|
-
"<": 18
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Complex Conditions
|
|
95
|
-
- `andConditions`: All conditions must be true
|
|
96
|
-
- `orConditions`: At least one condition must be true
|
|
97
|
-
|
|
98
|
-
```yaml
|
|
99
|
-
actions:
|
|
100
|
-
- what: hide
|
|
101
|
-
andConditions:
|
|
102
|
-
- when: ~.user.role
|
|
103
|
-
is: "user"
|
|
104
|
-
- when: ~.feature_enabled
|
|
105
|
-
is: false
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Data Integration
|
|
109
|
-
|
|
110
|
-
Actions use Reactive-JSON's template system with the `~` operator to access data:
|
|
111
|
-
|
|
112
|
-
- `~.property`: Access a property from the data context
|
|
113
|
-
- `~.object.property`: Navigate through nested objects
|
|
114
|
-
- `~.array[0]`: Access array elements
|
|
115
|
-
|
|
116
|
-
The template system resolves these paths at runtime and provides the current values for condition evaluation.
|
|
117
|
-
|
|
118
|
-
## Execution Order and Behavior
|
|
119
|
-
|
|
120
|
-
1. **Sequential evaluation**: Actions are evaluated in the order they appear in the array
|
|
121
|
-
2. **Condition precedence**: Conditions are evaluated before action execution
|
|
122
|
-
3. **Early termination**: Some actions (like `hide`) prevent subsequent actions from executing
|
|
123
|
-
4. **Synchronous execution**: All condition evaluations and actions are synchronous
|
|
124
|
-
|
|
125
|
-
## Practical Examples
|
|
126
|
-
|
|
127
|
-
### Conditional Element Visibility
|
|
128
|
-
|
|
129
|
-
```yaml
|
|
130
|
-
renderView:
|
|
131
|
-
- type: div
|
|
132
|
-
content: "Admin-only section"
|
|
133
|
-
actions:
|
|
134
|
-
- what: hide
|
|
135
|
-
when: ~.user.role
|
|
136
|
-
isNot: "admin"
|
|
137
|
-
|
|
138
|
-
- type: button
|
|
139
|
-
content: "Advanced feature"
|
|
140
|
-
actions:
|
|
141
|
-
- what: hide
|
|
142
|
-
when: ~.user.permissions
|
|
143
|
-
containsNot: "advanced_actions"
|
|
144
|
-
|
|
145
|
-
data:
|
|
146
|
-
user:
|
|
147
|
-
role: "user"
|
|
148
|
-
permissions: ["read", "write"]
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Contextual Help Interface
|
|
152
|
-
|
|
153
|
-
```yaml
|
|
154
|
-
renderView:
|
|
155
|
-
- type: label
|
|
156
|
-
content: "Username"
|
|
157
|
-
actions:
|
|
158
|
-
- what: tooltip
|
|
159
|
-
content: "Use only letters and numbers"
|
|
160
|
-
placement: "right"
|
|
161
|
-
|
|
162
|
-
- type: button
|
|
163
|
-
content: "More info"
|
|
164
|
-
actions:
|
|
165
|
-
- what: popover
|
|
166
|
-
title: "Detailed help"
|
|
167
|
-
content: "Complete instructions..."
|
|
168
|
-
placement: "top"
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Authentication Flow
|
|
172
|
-
|
|
173
|
-
```yaml
|
|
174
|
-
renderView:
|
|
175
|
-
- type: div
|
|
176
|
-
content: "Access denied"
|
|
177
|
-
actions:
|
|
178
|
-
- what: redirect
|
|
179
|
-
to: "/login"
|
|
180
|
-
when: ~.user.authenticated
|
|
181
|
-
is: false
|
|
182
|
-
|
|
183
|
-
- what: hide
|
|
184
|
-
when: ~.user.authenticated
|
|
185
|
-
is: true
|
|
186
|
-
|
|
187
|
-
data:
|
|
188
|
-
user:
|
|
189
|
-
authenticated: false
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Technical Limitations
|
|
193
|
-
|
|
194
|
-
1. **Execution order**: Actions are evaluated in definition order and cannot be reordered dynamically
|
|
195
|
-
2. **Hide behavior**: Once an element is hidden with the `hide` action, no subsequent actions execute
|
|
196
|
-
3. **Synchronous evaluation**: All conditions and actions are evaluated synchronously
|
|
197
|
-
4. **Data scope**: Actions can only access data from the current template context and global context
|
|
198
|
-
5. **No side effects**: Actions cannot directly modify global state or trigger reactions
|
|
199
|
-
6. **External dependencies**: Some actions (tooltip, popover) require React Bootstrap components
|
|
200
|
-
|
|
201
|
-
## Best Practices
|
|
202
|
-
|
|
203
|
-
1. **Keep conditions simple**: Avoid overly complex condition logic for better maintainability
|
|
204
|
-
2. **Consider performance**: Minimize frequently-evaluated complex conditions
|
|
205
|
-
3. **Use appropriate actions**: Choose `visuallyHide` over `hide` when content should remain accessible
|
|
206
|
-
4. **Test thoroughly**: Verify action behavior with different data states
|
|
207
|
-
5. **Document complex logic**: Add comments for non-obvious conditional logic
|
|
208
|
-
6. **Order matters**: Place critical actions (like `hide`) early in the action array when appropriate
|
|
209
|
-
|
|
210
|
-
## Related Documentation
|
|
211
|
-
|
|
212
|
-
- **Individual Action Documentation**: See the dedicated pages for each action type
|
|
213
|
-
- **[Reactions System](../reaction/index.md)**: Learn about handling user events and state changes
|
|
214
|
-
- **[Template System](../../template-system.md)**: Understand data binding and template expressions
|
|
27
|
+
- **[HashChangeListener](./HashChangeListener.md)**: Listens for URL hash changes
|
|
28
|
+
- **[MessageListener](./MessageListener.md)**: Listens for window messages
|
|
29
|
+
- **[ReactOnEvent](./ReactOnEvent.md)**: Reacts to custom events
|
|
@@ -1,278 +1,33 @@
|
|
|
1
1
|
renderView:
|
|
2
2
|
- type: Markdown
|
|
3
3
|
content: |
|
|
4
|
-
#
|
|
4
|
+
# Actions
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
> For an introduction to the actions system and detailed examples, see [Getting Started: Actions](../../getting-started/actions).
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Actions in Reactive-JSON allow you to modify element behavior and appearance based on dynamic conditions. They are evaluated continuously based on data state and provide state-driven UI adaptation.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Available Action Components
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- type: Markdown
|
|
16
|
-
content: |
|
|
17
|
-
This example demonstrates the fundamental structure of actions in Reactive-JSON.
|
|
18
|
-
|
|
19
|
-
Actions are defined as an array on any element and consist of:
|
|
20
|
-
- `what`: The type of action to execute
|
|
21
|
-
- **Action-specific properties**: Vary depending on the action type
|
|
22
|
-
- **Conditional properties**: Define when the action should be executed (optional)
|
|
12
|
+
### Visibility Control
|
|
13
|
+
- **[Hide](./Hide)**: Completely hides the element and its children
|
|
14
|
+
- **[VisuallyHide](./VisuallyHide)**: Visually hides the element while keeping it accessible to screen readers
|
|
23
15
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
content: "Toggle visibility"
|
|
28
|
-
actions:
|
|
29
|
-
- what: setData
|
|
30
|
-
on: click
|
|
31
|
-
path: ~.my_condition
|
|
32
|
-
value: false
|
|
33
|
-
when: ~.my_condition
|
|
34
|
-
is: true
|
|
35
|
-
stopPropagation: true
|
|
36
|
-
- what: setData
|
|
37
|
-
on: click
|
|
38
|
-
path: ~.my_condition
|
|
39
|
-
value: true
|
|
40
|
-
when: ~.my_condition
|
|
41
|
-
is: false
|
|
42
|
-
stopPropagation: true
|
|
16
|
+
### User Interaction
|
|
17
|
+
- **[Tooltip](./Tooltip)**: Displays a tooltip on hover
|
|
18
|
+
- **[Popover](./Popover)**: Shows a more complex popover on click
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
attributes:
|
|
47
|
-
style:
|
|
48
|
-
padding: "10px"
|
|
49
|
-
border: "1px solid #ccc"
|
|
50
|
-
margin: "5px 0"
|
|
51
|
-
actions:
|
|
52
|
-
- what: hide # Action type
|
|
53
|
-
when: ~.my_condition # Condition to evaluate
|
|
54
|
-
is: true # Expected value
|
|
20
|
+
### Navigation
|
|
21
|
+
- **[Redirect](./Redirect)**: Redirects to a specified URL
|
|
55
22
|
|
|
56
|
-
|
|
57
|
-
my_condition: false
|
|
23
|
+
### Event Management
|
|
58
24
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Action Types
|
|
62
|
-
|
|
63
|
-
Reactive-JSON provides several built-in actions:
|
|
64
|
-
|
|
65
|
-
- **[hide](Hide)**: Completely hides the element and its children
|
|
66
|
-
- **[visuallyHide](VisuallyHide)**: Visually hides the element while keeping it accessible to screen readers
|
|
67
|
-
- **[tooltip](Tooltip)**: Displays a tooltip on hover
|
|
68
|
-
- **[popover](Popover)**: Shows a more complex popover on click
|
|
69
|
-
- **[redirect](Redirect)**: Redirects to a specified URL
|
|
70
|
-
|
|
71
|
-
For detailed documentation of each action, including properties and examples, see their respective documentation pages.
|
|
72
|
-
|
|
73
|
-
- type: RjBuildDescriber
|
|
74
|
-
title: "Basic Conditional Actions"
|
|
75
|
-
description:
|
|
76
|
-
- type: Markdown
|
|
77
|
-
content: |
|
|
78
|
-
This example shows simple conditional actions using `is` and `isEmpty` conditions.
|
|
79
|
-
|
|
80
|
-
toDescribe:
|
|
81
|
-
renderView:
|
|
82
|
-
- type: div
|
|
83
|
-
content:
|
|
84
|
-
- type: div
|
|
85
|
-
content: "This shows only when status is 'active'"
|
|
86
|
-
attributes:
|
|
87
|
-
style:
|
|
88
|
-
padding: "10px"
|
|
89
|
-
backgroundColor: "#e8f5e8"
|
|
90
|
-
margin: "5px 0"
|
|
91
|
-
actions:
|
|
92
|
-
- what: hide
|
|
93
|
-
when: ~.status
|
|
94
|
-
isNot: "active"
|
|
95
|
-
|
|
96
|
-
- type: div
|
|
97
|
-
content: "This shows only when text is not empty"
|
|
98
|
-
attributes:
|
|
99
|
-
style:
|
|
100
|
-
padding: "10px"
|
|
101
|
-
backgroundColor: "#f0f8ff"
|
|
102
|
-
margin: "5px 0"
|
|
103
|
-
actions:
|
|
104
|
-
- what: hide
|
|
105
|
-
when: ~.text_input
|
|
106
|
-
isEmpty: true
|
|
107
|
-
|
|
108
|
-
- type: div
|
|
109
|
-
content:
|
|
110
|
-
- type: label
|
|
111
|
-
content: "Status: "
|
|
112
|
-
- type: SelectField
|
|
113
|
-
dataLocation: ~.status
|
|
114
|
-
options:
|
|
115
|
-
- value: "inactive"
|
|
116
|
-
label: "Inactive"
|
|
117
|
-
- value: "active"
|
|
118
|
-
label: "Active"
|
|
119
|
-
|
|
120
|
-
- type: br
|
|
121
|
-
|
|
122
|
-
- type: label
|
|
123
|
-
content: "Text: "
|
|
124
|
-
- type: TextField
|
|
125
|
-
dataLocation: ~.text_input
|
|
126
|
-
placeholder: "Type something..."
|
|
127
|
-
|
|
128
|
-
data:
|
|
129
|
-
status: "inactive"
|
|
130
|
-
text_input: ""
|
|
131
|
-
|
|
132
|
-
- type: RjBuildDescriber
|
|
133
|
-
title: "Tooltip Action Example"
|
|
134
|
-
description:
|
|
135
|
-
- type: Markdown
|
|
136
|
-
content: |
|
|
137
|
-
This example demonstrates the tooltip action with conditional display.
|
|
138
|
-
|
|
139
|
-
toDescribe:
|
|
140
|
-
renderView:
|
|
141
|
-
- type: div
|
|
142
|
-
content:
|
|
143
|
-
- type: button
|
|
144
|
-
content: "Hover for help (when enabled)"
|
|
145
|
-
actions:
|
|
146
|
-
- what: tooltip
|
|
147
|
-
content: "This is a helpful tooltip!"
|
|
148
|
-
placement: "top"
|
|
149
|
-
when: ~.show_tooltips
|
|
150
|
-
is: true
|
|
151
|
-
|
|
152
|
-
- type: br
|
|
153
|
-
- type: br
|
|
154
|
-
|
|
155
|
-
- type: label
|
|
156
|
-
content:
|
|
157
|
-
- type: CheckBoxField
|
|
158
|
-
dataLocation: ~.show_tooltips
|
|
159
|
-
options:
|
|
160
|
-
- value: true
|
|
161
|
-
label: ""
|
|
162
|
-
- " Enable tooltips"
|
|
163
|
-
|
|
164
|
-
data:
|
|
165
|
-
show_tooltips: true
|
|
166
|
-
|
|
167
|
-
- type: RjBuildDescriber
|
|
168
|
-
title: "Practical Form Example"
|
|
169
|
-
description:
|
|
170
|
-
- type: Markdown
|
|
171
|
-
content: |
|
|
172
|
-
This example shows a simple form with conditional submit button and validation messages.
|
|
173
|
-
|
|
174
|
-
toDescribe:
|
|
175
|
-
renderView:
|
|
176
|
-
- type: div
|
|
177
|
-
content:
|
|
178
|
-
- type: h4
|
|
179
|
-
content: "Simple Contact Form"
|
|
180
|
-
|
|
181
|
-
- type: div
|
|
182
|
-
content:
|
|
183
|
-
- type: label
|
|
184
|
-
content: "Name: "
|
|
185
|
-
- type: TextField
|
|
186
|
-
dataLocation: ~.form.name
|
|
187
|
-
placeholder: "Enter your name"
|
|
188
|
-
|
|
189
|
-
- type: br
|
|
190
|
-
|
|
191
|
-
- type: div
|
|
192
|
-
content:
|
|
193
|
-
- type: label
|
|
194
|
-
content: "Email: "
|
|
195
|
-
- type: TextField
|
|
196
|
-
dataLocation: ~.form.email
|
|
197
|
-
inputType: "email"
|
|
198
|
-
placeholder: "Enter your email"
|
|
199
|
-
|
|
200
|
-
- type: br
|
|
201
|
-
|
|
202
|
-
- type: div
|
|
203
|
-
content: "Please fill in both fields"
|
|
204
|
-
attributes:
|
|
205
|
-
style:
|
|
206
|
-
color: "red"
|
|
207
|
-
fontSize: "14px"
|
|
208
|
-
actions:
|
|
209
|
-
- what: hide
|
|
210
|
-
andConditions:
|
|
211
|
-
- when: ~.form.name
|
|
212
|
-
isEmpty: not
|
|
213
|
-
- when: ~.form.email
|
|
214
|
-
isEmpty: not
|
|
215
|
-
|
|
216
|
-
- type: button
|
|
217
|
-
content: "Submit"
|
|
218
|
-
attributes:
|
|
219
|
-
style:
|
|
220
|
-
backgroundColor: "#4caf50"
|
|
221
|
-
color: "white"
|
|
222
|
-
border: "none"
|
|
223
|
-
padding: "8px 16px"
|
|
224
|
-
actions:
|
|
225
|
-
- what: hide
|
|
226
|
-
when: ~.form.name
|
|
227
|
-
isEmpty: true
|
|
228
|
-
- what: hide
|
|
229
|
-
when: ~.form.email
|
|
230
|
-
isEmpty: true
|
|
231
|
-
- what: setData
|
|
232
|
-
on: click
|
|
233
|
-
path: ~.submitted
|
|
234
|
-
value: true
|
|
235
|
-
|
|
236
|
-
- type: div
|
|
237
|
-
content: "✅ Form submitted successfully!"
|
|
238
|
-
attributes:
|
|
239
|
-
style:
|
|
240
|
-
color: "green"
|
|
241
|
-
marginTop: "10px"
|
|
242
|
-
fontWeight: "bold"
|
|
243
|
-
actions:
|
|
244
|
-
- what: hide
|
|
245
|
-
when: ~.submitted
|
|
246
|
-
isNot: true
|
|
247
|
-
|
|
248
|
-
data:
|
|
249
|
-
form:
|
|
250
|
-
name: ""
|
|
251
|
-
email: ""
|
|
252
|
-
submitted: false
|
|
253
|
-
|
|
254
|
-
- type: Markdown
|
|
255
|
-
content: |
|
|
256
|
-
## Technical Limitations
|
|
257
|
-
|
|
258
|
-
1. **Execution order**: Actions are evaluated in definition order and cannot be reordered dynamically
|
|
259
|
-
2. **Hide behavior**: Once an element is hidden with the `hide` action, no subsequent actions execute
|
|
260
|
-
3. **Synchronous evaluation**: All conditions and actions are evaluated synchronously
|
|
261
|
-
4. **Data scope**: Actions can only access data from the current template context and global context
|
|
262
|
-
5. **No side effects**: Actions cannot directly modify global state or trigger reactions
|
|
263
|
-
6. **External dependencies**: Some actions (tooltip, popover) require React Bootstrap components
|
|
264
|
-
|
|
265
|
-
## Best Practices
|
|
25
|
+
Those actions have a special handling in Reactive-JSON. The engine transparently load them
|
|
26
|
+
when the user requests a [reaction](../../getting-started/reactions) on a given element component.
|
|
266
27
|
|
|
267
|
-
|
|
268
|
-
2. **Consider performance**: Minimize frequently-evaluated complex conditions
|
|
269
|
-
3. **Use appropriate actions**: Choose `visuallyHide` over `hide` when content should remain accessible
|
|
270
|
-
4. **Test thoroughly**: Verify action behavior with different data states
|
|
271
|
-
5. **Document complex logic**: Add comments for non-obvious conditional logic
|
|
272
|
-
6. **Order matters**: Place critical actions (like `hide`) early in the action array when appropriate
|
|
28
|
+
As a user, you won't need to work with them directly.
|
|
273
29
|
|
|
274
|
-
|
|
30
|
+
- **[HashChangeListener](./HashChangeListener)**: Listens for URL hash changes
|
|
31
|
+
- **[MessageListener](./MessageListener)**: Listens for window messages
|
|
32
|
+
- **[ReactOnEvent](./ReactOnEvent)**: Reacts to custom events
|
|
275
33
|
|
|
276
|
-
- **Individual Action Documentation**: See the dedicated pages for each action type
|
|
277
|
-
- **[Reactions System](../reaction/index)**: Learn about handling user events and state changes
|
|
278
|
-
- **[Template System](../../template-system)**: Understand data binding and template expressions
|