@ea-lab/reactive-json 0.0.4 → 0.0.6
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/dist/reactive-json.js +34005 -42617
- package/dist/reactive-json.umd.cjs +187 -204
- package/lib/engine/ComponentCollector.js +26 -0
- package/lib/engine/ReactiveJsonRoot.jsx +2 -0
- package/lib/engine/View.jsx +0 -8
- package/lib/main.jsx +12 -1
- package/package.json +2 -4
- package/lib/component/element/chart/BarChart.jsx +0 -40
- package/lib/component/element/chart/DoughnutChart.jsx +0 -32
- package/lib/component/element/chart/LineChart.jsx +0 -40
- package/lib/component/element/chart/PolarAreaChart.jsx +0 -32
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges component collections (aka plugins).
|
|
3
|
+
* @param {[{}]} collections Array of plugin collections.
|
|
4
|
+
* @return {{hook: *[], reaction: *[], action: *[], utility: *[], element: *[]}}
|
|
5
|
+
*/
|
|
6
|
+
export function mergeComponentCollections(collections) {
|
|
7
|
+
const mergedCollections = {
|
|
8
|
+
"action": [],
|
|
9
|
+
"element": [],
|
|
10
|
+
"hook": [],
|
|
11
|
+
"reaction": [],
|
|
12
|
+
"utility": [],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
collections.forEach((collection) => {
|
|
16
|
+
for (const [k, v] in Object.entries(collection)) {
|
|
17
|
+
if (!mergedCollections.hasOwnProperty(k)) {
|
|
18
|
+
mergedCollections[k] = [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mergedCollections[k].push(v);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return mergedCollections;
|
|
26
|
+
}
|
|
@@ -14,6 +14,7 @@ import {useEffect, useReducer, useState} from 'react';
|
|
|
14
14
|
* Use "POST" for post. Other values mean "GET".
|
|
15
15
|
* @param {string} dataUrl The URL of the document containing the build data. Either JSON or YAML.
|
|
16
16
|
* @param {{}} headersForData Headers for the data request, such as authentication info.
|
|
17
|
+
* @param {{}} plugins Reactive-JSON plugins.
|
|
17
18
|
* @param {boolean} debugMode Set to true to show the data structure and debug info.
|
|
18
19
|
* @param {React.Element|null} DebugModeContentWrapper Wrapper around the main reactive-json content when in debug mode.
|
|
19
20
|
* @param {React.Element|null} DebugModeDataWrapper Wrapper around the reactive-json debug data when in debug mode.
|
|
@@ -27,6 +28,7 @@ function ReactiveJsonRoot({
|
|
|
27
28
|
dataFetchMethod,
|
|
28
29
|
dataUrl,
|
|
29
30
|
headersForData,
|
|
31
|
+
plugins,
|
|
30
32
|
debugMode,
|
|
31
33
|
DebugModeContentWrapper,
|
|
32
34
|
DebugModeDataWrapper,
|
package/lib/engine/View.jsx
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import {useContext} from 'react';
|
|
2
|
-
import BarChart from "../component/element/chart/BarChart";
|
|
3
|
-
import DoughnutChart from "../component/element/chart/DoughnutChart";
|
|
4
|
-
import PolarAreaChart from "../component/element/chart/PolarAreaChart";
|
|
5
2
|
import CheckBoxField from "../component/element/form/CheckBoxField";
|
|
6
3
|
import DateField from "../component/element/form/DateField";
|
|
7
4
|
import NumberField from "../component/element/form/NumberField";
|
|
@@ -34,28 +31,23 @@ import {
|
|
|
34
31
|
Badge,
|
|
35
32
|
Button,
|
|
36
33
|
} from "react-bootstrap";
|
|
37
|
-
import LineChart from "../component/element/chart/LineChart";
|
|
38
34
|
|
|
39
35
|
const components = {
|
|
40
36
|
AccordionItem,
|
|
41
|
-
BarChart,
|
|
42
37
|
CheckBoxField,
|
|
43
38
|
Count,
|
|
44
39
|
DateField,
|
|
45
40
|
DataFilter,
|
|
46
41
|
DelayedActions,
|
|
47
|
-
DoughnutChart,
|
|
48
42
|
FolderSortableTree,
|
|
49
43
|
FormatNumeral,
|
|
50
44
|
Html,
|
|
51
45
|
LabelFromValue,
|
|
52
|
-
LineChart,
|
|
53
46
|
Modal,
|
|
54
47
|
NumberField,
|
|
55
48
|
PageControls,
|
|
56
49
|
Paragraph,
|
|
57
50
|
Phantom,
|
|
58
|
-
PolarAreaChart,
|
|
59
51
|
PreformattedMarkup,
|
|
60
52
|
SelectField,
|
|
61
53
|
SortableTreeItemCollapseButton,
|
package/lib/main.jsx
CHANGED
|
@@ -4,11 +4,22 @@
|
|
|
4
4
|
import "bootstrap/dist/css/bootstrap.min.css";
|
|
5
5
|
|
|
6
6
|
import ReactiveJsonRoot from "./engine/ReactiveJsonRoot.jsx";
|
|
7
|
+
import {mergeComponentCollections} from "./engine/ComponentCollector.js";
|
|
7
8
|
import {StrictMode} from "react"
|
|
8
9
|
import {createRoot} from "react-dom/client";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* mergeComponentCollections helps in loading plugins when reactive-json is loaded in library mode.
|
|
13
|
+
*/
|
|
14
|
+
export {ReactiveJsonRoot, mergeComponentCollections};
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Standalone mode.
|
|
18
|
+
* @example
|
|
19
|
+
* <reactive-json data-method="GET" data-url="https://your-site.example/rjs-build/build.json">
|
|
20
|
+
* <data-source-request-header data-header-field="X-Header-Field-Name" data-header-value="Your value"></data-source-request-header>
|
|
21
|
+
* </reactive-json>
|
|
22
|
+
*/
|
|
12
23
|
document.querySelectorAll("reactive-json").forEach((element) => {
|
|
13
24
|
// Use this to change the fetch method.
|
|
14
25
|
const maybeMethod = element.dataset?.method;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ea-lab/reactive-json",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"require": "./dist/reactive-json.umd.cjs",
|
|
14
14
|
"import": "./dist/reactive-json.js"
|
|
15
15
|
},
|
|
16
|
-
"./lib
|
|
16
|
+
"./lib/*": "./lib/*"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"dev": "vite",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"axios": "^1.8.4",
|
|
61
|
-
"chart.js": "^4.4.8",
|
|
62
61
|
"clsx": "^2.1.1",
|
|
63
62
|
"dnd-kit-sortable-tree": "^0.1.73",
|
|
64
63
|
"html-react-parser": "^5.2.3",
|
|
@@ -67,7 +66,6 @@
|
|
|
67
66
|
"lodash": "^4.17.21",
|
|
68
67
|
"react": ">=18",
|
|
69
68
|
"react-bootstrap": "^2.10.9",
|
|
70
|
-
"react-chartjs-2": "^5.3.0",
|
|
71
69
|
"react-dom": ">=18"
|
|
72
70
|
}
|
|
73
71
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import ActionDependant from "../../../engine/Actions";
|
|
2
|
-
import GlobalDataContext from "../../../engine/GlobalDataContext";
|
|
3
|
-
import TemplateContext from "../../../engine/TemplateContext";
|
|
4
|
-
import {evaluateTemplateValue, useEvaluatedAttributes} from "../../../engine/TemplateSystem";
|
|
5
|
-
import {
|
|
6
|
-
BarElement,
|
|
7
|
-
CategoryScale,
|
|
8
|
-
Chart as ChartJS,
|
|
9
|
-
Legend,
|
|
10
|
-
LinearScale,
|
|
11
|
-
Title,
|
|
12
|
-
Tooltip,
|
|
13
|
-
} from "chart.js";
|
|
14
|
-
import {useContext} from "react";
|
|
15
|
-
import {Bar} from "react-chartjs-2";
|
|
16
|
-
|
|
17
|
-
// Register the necessary modules for Chart.js.
|
|
18
|
-
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend);
|
|
19
|
-
|
|
20
|
-
const BarChart = ({props}) => {
|
|
21
|
-
const globalDataContext = useContext(GlobalDataContext);
|
|
22
|
-
const templateContext = useContext(TemplateContext);
|
|
23
|
-
const attributes = useEvaluatedAttributes(props.attributes);
|
|
24
|
-
|
|
25
|
-
const options = props.options || {};
|
|
26
|
-
|
|
27
|
-
const chartData = evaluateTemplateValue({
|
|
28
|
-
valueToEvaluate: props.data,
|
|
29
|
-
globalDataContext,
|
|
30
|
-
templateContext,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<ActionDependant {...props}>
|
|
35
|
-
{chartData && <Bar {...attributes} data={chartData} options={options}/>}
|
|
36
|
-
</ActionDependant>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default BarChart;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import ActionDependant from "../../../engine/Actions";
|
|
2
|
-
import GlobalDataContext from "../../../engine/GlobalDataContext";
|
|
3
|
-
import TemplateContext from "../../../engine/TemplateContext";
|
|
4
|
-
import {evaluateTemplateValue, useEvaluatedAttributes} from "../../../engine/TemplateSystem";
|
|
5
|
-
import {Chart as ChartJS, ArcElement, Tooltip, Legend} from "chart.js";
|
|
6
|
-
import {useContext} from "react";
|
|
7
|
-
import {Doughnut} from "react-chartjs-2";
|
|
8
|
-
|
|
9
|
-
// Registering necessary components for Chart.js
|
|
10
|
-
ChartJS.register(ArcElement, Tooltip, Legend);
|
|
11
|
-
|
|
12
|
-
const DoughnutChart = ({props}) => {
|
|
13
|
-
const globalDataContext = useContext(GlobalDataContext);
|
|
14
|
-
const templateContext = useContext(TemplateContext);
|
|
15
|
-
const attributes = useEvaluatedAttributes(props.attributes);
|
|
16
|
-
|
|
17
|
-
const options = props.options || {};
|
|
18
|
-
|
|
19
|
-
const chartData = evaluateTemplateValue({
|
|
20
|
-
valueToEvaluate: props.data,
|
|
21
|
-
globalDataContext,
|
|
22
|
-
templateContext,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<ActionDependant {...props}>
|
|
27
|
-
{chartData && <Doughnut {...attributes} data={chartData} options={options}/>}
|
|
28
|
-
</ActionDependant>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default DoughnutChart;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import ActionDependant from "../../../engine/Actions";
|
|
2
|
-
import GlobalDataContext from "../../../engine/GlobalDataContext";
|
|
3
|
-
import TemplateContext from "../../../engine/TemplateContext";
|
|
4
|
-
import {evaluateTemplateValue, useEvaluatedAttributes} from "../../../engine/TemplateSystem";
|
|
5
|
-
import {
|
|
6
|
-
CategoryScale,
|
|
7
|
-
Chart as ChartJS, Filler,
|
|
8
|
-
Legend,
|
|
9
|
-
LinearScale,
|
|
10
|
-
LineElement, PointElement,
|
|
11
|
-
Title,
|
|
12
|
-
Tooltip,
|
|
13
|
-
} from "chart.js";
|
|
14
|
-
import {useContext} from "react";
|
|
15
|
-
import {Line} from "react-chartjs-2";
|
|
16
|
-
|
|
17
|
-
// Register the necessary modules for Chart.js.
|
|
18
|
-
ChartJS.register(CategoryScale, LinearScale, LineElement, PointElement, Title, Tooltip, Legend, Filler);
|
|
19
|
-
|
|
20
|
-
const LineChart = ({props}) => {
|
|
21
|
-
const globalDataContext = useContext(GlobalDataContext);
|
|
22
|
-
const templateContext = useContext(TemplateContext);
|
|
23
|
-
const attributes = useEvaluatedAttributes(props.attributes);
|
|
24
|
-
|
|
25
|
-
const options = props.options || {};
|
|
26
|
-
|
|
27
|
-
const chartData = evaluateTemplateValue({
|
|
28
|
-
valueToEvaluate: props.data,
|
|
29
|
-
globalDataContext,
|
|
30
|
-
templateContext,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<ActionDependant {...props}>
|
|
35
|
-
{chartData && <Line {...attributes} data={chartData} options={options}/>}
|
|
36
|
-
</ActionDependant>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default LineChart;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import ActionDependant from "../../../engine/Actions";
|
|
2
|
-
import GlobalDataContext from "../../../engine/GlobalDataContext";
|
|
3
|
-
import TemplateContext from "../../../engine/TemplateContext";
|
|
4
|
-
import {evaluateTemplateValue, useEvaluatedAttributes} from "../../../engine/TemplateSystem";
|
|
5
|
-
import {Chart, RadialLinearScale, ArcElement, Tooltip, Legend} from 'chart.js';
|
|
6
|
-
import {useContext} from "react";
|
|
7
|
-
import {PolarArea} from 'react-chartjs-2';
|
|
8
|
-
|
|
9
|
-
// Registering the necessary components for Chart.js.
|
|
10
|
-
Chart.register(RadialLinearScale, ArcElement, Tooltip, Legend);
|
|
11
|
-
|
|
12
|
-
const PolarAreaChart = ({props}) => {
|
|
13
|
-
const globalDataContext = useContext(GlobalDataContext);
|
|
14
|
-
const templateContext = useContext(TemplateContext);
|
|
15
|
-
const attributes = useEvaluatedAttributes(props.attributes);
|
|
16
|
-
|
|
17
|
-
const options = props.options || {};
|
|
18
|
-
|
|
19
|
-
const chartData = evaluateTemplateValue({
|
|
20
|
-
valueToEvaluate: props.data,
|
|
21
|
-
globalDataContext,
|
|
22
|
-
templateContext,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<ActionDependant {...props}>
|
|
27
|
-
{chartData && <PolarArea {...attributes} data={chartData} options={options}/>}
|
|
28
|
-
</ActionDependant>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default PolarAreaChart;
|