@ea-lab/reactive-json-docs 0.8.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -5
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.md +168 -0
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/forward-update.md +2 -2
- package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +2 -2
- package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +48 -2
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +54 -2
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
- package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +14 -4
- 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/special/Count.yaml +99 -31
- package/public/rjbuild/docs/core/element/special/DataFilter.yaml +118 -38
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +154 -34
- package/public/rjbuild/docs/core/element/special/Switch.md +5 -5
- package/public/rjbuild/docs/core/element/special/Switch.yaml +9 -18
- 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/hook/index.md +38 -0
- package/public/rjbuild/docs/core/hook/index.yaml +44 -0
- package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
- package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
- package/public/rjbuild/docs/core/reaction/addData.md +17 -3
- package/public/rjbuild/docs/core/reaction/addData.yaml +53 -9
- package/public/rjbuild/docs/core/reaction/fetchData.yaml +44 -8
- package/public/rjbuild/docs/core/reaction/setData.md +18 -4
- package/public/rjbuild/docs/core/reaction/setData.yaml +18 -4
- 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 +2 -5
- package/public/rjbuild/docs/install.yaml +4 -10
- package/public/rjbuild/docs/{core → integration/bootstrap}/action/Popover.md +1 -1
- package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.md +1 -1
- package/public/rjbuild/docs/integration/bootstrap/element/html/AccordionItem.md +69 -0
- package/public/rjbuild/docs/integration/bootstrap/element/html/Modal.md +127 -0
- package/public/rjbuild/docs/integration/bootstrap/element/html/Tabs.md +150 -0
- package/public/rjbuild/docs/integration/bootstrap/element/html/index.md +13 -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 → integration/bootstrap}/action/Popover.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/action/Tooltip.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/CheckBoxField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/DateField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/NumberField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/SelectField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextAreaField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/TextField.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/formElementsCommon.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/form/index.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/AccordionItem.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Modal.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/html/Tabs.yaml +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/special/BootstrapElement.md +0 -0
- /package/public/rjbuild/docs/{core → integration/bootstrap}/element/special/BootstrapElement.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
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Native HTML Forms with Reactive-JSON
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
## Core Concept: Reactions for Data Synchronization
|
|
9
|
+
|
|
10
|
+
Native HTML elements require explicit **reactions** to synchronize user input with your data. This is done using the `setData` reaction triggered by user events.
|
|
11
|
+
|
|
12
|
+
- type: SyntaxHighlighter
|
|
13
|
+
language: yaml
|
|
14
|
+
title: "Basic Structure"
|
|
15
|
+
content: |
|
|
16
|
+
- type: input
|
|
17
|
+
attributes:
|
|
18
|
+
type: "text"
|
|
19
|
+
value: ~.fieldName # Display current data value
|
|
20
|
+
actions:
|
|
21
|
+
- what: setData # Reaction to update data
|
|
22
|
+
on: input # Event that triggers the reaction
|
|
23
|
+
path: ~.fieldName # Data path to update
|
|
24
|
+
value: "<reactive-json:event-new-value>" # Value from the event
|
|
25
|
+
|
|
26
|
+
- type: Markdown
|
|
27
|
+
content: |
|
|
28
|
+
## Event Value Patterns
|
|
29
|
+
|
|
30
|
+
### Forward Update Pattern (Recommended)
|
|
31
|
+
|
|
32
|
+
Use `<reactive-json:event-new-value>` for automatic value detection:
|
|
33
|
+
|
|
34
|
+
- **Auto-detects the correct property**: `event.target.value` for inputs, `event.target.checked` for checkboxes
|
|
35
|
+
- **Simplifies configuration**: No need to specify which property to access
|
|
36
|
+
- **Works for all form elements**: text, number, checkbox, select, textarea, etc.
|
|
37
|
+
|
|
38
|
+
### Alternative Explicit Syntax
|
|
39
|
+
|
|
40
|
+
For specific control, you can explicitly access event properties:
|
|
41
|
+
|
|
42
|
+
- `<reactive-json:event>.target.value` - Direct access to input value
|
|
43
|
+
- `<reactive-json:event>.target.checked` - Direct access to checkbox state
|
|
44
|
+
- `<reactive-json:event>.target.selectedIndex` - Access to select index
|
|
45
|
+
|
|
46
|
+
## Event Types for Different Use Cases
|
|
47
|
+
|
|
48
|
+
- **`on: input`** - Real-time updates as user types (immediate feedback)
|
|
49
|
+
- **`on: change`** - Updates when user commits the change (varies by element type):
|
|
50
|
+
- Text inputs: when value changes AND field loses focus
|
|
51
|
+
- Checkboxes/Radio: immediately when checked/unchecked
|
|
52
|
+
- Select: immediately when option is selected
|
|
53
|
+
- **`on: blur`** - Updates when user leaves the field (regardless of value change)
|
|
54
|
+
- **`on: focus`** - Triggered when user enters the field
|
|
55
|
+
|
|
56
|
+
- type: RjBuildDescriber
|
|
57
|
+
title: "Text Input Example"
|
|
58
|
+
description: |
|
|
59
|
+
Basic text input with real-time data synchronization using the setData reaction.
|
|
60
|
+
toDescribe:
|
|
61
|
+
renderView:
|
|
62
|
+
- type: label
|
|
63
|
+
content: "Name:"
|
|
64
|
+
- type: input
|
|
65
|
+
attributes:
|
|
66
|
+
type: "text"
|
|
67
|
+
value: ~.name
|
|
68
|
+
placeholder: "Enter your name"
|
|
69
|
+
actions:
|
|
70
|
+
- what: setData
|
|
71
|
+
on: input
|
|
72
|
+
path: ~.name
|
|
73
|
+
value: "<reactive-json:event-new-value>"
|
|
74
|
+
- type: div
|
|
75
|
+
content: ["Current value: ", ~.name]
|
|
76
|
+
data:
|
|
77
|
+
name: ""
|
|
78
|
+
|
|
79
|
+
- type: RjBuildDescriber
|
|
80
|
+
title: "Checkbox Example"
|
|
81
|
+
description: |
|
|
82
|
+
Checkbox with data synchronization using the change event for boolean values.
|
|
83
|
+
toDescribe:
|
|
84
|
+
renderView:
|
|
85
|
+
- type: label
|
|
86
|
+
content:
|
|
87
|
+
- type: input
|
|
88
|
+
attributes:
|
|
89
|
+
type: "checkbox"
|
|
90
|
+
checked: ~.isSelected
|
|
91
|
+
actions:
|
|
92
|
+
- what: setData
|
|
93
|
+
on: change
|
|
94
|
+
path: ~.isSelected
|
|
95
|
+
value: "<reactive-json:event-new-value>"
|
|
96
|
+
- " Accept terms and conditions"
|
|
97
|
+
- type: div
|
|
98
|
+
content:
|
|
99
|
+
- "Status: "
|
|
100
|
+
- type: LabelFromValue
|
|
101
|
+
dataLocation: ~.isSelected
|
|
102
|
+
options:
|
|
103
|
+
- label: "Accepté"
|
|
104
|
+
value: true
|
|
105
|
+
- label: "Non accepté"
|
|
106
|
+
value: false
|
|
107
|
+
data:
|
|
108
|
+
isSelected: false
|
|
109
|
+
|
|
110
|
+
- type: RjBuildDescriber
|
|
111
|
+
title: "Select Dropdown Example"
|
|
112
|
+
description: |
|
|
113
|
+
Select dropdown with options and change event handling.
|
|
114
|
+
toDescribe:
|
|
115
|
+
renderView:
|
|
116
|
+
- type: label
|
|
117
|
+
content: "Choose option:"
|
|
118
|
+
- type: select
|
|
119
|
+
attributes:
|
|
120
|
+
value: ~.selectedOption
|
|
121
|
+
content:
|
|
122
|
+
- type: option
|
|
123
|
+
attributes:
|
|
124
|
+
value: ""
|
|
125
|
+
content: "Select an option..."
|
|
126
|
+
- type: option
|
|
127
|
+
attributes:
|
|
128
|
+
value: "option1"
|
|
129
|
+
content: "Option 1"
|
|
130
|
+
- type: option
|
|
131
|
+
attributes:
|
|
132
|
+
value: "option2"
|
|
133
|
+
content: "Option 2"
|
|
134
|
+
- type: option
|
|
135
|
+
attributes:
|
|
136
|
+
value: "option3"
|
|
137
|
+
content: "Option 3"
|
|
138
|
+
actions:
|
|
139
|
+
- what: setData
|
|
140
|
+
on: change
|
|
141
|
+
path: ~.selectedOption
|
|
142
|
+
value: "<reactive-json:event-new-value>"
|
|
143
|
+
- type: div
|
|
144
|
+
content: ["Selected: ", ~.selectedOption]
|
|
145
|
+
data:
|
|
146
|
+
selectedOption: ""
|
|
147
|
+
|
|
148
|
+
- type: RjBuildDescriber
|
|
149
|
+
title: "Textarea Example"
|
|
150
|
+
description: |
|
|
151
|
+
Multi-line text input with real-time updates.
|
|
152
|
+
toDescribe:
|
|
153
|
+
renderView:
|
|
154
|
+
- type: label
|
|
155
|
+
content: "Description:"
|
|
156
|
+
- type: textarea
|
|
157
|
+
attributes:
|
|
158
|
+
value: ~.description
|
|
159
|
+
placeholder: "Enter description..."
|
|
160
|
+
rows: 4
|
|
161
|
+
actions:
|
|
162
|
+
- what: setData
|
|
163
|
+
on: input
|
|
164
|
+
path: ~.description
|
|
165
|
+
value: "<reactive-json:event-new-value>"
|
|
166
|
+
- type: div
|
|
167
|
+
content: ["Current text: ", ~.description]
|
|
168
|
+
data:
|
|
169
|
+
description: ""
|
|
170
|
+
|
|
171
|
+
- type: RjBuildDescriber
|
|
172
|
+
title: "Range Input Example"
|
|
173
|
+
description: |
|
|
174
|
+
Range input with min/max constraints and validation.
|
|
175
|
+
toDescribe:
|
|
176
|
+
renderView:
|
|
177
|
+
- type: label
|
|
178
|
+
content: "Quantity (0-100):"
|
|
179
|
+
- type: input
|
|
180
|
+
attributes:
|
|
181
|
+
type: "range"
|
|
182
|
+
value: ~.quantity
|
|
183
|
+
min: 0
|
|
184
|
+
max: 100
|
|
185
|
+
actions:
|
|
186
|
+
- what: setData
|
|
187
|
+
on: input
|
|
188
|
+
path: ~.quantity
|
|
189
|
+
value: "<reactive-json:event-new-value>"
|
|
190
|
+
- type: div
|
|
191
|
+
content: ["Current quantity: ", ~.quantity]
|
|
192
|
+
data:
|
|
193
|
+
quantity: "20"
|
|
194
|
+
|
|
195
|
+
- type: RjBuildDescriber
|
|
196
|
+
title: "Radio Buttons Example"
|
|
197
|
+
description: |
|
|
198
|
+
Radio button group with exclusive selection.
|
|
199
|
+
toDescribe:
|
|
200
|
+
renderView:
|
|
201
|
+
- type: VariablesDebug
|
|
202
|
+
- type: div
|
|
203
|
+
content: "Choose size:"
|
|
204
|
+
- type: label
|
|
205
|
+
content:
|
|
206
|
+
- type: input
|
|
207
|
+
attributes:
|
|
208
|
+
type: "radio"
|
|
209
|
+
name: "size"
|
|
210
|
+
value: "small"
|
|
211
|
+
checked: ~.sizeState.small
|
|
212
|
+
actions:
|
|
213
|
+
- what: SetAttributeValue
|
|
214
|
+
name: checked
|
|
215
|
+
value: "checked"
|
|
216
|
+
when: ~.selectedSize
|
|
217
|
+
is: "small"
|
|
218
|
+
- what: setData
|
|
219
|
+
on: change
|
|
220
|
+
path: ~.selectedSize
|
|
221
|
+
value: "small"
|
|
222
|
+
- what: setData
|
|
223
|
+
on: change
|
|
224
|
+
path: ~.sizeState.small
|
|
225
|
+
value: true
|
|
226
|
+
- what: setData
|
|
227
|
+
on: change
|
|
228
|
+
path: ~.sizeState.medium
|
|
229
|
+
value: false
|
|
230
|
+
- what: setData
|
|
231
|
+
on: change
|
|
232
|
+
path: ~.sizeState.large
|
|
233
|
+
value: false
|
|
234
|
+
- " Small"
|
|
235
|
+
- type: label
|
|
236
|
+
content:
|
|
237
|
+
- type: input
|
|
238
|
+
attributes:
|
|
239
|
+
type: "radio"
|
|
240
|
+
name: "size"
|
|
241
|
+
value: "medium"
|
|
242
|
+
checked: ~.sizeState.medium
|
|
243
|
+
actions:
|
|
244
|
+
- what: SetAttributeValue
|
|
245
|
+
name: checked
|
|
246
|
+
value: "checked"
|
|
247
|
+
when: ~.selectedSize
|
|
248
|
+
is: "medium"
|
|
249
|
+
- what: setData
|
|
250
|
+
on: change
|
|
251
|
+
path: ~.selectedSize
|
|
252
|
+
value: "medium"
|
|
253
|
+
- what: setData
|
|
254
|
+
on: change
|
|
255
|
+
path: ~.sizeState.small
|
|
256
|
+
value: false
|
|
257
|
+
- what: setData
|
|
258
|
+
on: change
|
|
259
|
+
path: ~.sizeState.medium
|
|
260
|
+
value: true
|
|
261
|
+
- what: setData
|
|
262
|
+
on: change
|
|
263
|
+
path: ~.sizeState.large
|
|
264
|
+
value: false
|
|
265
|
+
- " Medium"
|
|
266
|
+
- type: label
|
|
267
|
+
content:
|
|
268
|
+
- type: input
|
|
269
|
+
attributes:
|
|
270
|
+
type: "radio"
|
|
271
|
+
name: "size"
|
|
272
|
+
value: "large"
|
|
273
|
+
checked: ~.sizeState.large
|
|
274
|
+
actions:
|
|
275
|
+
- what: SetAttributeValue
|
|
276
|
+
name: checked
|
|
277
|
+
value: "checked"
|
|
278
|
+
when: ~.selectedSize
|
|
279
|
+
is: "large"
|
|
280
|
+
- what: setData
|
|
281
|
+
on: change
|
|
282
|
+
path: ~.selectedSize
|
|
283
|
+
value: "large"
|
|
284
|
+
- what: setData
|
|
285
|
+
on: change
|
|
286
|
+
path: ~.sizeState.small
|
|
287
|
+
value: false
|
|
288
|
+
- what: setData
|
|
289
|
+
on: change
|
|
290
|
+
path: ~.sizeState.medium
|
|
291
|
+
value: false
|
|
292
|
+
- what: setData
|
|
293
|
+
on: change
|
|
294
|
+
path: ~.sizeState.large
|
|
295
|
+
value: true
|
|
296
|
+
- " Large"
|
|
297
|
+
- type: div
|
|
298
|
+
content: ["Selected size: ", ~.selectedSize]
|
|
299
|
+
data:
|
|
300
|
+
selectedSize: "medium"
|
|
301
|
+
sizeState:
|
|
302
|
+
small: false
|
|
303
|
+
medium: true
|
|
304
|
+
large: false
|
|
305
|
+
|
|
306
|
+
- type: Markdown
|
|
307
|
+
content: |
|
|
308
|
+
## Advanced Patterns
|
|
309
|
+
|
|
310
|
+
- type: SyntaxHighlighter
|
|
311
|
+
language: yaml
|
|
312
|
+
title: "Form Validation with Conditional Actions"
|
|
313
|
+
content: |
|
|
314
|
+
- type: input
|
|
315
|
+
attributes:
|
|
316
|
+
type: "email"
|
|
317
|
+
value: ~.email
|
|
318
|
+
actions:
|
|
319
|
+
- what: setData
|
|
320
|
+
on: input
|
|
321
|
+
path: ~.email
|
|
322
|
+
value: "<reactive-json:event-new-value>"
|
|
323
|
+
- what: setData
|
|
324
|
+
on: blur
|
|
325
|
+
path: ~.emailValid
|
|
326
|
+
value: "<reactive-json:event>.target.validity.valid"
|
|
327
|
+
|
|
328
|
+
- type: SyntaxHighlighter
|
|
329
|
+
language: yaml
|
|
330
|
+
title: "Multiple Field Updates"
|
|
331
|
+
content: |
|
|
332
|
+
- type: input
|
|
333
|
+
attributes:
|
|
334
|
+
type: "text"
|
|
335
|
+
value: ~.firstName
|
|
336
|
+
actions:
|
|
337
|
+
- what: setData
|
|
338
|
+
on: input
|
|
339
|
+
path: ~.firstName
|
|
340
|
+
value: "<reactive-json:event-new-value>"
|
|
341
|
+
- what: setData
|
|
342
|
+
on: input
|
|
343
|
+
path: ~.fullName
|
|
344
|
+
value: ["<reactive-json:event-new-value>", " ", ~.lastName]
|
|
345
|
+
|
|
346
|
+
- type: Markdown
|
|
347
|
+
content: |
|
|
348
|
+
## Simplification Alternatives
|
|
349
|
+
|
|
350
|
+
For simpler configuration and built-in styling, consider using pre-built form components:
|
|
351
|
+
|
|
352
|
+
- **Reactive-JSON Bootstrap**: `TextField`, `SelectField`, `CheckBoxField`, etc. with automatic data synchronization
|
|
353
|
+
- **Custom component libraries**: Create your own reusable form components with embedded reactions
|
|
354
|
+
|
|
355
|
+
- type: SyntaxHighlighter
|
|
356
|
+
language: yaml
|
|
357
|
+
title: "Comparison: Bootstrap vs Native"
|
|
358
|
+
content: |
|
|
359
|
+
# Simpler alternative using reactive-json-bootstrap
|
|
360
|
+
- type: TextField
|
|
361
|
+
label: "Username:"
|
|
362
|
+
dataLocation: ~.username # Automatic synchronization
|
|
363
|
+
|
|
364
|
+
# Equivalent native implementation
|
|
365
|
+
- type: label
|
|
366
|
+
content: "Username:"
|
|
367
|
+
- type: input
|
|
368
|
+
attributes:
|
|
369
|
+
type: "text"
|
|
370
|
+
value: ~.username
|
|
371
|
+
actions:
|
|
372
|
+
- what: setData
|
|
373
|
+
on: input
|
|
374
|
+
path: ~.username
|
|
375
|
+
value: "<reactive-json:event-new-value>"
|
|
376
|
+
|
|
377
|
+
- type: Markdown
|
|
378
|
+
content: |
|
|
379
|
+
## Best Practices
|
|
380
|
+
|
|
381
|
+
1. **Always include `setData` reactions** for interactive elements
|
|
382
|
+
2. **Choose appropriate events**: `input` for real-time updates, `change` for committed changes
|
|
383
|
+
3. **Use `<reactive-json:event-new-value>`** for automatic value detection
|
|
384
|
+
4. **Consider pre-built components** for complex forms to reduce configuration
|
|
385
|
+
5. **Test data flow** to ensure changes are properly synchronized
|
|
386
|
+
|
|
387
|
+
## Key Takeaways
|
|
388
|
+
|
|
389
|
+
- Native HTML elements provide full control but require explicit reactions
|
|
390
|
+
- The `setData` reaction is essential for data synchronization
|
|
391
|
+
- Use `<reactive-json:event-new-value>` for automatic value detection
|
|
392
|
+
- Different events (`input`, `change`, `blur`) serve different use cases
|
|
393
|
+
- Pre-built components can simplify complex forms while maintaining flexibility
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Hooks
|
|
2
|
+
|
|
3
|
+
> **Developer-Focused Section**: This documentation is primarily intended for developers who want to understand the internal hook system and extend Reactive-JSON with custom functionality.
|
|
4
|
+
|
|
5
|
+
Hooks in Reactive-JSON are reusable React functions that encapsulate common component logic. They follow React hook conventions and provide code factorization for complex functionalities.
|
|
6
|
+
|
|
7
|
+
## Available Hook Components
|
|
8
|
+
|
|
9
|
+
### Pagination
|
|
10
|
+
- **[usePagination](./usePagination.md)**: Creates customizable pagination systems with configurable components
|
|
11
|
+
|
|
12
|
+
### Attribute Processing
|
|
13
|
+
- **[useTransformedAttributes](./useTransformedAttributes.md)**: Applies attribute transformations based on configured transformers
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
Reactive-JSON hooks follow these core principles:
|
|
18
|
+
|
|
19
|
+
- **Context Integration**: Access to `GlobalDataContext` and `TemplateContext`
|
|
20
|
+
- **Reusability**: Extracted business logic for reuse across components
|
|
21
|
+
- **Customization**: Support for custom components and configurations
|
|
22
|
+
- **Performance**: Built-in optimizations to avoid unnecessary re-calculations
|
|
23
|
+
|
|
24
|
+
## Plugin Integration
|
|
25
|
+
|
|
26
|
+
Hooks can be integrated into the Reactive-JSON plugin system. This is actually how the core hooks (`usePagination`, `useTransformedAttributes`) are made available to the system - they are registered through the plugin architecture.
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const customPlugins = {
|
|
30
|
+
hook: {
|
|
31
|
+
usePagination,
|
|
32
|
+
useTransformedAttributes,
|
|
33
|
+
// Your custom hooks
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The core Reactive-JSON library uses this same mechanism internally to provide its built-in hooks, ensuring consistency between core functionality and custom extensions.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Hooks
|
|
5
|
+
|
|
6
|
+
> **Developer-Focused Section**: This documentation is primarily intended for developers who want to understand the internal hook system and extend Reactive-JSON with custom functionality.
|
|
7
|
+
|
|
8
|
+
Hooks in Reactive-JSON are reusable React functions that encapsulate common component logic. They follow React hook conventions and provide code factorization for complex functionalities.
|
|
9
|
+
|
|
10
|
+
## Available Hook Components
|
|
11
|
+
|
|
12
|
+
### Pagination
|
|
13
|
+
- **[usePagination](./usePagination)**: Creates customizable pagination systems with configurable components
|
|
14
|
+
|
|
15
|
+
### Attribute Processing
|
|
16
|
+
- **[useTransformedAttributes](./useTransformedAttributes)**: Applies attribute transformations based on configured transformers
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
Reactive-JSON hooks follow these core principles:
|
|
21
|
+
|
|
22
|
+
- **Context Integration**: Access to `GlobalDataContext` and `TemplateContext`
|
|
23
|
+
- **Reusability**: Extracted business logic for reuse across components
|
|
24
|
+
- **Customization**: Support for custom components and configurations
|
|
25
|
+
- **Performance**: Built-in optimizations to avoid unnecessary re-calculations
|
|
26
|
+
|
|
27
|
+
## Plugin Integration
|
|
28
|
+
|
|
29
|
+
Hooks can be integrated into the Reactive-JSON plugin system. This is actually how the core hooks (`usePagination`, `useTransformedAttributes`) are made available to the system - they are registered through the plugin architecture.
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const customPlugins = {
|
|
33
|
+
hook: {
|
|
34
|
+
usePagination,
|
|
35
|
+
useTransformedAttributes,
|
|
36
|
+
// Your custom hooks
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The core Reactive-JSON library uses this same mechanism internally to provide its built-in hooks, ensuring consistency between core functionality and custom extensions.
|
|
42
|
+
|
|
43
|
+
templates: {}
|
|
44
|
+
data: {}
|