@ea-lab/reactive-json-docs 0.4.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 (36) hide show
  1. package/package.json +2 -2
  2. package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
  3. package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
  4. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
  5. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
  6. package/public/rjbuild/docs/core/action/Hide.md +1 -1
  7. package/public/rjbuild/docs/core/action/Hide.yaml +10 -10
  8. package/public/rjbuild/docs/core/action/ReactOnEvent.md +12 -12
  9. package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +61 -101
  10. package/public/rjbuild/docs/core/action/Redirect.md +10 -2
  11. package/public/rjbuild/docs/core/action/Redirect.yaml +18 -51
  12. package/public/rjbuild/docs/core/action/VisuallyHide.yaml +10 -12
  13. package/public/rjbuild/docs/core/action/index.md +19 -204
  14. package/public/rjbuild/docs/core/action/index.yaml +19 -264
  15. package/public/rjbuild/docs/core/element/form/DateField.md +1 -1
  16. package/public/rjbuild/docs/core/element/form/DateField.yaml +4 -4
  17. package/public/rjbuild/docs/core/element/form/SelectField.yaml +2 -2
  18. package/public/rjbuild/docs/core/example/website.yaml +10 -10
  19. package/public/rjbuild/docs/core/reaction/index.md +17 -229
  20. package/public/rjbuild/docs/core/reaction/index.yaml +14 -242
  21. package/public/rjbuild/docs/core/reaction/setData.md +1 -1
  22. package/public/rjbuild/docs/core/reaction/setData.yaml +1 -1
  23. package/public/rjbuild/docs/docs-components/index.md +0 -2
  24. package/public/rjbuild/docs/docs-components/index.yaml +0 -2
  25. package/public/rjbuild/docs/getting-started/actions.md +294 -0
  26. package/public/rjbuild/docs/getting-started/actions.yaml +403 -0
  27. package/public/rjbuild/docs/getting-started/index.md +30 -6
  28. package/public/rjbuild/docs/getting-started/index.yaml +20 -6
  29. package/public/rjbuild/docs/getting-started/reactions.md +301 -0
  30. package/public/rjbuild/docs/getting-started/reactions.yaml +300 -0
  31. package/public/rjbuild/docs/getting-started/rjbuild-structure.md +10 -4
  32. package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +10 -4
  33. package/public/rjbuild/docs/getting-started/{template.md → template-contexts-data-binding.md} +16 -12
  34. package/public/rjbuild/docs/getting-started/{template.yaml → template-contexts-data-binding.yaml} +28 -14
  35. /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.md +0 -0
  36. /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.yaml +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ea-lab/reactive-json-docs",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Complete documentation for Reactive-JSON - Components, examples and LLM-parsable guides",
5
5
  "main": "public/rjbuild/docs/index.yaml",
