@ea-lab/reactive-json 1.4.0 → 2.0.1

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