@ea-lab/reactive-json-docs 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +2 -2
  2. package/public/rjbuild/docs/advanced-concepts/data-mapping.md +76 -0
  3. package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +140 -0
  4. package/public/rjbuild/docs/advanced-concepts/data-processors.md +373 -0
  5. package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +309 -0
  6. package/public/rjbuild/docs/advanced-concepts/index.md +10 -0
  7. package/public/rjbuild/docs/advanced-concepts/index.yaml +16 -0
  8. package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development-guide-llm.md +2 -0
  9. package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.md +1 -1
  10. package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.yaml +1 -1
  11. package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.md +2 -0
  12. package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.yaml +2 -0
  13. package/public/rjbuild/docs/core/action/Hide.md +1 -1
  14. package/public/rjbuild/docs/core/action/Hide.yaml +10 -10
  15. package/public/rjbuild/docs/core/action/ReactOnEvent.md +12 -12
  16. package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +61 -101
  17. package/public/rjbuild/docs/core/action/Redirect.md +10 -2
  18. package/public/rjbuild/docs/core/action/Redirect.yaml +18 -51
  19. package/public/rjbuild/docs/core/action/VisuallyHide.yaml +10 -12
  20. package/public/rjbuild/docs/core/action/index.md +19 -204
  21. package/public/rjbuild/docs/core/action/index.yaml +19 -264
  22. package/public/rjbuild/docs/core/dataMapping/index.md +31 -0
  23. package/public/rjbuild/docs/core/dataMapping/index.yaml +24 -0
  24. package/public/rjbuild/docs/core/dataMapping/simpleMapping.md +131 -0
  25. package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +376 -0
  26. package/public/rjbuild/docs/core/element/form/DateField.md +1 -1
  27. package/public/rjbuild/docs/core/element/form/DateField.yaml +4 -4
  28. package/public/rjbuild/docs/core/element/form/SelectField.yaml +2 -2
  29. package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.md +4 -3
  30. package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +114 -6
  31. package/public/rjbuild/docs/core/example/website.yaml +10 -10
  32. package/public/rjbuild/docs/core/reaction/index.md +17 -229
  33. package/public/rjbuild/docs/core/reaction/index.yaml +14 -242
  34. package/public/rjbuild/docs/core/reaction/setData.md +1 -1
  35. package/public/rjbuild/docs/core/reaction/setData.yaml +1 -1
  36. package/public/rjbuild/docs/docs-components/index.md +0 -2
  37. package/public/rjbuild/docs/docs-components/index.yaml +0 -2
  38. package/public/rjbuild/docs/getting-started/actions.md +294 -0
  39. package/public/rjbuild/docs/getting-started/actions.yaml +403 -0
  40. package/public/rjbuild/docs/{getting-started.md → getting-started/index.md} +30 -6
  41. package/public/rjbuild/docs/{getting-started.yaml → getting-started/index.yaml} +22 -6
  42. package/public/rjbuild/docs/getting-started/reactions.md +301 -0
  43. package/public/rjbuild/docs/getting-started/reactions.yaml +300 -0
  44. package/public/rjbuild/docs/getting-started/rjbuild-structure.md +358 -0
  45. package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +421 -0
  46. package/public/rjbuild/docs/{template.md → getting-started/template-contexts-data-binding.md} +16 -12
  47. package/public/rjbuild/docs/{template.yaml → getting-started/template-contexts-data-binding.yaml} +28 -14
  48. package/public/rjbuild/docs/install.yaml +682 -681
  49. /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.md +0 -0
  50. /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.yaml +0 -0
  51. /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.md +0 -0
  52. /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.yaml +0 -0
