cogsbox-state 0.5.302 → 0.5.303
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 +442 -415
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +67 -25
package/dist/CogsState.jsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
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 Et } from "react/jsx-runtime";
|
|
3
|
+
import { useState as ot, useRef as J, useEffect as lt, useLayoutEffect as St, useMemo as At, createElement as dt, useSyncExternalStore as Ft, startTransition as Ut, useCallback as wt } from "react";
|
|
4
|
+
import { transformStateFunc as Dt, isDeepEqual as q, isFunction as Q, getNestedValue as Y, getDifferences as $t, debounce as Wt } from "./utility.js";
|
|
5
|
+
import { pushFunc as Tt, updateFn as ct, cutFunc as ft, ValidationWrapper as Gt, FormControlComponent as Lt } from "./Functions.jsx";
|
|
6
|
+
import Ht from "superjson";
|
|
7
|
+
import { v4 as kt } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
13
|
-
function
|
|
9
|
+
import { getGlobalStore as o, formRefStore as Vt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as _t } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as zt } from "fast-json-patch";
|
|
12
|
+
import Bt from "react-use-measure";
|
|
13
|
+
function Nt(t, c) {
|
|
14
14
|
const m = o.getState().getInitialOptions, f = o.getState().setInitialStateOptions, y = m(t) || {};
|
|
15
15
|
f(t, {
|
|
16
16
|
...y,
|
|
17
17
|
...c
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Ct({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: c,
|
|
23
23
|
initialOptionsPart: m
|
|
24
24
|
}) {
|
|
25
|
-
const f =
|
|
25
|
+
const f = st(t) || {}, y = m[t] || {}, k = o.getState().setInitialStateOptions, p = { ...y, ...f };
|
|
26
26
|
let I = !1;
|
|
27
27
|
if (c)
|
|
28
28
|
for (const a in c)
|
|
29
29
|
p.hasOwnProperty(a) ? (a == "localStorage" && c[a] && p[a].key !== c[a]?.key && (I = !0, p[a] = c[a]), a == "initialState" && c[a] && p[a] !== c[a] && // Different references
|
|
30
|
-
!
|
|
30
|
+
!q(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 Se(t, { formElements: c, validation: m }) {
|
|
34
34
|
return { initialState: t, formElements: c, validation: m };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const me = (t, c) => {
|
|
37
37
|
let m = t;
|
|
38
|
-
const [f, y] =
|
|
38
|
+
const [f, y] = Dt(m);
|
|
39
39
|
(Object.keys(y).length > 0 || c && Object.keys(c).length > 0) && Object.keys(y).forEach((I) => {
|
|
40
40
|
y[I] = y[I] || {}, y[I].formElements = {
|
|
41
41
|
...c?.formElements,
|
|
@@ -43,16 +43,16 @@ const fe = (t, c) => {
|
|
|
43
43
|
...c?.validation,
|
|
44
44
|
...y[I].formElements || {}
|
|
45
45
|
// State-specific overrides
|
|
46
|
-
},
|
|
46
|
+
}, st(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] = ot(a?.componentId ?? kt());
|
|
50
|
+
Ct({
|
|
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, [
|
|
55
|
+
const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [L, O] = Kt(
|
|
56
56
|
S,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -71,46 +71,46 @@ const fe = (t, c) => {
|
|
|
71
71
|
return O;
|
|
72
72
|
};
|
|
73
73
|
function p(I, a) {
|
|
74
|
-
|
|
74
|
+
Ct({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Xt(I, a), yt(I);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: k, setCogsOptions: p };
|
|
77
77
|
}, {
|
|
78
|
-
setUpdaterState:
|
|
79
|
-
setState:
|
|
80
|
-
getInitialOptions:
|
|
81
|
-
getKeyState:
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
86
|
-
removeValidationError:
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = o.getState(),
|
|
78
|
+
setUpdaterState: mt,
|
|
79
|
+
setState: at,
|
|
80
|
+
getInitialOptions: st,
|
|
81
|
+
getKeyState: Mt,
|
|
82
|
+
getValidationErrors: qt,
|
|
83
|
+
setStateLog: Jt,
|
|
84
|
+
updateInitialStateGlobal: bt,
|
|
85
|
+
addValidationError: Yt,
|
|
86
|
+
removeValidationError: X,
|
|
87
|
+
setServerSyncActions: Zt
|
|
88
|
+
} = o.getState(), xt = (t, c, m, f, y) => {
|
|
89
89
|
m?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
91
91
|
c,
|
|
92
92
|
m.localStorage?.key,
|
|
93
93
|
f
|
|
94
94
|
);
|
|
95
|
-
const k =
|
|
95
|
+
const k = Q(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
|
|
96
96
|
if (k && f) {
|
|
97
97
|
const p = `${f}-${c}-${k}`;
|
|
98
98
|
let I;
|
|
99
99
|
try {
|
|
100
|
-
I =
|
|
100
|
+
I = vt(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 = Ht.serialize(a);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
p,
|
|
110
110
|
JSON.stringify(v.json)
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
-
},
|
|
113
|
+
}, vt = (t) => {
|
|
114
114
|
if (!t) return null;
|
|
115
115
|
try {
|
|
116
116
|
const c = window.localStorage.getItem(t);
|
|
@@ -118,20 +118,20 @@ const fe = (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
|
+
}, Xt = (t, c) => {
|
|
122
|
+
const m = o.getState().cogsStateStore[t], { sessionId: f } = _t(), y = Q(c?.localStorage?.key) ? c.localStorage.key(m) : c?.localStorage?.key;
|
|
123
123
|
if (y && f) {
|
|
124
|
-
const k =
|
|
124
|
+
const k = vt(
|
|
125
125
|
`${f}-${t}-${y}`
|
|
126
126
|
);
|
|
127
127
|
if (k && k.lastUpdated > (k.lastSyncedWithServer || 0))
|
|
128
|
-
return
|
|
128
|
+
return at(t, k.state), yt(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, Rt = (t, c, m, f, y, k) => {
|
|
132
132
|
const p = {
|
|
133
133
|
initialState: c,
|
|
134
|
-
updaterState:
|
|
134
|
+
updaterState: ht(
|
|
135
135
|
t,
|
|
136
136
|
f,
|
|
137
137
|
y,
|
|
@@ -139,8 +139,8 @@ const fe = (t, c) => {
|
|
|
139
139
|
),
|
|
140
140
|
state: m
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
},
|
|
142
|
+
bt(t, p.initialState), mt(t, p.updaterState), at(t, p.state);
|
|
143
|
+
}, yt = (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 fe = (t, c) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
m.forEach((f) => f());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, he = (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,22 +157,22 @@ const fe = (t, c) => {
|
|
|
157
157
|
return;
|
|
158
158
|
y && y.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Qt = (t, c, m, f) => {
|
|
161
161
|
switch (t) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
164
|
-
oldValue:
|
|
165
|
-
newValue:
|
|
164
|
+
oldValue: Y(c, f),
|
|
165
|
+
newValue: Y(m, f)
|
|
166
166
|
};
|
|
167
167
|
case "insert":
|
|
168
168
|
return {
|
|
169
169
|
oldValue: null,
|
|
170
170
|
// or undefined
|
|
171
|
-
newValue:
|
|
171
|
+
newValue: Y(m, f)
|
|
172
172
|
};
|
|
173
173
|
case "cut":
|
|
174
174
|
return {
|
|
175
|
-
oldValue:
|
|
175
|
+
oldValue: Y(c, f),
|
|
176
176
|
newValue: null
|
|
177
177
|
// or undefined
|
|
178
178
|
};
|
|
@@ -180,7 +180,7 @@ const fe = (t, c) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Kt(t, {
|
|
184
184
|
stateKey: c,
|
|
185
185
|
serverSync: m,
|
|
186
186
|
localStorage: f,
|
|
@@ -193,14 +193,14 @@ function Xt(t, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: S
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
197
|
-
let
|
|
198
|
-
const [h] =
|
|
196
|
+
const [L, O] = ot({}), { sessionId: F } = _t();
|
|
197
|
+
let H = !c;
|
|
198
|
+
const [h] = ot(c ?? kt()), l = o.getState().stateLog[h], ut = J(/* @__PURE__ */ new Set()), K = J(I ?? kt()), M = J(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
|
-
M.current =
|
|
201
|
+
M.current = st(h) ?? null, lt(() => {
|
|
202
202
|
if (v && v.stateKey === h && v.path?.[0]) {
|
|
203
|
-
|
|
203
|
+
at(h, (r) => ({
|
|
204
204
|
...r,
|
|
205
205
|
[v.path[0]]: v.newValue
|
|
206
206
|
}));
|
|
@@ -210,42 +210,42 @@ function Xt(t, {
|
|
|
210
210
|
userId: v.userId
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
}, [v]),
|
|
213
|
+
}, [v]), lt(() => {
|
|
214
214
|
if (a) {
|
|
215
|
-
|
|
215
|
+
Nt(h, {
|
|
216
216
|
initialState: a
|
|
217
217
|
});
|
|
218
218
|
const e = M.current, s = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, i = o.getState().initialStateGlobal[h];
|
|
219
|
-
if (!(i && !
|
|
219
|
+
if (!(i && !q(i, a) || !i) && !s)
|
|
220
220
|
return;
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
let
|
|
225
|
-
const
|
|
226
|
-
s &&
|
|
221
|
+
let g = null;
|
|
222
|
+
const E = Q(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
|
|
223
|
+
E && F && (g = vt(`${F}-${h}-${E}`));
|
|
224
|
+
let T = a, $ = !1;
|
|
225
|
+
const N = s ? Date.now() : 0, V = g?.lastUpdated || 0, P = g?.lastSyncedWithServer || 0;
|
|
226
|
+
s && N > V ? (T = e.serverState.data, $ = !0) : g && V > P && (T = g.state, e?.localStorage?.onChange && e?.localStorage?.onChange(T)), o.getState().initializeShadowState(h, a), Rt(
|
|
227
227
|
h,
|
|
228
228
|
a,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
), $ &&
|
|
229
|
+
T,
|
|
230
|
+
it,
|
|
231
|
+
K.current,
|
|
232
|
+
F
|
|
233
|
+
), $ && E && F && xt(T, h, e, F, Date.now()), yt(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
|
-
]),
|
|
241
|
-
|
|
240
|
+
]), St(() => {
|
|
241
|
+
H && Nt(h, {
|
|
242
242
|
serverSync: m,
|
|
243
243
|
formElements: y,
|
|
244
244
|
initialState: a,
|
|
245
245
|
localStorage: f,
|
|
246
246
|
middleware: M.current?.middleware
|
|
247
247
|
});
|
|
248
|
-
const e = `${h}////${
|
|
248
|
+
const e = `${h}////${K.current}`, r = o.getState().stateComponents.get(h) || {
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return r.components.set(e, {
|
|
@@ -258,182 +258,182 @@ function Xt(t, {
|
|
|
258
258
|
r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(h));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
261
|
-
const
|
|
261
|
+
const it = (e, r, s, i) => {
|
|
262
262
|
if (Array.isArray(r)) {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const g = `${h}-${r.join(".")}`;
|
|
264
|
+
ut.current.add(g);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
let
|
|
271
|
-
if ((!
|
|
272
|
-
const
|
|
273
|
-
if (Array.isArray(
|
|
274
|
-
|
|
275
|
-
const A = `${h}-${
|
|
276
|
-
|
|
266
|
+
const u = o.getState();
|
|
267
|
+
at(h, (g) => {
|
|
268
|
+
const E = Q(e) ? e(g) : e, T = `${h}-${r.join(".")}`;
|
|
269
|
+
if (T) {
|
|
270
|
+
let C = !1, w = u.signalDomElements.get(T);
|
|
271
|
+
if ((!w || w.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
|
|
272
|
+
const R = r.slice(0, -1), x = Y(E, R);
|
|
273
|
+
if (Array.isArray(x)) {
|
|
274
|
+
C = !0;
|
|
275
|
+
const A = `${h}-${R.join(".")}`;
|
|
276
|
+
w = u.signalDomElements.get(A);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
279
|
+
if (w) {
|
|
280
|
+
const R = C ? Y(E, r.slice(0, -1)) : Y(E, r);
|
|
281
|
+
w.forEach(({ parentId: x, position: A, effect: U }) => {
|
|
282
282
|
const j = document.querySelector(
|
|
283
|
-
`[data-parent-id="${
|
|
283
|
+
`[data-parent-id="${x}"]`
|
|
284
284
|
);
|
|
285
285
|
if (j) {
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
289
|
-
|
|
286
|
+
const B = Array.from(j.childNodes);
|
|
287
|
+
if (B[A]) {
|
|
288
|
+
const D = U ? new Function("state", `return (${U})(state)`)(R) : R;
|
|
289
|
+
B[A].textContent = String(D);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
console.log("shadowState",
|
|
295
|
+
console.log("shadowState", u.shadowStateStore), s.updateType === "update" && (i || M.current?.validation?.key) && r && X(
|
|
296
296
|
(i || M.current?.validation?.key) + "." + r.join(".")
|
|
297
297
|
);
|
|
298
298
|
const $ = r.slice(0, r.length - 1);
|
|
299
|
-
s.updateType === "cut" && M.current?.validation?.key &&
|
|
299
|
+
s.updateType === "cut" && M.current?.validation?.key && X(
|
|
300
300
|
M.current?.validation?.key + "." + $.join(".")
|
|
301
|
-
), s.updateType === "insert" && M.current?.validation?.key &&
|
|
301
|
+
), s.updateType === "insert" && M.current?.validation?.key && qt(
|
|
302
302
|
M.current?.validation?.key + "." + $.join(".")
|
|
303
|
-
).filter(([
|
|
304
|
-
let
|
|
305
|
-
if (
|
|
306
|
-
let A =
|
|
307
|
-
|
|
303
|
+
).filter(([w, R]) => {
|
|
304
|
+
let x = w?.split(".").length;
|
|
305
|
+
if (w == $.join(".") && x == $.length - 1) {
|
|
306
|
+
let A = w + "." + $;
|
|
307
|
+
X(w), Yt(A, R);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
310
|
+
const N = u.stateComponents.get(h);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", N), N) {
|
|
312
|
+
const C = $t(g, E), w = new Set(C), R = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
|
-
|
|
314
|
+
x,
|
|
315
315
|
A
|
|
316
|
-
] of
|
|
317
|
-
let
|
|
316
|
+
] of N.components.entries()) {
|
|
317
|
+
let U = !1;
|
|
318
318
|
const j = Array.isArray(A.reactiveType) ? A.reactiveType : [A.reactiveType || "component"];
|
|
319
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") && ((A.paths.has(
|
|
325
|
-
for (const
|
|
326
|
-
let
|
|
324
|
+
if (j.includes("component") && ((A.paths.has(R) || A.paths.has("")) && (U = !0), !U))
|
|
325
|
+
for (const B of w) {
|
|
326
|
+
let D = B;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (A.paths.has(
|
|
329
|
-
|
|
328
|
+
if (A.paths.has(D)) {
|
|
329
|
+
U = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
const W =
|
|
332
|
+
const b = D.lastIndexOf(".");
|
|
333
|
+
if (b !== -1) {
|
|
334
|
+
const W = D.substring(
|
|
335
335
|
0,
|
|
336
|
-
|
|
336
|
+
b
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
|
-
Number(
|
|
339
|
+
Number(D.substring(b + 1))
|
|
340
340
|
) && A.paths.has(W)) {
|
|
341
|
-
|
|
341
|
+
U = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
D = W;
|
|
345
345
|
} else
|
|
346
|
-
|
|
347
|
-
if (
|
|
346
|
+
D = "";
|
|
347
|
+
if (D === "")
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
if (
|
|
350
|
+
if (U) break;
|
|
351
351
|
}
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
354
|
-
let
|
|
355
|
-
typeof
|
|
352
|
+
if (!U && j.includes("deps") && A.depsFunction) {
|
|
353
|
+
const B = A.depsFunction(E);
|
|
354
|
+
let D = !1;
|
|
355
|
+
typeof B == "boolean" ? B && (D = !0) : q(A.deps, B) || (A.deps = B, D = !0), D && (U = !0);
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
U && A.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
const
|
|
362
|
-
r = r.map((
|
|
363
|
-
const
|
|
364
|
-
return
|
|
361
|
+
const V = Date.now();
|
|
362
|
+
r = r.map((C, w) => {
|
|
363
|
+
const R = r.slice(0, -1), x = Y(E, R);
|
|
364
|
+
return w === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (x.length - 1).toString() : C;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue:
|
|
366
|
+
const { oldValue: P, newValue: _ } = Qt(
|
|
367
367
|
s.updateType,
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
g,
|
|
369
|
+
E,
|
|
370
370
|
r
|
|
371
|
-
),
|
|
372
|
-
timeStamp:
|
|
371
|
+
), z = {
|
|
372
|
+
timeStamp: V,
|
|
373
373
|
stateKey: h,
|
|
374
374
|
path: r,
|
|
375
375
|
updateType: s.updateType,
|
|
376
376
|
status: "new",
|
|
377
|
-
oldValue:
|
|
378
|
-
newValue:
|
|
377
|
+
oldValue: P,
|
|
378
|
+
newValue: _
|
|
379
379
|
};
|
|
380
380
|
switch (s.updateType) {
|
|
381
381
|
case "update":
|
|
382
|
-
|
|
382
|
+
u.updateShadowAtPath(h, r, E);
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
|
|
385
|
+
const C = r.slice(0, -1);
|
|
386
|
+
u.insertShadowArrayElement(h, C, _);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
|
-
const
|
|
390
|
-
|
|
389
|
+
const w = r.slice(0, -1), R = parseInt(r[r.length - 1]);
|
|
390
|
+
u.removeShadowArrayElement(h, w, R);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
const
|
|
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) :
|
|
393
|
+
if (Jt(h, (C) => {
|
|
394
|
+
const R = [...C ?? [], z].reduce((x, A) => {
|
|
395
|
+
const U = `${A.stateKey}:${JSON.stringify(A.path)}`, j = x.get(U);
|
|
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) : x.set(U, { ...A }), x;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
|
-
return Array.from(
|
|
399
|
-
}),
|
|
400
|
-
|
|
398
|
+
return Array.from(R.values());
|
|
399
|
+
}), xt(
|
|
400
|
+
E,
|
|
401
401
|
h,
|
|
402
402
|
M.current,
|
|
403
|
-
|
|
403
|
+
F
|
|
404
404
|
), M.current?.middleware && M.current.middleware({
|
|
405
405
|
updateLog: l,
|
|
406
|
-
update:
|
|
406
|
+
update: z
|
|
407
407
|
}), M.current?.serverSync) {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
syncKey: typeof
|
|
411
|
-
rollBackState:
|
|
412
|
-
actionTimeStamp: Date.now() + (
|
|
408
|
+
const C = u.serverState[h], w = M.current?.serverSync;
|
|
409
|
+
Zt(h, {
|
|
410
|
+
syncKey: typeof w.syncKey == "string" ? w.syncKey : w.syncKey({ state: E }),
|
|
411
|
+
rollBackState: C,
|
|
412
|
+
actionTimeStamp: Date.now() + (w.debounce ?? 3e3),
|
|
413
413
|
status: "waiting"
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
|
-
return
|
|
416
|
+
return E;
|
|
417
417
|
});
|
|
418
418
|
};
|
|
419
|
-
o.getState().updaterState[h] || (
|
|
419
|
+
o.getState().updaterState[h] || (mt(
|
|
420
420
|
h,
|
|
421
|
-
|
|
421
|
+
ht(
|
|
422
422
|
h,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
it,
|
|
424
|
+
K.current,
|
|
425
|
+
F
|
|
426
426
|
)
|
|
427
|
-
), o.getState().cogsStateStore[h] ||
|
|
428
|
-
const d =
|
|
427
|
+
), o.getState().cogsStateStore[h] || at(h, t), o.getState().initialStateGlobal[h] || bt(h, t));
|
|
428
|
+
const d = At(() => ht(
|
|
429
429
|
h,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
), [h,
|
|
434
|
-
return [
|
|
430
|
+
it,
|
|
431
|
+
K.current,
|
|
432
|
+
F
|
|
433
|
+
), [h, F]);
|
|
434
|
+
return [Mt(h), d];
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function ht(t, c, m, f) {
|
|
437
437
|
const y = /* @__PURE__ */ new Map();
|
|
438
438
|
let k = 0;
|
|
439
439
|
const p = (v) => {
|
|
@@ -443,15 +443,15 @@ function St(t, c, m, f) {
|
|
|
443
443
|
k++;
|
|
444
444
|
}, I = {
|
|
445
445
|
removeValidation: (v) => {
|
|
446
|
-
v?.validationKey &&
|
|
446
|
+
v?.validationKey && X(v.validationKey);
|
|
447
447
|
},
|
|
448
448
|
revertToInitialState: (v) => {
|
|
449
449
|
const n = o.getState().getInitialOptions(t)?.validation;
|
|
450
|
-
n?.key &&
|
|
450
|
+
n?.key && X(n?.key), v?.validationKey && X(v.validationKey);
|
|
451
451
|
const S = o.getState().initialStateGlobal[t];
|
|
452
452
|
o.getState().clearSelectedIndexesForState(t), y.clear(), k++;
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const L = a(S, []), O = st(t), F = Q(O?.localStorage?.key) ? O?.localStorage?.key(S) : O?.localStorage?.key, H = `${f}-${t}-${F}`;
|
|
454
|
+
H && localStorage.removeItem(H), mt(t, L), at(t, S);
|
|
455
455
|
const h = o.getState().stateComponents.get(t);
|
|
456
456
|
return h && h.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -459,20 +459,20 @@ function St(t, c, m, f) {
|
|
|
459
459
|
},
|
|
460
460
|
updateInitialState: (v) => {
|
|
461
461
|
y.clear(), k++;
|
|
462
|
-
const n =
|
|
462
|
+
const n = ht(
|
|
463
463
|
t,
|
|
464
464
|
c,
|
|
465
465
|
m,
|
|
466
466
|
f
|
|
467
|
-
), S = o.getState().initialStateGlobal[t],
|
|
468
|
-
return localStorage.getItem(
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
467
|
+
), S = o.getState().initialStateGlobal[t], L = st(t), O = Q(L?.localStorage?.key) ? L?.localStorage?.key(S) : L?.localStorage?.key, F = `${f}-${t}-${O}`;
|
|
468
|
+
return localStorage.getItem(F) && localStorage.removeItem(F), Ut(() => {
|
|
469
|
+
bt(t, v), o.getState().initializeShadowState(t, v), mt(t, n), at(t, v);
|
|
470
|
+
const H = o.getState().stateComponents.get(t);
|
|
471
|
+
H && H.components.forEach((h) => {
|
|
472
472
|
h.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (H) => n.get()[H]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: o.getState().initialStateGlobal[t],
|
|
@@ -480,27 +480,27 @@ function St(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 &&
|
|
483
|
+
return !!(v && q(v, Mt(t)));
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(v, n = [], S) {
|
|
487
|
-
const
|
|
488
|
-
y.get(
|
|
487
|
+
const L = n.map(String).join(".");
|
|
488
|
+
y.get(L);
|
|
489
489
|
const O = function() {
|
|
490
490
|
return o().getNestedState(t, n);
|
|
491
491
|
};
|
|
492
492
|
Object.keys(I).forEach((h) => {
|
|
493
493
|
O[h] = I[h];
|
|
494
494
|
});
|
|
495
|
-
const
|
|
496
|
-
apply(h, l,
|
|
495
|
+
const F = {
|
|
496
|
+
apply(h, l, ut) {
|
|
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 ut = /* @__PURE__ */ new Set([
|
|
504
504
|
"insert",
|
|
505
505
|
"cut",
|
|
506
506
|
"cutByValue",
|
|
@@ -523,15 +523,15 @@ function St(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" && !ut.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);
|
|
530
530
|
if (r && !r.paths.has("")) {
|
|
531
531
|
const s = n.join(".");
|
|
532
532
|
let i = !0;
|
|
533
|
-
for (const
|
|
534
|
-
if (s.startsWith(
|
|
533
|
+
for (const u of r.paths)
|
|
534
|
+
if (s.startsWith(u) && (s === u || s[u.length] === ".")) {
|
|
535
535
|
i = !1;
|
|
536
536
|
break;
|
|
537
537
|
}
|
|
@@ -540,7 +540,7 @@ function St(t, c, m, f) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => $t(
|
|
544
544
|
o.getState().cogsStateStore[t],
|
|
545
545
|
o.getState().initialStateGlobal[t]
|
|
546
546
|
);
|
|
@@ -553,13 +553,13 @@ function St(t, c, m, f) {
|
|
|
553
553
|
try {
|
|
554
554
|
const i = await e.action(r);
|
|
555
555
|
if (i && !i.success && i.errors && s) {
|
|
556
|
-
o.getState().removeValidationError(s), i.errors.forEach((
|
|
557
|
-
const
|
|
558
|
-
o.getState().addValidationError(
|
|
556
|
+
o.getState().removeValidationError(s), i.errors.forEach((g) => {
|
|
557
|
+
const E = [s, ...g.path].join(".");
|
|
558
|
+
o.getState().addValidationError(E, g.message);
|
|
559
559
|
});
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
const u = o.getState().stateComponents.get(t);
|
|
561
|
+
u && u.components.forEach((g) => {
|
|
562
|
+
g.forceUpdate();
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
565
|
return i?.success && e.onSuccess ? e.onSuccess(i.data) : !i?.success && e.onError && e.onError(i.error), i;
|
|
@@ -568,20 +568,20 @@ function St(t, c, m, f) {
|
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
570
|
if (l === "_status") {
|
|
571
|
-
const d = o.getState().getNestedState(t, n), e = o.getState().initialStateGlobal[t], r =
|
|
572
|
-
return
|
|
571
|
+
const d = o.getState().getNestedState(t, n), e = o.getState().initialStateGlobal[t], r = Y(e, n);
|
|
572
|
+
return q(d, r) ? "fresh" : "stale";
|
|
573
573
|
}
|
|
574
574
|
if (l === "getStatus")
|
|
575
575
|
return function() {
|
|
576
576
|
const d = o().getNestedState(
|
|
577
577
|
t,
|
|
578
578
|
n
|
|
579
|
-
), e = o.getState().initialStateGlobal[t], r =
|
|
580
|
-
return
|
|
579
|
+
), e = o.getState().initialStateGlobal[t], r = Y(e, n);
|
|
580
|
+
return q(d, r) ? "fresh" : "stale";
|
|
581
581
|
};
|
|
582
582
|
if (l === "removeStorage")
|
|
583
583
|
return () => {
|
|
584
|
-
const d = o.getState().initialStateGlobal[t], e =
|
|
584
|
+
const d = o.getState().initialStateGlobal[t], e = st(t), r = Q(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, s = `${f}-${t}-${r}`;
|
|
585
585
|
s && localStorage.removeItem(s);
|
|
586
586
|
};
|
|
587
587
|
if (l === "showValidationErrors")
|
|
@@ -621,160 +621,187 @@ function St(t, c, m, f) {
|
|
|
621
621
|
itemHeight: r = 50,
|
|
622
622
|
overscan: s = 5,
|
|
623
623
|
stickToBottom: i = !1
|
|
624
|
-
} = e,
|
|
624
|
+
} = e, u = J(null), [g, E] = ot({
|
|
625
625
|
startIndex: 0,
|
|
626
626
|
endIndex: 10
|
|
627
|
-
}), [
|
|
628
|
-
() => $((
|
|
627
|
+
}), [T, $] = ot(0), N = wt(
|
|
628
|
+
() => $((b) => b + 1),
|
|
629
629
|
[]
|
|
630
|
-
),
|
|
631
|
-
|
|
632
|
-
const
|
|
630
|
+
), V = J(i), P = J(0), _ = J(!0), z = J(!1);
|
|
631
|
+
lt(() => {
|
|
632
|
+
const b = o.getState().subscribeToShadowState(t, N), W = setTimeout(N, 50);
|
|
633
633
|
return () => {
|
|
634
|
-
|
|
634
|
+
b(), clearTimeout(W);
|
|
635
635
|
};
|
|
636
|
-
}, [t,
|
|
637
|
-
const
|
|
636
|
+
}, [t, N]);
|
|
637
|
+
const C = o().getNestedState(
|
|
638
638
|
t,
|
|
639
639
|
n
|
|
640
|
-
),
|
|
641
|
-
const
|
|
642
|
-
let
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
640
|
+
), w = C.length, { totalHeight: R, positions: x, allItemsMeasured: A } = At(() => {
|
|
641
|
+
const b = o.getState().getShadowMetadata(t, n) || [];
|
|
642
|
+
let W = 0;
|
|
643
|
+
const tt = [];
|
|
644
|
+
let Z = !0;
|
|
645
|
+
for (let G = 0; G < w; G++) {
|
|
646
|
+
tt[G] = W;
|
|
647
|
+
const et = b[G]?.virtualizer?.itemHeight;
|
|
648
|
+
!et && w > 0 && (Z = !1), W += et || r;
|
|
648
649
|
}
|
|
649
|
-
return {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
650
|
+
return {
|
|
651
|
+
totalHeight: W,
|
|
652
|
+
positions: tt,
|
|
653
|
+
allItemsMeasured: Z
|
|
654
|
+
};
|
|
655
|
+
}, [w, t, n, r, T]), U = At(() => {
|
|
656
|
+
const b = Math.max(0, g.startIndex), W = Math.min(w, g.endIndex), tt = Array.from(
|
|
657
|
+
{ length: W - b },
|
|
658
|
+
(G, et) => b + et
|
|
659
|
+
), Z = tt.map((G) => C[G]);
|
|
660
|
+
return a(Z, n, {
|
|
656
661
|
...S,
|
|
657
|
-
validIndices:
|
|
662
|
+
validIndices: tt
|
|
658
663
|
});
|
|
659
|
-
}, [
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
const { scrollTop:
|
|
667
|
-
|
|
668
|
-
let
|
|
669
|
-
for (;
|
|
670
|
-
const
|
|
671
|
-
x[
|
|
664
|
+
}, [g.startIndex, g.endIndex, C, w]);
|
|
665
|
+
St(() => {
|
|
666
|
+
const b = u.current;
|
|
667
|
+
if (!b) return;
|
|
668
|
+
const W = V.current, tt = w > P.current;
|
|
669
|
+
P.current = w;
|
|
670
|
+
const Z = () => {
|
|
671
|
+
const { scrollTop: G, clientHeight: et, scrollHeight: jt } = b;
|
|
672
|
+
V.current = jt - G - et < 10;
|
|
673
|
+
let It = 0, gt = w - 1;
|
|
674
|
+
for (; It <= gt; ) {
|
|
675
|
+
const rt = Math.floor((It + gt) / 2);
|
|
676
|
+
x[rt] < G ? It = rt + 1 : gt = rt - 1;
|
|
672
677
|
}
|
|
673
|
-
const
|
|
674
|
-
let
|
|
675
|
-
const
|
|
676
|
-
for (;
|
|
677
|
-
|
|
678
|
-
|
|
678
|
+
const pt = Math.max(0, gt - s);
|
|
679
|
+
let nt = pt;
|
|
680
|
+
const Ot = G + et;
|
|
681
|
+
for (; nt < w && x[nt] < Ot; )
|
|
682
|
+
nt++;
|
|
683
|
+
nt = Math.min(w, nt + s), E((rt) => rt.startIndex !== pt || rt.endIndex !== nt ? { startIndex: pt, endIndex: nt } : rt);
|
|
679
684
|
};
|
|
680
|
-
|
|
685
|
+
if (b.addEventListener("scroll", Z, {
|
|
681
686
|
passive: !0
|
|
682
|
-
}), i
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
687
|
+
}), i)
|
|
688
|
+
if (_.current && !z.current) {
|
|
689
|
+
if (A && w > 0)
|
|
690
|
+
b.scrollTo({
|
|
691
|
+
top: b.scrollHeight,
|
|
692
|
+
behavior: "auto"
|
|
693
|
+
}), z.current = !0, _.current = !1;
|
|
694
|
+
else if (w > 0) {
|
|
695
|
+
const G = setTimeout(() => {
|
|
696
|
+
u.current && _.current && (u.current.scrollTo({
|
|
697
|
+
top: u.current.scrollHeight,
|
|
698
|
+
behavior: "auto"
|
|
699
|
+
}), z.current = !0, _.current = !1);
|
|
700
|
+
}, 100);
|
|
701
|
+
return () => clearTimeout(G);
|
|
702
|
+
}
|
|
703
|
+
} else !_.current && W && tt && requestAnimationFrame(() => {
|
|
704
|
+
b.scrollTo({
|
|
705
|
+
top: b.scrollHeight,
|
|
706
|
+
behavior: "smooth"
|
|
707
|
+
});
|
|
689
708
|
});
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
709
|
+
else
|
|
710
|
+
_.current = !1;
|
|
711
|
+
return Z(), () => b.removeEventListener("scroll", Z);
|
|
712
|
+
}, [
|
|
713
|
+
w,
|
|
714
|
+
x,
|
|
715
|
+
s,
|
|
716
|
+
i,
|
|
717
|
+
A
|
|
718
|
+
]);
|
|
719
|
+
const j = wt(
|
|
720
|
+
(b = "smooth") => {
|
|
721
|
+
u.current && u.current.scrollTo({
|
|
722
|
+
top: u.current.scrollHeight,
|
|
723
|
+
behavior: b
|
|
697
724
|
});
|
|
698
725
|
},
|
|
699
726
|
[]
|
|
700
|
-
),
|
|
701
|
-
(
|
|
702
|
-
|
|
703
|
-
top: x[
|
|
704
|
-
behavior:
|
|
727
|
+
), B = wt(
|
|
728
|
+
(b, W = "smooth") => {
|
|
729
|
+
u.current && x[b] !== void 0 && u.current.scrollTo({
|
|
730
|
+
top: x[b],
|
|
731
|
+
behavior: W
|
|
705
732
|
});
|
|
706
733
|
},
|
|
707
734
|
[x]
|
|
708
|
-
),
|
|
735
|
+
), D = {
|
|
709
736
|
outer: {
|
|
710
|
-
ref:
|
|
737
|
+
ref: u,
|
|
711
738
|
style: { overflowY: "auto", height: "100%" }
|
|
712
739
|
},
|
|
713
740
|
inner: {
|
|
714
741
|
style: {
|
|
715
|
-
height: `${
|
|
742
|
+
height: `${R}px`,
|
|
716
743
|
position: "relative"
|
|
717
744
|
}
|
|
718
745
|
},
|
|
719
746
|
list: {
|
|
720
747
|
style: {
|
|
721
|
-
transform: `translateY(${x[
|
|
748
|
+
transform: `translateY(${x[g.startIndex] || 0}px)`
|
|
722
749
|
}
|
|
723
750
|
}
|
|
724
751
|
};
|
|
725
752
|
return {
|
|
726
|
-
virtualState:
|
|
727
|
-
virtualizerProps:
|
|
728
|
-
scrollToBottom:
|
|
729
|
-
scrollToIndex:
|
|
753
|
+
virtualState: U,
|
|
754
|
+
virtualizerProps: D,
|
|
755
|
+
scrollToBottom: j,
|
|
756
|
+
scrollToIndex: B
|
|
730
757
|
};
|
|
731
758
|
};
|
|
732
759
|
if (l === "stateSort")
|
|
733
760
|
return (e) => {
|
|
734
761
|
const s = [...d()].sort(
|
|
735
|
-
(
|
|
736
|
-
), i = s.map(({ item:
|
|
762
|
+
(g, E) => e(g.item, E.item)
|
|
763
|
+
), i = s.map(({ item: g }) => g), u = {
|
|
737
764
|
...S,
|
|
738
765
|
validIndices: s.map(
|
|
739
|
-
({ originalIndex:
|
|
766
|
+
({ originalIndex: g }) => g
|
|
740
767
|
)
|
|
741
768
|
};
|
|
742
|
-
return a(i, n,
|
|
769
|
+
return a(i, n, u);
|
|
743
770
|
};
|
|
744
771
|
if (l === "stateFilter")
|
|
745
772
|
return (e) => {
|
|
746
773
|
const s = d().filter(
|
|
747
|
-
({ item:
|
|
748
|
-
), i = s.map(({ item:
|
|
774
|
+
({ item: g }, E) => e(g, E)
|
|
775
|
+
), i = s.map(({ item: g }) => g), u = {
|
|
749
776
|
...S,
|
|
750
777
|
validIndices: s.map(
|
|
751
|
-
({ originalIndex:
|
|
778
|
+
({ originalIndex: g }) => g
|
|
752
779
|
)
|
|
753
780
|
};
|
|
754
|
-
return a(i, n,
|
|
781
|
+
return a(i, n, u);
|
|
755
782
|
};
|
|
756
783
|
if (l === "stateMap")
|
|
757
784
|
return (e) => {
|
|
758
785
|
const r = o.getState().getNestedState(t, n);
|
|
759
|
-
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i,
|
|
760
|
-
const
|
|
761
|
-
return e(
|
|
786
|
+
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
|
|
787
|
+
const g = r[i], E = [...n, i.toString()], T = a(g, E, S);
|
|
788
|
+
return e(g, T, {
|
|
762
789
|
register: () => {
|
|
763
|
-
const [,
|
|
764
|
-
|
|
765
|
-
const
|
|
790
|
+
const [, N] = ot({}), V = `${m}-${n.join(".")}-${i}`;
|
|
791
|
+
St(() => {
|
|
792
|
+
const P = `${t}////${V}`, _ = o.getState().stateComponents.get(t) || {
|
|
766
793
|
components: /* @__PURE__ */ new Map()
|
|
767
794
|
};
|
|
768
|
-
return
|
|
769
|
-
forceUpdate: () =>
|
|
770
|
-
paths: /* @__PURE__ */ new Set([
|
|
771
|
-
}), o.getState().stateComponents.set(t,
|
|
772
|
-
const
|
|
773
|
-
|
|
795
|
+
return _.components.set(P, {
|
|
796
|
+
forceUpdate: () => N({}),
|
|
797
|
+
paths: /* @__PURE__ */ new Set([E.join(".")])
|
|
798
|
+
}), o.getState().stateComponents.set(t, _), () => {
|
|
799
|
+
const z = o.getState().stateComponents.get(t);
|
|
800
|
+
z && z.components.delete(P);
|
|
774
801
|
};
|
|
775
|
-
}, [t,
|
|
802
|
+
}, [t, V]);
|
|
776
803
|
},
|
|
777
|
-
index:
|
|
804
|
+
index: u,
|
|
778
805
|
originalIndex: i
|
|
779
806
|
});
|
|
780
807
|
}) : (console.warn(
|
|
@@ -784,19 +811,19 @@ function St(t, c, m, f) {
|
|
|
784
811
|
};
|
|
785
812
|
if (l === "stateMapNoRender")
|
|
786
813
|
return (e) => v.map((s, i) => {
|
|
787
|
-
let
|
|
788
|
-
S?.validIndices && S.validIndices[i] !== void 0 ?
|
|
789
|
-
const
|
|
814
|
+
let u;
|
|
815
|
+
S?.validIndices && S.validIndices[i] !== void 0 ? u = S.validIndices[i] : u = i;
|
|
816
|
+
const g = [...n, u.toString()], E = a(s, g, S);
|
|
790
817
|
return e(
|
|
791
818
|
s,
|
|
792
|
-
|
|
819
|
+
E,
|
|
793
820
|
i,
|
|
794
821
|
v,
|
|
795
822
|
a(v, n, S)
|
|
796
823
|
);
|
|
797
824
|
});
|
|
798
825
|
if (l === "$stateMap")
|
|
799
|
-
return (e) =>
|
|
826
|
+
return (e) => dt(te, {
|
|
800
827
|
proxy: {
|
|
801
828
|
_stateKey: t,
|
|
802
829
|
_path: n,
|
|
@@ -808,17 +835,17 @@ function St(t, c, m, f) {
|
|
|
808
835
|
if (l === "stateList")
|
|
809
836
|
return (e) => {
|
|
810
837
|
const r = o.getState().getNestedState(t, n);
|
|
811
|
-
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i,
|
|
812
|
-
const
|
|
813
|
-
return
|
|
838
|
+
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
|
|
839
|
+
const g = r[i], E = [...n, i.toString()], T = a(g, E, S), $ = `${m}-${n.join(".")}-${i}`;
|
|
840
|
+
return dt(ne, {
|
|
814
841
|
key: i,
|
|
815
842
|
stateKey: t,
|
|
816
843
|
itemComponentId: $,
|
|
817
|
-
itemPath:
|
|
844
|
+
itemPath: E,
|
|
818
845
|
children: e(
|
|
819
|
-
u,
|
|
820
|
-
w,
|
|
821
846
|
g,
|
|
847
|
+
T,
|
|
848
|
+
u,
|
|
822
849
|
r,
|
|
823
850
|
a(r, n, S)
|
|
824
851
|
)
|
|
@@ -853,36 +880,36 @@ function St(t, c, m, f) {
|
|
|
853
880
|
return a(s, i);
|
|
854
881
|
};
|
|
855
882
|
if (l === "insert")
|
|
856
|
-
return (e) => (p(n),
|
|
883
|
+
return (e) => (p(n), Tt(c, e, n, t), a(
|
|
857
884
|
o.getState().getNestedState(t, n),
|
|
858
885
|
n
|
|
859
886
|
));
|
|
860
887
|
if (l === "uniqueInsert")
|
|
861
888
|
return (e, r, s) => {
|
|
862
|
-
const i = o.getState().getNestedState(t, n),
|
|
863
|
-
let
|
|
864
|
-
if (!i.some((
|
|
889
|
+
const i = o.getState().getNestedState(t, n), u = Q(e) ? e(i) : e;
|
|
890
|
+
let g = null;
|
|
891
|
+
if (!i.some((T) => {
|
|
865
892
|
if (r) {
|
|
866
|
-
const
|
|
867
|
-
(
|
|
893
|
+
const N = r.every(
|
|
894
|
+
(V) => q(T[V], u[V])
|
|
868
895
|
);
|
|
869
|
-
return
|
|
896
|
+
return N && (g = T), N;
|
|
870
897
|
}
|
|
871
|
-
const $ =
|
|
872
|
-
return $ && (
|
|
898
|
+
const $ = q(T, u);
|
|
899
|
+
return $ && (g = T), $;
|
|
873
900
|
}))
|
|
874
|
-
p(n),
|
|
875
|
-
else if (s &&
|
|
876
|
-
const
|
|
877
|
-
(
|
|
901
|
+
p(n), Tt(c, u, n, t);
|
|
902
|
+
else if (s && g) {
|
|
903
|
+
const T = s(g), $ = i.map(
|
|
904
|
+
(N) => q(N, g) ? T : N
|
|
878
905
|
);
|
|
879
|
-
p(n),
|
|
906
|
+
p(n), ct(c, $, n);
|
|
880
907
|
}
|
|
881
908
|
};
|
|
882
909
|
if (l === "cut")
|
|
883
910
|
return (e, r) => {
|
|
884
911
|
if (!r?.waitForSync)
|
|
885
|
-
return p(n),
|
|
912
|
+
return p(n), ft(c, n, t, e), a(
|
|
886
913
|
o.getState().getNestedState(t, n),
|
|
887
914
|
n
|
|
888
915
|
);
|
|
@@ -890,17 +917,17 @@ function St(t, c, m, f) {
|
|
|
890
917
|
if (l === "cutByValue")
|
|
891
918
|
return (e) => {
|
|
892
919
|
for (let r = 0; r < v.length; r++)
|
|
893
|
-
v[r] === e &&
|
|
920
|
+
v[r] === e && ft(c, n, t, r);
|
|
894
921
|
};
|
|
895
922
|
if (l === "toggleByValue")
|
|
896
923
|
return (e) => {
|
|
897
924
|
const r = v.findIndex((s) => s === e);
|
|
898
|
-
r > -1 ?
|
|
925
|
+
r > -1 ? ft(c, n, t, r) : Tt(c, e, n, t);
|
|
899
926
|
};
|
|
900
927
|
if (l === "stateFind")
|
|
901
928
|
return (e) => {
|
|
902
929
|
const s = d().find(
|
|
903
|
-
({ item:
|
|
930
|
+
({ item: u }, g) => e(u, g)
|
|
904
931
|
);
|
|
905
932
|
if (!s) return;
|
|
906
933
|
const i = [...n, s.originalIndex.toString()];
|
|
@@ -909,22 +936,22 @@ function St(t, c, m, f) {
|
|
|
909
936
|
if (l === "findWith")
|
|
910
937
|
return (e, r) => {
|
|
911
938
|
const i = d().find(
|
|
912
|
-
({ item:
|
|
939
|
+
({ item: g }) => g[e] === r
|
|
913
940
|
);
|
|
914
941
|
if (!i) return;
|
|
915
|
-
const
|
|
916
|
-
return a(i.item,
|
|
942
|
+
const u = [...n, i.originalIndex.toString()];
|
|
943
|
+
return a(i.item, u, S);
|
|
917
944
|
};
|
|
918
945
|
}
|
|
919
|
-
const
|
|
920
|
-
if (!isNaN(Number(
|
|
946
|
+
const K = n[n.length - 1];
|
|
947
|
+
if (!isNaN(Number(K))) {
|
|
921
948
|
const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
|
|
922
949
|
if (Array.isArray(e) && l === "cut")
|
|
923
|
-
return () =>
|
|
950
|
+
return () => ft(
|
|
924
951
|
c,
|
|
925
952
|
d,
|
|
926
953
|
t,
|
|
927
|
-
Number(
|
|
954
|
+
Number(K)
|
|
928
955
|
);
|
|
929
956
|
}
|
|
930
957
|
if (l === "get")
|
|
@@ -936,13 +963,13 @@ function St(t, c, m, f) {
|
|
|
936
963
|
return o.getState().getNestedState(t, n);
|
|
937
964
|
};
|
|
938
965
|
if (l === "$derive")
|
|
939
|
-
return (d) =>
|
|
966
|
+
return (d) => Pt({
|
|
940
967
|
_stateKey: t,
|
|
941
968
|
_path: n,
|
|
942
969
|
_effect: d.toString()
|
|
943
970
|
});
|
|
944
971
|
if (l === "$get")
|
|
945
|
-
return () =>
|
|
972
|
+
return () => Pt({
|
|
946
973
|
_stateKey: t,
|
|
947
974
|
_path: n
|
|
948
975
|
});
|
|
@@ -951,7 +978,7 @@ function St(t, c, m, f) {
|
|
|
951
978
|
return o.getState().getSyncInfo(d);
|
|
952
979
|
}
|
|
953
980
|
if (l == "getLocalStorage")
|
|
954
|
-
return (d) =>
|
|
981
|
+
return (d) => vt(f + "-" + t + "-" + d);
|
|
955
982
|
if (l === "_selected") {
|
|
956
983
|
const d = n.slice(0, -1), e = d.join("."), r = o.getState().getNestedState(t, d);
|
|
957
984
|
return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
|
|
@@ -961,7 +988,7 @@ function St(t, c, m, f) {
|
|
|
961
988
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), s = e.join(".");
|
|
962
989
|
d ? o.getState().setSelectedIndex(t, s, r) : o.getState().setSelectedIndex(t, s, void 0);
|
|
963
990
|
const i = o.getState().getNestedState(t, [...e]);
|
|
964
|
-
|
|
991
|
+
ct(c, i, e), p(e);
|
|
965
992
|
};
|
|
966
993
|
if (l === "toggleSelected")
|
|
967
994
|
return () => {
|
|
@@ -972,13 +999,13 @@ function St(t, c, m, f) {
|
|
|
972
999
|
s === e ? void 0 : e
|
|
973
1000
|
);
|
|
974
1001
|
const i = o.getState().getNestedState(t, [...d]);
|
|
975
|
-
|
|
1002
|
+
ct(c, i, d), p(d);
|
|
976
1003
|
};
|
|
977
1004
|
if (n.length == 0) {
|
|
978
1005
|
if (l === "applyJsonPatch")
|
|
979
1006
|
return (d) => {
|
|
980
|
-
const e = o.getState().cogsStateStore[t], s =
|
|
981
|
-
|
|
1007
|
+
const e = o.getState().cogsStateStore[t], s = zt(e, d).newDocument;
|
|
1008
|
+
Rt(
|
|
982
1009
|
t,
|
|
983
1010
|
o.getState().initialStateGlobal[t],
|
|
984
1011
|
s,
|
|
@@ -988,57 +1015,57 @@ function St(t, c, m, f) {
|
|
|
988
1015
|
);
|
|
989
1016
|
const i = o.getState().stateComponents.get(t);
|
|
990
1017
|
if (i) {
|
|
991
|
-
const
|
|
1018
|
+
const u = $t(e, s), g = new Set(u);
|
|
992
1019
|
for (const [
|
|
993
|
-
|
|
994
|
-
|
|
1020
|
+
E,
|
|
1021
|
+
T
|
|
995
1022
|
] of i.components.entries()) {
|
|
996
1023
|
let $ = !1;
|
|
997
|
-
const
|
|
998
|
-
if (!
|
|
999
|
-
if (
|
|
1000
|
-
|
|
1024
|
+
const N = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
|
|
1025
|
+
if (!N.includes("none")) {
|
|
1026
|
+
if (N.includes("all")) {
|
|
1027
|
+
T.forceUpdate();
|
|
1001
1028
|
continue;
|
|
1002
1029
|
}
|
|
1003
|
-
if (
|
|
1004
|
-
for (const
|
|
1005
|
-
if (
|
|
1030
|
+
if (N.includes("component") && (T.paths.has("") && ($ = !0), !$))
|
|
1031
|
+
for (const V of g) {
|
|
1032
|
+
if (T.paths.has(V)) {
|
|
1006
1033
|
$ = !0;
|
|
1007
1034
|
break;
|
|
1008
1035
|
}
|
|
1009
|
-
let
|
|
1010
|
-
for (;
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1036
|
+
let P = V.lastIndexOf(".");
|
|
1037
|
+
for (; P !== -1; ) {
|
|
1038
|
+
const _ = V.substring(0, P);
|
|
1039
|
+
if (T.paths.has(_)) {
|
|
1013
1040
|
$ = !0;
|
|
1014
1041
|
break;
|
|
1015
1042
|
}
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1043
|
+
const z = V.substring(
|
|
1044
|
+
P + 1
|
|
1018
1045
|
);
|
|
1019
|
-
if (!isNaN(Number(
|
|
1020
|
-
const
|
|
1021
|
-
if (
|
|
1022
|
-
const
|
|
1046
|
+
if (!isNaN(Number(z))) {
|
|
1047
|
+
const C = _.lastIndexOf(".");
|
|
1048
|
+
if (C !== -1) {
|
|
1049
|
+
const w = _.substring(
|
|
1023
1050
|
0,
|
|
1024
|
-
|
|
1051
|
+
C
|
|
1025
1052
|
);
|
|
1026
|
-
if (
|
|
1053
|
+
if (T.paths.has(w)) {
|
|
1027
1054
|
$ = !0;
|
|
1028
1055
|
break;
|
|
1029
1056
|
}
|
|
1030
1057
|
}
|
|
1031
1058
|
}
|
|
1032
|
-
|
|
1059
|
+
P = _.lastIndexOf(".");
|
|
1033
1060
|
}
|
|
1034
1061
|
if ($) break;
|
|
1035
1062
|
}
|
|
1036
|
-
if (!$ &&
|
|
1037
|
-
const
|
|
1038
|
-
let
|
|
1039
|
-
typeof
|
|
1063
|
+
if (!$ && N.includes("deps") && T.depsFunction) {
|
|
1064
|
+
const V = T.depsFunction(s);
|
|
1065
|
+
let P = !1;
|
|
1066
|
+
typeof V == "boolean" ? V && (P = !0) : q(T.deps, V) || (T.deps = V, P = !0), P && ($ = !0);
|
|
1040
1067
|
}
|
|
1041
|
-
$ &&
|
|
1068
|
+
$ && T.forceUpdate();
|
|
1042
1069
|
}
|
|
1043
1070
|
}
|
|
1044
1071
|
}
|
|
@@ -1050,18 +1077,18 @@ function St(t, c, m, f) {
|
|
|
1050
1077
|
throw new Error("Zod schema not found");
|
|
1051
1078
|
if (!d?.key)
|
|
1052
1079
|
throw new Error("Validation key not found");
|
|
1053
|
-
|
|
1080
|
+
X(d.key);
|
|
1054
1081
|
const r = o.getState().cogsStateStore[t];
|
|
1055
1082
|
try {
|
|
1056
1083
|
const s = o.getState().getValidationErrors(d.key);
|
|
1057
|
-
s && s.length > 0 && s.forEach(([
|
|
1058
|
-
|
|
1084
|
+
s && s.length > 0 && s.forEach(([u]) => {
|
|
1085
|
+
u && u.startsWith(d.key) && X(u);
|
|
1059
1086
|
});
|
|
1060
1087
|
const i = d.zodSchema.safeParse(r);
|
|
1061
|
-
return i.success ? !0 : (i.error.errors.forEach((
|
|
1062
|
-
const
|
|
1063
|
-
e($,
|
|
1064
|
-
}),
|
|
1088
|
+
return i.success ? !0 : (i.error.errors.forEach((g) => {
|
|
1089
|
+
const E = g.path, T = g.message, $ = [d.key, ...E].join(".");
|
|
1090
|
+
e($, T);
|
|
1091
|
+
}), yt(t), !1);
|
|
1065
1092
|
} catch (s) {
|
|
1066
1093
|
return console.error("Zod schema validation failed", s), !1;
|
|
1067
1094
|
}
|
|
@@ -1070,7 +1097,7 @@ function St(t, c, m, f) {
|
|
|
1070
1097
|
if (l === "getComponents")
|
|
1071
1098
|
return () => o().stateComponents.get(t);
|
|
1072
1099
|
if (l === "getAllFormRefs")
|
|
1073
|
-
return () =>
|
|
1100
|
+
return () => Vt.getState().getFormRefsByStateKey(t);
|
|
1074
1101
|
if (l === "_initialState")
|
|
1075
1102
|
return o.getState().initialStateGlobal[t];
|
|
1076
1103
|
if (l === "_serverState")
|
|
@@ -1083,13 +1110,13 @@ function St(t, c, m, f) {
|
|
|
1083
1110
|
if (l === "removeValidation") return I.removeValidation;
|
|
1084
1111
|
}
|
|
1085
1112
|
if (l === "getFormRef")
|
|
1086
|
-
return () =>
|
|
1113
|
+
return () => Vt.getState().getFormRef(t + "." + n.join("."));
|
|
1087
1114
|
if (l === "validationWrapper")
|
|
1088
1115
|
return ({
|
|
1089
1116
|
children: d,
|
|
1090
1117
|
hideMessage: e
|
|
1091
|
-
}) => /* @__PURE__ */
|
|
1092
|
-
|
|
1118
|
+
}) => /* @__PURE__ */ Et(
|
|
1119
|
+
Gt,
|
|
1093
1120
|
{
|
|
1094
1121
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1095
1122
|
path: n,
|
|
@@ -1105,21 +1132,21 @@ function St(t, c, m, f) {
|
|
|
1105
1132
|
if (l === "update")
|
|
1106
1133
|
return (d, e) => {
|
|
1107
1134
|
if (e?.debounce)
|
|
1108
|
-
|
|
1109
|
-
|
|
1135
|
+
Wt(() => {
|
|
1136
|
+
ct(c, d, n, "");
|
|
1110
1137
|
const r = o.getState().getNestedState(t, n);
|
|
1111
1138
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1112
1139
|
}, e.debounce);
|
|
1113
1140
|
else {
|
|
1114
|
-
|
|
1141
|
+
ct(c, d, n, "");
|
|
1115
1142
|
const r = o.getState().getNestedState(t, n);
|
|
1116
1143
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1117
1144
|
}
|
|
1118
1145
|
p(n);
|
|
1119
1146
|
};
|
|
1120
1147
|
if (l === "formElement")
|
|
1121
|
-
return (d, e) => /* @__PURE__ */
|
|
1122
|
-
|
|
1148
|
+
return (d, e) => /* @__PURE__ */ Et(
|
|
1149
|
+
Lt,
|
|
1123
1150
|
{
|
|
1124
1151
|
setState: c,
|
|
1125
1152
|
stateKey: t,
|
|
@@ -1128,23 +1155,23 @@ function St(t, c, m, f) {
|
|
|
1128
1155
|
formOpts: e
|
|
1129
1156
|
}
|
|
1130
1157
|
);
|
|
1131
|
-
const M = [...n, l],
|
|
1132
|
-
return a(
|
|
1158
|
+
const M = [...n, l], it = o.getState().getNestedState(t, M);
|
|
1159
|
+
return a(it, M, S);
|
|
1133
1160
|
}
|
|
1134
|
-
},
|
|
1135
|
-
return y.set(
|
|
1136
|
-
proxy:
|
|
1161
|
+
}, H = new Proxy(O, F);
|
|
1162
|
+
return y.set(L, {
|
|
1163
|
+
proxy: H,
|
|
1137
1164
|
stateVersion: k
|
|
1138
|
-
}),
|
|
1165
|
+
}), H;
|
|
1139
1166
|
}
|
|
1140
1167
|
return a(
|
|
1141
1168
|
o.getState().getNestedState(t, [])
|
|
1142
1169
|
);
|
|
1143
1170
|
}
|
|
1144
|
-
function
|
|
1145
|
-
return
|
|
1171
|
+
function Pt(t) {
|
|
1172
|
+
return dt(ee, { proxy: t });
|
|
1146
1173
|
}
|
|
1147
|
-
function
|
|
1174
|
+
function te({
|
|
1148
1175
|
proxy: t,
|
|
1149
1176
|
rebuildStateShape: c
|
|
1150
1177
|
}) {
|
|
@@ -1156,11 +1183,11 @@ function Qt({
|
|
|
1156
1183
|
(y, k, p, I, a) => t._mapFn(y, k, p, I, a)
|
|
1157
1184
|
) : null;
|
|
1158
1185
|
}
|
|
1159
|
-
function
|
|
1186
|
+
function ee({
|
|
1160
1187
|
proxy: t
|
|
1161
1188
|
}) {
|
|
1162
1189
|
const c = J(null), m = `${t._stateKey}-${t._path.join(".")}`;
|
|
1163
|
-
return
|
|
1190
|
+
return lt(() => {
|
|
1164
1191
|
const f = c.current;
|
|
1165
1192
|
if (!f || !f.parentElement) return;
|
|
1166
1193
|
const y = f.parentElement, p = Array.from(y.childNodes).indexOf(f);
|
|
@@ -1187,16 +1214,16 @@ function Kt({
|
|
|
1187
1214
|
else
|
|
1188
1215
|
S = n;
|
|
1189
1216
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1190
|
-
const
|
|
1191
|
-
f.replaceWith(
|
|
1192
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1217
|
+
const L = document.createTextNode(String(S));
|
|
1218
|
+
f.replaceWith(L);
|
|
1219
|
+
}, [t._stateKey, t._path.join("."), t._effect]), dt("span", {
|
|
1193
1220
|
ref: c,
|
|
1194
1221
|
style: { display: "none" },
|
|
1195
1222
|
"data-signal-id": m
|
|
1196
1223
|
});
|
|
1197
1224
|
}
|
|
1198
|
-
function
|
|
1199
|
-
const c =
|
|
1225
|
+
function ve(t) {
|
|
1226
|
+
const c = Ft(
|
|
1200
1227
|
(m) => {
|
|
1201
1228
|
const f = o.getState().stateComponents.get(t._stateKey) || {
|
|
1202
1229
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1208,22 +1235,22 @@ function me(t) {
|
|
|
1208
1235
|
},
|
|
1209
1236
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1210
1237
|
);
|
|
1211
|
-
return
|
|
1238
|
+
return dt("text", {}, String(c));
|
|
1212
1239
|
}
|
|
1213
|
-
function
|
|
1240
|
+
function ne({
|
|
1214
1241
|
stateKey: t,
|
|
1215
1242
|
itemComponentId: c,
|
|
1216
1243
|
itemPath: m,
|
|
1217
1244
|
children: f
|
|
1218
1245
|
}) {
|
|
1219
|
-
const [, y] =
|
|
1220
|
-
return
|
|
1246
|
+
const [, y] = ot({}), [k, p] = Bt(), I = J(null);
|
|
1247
|
+
return lt(() => {
|
|
1221
1248
|
p.height > 0 && p.height !== I.current && (I.current = p.height, o.getState().setShadowMetadata(t, m, {
|
|
1222
1249
|
virtualizer: {
|
|
1223
1250
|
itemHeight: p.height
|
|
1224
1251
|
}
|
|
1225
1252
|
}));
|
|
1226
|
-
}, [p.height, t, m]),
|
|
1253
|
+
}, [p.height, t, m]), St(() => {
|
|
1227
1254
|
const a = `${t}////${c}`, v = o.getState().stateComponents.get(t) || {
|
|
1228
1255
|
components: /* @__PURE__ */ new Map()
|
|
1229
1256
|
};
|
|
@@ -1234,14 +1261,14 @@ function te({
|
|
|
1234
1261
|
const n = o.getState().stateComponents.get(t);
|
|
1235
1262
|
n && n.components.delete(a);
|
|
1236
1263
|
};
|
|
1237
|
-
}, [t, c, m.join(".")]), /* @__PURE__ */
|
|
1264
|
+
}, [t, c, m.join(".")]), /* @__PURE__ */ Et("div", { ref: k, children: f });
|
|
1238
1265
|
}
|
|
1239
1266
|
export {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1267
|
+
Pt as $cogsSignal,
|
|
1268
|
+
ve as $cogsSignalStore,
|
|
1269
|
+
Se as addStateOptions,
|
|
1270
|
+
me as createCogsState,
|
|
1271
|
+
he as notifyComponent,
|
|
1272
|
+
Kt as useCogsStateFn
|
|
1246
1273
|
};
|
|
1247
1274
|
//# sourceMappingURL=CogsState.jsx.map
|