@ea-lab/reactive-json-docs 0.1.2

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 (93) hide show
  1. package/README-npm.md +49 -0
  2. package/README.md +86 -0
  3. package/package.json +79 -0
  4. package/public/rjbuild/component-doc/chartjs/components.yaml +252 -0
  5. package/public/rjbuild/component-doc/chartjs/overview.yaml +51 -0
  6. package/public/rjbuild/component-doc/core/action/HashChangeListener.md +90 -0
  7. package/public/rjbuild/component-doc/core/action/HashChangeListener.yaml +124 -0
  8. package/public/rjbuild/component-doc/core/action/Hide.md +22 -0
  9. package/public/rjbuild/component-doc/core/action/Hide.yaml +60 -0
  10. package/public/rjbuild/component-doc/core/action/MessageListener.md +93 -0
  11. package/public/rjbuild/component-doc/core/action/MessageListener.yaml +153 -0
  12. package/public/rjbuild/component-doc/core/action/Popover.md +26 -0
  13. package/public/rjbuild/component-doc/core/action/Popover.yaml +100 -0
  14. package/public/rjbuild/component-doc/core/action/ReactOnEvent.md +81 -0
  15. package/public/rjbuild/component-doc/core/action/ReactOnEvent.yaml +133 -0
  16. package/public/rjbuild/component-doc/core/action/Redirect.md +20 -0
  17. package/public/rjbuild/component-doc/core/action/Redirect.yaml +68 -0
  18. package/public/rjbuild/component-doc/core/action/Tooltip.md +22 -0
  19. package/public/rjbuild/component-doc/core/action/Tooltip.yaml +90 -0
  20. package/public/rjbuild/component-doc/core/action/VisuallyHide.md +21 -0
  21. package/public/rjbuild/component-doc/core/action/VisuallyHide.yaml +62 -0
  22. package/public/rjbuild/component-doc/core/action/index.md +214 -0
  23. package/public/rjbuild/component-doc/core/action/index.yaml +278 -0
  24. package/public/rjbuild/component-doc/core/element/form/CheckBoxField.md +276 -0
  25. package/public/rjbuild/component-doc/core/element/form/CheckBoxField.yaml +338 -0
  26. package/public/rjbuild/component-doc/core/element/form/DateField.md +189 -0
  27. package/public/rjbuild/component-doc/core/element/form/DateField.yaml +264 -0
  28. package/public/rjbuild/component-doc/core/element/form/NumberField.md +136 -0
  29. package/public/rjbuild/component-doc/core/element/form/NumberField.yaml +103 -0
  30. package/public/rjbuild/component-doc/core/element/form/SelectField.md +304 -0
  31. package/public/rjbuild/component-doc/core/element/form/SelectField.yaml +360 -0
  32. package/public/rjbuild/component-doc/core/element/form/TextAreaField.md +134 -0
  33. package/public/rjbuild/component-doc/core/element/form/TextAreaField.yaml +146 -0
  34. package/public/rjbuild/component-doc/core/element/form/TextField.md +129 -0
  35. package/public/rjbuild/component-doc/core/element/form/TextField.yaml +147 -0
  36. package/public/rjbuild/component-doc/core/element/form/formElementsCommon.md +106 -0
  37. package/public/rjbuild/component-doc/core/element/form/index.md +50 -0
  38. package/public/rjbuild/component-doc/core/element/form/index.yaml +96 -0
  39. package/public/rjbuild/component-doc/core/element/html/AccordionItem.yaml +47 -0
  40. package/public/rjbuild/component-doc/core/element/html/FolderSortableTree.yaml +81 -0
  41. package/public/rjbuild/component-doc/core/element/html/FormatNumeral.yaml +58 -0
  42. package/public/rjbuild/component-doc/core/element/html/Html.yaml +67 -0
  43. package/public/rjbuild/component-doc/core/element/html/LabelFromValue.yaml +54 -0
  44. package/public/rjbuild/component-doc/core/element/html/Modal.yaml +93 -0
  45. package/public/rjbuild/component-doc/core/element/html/PreformattedMarkup.yaml +37 -0
  46. package/public/rjbuild/component-doc/core/element/html/SortableTreeItemCollapseButton.yaml +92 -0
  47. package/public/rjbuild/component-doc/core/element/html/Tabs.yaml +57 -0
  48. package/public/rjbuild/component-doc/core/element/special/BootstrapElement.md +17 -0
  49. package/public/rjbuild/component-doc/core/element/special/BootstrapElement.yaml +18 -0
  50. package/public/rjbuild/component-doc/core/element/special/Count.md +37 -0
  51. package/public/rjbuild/component-doc/core/element/special/Count.yaml +325 -0
  52. package/public/rjbuild/component-doc/core/element/special/DataFilter.md +149 -0
  53. package/public/rjbuild/component-doc/core/element/special/DataFilter.yaml +315 -0
  54. package/public/rjbuild/component-doc/core/element/special/DelayedActions.md +51 -0
  55. package/public/rjbuild/component-doc/core/element/special/DelayedActions.yaml +55 -0
  56. package/public/rjbuild/component-doc/core/element/special/PageControls.md +126 -0
  57. package/public/rjbuild/component-doc/core/element/special/PageControls.yaml +133 -0
  58. package/public/rjbuild/component-doc/core/element/special/Phantom.md +31 -0
  59. package/public/rjbuild/component-doc/core/element/special/Phantom.yaml +34 -0
  60. package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.md +27 -0
  61. package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.yaml +51 -0
  62. package/public/rjbuild/component-doc/core/element/special/Switch.md +262 -0
  63. package/public/rjbuild/component-doc/core/element/special/Switch.yaml +348 -0
  64. package/public/rjbuild/component-doc/core/example/accordion.md +96 -0
  65. package/public/rjbuild/component-doc/core/example/accordion.yaml +64 -0
  66. package/public/rjbuild/component-doc/core/example/dynamic-content.md +197 -0
  67. package/public/rjbuild/component-doc/core/example/dynamic-content.yaml +237 -0
  68. package/public/rjbuild/component-doc/core/example/html.md +66 -0
  69. package/public/rjbuild/component-doc/core/example/html.yaml +83 -0
  70. package/public/rjbuild/component-doc/core/example/website.yaml +1663 -0
  71. package/public/rjbuild/component-doc/core/reaction/addData.md +96 -0
  72. package/public/rjbuild/component-doc/core/reaction/addData.yaml +133 -0
  73. package/public/rjbuild/component-doc/core/reaction/fetchData.md +60 -0
  74. package/public/rjbuild/component-doc/core/reaction/fetchData.yaml +156 -0
  75. package/public/rjbuild/component-doc/core/reaction/index.md +236 -0
  76. package/public/rjbuild/component-doc/core/reaction/index.yaml +254 -0
  77. package/public/rjbuild/component-doc/core/reaction/moveData.md +68 -0
  78. package/public/rjbuild/component-doc/core/reaction/moveData.yaml +71 -0
  79. package/public/rjbuild/component-doc/core/reaction/postMessage.md +63 -0
  80. package/public/rjbuild/component-doc/core/reaction/postMessage.yaml +68 -0
  81. package/public/rjbuild/component-doc/core/reaction/redirectNow.md +37 -0
  82. package/public/rjbuild/component-doc/core/reaction/redirectNow.yaml +37 -0
  83. package/public/rjbuild/component-doc/core/reaction/removeData.md +78 -0
  84. package/public/rjbuild/component-doc/core/reaction/removeData.yaml +56 -0
  85. package/public/rjbuild/component-doc/core/reaction/setClipboardData.md +44 -0
  86. package/public/rjbuild/component-doc/core/reaction/setClipboardData.yaml +41 -0
  87. package/public/rjbuild/component-doc/core/reaction/setData.md +93 -0
  88. package/public/rjbuild/component-doc/core/reaction/setData.yaml +85 -0
  89. package/public/rjbuild/component-doc/core/reaction/submitData.md +138 -0
  90. package/public/rjbuild/component-doc/core/reaction/submitData.yaml +141 -0
  91. package/public/rjbuild/component-doc/core/reaction/triggerEvent.md +59 -0
  92. package/public/rjbuild/component-doc/core/reaction/triggerEvent.yaml +59 -0
  93. package/public/rjbuild/component-doc/index.yaml +13 -0