6
6
  "files": [
@@ -26,7 +26,7 @@
26
26
  "private": false,
27
27
  "devDependencies": {
28
28
  "@craco/craco": "^7.1.0",
29
- "@ea-lab/reactive-json": "^0.3.1",
29
+ "@ea-lab/reactive-json": "^0.4.0",
30
30
  "@ea-lab/reactive-json-chartjs": "^0.0.23",
31
31
  "@npmcli/fs": "^4.0.0",
32
32
  "@reduxjs/toolkit": "^2.6.1",
@@ -6,4 +6,5 @@ This section covers advanced features and concepts in Reactive-JSON that enable
6
6
 
7
7
  - **[Data Mapping](data-mapping.md)**: Learn how to selectively dispatch and transform response data using the Data Mapping system
8
8
  - **[Data Processors](data-processors.md)**: Learn how to intercept and modify data from HTTP requests using the DataProcessor system
9
+ - **[Forward Update](forward-update.md)**: Implementation details about the retrieval of event values.
9
10
  - **[Plugins](plugins/index.md)**: Learn how to extend Reactive-JSON with custom components and plugins.
@@ -9,6 +9,7 @@ renderView:
9
9
 
10
10
  - **[Data Mapping](data-mapping)**: Learn how to selectively dispatch and transform response data using the Data Mapping system.
11
11
  - **[Data Processors](data-processors)**: Learn how to intercept and modify data from HTTP requests using the DataProcessor system.
12
+ - **[Forward Update](forward-update)**: Implementation details about the retrieval of event values.
12
13
  - **[Plugins](plugins/index)**: Learn how to extend Reactive-JSON with custom components and plugins.
13
14
 
14
15
  data:
@@ -19,7 +19,7 @@ All components have access to these React contexts:
19
19
  - **TemplateContext**: Contains current template data for evaluation
20
20
 
21
21
  Other specialized contexts are available.
22
- - **EventDispatcherContext**: Centralized event handling system, mostly used by the [reaction system](/docs/core/reaction/index).
22
+ - **EventDispatcherContext**: Centralized event handling system, mostly used by the [reaction system](/docs/getting-started/reactions).
23
23
  - **PaginationContext**: Used by components that integrate pagination, such as [Switch](/docs/core/element/special/Switch).
24
24
 
25
25
  ## Basic Element Component
@@ -22,7 +22,7 @@ renderView:
22
22
  - **TemplateContext**: Contains current template data for evaluation
23
23
 
24
24
  Other specialized contexts are available.
25
- - **EventDispatcherContext**: Centralized event handling system, mostly used by the [reaction system](/docs/core/reaction/index).
25
+ - **EventDispatcherContext**: Centralized event handling system, mostly used by the [reaction system](/docs/getting-started/reactions).
26
26
  - **PaginationContext**: Used by components that integrate pagination, such as [Switch](/docs/core/element/special/Switch).
27
27
 
28
28
  ## Basic Element Component
@@ -19,4 +19,4 @@ renderView:
19
19
  ```
20
20
 
21
21
  ## Limitation
22
- - The element no longer exists in the DOM, so no events can be attached to it.
22
+ - When hidden, the element no longer exists in the DOM, so no events can be attached to it.
@@ -30,31 +30,31 @@ renderView:
30
30
  actions:
31
31
  - what: setData
32
32
  on: click
33
- path: "shouldHide"
34
- value: ~.shouldHide
35
- is: false
33
+ path: ~.shouldHide
34
+ value: "true"
35
+ when: ~.shouldHide
36
+ is: "false"
36
37
  - what: setData
37
38
  on: click
38
- path: "shouldHide"
39
- value: ~.shouldHide
40
- is: true
39
+ path: ~.shouldHide
40
+ value: "false"
41
41
  when: ~.shouldHide
42
- is: false
42
+ is: "true"
43
43
 
44
44
  - type: div
45
45
  content: "This text will be hidden when shouldHide is true."
46
46
  actions:
47
47
  - what: hide
48
48
  when: ~.shouldHide
49
- is: true
49
+ is: "true"
50
50
 
51
51
  - type: div
52
52
  content: ["Current state: shouldHide = ", ~.shouldHide]
53
53
 
54
54
  data:
55
- shouldHide: false
55
+ shouldHide: "false"
56
56
 
57
57
  - type: Markdown
58
58
  content: |
59
59
  ## Limitation
60
- - The element no longer exists in the DOM, so no events can be attached to it.
60
+ - When hidden, the element no longer exists in the DOM, so no events can be attached to it.
@@ -1,8 +1,8 @@
1
1
  # ReactOnEvent
2
2
 
3
- **Type**: Internal Action Component
3
+ 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.
4
4
 
5
- **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.
5
+ > **Important**: It should **not** be used directly as an element type. The Reactive-JSON engine will automatically instantiate it when needed.
6
6
 
7
7
  ## How it Works
8
8
 
@@ -43,8 +43,8 @@ ReactOnEvent supports any DOM event by prefixing with `on` and capitalizing the
43
43
 
44
44
  Some events have special handling and **do not** use ReactOnEvent:
45
45
 
46
- - `on: "message"` → Uses MessageListener component (listens on window)
47
- - `on: "hashchange"` → Uses HashChangeListener component (listens on window)
46
+ - `on: "message"` → Uses the [MessageListener](MessageListener.md) component (listens on window)
47
+ - `on: "hashchange"` → Uses the [HashChangeListener](HashChangeListener.md) component (listens on window)
48
48
 
49
49
  ## Event Propagation Control
50
50
 
@@ -67,15 +67,15 @@ actions:
67
67
  - **Context preservation**: Maintains access to global and template data contexts
68
68
  - **Early termination**: Supports `stopPropagation: true` to halt reaction chain execution
69
69
 
70
+ ## Important Notes
71
+
72
+ - **Never use `type: ReactOnEvent`** in your renderView - it's an internal component
73
+ - **Use `actions` with `on: "eventName"`** - this is the correct way to handle events
74
+ - **ReactOnEvent is automatically instantiated** by the Actions system when needed
75
+ - **Event propagation is stopped by default** - use `stopPropagation: false` to change this
76
+
70
77
  ## Related Components
71
78
 
72
79
  - **[MessageListener](MessageListener.md)**: Handles `on: "message"` events
73
80
  - **[HashChangeListener](HashChangeListener.md)**: Handles `on: "hashchange"` events
74
- - **[Reactions System](../reaction/index.md)**: The actual reaction functions that ReactOnEvent executes
75
-
76
- ## Important Notes
77
-
78
- - **Not for direct use**: Never use `type: ReactOnEvent` in your renderView
79
- - **Automatic instantiation**: The Actions system creates this component automatically
80
- - **Internal implementation**: This is part of the framework's internal architecture
81
- - **Event binding**: Events are bound to the actual DOM elements, not wrapper components
81
+ - **[Reactions System](../../getting-started/reactions.md)**: The actual reaction functions that ReactOnEvent executes
@@ -3,9 +3,9 @@ renderView:
3
3
  content: |
4
4
  # ReactOnEvent
5
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.
6
+ ReactOnEvent is an internal action component that is automatically instantiated by the Actions system when reactions with event handlers (`on: "eventName"`) are detected.
7
+
8
+ > **Important**: It should **not** be used directly as an element type. The Reactive-JSON engine will automatically instantiate it when needed.
9
9
 
10
10
  ## How it Works
11
11
 
@@ -16,105 +16,66 @@ renderView:
16
16
  3. Creates a ReactOnEvent component that attaches the appropriate event listeners
17
17
  4. Wraps the target element with these event handlers
18
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.
19
+ ## Usage Pattern
27
20
 
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]
21
+ Instead of using ReactOnEvent directly, you define reactions in the `actions` array of any element:
92
22
 
23
+ ```yaml
24
+ renderView:
93
25
  - type: button
94
- content: "Reset all"
26
+ content: "Click me"
95
27
  actions:
96
28
  - 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
29
+ on: click # This triggers ReactOnEvent internally
30
+ path: "buttonClicked"
31
+ value: true
32
+ ```
33
+
34
+ ## Supported Event Types
35
+
36
+ ReactOnEvent supports any DOM event by prefixing with `on` and capitalizing the first letter:
37
+
38
+ - `on: click` → `onClick`
39
+ - `on: change` → `onChange`
40
+ - `on: mouseover` → `onMouseOver`
41
+ - `on: keydown` → `onKeyDown`
42
+ - `on: submit` → `onSubmit`
43
+ - etc.
44
+
45
+ ## Special Event Handling
46
+
47
+ Some events have special handling and **do not** use ReactOnEvent:
48
+
49
+ - `on: "message"` → Uses the [MessageListener](MessageListener.md) component (listens on window)
50
+ - `on: "hashchange"` → Uses the [HashChangeListener](HashChangeListener.md) component (listens on window)
51
+
52
+ ## Event Propagation Control
53
+
54
+ By default, ReactOnEvent stops event propagation. You can control this behavior:
55
+
56
+ ```yaml
57
+ actions:
58
+ - what: setData
59
+ on: click
60
+ path: "clicked"
61
+ value: true
62
+ stopPropagation: false # Allow event to continue propagating
63
+ ```
64
+
65
+ ## Event Placeholders
66
+
67
+ ReactOnEvent supports special placeholders to access event data:
68
+
69
+ - `<reactive-json:event-new-value>`: Returns the most relevant value from form events (checked for checkboxes, value for inputs)
70
+ - `<reactive-json:event>.propertyPath`: Access any event property (e.g., `.data.message` for MessageEvent, `.key` for KeyboardEvent)
71
+
72
+ ## Technical Implementation
112
73
 
113
- data:
114
- clicked: false
115
- clickCount: 0
116
- inputValue: ""
117
- hovered: false
74
+ - **Event attachment**: Uses React's event system via `cloneElement`
75
+ - **Multiple events**: Can handle multiple event types on the same element
76
+ - **Reaction execution**: Executes reactions in the order they appear
77
+ - **Context preservation**: Maintains access to global and template data contexts
78
+ - **Early termination**: Supports `stopPropagation: true` to halt reaction chain execution
118
79
 
119
80
  - type: Markdown
120
81
  content: |
@@ -125,9 +86,8 @@ renderView:
125
86
  - **ReactOnEvent is automatically instantiated** by the Actions system when needed
126
87
  - **Event propagation is stopped by default** - use `stopPropagation: false` to change this
127
88
 
128
- ## Related Documentation
89
+ ## Related Components
129
90
 
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
91
+ - **[MessageListener](MessageListener.md)**: Handles `on: "message"` events
92
+ - **[HashChangeListener](HashChangeListener.md)**: Handles `on: "hashchange"` events
93
+ - **[Reactions System](../../getting-started/reactions.md)**: The actual reaction functions that ReactOnEvent executes
@@ -6,14 +6,22 @@
6
6
  - `to`: destination URL
7
7
 
8
8
  ## Example
9
+
10
+ The following example will redirect the current page when the user clicks on the button.
11
+
9
12
  ```yaml
10
13
  renderView:
11
14
  - type: button
12
- content: "Go to Google"
15
+ content: "Go to EA Lab"
13
16
  actions:
14
17
  - what: redirect
15
- to: "https://www.google.com"
18
+ to: "https://ea-lab.io"
19
+ when: ~~.allowRedirect
20
+ is: "true"
21
+ - what: setData
16
22
  on: click
23
+ path: ~~.allowRedirect
24
+ value: "true"
17
25
  ```
18
26
 
19
27
  ## Limitation
@@ -8,59 +8,26 @@ renderView:
8
8
  ## Properties
9
9
  - `to`: destination URL
10
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
11
+ - type: Markdown
12
+ content: |
13
+ ## Example
58
14
 
59
- - type: div
60
- content: ["Redirect allowed: ", ~.allowRedirect]
15
+ The following example will redirect the current page when the user clicks on the button.
61
16
 
62
- data:
63
- allowRedirect: false
17
+ ```yaml
18
+ renderView:
19
+ - type: button
20
+ content: "Go to EA Lab"
21
+ actions:
22
+ - what: redirect
23
+ to: "https://ea-lab.io"
24
+ when: ~~.allowRedirect
25
+ is: "true"
26
+ - what: setData
27
+ on: click
28
+ path: ~~.allowRedirect
29
+ value: "true"
30
+ ```
64
31
 
65
32
  - type: Markdown
66
33
  content: |
@@ -29,32 +29,30 @@ renderView:
29
29
  actions:
30
30
  - what: setData
31
31
  on: click
32
- path: "shouldVisuallyHide"
33
- value: ~.shouldVisuallyHide
34
- is: false
32
+ path: ~.shouldVisuallyHide
33
+ value: "false"
34
+ when: ~.shouldVisuallyHide
35
+ is: "true"
36
+ stopPropagation: true
35
37
  - what: setData
36
38
  on: click
37
- path: "shouldVisuallyHide"
38
- value: ~.shouldVisuallyHide
39
- is: true
39
+ path: ~.shouldVisuallyHide
40
+ value: "true"
40
41
  when: ~.shouldVisuallyHide
41
- is: false
42
+ is: "false"
42
43
 
43
44
  - type: div
44
45
  content: "This text will be visually hidden but remains in the DOM."
45
46
  actions:
46
47
  - what: visuallyHide
47
48
  when: ~.shouldVisuallyHide
48
- is: true
49
+ is: "true"
49
50
 
50
51
  - type: div
51
52
  content: ["Current state: shouldVisuallyHide = ", ~.shouldVisuallyHide]
52
53
 
53
- - type: div
54
- content: "↑ Notice the space is preserved even when hidden"
55
-
56
54
  data:
57
- shouldVisuallyHide: false
55
+ shouldVisuallyHide: "false"
58
56
 
59
57
  - type: Markdown
60
58
  content: |