@ea-lab/reactive-json-docs 0.7.0 → 1.0.0-alpha.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 +7 -5
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +2 -2
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development-guide-llm.md +14 -14
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +47 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +53 -1
- package/public/rjbuild/docs/core/action/HashChangeListener.md +1 -1
- package/public/rjbuild/docs/core/action/HashChangeListener.yaml +24 -6
- package/public/rjbuild/docs/core/action/Hide.md +2 -2
- package/public/rjbuild/docs/core/action/Hide.yaml +4 -3
- package/public/rjbuild/docs/core/action/MessageListener.md +4 -4
- package/public/rjbuild/docs/core/action/MessageListener.yaml +18 -6
- package/public/rjbuild/docs/core/action/ReactOnEvent.md +4 -4
- package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +4 -4
- package/public/rjbuild/docs/core/action/Redirect.md +2 -2
- package/public/rjbuild/docs/core/action/Redirect.yaml +8 -2
- package/public/rjbuild/docs/core/action/VisuallyHide.md +2 -2
- package/public/rjbuild/docs/core/action/VisuallyHide.yaml +2 -2
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.md +5 -5
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +90 -60
- package/public/rjbuild/docs/core/element/debug/VariablesDebug.md +59 -0
- package/public/rjbuild/docs/core/element/debug/VariablesDebug.yaml +71 -0
- package/public/rjbuild/docs/core/element/form/Input.md +307 -0
- package/public/rjbuild/docs/core/element/form/Input.yaml +572 -0
- package/public/rjbuild/docs/core/element/html/FolderSortableTree.yaml +40 -12
- package/public/rjbuild/docs/core/element/html/FormatNumeral.yaml +21 -7
- package/public/rjbuild/docs/core/element/html/Html.yaml +26 -9
- package/public/rjbuild/docs/core/element/html/LabelFromValue.yaml +25 -8
- package/public/rjbuild/docs/core/element/html/PreformattedMarkup.yaml +23 -7
- package/public/rjbuild/docs/core/element/html/SortableTreeItemCollapseButton.yaml +7 -6
- package/public/rjbuild/docs/core/element/html/SyntaxHighlighter.yaml +56 -20
- package/public/rjbuild/docs/core/element/special/Count.md +8 -10
- package/public/rjbuild/docs/core/element/special/Count.yaml +121 -40
- package/public/rjbuild/docs/core/element/special/DataFilter.md +40 -41
- package/public/rjbuild/docs/core/element/special/DataFilter.yaml +197 -81
- package/public/rjbuild/docs/core/element/special/DelayedActions.md +13 -15
- package/public/rjbuild/docs/core/element/special/DelayedActions.yaml +32 -13
- package/public/rjbuild/docs/core/element/special/PageControls.md +8 -10
- package/public/rjbuild/docs/core/element/special/PageControls.yaml +9 -8
- package/public/rjbuild/docs/core/element/special/Phantom.md +9 -11
- package/public/rjbuild/docs/core/element/special/Phantom.yaml +22 -9
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.md +7 -9
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +167 -49
- package/public/rjbuild/docs/core/element/special/Switch.md +36 -38
- package/public/rjbuild/docs/core/element/special/Switch.yaml +68 -40
- package/public/rjbuild/docs/core/example/html.md +2 -2
- package/public/rjbuild/docs/core/example/html.yaml +2 -3
- package/public/rjbuild/docs/core/example/native-html-forms.md +245 -0
- package/public/rjbuild/docs/core/example/native-html-forms.yaml +393 -0
- package/public/rjbuild/docs/core/reaction/addData.md +17 -5
- package/public/rjbuild/docs/core/reaction/addData.yaml +70 -11
- package/public/rjbuild/docs/core/reaction/fetchData.md +1 -2
- package/public/rjbuild/docs/core/reaction/fetchData.yaml +84 -19
- package/public/rjbuild/docs/core/reaction/moveData.md +0 -4
- package/public/rjbuild/docs/core/reaction/moveData.yaml +28 -6
- package/public/rjbuild/docs/core/reaction/postMessage.md +0 -4
- package/public/rjbuild/docs/core/reaction/postMessage.yaml +29 -6
- package/public/rjbuild/docs/core/reaction/redirectNow.md +0 -4
- package/public/rjbuild/docs/core/reaction/redirectNow.yaml +10 -3
- package/public/rjbuild/docs/core/reaction/removeData.md +2 -6
- package/public/rjbuild/docs/core/reaction/removeData.yaml +40 -2
- package/public/rjbuild/docs/core/reaction/setClipboardData.md +0 -4
- package/public/rjbuild/docs/core/reaction/setClipboardData.yaml +10 -3
- package/public/rjbuild/docs/core/reaction/setData.md +18 -8
- package/public/rjbuild/docs/core/reaction/setData.yaml +43 -11
- package/public/rjbuild/docs/core/reaction/submitData.md +2 -3
- package/public/rjbuild/docs/core/reaction/submitData.yaml +43 -7
- package/public/rjbuild/docs/core/reaction/triggerEvent.md +0 -4
- package/public/rjbuild/docs/core/reaction/triggerEvent.yaml +25 -11
- package/public/rjbuild/docs/docs-components/Mermaid.md +254 -0
- package/public/rjbuild/docs/docs-components/Mermaid.yaml +339 -0
- package/public/rjbuild/docs/docs-components/index.yaml +1 -0
- package/public/rjbuild/docs/getting-started/actions.md +1 -1
- package/public/rjbuild/docs/index.yaml +2 -1
- package/public/rjbuild/docs/install.md +26 -29
- package/public/rjbuild/docs/install.yaml +4 -10
- package/public/rjbuild/docs/integration/bootstrap/action/Popover.md +26 -0
- package/public/rjbuild/docs/{core → integration/bootstrap}/action/Popover.yaml +28 -5
- package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.md +4 -4
- package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.yaml +16 -3
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.md +8 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.yaml +40 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.md +5 -5
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.yaml +27 -5
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.md +7 -7
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.yaml +32 -7
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.md +9 -9
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.yaml +46 -9
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.md +8 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.yaml +36 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.md +8 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.yaml +38 -8
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/formElementsCommon.md +2 -4
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.md +0 -2
- package/public/rjbuild/docs/integration/bootstrap/element/html/AccordionItem.md +69 -0
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/AccordionItem.yaml +19 -7
- package/public/rjbuild/docs/integration/bootstrap/element/html/Modal.md +127 -0
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Modal.yaml +35 -12
- package/public/rjbuild/docs/integration/bootstrap/element/html/Tabs.md +150 -0
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Tabs.yaml +24 -15
- package/public/rjbuild/docs/integration/bootstrap/element/html/index.md +13 -0
- package/public/rjbuild/docs/{core → integration/bootstrap}/element/special/BootstrapElement.md +4 -6
- package/public/rjbuild/docs/integration/bootstrap/element/special/BootstrapElement.yaml +29 -0
- package/public/rjbuild/docs/integration/bootstrap/element/special/index.md +19 -0
- package/public/rjbuild/docs/integration/bootstrap/example/website.md +41 -0
- package/public/rjbuild/docs/integration/bootstrap/overview.md +69 -0
- package/public/rjbuild/docs/integration/bootstrap/overview.yaml +87 -0
- package/public/rjbuild/docs/core/action/Popover.md +0 -26
- package/public/rjbuild/docs/core/element/special/BootstrapElement.yaml +0 -18
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/example/accordion.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/example/accordion.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/example/dynamic-content.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/example/dynamic-content.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/example/website.yaml +0 -0
- /package/public/rjbuild/docs/{chartjs → integration/chartjs}/components.yaml +0 -0
- /package/public/rjbuild/docs/{chartjs → integration/chartjs}/overview.yaml +0 -0
|
@@ -6,24 +6,61 @@ renderView:
|
|
|
6
6
|
The `Switch` component allows you to render a list or collection of items using a template, with support for dynamic data, options, and pagination. It is useful for displaying arrays, lists, or collections where each item can be rendered with a specific template or configuration.
|
|
7
7
|
|
|
8
8
|
## Properties
|
|
9
|
-
- `content` (object/array/string, required): The data or path to the data to iterate over
|
|
10
|
-
- `options` (object, optional): Mapping of keys to templates for rendering each item (used for object/array of objects)
|
|
11
|
-
- `singleOption` (object, optional): Template to use for each item when all items share the same structure
|
|
12
|
-
- `cardinality` (number, optional): Maximum number of items to render (default: unlimited)
|
|
13
|
-
- `paginated` (boolean, optional): Whether to enable pagination (default: false)
|
|
14
|
-
- `paginationProps` (object, optional): Pagination configuration (page size, etc.)
|
|
15
|
-
- `before` (object, optional): Content to render before the list
|
|
16
|
-
- `after` (object, optional): Content to render after the list
|
|
17
|
-
- `contentWrapper` (object, optional): HTML element configuration to wrap the main content (items only, not before/after)
|
|
18
|
-
- `tag` (string, optional): HTML tag name (default: "div")
|
|
19
|
-
- `attributes` (object, optional): HTML attributes to apply to the wrapper element (supports template evaluation)
|
|
20
9
|
|
|
10
|
+
- type: DefinitionList
|
|
11
|
+
content:
|
|
12
|
+
- term:
|
|
13
|
+
code: content
|
|
14
|
+
after: "(object|array|string, required)"
|
|
15
|
+
details:
|
|
16
|
+
type: Markdown
|
|
17
|
+
content: "Data or path to the data to iterate over."
|
|
18
|
+
- term:
|
|
19
|
+
code: options
|
|
20
|
+
after: "(object, optional)"
|
|
21
|
+
details: "Mapping of keys to templates for rendering each item (used for object/array of objects)."
|
|
22
|
+
- term:
|
|
23
|
+
code: singleOption
|
|
24
|
+
after: "(object, optional)"
|
|
25
|
+
details: "Template to use for each item when all items share the same structure."
|
|
26
|
+
- term:
|
|
27
|
+
code: cardinality
|
|
28
|
+
after: "(number, optional)"
|
|
29
|
+
details: "Maximum number of items to render (default: unlimited)."
|
|
30
|
+
- term:
|
|
31
|
+
code: paginated
|
|
32
|
+
after: "(boolean, optional)"
|
|
33
|
+
details: "Whether to enable pagination (default: false)."
|
|
34
|
+
- term:
|
|
35
|
+
code: paginationProps
|
|
36
|
+
after: "(object, optional)"
|
|
37
|
+
details: "Pagination configuration (page size, etc.)."
|
|
38
|
+
- term:
|
|
39
|
+
code: before
|
|
40
|
+
after: "(object, optional)"
|
|
41
|
+
details: "Content to render before the list."
|
|
42
|
+
- term:
|
|
43
|
+
code: after
|
|
44
|
+
after: "(object, optional)"
|
|
45
|
+
details: "Content to render after the list."
|
|
46
|
+
- term:
|
|
47
|
+
code: contentWrapper
|
|
48
|
+
after: "(object, optional)"
|
|
49
|
+
details:
|
|
50
|
+
type: Markdown
|
|
51
|
+
content: |
|
|
52
|
+
HTML element configuration to wrap the main content (items only, not before/after):
|
|
53
|
+
- `tag` (string, optional): HTML tag name (default: `div`)
|
|
54
|
+
- `attributes` (object, optional): HTML attributes to apply to the wrapper element (supports template evaluation)
|
|
55
|
+
|
|
56
|
+
- type: Markdown
|
|
57
|
+
content: |
|
|
21
58
|
## Behavior
|
|
22
|
-
- Iterates over the provided data and renders each item using the specified template(s)
|
|
23
|
-
- If `options` is provided, uses the corresponding template for each key
|
|
24
|
-
- If `singleOption` is provided, uses the same template for all items
|
|
25
|
-
- Supports limiting the number of items with `cardinality
|
|
26
|
-
- Supports pagination if `paginated` is true
|
|
59
|
+
- Iterates over the provided data and renders each item using the specified template(s).
|
|
60
|
+
- If `options` is provided, uses the corresponding template for each key.
|
|
61
|
+
- If `singleOption` is provided, uses the same template for all items.
|
|
62
|
+
- Supports limiting the number of items with `cardinality`.
|
|
63
|
+
- Supports pagination if `paginated` is true.
|
|
27
64
|
- Renders optional `before` and `after` content
|
|
28
65
|
- Can wrap the main content (items) with a custom HTML element using `contentWrapper`
|
|
29
66
|
|
|
@@ -88,7 +125,7 @@ renderView:
|
|
|
88
125
|
```
|
|
89
126
|
|
|
90
127
|
- type: RjBuildDescriber
|
|
91
|
-
title: "
|
|
128
|
+
title: "Simple usage with `singleOption` (no pagination)"
|
|
92
129
|
description: |
|
|
93
130
|
This example shows a basic Switch rendering a list of users with a single template.
|
|
94
131
|
toDescribe:
|
|
@@ -108,7 +145,7 @@ renderView:
|
|
|
108
145
|
- name: "Charlie"
|
|
109
146
|
|
|
110
147
|
- type: RjBuildDescriber
|
|
111
|
-
title: "
|
|
148
|
+
title: "Usage with `options` (different templates per key)"
|
|
112
149
|
description: |
|
|
113
150
|
This example shows how to use different templates for each key in the data.
|
|
114
151
|
toDescribe:
|
|
@@ -139,7 +176,7 @@ renderView:
|
|
|
139
176
|
value: 25
|
|
140
177
|
|
|
141
178
|
- type: RjBuildDescriber
|
|
142
|
-
title: "
|
|
179
|
+
title: "Usage with `singleOption` and pagination (4 per page, 10 items)"
|
|
143
180
|
description: |
|
|
144
181
|
This example demonstrates pagination with 4 items per page and 10 items in total. PageControls is added to the end of the list.
|
|
145
182
|
toDescribe:
|
|
@@ -173,7 +210,7 @@ renderView:
|
|
|
173
210
|
- value: 10
|
|
174
211
|
|
|
175
212
|
- type: RjBuildDescriber
|
|
176
|
-
title: "
|
|
213
|
+
title: "Usage with `contentWrapper` for CSS Grid Layout"
|
|
177
214
|
description: |
|
|
178
215
|
This example demonstrates how to use contentWrapper to apply a CSS Grid layout to the Switch items.
|
|
179
216
|
toDescribe:
|
|
@@ -190,7 +227,7 @@ renderView:
|
|
|
190
227
|
gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))"
|
|
191
228
|
gap: 1rem
|
|
192
229
|
padding: 1rem
|
|
193
|
-
|
|
230
|
+
border: "1px solid currentColor"
|
|
194
231
|
borderRadius: 8px
|
|
195
232
|
before:
|
|
196
233
|
type: h3
|
|
@@ -201,31 +238,28 @@ renderView:
|
|
|
201
238
|
style:
|
|
202
239
|
textAlign: center
|
|
203
240
|
marginTop: 1rem
|
|
204
|
-
color: "#666"
|
|
205
241
|
content: "End of product list"
|
|
206
242
|
templates:
|
|
207
243
|
productCard:
|
|
208
244
|
type: div
|
|
209
245
|
attributes:
|
|
210
246
|
style:
|
|
211
|
-
border: "1px solid
|
|
247
|
+
border: "1px solid currentColor"
|
|
212
248
|
borderRadius: 8px
|
|
213
249
|
padding: 1rem
|
|
214
|
-
backgroundColor: white
|
|
215
250
|
textAlign: center
|
|
216
251
|
content:
|
|
217
252
|
- type: h4
|
|
218
253
|
attributes:
|
|
219
254
|
style:
|
|
220
255
|
margin: "0 0 0.5rem 0"
|
|
221
|
-
color: "#333"
|
|
222
256
|
content: ~.name
|
|
223
257
|
- type: p
|
|
224
258
|
attributes:
|
|
225
259
|
style:
|
|
226
260
|
margin: 0
|
|
227
|
-
color: "#666"
|
|
228
261
|
fontSize: "0.9rem"
|
|
262
|
+
opacity: 0.8
|
|
229
263
|
content: ~.description
|
|
230
264
|
data:
|
|
231
265
|
products:
|
|
@@ -239,7 +273,7 @@ renderView:
|
|
|
239
273
|
description: "Affordable product D"
|
|
240
274
|
|
|
241
275
|
- type: RjBuildDescriber
|
|
242
|
-
title: "
|
|
276
|
+
title: "Usage with `contentWrapper` and Pagination"
|
|
243
277
|
description: |
|
|
244
278
|
This example shows how contentWrapper works seamlessly with pagination.
|
|
245
279
|
toDescribe:
|
|
@@ -261,7 +295,7 @@ renderView:
|
|
|
261
295
|
gap: 1rem
|
|
262
296
|
justifyContent: center
|
|
263
297
|
padding: 1rem
|
|
264
|
-
border: "2px dashed
|
|
298
|
+
border: "2px dashed currentColor"
|
|
265
299
|
borderRadius: 8px
|
|
266
300
|
after:
|
|
267
301
|
type: PageControls
|
|
@@ -272,10 +306,9 @@ renderView:
|
|
|
272
306
|
style:
|
|
273
307
|
flex: "0 1 150px"
|
|
274
308
|
padding: 1rem
|
|
275
|
-
|
|
309
|
+
border: "1px solid currentColor"
|
|
276
310
|
borderRadius: 8px
|
|
277
311
|
textAlign: center
|
|
278
|
-
border: "1px solid #90caf9"
|
|
279
312
|
content: ~.title
|
|
280
313
|
data:
|
|
281
314
|
cards:
|
|
@@ -288,7 +321,7 @@ renderView:
|
|
|
288
321
|
- title: "Card 7"
|
|
289
322
|
|
|
290
323
|
- type: RjBuildDescriber
|
|
291
|
-
title: "
|
|
324
|
+
title: "Dynamic `contentWrapper` with Template Evaluation"
|
|
292
325
|
description: |
|
|
293
326
|
This example demonstrates how contentWrapper attributes can use template evaluation to create dynamic layouts.
|
|
294
327
|
toDescribe:
|
|
@@ -306,15 +339,14 @@ renderView:
|
|
|
306
339
|
gridTemplateColumns: ~.wrapperConfig.columns
|
|
307
340
|
gap: ~.wrapperConfig.spacing
|
|
308
341
|
padding: ~.wrapperConfig.padding
|
|
309
|
-
backgroundColor: ~.theme.background
|
|
310
342
|
border: ~.theme.border
|
|
311
343
|
borderRadius: ~.theme.borderRadius
|
|
312
344
|
before:
|
|
313
345
|
type: h3
|
|
314
346
|
attributes:
|
|
315
347
|
style:
|
|
316
|
-
color: ~.theme.titleColor
|
|
317
348
|
textAlign: center
|
|
349
|
+
fontWeight: bold
|
|
318
350
|
content: ~.title
|
|
319
351
|
templates:
|
|
320
352
|
dynamicCard:
|
|
@@ -322,10 +354,10 @@ renderView:
|
|
|
322
354
|
attributes:
|
|
323
355
|
style:
|
|
324
356
|
padding: 1rem
|
|
325
|
-
|
|
357
|
+
border: ~.theme.cardBorder
|
|
326
358
|
borderRadius: 6px
|
|
327
359
|
textAlign: center
|
|
328
|
-
|
|
360
|
+
|
|
329
361
|
content: ~.name
|
|
330
362
|
data:
|
|
331
363
|
title: "Dynamic Gallery"
|
|
@@ -335,12 +367,8 @@ renderView:
|
|
|
335
367
|
spacing: "1.5rem"
|
|
336
368
|
padding: "2rem"
|
|
337
369
|
theme:
|
|
338
|
-
|
|
339
|
-
border: "2px solid #2196f3"
|
|
370
|
+
border: "2px solid currentColor"
|
|
340
371
|
borderRadius: "12px"
|
|
341
|
-
titleColor: "#1976d2"
|
|
342
|
-
cardBackground: "#ffffff"
|
|
343
|
-
textColor: "#333333"
|
|
344
372
|
items:
|
|
345
373
|
- name: "Element A"
|
|
346
374
|
- name: "Element B"
|
|
@@ -39,7 +39,7 @@ HTML attributes are supported through the `attributes` property. Each attribute
|
|
|
39
39
|
> When using inline styles, you must use a specific structure:
|
|
40
40
|
> - Use an object with CSS properties as keys
|
|
41
41
|
> - Use camelCase for property names instead of hyphen-based CSS casing
|
|
42
|
-
> - For example, use `
|
|
42
|
+
> - For example, use `borderRadius` instead of `border-radius`
|
|
43
43
|
|
|
44
44
|
### Example with Attributes and Styles
|
|
45
45
|
```yaml
|
|
@@ -48,7 +48,7 @@ renderView:
|
|
|
48
48
|
attributes:
|
|
49
49
|
data-attr: Hello!
|
|
50
50
|
style:
|
|
51
|
-
|
|
51
|
+
border: "2px solid rgb(250,242,0)"
|
|
52
52
|
padding: 0.5em
|
|
53
53
|
content:
|
|
54
54
|
- "This is a "
|
|
@@ -60,15 +60,14 @@ renderView:
|
|
|
60
60
|
specify an object with the CSS property as the key, and CSS value as the value.
|
|
61
61
|
Each key must be using **camelCase** instead of the usual hyphen-based CSS casing.
|
|
62
62
|
|
|
63
|
-
In the following example, `
|
|
64
|
-
CSS property.
|
|
63
|
+
In the following example, `border` is used to add visual styling.
|
|
65
64
|
toDescribe:
|
|
66
65
|
renderView:
|
|
67
66
|
- type: div
|
|
68
67
|
attributes:
|
|
69
68
|
data-attr: Hello!
|
|
70
69
|
style:
|
|
71
|
-
|
|
70
|
+
border: "2px solid rgb(250,242,0)"
|
|
72
71
|
padding: 0.5em
|
|
73
72
|
content:
|
|
74
73
|
- "This is a "
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Native HTML Forms
|
|
2
|
+
|
|
3
|
+
This guide explains how to use native HTML form elements (`input`, `select`, `textarea`) with Reactive-JSON's reaction system to create interactive forms with proper data synchronization.
|
|
4
|
+
|
|
5
|
+
## Core Concept: Reactions for Data Synchronization
|
|
6
|
+
|
|
7
|
+
Native HTML elements require explicit **reactions** to synchronize user input with your data. This is done using the `setData` reaction triggered by user events.
|
|
8
|
+
|
|
9
|
+
### Basic Structure
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
- type: input
|
|
13
|
+
attributes:
|
|
14
|
+
type: "text"
|
|
15
|
+
value: ~.fieldName # Display current data value
|
|
16
|
+
actions:
|
|
17
|
+
- what: setData # Reaction to update data
|
|
18
|
+
on: input # Event that triggers the reaction
|
|
19
|
+
path: ~.fieldName # Data path to update
|
|
20
|
+
value: "<reactive-json:event-new-value>" # Value from the event
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Event Value Patterns
|
|
24
|
+
|
|
25
|
+
### Forward Update Pattern (Recommended)
|
|
26
|
+
|
|
27
|
+
Use `<reactive-json:event-new-value>` for automatic value detection:
|
|
28
|
+
|
|
29
|
+
- **Auto-detects the correct property**: `event.target.value` for inputs, `event.target.checked` for checkboxes
|
|
30
|
+
- **Simplifies configuration**: No need to specify which property to access
|
|
31
|
+
- **Works for all form elements**: text, number, checkbox, select, textarea, etc.
|
|
32
|
+
|
|
33
|
+
### Alternative Explicit Syntax
|
|
34
|
+
|
|
35
|
+
For specific control, you can explicitly access event properties:
|
|
36
|
+
|
|
37
|
+
- `<reactive-json:event>.target.value` - Direct access to input value
|
|
38
|
+
- `<reactive-json:event>.target.checked` - Direct access to checkbox state
|
|
39
|
+
- `<reactive-json:event>.target.selectedIndex` - Access to select index
|
|
40
|
+
|
|
41
|
+
## Event Types for Different Use Cases
|
|
42
|
+
|
|
43
|
+
- **`on: input`** - Real-time updates as user types (immediate feedback)
|
|
44
|
+
- **`on: change`** - Updates when user commits the change (varies by element type):
|
|
45
|
+
- Text inputs: when value changes AND field loses focus
|
|
46
|
+
- Checkboxes/Radio: immediately when checked/unchecked
|
|
47
|
+
- Select: immediately when option is selected
|
|
48
|
+
- **`on: blur`** - Updates when user leaves the field (regardless of value change)
|
|
49
|
+
- **`on: focus`** - Triggered when user enters the field
|
|
50
|
+
|
|
51
|
+
## Common Patterns
|
|
52
|
+
|
|
53
|
+
### Label Association
|
|
54
|
+
|
|
55
|
+
Use the `for` attribute to associate labels with form elements for accessibility:
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
- type: label
|
|
59
|
+
attributes:
|
|
60
|
+
for: "username-field"
|
|
61
|
+
content: "Username:"
|
|
62
|
+
- type: input
|
|
63
|
+
attributes:
|
|
64
|
+
id: "username-field"
|
|
65
|
+
type: "text"
|
|
66
|
+
value: ~.username
|
|
67
|
+
actions:
|
|
68
|
+
- what: setData
|
|
69
|
+
on: input
|
|
70
|
+
path: ~.username
|
|
71
|
+
value: "<reactive-json:event-new-value>"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Note**: Reactive-JSON automatically converts the HTML `for` attribute to React's `htmlFor` property.
|
|
75
|
+
|
|
76
|
+
### Text Input
|
|
77
|
+
```yaml
|
|
78
|
+
- type: input
|
|
79
|
+
attributes:
|
|
80
|
+
type: "text"
|
|
81
|
+
value: ~.fieldName
|
|
82
|
+
actions:
|
|
83
|
+
- what: setData
|
|
84
|
+
on: input
|
|
85
|
+
path: ~.fieldName
|
|
86
|
+
value: "<reactive-json:event-new-value>"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Checkbox
|
|
90
|
+
```yaml
|
|
91
|
+
- type: input
|
|
92
|
+
attributes:
|
|
93
|
+
type: "checkbox"
|
|
94
|
+
checked: ~.isSelected
|
|
95
|
+
actions:
|
|
96
|
+
- what: setData
|
|
97
|
+
on: change
|
|
98
|
+
path: ~.isSelected
|
|
99
|
+
value: "<reactive-json:event-new-value>"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Select Dropdown
|
|
103
|
+
```yaml
|
|
104
|
+
- type: select
|
|
105
|
+
attributes:
|
|
106
|
+
value: ~.selectedOption
|
|
107
|
+
content:
|
|
108
|
+
- type: option
|
|
109
|
+
attributes:
|
|
110
|
+
value: "option1"
|
|
111
|
+
content: "Option 1"
|
|
112
|
+
actions:
|
|
113
|
+
- what: setData
|
|
114
|
+
on: change
|
|
115
|
+
path: ~.selectedOption
|
|
116
|
+
value: "<reactive-json:event-new-value>"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Textarea
|
|
120
|
+
```yaml
|
|
121
|
+
- type: textarea
|
|
122
|
+
attributes:
|
|
123
|
+
value: ~.description
|
|
124
|
+
placeholder: "Enter description..."
|
|
125
|
+
rows: 4
|
|
126
|
+
actions:
|
|
127
|
+
- what: setData
|
|
128
|
+
on: input
|
|
129
|
+
path: ~.description
|
|
130
|
+
value: "<reactive-json:event-new-value>"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Number Input
|
|
134
|
+
```yaml
|
|
135
|
+
- type: input
|
|
136
|
+
attributes:
|
|
137
|
+
type: "number"
|
|
138
|
+
value: ~.quantity
|
|
139
|
+
min: 0
|
|
140
|
+
max: 100
|
|
141
|
+
actions:
|
|
142
|
+
- what: setData
|
|
143
|
+
on: input
|
|
144
|
+
path: ~.quantity
|
|
145
|
+
value: "<reactive-json:event-new-value>"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Radio Buttons
|
|
149
|
+
```yaml
|
|
150
|
+
- type: input
|
|
151
|
+
attributes:
|
|
152
|
+
type: "radio"
|
|
153
|
+
name: "size"
|
|
154
|
+
value: "small"
|
|
155
|
+
checked: ~.selectedSize
|
|
156
|
+
actions:
|
|
157
|
+
- what: setData
|
|
158
|
+
on: change
|
|
159
|
+
path: ~.selectedSize
|
|
160
|
+
value: "small"
|
|
161
|
+
|
|
162
|
+
- type: input
|
|
163
|
+
attributes:
|
|
164
|
+
type: "radio"
|
|
165
|
+
name: "size"
|
|
166
|
+
value: "large"
|
|
167
|
+
checked: ~.selectedSize
|
|
168
|
+
actions:
|
|
169
|
+
- what: setData
|
|
170
|
+
on: change
|
|
171
|
+
path: ~.selectedSize
|
|
172
|
+
value: "large"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Advanced Patterns
|
|
176
|
+
|
|
177
|
+
### Form Validation with Conditional Actions
|
|
178
|
+
```yaml
|
|
179
|
+
- type: input
|
|
180
|
+
attributes:
|
|
181
|
+
type: "email"
|
|
182
|
+
value: ~.email
|
|
183
|
+
actions:
|
|
184
|
+
- what: setData
|
|
185
|
+
on: input
|
|
186
|
+
path: ~.email
|
|
187
|
+
value: "<reactive-json:event-new-value>"
|
|
188
|
+
- what: setData
|
|
189
|
+
on: blur
|
|
190
|
+
path: ~.emailValid
|
|
191
|
+
value: "<reactive-json:event>.target.validity.valid"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Multiple Field Updates
|
|
195
|
+
```yaml
|
|
196
|
+
- type: input
|
|
197
|
+
attributes:
|
|
198
|
+
type: "text"
|
|
199
|
+
value: ~.firstName
|
|
200
|
+
actions:
|
|
201
|
+
- what: setData
|
|
202
|
+
on: input
|
|
203
|
+
path: ~.firstName
|
|
204
|
+
value: "<reactive-json:event-new-value>"
|
|
205
|
+
- what: setData
|
|
206
|
+
on: input
|
|
207
|
+
path: ~.fullName
|
|
208
|
+
value: ["<reactive-json:event-new-value>", " ", ~.lastName]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Simplification Alternatives
|
|
212
|
+
|
|
213
|
+
For simpler configuration and built-in styling, consider using pre-built form components:
|
|
214
|
+
|
|
215
|
+
- **Reactive-JSON Bootstrap**: `TextField`, `SelectField`, `CheckBoxField`, etc. with automatic data synchronization
|
|
216
|
+
- **Custom component libraries**: Create your own reusable form components with embedded reactions
|
|
217
|
+
|
|
218
|
+
Example with Bootstrap components:
|
|
219
|
+
```yaml
|
|
220
|
+
# Simpler alternative using reactive-json-bootstrap
|
|
221
|
+
- type: TextField
|
|
222
|
+
label: "Username:"
|
|
223
|
+
dataLocation: ~.username # Automatic synchronization
|
|
224
|
+
|
|
225
|
+
# Equivalent native implementation
|
|
226
|
+
- type: label
|
|
227
|
+
content: "Username:"
|
|
228
|
+
- type: input
|
|
229
|
+
attributes:
|
|
230
|
+
type: "text"
|
|
231
|
+
value: ~.username
|
|
232
|
+
actions:
|
|
233
|
+
- what: setData
|
|
234
|
+
on: input
|
|
235
|
+
path: ~.username
|
|
236
|
+
value: "<reactive-json:event-new-value>"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Best Practices
|
|
240
|
+
|
|
241
|
+
1. **Always include `setData` reactions** for interactive elements
|
|
242
|
+
2. **Choose appropriate events**: `input` for real-time updates, `change` for committed changes
|
|
243
|
+
3. **Use `<reactive-json:event-new-value>`** for automatic value detection
|
|
244
|
+
4. **Consider pre-built components** for complex forms to reduce configuration
|
|
245
|
+
5. **Test data flow** to ensure changes are properly synchronized
|