@ea-lab/reactive-json-docs 0.1.2
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/README-npm.md +49 -0
- package/README.md +86 -0
- package/package.json +79 -0
- package/public/rjbuild/component-doc/chartjs/components.yaml +252 -0
- package/public/rjbuild/component-doc/chartjs/overview.yaml +51 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.md +90 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.yaml +124 -0
- package/public/rjbuild/component-doc/core/action/Hide.md +22 -0
- package/public/rjbuild/component-doc/core/action/Hide.yaml +60 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.md +93 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.yaml +153 -0
- package/public/rjbuild/component-doc/core/action/Popover.md +26 -0
- package/public/rjbuild/component-doc/core/action/Popover.yaml +100 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.md +81 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.yaml +133 -0
- package/public/rjbuild/component-doc/core/action/Redirect.md +20 -0
- package/public/rjbuild/component-doc/core/action/Redirect.yaml +68 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.md +22 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.yaml +90 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.md +21 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.yaml +62 -0
- package/public/rjbuild/component-doc/core/action/index.md +214 -0
- package/public/rjbuild/component-doc/core/action/index.yaml +278 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.md +276 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.yaml +338 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.md +189 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.yaml +264 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.md +136 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.yaml +103 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.md +304 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.yaml +360 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.md +134 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.yaml +146 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.md +129 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.yaml +147 -0
- package/public/rjbuild/component-doc/core/element/form/formElementsCommon.md +106 -0
- package/public/rjbuild/component-doc/core/element/form/index.md +50 -0
- package/public/rjbuild/component-doc/core/element/form/index.yaml +96 -0
- package/public/rjbuild/component-doc/core/element/html/AccordionItem.yaml +47 -0
- package/public/rjbuild/component-doc/core/element/html/FolderSortableTree.yaml +81 -0
- package/public/rjbuild/component-doc/core/element/html/FormatNumeral.yaml +58 -0
- package/public/rjbuild/component-doc/core/element/html/Html.yaml +67 -0
- package/public/rjbuild/component-doc/core/element/html/LabelFromValue.yaml +54 -0
- package/public/rjbuild/component-doc/core/element/html/Modal.yaml +93 -0
- package/public/rjbuild/component-doc/core/element/html/PreformattedMarkup.yaml +37 -0
- package/public/rjbuild/component-doc/core/element/html/SortableTreeItemCollapseButton.yaml +92 -0
- package/public/rjbuild/component-doc/core/element/html/Tabs.yaml +57 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.md +17 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.yaml +18 -0
- package/public/rjbuild/component-doc/core/element/special/Count.md +37 -0
- package/public/rjbuild/component-doc/core/element/special/Count.yaml +325 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.md +149 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.yaml +315 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.md +51 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.yaml +55 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.md +126 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.yaml +133 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.md +31 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.yaml +34 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.md +27 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.yaml +51 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.md +262 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.yaml +348 -0
- package/public/rjbuild/component-doc/core/example/accordion.md +96 -0
- package/public/rjbuild/component-doc/core/example/accordion.yaml +64 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.md +197 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.yaml +237 -0
- package/public/rjbuild/component-doc/core/example/html.md +66 -0
- package/public/rjbuild/component-doc/core/example/html.yaml +83 -0
- package/public/rjbuild/component-doc/core/example/website.yaml +1663 -0
- package/public/rjbuild/component-doc/core/reaction/addData.md +96 -0
- package/public/rjbuild/component-doc/core/reaction/addData.yaml +133 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.md +60 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.yaml +156 -0
- package/public/rjbuild/component-doc/core/reaction/index.md +236 -0
- package/public/rjbuild/component-doc/core/reaction/index.yaml +254 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.md +68 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.yaml +71 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.md +63 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.yaml +68 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.md +37 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.yaml +37 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.md +78 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.yaml +56 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.md +44 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.yaml +41 -0
- package/public/rjbuild/component-doc/core/reaction/setData.md +93 -0
- package/public/rjbuild/component-doc/core/reaction/setData.yaml +85 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.md +138 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.yaml +141 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.md +59 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.yaml +59 -0
- package/public/rjbuild/component-doc/index.yaml +13 -0
package/README-npm.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @ea-lab/reactive-json-docs
|
|
2
|
+
|
|
3
|
+
Complete documentation for Reactive-JSON - LLM-Parsable Format
|
|
4
|
+
|
|
5
|
+
## 📚 Content
|
|
6
|
+
|
|
7
|
+
This package contains the complete Reactive-JSON documentation in YAML format, optimized for easy parsing by LLMs:
|
|
8
|
+
|
|
9
|
+
- **Core Components**: HTML elements, actions & reactions, form elements, special components, etc.
|
|
10
|
+
- **Integrations**: Chart.js components and others
|
|
11
|
+
- **Examples**: Complete use cases and demos
|
|
12
|
+
|
|
13
|
+
## 🚀 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @ea-lab/reactive-json-docs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 📖 Usage
|
|
20
|
+
|
|
21
|
+
### For LLM Users
|
|
22
|
+
|
|
23
|
+
Tell your LLM about this package:
|
|
24
|
+
|
|
25
|
+
> "I have the npm package `@ea-lab/reactive-json-docs` installed, which contains complete documentation for @ea-lab/reactive-json and plugins. The documentation is located in `node_modules/@ea-lab/reactive-json-docs/public/rjbuild/component-doc/`. Can you help me understand how to use Reactive-JSON components?"
|
|
26
|
+
|
|
27
|
+
### Structure
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
component-doc/
|
|
31
|
+
├── index.yaml # Main index
|
|
32
|
+
├── core/
|
|
33
|
+
│ ├── action/ # Actions (Hide, Show, Redirect...)
|
|
34
|
+
│ ├── element/ # UI Elements
|
|
35
|
+
│ │ ├── form/ # Form fields
|
|
36
|
+
│ │ ├── html/ # HTML elements
|
|
37
|
+
│ │ └── special/ # Special components
|
|
38
|
+
│ ├── example/ # Complete examples
|
|
39
|
+
│ └── reaction/ # Reactivity system
|
|
40
|
+
└── chartjs/ # Chart.js integration
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🤖 LLM-Optimized
|
|
44
|
+
|
|
45
|
+
- Standardized YAML format
|
|
46
|
+
- Complete documentation with examples
|
|
47
|
+
- Structured metadata
|
|
48
|
+
- Detailed use cases
|
|
49
|
+
- Cross-references
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# reactive-json-docs
|
|
2
|
+
|
|
3
|
+
Documentation project for *[reactive-json](https://github.com/Ealab-collab/reactive-json)* (`@ea-lab/reactive-json`),
|
|
4
|
+
a React-based library that transforms JSON (or YAML) into HTML markup.
|
|
5
|
+
|
|
6
|
+
This project serves as the complete documentation hub for *reactive-json* and its ecosystem,
|
|
7
|
+
providing structured YAML documentation files optimized for LLM parsing and developer reference.
|
|
8
|
+
|
|
9
|
+
## The gist
|
|
10
|
+
|
|
11
|
+
Two npm packages are available:
|
|
12
|
+
|
|
13
|
+
**📚 Documentation Package** (this project):
|
|
14
|
+
```bash
|
|
15
|
+
npm install @ea-lab/reactive-json-docs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**⚛️ Main Library Package**:
|
|
19
|
+
```bash
|
|
20
|
+
npm install @ea-lab/reactive-json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The documentation package is optimized for LLMs and development tools, while the main library package is what you use in your React applications.
|
|
24
|
+
|
|
25
|
+
The complete documentation repository can be found at: [reactive-json-docs](https://github.com/Ealab-collab/reactive-json-docs).
|
|
26
|
+
|
|
27
|
+
You can also run the documentation website locally with `npm start` to browse the interactive documentation.
|
|
28
|
+
|
|
29
|
+
## Project structure
|
|
30
|
+
|
|
31
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
32
|
+
|
|
33
|
+
The usual commands can be found in the annex [README-CRA.md](README-CRA.md).
|
|
34
|
+
|
|
35
|
+
> 💡 **Community contribution welcome**: We'd love to migrate this project to [Vite](https://vitejs.dev) for better performance and developer experience!
|
|
36
|
+
|
|
37
|
+
The following is the specific documentation for the *reactive-json-docs* project.
|
|
38
|
+
|
|
39
|
+
### Documentation directory `/public/rjbuild`
|
|
40
|
+
|
|
41
|
+
This directory contains the structured documentation files for *reactive-json*.
|
|
42
|
+
|
|
43
|
+
The `/public/rjbuild/component-doc` directory contains the main documentation in YAML format:
|
|
44
|
+
- **Core components**: Actions, form elements, HTML elements, special components
|
|
45
|
+
- **Integrations**: Chart.js and other plugin documentation
|
|
46
|
+
- **Examples**: Complete use cases and implementation demos
|
|
47
|
+
- **Reactions**: Reactivity system and event handling
|
|
48
|
+
|
|
49
|
+
These YAML files are the structured documentation that powers both the web interface
|
|
50
|
+
and the npm package for LLM consumption.
|
|
51
|
+
|
|
52
|
+
### Pages directory `/public/rjbuild/pages`
|
|
53
|
+
|
|
54
|
+
Contains the website pages:
|
|
55
|
+
- `home.yaml` - Website homepage
|
|
56
|
+
- `docs.yaml` - Documentation browser index page
|
|
57
|
+
- `home-docs/` - Styling guides for this documentation project only
|
|
58
|
+
|
|
59
|
+
### Hull `/src/hull`
|
|
60
|
+
|
|
61
|
+
Contains the code that powers the documentation website interface.
|
|
62
|
+
|
|
63
|
+
This includes the React components that render the documentation browser,
|
|
64
|
+
component demos, and interactive examples.
|
|
65
|
+
|
|
66
|
+
The documentation website provides a user-friendly interface to browse
|
|
67
|
+
all available reactive-json components and their usage examples.
|
|
68
|
+
|
|
69
|
+
## Publishing Documentation
|
|
70
|
+
|
|
71
|
+
This project can publish its documentation as an npm package. See [PUBLICATION-GUIDE.md](PUBLICATION-GUIDE.md) for details.
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
Run the documentation website locally:
|
|
76
|
+
```bash
|
|
77
|
+
npm start
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Build the documentation website:
|
|
81
|
+
```bash
|
|
82
|
+
npm run build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The documentation files in `/public/rjbuild/component-doc` are the source of truth
|
|
86
|
+
for all reactive-json component documentation.
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ea-lab/reactive-json-docs",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Complete documentation for Reactive-JSON - Components, examples and LLM-parsable guides",
|
|
5
|
+
"main": "public/rjbuild/component-doc/index.yaml",
|
|
6
|
+
"files": [
|
|
7
|
+
"public/rjbuild/component-doc/**/*",
|
|
8
|
+
"README-npm.md"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"reactive-json",
|
|
12
|
+
"documentation",
|
|
13
|
+
"components",
|
|
14
|
+
"yaml",
|
|
15
|
+
"llm-parsable",
|
|
16
|
+
"react",
|
|
17
|
+
"json-forms"
|
|
18
|
+
],
|
|
19
|
+
"author": "EA-Lab",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/your-username/reactive-json-standalone.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/your-username/reactive-json-standalone#readme",
|
|
26
|
+
"private": false,
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@craco/craco": "^7.1.0",
|
|
29
|
+
"@ea-lab/reactive-json": "^0.0.37",
|
|
30
|
+
"@ea-lab/reactive-json-chartjs": "^0.0.23",
|
|
31
|
+
"@npmcli/fs": "^4.0.0",
|
|
32
|
+
"@reduxjs/toolkit": "^2.6.1",
|
|
33
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
34
|
+
"@testing-library/react": "^16.3.0",
|
|
35
|
+
"@testing-library/user-event": "^14.6.1",
|
|
36
|
+
"bootstrap": "^5.3.5",
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"react": "^19.1.0",
|
|
39
|
+
"react-bootstrap": "^2.10.2",
|
|
40
|
+
"react-dom": "^19.1.0",
|
|
41
|
+
"react-markdown": "^10.1.0",
|
|
42
|
+
"react-redux": "^9.2.0",
|
|
43
|
+
"react-router-dom": "^7.5.0",
|
|
44
|
+
"react-scripts": "^5.0.1",
|
|
45
|
+
"react-syntax-highlighter": "^15.6.1",
|
|
46
|
+
"redux": "^5.0.1",
|
|
47
|
+
"web-vitals": "^4.2.4"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"start": "craco start",
|
|
51
|
+
"build": "craco build",
|
|
52
|
+
"test": "craco test",
|
|
53
|
+
"eject": "craco eject",
|
|
54
|
+
"publish-docs": "npm publish --access public"
|
|
55
|
+
},
|
|
56
|
+
"eslintConfig": {
|
|
57
|
+
"extends": [
|
|
58
|
+
"react-app",
|
|
59
|
+
"react-app/jest"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"browser": {
|
|
63
|
+
"fs": false,
|
|
64
|
+
"path": false,
|
|
65
|
+
"os": false
|
|
66
|
+
},
|
|
67
|
+
"browserslist": {
|
|
68
|
+
"production": [
|
|
69
|
+
">0.2%",
|
|
70
|
+
"not dead",
|
|
71
|
+
"not op_mini all"
|
|
72
|
+
],
|
|
73
|
+
"development": [
|
|
74
|
+
"last 1 chrome version",
|
|
75
|
+
"last 1 firefox version",
|
|
76
|
+
"last 1 safari version"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: h1
|
|
3
|
+
content: ChartJS components
|
|
4
|
+
|
|
5
|
+
- type: RjBuildDescriber
|
|
6
|
+
title: Bar chart
|
|
7
|
+
toDescribe:
|
|
8
|
+
renderView:
|
|
9
|
+
- type: div
|
|
10
|
+
attributes:
|
|
11
|
+
class: chart-container
|
|
12
|
+
style:
|
|
13
|
+
position: relative
|
|
14
|
+
height: 60vh
|
|
15
|
+
content:
|
|
16
|
+
- type: BarChart
|
|
17
|
+
options:
|
|
18
|
+
plugins:
|
|
19
|
+
legend:
|
|
20
|
+
position: bottom
|
|
21
|
+
data: ~~.barChartData
|
|
22
|
+
templates:
|
|
23
|
+
data:
|
|
24
|
+
barChartData:
|
|
25
|
+
labels:
|
|
26
|
+
- Students
|
|
27
|
+
- Teachers
|
|
28
|
+
- Employees
|
|
29
|
+
datasets:
|
|
30
|
+
- label: Private school
|
|
31
|
+
data: [ 10, 20, 3 ]
|
|
32
|
+
backgroundColor:
|
|
33
|
+
- rgb(255, 99, 132)
|
|
34
|
+
- rgb(54, 162, 235)
|
|
35
|
+
- rgb(255, 206, 86)
|
|
36
|
+
borderColor:
|
|
37
|
+
- rgba(255, 99, 132, 0.7)
|
|
38
|
+
- rgba(54, 162, 235, 0.7)
|
|
39
|
+
- rgba(255, 206, 86, 0.7)
|
|
40
|
+
borderWidth: 1
|
|
41
|
+
|
|
42
|
+
- type: RjBuildDescriber
|
|
43
|
+
title: Doughnut chart
|
|
44
|
+
toDescribe:
|
|
45
|
+
renderView:
|
|
46
|
+
- type: div
|
|
47
|
+
attributes:
|
|
48
|
+
class: chart-container
|
|
49
|
+
style:
|
|
50
|
+
position: relative
|
|
51
|
+
height: 60vh
|
|
52
|
+
content:
|
|
53
|
+
- type: DoughnutChart
|
|
54
|
+
options:
|
|
55
|
+
plugins:
|
|
56
|
+
legend:
|
|
57
|
+
position: right
|
|
58
|
+
data: ~~.doughnutChartData
|
|
59
|
+
templates:
|
|
60
|
+
data:
|
|
61
|
+
doughnutChartData:
|
|
62
|
+
labels:
|
|
63
|
+
- Male
|
|
64
|
+
- Female
|
|
65
|
+
datasets:
|
|
66
|
+
- label: Gender distribution
|
|
67
|
+
data: [ 60, 40 ]
|
|
68
|
+
backgroundColor:
|
|
69
|
+
- rgb(75, 192, 192)
|
|
70
|
+
- rgb(255, 205, 86)
|
|
71
|
+
borderColor:
|
|
72
|
+
- rgba(75, 192, 192, 0.7)
|
|
73
|
+
- rgba(255, 205, 86, 0.7)
|
|
74
|
+
borderWidth: 1
|
|
75
|
+
|
|
76
|
+
- type: RjBuildDescriber
|
|
77
|
+
title: Polar area chart
|
|
78
|
+
toDescribe:
|
|
79
|
+
renderView:
|
|
80
|
+
- type: div
|
|
81
|
+
attributes:
|
|
82
|
+
class: chart-container
|
|
83
|
+
style:
|
|
84
|
+
position: relative
|
|
85
|
+
height: 60vh
|
|
86
|
+
content:
|
|
87
|
+
- type: PolarAreaChart
|
|
88
|
+
options:
|
|
89
|
+
plugins:
|
|
90
|
+
legend:
|
|
91
|
+
position: right
|
|
92
|
+
data: ~~.polarAreaChartData
|
|
93
|
+
templates:
|
|
94
|
+
data:
|
|
95
|
+
polarAreaChartData:
|
|
96
|
+
labels:
|
|
97
|
+
- Red
|
|
98
|
+
- Blue
|
|
99
|
+
- Yellow
|
|
100
|
+
- Green
|
|
101
|
+
datasets:
|
|
102
|
+
- label: Colors
|
|
103
|
+
data: [ 12, 19, 10, 7 ]
|
|
104
|
+
backgroundColor:
|
|
105
|
+
- rgba(255, 99, 132, 0.6)
|
|
106
|
+
- rgba(54, 162, 235, 0.6)
|
|
107
|
+
- rgba(255, 206, 86, 0.6)
|
|
108
|
+
- rgba(75, 192, 192, 0.6)
|
|
109
|
+
borderColor:
|
|
110
|
+
- rgba(255, 99, 132, 1)
|
|
111
|
+
- rgba(54, 162, 235, 1)
|
|
112
|
+
- rgba(255, 206, 86, 1)
|
|
113
|
+
- rgba(75, 192, 192, 1)
|
|
114
|
+
borderWidth: 1
|
|
115
|
+
|
|
116
|
+
- type: RjBuildDescriber
|
|
117
|
+
title: Line chart
|
|
118
|
+
toDescribe:
|
|
119
|
+
renderView:
|
|
120
|
+
- type: div
|
|
121
|
+
attributes:
|
|
122
|
+
class: chart-container
|
|
123
|
+
style:
|
|
124
|
+
position: relative
|
|
125
|
+
height: 60vh
|
|
126
|
+
content:
|
|
127
|
+
- type: LineChart
|
|
128
|
+
options:
|
|
129
|
+
plugins:
|
|
130
|
+
legend:
|
|
131
|
+
position: bottom
|
|
132
|
+
data: ~~.lineChartData
|
|
133
|
+
templates:
|
|
134
|
+
data:
|
|
135
|
+
lineChartData:
|
|
136
|
+
labels:
|
|
137
|
+
- January
|
|
138
|
+
- February
|
|
139
|
+
- March
|
|
140
|
+
- April
|
|
141
|
+
- May
|
|
142
|
+
datasets:
|
|
143
|
+
- label: Sales
|
|
144
|
+
data:
|
|
145
|
+
- 30
|
|
146
|
+
- 45
|
|
147
|
+
- 28
|
|
148
|
+
- 50
|
|
149
|
+
- 75
|
|
150
|
+
backgroundColor: rgba(54, 162, 235, 0.2)
|
|
151
|
+
borderColor: rgba(54, 162, 235, 1)
|
|
152
|
+
borderWidth: 2
|
|
153
|
+
|
|
154
|
+
- type: RjBuildDescriber
|
|
155
|
+
title: Embedded line charts
|
|
156
|
+
toDescribe:
|
|
157
|
+
renderView:
|
|
158
|
+
- type: div
|
|
159
|
+
attributes:
|
|
160
|
+
class: chart-container
|
|
161
|
+
style:
|
|
162
|
+
position: relative
|
|
163
|
+
height: 60vh
|
|
164
|
+
content:
|
|
165
|
+
- type: LineChart
|
|
166
|
+
options:
|
|
167
|
+
plugins:
|
|
168
|
+
legend:
|
|
169
|
+
position: bottom
|
|
170
|
+
filler:
|
|
171
|
+
propagate: true
|
|
172
|
+
elements:
|
|
173
|
+
line:
|
|
174
|
+
tension: 0.4
|
|
175
|
+
borderWidth: 2
|
|
176
|
+
point:
|
|
177
|
+
radius: 0
|
|
178
|
+
scales:
|
|
179
|
+
y:
|
|
180
|
+
stacked: true
|
|
181
|
+
data: ~~.embeddedLineChartData
|
|
182
|
+
templates:
|
|
183
|
+
data:
|
|
184
|
+
embeddedLineChartData:
|
|
185
|
+
labels: [ Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday ]
|
|
186
|
+
datasets:
|
|
187
|
+
- label: "Presence"
|
|
188
|
+
data: [ 3, 7, 5, 12, 6, 2, 1 ]
|
|
189
|
+
fill: true
|
|
190
|
+
backgroundColor: rgba(0, 255, 0, 0.4)
|
|
191
|
+
borderColor: rgba(0, 255, 0, 1)
|
|
192
|
+
borderWidth: 2
|
|
193
|
+
- label: "Absence"
|
|
194
|
+
data: [ 2, 1, 3, 2, 4, 6, 7 ]
|
|
195
|
+
fill: true
|
|
196
|
+
backgroundColor: rgba(255, 0, 0, 0.4)
|
|
197
|
+
borderColor: rgba(255, 0, 0, 1)
|
|
198
|
+
borderWidth: 2
|
|
199
|
+
|
|
200
|
+
- type: RjBuildDescriber
|
|
201
|
+
title: Filled line chart
|
|
202
|
+
toDescribe:
|
|
203
|
+
renderView:
|
|
204
|
+
- type: div
|
|
205
|
+
attributes:
|
|
206
|
+
class: chart-container
|
|
207
|
+
style:
|
|
208
|
+
position: relative
|
|
209
|
+
height: 60vh
|
|
210
|
+
content:
|
|
211
|
+
- type: LineChart
|
|
212
|
+
options:
|
|
213
|
+
plugins:
|
|
214
|
+
legend:
|
|
215
|
+
position: bottom
|
|
216
|
+
filler:
|
|
217
|
+
propagate: true
|
|
218
|
+
elements:
|
|
219
|
+
line:
|
|
220
|
+
tension: 0.4
|
|
221
|
+
borderWidth: 2
|
|
222
|
+
point:
|
|
223
|
+
radius: 0
|
|
224
|
+
data: ~~.filledLineChartData
|
|
225
|
+
templates:
|
|
226
|
+
data:
|
|
227
|
+
filledLineChartData:
|
|
228
|
+
labels:
|
|
229
|
+
- January
|
|
230
|
+
- February
|
|
231
|
+
- March
|
|
232
|
+
- April
|
|
233
|
+
- May
|
|
234
|
+
- June
|
|
235
|
+
- July
|
|
236
|
+
datasets:
|
|
237
|
+
- label: "Revenue"
|
|
238
|
+
data: [ 5000, 7000, 6500, 8500, 9000, 3000, 2000 ]
|
|
239
|
+
fill: true
|
|
240
|
+
backgroundColor: rgba(0, 128, 255, 0.4)
|
|
241
|
+
borderColor: rgba(0, 128, 255, 1)
|
|
242
|
+
borderWidth: 2
|
|
243
|
+
- label: "Expenses"
|
|
244
|
+
data: [ 3000, 4000, 4200, 5000, 4800, 6200, 5800 ]
|
|
245
|
+
fill: true
|
|
246
|
+
backgroundColor: rgba(255, 99, 132, 0.4)
|
|
247
|
+
borderColor: rgba(255, 99, 132, 1)
|
|
248
|
+
borderWidth: 2
|
|
249
|
+
|
|
250
|
+
templates:
|
|
251
|
+
|
|
252
|
+
data: { }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: h1
|
|
3
|
+
content: Chart.js integration overview
|
|
4
|
+
|
|
5
|
+
- type: Markdown
|
|
6
|
+
content: |
|
|
7
|
+
Reactive-JSON has Chart.js integration through the `@ea-lab/reactive-json-chartjs` plugin.
|
|
8
|
+
|
|
9
|
+
The Chart.js integration adds components such as: `BarChart`, `LineChart`, `PolarAreaChart`.
|
|
10
|
+
|
|
11
|
+
The Chart.js components use a config structure similar to the Chart.js library, so the official documentation
|
|
12
|
+
also applies here (as long the versions match).
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
The demo website you currently look at has already this integration installed and ready.
|
|
17
|
+
|
|
18
|
+
To enable the integration on your own project that uses Reactive-JSON, make sure
|
|
19
|
+
that the integration is installed and loaded.
|
|
20
|
+
|
|
21
|
+
Chart.js is available through the `@ea-lab/reactive-json-chartjs` plugin. To get it:
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
npm i @ea-lab/reactive-json-chartjs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then make it available to ReactiveJsonRoot:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import {ReactiveJsonRoot} from "@ea-lab/reactive-json";
|
|
31
|
+
import {mergeComponentCollections} from "@ea-lab/reactive-json";
|
|
32
|
+
import {chartjsComponents} from "@ea-lab/reactive-json-chartjs";
|
|
33
|
+
|
|
34
|
+
export const YourComponent = () => {
|
|
35
|
+
|
|
36
|
+
const rjRootProps = {
|
|
37
|
+
// Set your own props to rjRootProps such as dataUrl.
|
|
38
|
+
// ...
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Set the plugins prop by merging the component collections.
|
|
42
|
+
// Here, we only have a single plugin, but you can add your own of course.
|
|
43
|
+
rjRootProps.plugins = mergeComponentCollections([chartjsComponents]);
|
|
44
|
+
|
|
45
|
+
return <ReactiveJsonRoot {...rjRootProps} />;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
templates:
|
|
50
|
+
|
|
51
|
+
data: { }
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# HashChangeListener
|
|
2
|
+
|
|
3
|
+
**Description**: Listens to hash changes (URL fragment) in the window and executes a reaction function in response. This is an internal action component that is automatically used when you specify `on: "hashchange"` in your actions.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
HashChangeListener is **not** used directly as an element type. Instead, it is automatically triggered when you use `on: "hashchange"` in any action. The system automatically adds this component to listen for hash changes globally.
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
When using `on: "hashchange"` in actions, you can specify:
|
|
12
|
+
|
|
13
|
+
- `what` (required): name of the reaction function to execute (e.g., `setData`, `fetchData`, `submitData`, etc.)
|
|
14
|
+
- `whenHashIs` (optional): hash value that should trigger the reaction (includes the '#' character)
|
|
15
|
+
- `whenHashWas` (optional): previous hash value that should trigger the reaction (includes the '#' character)
|
|
16
|
+
- All other properties are passed as arguments to the reaction function
|
|
17
|
+
|
|
18
|
+
## Behavior
|
|
19
|
+
|
|
20
|
+
When you use `on: "hashchange"` in an action:
|
|
21
|
+
|
|
22
|
+
1. The system automatically adds a HashChangeListener component
|
|
23
|
+
2. It listens to hash changes via the global event system (`EventDispatcherContext`)
|
|
24
|
+
3. When a hash change occurs:
|
|
25
|
+
- If `whenHashIs` is defined, checks if the new hash matches
|
|
26
|
+
- If `whenHashWas` is defined, checks if the old hash matches
|
|
27
|
+
- If conditions are met, executes the reaction function specified in `what`
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### React to specific hash
|
|
32
|
+
```yaml
|
|
33
|
+
renderView:
|
|
34
|
+
- type: button
|
|
35
|
+
content: "Click me"
|
|
36
|
+
actions:
|
|
37
|
+
- what: setData
|
|
38
|
+
on: hashchange
|
|
39
|
+
whenHashIs: "#section2"
|
|
40
|
+
path: "currentSection"
|
|
41
|
+
value: "section2"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### React to previous hash change
|
|
45
|
+
```yaml
|
|
46
|
+
renderView:
|
|
47
|
+
- type: div
|
|
48
|
+
content: "Page content"
|
|
49
|
+
actions:
|
|
50
|
+
- what: fetchData
|
|
51
|
+
on: hashchange
|
|
52
|
+
whenHashWas: "#home"
|
|
53
|
+
url: "/api/section-data"
|
|
54
|
+
path: "sectionData"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### React to any hash change
|
|
58
|
+
```yaml
|
|
59
|
+
renderView:
|
|
60
|
+
- type: div
|
|
61
|
+
content: "Navigation"
|
|
62
|
+
actions:
|
|
63
|
+
- what: setData
|
|
64
|
+
on: hashchange
|
|
65
|
+
path: "hashChanged"
|
|
66
|
+
value: true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## System Integration
|
|
70
|
+
|
|
71
|
+
- **EventDispatcherContext**: Uses the global event system to optimize performance
|
|
72
|
+
- **TemplateSystem**: The `whenHashIs` and `whenHashWas` values are evaluated through the template system
|
|
73
|
+
- **GlobalDataContext**: Provides context for reaction execution
|
|
74
|
+
- **Actions.jsx**: Automatically instantiated when `on: "hashchange"` is detected
|
|
75
|
+
|
|
76
|
+
## Limitations
|
|
77
|
+
|
|
78
|
+
- Only works with `on: "hashchange"` in actions (not as a standalone element)
|
|
79
|
+
- Only works on hash changes (URL fragment)
|
|
80
|
+
- Depends on ReactiveJSON's global event system
|
|
81
|
+
- Hashes must include the '#' character (e.g., "#section1", not "section1")
|
|
82
|
+
- One reaction per action definition (use multiple actions for multiple reactions)
|
|
83
|
+
|
|
84
|
+
## Technical Details
|
|
85
|
+
|
|
86
|
+
- Automatically instantiated by the Actions system when `on: "hashchange"` is used
|
|
87
|
+
- Uses `useEffect` to subscribe/unsubscribe to events
|
|
88
|
+
- Reaction functions are imported from `ReactOnEvent.jsx`
|
|
89
|
+
- Optimized to avoid too many real DOM listeners through the context system
|
|
90
|
+
- Automatically cleans up listeners when component unmounts
|