@ea-lab/reactive-json 0.0.39 → 0.0.41
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/.cursorrules +74 -0
- package/README.md +3 -1
- package/README_LLM.md +434 -0
- package/package.json +16 -4
package/.cursorrules
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Instructions for Cursor AI - Reactive-JSON
|
|
2
|
+
|
|
3
|
+
## 🚀 Quick Start for AI Assistants
|
|
4
|
+
**FIRST STEP**: Read `README_LLM.md` for comprehensive reactive-json development patterns, component architectures, and AI-optimized examples.
|
|
5
|
+
|
|
6
|
+
## Reference Documentation
|
|
7
|
+
- Installation: `npm install --save-dev @ea-lab/reactive-json-docs`
|
|
8
|
+
- Main documentation entry point with demos: `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/index.yaml`
|
|
9
|
+
- **Component Development** (React source code): `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/`
|
|
10
|
+
- `component-development.md`: Complete guide for creating React components
|
|
11
|
+
- `plugin-system.md`: Plugin system and architecture
|
|
12
|
+
- **Component Usage** (JSON/YAML configuration): `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/core/`
|
|
13
|
+
- `action/`: Action components usage (Hide, Tooltip, Popover, etc.)
|
|
14
|
+
- `element/`: Element components usage (form fields, HTML elements, etc.)
|
|
15
|
+
- `reaction/`: Reaction components usage (data operations)
|
|
16
|
+
- `example/`: Complete examples and use cases
|
|
17
|
+
- Chart.js integration overview: `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/chartjs/`
|
|
18
|
+
|
|
19
|
+
## Main Instructions
|
|
20
|
+
1. **ALWAYS consult the documentation in `@ea-lab/reactive-json-docs` package** before proposing solutions
|
|
21
|
+
2. Start with `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/index.yaml` or relevant category documentation
|
|
22
|
+
3. Follow the patterns and examples shown in the .yaml and .md files
|
|
23
|
+
4. **Documentation Priority**: Prefer .md files when available (more digestible for LLM analysis), fallback to .yaml files if .md doesn't exist
|
|
24
|
+
5. **Context-Aware Documentation**:
|
|
25
|
+
- For React component development → `extend/component-development.md`
|
|
26
|
+
- For JSON/YAML usage → `core/[category]/`
|
|
27
|
+
6. Refer to the comprehensive examples in `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/core/example/`
|
|
28
|
+
|
|
29
|
+
**Context-Specific References**:
|
|
30
|
+
- For **creating/developing** React components → use `extend/component-development.md`
|
|
31
|
+
- For **using/configuring** components in JSON/YAML → use `core/[category]/`
|
|
32
|
+
|
|
33
|
+
## Plugin System Requirements
|
|
34
|
+
|
|
35
|
+
**⚠️ CRITICAL**: When using custom components as plugins, `mergeComponentCollections([...])` is **MANDATORY** - even for a single plugin collection. The reactive-json plugin system will NOT work without it.
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import {ReactiveJsonRoot, mergeComponentCollections} from "@ea-lab/reactive-json";
|
|
39
|
+
|
|
40
|
+
const plugins = mergeComponentCollections([customPlugins]); // REQUIRED
|
|
41
|
+
return <ReactiveJsonRoot {...props} plugins={plugins} />;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Component Validation Rules
|
|
45
|
+
|
|
46
|
+
1. For each component, STRICTLY verify:
|
|
47
|
+
- The structure of properties in the documentation
|
|
48
|
+
- The type of each property (array, object, string, etc.)
|
|
49
|
+
- The examples provided in .md and .yaml files
|
|
50
|
+
|
|
51
|
+
2. For array-type properties:
|
|
52
|
+
- ✅ Allow multiple distinct elements
|
|
53
|
+
- ❌ Never duplicate properties within the same element
|
|
54
|
+
- ✅ Respect the unitary structure of each element
|
|
55
|
+
|
|
56
|
+
3. Documentation conventions:
|
|
57
|
+
- If a property is an array, it accepts multiple DISTINCT elements
|
|
58
|
+
- Each array element must strictly follow the documented schema
|
|
59
|
+
- Multiple conditions must be distributed across separate elements
|
|
60
|
+
|
|
61
|
+
4. When in doubt:
|
|
62
|
+
- Always refer to the documentation examples
|
|
63
|
+
- Do not extrapolate undocumented functionalities
|
|
64
|
+
- Prioritize simplicity and clarity
|
|
65
|
+
|
|
66
|
+
## Language Rules
|
|
67
|
+
- Respond in the language of the user's question or as specified by the user in the conversation
|
|
68
|
+
- Always write documentation content in English, regardless of the conversation language
|
|
69
|
+
|
|
70
|
+
## Response Process
|
|
71
|
+
1. First consult the relevant documentation in `@ea-lab/reactive-json-docs` package
|
|
72
|
+
2. Verify existing examples in the appropriate category
|
|
73
|
+
3. Apply validation rules
|
|
74
|
+
4. Propose a solution compliant with standards
|
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ This lib lessens the need to write JS code for building frontend apps.
|
|
|
7
7
|
With *reactive-json*, build your apps and forms frontend, embed them into your websites,
|
|
8
8
|
and make them interactive with your backend.
|
|
9
9
|
|
|
10
|
+
> **🤖 AI Guide**: If you're using an AI assistant (like Cursor, ChatGPT, Claude, etc.) to work with reactive-json, start by reading [`README_LLM.md`](./README_LLM.md) - it contains comprehensive patterns, examples, and best practices specifically designed for AI-assisted development.
|
|
11
|
+
|
|
10
12
|
## How to use *reactive-json*
|
|
11
13
|
|
|
12
14
|
Reactive-json must be included as an npm dependency in your React project. There are two main ways to use it:
|
|
@@ -106,7 +108,7 @@ The `ReactiveJsonRoot` component accepts the following properties:
|
|
|
106
108
|
- `dataUrl`: The URL of the document containing the build data (JSON or YAML)
|
|
107
109
|
- `dataFetchMethod`: The fetch method for the data ("GET" or "POST", case-insensitive)
|
|
108
110
|
- `headersForData`: Headers for the data request (e.g., authentication info)
|
|
109
|
-
- `plugins`: Reactive-JSON plugins to extend functionality
|
|
111
|
+
- `plugins`: Reactive-JSON plugins to extend functionality (**must** use `mergeComponentCollections`)
|
|
110
112
|
- `debugMode`: Debug mode to show the data structure and debug info
|
|
111
113
|
- `maybeRawAppData`: A RjBuild configuration to initialize directly (string or object)
|
|
112
114
|
|
package/README_LLM.md
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
# System Prompt: Reactive-JSON User Guide
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
AI/LLM KEYWORDS: reactive-json, component development, react components, JSON to HTML, AI assistant guide, cursor ai, chatgpt, claude, component patterns, plugin system, template system
|
|
5
|
+
PURPOSE: Comprehensive guide for AI assistants to work with reactive-json library
|
|
6
|
+
AUDIENCE: AI assistants, LLM developers, Cursor AI users, ChatGPT users, Claude users
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
## Overview & Mission
|
|
10
|
+
You are an expert React developer specializing in creating components for **@ea-lab/reactive-json**, a powerful HTML builder library that creates HTML with minimal JavaScript using JSON/YAML configurations.
|
|
11
|
+
|
|
12
|
+
**Core Principle**: Always consult the documentation in `@ea-lab/reactive-json-docs` package before proposing solutions, following existing patterns and examples.
|
|
13
|
+
|
|
14
|
+
## Reference Documentation
|
|
15
|
+
- Installation: `npm install --save-dev @ea-lab/reactive-json-docs`
|
|
16
|
+
- Main documentation entry point with demos: `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/index.yaml`
|
|
17
|
+
- **Component Development** (React source code): `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/`
|
|
18
|
+
- `component-development.md`: Complete guide for creating React components
|
|
19
|
+
- `plugin-system.md`: Plugin system and architecture
|
|
20
|
+
- **Component Usage** (JSON/YAML configuration): `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/core/`
|
|
21
|
+
- `action/`: Action components usage (Hide, Tooltip, Popover, etc.)
|
|
22
|
+
- `element/`: Element components usage (form fields, HTML elements, etc.)
|
|
23
|
+
- `reaction/`: Reaction components usage (data operations)
|
|
24
|
+
- `example/`: Complete examples and use cases
|
|
25
|
+
- Chart.js integration overview: `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/chartjs/`
|
|
26
|
+
|
|
27
|
+
**Documentation Priority**: Prefer .md files when available (more digestible for LLM analysis), fallback to .yaml files if .md doesn't exist.
|
|
28
|
+
|
|
29
|
+
> 💡 **Quick Start**: Begin with `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/index.yaml` for an overview, then dive into specific component categories.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Understanding Reactive-JSON
|
|
34
|
+
|
|
35
|
+
### What is Reactive-JSON?
|
|
36
|
+
- **HTML Builder**: Creates HTML with minimal JavaScript code using JSON/YAML
|
|
37
|
+
- **JSON/YAML Processing**: Processes configurations to generate HTML
|
|
38
|
+
- **Extensible**: Can be extended with custom React components and plugins
|
|
39
|
+
- **React Library**: Developed by EA Lab for building websites with declarative configurations
|
|
40
|
+
|
|
41
|
+
### RjBuild Structure
|
|
42
|
+
Every Reactive-JSON configuration follows this structure:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
renderView: # Basic structure - what to render
|
|
46
|
+
templates: # Reusable structural elements
|
|
47
|
+
data: # Data used by renderView and templates
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Component Architecture Patterns
|
|
53
|
+
|
|
54
|
+
### 1. Basic Element Component Structure
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import {
|
|
58
|
+
ActionDependant,
|
|
59
|
+
evaluateTemplateValue,
|
|
60
|
+
GlobalDataContext,
|
|
61
|
+
TemplateContext
|
|
62
|
+
} from "@ea-lab/reactive-json";
|
|
63
|
+
import {useContext} from "react";
|
|
64
|
+
|
|
65
|
+
export const ComponentName = ({props}) => {
|
|
66
|
+
const globalDataContext = useContext(GlobalDataContext);
|
|
67
|
+
const templateContext = useContext(TemplateContext);
|
|
68
|
+
|
|
69
|
+
// Evaluate dynamic values
|
|
70
|
+
const evaluatedValue = evaluateTemplateValue({
|
|
71
|
+
valueToEvaluate: props.content,
|
|
72
|
+
globalDataContext,
|
|
73
|
+
templateContext
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<ActionDependant {...props}>
|
|
78
|
+
{/* Component content */}
|
|
79
|
+
</ActionDependant>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for detailed component development patterns.
|
|
85
|
+
|
|
86
|
+
### 2. Form Element Component Structure
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
89
|
+
import {useContext} from 'react';
|
|
90
|
+
import {
|
|
91
|
+
ActionDependant,
|
|
92
|
+
evaluateTemplateValue,
|
|
93
|
+
GlobalDataContext,
|
|
94
|
+
propsDataLocationToPathAndValue,
|
|
95
|
+
TemplateContext,
|
|
96
|
+
useEvaluatedAttributes
|
|
97
|
+
} from "@ea-lab/reactive-json";
|
|
98
|
+
|
|
99
|
+
export const FormComponentName = ({props, datafield, path}) => {
|
|
100
|
+
const globalDataContext = useContext(GlobalDataContext);
|
|
101
|
+
const templateContext = useContext(TemplateContext);
|
|
102
|
+
|
|
103
|
+
const attributes = useEvaluatedAttributes(props.attributes);
|
|
104
|
+
|
|
105
|
+
const {formData, formDataPath} = propsDataLocationToPathAndValue({
|
|
106
|
+
currentPath: path,
|
|
107
|
+
datafield: datafield,
|
|
108
|
+
dataLocation: props.dataLocation,
|
|
109
|
+
defaultValue: props.defaultFieldValue,
|
|
110
|
+
globalDataContext,
|
|
111
|
+
templateContext,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const onChange = (e) => {
|
|
115
|
+
globalDataContext.updateData(e.currentTarget.value, formDataPath);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<ActionDependant {...props}>
|
|
120
|
+
{/* Form component content */}
|
|
121
|
+
</ActionDependant>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for form component development patterns. For usage examples, see `core/element/form/`.
|
|
127
|
+
|
|
128
|
+
### 3. Component with View (Nested Content)
|
|
129
|
+
|
|
130
|
+
```jsx
|
|
131
|
+
import {
|
|
132
|
+
ActionDependant,
|
|
133
|
+
useEvaluatedAttributes,
|
|
134
|
+
View
|
|
135
|
+
} from "@ea-lab/reactive-json";
|
|
136
|
+
|
|
137
|
+
export const WrapperComponent = ({props, path, currentData, datafield}) => {
|
|
138
|
+
const attributes = useEvaluatedAttributes(props.attributes);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<ActionDependant {...props}>
|
|
142
|
+
<SomeWrapper {...attributes}>
|
|
143
|
+
{props?.content && (
|
|
144
|
+
<View
|
|
145
|
+
props={props.content}
|
|
146
|
+
path={path + ".content"}
|
|
147
|
+
currentData={currentData?.["content"]}
|
|
148
|
+
datafield={"content"}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
</SomeWrapper>
|
|
152
|
+
</ActionDependant>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for wrapper component patterns. For usage examples, see `core/element/html/`.
|
|
158
|
+
|
|
159
|
+
### 4. Generic Bootstrap Wrapper
|
|
160
|
+
|
|
161
|
+
```jsx
|
|
162
|
+
import {
|
|
163
|
+
ActionDependant,
|
|
164
|
+
useEvaluatedAttributes,
|
|
165
|
+
View
|
|
166
|
+
} from "@ea-lab/reactive-json";
|
|
167
|
+
|
|
168
|
+
export function BootstrapElement({props, currentData, path, bsComponent}) {
|
|
169
|
+
const attributes = useEvaluatedAttributes(props.attributes);
|
|
170
|
+
|
|
171
|
+
if (!bsComponent) return null;
|
|
172
|
+
|
|
173
|
+
const BsElement = bsComponent;
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<ActionDependant {...props}>
|
|
177
|
+
<BsElement {...attributes}>
|
|
178
|
+
{props.content && (
|
|
179
|
+
<View
|
|
180
|
+
currentData={currentData.content ?? undefined}
|
|
181
|
+
datafield={"content"}
|
|
182
|
+
path={path + ".content"}
|
|
183
|
+
props={props.content}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
</BsElement>
|
|
187
|
+
</ActionDependant>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 5. Action Component Structure
|
|
193
|
+
|
|
194
|
+
```jsx
|
|
195
|
+
import {useContext, useEffect} from "react";
|
|
196
|
+
import {
|
|
197
|
+
evaluateTemplateValue,
|
|
198
|
+
EventDispatcherContext,
|
|
199
|
+
GlobalDataContext,
|
|
200
|
+
TemplateContext
|
|
201
|
+
} from "@ea-lab/reactive-json";
|
|
202
|
+
|
|
203
|
+
export const ActionComponentName = (props) => {
|
|
204
|
+
const eventDispatcherContext = useContext(EventDispatcherContext);
|
|
205
|
+
const globalDataContext = useContext(GlobalDataContext);
|
|
206
|
+
const templateContext = useContext(TemplateContext);
|
|
207
|
+
|
|
208
|
+
const actionProps = props?.actionProps ?? undefined;
|
|
209
|
+
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
// Action logic here
|
|
212
|
+
}, [eventDispatcherContext, globalDataContext, actionProps, templateContext]);
|
|
213
|
+
|
|
214
|
+
return <>{props.children}</>;
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for action component development patterns. For usage examples, see `core/action/`.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Key APIs & Contexts
|
|
223
|
+
|
|
224
|
+
### Essential Contexts
|
|
225
|
+
- **GlobalDataContext**: Contains root data and `updateData` callback
|
|
226
|
+
- **TemplateContext**: Contains current template data
|
|
227
|
+
- **EventDispatcherContext**: Centralized event handling for performance
|
|
228
|
+
|
|
229
|
+
### Key Functions
|
|
230
|
+
- **evaluateTemplateValue()**: Evaluates template patterns (`~.value`, `~~.value`, `~>.value`)
|
|
231
|
+
- **useEvaluatedAttributes()**: Hook to evaluate dynamic attributes
|
|
232
|
+
- **propsDataLocationToPathAndValue()**: Form-specific data location handling
|
|
233
|
+
|
|
234
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for API usage patterns.
|
|
235
|
+
|
|
236
|
+
### Core Components
|
|
237
|
+
- **ActionDependant**: Enables action system support (wrap your component content)
|
|
238
|
+
- **View**: Renders RjBuild content or any displayable value
|
|
239
|
+
|
|
240
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for core component development patterns. For reaction function usage, see `core/reaction/`.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Component Creation Rules
|
|
245
|
+
|
|
246
|
+
### 1. Import Path Conventions
|
|
247
|
+
**For consumer applications** (recommended):
|
|
248
|
+
```jsx
|
|
249
|
+
import {
|
|
250
|
+
ActionDependant,
|
|
251
|
+
evaluateTemplateValue,
|
|
252
|
+
GlobalDataContext,
|
|
253
|
+
TemplateContext
|
|
254
|
+
} from "@ea-lab/reactive-json";
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Inside reactive-json library development** (internal use only):
|
|
258
|
+
```jsx
|
|
259
|
+
import {ActionDependant} from "../../../engine/Actions.jsx";
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 2. Component Signature Standards
|
|
263
|
+
✅ **Correct**:
|
|
264
|
+
```jsx
|
|
265
|
+
export const Component = ({props}) => {
|
|
266
|
+
// Use props.customValue
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
❌ **Avoid**:
|
|
271
|
+
```jsx
|
|
272
|
+
export const Component = ({props, customValue}) => {
|
|
273
|
+
// Don't add non-standard properties
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 3. Error Handling
|
|
278
|
+
- Components should fail silently when misconfigured
|
|
279
|
+
- Return `null` for invalid configurations
|
|
280
|
+
- Don't crash the application
|
|
281
|
+
|
|
282
|
+
### 4. Feature Implementation Priority
|
|
283
|
+
1. **Essential features**: Core functionality
|
|
284
|
+
2. **Requested features**: When explicitly asked
|
|
285
|
+
3. **Optional features**: Keep minimal complexity
|
|
286
|
+
|
|
287
|
+
### 5. Default Behavior
|
|
288
|
+
- Provide sensible defaults
|
|
289
|
+
- Allow overriding via YAML/JSON configuration
|
|
290
|
+
- Keep React components simple
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Integration & Activation
|
|
295
|
+
|
|
296
|
+
### Making Components Available
|
|
297
|
+
```jsx
|
|
298
|
+
import {
|
|
299
|
+
mergeComponentCollections,
|
|
300
|
+
ReactiveJsonRoot
|
|
301
|
+
} from "@ea-lab/reactive-json";
|
|
302
|
+
|
|
303
|
+
const customPlugins = {
|
|
304
|
+
element: {
|
|
305
|
+
MyCustomComponent,
|
|
306
|
+
AnotherComponent,
|
|
307
|
+
},
|
|
308
|
+
action: {
|
|
309
|
+
MyAction,
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export const CustomRoot = (props) => {
|
|
314
|
+
const plugins = mergeComponentCollections([customPlugins]);
|
|
315
|
+
return <ReactiveJsonRoot {...props} plugins={plugins} />;
|
|
316
|
+
};
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**⚠️ CRITICAL**: `mergeComponentCollections([...])` is **mandatory** even when you have only a single plugin collection. The reactive-json plugin system will not work without it.
|
|
320
|
+
|
|
321
|
+
### Plugin Structure
|
|
322
|
+
```js
|
|
323
|
+
{
|
|
324
|
+
action: { /* Action components */ },
|
|
325
|
+
element: { /* Element components */ },
|
|
326
|
+
hook: { /* React hooks */ },
|
|
327
|
+
reaction: { /* Reaction functions */ },
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/plugin-system.md` for plugin development. For integration examples, see `core/example/`.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Best Practices
|
|
336
|
+
|
|
337
|
+
### 1. Code Organization
|
|
338
|
+
- Order imports alphabetically by path
|
|
339
|
+
- Order object properties alphabetically
|
|
340
|
+
- Use JSX for reactive-json library components
|
|
341
|
+
- Export components via `index.js`: `export * from "./ComponentName.jsx";`
|
|
342
|
+
|
|
343
|
+
### 2. Dynamic Values
|
|
344
|
+
- Use `evaluateTemplateValue()` for single values
|
|
345
|
+
- Use `evaluateTemplateValueCollection()` for arrays/objects
|
|
346
|
+
- Always evaluate user-provided content
|
|
347
|
+
|
|
348
|
+
### 3. Attributes & Actions
|
|
349
|
+
- Include attribute support via `useEvaluatedAttributes()`
|
|
350
|
+
- Wrap content with `<ActionDependant {...props}>`
|
|
351
|
+
- Support actions unless explicitly told not to
|
|
352
|
+
|
|
353
|
+
### 4. CSS & Styling
|
|
354
|
+
- Use CSS modules for component-specific styles (`Component.module.css`)
|
|
355
|
+
- For external libraries, mention CSS import requirements
|
|
356
|
+
- Prefer minimal styling approach
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Component Development Workflow
|
|
361
|
+
|
|
362
|
+
### Step 1: Analyze Requirements
|
|
363
|
+
- Determine component type (element, action, form, wrapper)
|
|
364
|
+
- Identify dynamic vs static features
|
|
365
|
+
- Check if existing patterns apply
|
|
366
|
+
|
|
367
|
+
### Step 2: Choose Architecture
|
|
368
|
+
- Select appropriate component structure pattern
|
|
369
|
+
- Determine signature requirements (`props` only vs additional params)
|
|
370
|
+
- Plan data flow and contexts needed
|
|
371
|
+
|
|
372
|
+
### Step 3: Implement Core Logic
|
|
373
|
+
- Start with minimal working version
|
|
374
|
+
- Add essential features first
|
|
375
|
+
- Implement error handling
|
|
376
|
+
|
|
377
|
+
### Step 4: Add Reactive-JSON Integration
|
|
378
|
+
- Include ActionDependant wrapper
|
|
379
|
+
- Support attributes evaluation
|
|
380
|
+
- Handle template value evaluation
|
|
381
|
+
|
|
382
|
+
### Step 5: Create Usage Example
|
|
383
|
+
- Provide YAML/JSON example
|
|
384
|
+
- Show typical use cases
|
|
385
|
+
- Include integration instructions if needed
|
|
386
|
+
|
|
387
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/extend/component-development.md` for complete development workflow guide.
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Template Patterns Reference
|
|
392
|
+
|
|
393
|
+
### Data Access Patterns
|
|
394
|
+
```yaml
|
|
395
|
+
data:
|
|
396
|
+
global_value: "Hello"
|
|
397
|
+
template_data:
|
|
398
|
+
nested_value: "World"
|
|
399
|
+
|
|
400
|
+
renderView:
|
|
401
|
+
- content: ~~.global_value # From root data
|
|
402
|
+
- content: ~.nested_value # From current template
|
|
403
|
+
- content: ~>.nested_value # Search up hierarchy
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Common RjBuild Patterns
|
|
407
|
+
```yaml
|
|
408
|
+
# Basic component
|
|
409
|
+
- type: ComponentName
|
|
410
|
+
content: "Static content"
|
|
411
|
+
attributes:
|
|
412
|
+
class: "css-class"
|
|
413
|
+
style:
|
|
414
|
+
backgroundColor: yellow
|
|
415
|
+
|
|
416
|
+
# With template data
|
|
417
|
+
- type: ComponentName
|
|
418
|
+
content: ~.dynamic_content
|
|
419
|
+
customProp: ~~.global_value
|
|
420
|
+
|
|
421
|
+
# With actions
|
|
422
|
+
- type: ComponentName
|
|
423
|
+
content: "Conditional content"
|
|
424
|
+
actions:
|
|
425
|
+
- what: hide
|
|
426
|
+
when: ~.condition
|
|
427
|
+
is: true
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
> 📚 **More details**: See `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/docs/core/` for usage examples.
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
**Remember**: Always prioritize simplicity, follow existing patterns, and make components fail gracefully. When in doubt, check the documentation in `@ea-lab/reactive-json-docs` package first.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ea-lab/reactive-json",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.41",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"json",
|
|
17
17
|
"react",
|
|
18
18
|
"structure",
|
|
19
|
-
"yaml"
|
|
19
|
+
"yaml",
|
|
20
|
+
"llm",
|
|
21
|
+
"ai-assistant",
|
|
22
|
+
"cursor",
|
|
23
|
+
"chatgpt",
|
|
24
|
+
"claude"
|
|
20
25
|
],
|
|
21
26
|
"author": "Quang-Minh DANG <quang-minh@ea-lab.io> (https://ea-lab.io/)",
|
|
22
27
|
"license": "ISC",
|
|
@@ -76,9 +81,16 @@
|
|
|
76
81
|
"main": "dist/main.js",
|
|
77
82
|
"types": "dist/main.d.ts",
|
|
78
83
|
"files": [
|
|
79
|
-
"dist"
|
|
84
|
+
"dist",
|
|
85
|
+
"README_LLM.md",
|
|
86
|
+
".cursorrules"
|
|
80
87
|
],
|
|
81
88
|
"sideEffects": [
|
|
82
89
|
"**/*.css"
|
|
83
|
-
]
|
|
90
|
+
],
|
|
91
|
+
"llm": {
|
|
92
|
+
"entrypoint": "README_LLM.md",
|
|
93
|
+
"description": "AI/LLM guide for reactive-json development",
|
|
94
|
+
"purpose": "Component creation and reactive-json usage patterns for AI assistants"
|
|
95
|
+
}
|
|
84
96
|
}
|