@@ -0,0 +1,421 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # RjBuild File Structure
5
+
6
+ ## What is an RjBuild?
7
+
8
+ An **RjBuild** is the standard file format used by Reactive-JSON to build interactive web applications. It is a JSON or YAML structure that completely describes a user interface, its data, and behavior, without requiring traditional JavaScript code.
9
+
10
+ > By extension, we also call "RjBuild" any fragment of this structure, particularly a portion of `renderView` and `templates` that can be reused or included in other RjBuilds.
11
+
12
+ ### Supported Formats
13
+
14
+ An RjBuild can be written in two formats:
15
+
16
+ - **YAML** (recommended): More readable and easier to write for humans, ideal for creation and maintenance
17
+ - **JSON**: Standard supported format, useful for programmatic generation or integration with existing tools
18
+
19
+ **YAML is preferable** for most use cases as it offers better readability, allows comments, and is more tolerant of minor syntax errors.
20
+
21
+ ## Basic Structure of an RjBuild
22
+
23
+ Any RjBuild file can contain up to four main sections:
24
+
25
+ - `renderView`: User interface structure (required)
26
+ - `templates`: Reusable components (optional)
27
+ - `data`: Initial state and data (optional)
28
+ - `additionalDataSource`: External data sources (optional)
29
+
30
+ - type: TabbedSerializer
31
+ yamlSerializedContent: |
32
+ renderView: # User interface structure (required)
33
+ - type: div
34
+ content: "Hello World"
35
+
36
+ templates: # Reusable components (optional)
37
+ myComponent:
38
+ type: div
39
+ content: "Template content"
40
+
41
+ data: # Initial state and data (optional)
42
+ message: "Welcome!"
43
+ user:
44
+ name: "John"
45
+
46
+ additionalDataSource: # External data sources (optional)
47
+ - src: "/api/data.json"
48
+ path: ~~.dynamicData
49
+
50
+ - type: Markdown
51
+ content: |
52
+
53
+ ## Section `renderView` (Required)
54
+
55
+ The `renderView` section defines the **user interface** that will be displayed. It is the only required section of an RjBuild.
56
+
57
+ ### Role
58
+ - Determines the visual structure of the application
59
+ - Defines the components to display and their organization
60
+ - Specifies interactions and behaviors
61
+
62
+ ### Structure
63
+
64
+ - type: TabbedSerializer
65
+ yamlSerializedContent: |
66
+ renderView:
67
+ - type: ComponentName # Type of component to render
68
+ content: "Content" # Component content
69
+ attributes: # HTML attributes (optional)
70
+ class: "css-class"
71
+ actions: # Interactive actions (optional)
72
+ - what: hide
73
+ on: click
74
+
75
+ - type: Markdown
76
+ content: |
77
+
78
+ ### Examples
79
+
80
+ #### Simple interface
81
+
82
+ - type: TabbedSerializer
83
+ yamlSerializedContent: |
84
+ renderView:
85
+ - type: div
86
+ content:
87
+ - type: h1
88
+ content: "My Application"
89
+ - type: p
90
+ content: "Welcome!"
91
+
92
+ - type: Markdown
93
+ content: |
94
+
95
+ #### With dynamic data
96
+
97
+ - type: TabbedSerializer
98
+ yamlSerializedContent: |
99
+ renderView:
100
+ - type: div
101
+ content: ["Hello ", ~~.user.name, "!"]
102
+
103
+ data:
104
+ user:
105
+ name: "Marie"
106
+
107
+ - type: Markdown
108
+ content: |
109
+
110
+ ## Section `data` (Optional)
111
+
112
+ The `data` section contains the **initial state** of the application. This data can be read and modified by components.
113
+
114
+ ### Role
115
+ - Provides the initial state of the application
116
+ - Stores data modifiable by user interactions
117
+ - Enables data sharing between components
118
+
119
+ ### Structure
120
+
121
+ - type: TabbedSerializer
122
+ yamlSerializedContent: |
123
+ data:
124
+ # Simple data
125
+ title: "My Site"
126
+ isLoggedIn: false
127
+
128
+ # Objects
129
+ user:
130
+ name: "John"
131
+ email: "john@example.com"
132
+
133
+ # Arrays
134
+ items:
135
+ - name: "Item 1"
136
+ active: true
137
+ - name: "Item 2"
138
+ active: false
139
+
140
+ - type: Markdown
141
+ content: |
142
+ ### Data Access
143
+
144
+ To use data in a component, you can use the following syntax:
145
+
146
+ - **`~~.`**: Global access to data from anywhere in the RjBuild
147
+ - **`~.`**: Local access to data from the current context (template)
148
+
149
+ ### Usage Examples
150
+
151
+ #### Forms with state
152
+
153
+ - type: TabbedSerializer
154
+ yamlSerializedContent: |
155
+ renderView:
156
+ - type: TextField
157
+ label: "Name"
158
+ dataLocation: ~~.user.name
159
+ - type: div
160
+ content: ["Entered name: ", ~~.user.name]
161
+
162
+ data:
163
+ user:
164
+ name: "Initial value"
165
+
166
+ - type: Markdown
167
+ content: |
168
+
169
+ #### Conditional display
170
+
171
+ - type: TabbedSerializer
172
+ yamlSerializedContent: |
173
+ renderView:
174
+ - type: div
175
+ content: "User is logged in!"
176
+ actions:
177
+ - what: hide
178
+ when: ~~.isLoggedIn
179
+ is: false
180
+
181
+ data:
182
+ isLoggedIn: true
183
+
184
+ - type: Markdown
185
+ content: |
186
+ > You can get more information about data access in the [template system documentation](/docs/getting-started/template-contexts-data-binding).
187
+
188
+ ## Section `templates` (Optional)
189
+
190
+ The `templates` section defines **reusable components** that can be used in `renderView` or other templates.
191
+
192
+ ### Role
193
+ - Avoids code duplication
194
+ - Enables reuse of complex structures
195
+ - Facilitates maintenance and modifications
196
+
197
+ ### Structure
198
+
199
+ - type: TabbedSerializer
200
+ yamlSerializedContent: |
201
+ templates:
202
+ templateName: # Template name
203
+ type: ComponentName # Template structure
204
+ content: "Content"
205
+
206
+ multipleComponents: # Template with multiple components
207
+ - type: div
208
+ content: "Component 1"
209
+ - type: p
210
+ content: "Component 2"
211
+
212
+ - type: Markdown
213
+ content: |
214
+
215
+ ### Using templates
216
+
217
+ - type: TabbedSerializer
218
+ yamlSerializedContent: |
219
+ renderView:
220
+ - load: templateName # Loads and displays the template
221
+
222
+ templates:
223
+ templateName:
224
+ type: div
225
+ content: "I am a reusable template!"
226
+
227
+ - type: Markdown
228
+ content: |
229
+
230
+ ### Data Context
231
+ Templates create their own **data context** when used with components like `Switch`:
232
+
233
+ - type: TabbedSerializer
234
+ yamlSerializedContent: |
235
+ renderView:
236
+ - type: Switch
237
+ content: ~~.users # Iterates over each user
238
+ singleOption:
239
+ load: userCard # Each user uses the template
240
+
241
+ templates:
242
+ userCard:
243
+ type: div
244
+ content:
245
+ - "Name: "
246
+ - ~.name # Local access to current user's name
247
+ - " (Admin: "
248
+ - ~~.isAdmin # Global access to settings
249
+
250
+ data:
251
+ isAdmin: true
252
+ users:
253
+ - name: "Alice"
254
+ - name: "Bob"
255
+
256
+ - type: Markdown
257
+ content: |
258
+
259
+ ## Section `additionalDataSource` (Optional)
260
+
261
+ The `additionalDataSource` section allows **loading data from external sources** during application initialization.
262
+
263
+ ### Role
264
+ - Integrates dynamic data from APIs
265
+ - Enables asynchronous data loading
266
+ - Separates static data from dynamic data
267
+
268
+ ### Structure
269
+
270
+ - type: TabbedSerializer
271
+ yamlSerializedContent: |
272
+ additionalDataSource:
273
+ - src: "/api/endpoint" # Source URL (required)
274
+ path: ~~.targetPath # Where to place the data (optional)
275
+ method: GET # HTTP method (optional, default: GET)
276
+ blocking: true # Block rendering (optional, default: false)
277
+
278
+ - type: Markdown
279
+ content: |
280
+
281
+ ### Properties
282
+ - **`src`** (required): URL of the data source
283
+ - **`path`** (optional): Path where to place the data (template syntax)
284
+ - **`method`** (optional): HTTP method (GET, POST, etc.)
285
+ - **`dataMapping`** (optional): Configure selective data dispatch using mapping processors
286
+ - **`blocking`** (optional): If `true`, waits for loading before displaying
287
+
288
+ ### Loading Modes
289
+
290
+ #### Blocking loading
291
+
292
+ - type: TabbedSerializer
293
+ yamlSerializedContent: |
294
+ additionalDataSource:
295
+ - src: "/api/user-profile.json"
296
+ path: ~~.currentUser
297
+ blocking: true # Page waits for loading
298
+
299
+ - type: Markdown
300
+ content: |
301
+
302
+ #### Non-blocking loading
303
+
304
+ - type: TabbedSerializer
305
+ yamlSerializedContent: |
306
+ additionalDataSource:
307
+ - src: "/api/notifications.json"
308
+ path: ~~.notifications
309
+ blocking: false # Page displays immediately
310
+
311
+ - type: Markdown
312
+ content: |
313
+
314
+ ### Data Placement
315
+
316
+ #### With specific path
317
+
318
+ - type: TabbedSerializer
319
+ yamlSerializedContent: |
320
+ additionalDataSource:
321
+ - src: "/api/user.json"
322
+ path: ~~.currentUser
323
+
324
+ # Data will be placed in data.currentUser
325
+
326
+ - type: Markdown
327
+ content: |
328
+
329
+ #### Root-level merge
330
+
331
+ - type: TabbedSerializer
332
+ yamlSerializedContent: |
333
+ additionalDataSource:
334
+ - src: "/api/config.json"
335
+ # No path = direct merge into data
336
+
337
+ - type: Markdown
338
+ content: |
339
+
340
+ ### Data Mapping Integration
341
+
342
+ Data Mapping can be used with `additionalDataSource` to selectively dispatch response data to specific locations:
343
+
344
+ - type: TabbedSerializer
345
+ yamlSerializedContent: |
346
+ additionalDataSource:
347
+ - src: "/api/user-profile"
348
+ blocking: true
349
+ dataMapping:
350
+ simpleMapping:
351
+ stringMap:
352
+ "profile.displayName": { value: "user.name" }
353
+ "profile.email": { value: "user.email" }
354
+ "settings.theme":
355
+ value: "user.preferences.theme"
356
+ required: false
357
+ defaultValue: "light"
358
+
359
+ - type: Markdown
360
+ content: |
361
+
362
+ **Note**: When `dataMapping` is configured, it takes priority over the `path` property. For more details, see [Data Mapping Documentation](../advanced-concepts/data-mapping).
363
+
364
+ ### Complete Example
365
+
366
+ - type: TabbedSerializer
367
+ yamlSerializedContent: |
368
+ renderView:
369
+ - type: div
370
+ content:
371
+ - type: h1
372
+ content: ["Hello ", ~~.currentUser.name]
373
+ - type: p
374
+ content: ["Version: ", ~~.systemConfig.version]
375
+
376
+ data:
377
+ currentUser:
378
+ name: "Loading..." # Temporary value
379
+ systemConfig:
380
+ version: "Loading..."
381
+
382
+ additionalDataSource:
383
+ # Critical user data (blocking)
384
+ - src: "/api/user-profile.json"
385
+ path: ~~.currentUser
386
+ blocking: true
387
+
388
+ # System configuration (non-blocking)
389
+ - src: "/api/system-config.json"
390
+ path: ~~.systemConfig
391
+ blocking: false
392
+
393
+ - type: Markdown
394
+ content: |
395
+
396
+ ## Best Practices
397
+
398
+ ### Organization
399
+ 1. **Logical structure**: Organize your data by functional domain
400
+ 2. **Reusable templates**: Create templates to avoid duplication
401
+ 3. **Default values**: Provide temporary values for external data
402
+
403
+ ### Performance
404
+ 1. **Smart loading**: Use `blocking: true` only for critical data
405
+ 2. **Minimal data**: Load only necessary data
406
+ 3. **Optimized templates**: Avoid overly complex templates
407
+
408
+ ### Maintainability
409
+ 1. **Consistent naming**: Use clear conventions for templates and data.
410
+ 2. **Documentation**: Comment complex sections.
411
+ 3. **Validation**: Verify the structure of your external data.
412
+
413
+ ## Next Steps
414
+
415
+ Now that you understand the structure of RjBuilds, learn about the **[Template System](./template-contexts-data-binding)** to master data binding and create reusable components.
416
+
417
+ The template system is crucial for building maintainable and dynamic applications with Reactive-JSON.
418
+
419
+ templates:
420
+
421
+ data:
@@ -1,6 +1,4 @@
1
- # Template and Context System
2
-
3
- ## Introduction
1
+ # Template, Contexts, and Data Binding
4
2
 