@@ -0,0 +1,56 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # Reaction: removeData
5
+
6
+ The `removeData` reaction deletes data from a specific location in the global data context. It can operate in two modes: `path` mode or `target` mode.
7
+
8
+ - type: RjBuildDescriber
9
+ title: "1. Using `path` to remove a specific key"
10
+ description: "This example shows how to delete a specific user profile field by clicking a button."
11
+ toDescribe:
12
+ renderView:
13
+ - type: div
14
+ content: ["User email: ", ~.user.email]
15
+ - type: button
16
+ content: "Remove Email"
17
+ actions:
18
+ - what: removeData
19
+ on: click
20
+ path: ~.user.email
21
+ data:
22
+ user:
23
+ name: "John Doe"
24
+ email: "john.doe@example.com"
25
+
26
+ - type: RjBuildDescriber
27
+ title: "2. Using `target` to remove an item from a list"
28
+ description: |
29
+ This example shows a list of users where each user can be removed by clicking a "Remove" button next to their name.
30
+ The reaction uses `target: currentTemplateData` to identify which item to remove from the list.
31
+ toDescribe:
32
+ renderView:
33
+ - type: Switch
34
+ content: ~.users
35
+ singleOption:
36
+ load: user_item
37
+ templates:
38
+ user_item:
39
+ type: div
40
+ content:
41
+ - ~.name
42
+ - type: button
43
+ content: "Remove"
44
+ attributes:
45
+ style:
46
+ marginLeft: 10px
47
+ actions:
48
+ - what: removeData
49
+ on: click
50
+ target: currentTemplateData
51
+ parentLevel: 0
52
+ data:
53
+ users:
54
+ - name: "Alice"
55
+ - name: "Bob"
56
+ - name: "Charlie"
@@ -0,0 +1,44 @@
1
+ # Reaction: setClipboardData
2
+
3
+ ## Introduction
4
+
5
+ The `setClipboardData` reaction copies a specified value to the user's clipboard. This is useful for creating "Copy to clipboard" buttons for sharing information like referral codes, URLs, or any text-based data.
6
+
7
+ ## Properties
8
+
9
+ - `what` (string, required): The name of the reaction, which must be `setClipboardData`.
10
+ - `on` (string, required): The name of the event that triggers the reaction (e.g., `click`).
11
+ - `value` (any, required): The value to be copied to the clipboard. The value is evaluated, so it can be a literal string or a path to data.
12
+
13
+ ## Behavior
14
+
15
+ - When triggered, the reaction evaluates the `value` property.
16
+ - If the evaluated value is a string, it uses the `navigator.clipboard.writeText()` API to copy it to the clipboard.
17
+ - If the evaluated value is not a string, the reaction does nothing.
18
+ - An error is logged to the console if the clipboard operation fails (e.g., due to browser permissions).
19
+
20
+ ## Example
21
+
22
+ ### Copying text to the clipboard
23
+
24
+ This example shows a button that, when clicked, copies the value of `~.shareable_code` to the clipboard.
25
+
26
+ ```yaml
27
+ renderView:
28
+ - type: div
29
+ content: "Your code: ~.shareable_code"
30
+ - type: button
31
+ content: "Copy Code"
32
+ actions:
33
+ - what: setClipboardData
34
+ on: click
35
+ value: ~.shareable_code
36
+ data:
37
+ shareable_code: "ABC-123-XYZ"
38
+ ```
39
+
40
+ ## Limitations
41
+
42
+ - This reaction relies on the Clipboard API, which requires a secure context (HTTPS) to function in most modern browsers.
43
+ - The user may be prompted for permission to access the clipboard, depending on browser settings.
44
+ - The reaction only supports copying string values. Numbers and other types will be converted to strings, but objects and arrays will not be copied.
@@ -0,0 +1,41 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # Reaction: setClipboardData
5
+
6
+ The `setClipboardData` reaction copies a specified value to the user's clipboard.
7
+
8
+ ## Properties
9
+
10
+ - `what` (string, required): The name of the reaction, which must be `setClipboardData`.
11
+ - `on` (string, required): The name of the event that triggers the reaction (e.g., `click`).
12
+ - `value` (any, required): The value to be copied to the clipboard. The value is evaluated, so it can be a literal string or a path to data.
13
+
14
+ ## Behavior
15
+
16
+ - When triggered, the reaction evaluates the `value` property.
17
+ - If the evaluated value is a string, it uses the `navigator.clipboard.writeText()` API to copy it to the clipboard.
18
+ - If the evaluated value is not a string, the reaction does nothing.
19
+ - An error is logged to the console if the clipboard operation fails (e.g., due to browser permissions).
20
+
21
+ ## Limitations
22
+
23
+ - This reaction relies on the Clipboard API, which requires a secure context (HTTPS) to function in most modern browsers.
24
+ - The user may be prompted for permission to access the clipboard, depending on browser settings.
25
+ - The reaction only supports copying string values. Numbers and other types will be converted to strings, but objects and arrays will not be copied.
26
+
27
+ - type: RjBuildDescriber
28
+ title: "Copying text to the clipboard"
29
+ description: "This example shows a button that, when clicked, copies the value of `~.shareable_code` to the clipboard."
30
+ toDescribe:
31
+ renderView:
32
+ - type: div
33
+ content: ["Your code: ", ~.shareable_code]
34
+ - type: button
35
+ content: "Copy Code"
36
+ actions:
37
+ - what: setClipboardData
38
+ on: click
39
+ value: ~.shareable_code
40
+ data:
41
+ shareable_code: "ABC-123-XYZ"
@@ -0,0 +1,93 @@
1
+ # Reaction: setData
2
+
3
+ ## Introduction
4
+
5
+ The `setData` reaction updates the data at a specific location in the global data context. It is one of the most fundamental reactions for managing state and making applications interactive. It can be used to set simple values, objects, or the result of a template evaluation.
6
+
7
+ ## Properties
8
+
9
+ - `what` (string, required): The name of the reaction, which must be `setData`.
10
+ - `on` (string, required): The name of the event that triggers the reaction (e.g., `click`, `change`).
11
+ - `path` (string, required): The target location in the data context where the value will be set. It supports `~.` notation for relative paths.
12
+ - `value` (any, required): The value to set at the specified path. This value is evaluated, so it can be a literal, a path to other data, or a template string.
13
+ - **Conditional properties** (optional): Like all reactions, `setData` supports conditional execution using `when`, `is`, `isNot`, `isEmpty`, `contains`, `>`, `<`, `>=`, `<=`, `andConditions`, `orConditions`.
14
+
15
+ ## Behavior
16
+
17
+ - When triggered by the specified event (`on`), `setData` evaluates the `value` property within the current context.
18
+ - It then updates the data at the location specified by `path`.
19
+ - If the `value` is an object or an array, it is deep-cloned before being set to prevent shared-state mutations.
20
+ - If the `path` does not exist, it will be created.
21
+
22
+ ## Example
23
+
24
+ ### Basic Usage
25
+
26
+ This example demonstrates how to use `setData` to change a text value when a button is clicked.
27
+
28
+ ```yaml
29
+ renderView:
30
+ - type: div
31
+ content: "Current value: ~.myValue"
32
+ - type: button
33
+ content: "Set value to 'Hello World'"
34
+ actions:
35
+ - what: setData
36
+ on: click
37
+ path: ~.myValue
38
+ value: "Hello World"
39
+ - type: button
40
+ content: "Set value to 'Another value'"
41
+ attributes:
42
+ style:
43
+ marginLeft: 5px
44
+ actions:
45
+ - what: setData
46
+ on: click
47
+ path: ~.myValue
48
+ value: "Another value"
49
+ data:
50
+ myValue: "initial value"
51
+ ```
52
+
53
+ ### Conditional Usage
54
+
55
+ This example shows how to use conditions with `setData` to only execute when certain criteria are met.
56
+
57
+ ```yaml
58
+ renderView:
59
+ - type: TextField
60
+ dataLocation: ~.username
61
+ label: "Username:"
62
+ placeholder: "Enter username"
63
+ - type: button
64
+ content: "Set Welcome Message"
65
+ actions:
66
+ - what: setData
67
+ on: click
68
+ path: ~.message
69
+ value: ["Welcome, ", ~.username, "!"]
70
+ when: ~.username
71
+ isEmpty: "not"
72
+ - what: setData
73
+ on: click
74
+ path: ~.message
75
+ value: "Please enter a username first"
76
+ when: ~.username
77
+ isEmpty: true
78
+ - type: div
79
+ content: ~.message
80
+ actions:
81
+ - what: hide
82
+ when: ~.message
83
+ isEmpty: true
84
+
85
+ data:
86
+ username: ""
87
+ message: ""
88
+ ```
89
+
90
+ ## Limitations
91
+
92
+ - The `path` and `value` properties are mandatory for the reaction to have an effect.
93
+ - When conditions are not met, the reaction is skipped entirely.
@@ -0,0 +1,85 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # Reaction: setData
5
+
6
+ The `setData` reaction updates the data at a specific location in the global data context. It is one of the most fundamental reactions for managing state and making applications interactive. It can be used to set simple values, objects, or the result of a template evaluation.
7
+
8
+ ### Properties
9
+ - `what` (string, required): The name of the reaction, which must be `setData`.
10
+ - `on` (string, required): The name of the event that triggers the reaction (e.g., `click`, `change`).
11
+ - `path` (string, required): The target location in the data context where the value will be set. It supports `~.` notation for relative paths.
12
+ - `value` (any, required): The value to set at the specified path. This value is evaluated, so it can be a literal, a path to other data, or a template string.
13
+ - **Conditional properties** (optional): Like all reactions, `setData` supports conditional execution using `when`, `is`, `isNot`, `isEmpty`, `contains`, `>`, `<`, `>=`, `<=`, `andConditions`, `orConditions`.
14
+
15
+ ### Behavior
16
+ - When triggered by the specified event (`on`), `setData` evaluates the `value` property within the current context.
17
+ - It then updates the data at the location specified by `path`.
18
+ - If the `value` is an object or an array, it is deep-cloned before being set to prevent shared-state mutations.
19
+ - If the `path` does not exist, it will be created.
20
+ - If conditions are specified, the reaction only executes when those conditions evaluate to true.
21
+
22
+ ### Limitations
23
+ - The `path` and `value` properties are mandatory for the reaction to have an effect.
24
+ - When conditions are not met, the reaction is skipped entirely.
25
+
26
+ - type: RjBuildDescriber
27
+ title: "Basic Usage"
28
+ description: "This example demonstrates how to use `setData` to change a text value when a button is clicked."
29
+ toDescribe:
30
+ renderView:
31
+ - type: div
32
+ content: ["Current value: ", ~.myValue]
33
+ - type: button
34
+ content: "Set value to 'Hello World'"
35
+ actions:
36
+ - what: setData
37
+ on: click
38
+ path: ~.myValue
39
+ value: "Hello World"
40
+ - type: button
41
+ content: "Set value to 'Another value'"
42
+ attributes:
43
+ style:
44
+ marginLeft: 5px
45
+ actions:
46
+ - what: setData
47
+ on: click
48
+ path: ~.myValue
49
+ value: "Another value"
50
+ data:
51
+ myValue: "initial value"
52
+
53
+ - type: RjBuildDescriber
54
+ title: "Conditional Usage"
55
+ description: "This example shows how to use conditions with `setData` to only execute when certain criteria are met."
56
+ toDescribe:
57
+ renderView:
58
+ - type: TextField
59
+ dataLocation: ~.username
60
+ label: "Username:"
61
+ placeholder: "Enter username"
62
+ - type: button
63
+ content: "Set Welcome Message"
64
+ actions:
65
+ - what: setData
66
+ on: click
67
+ path: ~.message
68
+ value: ["Welcome, ", ~.username, "!"]
69
+ when: ~.username
70
+ isEmpty: "not"
71
+ - what: setData
72
+ on: click
73
+ path: ~.message
74
+ value: "Please enter a username first"
75
+ when: ~.username
76
+ isEmpty: true
77
+ - type: div
78
+ content: ~.message
79
+ actions:
80
+ - what: hide
81
+ when: ~.message
82
+ isEmpty: true
83
+ data:
84
+ username: ""
85
+ message: ""
@@ -0,0 +1,138 @@
1
+ # Reactive-JSON submitData Documentation
2
+
3
+ ## Introduction
4
+ `submitData` is a reaction that allows sending data to a server via HTTP requests (usually POST). It's especially useful for form submissions and API interactions.
5
+
6
+ - The payload can be customized with the `data` property.
7
+ - Only one submission can be active at a time (global lock).
8
+ - The response can refresh the app (default) or be ignored.
9
+
10
+ ## Properties
11
+ - `url` (string, required): The destination URL for the request
12
+ - `httpMethod` (string, optional): The HTTP method to use (default: "post")
13
+ - `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.
14
+ - `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
+ - `submitSilently` (boolean, optional): If true, doesn't apply visual disabling styles during submission
16
+
17
+ ## Behavior
18
+ - Only one submission can be active at a time (global lock)
19
+ - The default HTTP method is POST, but can be customized
20
+ - The payload is either the provided `data` object or the full data context
21
+ - Only the first level of the `data` object is evaluated as templates
22
+ - The server response must be a valid rjbuild if `refreshAppOnResponse` is true
23
+ - If `refreshAppOnResponse` is false, the response is ignored (webhook mode)
24
+ - In case of an error, the submission is cancelled and logged to the console
25
+ - Interface elements are visually disabled during submission (unless `submitSilently` is enabled)
26
+
27
+ ## Submission States & Styling
28
+ The system uses a global locking mechanism to handle submissions:
29
+ - Only one submission can be active at a time for all application roots
30
+ - New submissions are ignored while another is in progress
31
+ - Interface elements are visually disabled (unless `submitSilently` is enabled)
32
+ - The lock is released once the response is received
33
+
34
+ This limitation is intentional to avoid data consistency issues but may be restrictive in some use cases.
35
+
36
+ ### Styling Submitting State (CSS)
37
+ You can visually disable form controls during submission using CSS. There are two main approaches:
38
+
39
+ #### 1. Target only the submitting control (button, input, etc.)
40
+ The element that triggered the submission receives `data-is-submitting="true"` during the request:
41
+
42
+ ```css
43
+ input[data-is-submitting="true"],
44
+ button[data-is-submitting="true"],
45
+ select[data-is-submitting="true"],
46
+ textarea[data-is-submitting="true"] {
47
+ opacity: 0.5;
48
+ pointer-events: none;
49
+ cursor: not-allowed;
50
+ }
51
+ ```
52
+
53
+ #### 2. Target all controls globally during submission
54
+ While a submission is in progress, the `<body>` receives `data-html-builder-is-submitting="true"`. You can use this to disable all form controls:
55
+
56
+ ```css
57
+ body[data-html-builder-is-submitting="true"] input,
58
+ body[data-html-builder-is-submitting="true"] button,
59
+ body[data-html-builder-is-submitting="true"] select,
60
+ body[data-html-builder-is-submitting="true"] textarea {
61
+ opacity: 0.5;
62
+ pointer-events: none;
63
+ cursor: not-allowed;
64
+ }
65
+ ```
66
+
67
+ Choose the approach that best fits your UX needs.
68
+
69
+ ## Example
70
+ ```yaml
71
+ actions:
72
+ - what: submitData
73
+ on: click
74
+ url: "/mockup-api/submitData/example.json"
75
+ data:
76
+ username: ~.form_data.username
77
+ refreshAppOnResponse: true
78
+ ```
79
+
80
+ ## Data Management
81
+ Only the first level of the `data` object is evaluated as templates. For nested objects, you must specify the full path explicitly.
82
+
83
+ Example:
84
+ ```yaml
85
+ data:
86
+ username: ~.form_data.username # Evaluated
87
+ profile:
88
+ name: ~.user.name # Not evaluated (static)
89
+ email: ~.user.email # Not evaluated (static)
90
+ ```
91
+
92
+ If `data` is not specified, the entire `data` context is sent as `{ data: ... }`.
93
+
94
+ ### __state Property
95
+ `__state` is a special property that is automatically added to the payload when sending data if it exists in the global context. It allows transmitting the application state to the server.
96
+
97
+ Example usage in a multi-screen form:
98
+ ```yaml
99
+ # State sent to server
100
+ data:
101
+ form_data:
102
+ username: "john"
103
+ email: "john@example.com"
104
+ __state:
105
+ current_screen: "step2"
106
+ previous_screen: "step1"
107
+ form_progress: 50
108
+
109
+ # Server response
110
+ data:
111
+ form_data:
112
+ username: "john"
113
+ email: "john@example.com"
114
+ __state:
115
+ current_screen: "step3"
116
+ previous_screen: "step2"
117
+ form_progress: 75
118
+ validation_status: "success"
119
+ ```
120
+
121
+ This bidirectional state synchronization allows to:
122
+ - Validate that the progression is consistent
123
+ - Adapt the response based on the current screen
124
+ - Manage navigation between screens
125
+ - Save progression state
126
+ - Maintain consistency between client and server
127
+
128
+ ## Limitations
129
+ - Only one submission can be active at a time (global lock)
130
+ - Only the first level of the `data` object is evaluated as templates
131
+ - Only POST (or custom method) requests are supported
132
+ - The server response must be a valid rjbuild if `refreshAppOnResponse` is true
133
+ - No built-in error handling beyond console logging
134
+ - No support for request cancellation
135
+ - No support for timeouts
136
+ - No support for dynamic URLs (URLs must be static strings)
137
+ - No support for query parameters in URL templates
138
+ - No support for complex URL routing or path generation
@@ -0,0 +1,141 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # submitData
5
+
6
+ `submitData` is a reaction that allows sending data to a server via HTTP requests (usually POST). It's especially useful for form submissions and API interactions.
7
+
8
+ - The payload can be customized with the `data` property.
9
+ - Only one submission can be active at a time (global lock).
10
+ - The response can refresh the app (default) or be ignored.
11
+
12
+ ## Properties
13
+ - `url` (string, required): The destination URL for the request
14
+ - `httpMethod` (string, optional): The HTTP method to use (default: "post")
15
+ - `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.
16
+ - `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`).
17
+ - `submitSilently` (boolean, optional): If true, doesn't apply visual disabling styles during submission
18
+
19
+ ## Behavior
20
+ - Only one submission can be active at a time (global lock)
21
+ - The default HTTP method is POST, but can be customized
22
+ - The payload is either the provided `data` object or the full data context
23
+ - Only the first level of the `data` object is evaluated as templates
24
+ - The server response must be a valid rjbuild if `refreshAppOnResponse` is true
25
+ - If `refreshAppOnResponse` is false, the response is ignored (webhook mode)
26
+ - In case of an error, the submission is cancelled and logged to the console
27
+ - Interface elements are visually disabled during submission (unless `submitSilently` is enabled)
28
+
29
+ ## Submission States & Styling
30
+ The system uses a global locking mechanism to handle submissions:
31
+ - Only one submission can be active at a time for all application roots
32
+ - New submissions are ignored while another is in progress
33
+ - Interface elements are visually disabled (unless `submitSilently` is enabled)
34
+ - The lock is released once the response is received
35
+
36
+ This limitation is intentional to avoid data consistency issues but may be restrictive in some use cases.
37
+
38
+ ### Styling Submitting State (CSS)
39
+ You can visually disable form controls during submission using CSS. There are two main approaches:
40
+
41
+ #### 1. Target only the submitting control (button, input, etc.)
42
+ The element that triggered the submission receives `data-is-submitting="true"` during the request:
43
+
44
+ ```css
45
+ input[data-is-submitting="true"],
46
+ button[data-is-submitting="true"],
47
+ select[data-is-submitting="true"],
48
+ textarea[data-is-submitting="true"] {
49
+ opacity: 0.5;
50
+ pointer-events: none;
51
+ cursor: not-allowed;
52
+ }
53
+ ```
54
+
55
+ #### 2. Target all controls globally during submission
56
+ While a submission is in progress, the `<body>` receives `data-html-builder-is-submitting="true"`. You can use this to disable all form controls:
57
+
58
+ ```css
59
+ body[data-html-builder-is-submitting="true"] input,
60
+ body[data-html-builder-is-submitting="true"] button,
61
+ body[data-html-builder-is-submitting="true"] select,
62
+ body[data-html-builder-is-submitting="true"] textarea {
63
+ opacity: 0.5;
64
+ pointer-events: none;
65
+ cursor: not-allowed;
66
+ }
67
+ ```
68
+
69
+ Choose the approach that best fits your UX needs.
70
+
71
+ ## Example
72
+ ```yaml
73
+ actions:
74
+ - what: submitData
75
+ on: click
76
+ url: "/mockup-api/submitData/example.json"
77
+ data:
78
+ username: ~.form_data.username
79
+ refreshAppOnResponse: true
80
+ ```
81
+
82
+ ## Data Management
83
+ Only the first level of the `data` object is evaluated as templates. For nested objects, you must specify the full path explicitly.
84
+
85
+ Example:
86
+ ```yaml
87
+ data:
88
+ username: ~.form_data.username # Evaluated
89
+ profile:
90
+ name: ~.user.name # Not evaluated (static)
91
+ email: ~.user.email # Not evaluated (static)
92
+ ```
93
+
94
+ If `data` is not specified, the entire `data` context is sent as `{ data: ... }`.
95
+
96
+ ### __state Property
97
+ `__state` is a special property that is automatically added to the payload when sending data if it exists in the global context. It allows transmitting the application state to the server.
98
+
99
+ Example usage in a multi-screen form:
100
+ ```yaml
101
+ # State sent to server
102
+ data:
103
+ form_data:
104
+ username: "john"
105
+ email: "john@example.com"
106
+ __state:
107
+ current_screen: "step2"
108
+ previous_screen: "step1"
109
+ form_progress: 50
110
+
111
+ # Server response
112
+ data:
113
+ form_data:
114
+ username: "john"
115
+ email: "john@example.com"
116
+ __state:
117
+ current_screen: "step3"
118
+ previous_screen: "step2"
119
+ form_progress: 75
120
+ validation_status: "success"
121
+ ```
122
+
123
+ This bidirectional state synchronization allows to:
124
+ - Validate that the progression is consistent
125
+ - Adapt the response based on the current screen
126
+ - Manage navigation between screens
127
+ - Save progression state
128
+ - Maintain consistency between client and server
129
+
130
+ ## Limitations
131
+ - Only one submission can be active at a time (global lock)
132
+ - Only the first level of the `data` object is evaluated as templates
133
+ - Only POST (or custom method) requests are supported
134
+ - The server response must be a valid rjbuild if `refreshAppOnResponse` is true
135
+ - No built-in error handling beyond console logging
136
+ - No support for request cancellation
137
+ - No support for timeouts
138
+ - No support for dynamic URLs (URLs must be static strings)
139
+ - No support for query parameters in URL templates
140
+ - No support for complex URL routing or path generation
141
+
@@ -0,0 +1,59 @@
1
+ # Reaction: triggerEvent
2
+
3
+ ## Introduction
4
+
5
+ The `triggerEvent` reaction programmatically dispatches an event on one or more target elements found via a CSS selector. This allows for indirect interactions, such as one button triggering the `click` event of another element, or simulating user actions on specific components.
6
+
7
+ ## Properties
8
+
9
+ - `what` (string, required): The name of the reaction, must be `triggerEvent`.
10
+ - `on` (string, required): The event that triggers this reaction.
11
+ - `eventName` (string, required): The name of the event to dispatch on the target element(s) (e.g., `click`, `focus`).
12
+ - `selector` (string, required): A CSS selector to identify the target element(s) that will receive the event.
13
+ - `selectorBase` (string, optional): Defines the starting point for the `selector` search.
14
+ - If omitted, the search starts from the `document` root.
15
+ - If set to `'currentEventTarget'`, the search starts from the element that triggered the reaction.
16
+ - If set to another CSS selector, the search starts from the closest ancestor matching that selector.
17
+
18
+ ## Behavior
19
+
20
+ - When triggered, the reaction searches for elements matching the `selector` within the scope defined by `selectorBase`.
21
+ - It then dispatches a new DOM event of type `eventName` on each found element.
22
+ - The event bubbles up the DOM (`bubbles: true`).
23
+ - To ensure reliable event dispatch on multiple targets, especially for synchronous events like `click`, the reaction dispatches events sequentially using Promises.
24
+
25
+ ## Example
26
+
27
+ ### Triggering a click on another element
28
+
29
+ In this example, clicking the first button (`Trigger a click...`) does not update the status directly. Instead, it dispatches a `click` event on the second button (`Update the status`). The second button has its own `click` reaction that updates the status. Therefore, clicking either button will result in the same final action: the status text gets updated.
30
+
31
+ ```yaml
32
+ renderView:
33
+ - type: button
34
+ content: "Trigger a click on the other button"
35
+ actions:
36
+ - what: triggerEvent
37
+ on: click
38
+ eventName: "click"
39
+ selector: "#target-button"
40
+ - type: button
41
+ content: "Update the status"
42
+ attributes:
43
+ id: "target-button"
44
+ actions:
45
+ - what: setData
46
+ on: click
47
+ path: ~.status
48
+ value: "Clicked!"
49
+ - type: div
50
+ content: "Status: ~.status"
51
+ data:
52
+ status: "Not clicked"
53
+ ```
54
+
55
+ ## Limitations
56
+
57
+ - The target elements must exist in the DOM when the reaction is triggered.
58
+ - The behavior depends on the target element having an event listener for the dispatched `eventName`.
59
+ - Complex events with custom data are not supported; it dispatches a standard `Event`.