@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.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/public/rjbuild/docs/advanced-concepts/attribute-transformers.md +168 -0
  3. package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
  4. package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
  5. package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
  6. package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
  7. package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
  8. package/public/rjbuild/docs/advanced-concepts/forward-update.md +2 -2
  9. package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +2 -2
  10. package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
  11. package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
  12. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
  13. package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
  14. package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.md +1 -1
  15. package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +1 -1
  16. package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
  17. package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
  18. package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
  19. package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
  20. package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
  21. package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
  22. package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
  23. package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
  24. package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
  25. package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
  26. package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
  27. package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
  28. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
  29. package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
  30. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
  31. package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
  32. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
  33. package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
  34. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
  35. package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
  36. package/public/rjbuild/docs/core/hook/index.md +38 -0
  37. package/public/rjbuild/docs/core/hook/index.yaml +44 -0
  38. package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
  39. package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
  40. package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
  41. package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
@@ -0,0 +1,130 @@
1
+ # useTransformedAttributes
2
+
3
+ Applies attribute transformations based on configured transformers in plugins. This hook allows conditional modification of component attributes by applying a series of defined transformations.
4
+
5
+ ## Hook Signature
6
+
7
+ ```javascript
8
+ const transformedAttributes = useTransformedAttributes(attrsToTransform, transformProps)
9
+ ```
10
+
11
+ ## Parameters
12
+
13
+ - `attrsToTransform` (object): Raw attributes to transform
14
+ - `transformProps` (array, optional): Array of transformation definitions to apply
15
+
16
+ ## Return Value
17
+
18
+ - `transformedAttributes` (object): Final attributes after applying transformations (spread on target element/component)
19
+
20
+ ## How It Works
21
+
22
+ The hook follows this logic:
23
+
24
+ 1. **Validation Check**: If `transformProps` is `undefined`, returns original attributes
25
+ 2. **Transformer Retrieval**: Accesses transformers via `globalDataContext.plugins.attributeTransformer`
26
+ 3. **Sequential Application**: Applies each transformation in defined order
27
+ 4. **Conditional Validation**: Each transformation is validated before application via `isValid()`
28
+ 5. **Accumulation**: Transformations are applied cumulatively
29
+
30
+ ## Supported Transformer Types
31
+
32
+ The following transformers are available in the system:
33
+
34
+ ### setAttributeValue
35
+ Sets an attribute value conditionally.
36
+
37
+ ### toggleAttributeValue
38
+ Toggles between two values for an attribute.
39
+
40
+ ### unsetAttribute
41
+ Completely removes an attribute.
42
+
43
+ ### unsetAttributeValue
44
+ Removes an attribute value (sets to `undefined`).
45
+
46
+ ## Example Usage
47
+
48
+ ```jsx
49
+ import { useTransformedAttributes } from '@ea-lab/reactive-json';
50
+
51
+ const MyComponent = ({ props }) => {
52
+ const baseAttributes = {
53
+ className: "btn btn-primary",
54
+ disabled: false,
55
+ title: "Click me"
56
+ };
57
+
58
+ const transformedAttributes = useTransformedAttributes(
59
+ baseAttributes,
60
+ props.attributeTransforms
61
+ );
62
+
63
+ return <button {...transformedAttributes}>Submit</button>;
64
+ };
65
+ ```
66
+
67
+ ## Transformation Configuration
68
+
69
+ ```yaml
70
+ # Example configuration in RjBuild
71
+ - type: MyComponent
72
+ attributeTransforms:
73
+ - what: setAttributeValue
74
+ when: ~~.form.isSubmitting
75
+ is: true
76
+ attributeName: disabled
77
+ value: true
78
+
79
+ - what: toggleAttributeValue
80
+ when: ~~.theme
81
+ is: "dark"
82
+ attributeName: className
83
+ value1: "btn btn-primary"
84
+ value2: "btn btn-primary btn-dark"
85
+
86
+ - what: unsetAttribute
87
+ when: ~~.user.role
88
+ is: "guest"
89
+ attributeName: title
90
+ ```
91
+
92
+ ## Context Integration
93
+
94
+ The hook automatically uses:
95
+
96
+ - **GlobalDataContext**: For accessing plugins and global data
97
+ - **TemplateContext**: For condition evaluation in templates
98
+
99
+ ## Transformation Validation
100
+
101
+ Each transformation is validated via the `isValid()` function which checks:
102
+
103
+ - The `when` condition against the `is` value
104
+ - Supported comparison operators
105
+ - Data availability in contexts
106
+
107
+ ## Error Handling
108
+
109
+ The hook is designed to be resilient:
110
+
111
+ - **Missing Transformer**: Silently ignores the transformation
112
+ - **Failed Validation**: Ignores invalid transformation
113
+ - **Missing Plugins**: Returns original attributes
114
+ - **Missing Data**: Ignores transformations that cannot be evaluated
115
+
116
+ ## Performance
117
+
118
+ - **Sequential Application**: Transformations applied in order with accumulation
119
+ - **Optimized Validation**: Invalid transformations ignored quickly
120
+ - **Reusability**: Hook can be called multiple times without performance impact
121
+
122
+ ## Relationship with Transformers
123
+
124
+ This hook is closely related to the attributeTransformer system:
125
+
126
+ - Uses transformers registered in plugins
127
+ - Respects transformer syntax (`what`, `when`, `is` properties)
128
+ - Integrates with global validation system
129
+
130
+ For details on individual transformers, see [attributeTransformer documentation](../attributeTransformer/index.md).
@@ -0,0 +1,164 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # useTransformedAttributes
5
+
6
+ Applies attribute transformations based on configured transformers in plugins. This hook allows conditional modification of component attributes by applying a series of defined transformations.
7
+
8
+ ## Hook Signature
9
+
10
+ - type: SyntaxHighlighter
11
+ language: "javascript"
12
+ content: |
13
+ const transformedAttributes = useTransformedAttributes(attrsToTransform, transformProps)
14
+
15
+ - type: Markdown
16
+ content: |
17
+ ## Parameters
18
+
19
+ - type: DefinitionList
20
+ content:
21
+ - term:
22
+ code: attrsToTransform
23
+ after: "(object)"
24
+ details: "Raw attributes to transform"
25
+ - term:
26
+ code: transformProps
27
+ after: "(array, optional)"
28
+ details: "Array of transformation definitions to apply"
29
+
30
+ - type: Markdown
31
+ content: |
32
+ ## Return Value
33
+
34
+ - type: DefinitionList
35
+ content:
36
+ - term:
37
+ code: transformedAttributes
38
+ after: "(object)"
39
+ details: "Final attributes after applying transformations (spread on target element/component)"
40
+
41
+ - type: Markdown
42
+ content: |
43
+ ## How It Works
44
+
45
+ The hook follows this logic:
46
+
47
+ 1. **Validation Check**: If `transformProps` is `undefined`, returns original attributes
48
+ 2. **Transformer Retrieval**: Accesses transformers via `globalDataContext.plugins.attributeTransformer`
49
+ 3. **Sequential Application**: Applies each transformation in defined order
50
+ 4. **Conditional Validation**: Each transformation is validated before application via `isValid()`
51
+ 5. **Accumulation**: Transformations are applied cumulatively
52
+
53
+ ## Supported Transformer Types
54
+
55
+ The following transformers are available in the system:
56
+
57
+ ### setAttributeValue
58
+ Sets an attribute value conditionally.
59
+
60
+ ### toggleAttributeValue
61
+ Toggles between two values for an attribute.
62
+
63
+ ### unsetAttribute
64
+ Completely removes an attribute.
65
+
66
+ ### unsetAttributeValue
67
+ Removes an attribute value (sets to `undefined`).
68
+
69
+ - type: Markdown
70
+ content: |
71
+ ## Example Usage
72
+
73
+ - type: SyntaxHighlighter
74
+ language: "jsx"
75
+ content: |
76
+ import { useTransformedAttributes } from '@ea-lab/reactive-json';
77
+
78
+ const MyComponent = ({ props }) => {
79
+ const baseAttributes = {
80
+ className: "btn btn-primary",
81
+ disabled: false,
82
+ title: "Click me"
83
+ };
84
+
85
+ const transformedAttributes = useTransformedAttributes(
86
+ baseAttributes,
87
+ props.attributeTransforms
88
+ );
89
+
90
+ return <button {...transformedAttributes}>Submit</button>;
91
+ };
92
+
93
+ - type: Markdown
94
+ content: |
95
+ ## Transformation Configuration
96
+
97
+ - type: SyntaxHighlighter
98
+ language: "yaml"
99
+ content: |
100
+ # Example configuration in RjBuild
101
+ - type: MyComponent
102
+ attributeTransforms:
103
+ - what: setAttributeValue
104
+ when: ~~.form.isSubmitting
105
+ is: true
106
+ attributeName: disabled
107
+ value: true
108
+
109
+ - what: toggleAttributeValue
110
+ when: ~~.theme
111
+ is: "dark"
112
+ attributeName: className
113
+ value1: "btn btn-primary"
114
+ value2: "btn btn-primary btn-dark"
115
+
116
+ - what: unsetAttribute
117
+ when: ~~.user.role
118
+ is: "guest"
119
+ attributeName: title
120
+
121
+ - type: Markdown
122
+ content: |
123
+ ## Context Integration
124
+
125
+ The hook automatically uses:
126
+
127
+ - **GlobalDataContext**: For accessing plugins and global data
128
+ - **TemplateContext**: For condition evaluation in templates
129
+
130
+ ## Transformation Validation
131
+
132
+ Each transformation is validated via the `isValid()` function which checks:
133
+
134
+ - The `when` condition against the `is` value
135
+ - Supported comparison operators
136
+ - Data availability in contexts
137
+
138
+ ## Error Handling
139
+
140
+ The hook is designed to be resilient:
141
+
142
+ - **Missing Transformer**: Silently ignores the transformation
143
+ - **Failed Validation**: Ignores invalid transformation
144
+ - **Missing Plugins**: Returns original attributes
145
+ - **Missing Data**: Ignores transformations that cannot be evaluated
146
+
147
+ ## Performance
148
+
149
+ - **Sequential Application**: Transformations applied in order with accumulation
150
+ - **Optimized Validation**: Invalid transformations ignored quickly
151
+ - **Reusability**: Hook can be called multiple times without performance impact
152
+
153
+ ## Relationship with Transformers
154
+
155
+ This hook is closely related to the attributeTransformer system:
156
+
157
+ - Uses transformers registered in plugins
158
+ - Respects transformer syntax (`what`, `when`, `is` properties)
159
+ - Integrates with global validation system
160
+
161
+ For details on individual transformers, see [attributeTransformer documentation](../attributeTransformer/index).
162
+
163
+ templates: {}
164
+ data: {}