cogsbox-state 0.5.419 → 0.5.421
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/CogsState.jsx +265 -259
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +33 -16
package/dist/CogsState.jsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import { pushFunc as
|
|
6
|
-
import
|
|
7
|
-
import { v4 as
|
|
2
|
+
import { jsx as yt } from "react/jsx-runtime";
|
|
3
|
+
import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as xt, useMemo as It, createElement as ct, useSyncExternalStore as Mt, startTransition as Ot, useCallback as ft } from "react";
|
|
4
|
+
import { transformStateFunc as jt, isDeepEqual as q, isFunction as K, getNestedValue as Y, getDifferences as wt, debounce as Ut } from "./utility.js";
|
|
5
|
+
import { pushFunc as vt, updateFn as st, cutFunc as gt, ValidationWrapper as Ft, FormControlComponent as Dt } from "./Functions.jsx";
|
|
6
|
+
import Lt from "superjson";
|
|
7
|
+
import { v4 as pt } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
13
|
-
function
|
|
9
|
+
import { getGlobalStore as o, formRefStore as kt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as Nt } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as Gt } from "fast-json-patch";
|
|
12
|
+
import Wt from "react-use-measure";
|
|
13
|
+
function At(t, s) {
|
|
14
14
|
const S = o.getState().getInitialOptions, u = o.getState().setInitialStateOptions, v = S(t) || {};
|
|
15
15
|
u(t, {
|
|
16
16
|
...v,
|
|
17
17
|
...s
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function bt({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: s,
|
|
23
23
|
initialOptionsPart: S
|
|
@@ -30,12 +30,12 @@ function Vt({
|
|
|
30
30
|
!q(I[i], s[i]) && (y = !0, I[i] = s[i])) : (y = !0, I[i] = s[i]);
|
|
31
31
|
y && V(t, I);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function de(t, { formElements: s, validation: S }) {
|
|
34
34
|
return { initialState: t, formElements: s, validation: S };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const ue = (t, s) => {
|
|
37
37
|
let S = t;
|
|
38
|
-
const [u, v] =
|
|
38
|
+
const [u, v] = jt(S);
|
|
39
39
|
(Object.keys(v).length > 0 || s && Object.keys(s).length > 0) && Object.keys(v).forEach((y) => {
|
|
40
40
|
v[y] = v[y] || {}, v[y].formElements = {
|
|
41
41
|
...s?.formElements,
|
|
@@ -46,13 +46,13 @@ const ge = (t, s) => {
|
|
|
46
46
|
}, rt(y) || o.getState().setInitialStateOptions(y, v[y]);
|
|
47
47
|
}), o.getState().setInitialStates(u), o.getState().setCreatedState(u);
|
|
48
48
|
const V = (y, i) => {
|
|
49
|
-
const [h] = ot(i?.componentId ??
|
|
50
|
-
|
|
49
|
+
const [h] = ot(i?.componentId ?? pt());
|
|
50
|
+
bt({
|
|
51
51
|
stateKey: y,
|
|
52
52
|
options: i,
|
|
53
53
|
initialOptionsPart: v
|
|
54
54
|
});
|
|
55
|
-
const n = o.getState().cogsStateStore[y] || u[y], g = i?.modifyState ? i.modifyState(n) : n, [L,
|
|
55
|
+
const n = o.getState().cogsStateStore[y] || u[y], g = i?.modifyState ? i.modifyState(n) : n, [L, U] = Yt(
|
|
56
56
|
g,
|
|
57
57
|
{
|
|
58
58
|
stateKey: y,
|
|
@@ -68,24 +68,24 @@ const ge = (t, s) => {
|
|
|
68
68
|
serverState: i?.serverState
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
|
-
return
|
|
71
|
+
return U;
|
|
72
72
|
};
|
|
73
73
|
function I(y, i) {
|
|
74
|
-
|
|
74
|
+
bt({ stateKey: y, options: i, initialOptionsPart: v }), i.localStorage && qt(y, i), lt(y);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: V, setCogsOptions: I };
|
|
77
77
|
}, {
|
|
78
78
|
setUpdaterState: St,
|
|
79
79
|
setState: nt,
|
|
80
80
|
getInitialOptions: rt,
|
|
81
|
-
getKeyState:
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
81
|
+
getKeyState: Pt,
|
|
82
|
+
getValidationErrors: zt,
|
|
83
|
+
setStateLog: Ht,
|
|
84
|
+
updateInitialStateGlobal: Et,
|
|
85
|
+
addValidationError: Ct,
|
|
86
86
|
removeValidationError: X,
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = o.getState(),
|
|
87
|
+
setServerSyncActions: Bt
|
|
88
|
+
} = o.getState(), Vt = (t, s, S, u, v) => {
|
|
89
89
|
S?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
91
91
|
s,
|
|
@@ -104,7 +104,7 @@ const ge = (t, s) => {
|
|
|
104
104
|
state: t,
|
|
105
105
|
lastUpdated: Date.now(),
|
|
106
106
|
lastSyncedWithServer: v ?? y
|
|
107
|
-
}, h =
|
|
107
|
+
}, h = Lt.serialize(i);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
I,
|
|
110
110
|
JSON.stringify(h.json)
|
|
@@ -118,17 +118,17 @@ const ge = (t, s) => {
|
|
|
118
118
|
} catch (s) {
|
|
119
119
|
return console.error("Error loading from localStorage:", s), null;
|
|
120
120
|
}
|
|
121
|
-
},
|
|
122
|
-
const S = o.getState().cogsStateStore[t], { sessionId: u } =
|
|
121
|
+
}, qt = (t, s) => {
|
|
122
|
+
const S = o.getState().cogsStateStore[t], { sessionId: u } = Nt(), v = K(s?.localStorage?.key) ? s.localStorage.key(S) : s?.localStorage?.key;
|
|
123
123
|
if (v && u) {
|
|
124
124
|
const V = ht(
|
|
125
125
|
`${u}-${t}-${v}`
|
|
126
126
|
);
|
|
127
127
|
if (V && V.lastUpdated > (V.lastSyncedWithServer || 0))
|
|
128
|
-
return nt(t, V.state),
|
|
128
|
+
return nt(t, V.state), lt(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, _t = (t, s, S, u, v, V) => {
|
|
132
132
|
const I = {
|
|
133
133
|
initialState: s,
|
|
134
134
|
updaterState: mt(
|
|
@@ -139,8 +139,8 @@ const ge = (t, s) => {
|
|
|
139
139
|
),
|
|
140
140
|
state: S
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
},
|
|
142
|
+
Et(t, I.initialState), St(t, I.updaterState), nt(t, I.state);
|
|
143
|
+
}, lt = (t) => {
|
|
144
144
|
const s = o.getState().stateComponents.get(t);
|
|
145
145
|
if (!s) return;
|
|
146
146
|
const S = /* @__PURE__ */ new Set();
|
|
@@ -149,7 +149,7 @@ const ge = (t, s) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
S.forEach((u) => u());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, ge = (t, s) => {
|
|
153
153
|
const S = o.getState().stateComponents.get(t);
|
|
154
154
|
if (S) {
|
|
155
155
|
const u = `${t}////${s}`, v = S.components.get(u);
|
|
@@ -157,7 +157,7 @@ const ge = (t, s) => {
|
|
|
157
157
|
return;
|
|
158
158
|
v && v.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Jt = (t, s, S, u) => {
|
|
161
161
|
switch (t) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
@@ -180,7 +180,7 @@ const ge = (t, s) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Yt(t, {
|
|
184
184
|
stateKey: s,
|
|
185
185
|
serverSync: S,
|
|
186
186
|
localStorage: u,
|
|
@@ -193,12 +193,12 @@ function Zt(t, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: g
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [L,
|
|
197
|
-
let
|
|
198
|
-
const [f] = ot(s ??
|
|
196
|
+
const [L, U] = ot({}), { sessionId: F } = Nt();
|
|
197
|
+
let z = !s;
|
|
198
|
+
const [f] = ot(s ?? pt()), l = o.getState().stateLog[f], dt = J(/* @__PURE__ */ new Set()), tt = J(y ?? pt()), M = J(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
|
-
|
|
201
|
+
M.current = rt(f) ?? null, et(() => {
|
|
202
202
|
if (h && h.stateKey === f && h.path?.[0]) {
|
|
203
203
|
nt(f, (r) => ({
|
|
204
204
|
...r,
|
|
@@ -212,136 +212,136 @@ function Zt(t, {
|
|
|
212
212
|
}
|
|
213
213
|
}, [h]), et(() => {
|
|
214
214
|
if (i) {
|
|
215
|
-
|
|
215
|
+
At(f, {
|
|
216
216
|
initialState: i
|
|
217
217
|
});
|
|
218
|
-
const e =
|
|
218
|
+
const e = M.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = o.getState().initialStateGlobal[f];
|
|
219
219
|
if (!(c && !q(c, i) || !c) && !a)
|
|
220
220
|
return;
|
|
221
221
|
let m = null;
|
|
222
222
|
const k = K(e?.localStorage?.key) ? e?.localStorage?.key(i) : e?.localStorage?.key;
|
|
223
|
-
k &&
|
|
223
|
+
k && F && (m = ht(`${F}-${f}-${k}`));
|
|
224
224
|
let p = i, b = !1;
|
|
225
|
-
const
|
|
226
|
-
a &&
|
|
225
|
+
const _ = a ? Date.now() : 0, P = m?.lastUpdated || 0, R = m?.lastSyncedWithServer || 0;
|
|
226
|
+
a && _ > P ? (p = e.serverState.data, b = !0) : m && P > R && (p = m.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(f, i), _t(
|
|
227
227
|
f,
|
|
228
228
|
i,
|
|
229
229
|
p,
|
|
230
230
|
at,
|
|
231
231
|
tt.current,
|
|
232
|
-
|
|
233
|
-
), b && k &&
|
|
232
|
+
F
|
|
233
|
+
), b && k && F && Vt(p, f, e, F, Date.now()), lt(f), (Array.isArray(I) ? I : [I || "component"]).includes("none") || U({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
i,
|
|
237
237
|
g?.status,
|
|
238
238
|
g?.data,
|
|
239
239
|
...n || []
|
|
240
|
-
]),
|
|
241
|
-
|
|
240
|
+
]), xt(() => {
|
|
241
|
+
z && At(f, {
|
|
242
242
|
serverSync: S,
|
|
243
243
|
formElements: v,
|
|
244
244
|
initialState: i,
|
|
245
245
|
localStorage: u,
|
|
246
|
-
middleware:
|
|
246
|
+
middleware: M.current?.middleware
|
|
247
247
|
});
|
|
248
248
|
const e = `${f}////${tt.current}`, r = o.getState().stateComponents.get(f) || {
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return r.components.set(e, {
|
|
252
|
-
forceUpdate: () =>
|
|
252
|
+
forceUpdate: () => U({}),
|
|
253
253
|
paths: /* @__PURE__ */ new Set(),
|
|
254
254
|
deps: [],
|
|
255
255
|
depsFunction: V || void 0,
|
|
256
256
|
reactiveType: I ?? ["component", "deps"]
|
|
257
|
-
}), o.getState().stateComponents.set(f, r),
|
|
257
|
+
}), o.getState().stateComponents.set(f, r), U({}), () => {
|
|
258
258
|
r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(f));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
261
261
|
const at = (e, r, a, c) => {
|
|
262
262
|
if (Array.isArray(r)) {
|
|
263
263
|
const m = `${f}-${r.join(".")}`;
|
|
264
|
-
|
|
264
|
+
dt.current.add(m);
|
|
265
265
|
}
|
|
266
266
|
const w = o.getState();
|
|
267
267
|
nt(f, (m) => {
|
|
268
268
|
const k = K(e) ? e(m) : e, p = `${f}-${r.join(".")}`;
|
|
269
269
|
if (p) {
|
|
270
|
-
let
|
|
270
|
+
let T = !1, $ = w.signalDomElements.get(p);
|
|
271
271
|
if ((!$ || $.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
|
|
272
272
|
const x = r.slice(0, -1), G = Y(k, x);
|
|
273
273
|
if (Array.isArray(G)) {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
$ = w.signalDomElements.get(
|
|
274
|
+
T = !0;
|
|
275
|
+
const A = `${f}-${x.join(".")}`;
|
|
276
|
+
$ = w.signalDomElements.get(A);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
if ($) {
|
|
280
|
-
const x =
|
|
281
|
-
$.forEach(({ parentId: G, position:
|
|
282
|
-
const
|
|
280
|
+
const x = T ? Y(k, r.slice(0, -1)) : Y(k, r);
|
|
281
|
+
$.forEach(({ parentId: G, position: A, effect: D }) => {
|
|
282
|
+
const O = document.querySelector(
|
|
283
283
|
`[data-parent-id="${G}"]`
|
|
284
284
|
);
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
285
|
+
if (O) {
|
|
286
|
+
const B = Array.from(O.childNodes);
|
|
287
|
+
if (B[A]) {
|
|
288
288
|
const E = D ? new Function("state", `return (${D})(state)`)(x) : x;
|
|
289
|
-
|
|
289
|
+
B[A].textContent = String(E);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
console.log("shadowState", w.shadowStateStore), a.updateType === "update" && (c ||
|
|
296
|
-
(c ||
|
|
295
|
+
console.log("shadowState", w.shadowStateStore), a.updateType === "update" && (c || M.current?.validation?.key) && r && X(
|
|
296
|
+
(c || M.current?.validation?.key) + "." + r.join(".")
|
|
297
297
|
);
|
|
298
298
|
const b = r.slice(0, r.length - 1);
|
|
299
|
-
a.updateType === "cut" &&
|
|
300
|
-
|
|
301
|
-
), a.updateType === "insert" &&
|
|
302
|
-
|
|
299
|
+
a.updateType === "cut" && M.current?.validation?.key && X(
|
|
300
|
+
M.current?.validation?.key + "." + b.join(".")
|
|
301
|
+
), a.updateType === "insert" && M.current?.validation?.key && zt(
|
|
302
|
+
M.current?.validation?.key + "." + b.join(".")
|
|
303
303
|
).filter(([$, x]) => {
|
|
304
304
|
let G = $?.split(".").length;
|
|
305
305
|
if ($ == b.join(".") && G == b.length - 1) {
|
|
306
|
-
let
|
|
307
|
-
X($),
|
|
306
|
+
let A = $ + "." + b;
|
|
307
|
+
X($), Ct(A, x);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
310
|
+
const _ = w.stateComponents.get(f);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", _), _) {
|
|
312
|
+
const T = wt(m, k), $ = new Set(T), x = a.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
314
|
G,
|
|
315
|
-
|
|
316
|
-
] of
|
|
315
|
+
A
|
|
316
|
+
] of _.components.entries()) {
|
|
317
317
|
let D = !1;
|
|
318
|
-
const
|
|
319
|
-
if (console.log("component",
|
|
320
|
-
if (
|
|
321
|
-
|
|
318
|
+
const O = Array.isArray(A.reactiveType) ? A.reactiveType : [A.reactiveType || "component"];
|
|
319
|
+
if (console.log("component", A), !O.includes("none")) {
|
|
320
|
+
if (O.includes("all")) {
|
|
321
|
+
A.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (
|
|
325
|
-
for (const
|
|
326
|
-
let E =
|
|
324
|
+
if (O.includes("component") && ((A.paths.has(x) || A.paths.has("")) && (D = !0), !D))
|
|
325
|
+
for (const B of $) {
|
|
326
|
+
let E = B;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (
|
|
328
|
+
if (A.paths.has(E)) {
|
|
329
329
|
D = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
332
|
const N = E.lastIndexOf(".");
|
|
333
333
|
if (N !== -1) {
|
|
334
|
-
const
|
|
334
|
+
const C = E.substring(
|
|
335
335
|
0,
|
|
336
336
|
N
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
339
|
Number(E.substring(N + 1))
|
|
340
|
-
) &&
|
|
340
|
+
) && A.paths.has(C)) {
|
|
341
341
|
D = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
E =
|
|
344
|
+
E = C;
|
|
345
345
|
} else
|
|
346
346
|
E = "";
|
|
347
347
|
if (E === "")
|
|
@@ -349,21 +349,21 @@ function Zt(t, {
|
|
|
349
349
|
}
|
|
350
350
|
if (D) break;
|
|
351
351
|
}
|
|
352
|
-
if (!D &&
|
|
353
|
-
const
|
|
352
|
+
if (!D && O.includes("deps") && A.depsFunction) {
|
|
353
|
+
const B = A.depsFunction(k);
|
|
354
354
|
let E = !1;
|
|
355
|
-
typeof
|
|
355
|
+
typeof B == "boolean" ? B && (E = !0) : q(A.deps, B) || (A.deps = B, E = !0), E && (D = !0);
|
|
356
356
|
}
|
|
357
|
-
D &&
|
|
357
|
+
D && A.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
const P = Date.now();
|
|
362
|
-
r = r.map((
|
|
362
|
+
r = r.map((T, $) => {
|
|
363
363
|
const x = r.slice(0, -1), G = Y(k, x);
|
|
364
|
-
return $ === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (G.length - 1).toString() :
|
|
364
|
+
return $ === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (G.length - 1).toString() : T;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue:
|
|
366
|
+
const { oldValue: R, newValue: H } = Jt(
|
|
367
367
|
a.updateType,
|
|
368
368
|
m,
|
|
369
369
|
k,
|
|
@@ -374,41 +374,41 @@ function Zt(t, {
|
|
|
374
374
|
path: r,
|
|
375
375
|
updateType: a.updateType,
|
|
376
376
|
status: "new",
|
|
377
|
-
oldValue:
|
|
378
|
-
newValue:
|
|
377
|
+
oldValue: R,
|
|
378
|
+
newValue: H
|
|
379
379
|
};
|
|
380
380
|
switch (a.updateType) {
|
|
381
381
|
case "update":
|
|
382
382
|
w.updateShadowAtPath(f, r, k);
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
w.insertShadowArrayElement(f,
|
|
385
|
+
const T = r.slice(0, -1);
|
|
386
|
+
w.insertShadowArrayElement(f, T, H);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
389
|
const $ = r.slice(0, -1), x = parseInt(r[r.length - 1]);
|
|
390
390
|
w.removeShadowArrayElement(f, $, x);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const x = [...
|
|
395
|
-
const D = `${
|
|
396
|
-
return
|
|
393
|
+
if (Ht(f, (T) => {
|
|
394
|
+
const x = [...T ?? [], Q].reduce((G, A) => {
|
|
395
|
+
const D = `${A.stateKey}:${JSON.stringify(A.path)}`, O = G.get(D);
|
|
396
|
+
return O ? (O.timeStamp = Math.max(O.timeStamp, A.timeStamp), O.newValue = A.newValue, O.oldValue = O.oldValue ?? A.oldValue, O.updateType = A.updateType) : G.set(D, { ...A }), G;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
398
|
return Array.from(x.values());
|
|
399
|
-
}),
|
|
399
|
+
}), Vt(
|
|
400
400
|
k,
|
|
401
401
|
f,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
),
|
|
402
|
+
M.current,
|
|
403
|
+
F
|
|
404
|
+
), M.current?.middleware && M.current.middleware({
|
|
405
405
|
updateLog: l,
|
|
406
406
|
update: Q
|
|
407
|
-
}),
|
|
408
|
-
const
|
|
409
|
-
|
|
407
|
+
}), M.current?.serverSync) {
|
|
408
|
+
const T = w.serverState[f], $ = M.current?.serverSync;
|
|
409
|
+
Bt(f, {
|
|
410
410
|
syncKey: typeof $.syncKey == "string" ? $.syncKey : $.syncKey({ state: k }),
|
|
411
|
-
rollBackState:
|
|
411
|
+
rollBackState: T,
|
|
412
412
|
actionTimeStamp: Date.now() + ($.debounce ?? 3e3),
|
|
413
413
|
status: "waiting"
|
|
414
414
|
});
|
|
@@ -422,16 +422,16 @@ function Zt(t, {
|
|
|
422
422
|
f,
|
|
423
423
|
at,
|
|
424
424
|
tt.current,
|
|
425
|
-
|
|
425
|
+
F
|
|
426
426
|
)
|
|
427
|
-
), o.getState().cogsStateStore[f] || nt(f, t), o.getState().initialStateGlobal[f] ||
|
|
428
|
-
const d =
|
|
427
|
+
), o.getState().cogsStateStore[f] || nt(f, t), o.getState().initialStateGlobal[f] || Et(f, t));
|
|
428
|
+
const d = It(() => mt(
|
|
429
429
|
f,
|
|
430
430
|
at,
|
|
431
431
|
tt.current,
|
|
432
|
-
|
|
433
|
-
), [f,
|
|
434
|
-
return [
|
|
432
|
+
F
|
|
433
|
+
), [f, F]);
|
|
434
|
+
return [Pt(f), d];
|
|
435
435
|
}
|
|
436
436
|
function mt(t, s, S, u) {
|
|
437
437
|
const v = /* @__PURE__ */ new Map();
|
|
@@ -450,8 +450,8 @@ function mt(t, s, S, u) {
|
|
|
450
450
|
n?.key && X(n?.key), h?.validationKey && X(h.validationKey);
|
|
451
451
|
const g = o.getState().initialStateGlobal[t];
|
|
452
452
|
o.getState().clearSelectedIndexesForState(t), v.clear(), V++;
|
|
453
|
-
const L = i(g, []),
|
|
454
|
-
|
|
453
|
+
const L = i(g, []), U = rt(t), F = K(U?.localStorage?.key) ? U?.localStorage?.key(g) : U?.localStorage?.key, z = `${u}-${t}-${F}`;
|
|
454
|
+
z && localStorage.removeItem(z), St(t, L), nt(t, g);
|
|
455
455
|
const f = o.getState().stateComponents.get(t);
|
|
456
456
|
return f && f.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -464,15 +464,15 @@ function mt(t, s, S, u) {
|
|
|
464
464
|
s,
|
|
465
465
|
S,
|
|
466
466
|
u
|
|
467
|
-
), g = o.getState().initialStateGlobal[t], L = rt(t),
|
|
468
|
-
return localStorage.getItem(
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
467
|
+
), g = o.getState().initialStateGlobal[t], L = rt(t), U = K(L?.localStorage?.key) ? L?.localStorage?.key(g) : L?.localStorage?.key, F = `${u}-${t}-${U}`;
|
|
468
|
+
return localStorage.getItem(F) && localStorage.removeItem(F), Ot(() => {
|
|
469
|
+
Et(t, h), o.getState().initializeShadowState(t, h), St(t, n), nt(t, h);
|
|
470
|
+
const z = o.getState().stateComponents.get(t);
|
|
471
|
+
z && z.components.forEach((f) => {
|
|
472
472
|
f.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (z) => n.get()[z]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: o.getState().initialStateGlobal[t],
|
|
@@ -480,27 +480,27 @@ function mt(t, s, S, u) {
|
|
|
480
480
|
_isLoading: o.getState().isLoadingGlobal[t],
|
|
481
481
|
_isServerSynced: () => {
|
|
482
482
|
const h = o.getState().serverState[t];
|
|
483
|
-
return !!(h && q(h,
|
|
483
|
+
return !!(h && q(h, Pt(t)));
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function i(h, n = [], g) {
|
|
487
487
|
const L = n.map(String).join(".");
|
|
488
488
|
v.get(L);
|
|
489
|
-
const
|
|
489
|
+
const U = function() {
|
|
490
490
|
return o().getNestedState(t, n);
|
|
491
491
|
};
|
|
492
492
|
Object.keys(y).forEach((f) => {
|
|
493
|
-
|
|
493
|
+
U[f] = y[f];
|
|
494
494
|
});
|
|
495
|
-
const
|
|
496
|
-
apply(f, l,
|
|
495
|
+
const F = {
|
|
496
|
+
apply(f, l, dt) {
|
|
497
497
|
return console.log(
|
|
498
498
|
`PROXY APPLY TRAP HIT: stateKey=${t}, path=${n.join(".")}`
|
|
499
499
|
), console.trace("Apply trap stack trace"), o().getNestedState(t, n);
|
|
500
500
|
},
|
|
501
501
|
get(f, l) {
|
|
502
502
|
g?.validIndices && !Array.isArray(h) && (g = { ...g, validIndices: void 0 });
|
|
503
|
-
const
|
|
503
|
+
const dt = /* @__PURE__ */ new Set([
|
|
504
504
|
"insert",
|
|
505
505
|
"cut",
|
|
506
506
|
"cutByValue",
|
|
@@ -523,7 +523,7 @@ function mt(t, s, S, u) {
|
|
|
523
523
|
"_stateKey",
|
|
524
524
|
"getComponents"
|
|
525
525
|
]);
|
|
526
|
-
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !
|
|
526
|
+
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !dt.has(l)) {
|
|
527
527
|
const d = `${t}////${S}`, e = o.getState().stateComponents.get(t);
|
|
528
528
|
if (e) {
|
|
529
529
|
const r = e.components.get(d);
|
|
@@ -540,7 +540,7 @@ function mt(t, s, S, u) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => wt(
|
|
544
544
|
o.getState().cogsStateStore[t],
|
|
545
545
|
o.getState().initialStateGlobal[t]
|
|
546
546
|
);
|
|
@@ -625,46 +625,46 @@ function mt(t, s, S, u) {
|
|
|
625
625
|
} = e, m = J(null), [k, p] = ot({
|
|
626
626
|
startIndex: 0,
|
|
627
627
|
endIndex: 10
|
|
628
|
-
}), [b,
|
|
628
|
+
}), [b, _] = ot(0), P = J(!0), R = J(!1), H = J(0);
|
|
629
629
|
et(() => o.getState().subscribeToShadowState(t, () => {
|
|
630
|
-
|
|
630
|
+
_((N) => N + 1);
|
|
631
631
|
}), [t]);
|
|
632
632
|
const Q = o().getNestedState(
|
|
633
633
|
t,
|
|
634
634
|
n
|
|
635
|
-
),
|
|
635
|
+
), T = Q.length, { totalHeight: $, positions: x } = It(() => {
|
|
636
636
|
const E = o.getState().getShadowMetadata(t, n) || [];
|
|
637
637
|
let N = 0;
|
|
638
|
-
const
|
|
639
|
-
for (let
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
N +=
|
|
638
|
+
const C = [];
|
|
639
|
+
for (let j = 0; j < T; j++) {
|
|
640
|
+
C[j] = N;
|
|
641
|
+
const W = E[j]?.virtualizer?.itemHeight;
|
|
642
|
+
N += W || r;
|
|
643
643
|
}
|
|
644
|
-
return { totalHeight: N, positions:
|
|
644
|
+
return { totalHeight: N, positions: C };
|
|
645
645
|
}, [
|
|
646
|
-
|
|
646
|
+
T,
|
|
647
647
|
t,
|
|
648
648
|
n.join("."),
|
|
649
649
|
r,
|
|
650
650
|
b
|
|
651
|
-
]), G =
|
|
652
|
-
const E = Math.max(0, k.startIndex), N = Math.min(
|
|
651
|
+
]), G = It(() => {
|
|
652
|
+
const E = Math.max(0, k.startIndex), N = Math.min(T, k.endIndex), C = Array.from(
|
|
653
653
|
{ length: N - E },
|
|
654
|
-
(
|
|
655
|
-
),
|
|
656
|
-
return i(
|
|
654
|
+
(W, it) => E + it
|
|
655
|
+
), j = C.map((W) => Q[W]);
|
|
656
|
+
return i(j, n, {
|
|
657
657
|
...g,
|
|
658
|
-
validIndices:
|
|
658
|
+
validIndices: C
|
|
659
659
|
});
|
|
660
|
-
}, [k.startIndex, k.endIndex, Q,
|
|
661
|
-
const E = o.getState().getShadowMetadata(t, n) || [], N =
|
|
660
|
+
}, [k.startIndex, k.endIndex, Q, T]), A = ft(() => {
|
|
661
|
+
const E = o.getState().getShadowMetadata(t, n) || [], N = T - 1;
|
|
662
662
|
if (N >= 0) {
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
return
|
|
663
|
+
const C = E[N];
|
|
664
|
+
if (C?.virtualizer?.domRef) {
|
|
665
|
+
const j = C.virtualizer.domRef;
|
|
666
|
+
if (j && j.scrollIntoView)
|
|
667
|
+
return j.scrollIntoView({
|
|
668
668
|
behavior: "auto",
|
|
669
669
|
block: "end",
|
|
670
670
|
inline: "nearest"
|
|
@@ -672,61 +672,67 @@ function mt(t, s, S, u) {
|
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
return !1;
|
|
675
|
-
}, [t, n,
|
|
675
|
+
}, [t, n, T]);
|
|
676
676
|
et(() => {
|
|
677
|
-
if (!c ||
|
|
678
|
-
const E =
|
|
679
|
-
if ((E || N) && P.current) {
|
|
680
|
-
const
|
|
677
|
+
if (!c || T === 0) return;
|
|
678
|
+
const E = T > H.current, N = H.current === 0 && T > 0;
|
|
679
|
+
if ((E || N) && P.current && !R.current) {
|
|
680
|
+
const C = Math.ceil(
|
|
681
681
|
(m.current?.clientHeight || 0) / r
|
|
682
|
-
),
|
|
682
|
+
), j = {
|
|
683
683
|
startIndex: Math.max(
|
|
684
684
|
0,
|
|
685
|
-
|
|
685
|
+
T - C - a
|
|
686
686
|
),
|
|
687
|
-
endIndex:
|
|
687
|
+
endIndex: T
|
|
688
688
|
};
|
|
689
|
-
p(
|
|
689
|
+
p(j);
|
|
690
|
+
const W = setTimeout(() => {
|
|
690
691
|
m.current && (m.current.scrollTop = m.current.scrollHeight);
|
|
691
692
|
}, 50);
|
|
693
|
+
return () => clearTimeout(W);
|
|
692
694
|
}
|
|
693
|
-
|
|
694
|
-
}, [
|
|
695
|
+
H.current = T;
|
|
696
|
+
}, [T, r, a]), et(() => {
|
|
695
697
|
const E = m.current;
|
|
696
698
|
if (!E) return;
|
|
697
699
|
const N = () => {
|
|
698
|
-
const { scrollTop:
|
|
699
|
-
P.current =
|
|
700
|
+
const { scrollTop: C, scrollHeight: j, clientHeight: W } = E, it = j - C - W;
|
|
701
|
+
P.current = it < 5, it > 100 && (R.current = !0), it < 5 && (R.current = !1);
|
|
700
702
|
let ut = 0;
|
|
701
703
|
for (let Z = 0; Z < x.length; Z++)
|
|
702
|
-
if (x[Z] >
|
|
704
|
+
if (x[Z] > C - r * a) {
|
|
703
705
|
ut = Math.max(0, Z - 1);
|
|
704
706
|
break;
|
|
705
707
|
}
|
|
706
|
-
let
|
|
707
|
-
const
|
|
708
|
-
for (let Z = ut; Z < x.length && !(x[Z] >
|
|
709
|
-
|
|
708
|
+
let Tt = ut;
|
|
709
|
+
const Rt = C + W;
|
|
710
|
+
for (let Z = ut; Z < x.length && !(x[Z] > Rt + r * a); Z++)
|
|
711
|
+
Tt = Z;
|
|
710
712
|
p({
|
|
711
713
|
startIndex: Math.max(0, ut),
|
|
712
|
-
endIndex: Math.min(
|
|
714
|
+
endIndex: Math.min(T, Tt + 1 + a)
|
|
713
715
|
});
|
|
714
716
|
};
|
|
715
|
-
|
|
717
|
+
if (E.addEventListener("scroll", N, {
|
|
716
718
|
passive: !0
|
|
717
|
-
}), c &&
|
|
719
|
+
}), c && T > 0 && !R.current) {
|
|
720
|
+
const { scrollTop: C } = E;
|
|
721
|
+
C === 0 && (E.scrollTop = E.scrollHeight, P.current = !0);
|
|
722
|
+
}
|
|
723
|
+
return N(), () => {
|
|
718
724
|
E.removeEventListener("scroll", N);
|
|
719
725
|
};
|
|
720
|
-
}, [x,
|
|
726
|
+
}, [x, T, r, a, c]);
|
|
721
727
|
const D = ft(() => {
|
|
722
|
-
P.current = !0, !
|
|
723
|
-
}, [
|
|
728
|
+
P.current = !0, R.current = !1, !A() && m.current && (m.current.scrollTop = m.current.scrollHeight);
|
|
729
|
+
}, [A]), O = ft(
|
|
724
730
|
(E, N = "smooth") => {
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
729
|
-
|
|
731
|
+
const j = (o.getState().getShadowMetadata(t, n) || [])[E];
|
|
732
|
+
if (j?.virtualizer?.domRef) {
|
|
733
|
+
const W = j.virtualizer.domRef;
|
|
734
|
+
if (W && W.scrollIntoView) {
|
|
735
|
+
W.scrollIntoView({ behavior: N, block: "end" });
|
|
730
736
|
return;
|
|
731
737
|
}
|
|
732
738
|
}
|
|
@@ -736,7 +742,7 @@ function mt(t, s, S, u) {
|
|
|
736
742
|
});
|
|
737
743
|
},
|
|
738
744
|
[x, t, n]
|
|
739
|
-
),
|
|
745
|
+
), B = {
|
|
740
746
|
outer: {
|
|
741
747
|
ref: m,
|
|
742
748
|
style: { overflowY: "auto", height: "100%" }
|
|
@@ -755,9 +761,9 @@ function mt(t, s, S, u) {
|
|
|
755
761
|
};
|
|
756
762
|
return {
|
|
757
763
|
virtualState: G,
|
|
758
|
-
virtualizerProps:
|
|
764
|
+
virtualizerProps: B,
|
|
759
765
|
scrollToBottom: D,
|
|
760
|
-
scrollToIndex:
|
|
766
|
+
scrollToIndex: O
|
|
761
767
|
};
|
|
762
768
|
};
|
|
763
769
|
if (l === "stateMapNoRender")
|
|
@@ -774,7 +780,7 @@ function mt(t, s, S, u) {
|
|
|
774
780
|
);
|
|
775
781
|
});
|
|
776
782
|
if (l === "$stateMap")
|
|
777
|
-
return (e) =>
|
|
783
|
+
return (e) => ct(Zt, {
|
|
778
784
|
proxy: {
|
|
779
785
|
_stateKey: t,
|
|
780
786
|
_path: n,
|
|
@@ -788,7 +794,7 @@ function mt(t, s, S, u) {
|
|
|
788
794
|
const r = o.getState().getNestedState(t, n);
|
|
789
795
|
return Array.isArray(r) ? (g?.validIndices || Array.from({ length: r.length }, (c, w) => w)).map((c, w) => {
|
|
790
796
|
const m = r[c], k = [...n, c.toString()], p = i(m, k, g), b = `${S}-${n.join(".")}-${c}`;
|
|
791
|
-
return
|
|
797
|
+
return ct(Qt, {
|
|
792
798
|
key: c,
|
|
793
799
|
stateKey: t,
|
|
794
800
|
itemComponentId: b,
|
|
@@ -831,7 +837,7 @@ function mt(t, s, S, u) {
|
|
|
831
837
|
return i(a, c);
|
|
832
838
|
};
|
|
833
839
|
if (l === "insert")
|
|
834
|
-
return (e) => (I(n),
|
|
840
|
+
return (e) => (I(n), vt(s, e, n, t), i(
|
|
835
841
|
o.getState().getNestedState(t, n),
|
|
836
842
|
n
|
|
837
843
|
));
|
|
@@ -841,20 +847,20 @@ function mt(t, s, S, u) {
|
|
|
841
847
|
let m = null;
|
|
842
848
|
if (!c.some((p) => {
|
|
843
849
|
if (r) {
|
|
844
|
-
const
|
|
850
|
+
const _ = r.every(
|
|
845
851
|
(P) => q(p[P], w[P])
|
|
846
852
|
);
|
|
847
|
-
return
|
|
853
|
+
return _ && (m = p), _;
|
|
848
854
|
}
|
|
849
855
|
const b = q(p, w);
|
|
850
856
|
return b && (m = p), b;
|
|
851
857
|
}))
|
|
852
|
-
I(n),
|
|
858
|
+
I(n), vt(s, w, n, t);
|
|
853
859
|
else if (a && m) {
|
|
854
860
|
const p = a(m), b = c.map(
|
|
855
|
-
(
|
|
861
|
+
(_) => q(_, m) ? p : _
|
|
856
862
|
);
|
|
857
|
-
I(n),
|
|
863
|
+
I(n), st(s, b, n);
|
|
858
864
|
}
|
|
859
865
|
};
|
|
860
866
|
if (l === "cut")
|
|
@@ -873,7 +879,7 @@ function mt(t, s, S, u) {
|
|
|
873
879
|
if (l === "toggleByValue")
|
|
874
880
|
return (e) => {
|
|
875
881
|
const r = h.findIndex((a) => a === e);
|
|
876
|
-
r > -1 ? gt(s, n, t, r) :
|
|
882
|
+
r > -1 ? gt(s, n, t, r) : vt(s, e, n, t);
|
|
877
883
|
};
|
|
878
884
|
if (l === "stateFind")
|
|
879
885
|
return (e) => {
|
|
@@ -914,13 +920,13 @@ function mt(t, s, S, u) {
|
|
|
914
920
|
return o.getState().getNestedState(t, n);
|
|
915
921
|
};
|
|
916
922
|
if (l === "$derive")
|
|
917
|
-
return (d) =>
|
|
923
|
+
return (d) => $t({
|
|
918
924
|
_stateKey: t,
|
|
919
925
|
_path: n,
|
|
920
926
|
_effect: d.toString()
|
|
921
927
|
});
|
|
922
928
|
if (l === "$get")
|
|
923
|
-
return () =>
|
|
929
|
+
return () => $t({
|
|
924
930
|
_stateKey: t,
|
|
925
931
|
_path: n
|
|
926
932
|
});
|
|
@@ -939,7 +945,7 @@ function mt(t, s, S, u) {
|
|
|
939
945
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), a = e.join(".");
|
|
940
946
|
d ? o.getState().setSelectedIndex(t, a, r) : o.getState().setSelectedIndex(t, a, void 0);
|
|
941
947
|
const c = o.getState().getNestedState(t, [...e]);
|
|
942
|
-
|
|
948
|
+
st(s, c, e), I(e);
|
|
943
949
|
};
|
|
944
950
|
if (l === "toggleSelected")
|
|
945
951
|
return () => {
|
|
@@ -950,7 +956,7 @@ function mt(t, s, S, u) {
|
|
|
950
956
|
a === e ? void 0 : e
|
|
951
957
|
);
|
|
952
958
|
const c = o.getState().getNestedState(t, [...d]);
|
|
953
|
-
|
|
959
|
+
st(s, c, d), I(d);
|
|
954
960
|
};
|
|
955
961
|
if (n.length == 0) {
|
|
956
962
|
if (l === "addValidation")
|
|
@@ -960,13 +966,13 @@ function mt(t, s, S, u) {
|
|
|
960
966
|
throw new Error("Validation key not found");
|
|
961
967
|
X(e.key), console.log("addValidationError", d), d.forEach((r) => {
|
|
962
968
|
const a = [e.key, ...r.path].join(".");
|
|
963
|
-
console.log("fullErrorPath", a),
|
|
964
|
-
}),
|
|
969
|
+
console.log("fullErrorPath", a), Ct(a, r.message);
|
|
970
|
+
}), lt(t);
|
|
965
971
|
};
|
|
966
972
|
if (l === "applyJsonPatch")
|
|
967
973
|
return (d) => {
|
|
968
|
-
const e = o.getState().cogsStateStore[t], a =
|
|
969
|
-
|
|
974
|
+
const e = o.getState().cogsStateStore[t], a = Gt(e, d).newDocument;
|
|
975
|
+
_t(
|
|
970
976
|
t,
|
|
971
977
|
o.getState().initialStateGlobal[t],
|
|
972
978
|
a,
|
|
@@ -976,40 +982,40 @@ function mt(t, s, S, u) {
|
|
|
976
982
|
);
|
|
977
983
|
const c = o.getState().stateComponents.get(t);
|
|
978
984
|
if (c) {
|
|
979
|
-
const w =
|
|
985
|
+
const w = wt(e, a), m = new Set(w);
|
|
980
986
|
for (const [
|
|
981
987
|
k,
|
|
982
988
|
p
|
|
983
989
|
] of c.components.entries()) {
|
|
984
990
|
let b = !1;
|
|
985
|
-
const
|
|
986
|
-
if (!
|
|
987
|
-
if (
|
|
991
|
+
const _ = Array.isArray(p.reactiveType) ? p.reactiveType : [p.reactiveType || "component"];
|
|
992
|
+
if (!_.includes("none")) {
|
|
993
|
+
if (_.includes("all")) {
|
|
988
994
|
p.forceUpdate();
|
|
989
995
|
continue;
|
|
990
996
|
}
|
|
991
|
-
if (
|
|
997
|
+
if (_.includes("component") && (p.paths.has("") && (b = !0), !b))
|
|
992
998
|
for (const P of m) {
|
|
993
999
|
if (p.paths.has(P)) {
|
|
994
1000
|
b = !0;
|
|
995
1001
|
break;
|
|
996
1002
|
}
|
|
997
|
-
let
|
|
998
|
-
for (;
|
|
999
|
-
const
|
|
1000
|
-
if (p.paths.has(
|
|
1003
|
+
let R = P.lastIndexOf(".");
|
|
1004
|
+
for (; R !== -1; ) {
|
|
1005
|
+
const H = P.substring(0, R);
|
|
1006
|
+
if (p.paths.has(H)) {
|
|
1001
1007
|
b = !0;
|
|
1002
1008
|
break;
|
|
1003
1009
|
}
|
|
1004
1010
|
const Q = P.substring(
|
|
1005
|
-
|
|
1011
|
+
R + 1
|
|
1006
1012
|
);
|
|
1007
1013
|
if (!isNaN(Number(Q))) {
|
|
1008
|
-
const
|
|
1009
|
-
if (
|
|
1010
|
-
const $ =
|
|
1014
|
+
const T = H.lastIndexOf(".");
|
|
1015
|
+
if (T !== -1) {
|
|
1016
|
+
const $ = H.substring(
|
|
1011
1017
|
0,
|
|
1012
|
-
|
|
1018
|
+
T
|
|
1013
1019
|
);
|
|
1014
1020
|
if (p.paths.has($)) {
|
|
1015
1021
|
b = !0;
|
|
@@ -1017,14 +1023,14 @@ function mt(t, s, S, u) {
|
|
|
1017
1023
|
}
|
|
1018
1024
|
}
|
|
1019
1025
|
}
|
|
1020
|
-
|
|
1026
|
+
R = H.lastIndexOf(".");
|
|
1021
1027
|
}
|
|
1022
1028
|
if (b) break;
|
|
1023
1029
|
}
|
|
1024
|
-
if (!b &&
|
|
1030
|
+
if (!b && _.includes("deps") && p.depsFunction) {
|
|
1025
1031
|
const P = p.depsFunction(a);
|
|
1026
|
-
let
|
|
1027
|
-
typeof P == "boolean" ? P && (
|
|
1032
|
+
let R = !1;
|
|
1033
|
+
typeof P == "boolean" ? P && (R = !0) : q(p.deps, P) || (p.deps = P, R = !0), R && (b = !0);
|
|
1028
1034
|
}
|
|
1029
1035
|
b && p.forceUpdate();
|
|
1030
1036
|
}
|
|
@@ -1049,7 +1055,7 @@ function mt(t, s, S, u) {
|
|
|
1049
1055
|
return c.success ? !0 : (c.error.errors.forEach((m) => {
|
|
1050
1056
|
const k = m.path, p = m.message, b = [d.key, ...k].join(".");
|
|
1051
1057
|
e(b, p);
|
|
1052
|
-
}),
|
|
1058
|
+
}), lt(t), !1);
|
|
1053
1059
|
} catch (a) {
|
|
1054
1060
|
return console.error("Zod schema validation failed", a), !1;
|
|
1055
1061
|
}
|
|
@@ -1058,7 +1064,7 @@ function mt(t, s, S, u) {
|
|
|
1058
1064
|
if (l === "getComponents")
|
|
1059
1065
|
return () => o().stateComponents.get(t);
|
|
1060
1066
|
if (l === "getAllFormRefs")
|
|
1061
|
-
return () =>
|
|
1067
|
+
return () => kt.getState().getFormRefsByStateKey(t);
|
|
1062
1068
|
if (l === "_initialState")
|
|
1063
1069
|
return o.getState().initialStateGlobal[t];
|
|
1064
1070
|
if (l === "_serverState")
|
|
@@ -1071,13 +1077,13 @@ function mt(t, s, S, u) {
|
|
|
1071
1077
|
if (l === "removeValidation") return y.removeValidation;
|
|
1072
1078
|
}
|
|
1073
1079
|
if (l === "getFormRef")
|
|
1074
|
-
return () =>
|
|
1080
|
+
return () => kt.getState().getFormRef(t + "." + n.join("."));
|
|
1075
1081
|
if (l === "validationWrapper")
|
|
1076
1082
|
return ({
|
|
1077
1083
|
children: d,
|
|
1078
1084
|
hideMessage: e
|
|
1079
|
-
}) => /* @__PURE__ */
|
|
1080
|
-
|
|
1085
|
+
}) => /* @__PURE__ */ yt(
|
|
1086
|
+
Ft,
|
|
1081
1087
|
{
|
|
1082
1088
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1083
1089
|
path: n,
|
|
@@ -1093,21 +1099,21 @@ function mt(t, s, S, u) {
|
|
|
1093
1099
|
if (l === "update")
|
|
1094
1100
|
return (d, e) => {
|
|
1095
1101
|
if (e?.debounce)
|
|
1096
|
-
|
|
1097
|
-
|
|
1102
|
+
Ut(() => {
|
|
1103
|
+
st(s, d, n, "");
|
|
1098
1104
|
const r = o.getState().getNestedState(t, n);
|
|
1099
1105
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1100
1106
|
}, e.debounce);
|
|
1101
1107
|
else {
|
|
1102
|
-
|
|
1108
|
+
st(s, d, n, "");
|
|
1103
1109
|
const r = o.getState().getNestedState(t, n);
|
|
1104
1110
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1105
1111
|
}
|
|
1106
1112
|
I(n);
|
|
1107
1113
|
};
|
|
1108
1114
|
if (l === "formElement")
|
|
1109
|
-
return (d, e) => /* @__PURE__ */
|
|
1110
|
-
|
|
1115
|
+
return (d, e) => /* @__PURE__ */ yt(
|
|
1116
|
+
Dt,
|
|
1111
1117
|
{
|
|
1112
1118
|
setState: s,
|
|
1113
1119
|
stateKey: t,
|
|
@@ -1116,23 +1122,23 @@ function mt(t, s, S, u) {
|
|
|
1116
1122
|
formOpts: e
|
|
1117
1123
|
}
|
|
1118
1124
|
);
|
|
1119
|
-
const
|
|
1120
|
-
return i(at,
|
|
1125
|
+
const M = [...n, l], at = o.getState().getNestedState(t, M);
|
|
1126
|
+
return i(at, M, g);
|
|
1121
1127
|
}
|
|
1122
|
-
},
|
|
1128
|
+
}, z = new Proxy(U, F);
|
|
1123
1129
|
return v.set(L, {
|
|
1124
|
-
proxy:
|
|
1130
|
+
proxy: z,
|
|
1125
1131
|
stateVersion: V
|
|
1126
|
-
}),
|
|
1132
|
+
}), z;
|
|
1127
1133
|
}
|
|
1128
1134
|
return i(
|
|
1129
1135
|
o.getState().getNestedState(t, [])
|
|
1130
1136
|
);
|
|
1131
1137
|
}
|
|
1132
|
-
function
|
|
1133
|
-
return
|
|
1138
|
+
function $t(t) {
|
|
1139
|
+
return ct(Xt, { proxy: t });
|
|
1134
1140
|
}
|
|
1135
|
-
function
|
|
1141
|
+
function Zt({
|
|
1136
1142
|
proxy: t,
|
|
1137
1143
|
rebuildStateShape: s
|
|
1138
1144
|
}) {
|
|
@@ -1144,7 +1150,7 @@ function Xt({
|
|
|
1144
1150
|
(v, V, I, y, i) => t._mapFn(v, V, I, y, i)
|
|
1145
1151
|
) : null;
|
|
1146
1152
|
}
|
|
1147
|
-
function
|
|
1153
|
+
function Xt({
|
|
1148
1154
|
proxy: t
|
|
1149
1155
|
}) {
|
|
1150
1156
|
const s = J(null), S = `${t._stateKey}-${t._path.join(".")}`;
|
|
@@ -1169,22 +1175,22 @@ function Qt({
|
|
|
1169
1175
|
"state",
|
|
1170
1176
|
`return (${t._effect})(state)`
|
|
1171
1177
|
)(n);
|
|
1172
|
-
} catch (
|
|
1173
|
-
console.error("Error evaluating effect function during mount:",
|
|
1178
|
+
} catch (U) {
|
|
1179
|
+
console.error("Error evaluating effect function during mount:", U), g = n;
|
|
1174
1180
|
}
|
|
1175
1181
|
else
|
|
1176
1182
|
g = n;
|
|
1177
1183
|
g !== null && typeof g == "object" && (g = JSON.stringify(g));
|
|
1178
1184
|
const L = document.createTextNode(String(g));
|
|
1179
1185
|
u.replaceWith(L);
|
|
1180
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1186
|
+
}, [t._stateKey, t._path.join("."), t._effect]), ct("span", {
|
|
1181
1187
|
ref: s,
|
|
1182
1188
|
style: { display: "none" },
|
|
1183
1189
|
"data-signal-id": S
|
|
1184
1190
|
});
|
|
1185
1191
|
}
|
|
1186
|
-
function
|
|
1187
|
-
const s =
|
|
1192
|
+
function fe(t) {
|
|
1193
|
+
const s = Mt(
|
|
1188
1194
|
(S) => {
|
|
1189
1195
|
const u = o.getState().stateComponents.get(t._stateKey) || {
|
|
1190
1196
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1196,15 +1202,15 @@ function Se(t) {
|
|
|
1196
1202
|
},
|
|
1197
1203
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1198
1204
|
);
|
|
1199
|
-
return
|
|
1205
|
+
return ct("text", {}, String(s));
|
|
1200
1206
|
}
|
|
1201
|
-
function
|
|
1207
|
+
function Qt({
|
|
1202
1208
|
stateKey: t,
|
|
1203
1209
|
itemComponentId: s,
|
|
1204
1210
|
itemPath: S,
|
|
1205
1211
|
children: u
|
|
1206
1212
|
}) {
|
|
1207
|
-
const [, v] = ot({}), [V, I] =
|
|
1213
|
+
const [, v] = ot({}), [V, I] = Wt(), y = J(null), i = J(null), h = ft(
|
|
1208
1214
|
(n) => {
|
|
1209
1215
|
V(n), y.current = n;
|
|
1210
1216
|
},
|
|
@@ -1218,7 +1224,7 @@ function Kt({
|
|
|
1218
1224
|
// Store the actual DOM element reference
|
|
1219
1225
|
}
|
|
1220
1226
|
}));
|
|
1221
|
-
}, [I.height, t, S]),
|
|
1227
|
+
}, [I.height, t, S]), xt(() => {
|
|
1222
1228
|
const n = `${t}////${s}`, g = o.getState().stateComponents.get(t) || {
|
|
1223
1229
|
components: /* @__PURE__ */ new Map()
|
|
1224
1230
|
};
|
|
@@ -1229,14 +1235,14 @@ function Kt({
|
|
|
1229
1235
|
const L = o.getState().stateComponents.get(t);
|
|
1230
1236
|
L && L.components.delete(n);
|
|
1231
1237
|
};
|
|
1232
|
-
}, [t, s, S.join(".")]), /* @__PURE__ */
|
|
1238
|
+
}, [t, s, S.join(".")]), /* @__PURE__ */ yt("div", { ref: h, children: u });
|
|
1233
1239
|
}
|
|
1234
1240
|
export {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
+
$t as $cogsSignal,
|
|
1242
|
+
fe as $cogsSignalStore,
|
|
1243
|
+
de as addStateOptions,
|
|
1244
|
+
ue as createCogsState,
|
|
1245
|
+
ge as notifyComponent,
|
|
1246
|
+
Yt as useCogsStateFn
|
|
1241
1247
|
};
|
|
1242
1248
|
//# sourceMappingURL=CogsState.jsx.map
|