@ea-lab/reactive-json-docs 2.8.0 → 2.11.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 +2 -2
- package/public/rjbuild/docs/core/element/form/CheckBoxField.md +142 -18
- package/public/rjbuild/docs/core/element/form/CheckBoxField.yaml +132 -7
- package/public/rjbuild/docs/core/element/form/SelectField.md +36 -10
- package/public/rjbuild/docs/core/element/form/SelectField.yaml +37 -3
- package/public/rjbuild/docs/core/element/form/formElementsCommon.md +32 -0
- package/public/rjbuild/docs/core/element/html/Html.yaml +47 -0
- package/public/rjbuild/docs/core/element/html/LabelFromValue.md +159 -0
- package/public/rjbuild/docs/core/element/html/LabelFromValue.yaml +163 -10
- package/public/rjbuild/docs/core/element/special/DataSync.md +41 -1
- package/public/rjbuild/docs/core/element/special/DataSync.yaml +41 -1
- package/public/rjbuild/docs/core/example/native-html-forms.md +19 -2
- package/public/rjbuild/docs/core/hook/index.md +3 -0
- package/public/rjbuild/docs/core/hook/index.yaml +3 -0
- package/public/rjbuild/docs/core/reaction/collectField.md +51 -0
- package/public/rjbuild/docs/core/reaction/collectField.yaml +81 -0
- package/public/rjbuild/docs/core/reaction/fetchData.md +21 -1
- package/public/rjbuild/docs/core/reaction/fetchData.yaml +2 -2
- package/public/rjbuild/docs/core/reaction/index.md +5 -0
- package/public/rjbuild/docs/core/reaction/index.yaml +5 -0
- package/public/rjbuild/docs/core/reaction/joinData.md +51 -0
- package/public/rjbuild/docs/core/reaction/joinData.yaml +87 -0
- package/public/rjbuild/docs/core/reaction/printPage.md +22 -0
- package/public/rjbuild/docs/core/reaction/printPage.yaml +29 -0
- package/public/rjbuild/docs/core/reaction/redirectNow.md +20 -2
- package/public/rjbuild/docs/core/reaction/redirectNow.yaml +24 -3
- package/public/rjbuild/docs/core/reaction/setClipboardData.md +35 -6
- package/public/rjbuild/docs/core/reaction/setClipboardData.yaml +18 -6
- package/public/rjbuild/docs/core/reaction/stringifyData.md +45 -0
- package/public/rjbuild/docs/core/reaction/stringifyData.yaml +58 -0
- package/public/rjbuild/docs/core/reaction/submitData.md +1 -1
- package/public/rjbuild/docs/core/reaction/submitData.yaml +4 -2
- package/public/rjbuild/docs/core/reaction/toggleData.md +72 -0
- package/public/rjbuild/docs/core/reaction/toggleData.yaml +77 -0
- package/public/rjbuild/docs/getting-started/reactions.md +5 -0
- package/public/rjbuild/docs/getting-started/reactions.yaml +5 -0
- package/public/rjbuild/docs/getting-started/rjbuild-structure.md +23 -1
- package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +25 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
- The response can refresh the app (default) or be ignored.
|
|
8
8
|
|
|
9
9
|
## Properties
|
|
10
|
-
- `url` (string, required): The destination URL for the request
|
|
10
|
+
- `url` (string or array, required): The destination URL for the request: a string or a template reference, or an array of segments built like the `src` of `additionalDataSource` (references evaluated in the current template context). No request is sent when the URL is empty, or when a required segment is empty. See [Dynamic URLs with `src` as Array](../../getting-started/rjbuild-structure.md#dynamic-urls-with-src-as-array).
|
|
11
11
|
- `httpMethod` (string, optional): The HTTP method to use (default: "post")
|
|
12
12
|
- `data` (object, optional): The data to send. If not specified, data is sent in an object with the structure `{ data: globalDataContext.templateData }`. If `__state` exists in the context, it is automatically added.
|
|
13
13
|
- `refreshAppOnResponse` (boolean, optional): If true (default), reloads the application with the server response. If false, the response is ignored and **no change is made to the application's state or display** (just like `fetchData`).
|
|
@@ -15,8 +15,10 @@ renderView:
|
|
|
15
15
|
content:
|
|
16
16
|
- term:
|
|
17
17
|
code: url
|
|
18
|
-
after: "(string, required)"
|
|
19
|
-
details:
|
|
18
|
+
after: "(string or array, required)"
|
|
19
|
+
details:
|
|
20
|
+
type: Markdown
|
|
21
|
+
content: "The destination URL for the request: a string or a template reference, or an array of segments built like the `src` of `additionalDataSource` (references evaluated in the current template context). No request is sent when the URL is empty, or when a required segment is empty."
|
|
20
22
|
- term:
|
|
21
23
|
code: httpMethod
|
|
22
24
|
after: "(string, optional)"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Reaction: toggleData
|
|
2
|
+
|
|
3
|
+
The `toggleData` reaction adds a value to an array when it is absent, and removes it when it is present. The other values of the array are kept. It is the building block of on/off filters and of data-driven selections (tags, recipients, checked rows).
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
- `path` (string, required): The location of the array (template syntax).
|
|
8
|
+
- `value` (any, required): The value to add or remove. It is evaluated, so it can be a literal or a template reference.
|
|
9
|
+
|
|
10
|
+
## Behavior
|
|
11
|
+
|
|
12
|
+
- The value is appended when it is absent from the array, and removed when it is present. The order of the other values is kept.
|
|
13
|
+
- A missing location, or a location that does not hold an array, counts as an empty array: the result is always an array.
|
|
14
|
+
- The values are compared as strings: a numeric identifier (`12`) matches its text form (`"12"`).
|
|
15
|
+
- Nothing happens when the value is `null`, `undefined` or an empty string, such as a value coming from a data source that is not loaded yet. The array never receives an empty value.
|
|
16
|
+
- The current array is read from the complete data, even inside a `DataFilter`.
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
### Filter toggle
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
renderView:
|
|
24
|
+
- type: button
|
|
25
|
+
content: "My tasks"
|
|
26
|
+
actions:
|
|
27
|
+
- what: toggleData
|
|
28
|
+
on: click
|
|
29
|
+
path: ~~.filters.assignee
|
|
30
|
+
value: ~~.currentUser.id
|
|
31
|
+
|
|
32
|
+
data:
|
|
33
|
+
currentUser:
|
|
34
|
+
id: 12
|
|
35
|
+
filters:
|
|
36
|
+
assignee: []
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### One toggle per list item
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
renderView:
|
|
43
|
+
- type: Switch
|
|
44
|
+
content: ~~.rows
|
|
45
|
+
singleOption:
|
|
46
|
+
load: row
|
|
47
|
+
|
|
48
|
+
templates:
|
|
49
|
+
row:
|
|
50
|
+
type: button
|
|
51
|
+
content: ~.title
|
|
52
|
+
actions:
|
|
53
|
+
- what: toggleData
|
|
54
|
+
on: click
|
|
55
|
+
path: ~~.selection
|
|
56
|
+
value: ~.id
|
|
57
|
+
|
|
58
|
+
data:
|
|
59
|
+
rows:
|
|
60
|
+
- id: 1
|
|
61
|
+
title: "First"
|
|
62
|
+
- id: 2
|
|
63
|
+
title: "Second"
|
|
64
|
+
selection: []
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To show the state of each item, use `attributeTransforms` with a `contains` condition on the array (see [CheckBoxField](../element/form/CheckBoxField.md#data-driven-checkbox-lists)).
|
|
68
|
+
|
|
69
|
+
## Limitations
|
|
70
|
+
|
|
71
|
+
- Only arrays of scalar values are supported: objects are compared by their string form.
|
|
72
|
+
- `addData` appends without checking duplicates, and `removeData` removes by path: use `toggleData` to add or remove a known value.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Reaction: toggleData
|
|
5
|
+
|
|
6
|
+
The `toggleData` reaction adds a value to an array when it is absent, and removes it when it is present. The other values of the array are kept. It is the building block of on/off filters and of data-driven selections (tags, recipients, checked rows).
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
- type: DefinitionList
|
|
11
|
+
content:
|
|
12
|
+
- term:
|
|
13
|
+
code: path
|
|
14
|
+
after: "(string, required)"
|
|
15
|
+
details: "The location of the array (template syntax)."
|
|
16
|
+
- term:
|
|
17
|
+
code: value
|
|
18
|
+
after: "(any, required)"
|
|
19
|
+
details: "The value to add or remove. It is evaluated, so it can be a literal or a template reference."
|
|
20
|
+
|
|
21
|
+
- type: Markdown
|
|
22
|
+
content: |
|
|
23
|
+
## Behavior
|
|
24
|
+
|
|
25
|
+
- The value is appended when it is absent from the array, and removed when it is present. The order of the other values is kept.
|
|
26
|
+
- A missing location, or a location that does not hold an array, counts as an empty array: the result is always an array.
|
|
27
|
+
- The values are compared as strings: a numeric identifier (`12`) matches its text form (`"12"`).
|
|
28
|
+
- Nothing happens when the value is `null`, `undefined` or an empty string, such as a value coming from a data source that is not loaded yet. The array never receives an empty value.
|
|
29
|
+
- The current array is read from the complete data, even inside a `DataFilter`.
|
|
30
|
+
|
|
31
|
+
- type: RjBuildDescriber
|
|
32
|
+
title: "One toggle per list item"
|
|
33
|
+
description: "Each button adds or removes the id of its item in the selection."
|
|
34
|
+
toDescribe:
|
|
35
|
+
renderView:
|
|
36
|
+
- type: Switch
|
|
37
|
+
content: ~~.rows
|
|
38
|
+
singleOption:
|
|
39
|
+
load: row
|
|
40
|
+
- type: div
|
|
41
|
+
content:
|
|
42
|
+
- type: strong
|
|
43
|
+
content: "Selection: "
|
|
44
|
+
- type: Join
|
|
45
|
+
content: ~~.selection
|
|
46
|
+
separator: ", "
|
|
47
|
+
templates:
|
|
48
|
+
row:
|
|
49
|
+
type: button
|
|
50
|
+
attributes:
|
|
51
|
+
type: button
|
|
52
|
+
style:
|
|
53
|
+
marginRight: "0.5rem"
|
|
54
|
+
content: ~.title
|
|
55
|
+
actions:
|
|
56
|
+
- what: toggleData
|
|
57
|
+
on: click
|
|
58
|
+
path: ~~.selection
|
|
59
|
+
value: ~.id
|
|
60
|
+
data:
|
|
61
|
+
rows:
|
|
62
|
+
- id: 1
|
|
63
|
+
title: "First"
|
|
64
|
+
- id: 2
|
|
65
|
+
title: "Second"
|
|
66
|
+
- id: 3
|
|
67
|
+
title: "Third"
|
|
68
|
+
selection: []
|
|
69
|
+
|
|
70
|
+
- type: Markdown
|
|
71
|
+
content: |
|
|
72
|
+
To show the state of each item, use `attributeTransforms` with a `contains` condition on the array (see [CheckBoxField](../element/form/CheckBoxField)).
|
|
73
|
+
|
|
74
|
+
## Limitations
|
|
75
|
+
|
|
76
|
+
- Only arrays of scalar values are supported: objects are compared by their string form.
|
|
77
|
+
- `addData` appends without checking duplicates, and `removeData` removes by path: use `toggleData` to add or remove a known value.
|
|
@@ -71,6 +71,10 @@ Reactive-JSON provides several built-in reactions:
|
|
|
71
71
|
- **addData**: Adds new data to the specified path.
|
|
72
72
|
- **removeData**: Removes data from the specified path.
|
|
73
73
|
- **moveData**: Moves data from one path to another.
|
|
74
|
+
- **toggleData**: Adds a value to an array when absent, removes it when present.
|
|
75
|
+
- **collectField**: Writes the values of a field of every item of a collection as an array.
|
|
76
|
+
- **joinData**: Writes a string built from several parts.
|
|
77
|
+
- **stringifyData**: Writes the JSON representation of a value.
|
|
74
78
|
|
|
75
79
|
### Network Operations
|
|
76
80
|
- **fetchData**: Fetches data from a URL using GET requests.
|
|
@@ -81,6 +85,7 @@ Reactive-JSON provides several built-in reactions:
|
|
|
81
85
|
- **redirectNow**: Performs an immediate redirect.
|
|
82
86
|
- **triggerEvent**: Triggers a custom event.
|
|
83
87
|
- **postMessage**: Sends a message to another window/frame.
|
|
88
|
+
- **printPage**: Opens the print dialog of the browser.
|
|
84
89
|
|
|
85
90
|
For detailed documentation of each reaction, including properties and examples, see their respective documentation pages.
|
|
86
91
|
|
|
@@ -96,6 +96,10 @@ renderView:
|
|
|
96
96
|
- **[addData](../core/reaction/addData)**: Adds new data to the specified path.
|
|
97
97
|
- **[removeData](../core/reaction/removeData)**: Removes data from the specified path.
|
|
98
98
|
- **[moveData](../core/reaction/moveData)**: Moves data from one path to another.
|
|
99
|
+
- **[toggleData](../core/reaction/toggleData)**: Adds a value to an array when absent, removes it when present.
|
|
100
|
+
- **[collectField](../core/reaction/collectField)**: Writes the values of a field of every item of a collection as an array.
|
|
101
|
+
- **[joinData](../core/reaction/joinData)**: Writes a string built from several parts.
|
|
102
|
+
- **[stringifyData](../core/reaction/stringifyData)**: Writes the JSON representation of a value.
|
|
99
103
|
|
|
100
104
|
### Network Operations
|
|
101
105
|
- **[fetchData](../core/reaction/fetchData)**: Fetches data from a URL using GET requests.
|
|
@@ -106,6 +110,7 @@ renderView:
|
|
|
106
110
|
- **[redirectNow](../core/reaction/redirectNow)**: Performs an immediate redirect.
|
|
107
111
|
- **[triggerEvent](../core/reaction/triggerEvent)**: Triggers a custom event.
|
|
108
112
|
- **[postMessage](../core/reaction/postMessage)**: Sends a message to another window/frame.
|
|
113
|
+
- **[printPage](../core/reaction/printPage)**: Opens the print dialog of the browser.
|
|
109
114
|
|
|
110
115
|
For detailed documentation of each reaction, including properties and examples, see their respective documentation pages.
|
|
111
116
|
|
|
@@ -336,10 +336,14 @@ additionalDataSource:
|
|
|
336
336
|
blocking: true
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
+
**Array values:** when the value resolves to an array, the param is repeated for each item: `{ param: "domains", value: ~~.domains }` with `domains: ["a.fr", "b.fr"]` gives `?domains=a.fr&domains=b.fr`. The empty items are skipped, and an empty array counts as an empty value. For a PHP backend, name the param with brackets (`domains[]`) to receive an array.
|
|
340
|
+
|
|
339
341
|
**Null handling for params:**
|
|
340
342
|
- If either the key or the value resolves to `null`/empty and `required` is absent or `false`, the param is **silently omitted** from the URL.
|
|
341
343
|
- If either resolves to `null`/empty and `required: true` is set, the entire URL is **aborted**, triggering `fallbackDataSource` if defined.
|
|
342
344
|
|
|
345
|
+
An aborted URL logs a warning naming the caller (`additionalDataSource`, `redirectNow`, `href attribute`...), the empty part and its position in the array.
|
|
346
|
+
|
|
343
347
|
```yaml
|
|
344
348
|
additionalDataSource:
|
|
345
349
|
- src:
|
|
@@ -355,7 +359,7 @@ additionalDataSource:
|
|
|
355
359
|
|
|
356
360
|
#### Mixing all three types
|
|
357
361
|
|
|
358
|
-
Path parts (plain strings, `~~.`/`~.` strings, and `segment` objects) are concatenated in order. All `param` objects are collected and appended as a query string after the path.
|
|
362
|
+
Path parts (plain strings, `~~.`/`~.` strings, and `segment` objects) are concatenated in order. All `param` objects are collected and appended as a query string after the path. When the path already holds a query string (`/api/items?sort=asc`), the parameters continue it with `&`.
|
|
359
363
|
|
|
360
364
|
```yaml
|
|
361
365
|
additionalDataSource:
|
|
@@ -400,6 +404,24 @@ data:
|
|
|
400
404
|
timeLogs: []
|
|
401
405
|
```
|
|
402
406
|
|
|
407
|
+
#### The same format elsewhere
|
|
408
|
+
|
|
409
|
+
The segments format is also accepted by:
|
|
410
|
+
|
|
411
|
+
- `url` of the [fetchData](../core/reaction/fetchData.md) and [submitData](../core/reaction/submitData.md) reactions: no request is sent when a required segment is empty;
|
|
412
|
+
- `to` of the [redirectNow](../core/reaction/redirectNow.md) reaction: no navigation when a required segment is empty;
|
|
413
|
+
- the URL attributes (`href`, `src`, `action`, `formAction`, `poster`) of any element: the attribute is omitted when a required segment is empty;
|
|
414
|
+
- `parts` of the [joinData](../core/reaction/joinData.md) reaction, which writes the composed string in the data.
|
|
415
|
+
|
|
416
|
+
There, the references are evaluated in the current template context: `~.slug` reads the current template data (e.g. the current `Switch` item), `~~.` the global data, `~>key` an ancestor. In `additionalDataSource.src`, both `~.` and `~~.` read the root data. In a reaction, the event placeholders also work in the parts, `required` included: `{ segment: "<reactive-json:event-new-value>.id", required: true }`.
|
|
417
|
+
|
|
418
|
+
```yaml
|
|
419
|
+
- type: a
|
|
420
|
+
attributes:
|
|
421
|
+
href: ["/article/", ~.year, "/", { segment: ~.slug, required: true }]
|
|
422
|
+
content: ~.title
|
|
423
|
+
```
|
|
424
|
+
|
|
403
425
|
### Fallback Sources
|
|
404
426
|
|
|
405
427
|
The `fallbackDataSource` property defines an alternate source that is tried automatically when the primary source cannot be used. It accepts the same structure as a regular `additionalDataSource` item, including its own `fallbackDataSource` for chaining.
|
|
@@ -355,10 +355,14 @@ renderView:
|
|
|
355
355
|
|
|
356
356
|
A param object adds a key-value pair to the URL query string. Both the key and the value accept store references.
|
|
357
357
|
|
|
358
|
+
**Array values:** when the value resolves to an array, the param is repeated for each item: `{ param: "domains", value: ~~.domains }` with `domains: ["a.fr", "b.fr"]` gives `?domains=a.fr&domains=b.fr`. The empty items are skipped, and an empty array counts as an empty value. For a PHP backend, name the param with brackets (`domains[]`) to receive an array.
|
|
359
|
+
|
|
358
360
|
**Null handling:**
|
|
359
361
|
- If either the key or the value resolves to `null`/empty and `required` is absent or `false`, the param is **silently omitted** from the URL.
|
|
360
362
|
- If either resolves to `null`/empty and `required: true` is set, the entire URL is **aborted**, triggering `fallbackDataSource` if defined.
|
|
361
363
|
|
|
364
|
+
An aborted URL logs a warning naming the caller (`additionalDataSource`, `redirectNow`, `href attribute`...), the empty part and its position in the array.
|
|
365
|
+
|
|
362
366
|
- type: TabbedSerializer
|
|
363
367
|
yamlSerializedContent: |
|
|
364
368
|
additionalDataSource:
|
|
@@ -379,7 +383,7 @@ renderView:
|
|
|
379
383
|
|
|
380
384
|
#### Mixing all three types
|
|
381
385
|
|
|
382
|
-
Path parts (plain strings, `~~.`/`~.` strings, and `segment` objects) are concatenated in order. All `param` objects are collected and appended as a query string after the path.
|
|
386
|
+
Path parts (plain strings, `~~.`/`~.` strings, and `segment` objects) are concatenated in order. All `param` objects are collected and appended as a query string after the path. When the path already holds a query string (`/api/items?sort=asc`), the parameters continue it with `&`.
|
|
383
387
|
|
|
384
388
|
- type: TabbedSerializer
|
|
385
389
|
yamlSerializedContent: |
|
|
@@ -428,6 +432,26 @@ renderView:
|
|
|
428
432
|
taskId: "" # Will be overridden by dataOverride
|
|
429
433
|
timeLogs: []
|
|
430
434
|
|
|
435
|
+
- type: Markdown
|
|
436
|
+
content: |
|
|
437
|
+
#### The same format elsewhere
|
|
438
|
+
|
|
439
|
+
The segments format is also accepted by:
|
|
440
|
+
|
|
441
|
+
- `url` of the [fetchData](../core/reaction/fetchData) and [submitData](../core/reaction/submitData) reactions: no request is sent when a required segment is empty;
|
|
442
|
+
- `to` of the [redirectNow](../core/reaction/redirectNow) reaction: no navigation when a required segment is empty;
|
|
443
|
+
- the URL attributes (`href`, `src`, `action`, `formAction`, `poster`) of any element: the attribute is omitted when a required segment is empty;
|
|
444
|
+
- `parts` of the [joinData](../core/reaction/joinData) reaction, which writes the composed string in the data.
|
|
445
|
+
|
|
446
|
+
There, the references are evaluated in the current template context: `~.slug` reads the current template data (e.g. the current `Switch` item), `~~.` the global data, `~>key` an ancestor. In `additionalDataSource.src`, both `~.` and `~~.` read the root data. In a reaction, the event placeholders also work in the parts, `required` included: `{ segment: "<reactive-json:event-new-value>.id", required: true }`.
|
|
447
|
+
|
|
448
|
+
```yaml
|
|
449
|
+
- type: a
|
|
450
|
+
attributes:
|
|
451
|
+
href: ["/article/", ~.year, "/", { segment: ~.slug, required: true }]
|
|
452
|
+
content: ~.title
|
|
453
|
+
```
|
|
454
|
+
|
|
431
455
|
- type: Markdown
|
|
432
456
|
content: |
|
|
433
457
|
|