@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.
- package/README-npm.md +49 -0
- package/README.md +86 -0
- package/package.json +79 -0
- package/public/rjbuild/component-doc/chartjs/components.yaml +252 -0
- package/public/rjbuild/component-doc/chartjs/overview.yaml +51 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.md +90 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.yaml +124 -0
- package/public/rjbuild/component-doc/core/action/Hide.md +22 -0
- package/public/rjbuild/component-doc/core/action/Hide.yaml +60 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.md +93 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.yaml +153 -0
- package/public/rjbuild/component-doc/core/action/Popover.md +26 -0
- package/public/rjbuild/component-doc/core/action/Popover.yaml +100 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.md +81 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.yaml +133 -0
- package/public/rjbuild/component-doc/core/action/Redirect.md +20 -0
- package/public/rjbuild/component-doc/core/action/Redirect.yaml +68 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.md +22 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.yaml +90 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.md +21 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.yaml +62 -0
- package/public/rjbuild/component-doc/core/action/index.md +214 -0
- package/public/rjbuild/component-doc/core/action/index.yaml +278 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.md +276 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.yaml +338 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.md +189 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.yaml +264 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.md +136 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.yaml +103 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.md +304 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.yaml +360 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.md +134 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.yaml +146 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.md +129 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.yaml +147 -0
- package/public/rjbuild/component-doc/core/element/form/formElementsCommon.md +106 -0
- package/public/rjbuild/component-doc/core/element/form/index.md +50 -0
- package/public/rjbuild/component-doc/core/element/form/index.yaml +96 -0
- package/public/rjbuild/component-doc/core/element/html/AccordionItem.yaml +47 -0
- package/public/rjbuild/component-doc/core/element/html/FolderSortableTree.yaml +81 -0
- package/public/rjbuild/component-doc/core/element/html/FormatNumeral.yaml +58 -0
- package/public/rjbuild/component-doc/core/element/html/Html.yaml +67 -0
- package/public/rjbuild/component-doc/core/element/html/LabelFromValue.yaml +54 -0
- package/public/rjbuild/component-doc/core/element/html/Modal.yaml +93 -0
- package/public/rjbuild/component-doc/core/element/html/PreformattedMarkup.yaml +37 -0
- package/public/rjbuild/component-doc/core/element/html/SortableTreeItemCollapseButton.yaml +92 -0
- package/public/rjbuild/component-doc/core/element/html/Tabs.yaml +57 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.md +17 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.yaml +18 -0
- package/public/rjbuild/component-doc/core/element/special/Count.md +37 -0
- package/public/rjbuild/component-doc/core/element/special/Count.yaml +325 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.md +149 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.yaml +315 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.md +51 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.yaml +55 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.md +126 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.yaml +133 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.md +31 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.yaml +34 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.md +27 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.yaml +51 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.md +262 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.yaml +348 -0
- package/public/rjbuild/component-doc/core/example/accordion.md +96 -0
- package/public/rjbuild/component-doc/core/example/accordion.yaml +64 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.md +197 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.yaml +237 -0
- package/public/rjbuild/component-doc/core/example/html.md +66 -0
- package/public/rjbuild/component-doc/core/example/html.yaml +83 -0
- package/public/rjbuild/component-doc/core/example/website.yaml +1663 -0
- package/public/rjbuild/component-doc/core/reaction/addData.md +96 -0
- package/public/rjbuild/component-doc/core/reaction/addData.yaml +133 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.md +60 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.yaml +156 -0
- package/public/rjbuild/component-doc/core/reaction/index.md +236 -0
- package/public/rjbuild/component-doc/core/reaction/index.yaml +254 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.md +68 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.yaml +71 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.md +63 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.yaml +68 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.md +37 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.yaml +37 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.md +78 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.yaml +56 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.md +44 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.yaml +41 -0
- package/public/rjbuild/component-doc/core/reaction/setData.md +93 -0
- package/public/rjbuild/component-doc/core/reaction/setData.yaml +85 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.md +138 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.yaml +141 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.md +59 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.yaml +59 -0
- package/public/rjbuild/component-doc/index.yaml +13 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# ReactOnEvent
|
|
5
|
+
|
|
6
|
+
**Type**: Internal Action Component
|
|
7
|
+
|
|
8
|
+
**Description**: ReactOnEvent is an internal action component that is automatically instantiated by the Actions system when reactions with event handlers (`on: "eventName"`) are detected. It should **not** be used directly as an element type.
|
|
9
|
+
|
|
10
|
+
## How it Works
|
|
11
|
+
|
|
12
|
+
When you define actions with event handlers (like `on: "click"`), the Actions system automatically:
|
|
13
|
+
|
|
14
|
+
1. Collects all reactions with event handlers for the element
|
|
15
|
+
2. Groups them by event type (click, change, mouseover, etc.)
|
|
16
|
+
3. Creates a ReactOnEvent component that attaches the appropriate event listeners
|
|
17
|
+
4. Wraps the target element with these event handlers
|
|
18
|
+
|
|
19
|
+
- type: RjBuildDescriber
|
|
20
|
+
title: "Correct Usage: Reactions with Events"
|
|
21
|
+
description:
|
|
22
|
+
- type: Markdown
|
|
23
|
+
content: |
|
|
24
|
+
This example shows the **correct** way to use event handling in Reactive-JSON.
|
|
25
|
+
|
|
26
|
+
ReactOnEvent is automatically created by the system when you use `on: "eventName"` in actions.
|
|
27
|
+
|
|
28
|
+
toDescribe:
|
|
29
|
+
renderView:
|
|
30
|
+
- type: div
|
|
31
|
+
content:
|
|
32
|
+
- type: button
|
|
33
|
+
content: "Click me"
|
|
34
|
+
actions:
|
|
35
|
+
- what: setData
|
|
36
|
+
on: click # ReactOnEvent handles this automatically
|
|
37
|
+
path: "clicked"
|
|
38
|
+
value: true
|
|
39
|
+
- what: setData
|
|
40
|
+
on: click
|
|
41
|
+
path: "clickCount"
|
|
42
|
+
value: 1
|
|
43
|
+
when: ~.clickCount
|
|
44
|
+
isEmpty: true
|
|
45
|
+
- what: setData
|
|
46
|
+
on: click
|
|
47
|
+
path: "clickCount"
|
|
48
|
+
value: "~.clickCount + 1"
|
|
49
|
+
when: ~.clickCount
|
|
50
|
+
isEmpty: "not"
|
|
51
|
+
|
|
52
|
+
- type: input
|
|
53
|
+
props:
|
|
54
|
+
type: "text"
|
|
55
|
+
placeholder: "Type something..."
|
|
56
|
+
actions:
|
|
57
|
+
- what: setData
|
|
58
|
+
on: change # ReactOnEvent handles this automatically
|
|
59
|
+
path: "inputValue"
|
|
60
|
+
value: "~event.target.value"
|
|
61
|
+
|
|
62
|
+
- type: div
|
|
63
|
+
content: "Mouse over this area"
|
|
64
|
+
props:
|
|
65
|
+
style:
|
|
66
|
+
padding: "10px"
|
|
67
|
+
border: "1px solid #ccc"
|
|
68
|
+
backgroundColor: "~.hovered ? '#f0f0f0' : 'white'"
|
|
69
|
+
actions:
|
|
70
|
+
- what: setData
|
|
71
|
+
on: mouseover # ReactOnEvent handles this automatically
|
|
72
|
+
path: "hovered"
|
|
73
|
+
value: true
|
|
74
|
+
- what: setData
|
|
75
|
+
on: mouseleave # ReactOnEvent handles this automatically
|
|
76
|
+
path: "hovered"
|
|
77
|
+
value: false
|
|
78
|
+
|
|
79
|
+
- type: div
|
|
80
|
+
content:
|
|
81
|
+
- type: div
|
|
82
|
+
content: ["Button clicked: ", ~.clicked]
|
|
83
|
+
|
|
84
|
+
- type: div
|
|
85
|
+
content: ["Click count: ", ~.clickCount]
|
|
86
|
+
|
|
87
|
+
- type: div
|
|
88
|
+
content: ["Input value: '", ~.inputValue, "'"]
|
|
89
|
+
|
|
90
|
+
- type: div
|
|
91
|
+
content: ["Mouse hover state: ", ~.hovered]
|
|
92
|
+
|
|
93
|
+
- type: button
|
|
94
|
+
content: "Reset all"
|
|
95
|
+
actions:
|
|
96
|
+
- what: setData
|
|
97
|
+
on: click
|
|
98
|
+
path: "clicked"
|
|
99
|
+
value: false
|
|
100
|
+
- what: setData
|
|
101
|
+
on: click
|
|
102
|
+
path: "clickCount"
|
|
103
|
+
value: 0
|
|
104
|
+
- what: setData
|
|
105
|
+
on: click
|
|
106
|
+
path: "inputValue"
|
|
107
|
+
value: ""
|
|
108
|
+
- what: setData
|
|
109
|
+
on: click
|
|
110
|
+
path: "hovered"
|
|
111
|
+
value: false
|
|
112
|
+
|
|
113
|
+
data:
|
|
114
|
+
clicked: false
|
|
115
|
+
clickCount: 0
|
|
116
|
+
inputValue: ""
|
|
117
|
+
hovered: false
|
|
118
|
+
|
|
119
|
+
- type: Markdown
|
|
120
|
+
content: |
|
|
121
|
+
## Important Notes
|
|
122
|
+
|
|
123
|
+
- **Never use `type: ReactOnEvent`** in your renderView - it's an internal component
|
|
124
|
+
- **Use `actions` with `on: "eventName"`** - this is the correct way to handle events
|
|
125
|
+
- **ReactOnEvent is automatically instantiated** by the Actions system when needed
|
|
126
|
+
- **Event propagation is stopped by default** - use `stopPropagation: false` to change this
|
|
127
|
+
|
|
128
|
+
## Related Documentation
|
|
129
|
+
|
|
130
|
+
- **[Actions System](index.md)**: Learn about the actions system that uses ReactOnEvent
|
|
131
|
+
- **[Reactions](../reaction/index.md)**: The reaction functions that ReactOnEvent executes
|
|
132
|
+
- **[MessageListener](MessageListener.md)**: For `on: "message"` events
|
|
133
|
+
- **[HashChangeListener](HashChangeListener.md)**: For `on: "hashchange"` events
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Redirect
|
|
2
|
+
|
|
3
|
+
**Description**: Redirects the user to a given URL if the condition is met.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
- `to`: destination URL
|
|
7
|
+
|
|
8
|
+
## Example
|
|
9
|
+
```yaml
|
|
10
|
+
renderView:
|
|
11
|
+
- type: button
|
|
12
|
+
content: "Go to Google"
|
|
13
|
+
actions:
|
|
14
|
+
- what: redirect
|
|
15
|
+
to: "https://www.google.com"
|
|
16
|
+
on: click
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Limitation
|
|
20
|
+
- The redirection is immediate and replaces the current page.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Redirect
|
|
5
|
+
|
|
6
|
+
**Description**: Redirects the user to a given URL if the condition is met.
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
- `to`: destination URL
|
|
10
|
+
|
|
11
|
+
- type: RjBuildDescriber
|
|
12
|
+
title: "Redirect Action Example"
|
|
13
|
+
description:
|
|
14
|
+
- type: Markdown
|
|
15
|
+
content: |
|
|
16
|
+
This example demonstrates the `redirect` action. **Warning**: clicking the button below will actually redirect you!
|
|
17
|
+
|
|
18
|
+
For demonstration purposes, this redirects to a safe page (the current page), but in real usage you would specify any URL.
|
|
19
|
+
|
|
20
|
+
toDescribe:
|
|
21
|
+
renderView:
|
|
22
|
+
- type: div
|
|
23
|
+
content:
|
|
24
|
+
- type: button
|
|
25
|
+
content: "Redirect to Current Page (Safe Demo)"
|
|
26
|
+
actions:
|
|
27
|
+
- what: redirect
|
|
28
|
+
on: click
|
|
29
|
+
to: "."
|
|
30
|
+
|
|
31
|
+
- type: div
|
|
32
|
+
content: "↑ Click the button above to see the redirect in action"
|
|
33
|
+
|
|
34
|
+
- type: button
|
|
35
|
+
content: "Conditional Redirect (Google)"
|
|
36
|
+
actions:
|
|
37
|
+
- what: redirect
|
|
38
|
+
on: click
|
|
39
|
+
to: "https://www.google.com"
|
|
40
|
+
when: ~.allowRedirect
|
|
41
|
+
is: true
|
|
42
|
+
|
|
43
|
+
- type: button
|
|
44
|
+
content: "Toggle Redirect Permission"
|
|
45
|
+
actions:
|
|
46
|
+
- what: setData
|
|
47
|
+
on: click
|
|
48
|
+
path: "allowRedirect"
|
|
49
|
+
value: ~.allowRedirect
|
|
50
|
+
is: false
|
|
51
|
+
- what: setData
|
|
52
|
+
on: click
|
|
53
|
+
path: "allowRedirect"
|
|
54
|
+
value: ~.allowRedirect
|
|
55
|
+
is: true
|
|
56
|
+
when: ~.allowRedirect
|
|
57
|
+
is: false
|
|
58
|
+
|
|
59
|
+
- type: div
|
|
60
|
+
content: ["Redirect allowed: ", ~.allowRedirect]
|
|
61
|
+
|
|
62
|
+
data:
|
|
63
|
+
allowRedirect: false
|
|
64
|
+
|
|
65
|
+
- type: Markdown
|
|
66
|
+
content: |
|
|
67
|
+
## Limitation
|
|
68
|
+
- The redirection is immediate and replaces the current page.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
**Description**: Displays a Bootstrap tooltip when hovering over the element.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
- `content`: tooltip content (text or component)
|
|
7
|
+
- `placement` (optional): tooltip position (`top`, `bottom`, `left`, `right`)
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
```yaml
|
|
11
|
+
renderView:
|
|
12
|
+
- type: button
|
|
13
|
+
content: "Hover me"
|
|
14
|
+
actions:
|
|
15
|
+
- what: tooltip
|
|
16
|
+
content: "This is a tooltip."
|
|
17
|
+
placement: top
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Limitation
|
|
21
|
+
- Requires Bootstrap CSS.
|
|
22
|
+
- The child component must be able to accept a React reference.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Tooltip
|
|
5
|
+
|
|
6
|
+
**Description**: Displays a Bootstrap tooltip when hovering over the element.
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
- `content`: tooltip content (text or component)
|
|
10
|
+
- `placement` (optional): tooltip position (`top`, `bottom`, `left`, `right`)
|
|
11
|
+
|
|
12
|
+
- type: RjBuildDescriber
|
|
13
|
+
title: "Tooltip Action Example"
|
|
14
|
+
description:
|
|
15
|
+
- type: Markdown
|
|
16
|
+
content: |
|
|
17
|
+
This example shows different tooltip configurations. Hover over the buttons to see the tooltips in action.
|
|
18
|
+
|
|
19
|
+
**Note**: Tooltips require Bootstrap CSS to display properly.
|
|
20
|
+
|
|
21
|
+
toDescribe:
|
|
22
|
+
renderView:
|
|
23
|
+
- type: div
|
|
24
|
+
content:
|
|
25
|
+
- type: button
|
|
26
|
+
content: "Hover me (top)"
|
|
27
|
+
actions:
|
|
28
|
+
- what: tooltip
|
|
29
|
+
content: "This is a tooltip on top."
|
|
30
|
+
placement: top
|
|
31
|
+
|
|
32
|
+
- " "
|
|
33
|
+
|
|
34
|
+
- type: button
|
|
35
|
+
content: "Hover me (bottom)"
|
|
36
|
+
actions:
|
|
37
|
+
- what: tooltip
|
|
38
|
+
content: "This is a tooltip on bottom."
|
|
39
|
+
placement: bottom
|
|
40
|
+
|
|
41
|
+
- " "
|
|
42
|
+
|
|
43
|
+
- type: button
|
|
44
|
+
content: "Hover me (left)"
|
|
45
|
+
actions:
|
|
46
|
+
- what: tooltip
|
|
47
|
+
content: "This is a tooltip on left."
|
|
48
|
+
placement: left
|
|
49
|
+
|
|
50
|
+
- " "
|
|
51
|
+
|
|
52
|
+
- type: button
|
|
53
|
+
content: "Hover me (right)"
|
|
54
|
+
actions:
|
|
55
|
+
- what: tooltip
|
|
56
|
+
content: "This is a tooltip on right."
|
|
57
|
+
placement: right
|
|
58
|
+
|
|
59
|
+
- type: br
|
|
60
|
+
|
|
61
|
+
- type: br
|
|
62
|
+
|
|
63
|
+
- type: button
|
|
64
|
+
content: "Dynamic tooltip"
|
|
65
|
+
actions:
|
|
66
|
+
- what: tooltip
|
|
67
|
+
content: ["Current time: ", ~.currentTime]
|
|
68
|
+
placement: top
|
|
69
|
+
|
|
70
|
+
- " "
|
|
71
|
+
|
|
72
|
+
- type: button
|
|
73
|
+
content: "Update time"
|
|
74
|
+
actions:
|
|
75
|
+
- what: setData
|
|
76
|
+
on: click
|
|
77
|
+
path: "currentTime"
|
|
78
|
+
value: "Updated!"
|
|
79
|
+
|
|
80
|
+
- type: div
|
|
81
|
+
content: ["Tooltip content: ", ~.currentTime]
|
|
82
|
+
|
|
83
|
+
data:
|
|
84
|
+
currentTime: "Not set"
|
|
85
|
+
|
|
86
|
+
- type: Markdown
|
|
87
|
+
content: |
|
|
88
|
+
## Limitation
|
|
89
|
+
- Requires Bootstrap CSS.
|
|
90
|
+
- The child component must be able to accept a React reference.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# VisuallyHide
|
|
2
|
+
|
|
3
|
+
**Description**: Visually hides the element but keeps it in the DOM (useful for accessibility or to keep the element reactive to events).
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
- None
|
|
7
|
+
|
|
8
|
+
## Behavior
|
|
9
|
+
- The element is rendered in the DOM but with `display: none`.
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
```yaml
|
|
13
|
+
renderView:
|
|
14
|
+
- type: div
|
|
15
|
+
content: "This text will be visually hidden."
|
|
16
|
+
actions:
|
|
17
|
+
- what: visuallyHide
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Limitation
|
|
21
|
+
- The element remains in the DOM, which can impact accessibility or performance if overused.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# VisuallyHide
|
|
5
|
+
|
|
6
|
+
**Description**: Visually hides the element but keeps it in the DOM (useful for accessibility or to keep the element reactive to events).
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
- None
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
- The element is rendered in the DOM but with `display: none`.
|
|
13
|
+
|
|
14
|
+
- type: RjBuildDescriber
|
|
15
|
+
title: "VisuallyHide Action Example"
|
|
16
|
+
description:
|
|
17
|
+
- type: Markdown
|
|
18
|
+
content: |
|
|
19
|
+
This example shows how the `visuallyHide` action makes an element invisible while keeping it in the DOM.
|
|
20
|
+
|
|
21
|
+
Compare with the `hide` action: visually hidden elements can still respond to events and maintain their place in the DOM structure.
|
|
22
|
+
|
|
23
|
+
toDescribe:
|
|
24
|
+
renderView:
|
|
25
|
+
- type: div
|
|
26
|
+
content:
|
|
27
|
+
- type: button
|
|
28
|
+
content: "Toggle visual hiding"
|
|
29
|
+
actions:
|
|
30
|
+
- what: setData
|
|
31
|
+
on: click
|
|
32
|
+
path: "shouldVisuallyHide"
|
|
33
|
+
value: ~.shouldVisuallyHide
|
|
34
|
+
is: false
|
|
35
|
+
- what: setData
|
|
36
|
+
on: click
|
|
37
|
+
path: "shouldVisuallyHide"
|
|
38
|
+
value: ~.shouldVisuallyHide
|
|
39
|
+
is: true
|
|
40
|
+
when: ~.shouldVisuallyHide
|
|
41
|
+
is: false
|
|
42
|
+
|
|
43
|
+
- type: div
|
|
44
|
+
content: "This text will be visually hidden but remains in the DOM."
|
|
45
|
+
actions:
|
|
46
|
+
- what: visuallyHide
|
|
47
|
+
when: ~.shouldVisuallyHide
|
|
48
|
+
is: true
|
|
49
|
+
|
|
50
|
+
- type: div
|
|
51
|
+
content: ["Current state: shouldVisuallyHide = ", ~.shouldVisuallyHide]
|
|
52
|
+
|
|
53
|
+
- type: div
|
|
54
|
+
content: "↑ Notice the space is preserved even when hidden"
|
|
55
|
+
|
|
56
|
+
data:
|
|
57
|
+
shouldVisuallyHide: false
|
|
58
|
+
|
|
59
|
+
- type: Markdown
|
|
60
|
+
content: |
|
|
61
|
+
## Limitation
|
|
62
|
+
- The element remains in the DOM, which can impact accessibility or performance if overused.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Reactive-JSON Actions System Documentation
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The Reactive-JSON actions system allows you to modify element behavior and appearance based on dynamic conditions. Actions are applied to individual elements and can control visibility, display tooltips, redirect users, or trigger other behaviors based on the current data state.
|
|
6
|
+
|
|
7
|
+
This system enables you to create interactive interfaces directly through JSON configuration, without requiring custom JavaScript code.
|
|
8
|
+
|
|
9
|
+
### Basic Structure
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
renderView:
|
|
13
|
+
- type: div
|
|
14
|
+
content: "My content"
|
|
15
|
+
actions:
|
|
16
|
+
- what: hide # Action type
|
|
17
|
+
when: ~.my_condition # Condition to evaluate
|
|
18
|
+
is: true # Expected value
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## How Actions Work
|
|
22
|
+
|
|
23
|
+
Actions are defined as an array on any element and are evaluated in the order they appear. Each action consists of:
|
|
24
|
+
|
|
25
|
+
- `what`: The type of action to execute
|
|
26
|
+
- **Action-specific properties**: Vary depending on the action type
|
|
27
|
+
- **Conditional properties**: Define when the action should be executed (optional)
|
|
28
|
+
|
|
29
|
+
### Action Types
|
|
30
|
+
|
|
31
|
+
Reactive-JSON provides several built-in actions:
|
|
32
|
+
|
|
33
|
+
- **[hide](Hide.md)**: Completely hides the element and its children
|
|
34
|
+
- **[visuallyHide](VisuallyHide.md)**: Visually hides the element while keeping it accessible to screen readers
|
|
35
|
+
- **[tooltip](Tooltip.md)**: Displays a tooltip on hover
|
|
36
|
+
- **[popover](Popover.md)**: Shows a more complex popover on click
|
|
37
|
+
- **[redirect](Redirect.md)**: Redirects to a specified URL
|
|
38
|
+
|
|
39
|
+
For detailed documentation of each action, including properties and examples, see their respective documentation pages.
|
|
40
|
+
|
|
41
|
+
## Conditional Execution
|
|
42
|
+
|
|
43
|
+
Actions can be made conditional using various comparison operators. If no conditions are specified, the action will always execute.
|
|
44
|
+
|
|
45
|
+
### Basic Comparisons
|
|
46
|
+
- `is`: Value equals exactly
|
|
47
|
+
- `isNot`: Value is different from
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
actions:
|
|
51
|
+
- what: hide
|
|
52
|
+
when: ~.status
|
|
53
|
+
is: "inactive"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Empty Value Tests
|
|
57
|
+
- `isEmpty: true`: Value is empty (null, undefined, "", [], {})
|
|
58
|
+
- `isEmpty: "not"`: Value is not empty
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
actions:
|
|
62
|
+
- what: hide
|
|
63
|
+
when: ~.user.name
|
|
64
|
+
isEmpty: true
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Content Search
|
|
68
|
+
- `contains`: Contains a substring or element
|
|
69
|
+
- `containsNot`: Does not contain a substring or element
|
|
70
|
+
- `containedBy`: Value is contained within another value
|
|
71
|
+
- `containedByNot`: Value is not contained within another value
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
actions:
|
|
75
|
+
- what: hide
|
|
76
|
+
when: ~.user.roles
|
|
77
|
+
contains: "admin"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Numeric and Date Comparisons
|
|
81
|
+
- `">"`: Greater than
|
|
82
|
+
- `"<"`: Less than
|
|
83
|
+
- `">="`: Greater than or equal to
|
|
84
|
+
- `"<="`: Less than or equal to
|
|
85
|
+
- `compareAsDates: true`: Compare values as dates
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
actions:
|
|
89
|
+
- what: hide
|
|
90
|
+
when: ~.user.age
|
|
91
|
+
"<": 18
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Complex Conditions
|
|
95
|
+
- `andConditions`: All conditions must be true
|
|
96
|
+
- `orConditions`: At least one condition must be true
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
actions:
|
|
100
|
+
- what: hide
|
|
101
|
+
andConditions:
|
|
102
|
+
- when: ~.user.role
|
|
103
|
+
is: "user"
|
|
104
|
+
- when: ~.feature_enabled
|
|
105
|
+
is: false
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Data Integration
|
|
109
|
+
|
|
110
|
+
Actions use Reactive-JSON's template system with the `~` operator to access data:
|
|
111
|
+
|
|
112
|
+
- `~.property`: Access a property from the data context
|
|
113
|
+
- `~.object.property`: Navigate through nested objects
|
|
114
|
+
- `~.array[0]`: Access array elements
|
|
115
|
+
|
|
116
|
+
The template system resolves these paths at runtime and provides the current values for condition evaluation.
|
|
117
|
+
|
|
118
|
+
## Execution Order and Behavior
|
|
119
|
+
|
|
120
|
+
1. **Sequential evaluation**: Actions are evaluated in the order they appear in the array
|
|
121
|
+
2. **Condition precedence**: Conditions are evaluated before action execution
|
|
122
|
+
3. **Early termination**: Some actions (like `hide`) prevent subsequent actions from executing
|
|
123
|
+
4. **Synchronous execution**: All condition evaluations and actions are synchronous
|
|
124
|
+
|
|
125
|
+
## Practical Examples
|
|
126
|
+
|
|
127
|
+
### Conditional Element Visibility
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
renderView:
|
|
131
|
+
- type: div
|
|
132
|
+
content: "Admin-only section"
|
|
133
|
+
actions:
|
|
134
|
+
- what: hide
|
|
135
|
+
when: ~.user.role
|
|
136
|
+
isNot: "admin"
|
|
137
|
+
|
|
138
|
+
- type: button
|
|
139
|
+
content: "Advanced feature"
|
|
140
|
+
actions:
|
|
141
|
+
- what: hide
|
|
142
|
+
when: ~.user.permissions
|
|
143
|
+
containsNot: "advanced_actions"
|
|
144
|
+
|
|
145
|
+
data:
|
|
146
|
+
user:
|
|
147
|
+
role: "user"
|
|
148
|
+
permissions: ["read", "write"]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Contextual Help Interface
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
renderView:
|
|
155
|
+
- type: label
|
|
156
|
+
content: "Username"
|
|
157
|
+
actions:
|
|
158
|
+
- what: tooltip
|
|
159
|
+
content: "Use only letters and numbers"
|
|
160
|
+
placement: "right"
|
|
161
|
+
|
|
162
|
+
- type: button
|
|
163
|
+
content: "More info"
|
|
164
|
+
actions:
|
|
165
|
+
- what: popover
|
|
166
|
+
title: "Detailed help"
|
|
167
|
+
content: "Complete instructions..."
|
|
168
|
+
placement: "top"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Authentication Flow
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
renderView:
|
|
175
|
+
- type: div
|
|
176
|
+
content: "Access denied"
|
|
177
|
+
actions:
|
|
178
|
+
- what: redirect
|
|
179
|
+
to: "/login"
|
|
180
|
+
when: ~.user.authenticated
|
|
181
|
+
is: false
|
|
182
|
+
|
|
183
|
+
- what: hide
|
|
184
|
+
when: ~.user.authenticated
|
|
185
|
+
is: true
|
|
186
|
+
|
|
187
|
+
data:
|
|
188
|
+
user:
|
|
189
|
+
authenticated: false
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Technical Limitations
|
|
193
|
+
|
|
194
|
+
1. **Execution order**: Actions are evaluated in definition order and cannot be reordered dynamically
|
|
195
|
+
2. **Hide behavior**: Once an element is hidden with the `hide` action, no subsequent actions execute
|
|
196
|
+
3. **Synchronous evaluation**: All conditions and actions are evaluated synchronously
|
|
197
|
+
4. **Data scope**: Actions can only access data from the current template context and global context
|
|
198
|
+
5. **No side effects**: Actions cannot directly modify global state or trigger reactions
|
|
199
|
+
6. **External dependencies**: Some actions (tooltip, popover) require React Bootstrap components
|
|
200
|
+
|
|
201
|
+
## Best Practices
|
|
202
|
+
|
|
203
|
+
1. **Keep conditions simple**: Avoid overly complex condition logic for better maintainability
|
|
204
|
+
2. **Consider performance**: Minimize frequently-evaluated complex conditions
|
|
205
|
+
3. **Use appropriate actions**: Choose `visuallyHide` over `hide` when content should remain accessible
|
|
206
|
+
4. **Test thoroughly**: Verify action behavior with different data states
|
|
207
|
+
5. **Document complex logic**: Add comments for non-obvious conditional logic
|
|
208
|
+
6. **Order matters**: Place critical actions (like `hide`) early in the action array when appropriate
|
|
209
|
+
|
|
210
|
+
## Related Documentation
|
|
211
|
+
|
|
212
|
+
- **Individual Action Documentation**: See the dedicated pages for each action type
|
|
213
|
+
- **[Reactions System](../reaction/index.md)**: Learn about handling user events and state changes
|
|
214
|
+
- **[Template System](../../template-system.md)**: Understand data binding and template expressions
|