@ea-lab/reactive-json-docs 0.4.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/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/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/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/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/index.md +30 -6
- package/public/rjbuild/docs/getting-started/index.yaml +20 -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 +10 -4
- package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +10 -4
- package/public/rjbuild/docs/getting-started/{template.md → template-contexts-data-binding.md} +16 -12
- package/public/rjbuild/docs/getting-started/{template.yaml → template-contexts-data-binding.yaml} +28 -14
- /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
|
@@ -1,236 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reactions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> For an introduction to the reactions system and detailed examples, see [Getting Started: Reactions](../../getting-started/reactions.md).
|
|
4
4
|
|
|
5
|
-
Reactions
|
|
5
|
+
Reactions in Reactive-JSON allow you to respond to user events and perform operations like data updates, network requests, and browser interactions. They execute in response to user events to modify application state and trigger behaviors.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
```yaml
|
|
9
|
-
renderView:
|
|
10
|
-
- type: button
|
|
11
|
-
content: Click me
|
|
12
|
-
actions:
|
|
13
|
-
- what: setData # Reaction type
|
|
14
|
-
on: click # Event that triggers the reaction
|
|
15
|
-
path: ~.my_state # Where to store the data
|
|
16
|
-
value: "on" # Value to set
|
|
17
|
-
```
|
|
7
|
+
## Available Reaction Components
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
### Data Management
|
|
10
|
+
- **[setData](./setData.md)**: Sets data at the specified path
|
|
11
|
+
- **[addData](./addData.md)**: Adds new data to the specified path
|
|
12
|
+
- **[removeData](./removeData.md)**: Removes data from the specified path
|
|
13
|
+
- **[moveData](./moveData.md)**: Moves data from one path to another
|
|
20
14
|
|
|
21
|
-
###
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- `removeData` : Removes data from the specified path
|
|
25
|
-
- `moveData` : Moves data from one path to another
|
|
15
|
+
### Network Operations
|
|
16
|
+
- **[fetchData](./fetchData.md)**: Fetches data from a URL using GET requests
|
|
17
|
+
- **[submitData](./submitData.md)**: Submits data to a server endpoint using POST/PUT/DELETE
|
|
26
18
|
|
|
27
|
-
###
|
|
28
|
-
-
|
|
29
|
-
-
|
|
19
|
+
### Browser Operations
|
|
20
|
+
- **[setClipboardData](./setClipboardData.md)**: Copies data to the clipboard
|
|
21
|
+
- **[redirectNow](./redirectNow.md)**: Performs an immediate redirect
|
|
22
|
+
- **[triggerEvent](./triggerEvent.md)**: Triggers a custom event
|
|
23
|
+
- **[postMessage](./postMessage.md)**: Sends a message to another window/frame
|
|
30
24
|
|
|
31
|
-
### 1.3 Browser Operations
|
|
32
|
-
- `setClipboardData` : Copies data to the clipboard
|
|
33
|
-
- `redirectNow` : Performs an immediate redirect
|
|
34
|
-
- `triggerEvent` : Triggers a custom event
|
|
35
|
-
- `postMessage` : Sends a message to another window/frame
|
|
36
|
-
|
|
37
|
-
## 2. Reaction Structure
|
|
38
|
-
Each reaction is defined by:
|
|
39
|
-
- `what` : The name of the reaction to execute
|
|
40
|
-
- `on` : The event that triggers the reaction
|
|
41
|
-
- Reaction-specific options (vary by reaction type)
|
|
42
|
-
- **Optional conditions** : Reactions support the same conditional system as actions
|
|
43
|
-
|
|
44
|
-
### 2.1 Conditional Reactions
|
|
45
|
-
Just like actions, reactions can be made conditional using various comparison operators:
|
|
46
|
-
|
|
47
|
-
- `when` + `is` / `isNot` : Value equality checks
|
|
48
|
-
- `when` + `isEmpty` : Empty value tests
|
|
49
|
-
- `when` + `contains` / `containsNot` : Content search
|
|
50
|
-
- `when` + `>`, `<`, `>=`, `<=` : Numeric/date comparisons
|
|
51
|
-
- `andConditions` / `orConditions` : Complex condition logic
|
|
52
|
-
|
|
53
|
-
For example:
|
|
54
|
-
```yaml
|
|
55
|
-
actions:
|
|
56
|
-
- what: setData # Reaction name
|
|
57
|
-
on: click # Triggering event
|
|
58
|
-
path: ~.user.profile # Reaction-specific option
|
|
59
|
-
value: ~.form_data # Reaction-specific option
|
|
60
|
-
when: ~.is_editing # Condition - only execute if editing
|
|
61
|
-
is: true # Condition value
|
|
62
|
-
- what: submitData # Reaction name
|
|
63
|
-
on: submit # Triggering event
|
|
64
|
-
url: "/api/endpoint" # Reaction-specific option
|
|
65
|
-
method: "POST" # Reaction-specific option
|
|
66
|
-
data: ~.form_data # Reaction-specific option
|
|
67
|
-
when: ~.form_data # Condition - only submit if form has data
|
|
68
|
-
isEmpty: "not" # Condition check
|
|
69
|
-
- what: setData # Multiple conditions example
|
|
70
|
-
on: click
|
|
71
|
-
path: ~.result
|
|
72
|
-
value: "success"
|
|
73
|
-
andConditions: # All conditions must be true
|
|
74
|
-
- when: ~.user.role
|
|
75
|
-
is: "admin"
|
|
76
|
-
- when: ~.feature_enabled
|
|
77
|
-
is: true
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## 3. Event Types
|
|
81
|
-
The `on` property accepts standard browser events. These events are the same as those used in standard web development, and their availability depends on the HTML element type. For example, a `change` event will only work on form elements like `input`, `select`, or `textarea`, while a `click` event works on any element.
|
|
82
|
-
|
|
83
|
-
Common event types:
|
|
84
|
-
- `click` : Mouse click (works on any element)
|
|
85
|
-
- `change` : Form input change (works on form elements only)
|
|
86
|
-
- `submit` : Form submission (works on form elements only)
|
|
87
|
-
- `keydown` : Keyboard key press (works on elements that can receive focus)
|
|
88
|
-
- `keyup` : Keyboard key release (works on elements that can receive focus)
|
|
89
|
-
|
|
90
|
-
## 4. Event Control
|
|
91
|
-
The `stopPropagation` property can be used to control event bubbling and subsequent actions:
|
|
92
|
-
```yaml
|
|
93
|
-
actions:
|
|
94
|
-
- what: setData
|
|
95
|
-
on: click
|
|
96
|
-
path: ~.state
|
|
97
|
-
value: "on"
|
|
98
|
-
stopPropagation: true # Prevents event bubbling AND stops execution of subsequent actions
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
When `stopPropagation` is set to `true`, it:
|
|
102
|
-
1. Prevents the event from bubbling up to parent elements
|
|
103
|
-
2. Stops the execution of any subsequent actions defined for the same event
|
|
104
|
-
|
|
105
|
-
This is particularly useful when you want to ensure that only the first matching action is executed, even if multiple actions are defined for the same event.
|
|
106
|
-
|
|
107
|
-
## 5. Technical Details
|
|
108
|
-
- Reactions are triggered by events
|
|
109
|
-
- Multiple reactions can be defined for the same event
|
|
110
|
-
- Reactions are executed in order
|
|
111
|
-
- Reactions can be chained together
|
|
112
|
-
- **Reactions support all the same conditional operators as actions**: `when`, `is`, `isNot`, `isEmpty`, `contains`, `>`, `<`, `>=`, `<=`, `andConditions`, `orConditions`
|
|
113
|
-
- Conditional reactions only execute when their conditions evaluate to true
|
|
114
|
-
- The execution order of multiple reactions on the same event is guaranteed to match their order in the YAML
|
|
115
|
-
- If a reaction's conditions are not met, it is skipped and the next reaction is evaluated
|
|
116
|
-
|
|
117
|
-
## 6. Limitations
|
|
118
|
-
- Reactions cannot modify external state
|
|
119
|
-
- Network operations must be properly configured
|
|
120
|
-
- Browser operations require appropriate permissions
|
|
121
|
-
|
|
122
|
-
## 7. Complete Examples
|
|
123
|
-
|
|
124
|
-
### 7.1 Data Input and Submission
|
|
125
|
-
```yaml
|
|
126
|
-
renderView:
|
|
127
|
-
- type: TextField
|
|
128
|
-
label: "Username"
|
|
129
|
-
placeholder: "Enter your username"
|
|
130
|
-
dataLocation: ~.form_data.username
|
|
131
|
-
- type: TextField
|
|
132
|
-
label: "Email"
|
|
133
|
-
placeholder: "Enter your email"
|
|
134
|
-
inputType: "email"
|
|
135
|
-
dataLocation: ~.form_data.email
|
|
136
|
-
- type: button
|
|
137
|
-
content: Submit
|
|
138
|
-
actions:
|
|
139
|
-
- what: submitData
|
|
140
|
-
on: click
|
|
141
|
-
url: "/api/submit"
|
|
142
|
-
data:
|
|
143
|
-
username: ~.form_data.username
|
|
144
|
-
email: ~.form_data.email
|
|
145
|
-
when: ~.form_data.username
|
|
146
|
-
isEmpty: not
|
|
147
|
-
|
|
148
|
-
data:
|
|
149
|
-
form_data:
|
|
150
|
-
username: ""
|
|
151
|
-
email: ""
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 7.2 Conditional Reactions Example
|
|
155
|
-
```yaml
|
|
156
|
-
renderView:
|
|
157
|
-
- type: button
|
|
158
|
-
content: "Toggle State"
|
|
159
|
-
actions:
|
|
160
|
-
- what: setData
|
|
161
|
-
on: click
|
|
162
|
-
path: ~.button_state
|
|
163
|
-
value: "on"
|
|
164
|
-
when: ~.button_state
|
|
165
|
-
is: "off"
|
|
166
|
-
stopPropagation: true
|
|
167
|
-
- what: setData
|
|
168
|
-
on: click
|
|
169
|
-
path: ~.button_state
|
|
170
|
-
value: "off"
|
|
171
|
-
when: ~.button_state
|
|
172
|
-
is: "on"
|
|
173
|
-
stopPropagation: true
|
|
174
|
-
- type: div
|
|
175
|
-
content: ["Button state: ", ~.button_state]
|
|
176
|
-
- type: div
|
|
177
|
-
content: "Button has been clicked!"
|
|
178
|
-
actions:
|
|
179
|
-
- what: hide
|
|
180
|
-
when: ~.button_state
|
|
181
|
-
is: "off"
|
|
182
|
-
|
|
183
|
-
data:
|
|
184
|
-
button_state: "off"
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 7.3 Complex Conditional Logic
|
|
188
|
-
```yaml
|
|
189
|
-
renderView:
|
|
190
|
-
- type: TextField
|
|
191
|
-
label: "Enter a number:"
|
|
192
|
-
dataLocation: ~.user_input
|
|
193
|
-
inputType: "number"
|
|
194
|
-
- type: button
|
|
195
|
-
content: "Process Number"
|
|
196
|
-
actions:
|
|
197
|
-
- what: setData
|
|
198
|
-
on: click
|
|
199
|
-
path: ~.result
|
|
200
|
-
value: "Number is valid and positive!"
|
|
201
|
-
andConditions:
|
|
202
|
-
- when: ~.user_input
|
|
203
|
-
isEmpty: "not"
|
|
204
|
-
- when: ~.user_input
|
|
205
|
-
">": 0
|
|
206
|
-
- what: setData
|
|
207
|
-
on: click
|
|
208
|
-
path: ~.result
|
|
209
|
-
value: "Number must be positive!"
|
|
210
|
-
when: ~.user_input
|
|
211
|
-
"<=": 0
|
|
212
|
-
- what: setData
|
|
213
|
-
on: click
|
|
214
|
-
path: ~.result
|
|
215
|
-
value: "Please enter a number!"
|
|
216
|
-
when: ~.user_input
|
|
217
|
-
isEmpty: true
|
|
218
|
-
- type: div
|
|
219
|
-
content: ["Result: ", ~.result]
|
|
220
|
-
actions:
|
|
221
|
-
- what: hide
|
|
222
|
-
when: ~.result
|
|
223
|
-
isEmpty: true
|
|
224
|
-
|
|
225
|
-
data:
|
|
226
|
-
user_input: null
|
|
227
|
-
result: null
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## Conclusion
|
|
231
|
-
|
|
232
|
-
You now have a good understanding of reactions in Reactive-JSON. We've seen how they allow you to respond to user events and perform various operations like data updates and network requests.
|
|
233
|
-
|
|
234
|
-
To create complete interactive interfaces, you should combine reactions with actions. Actions handle the conditional behavior of elements, while reactions handle user interactions and data updates.
|
|
235
|
-
|
|
236
|
-
For more information about actions and conditional behavior, check out the [Actions Documentation](../action/index.md).
|
|
@@ -1,254 +1,26 @@
|
|
|
1
1
|
renderView:
|
|
2
2
|
- type: Markdown
|
|
3
3
|
content: |
|
|
4
|
-
#
|
|
4
|
+
# Reactions
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
> For an introduction to the reactions system and detailed examples, see [Getting Started: Reactions](../../getting-started/reactions).
|
|
7
7
|
|
|
8
|
-
Reactions
|
|
8
|
+
Reactions in Reactive-JSON allow you to respond to user events and perform operations like data updates, network requests, and browser interactions. They execute in response to user events to modify application state and trigger behaviors.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- type: RjBuildDescriber
|
|
13
|
-
title: "Basic Reaction Structure"
|
|
14
|
-
description:
|
|
15
|
-
- type: Markdown
|
|
16
|
-
content: |
|
|
17
|
-
This example demonstrates the fundamental structure of reactions in Reactive-JSON.
|
|
18
|
-
|
|
19
|
-
Reactions are defined as part of the `actions` array on any element and consist of:
|
|
20
|
-
- `what`: The name of the reaction to execute
|
|
21
|
-
- `on`: The event that triggers the reaction
|
|
22
|
-
- **Reaction-specific properties**: Vary depending on the reaction type
|
|
23
|
-
- **Optional conditions**: Same conditional system as actions
|
|
24
|
-
|
|
25
|
-
toDescribe:
|
|
26
|
-
renderView:
|
|
27
|
-
- type: TextField
|
|
28
|
-
label: "Enter some text:"
|
|
29
|
-
dataLocation: ~.user_input
|
|
30
|
-
placeholder: "Type something..."
|
|
31
|
-
|
|
32
|
-
- type: button
|
|
33
|
-
content: "Save Text"
|
|
34
|
-
actions:
|
|
35
|
-
- what: setData # Reaction type
|
|
36
|
-
on: click # Triggering event
|
|
37
|
-
path: ~.saved_text # Reaction-specific property
|
|
38
|
-
value: ~.user_input # Reaction-specific property
|
|
39
|
-
when: ~.user_input # Optional condition
|
|
40
|
-
isEmpty: "not" # Condition value
|
|
41
|
-
|
|
42
|
-
- type: div
|
|
43
|
-
content: ["Saved text: ", ~.saved_text]
|
|
44
|
-
actions:
|
|
45
|
-
- what: hide # Action (no 'on' property)
|
|
46
|
-
when: ~.saved_text # Condition
|
|
47
|
-
isEmpty: true
|
|
48
|
-
|
|
49
|
-
data:
|
|
50
|
-
user_input: ""
|
|
51
|
-
saved_text: ""
|
|
52
|
-
|
|
53
|
-
- type: Markdown
|
|
54
|
-
content: |
|
|
55
|
-
## Reaction Types
|
|
56
|
-
|
|
57
|
-
Reactive-JSON provides several built-in reactions:
|
|
10
|
+
## Available Reaction Components
|
|
58
11
|
|
|
59
12
|
### Data Management
|
|
60
|
-
- **[setData](setData)**: Sets data at the specified path
|
|
61
|
-
- **[addData](addData)**: Adds new data to the specified path
|
|
62
|
-
- **[removeData](removeData)**: Removes data from the specified path
|
|
63
|
-
- **[moveData](moveData)**: Moves data from one path to another
|
|
13
|
+
- **[setData](./setData)**: Sets data at the specified path
|
|
14
|
+
- **[addData](./addData)**: Adds new data to the specified path
|
|
15
|
+
- **[removeData](./removeData)**: Removes data from the specified path
|
|
16
|
+
- **[moveData](./moveData)**: Moves data from one path to another
|
|
64
17
|
|
|
65
18
|
### Network Operations
|
|
66
|
-
- **[fetchData](fetchData)**: Fetches data from a URL using GET requests
|
|
67
|
-
- **[submitData](submitData)**: Submits data to a server endpoint using POST/PUT/DELETE
|
|
19
|
+
- **[fetchData](./fetchData)**: Fetches data from a URL using GET requests
|
|
20
|
+
- **[submitData](./submitData)**: Submits data to a server endpoint using POST/PUT/DELETE
|
|
68
21
|
|
|
69
22
|
### Browser Operations
|
|
70
|
-
- **[setClipboardData](setClipboardData)**: Copies data to the clipboard
|
|
71
|
-
- **[redirectNow](redirectNow)**: Performs an immediate redirect
|
|
72
|
-
- **[triggerEvent](triggerEvent)**: Triggers a custom event
|
|
73
|
-
- **[postMessage](postMessage)**: Sends a message to another window/frame
|
|
74
|
-
|
|
75
|
-
For detailed documentation of each reaction, including properties and examples, see their respective documentation pages.
|
|
76
|
-
|
|
77
|
-
- type: RjBuildDescriber
|
|
78
|
-
title: "Event Types and Conditional Reactions"
|
|
79
|
-
description:
|
|
80
|
-
- type: Markdown
|
|
81
|
-
content: |
|
|
82
|
-
This example shows different event types and conditional reactions.
|
|
83
|
-
|
|
84
|
-
Common event types:
|
|
85
|
-
- `click`: Mouse click (works on any element)
|
|
86
|
-
- `change`: Form input change (works on form elements only)
|
|
87
|
-
- `submit`: Form submission (works on form elements only)
|
|
88
|
-
- `keydown`/`keyup`: Keyboard events (works on focusable elements)
|
|
89
|
-
|
|
90
|
-
toDescribe:
|
|
91
|
-
renderView:
|
|
92
|
-
- type: button
|
|
93
|
-
content: "Toggle Mode (Click)"
|
|
94
|
-
actions:
|
|
95
|
-
- what: setData
|
|
96
|
-
on: click
|
|
97
|
-
path: ~.mode
|
|
98
|
-
value: "editing"
|
|
99
|
-
when: ~.mode
|
|
100
|
-
isNot: "editing"
|
|
101
|
-
- what: setData
|
|
102
|
-
on: click
|
|
103
|
-
path: ~.mode
|
|
104
|
-
value: "viewing"
|
|
105
|
-
when: ~.mode
|
|
106
|
-
is: "editing"
|
|
107
|
-
|
|
108
|
-
- type: TextField
|
|
109
|
-
label: "Text field (onChange):"
|
|
110
|
-
dataLocation: ~.text_value
|
|
111
|
-
actions:
|
|
112
|
-
- what: setData
|
|
113
|
-
on: change
|
|
114
|
-
path: ~.last_change
|
|
115
|
-
value: ~.text_value
|
|
116
|
-
when: ~.mode
|
|
117
|
-
is: "editing"
|
|
118
|
-
|
|
119
|
-
- type: div
|
|
120
|
-
content: ["Current mode: ", ~.mode]
|
|
121
|
-
|
|
122
|
-
- type: div
|
|
123
|
-
content: ["Last change: ", ~.last_change]
|
|
124
|
-
actions:
|
|
125
|
-
- what: hide
|
|
126
|
-
when: ~.last_change
|
|
127
|
-
isEmpty: true
|
|
128
|
-
|
|
129
|
-
data:
|
|
130
|
-
mode: "viewing"
|
|
131
|
-
text_value: ""
|
|
132
|
-
last_change: ""
|
|
133
|
-
|
|
134
|
-
- type: RjBuildDescriber
|
|
135
|
-
title: "Data Management Example"
|
|
136
|
-
description:
|
|
137
|
-
- type: Markdown
|
|
138
|
-
content: |
|
|
139
|
-
This example demonstrates the core data management reactions: setData, addData, and removeData.
|
|
140
|
-
|
|
141
|
-
toDescribe:
|
|
142
|
-
renderView:
|
|
143
|
-
- type: TextField
|
|
144
|
-
label: "Add item:"
|
|
145
|
-
dataLocation: ~.new_item
|
|
146
|
-
placeholder: "Enter item name"
|
|
147
|
-
|
|
148
|
-
- type: button
|
|
149
|
-
content: "Add Item"
|
|
150
|
-
actions:
|
|
151
|
-
- what: addData
|
|
152
|
-
on: click
|
|
153
|
-
path: ~.items
|
|
154
|
-
value:
|
|
155
|
-
name: ~.new_item
|
|
156
|
-
when: ~.new_item
|
|
157
|
-
isEmpty: "not"
|
|
158
|
-
- what: setData
|
|
159
|
-
on: click
|
|
160
|
-
path: ~.new_item
|
|
161
|
-
value: ""
|
|
162
|
-
when: ~.new_item
|
|
163
|
-
isEmpty: "not"
|
|
164
|
-
|
|
165
|
-
- type: div
|
|
166
|
-
content: "Items:"
|
|
167
|
-
attributes:
|
|
168
|
-
style:
|
|
169
|
-
fontWeight: "bold"
|
|
170
|
-
margin: "10px 0 5px 0"
|
|
171
|
-
|
|
172
|
-
- type: Switch
|
|
173
|
-
content: ~.items
|
|
174
|
-
singleOption:
|
|
175
|
-
load: itemTemplate
|
|
176
|
-
|
|
177
|
-
templates:
|
|
178
|
-
itemTemplate:
|
|
179
|
-
type: div
|
|
180
|
-
content:
|
|
181
|
-
- "• "
|
|
182
|
-
- ~.name
|
|
183
|
-
- type: button
|
|
184
|
-
content: " [Remove]"
|
|
185
|
-
attributes:
|
|
186
|
-
style:
|
|
187
|
-
marginLeft: "10px"
|
|
188
|
-
background: "red"
|
|
189
|
-
color: "white"
|
|
190
|
-
border: "none"
|
|
191
|
-
padding: "2px 8px"
|
|
192
|
-
fontSize: "12px"
|
|
193
|
-
actions:
|
|
194
|
-
- what: removeData
|
|
195
|
-
on: click
|
|
196
|
-
target: currentTemplateData
|
|
197
|
-
parentLevel: 0
|
|
198
|
-
|
|
199
|
-
data:
|
|
200
|
-
new_item: ""
|
|
201
|
-
items:
|
|
202
|
-
- name: "Sample item 1"
|
|
203
|
-
- name: "Sample item 2"
|
|
204
|
-
|
|
205
|
-
- type: Markdown
|
|
206
|
-
content: |
|
|
207
|
-
## Advanced Features
|
|
208
|
-
|
|
209
|
-
### Conditional Logic
|
|
210
|
-
Reactions support the same conditional operators as actions:
|
|
211
|
-
- `when` + `is`/`isNot`: Value equality checks
|
|
212
|
-
- `when` + `isEmpty`: Empty value tests
|
|
213
|
-
- `when` + `contains`/`containsNot`: Content search
|
|
214
|
-
- `when` + `>`, `<`, `>=`, `<=`: Numeric/date comparisons
|
|
215
|
-
- `andConditions`/`orConditions`: Complex condition logic
|
|
216
|
-
|
|
217
|
-
### Event Control
|
|
218
|
-
Use `stopPropagation: true` to:
|
|
219
|
-
1. Prevent event bubbling to parent elements
|
|
220
|
-
2. Stop execution of subsequent actions for the same event
|
|
221
|
-
|
|
222
|
-
### Execution Order
|
|
223
|
-
- Multiple reactions on the same event execute in the order they are defined
|
|
224
|
-
- Reactions with unmet conditions are skipped
|
|
225
|
-
- Actions (without `on` property) are evaluated separately from reactions
|
|
226
|
-
|
|
227
|
-
- type: Markdown
|
|
228
|
-
content: |
|
|
229
|
-
## Technical Details
|
|
230
|
-
|
|
231
|
-
- Reactions are triggered by DOM events
|
|
232
|
-
- Multiple reactions can be defined for the same event
|
|
233
|
-
- Reactions are executed in the order they appear in the YAML
|
|
234
|
-
- Reactions can be chained together by modifying data that other reactions depend on
|
|
235
|
-
- Conditional reactions only execute when their conditions evaluate to true
|
|
236
|
-
- The `stopPropagation` property affects both event bubbling and subsequent action execution
|
|
237
|
-
|
|
238
|
-
## Limitations
|
|
239
|
-
|
|
240
|
-
- Event availability depends on the HTML element type (e.g., `change` only works on form elements)
|
|
241
|
-
- Network operations require proper CORS configuration
|
|
242
|
-
- Browser operations require appropriate permissions
|
|
243
|
-
- No built-in error handling beyond console logging for network operations
|
|
244
|
-
- Only one network request (fetch/submit) can be active at a time
|
|
245
|
-
- URLs in network operations must be static strings (dynamic URLs not supported)
|
|
246
|
-
|
|
247
|
-
## Best Practices
|
|
248
|
-
|
|
249
|
-
1. **Use descriptive conditions**: Make your conditional logic clear and readable
|
|
250
|
-
2. **Handle empty states**: Always consider what happens when data is empty or undefined
|
|
251
|
-
3. **Order matters**: Place more specific conditions before general ones
|
|
252
|
-
4. **Use stopPropagation wisely**: Only use it when you specifically need to prevent event bubbling or stop action execution
|
|
253
|
-
5. **Test network operations**: Ensure your API endpoints return the expected format
|
|
254
|
-
6. **Provide user feedback**: Use visual indicators during loading states (see individual reaction documentation for CSS examples)
|
|
23
|
+
- **[setClipboardData](./setClipboardData)**: Copies data to the clipboard
|
|
24
|
+
- **[redirectNow](./redirectNow)**: Performs an immediate redirect
|
|
25
|
+
- **[triggerEvent](./triggerEvent)**: Triggers a custom event
|
|
26
|
+
- **[postMessage](./postMessage)**: Sends a message to another window/frame
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
This section documents components that are specific to the reactive-json-docs package. These components are not part of the core Reactive-JSON library but are provided by the documentation system to enhance the presentation of examples and technical content.
|
|
6
6
|
|
|
7
|
-
**Important**: These components are only available when using reactive-json-docs and are not included in the core @ea-lab/reactive-json package.
|
|
8
|
-
|
|
9
7
|
## Available Components
|
|
10
8
|
|
|
11
9
|
The documentation system provides specialized components for:
|
|
@@ -7,8 +7,6 @@ renderView:
|
|
|
7
7
|
|
|
8
8
|
This section documents components that are specific to the reactive-json-docs package. These components are not part of the core Reactive-JSON library but are provided by the documentation system to enhance the presentation of examples and technical content.
|
|
9
9
|
|
|
10
|
-
**Important**: These components are only available when using reactive-json-docs and are not included in the core @ea-lab/reactive-json package.
|
|
11
|
-
|
|
12
10
|
## Available Components
|
|
13
11
|
|
|
14
12
|
The documentation system provides specialized components for:
|