cogsbox-state 0.5.418 → 0.5.419
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 +118 -120
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +3 -14
package/dist/CogsState.jsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as It } from "react/jsx-runtime";
|
|
3
|
-
import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as Nt, useMemo as wt, createElement as
|
|
3
|
+
import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as Nt, useMemo as wt, createElement as st, useSyncExternalStore as Ot, startTransition as jt, useCallback as ft } from "react";
|
|
4
4
|
import { transformStateFunc as Ut, isDeepEqual as q, isFunction as K, getNestedValue as Y, getDifferences as pt, debounce as Ft } from "./utility.js";
|
|
5
|
-
import { pushFunc as yt, updateFn as
|
|
5
|
+
import { pushFunc as yt, updateFn as it, cutFunc as gt, ValidationWrapper as Dt, FormControlComponent as Lt } from "./Functions.jsx";
|
|
6
6
|
import Gt from "superjson";
|
|
7
7
|
import { v4 as Et } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
9
|
+
import { getGlobalStore as o, formRefStore as Tt } from "./store.js";
|
|
10
10
|
import { useCogsConfig as Pt } from "./CogsStateClient.jsx";
|
|
11
11
|
import { applyPatch as Wt } from "fast-json-patch";
|
|
12
12
|
import zt from "react-use-measure";
|
|
@@ -52,7 +52,7 @@ const ge = (t, s) => {
|
|
|
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, j] = Zt(
|
|
56
56
|
g,
|
|
57
57
|
{
|
|
58
58
|
stateKey: y,
|
|
@@ -68,10 +68,10 @@ const ge = (t, s) => {
|
|
|
68
68
|
serverState: i?.serverState
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
|
-
return
|
|
71
|
+
return j;
|
|
72
72
|
};
|
|
73
73
|
function I(y, i) {
|
|
74
|
-
Vt({ stateKey: y, options: i, initialOptionsPart: v }), i.localStorage && Jt(y, i),
|
|
74
|
+
Vt({ stateKey: y, options: i, initialOptionsPart: v }), i.localStorage && Jt(y, i), ct(y);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: V, setCogsOptions: I };
|
|
77
77
|
}, {
|
|
@@ -125,7 +125,7 @@ const ge = (t, s) => {
|
|
|
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), ct(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
131
|
}, Rt = (t, s, S, u, v, V) => {
|
|
@@ -140,7 +140,7 @@ const ge = (t, s) => {
|
|
|
140
140
|
state: S
|
|
141
141
|
};
|
|
142
142
|
At(t, I.initialState), St(t, I.updaterState), nt(t, I.state);
|
|
143
|
-
},
|
|
143
|
+
}, ct = (t) => {
|
|
144
144
|
const s = o.getState().stateComponents.get(t);
|
|
145
145
|
if (!s) return;
|
|
146
146
|
const S = /* @__PURE__ */ new Set();
|
|
@@ -193,9 +193,9 @@ function Zt(t, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: g
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [L,
|
|
197
|
-
let
|
|
198
|
-
const [f] = ot(s ?? Et()), l = o.getState().stateLog[f],
|
|
196
|
+
const [L, j] = ot({}), { sessionId: U } = Pt();
|
|
197
|
+
let W = !s;
|
|
198
|
+
const [f] = ot(s ?? Et()), l = o.getState().stateLog[f], lt = J(/* @__PURE__ */ new Set()), tt = J(y ?? Et()), R = J(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
201
|
R.current = rt(f) ?? null, et(() => {
|
|
@@ -220,17 +220,17 @@ function Zt(t, {
|
|
|
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 && U && (m = ht(`${U}-${f}-${k}`));
|
|
224
224
|
let p = i, b = !1;
|
|
225
|
-
const C = a ? Date.now() : 0, P = m?.lastUpdated || 0,
|
|
226
|
-
a && C > P ? (p = e.serverState.data, b = !0) : m && P >
|
|
225
|
+
const C = a ? Date.now() : 0, P = m?.lastUpdated || 0, F = m?.lastSyncedWithServer || 0;
|
|
226
|
+
a && C > P ? (p = e.serverState.data, b = !0) : m && P > F && (p = m.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(f, i), Rt(
|
|
227
227
|
f,
|
|
228
228
|
i,
|
|
229
229
|
p,
|
|
230
230
|
at,
|
|
231
231
|
tt.current,
|
|
232
|
-
|
|
233
|
-
), b && k &&
|
|
232
|
+
U
|
|
233
|
+
), b && k && U && $t(p, f, e, U, Date.now()), ct(f), (Array.isArray(I) ? I : [I || "component"]).includes("none") || j({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
i,
|
|
@@ -238,7 +238,7 @@ function Zt(t, {
|
|
|
238
238
|
g?.data,
|
|
239
239
|
...n || []
|
|
240
240
|
]), Nt(() => {
|
|
241
|
-
|
|
241
|
+
W && bt(f, {
|
|
242
242
|
serverSync: S,
|
|
243
243
|
formElements: v,
|
|
244
244
|
initialState: i,
|
|
@@ -249,19 +249,19 @@ function Zt(t, {
|
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return r.components.set(e, {
|
|
252
|
-
forceUpdate: () =>
|
|
252
|
+
forceUpdate: () => j({}),
|
|
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), j({}), () => {
|
|
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
|
+
lt.current.add(m);
|
|
265
265
|
}
|
|
266
266
|
const w = o.getState();
|
|
267
267
|
nt(f, (m) => {
|
|
@@ -279,14 +279,14 @@ function Zt(t, {
|
|
|
279
279
|
if ($) {
|
|
280
280
|
const x = A ? Y(k, r.slice(0, -1)) : Y(k, r);
|
|
281
281
|
$.forEach(({ parentId: G, position: T, effect: D }) => {
|
|
282
|
-
const
|
|
282
|
+
const M = document.querySelector(
|
|
283
283
|
`[data-parent-id="${G}"]`
|
|
284
284
|
);
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
285
|
+
if (M) {
|
|
286
|
+
const H = Array.from(M.childNodes);
|
|
287
|
+
if (H[T]) {
|
|
288
288
|
const E = D ? new Function("state", `return (${D})(state)`)(x) : x;
|
|
289
|
-
|
|
289
|
+
H[T].textContent = String(E);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
@@ -315,15 +315,15 @@ function Zt(t, {
|
|
|
315
315
|
T
|
|
316
316
|
] of C.components.entries()) {
|
|
317
317
|
let D = !1;
|
|
318
|
-
const
|
|
319
|
-
if (console.log("component", T), !
|
|
320
|
-
if (
|
|
318
|
+
const M = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
|
|
319
|
+
if (console.log("component", T), !M.includes("none")) {
|
|
320
|
+
if (M.includes("all")) {
|
|
321
321
|
T.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (
|
|
325
|
-
for (const
|
|
326
|
-
let E =
|
|
324
|
+
if (M.includes("component") && ((T.paths.has(x) || T.paths.has("")) && (D = !0), !D))
|
|
325
|
+
for (const H of $) {
|
|
326
|
+
let E = H;
|
|
327
327
|
for (; ; ) {
|
|
328
328
|
if (T.paths.has(E)) {
|
|
329
329
|
D = !0;
|
|
@@ -349,10 +349,10 @@ function Zt(t, {
|
|
|
349
349
|
}
|
|
350
350
|
if (D) break;
|
|
351
351
|
}
|
|
352
|
-
if (!D &&
|
|
353
|
-
const
|
|
352
|
+
if (!D && M.includes("deps") && T.depsFunction) {
|
|
353
|
+
const H = T.depsFunction(k);
|
|
354
354
|
let E = !1;
|
|
355
|
-
typeof
|
|
355
|
+
typeof H == "boolean" ? H && (E = !0) : q(T.deps, H) || (T.deps = H, E = !0), E && (D = !0);
|
|
356
356
|
}
|
|
357
357
|
D && T.forceUpdate();
|
|
358
358
|
}
|
|
@@ -363,7 +363,7 @@ function Zt(t, {
|
|
|
363
363
|
const x = r.slice(0, -1), G = Y(k, x);
|
|
364
364
|
return $ === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (G.length - 1).toString() : A;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue:
|
|
366
|
+
const { oldValue: F, newValue: z } = Yt(
|
|
367
367
|
a.updateType,
|
|
368
368
|
m,
|
|
369
369
|
k,
|
|
@@ -374,8 +374,8 @@ function Zt(t, {
|
|
|
374
374
|
path: r,
|
|
375
375
|
updateType: a.updateType,
|
|
376
376
|
status: "new",
|
|
377
|
-
oldValue:
|
|
378
|
-
newValue:
|
|
377
|
+
oldValue: F,
|
|
378
|
+
newValue: z
|
|
379
379
|
};
|
|
380
380
|
switch (a.updateType) {
|
|
381
381
|
case "update":
|
|
@@ -383,7 +383,7 @@ function Zt(t, {
|
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
385
|
const A = r.slice(0, -1);
|
|
386
|
-
w.insertShadowArrayElement(f, A,
|
|
386
|
+
w.insertShadowArrayElement(f, A, z);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
389
|
const $ = r.slice(0, -1), x = parseInt(r[r.length - 1]);
|
|
@@ -392,15 +392,15 @@ function Zt(t, {
|
|
|
392
392
|
}
|
|
393
393
|
if (Bt(f, (A) => {
|
|
394
394
|
const x = [...A ?? [], Q].reduce((G, T) => {
|
|
395
|
-
const D = `${T.stateKey}:${JSON.stringify(T.path)}`,
|
|
396
|
-
return
|
|
395
|
+
const D = `${T.stateKey}:${JSON.stringify(T.path)}`, M = G.get(D);
|
|
396
|
+
return M ? (M.timeStamp = Math.max(M.timeStamp, T.timeStamp), M.newValue = T.newValue, M.oldValue = M.oldValue ?? T.oldValue, M.updateType = T.updateType) : G.set(D, { ...T }), G;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
398
|
return Array.from(x.values());
|
|
399
399
|
}), $t(
|
|
400
400
|
k,
|
|
401
401
|
f,
|
|
402
402
|
R.current,
|
|
403
|
-
|
|
403
|
+
U
|
|
404
404
|
), R.current?.middleware && R.current.middleware({
|
|
405
405
|
updateLog: l,
|
|
406
406
|
update: Q
|
|
@@ -422,15 +422,15 @@ function Zt(t, {
|
|
|
422
422
|
f,
|
|
423
423
|
at,
|
|
424
424
|
tt.current,
|
|
425
|
-
|
|
425
|
+
U
|
|
426
426
|
)
|
|
427
427
|
), o.getState().cogsStateStore[f] || nt(f, t), o.getState().initialStateGlobal[f] || At(f, t));
|
|
428
428
|
const d = wt(() => mt(
|
|
429
429
|
f,
|
|
430
430
|
at,
|
|
431
431
|
tt.current,
|
|
432
|
-
|
|
433
|
-
), [f,
|
|
432
|
+
U
|
|
433
|
+
), [f, U]);
|
|
434
434
|
return [Ct(f), d];
|
|
435
435
|
}
|
|
436
436
|
function mt(t, s, S, u) {
|
|
@@ -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, []), j = rt(t), U = K(j?.localStorage?.key) ? j?.localStorage?.key(g) : j?.localStorage?.key, W = `${u}-${t}-${U}`;
|
|
454
|
+
W && localStorage.removeItem(W), 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(
|
|
467
|
+
), g = o.getState().initialStateGlobal[t], L = rt(t), j = K(L?.localStorage?.key) ? L?.localStorage?.key(g) : L?.localStorage?.key, U = `${u}-${t}-${j}`;
|
|
468
|
+
return localStorage.getItem(U) && localStorage.removeItem(U), jt(() => {
|
|
469
469
|
At(t, h), o.getState().initializeShadowState(t, h), St(t, n), nt(t, h);
|
|
470
|
-
const
|
|
471
|
-
|
|
470
|
+
const W = o.getState().stateComponents.get(t);
|
|
471
|
+
W && W.components.forEach((f) => {
|
|
472
472
|
f.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (W) => n.get()[W]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: o.getState().initialStateGlobal[t],
|
|
@@ -486,21 +486,21 @@ function mt(t, s, S, u) {
|
|
|
486
486
|
function i(h, n = [], g) {
|
|
487
487
|
const L = n.map(String).join(".");
|
|
488
488
|
v.get(L);
|
|
489
|
-
const
|
|
489
|
+
const j = function() {
|
|
490
490
|
return o().getNestedState(t, n);
|
|
491
491
|
};
|
|
492
492
|
Object.keys(y).forEach((f) => {
|
|
493
|
-
|
|
493
|
+
j[f] = y[f];
|
|
494
494
|
});
|
|
495
|
-
const
|
|
496
|
-
apply(f, l,
|
|
495
|
+
const U = {
|
|
496
|
+
apply(f, l, lt) {
|
|
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 lt = /* @__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" && !lt.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);
|
|
@@ -625,7 +625,7 @@ 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, C] = ot(0), P = J(!0),
|
|
628
|
+
}), [b, C] = ot(0), P = J(!0), F = J(0), z = J(!1);
|
|
629
629
|
et(() => o.getState().subscribeToShadowState(t, () => {
|
|
630
630
|
C((N) => N + 1);
|
|
631
631
|
}), [t]);
|
|
@@ -636,10 +636,10 @@ function mt(t, s, S, u) {
|
|
|
636
636
|
const E = o.getState().getShadowMetadata(t, n) || [];
|
|
637
637
|
let N = 0;
|
|
638
638
|
const _ = [];
|
|
639
|
-
for (let
|
|
640
|
-
_[
|
|
641
|
-
const
|
|
642
|
-
N +=
|
|
639
|
+
for (let O = 0; O < A; O++) {
|
|
640
|
+
_[O] = N;
|
|
641
|
+
const B = E[O]?.virtualizer?.itemHeight;
|
|
642
|
+
N += B || r;
|
|
643
643
|
}
|
|
644
644
|
return { totalHeight: N, positions: _ };
|
|
645
645
|
}, [
|
|
@@ -651,9 +651,9 @@ function mt(t, s, S, u) {
|
|
|
651
651
|
]), G = wt(() => {
|
|
652
652
|
const E = Math.max(0, k.startIndex), N = Math.min(A, k.endIndex), _ = Array.from(
|
|
653
653
|
{ length: N - E },
|
|
654
|
-
(
|
|
655
|
-
),
|
|
656
|
-
return i(
|
|
654
|
+
(B, dt) => E + dt
|
|
655
|
+
), O = _.map((B) => Q[B]);
|
|
656
|
+
return i(O, n, {
|
|
657
657
|
...g,
|
|
658
658
|
validIndices: _
|
|
659
659
|
});
|
|
@@ -662,9 +662,9 @@ function mt(t, s, S, u) {
|
|
|
662
662
|
if (N >= 0) {
|
|
663
663
|
const _ = E[N];
|
|
664
664
|
if (_?.virtualizer?.domRef) {
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
return
|
|
665
|
+
const O = _.virtualizer.domRef;
|
|
666
|
+
if (O && O.scrollIntoView)
|
|
667
|
+
return O.scrollIntoView({
|
|
668
668
|
behavior: "auto",
|
|
669
669
|
block: "end",
|
|
670
670
|
inline: "nearest"
|
|
@@ -675,43 +675,41 @@ function mt(t, s, S, u) {
|
|
|
675
675
|
}, [t, n, A]);
|
|
676
676
|
et(() => {
|
|
677
677
|
if (!c || A === 0) return;
|
|
678
|
-
const E = A >
|
|
679
|
-
if ((E || N) && P.current
|
|
678
|
+
const E = A > F.current, N = F.current === 0 && A > 0;
|
|
679
|
+
if ((E || N) && P.current) {
|
|
680
680
|
const _ = Math.ceil(
|
|
681
681
|
(m.current?.clientHeight || 0) / r
|
|
682
|
-
),
|
|
682
|
+
), O = {
|
|
683
683
|
startIndex: Math.max(
|
|
684
684
|
0,
|
|
685
685
|
A - _ - a
|
|
686
686
|
),
|
|
687
687
|
endIndex: A
|
|
688
688
|
};
|
|
689
|
-
p(
|
|
690
|
-
|
|
691
|
-
!T() && m.current && (m.current.scrollTop = m.current.scrollHeight);
|
|
689
|
+
p(O), setTimeout(() => {
|
|
690
|
+
m.current && (m.current.scrollTop = m.current.scrollHeight);
|
|
692
691
|
}, 50);
|
|
693
|
-
return M.current = A, () => clearTimeout(W);
|
|
694
692
|
}
|
|
695
|
-
|
|
693
|
+
F.current = A;
|
|
696
694
|
}, [A]), et(() => {
|
|
697
695
|
const E = m.current;
|
|
698
696
|
if (!E) return;
|
|
699
697
|
const N = () => {
|
|
700
|
-
const { scrollTop: _, scrollHeight:
|
|
701
|
-
P.current = vt, !vt &&
|
|
698
|
+
const { scrollTop: _, scrollHeight: O, clientHeight: B } = E, dt = O - _ - B, vt = dt < 5;
|
|
699
|
+
P.current = vt, !vt && dt > 50 && (z.current = !0), vt && (z.current = !1);
|
|
702
700
|
let ut = 0;
|
|
703
701
|
for (let Z = 0; Z < x.length; Z++)
|
|
704
702
|
if (x[Z] > _ - r * a) {
|
|
705
703
|
ut = Math.max(0, Z - 1);
|
|
706
704
|
break;
|
|
707
705
|
}
|
|
708
|
-
let
|
|
709
|
-
const Mt = _ +
|
|
706
|
+
let kt = ut;
|
|
707
|
+
const Mt = _ + B;
|
|
710
708
|
for (let Z = ut; Z < x.length && !(x[Z] > Mt + r * a); Z++)
|
|
711
|
-
|
|
709
|
+
kt = Z;
|
|
712
710
|
p({
|
|
713
711
|
startIndex: Math.max(0, ut),
|
|
714
|
-
endIndex: Math.min(A,
|
|
712
|
+
endIndex: Math.min(A, kt + 1 + a)
|
|
715
713
|
});
|
|
716
714
|
};
|
|
717
715
|
return E.addEventListener("scroll", N, {
|
|
@@ -722,13 +720,13 @@ function mt(t, s, S, u) {
|
|
|
722
720
|
}, [x, A, r, a, c]);
|
|
723
721
|
const D = ft(() => {
|
|
724
722
|
P.current = !0, !T() && m.current && (m.current.scrollTop = m.current.scrollHeight);
|
|
725
|
-
}, [T]),
|
|
723
|
+
}, [T]), M = ft(
|
|
726
724
|
(E, N = "smooth") => {
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
729
|
-
const
|
|
730
|
-
if (
|
|
731
|
-
|
|
725
|
+
const O = (o.getState().getShadowMetadata(t, n) || [])[E];
|
|
726
|
+
if (O?.virtualizer?.domRef) {
|
|
727
|
+
const B = O.virtualizer.domRef;
|
|
728
|
+
if (B && B.scrollIntoView) {
|
|
729
|
+
B.scrollIntoView({ behavior: N, block: "center" });
|
|
732
730
|
return;
|
|
733
731
|
}
|
|
734
732
|
}
|
|
@@ -738,7 +736,7 @@ function mt(t, s, S, u) {
|
|
|
738
736
|
});
|
|
739
737
|
},
|
|
740
738
|
[x, t, n]
|
|
741
|
-
),
|
|
739
|
+
), H = {
|
|
742
740
|
outer: {
|
|
743
741
|
ref: m,
|
|
744
742
|
style: { overflowY: "auto", height: "100%" }
|
|
@@ -757,9 +755,9 @@ function mt(t, s, S, u) {
|
|
|
757
755
|
};
|
|
758
756
|
return {
|
|
759
757
|
virtualState: G,
|
|
760
|
-
virtualizerProps:
|
|
758
|
+
virtualizerProps: H,
|
|
761
759
|
scrollToBottom: D,
|
|
762
|
-
scrollToIndex:
|
|
760
|
+
scrollToIndex: M
|
|
763
761
|
};
|
|
764
762
|
};
|
|
765
763
|
if (l === "stateMapNoRender")
|
|
@@ -776,7 +774,7 @@ function mt(t, s, S, u) {
|
|
|
776
774
|
);
|
|
777
775
|
});
|
|
778
776
|
if (l === "$stateMap")
|
|
779
|
-
return (e) =>
|
|
777
|
+
return (e) => st(Xt, {
|
|
780
778
|
proxy: {
|
|
781
779
|
_stateKey: t,
|
|
782
780
|
_path: n,
|
|
@@ -790,7 +788,7 @@ function mt(t, s, S, u) {
|
|
|
790
788
|
const r = o.getState().getNestedState(t, n);
|
|
791
789
|
return Array.isArray(r) ? (g?.validIndices || Array.from({ length: r.length }, (c, w) => w)).map((c, w) => {
|
|
792
790
|
const m = r[c], k = [...n, c.toString()], p = i(m, k, g), b = `${S}-${n.join(".")}-${c}`;
|
|
793
|
-
return
|
|
791
|
+
return st(Kt, {
|
|
794
792
|
key: c,
|
|
795
793
|
stateKey: t,
|
|
796
794
|
itemComponentId: b,
|
|
@@ -856,7 +854,7 @@ function mt(t, s, S, u) {
|
|
|
856
854
|
const p = a(m), b = c.map(
|
|
857
855
|
(C) => q(C, m) ? p : C
|
|
858
856
|
);
|
|
859
|
-
I(n),
|
|
857
|
+
I(n), it(s, b, n);
|
|
860
858
|
}
|
|
861
859
|
};
|
|
862
860
|
if (l === "cut")
|
|
@@ -941,7 +939,7 @@ function mt(t, s, S, u) {
|
|
|
941
939
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), a = e.join(".");
|
|
942
940
|
d ? o.getState().setSelectedIndex(t, a, r) : o.getState().setSelectedIndex(t, a, void 0);
|
|
943
941
|
const c = o.getState().getNestedState(t, [...e]);
|
|
944
|
-
|
|
942
|
+
it(s, c, e), I(e);
|
|
945
943
|
};
|
|
946
944
|
if (l === "toggleSelected")
|
|
947
945
|
return () => {
|
|
@@ -952,7 +950,7 @@ function mt(t, s, S, u) {
|
|
|
952
950
|
a === e ? void 0 : e
|
|
953
951
|
);
|
|
954
952
|
const c = o.getState().getNestedState(t, [...d]);
|
|
955
|
-
|
|
953
|
+
it(s, c, d), I(d);
|
|
956
954
|
};
|
|
957
955
|
if (n.length == 0) {
|
|
958
956
|
if (l === "addValidation")
|
|
@@ -963,7 +961,7 @@ function mt(t, s, S, u) {
|
|
|
963
961
|
X(e.key), console.log("addValidationError", d), d.forEach((r) => {
|
|
964
962
|
const a = [e.key, ...r.path].join(".");
|
|
965
963
|
console.log("fullErrorPath", a), _t(a, r.message);
|
|
966
|
-
}),
|
|
964
|
+
}), ct(t);
|
|
967
965
|
};
|
|
968
966
|
if (l === "applyJsonPatch")
|
|
969
967
|
return (d) => {
|
|
@@ -996,20 +994,20 @@ function mt(t, s, S, u) {
|
|
|
996
994
|
b = !0;
|
|
997
995
|
break;
|
|
998
996
|
}
|
|
999
|
-
let
|
|
1000
|
-
for (;
|
|
1001
|
-
const
|
|
1002
|
-
if (p.paths.has(
|
|
997
|
+
let F = P.lastIndexOf(".");
|
|
998
|
+
for (; F !== -1; ) {
|
|
999
|
+
const z = P.substring(0, F);
|
|
1000
|
+
if (p.paths.has(z)) {
|
|
1003
1001
|
b = !0;
|
|
1004
1002
|
break;
|
|
1005
1003
|
}
|
|
1006
1004
|
const Q = P.substring(
|
|
1007
|
-
|
|
1005
|
+
F + 1
|
|
1008
1006
|
);
|
|
1009
1007
|
if (!isNaN(Number(Q))) {
|
|
1010
|
-
const A =
|
|
1008
|
+
const A = z.lastIndexOf(".");
|
|
1011
1009
|
if (A !== -1) {
|
|
1012
|
-
const $ =
|
|
1010
|
+
const $ = z.substring(
|
|
1013
1011
|
0,
|
|
1014
1012
|
A
|
|
1015
1013
|
);
|
|
@@ -1019,14 +1017,14 @@ function mt(t, s, S, u) {
|
|
|
1019
1017
|
}
|
|
1020
1018
|
}
|
|
1021
1019
|
}
|
|
1022
|
-
|
|
1020
|
+
F = z.lastIndexOf(".");
|
|
1023
1021
|
}
|
|
1024
1022
|
if (b) break;
|
|
1025
1023
|
}
|
|
1026
1024
|
if (!b && C.includes("deps") && p.depsFunction) {
|
|
1027
1025
|
const P = p.depsFunction(a);
|
|
1028
|
-
let
|
|
1029
|
-
typeof P == "boolean" ? P && (
|
|
1026
|
+
let F = !1;
|
|
1027
|
+
typeof P == "boolean" ? P && (F = !0) : q(p.deps, P) || (p.deps = P, F = !0), F && (b = !0);
|
|
1030
1028
|
}
|
|
1031
1029
|
b && p.forceUpdate();
|
|
1032
1030
|
}
|
|
@@ -1051,7 +1049,7 @@ function mt(t, s, S, u) {
|
|
|
1051
1049
|
return c.success ? !0 : (c.error.errors.forEach((m) => {
|
|
1052
1050
|
const k = m.path, p = m.message, b = [d.key, ...k].join(".");
|
|
1053
1051
|
e(b, p);
|
|
1054
|
-
}),
|
|
1052
|
+
}), ct(t), !1);
|
|
1055
1053
|
} catch (a) {
|
|
1056
1054
|
return console.error("Zod schema validation failed", a), !1;
|
|
1057
1055
|
}
|
|
@@ -1060,7 +1058,7 @@ function mt(t, s, S, u) {
|
|
|
1060
1058
|
if (l === "getComponents")
|
|
1061
1059
|
return () => o().stateComponents.get(t);
|
|
1062
1060
|
if (l === "getAllFormRefs")
|
|
1063
|
-
return () =>
|
|
1061
|
+
return () => Tt.getState().getFormRefsByStateKey(t);
|
|
1064
1062
|
if (l === "_initialState")
|
|
1065
1063
|
return o.getState().initialStateGlobal[t];
|
|
1066
1064
|
if (l === "_serverState")
|
|
@@ -1073,7 +1071,7 @@ function mt(t, s, S, u) {
|
|
|
1073
1071
|
if (l === "removeValidation") return y.removeValidation;
|
|
1074
1072
|
}
|
|
1075
1073
|
if (l === "getFormRef")
|
|
1076
|
-
return () =>
|
|
1074
|
+
return () => Tt.getState().getFormRef(t + "." + n.join("."));
|
|
1077
1075
|
if (l === "validationWrapper")
|
|
1078
1076
|
return ({
|
|
1079
1077
|
children: d,
|
|
@@ -1096,12 +1094,12 @@ function mt(t, s, S, u) {
|
|
|
1096
1094
|
return (d, e) => {
|
|
1097
1095
|
if (e?.debounce)
|
|
1098
1096
|
Ft(() => {
|
|
1099
|
-
|
|
1097
|
+
it(s, d, n, "");
|
|
1100
1098
|
const r = o.getState().getNestedState(t, n);
|
|
1101
1099
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1102
1100
|
}, e.debounce);
|
|
1103
1101
|
else {
|
|
1104
|
-
|
|
1102
|
+
it(s, d, n, "");
|
|
1105
1103
|
const r = o.getState().getNestedState(t, n);
|
|
1106
1104
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1107
1105
|
}
|
|
@@ -1121,18 +1119,18 @@ function mt(t, s, S, u) {
|
|
|
1121
1119
|
const R = [...n, l], at = o.getState().getNestedState(t, R);
|
|
1122
1120
|
return i(at, R, g);
|
|
1123
1121
|
}
|
|
1124
|
-
},
|
|
1122
|
+
}, W = new Proxy(j, U);
|
|
1125
1123
|
return v.set(L, {
|
|
1126
|
-
proxy:
|
|
1124
|
+
proxy: W,
|
|
1127
1125
|
stateVersion: V
|
|
1128
|
-
}),
|
|
1126
|
+
}), W;
|
|
1129
1127
|
}
|
|
1130
1128
|
return i(
|
|
1131
1129
|
o.getState().getNestedState(t, [])
|
|
1132
1130
|
);
|
|
1133
1131
|
}
|
|
1134
1132
|
function xt(t) {
|
|
1135
|
-
return
|
|
1133
|
+
return st(Qt, { proxy: t });
|
|
1136
1134
|
}
|
|
1137
1135
|
function Xt({
|
|
1138
1136
|
proxy: t,
|
|
@@ -1171,15 +1169,15 @@ function Qt({
|
|
|
1171
1169
|
"state",
|
|
1172
1170
|
`return (${t._effect})(state)`
|
|
1173
1171
|
)(n);
|
|
1174
|
-
} catch (
|
|
1175
|
-
console.error("Error evaluating effect function during mount:",
|
|
1172
|
+
} catch (j) {
|
|
1173
|
+
console.error("Error evaluating effect function during mount:", j), g = n;
|
|
1176
1174
|
}
|
|
1177
1175
|
else
|
|
1178
1176
|
g = n;
|
|
1179
1177
|
g !== null && typeof g == "object" && (g = JSON.stringify(g));
|
|
1180
1178
|
const L = document.createTextNode(String(g));
|
|
1181
1179
|
u.replaceWith(L);
|
|
1182
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1180
|
+
}, [t._stateKey, t._path.join("."), t._effect]), st("span", {
|
|
1183
1181
|
ref: s,
|
|
1184
1182
|
style: { display: "none" },
|
|
1185
1183
|
"data-signal-id": S
|
|
@@ -1198,7 +1196,7 @@ function Se(t) {
|
|
|
1198
1196
|
},
|
|
1199
1197
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1200
1198
|
);
|
|
1201
|
-
return
|
|
1199
|
+
return st("text", {}, String(s));
|
|
1202
1200
|
}
|
|
1203
1201
|
function Kt({
|
|
1204
1202
|
stateKey: t,
|