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