@ea-lab/reactive-json-docs 0.1.6 → 0.1.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ea-lab/reactive-json-docs",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
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": [
@@ -190,4 +190,17 @@ export const MyAction = (props) => {
190
190
  ### Integration Requirements
191
191
  - Components must accept props in the standard format
192
192
  - Form components should implement proper data binding
193
- - Action components should not interfere with normal rendering
193
+ - Action components should not interfere with normal rendering
194
+
195
+ ## Making Your Components Available
196
+
197
+ Now that you've learned how to create custom React components that integrate seamlessly with Reactive-JSON, the next step is understanding how to make them available in your applications.
198
+
199
+ Your custom components need to be registered through the plugin system. For complete guidance on plugin registration, organization, and advanced management patterns, continue to the dedicated [Plugin System Guide](plugin-system).
200
+
201
+ This guide will show you how to:
202
+ - Register your components using the plugin system
203
+ - Organize and structure your plugins effectively
204
+ - Combine multiple plugin sources seamlessly
205
+ - Create reusable plugin collections
206
+ - Handle complex plugin dependencies and distribution patterns
@@ -210,6 +210,19 @@ renderView:
210
210
  - Form components should implement proper data binding
211
211
  - Action components should not interfere with normal rendering
212
212
 
213
+ ## Making Your Components Available
214
+
215
+ Now that you've learned how to create custom React components that integrate seamlessly with Reactive-JSON, the next step is understanding how to make them available in your applications.
216
+
217
+ Your custom components need to be registered through the plugin system. For complete guidance on plugin registration, organization, and advanced management patterns, continue to the dedicated [Plugin System Guide](plugin-system).
218
+
219
+ This guide will show you how to:
220
+ - Register your components using the plugin system
221
+ - Organize and structure your plugins effectively
222
+ - Combine multiple plugin sources seamlessly
223
+ - Create reusable plugin collections
224
+ - Handle complex plugin dependencies and distribution patterns
225
+
213
226
  templates:
214
227
 
215
228
  data: {}
@@ -39,25 +39,23 @@ export const myPlugin = {
39
39
  Then, register the plugin with the ReactiveJsonRoot component:
40
40
 
41
41
  ```jsx
42
- import { ReactiveJsonRoot } from "@ea-lab/reactive-json";
42
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
43
43
  import { myPlugin } from "./plugins/myPlugin.js";
44
44
 
45
45
  const App = () => {
46
46
  return (
47
47
  <ReactiveJsonRoot
48
- plugins={[myPlugin]}
48
+ plugins={mergeComponentCollections([myPlugin])}
49
49
  />
50
50
  );
51
51
  };
52
52
  ```
53
53
 
54
- The plugin is now available throughout the application.
55
-
56
54
  You can now use the components in your RjBuild configuration:
57
55
 
58
56
  ```jsx
59
57
  import React from 'react';
60
- import { ReactiveJsonRoot } from "@ea-lab/reactive-json";
58
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
61
59
  import { myPlugin } from "./plugins/myPlugin.js";
62
60
 
63
61
  const App = () => {
@@ -75,7 +73,7 @@ const App = () => {
75
73
  return (
76
74
  <ReactiveJsonRoot
77
75
  rjBuild={rjBuildConfig}
78
- plugins={[myPlugin]}
76
+ plugins={mergeComponentCollections([myPlugin])}
79
77
  />
80
78
  );
81
79
  };
@@ -83,60 +81,93 @@ const App = () => {
83
81
 
84
82
  The plugin is now available throughout the application.
85
83
 
86
- ## Multi-Plugin Application
84
+ ## Multi-Plugin Application & Plugin Merging
87
85
 
88
- Applications can use multiple plugins, allowing for modular component organization.
86
+ When your application needs multiple plugins from different sources, you can combine them using `mergeComponentCollections`.
87
+
88
+ ### Multiple Plugin Usage
89
89
 
90
90
  ```jsx
91
- import { uiPlugin } from "./plugins/uiPlugin.js";
92
- import { formPlugin } from "./plugins/formPlugin.js";
93
- import { chartsPlugin } from "./plugins/chartsPlugin.js";
91
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
92
+ import { chartjsComponents } from "@ea-lab/reactive-json-chartjs";
93
+ import { customPlugins } from "./plugins/customPlugins.js";
94
+ import { thirdPartyPlugin } from "third-party-reactive-json-plugin";
94
95
 
95
96
  const App = () => {
96
97
  return (
97
98
  <ReactiveJsonRoot
98
99
  rjBuild={rjBuildConfig}
99
- plugins={[
100
- uiPlugin,
101
- formPlugin,
102
- chartsPlugin
103
- ]}
100
+ plugins={mergeComponentCollections([
101
+ chartjsComponents,
102
+ customPlugins,
103
+ thirdPartyPlugin
104
+ ])}
104
105
  />
105
106
  );
106
107
  };
107
108
  ```
108
109
 
109
- ## Plugin Development Patterns
110
+ ### Custom ReactiveJsonRoot Wrapper
110
111
 
111
- ### Standalone Plugin
112
+ Creating a custom wrapper allows you to **centralize plugin inclusion** across your entire application. Instead of manually importing and merging plugins in every component that uses Reactive-JSON, you define them once in a wrapper component.
112
113
 
113
- For single-purpose plugins with a few related components:
114
+ #### Benefits of Centralized Plugin Management
114
115
 
115
- ```javascript
116
- export const simplePlugin = {
117
- element: {
118
- Alert: AlertComponent,
119
- Badge: BadgeComponent,
120
- }
116
+ - **Consistency**: Ensures all parts of your application have access to the same set of components
117
+ - **Maintainability**: Update plugin dependencies in one place
118
+ - **Simplicity**: Other components only need to import your wrapper, not individual plugins
119
+ - **Standardization**: Enforces a consistent plugin configuration across teams
120
+
121
+ #### Implementation Example
122
+
123
+ ```jsx
124
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
125
+ import { chartjsComponents } from "@ea-lab/reactive-json-chartjs";
126
+ import { customPlugins } from "./plugins/customPlugins.js";
127
+ import { companyUIComponents } from "@company/reactive-json-ui";
128
+
129
+ export const CustomReactiveJsonRoot = (props) => {
130
+ const additionalProps = {};
131
+
132
+ // Centralize all plugin dependencies for the entire application
133
+ additionalProps.plugins = mergeComponentCollections([
134
+ chartjsComponents, // Third-party charting components
135
+ customPlugins, // Application-specific components
136
+ companyUIComponents // Company-wide design system
137
+ ]);
138
+
139
+ const finalProps = { ...props, ...additionalProps };
140
+
141
+ return <ReactiveJsonRoot {...finalProps} />;
142
+ };
143
+ ```
144
+
145
+ #### Usage Across Your Application
146
+
147
+ Once created, your wrapper simplifies usage throughout your application:
148
+
149
+ ```jsx
150
+ import { CustomReactiveJsonRoot } from "./components/CustomReactiveJsonRoot";
151
+
152
+ // Component A
153
+ export const Dashboard = () => {
154
+ return (
155
+ <CustomReactiveJsonRoot rjBuild={dashboardConfig} />
156
+ );
157
+ };
158
+
159
+ // Component B
160
+ export const ReportPage = () => {
161
+ return (
162
+ <CustomReactiveJsonRoot rjBuild={reportConfig} />
163
+ );
121
164
  };
122
165
  ```
123
166
 
124
167
  ## Best Practices
125
168
 
126
- ### Plugin Organization
127
169
  1. **Group related components** in the same plugin
128
170
  2. **Use descriptive names** for components and plugins
129
171
  3. **Document component props** and usage patterns
130
172
  4. **Provide examples** for complex components
131
-
132
- ### Distribution
133
- 1. **Package as npm modules** for easy distribution
134
- 2. **Include TypeScript definitions** if using TypeScript
135
- 3. **Provide clear documentation** and examples
136
- 4. **Follow semantic versioning** for releases
137
-
138
- ### Performance
139
- 1. **Lazy load large plugins** when possible
140
- 2. **Avoid global state** in plugin components
141
- 3. **Use React best practices** for component implementation
142
- 4. **Test plugin compatibility** with different Reactive-JSON versions
173
+ 5. **Choose non-conflicting names** with existing components
@@ -22,7 +22,9 @@ renderView:
22
22
 
23
23
  First, regroup your components in a plugin object.
24
24
 
25
- ```jsx
25
+ - type: SyntaxHighlighter
26
+ language: jsx
27
+ content: |
26
28
  // myPlugin.js
27
29
  import { MyButton } from "./components/MyButton.jsx";
28
30
  import { MyForm } from "./components/MyForm.jsx";
@@ -37,111 +39,158 @@ renderView:
37
39
  MyAction,
38
40
  }
39
41
  };
40
- ```
41
42
 
43
+ - type: Markdown
44
+ content: |
42
45
  Then, register the plugin with the ReactiveJsonRoot component:
43
46
 
44
- ```jsx
45
- import { ReactiveJsonRoot } from "@ea-lab/reactive-json";
47
+ - type: SyntaxHighlighter
48
+ language: jsx
49
+ content: |
50
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
46
51
  import { myPlugin } from "./plugins/myPlugin.js";
47
52
 
48
53
  const App = () => {
49
54
  return (
50
55
  <ReactiveJsonRoot
51
- plugins={[myPlugin]}
56
+ plugins={mergeComponentCollections([myPlugin])}
52
57
  />
53
58
  );
54
59
  };
55
- ```
56
-
57
- The plugin is now available throughout the application.
58
60
 
61
+ - type: Markdown
62
+ content: |
59
63
  You can now use the components in your RjBuild configuration:
60
64
 
61
- ```jsx
62
- import React from 'react';
63
- import { ReactiveJsonRoot } from "@ea-lab/reactive-json";
64
- import { myPlugin } from "./plugins/myPlugin.js";
65
-
66
- const App = () => {
67
- const rjBuildConfig = {
68
- renderView: [
69
- {
70
- type: "MyButton",
71
- content: "Click me!",
72
- customProperty: "some value"
73
- }
74
- ],
75
- data: {}
76
- };
77
-
78
- return (
79
- <ReactiveJsonRoot
80
- rjBuild={rjBuildConfig}
81
- plugins={[myPlugin]}
82
- />
83
- );
84
- };
85
- ```
65
+ - type: SyntaxHighlighter
66
+ language: jsx
67
+ content: |
68
+ import React from 'react';
69
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
70
+ import { myPlugin } from "./plugins/myPlugin.js";
71
+
72
+ const App = () => {
73
+ const rjBuildConfig = {
74
+ renderView: [
75
+ {
76
+ type: "MyButton",
77
+ content: "Click me!",
78
+ customProperty: "some value"
79
+ }
80
+ ],
81
+ data: {}
82
+ };
83
+
84
+ return (
85
+ <ReactiveJsonRoot
86
+ rjBuild={rjBuildConfig}
87
+ plugins={mergeComponentCollections([myPlugin])}
88
+ />
89
+ );
90
+ };
86
91
 
92
+ - type: Markdown
93
+ content: |
87
94
  The plugin is now available throughout the application.
88
95
 
89
- ## Multi-Plugin Application
90
-
91
- Applications can use multiple plugins, allowing for modular component organization.
96
+ ## Multi-Plugin Application & Plugin Merging
97
+
98
+ When your application needs multiple plugins from different sources, you can combine them using `mergeComponentCollections`.
99
+
100
+ ### Multiple Plugin Usage
92
101
 
93
- ```jsx
94
- import { uiPlugin } from "./plugins/uiPlugin.js";
95
- import { formPlugin } from "./plugins/formPlugin.js";
96
- import { chartsPlugin } from "./plugins/chartsPlugin.js";
102
+ - type: SyntaxHighlighter
103
+ language: jsx
104
+ content: |
105
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
106
+ import { chartjsComponents } from "@ea-lab/reactive-json-chartjs";
107
+ import { customPlugins } from "./plugins/customPlugins.js";
108
+ import { thirdPartyPlugin } from "third-party-reactive-json-plugin";
97
109
 
98
110
  const App = () => {
99
111
  return (
100
112
  <ReactiveJsonRoot
101
113
  rjBuild={rjBuildConfig}
102
- plugins={[
103
- uiPlugin,
104
- formPlugin,
105
- chartsPlugin
106
- ]}
114
+ plugins={mergeComponentCollections([
115
+ chartjsComponents,
116
+ customPlugins,
117
+ thirdPartyPlugin
118
+ ])}
107
119
  />
108
120
  );
109
121
  };
110
- ```
111
122
 
112
- ## Plugin Development Patterns
123
+ - type: Markdown
124
+ content: |
125
+ ### Custom ReactiveJsonRoot Wrapper
126
+
127
+ Creating a custom wrapper allows you to **centralize plugin inclusion** across your entire application. Instead of manually importing and merging plugins in every component that uses Reactive-JSON, you define them once in a wrapper component.
128
+
129
+ #### Benefits of Centralized Plugin Management
130
+
131
+ - **Consistency**: Ensures all parts of your application have access to the same set of components
132
+ - **Maintainability**: Update plugin dependencies in one place
133
+ - **Simplicity**: Other components only need to import your wrapper, not individual plugins
134
+ - **Standardization**: Enforces a consistent plugin configuration across teams
135
+
136
+ #### Implementation Example
137
+
138
+ - type: SyntaxHighlighter
139
+ language: jsx
140
+ content: |
141
+ import { ReactiveJsonRoot, mergeComponentCollections } from "@ea-lab/reactive-json";
142
+ import { chartjsComponents } from "@ea-lab/reactive-json-chartjs";
143
+ import { customPlugins } from "./plugins/customPlugins.js";
144
+ import { companyUIComponents } from "@company/reactive-json-ui";
145
+
146
+ export const CustomReactiveJsonRoot = (props) => {
147
+ const additionalProps = {};
148
+
149
+ // Centralize all plugin dependencies for the entire application
150
+ additionalProps.plugins = mergeComponentCollections([
151
+ chartjsComponents, // Third-party charting components
152
+ customPlugins, // Application-specific components
153
+ companyUIComponents // Company-wide design system
154
+ ]);
155
+
156
+ const finalProps = { ...props, ...additionalProps };
157
+
158
+ return <ReactiveJsonRoot {...finalProps} />;
159
+ };
160
+
161
+ - type: Markdown
162
+ content: |
163
+ #### Usage Across Your Application
164
+
165
+ Once created, your wrapper simplifies usage throughout your application:
113
166
 
114
- ### Standalone Plugin
167
+ - type: SyntaxHighlighter
168
+ language: jsx
169
+ content: |
170
+ import { CustomReactiveJsonRoot } from "./components/CustomReactiveJsonRoot";
115
171
 
116
- For single-purpose plugins with a few related components:
172
+ // Component A
173
+ export const Dashboard = () => {
174
+ return (
175
+ <CustomReactiveJsonRoot rjBuild={dashboardConfig} />
176
+ );
177
+ };
117
178
 
118
- ```javascript
119
- export const simplePlugin = {
120
- element: {
121
- Alert: AlertComponent,
122
- Badge: BadgeComponent,
123
- }
179
+ // Component B
180
+ export const ReportPage = () => {
181
+ return (
182
+ <CustomReactiveJsonRoot rjBuild={reportConfig} />
183
+ );
124
184
  };
125
- ```
126
185
 
186
+ - type: Markdown
187
+ content: |
127
188
  ## Best Practices
128
189
 
129
- ### Plugin Organization
130
190
  1. **Group related components** in the same plugin
131
191
  2. **Use descriptive names** for components and plugins
132
192
  3. **Document component props** and usage patterns
133
193
  4. **Provide examples** for complex components
134
-
135
- ### Distribution
136
- 1. **Package as npm modules** for easy distribution
137
- 2. **Include TypeScript definitions** if using TypeScript
138
- 3. **Provide clear documentation** and examples
139
- 4. **Follow semantic versioning** for releases
140
-
141
- ### Performance
142
- 1. **Lazy load large plugins** when possible
143
- 2. **Avoid global state** in plugin components
144
- 3. **Use React best practices** for component implementation
145
- 4. **Test plugin compatibility** with different Reactive-JSON versions
194
+ 5. **Choose non-conflicting names** with existing components
146
195
 
147
196
  templates:
@@ -0,0 +1,151 @@
1
+ # Reactive-JSON Getting Started Guide
2
+
3
+ ## Introduction
4
+
5
+ Reactive-JSON is a powerful library that allows you to create interactive user interfaces using only JSON/YAML configurations. No need to write complex JavaScript code - simply define your interface and its behavior declaratively.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ea-lab/reactive-json
11
+ ```
12
+
13
+ ## Basic Structure
14
+
15
+ Every Reactive-JSON configuration follows this structure:
16
+
17
+ ```yaml
18
+ renderView: # Defines what should be rendered
19
+ - type: div
20
+ content: "Hello World!"
21
+
22
+ templates: # Defines reusable templates (optional)
23
+ myTemplate:
24
+ type: div
25
+ content: "Template content"
26
+
27
+ data: # Defines the data to be used (optional)
28
+ message: "Hello!"
29
+ ```
30
+
31
+ ## Key Concepts
32
+
33
+ ### 1. Template System
34
+
35
+ Reactive-JSON uses three main notations to access data:
36
+
37
+ - `~.` : Local context (relative to current template)
38
+ - `~~.` : Global context (access to global data)
39
+ - `~>field` : Access to a specific parent context
40
+
41
+ Example:
42
+ ```yaml
43
+ templates:
44
+ userCard:
45
+ type: div
46
+ content:
47
+ - type: div
48
+ content: ["Name: ", ~.name] # Local access to user data
49
+ - type: div
50
+ content: ["Admin: ", ~~.isAdmin] # Global access to isAdmin
51
+ ```
52
+
53
+ ### 2. Basic Elements
54
+
55
+ Reactive-JSON provides several types of elements:
56
+
57
+ #### HTML Elements
58
+ - Div, Button, Modal, Accordion, etc.
59
+ - Example:
60
+ ```yaml
61
+ renderView:
62
+ - type: button
63
+ content: "Click me"
64
+ ```
65
+
66
+ #### Form Fields
67
+ - TextField, SelectField, CheckBoxField, etc.
68
+ - Example:
69
+ ```yaml
70
+ renderView:
71
+ - type: TextField
72
+ label: "Username"
73
+ dataLocation: ~.username
74
+ ```
75
+
76
+ #### Special Elements
77
+ - DataFilter, Switch, Count, etc.
78
+ - Example:
79
+ ```yaml
80
+ renderView:
81
+ - type: Switch
82
+ content: ~.items
83
+ template:
84
+ type: div
85
+ content: ~.name
86
+ ```
87
+
88
+ ### 3. Actions and Reactions
89
+
90
+ #### Actions
91
+ Actions modify element behavior:
92
+ ```yaml
93
+ renderView:
94
+ - type: div
95
+ content: "Hidden content"
96
+ actions:
97
+ - what: hide
98
+ when: ~.shouldHide
99
+ is: true
100
+ ```
101
+
102
+ #### Reactions
103
+ Reactions respond to user events:
104
+ ```yaml
105
+ renderView:
106
+ - type: button
107
+ content: "Save"
108
+ actions:
109
+ - what: setData
110
+ on: click
111
+ path: ~.saved
112
+ value: true
113
+ ```
114
+
115
+ ## Complete Example
116
+
117
+ Here's a simple example of an interactive form:
118
+
119
+ ```yaml
120
+ renderView:
121
+ - type: div
122
+ content:
123
+ - type: TextField
124
+ label: "Name"
125
+ dataLocation: ~.form.name
126
+ - type: TextField
127
+ label: "Email"
128
+ dataLocation: ~.form.email
129
+ - type: button
130
+ content: "Submit"
131
+ actions:
132
+ - what: submitData
133
+ on: click
134
+ url: "/api/submit"
135
+ data: ~.form
136
+ when: ~.form.name
137
+ isEmpty: not
138
+
139
+ data:
140
+ form:
141
+ name: ""
142
+ email: ""
143
+ ```
144
+
145
+ ## Next Steps
146
+
147
+ 1. Explore the [complete examples](/docs/core/example) to see Reactive-JSON in action
148
+ 2. Check out the [elements documentation](/docs/core/element) to discover all available components
149
+ 3. Learn how to use the [action system](/docs/core/action) to create interactive interfaces
150
+ 4. Discover the [reaction system](/docs/core/reaction) to handle user interactions
151
+ 5. If needed, learn how to [extend Reactive-JSON](/docs/extend) with your own components