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