@ea-lab/reactive-json 1.0.0-alpha.1 → 1.0.0-alpha.3
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/assets/VariablesDebug.css +4 -1
- package/dist/component/element/debug/VariablesDebug/VariablesDebug.js +15 -16
- package/dist/component/element/html/FolderSortableTree.js +7 -7
- package/dist/component/element/html/Html.js +57 -9
- package/dist/component/element/html/LabelFromValue.js +4 -4
- package/dist/component/element/html/index.js +1 -1
- package/dist/component/element/index.js +37 -31
- package/dist/component/element/special/DataFilter.js +1 -1
- package/dist/component/element/special/DelayedActions.js +3 -3
- package/dist/component/element/special/Phantom.js +1 -1
- package/dist/component/element/special/ReactiveJsonBasicComponentWrapper.js +11 -24
- package/dist/component/element/special/ReactiveJsonSubroot.js +53 -12
- package/dist/component/element/special/Switch.js +16 -16
- package/dist/component/element/special/index.js +6 -6
- package/dist/component/index.js +69 -68
- package/dist/coreComponentsPlugin.js +13 -6
- package/dist/engine/ReactiveJsonRoot.js +373 -18
- package/dist/engine/View.js +74 -7
- package/dist/engine/index.js +5 -5
- package/dist/{index-B3RKTGQ2.js → index-BNvY8PkY.js} +1 -1
- package/dist/index-Ya6_R5yr.js +23 -0
- package/dist/main.js +90 -87
- package/package.json +1 -1
- package/dist/View-D8TN1L2h.js +0 -126
- package/dist/assets/reset.css +0 -4
- package/dist/index-BYLJtf9L.js +0 -462
package/dist/component/index.js
CHANGED
|
@@ -1,86 +1,87 @@
|
|
|
1
1
|
import { HashChangeListener as r } from "./action/HashChangeListener.js";
|
|
2
|
-
import { Hide as
|
|
3
|
-
import { MessageListener as
|
|
2
|
+
import { Hide as m } from "./action/Hide.js";
|
|
3
|
+
import { MessageListener as a } from "./action/MessageListener.js";
|
|
4
4
|
import { ReactOnEvent as x } from "./action/ReactOnEvent.js";
|
|
5
|
-
import { Redirect as
|
|
5
|
+
import { Redirect as s } from "./action/Redirect.js";
|
|
6
6
|
import { SetAttributeValue as l } from "./action/SetAttributeValue.js";
|
|
7
7
|
import { ToggleAttributeValue as c } from "./action/ToggleAttributeValue.js";
|
|
8
8
|
import { UnsetAttribute as b } from "./action/UnsetAttribute.js";
|
|
9
9
|
import { UnsetAttributeValue as d } from "./action/UnsetAttributeValue.js";
|
|
10
10
|
import { VisuallyHide as R } from "./action/VisuallyHide.js";
|
|
11
|
-
import { coreDataMappingComponents as
|
|
12
|
-
import { coreDataProcessorComponents as
|
|
13
|
-
import {
|
|
14
|
-
import { usePagination as
|
|
15
|
-
import { coreReactionComponents as
|
|
16
|
-
import { simpleMapping as
|
|
17
|
-
import { VariablesDebug as
|
|
18
|
-
import { FolderSortableTree as
|
|
19
|
-
import { FormatNumeral as
|
|
20
|
-
import {
|
|
21
|
-
import { LabelFromValue as
|
|
22
|
-
import { PreformattedMarkup as
|
|
23
|
-
import { SortableTreeItemCollapseButton as
|
|
24
|
-
import { Count as
|
|
25
|
-
import { DataFilter as
|
|
26
|
-
import { DelayedActions as
|
|
27
|
-
import { PageControls as
|
|
28
|
-
import { Phantom as
|
|
11
|
+
import { coreDataMappingComponents as V } from "./dataMapping/index.js";
|
|
12
|
+
import { coreDataProcessorComponents as A } from "./dataProcessor/index.js";
|
|
13
|
+
import { coreElementComponents as H } from "./element/index.js";
|
|
14
|
+
import { usePagination as P } from "./hook/usePagination.js";
|
|
15
|
+
import { coreReactionComponents as E } from "./reaction/index.js";
|
|
16
|
+
import { simpleMapping as L } from "./dataMapping/simpleMapping.js";
|
|
17
|
+
import { VariablesDebug as y } from "./element/debug/VariablesDebug/VariablesDebug.js";
|
|
18
|
+
import { FolderSortableTree as J } from "./element/html/FolderSortableTree.js";
|
|
19
|
+
import { FormatNumeral as U } from "./element/html/FormatNumeral.js";
|
|
20
|
+
import { Html as q } from "./element/html/Html.js";
|
|
21
|
+
import { LabelFromValue as O } from "./element/html/LabelFromValue.js";
|
|
22
|
+
import { PreformattedMarkup as j } from "./element/html/PreformattedMarkup.js";
|
|
23
|
+
import { SortableTreeItemCollapseButton as G } from "./element/html/SortableTreeItemCollapseButton.js";
|
|
24
|
+
import { Count as Q } from "./element/special/Count.js";
|
|
25
|
+
import { DataFilter as Y } from "./element/special/DataFilter.js";
|
|
26
|
+
import { DelayedActions as _, getReactionFunctionsToExecute as $ } from "./element/special/DelayedActions.js";
|
|
27
|
+
import { PageControls as oe } from "./element/special/PageControls.js";
|
|
28
|
+
import { Phantom as te } from "./element/special/Phantom.js";
|
|
29
29
|
import { ReactiveJsonBasicComponentWrapper as pe } from "./element/special/ReactiveJsonBasicComponentWrapper.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
30
|
+
import { ReactiveJsonSubroot as fe } from "./element/special/ReactiveJsonSubroot.js";
|
|
31
|
+
import { Switch as ne } from "./element/special/Switch.js";
|
|
32
|
+
import { addData as ie } from "./reaction/addData.js";
|
|
33
|
+
import { fetchData as ue } from "./reaction/fetchData.js";
|
|
34
|
+
import { e as ge } from "../httpRequestCommon-DUo2Oxgl.js";
|
|
35
|
+
import { moveData as De } from "./reaction/moveData.js";
|
|
36
|
+
import { postMessage as Ce } from "./reaction/postMessage.js";
|
|
37
|
+
import { redirectNow as ve } from "./reaction/redirectNow.js";
|
|
38
|
+
import { removeData as he } from "./reaction/removeData.js";
|
|
39
|
+
import { setClipboardData as Fe } from "./reaction/setClipboardData.js";
|
|
40
|
+
import { setData as Me } from "./reaction/setData.js";
|
|
41
|
+
import { submitData as Se } from "./reaction/submitData.js";
|
|
42
|
+
import { triggerEvent as Te } from "./reaction/triggerEvent.js";
|
|
42
43
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
Q as Count,
|
|
45
|
+
Y as DataFilter,
|
|
46
|
+
_ as DelayedActions,
|
|
47
|
+
J as FolderSortableTree,
|
|
48
|
+
U as FormatNumeral,
|
|
48
49
|
r as HashChangeListener,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
m as Hide,
|
|
51
|
+
q as Html,
|
|
52
|
+
O as LabelFromValue,
|
|
53
|
+
a as MessageListener,
|
|
54
|
+
oe as PageControls,
|
|
55
|
+
te as Phantom,
|
|
56
|
+
j as PreformattedMarkup,
|
|
56
57
|
x as ReactOnEvent,
|
|
57
58
|
pe as ReactiveJsonBasicComponentWrapper,
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
fe as ReactiveJsonSubroot,
|
|
60
|
+
s as Redirect,
|
|
60
61
|
l as SetAttributeValue,
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
G as SortableTreeItemCollapseButton,
|
|
63
|
+
ne as Switch,
|
|
63
64
|
c as ToggleAttributeValue,
|
|
64
65
|
b as UnsetAttribute,
|
|
65
66
|
d as UnsetAttributeValue,
|
|
66
|
-
|
|
67
|
+
y as VariablesDebug,
|
|
67
68
|
R as VisuallyHide,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
ie as addData,
|
|
70
|
+
V as coreDataMappingComponents,
|
|
71
|
+
A as coreDataProcessorComponents,
|
|
72
|
+
H as coreElementComponents,
|
|
73
|
+
E as coreReactionComponents,
|
|
74
|
+
ge as executeHttpRequest,
|
|
75
|
+
ue as fetchData,
|
|
76
|
+
$ as getReactionFunctionsToExecute,
|
|
77
|
+
De as moveData,
|
|
78
|
+
Ce as postMessage,
|
|
79
|
+
ve as redirectNow,
|
|
80
|
+
he as removeData,
|
|
81
|
+
Fe as setClipboardData,
|
|
82
|
+
Me as setData,
|
|
83
|
+
L as simpleMapping,
|
|
84
|
+
Se as submitData,
|
|
85
|
+
Te as triggerEvent,
|
|
86
|
+
P as usePagination
|
|
86
87
|
};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import "./index-BA09SSaJ.js";
|
|
2
|
-
import "./component/dataMapping/index.js";
|
|
3
|
-
import "./component/dataProcessor/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import "./component/reaction/index.js";
|
|
1
|
+
import { c as o } from "./index-BA09SSaJ.js";
|
|
2
|
+
import { coreDataMappingComponents as t } from "./component/dataMapping/index.js";
|
|
3
|
+
import { coreDataProcessorComponents as e } from "./component/dataProcessor/index.js";
|
|
4
|
+
import { coreElementComponents as n } from "./component/element/index.js";
|
|
5
|
+
import { coreReactionComponents as r } from "./component/reaction/index.js";
|
|
6
|
+
const s = {
|
|
7
|
+
action: o,
|
|
8
|
+
dataMapping: t,
|
|
9
|
+
dataProcessor: e,
|
|
10
|
+
element: n,
|
|
11
|
+
reaction: r
|
|
12
|
+
};
|
|
6
13
|
export {
|
|
7
|
-
|
|
14
|
+
s as coreComponentsPlugin
|
|
8
15
|
};
|
|
@@ -1,20 +1,375 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import "../httpRequestCommon-DUo2Oxgl.js";
|
|
3
|
-
import "../lodash-CYNxjS-I.js";
|
|
4
|
-
import "react";
|
|
5
|
-
import "../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
|
|
6
|
-
import {
|
|
7
|
-
import "./ComponentCollector.js";
|
|
8
|
-
import "./EventDispatcherProvider.js";
|
|
9
|
-
import "./GlobalDataContextProvider.js";
|
|
10
|
-
import "./ParsingDebugDisplay/ParsingDebugDisplay.js";
|
|
11
|
-
import "./TemplateContext.js";
|
|
12
|
-
import "./TemplateSystem.js";
|
|
13
|
-
import "./utility/alterData.js";
|
|
14
|
-
import "./utility/dataMappingSystem.js";
|
|
15
|
-
import "./utility/parseRjBuild.js";
|
|
16
|
-
import "./utility/stringToBoolean.js";
|
|
17
|
-
import "
|
|
1
|
+
import { jsx as C, jsxs as L, Fragment as pt } from "react/jsx-runtime";
|
|
2
|
+
import { a as _ } from "../httpRequestCommon-DUo2Oxgl.js";
|
|
3
|
+
import { l as ut } from "../lodash-CYNxjS-I.js";
|
|
4
|
+
import { useReducer as dt, useState as v, useRef as ft, useEffect as q } from "react";
|
|
5
|
+
import { r as mt } from "../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
|
|
6
|
+
import { coreComponentsPlugin as tt } from "../coreComponentsPlugin.js";
|
|
7
|
+
import { mergeComponentCollections as ht } from "./ComponentCollector.js";
|
|
8
|
+
import { EventDispatcherProvider as gt } from "./EventDispatcherProvider.js";
|
|
9
|
+
import { GlobalDataContextProvider as yt } from "./GlobalDataContextProvider.js";
|
|
10
|
+
import Dt from "./ParsingDebugDisplay/ParsingDebugDisplay.js";
|
|
11
|
+
import { TemplateContext as Pt } from "./TemplateContext.js";
|
|
12
|
+
import { dataLocationToPath as Ct } from "./TemplateSystem.js";
|
|
13
|
+
import { alterData as bt } from "./utility/alterData.js";
|
|
14
|
+
import { applyDataMapping as Et } from "./utility/dataMappingSystem.js";
|
|
15
|
+
import { parseRjBuild as vt } from "./utility/parseRjBuild.js";
|
|
16
|
+
import { stringToBoolean as wt } from "./utility/stringToBoolean.js";
|
|
17
|
+
import { View as St } from "./View.js";
|
|
18
|
+
const xt = ({
|
|
19
|
+
dataOverride: w,
|
|
20
|
+
dataFetchMethod: M,
|
|
21
|
+
dataUrl: z,
|
|
22
|
+
debugMode: et,
|
|
23
|
+
DebugModeContentWrapper: A,
|
|
24
|
+
DebugModeDataWrapper: K,
|
|
25
|
+
DebugModeRootWrapper: rt,
|
|
26
|
+
headersForData: X,
|
|
27
|
+
headersForRjBuild: c,
|
|
28
|
+
maybeRawAppData: $,
|
|
29
|
+
maybeRawAppRjBuild: d,
|
|
30
|
+
plugins: H,
|
|
31
|
+
rjBuildFetchMethod: b,
|
|
32
|
+
rjBuildUrl: f,
|
|
33
|
+
upstreamUpdateCallbacks: N
|
|
34
|
+
}) => {
|
|
35
|
+
const h = [];
|
|
36
|
+
M && (h.push({
|
|
37
|
+
deprecatedProperty: "dataFetchMethod",
|
|
38
|
+
newProperty: "rjBuildFetchMethod"
|
|
39
|
+
}), b = M), z && (h.push({
|
|
40
|
+
deprecatedProperty: "dataUrl",
|
|
41
|
+
newProperty: "rjBuildUrl"
|
|
42
|
+
}), f = z), X && (h.push({
|
|
43
|
+
deprecatedProperty: "headersForData",
|
|
44
|
+
newProperty: "headersForRjBuild"
|
|
45
|
+
}), c = X), $ && (h.push({
|
|
46
|
+
deprecatedProperty: "maybeRawAppData",
|
|
47
|
+
newProperty: "maybeRawAppRjBuild"
|
|
48
|
+
}), d = $), h.length > 0 && console.warn(
|
|
49
|
+
"A ReactiveJsonRoot component got the following deprecated properties that must be replaced: " + h.map((t) => t.deprecatedProperty + " -> " + t.newProperty).join(", ")
|
|
50
|
+
);
|
|
51
|
+
const [S, g] = dt(
|
|
52
|
+
(t, a) => {
|
|
53
|
+
switch (a.type) {
|
|
54
|
+
case "setData":
|
|
55
|
+
return { updateId: 0, realCurrentData: a.data };
|
|
56
|
+
case "updateData":
|
|
57
|
+
return it(t, a.path, a.value, a.updateMode);
|
|
58
|
+
default:
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{ updateId: 0, realCurrentData: {} }
|
|
63
|
+
), [at, ot] = v({}), [nt, Q] = v({}), [st, Y] = v([]), [x, T] = v(() => {
|
|
64
|
+
if (d)
|
|
65
|
+
return typeof d == "string" ? d : JSON.stringify(d);
|
|
66
|
+
}), [V, Z] = v(null), n = ft(null);
|
|
67
|
+
q(() => () => {
|
|
68
|
+
typeof document < "u" && n.current && n.current.parentNode && (n.current.parentNode.removeChild(n.current), n.current = null);
|
|
69
|
+
}, []);
|
|
70
|
+
const I = H ? ht([tt, H]) : tt;
|
|
71
|
+
q(() => {
|
|
72
|
+
f && (typeof b == "string" && b.toLowerCase() === "post" ? _.post(f, {
|
|
73
|
+
headers: c
|
|
74
|
+
}).then((t) => {
|
|
75
|
+
T(t.data);
|
|
76
|
+
}) : _.get(f, {
|
|
77
|
+
headers: c
|
|
78
|
+
}).then((t) => {
|
|
79
|
+
T(t.data);
|
|
80
|
+
}));
|
|
81
|
+
}, [f, c]), q(() => {
|
|
82
|
+
if (!x)
|
|
83
|
+
return;
|
|
84
|
+
const t = vt(x);
|
|
85
|
+
if (!t.success) {
|
|
86
|
+
if (console.group(
|
|
87
|
+
`Tried to load the app's RjBuild but the ${t.format} content could not be parsed.`
|
|
88
|
+
), console.error(t.error.message), console.debug("Context:", {
|
|
89
|
+
rjBuildUrl: f,
|
|
90
|
+
rjBuildFetchMethod: b,
|
|
91
|
+
headersForRjBuild: c,
|
|
92
|
+
maybeRawAppRjBuild: d,
|
|
93
|
+
dataOverride: w
|
|
94
|
+
}), console.debug("Error details:", t.error), console.groupEnd(), typeof document < "u") {
|
|
95
|
+
let e = document.getElementById("rj-parsing-error-root");
|
|
96
|
+
if (e || (e = document.createElement("div"), e.id = "rj-parsing-error-root", document.body.appendChild(e)), !n.current) {
|
|
97
|
+
const p = document.createElement("div");
|
|
98
|
+
e.appendChild(p), n.current = p;
|
|
99
|
+
}
|
|
100
|
+
Z(
|
|
101
|
+
mt.createPortal(
|
|
102
|
+
/* @__PURE__ */ C(
|
|
103
|
+
Dt,
|
|
104
|
+
{
|
|
105
|
+
processedRjBuild: t,
|
|
106
|
+
errorContext: {
|
|
107
|
+
rjBuildUrl: f,
|
|
108
|
+
rjBuildFetchMethod: b,
|
|
109
|
+
headersForRjBuild: c,
|
|
110
|
+
maybeRawAppRjBuild: d
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
n.current,
|
|
115
|
+
() => {
|
|
116
|
+
n.current && (n.current.parentNode.removeChild(n.current), n.current = null);
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
V && (Z(null), typeof document < "u" && n.current && n.current.parentNode && (n.current.parentNode.removeChild(n.current), n.current = null));
|
|
124
|
+
const a = t.data;
|
|
125
|
+
ot(a.templates ?? a.listForms), !a.templates && a.listForms && console.log(
|
|
126
|
+
"'listForms' needs to be renamed to 'templates'. The support for 'listForms' will be removed in the next releases of reactive-json."
|
|
127
|
+
);
|
|
128
|
+
let i = w === void 0 ? a.data : w;
|
|
129
|
+
const s = a.additionalDataSource;
|
|
130
|
+
if (!Array.isArray(s) || s.length === 0) {
|
|
131
|
+
g({ type: "setData", data: i }), Q(a.renderView), Y(Object.keys(a.renderView));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const m = {
|
|
135
|
+
headersForRjBuild: c,
|
|
136
|
+
templateData: i,
|
|
137
|
+
templatePath: "data",
|
|
138
|
+
setData: R,
|
|
139
|
+
updateData: W
|
|
140
|
+
}, r = {
|
|
141
|
+
templateData: i,
|
|
142
|
+
templatePath: "data"
|
|
143
|
+
}, l = s.filter((e) => e.blocking === !0), E = s.filter((e) => e.blocking !== !0), o = async (e, p) => {
|
|
144
|
+
var y;
|
|
145
|
+
try {
|
|
146
|
+
if (!e.src) {
|
|
147
|
+
console.warn("additionalDataSource item number " + p + " missing 'src' property.", e);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const D = {
|
|
151
|
+
method: ((y = e.method) == null ? void 0 : y.toUpperCase()) || "GET",
|
|
152
|
+
url: e.src
|
|
153
|
+
};
|
|
154
|
+
c && Object.keys(c).length > 0 && (D.headers = c);
|
|
155
|
+
const k = await _(D), ct = {
|
|
156
|
+
url: D.url,
|
|
157
|
+
method: D.method,
|
|
158
|
+
headers: D.headers || {},
|
|
159
|
+
body: D.data
|
|
160
|
+
}, lt = {
|
|
161
|
+
headers: k.headers || {},
|
|
162
|
+
status: k.status,
|
|
163
|
+
data: k.data
|
|
164
|
+
}, P = bt({
|
|
165
|
+
requestContext: ct,
|
|
166
|
+
responseContext: lt,
|
|
167
|
+
responseBody: k.data,
|
|
168
|
+
// additionalDataSource always processes raw data, not RjBuild.
|
|
169
|
+
isRjBuild: !1,
|
|
170
|
+
dataProcessors: (I == null ? void 0 : I.dataProcessor) || {}
|
|
171
|
+
});
|
|
172
|
+
if (e.dataMapping)
|
|
173
|
+
try {
|
|
174
|
+
Et({
|
|
175
|
+
dataMapping: e.dataMapping,
|
|
176
|
+
responseData: P,
|
|
177
|
+
globalDataContext: m,
|
|
178
|
+
templateContext: r
|
|
179
|
+
});
|
|
180
|
+
return;
|
|
181
|
+
} catch (u) {
|
|
182
|
+
console.error("Error applying dataMapping for additionalDataSource:", u);
|
|
183
|
+
}
|
|
184
|
+
if (!e.path) {
|
|
185
|
+
if (typeof P != "object" || Array.isArray(P)) {
|
|
186
|
+
console.warn(
|
|
187
|
+
"additionalDataSource data cannot be merged at root - must be an object:",
|
|
188
|
+
P
|
|
189
|
+
);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
Object.entries(P).forEach(([u, G]) => {
|
|
193
|
+
g({
|
|
194
|
+
type: "updateData",
|
|
195
|
+
path: u,
|
|
196
|
+
value: G
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const u = Ct({
|
|
203
|
+
dataLocation: e.path,
|
|
204
|
+
currentPath: "data",
|
|
205
|
+
globalDataContext: m,
|
|
206
|
+
templateContext: r
|
|
207
|
+
});
|
|
208
|
+
if (typeof u != "string") {
|
|
209
|
+
console.warn(
|
|
210
|
+
"additionalDataSource path evaluation did not result in a string:",
|
|
211
|
+
e.path,
|
|
212
|
+
"->",
|
|
213
|
+
u
|
|
214
|
+
);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const G = u.substring(5);
|
|
218
|
+
g({
|
|
219
|
+
type: "updateData",
|
|
220
|
+
path: G,
|
|
221
|
+
value: P
|
|
222
|
+
});
|
|
223
|
+
} catch (u) {
|
|
224
|
+
console.error("Error evaluating additionalDataSource path:", e.path, u);
|
|
225
|
+
}
|
|
226
|
+
} catch (B) {
|
|
227
|
+
console.error("Error fetching additional data source:", e.src, B);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
g({ type: "setData", data: i }), (async () => {
|
|
231
|
+
if (l.length > 0) {
|
|
232
|
+
const e = l.map((p, y) => o(p, y));
|
|
233
|
+
await Promise.allSettled(e).catch((p) => {
|
|
234
|
+
console.error("Error processing blocking additionalDataSource:", p);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (Q(a.renderView), Y(Object.keys(a.renderView)), E.length > 0) {
|
|
238
|
+
const e = E.map(
|
|
239
|
+
(p, y) => o(p, l.length + y)
|
|
240
|
+
);
|
|
241
|
+
Promise.allSettled(e);
|
|
242
|
+
}
|
|
243
|
+
})();
|
|
244
|
+
}, [x, w, c]);
|
|
245
|
+
function j(t, a, i) {
|
|
246
|
+
if (!N || N.size === 0)
|
|
247
|
+
return !1;
|
|
248
|
+
for (const [s, m] of N)
|
|
249
|
+
if (t === s || t.startsWith(s + ".") || s === "") {
|
|
250
|
+
const r = s === "" ? t : t.substring(s.length + 1);
|
|
251
|
+
try {
|
|
252
|
+
return m(a, r, i), !0;
|
|
253
|
+
} catch (l) {
|
|
254
|
+
console.warn("Error during upstream update:", l);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return !1;
|
|
259
|
+
}
|
|
260
|
+
function W(t, a, i = void 0) {
|
|
261
|
+
let s = a.replace("data.", "");
|
|
262
|
+
j(s, t, i) || g({
|
|
263
|
+
type: "updateData",
|
|
264
|
+
path: s,
|
|
265
|
+
value: t,
|
|
266
|
+
updateMode: i
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function R(t) {
|
|
270
|
+
j("", t, void 0) || g({
|
|
271
|
+
type: "setData",
|
|
272
|
+
data: t
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function it(t, a, i, s = void 0) {
|
|
276
|
+
const m = a.split(".");
|
|
277
|
+
(typeof t.realCurrentData != "object" || t.realCurrentData === null || Array.isArray(t.realCurrentData)) && (t.realCurrentData = {});
|
|
278
|
+
let r = t.realCurrentData;
|
|
279
|
+
for (let l = 0, E = m.length; l < E; l++) {
|
|
280
|
+
const o = m[l];
|
|
281
|
+
if (l === E - 1) {
|
|
282
|
+
if (s === "remove" && Array.isArray(r))
|
|
283
|
+
r.splice(o, 1);
|
|
284
|
+
else if (s === "move")
|
|
285
|
+
if (i.increment) {
|
|
286
|
+
if (!Array.isArray(r))
|
|
287
|
+
return t;
|
|
288
|
+
const J = Math.min(
|
|
289
|
+
r.length,
|
|
290
|
+
Math.max(0, parseInt(o) + parseInt(i.increment))
|
|
291
|
+
);
|
|
292
|
+
if (J === parseInt(o))
|
|
293
|
+
return t;
|
|
294
|
+
const e = r.splice(o, 1);
|
|
295
|
+
if (e.length < 1)
|
|
296
|
+
return t;
|
|
297
|
+
r.splice(J, 0, e[0]);
|
|
298
|
+
} else
|
|
299
|
+
return t;
|
|
300
|
+
else if (i === void 0)
|
|
301
|
+
delete r[o];
|
|
302
|
+
else {
|
|
303
|
+
if (ut.isEqual(i, r[o]))
|
|
304
|
+
return t;
|
|
305
|
+
s === "add" ? (r[o] === void 0 && (r[o] = []), r[o].push(i)) : r[o] = i;
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
// Using modulo in case of massive update counts in long frontend sessions.
|
|
309
|
+
updateId: (t.updateId ?? 0) % (Number.MAX_SAFE_INTEGER - 1) + 1,
|
|
310
|
+
realCurrentData: t.realCurrentData
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (r.hasOwnProperty(o)) {
|
|
314
|
+
(typeof r[o] != "object" || r[o] === null) && (r[o] = {}), r = r[o];
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
r[o] = {}, r = r[o];
|
|
318
|
+
}
|
|
319
|
+
throw new Error("Could not update data.");
|
|
320
|
+
}
|
|
321
|
+
if (!x)
|
|
322
|
+
return null;
|
|
323
|
+
const U = st.map((t) => {
|
|
324
|
+
var a;
|
|
325
|
+
return /* @__PURE__ */ C(
|
|
326
|
+
St,
|
|
327
|
+
{
|
|
328
|
+
datafield: t,
|
|
329
|
+
props: nt[t],
|
|
330
|
+
path: "data." + t,
|
|
331
|
+
currentData: (a = S.realCurrentData) == null ? void 0 : a[t]
|
|
332
|
+
},
|
|
333
|
+
t
|
|
334
|
+
);
|
|
335
|
+
}), O = wt(et), F = /* @__PURE__ */ C(gt, { children: /* @__PURE__ */ L(
|
|
336
|
+
yt,
|
|
337
|
+
{
|
|
338
|
+
value: {
|
|
339
|
+
element: at,
|
|
340
|
+
headersForRjBuild: c,
|
|
341
|
+
plugins: I,
|
|
342
|
+
// Expose the root component to avoid import cycles in core plugins.
|
|
343
|
+
ReactiveJsonRoot: xt,
|
|
344
|
+
setData: R,
|
|
345
|
+
setRawAppRjBuild: T,
|
|
346
|
+
templateData: S.realCurrentData,
|
|
347
|
+
templatePath: "data",
|
|
348
|
+
updateData: W
|
|
349
|
+
},
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ C(
|
|
352
|
+
Pt.Provider,
|
|
353
|
+
{
|
|
354
|
+
value: {
|
|
355
|
+
templateData: S.realCurrentData,
|
|
356
|
+
templatePath: "data"
|
|
357
|
+
},
|
|
358
|
+
children: O && A ? /* @__PURE__ */ C(A, { children: U }) : U
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
O ? K && /* @__PURE__ */ C(K, { children: JSON.stringify(S.realCurrentData, null, " ") }) : null
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
) });
|
|
365
|
+
return O && A ? /* @__PURE__ */ L(rt, { children: [
|
|
366
|
+
F,
|
|
367
|
+
V
|
|
368
|
+
] }) : /* @__PURE__ */ L(pt, { children: [
|
|
369
|
+
F,
|
|
370
|
+
V
|
|
371
|
+
] });
|
|
372
|
+
};
|
|
18
373
|
export {
|
|
19
|
-
|
|
374
|
+
xt as ReactiveJsonRoot
|
|
20
375
|
};
|
package/dist/engine/View.js
CHANGED
|
@@ -1,9 +1,76 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as y } from "react";
|
|
3
|
+
import { GlobalDataContext as D } from "./GlobalDataContext.js";
|
|
4
|
+
import { TemplateContext as C } from "./TemplateContext.js";
|
|
5
|
+
import L, { evaluateTemplateValue as x, dataLocationToPath as P } from "./TemplateSystem.js";
|
|
6
|
+
function u({ props: t, currentData: o, datafield: c, path: n }) {
|
|
7
|
+
const i = y(D), v = y(C), f = i.plugins ?? {}, d = (f == null ? void 0 : f.element) ?? {};
|
|
8
|
+
if (!d)
|
|
9
|
+
return null;
|
|
10
|
+
const { element: T } = i;
|
|
11
|
+
if (o === void 0 && (o = ""), t != null && t.type) {
|
|
12
|
+
let e = d[t.type] ?? void 0;
|
|
13
|
+
const a = d.Html;
|
|
14
|
+
return e === void 0 && (e = a), e ? (a === e && (t.tag = t.tag ?? t.type), /* @__PURE__ */ l(e, { path: n, props: t, currentData: o, datafield: c })) : (console.warn(`No component found for type "${t.type}" and no Html fallback available.`), null);
|
|
15
|
+
}
|
|
16
|
+
if (t != null && t.load) {
|
|
17
|
+
let e;
|
|
18
|
+
const a = (t == null ? void 0 : t.customDataLocation) ?? void 0, m = a ? (
|
|
19
|
+
// The data is located somewhere in the current data.
|
|
20
|
+
x({
|
|
21
|
+
globalDataContext: i,
|
|
22
|
+
templateContext: v,
|
|
23
|
+
valueToEvaluate: a
|
|
24
|
+
})
|
|
25
|
+
) : (
|
|
26
|
+
// The data is the current data.
|
|
27
|
+
o
|
|
28
|
+
), r = a ? P({
|
|
29
|
+
dataLocation: a,
|
|
30
|
+
currentPath: n,
|
|
31
|
+
globalDataContext: i,
|
|
32
|
+
templateContext: v
|
|
33
|
+
}) : n;
|
|
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
|
|
43
|
+
}
|
|
44
|
+
) : /* @__PURE__ */ l(C.Provider, { value: { templateData: m, templatePath: r }, children: /* @__PURE__ */ l(
|
|
45
|
+
u,
|
|
46
|
+
{
|
|
47
|
+
currentData: m,
|
|
48
|
+
datafield: c,
|
|
49
|
+
path: r,
|
|
50
|
+
props: e
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
53
|
+
}
|
|
54
|
+
return Array.isArray(t) ? t.map((e, a) => /* @__PURE__ */ l(
|
|
55
|
+
u,
|
|
56
|
+
{
|
|
57
|
+
currentData: o[a] ?? void 0,
|
|
58
|
+
datafield: a,
|
|
59
|
+
path: n + "." + a,
|
|
60
|
+
props: e ?? void 0
|
|
61
|
+
},
|
|
62
|
+
n + "." + a
|
|
63
|
+
)) : typeof t == "object" ? Object.entries(t).map(([e, a]) => /* @__PURE__ */ l(
|
|
64
|
+
u,
|
|
65
|
+
{
|
|
66
|
+
currentData: o[e] ?? void 0,
|
|
67
|
+
datafield: e ?? void 0,
|
|
68
|
+
path: n + "." + e,
|
|
69
|
+
props: a
|
|
70
|
+
},
|
|
71
|
+
n + "." + e
|
|
72
|
+
)) : /* @__PURE__ */ l(L, { valueToEvaluate: o || (t ?? null) });
|
|
73
|
+
}
|
|
7
74
|
export {
|
|
8
|
-
|
|
75
|
+
u as View
|
|
9
76
|
};
|