@ea-lab/reactive-json 1.4.0 → 2.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.
- package/dist/component/action/CustomEventListener.js +3 -2
- package/dist/component/action/ReactOnEvent.js +6 -5
- package/dist/component/attributeTransformer/setAttributeValue.js +20 -19
- package/dist/component/attributeTransformer/toggleAttributeValue.js +15 -14
- package/dist/component/attributeTransformer/unsetAttributeValue.js +8 -7
- package/dist/component/element/debug/VariablesDebug/VariablesDebug.js +74 -60
- package/dist/component/element/html/LabelFromValue.js +30 -18
- package/dist/component/element/index.js +28 -26
- package/dist/component/element/special/DataFilter.js +49 -40
- package/dist/component/element/special/DataSync.js +94 -0
- package/dist/component/element/special/index.js +15 -13
- package/dist/component/index.js +57 -55
- package/dist/component/reaction/fetchData.js +1 -1
- package/dist/component/reaction/index.js +1 -1
- package/dist/component/reaction/submitData.js +1 -1
- package/dist/component/reaction/utility/httpRequestCommon.js +118 -5
- package/dist/component/reaction/utility/index.js +1 -1
- package/dist/engine/DataStore.js +120 -0
- package/dist/engine/ReactiveJsonRoot.js +218 -277
- package/dist/engine/StoreContext.js +17 -0
- package/dist/engine/View.js +94 -58
- package/dist/engine/hook/useReactiveData.js +9 -0
- package/dist/engine/index.js +53 -45
- package/dist/engine/utility/formElementsCommon.js +36 -23
- package/dist/{httpRequestCommon-C7MsJIKA.js → index-BUPRVmV-.js} +616 -733
- package/dist/index-DJuOXIM5.js +25 -0
- package/dist/main.js +156 -146
- package/package.json +1 -1
- package/dist/index-Ya6_R5yr.js +0 -23
package/dist/engine/View.js
CHANGED
|
@@ -1,76 +1,112 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { GlobalDataContext as
|
|
4
|
-
import { TemplateContext as
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useContext as x, useReducer as H, useSyncExternalStore as L, useMemo as O, useCallback as S } from "react";
|
|
3
|
+
import { GlobalDataContext as V } from "./GlobalDataContext.js";
|
|
4
|
+
import { TemplateContext as W } from "./TemplateContext.js";
|
|
5
|
+
import { useStore as N } from "./StoreContext.js";
|
|
6
|
+
import G, { dataLocationToPath as w } from "./TemplateSystem.js";
|
|
7
|
+
const y = (t) => !t || t === "data" ? "" : t.startsWith("data.") ? t.substring(5) : t, P = ({ props: t, datafield: g, path: o }) => {
|
|
8
|
+
const r = N(), i = x(V), s = x(W), [, J] = H((e) => e + 1, 0), v = y(o), D = (s == null ? void 0 : s.templatePath) || "data", b = (i == null ? void 0 : i.templatePath) || "data", C = L(
|
|
9
|
+
(e) => r.subscribe(v, e),
|
|
10
|
+
() => r.get(v)
|
|
11
|
+
), u = O(() => {
|
|
12
|
+
if (!t || typeof t != "object") return [];
|
|
13
|
+
const e = [], n = (a) => {
|
|
14
|
+
if (a)
|
|
15
|
+
if (typeof a == "string") {
|
|
16
|
+
if (a.startsWith("~.") || a.startsWith("~~.") || a.startsWith("~>") || a.startsWith("~~>"))
|
|
17
|
+
try {
|
|
18
|
+
const c = w({
|
|
19
|
+
dataLocation: a,
|
|
20
|
+
currentPath: o,
|
|
21
|
+
globalDataContext: { templatePath: b },
|
|
22
|
+
templateContext: { templatePath: D }
|
|
23
|
+
});
|
|
24
|
+
c && c !== o && e.push(y(c));
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
} else typeof a == "object" && Object.values(a).forEach((c) => n(c));
|
|
28
|
+
};
|
|
29
|
+
return n(t), [...new Set(e)];
|
|
30
|
+
}, [t, o, D, b]), E = S((e) => {
|
|
31
|
+
const n = u.map(
|
|
32
|
+
(a) => r.subscribe(a, e)
|
|
33
|
+
);
|
|
34
|
+
return () => n.forEach((a) => a());
|
|
35
|
+
}, [u, r]), R = S(() => {
|
|
36
|
+
const e = u.map((n) => r.get(n));
|
|
37
|
+
return JSON.stringify(e);
|
|
38
|
+
}, [u, r]);
|
|
39
|
+
L(E, R);
|
|
40
|
+
const m = i.plugins ?? {}, f = (m == null ? void 0 : m.element) ?? {};
|
|
41
|
+
if (!f)
|
|
9
42
|
return null;
|
|
10
|
-
const { element:
|
|
11
|
-
if (
|
|
12
|
-
let e =
|
|
13
|
-
const
|
|
14
|
-
return e === void 0 && (e =
|
|
43
|
+
const { element: k } = i, d = C === void 0 ? "" : C;
|
|
44
|
+
if (t != null && t.type) {
|
|
45
|
+
let e = f[t.type] ?? void 0;
|
|
46
|
+
const n = f.Html;
|
|
47
|
+
return e === void 0 && (e = n), e ? (n === e && (t.tag || (t.tag = t.type)), /* @__PURE__ */ l(e, { path: o, props: t, currentData: d, datafield: g })) : (console.warn(`No component found for type "${t.type}" and no Html fallback available.`), null);
|
|
15
48
|
}
|
|
16
49
|
if (t != null && t.load) {
|
|
17
50
|
let e;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
typeof t.load == "function" ? e = t.load(m) : e = T[t.load];
|
|
35
|
-
const { load: h, customDataLocation: g, ...b } = t;
|
|
36
|
-
return e = { ...e, ...b }, t.keepTemplateContext ? /* @__PURE__ */ l(
|
|
37
|
-
u,
|
|
38
|
-
{
|
|
39
|
-
currentData: m,
|
|
40
|
-
datafield: c,
|
|
41
|
-
path: r,
|
|
42
|
-
props: e
|
|
51
|
+
const n = (t == null ? void 0 : t.customDataLocation) ?? void 0;
|
|
52
|
+
let a;
|
|
53
|
+
if (n)
|
|
54
|
+
try {
|
|
55
|
+
a = w({
|
|
56
|
+
dataLocation: n,
|
|
57
|
+
currentPath: o,
|
|
58
|
+
globalDataContext: { templatePath: "data", get templateData() {
|
|
59
|
+
return r.get("");
|
|
60
|
+
} },
|
|
61
|
+
templateContext: { templatePath: o, get templateData() {
|
|
62
|
+
return r.get("");
|
|
63
|
+
} }
|
|
64
|
+
});
|
|
65
|
+
} catch (h) {
|
|
66
|
+
console.error("View: Error evaluating customDataLocation", h), a = o;
|
|
43
67
|
}
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
else
|
|
69
|
+
a = o;
|
|
70
|
+
typeof t.load == "function" ? e = t.load(d) : e = k[t.load];
|
|
71
|
+
const { load: c, customDataLocation: M, ...z } = t;
|
|
72
|
+
e = { ...e, ...z };
|
|
73
|
+
const T = /* @__PURE__ */ l(
|
|
74
|
+
P,
|
|
46
75
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
path: r,
|
|
76
|
+
datafield: g,
|
|
77
|
+
path: a,
|
|
50
78
|
props: e
|
|
51
79
|
}
|
|
52
|
-
)
|
|
80
|
+
);
|
|
81
|
+
if (t.keepTemplateContext)
|
|
82
|
+
return T;
|
|
83
|
+
const A = {
|
|
84
|
+
templatePath: a,
|
|
85
|
+
get templateData() {
|
|
86
|
+
const h = y(a);
|
|
87
|
+
return r.get(h);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return /* @__PURE__ */ l(W.Provider, { value: A, children: T });
|
|
53
91
|
}
|
|
54
|
-
return Array.isArray(t) ? t.map((e,
|
|
55
|
-
|
|
92
|
+
return Array.isArray(t) ? t.map((e, n) => /* @__PURE__ */ l(
|
|
93
|
+
P,
|
|
56
94
|
{
|
|
57
|
-
|
|
58
|
-
datafield:
|
|
59
|
-
path: n + "." + a,
|
|
95
|
+
path: o + "." + n,
|
|
96
|
+
datafield: n,
|
|
60
97
|
props: e ?? void 0
|
|
61
98
|
},
|
|
62
|
-
|
|
63
|
-
)) : typeof t == "object" ? Object.entries(t).map(([e,
|
|
64
|
-
|
|
99
|
+
o + "." + n
|
|
100
|
+
)) : typeof t == "object" ? Object.entries(t).map(([e, n]) => /* @__PURE__ */ l(
|
|
101
|
+
P,
|
|
65
102
|
{
|
|
66
|
-
|
|
103
|
+
path: o + "." + e,
|
|
67
104
|
datafield: e ?? void 0,
|
|
68
|
-
|
|
69
|
-
props: a
|
|
105
|
+
props: n
|
|
70
106
|
},
|
|
71
|
-
|
|
72
|
-
)) : /* @__PURE__ */ l(
|
|
73
|
-
}
|
|
107
|
+
o + "." + e
|
|
108
|
+
)) : /* @__PURE__ */ l(G, { valueToEvaluate: d || (t ?? null) });
|
|
109
|
+
};
|
|
74
110
|
export {
|
|
75
|
-
|
|
111
|
+
P as View
|
|
76
112
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useStore as u } from "../StoreContext.js";
|
|
2
|
+
import { useCallback as s, useSyncExternalStore as i } from "react";
|
|
3
|
+
const c = (t) => !t || t === "data" ? "" : t.startsWith("data.") ? t.substring(5) : t, f = (t) => {
|
|
4
|
+
const r = u(), e = c(t), n = s((a) => r.subscribe(e, a), [e, r]), o = s(() => r.get(e), [e, r]);
|
|
5
|
+
return i(n, o);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
f as useReactiveData
|
|
9
|
+
};
|
package/dist/engine/index.js
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
1
|
import { ActionDependant as o, isValid as r } from "./Actions.js";
|
|
2
2
|
import { mergeComponentCollections as p } from "./ComponentCollector.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
3
|
+
import { DataStore as n } from "./DataStore.js";
|
|
4
|
+
import { EventDispatcherContext as l } from "./EventDispatcherContext.js";
|
|
5
|
+
import { EventDispatcherProvider as f, addEventListener as s, removeEventListener as u } from "./EventDispatcherProvider.js";
|
|
6
|
+
import { GlobalDataContext as c } from "./GlobalDataContext.js";
|
|
7
|
+
import { GlobalDataContextProvider as D } from "./GlobalDataContextProvider.js";
|
|
8
|
+
import { PaginationContext as b } from "./PaginationContext.js";
|
|
9
|
+
import { ReactiveJsonRoot as R } from "./ReactiveJsonRoot.js";
|
|
10
|
+
import { StoreContext as g, StoreProvider as A, useStore as E } from "./StoreContext.js";
|
|
11
|
+
import { TemplateContext as V } from "./TemplateContext.js";
|
|
12
|
+
import { dataLocationToPath as L, evaluateAttributes as y, evaluateTemplateValue as z, evaluateTemplateValueCollection as F, isTemplateValue as J, useEvaluatedAttributes as B } from "./TemplateSystem.js";
|
|
13
|
+
import { useReactiveData as j } from "./hook/useReactiveData.js";
|
|
14
|
+
import { alterData as M } from "./utility/alterData.js";
|
|
15
|
+
import { analyzeDataOverrideReferences as O } from "./utility/analyzeDataOverrideReferences.js";
|
|
16
|
+
import { applyDataMapping as q } from "./utility/dataMappingSystem.js";
|
|
17
|
+
import { replaceEventPlaceholders as I } from "./utility/eventPlaceholderSystem.js";
|
|
18
|
+
import { formatString as Q, maybeFormatString as U } from "./utility/formatString.js";
|
|
19
|
+
import { propsDataLocationToPathAndValue as X } from "./utility/formElementsCommon.js";
|
|
20
|
+
import { parseRjBuild as Z } from "./utility/parseRjBuild.js";
|
|
21
|
+
import { normalizeAttributeNameForReactJsx as $, normalizeAttributesForReactJsx as ee } from "./utility/reactJsxHelpers.js";
|
|
22
|
+
import { stringToBoolean as oe } from "./utility/stringToBoolean.js";
|
|
23
|
+
import { View as ae } from "./View.js";
|
|
21
24
|
export {
|
|
22
25
|
o as ActionDependant,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
c as
|
|
27
|
-
D as
|
|
28
|
-
b as
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
n as DataStore,
|
|
27
|
+
l as EventDispatcherContext,
|
|
28
|
+
f as EventDispatcherProvider,
|
|
29
|
+
c as GlobalDataContext,
|
|
30
|
+
D as GlobalDataContextProvider,
|
|
31
|
+
b as PaginationContext,
|
|
32
|
+
R as ReactiveJsonRoot,
|
|
33
|
+
g as StoreContext,
|
|
34
|
+
A as StoreProvider,
|
|
35
|
+
V as TemplateContext,
|
|
36
|
+
ae as View,
|
|
37
|
+
s as addEventListener,
|
|
38
|
+
M as alterData,
|
|
39
|
+
O as analyzeDataOverrideReferences,
|
|
40
|
+
q as applyDataMapping,
|
|
41
|
+
L as dataLocationToPath,
|
|
42
|
+
y as evaluateAttributes,
|
|
43
|
+
z as evaluateTemplateValue,
|
|
44
|
+
F as evaluateTemplateValueCollection,
|
|
45
|
+
Q as formatString,
|
|
46
|
+
J as isTemplateValue,
|
|
41
47
|
r as isValid,
|
|
42
|
-
|
|
48
|
+
U as maybeFormatString,
|
|
43
49
|
p as mergeComponentCollections,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
$ as normalizeAttributeNameForReactJsx,
|
|
51
|
+
ee as normalizeAttributesForReactJsx,
|
|
52
|
+
Z as parseRjBuild,
|
|
53
|
+
X as propsDataLocationToPathAndValue,
|
|
54
|
+
u as removeEventListener,
|
|
55
|
+
I as replaceEventPlaceholders,
|
|
56
|
+
oe as stringToBoolean,
|
|
57
|
+
B as useEvaluatedAttributes,
|
|
58
|
+
j as useReactiveData,
|
|
59
|
+
E as useStore
|
|
52
60
|
};
|
|
@@ -1,34 +1,47 @@
|
|
|
1
|
-
import { evaluateTemplateValue as P, dataLocationToPath as
|
|
2
|
-
const
|
|
1
|
+
import { evaluateTemplateValue as P, dataLocationToPath as s } from "../TemplateSystem.js";
|
|
2
|
+
const i = ({
|
|
3
3
|
currentPath: v,
|
|
4
|
-
datafield:
|
|
5
|
-
dataLocation:
|
|
6
|
-
defaultValue:
|
|
7
|
-
globalDataContext:
|
|
4
|
+
datafield: r,
|
|
5
|
+
dataLocation: h,
|
|
6
|
+
defaultValue: o,
|
|
7
|
+
globalDataContext: m,
|
|
8
8
|
templateContext: a
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
10
|
+
const D = {
|
|
11
11
|
// This is the data that contains the current checked state.
|
|
12
12
|
formData: void 0,
|
|
13
13
|
// This is the path that leads to the data.
|
|
14
14
|
formDataPath: void 0
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
if (h && typeof h == "string")
|
|
17
|
+
D.formData = P({
|
|
18
|
+
globalDataContext: m,
|
|
19
|
+
templateContext: a,
|
|
20
|
+
valueToEvaluate: h
|
|
21
|
+
}) ?? o, D.formDataPath = s({
|
|
22
|
+
dataLocation: h,
|
|
23
|
+
currentPath: v,
|
|
24
|
+
globalDataContext: m,
|
|
25
|
+
templateContext: a
|
|
26
|
+
});
|
|
27
|
+
else {
|
|
28
|
+
if ((a.templateData[r] ?? void 0) === void 0)
|
|
29
|
+
if (typeof a.templateData == "object" && a.templateData !== null)
|
|
30
|
+
a.templateData[r] = o;
|
|
31
|
+
else
|
|
32
|
+
try {
|
|
33
|
+
a.templateData = {}, a.templateData[r] = o;
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
D.formData = a.templateData[r], D.formDataPath = s({
|
|
37
|
+
dataLocation: "~." + r,
|
|
38
|
+
currentPath: a.templatePath,
|
|
39
|
+
globalDataContext: m,
|
|
40
|
+
templateContext: a
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return D;
|
|
31
44
|
};
|
|
32
45
|
export {
|
|
33
|
-
|
|
46
|
+
i as propsDataLocationToPathAndValue
|
|
34
47
|
};
|