cogsbox-state 0.5.301 → 0.5.302
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 +257 -253
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +50 -40
package/dist/CogsState.jsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { transformStateFunc as Ft, isDeepEqual as B, isFunction as X, getNestedValue as q, getDifferences as
|
|
5
|
-
import { pushFunc as
|
|
6
|
-
import
|
|
7
|
-
import { v4 as
|
|
2
|
+
import { jsx as wt } from "react/jsx-runtime";
|
|
3
|
+
import { useState as et, useRef as J, useEffect as st, useLayoutEffect as gt, useMemo as Tt, createElement as it, useSyncExternalStore as Ot, startTransition as Rt, useCallback as It } from "react";
|
|
4
|
+
import { transformStateFunc as Ft, isDeepEqual as B, isFunction as X, getNestedValue as q, getDifferences as Et, debounce as Ut } from "./utility.js";
|
|
5
|
+
import { pushFunc as pt, updateFn as at, cutFunc as ut, ValidationWrapper as Dt, FormControlComponent as Wt } from "./Functions.jsx";
|
|
6
|
+
import Gt from "superjson";
|
|
7
|
+
import { v4 as At } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
9
|
+
import { getGlobalStore as o, formRefStore as kt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as xt } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as Lt } from "fast-json-patch";
|
|
12
|
+
import Ht from "react-use-measure";
|
|
13
13
|
function bt(t, c) {
|
|
14
14
|
const m = o.getState().getInitialOptions, f = o.getState().setInitialStateOptions, y = m(t) || {};
|
|
15
15
|
f(t, {
|
|
@@ -17,7 +17,7 @@ function bt(t, c) {
|
|
|
17
17
|
...c
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Vt({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: c,
|
|
23
23
|
initialOptionsPart: m
|
|
@@ -30,10 +30,10 @@ function Nt({
|
|
|
30
30
|
!B(p[a], c[a]) && (I = !0, p[a] = c[a])) : (I = !0, p[a] = c[a]);
|
|
31
31
|
I && k(t, p);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ge(t, { formElements: c, validation: m }) {
|
|
34
34
|
return { initialState: t, formElements: c, validation: m };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const fe = (t, c) => {
|
|
37
37
|
let m = t;
|
|
38
38
|
const [f, y] = Ft(m);
|
|
39
39
|
(Object.keys(y).length > 0 || c && Object.keys(c).length > 0) && Object.keys(y).forEach((I) => {
|
|
@@ -46,13 +46,13 @@ const he = (t, c) => {
|
|
|
46
46
|
}, rt(I) || o.getState().setInitialStateOptions(I, y[I]);
|
|
47
47
|
}), o.getState().setInitialStates(f), o.getState().setCreatedState(f);
|
|
48
48
|
const k = (I, a) => {
|
|
49
|
-
const [v] =
|
|
50
|
-
|
|
49
|
+
const [v] = et(a?.componentId ?? At());
|
|
50
|
+
Vt({
|
|
51
51
|
stateKey: I,
|
|
52
52
|
options: a,
|
|
53
53
|
initialOptionsPart: y
|
|
54
54
|
});
|
|
55
|
-
const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [G, O] =
|
|
55
|
+
const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [G, O] = Xt(
|
|
56
56
|
S,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -71,21 +71,21 @@ const he = (t, c) => {
|
|
|
71
71
|
return O;
|
|
72
72
|
};
|
|
73
73
|
function p(I, a) {
|
|
74
|
-
|
|
74
|
+
Vt({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Yt(I, a), ht(I);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: k, setCogsOptions: p };
|
|
77
77
|
}, {
|
|
78
|
-
setUpdaterState:
|
|
79
|
-
setState:
|
|
78
|
+
setUpdaterState: ft,
|
|
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: Bt,
|
|
84
|
+
updateInitialStateGlobal: $t,
|
|
85
|
+
addValidationError: qt,
|
|
86
86
|
removeValidationError: Z,
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = o.getState(),
|
|
87
|
+
setServerSyncActions: Jt
|
|
88
|
+
} = o.getState(), Nt = (t, c, m, f, y) => {
|
|
89
89
|
m?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
91
91
|
c,
|
|
@@ -97,20 +97,20 @@ const he = (t, c) => {
|
|
|
97
97
|
const p = `${f}-${c}-${k}`;
|
|
98
98
|
let I;
|
|
99
99
|
try {
|
|
100
|
-
I =
|
|
100
|
+
I = mt(p)?.lastSyncedWithServer;
|
|
101
101
|
} catch {
|
|
102
102
|
}
|
|
103
103
|
const a = {
|
|
104
104
|
state: t,
|
|
105
105
|
lastUpdated: Date.now(),
|
|
106
106
|
lastSyncedWithServer: y ?? I
|
|
107
|
-
}, v =
|
|
107
|
+
}, v = Gt.serialize(a);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
p,
|
|
110
110
|
JSON.stringify(v.json)
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
-
},
|
|
113
|
+
}, mt = (t) => {
|
|
114
114
|
if (!t) return null;
|
|
115
115
|
try {
|
|
116
116
|
const c = window.localStorage.getItem(t);
|
|
@@ -118,20 +118,20 @@ const he = (t, c) => {
|
|
|
118
118
|
} catch (c) {
|
|
119
119
|
return console.error("Error loading from localStorage:", c), null;
|
|
120
120
|
}
|
|
121
|
-
},
|
|
122
|
-
const m = o.getState().cogsStateStore[t], { sessionId: f } =
|
|
121
|
+
}, Yt = (t, c) => {
|
|
122
|
+
const m = o.getState().cogsStateStore[t], { sessionId: f } = xt(), y = X(c?.localStorage?.key) ? c.localStorage.key(m) : c?.localStorage?.key;
|
|
123
123
|
if (y && f) {
|
|
124
|
-
const k =
|
|
124
|
+
const k = mt(
|
|
125
125
|
`${f}-${t}-${y}`
|
|
126
126
|
);
|
|
127
127
|
if (k && k.lastUpdated > (k.lastSyncedWithServer || 0))
|
|
128
|
-
return
|
|
128
|
+
return nt(t, k.state), ht(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, _t = (t, c, m, f, y, k) => {
|
|
132
132
|
const p = {
|
|
133
133
|
initialState: c,
|
|
134
|
-
updaterState:
|
|
134
|
+
updaterState: St(
|
|
135
135
|
t,
|
|
136
136
|
f,
|
|
137
137
|
y,
|
|
@@ -139,8 +139,8 @@ const he = (t, c) => {
|
|
|
139
139
|
),
|
|
140
140
|
state: m
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
},
|
|
142
|
+
$t(t, p.initialState), ft(t, p.updaterState), nt(t, p.state);
|
|
143
|
+
}, ht = (t) => {
|
|
144
144
|
const c = o.getState().stateComponents.get(t);
|
|
145
145
|
if (!c) return;
|
|
146
146
|
const m = /* @__PURE__ */ new Set();
|
|
@@ -149,7 +149,7 @@ const he = (t, c) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
m.forEach((f) => f());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, Se = (t, c) => {
|
|
153
153
|
const m = o.getState().stateComponents.get(t);
|
|
154
154
|
if (m) {
|
|
155
155
|
const f = `${t}////${c}`, y = m.components.get(f);
|
|
@@ -157,7 +157,7 @@ const he = (t, c) => {
|
|
|
157
157
|
return;
|
|
158
158
|
y && y.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Zt = (t, c, m, f) => {
|
|
161
161
|
switch (t) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
@@ -180,7 +180,7 @@ const he = (t, c) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Xt(t, {
|
|
184
184
|
stateKey: c,
|
|
185
185
|
serverSync: m,
|
|
186
186
|
localStorage: f,
|
|
@@ -193,14 +193,14 @@ function Qt(t, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: S
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [G, O] =
|
|
196
|
+
const [G, O] = et({}), { sessionId: R } = xt();
|
|
197
197
|
let L = !c;
|
|
198
|
-
const [h] =
|
|
198
|
+
const [h] = et(c ?? At()), l = o.getState().stateLog[h], ct = J(/* @__PURE__ */ new Set()), Q = J(I ?? At()), M = J(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
|
-
M.current = rt(h) ?? null,
|
|
201
|
+
M.current = rt(h) ?? null, st(() => {
|
|
202
202
|
if (v && v.stateKey === h && v.path?.[0]) {
|
|
203
|
-
|
|
203
|
+
nt(h, (r) => ({
|
|
204
204
|
...r,
|
|
205
205
|
[v.path[0]]: v.newValue
|
|
206
206
|
}));
|
|
@@ -210,7 +210,7 @@ function Qt(t, {
|
|
|
210
210
|
userId: v.userId
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
}, [v]),
|
|
213
|
+
}, [v]), st(() => {
|
|
214
214
|
if (a) {
|
|
215
215
|
bt(h, {
|
|
216
216
|
initialState: a
|
|
@@ -220,24 +220,24 @@ function Qt(t, {
|
|
|
220
220
|
return;
|
|
221
221
|
let u = null;
|
|
222
222
|
const T = X(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
|
|
223
|
-
T && R && (u =
|
|
223
|
+
T && R && (u = mt(`${R}-${h}-${T}`));
|
|
224
224
|
let w = a, $ = !1;
|
|
225
|
-
const
|
|
226
|
-
s &&
|
|
225
|
+
const P = s ? Date.now() : 0, C = u?.lastUpdated || 0, _ = u?.lastSyncedWithServer || 0;
|
|
226
|
+
s && P > C ? (w = e.serverState.data, $ = !0) : u && C > _ && (w = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), o.getState().initializeShadowState(h, a), _t(
|
|
227
227
|
h,
|
|
228
228
|
a,
|
|
229
229
|
w,
|
|
230
230
|
ot,
|
|
231
231
|
Q.current,
|
|
232
232
|
R
|
|
233
|
-
), $ && T && R &&
|
|
233
|
+
), $ && T && R && Nt(w, h, e, R, Date.now()), ht(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || O({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
a,
|
|
237
237
|
S?.status,
|
|
238
238
|
S?.data,
|
|
239
239
|
...n || []
|
|
240
|
-
]),
|
|
240
|
+
]), gt(() => {
|
|
241
241
|
L && bt(h, {
|
|
242
242
|
serverSync: m,
|
|
243
243
|
formElements: y,
|
|
@@ -261,32 +261,32 @@ function Qt(t, {
|
|
|
261
261
|
const ot = (e, r, s, i) => {
|
|
262
262
|
if (Array.isArray(r)) {
|
|
263
263
|
const u = `${h}-${r.join(".")}`;
|
|
264
|
-
|
|
264
|
+
ct.current.add(u);
|
|
265
265
|
}
|
|
266
266
|
const g = o.getState();
|
|
267
|
-
|
|
267
|
+
nt(h, (u) => {
|
|
268
268
|
const T = X(e) ? e(u) : e, w = `${h}-${r.join(".")}`;
|
|
269
269
|
if (w) {
|
|
270
|
-
let
|
|
271
|
-
if ((!
|
|
272
|
-
const
|
|
270
|
+
let b = !1, V = g.signalDomElements.get(w);
|
|
271
|
+
if ((!V || V.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
|
|
272
|
+
const x = r.slice(0, -1), D = q(T, x);
|
|
273
273
|
if (Array.isArray(D)) {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
274
|
+
b = !0;
|
|
275
|
+
const A = `${h}-${x.join(".")}`;
|
|
276
|
+
V = g.signalDomElements.get(A);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
279
|
+
if (V) {
|
|
280
|
+
const x = b ? q(T, r.slice(0, -1)) : q(T, r);
|
|
281
|
+
V.forEach(({ parentId: D, position: A, effect: F }) => {
|
|
282
282
|
const j = document.querySelector(
|
|
283
283
|
`[data-parent-id="${D}"]`
|
|
284
284
|
);
|
|
285
285
|
if (j) {
|
|
286
|
-
const
|
|
287
|
-
if (A
|
|
288
|
-
const N =
|
|
289
|
-
A
|
|
286
|
+
const E = Array.from(j.childNodes);
|
|
287
|
+
if (E[A]) {
|
|
288
|
+
const N = F ? new Function("state", `return (${F})(state)`)(x) : x;
|
|
289
|
+
E[A].textContent = String(N);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
@@ -298,35 +298,35 @@ function Qt(t, {
|
|
|
298
298
|
const $ = r.slice(0, r.length - 1);
|
|
299
299
|
s.updateType === "cut" && M.current?.validation?.key && Z(
|
|
300
300
|
M.current?.validation?.key + "." + $.join(".")
|
|
301
|
-
), s.updateType === "insert" && M.current?.validation?.key &&
|
|
301
|
+
), s.updateType === "insert" && M.current?.validation?.key && zt(
|
|
302
302
|
M.current?.validation?.key + "." + $.join(".")
|
|
303
|
-
).filter(([
|
|
304
|
-
let D =
|
|
305
|
-
if (
|
|
306
|
-
let
|
|
307
|
-
Z(
|
|
303
|
+
).filter(([V, x]) => {
|
|
304
|
+
let D = V?.split(".").length;
|
|
305
|
+
if (V == $.join(".") && D == $.length - 1) {
|
|
306
|
+
let A = V + "." + $;
|
|
307
|
+
Z(V), qt(A, x);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
310
|
+
const P = g.stateComponents.get(h);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", P), P) {
|
|
312
|
+
const b = Et(u, T), V = new Set(b), x = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
314
|
D,
|
|
315
|
-
|
|
316
|
-
] of
|
|
317
|
-
let
|
|
318
|
-
const j = Array.isArray(
|
|
319
|
-
if (console.log("component",
|
|
315
|
+
A
|
|
316
|
+
] of P.components.entries()) {
|
|
317
|
+
let F = !1;
|
|
318
|
+
const j = Array.isArray(A.reactiveType) ? A.reactiveType : [A.reactiveType || "component"];
|
|
319
|
+
if (console.log("component", A), !j.includes("none")) {
|
|
320
320
|
if (j.includes("all")) {
|
|
321
|
-
|
|
321
|
+
A.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (j.includes("component") && ((
|
|
325
|
-
for (const
|
|
326
|
-
let N =
|
|
324
|
+
if (j.includes("component") && ((A.paths.has(x) || A.paths.has("")) && (F = !0), !F))
|
|
325
|
+
for (const E of V) {
|
|
326
|
+
let N = E;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (
|
|
329
|
-
|
|
328
|
+
if (A.paths.has(N)) {
|
|
329
|
+
F = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
332
|
const z = N.lastIndexOf(".");
|
|
@@ -337,8 +337,8 @@ function Qt(t, {
|
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
339
|
Number(N.substring(z + 1))
|
|
340
|
-
) &&
|
|
341
|
-
|
|
340
|
+
) && A.paths.has(W)) {
|
|
341
|
+
F = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
344
|
N = W;
|
|
@@ -347,23 +347,23 @@ function Qt(t, {
|
|
|
347
347
|
if (N === "")
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
if (
|
|
350
|
+
if (F) break;
|
|
351
351
|
}
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
352
|
+
if (!F && j.includes("deps") && A.depsFunction) {
|
|
353
|
+
const E = A.depsFunction(T);
|
|
354
354
|
let N = !1;
|
|
355
|
-
typeof
|
|
355
|
+
typeof E == "boolean" ? E && (N = !0) : B(A.deps, E) || (A.deps = E, N = !0), N && (F = !0);
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
F && A.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
const C = Date.now();
|
|
362
|
-
r = r.map((
|
|
363
|
-
const
|
|
364
|
-
return
|
|
362
|
+
r = r.map((b, V) => {
|
|
363
|
+
const x = r.slice(0, -1), D = q(T, x);
|
|
364
|
+
return V === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (D.length - 1).toString() : b;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue: _, newValue:
|
|
366
|
+
const { oldValue: _, newValue: U } = Zt(
|
|
367
367
|
s.updateType,
|
|
368
368
|
u,
|
|
369
369
|
T,
|
|
@@ -375,28 +375,28 @@ function Qt(t, {
|
|
|
375
375
|
updateType: s.updateType,
|
|
376
376
|
status: "new",
|
|
377
377
|
oldValue: _,
|
|
378
|
-
newValue:
|
|
378
|
+
newValue: U
|
|
379
379
|
};
|
|
380
380
|
switch (s.updateType) {
|
|
381
381
|
case "update":
|
|
382
382
|
g.updateShadowAtPath(h, r, T);
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
g.insertShadowArrayElement(h,
|
|
385
|
+
const b = r.slice(0, -1);
|
|
386
|
+
g.insertShadowArrayElement(h, b, U);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
|
-
const
|
|
390
|
-
g.removeShadowArrayElement(h,
|
|
389
|
+
const V = r.slice(0, -1), x = parseInt(r[r.length - 1]);
|
|
390
|
+
g.removeShadowArrayElement(h, V, x);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
return j ? (j.timeStamp = Math.max(j.timeStamp,
|
|
393
|
+
if (Bt(h, (b) => {
|
|
394
|
+
const x = [...b ?? [], H].reduce((D, A) => {
|
|
395
|
+
const F = `${A.stateKey}:${JSON.stringify(A.path)}`, j = D.get(F);
|
|
396
|
+
return j ? (j.timeStamp = Math.max(j.timeStamp, A.timeStamp), j.newValue = A.newValue, j.oldValue = j.oldValue ?? A.oldValue, j.updateType = A.updateType) : D.set(F, { ...A }), D;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
|
-
return Array.from(
|
|
399
|
-
}),
|
|
398
|
+
return Array.from(x.values());
|
|
399
|
+
}), Nt(
|
|
400
400
|
T,
|
|
401
401
|
h,
|
|
402
402
|
M.current,
|
|
@@ -405,35 +405,35 @@ function Qt(t, {
|
|
|
405
405
|
updateLog: l,
|
|
406
406
|
update: H
|
|
407
407
|
}), M.current?.serverSync) {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
syncKey: typeof
|
|
411
|
-
rollBackState:
|
|
412
|
-
actionTimeStamp: Date.now() + (
|
|
408
|
+
const b = g.serverState[h], V = M.current?.serverSync;
|
|
409
|
+
Jt(h, {
|
|
410
|
+
syncKey: typeof V.syncKey == "string" ? V.syncKey : V.syncKey({ state: T }),
|
|
411
|
+
rollBackState: b,
|
|
412
|
+
actionTimeStamp: Date.now() + (V.debounce ?? 3e3),
|
|
413
413
|
status: "waiting"
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
return T;
|
|
417
417
|
});
|
|
418
418
|
};
|
|
419
|
-
o.getState().updaterState[h] || (
|
|
419
|
+
o.getState().updaterState[h] || (ft(
|
|
420
420
|
h,
|
|
421
|
-
|
|
421
|
+
St(
|
|
422
422
|
h,
|
|
423
423
|
ot,
|
|
424
424
|
Q.current,
|
|
425
425
|
R
|
|
426
426
|
)
|
|
427
|
-
), o.getState().cogsStateStore[h] ||
|
|
428
|
-
const d =
|
|
427
|
+
), o.getState().cogsStateStore[h] || nt(h, t), o.getState().initialStateGlobal[h] || $t(h, t));
|
|
428
|
+
const d = Tt(() => St(
|
|
429
429
|
h,
|
|
430
430
|
ot,
|
|
431
431
|
Q.current,
|
|
432
432
|
R
|
|
433
433
|
), [h, R]);
|
|
434
|
-
return [
|
|
434
|
+
return [Pt(h), d];
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function St(t, c, m, f) {
|
|
437
437
|
const y = /* @__PURE__ */ new Map();
|
|
438
438
|
let k = 0;
|
|
439
439
|
const p = (v) => {
|
|
@@ -451,7 +451,7 @@ function mt(t, c, m, f) {
|
|
|
451
451
|
const S = o.getState().initialStateGlobal[t];
|
|
452
452
|
o.getState().clearSelectedIndexesForState(t), y.clear(), k++;
|
|
453
453
|
const G = a(S, []), O = rt(t), R = X(O?.localStorage?.key) ? O?.localStorage?.key(S) : O?.localStorage?.key, L = `${f}-${t}-${R}`;
|
|
454
|
-
L && localStorage.removeItem(L),
|
|
454
|
+
L && localStorage.removeItem(L), ft(t, G), nt(t, S);
|
|
455
455
|
const h = o.getState().stateComponents.get(t);
|
|
456
456
|
return h && h.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -459,14 +459,14 @@ function mt(t, c, m, f) {
|
|
|
459
459
|
},
|
|
460
460
|
updateInitialState: (v) => {
|
|
461
461
|
y.clear(), k++;
|
|
462
|
-
const n =
|
|
462
|
+
const n = St(
|
|
463
463
|
t,
|
|
464
464
|
c,
|
|
465
465
|
m,
|
|
466
466
|
f
|
|
467
467
|
), S = o.getState().initialStateGlobal[t], G = rt(t), O = X(G?.localStorage?.key) ? G?.localStorage?.key(S) : G?.localStorage?.key, R = `${f}-${t}-${O}`;
|
|
468
|
-
return localStorage.getItem(R) && localStorage.removeItem(R),
|
|
469
|
-
|
|
468
|
+
return localStorage.getItem(R) && localStorage.removeItem(R), Rt(() => {
|
|
469
|
+
$t(t, v), o.getState().initializeShadowState(t, v), ft(t, n), nt(t, v);
|
|
470
470
|
const L = o.getState().stateComponents.get(t);
|
|
471
471
|
L && L.components.forEach((h) => {
|
|
472
472
|
h.forceUpdate();
|
|
@@ -480,7 +480,7 @@ function mt(t, c, m, f) {
|
|
|
480
480
|
_isLoading: o.getState().isLoadingGlobal[t],
|
|
481
481
|
_isServerSynced: () => {
|
|
482
482
|
const v = o.getState().serverState[t];
|
|
483
|
-
return !!(v && B(v,
|
|
483
|
+
return !!(v && B(v, Pt(t)));
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(v, n = [], S) {
|
|
@@ -493,14 +493,14 @@ function mt(t, c, m, f) {
|
|
|
493
493
|
O[h] = I[h];
|
|
494
494
|
});
|
|
495
495
|
const R = {
|
|
496
|
-
apply(h, l,
|
|
496
|
+
apply(h, l, ct) {
|
|
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(h, l) {
|
|
502
502
|
S?.validIndices && !Array.isArray(v) && (S = { ...S, validIndices: void 0 });
|
|
503
|
-
const
|
|
503
|
+
const ct = /* @__PURE__ */ new Set([
|
|
504
504
|
"insert",
|
|
505
505
|
"cut",
|
|
506
506
|
"cutByValue",
|
|
@@ -523,7 +523,7 @@ function mt(t, c, m, f) {
|
|
|
523
523
|
"_stateKey",
|
|
524
524
|
"getComponents"
|
|
525
525
|
]);
|
|
526
|
-
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !
|
|
526
|
+
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !ct.has(l)) {
|
|
527
527
|
const d = `${t}////${m}`, 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, c, m, f) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => Et(
|
|
544
544
|
o.getState().cogsStateStore[t],
|
|
545
545
|
o.getState().initialStateGlobal[t]
|
|
546
546
|
);
|
|
@@ -619,110 +619,114 @@ function mt(t, c, m, f) {
|
|
|
619
619
|
return (e) => {
|
|
620
620
|
const {
|
|
621
621
|
itemHeight: r = 50,
|
|
622
|
-
// Default/estimated height
|
|
623
622
|
overscan: s = 5,
|
|
624
623
|
stickToBottom: i = !1
|
|
625
|
-
} = e, g = J(null), [u, T] =
|
|
624
|
+
} = e, g = J(null), [u, T] = et({
|
|
626
625
|
startIndex: 0,
|
|
627
626
|
endIndex: 10
|
|
628
|
-
}), [w, $] =
|
|
629
|
-
() => $((
|
|
627
|
+
}), [w, $] = et(0), P = It(
|
|
628
|
+
() => $((E) => E + 1),
|
|
630
629
|
[]
|
|
631
|
-
);
|
|
632
|
-
|
|
633
|
-
const
|
|
630
|
+
), C = J(i), _ = J(0), U = J(!0);
|
|
631
|
+
st(() => {
|
|
632
|
+
const E = o.getState().subscribeToShadowState(t, P), N = setTimeout(P, 50);
|
|
634
633
|
return () => {
|
|
635
|
-
|
|
634
|
+
E(), clearTimeout(N);
|
|
636
635
|
};
|
|
637
|
-
}, [t,
|
|
638
|
-
const
|
|
636
|
+
}, [t, P]);
|
|
637
|
+
const H = o().getNestedState(
|
|
639
638
|
t,
|
|
640
639
|
n
|
|
641
|
-
),
|
|
642
|
-
const
|
|
640
|
+
), b = H.length, { totalHeight: V, positions: x } = Tt(() => {
|
|
641
|
+
const E = o.getState().getShadowMetadata(t, n) || [];
|
|
643
642
|
let N = 0;
|
|
644
643
|
const z = [];
|
|
645
|
-
for (let W = 0; W <
|
|
644
|
+
for (let W = 0; W < b; W++) {
|
|
646
645
|
z[W] = N;
|
|
647
|
-
const Y =
|
|
646
|
+
const Y = E[W]?.virtualizer?.itemHeight;
|
|
648
647
|
N += Y || r;
|
|
649
648
|
}
|
|
650
649
|
return { totalHeight: N, positions: z };
|
|
651
|
-
}, [
|
|
652
|
-
const
|
|
653
|
-
{ length: N -
|
|
654
|
-
(Y,
|
|
650
|
+
}, [b, t, n, r, w]), D = Tt(() => {
|
|
651
|
+
const E = Math.max(0, u.startIndex), N = Math.min(b, u.endIndex), z = Array.from(
|
|
652
|
+
{ length: N - E },
|
|
653
|
+
(Y, lt) => E + lt
|
|
655
654
|
), W = z.map((Y) => H[Y]);
|
|
656
655
|
return a(W, n, {
|
|
657
656
|
...S,
|
|
658
657
|
validIndices: z
|
|
659
658
|
});
|
|
660
|
-
}, [u.startIndex, u.endIndex, H]);
|
|
661
|
-
|
|
662
|
-
const
|
|
663
|
-
if (!
|
|
664
|
-
const N =
|
|
665
|
-
|
|
666
|
-
const
|
|
667
|
-
const { scrollTop: Y, clientHeight:
|
|
668
|
-
C.current =
|
|
669
|
-
let
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
for (; K <
|
|
659
|
+
}, [u.startIndex, u.endIndex, H, b]);
|
|
660
|
+
gt(() => {
|
|
661
|
+
const E = g.current;
|
|
662
|
+
if (!E) return;
|
|
663
|
+
const N = C.current, z = b > _.current;
|
|
664
|
+
_.current = b;
|
|
665
|
+
const W = () => {
|
|
666
|
+
const { scrollTop: Y, clientHeight: lt, scrollHeight: Mt } = E;
|
|
667
|
+
C.current = Mt - Y - lt < 10;
|
|
668
|
+
let vt = 0, dt = b - 1;
|
|
669
|
+
for (; vt <= dt; ) {
|
|
670
|
+
const tt = Math.floor((vt + dt) / 2);
|
|
671
|
+
x[tt] < Y ? vt = tt + 1 : dt = tt - 1;
|
|
672
|
+
}
|
|
673
|
+
const yt = Math.max(0, dt - s);
|
|
674
|
+
let K = yt;
|
|
675
|
+
const jt = Y + lt;
|
|
676
|
+
for (; K < b && x[K] < jt; )
|
|
678
677
|
K++;
|
|
679
|
-
|
|
678
|
+
K = Math.min(b, K + s), T((tt) => tt.startIndex !== yt || tt.endIndex !== K ? { startIndex: yt, endIndex: K } : tt);
|
|
680
679
|
};
|
|
681
|
-
return
|
|
680
|
+
return E.addEventListener("scroll", W, {
|
|
682
681
|
passive: !0
|
|
683
|
-
}),
|
|
684
|
-
top:
|
|
685
|
-
behavior: "auto"
|
|
686
|
-
}) : N && z && A.scrollTo({
|
|
687
|
-
top: A.scrollHeight,
|
|
682
|
+
}), i && (U.current ? E.scrollTo({
|
|
683
|
+
top: E.scrollHeight,
|
|
688
684
|
behavior: "auto"
|
|
689
|
-
})
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
685
|
+
}) : N && z && requestAnimationFrame(() => {
|
|
686
|
+
E.scrollTo({
|
|
687
|
+
top: E.scrollHeight,
|
|
688
|
+
behavior: "smooth"
|
|
689
|
+
});
|
|
690
|
+
})), U.current = !1, W(), () => E.removeEventListener("scroll", W);
|
|
691
|
+
}, [b, x, s, i]);
|
|
692
|
+
const A = It(
|
|
693
|
+
(E = "smooth") => {
|
|
693
694
|
g.current && g.current.scrollTo({
|
|
694
695
|
top: g.current.scrollHeight,
|
|
695
|
-
behavior:
|
|
696
|
+
behavior: E
|
|
696
697
|
});
|
|
697
698
|
},
|
|
698
699
|
[]
|
|
699
|
-
),
|
|
700
|
-
(
|
|
701
|
-
g.current && g.current.scrollTo({
|
|
702
|
-
top:
|
|
700
|
+
), F = It(
|
|
701
|
+
(E, N = "smooth") => {
|
|
702
|
+
g.current && x[E] !== void 0 && g.current.scrollTo({
|
|
703
|
+
top: x[E],
|
|
703
704
|
behavior: N
|
|
704
705
|
});
|
|
705
706
|
},
|
|
706
|
-
[
|
|
707
|
+
[x]
|
|
707
708
|
), j = {
|
|
708
709
|
outer: {
|
|
709
710
|
ref: g,
|
|
710
711
|
style: { overflowY: "auto", height: "100%" }
|
|
711
712
|
},
|
|
712
713
|
inner: {
|
|
713
|
-
style: {
|
|
714
|
+
style: {
|
|
715
|
+
height: `${V}px`,
|
|
716
|
+
position: "relative"
|
|
717
|
+
}
|
|
714
718
|
},
|
|
715
719
|
list: {
|
|
716
720
|
style: {
|
|
717
|
-
transform: `translateY(${
|
|
721
|
+
transform: `translateY(${x[u.startIndex] || 0}px)`
|
|
718
722
|
}
|
|
719
723
|
}
|
|
720
724
|
};
|
|
721
725
|
return {
|
|
722
726
|
virtualState: D,
|
|
723
727
|
virtualizerProps: j,
|
|
724
|
-
scrollToBottom:
|
|
725
|
-
scrollToIndex:
|
|
728
|
+
scrollToBottom: A,
|
|
729
|
+
scrollToIndex: F
|
|
726
730
|
};
|
|
727
731
|
};
|
|
728
732
|
if (l === "stateSort")
|
|
@@ -756,15 +760,15 @@ function mt(t, c, m, f) {
|
|
|
756
760
|
const u = r[i], T = [...n, i.toString()], w = a(u, T, S);
|
|
757
761
|
return e(u, w, {
|
|
758
762
|
register: () => {
|
|
759
|
-
const [,
|
|
760
|
-
|
|
761
|
-
const _ = `${t}////${C}`,
|
|
763
|
+
const [, P] = et({}), C = `${m}-${n.join(".")}-${i}`;
|
|
764
|
+
gt(() => {
|
|
765
|
+
const _ = `${t}////${C}`, U = o.getState().stateComponents.get(t) || {
|
|
762
766
|
components: /* @__PURE__ */ new Map()
|
|
763
767
|
};
|
|
764
|
-
return
|
|
765
|
-
forceUpdate: () =>
|
|
768
|
+
return U.components.set(_, {
|
|
769
|
+
forceUpdate: () => P({}),
|
|
766
770
|
paths: /* @__PURE__ */ new Set([T.join(".")])
|
|
767
|
-
}), o.getState().stateComponents.set(t,
|
|
771
|
+
}), o.getState().stateComponents.set(t, U), () => {
|
|
768
772
|
const H = o.getState().stateComponents.get(t);
|
|
769
773
|
H && H.components.delete(_);
|
|
770
774
|
};
|
|
@@ -792,7 +796,7 @@ function mt(t, c, m, f) {
|
|
|
792
796
|
);
|
|
793
797
|
});
|
|
794
798
|
if (l === "$stateMap")
|
|
795
|
-
return (e) =>
|
|
799
|
+
return (e) => it(Qt, {
|
|
796
800
|
proxy: {
|
|
797
801
|
_stateKey: t,
|
|
798
802
|
_path: n,
|
|
@@ -806,7 +810,7 @@ function mt(t, c, m, f) {
|
|
|
806
810
|
const r = o.getState().getNestedState(t, n);
|
|
807
811
|
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
|
|
808
812
|
const u = r[i], T = [...n, i.toString()], w = a(u, T, S), $ = `${m}-${n.join(".")}-${i}`;
|
|
809
|
-
return
|
|
813
|
+
return it(te, {
|
|
810
814
|
key: i,
|
|
811
815
|
stateKey: t,
|
|
812
816
|
itemComponentId: $,
|
|
@@ -849,7 +853,7 @@ function mt(t, c, m, f) {
|
|
|
849
853
|
return a(s, i);
|
|
850
854
|
};
|
|
851
855
|
if (l === "insert")
|
|
852
|
-
return (e) => (p(n),
|
|
856
|
+
return (e) => (p(n), pt(c, e, n, t), a(
|
|
853
857
|
o.getState().getNestedState(t, n),
|
|
854
858
|
n
|
|
855
859
|
));
|
|
@@ -859,26 +863,26 @@ function mt(t, c, m, f) {
|
|
|
859
863
|
let u = null;
|
|
860
864
|
if (!i.some((w) => {
|
|
861
865
|
if (r) {
|
|
862
|
-
const
|
|
866
|
+
const P = r.every(
|
|
863
867
|
(C) => B(w[C], g[C])
|
|
864
868
|
);
|
|
865
|
-
return
|
|
869
|
+
return P && (u = w), P;
|
|
866
870
|
}
|
|
867
871
|
const $ = B(w, g);
|
|
868
872
|
return $ && (u = w), $;
|
|
869
873
|
}))
|
|
870
|
-
p(n),
|
|
874
|
+
p(n), pt(c, g, n, t);
|
|
871
875
|
else if (s && u) {
|
|
872
876
|
const w = s(u), $ = i.map(
|
|
873
|
-
(
|
|
877
|
+
(P) => B(P, u) ? w : P
|
|
874
878
|
);
|
|
875
|
-
p(n),
|
|
879
|
+
p(n), at(c, $, n);
|
|
876
880
|
}
|
|
877
881
|
};
|
|
878
882
|
if (l === "cut")
|
|
879
883
|
return (e, r) => {
|
|
880
884
|
if (!r?.waitForSync)
|
|
881
|
-
return p(n),
|
|
885
|
+
return p(n), ut(c, n, t, e), a(
|
|
882
886
|
o.getState().getNestedState(t, n),
|
|
883
887
|
n
|
|
884
888
|
);
|
|
@@ -886,12 +890,12 @@ function mt(t, c, m, f) {
|
|
|
886
890
|
if (l === "cutByValue")
|
|
887
891
|
return (e) => {
|
|
888
892
|
for (let r = 0; r < v.length; r++)
|
|
889
|
-
v[r] === e &&
|
|
893
|
+
v[r] === e && ut(c, n, t, r);
|
|
890
894
|
};
|
|
891
895
|
if (l === "toggleByValue")
|
|
892
896
|
return (e) => {
|
|
893
897
|
const r = v.findIndex((s) => s === e);
|
|
894
|
-
r > -1 ?
|
|
898
|
+
r > -1 ? ut(c, n, t, r) : pt(c, e, n, t);
|
|
895
899
|
};
|
|
896
900
|
if (l === "stateFind")
|
|
897
901
|
return (e) => {
|
|
@@ -916,7 +920,7 @@ function mt(t, c, m, f) {
|
|
|
916
920
|
if (!isNaN(Number(Q))) {
|
|
917
921
|
const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
|
|
918
922
|
if (Array.isArray(e) && l === "cut")
|
|
919
|
-
return () =>
|
|
923
|
+
return () => ut(
|
|
920
924
|
c,
|
|
921
925
|
d,
|
|
922
926
|
t,
|
|
@@ -932,13 +936,13 @@ function mt(t, c, m, f) {
|
|
|
932
936
|
return o.getState().getNestedState(t, n);
|
|
933
937
|
};
|
|
934
938
|
if (l === "$derive")
|
|
935
|
-
return (d) =>
|
|
939
|
+
return (d) => Ct({
|
|
936
940
|
_stateKey: t,
|
|
937
941
|
_path: n,
|
|
938
942
|
_effect: d.toString()
|
|
939
943
|
});
|
|
940
944
|
if (l === "$get")
|
|
941
|
-
return () =>
|
|
945
|
+
return () => Ct({
|
|
942
946
|
_stateKey: t,
|
|
943
947
|
_path: n
|
|
944
948
|
});
|
|
@@ -947,7 +951,7 @@ function mt(t, c, m, f) {
|
|
|
947
951
|
return o.getState().getSyncInfo(d);
|
|
948
952
|
}
|
|
949
953
|
if (l == "getLocalStorage")
|
|
950
|
-
return (d) =>
|
|
954
|
+
return (d) => mt(f + "-" + t + "-" + d);
|
|
951
955
|
if (l === "_selected") {
|
|
952
956
|
const d = n.slice(0, -1), e = d.join("."), r = o.getState().getNestedState(t, d);
|
|
953
957
|
return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
|
|
@@ -957,7 +961,7 @@ function mt(t, c, m, f) {
|
|
|
957
961
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), s = e.join(".");
|
|
958
962
|
d ? o.getState().setSelectedIndex(t, s, r) : o.getState().setSelectedIndex(t, s, void 0);
|
|
959
963
|
const i = o.getState().getNestedState(t, [...e]);
|
|
960
|
-
|
|
964
|
+
at(c, i, e), p(e);
|
|
961
965
|
};
|
|
962
966
|
if (l === "toggleSelected")
|
|
963
967
|
return () => {
|
|
@@ -968,13 +972,13 @@ function mt(t, c, m, f) {
|
|
|
968
972
|
s === e ? void 0 : e
|
|
969
973
|
);
|
|
970
974
|
const i = o.getState().getNestedState(t, [...d]);
|
|
971
|
-
|
|
975
|
+
at(c, i, d), p(d);
|
|
972
976
|
};
|
|
973
977
|
if (n.length == 0) {
|
|
974
978
|
if (l === "applyJsonPatch")
|
|
975
979
|
return (d) => {
|
|
976
|
-
const e = o.getState().cogsStateStore[t], s =
|
|
977
|
-
|
|
980
|
+
const e = o.getState().cogsStateStore[t], s = Lt(e, d).newDocument;
|
|
981
|
+
_t(
|
|
978
982
|
t,
|
|
979
983
|
o.getState().initialStateGlobal[t],
|
|
980
984
|
s,
|
|
@@ -984,19 +988,19 @@ function mt(t, c, m, f) {
|
|
|
984
988
|
);
|
|
985
989
|
const i = o.getState().stateComponents.get(t);
|
|
986
990
|
if (i) {
|
|
987
|
-
const g =
|
|
991
|
+
const g = Et(e, s), u = new Set(g);
|
|
988
992
|
for (const [
|
|
989
993
|
T,
|
|
990
994
|
w
|
|
991
995
|
] of i.components.entries()) {
|
|
992
996
|
let $ = !1;
|
|
993
|
-
const
|
|
994
|
-
if (!
|
|
995
|
-
if (
|
|
997
|
+
const P = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
|
|
998
|
+
if (!P.includes("none")) {
|
|
999
|
+
if (P.includes("all")) {
|
|
996
1000
|
w.forceUpdate();
|
|
997
1001
|
continue;
|
|
998
1002
|
}
|
|
999
|
-
if (
|
|
1003
|
+
if (P.includes("component") && (w.paths.has("") && ($ = !0), !$))
|
|
1000
1004
|
for (const C of u) {
|
|
1001
1005
|
if (w.paths.has(C)) {
|
|
1002
1006
|
$ = !0;
|
|
@@ -1004,8 +1008,8 @@ function mt(t, c, m, f) {
|
|
|
1004
1008
|
}
|
|
1005
1009
|
let _ = C.lastIndexOf(".");
|
|
1006
1010
|
for (; _ !== -1; ) {
|
|
1007
|
-
const
|
|
1008
|
-
if (w.paths.has(
|
|
1011
|
+
const U = C.substring(0, _);
|
|
1012
|
+
if (w.paths.has(U)) {
|
|
1009
1013
|
$ = !0;
|
|
1010
1014
|
break;
|
|
1011
1015
|
}
|
|
@@ -1013,23 +1017,23 @@ function mt(t, c, m, f) {
|
|
|
1013
1017
|
_ + 1
|
|
1014
1018
|
);
|
|
1015
1019
|
if (!isNaN(Number(H))) {
|
|
1016
|
-
const
|
|
1017
|
-
if (
|
|
1018
|
-
const
|
|
1020
|
+
const b = U.lastIndexOf(".");
|
|
1021
|
+
if (b !== -1) {
|
|
1022
|
+
const V = U.substring(
|
|
1019
1023
|
0,
|
|
1020
|
-
|
|
1024
|
+
b
|
|
1021
1025
|
);
|
|
1022
|
-
if (w.paths.has(
|
|
1026
|
+
if (w.paths.has(V)) {
|
|
1023
1027
|
$ = !0;
|
|
1024
1028
|
break;
|
|
1025
1029
|
}
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
|
-
_ =
|
|
1032
|
+
_ = U.lastIndexOf(".");
|
|
1029
1033
|
}
|
|
1030
1034
|
if ($) break;
|
|
1031
1035
|
}
|
|
1032
|
-
if (!$ &&
|
|
1036
|
+
if (!$ && P.includes("deps") && w.depsFunction) {
|
|
1033
1037
|
const C = w.depsFunction(s);
|
|
1034
1038
|
let _ = !1;
|
|
1035
1039
|
typeof C == "boolean" ? C && (_ = !0) : B(w.deps, C) || (w.deps = C, _ = !0), _ && ($ = !0);
|
|
@@ -1057,7 +1061,7 @@ function mt(t, c, m, f) {
|
|
|
1057
1061
|
return i.success ? !0 : (i.error.errors.forEach((u) => {
|
|
1058
1062
|
const T = u.path, w = u.message, $ = [d.key, ...T].join(".");
|
|
1059
1063
|
e($, w);
|
|
1060
|
-
}),
|
|
1064
|
+
}), ht(t), !1);
|
|
1061
1065
|
} catch (s) {
|
|
1062
1066
|
return console.error("Zod schema validation failed", s), !1;
|
|
1063
1067
|
}
|
|
@@ -1066,7 +1070,7 @@ function mt(t, c, m, f) {
|
|
|
1066
1070
|
if (l === "getComponents")
|
|
1067
1071
|
return () => o().stateComponents.get(t);
|
|
1068
1072
|
if (l === "getAllFormRefs")
|
|
1069
|
-
return () =>
|
|
1073
|
+
return () => kt.getState().getFormRefsByStateKey(t);
|
|
1070
1074
|
if (l === "_initialState")
|
|
1071
1075
|
return o.getState().initialStateGlobal[t];
|
|
1072
1076
|
if (l === "_serverState")
|
|
@@ -1079,13 +1083,13 @@ function mt(t, c, m, f) {
|
|
|
1079
1083
|
if (l === "removeValidation") return I.removeValidation;
|
|
1080
1084
|
}
|
|
1081
1085
|
if (l === "getFormRef")
|
|
1082
|
-
return () =>
|
|
1086
|
+
return () => kt.getState().getFormRef(t + "." + n.join("."));
|
|
1083
1087
|
if (l === "validationWrapper")
|
|
1084
1088
|
return ({
|
|
1085
1089
|
children: d,
|
|
1086
1090
|
hideMessage: e
|
|
1087
|
-
}) => /* @__PURE__ */
|
|
1088
|
-
|
|
1091
|
+
}) => /* @__PURE__ */ wt(
|
|
1092
|
+
Dt,
|
|
1089
1093
|
{
|
|
1090
1094
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1091
1095
|
path: n,
|
|
@@ -1101,21 +1105,21 @@ function mt(t, c, m, f) {
|
|
|
1101
1105
|
if (l === "update")
|
|
1102
1106
|
return (d, e) => {
|
|
1103
1107
|
if (e?.debounce)
|
|
1104
|
-
|
|
1105
|
-
|
|
1108
|
+
Ut(() => {
|
|
1109
|
+
at(c, d, n, "");
|
|
1106
1110
|
const r = o.getState().getNestedState(t, n);
|
|
1107
1111
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1108
1112
|
}, e.debounce);
|
|
1109
1113
|
else {
|
|
1110
|
-
|
|
1114
|
+
at(c, d, n, "");
|
|
1111
1115
|
const r = o.getState().getNestedState(t, n);
|
|
1112
1116
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1113
1117
|
}
|
|
1114
1118
|
p(n);
|
|
1115
1119
|
};
|
|
1116
1120
|
if (l === "formElement")
|
|
1117
|
-
return (d, e) => /* @__PURE__ */
|
|
1118
|
-
|
|
1121
|
+
return (d, e) => /* @__PURE__ */ wt(
|
|
1122
|
+
Wt,
|
|
1119
1123
|
{
|
|
1120
1124
|
setState: c,
|
|
1121
1125
|
stateKey: t,
|
|
@@ -1137,10 +1141,10 @@ function mt(t, c, m, f) {
|
|
|
1137
1141
|
o.getState().getNestedState(t, [])
|
|
1138
1142
|
);
|
|
1139
1143
|
}
|
|
1140
|
-
function
|
|
1141
|
-
return
|
|
1144
|
+
function Ct(t) {
|
|
1145
|
+
return it(Kt, { proxy: t });
|
|
1142
1146
|
}
|
|
1143
|
-
function
|
|
1147
|
+
function Qt({
|
|
1144
1148
|
proxy: t,
|
|
1145
1149
|
rebuildStateShape: c
|
|
1146
1150
|
}) {
|
|
@@ -1152,11 +1156,11 @@ function Kt({
|
|
|
1152
1156
|
(y, k, p, I, a) => t._mapFn(y, k, p, I, a)
|
|
1153
1157
|
) : null;
|
|
1154
1158
|
}
|
|
1155
|
-
function
|
|
1159
|
+
function Kt({
|
|
1156
1160
|
proxy: t
|
|
1157
1161
|
}) {
|
|
1158
1162
|
const c = J(null), m = `${t._stateKey}-${t._path.join(".")}`;
|
|
1159
|
-
return
|
|
1163
|
+
return st(() => {
|
|
1160
1164
|
const f = c.current;
|
|
1161
1165
|
if (!f || !f.parentElement) return;
|
|
1162
1166
|
const y = f.parentElement, p = Array.from(y.childNodes).indexOf(f);
|
|
@@ -1185,14 +1189,14 @@ function te({
|
|
|
1185
1189
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1186
1190
|
const G = document.createTextNode(String(S));
|
|
1187
1191
|
f.replaceWith(G);
|
|
1188
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1192
|
+
}, [t._stateKey, t._path.join("."), t._effect]), it("span", {
|
|
1189
1193
|
ref: c,
|
|
1190
1194
|
style: { display: "none" },
|
|
1191
1195
|
"data-signal-id": m
|
|
1192
1196
|
});
|
|
1193
1197
|
}
|
|
1194
|
-
function
|
|
1195
|
-
const c =
|
|
1198
|
+
function me(t) {
|
|
1199
|
+
const c = Ot(
|
|
1196
1200
|
(m) => {
|
|
1197
1201
|
const f = o.getState().stateComponents.get(t._stateKey) || {
|
|
1198
1202
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1204,22 +1208,22 @@ function ye(t) {
|
|
|
1204
1208
|
},
|
|
1205
1209
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1206
1210
|
);
|
|
1207
|
-
return
|
|
1211
|
+
return it("text", {}, String(c));
|
|
1208
1212
|
}
|
|
1209
|
-
function
|
|
1213
|
+
function te({
|
|
1210
1214
|
stateKey: t,
|
|
1211
1215
|
itemComponentId: c,
|
|
1212
1216
|
itemPath: m,
|
|
1213
1217
|
children: f
|
|
1214
1218
|
}) {
|
|
1215
|
-
const [, y] =
|
|
1216
|
-
return
|
|
1219
|
+
const [, y] = et({}), [k, p] = Ht(), I = J(null);
|
|
1220
|
+
return st(() => {
|
|
1217
1221
|
p.height > 0 && p.height !== I.current && (I.current = p.height, o.getState().setShadowMetadata(t, m, {
|
|
1218
1222
|
virtualizer: {
|
|
1219
1223
|
itemHeight: p.height
|
|
1220
1224
|
}
|
|
1221
1225
|
}));
|
|
1222
|
-
}, [p.height, t, m]),
|
|
1226
|
+
}, [p.height, t, m]), gt(() => {
|
|
1223
1227
|
const a = `${t}////${c}`, v = o.getState().stateComponents.get(t) || {
|
|
1224
1228
|
components: /* @__PURE__ */ new Map()
|
|
1225
1229
|
};
|
|
@@ -1230,14 +1234,14 @@ function ee({
|
|
|
1230
1234
|
const n = o.getState().stateComponents.get(t);
|
|
1231
1235
|
n && n.components.delete(a);
|
|
1232
1236
|
};
|
|
1233
|
-
}, [t, c, m.join(".")]), /* @__PURE__ */
|
|
1237
|
+
}, [t, c, m.join(".")]), /* @__PURE__ */ wt("div", { ref: k, children: f });
|
|
1234
1238
|
}
|
|
1235
1239
|
export {
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1240
|
+
Ct as $cogsSignal,
|
|
1241
|
+
me as $cogsSignalStore,
|
|
1242
|
+
ge as addStateOptions,
|
|
1243
|
+
fe as createCogsState,
|
|
1244
|
+
Se as notifyComponent,
|
|
1245
|
+
Xt as useCogsStateFn
|
|
1242
1246
|
};
|
|
1243
1247
|
//# sourceMappingURL=CogsState.jsx.map
|