cogsbox-state 0.5.371 → 0.5.373
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 +237 -237
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +24 -21
package/dist/CogsState.jsx
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import { pushFunc as
|
|
6
|
-
import
|
|
7
|
-
import { v4 as
|
|
2
|
+
import { jsx as ye } from "react/jsx-runtime";
|
|
3
|
+
import { useState as Q, useRef as Z, useEffect as oe, useLayoutEffect as ce, useMemo as pe, createElement as le, useSyncExternalStore as Ge, startTransition as Le, useCallback as Ae } from "react";
|
|
4
|
+
import { transformStateFunc as Re, isDeepEqual as q, isFunction as K, getNestedValue as J, getDifferences as Ee, debounce as De } from "./utility.js";
|
|
5
|
+
import { pushFunc as ve, updateFn as ie, cutFunc as fe, ValidationWrapper as Ue, FormControlComponent as je } from "./Functions.jsx";
|
|
6
|
+
import He from "superjson";
|
|
7
|
+
import { v4 as we } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as r, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
13
|
-
function
|
|
9
|
+
import { getGlobalStore as r, formRefStore as Ne } from "./store.js";
|
|
10
|
+
import { useCogsConfig as xe } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as Fe } from "fast-json-patch";
|
|
12
|
+
import Be from "react-use-measure";
|
|
13
|
+
function Ce(e, i) {
|
|
14
14
|
const m = r.getState().getInitialOptions, g = r.getState().setInitialStateOptions, T = m(e) || {};
|
|
15
15
|
g(e, {
|
|
16
16
|
...T,
|
|
17
17
|
...i
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function $e({
|
|
21
21
|
stateKey: e,
|
|
22
22
|
options: i,
|
|
23
23
|
initialOptionsPart: m
|
|
24
24
|
}) {
|
|
25
|
-
const g =
|
|
25
|
+
const g = re(e) || {}, T = m[e] || {}, C = r.getState().setInitialStateOptions, p = { ...T, ...g };
|
|
26
26
|
let v = !1;
|
|
27
27
|
if (i)
|
|
28
28
|
for (const a in i)
|
|
@@ -30,12 +30,12 @@ function Ce({
|
|
|
30
30
|
!q(p[a], i[a]) && (v = !0, p[a] = i[a])) : (v = !0, p[a] = i[a]);
|
|
31
31
|
v && C(e, p);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function gt(e, { formElements: i, validation: m }) {
|
|
34
34
|
return { initialState: e, formElements: i, validation: m };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const ft = (e, i) => {
|
|
37
37
|
let m = e;
|
|
38
|
-
const [g, T] =
|
|
38
|
+
const [g, T] = Re(m);
|
|
39
39
|
(Object.keys(T).length > 0 || i && Object.keys(i).length > 0) && Object.keys(T).forEach((v) => {
|
|
40
40
|
T[v] = T[v] || {}, T[v].formElements = {
|
|
41
41
|
...i?.formElements,
|
|
@@ -43,16 +43,16 @@ const gt = (e, i) => {
|
|
|
43
43
|
...i?.validation,
|
|
44
44
|
...T[v].formElements || {}
|
|
45
45
|
// State-specific overrides
|
|
46
|
-
},
|
|
46
|
+
}, re(v) || r.getState().setInitialStateOptions(v, T[v]);
|
|
47
47
|
}), r.getState().setInitialStates(g), r.getState().setCreatedState(g);
|
|
48
48
|
const C = (v, a) => {
|
|
49
|
-
const [h] =
|
|
50
|
-
|
|
49
|
+
const [h] = Q(a?.componentId ?? we());
|
|
50
|
+
$e({
|
|
51
51
|
stateKey: v,
|
|
52
52
|
options: a,
|
|
53
53
|
initialOptionsPart: T
|
|
54
54
|
});
|
|
55
|
-
const n = r.getState().cogsStateStore[v] || g[v], S = a?.modifyState ? a.modifyState(n) : n, [
|
|
55
|
+
const n = r.getState().cogsStateStore[v] || g[v], S = a?.modifyState ? a.modifyState(n) : n, [H, G] = Xe(
|
|
56
56
|
S,
|
|
57
57
|
{
|
|
58
58
|
stateKey: v,
|
|
@@ -71,28 +71,28 @@ const gt = (e, i) => {
|
|
|
71
71
|
return G;
|
|
72
72
|
};
|
|
73
73
|
function p(v, a) {
|
|
74
|
-
|
|
74
|
+
$e({ stateKey: v, options: a, initialOptionsPart: T }), a.localStorage && Ye(v, a), he(v);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: C, setCogsOptions: p };
|
|
77
77
|
}, {
|
|
78
78
|
setUpdaterState: Se,
|
|
79
79
|
setState: ne,
|
|
80
|
-
getInitialOptions:
|
|
80
|
+
getInitialOptions: re,
|
|
81
81
|
getKeyState: Me,
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
86
|
-
removeValidationError:
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = r.getState(),
|
|
82
|
+
getValidationErrors: We,
|
|
83
|
+
setStateLog: ze,
|
|
84
|
+
updateInitialStateGlobal: _e,
|
|
85
|
+
addValidationError: qe,
|
|
86
|
+
removeValidationError: X,
|
|
87
|
+
setServerSyncActions: Je
|
|
88
|
+
} = r.getState(), ke = (e, i, m, g, T) => {
|
|
89
89
|
m?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
91
91
|
i,
|
|
92
92
|
m.localStorage?.key,
|
|
93
93
|
g
|
|
94
94
|
);
|
|
95
|
-
const C =
|
|
95
|
+
const C = K(m?.localStorage?.key) ? m.localStorage?.key(e) : m?.localStorage?.key;
|
|
96
96
|
if (C && g) {
|
|
97
97
|
const p = `${g}-${i}-${C}`;
|
|
98
98
|
let v;
|
|
@@ -104,7 +104,7 @@ const gt = (e, i) => {
|
|
|
104
104
|
state: e,
|
|
105
105
|
lastUpdated: Date.now(),
|
|
106
106
|
lastSyncedWithServer: T ?? v
|
|
107
|
-
}, h =
|
|
107
|
+
}, h = He.serialize(a);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
p,
|
|
110
110
|
JSON.stringify(h.json)
|
|
@@ -118,8 +118,8 @@ const gt = (e, i) => {
|
|
|
118
118
|
} catch (i) {
|
|
119
119
|
return console.error("Error loading from localStorage:", i), null;
|
|
120
120
|
}
|
|
121
|
-
},
|
|
122
|
-
const m = r.getState().cogsStateStore[e], { sessionId: g } =
|
|
121
|
+
}, Ye = (e, i) => {
|
|
122
|
+
const m = r.getState().cogsStateStore[e], { sessionId: g } = xe(), T = K(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
|
|
123
123
|
if (T && g) {
|
|
124
124
|
const C = Ie(
|
|
125
125
|
`${g}-${e}-${T}`
|
|
@@ -128,7 +128,7 @@ const gt = (e, i) => {
|
|
|
128
128
|
return ne(e, C.state), he(e), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, Pe = (e, i, m, g, T, C) => {
|
|
132
132
|
const p = {
|
|
133
133
|
initialState: i,
|
|
134
134
|
updaterState: me(
|
|
@@ -139,7 +139,7 @@ const gt = (e, i) => {
|
|
|
139
139
|
),
|
|
140
140
|
state: m
|
|
141
141
|
};
|
|
142
|
-
|
|
142
|
+
_e(e, p.initialState), Se(e, p.updaterState), ne(e, p.state);
|
|
143
143
|
}, he = (e) => {
|
|
144
144
|
const i = r.getState().stateComponents.get(e);
|
|
145
145
|
if (!i) return;
|
|
@@ -149,7 +149,7 @@ const gt = (e, i) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
m.forEach((g) => g());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, St = (e, i) => {
|
|
153
153
|
const m = r.getState().stateComponents.get(e);
|
|
154
154
|
if (m) {
|
|
155
155
|
const g = `${e}////${i}`, T = m.components.get(g);
|
|
@@ -157,7 +157,7 @@ const gt = (e, i) => {
|
|
|
157
157
|
return;
|
|
158
158
|
T && T.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Ze = (e, i, m, g) => {
|
|
161
161
|
switch (e) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
@@ -180,7 +180,7 @@ const gt = (e, i) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Xe(e, {
|
|
184
184
|
stateKey: i,
|
|
185
185
|
serverSync: m,
|
|
186
186
|
localStorage: g,
|
|
@@ -193,12 +193,12 @@ function Ze(e, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: S
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
197
|
-
let
|
|
198
|
-
const [I] =
|
|
196
|
+
const [H, G] = Q({}), { sessionId: L } = xe();
|
|
197
|
+
let F = !i;
|
|
198
|
+
const [I] = Q(i ?? we()), l = r.getState().stateLog[I], de = Z(/* @__PURE__ */ new Set()), ee = Z(v ?? we()), P = Z(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
|
-
P.current =
|
|
201
|
+
P.current = re(I) ?? null, oe(() => {
|
|
202
202
|
if (h && h.stateKey === I && h.path?.[0]) {
|
|
203
203
|
ne(I, (o) => ({
|
|
204
204
|
...o,
|
|
@@ -210,27 +210,27 @@ function Ze(e, {
|
|
|
210
210
|
userId: h.userId
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
}, [h]),
|
|
213
|
+
}, [h]), oe(() => {
|
|
214
214
|
if (a) {
|
|
215
|
-
|
|
215
|
+
Ce(I, {
|
|
216
216
|
initialState: a
|
|
217
217
|
});
|
|
218
218
|
const t = P.current, s = t?.serverState?.id !== void 0 && t?.serverState?.status === "success" && t?.serverState?.data, c = r.getState().initialStateGlobal[I];
|
|
219
219
|
if (!(c && !q(c, a) || !c) && !s)
|
|
220
220
|
return;
|
|
221
221
|
let u = null;
|
|
222
|
-
const E =
|
|
222
|
+
const E = K(t?.localStorage?.key) ? t?.localStorage?.key(a) : t?.localStorage?.key;
|
|
223
223
|
E && L && (u = Ie(`${L}-${I}-${E}`));
|
|
224
224
|
let y = a, O = !1;
|
|
225
|
-
const
|
|
226
|
-
s &&
|
|
225
|
+
const k = s ? Date.now() : 0, A = u?.lastUpdated || 0, x = u?.lastSyncedWithServer || 0;
|
|
226
|
+
s && k > A ? (y = t.serverState.data, O = !0) : u && A > x && (y = u.state, t?.localStorage?.onChange && t?.localStorage?.onChange(y)), r.getState().initializeShadowState(I, a), Pe(
|
|
227
227
|
I,
|
|
228
228
|
a,
|
|
229
229
|
y,
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
ae,
|
|
231
|
+
ee.current,
|
|
232
232
|
L
|
|
233
|
-
), O && E && L &&
|
|
233
|
+
), O && E && L && ke(y, I, t, L, Date.now()), he(I), (Array.isArray(p) ? p : [p || "component"]).includes("none") || G({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
a,
|
|
@@ -238,14 +238,14 @@ function Ze(e, {
|
|
|
238
238
|
S?.data,
|
|
239
239
|
...n || []
|
|
240
240
|
]), ce(() => {
|
|
241
|
-
|
|
241
|
+
F && Ce(I, {
|
|
242
242
|
serverSync: m,
|
|
243
243
|
formElements: T,
|
|
244
244
|
initialState: a,
|
|
245
245
|
localStorage: g,
|
|
246
246
|
middleware: P.current?.middleware
|
|
247
247
|
});
|
|
248
|
-
const t = `${I}////${
|
|
248
|
+
const t = `${I}////${ee.current}`, o = r.getState().stateComponents.get(I) || {
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return o.components.set(t, {
|
|
@@ -258,26 +258,26 @@ function Ze(e, {
|
|
|
258
258
|
o && (o.components.delete(t), o.components.size === 0 && r.getState().stateComponents.delete(I));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
261
|
-
const
|
|
261
|
+
const ae = (t, o, s, c) => {
|
|
262
262
|
if (Array.isArray(o)) {
|
|
263
263
|
const u = `${I}-${o.join(".")}`;
|
|
264
264
|
de.current.add(u);
|
|
265
265
|
}
|
|
266
266
|
const f = r.getState();
|
|
267
267
|
ne(I, (u) => {
|
|
268
|
-
const E =
|
|
268
|
+
const E = K(t) ? t(u) : t, y = `${I}-${o.join(".")}`;
|
|
269
269
|
if (y) {
|
|
270
|
-
let
|
|
270
|
+
let M = !1, N = f.signalDomElements.get(y);
|
|
271
271
|
if ((!N || N.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
|
|
272
272
|
const _ = o.slice(0, -1), j = J(E, _);
|
|
273
273
|
if (Array.isArray(j)) {
|
|
274
|
-
|
|
274
|
+
M = !0;
|
|
275
275
|
const w = `${I}-${_.join(".")}`;
|
|
276
276
|
N = f.signalDomElements.get(w);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
if (N) {
|
|
280
|
-
const _ =
|
|
280
|
+
const _ = M ? J(E, o.slice(0, -1)) : J(E, o);
|
|
281
281
|
N.forEach(({ parentId: j, position: w, effect: R }) => {
|
|
282
282
|
const V = document.querySelector(
|
|
283
283
|
`[data-parent-id="${j}"]`
|
|
@@ -292,28 +292,28 @@ function Ze(e, {
|
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
console.log("shadowState", f.shadowStateStore), s.updateType === "update" && (c || P.current?.validation?.key) && o &&
|
|
295
|
+
console.log("shadowState", f.shadowStateStore), s.updateType === "update" && (c || P.current?.validation?.key) && o && X(
|
|
296
296
|
(c || P.current?.validation?.key) + "." + o.join(".")
|
|
297
297
|
);
|
|
298
298
|
const O = o.slice(0, o.length - 1);
|
|
299
|
-
s.updateType === "cut" && P.current?.validation?.key &&
|
|
299
|
+
s.updateType === "cut" && P.current?.validation?.key && X(
|
|
300
300
|
P.current?.validation?.key + "." + O.join(".")
|
|
301
|
-
), s.updateType === "insert" && P.current?.validation?.key &&
|
|
301
|
+
), s.updateType === "insert" && P.current?.validation?.key && We(
|
|
302
302
|
P.current?.validation?.key + "." + O.join(".")
|
|
303
303
|
).filter(([N, _]) => {
|
|
304
304
|
let j = N?.split(".").length;
|
|
305
305
|
if (N == O.join(".") && j == O.length - 1) {
|
|
306
306
|
let w = N + "." + O;
|
|
307
|
-
|
|
307
|
+
X(N), qe(w, _);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
310
|
+
const k = f.stateComponents.get(I);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", k), k) {
|
|
312
|
+
const M = Ee(u, E), N = new Set(M), _ = s.updateType === "update" ? o.join(".") : o.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
314
|
j,
|
|
315
315
|
w
|
|
316
|
-
] of
|
|
316
|
+
] of k.components.entries()) {
|
|
317
317
|
let R = !1;
|
|
318
318
|
const V = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
|
|
319
319
|
if (console.log("component", w), !V.includes("none")) {
|
|
@@ -329,14 +329,14 @@ function Ze(e, {
|
|
|
329
329
|
R = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
332
|
+
const $ = D.lastIndexOf(".");
|
|
333
|
+
if ($ !== -1) {
|
|
334
334
|
const b = D.substring(
|
|
335
335
|
0,
|
|
336
|
-
|
|
336
|
+
$
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
|
-
Number(D.substring(
|
|
339
|
+
Number(D.substring($ + 1))
|
|
340
340
|
) && w.paths.has(b)) {
|
|
341
341
|
R = !0;
|
|
342
342
|
break;
|
|
@@ -359,11 +359,11 @@ function Ze(e, {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
const A = Date.now();
|
|
362
|
-
o = o.map((
|
|
362
|
+
o = o.map((M, N) => {
|
|
363
363
|
const _ = o.slice(0, -1), j = J(E, _);
|
|
364
|
-
return N === o.length - 1 && ["insert", "cut"].includes(s.updateType) ? (j.length - 1).toString() :
|
|
364
|
+
return N === o.length - 1 && ["insert", "cut"].includes(s.updateType) ? (j.length - 1).toString() : M;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue:
|
|
366
|
+
const { oldValue: x, newValue: U } = Ze(
|
|
367
367
|
s.updateType,
|
|
368
368
|
u,
|
|
369
369
|
E,
|
|
@@ -374,7 +374,7 @@ function Ze(e, {
|
|
|
374
374
|
path: o,
|
|
375
375
|
updateType: s.updateType,
|
|
376
376
|
status: "new",
|
|
377
|
-
oldValue:
|
|
377
|
+
oldValue: x,
|
|
378
378
|
newValue: U
|
|
379
379
|
};
|
|
380
380
|
switch (s.updateType) {
|
|
@@ -382,21 +382,21 @@ function Ze(e, {
|
|
|
382
382
|
f.updateShadowAtPath(I, o, E);
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
f.insertShadowArrayElement(I,
|
|
385
|
+
const M = o.slice(0, -1);
|
|
386
|
+
f.insertShadowArrayElement(I, M, U);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
389
|
const N = o.slice(0, -1), _ = parseInt(o[o.length - 1]);
|
|
390
390
|
f.removeShadowArrayElement(I, N, _);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const _ = [...
|
|
393
|
+
if (ze(I, (M) => {
|
|
394
|
+
const _ = [...M ?? [], Y].reduce((j, w) => {
|
|
395
395
|
const R = `${w.stateKey}:${JSON.stringify(w.path)}`, V = j.get(R);
|
|
396
396
|
return V ? (V.timeStamp = Math.max(V.timeStamp, w.timeStamp), V.newValue = w.newValue, V.oldValue = V.oldValue ?? w.oldValue, V.updateType = w.updateType) : j.set(R, { ...w }), j;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
398
|
return Array.from(_.values());
|
|
399
|
-
}),
|
|
399
|
+
}), ke(
|
|
400
400
|
E,
|
|
401
401
|
I,
|
|
402
402
|
P.current,
|
|
@@ -405,10 +405,10 @@ function Ze(e, {
|
|
|
405
405
|
updateLog: l,
|
|
406
406
|
update: Y
|
|
407
407
|
}), P.current?.serverSync) {
|
|
408
|
-
const
|
|
409
|
-
|
|
408
|
+
const M = f.serverState[I], N = P.current?.serverSync;
|
|
409
|
+
Je(I, {
|
|
410
410
|
syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: E }),
|
|
411
|
-
rollBackState:
|
|
411
|
+
rollBackState: M,
|
|
412
412
|
actionTimeStamp: Date.now() + (N.debounce ?? 3e3),
|
|
413
413
|
status: "waiting"
|
|
414
414
|
});
|
|
@@ -420,15 +420,15 @@ function Ze(e, {
|
|
|
420
420
|
I,
|
|
421
421
|
me(
|
|
422
422
|
I,
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
ae,
|
|
424
|
+
ee.current,
|
|
425
425
|
L
|
|
426
426
|
)
|
|
427
|
-
), r.getState().cogsStateStore[I] || ne(I, e), r.getState().initialStateGlobal[I] ||
|
|
428
|
-
const d =
|
|
427
|
+
), r.getState().cogsStateStore[I] || ne(I, e), r.getState().initialStateGlobal[I] || _e(I, e));
|
|
428
|
+
const d = pe(() => me(
|
|
429
429
|
I,
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
ae,
|
|
431
|
+
ee.current,
|
|
432
432
|
L
|
|
433
433
|
), [I, L]);
|
|
434
434
|
return [Me(I), d];
|
|
@@ -443,15 +443,15 @@ function me(e, i, m, g) {
|
|
|
443
443
|
C++;
|
|
444
444
|
}, v = {
|
|
445
445
|
removeValidation: (h) => {
|
|
446
|
-
h?.validationKey &&
|
|
446
|
+
h?.validationKey && X(h.validationKey);
|
|
447
447
|
},
|
|
448
448
|
revertToInitialState: (h) => {
|
|
449
449
|
const n = r.getState().getInitialOptions(e)?.validation;
|
|
450
|
-
n?.key &&
|
|
450
|
+
n?.key && X(n?.key), h?.validationKey && X(h.validationKey);
|
|
451
451
|
const S = r.getState().initialStateGlobal[e];
|
|
452
452
|
r.getState().clearSelectedIndexesForState(e), T.clear(), C++;
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const H = a(S, []), G = re(e), L = K(G?.localStorage?.key) ? G?.localStorage?.key(S) : G?.localStorage?.key, F = `${g}-${e}-${L}`;
|
|
454
|
+
F && localStorage.removeItem(F), Se(e, H), ne(e, S);
|
|
455
455
|
const I = r.getState().stateComponents.get(e);
|
|
456
456
|
return I && I.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -464,15 +464,15 @@ function me(e, i, m, g) {
|
|
|
464
464
|
i,
|
|
465
465
|
m,
|
|
466
466
|
g
|
|
467
|
-
), S = r.getState().initialStateGlobal[e],
|
|
468
|
-
return localStorage.getItem(L) && localStorage.removeItem(L),
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
467
|
+
), S = r.getState().initialStateGlobal[e], H = re(e), G = K(H?.localStorage?.key) ? H?.localStorage?.key(S) : H?.localStorage?.key, L = `${g}-${e}-${G}`;
|
|
468
|
+
return localStorage.getItem(L) && localStorage.removeItem(L), Le(() => {
|
|
469
|
+
_e(e, h), r.getState().initializeShadowState(e, h), Se(e, n), ne(e, h);
|
|
470
|
+
const F = r.getState().stateComponents.get(e);
|
|
471
|
+
F && F.components.forEach((I) => {
|
|
472
472
|
I.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (F) => n.get()[F]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: r.getState().initialStateGlobal[e],
|
|
@@ -484,8 +484,8 @@ function me(e, i, m, g) {
|
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(h, n = [], S) {
|
|
487
|
-
const
|
|
488
|
-
T.get(
|
|
487
|
+
const H = n.map(String).join(".");
|
|
488
|
+
T.get(H);
|
|
489
489
|
const G = function() {
|
|
490
490
|
return r().getNestedState(e, n);
|
|
491
491
|
};
|
|
@@ -540,7 +540,7 @@ function me(e, i, m, g) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => Ee(
|
|
544
544
|
r.getState().cogsStateStore[e],
|
|
545
545
|
r.getState().initialStateGlobal[e]
|
|
546
546
|
);
|
|
@@ -581,7 +581,7 @@ function me(e, i, m, g) {
|
|
|
581
581
|
};
|
|
582
582
|
if (l === "removeStorage")
|
|
583
583
|
return () => {
|
|
584
|
-
const d = r.getState().initialStateGlobal[e], t =
|
|
584
|
+
const d = r.getState().initialStateGlobal[e], t = re(e), o = K(t?.localStorage?.key) ? t?.localStorage?.key(d) : t?.localStorage?.key, s = `${g}-${e}-${o}`;
|
|
585
585
|
s && localStorage.removeItem(s);
|
|
586
586
|
};
|
|
587
587
|
if (l === "showValidationErrors")
|
|
@@ -622,131 +622,131 @@ function me(e, i, m, g) {
|
|
|
622
622
|
overscan: s = 6,
|
|
623
623
|
stickToBottom: c = !1,
|
|
624
624
|
dependencies: f = []
|
|
625
|
-
} = t, u =
|
|
625
|
+
} = t, u = Z(!1), E = Z(null), [y, O] = Q({
|
|
626
626
|
startIndex: 0,
|
|
627
627
|
endIndex: 10
|
|
628
|
-
}), [
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
}), [k, A] = Q("IDLE_AT_TOP"), x = Z(0), U = Z(f), [Y, M] = Q(0);
|
|
629
|
+
oe(() => r.getState().subscribeToShadowState(e, () => {
|
|
630
|
+
M((b) => b + 1);
|
|
631
631
|
}), [e]);
|
|
632
632
|
const N = r().getNestedState(
|
|
633
633
|
e,
|
|
634
634
|
n
|
|
635
|
-
), _ = N.length, { totalHeight: j, positions: w } =
|
|
636
|
-
const
|
|
635
|
+
), _ = N.length, { totalHeight: j, positions: w } = pe(() => {
|
|
636
|
+
const $ = r.getState().getShadowMetadata(e, n) || [];
|
|
637
637
|
let b = 0;
|
|
638
|
-
const
|
|
639
|
-
for (let
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
b +=
|
|
638
|
+
const z = [];
|
|
639
|
+
for (let B = 0; B < _; B++) {
|
|
640
|
+
z[B] = b;
|
|
641
|
+
const te = $[B]?.virtualizer?.itemHeight;
|
|
642
|
+
b += te || o;
|
|
643
643
|
}
|
|
644
|
-
return { totalHeight: b, positions:
|
|
644
|
+
return { totalHeight: b, positions: z };
|
|
645
645
|
}, [
|
|
646
646
|
_,
|
|
647
647
|
e,
|
|
648
648
|
n.join("."),
|
|
649
649
|
o,
|
|
650
650
|
Y
|
|
651
|
-
]), R =
|
|
652
|
-
const
|
|
653
|
-
{ length: b -
|
|
654
|
-
(
|
|
655
|
-
),
|
|
656
|
-
return a(
|
|
651
|
+
]), R = pe(() => {
|
|
652
|
+
const $ = Math.max(0, y.startIndex), b = Math.min(_, y.endIndex), z = Array.from(
|
|
653
|
+
{ length: b - $ },
|
|
654
|
+
(te, se) => $ + se
|
|
655
|
+
), B = z.map((te) => N[te]);
|
|
656
|
+
return a(B, n, {
|
|
657
657
|
...S,
|
|
658
|
-
validIndices:
|
|
658
|
+
validIndices: z
|
|
659
659
|
});
|
|
660
660
|
}, [y.startIndex, y.endIndex, N, _]);
|
|
661
661
|
ce(() => {
|
|
662
|
-
const
|
|
662
|
+
const $ = !q(
|
|
663
663
|
f,
|
|
664
664
|
U.current
|
|
665
|
-
), b = _ >
|
|
666
|
-
if (
|
|
665
|
+
), b = _ > x.current;
|
|
666
|
+
if ($) {
|
|
667
667
|
console.log("TRANSITION: Deps changed -> IDLE_AT_TOP"), A("IDLE_AT_TOP");
|
|
668
668
|
return;
|
|
669
669
|
}
|
|
670
|
-
b &&
|
|
670
|
+
b && k === "LOCKED_AT_BOTTOM" && c && (console.log(
|
|
671
671
|
"TRANSITION: New items arrived while locked -> GETTING_HEIGHTS"
|
|
672
|
-
), A("GETTING_HEIGHTS")),
|
|
672
|
+
), A("GETTING_HEIGHTS")), x.current = _, U.current = f;
|
|
673
673
|
}, [_, ...f]), ce(() => {
|
|
674
|
-
const
|
|
675
|
-
if (
|
|
674
|
+
const $ = E.current;
|
|
675
|
+
if (!$) return;
|
|
676
676
|
let b;
|
|
677
|
-
if (
|
|
677
|
+
if (k === "IDLE_AT_TOP" && c && _ > 0)
|
|
678
678
|
console.log(
|
|
679
679
|
"ACTION (IDLE_AT_TOP): Data has arrived -> GETTING_HEIGHTS"
|
|
680
680
|
), A("GETTING_HEIGHTS");
|
|
681
|
-
else if (
|
|
681
|
+
else if (k === "GETTING_HEIGHTS")
|
|
682
682
|
console.log(
|
|
683
683
|
"ACTION (GETTING_HEIGHTS): Setting range to end and starting loop."
|
|
684
684
|
), O({
|
|
685
685
|
startIndex: Math.max(0, _ - 10 - s),
|
|
686
686
|
endIndex: _
|
|
687
687
|
}), b = setInterval(() => {
|
|
688
|
-
const
|
|
689
|
-
((r.getState().getShadowMetadata(e, n) || [])[
|
|
688
|
+
const z = _ - 1;
|
|
689
|
+
((r.getState().getShadowMetadata(e, n) || [])[z]?.virtualizer?.itemHeight || 0) > 0 && (clearInterval(b), u.current || (console.log(
|
|
690
690
|
"ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
|
|
691
|
-
), A("SCROLLING_TO_BOTTOM"));
|
|
691
|
+
), A("SCROLLING_TO_BOTTOM")));
|
|
692
692
|
}, 100);
|
|
693
|
-
else if (
|
|
693
|
+
else if (k === "SCROLLING_TO_BOTTOM") {
|
|
694
694
|
console.log(
|
|
695
695
|
"ACTION (SCROLLING_TO_BOTTOM): Executing scroll."
|
|
696
696
|
);
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
top:
|
|
700
|
-
behavior:
|
|
697
|
+
const z = x.current === 0 ? "auto" : "smooth";
|
|
698
|
+
$.scrollTo({
|
|
699
|
+
top: $.scrollHeight,
|
|
700
|
+
behavior: z
|
|
701
701
|
});
|
|
702
|
-
const
|
|
702
|
+
const B = setTimeout(
|
|
703
703
|
() => {
|
|
704
704
|
console.log(
|
|
705
705
|
"ACTION (SCROLLING_TO_BOTTOM): Scroll finished -> LOCKED_AT_BOTTOM"
|
|
706
706
|
), u.current = !1, A("LOCKED_AT_BOTTOM");
|
|
707
707
|
},
|
|
708
|
-
|
|
708
|
+
z === "smooth" ? 500 : 50
|
|
709
709
|
);
|
|
710
|
-
return () => clearTimeout(
|
|
710
|
+
return () => clearTimeout(B);
|
|
711
711
|
}
|
|
712
712
|
return () => {
|
|
713
713
|
b && clearInterval(b);
|
|
714
714
|
};
|
|
715
|
-
}, [
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
715
|
+
}, [k, _, w]), oe(() => {
|
|
716
|
+
const $ = E.current;
|
|
717
|
+
if (!$) return;
|
|
718
718
|
const b = () => {
|
|
719
|
-
|
|
719
|
+
$.scrollHeight - $.scrollTop - $.clientHeight < 1 ? u.current = !1 : (console.log(
|
|
720
720
|
"USER ACTION: Scrolled up -> IDLE_NOT_AT_BOTTOM"
|
|
721
|
-
), u.current = !0, A("IDLE_NOT_AT_BOTTOM"))
|
|
722
|
-
const { scrollTop:
|
|
723
|
-
let
|
|
724
|
-
for (;
|
|
725
|
-
const
|
|
726
|
-
w[
|
|
721
|
+
), u.current = !0, A("IDLE_NOT_AT_BOTTOM"));
|
|
722
|
+
const { scrollTop: B, clientHeight: te } = $;
|
|
723
|
+
let se = 0, ue = _ - 1;
|
|
724
|
+
for (; se <= ue; ) {
|
|
725
|
+
const Te = Math.floor((se + ue) / 2);
|
|
726
|
+
w[Te] < B ? se = Te + 1 : ue = Te - 1;
|
|
727
727
|
}
|
|
728
|
-
const
|
|
729
|
-
let
|
|
730
|
-
const
|
|
731
|
-
for (;
|
|
732
|
-
|
|
728
|
+
const Oe = Math.max(0, ue - s);
|
|
729
|
+
let ge = Oe;
|
|
730
|
+
const Ve = B + te;
|
|
731
|
+
for (; ge < _ && w[ge] < Ve; )
|
|
732
|
+
ge++;
|
|
733
733
|
O({
|
|
734
|
-
startIndex:
|
|
735
|
-
endIndex: Math.min(_,
|
|
734
|
+
startIndex: Oe,
|
|
735
|
+
endIndex: Math.min(_, ge + s)
|
|
736
736
|
});
|
|
737
737
|
};
|
|
738
|
-
return
|
|
738
|
+
return $.addEventListener("scroll", b, {
|
|
739
739
|
passive: !0
|
|
740
|
-
}), () =>
|
|
741
|
-
}, [_, w,
|
|
742
|
-
const V =
|
|
740
|
+
}), () => $.removeEventListener("scroll", b);
|
|
741
|
+
}, [_, w, k]);
|
|
742
|
+
const V = Ae(() => {
|
|
743
743
|
console.log(
|
|
744
744
|
"USER ACTION: Clicked scroll button -> SCROLLING_TO_BOTTOM"
|
|
745
745
|
), A("SCROLLING_TO_BOTTOM");
|
|
746
|
-
}, []), W =
|
|
747
|
-
(
|
|
748
|
-
E.current && w[
|
|
749
|
-
top: w[
|
|
746
|
+
}, []), W = Ae(
|
|
747
|
+
($, b = "smooth") => {
|
|
748
|
+
E.current && w[$] !== void 0 && (A("IDLE_NOT_AT_BOTTOM"), E.current.scrollTo({
|
|
749
|
+
top: w[$],
|
|
750
750
|
behavior: b
|
|
751
751
|
}));
|
|
752
752
|
},
|
|
@@ -806,17 +806,17 @@ function me(e, i, m, g) {
|
|
|
806
806
|
const u = o[c], E = [...n, c.toString()], y = a(u, E, S);
|
|
807
807
|
return t(u, y, {
|
|
808
808
|
register: () => {
|
|
809
|
-
const [,
|
|
809
|
+
const [, k] = Q({}), A = `${m}-${n.join(".")}-${c}`;
|
|
810
810
|
ce(() => {
|
|
811
|
-
const
|
|
811
|
+
const x = `${e}////${A}`, U = r.getState().stateComponents.get(e) || {
|
|
812
812
|
components: /* @__PURE__ */ new Map()
|
|
813
813
|
};
|
|
814
|
-
return U.components.set(
|
|
815
|
-
forceUpdate: () =>
|
|
814
|
+
return U.components.set(x, {
|
|
815
|
+
forceUpdate: () => k({}),
|
|
816
816
|
paths: /* @__PURE__ */ new Set([E.join(".")])
|
|
817
817
|
}), r.getState().stateComponents.set(e, U), () => {
|
|
818
818
|
const Y = r.getState().stateComponents.get(e);
|
|
819
|
-
Y && Y.components.delete(
|
|
819
|
+
Y && Y.components.delete(x);
|
|
820
820
|
};
|
|
821
821
|
}, [e, A]);
|
|
822
822
|
},
|
|
@@ -842,7 +842,7 @@ function me(e, i, m, g) {
|
|
|
842
842
|
);
|
|
843
843
|
});
|
|
844
844
|
if (l === "$stateMap")
|
|
845
|
-
return (t) => le(
|
|
845
|
+
return (t) => le(Qe, {
|
|
846
846
|
proxy: {
|
|
847
847
|
_stateKey: e,
|
|
848
848
|
_path: n,
|
|
@@ -856,7 +856,7 @@ function me(e, i, m, g) {
|
|
|
856
856
|
const o = r.getState().getNestedState(e, n);
|
|
857
857
|
return Array.isArray(o) ? (S?.validIndices || Array.from({ length: o.length }, (c, f) => f)).map((c, f) => {
|
|
858
858
|
const u = o[c], E = [...n, c.toString()], y = a(u, E, S), O = `${m}-${n.join(".")}-${c}`;
|
|
859
|
-
return le(
|
|
859
|
+
return le(et, {
|
|
860
860
|
key: c,
|
|
861
861
|
stateKey: e,
|
|
862
862
|
itemComponentId: O,
|
|
@@ -899,28 +899,28 @@ function me(e, i, m, g) {
|
|
|
899
899
|
return a(s, c);
|
|
900
900
|
};
|
|
901
901
|
if (l === "insert")
|
|
902
|
-
return (t) => (p(n),
|
|
902
|
+
return (t) => (p(n), ve(i, t, n, e), a(
|
|
903
903
|
r.getState().getNestedState(e, n),
|
|
904
904
|
n
|
|
905
905
|
));
|
|
906
906
|
if (l === "uniqueInsert")
|
|
907
907
|
return (t, o, s) => {
|
|
908
|
-
const c = r.getState().getNestedState(e, n), f =
|
|
908
|
+
const c = r.getState().getNestedState(e, n), f = K(t) ? t(c) : t;
|
|
909
909
|
let u = null;
|
|
910
910
|
if (!c.some((y) => {
|
|
911
911
|
if (o) {
|
|
912
|
-
const
|
|
912
|
+
const k = o.every(
|
|
913
913
|
(A) => q(y[A], f[A])
|
|
914
914
|
);
|
|
915
|
-
return
|
|
915
|
+
return k && (u = y), k;
|
|
916
916
|
}
|
|
917
917
|
const O = q(y, f);
|
|
918
918
|
return O && (u = y), O;
|
|
919
919
|
}))
|
|
920
|
-
p(n),
|
|
920
|
+
p(n), ve(i, f, n, e);
|
|
921
921
|
else if (s && u) {
|
|
922
922
|
const y = s(u), O = c.map(
|
|
923
|
-
(
|
|
923
|
+
(k) => q(k, u) ? y : k
|
|
924
924
|
);
|
|
925
925
|
p(n), ie(i, O, n);
|
|
926
926
|
}
|
|
@@ -941,7 +941,7 @@ function me(e, i, m, g) {
|
|
|
941
941
|
if (l === "toggleByValue")
|
|
942
942
|
return (t) => {
|
|
943
943
|
const o = h.findIndex((s) => s === t);
|
|
944
|
-
o > -1 ? fe(i, n, e, o) :
|
|
944
|
+
o > -1 ? fe(i, n, e, o) : ve(i, t, n, e);
|
|
945
945
|
};
|
|
946
946
|
if (l === "stateFind")
|
|
947
947
|
return (t) => {
|
|
@@ -962,15 +962,15 @@ function me(e, i, m, g) {
|
|
|
962
962
|
return a(c.item, f, S);
|
|
963
963
|
};
|
|
964
964
|
}
|
|
965
|
-
const
|
|
966
|
-
if (!isNaN(Number(
|
|
965
|
+
const ee = n[n.length - 1];
|
|
966
|
+
if (!isNaN(Number(ee))) {
|
|
967
967
|
const d = n.slice(0, -1), t = r.getState().getNestedState(e, d);
|
|
968
968
|
if (Array.isArray(t) && l === "cut")
|
|
969
969
|
return () => fe(
|
|
970
970
|
i,
|
|
971
971
|
d,
|
|
972
972
|
e,
|
|
973
|
-
Number(
|
|
973
|
+
Number(ee)
|
|
974
974
|
);
|
|
975
975
|
}
|
|
976
976
|
if (l === "get")
|
|
@@ -982,13 +982,13 @@ function me(e, i, m, g) {
|
|
|
982
982
|
return r.getState().getNestedState(e, n);
|
|
983
983
|
};
|
|
984
984
|
if (l === "$derive")
|
|
985
|
-
return (d) =>
|
|
985
|
+
return (d) => be({
|
|
986
986
|
_stateKey: e,
|
|
987
987
|
_path: n,
|
|
988
988
|
_effect: d.toString()
|
|
989
989
|
});
|
|
990
990
|
if (l === "$get")
|
|
991
|
-
return () =>
|
|
991
|
+
return () => be({
|
|
992
992
|
_stateKey: e,
|
|
993
993
|
_path: n
|
|
994
994
|
});
|
|
@@ -1023,8 +1023,8 @@ function me(e, i, m, g) {
|
|
|
1023
1023
|
if (n.length == 0) {
|
|
1024
1024
|
if (l === "applyJsonPatch")
|
|
1025
1025
|
return (d) => {
|
|
1026
|
-
const t = r.getState().cogsStateStore[e], s =
|
|
1027
|
-
|
|
1026
|
+
const t = r.getState().cogsStateStore[e], s = Fe(t, d).newDocument;
|
|
1027
|
+
Pe(
|
|
1028
1028
|
e,
|
|
1029
1029
|
r.getState().initialStateGlobal[e],
|
|
1030
1030
|
s,
|
|
@@ -1034,40 +1034,40 @@ function me(e, i, m, g) {
|
|
|
1034
1034
|
);
|
|
1035
1035
|
const c = r.getState().stateComponents.get(e);
|
|
1036
1036
|
if (c) {
|
|
1037
|
-
const f =
|
|
1037
|
+
const f = Ee(t, s), u = new Set(f);
|
|
1038
1038
|
for (const [
|
|
1039
1039
|
E,
|
|
1040
1040
|
y
|
|
1041
1041
|
] of c.components.entries()) {
|
|
1042
1042
|
let O = !1;
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
1045
|
-
if (
|
|
1043
|
+
const k = Array.isArray(y.reactiveType) ? y.reactiveType : [y.reactiveType || "component"];
|
|
1044
|
+
if (!k.includes("none")) {
|
|
1045
|
+
if (k.includes("all")) {
|
|
1046
1046
|
y.forceUpdate();
|
|
1047
1047
|
continue;
|
|
1048
1048
|
}
|
|
1049
|
-
if (
|
|
1049
|
+
if (k.includes("component") && (y.paths.has("") && (O = !0), !O))
|
|
1050
1050
|
for (const A of u) {
|
|
1051
1051
|
if (y.paths.has(A)) {
|
|
1052
1052
|
O = !0;
|
|
1053
1053
|
break;
|
|
1054
1054
|
}
|
|
1055
|
-
let
|
|
1056
|
-
for (;
|
|
1057
|
-
const U = A.substring(0,
|
|
1055
|
+
let x = A.lastIndexOf(".");
|
|
1056
|
+
for (; x !== -1; ) {
|
|
1057
|
+
const U = A.substring(0, x);
|
|
1058
1058
|
if (y.paths.has(U)) {
|
|
1059
1059
|
O = !0;
|
|
1060
1060
|
break;
|
|
1061
1061
|
}
|
|
1062
1062
|
const Y = A.substring(
|
|
1063
|
-
|
|
1063
|
+
x + 1
|
|
1064
1064
|
);
|
|
1065
1065
|
if (!isNaN(Number(Y))) {
|
|
1066
|
-
const
|
|
1067
|
-
if (
|
|
1066
|
+
const M = U.lastIndexOf(".");
|
|
1067
|
+
if (M !== -1) {
|
|
1068
1068
|
const N = U.substring(
|
|
1069
1069
|
0,
|
|
1070
|
-
|
|
1070
|
+
M
|
|
1071
1071
|
);
|
|
1072
1072
|
if (y.paths.has(N)) {
|
|
1073
1073
|
O = !0;
|
|
@@ -1075,14 +1075,14 @@ function me(e, i, m, g) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1078
|
+
x = U.lastIndexOf(".");
|
|
1079
1079
|
}
|
|
1080
1080
|
if (O) break;
|
|
1081
1081
|
}
|
|
1082
|
-
if (!O &&
|
|
1082
|
+
if (!O && k.includes("deps") && y.depsFunction) {
|
|
1083
1083
|
const A = y.depsFunction(s);
|
|
1084
|
-
let
|
|
1085
|
-
typeof A == "boolean" ? A && (
|
|
1084
|
+
let x = !1;
|
|
1085
|
+
typeof A == "boolean" ? A && (x = !0) : q(y.deps, A) || (y.deps = A, x = !0), x && (O = !0);
|
|
1086
1086
|
}
|
|
1087
1087
|
O && y.forceUpdate();
|
|
1088
1088
|
}
|
|
@@ -1096,12 +1096,12 @@ function me(e, i, m, g) {
|
|
|
1096
1096
|
throw new Error("Zod schema not found");
|
|
1097
1097
|
if (!d?.key)
|
|
1098
1098
|
throw new Error("Validation key not found");
|
|
1099
|
-
|
|
1099
|
+
X(d.key);
|
|
1100
1100
|
const o = r.getState().cogsStateStore[e];
|
|
1101
1101
|
try {
|
|
1102
1102
|
const s = r.getState().getValidationErrors(d.key);
|
|
1103
1103
|
s && s.length > 0 && s.forEach(([f]) => {
|
|
1104
|
-
f && f.startsWith(d.key) &&
|
|
1104
|
+
f && f.startsWith(d.key) && X(f);
|
|
1105
1105
|
});
|
|
1106
1106
|
const c = d.zodSchema.safeParse(o);
|
|
1107
1107
|
return c.success ? !0 : (c.error.errors.forEach((u) => {
|
|
@@ -1116,7 +1116,7 @@ function me(e, i, m, g) {
|
|
|
1116
1116
|
if (l === "getComponents")
|
|
1117
1117
|
return () => r().stateComponents.get(e);
|
|
1118
1118
|
if (l === "getAllFormRefs")
|
|
1119
|
-
return () =>
|
|
1119
|
+
return () => Ne.getState().getFormRefsByStateKey(e);
|
|
1120
1120
|
if (l === "_initialState")
|
|
1121
1121
|
return r.getState().initialStateGlobal[e];
|
|
1122
1122
|
if (l === "_serverState")
|
|
@@ -1129,13 +1129,13 @@ function me(e, i, m, g) {
|
|
|
1129
1129
|
if (l === "removeValidation") return v.removeValidation;
|
|
1130
1130
|
}
|
|
1131
1131
|
if (l === "getFormRef")
|
|
1132
|
-
return () =>
|
|
1132
|
+
return () => Ne.getState().getFormRef(e + "." + n.join("."));
|
|
1133
1133
|
if (l === "validationWrapper")
|
|
1134
1134
|
return ({
|
|
1135
1135
|
children: d,
|
|
1136
1136
|
hideMessage: t
|
|
1137
|
-
}) => /* @__PURE__ */
|
|
1138
|
-
|
|
1137
|
+
}) => /* @__PURE__ */ ye(
|
|
1138
|
+
Ue,
|
|
1139
1139
|
{
|
|
1140
1140
|
formOpts: t ? { validation: { message: "" } } : void 0,
|
|
1141
1141
|
path: n,
|
|
@@ -1151,7 +1151,7 @@ function me(e, i, m, g) {
|
|
|
1151
1151
|
if (l === "update")
|
|
1152
1152
|
return (d, t) => {
|
|
1153
1153
|
if (t?.debounce)
|
|
1154
|
-
|
|
1154
|
+
De(() => {
|
|
1155
1155
|
ie(i, d, n, "");
|
|
1156
1156
|
const o = r.getState().getNestedState(e, n);
|
|
1157
1157
|
t?.afterUpdate && t.afterUpdate(o);
|
|
@@ -1164,8 +1164,8 @@ function me(e, i, m, g) {
|
|
|
1164
1164
|
p(n);
|
|
1165
1165
|
};
|
|
1166
1166
|
if (l === "formElement")
|
|
1167
|
-
return (d, t) => /* @__PURE__ */
|
|
1168
|
-
|
|
1167
|
+
return (d, t) => /* @__PURE__ */ ye(
|
|
1168
|
+
je,
|
|
1169
1169
|
{
|
|
1170
1170
|
setState: i,
|
|
1171
1171
|
stateKey: e,
|
|
@@ -1174,23 +1174,23 @@ function me(e, i, m, g) {
|
|
|
1174
1174
|
formOpts: t
|
|
1175
1175
|
}
|
|
1176
1176
|
);
|
|
1177
|
-
const P = [...n, l],
|
|
1178
|
-
return a(
|
|
1177
|
+
const P = [...n, l], ae = r.getState().getNestedState(e, P);
|
|
1178
|
+
return a(ae, P, S);
|
|
1179
1179
|
}
|
|
1180
|
-
},
|
|
1181
|
-
return T.set(
|
|
1182
|
-
proxy:
|
|
1180
|
+
}, F = new Proxy(G, L);
|
|
1181
|
+
return T.set(H, {
|
|
1182
|
+
proxy: F,
|
|
1183
1183
|
stateVersion: C
|
|
1184
|
-
}),
|
|
1184
|
+
}), F;
|
|
1185
1185
|
}
|
|
1186
1186
|
return a(
|
|
1187
1187
|
r.getState().getNestedState(e, [])
|
|
1188
1188
|
);
|
|
1189
1189
|
}
|
|
1190
|
-
function
|
|
1191
|
-
return le(
|
|
1190
|
+
function be(e) {
|
|
1191
|
+
return le(Ke, { proxy: e });
|
|
1192
1192
|
}
|
|
1193
|
-
function
|
|
1193
|
+
function Qe({
|
|
1194
1194
|
proxy: e,
|
|
1195
1195
|
rebuildStateShape: i
|
|
1196
1196
|
}) {
|
|
@@ -1202,11 +1202,11 @@ function Xe({
|
|
|
1202
1202
|
(T, C, p, v, a) => e._mapFn(T, C, p, v, a)
|
|
1203
1203
|
) : null;
|
|
1204
1204
|
}
|
|
1205
|
-
function
|
|
1205
|
+
function Ke({
|
|
1206
1206
|
proxy: e
|
|
1207
1207
|
}) {
|
|
1208
|
-
const i =
|
|
1209
|
-
return
|
|
1208
|
+
const i = Z(null), m = `${e._stateKey}-${e._path.join(".")}`;
|
|
1209
|
+
return oe(() => {
|
|
1210
1210
|
const g = i.current;
|
|
1211
1211
|
if (!g || !g.parentElement) return;
|
|
1212
1212
|
const T = g.parentElement, p = Array.from(T.childNodes).indexOf(g);
|
|
@@ -1233,16 +1233,16 @@ function Qe({
|
|
|
1233
1233
|
else
|
|
1234
1234
|
S = n;
|
|
1235
1235
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1236
|
-
const
|
|
1237
|
-
g.replaceWith(
|
|
1236
|
+
const H = document.createTextNode(String(S));
|
|
1237
|
+
g.replaceWith(H);
|
|
1238
1238
|
}, [e._stateKey, e._path.join("."), e._effect]), le("span", {
|
|
1239
1239
|
ref: i,
|
|
1240
1240
|
style: { display: "none" },
|
|
1241
1241
|
"data-signal-id": m
|
|
1242
1242
|
});
|
|
1243
1243
|
}
|
|
1244
|
-
function
|
|
1245
|
-
const i =
|
|
1244
|
+
function mt(e) {
|
|
1245
|
+
const i = Ge(
|
|
1246
1246
|
(m) => {
|
|
1247
1247
|
const g = r.getState().stateComponents.get(e._stateKey) || {
|
|
1248
1248
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1256,14 +1256,14 @@ function St(e) {
|
|
|
1256
1256
|
);
|
|
1257
1257
|
return le("text", {}, String(i));
|
|
1258
1258
|
}
|
|
1259
|
-
function
|
|
1259
|
+
function et({
|
|
1260
1260
|
stateKey: e,
|
|
1261
1261
|
itemComponentId: i,
|
|
1262
1262
|
itemPath: m,
|
|
1263
1263
|
children: g
|
|
1264
1264
|
}) {
|
|
1265
|
-
const [, T] =
|
|
1266
|
-
return
|
|
1265
|
+
const [, T] = Q({}), [C, p] = Be(), v = Z(null);
|
|
1266
|
+
return oe(() => {
|
|
1267
1267
|
p.height > 0 && p.height !== v.current && (v.current = p.height, r.getState().setShadowMetadata(e, m, {
|
|
1268
1268
|
virtualizer: {
|
|
1269
1269
|
itemHeight: p.height
|
|
@@ -1280,14 +1280,14 @@ function Ke({
|
|
|
1280
1280
|
const n = r.getState().stateComponents.get(e);
|
|
1281
1281
|
n && n.components.delete(a);
|
|
1282
1282
|
};
|
|
1283
|
-
}, [e, i, m.join(".")]), /* @__PURE__ */
|
|
1283
|
+
}, [e, i, m.join(".")]), /* @__PURE__ */ ye("div", { ref: C, children: g });
|
|
1284
1284
|
}
|
|
1285
1285
|
export {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1286
|
+
be as $cogsSignal,
|
|
1287
|
+
mt as $cogsSignalStore,
|
|
1288
|
+
gt as addStateOptions,
|
|
1289
|
+
ft as createCogsState,
|
|
1290
|
+
St as notifyComponent,
|
|
1291
|
+
Xe as useCogsStateFn
|
|
1292
1292
|
};
|
|
1293
1293
|
//# sourceMappingURL=CogsState.jsx.map
|