@ea-lab/reactive-json-docs 0.1.2
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/README-npm.md +49 -0
- package/README.md +86 -0
- package/package.json +79 -0
- package/public/rjbuild/component-doc/chartjs/components.yaml +252 -0
- package/public/rjbuild/component-doc/chartjs/overview.yaml +51 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.md +90 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.yaml +124 -0
- package/public/rjbuild/component-doc/core/action/Hide.md +22 -0
- package/public/rjbuild/component-doc/core/action/Hide.yaml +60 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.md +93 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.yaml +153 -0
- package/public/rjbuild/component-doc/core/action/Popover.md +26 -0
- package/public/rjbuild/component-doc/core/action/Popover.yaml +100 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.md +81 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.yaml +133 -0
- package/public/rjbuild/component-doc/core/action/Redirect.md +20 -0
- package/public/rjbuild/component-doc/core/action/Redirect.yaml +68 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.md +22 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.yaml +90 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.md +21 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.yaml +62 -0
- package/public/rjbuild/component-doc/core/action/index.md +214 -0
- package/public/rjbuild/component-doc/core/action/index.yaml +278 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.md +276 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.yaml +338 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.md +189 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.yaml +264 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.md +136 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.yaml +103 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.md +304 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.yaml +360 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.md +134 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.yaml +146 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.md +129 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.yaml +147 -0
- package/public/rjbuild/component-doc/core/element/form/formElementsCommon.md +106 -0
- package/public/rjbuild/component-doc/core/element/form/index.md +50 -0
- package/public/rjbuild/component-doc/core/element/form/index.yaml +96 -0
- package/public/rjbuild/component-doc/core/element/html/AccordionItem.yaml +47 -0
- package/public/rjbuild/component-doc/core/element/html/FolderSortableTree.yaml +81 -0
- package/public/rjbuild/component-doc/core/element/html/FormatNumeral.yaml +58 -0
- package/public/rjbuild/component-doc/core/element/html/Html.yaml +67 -0
- package/public/rjbuild/component-doc/core/element/html/LabelFromValue.yaml +54 -0
- package/public/rjbuild/component-doc/core/element/html/Modal.yaml +93 -0
- package/public/rjbuild/component-doc/core/element/html/PreformattedMarkup.yaml +37 -0
- package/public/rjbuild/component-doc/core/element/html/SortableTreeItemCollapseButton.yaml +92 -0
- package/public/rjbuild/component-doc/core/element/html/Tabs.yaml +57 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.md +17 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.yaml +18 -0
- package/public/rjbuild/component-doc/core/element/special/Count.md +37 -0
- package/public/rjbuild/component-doc/core/element/special/Count.yaml +325 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.md +149 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.yaml +315 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.md +51 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.yaml +55 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.md +126 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.yaml +133 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.md +31 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.yaml +34 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.md +27 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.yaml +51 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.md +262 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.yaml +348 -0
- package/public/rjbuild/component-doc/core/example/accordion.md +96 -0
- package/public/rjbuild/component-doc/core/example/accordion.yaml +64 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.md +197 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.yaml +237 -0
- package/public/rjbuild/component-doc/core/example/html.md +66 -0
- package/public/rjbuild/component-doc/core/example/html.yaml +83 -0
- package/public/rjbuild/component-doc/core/example/website.yaml +1663 -0
- package/public/rjbuild/component-doc/core/reaction/addData.md +96 -0
- package/public/rjbuild/component-doc/core/reaction/addData.yaml +133 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.md +60 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.yaml +156 -0
- package/public/rjbuild/component-doc/core/reaction/index.md +236 -0
- package/public/rjbuild/component-doc/core/reaction/index.yaml +254 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.md +68 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.yaml +71 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.md +63 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.yaml +68 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.md +37 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.yaml +37 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.md +78 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.yaml +56 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.md +44 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.yaml +41 -0
- package/public/rjbuild/component-doc/core/reaction/setData.md +93 -0
- package/public/rjbuild/component-doc/core/reaction/setData.yaml +85 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.md +138 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.yaml +141 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.md +59 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.yaml +59 -0
- package/public/rjbuild/component-doc/index.yaml +13 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Reactive-JSON Actions System Documentation
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
The Reactive-JSON actions system allows you to modify element behavior and appearance based on dynamic conditions. Actions are applied to individual elements and can control visibility, display tooltips, redirect users, or trigger other behaviors based on the current data state.
|
|
9
|
+
|
|
10
|
+
This system enables you to create interactive interfaces directly through JSON configuration, without requiring custom JavaScript code.
|
|
11
|
+
|
|
12
|
+
- type: RjBuildDescriber
|
|
13
|
+
title: "Basic Action Structure"
|
|
14
|
+
description:
|
|
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)
|
|
23
|
+
|
|
24
|
+
toDescribe:
|
|
25
|
+
renderView:
|
|
26
|
+
- type: button
|
|
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
|
|
43
|
+
|
|
44
|
+
- type: div
|
|
45
|
+
content: "This content can be hidden"
|
|
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
|
|
55
|
+
|
|
56
|
+
data:
|
|
57
|
+
my_condition: false
|
|
58
|
+
|
|
59
|
+
- type: Markdown
|
|
60
|
+
content: |
|
|
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
|
|
266
|
+
|
|
267
|
+
1. **Keep conditions simple**: Avoid overly complex condition logic for better maintainability
|
|
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
|
|
273
|
+
|
|
274
|
+
## Related Documentation
|
|
275
|
+
|
|
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
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# CheckBoxField
|
|
2
|
+
|
|
3
|
+
The `CheckBoxField` component renders checkbox or radio button groups using React Bootstrap. It supports both single and multiple selections, dynamic options, and intelligent data storage based on the control type and configuration.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
- `dataLocation` (string, optional): Path to bind the field value in the data context
|
|
8
|
+
- `defaultFieldValue` (any, optional): Default value when no data is present
|
|
9
|
+
- `options` (array, optional): Static array of option objects with `label` and `value` properties
|
|
10
|
+
- `dynamicOptions` (string, optional): Template path to dynamic options array
|
|
11
|
+
- `controlType` (string, optional): Type of control - "checkbox" (default) or "radio"
|
|
12
|
+
- `multiple` (boolean, optional): Force array storage for checkboxes (default: auto-detected)
|
|
13
|
+
- `attributes` (object, optional): Attributes applied to the Form.Group container
|
|
14
|
+
- `actions` (array, optional): Actions to execute based on field state
|
|
15
|
+
|
|
16
|
+
## Option Format
|
|
17
|
+
|
|
18
|
+
Each option object must have:
|
|
19
|
+
- `label` (string|object): Display text or Reactive-JSON content for the option
|
|
20
|
+
- `value` (any): The actual value to store when selected
|
|
21
|
+
- `attributes` (object, optional): Additional attributes for the specific option
|
|
22
|
+
|
|
23
|
+
## Data Storage Modes
|
|
24
|
+
|
|
25
|
+
The component uses different data storage strategies:
|
|
26
|
+
|
|
27
|
+
### Single Value Mode
|
|
28
|
+
- Used for radio buttons (`controlType: "radio"`)
|
|
29
|
+
- Used for single checkbox when `options.length === 1` and `multiple` is not set
|
|
30
|
+
- Stores the selected value directly
|
|
31
|
+
|
|
32
|
+
### Array Mode
|
|
33
|
+
- Used for multiple checkboxes when `options.length > 1` or `multiple: true`
|
|
34
|
+
- Stores selected values in an array
|
|
35
|
+
- Automatically manages array additions and removals
|
|
36
|
+
|
|
37
|
+
## Basic Examples
|
|
38
|
+
|
|
39
|
+
### Multiple Checkboxes
|
|
40
|
+
```yaml
|
|
41
|
+
renderView:
|
|
42
|
+
- type: CheckBoxField
|
|
43
|
+
dataLocation: ~.interests
|
|
44
|
+
options:
|
|
45
|
+
- label: "Technology"
|
|
46
|
+
value: "tech"
|
|
47
|
+
- label: "Sports"
|
|
48
|
+
value: "sports"
|
|
49
|
+
- label: "Music"
|
|
50
|
+
value: "music"
|
|
51
|
+
- label: "Travel"
|
|
52
|
+
value: "travel"
|
|
53
|
+
|
|
54
|
+
data:
|
|
55
|
+
interests:
|
|
56
|
+
- sports
|
|
57
|
+
- travel
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Radio Buttons
|
|
61
|
+
```yaml
|
|
62
|
+
renderView:
|
|
63
|
+
- type: CheckBoxField
|
|
64
|
+
dataLocation: ~.priority
|
|
65
|
+
controlType: "radio"
|
|
66
|
+
options:
|
|
67
|
+
- label: "Low"
|
|
68
|
+
value: "low"
|
|
69
|
+
- label: "Medium"
|
|
70
|
+
value: "medium"
|
|
71
|
+
- label: "High"
|
|
72
|
+
value: "high"
|
|
73
|
+
- label: "Critical"
|
|
74
|
+
value: "critical"
|
|
75
|
+
|
|
76
|
+
data:
|
|
77
|
+
priority: ""
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Single Checkbox
|
|
81
|
+
```yaml
|
|
82
|
+
renderView:
|
|
83
|
+
- type: CheckBoxField
|
|
84
|
+
dataLocation: ~.acceptTerms
|
|
85
|
+
options:
|
|
86
|
+
- label: "I accept the terms and conditions"
|
|
87
|
+
value: true
|
|
88
|
+
- type: CheckBoxField
|
|
89
|
+
dataLocation: ~.newsletter
|
|
90
|
+
options:
|
|
91
|
+
- label: "Subscribe to newsletter"
|
|
92
|
+
value: true
|
|
93
|
+
|
|
94
|
+
data:
|
|
95
|
+
acceptTerms: false
|
|
96
|
+
newsletter: false
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Value Types Limitations
|
|
100
|
+
|
|
101
|
+
**Important**: CheckBoxField has limitations with non-string value types due to HTML input behavior:
|
|
102
|
+
|
|
103
|
+
- ✅ **String values**: Work perfectly (`"tech"`, `"sports"`, etc.)
|
|
104
|
+
- ✅ **Boolean values**: Work for single checkboxes (`true`/`false`)
|
|
105
|
+
- ❌ **Numeric values**: May cause issues due to string conversion in HTML inputs
|
|
106
|
+
- ❌ **Complex objects**: Not supported in array mode
|
|
107
|
+
|
|
108
|
+
**Recommendation**: Use string values for reliability. Numeric and complex value type support may be improved in future versions.
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
# ✅ Recommended - String values
|
|
112
|
+
options:
|
|
113
|
+
- label: "Priority 1"
|
|
114
|
+
value: "priority_1"
|
|
115
|
+
- label: "Priority 2"
|
|
116
|
+
value: "priority_2"
|
|
117
|
+
|
|
118
|
+
# ❌ Avoid - Numeric values may cause issues
|
|
119
|
+
options:
|
|
120
|
+
- label: "Priority 1"
|
|
121
|
+
value: 1
|
|
122
|
+
- label: "Priority 2"
|
|
123
|
+
value: 2
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Dynamic Options with Conditional Display
|
|
127
|
+
|
|
128
|
+
CheckBoxField supports dynamic options loaded from data using `dynamicOptions`. Since dynamic path selection like `~.data[~.key]` is not supported, the recommended technique is:
|
|
129
|
+
|
|
130
|
+
1. **Create one CheckBoxField per category** instead of trying to use dynamic paths
|
|
131
|
+
2. **Use conditional `hide` actions** to show only the relevant CheckBoxField
|
|
132
|
+
3. **Store selections in separate data locations** for each category
|
|
133
|
+
|
|
134
|
+
### Example: Skills by Category
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
renderView:
|
|
138
|
+
- type: SelectField
|
|
139
|
+
dataLocation: ~.selectedCategory
|
|
140
|
+
label: "Select Category to see available skills:"
|
|
141
|
+
options:
|
|
142
|
+
- label: "Choose category"
|
|
143
|
+
value: ""
|
|
144
|
+
- label: "Technology"
|
|
145
|
+
value: "technology"
|
|
146
|
+
- label: "Business"
|
|
147
|
+
value: "business"
|
|
148
|
+
- label: "Creative"
|
|
149
|
+
value: "creative"
|
|
150
|
+
- type: CheckBoxField
|
|
151
|
+
dataLocation: ~.techSkills
|
|
152
|
+
dynamicOptions: ~.skillCategories.technology
|
|
153
|
+
actions:
|
|
154
|
+
- what: hide
|
|
155
|
+
when: ~.selectedCategory
|
|
156
|
+
isNot: "technology"
|
|
157
|
+
- type: CheckBoxField
|
|
158
|
+
dataLocation: ~.businessSkills
|
|
159
|
+
dynamicOptions: ~.skillCategories.business
|
|
160
|
+
actions:
|
|
161
|
+
- what: hide
|
|
162
|
+
when: ~.selectedCategory
|
|
163
|
+
isNot: "business"
|
|
164
|
+
- type: CheckBoxField
|
|
165
|
+
dataLocation: ~.creativeSkills
|
|
166
|
+
dynamicOptions: ~.skillCategories.creative
|
|
167
|
+
actions:
|
|
168
|
+
- what: hide
|
|
169
|
+
when: ~.selectedCategory
|
|
170
|
+
isNot: "creative"
|
|
171
|
+
|
|
172
|
+
data:
|
|
173
|
+
selectedCategory: ""
|
|
174
|
+
techSkills: []
|
|
175
|
+
businessSkills: []
|
|
176
|
+
creativeSkills: []
|
|
177
|
+
skillCategories:
|
|
178
|
+
technology:
|
|
179
|
+
- label: "JavaScript"
|
|
180
|
+
value: "javascript"
|
|
181
|
+
- label: "Python"
|
|
182
|
+
value: "python"
|
|
183
|
+
- label: "React"
|
|
184
|
+
value: "react"
|
|
185
|
+
- label: "Node.js"
|
|
186
|
+
value: "nodejs"
|
|
187
|
+
business:
|
|
188
|
+
- label: "Project Management"
|
|
189
|
+
value: "pm"
|
|
190
|
+
- label: "Marketing"
|
|
191
|
+
value: "marketing"
|
|
192
|
+
- label: "Sales"
|
|
193
|
+
value: "sales"
|
|
194
|
+
- label: "Finance"
|
|
195
|
+
value: "finance"
|
|
196
|
+
creative:
|
|
197
|
+
- label: "Graphic Design"
|
|
198
|
+
value: "design"
|
|
199
|
+
- label: "Photography"
|
|
200
|
+
value: "photo"
|
|
201
|
+
- label: "Writing"
|
|
202
|
+
value: "writing"
|
|
203
|
+
- label: "Video Editing"
|
|
204
|
+
value: "video"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Why Not Dynamic Paths?
|
|
208
|
+
|
|
209
|
+
```yaml
|
|
210
|
+
# ❌ This does NOT work in Reactive-JSON:
|
|
211
|
+
renderView:
|
|
212
|
+
- type: CheckBoxField
|
|
213
|
+
dynamicOptions: ~.categories[~.selectedCategory]
|
|
214
|
+
|
|
215
|
+
# ✅ Use this approach instead:
|
|
216
|
+
renderView:
|
|
217
|
+
- type: CheckBoxField
|
|
218
|
+
dynamicOptions: ~.categories.technology
|
|
219
|
+
actions:
|
|
220
|
+
- what: hide
|
|
221
|
+
when: ~.selectedCategory
|
|
222
|
+
isNot: "technology"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
This technique ensures clean separation of data and provides predictable behavior.
|
|
226
|
+
|
|
227
|
+
## Option Attributes
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
renderView:
|
|
231
|
+
- type: CheckBoxField
|
|
232
|
+
dataLocation: ~.notifications
|
|
233
|
+
options:
|
|
234
|
+
- label: "Email notifications"
|
|
235
|
+
value: "email"
|
|
236
|
+
attributes:
|
|
237
|
+
style:
|
|
238
|
+
color: "blue"
|
|
239
|
+
- label: "SMS notifications (premium feature)"
|
|
240
|
+
value: "sms"
|
|
241
|
+
attributes:
|
|
242
|
+
disabled: true
|
|
243
|
+
title: "This feature requires a premium subscription"
|
|
244
|
+
- label: "Push notifications"
|
|
245
|
+
value: "push"
|
|
246
|
+
attributes:
|
|
247
|
+
style:
|
|
248
|
+
fontWeight: "bold"
|
|
249
|
+
|
|
250
|
+
data:
|
|
251
|
+
notifications: []
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Limitations
|
|
255
|
+
|
|
256
|
+
### Value Types
|
|
257
|
+
- **Numeric values**: May cause issues due to string conversion in HTML input elements
|
|
258
|
+
- **Complex objects**: Cannot be used as option values in array mode
|
|
259
|
+
- **Recommendation**: Use string values for most cases. Numeric and complex value type support may be improved in future versions.
|
|
260
|
+
|
|
261
|
+
### General Limitations
|
|
262
|
+
- Option labels support template evaluation but with limited View component rendering
|
|
263
|
+
- No support for indeterminate checkbox state
|
|
264
|
+
- No built-in option grouping or hierarchical structure
|
|
265
|
+
- Array mode may not preserve object key order in older JavaScript engines
|
|
266
|
+
- No built-in validation for minimum/maximum selections
|
|
267
|
+
- Limited styling options compared to custom checkbox implementations
|
|
268
|
+
|
|
269
|
+
## Value Type Handling
|
|
270
|
+
|
|
271
|
+
The component handles special string values in radio mode:
|
|
272
|
+
- Empty string `""` becomes `undefined`
|
|
273
|
+
- String `"true"` becomes boolean `true`
|
|
274
|
+
- String `"false"` becomes boolean `false`
|
|
275
|
+
- String `"null"` becomes `null`
|
|
276
|
+
- Other strings remain as strings
|