5
3
  The template system in reactive-json efficiently manages data contexts and their access. Understanding how templates "containerize" data is essential for properly using components, actions, and reactions.
6
4
 
@@ -110,10 +108,10 @@ data:
110
108
  title: "User List"
111
109
  config:
112
110
  theme: "light"
113
- level1:
114
- items:
115
- - name: "Item 1"
116
- # userList template instances run here at: data.config.userSection.level1.items
111
+ level1:
112
+ items:
113
+ - name: "Item 1"
114
+ # userList template instances run here at: data.config.userSection.config.level1.items
117
115
 
118
116
  templates:
119
117
  userList:
@@ -130,7 +128,7 @@ templates:
130
128
 
131
129
  renderView:
132
130
  - type: Switch
133
- content: ~~.config.userSection.level1.items
131
+ content: ~~.config.userSection.config.level1.items
134
132
  singleOption:
135
133
  load: userList
136
134
  ```
@@ -183,7 +181,13 @@ data:
183
181
 
184
182
  ## Best Practices
185
183
 
186
- 1. **Context Coherence**: Ensure components that need to share data are in the same context
187
- 2. **Global Access**: Use `~~.` for data that needs to be shared between different templates
188
- 3. **Hierarchical Navigation**: Use `~>key` to find nearest occurrence or `~~>key` to find global setting
189
- 4. **Local vs Global**: `~>` prioritizes local overrides, `~~>` prioritizes global settings
184
+ 1. **Context Coherence**: Ensure components that need to share data are in the same context.
185
+ 2. **Global Access**: Use `~~.` for data that needs to be shared between different templates.
186
+ 3. **Hierarchical Navigation**: Use `~>key` to find nearest occurrence or `~~>key` to find global setting.
187
+ 4. **Local vs Global**: `~>` prioritizes local overrides, `~~>` prioritizes global settings.
188
+
189
+ ## Next Steps
190
+
191
+ Now that you understand the template system and data binding, learn about **[Actions](./actions.md)** to make your interfaces interactive and responsive to data changes.
192
+
193
+ Actions will allow you to hide, show, and manipulate elements based on the current application state.
@@ -1,14 +1,12 @@
1
1
  renderView:
2
2
  - type: Markdown
3
3
  content: |
4
- # Template and Context System
5
-
6
- ## Introduction
4
+ # Template, Contexts, and Data Binding
7
5
 
8
6
  The template system in reactive-json efficiently manages data contexts and their access. Understanding how templates "containerize" data is essential for properly using components, actions, and reactions.
9
7
 
10
- - type: Markdown
11
- content: |
8
+ ## Context Notations
9
+
12
10
  There are four main notations for accessing data:
13
11
 
14
12
  - `~.` : Local context (relative to current template)
@@ -19,7 +17,9 @@ renderView:
19
17
  Each notation is explained with examples below.
20
18
 
21
19
  - type: RjBuildDescriber
22
- title: "Local Context (`~.`)"
20
+ title:
21
+ type: Markdown
22
+ content: "Local Context: `~.`"
23
23
  description:
24
24
  - type: Markdown
25
25
  content: |
@@ -34,7 +34,9 @@ renderView:
34
34
  username: "John"
35
35
 
36
36
  - type: RjBuildDescriber
37
- title: "Global Context (`~~.`)"
37
+ title:
38
+ type: Markdown
39
+ content: "Global Context: `~~.`"
38
40
  description:
39
41
  - type: Markdown
40
42
  content: |
@@ -61,7 +63,9 @@ renderView:
61
63
  isAdmin: true
62
64
 
63
65
  - type: RjBuildDescriber
64
- title: "Nearest Key (`~>key`)"
66
+ title:
67
+ type: Markdown
68
+ content: "Nearest Key: `~>key`"
65
69
  description:
66
70
  - type: Markdown
67
71
  content: |
@@ -89,7 +93,9 @@ renderView:
89
93
  - name: "Item 1" # themeDisplay template runs here
90
94
 
91
95
  - type: RjBuildDescriber
92
- title: "Top-level Key (`~~>key`)"
96
+ title:
97
+ type: Markdown
98
+ content: "Top-level Key: `~~>key`"
93
99
  description:
94
100
  - type: Markdown
95
101
  content: |
@@ -193,10 +199,10 @@ renderView:
193
199
  title: "User List"
194
200
  config:
195
201
  theme: "light"
196
- level1:
197
- items:
198
- - name: "Item 1"
199
- # userList template instances run here at: data.config.userSection.level1.items
202
+ level1:
203
+ items:
204
+ - name: "Item 1"
205
+ # userList template instances run here at: data.config.userSection.config.level1.items
200
206
 
201
207
  templates:
202
208
  userList:
@@ -213,10 +219,18 @@ renderView:
213
219
 
214
220
  renderView:
215
221
  - type: Switch
216
- content: ~~.config.userSection.level1.items
222
+ content: ~~.config.userSection.config.level1.items
217
223
  singleOption:
218
224
  load: userList
219
225
 
226
+ - type: Markdown
227
+ content: |
228
+ ## Next Steps
229
+
230
+ Now that you understand the template system and data binding, learn about **[Actions](./actions)** to make your interfaces interactive and responsive to data changes.
231
+
232
+ Actions will allow you to hide, show, and manipulate elements based on the current application state.
233
+
220
234
  templates:
221
235
 
222
236
  data: {}