@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,358 @@
1
+ # RjBuild File Structure
2
+
3
+ ## What is an RjBuild?
4
+
5
+ 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.
6
+
7
+ > 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.
8
+
9
+ ### Supported Formats
10
+
11
+ An RjBuild can be written in two formats:
12
+
13
+ - **YAML** (recommended): More readable and easier to write for humans, ideal for creation and maintenance
14
+ - **JSON**: Standard supported format, useful for programmatic generation or integration with existing tools
15
+
16
+ **YAML is preferable** for most use cases as it offers better readability, allows comments, and is more tolerant of minor syntax errors.
17
+
18
+ ## Basic Structure of an RjBuild
19
+
20
+ Any RjBuild file can contain up to four main sections:
21
+
22
+ - `renderView`: User interface structure (required)
23
+ - `templates`: Reusable components (optional)
24
+ - `data`: Initial state and data (optional)
25
+ - `additionalDataSource`: External data sources (optional)
26
+
27
+ ```yaml
28
+ renderView: # User interface structure (required)
29
+ - type: div
30
+ content: "Hello World"
31
+
32
+ templates: # Reusable components (optional)
33
+ myComponent:
34
+ type: div
35
+ content: "Template content"
36
+
37
+ data: # Initial state and data (optional)
38
+ message: "Welcome!"
39
+ user:
40
+ name: "John"
41
+
42
+ additionalDataSource: # External data sources (optional)
43
+ - src: "/api/data.json"
44
+ path: ~~.dynamicData
45
+ ```
46
+
47
+ ## Section `renderView` (Required)
48
+
49
+ The `renderView` section defines the **user interface** that will be displayed. It is the only required section of an RjBuild.
50
+
51
+ ### Role
52
+ - Determines the visual structure of the application
53
+ - Defines the components to display and their organization
54
+ - Specifies interactions and behaviors
55
+
56
+ ### Structure
57
+
58
+ ```yaml
59
+ renderView:
60
+ - type: ComponentName # Type of component to render
61
+ content: "Content" # Component content
62
+ attributes: # HTML attributes (optional)
63
+ class: "css-class"
64
+ actions: # Interactive actions (optional)
65
+ - what: hide
66
+ on: click
67
+ ```
68
+
69
+ ### Examples
70
+
71
+ #### Simple interface
72
+ ```yaml
73
+ renderView:
74
+ - type: div
75
+ content:
76
+ - type: h1
77
+ content: "My Application"
78
+ - type: p
79
+ content: "Welcome!"
80
+ ```
81
+
82
+ #### With dynamic data
83
+ ```yaml
84
+ renderView:
85
+ - type: div
86
+ content: ["Hello ", ~~.user.name, "!"]
87
+
88
+ data:
89
+ user:
90
+ name: "Marie"
91
+ ```
92
+
93
+ ## Section `data` (Optional)
94
+
95
+ The `data` section contains the **initial state** of the application. This data can be read and modified by components.
96
+
97
+ ### Role
98
+ - Provides the initial state of the application
99
+ - Stores data modifiable by user interactions
100
+ - Enables data sharing between components
101
+
102
+ ### Structure
103
+
104
+ ```yaml
105
+ data:
106
+ # Simple data
107
+ title: "My Site"
108
+ isLoggedIn: false
109
+
110
+ # Objects
111
+ user:
112
+ name: "John"
113
+ email: "john@example.com"
114
+
115
+ # Arrays
116
+ items:
117
+ - name: "Item 1"
118
+ active: true
119
+ - name: "Item 2"
120
+ active: false
121
+ ```
122
+
123
+ ### Data Access
124
+
125
+ To use data in a component, you can use the following syntax:
126
+
127
+ - **`~~.`**: Global access to data from anywhere in the RjBuild
128
+ - **`~.`**: Local access to data from the current context (template)
129
+
130
+ ### Usage Examples
131
+
132
+ #### Forms with state
133
+ ```yaml
134
+ renderView:
135
+ - type: TextField
136
+ label: "Name"
137
+ dataLocation: ~~.user.name
138
+ - type: div
139
+ content: ["Entered name: ", ~~.user.name]
140
+
141
+ data:
142
+ user:
143
+ name: "Initial value"
144
+ ```
145
+
146
+ #### Conditional display
147
+ ```yaml
148
+ renderView:
149
+ - type: div
150
+ content: "User is logged in!"
151
+ actions:
152
+ - what: hide
153
+ when: ~~.isLoggedIn
154
+ is: false
155
+
156
+ data:
157
+ isLoggedIn: true
158
+ ```
159
+
160
+ > You can get more information about data access in the [template system documentation](./template-contexts-data-binding.md).
161
+
162
+ ## Section `templates` (Optional)
163
+
164
+ The `templates` section defines **reusable components** that can be used in `renderView` or other templates.
165
+
166
+ ### Role
167
+ - Avoids code duplication
168
+ - Enables reuse of complex structures
169
+ - Facilitates maintenance and modifications
170
+
171
+ ### Structure
172
+
173
+ ```yaml
174
+ templates:
175
+ templateName: # Template name
176
+ type: ComponentName # Template structure
177
+ content: "Content"
178
+
179
+ multipleComponents: # Template with multiple components
180
+ - type: div
181
+ content: "Component 1"
182
+ - type: p
183
+ content: "Component 2"
184
+ ```
185
+
186
+ ### Using templates
187
+
188
+ ```yaml
189
+ renderView:
190
+ - load: templateName # Loads and displays the template
191
+
192
+ templates:
193
+ templateName:
194
+ type: div
195
+ content: "I am a reusable template!"
196
+ ```
197
+
198
+ ### Data Context
199
+
200
+ Templates create their own **data context** when used with components like `Switch`:
201
+
202
+ ```yaml
203
+ renderView:
204
+ - type: Switch
205
+ content: ~~.users # Iterates over each user
206
+ singleOption:
207
+ load: userCard # Each user uses the template
208
+
209
+ templates:
210
+ userCard:
211
+ type: div
212
+ content:
213
+ - "Name: "
214
+ - ~.name # Local access to current user's name
215
+ - " (Admin: "
216
+ - ~~.isAdmin # Global access to settings
217
+
218
+ data:
219
+ isAdmin: true
220
+ users:
221
+ - name: "Alice"
222
+ - name: "Bob"
223
+ ```
224
+
225
+ ## Section `additionalDataSource` (Optional)
226
+
227
+ The `additionalDataSource` section allows **loading data from external sources** during application initialization.
228
+
229
+ ### Role
230
+ - Integrates dynamic data from APIs
231
+ - Enables asynchronous data loading
232
+ - Separates static data from dynamic data
233
+
234
+ ### Structure
235
+
236
+ ```yaml
237
+ additionalDataSource:
238
+ - src: "/api/endpoint" # Source URL (required)
239
+ path: ~~.targetPath # Where to place the data (optional)
240
+ method: GET # HTTP method (optional, default: GET)
241
+ blocking: true # Block rendering (optional, default: false)
242
+ ```
243
+
244
+ ### Properties
245
+ - **`src`** (required): URL of the data source
246
+ - **`path`** (optional): Path where to place the data (template syntax)
247
+ - **`method`** (optional): HTTP method (GET, POST, etc.)
248
+ - **`dataMapping`** (optional): Configure selective data dispatch using mapping processors
249
+ - **`blocking`** (optional): If `true`, waits for loading before displaying
250
+
251
+ ### Loading Modes
252
+
253
+ #### Blocking loading
254
+ ```yaml
255
+ additionalDataSource:
256
+ - src: "/api/user-profile.json"
257
+ path: ~~.currentUser
258
+ blocking: true # Page waits for loading
259
+ ```
260
+
261
+ #### Non-blocking loading
262
+ ```yaml
263
+ additionalDataSource:
264
+ - src: "/api/notifications.json"
265
+ path: ~~.notifications
266
+ blocking: false # Page displays immediately
267
+ ```
268
+
269
+ ### Data Placement
270
+
271
+ #### With specific path
272
+ ```yaml
273
+ additionalDataSource:
274
+ - src: "/api/user.json"
275
+ path: ~~.currentUser
276
+
277
+ # Data will be placed in data.currentUser
278
+ ```
279
+
280
+ #### Root-level merge
281
+ ```yaml
282
+ additionalDataSource:
283
+ - src: "/api/config.json"
284
+ # No path = direct merge into data
285
+ ```
286
+
287
+ ### Data Mapping Integration
288
+
289
+ Data Mapping can be used with `additionalDataSource` to selectively dispatch response data to specific locations:
290
+
291
+ ```yaml
292
+ additionalDataSource:
293
+ - src: "/api/user-profile"
294
+ blocking: true
295
+ dataMapping:
296
+ simpleMapping:
297
+ stringMap:
298
+ "profile.displayName": { value: "user.name" }
299
+ "profile.email": { value: "user.email" }
300
+ "settings.theme":
301
+ value: "user.preferences.theme"
302
+ required: false
303
+ defaultValue: "light"
304
+ ```
305
+
306
+ **Note**: When `dataMapping` is configured, it takes priority over the `path` property. For more details, see [Data Mapping Documentation](../advanced-concepts/data-mapping.md).
307
+
308
+ ### Complete Example
309
+
310
+ ```yaml
311
+ renderView:
312
+ - type: div
313
+ content:
314
+ - type: h1
315
+ content: ["Hello ", ~~.currentUser.name]
316
+ - type: p
317
+ content: ["Version: ", ~~.systemConfig.version]
318
+
319
+ data:
320
+ currentUser:
321
+ name: "Loading..." # Temporary value
322
+ systemConfig:
323
+ version: "Loading..."
324
+
325
+ additionalDataSource:
326
+ # Critical user data (blocking)
327
+ - src: "/api/user-profile.json"
328
+ path: ~~.currentUser
329
+ blocking: true
330
+
331
+ # System configuration (non-blocking)
332
+ - src: "/api/system-config.json"
333
+ path: ~~.systemConfig
334
+ blocking: false
335
+ ```
336
+
337
+ ## Best Practices
338
+
339
+ ### Organization
340
+ 1. **Logical structure**: Organize your data by functional domain
341
+ 2. **Reusable templates**: Create templates to avoid duplication
342
+ 3. **Default values**: Provide temporary values for external data
343
+
344
+ ### Performance
345
+ 1. **Smart loading**: Use `blocking: true` only for critical data
346
+ 2. **Minimal data**: Load only necessary data
347
+ 3. **Optimized templates**: Avoid overly complex templates
348
+
349
+ ### Maintainability
350
+ 1. **Consistent naming**: Use clear conventions for templates and data.
351
+ 2. **Documentation**: Comment complex sections.
352
+ 3. **Validation**: Verify the structure of your external data.
353
+
354
+ ## Next Steps
355
+
356
+ Now that you understand the structure of RjBuilds, learn about the **[Template System](./template-contexts-data-binding.md)** to master data binding and create reusable components.
357
+
358
+ The template system is crucial for building maintainable and dynamic applications with Reactive-JSON.