@ea-lab/reactive-json-docs 1.0.0-alpha.0 → 1.0.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/advanced-concepts/attribute-transformers.md +168 -0
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/forward-update.md +2 -2
- package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +2 -2
- package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +1 -1
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
- package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
- package/public/rjbuild/docs/core/hook/index.md +38 -0
- package/public/rjbuild/docs/core/hook/index.yaml +44 -0
- package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
- package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ea-lab/reactive-json-docs",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.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": "^1.0.
|
|
29
|
+
"@ea-lab/reactive-json": "^1.0.1",
|
|
30
30
|
"@ea-lab/reactive-json-chartjs": "^1.0.0",
|
|
31
31
|
"@npmcli/fs": "^4.0.0",
|
|
32
32
|
"@reduxjs/toolkit": "^2.6.1",
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Attribute Transformers
|
|
2
|
+
|
|
3
|
+
> **Note**: Reactive-JSON provides two systems for attribute modification:
|
|
4
|
+
>
|
|
5
|
+
> - **Attribute Transformers** (this section): Execute **before rendering**, modify attributes for child components
|
|
6
|
+
> - **[Attribute Actions](../core/action/Attribute/index.md)**: Execute **after rendering**, modify DOM attributes directly
|
|
7
|
+
>
|
|
8
|
+
> Choose transformers for pre-render attribute conditioning and actions for post-render DOM manipulation.
|
|
9
|
+
|
|
10
|
+
Attribute Transformers in Reactive-JSON allow you to modify element attributes before rendering based on dynamic conditions. They are evaluated during the attribute evaluation phase and provide pre-render attribute manipulation capabilities.
|
|
11
|
+
|
|
12
|
+
## Key Differences from Actions
|
|
13
|
+
|
|
14
|
+
- **Timing**: Attribute transformers execute **before rendering**, while actions execute **after rendering**
|
|
15
|
+
- **Impact**: Transformers affect attributes passed to child components, actions modify the DOM directly
|
|
16
|
+
- **Use case**: Transformers are ideal for conditional attribute values that need to be available to child components
|
|
17
|
+
|
|
18
|
+
## Available Transformers
|
|
19
|
+
|
|
20
|
+
For a complete list of built-in attribute transformers, see **[Attribute Transformers Reference](../core/attributeTransformer/index.md)**.
|
|
21
|
+
|
|
22
|
+
## Extensibility
|
|
23
|
+
|
|
24
|
+
The Attribute Transformer system is fully extensible through the plugin system. You can create custom transformers to handle specific attribute manipulation needs in your application.
|
|
25
|
+
|
|
26
|
+
### Creating Custom Attribute Transformers
|
|
27
|
+
|
|
28
|
+
Attribute transformers are JavaScript functions that receive attributes and transformation properties, then return the modified attributes:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// customTransformer.js
|
|
32
|
+
export const myCustomTransformer = ({ attributes, globalDataContext, singleTransformProps, templateContext }) => {
|
|
33
|
+
const { name, customProperty } = singleTransformProps;
|
|
34
|
+
|
|
35
|
+
// Your custom logic here
|
|
36
|
+
// Modify the attributes object
|
|
37
|
+
|
|
38
|
+
return attributes;
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Plugin Registration
|
|
43
|
+
|
|
44
|
+
Include your custom transformers in a plugin and register them with ReactiveJsonRoot:
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// myPlugin.js
|
|
48
|
+
import { myCustomTransformer } from "./transformers/customTransformer.js";
|
|
49
|
+
|
|
50
|
+
export const myPlugin = {
|
|
51
|
+
attributeTransformer: {
|
|
52
|
+
myCustomTransformer,
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
// App.js
|
|
59
|
+
import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
|
|
60
|
+
import { myPlugin } from "./plugins/myPlugin.js";
|
|
61
|
+
|
|
62
|
+
const App = () => {
|
|
63
|
+
return (
|
|
64
|
+
<ReactiveJsonRoot
|
|
65
|
+
plugins={mergeComponentCollections([myPlugin])}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Usage in RjBuild
|
|
72
|
+
|
|
73
|
+
Once registered, your custom transformer can be used in any element:
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
renderView:
|
|
77
|
+
- type: div
|
|
78
|
+
attributes:
|
|
79
|
+
class: "base-class"
|
|
80
|
+
attributeTransforms:
|
|
81
|
+
- what: myCustomTransformer
|
|
82
|
+
name: "data-custom"
|
|
83
|
+
customProperty: "value"
|
|
84
|
+
when: ~~.someCondition
|
|
85
|
+
is: true
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For detailed component development guidance, see **[Plugin Development](./plugins/index.md)**.
|
|
89
|
+
|
|
90
|
+
## Basic Usage
|
|
91
|
+
|
|
92
|
+
Attribute transformers are defined in the `attributeTransforms` array on any element:
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
renderView:
|
|
96
|
+
- type: div
|
|
97
|
+
attributes:
|
|
98
|
+
class: "base-class"
|
|
99
|
+
data-status: "default"
|
|
100
|
+
attributeTransforms:
|
|
101
|
+
# Add class conditionally
|
|
102
|
+
- what: setAttributeValue
|
|
103
|
+
name: "class"
|
|
104
|
+
value: "active"
|
|
105
|
+
when: ~~.isActive
|
|
106
|
+
is: true
|
|
107
|
+
|
|
108
|
+
# Remove attribute entirely
|
|
109
|
+
- what: unsetAttribute
|
|
110
|
+
name: "data-status"
|
|
111
|
+
when: ~~.hideStatus
|
|
112
|
+
is: true
|
|
113
|
+
|
|
114
|
+
# Toggle between states
|
|
115
|
+
- what: toggleAttributeValue
|
|
116
|
+
name: "class"
|
|
117
|
+
value: ["theme-light", "theme-dark"]
|
|
118
|
+
when: ~~.toggleTheme
|
|
119
|
+
isNotEmpty:
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Execution Order
|
|
123
|
+
|
|
124
|
+
Attribute transformers are applied in the order they appear in the `attributeTransforms` array:
|
|
125
|
+
|
|
126
|
+
1. Base attributes are evaluated (template resolution)
|
|
127
|
+
2. Each transformer is applied sequentially
|
|
128
|
+
3. The final attributes are passed to the component/element
|
|
129
|
+
|
|
130
|
+
## Conditional Execution
|
|
131
|
+
|
|
132
|
+
All attribute transformers support the same conditional system as actions:
|
|
133
|
+
|
|
134
|
+
- **`when`**: Specifies the data value to evaluate
|
|
135
|
+
- **`is`**: Exact value comparison
|
|
136
|
+
- **`isEmpty`/`isNotEmpty`**: Empty/non-empty checks
|
|
137
|
+
- **Template evaluation**: Full support for `~.`, `~~.`, `~>`, `~~>` patterns
|
|
138
|
+
|
|
139
|
+
## Common Patterns
|
|
140
|
+
|
|
141
|
+
### Conditional Styling
|
|
142
|
+
```yaml
|
|
143
|
+
attributeTransforms:
|
|
144
|
+
- what: setAttributeValue
|
|
145
|
+
name: "class"
|
|
146
|
+
value: "error"
|
|
147
|
+
when: ~~.validation.hasErrors
|
|
148
|
+
is: true
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### State-based Attributes
|
|
152
|
+
```yaml
|
|
153
|
+
attributeTransforms:
|
|
154
|
+
- what: toggleAttributeValue
|
|
155
|
+
name: "aria-expanded"
|
|
156
|
+
value: "true"
|
|
157
|
+
when: ~~.menu.isOpen
|
|
158
|
+
is: true
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Dynamic Data Attributes
|
|
162
|
+
```yaml
|
|
163
|
+
attributeTransforms:
|
|
164
|
+
- what: setAttributeValue
|
|
165
|
+
name: "data-user-role"
|
|
166
|
+
value: ~~.currentUser.role
|
|
167
|
+
mode: "replace"
|
|
168
|
+
```
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Attribute Transformers
|
|
5
|
+
|
|
6
|
+
> **Note**: Reactive-JSON provides two systems for attribute modification:
|
|
7
|
+
>
|
|
8
|
+
> - **Attribute Transformers** (this section): Execute **before rendering**, modify attributes for child components
|
|
9
|
+
> - **[Attribute Actions](../core/action/Attribute/index)**: Execute **after rendering**, modify DOM attributes directly
|
|
10
|
+
>
|
|
11
|
+
> Choose transformers for pre-render attribute conditioning and actions for post-render DOM manipulation.
|
|
12
|
+
|
|
13
|
+
Attribute Transformers in Reactive-JSON allow you to modify element attributes before rendering based on dynamic conditions. They are evaluated during the attribute evaluation phase and provide pre-render attribute manipulation capabilities.
|
|
14
|
+
|
|
15
|
+
- type: TabbedSerializer
|
|
16
|
+
yamlSerializedContent: |
|
|
17
|
+
renderView:
|
|
18
|
+
- type: div
|
|
19
|
+
attributes:
|
|
20
|
+
class: "base-class"
|
|
21
|
+
data-status: "default"
|
|
22
|
+
attributeTransforms:
|
|
23
|
+
# Add class conditionally
|
|
24
|
+
- what: setAttributeValue
|
|
25
|
+
name: "class"
|
|
26
|
+
value: "active"
|
|
27
|
+
when: ~~.isActive
|
|
28
|
+
is: true
|
|
29
|
+
|
|
30
|
+
# Remove attribute entirely
|
|
31
|
+
- what: unsetAttribute
|
|
32
|
+
name: "data-status"
|
|
33
|
+
when: ~~.hideStatus
|
|
34
|
+
is: true
|
|
35
|
+
|
|
36
|
+
# Toggle between states
|
|
37
|
+
- what: toggleAttributeValue
|
|
38
|
+
name: "class"
|
|
39
|
+
value: ["theme-light", "theme-dark"]
|
|
40
|
+
when: ~~.toggleTheme
|
|
41
|
+
isNotEmpty:
|
|
42
|
+
|
|
43
|
+
- type: Markdown
|
|
44
|
+
content: |
|
|
45
|
+
## Key Differences from Actions
|
|
46
|
+
|
|
47
|
+
- **Timing**: Attribute transformers execute **before rendering**, while actions execute **after rendering**
|
|
48
|
+
- **Impact**: Transformers affect attributes passed to child components, actions modify the DOM directly
|
|
49
|
+
- **Use case**: Transformers are ideal for conditional attribute values that need to be available to child components
|
|
50
|
+
|
|
51
|
+
## Available Transformers
|
|
52
|
+
|
|
53
|
+
For a complete list of built-in attribute transformers, see **[Attribute Transformers Reference](../core/attributeTransformer/index)**.
|
|
54
|
+
|
|
55
|
+
## Extensibility
|
|
56
|
+
|
|
57
|
+
The Attribute Transformer system is fully extensible through the plugin system. You can create custom transformers to handle specific attribute manipulation needs in your application.
|
|
58
|
+
|
|
59
|
+
### Creating Custom Attribute Transformers
|
|
60
|
+
|
|
61
|
+
Attribute transformers are JavaScript functions that receive attributes and transformation properties, then return the modified attributes:
|
|
62
|
+
|
|
63
|
+
- type: SyntaxHighlighter
|
|
64
|
+
language: javascript
|
|
65
|
+
content: |
|
|
66
|
+
// customTransformer.js
|
|
67
|
+
export const myCustomTransformer = ({ attributes, globalDataContext, singleTransformProps, templateContext }) => {
|
|
68
|
+
const { name, customProperty } = singleTransformProps;
|
|
69
|
+
|
|
70
|
+
// Your custom logic here
|
|
71
|
+
// Modify the attributes object
|
|
72
|
+
|
|
73
|
+
return attributes;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
- type: Markdown
|
|
77
|
+
content: |
|
|
78
|
+
### Plugin Registration
|
|
79
|
+
|
|
80
|
+
Include your custom transformers in a plugin and register them with ReactiveJsonRoot:
|
|
81
|
+
|
|
82
|
+
- type: SyntaxHighlighter
|
|
83
|
+
language: javascript
|
|
84
|
+
content: |
|
|
85
|
+
// myPlugin.js
|
|
86
|
+
import { myCustomTransformer } from "./transformers/customTransformer.js";
|
|
87
|
+
|
|
88
|
+
export const myPlugin = {
|
|
89
|
+
attributeTransformer: {
|
|
90
|
+
myCustomTransformer,
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
- type: SyntaxHighlighter
|
|
95
|
+
language: javascript
|
|
96
|
+
content: |
|
|
97
|
+
// App.js
|
|
98
|
+
import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
|
|
99
|
+
import { myPlugin } from "./plugins/myPlugin.js";
|
|
100
|
+
|
|
101
|
+
const App = () => {
|
|
102
|
+
return (
|
|
103
|
+
<ReactiveJsonRoot
|
|
104
|
+
plugins={mergeComponentCollections([myPlugin])}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
- type: Markdown
|
|
110
|
+
content: |
|
|
111
|
+
### Usage in RjBuild
|
|
112
|
+
|
|
113
|
+
Once registered, your custom transformer can be used in any element:
|
|
114
|
+
|
|
115
|
+
- type: TabbedSerializer
|
|
116
|
+
yamlSerializedContent: |
|
|
117
|
+
renderView:
|
|
118
|
+
- type: div
|
|
119
|
+
attributes:
|
|
120
|
+
class: "base-class"
|
|
121
|
+
attributeTransforms:
|
|
122
|
+
- what: myCustomTransformer
|
|
123
|
+
name: "data-custom"
|
|
124
|
+
customProperty: "value"
|
|
125
|
+
when: ~~.someCondition
|
|
126
|
+
is: true
|
|
127
|
+
|
|
128
|
+
- type: Markdown
|
|
129
|
+
content: |
|
|
130
|
+
For detailed component development guidance, see **[Plugin Development](./plugins/index)**.
|
|
131
|
+
|
|
132
|
+
## Execution Order
|
|
133
|
+
|
|
134
|
+
Attribute transformers are applied in the order they appear in the `attributeTransforms` array:
|
|
135
|
+
|
|
136
|
+
1. Base attributes are evaluated (template resolution)
|
|
137
|
+
2. Each transformer is applied sequentially
|
|
138
|
+
3. The final attributes are passed to the component/element
|
|
139
|
+
|
|
140
|
+
## Conditional Execution
|
|
141
|
+
|
|
142
|
+
All attribute transformers support the same conditional system as actions:
|
|
143
|
+
|
|
144
|
+
- **`when`**: Specifies the data value to evaluate
|
|
145
|
+
- **`is`**: Exact value comparison
|
|
146
|
+
- **`isEmpty`/`isNotEmpty`**: Empty/non-empty checks
|
|
147
|
+
- **Template evaluation**: Full support for `~.`, `~~.`, `~>`, `~~>` patterns
|
|
148
|
+
|
|
149
|
+
data:
|
|
150
|
+
page_title: "Attribute Transformers - Reactive-JSON Documentation"
|
|
151
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Data
|
|
1
|
+
# Data mapping
|
|
2
2
|
|
|
3
|
-
Data
|
|
3
|
+
Data mapping is a powerful, extensible system in Reactive-JSON that allows you to selectively dispatch and transform response data from HTTP requests to specific locations in your application state.
|
|
4
4
|
|
|
5
5
|
## System Architecture
|
|
6
6
|
|
|
7
|
-
The Data
|
|
7
|
+
The Data mapping system operates **after** Data Processors have processed the response, providing a clean separation of concerns:
|
|
8
8
|
|
|
9
9
|
1. **HTTP Request** → Server responds with raw data
|
|
10
10
|
2. **Data Processors** → Transform/validate the raw response
|
|
11
|
-
3. **Data
|
|
11
|
+
3. **Data mapping** → Selectively dispatch transformed data to application state
|
|
12
12
|
4. **Application State** → Updated with mapped data
|
|
13
13
|
|
|
14
14
|
## Core Components
|
|
@@ -26,7 +26,7 @@ Reactive-JSON includes **simpleMapping** as a core data mapper, providing string
|
|
|
26
26
|
|
|
27
27
|
## Custom Data Mappers
|
|
28
28
|
|
|
29
|
-
The Data
|
|
29
|
+
The Data mapping system is extensible through custom mapper plugins. You can create specialized mappers for complex transformation logic, integration with external libraries, or domain-specific processing needs.
|
|
30
30
|
|
|
31
31
|
### Creating Custom Mappers
|
|
32
32
|
|
|
@@ -53,7 +53,7 @@ Custom mappers are automatically merged with core mappers, allowing you to exten
|
|
|
53
53
|
|
|
54
54
|
## Usage Context
|
|
55
55
|
|
|
56
|
-
Data
|
|
56
|
+
Data mapping can be used with all HTTP-based data operations in Reactive-JSON:
|
|
57
57
|
|
|
58
58
|
- **fetchData & submitData reactions**: Process API responses selectively
|
|
59
59
|
- **additionalDataSources**: Map initial data loading responses
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
renderView:
|
|
2
2
|
- type: Markdown
|
|
3
3
|
content: |
|
|
4
|
-
# Data
|
|
4
|
+
# Data mapping
|
|
5
5
|
|
|
6
|
-
Data
|
|
6
|
+
Data mapping is a powerful, extensible system in Reactive-JSON that allows you to selectively dispatch and transform response data from HTTP requests to specific locations in your application state. This system provides fine-grained control over how incoming data is processed and stored after HTTP operations.
|
|
7
7
|
|
|
8
8
|
Data mapping occurs after the [Data Processors](data-processors) have processed the response.
|
|
9
9
|
|
|
10
10
|
## System Architecture
|
|
11
11
|
|
|
12
|
-
The Data
|
|
12
|
+
The Data mapping system processes HTTP response data to selectively dispatch it to application state:
|
|
13
13
|
|
|
14
14
|
1. **HTTP Request** → Server responds with data
|
|
15
|
-
2. **Data
|
|
15
|
+
2. **Data mapping** → Selectively dispatch response data to application state
|
|
16
16
|
3. **Application State** → Updated with mapped data
|
|
17
17
|
|
|
18
18
|
## Core Components
|
|
@@ -30,7 +30,7 @@ renderView:
|
|
|
30
30
|
|
|
31
31
|
## Custom Data Mappers
|
|
32
32
|
|
|
33
|
-
The Data
|
|
33
|
+
The Data mapping system is extensible through custom mapper plugins. You can create specialized mappers for complex transformation logic, integration with external libraries, or domain-specific processing needs.
|
|
34
34
|
|
|
35
35
|
### Creating Custom Mappers
|
|
36
36
|
|
|
@@ -68,7 +68,7 @@ renderView:
|
|
|
68
68
|
|
|
69
69
|
## Usage Context
|
|
70
70
|
|
|
71
|
-
Data
|
|
71
|
+
Data mapping can be used with all HTTP-based data operations in Reactive-JSON:
|
|
72
72
|
|
|
73
73
|
- type: Markdown
|
|
74
74
|
content: |
|
|
@@ -100,7 +100,7 @@ renderView:
|
|
|
100
100
|
|
|
101
101
|
## Plugin System Integration
|
|
102
102
|
|
|
103
|
-
The Data
|
|
103
|
+
The Data mapping system integrates with Reactive-JSON's plugin architecture:
|
|
104
104
|
|
|
105
105
|
```javascript
|
|
106
106
|
import { mergeComponentCollections, ReactiveJsonRoot } from "@ea-lab/reactive-json";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Data
|
|
1
|
+
# Data processors
|
|
2
2
|
|
|
3
|
-
Data
|
|
3
|
+
Data processors are a powerful feature in Reactive-JSON that allow you to intercept and modify data received via `fetchData`, `submitData`, and `additionalDataSources`. This enables you to implement data transformation, validation, security filtering, and other data processing logic in a centralized and reusable way.
|
|
4
4
|
|
|
5
|
-
## How Data
|
|
5
|
+
## How Data processors Work
|
|
6
6
|
|
|
7
|
-
When Reactive-JSON receives data from HTTP requests, it automatically passes the data through all registered Data
|
|
7
|
+
When Reactive-JSON receives data from HTTP requests, it automatically passes the data through all registered Data processors in order. Each processor:
|
|
8
8
|
|
|
9
9
|
1. **Examines the request and response context** (URL, method, headers, status, etc.)
|
|
10
10
|
2. **Receives the current data** being processed
|
|
@@ -54,14 +54,14 @@ Information about the HTTP response:
|
|
|
54
54
|
- `data`: Raw response data
|
|
55
55
|
|
|
56
56
|
### dataToProcess
|
|
57
|
-
The data currently being processed. This may have been modified by previous Data
|
|
57
|
+
The data currently being processed. This may have been modified by previous Data processors in the chain.
|
|
58
58
|
|
|
59
59
|
### originalDataToProcess
|
|
60
60
|
The original data before any processing, useful for comparison or logging.
|
|
61
61
|
|
|
62
62
|
## Plugin Registration
|
|
63
63
|
|
|
64
|
-
Data
|
|
64
|
+
Data processors are registered through the plugin system:
|
|
65
65
|
|
|
66
66
|
```javascript
|
|
67
67
|
import { mergeComponentCollections } from "@ea-lab/reactive-json";
|
|
@@ -222,7 +222,7 @@ additionalDataSource:
|
|
|
222
222
|
## Best Practices
|
|
223
223
|
|
|
224
224
|
### Always Return Data
|
|
225
|
-
Data
|
|
225
|
+
Data processors **must always return data**. To skip processing, return the original data:
|
|
226
226
|
|
|
227
227
|
```javascript
|
|
228
228
|
const myProcessor = ({ requestContext, responseContext, dataToProcess, originalDataToProcess }) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
renderView:
|
|
2
2
|
- type: Markdown
|
|
3
3
|
content: |
|
|
4
|
-
# Data
|
|
4
|
+
# Data processors
|
|
5
5
|
|
|
6
|
-
Data
|
|
6
|
+
Data processors are a powerful feature in Reactive-JSON that allow you to intercept and modify data received via `fetchData`, `submitData`, and `additionalDataSources`. This enables you to implement data transformation, validation, security filtering, and other data processing logic in a centralized and reusable way.
|
|
7
7
|
|
|
8
|
-
## How Data
|
|
8
|
+
## How Data processors Work
|
|
9
9
|
|
|
10
|
-
When Reactive-JSON receives data from HTTP requests, it automatically passes the data through all registered Data
|
|
10
|
+
When Reactive-JSON receives data from HTTP requests, it automatically passes the data through all registered Data processors in order. Each processor:
|
|
11
11
|
|
|
12
12
|
1. **Examines the request and response context** (URL, method, headers, status, etc.)
|
|
13
13
|
2. **Receives the current data** being processed
|
|
@@ -73,7 +73,7 @@ renderView:
|
|
|
73
73
|
details:
|
|
74
74
|
type: Markdown
|
|
75
75
|
content: |
|
|
76
|
-
The data currently being processed. This may have been modified by previous Data
|
|
76
|
+
The data currently being processed. This may have been modified by previous Data processors in the chain.
|
|
77
77
|
|
|
78
78
|
- term: originalDataToProcess
|
|
79
79
|
details:
|
|
@@ -85,7 +85,7 @@ renderView:
|
|
|
85
85
|
content: |
|
|
86
86
|
## Plugin Registration
|
|
87
87
|
|
|
88
|
-
Data
|
|
88
|
+
Data processors are registered through the plugin system:
|
|
89
89
|
|
|
90
90
|
- type: SyntaxHighlighter
|
|
91
91
|
language: javascript
|
|
@@ -213,7 +213,7 @@ renderView:
|
|
|
213
213
|
## Best Practices
|
|
214
214
|
|
|
215
215
|
### Always Return Data
|
|
216
|
-
Data
|
|
216
|
+
Data processors **must always return data**. To skip processing, return the original data:
|
|
217
217
|
|
|
218
218
|
- type: SyntaxHighlighter
|
|
219
219
|
language: javascript
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Forward
|
|
1
|
+
# Forward update
|
|
2
2
|
|
|
3
3
|
Added in **reactive-json@0.0.43**.
|
|
4
4
|
|
|
5
5
|
> Use the special placeholder `<reactive-json:event>` to reference values coming directly from the DOM or the custom event that triggered a reaction.
|
|
6
6
|
|
|
7
|
-
The **Forward
|
|
7
|
+
The **Forward update** pattern lets you use the special placeholder `<reactive-json:event>` inside any reaction arguments. It is primarily useful with `setData`, but can be applied to any reaction. Instead of reading a value *after* the global data has been updated, you can forward the fresh value carried by the event itself.
|
|
8
8
|
|
|
9
9
|
## Syntax
|
|
10
10
|
|
|
@@ -7,11 +7,11 @@ renderView:
|
|
|
7
7
|
|
|
8
8
|
- type: Markdown
|
|
9
9
|
content: |
|
|
10
|
-
# Forward
|
|
10
|
+
# Forward update
|
|
11
11
|
|
|
12
12
|
> Use the special placeholder `<reactive-json:event>` to reference values coming directly from the DOM or custom event that triggered a reaction.
|
|
13
13
|
|
|
14
|
-
The **Forward
|
|
14
|
+
The **Forward update** pattern lets you use the special placeholder `<reactive-json:event>` inside any reaction arguments.
|
|
15
15
|
It is primarily useful with `setData`, but can be applied to any reaction.
|
|
16
16
|
Instead of reading a value *after* the global data has been updated, you can forward the fresh value carried by the event itself.
|
|
17
17
|
|
|
@@ -4,6 +4,7 @@ This section covers advanced features and concepts in Reactive-JSON that enable
|
|
|
4
4
|
|
|
5
5
|
## Topics
|
|
6
6
|
|
|
7
|
+
- **[Attribute Transformers](attribute-transformers.md)**: Details on how element attributes can be modified by the app state.
|
|
7
8
|
- **[Data Mapping](data-mapping.md)**: Learn how to selectively dispatch and transform response data using the Data Mapping system
|
|
8
9
|
- **[Data Processors](data-processors.md)**: Learn how to intercept and modify data from HTTP requests using the DataProcessor system
|
|
9
10
|
- **[Forward Update](forward-update.md)**: Implementation details about the retrieval of event values.
|
|
@@ -7,6 +7,7 @@ renderView:
|
|
|
7
7
|
|
|
8
8
|
## Topics
|
|
9
9
|
|
|
10
|
+
- **[Attribute Transformers](attribute-transformers)**: Details on how element attributes can be modified by the app state.
|
|
10
11
|
- **[Data Mapping](data-mapping)**: Learn how to selectively dispatch and transform response data using the Data Mapping system.
|
|
11
12
|
- **[Data Processors](data-processors)**: Learn how to intercept and modify data from HTTP requests using the DataProcessor system.
|
|
12
13
|
- **[Forward Update](forward-update)**: Implementation details about the retrieval of event values.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# SetAttributeValue
|
|
2
2
|
|
|
3
|
+
> **Alternative**: For pre-render attribute modification, see the [setAttributeValue transformer](../../attributeTransformer/setAttributeValue.md).
|
|
4
|
+
|
|
3
5
|
Dynamically sets or modifies the value of an HTML attribute on an element.
|
|
4
6
|
|
|
5
7
|
## Basic Syntax
|
|
@@ -3,6 +3,8 @@ renderView:
|
|
|
3
3
|
content: |
|
|
4
4
|
# SetAttributeValue
|
|
5
5
|
|
|
6
|
+
> **Alternative**: For pre-render attribute modification, see the [setAttributeValue transformer](../../attributeTransformer/setAttributeValue).
|
|
7
|
+
|
|
6
8
|
Dynamically sets or modifies the value of an HTML attribute on an element.
|
|
7
9
|
|
|
8
10
|
## Basic Syntax
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ToggleAttributeValue
|
|
2
2
|
|
|
3
|
+
> **Alternative**: For pre-render attribute modification, see the [toggleAttributeValue transformer](../../attributeTransformer/toggleAttributeValue.md).
|
|
4
|
+
|
|
3
5
|
Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values.
|
|
4
6
|
|
|
5
7
|
## Important Notes
|
|
@@ -3,6 +3,8 @@ renderView:
|
|
|
3
3
|
content: |
|
|
4
4
|
# ToggleAttributeValue
|
|
5
5
|
|
|
6
|
+
> **Alternative**: For pre-render attribute modification, see the [toggleAttributeValue transformer](../../attributeTransformer/toggleAttributeValue).
|
|
7
|
+
|
|
6
8
|
Toggles the presence of a specific value in an HTML attribute. Supports both simple on-off toggles and cyclic toggling through multiple values.
|
|
7
9
|
|
|
8
10
|
## Important Notes
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# UnsetAttributeValue
|
|
2
2
|
|
|
3
|
+
> **Alternative**: For pre-render attribute modification, see the [unsetAttributeValue transformer](../../attributeTransformer/unsetAttributeValue.md).
|
|
4
|
+
|
|
3
5
|
Removes a specific value from an HTML attribute while preserving other values.
|
|
4
6
|
|
|
5
7
|
## Basic Syntax
|
|
@@ -3,6 +3,8 @@ renderView:
|
|
|
3
3
|
content: |
|
|
4
4
|
# UnsetAttributeValue
|
|
5
5
|
|
|
6
|
+
> **Alternative**: For pre-render attribute modification, see the [unsetAttributeValue transformer](../../attributeTransformer/unsetAttributeValue).
|
|
7
|
+
|
|
6
8
|
Removes a specific value from an HTML attribute while preserving other values.
|
|
7
9
|
|
|
8
10
|
## Basic Syntax
|