cogsbox-state 0.5.451 → 0.5.452
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.d.ts +1 -3
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +463 -477
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +5 -68
package/dist/CogsState.jsx
CHANGED
|
@@ -3,11 +3,11 @@ import { jsx as ot, Fragment as Ot } from "react/jsx-runtime";
|
|
|
3
3
|
import { memo as Ut, useState as K, useRef as q, useCallback as ct, useEffect as Z, useLayoutEffect as dt, useMemo as gt, createElement as lt, startTransition as Rt } from "react";
|
|
4
4
|
import { createRoot as At } from "react-dom/client";
|
|
5
5
|
import { transformStateFunc as Nt, isFunction as at, isArray as Tt, getDifferences as Ct, isDeepEqual as st } from "./utility.js";
|
|
6
|
-
import { ValidationWrapper as
|
|
6
|
+
import { ValidationWrapper as kt } from "./Functions.jsx";
|
|
7
7
|
import Ft from "superjson";
|
|
8
8
|
import { v4 as rt } from "uuid";
|
|
9
9
|
import { getGlobalStore as e, formRefStore as vt } from "./store.js";
|
|
10
|
-
import { useCogsConfig as
|
|
10
|
+
import { useCogsConfig as Pt } from "./CogsStateClient.jsx";
|
|
11
11
|
import { useInView as jt } from "react-intersection-observer";
|
|
12
12
|
function yt(t, n) {
|
|
13
13
|
const S = e.getState().getInitialOptions, g = e.getState().setInitialStateOptions, y = S(t) || {};
|
|
@@ -16,17 +16,17 @@ function yt(t, n) {
|
|
|
16
16
|
...n
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Vt({
|
|
20
20
|
stateKey: t,
|
|
21
21
|
options: n,
|
|
22
22
|
initialOptionsPart: S
|
|
23
23
|
}) {
|
|
24
|
-
const g = nt(t) || {}, y = S[t] || {},
|
|
25
|
-
let
|
|
24
|
+
const g = nt(t) || {}, y = S[t] || {}, w = e.getState().setInitialStateOptions, T = { ...y, ...g };
|
|
25
|
+
let u = !1;
|
|
26
26
|
if (n)
|
|
27
27
|
for (const f in n)
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
T.hasOwnProperty(f) ? (f == "localStorage" && n[f] && T[f].key !== n[f]?.key && (u = !0, T[f] = n[f]), f == "defaultState" && n[f] && T[f] !== n[f] && !st(T[f], n[f]) && (u = !0, T[f] = n[f])) : (u = !0, T[f] = n[f]);
|
|
29
|
+
u && w(t, T);
|
|
30
30
|
}
|
|
31
31
|
function ie(t, { formElements: n, validation: S }) {
|
|
32
32
|
return { initialState: t, formElements: n, validation: S };
|
|
@@ -34,8 +34,8 @@ function ie(t, { formElements: n, validation: S }) {
|
|
|
34
34
|
const Lt = (t, n) => {
|
|
35
35
|
let S = t;
|
|
36
36
|
const [g, y] = Nt(S);
|
|
37
|
-
n?.__fromSyncSchema && n?.__syncNotifications && e.getState().setInitialStateOptions("__notifications", n.__syncNotifications), Object.keys(g).forEach((
|
|
38
|
-
let f = y[
|
|
37
|
+
n?.__fromSyncSchema && n?.__syncNotifications && e.getState().setInitialStateOptions("__notifications", n.__syncNotifications), Object.keys(g).forEach((u) => {
|
|
38
|
+
let f = y[u] || {};
|
|
39
39
|
const A = {
|
|
40
40
|
...f
|
|
41
41
|
};
|
|
@@ -45,26 +45,26 @@ const Lt = (t, n) => {
|
|
|
45
45
|
}), n?.validation && (A.validation = {
|
|
46
46
|
...n.validation,
|
|
47
47
|
...f.validation || {}
|
|
48
|
-
}, n.validation.key && !f.validation?.key && (A.validation.key = `${n.validation.key}.${
|
|
49
|
-
const I = nt(
|
|
50
|
-
I ? e.getState().setInitialStateOptions(
|
|
48
|
+
}, n.validation.key && !f.validation?.key && (A.validation.key = `${n.validation.key}.${u}`)), Object.keys(A).length > 0) {
|
|
49
|
+
const I = nt(u);
|
|
50
|
+
I ? e.getState().setInitialStateOptions(u, {
|
|
51
51
|
...I,
|
|
52
52
|
...A
|
|
53
|
-
}) : e.getState().setInitialStateOptions(
|
|
53
|
+
}) : e.getState().setInitialStateOptions(u, A);
|
|
54
54
|
}
|
|
55
|
-
}), Object.keys(g).forEach((
|
|
56
|
-
e.getState().initializeShadowState(
|
|
55
|
+
}), Object.keys(g).forEach((u) => {
|
|
56
|
+
e.getState().initializeShadowState(u, g[u]);
|
|
57
57
|
});
|
|
58
|
-
const
|
|
58
|
+
const w = (u, f) => {
|
|
59
59
|
const [A] = K(f?.componentId ?? rt());
|
|
60
|
-
|
|
61
|
-
stateKey:
|
|
60
|
+
Vt({
|
|
61
|
+
stateKey: u,
|
|
62
62
|
options: f,
|
|
63
63
|
initialOptionsPart: y
|
|
64
64
|
});
|
|
65
|
-
const I = e.getState().getShadowValue(
|
|
65
|
+
const I = e.getState().getShadowValue(u) || g[u], i = f?.modifyState ? f.modifyState(I) : I;
|
|
66
66
|
return zt(i, {
|
|
67
|
-
stateKey:
|
|
67
|
+
stateKey: u,
|
|
68
68
|
syncUpdate: f?.syncUpdate,
|
|
69
69
|
componentId: A,
|
|
70
70
|
localStorage: f?.localStorage,
|
|
@@ -76,37 +76,23 @@ const Lt = (t, n) => {
|
|
|
76
76
|
serverState: f?.serverState
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
-
function
|
|
80
|
-
|
|
79
|
+
function T(u, f) {
|
|
80
|
+
Vt({ stateKey: u, options: f, initialOptionsPart: y }), f.localStorage && xt(u, f), it(u);
|
|
81
81
|
}
|
|
82
|
-
return { useCogsState:
|
|
82
|
+
return { useCogsState: w, setCogsOptions: T };
|
|
83
83
|
};
|
|
84
84
|
function ce(t) {
|
|
85
85
|
const n = t.schemas, S = {};
|
|
86
|
-
for (const
|
|
87
|
-
const
|
|
88
|
-
S[
|
|
86
|
+
for (const w in n) {
|
|
87
|
+
const T = n[w];
|
|
88
|
+
S[w] = T?.schemas?.defaultValues || {};
|
|
89
89
|
}
|
|
90
90
|
const g = Lt(S, {
|
|
91
91
|
__fromSyncSchema: !0,
|
|
92
92
|
__syncNotifications: t.notifications
|
|
93
93
|
});
|
|
94
94
|
return {
|
|
95
|
-
useCogsState: (
|
|
96
|
-
const c = n[v];
|
|
97
|
-
if (c?.apiParamsSchema && M?.apiParams) {
|
|
98
|
-
const I = c.apiParamsSchema.safeParse(M.apiParams);
|
|
99
|
-
if (!I.success)
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Invalid API params for ${String(v)}: ${I.error.message}`
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
const { apiParams: f, ...A } = M || {};
|
|
105
|
-
return g.useCogsState(
|
|
106
|
-
v,
|
|
107
|
-
A
|
|
108
|
-
);
|
|
109
|
-
},
|
|
95
|
+
useCogsState: (w, T) => g.useCogsState(w, T),
|
|
110
96
|
setCogsOptions: g.setCogsOptions
|
|
111
97
|
};
|
|
112
98
|
}
|
|
@@ -124,23 +110,23 @@ const {
|
|
|
124
110
|
S.localStorage?.key,
|
|
125
111
|
g
|
|
126
112
|
);
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
let
|
|
113
|
+
const w = at(S?.localStorage?.key) ? S.localStorage?.key(t) : S?.localStorage?.key;
|
|
114
|
+
if (w && g) {
|
|
115
|
+
const T = `${g}-${n}-${w}`;
|
|
116
|
+
let u;
|
|
131
117
|
try {
|
|
132
|
-
|
|
118
|
+
u = St(T)?.lastSyncedWithServer;
|
|
133
119
|
} catch {
|
|
134
120
|
}
|
|
135
121
|
const f = e.getState().getShadowMetadata(n, []), A = {
|
|
136
122
|
state: t,
|
|
137
123
|
lastUpdated: Date.now(),
|
|
138
|
-
lastSyncedWithServer:
|
|
124
|
+
lastSyncedWithServer: u,
|
|
139
125
|
stateSource: f?.stateSource,
|
|
140
126
|
baseServerState: f?.baseServerState
|
|
141
127
|
}, I = Ft.serialize(A);
|
|
142
128
|
window.localStorage.setItem(
|
|
143
|
-
|
|
129
|
+
T,
|
|
144
130
|
JSON.stringify(I.json)
|
|
145
131
|
);
|
|
146
132
|
}
|
|
@@ -153,12 +139,12 @@ const {
|
|
|
153
139
|
return console.error("Error loading from localStorage:", n), null;
|
|
154
140
|
}
|
|
155
141
|
}, xt = (t, n) => {
|
|
156
|
-
const S = e.getState().getShadowValue(t), { sessionId: g } =
|
|
142
|
+
const S = e.getState().getShadowValue(t), { sessionId: g } = Pt(), y = at(n?.localStorage?.key) ? n.localStorage.key(S) : n?.localStorage?.key;
|
|
157
143
|
if (y && g) {
|
|
158
|
-
const
|
|
144
|
+
const w = St(
|
|
159
145
|
`${g}-${t}-${y}`
|
|
160
146
|
);
|
|
161
|
-
if (
|
|
147
|
+
if (w && w.lastUpdated > (w.lastSyncedWithServer || 0))
|
|
162
148
|
return it(t), !0;
|
|
163
149
|
}
|
|
164
150
|
return !1;
|
|
@@ -181,16 +167,16 @@ const {
|
|
|
181
167
|
}
|
|
182
168
|
};
|
|
183
169
|
function wt(t, n, S, g) {
|
|
184
|
-
const y = e.getState(),
|
|
170
|
+
const y = e.getState(), w = y.getShadowMetadata(t, n);
|
|
185
171
|
if (y.setShadowMetadata(t, n, {
|
|
186
|
-
...
|
|
172
|
+
...w,
|
|
187
173
|
isDirty: !1,
|
|
188
174
|
stateSource: "server",
|
|
189
175
|
lastServerSync: g || Date.now()
|
|
190
176
|
}), Array.isArray(S)) {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
const A =
|
|
177
|
+
const T = y.getShadowMetadata(t, n);
|
|
178
|
+
T?.arrayKeys && T.arrayKeys.forEach((u, f) => {
|
|
179
|
+
const A = u.split(".").slice(1), I = S[f];
|
|
194
180
|
I !== void 0 && wt(
|
|
195
181
|
t,
|
|
196
182
|
A,
|
|
@@ -198,9 +184,9 @@ function wt(t, n, S, g) {
|
|
|
198
184
|
g
|
|
199
185
|
);
|
|
200
186
|
});
|
|
201
|
-
} else S && typeof S == "object" && S.constructor === Object && Object.keys(S).forEach((
|
|
202
|
-
const
|
|
203
|
-
wt(t,
|
|
187
|
+
} else S && typeof S == "object" && S.constructor === Object && Object.keys(S).forEach((T) => {
|
|
188
|
+
const u = [...n, T], f = S[T];
|
|
189
|
+
wt(t, u, f, g);
|
|
204
190
|
});
|
|
205
191
|
}
|
|
206
192
|
function zt(t, {
|
|
@@ -208,20 +194,20 @@ function zt(t, {
|
|
|
208
194
|
localStorage: S,
|
|
209
195
|
formElements: g,
|
|
210
196
|
reactiveDeps: y,
|
|
211
|
-
reactiveType:
|
|
212
|
-
componentId:
|
|
213
|
-
defaultState:
|
|
197
|
+
reactiveType: w,
|
|
198
|
+
componentId: T,
|
|
199
|
+
defaultState: u,
|
|
214
200
|
syncUpdate: f,
|
|
215
201
|
dependencies: A,
|
|
216
202
|
serverState: I
|
|
217
203
|
} = {}) {
|
|
218
|
-
const [i, h] = K({}), { sessionId:
|
|
204
|
+
const [i, h] = K({}), { sessionId: M } = Pt();
|
|
219
205
|
let z = !n;
|
|
220
|
-
const [
|
|
206
|
+
const [c] = K(n ?? rt()), B = e.getState().stateLog[c], J = q(/* @__PURE__ */ new Set()), H = q(T ?? rt()), W = q(
|
|
221
207
|
null
|
|
222
208
|
);
|
|
223
|
-
W.current = nt(
|
|
224
|
-
if (f && f.stateKey ===
|
|
209
|
+
W.current = nt(c) ?? null, Z(() => {
|
|
210
|
+
if (f && f.stateKey === c && f.path?.[0]) {
|
|
225
211
|
const o = `${f.stateKey}:${f.path.join(".")}`;
|
|
226
212
|
e.getState().setSyncInfo(o, {
|
|
227
213
|
timeStamp: f.timeStamp,
|
|
@@ -231,22 +217,22 @@ function zt(t, {
|
|
|
231
217
|
}, [f]);
|
|
232
218
|
const m = ct(
|
|
233
219
|
(o) => {
|
|
234
|
-
const a = o ? { ...nt(
|
|
220
|
+
const a = o ? { ...nt(c), ...o } : nt(c), d = a?.defaultState || u || t;
|
|
235
221
|
if (a?.serverState?.status === "success" && a?.serverState?.data !== void 0)
|
|
236
222
|
return {
|
|
237
223
|
value: a.serverState.data,
|
|
238
224
|
source: "server",
|
|
239
225
|
timestamp: a.serverState.timestamp || Date.now()
|
|
240
226
|
};
|
|
241
|
-
if (a?.localStorage?.key &&
|
|
242
|
-
const p = at(a.localStorage.key) ? a.localStorage.key(d) : a.localStorage.key,
|
|
243
|
-
`${
|
|
227
|
+
if (a?.localStorage?.key && M) {
|
|
228
|
+
const p = at(a.localStorage.key) ? a.localStorage.key(d) : a.localStorage.key, E = St(
|
|
229
|
+
`${M}-${c}-${p}`
|
|
244
230
|
);
|
|
245
|
-
if (
|
|
231
|
+
if (E && E.lastUpdated > (a?.serverState?.timestamp || 0))
|
|
246
232
|
return {
|
|
247
|
-
value:
|
|
233
|
+
value: E.state,
|
|
248
234
|
source: "localStorage",
|
|
249
|
-
timestamp:
|
|
235
|
+
timestamp: E.lastUpdated
|
|
250
236
|
};
|
|
251
237
|
}
|
|
252
238
|
return {
|
|
@@ -255,36 +241,36 @@ function zt(t, {
|
|
|
255
241
|
timestamp: Date.now()
|
|
256
242
|
};
|
|
257
243
|
},
|
|
258
|
-
[
|
|
244
|
+
[c, u, t, M]
|
|
259
245
|
);
|
|
260
246
|
Z(() => {
|
|
261
|
-
e.getState().setServerStateUpdate(
|
|
262
|
-
}, [I,
|
|
247
|
+
e.getState().setServerStateUpdate(c, I);
|
|
248
|
+
}, [I, c]), Z(() => e.getState().subscribeToPath(c, (r) => {
|
|
263
249
|
if (r?.type === "SERVER_STATE_UPDATE") {
|
|
264
250
|
const a = r.serverState;
|
|
265
251
|
if (a?.status === "success" && a.data !== void 0) {
|
|
266
|
-
yt(
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
const O =
|
|
252
|
+
yt(c, { serverState: a });
|
|
253
|
+
const l = typeof a.merge == "object" ? a.merge : a.merge === !0 ? {} : null, p = e.getState().getShadowValue(c), E = a.data;
|
|
254
|
+
if (l && Array.isArray(p) && Array.isArray(E)) {
|
|
255
|
+
const O = l.key || "id", C = new Set(
|
|
270
256
|
p.map((x) => x[O])
|
|
271
|
-
), F =
|
|
257
|
+
), F = E.filter((x) => !C.has(x[O]));
|
|
272
258
|
F.length > 0 && F.forEach((x) => {
|
|
273
|
-
e.getState().insertShadowArrayElement(
|
|
274
|
-
const N = e.getState().getShadowMetadata(
|
|
259
|
+
e.getState().insertShadowArrayElement(c, [], x);
|
|
260
|
+
const N = e.getState().getShadowMetadata(c, []);
|
|
275
261
|
if (N?.arrayKeys) {
|
|
276
262
|
const j = N.arrayKeys[N.arrayKeys.length - 1];
|
|
277
263
|
if (j) {
|
|
278
264
|
const b = j.split(".").slice(1);
|
|
279
|
-
e.getState().setShadowMetadata(
|
|
265
|
+
e.getState().setShadowMetadata(c, b, {
|
|
280
266
|
isDirty: !1,
|
|
281
267
|
stateSource: "server",
|
|
282
268
|
lastServerSync: a.timestamp || Date.now()
|
|
283
269
|
});
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
const U = [...b,
|
|
287
|
-
e.getState().setShadowMetadata(
|
|
270
|
+
const k = e.getState().getShadowValue(j);
|
|
271
|
+
k && typeof k == "object" && !Array.isArray(k) && Object.keys(k).forEach((P) => {
|
|
272
|
+
const U = [...b, P];
|
|
273
|
+
e.getState().setShadowMetadata(c, U, {
|
|
288
274
|
isDirty: !1,
|
|
289
275
|
stateSource: "server",
|
|
290
276
|
lastServerSync: a.timestamp || Date.now()
|
|
@@ -294,14 +280,14 @@ function zt(t, {
|
|
|
294
280
|
}
|
|
295
281
|
});
|
|
296
282
|
} else
|
|
297
|
-
e.getState().initializeShadowState(
|
|
298
|
-
|
|
283
|
+
e.getState().initializeShadowState(c, E), wt(
|
|
284
|
+
c,
|
|
299
285
|
[],
|
|
300
|
-
|
|
286
|
+
E,
|
|
301
287
|
a.timestamp
|
|
302
288
|
);
|
|
303
|
-
const _ = e.getState().getShadowMetadata(
|
|
304
|
-
e.getState().setShadowMetadata(
|
|
289
|
+
const _ = e.getState().getShadowMetadata(c, []);
|
|
290
|
+
e.getState().setShadowMetadata(c, [], {
|
|
305
291
|
..._,
|
|
306
292
|
stateSource: "server",
|
|
307
293
|
lastServerSync: a.timestamp || Date.now(),
|
|
@@ -309,95 +295,95 @@ function zt(t, {
|
|
|
309
295
|
});
|
|
310
296
|
}
|
|
311
297
|
}
|
|
312
|
-
}), [
|
|
313
|
-
const o = e.getState().getShadowMetadata(
|
|
298
|
+
}), [c, m]), Z(() => {
|
|
299
|
+
const o = e.getState().getShadowMetadata(c, []);
|
|
314
300
|
if (o && o.stateSource)
|
|
315
301
|
return;
|
|
316
|
-
const r = nt(
|
|
317
|
-
if (r?.defaultState !== void 0 ||
|
|
318
|
-
const a = r?.defaultState ||
|
|
319
|
-
r?.defaultState || yt(
|
|
302
|
+
const r = nt(c);
|
|
303
|
+
if (r?.defaultState !== void 0 || u !== void 0) {
|
|
304
|
+
const a = r?.defaultState || u;
|
|
305
|
+
r?.defaultState || yt(c, {
|
|
320
306
|
defaultState: a
|
|
321
307
|
});
|
|
322
|
-
const { value: d, source:
|
|
323
|
-
e.getState().initializeShadowState(
|
|
324
|
-
stateSource:
|
|
325
|
-
lastServerSync:
|
|
308
|
+
const { value: d, source: l, timestamp: p } = m();
|
|
309
|
+
e.getState().initializeShadowState(c, d), e.getState().setShadowMetadata(c, [], {
|
|
310
|
+
stateSource: l,
|
|
311
|
+
lastServerSync: l === "server" ? p : void 0,
|
|
326
312
|
isDirty: !1,
|
|
327
|
-
baseServerState:
|
|
328
|
-
}), it(
|
|
313
|
+
baseServerState: l === "server" ? d : void 0
|
|
314
|
+
}), it(c);
|
|
329
315
|
}
|
|
330
|
-
}, [
|
|
331
|
-
z && yt(
|
|
316
|
+
}, [c, ...A || []]), dt(() => {
|
|
317
|
+
z && yt(c, {
|
|
332
318
|
formElements: g,
|
|
333
|
-
defaultState:
|
|
319
|
+
defaultState: u,
|
|
334
320
|
localStorage: S,
|
|
335
321
|
middleware: W.current?.middleware
|
|
336
322
|
});
|
|
337
|
-
const o = `${
|
|
323
|
+
const o = `${c}////${H.current}`, r = e.getState().getShadowMetadata(c, []), a = r?.components || /* @__PURE__ */ new Map();
|
|
338
324
|
return a.set(o, {
|
|
339
325
|
forceUpdate: () => h({}),
|
|
340
|
-
reactiveType:
|
|
326
|
+
reactiveType: w ?? ["component", "deps"],
|
|
341
327
|
paths: /* @__PURE__ */ new Set(),
|
|
342
328
|
depsFunction: y || void 0,
|
|
343
|
-
deps: y ? y(e.getState().getShadowValue(
|
|
344
|
-
prevDeps: y ? y(e.getState().getShadowValue(
|
|
345
|
-
}), e.getState().setShadowMetadata(
|
|
329
|
+
deps: y ? y(e.getState().getShadowValue(c)) : [],
|
|
330
|
+
prevDeps: y ? y(e.getState().getShadowValue(c)) : []
|
|
331
|
+
}), e.getState().setShadowMetadata(c, [], {
|
|
346
332
|
...r,
|
|
347
333
|
components: a
|
|
348
334
|
}), h({}), () => {
|
|
349
|
-
const d = e.getState().getShadowMetadata(
|
|
350
|
-
|
|
351
|
-
const _ = p.split(".").slice(1), O = e.getState().getShadowMetadata(
|
|
352
|
-
O?.pathComponents && O.pathComponents.size === 0 && (delete O.pathComponents, e.getState().setShadowMetadata(
|
|
353
|
-
}), d?.components && e.getState().setShadowMetadata(
|
|
335
|
+
const d = e.getState().getShadowMetadata(c, []), l = d?.components?.get(o);
|
|
336
|
+
l?.paths && l.paths.forEach((p) => {
|
|
337
|
+
const _ = p.split(".").slice(1), O = e.getState().getShadowMetadata(c, _);
|
|
338
|
+
O?.pathComponents && O.pathComponents.size === 0 && (delete O.pathComponents, e.getState().setShadowMetadata(c, _, O));
|
|
339
|
+
}), d?.components && e.getState().setShadowMetadata(c, [], d);
|
|
354
340
|
};
|
|
355
341
|
}, []);
|
|
356
342
|
const Y = q(null), Q = (o, r, a) => {
|
|
357
|
-
const d = [
|
|
343
|
+
const d = [c, ...r].join(".");
|
|
358
344
|
if (Array.isArray(r)) {
|
|
359
|
-
const b = `${
|
|
345
|
+
const b = `${c}-${r.join(".")}`;
|
|
360
346
|
J.current.add(b);
|
|
361
347
|
}
|
|
362
|
-
const
|
|
348
|
+
const l = e.getState(), p = l.getShadowMetadata(c, r), E = l.getShadowValue(d), _ = a.updateType === "insert" && at(o) ? o({ state: E, uuid: rt() }) : at(o) ? o(E) : o, C = {
|
|
363
349
|
timeStamp: Date.now(),
|
|
364
|
-
stateKey:
|
|
350
|
+
stateKey: c,
|
|
365
351
|
path: r,
|
|
366
352
|
updateType: a.updateType,
|
|
367
353
|
status: "new",
|
|
368
|
-
oldValue:
|
|
354
|
+
oldValue: E,
|
|
369
355
|
newValue: _
|
|
370
356
|
};
|
|
371
357
|
switch (a.updateType) {
|
|
372
358
|
case "insert": {
|
|
373
|
-
|
|
374
|
-
const b =
|
|
359
|
+
l.insertShadowArrayElement(c, r, C.newValue), l.markAsDirty(c, r, { bubble: !0 });
|
|
360
|
+
const b = l.getShadowMetadata(c, r);
|
|
375
361
|
if (b?.arrayKeys) {
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const
|
|
379
|
-
|
|
362
|
+
const k = b.arrayKeys[b.arrayKeys.length - 1];
|
|
363
|
+
if (k) {
|
|
364
|
+
const P = k.split(".").slice(1);
|
|
365
|
+
l.markAsDirty(c, P, { bubble: !1 });
|
|
380
366
|
}
|
|
381
367
|
}
|
|
382
368
|
break;
|
|
383
369
|
}
|
|
384
370
|
case "cut": {
|
|
385
371
|
const b = r.slice(0, -1);
|
|
386
|
-
|
|
372
|
+
l.removeShadowArrayElement(c, r), l.markAsDirty(c, b, { bubble: !0 });
|
|
387
373
|
break;
|
|
388
374
|
}
|
|
389
375
|
case "update": {
|
|
390
|
-
|
|
376
|
+
l.updateShadowAtPath(c, r, C.newValue), l.markAsDirty(c, r, { bubble: !0 });
|
|
391
377
|
break;
|
|
392
378
|
}
|
|
393
379
|
}
|
|
394
380
|
if (a.sync !== !1 && Y.current && Y.current.connected && Y.current.updateState({ operation: C }), p?.signals && p.signals.length > 0) {
|
|
395
381
|
const b = a.updateType === "cut" ? null : _;
|
|
396
|
-
p.signals.forEach(({ parentId:
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
382
|
+
p.signals.forEach(({ parentId: k, position: P, effect: U }) => {
|
|
383
|
+
const v = document.querySelector(`[data-parent-id="${k}"]`);
|
|
384
|
+
if (v) {
|
|
385
|
+
const V = Array.from(v.childNodes);
|
|
386
|
+
if (V[P]) {
|
|
401
387
|
let $ = b;
|
|
402
388
|
if (U && b !== null)
|
|
403
389
|
try {
|
|
@@ -408,107 +394,107 @@ function zt(t, {
|
|
|
408
394
|
} catch (D) {
|
|
409
395
|
console.error("Error evaluating effect function:", D);
|
|
410
396
|
}
|
|
411
|
-
$ != null && typeof $ == "object" && ($ = JSON.stringify($)),
|
|
397
|
+
$ != null && typeof $ == "object" && ($ = JSON.stringify($)), V[P].textContent = String($ ?? "");
|
|
412
398
|
}
|
|
413
399
|
}
|
|
414
400
|
});
|
|
415
401
|
}
|
|
416
402
|
if (a.updateType === "insert" && p?.mapWrappers && p.mapWrappers.length > 0) {
|
|
417
|
-
const b =
|
|
418
|
-
[
|
|
403
|
+
const b = l.getShadowMetadata(c, r)?.arrayKeys || [], k = b[b.length - 1], P = l.getShadowValue(k), U = l.getShadowValue(
|
|
404
|
+
[c, ...r].join(".")
|
|
419
405
|
);
|
|
420
|
-
if (!
|
|
421
|
-
p.mapWrappers.forEach((
|
|
422
|
-
let
|
|
423
|
-
if (
|
|
424
|
-
for (const D of
|
|
425
|
-
if (D.type === "filter" && !D.fn(
|
|
426
|
-
|
|
406
|
+
if (!k || P === void 0) return;
|
|
407
|
+
p.mapWrappers.forEach((v) => {
|
|
408
|
+
let V = !0, $ = -1;
|
|
409
|
+
if (v.meta?.transforms && v.meta.transforms.length > 0) {
|
|
410
|
+
for (const D of v.meta.transforms)
|
|
411
|
+
if (D.type === "filter" && !D.fn(P, -1)) {
|
|
412
|
+
V = !1;
|
|
427
413
|
break;
|
|
428
414
|
}
|
|
429
|
-
if (
|
|
415
|
+
if (V) {
|
|
430
416
|
const D = It(
|
|
431
|
-
|
|
417
|
+
c,
|
|
432
418
|
r,
|
|
433
|
-
|
|
434
|
-
), R =
|
|
419
|
+
v.meta.transforms
|
|
420
|
+
), R = v.meta.transforms.find(
|
|
435
421
|
(L) => L.type === "sort"
|
|
436
422
|
);
|
|
437
423
|
if (R) {
|
|
438
424
|
const L = D.map((G) => ({
|
|
439
425
|
key: G,
|
|
440
|
-
value:
|
|
426
|
+
value: l.getShadowValue(G)
|
|
441
427
|
}));
|
|
442
|
-
L.push({ key:
|
|
443
|
-
(G) => G.key ===
|
|
428
|
+
L.push({ key: k, value: P }), L.sort((G, tt) => R.fn(G.value, tt.value)), $ = L.findIndex(
|
|
429
|
+
(G) => G.key === k
|
|
444
430
|
);
|
|
445
431
|
} else
|
|
446
432
|
$ = D.length;
|
|
447
433
|
}
|
|
448
434
|
} else
|
|
449
|
-
|
|
450
|
-
if (
|
|
435
|
+
V = !0, $ = b.length - 1;
|
|
436
|
+
if (V && v.containerRef && v.containerRef.isConnected) {
|
|
451
437
|
const D = document.createElement("div");
|
|
452
|
-
D.setAttribute("data-item-path",
|
|
453
|
-
const R = Array.from(
|
|
454
|
-
$ >= 0 && $ < R.length ?
|
|
438
|
+
D.setAttribute("data-item-path", k);
|
|
439
|
+
const R = Array.from(v.containerRef.children);
|
|
440
|
+
$ >= 0 && $ < R.length ? v.containerRef.insertBefore(
|
|
455
441
|
D,
|
|
456
442
|
R[$]
|
|
457
|
-
) :
|
|
458
|
-
const L = At(D), G = rt(), tt =
|
|
459
|
-
path:
|
|
443
|
+
) : v.containerRef.appendChild(D);
|
|
444
|
+
const L = At(D), G = rt(), tt = k.split(".").slice(1), et = v.rebuildStateShape({
|
|
445
|
+
path: v.path,
|
|
460
446
|
currentState: U,
|
|
461
|
-
componentId:
|
|
462
|
-
meta:
|
|
447
|
+
componentId: v.componentId,
|
|
448
|
+
meta: v.meta
|
|
463
449
|
});
|
|
464
450
|
L.render(
|
|
465
451
|
lt(Mt, {
|
|
466
|
-
stateKey:
|
|
452
|
+
stateKey: c,
|
|
467
453
|
itemComponentId: G,
|
|
468
454
|
itemPath: tt,
|
|
469
455
|
localIndex: $,
|
|
470
456
|
arraySetter: et,
|
|
471
|
-
rebuildStateShape:
|
|
472
|
-
renderFn:
|
|
457
|
+
rebuildStateShape: v.rebuildStateShape,
|
|
458
|
+
renderFn: v.mapFn
|
|
473
459
|
})
|
|
474
460
|
);
|
|
475
461
|
}
|
|
476
462
|
});
|
|
477
463
|
}
|
|
478
464
|
if (a.updateType === "cut") {
|
|
479
|
-
const b = r.slice(0, -1),
|
|
480
|
-
|
|
481
|
-
if (
|
|
482
|
-
const U =
|
|
465
|
+
const b = r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
466
|
+
k?.mapWrappers && k.mapWrappers.length > 0 && k.mapWrappers.forEach((P) => {
|
|
467
|
+
if (P.containerRef && P.containerRef.isConnected) {
|
|
468
|
+
const U = P.containerRef.querySelector(
|
|
483
469
|
`[data-item-path="${d}"]`
|
|
484
470
|
);
|
|
485
471
|
U && U.remove();
|
|
486
472
|
}
|
|
487
473
|
});
|
|
488
474
|
}
|
|
489
|
-
const x = e.getState().getShadowValue(
|
|
475
|
+
const x = e.getState().getShadowValue(c), N = e.getState().getShadowMetadata(c, []), j = /* @__PURE__ */ new Set();
|
|
490
476
|
if (console.log(
|
|
491
477
|
"rootMeta",
|
|
492
|
-
|
|
478
|
+
c,
|
|
493
479
|
e.getState().shadowStateStore
|
|
494
480
|
), !N?.components)
|
|
495
481
|
return x;
|
|
496
482
|
if (a.updateType === "update") {
|
|
497
483
|
let b = [...r];
|
|
498
484
|
for (; ; ) {
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
if (j.has(
|
|
485
|
+
const k = l.getShadowMetadata(c, b);
|
|
486
|
+
if (k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
487
|
+
if (j.has(P))
|
|
502
488
|
return;
|
|
503
|
-
const U = N.components?.get(
|
|
504
|
-
U && ((Array.isArray(U.reactiveType) ? U.reactiveType : [U.reactiveType || "component"]).includes("none") || (U.forceUpdate(), j.add(
|
|
489
|
+
const U = N.components?.get(P);
|
|
490
|
+
U && ((Array.isArray(U.reactiveType) ? U.reactiveType : [U.reactiveType || "component"]).includes("none") || (U.forceUpdate(), j.add(P)));
|
|
505
491
|
}), b.length === 0)
|
|
506
492
|
break;
|
|
507
493
|
b.pop();
|
|
508
494
|
}
|
|
509
|
-
_ && typeof _ == "object" && !Tt(_) &&
|
|
510
|
-
const U =
|
|
511
|
-
|
|
495
|
+
_ && typeof _ == "object" && !Tt(_) && E && typeof E == "object" && !Tt(E) && Ct(_, E).forEach((P) => {
|
|
496
|
+
const U = P.split("."), v = [...r, ...U], V = l.getShadowMetadata(c, v);
|
|
497
|
+
V?.pathComponents && V.pathComponents.forEach(($) => {
|
|
512
498
|
if (j.has($))
|
|
513
499
|
return;
|
|
514
500
|
const D = N.components?.get($);
|
|
@@ -516,16 +502,16 @@ function zt(t, {
|
|
|
516
502
|
});
|
|
517
503
|
});
|
|
518
504
|
} else if (a.updateType === "insert" || a.updateType === "cut") {
|
|
519
|
-
const b = a.updateType === "insert" ? r : r.slice(0, -1),
|
|
520
|
-
if (
|
|
521
|
-
const
|
|
522
|
-
|
|
505
|
+
const b = a.updateType === "insert" ? r : r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
506
|
+
if (k?.signals && k.signals.length > 0) {
|
|
507
|
+
const P = [c, ...b].join("."), U = l.getShadowValue(P);
|
|
508
|
+
k.signals.forEach(({ parentId: v, position: V, effect: $ }) => {
|
|
523
509
|
const D = document.querySelector(
|
|
524
|
-
`[data-parent-id="${
|
|
510
|
+
`[data-parent-id="${v}"]`
|
|
525
511
|
);
|
|
526
512
|
if (D) {
|
|
527
513
|
const R = Array.from(D.childNodes);
|
|
528
|
-
if (R[
|
|
514
|
+
if (R[V]) {
|
|
529
515
|
let L = U;
|
|
530
516
|
if ($)
|
|
531
517
|
try {
|
|
@@ -536,54 +522,54 @@ function zt(t, {
|
|
|
536
522
|
} catch (G) {
|
|
537
523
|
console.error("Error evaluating effect function:", G), L = U;
|
|
538
524
|
}
|
|
539
|
-
L != null && typeof L == "object" && (L = JSON.stringify(L)), R[
|
|
525
|
+
L != null && typeof L == "object" && (L = JSON.stringify(L)), R[V].textContent = String(L ?? "");
|
|
540
526
|
}
|
|
541
527
|
}
|
|
542
528
|
});
|
|
543
529
|
}
|
|
544
|
-
|
|
545
|
-
if (!j.has(
|
|
546
|
-
const U = N.components?.get(
|
|
547
|
-
U && (U.forceUpdate(), j.add(
|
|
530
|
+
k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
531
|
+
if (!j.has(P)) {
|
|
532
|
+
const U = N.components?.get(P);
|
|
533
|
+
U && (U.forceUpdate(), j.add(P));
|
|
548
534
|
}
|
|
549
535
|
});
|
|
550
536
|
}
|
|
551
|
-
return N.components.forEach((b,
|
|
552
|
-
if (j.has(
|
|
537
|
+
return N.components.forEach((b, k) => {
|
|
538
|
+
if (j.has(k))
|
|
553
539
|
return;
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
b.forceUpdate(), j.add(
|
|
540
|
+
const P = Array.isArray(b.reactiveType) ? b.reactiveType : [b.reactiveType || "component"];
|
|
541
|
+
if (P.includes("all")) {
|
|
542
|
+
b.forceUpdate(), j.add(k);
|
|
557
543
|
return;
|
|
558
544
|
}
|
|
559
|
-
if (
|
|
560
|
-
const U =
|
|
561
|
-
let
|
|
562
|
-
|
|
545
|
+
if (P.includes("deps") && b.depsFunction) {
|
|
546
|
+
const U = l.getShadowValue(c), v = b.depsFunction(U);
|
|
547
|
+
let V = !1;
|
|
548
|
+
v === !0 ? V = !0 : Array.isArray(v) && (st(b.prevDeps, v) || (b.prevDeps = v, V = !0)), V && (b.forceUpdate(), j.add(k));
|
|
563
549
|
}
|
|
564
|
-
}), j.clear(), Wt(
|
|
565
|
-
const
|
|
566
|
-
return
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
}), Array.from(
|
|
550
|
+
}), j.clear(), Wt(c, (b) => {
|
|
551
|
+
const k = [...b ?? [], C], P = /* @__PURE__ */ new Map();
|
|
552
|
+
return k.forEach((U) => {
|
|
553
|
+
const v = `${U.stateKey}:${JSON.stringify(U.path)}`, V = P.get(v);
|
|
554
|
+
V ? (V.timeStamp = Math.max(V.timeStamp, U.timeStamp), V.newValue = U.newValue, V.oldValue = V.oldValue ?? U.oldValue, V.updateType = U.updateType) : P.set(v, { ...U });
|
|
555
|
+
}), Array.from(P.values());
|
|
570
556
|
}), Ht(
|
|
571
557
|
_,
|
|
572
|
-
|
|
558
|
+
c,
|
|
573
559
|
W.current,
|
|
574
|
-
|
|
560
|
+
M
|
|
575
561
|
), W.current?.middleware && W.current.middleware({
|
|
576
562
|
updateLog: B,
|
|
577
563
|
update: C
|
|
578
564
|
}), x;
|
|
579
565
|
};
|
|
580
|
-
e.getState().initialStateGlobal[
|
|
566
|
+
e.getState().initialStateGlobal[c] || _t(c, t);
|
|
581
567
|
const X = gt(() => Dt(
|
|
582
|
-
|
|
568
|
+
c,
|
|
583
569
|
Q,
|
|
584
570
|
H.current,
|
|
585
|
-
|
|
586
|
-
), [
|
|
571
|
+
M
|
|
572
|
+
), [c, M]), s = W.current?.cogsSync;
|
|
587
573
|
return s && (Y.current = s(X)), X;
|
|
588
574
|
}
|
|
589
575
|
function Bt(t) {
|
|
@@ -598,53 +584,53 @@ const It = (t, n, S) => {
|
|
|
598
584
|
let g = e.getState().getShadowMetadata(t, n)?.arrayKeys || [];
|
|
599
585
|
if (!S || S.length === 0)
|
|
600
586
|
return g;
|
|
601
|
-
let y = g.map((
|
|
602
|
-
key:
|
|
603
|
-
value: e.getState().getShadowValue(
|
|
587
|
+
let y = g.map((w) => ({
|
|
588
|
+
key: w,
|
|
589
|
+
value: e.getState().getShadowValue(w)
|
|
604
590
|
}));
|
|
605
|
-
for (const
|
|
606
|
-
|
|
607
|
-
({ value:
|
|
608
|
-
) :
|
|
609
|
-
return y.map(({ key:
|
|
610
|
-
},
|
|
611
|
-
const g = `${t}////${n}`, { addPathComponent: y, getShadowMetadata:
|
|
612
|
-
!
|
|
591
|
+
for (const w of S)
|
|
592
|
+
w.type === "filter" ? y = y.filter(
|
|
593
|
+
({ value: T }, u) => w.fn(T, u)
|
|
594
|
+
) : w.type === "sort" && y.sort((T, u) => w.fn(T.value, u.value));
|
|
595
|
+
return y.map(({ key: w }) => w);
|
|
596
|
+
}, Et = (t, n, S) => {
|
|
597
|
+
const g = `${t}////${n}`, { addPathComponent: y, getShadowMetadata: w } = e.getState(), u = w(t, [])?.components?.get(g);
|
|
598
|
+
!u || u.reactiveType === "none" || !(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType]).includes("component") || y(t, S, g);
|
|
613
599
|
}, ft = (t, n, S) => {
|
|
614
|
-
const g = e.getState(), y = g.getShadowMetadata(t, []),
|
|
615
|
-
y?.components && y.components.forEach((
|
|
616
|
-
(Array.isArray(
|
|
617
|
-
}), g.getShadowMetadata(t, [...n, "getSelected"])?.pathComponents?.forEach((
|
|
618
|
-
y?.components?.get(
|
|
600
|
+
const g = e.getState(), y = g.getShadowMetadata(t, []), w = /* @__PURE__ */ new Set();
|
|
601
|
+
y?.components && y.components.forEach((u, f) => {
|
|
602
|
+
(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType || "component"]).includes("all") && (u.forceUpdate(), w.add(f));
|
|
603
|
+
}), g.getShadowMetadata(t, [...n, "getSelected"])?.pathComponents?.forEach((u) => {
|
|
604
|
+
y?.components?.get(u)?.forceUpdate();
|
|
619
605
|
});
|
|
620
|
-
const
|
|
621
|
-
for (let
|
|
622
|
-
const f =
|
|
606
|
+
const T = g.getShadowMetadata(t, n);
|
|
607
|
+
for (let u of T?.arrayKeys || []) {
|
|
608
|
+
const f = u + ".selected", A = g.getShadowMetadata(
|
|
623
609
|
t,
|
|
624
610
|
f.split(".").slice(1)
|
|
625
611
|
);
|
|
626
|
-
|
|
612
|
+
u == S && A?.pathComponents?.forEach((I) => {
|
|
627
613
|
y?.components?.get(I)?.forceUpdate();
|
|
628
614
|
});
|
|
629
615
|
}
|
|
630
616
|
};
|
|
631
617
|
function Dt(t, n, S, g) {
|
|
632
618
|
const y = /* @__PURE__ */ new Map();
|
|
633
|
-
let
|
|
634
|
-
const
|
|
619
|
+
let w = 0;
|
|
620
|
+
const T = (I) => {
|
|
635
621
|
const i = I.join(".");
|
|
636
622
|
for (const [h] of y)
|
|
637
623
|
(h === i || h.startsWith(i + ".")) && y.delete(h);
|
|
638
|
-
|
|
624
|
+
w++;
|
|
639
625
|
};
|
|
640
|
-
function
|
|
626
|
+
function u({
|
|
641
627
|
currentState: I,
|
|
642
628
|
path: i = [],
|
|
643
629
|
meta: h,
|
|
644
|
-
componentId:
|
|
630
|
+
componentId: M
|
|
645
631
|
}) {
|
|
646
|
-
const z = i.map(String).join("."),
|
|
647
|
-
I = e.getState().getShadowValue(
|
|
632
|
+
const z = i.map(String).join("."), c = [t, ...i].join(".");
|
|
633
|
+
I = e.getState().getShadowValue(c, h?.validIds);
|
|
648
634
|
const B = function() {
|
|
649
635
|
return e().getShadowValue(t, i);
|
|
650
636
|
}, J = {
|
|
@@ -652,7 +638,7 @@ function Dt(t, n, S, g) {
|
|
|
652
638
|
},
|
|
653
639
|
get(W, m) {
|
|
654
640
|
if (m === "_rebuildStateShape")
|
|
655
|
-
return
|
|
641
|
+
return u;
|
|
656
642
|
if (Object.getOwnPropertyNames(f).includes(m) && i.length === 0)
|
|
657
643
|
return f[m];
|
|
658
644
|
if (m === "getDifferences")
|
|
@@ -669,13 +655,13 @@ function Dt(t, n, S, g) {
|
|
|
669
655
|
const r = e.getState().getShadowValue(t, []), a = s?.validation?.key;
|
|
670
656
|
try {
|
|
671
657
|
const d = await o.action(r);
|
|
672
|
-
if (d && !d.success && d.errors && a && (e.getState().removeValidationError(a), d.errors.forEach((
|
|
673
|
-
const p = [a, ...
|
|
674
|
-
e.getState().addValidationError(p,
|
|
658
|
+
if (d && !d.success && d.errors && a && (e.getState().removeValidationError(a), d.errors.forEach((l) => {
|
|
659
|
+
const p = [a, ...l.path].join(".");
|
|
660
|
+
e.getState().addValidationError(p, l.message);
|
|
675
661
|
}), it(t)), d?.success) {
|
|
676
|
-
const
|
|
662
|
+
const l = e.getState().getShadowMetadata(t, []);
|
|
677
663
|
e.getState().setShadowMetadata(t, [], {
|
|
678
|
-
...
|
|
664
|
+
...l,
|
|
679
665
|
isDirty: !1,
|
|
680
666
|
lastServerSync: Date.now(),
|
|
681
667
|
stateSource: "server",
|
|
@@ -690,7 +676,7 @@ function Dt(t, n, S, g) {
|
|
|
690
676
|
};
|
|
691
677
|
if (m === "_status" || m === "getStatus") {
|
|
692
678
|
const s = () => {
|
|
693
|
-
const o = e.getState().getShadowMetadata(t, i), r = e.getState().getShadowValue(
|
|
679
|
+
const o = e.getState().getShadowMetadata(t, i), r = e.getState().getShadowValue(c);
|
|
694
680
|
return o?.isDirty === !0 ? "dirty" : o?.isDirty === !1 || o?.stateSource === "server" ? "synced" : o?.stateSource === "localStorage" ? "restored" : o?.stateSource === "default" ? "fresh" : e.getState().getShadowMetadata(t, [])?.stateSource === "server" && !o?.isDirty ? "synced" : r !== void 0 && !o ? "fresh" : "unknown";
|
|
695
681
|
};
|
|
696
682
|
return m === "_status" ? s() : s;
|
|
@@ -709,7 +695,7 @@ function Dt(t, n, S, g) {
|
|
|
709
695
|
if (m === "getSelected")
|
|
710
696
|
return () => {
|
|
711
697
|
const s = t + "." + i.join(".");
|
|
712
|
-
|
|
698
|
+
Et(t, M, [
|
|
713
699
|
...i,
|
|
714
700
|
"getSelected"
|
|
715
701
|
]);
|
|
@@ -721,10 +707,10 @@ function Dt(t, n, S, g) {
|
|
|
721
707
|
return;
|
|
722
708
|
const a = e.getState().getShadowValue(r);
|
|
723
709
|
if (a)
|
|
724
|
-
return
|
|
710
|
+
return u({
|
|
725
711
|
currentState: a,
|
|
726
712
|
path: r.split(".").slice(1),
|
|
727
|
-
componentId:
|
|
713
|
+
componentId: M
|
|
728
714
|
});
|
|
729
715
|
};
|
|
730
716
|
if (m === "getSelectedIndex")
|
|
@@ -745,7 +731,7 @@ function Dt(t, n, S, g) {
|
|
|
745
731
|
overscan: r = 6,
|
|
746
732
|
stickToBottom: a = !1,
|
|
747
733
|
scrollStickTolerance: d = 75
|
|
748
|
-
} = s,
|
|
734
|
+
} = s, l = q(null), [p, E] = K({
|
|
749
735
|
startIndex: 0,
|
|
750
736
|
endIndex: 10
|
|
751
737
|
}), [_, O] = K({}), C = q(!0), F = q({
|
|
@@ -757,60 +743,60 @@ function Dt(t, n, S, g) {
|
|
|
757
743
|
/* @__PURE__ */ new Map()
|
|
758
744
|
);
|
|
759
745
|
dt(() => {
|
|
760
|
-
if (!a || !
|
|
746
|
+
if (!a || !l.current || F.current.isUserScrolling)
|
|
761
747
|
return;
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
top:
|
|
748
|
+
const v = l.current;
|
|
749
|
+
v.scrollTo({
|
|
750
|
+
top: v.scrollHeight,
|
|
765
751
|
behavior: C.current ? "instant" : "smooth"
|
|
766
752
|
});
|
|
767
753
|
}, [_, a]);
|
|
768
754
|
const N = e.getState().getShadowMetadata(t, i)?.arrayKeys || [], { totalHeight: j, itemOffsets: b } = gt(() => {
|
|
769
|
-
let
|
|
770
|
-
const
|
|
755
|
+
let v = 0;
|
|
756
|
+
const V = /* @__PURE__ */ new Map();
|
|
771
757
|
return (e.getState().getShadowMetadata(t, i)?.arrayKeys || []).forEach((D) => {
|
|
772
758
|
const R = D.split(".").slice(1), L = e.getState().getShadowMetadata(t, R)?.virtualizer?.itemHeight || o;
|
|
773
|
-
|
|
759
|
+
V.set(D, {
|
|
774
760
|
height: L,
|
|
775
|
-
offset:
|
|
776
|
-
}),
|
|
777
|
-
}), x.current =
|
|
761
|
+
offset: v
|
|
762
|
+
}), v += L;
|
|
763
|
+
}), x.current = V, { totalHeight: v, itemOffsets: V };
|
|
778
764
|
}, [N.length, o]);
|
|
779
765
|
dt(() => {
|
|
780
|
-
if (a && N.length > 0 &&
|
|
781
|
-
const
|
|
782
|
-
if (
|
|
766
|
+
if (a && N.length > 0 && l.current && !F.current.isUserScrolling && C.current) {
|
|
767
|
+
const v = l.current, V = () => {
|
|
768
|
+
if (v.clientHeight > 0) {
|
|
783
769
|
const $ = Math.ceil(
|
|
784
|
-
|
|
770
|
+
v.clientHeight / o
|
|
785
771
|
), D = N.length - 1, R = Math.max(
|
|
786
772
|
0,
|
|
787
773
|
D - $ - r
|
|
788
774
|
);
|
|
789
|
-
|
|
790
|
-
|
|
775
|
+
E({ startIndex: R, endIndex: D }), requestAnimationFrame(() => {
|
|
776
|
+
P("instant"), C.current = !1;
|
|
791
777
|
});
|
|
792
778
|
} else
|
|
793
|
-
requestAnimationFrame(
|
|
779
|
+
requestAnimationFrame(V);
|
|
794
780
|
};
|
|
795
|
-
|
|
781
|
+
V();
|
|
796
782
|
}
|
|
797
783
|
}, [N.length, a, o, r]);
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
if (!
|
|
801
|
-
const
|
|
802
|
-
R.isNearBottom = L <= d,
|
|
784
|
+
const k = ct(() => {
|
|
785
|
+
const v = l.current;
|
|
786
|
+
if (!v) return;
|
|
787
|
+
const V = v.scrollTop, { scrollHeight: $, clientHeight: D } = v, R = F.current, L = $ - (V + D), G = R.isNearBottom;
|
|
788
|
+
R.isNearBottom = L <= d, V < R.lastScrollTop ? (R.scrollUpCount++, R.scrollUpCount > 3 && G && (R.isUserScrolling = !0, console.log("User scrolled away from bottom"))) : R.isNearBottom && (R.isUserScrolling = !1, R.scrollUpCount = 0), R.lastScrollTop = V;
|
|
803
789
|
let tt = 0;
|
|
804
790
|
for (let et = 0; et < N.length; et++) {
|
|
805
791
|
const ht = N[et], mt = x.current.get(ht);
|
|
806
|
-
if (mt && mt.offset + mt.height >
|
|
792
|
+
if (mt && mt.offset + mt.height > V) {
|
|
807
793
|
tt = et;
|
|
808
794
|
break;
|
|
809
795
|
}
|
|
810
796
|
}
|
|
811
797
|
if (tt !== p.startIndex) {
|
|
812
798
|
const et = Math.ceil(D / o);
|
|
813
|
-
|
|
799
|
+
E({
|
|
814
800
|
startIndex: Math.max(0, tt - r),
|
|
815
801
|
endIndex: Math.min(
|
|
816
802
|
N.length - 1,
|
|
@@ -826,28 +812,28 @@ function Dt(t, n, S, g) {
|
|
|
826
812
|
d
|
|
827
813
|
]);
|
|
828
814
|
Z(() => {
|
|
829
|
-
const
|
|
830
|
-
if (!(!
|
|
831
|
-
return
|
|
815
|
+
const v = l.current;
|
|
816
|
+
if (!(!v || !a))
|
|
817
|
+
return v.addEventListener("scroll", k, {
|
|
832
818
|
passive: !0
|
|
833
819
|
}), () => {
|
|
834
|
-
|
|
820
|
+
v.removeEventListener("scroll", k);
|
|
835
821
|
};
|
|
836
|
-
}, [
|
|
837
|
-
const
|
|
838
|
-
(
|
|
839
|
-
const
|
|
840
|
-
if (!
|
|
822
|
+
}, [k, a]);
|
|
823
|
+
const P = ct(
|
|
824
|
+
(v = "smooth") => {
|
|
825
|
+
const V = l.current;
|
|
826
|
+
if (!V) return;
|
|
841
827
|
F.current.isUserScrolling = !1, F.current.isNearBottom = !0, F.current.scrollUpCount = 0;
|
|
842
828
|
const $ = () => {
|
|
843
829
|
const D = (R = 0) => {
|
|
844
830
|
if (R > 5) return;
|
|
845
|
-
const L =
|
|
846
|
-
G + tt >= L - 1 || (
|
|
831
|
+
const L = V.scrollHeight, G = V.scrollTop, tt = V.clientHeight;
|
|
832
|
+
G + tt >= L - 1 || (V.scrollTo({
|
|
847
833
|
top: L,
|
|
848
|
-
behavior:
|
|
834
|
+
behavior: v
|
|
849
835
|
}), setTimeout(() => {
|
|
850
|
-
const et =
|
|
836
|
+
const et = V.scrollHeight, ht = V.scrollTop;
|
|
851
837
|
(et !== L || ht + tt < et - 1) && D(R + 1);
|
|
852
838
|
}, 50));
|
|
853
839
|
};
|
|
@@ -860,19 +846,19 @@ function Dt(t, n, S, g) {
|
|
|
860
846
|
[]
|
|
861
847
|
);
|
|
862
848
|
return Z(() => {
|
|
863
|
-
if (!a || !
|
|
864
|
-
const
|
|
849
|
+
if (!a || !l.current) return;
|
|
850
|
+
const v = l.current, V = F.current;
|
|
865
851
|
let $;
|
|
866
852
|
const D = () => {
|
|
867
853
|
clearTimeout($), $ = setTimeout(() => {
|
|
868
|
-
!
|
|
854
|
+
!V.isUserScrolling && V.isNearBottom && P(
|
|
869
855
|
C.current ? "instant" : "smooth"
|
|
870
856
|
);
|
|
871
857
|
}, 100);
|
|
872
858
|
}, R = new MutationObserver(() => {
|
|
873
|
-
|
|
859
|
+
V.isUserScrolling || D();
|
|
874
860
|
});
|
|
875
|
-
R.observe(
|
|
861
|
+
R.observe(v, {
|
|
876
862
|
childList: !0,
|
|
877
863
|
subtree: !0,
|
|
878
864
|
attributes: !0,
|
|
@@ -880,34 +866,34 @@ function Dt(t, n, S, g) {
|
|
|
880
866
|
// More specific than just 'height'
|
|
881
867
|
});
|
|
882
868
|
const L = (G) => {
|
|
883
|
-
G.target instanceof HTMLImageElement && !
|
|
869
|
+
G.target instanceof HTMLImageElement && !V.isUserScrolling && D();
|
|
884
870
|
};
|
|
885
|
-
return
|
|
886
|
-
|
|
871
|
+
return v.addEventListener("load", L, !0), C.current ? setTimeout(() => {
|
|
872
|
+
P("instant");
|
|
887
873
|
}, 0) : D(), () => {
|
|
888
|
-
clearTimeout($), R.disconnect(),
|
|
874
|
+
clearTimeout($), R.disconnect(), v.removeEventListener("load", L, !0);
|
|
889
875
|
};
|
|
890
|
-
}, [a, N.length,
|
|
876
|
+
}, [a, N.length, P]), {
|
|
891
877
|
virtualState: gt(() => {
|
|
892
|
-
const
|
|
878
|
+
const v = e.getState(), V = v.getShadowValue(
|
|
893
879
|
[t, ...i].join(".")
|
|
894
|
-
), $ =
|
|
880
|
+
), $ = v.getShadowMetadata(t, i)?.arrayKeys || [], D = V.slice(
|
|
895
881
|
p.startIndex,
|
|
896
882
|
p.endIndex + 1
|
|
897
883
|
), R = $.slice(
|
|
898
884
|
p.startIndex,
|
|
899
885
|
p.endIndex + 1
|
|
900
886
|
);
|
|
901
|
-
return
|
|
887
|
+
return u({
|
|
902
888
|
currentState: D,
|
|
903
889
|
path: i,
|
|
904
|
-
componentId:
|
|
890
|
+
componentId: M,
|
|
905
891
|
meta: { ...h, validIds: R }
|
|
906
892
|
});
|
|
907
893
|
}, [p.startIndex, p.endIndex, N.length]),
|
|
908
894
|
virtualizerProps: {
|
|
909
895
|
outer: {
|
|
910
|
-
ref:
|
|
896
|
+
ref: l,
|
|
911
897
|
style: {
|
|
912
898
|
overflowY: "auto",
|
|
913
899
|
height: "100%",
|
|
@@ -928,11 +914,11 @@ function Dt(t, n, S, g) {
|
|
|
928
914
|
}
|
|
929
915
|
}
|
|
930
916
|
},
|
|
931
|
-
scrollToBottom:
|
|
932
|
-
scrollToIndex: (
|
|
933
|
-
if (
|
|
934
|
-
const $ = x.current.get(N[
|
|
935
|
-
|
|
917
|
+
scrollToBottom: P,
|
|
918
|
+
scrollToIndex: (v, V = "smooth") => {
|
|
919
|
+
if (l.current && N[v]) {
|
|
920
|
+
const $ = x.current.get(N[v])?.offset || 0;
|
|
921
|
+
l.current.scrollTo({ top: $, behavior: V });
|
|
936
922
|
}
|
|
937
923
|
}
|
|
938
924
|
};
|
|
@@ -941,20 +927,20 @@ function Dt(t, n, S, g) {
|
|
|
941
927
|
return (s) => {
|
|
942
928
|
const [o, r] = K(
|
|
943
929
|
h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys
|
|
944
|
-
), a = e.getState().getShadowValue(
|
|
930
|
+
), a = e.getState().getShadowValue(c, h?.validIds);
|
|
945
931
|
if (!o)
|
|
946
932
|
throw new Error("No array keys found for mapping");
|
|
947
|
-
const d =
|
|
933
|
+
const d = u({
|
|
948
934
|
currentState: a,
|
|
949
935
|
path: i,
|
|
950
|
-
componentId:
|
|
936
|
+
componentId: M,
|
|
951
937
|
meta: h
|
|
952
938
|
});
|
|
953
|
-
return a.map((
|
|
954
|
-
const
|
|
955
|
-
currentState:
|
|
956
|
-
path:
|
|
957
|
-
componentId:
|
|
939
|
+
return a.map((l, p) => {
|
|
940
|
+
const E = o[p]?.split(".").slice(1), _ = u({
|
|
941
|
+
currentState: l,
|
|
942
|
+
path: E,
|
|
943
|
+
componentId: M,
|
|
958
944
|
meta: h
|
|
959
945
|
});
|
|
960
946
|
return s(
|
|
@@ -972,7 +958,7 @@ function Dt(t, n, S, g) {
|
|
|
972
958
|
_mapFn: s,
|
|
973
959
|
_meta: h
|
|
974
960
|
},
|
|
975
|
-
rebuildStateShape:
|
|
961
|
+
rebuildStateShape: u
|
|
976
962
|
});
|
|
977
963
|
if (m === "stateFind")
|
|
978
964
|
return (s) => {
|
|
@@ -983,11 +969,11 @@ function Dt(t, n, S, g) {
|
|
|
983
969
|
if (!a) continue;
|
|
984
970
|
const d = e.getState().getShadowValue(a);
|
|
985
971
|
if (s(d, r)) {
|
|
986
|
-
const
|
|
987
|
-
return
|
|
972
|
+
const l = a.split(".").slice(1);
|
|
973
|
+
return u({
|
|
988
974
|
currentState: d,
|
|
989
|
-
path:
|
|
990
|
-
componentId:
|
|
975
|
+
path: l,
|
|
976
|
+
componentId: M,
|
|
991
977
|
meta: h
|
|
992
978
|
// Pass along meta for potential further chaining
|
|
993
979
|
});
|
|
@@ -1000,12 +986,12 @@ function Dt(t, n, S, g) {
|
|
|
1000
986
|
if (!o)
|
|
1001
987
|
throw new Error("No array keys found for filtering.");
|
|
1002
988
|
const r = [], a = I.filter(
|
|
1003
|
-
(d,
|
|
989
|
+
(d, l) => s(d, l) ? (r.push(o[l]), !0) : !1
|
|
1004
990
|
);
|
|
1005
|
-
return
|
|
991
|
+
return u({
|
|
1006
992
|
currentState: a,
|
|
1007
993
|
path: i,
|
|
1008
|
-
componentId:
|
|
994
|
+
componentId: M,
|
|
1009
995
|
meta: {
|
|
1010
996
|
validIds: r,
|
|
1011
997
|
transforms: [
|
|
@@ -1027,10 +1013,10 @@ function Dt(t, n, S, g) {
|
|
|
1027
1013
|
item: a,
|
|
1028
1014
|
key: o[d]
|
|
1029
1015
|
}));
|
|
1030
|
-
return r.sort((a, d) => s(a.item, d.item)).filter(Boolean),
|
|
1016
|
+
return r.sort((a, d) => s(a.item, d.item)).filter(Boolean), u({
|
|
1031
1017
|
currentState: r.map((a) => a.item),
|
|
1032
1018
|
path: i,
|
|
1033
|
-
componentId:
|
|
1019
|
+
componentId: M,
|
|
1034
1020
|
meta: {
|
|
1035
1021
|
validIds: r.map((a) => a.key),
|
|
1036
1022
|
transforms: [
|
|
@@ -1047,11 +1033,11 @@ function Dt(t, n, S, g) {
|
|
|
1047
1033
|
flushInterval: r = 100,
|
|
1048
1034
|
bufferStrategy: a = "accumulate",
|
|
1049
1035
|
store: d,
|
|
1050
|
-
onFlush:
|
|
1036
|
+
onFlush: l
|
|
1051
1037
|
} = s;
|
|
1052
|
-
let p = [],
|
|
1038
|
+
let p = [], E = !1, _ = null;
|
|
1053
1039
|
const O = (j) => {
|
|
1054
|
-
if (!
|
|
1040
|
+
if (!E) {
|
|
1055
1041
|
if (a === "sliding" && p.length >= o)
|
|
1056
1042
|
p.shift();
|
|
1057
1043
|
else if (a === "dropping" && p.length >= o)
|
|
@@ -1063,8 +1049,8 @@ function Dt(t, n, S, g) {
|
|
|
1063
1049
|
const j = [...p];
|
|
1064
1050
|
if (p = [], d) {
|
|
1065
1051
|
const b = d(j);
|
|
1066
|
-
b !== void 0 && (Array.isArray(b) ? b : [b]).forEach((
|
|
1067
|
-
n(
|
|
1052
|
+
b !== void 0 && (Array.isArray(b) ? b : [b]).forEach((P) => {
|
|
1053
|
+
n(P, i, {
|
|
1068
1054
|
updateType: "insert"
|
|
1069
1055
|
});
|
|
1070
1056
|
});
|
|
@@ -1074,7 +1060,7 @@ function Dt(t, n, S, g) {
|
|
|
1074
1060
|
updateType: "insert"
|
|
1075
1061
|
});
|
|
1076
1062
|
});
|
|
1077
|
-
|
|
1063
|
+
l?.(j);
|
|
1078
1064
|
};
|
|
1079
1065
|
r > 0 && (_ = setInterval(C, r));
|
|
1080
1066
|
const F = rt(), x = e.getState().getShadowMetadata(t, i) || {}, N = x.streams || /* @__PURE__ */ new Map();
|
|
@@ -1086,10 +1072,10 @@ function Dt(t, n, S, g) {
|
|
|
1086
1072
|
writeMany: (j) => j.forEach(O),
|
|
1087
1073
|
flush: () => C(),
|
|
1088
1074
|
pause: () => {
|
|
1089
|
-
|
|
1075
|
+
E = !0;
|
|
1090
1076
|
},
|
|
1091
1077
|
resume: () => {
|
|
1092
|
-
|
|
1078
|
+
E = !1, p.length > 0 && C();
|
|
1093
1079
|
},
|
|
1094
1080
|
close: () => {
|
|
1095
1081
|
C(), _ && clearInterval(_);
|
|
@@ -1100,7 +1086,7 @@ function Dt(t, n, S, g) {
|
|
|
1100
1086
|
};
|
|
1101
1087
|
if (m === "stateList")
|
|
1102
1088
|
return (s) => /* @__PURE__ */ ot(() => {
|
|
1103
|
-
const r = q(/* @__PURE__ */ new Map()), a = h?.transforms && h.transforms.length > 0 ? `${
|
|
1089
|
+
const r = q(/* @__PURE__ */ new Map()), a = h?.transforms && h.transforms.length > 0 ? `${M}-${Bt(h.transforms)}` : `${M}-base`, [d, l] = K({}), { validIds: p, arrayValues: E } = gt(() => {
|
|
1104
1090
|
const O = e.getState().getShadowMetadata(t, i)?.transformCaches?.get(a);
|
|
1105
1091
|
let C;
|
|
1106
1092
|
O && O.validIds ? C = O.validIds : (C = It(
|
|
@@ -1112,37 +1098,37 @@ function Dt(t, n, S, g) {
|
|
|
1112
1098
|
computedAt: Date.now(),
|
|
1113
1099
|
transforms: h?.transforms || []
|
|
1114
1100
|
}));
|
|
1115
|
-
const F = e.getState().getShadowValue(
|
|
1101
|
+
const F = e.getState().getShadowValue(c, C);
|
|
1116
1102
|
return {
|
|
1117
1103
|
validIds: C,
|
|
1118
1104
|
arrayValues: F || []
|
|
1119
1105
|
};
|
|
1120
1106
|
}, [a, d]);
|
|
1121
1107
|
if (Z(() => {
|
|
1122
|
-
const O = e.getState().subscribeToPath(
|
|
1108
|
+
const O = e.getState().subscribeToPath(c, (C) => {
|
|
1123
1109
|
if (C.type === "GET_SELECTED")
|
|
1124
1110
|
return;
|
|
1125
1111
|
const x = e.getState().getShadowMetadata(t, i)?.transformCaches;
|
|
1126
1112
|
if (x)
|
|
1127
1113
|
for (const N of x.keys())
|
|
1128
|
-
N.startsWith(
|
|
1129
|
-
(C.type === "INSERT" || C.type === "REMOVE" || C.type === "CLEAR_SELECTION") &&
|
|
1114
|
+
N.startsWith(M) && x.delete(N);
|
|
1115
|
+
(C.type === "INSERT" || C.type === "REMOVE" || C.type === "CLEAR_SELECTION") && l({});
|
|
1130
1116
|
});
|
|
1131
1117
|
return () => {
|
|
1132
1118
|
O();
|
|
1133
1119
|
};
|
|
1134
|
-
}, [
|
|
1120
|
+
}, [M, c]), !Array.isArray(E))
|
|
1135
1121
|
return null;
|
|
1136
|
-
const _ =
|
|
1137
|
-
currentState:
|
|
1122
|
+
const _ = u({
|
|
1123
|
+
currentState: E,
|
|
1138
1124
|
path: i,
|
|
1139
|
-
componentId:
|
|
1125
|
+
componentId: M,
|
|
1140
1126
|
meta: {
|
|
1141
1127
|
...h,
|
|
1142
1128
|
validIds: p
|
|
1143
1129
|
}
|
|
1144
1130
|
});
|
|
1145
|
-
return /* @__PURE__ */ ot(Ot, { children:
|
|
1131
|
+
return /* @__PURE__ */ ot(Ot, { children: E.map((O, C) => {
|
|
1146
1132
|
const F = p[C];
|
|
1147
1133
|
if (!F)
|
|
1148
1134
|
return null;
|
|
@@ -1156,7 +1142,7 @@ function Dt(t, n, S, g) {
|
|
|
1156
1142
|
itemPath: N,
|
|
1157
1143
|
localIndex: C,
|
|
1158
1144
|
arraySetter: _,
|
|
1159
|
-
rebuildStateShape:
|
|
1145
|
+
rebuildStateShape: u,
|
|
1160
1146
|
renderFn: s
|
|
1161
1147
|
});
|
|
1162
1148
|
}) });
|
|
@@ -1164,28 +1150,28 @@ function Dt(t, n, S, g) {
|
|
|
1164
1150
|
if (m === "stateFlattenOn")
|
|
1165
1151
|
return (s) => {
|
|
1166
1152
|
const o = I;
|
|
1167
|
-
y.clear(),
|
|
1153
|
+
y.clear(), w++;
|
|
1168
1154
|
const r = o.flatMap(
|
|
1169
1155
|
(a) => a[s] ?? []
|
|
1170
1156
|
);
|
|
1171
|
-
return
|
|
1157
|
+
return u({
|
|
1172
1158
|
currentState: r,
|
|
1173
1159
|
path: [...i, "[*]", s],
|
|
1174
|
-
componentId:
|
|
1160
|
+
componentId: M,
|
|
1175
1161
|
meta: h
|
|
1176
1162
|
});
|
|
1177
1163
|
};
|
|
1178
1164
|
if (m === "index")
|
|
1179
1165
|
return (s) => {
|
|
1180
1166
|
const r = e.getState().getShadowMetadata(t, i)?.arrayKeys?.filter(
|
|
1181
|
-
(
|
|
1167
|
+
(l) => !h?.validIds || h?.validIds && h?.validIds?.includes(l)
|
|
1182
1168
|
)?.[s];
|
|
1183
1169
|
if (!r) return;
|
|
1184
1170
|
const a = e.getState().getShadowValue(r, h?.validIds);
|
|
1185
|
-
return
|
|
1171
|
+
return u({
|
|
1186
1172
|
currentState: a,
|
|
1187
1173
|
path: r.split(".").slice(1),
|
|
1188
|
-
componentId:
|
|
1174
|
+
componentId: M,
|
|
1189
1175
|
meta: h
|
|
1190
1176
|
});
|
|
1191
1177
|
};
|
|
@@ -1194,36 +1180,36 @@ function Dt(t, n, S, g) {
|
|
|
1194
1180
|
const s = e.getState().getShadowValue(t, i);
|
|
1195
1181
|
if (s.length === 0) return;
|
|
1196
1182
|
const o = s.length - 1, r = s[o], a = [...i, o.toString()];
|
|
1197
|
-
return
|
|
1183
|
+
return u({
|
|
1198
1184
|
currentState: r,
|
|
1199
1185
|
path: a,
|
|
1200
|
-
componentId:
|
|
1186
|
+
componentId: M,
|
|
1201
1187
|
meta: h
|
|
1202
1188
|
});
|
|
1203
1189
|
};
|
|
1204
1190
|
if (m === "insert")
|
|
1205
|
-
return (s, o) => (n(s, i, { updateType: "insert" }),
|
|
1191
|
+
return (s, o) => (n(s, i, { updateType: "insert" }), u({
|
|
1206
1192
|
currentState: e.getState().getShadowValue(t, i),
|
|
1207
1193
|
path: i,
|
|
1208
|
-
componentId:
|
|
1194
|
+
componentId: M,
|
|
1209
1195
|
meta: h
|
|
1210
1196
|
}));
|
|
1211
1197
|
if (m === "uniqueInsert")
|
|
1212
1198
|
return (s, o, r) => {
|
|
1213
1199
|
const a = e.getState().getShadowValue(t, i), d = at(s) ? s(a) : s;
|
|
1214
|
-
let
|
|
1215
|
-
if (!a.some((
|
|
1200
|
+
let l = null;
|
|
1201
|
+
if (!a.some((E) => {
|
|
1216
1202
|
const _ = o ? o.every(
|
|
1217
|
-
(O) => st(
|
|
1218
|
-
) : st(
|
|
1219
|
-
return _ && (
|
|
1203
|
+
(O) => st(E[O], d[O])
|
|
1204
|
+
) : st(E, d);
|
|
1205
|
+
return _ && (l = E), _;
|
|
1220
1206
|
}))
|
|
1221
|
-
|
|
1222
|
-
else if (r &&
|
|
1223
|
-
const
|
|
1224
|
-
(O) => st(O,
|
|
1207
|
+
T(i), n(d, i, { updateType: "insert" });
|
|
1208
|
+
else if (r && l) {
|
|
1209
|
+
const E = r(l), _ = a.map(
|
|
1210
|
+
(O) => st(O, l) ? E : O
|
|
1225
1211
|
);
|
|
1226
|
-
|
|
1212
|
+
T(i), n(_, i, {
|
|
1227
1213
|
updateType: "update"
|
|
1228
1214
|
});
|
|
1229
1215
|
}
|
|
@@ -1234,8 +1220,8 @@ function Dt(t, n, S, g) {
|
|
|
1234
1220
|
if (!r || r.length === 0) return;
|
|
1235
1221
|
const a = s == -1 ? r.length - 1 : s !== void 0 ? s : r.length - 1, d = r[a];
|
|
1236
1222
|
if (!d) return;
|
|
1237
|
-
const
|
|
1238
|
-
n(I,
|
|
1223
|
+
const l = d.split(".").slice(1);
|
|
1224
|
+
n(I, l, {
|
|
1239
1225
|
updateType: "cut"
|
|
1240
1226
|
});
|
|
1241
1227
|
};
|
|
@@ -1247,12 +1233,12 @@ function Dt(t, n, S, g) {
|
|
|
1247
1233
|
h?.transforms
|
|
1248
1234
|
);
|
|
1249
1235
|
if (!s || s.length === 0) return;
|
|
1250
|
-
const o = e.getState().selectedIndicesMap.get(
|
|
1236
|
+
const o = e.getState().selectedIndicesMap.get(c);
|
|
1251
1237
|
let r = s.findIndex(
|
|
1252
|
-
(
|
|
1238
|
+
(l) => l === o
|
|
1253
1239
|
);
|
|
1254
1240
|
const a = s[r == -1 ? s.length - 1 : r]?.split(".").slice(1);
|
|
1255
|
-
e.getState().clearSelectedIndex({ arrayKey:
|
|
1241
|
+
e.getState().clearSelectedIndex({ arrayKey: c });
|
|
1256
1242
|
const d = a?.slice(0, -1);
|
|
1257
1243
|
ft(t, d), n(I, a, {
|
|
1258
1244
|
updateType: "cut"
|
|
@@ -1279,8 +1265,8 @@ function Dt(t, n, S, g) {
|
|
|
1279
1265
|
if (!r) return;
|
|
1280
1266
|
let a = null;
|
|
1281
1267
|
for (const d of r) {
|
|
1282
|
-
const
|
|
1283
|
-
if (console.log("itemValue sdasdasdasd",
|
|
1268
|
+
const l = e.getState().getShadowValue(d);
|
|
1269
|
+
if (console.log("itemValue sdasdasdasd", l), l === s) {
|
|
1284
1270
|
a = d;
|
|
1285
1271
|
break;
|
|
1286
1272
|
}
|
|
@@ -1299,17 +1285,17 @@ function Dt(t, n, S, g) {
|
|
|
1299
1285
|
if (!r)
|
|
1300
1286
|
throw new Error("No array keys found for sorting");
|
|
1301
1287
|
let a = null, d = [];
|
|
1302
|
-
for (const
|
|
1303
|
-
let p = e.getState().getShadowValue(
|
|
1288
|
+
for (const l of r) {
|
|
1289
|
+
let p = e.getState().getShadowValue(l, h?.validIds);
|
|
1304
1290
|
if (p && p[s] === o) {
|
|
1305
|
-
a = p, d =
|
|
1291
|
+
a = p, d = l.split(".").slice(1);
|
|
1306
1292
|
break;
|
|
1307
1293
|
}
|
|
1308
1294
|
}
|
|
1309
|
-
return
|
|
1295
|
+
return u({
|
|
1310
1296
|
currentState: a,
|
|
1311
1297
|
path: d,
|
|
1312
|
-
componentId:
|
|
1298
|
+
componentId: M,
|
|
1313
1299
|
meta: h
|
|
1314
1300
|
});
|
|
1315
1301
|
};
|
|
@@ -1321,9 +1307,9 @@ function Dt(t, n, S, g) {
|
|
|
1321
1307
|
};
|
|
1322
1308
|
}
|
|
1323
1309
|
if (m === "get")
|
|
1324
|
-
return () => (
|
|
1310
|
+
return () => (Et(t, M, i), e.getState().getShadowValue(c, h?.validIds));
|
|
1325
1311
|
if (m === "getState")
|
|
1326
|
-
return () => e.getState().getShadowValue(
|
|
1312
|
+
return () => e.getState().getShadowValue(c, h?.validIds);
|
|
1327
1313
|
if (m === "$derive")
|
|
1328
1314
|
return (s) => bt({
|
|
1329
1315
|
_stateKey: t,
|
|
@@ -1361,7 +1347,7 @@ function Dt(t, n, S, g) {
|
|
|
1361
1347
|
e.getState().selectedIndicesMap.get(o) === r ? e.getState().clearSelectedIndex({ arrayKey: o }) : e.getState().setSelectedIndex(o, r);
|
|
1362
1348
|
};
|
|
1363
1349
|
if (m === "_componentId")
|
|
1364
|
-
return
|
|
1350
|
+
return M;
|
|
1365
1351
|
if (i.length == 0) {
|
|
1366
1352
|
if (m === "addValidation")
|
|
1367
1353
|
return (s) => {
|
|
@@ -1376,14 +1362,14 @@ function Dt(t, n, S, g) {
|
|
|
1376
1362
|
return (s) => {
|
|
1377
1363
|
const o = e.getState(), r = o.getShadowMetadata(t, []);
|
|
1378
1364
|
if (!r?.components) return;
|
|
1379
|
-
const a = (
|
|
1380
|
-
for (const
|
|
1381
|
-
const p = a(
|
|
1382
|
-
switch (
|
|
1365
|
+
const a = (l) => !l || l === "/" ? [] : l.split("/").slice(1).map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~")), d = /* @__PURE__ */ new Set();
|
|
1366
|
+
for (const l of s) {
|
|
1367
|
+
const p = a(l.path);
|
|
1368
|
+
switch (l.op) {
|
|
1383
1369
|
case "add":
|
|
1384
1370
|
case "replace": {
|
|
1385
|
-
const { value:
|
|
1386
|
-
o.updateShadowAtPath(t, p,
|
|
1371
|
+
const { value: E } = l;
|
|
1372
|
+
o.updateShadowAtPath(t, p, E), o.markAsDirty(t, p, { bubble: !0 });
|
|
1387
1373
|
let _ = [...p];
|
|
1388
1374
|
for (; ; ) {
|
|
1389
1375
|
const O = o.getShadowMetadata(
|
|
@@ -1401,9 +1387,9 @@ function Dt(t, n, S, g) {
|
|
|
1401
1387
|
break;
|
|
1402
1388
|
}
|
|
1403
1389
|
case "remove": {
|
|
1404
|
-
const
|
|
1405
|
-
o.removeShadowArrayElement(t, p), o.markAsDirty(t,
|
|
1406
|
-
let _ = [...
|
|
1390
|
+
const E = p.slice(0, -1);
|
|
1391
|
+
o.removeShadowArrayElement(t, p), o.markAsDirty(t, E, { bubble: !0 });
|
|
1392
|
+
let _ = [...E];
|
|
1407
1393
|
for (; ; ) {
|
|
1408
1394
|
const O = o.getShadowMetadata(
|
|
1409
1395
|
t,
|
|
@@ -1432,11 +1418,11 @@ function Dt(t, n, S, g) {
|
|
|
1432
1418
|
ut(s.key);
|
|
1433
1419
|
const r = e.getState().getShadowValue(t), a = o.safeParse(r);
|
|
1434
1420
|
return a.success ? !0 : ("issues" in a.error ? a.error.issues.forEach((d) => {
|
|
1435
|
-
const
|
|
1436
|
-
pt(
|
|
1421
|
+
const l = [s.key, ...d.path].join(".");
|
|
1422
|
+
pt(l, d.message);
|
|
1437
1423
|
}) : a.error.errors.forEach((d) => {
|
|
1438
|
-
const
|
|
1439
|
-
pt(
|
|
1424
|
+
const l = [s.key, ...d.path].join(".");
|
|
1425
|
+
pt(l, d.message);
|
|
1440
1426
|
}), it(t), !1);
|
|
1441
1427
|
};
|
|
1442
1428
|
if (m === "getComponents")
|
|
@@ -1451,7 +1437,7 @@ function Dt(t, n, S, g) {
|
|
|
1451
1437
|
children: s,
|
|
1452
1438
|
hideMessage: o
|
|
1453
1439
|
}) => /* @__PURE__ */ ot(
|
|
1454
|
-
|
|
1440
|
+
kt,
|
|
1455
1441
|
{
|
|
1456
1442
|
formOpts: o ? { validation: { message: "" } } : void 0,
|
|
1457
1443
|
path: i,
|
|
@@ -1500,24 +1486,24 @@ function Dt(t, n, S, g) {
|
|
|
1500
1486
|
{
|
|
1501
1487
|
stateKey: t,
|
|
1502
1488
|
path: i,
|
|
1503
|
-
rebuildStateShape:
|
|
1489
|
+
rebuildStateShape: u,
|
|
1504
1490
|
setState: n,
|
|
1505
1491
|
formOpts: o,
|
|
1506
1492
|
renderFn: s
|
|
1507
1493
|
}
|
|
1508
1494
|
);
|
|
1509
1495
|
const Q = [...i, m], X = e.getState().getShadowValue(t, Q);
|
|
1510
|
-
return
|
|
1496
|
+
return u({
|
|
1511
1497
|
currentState: X,
|
|
1512
1498
|
path: Q,
|
|
1513
|
-
componentId:
|
|
1499
|
+
componentId: M,
|
|
1514
1500
|
meta: h
|
|
1515
1501
|
});
|
|
1516
1502
|
}
|
|
1517
1503
|
}, H = new Proxy(B, J);
|
|
1518
1504
|
return y.set(z, {
|
|
1519
1505
|
proxy: H,
|
|
1520
|
-
stateVersion:
|
|
1506
|
+
stateVersion: w
|
|
1521
1507
|
}), H;
|
|
1522
1508
|
}
|
|
1523
1509
|
const f = {
|
|
@@ -1529,28 +1515,28 @@ function Dt(t, n, S, g) {
|
|
|
1529
1515
|
i?.key && ut(i.key), I?.validationKey && ut(I.validationKey);
|
|
1530
1516
|
const h = e.getState().getShadowMetadata(t, []);
|
|
1531
1517
|
h?.stateSource === "server" && h.baseServerState ? h.baseServerState : e.getState().initialStateGlobal[t];
|
|
1532
|
-
const
|
|
1533
|
-
e.getState().clearSelectedIndexesForState(t), y.clear(),
|
|
1534
|
-
currentState:
|
|
1518
|
+
const M = e.getState().initialStateGlobal[t];
|
|
1519
|
+
e.getState().clearSelectedIndexesForState(t), y.clear(), w++, e.getState().initializeShadowState(t, M), u({
|
|
1520
|
+
currentState: M,
|
|
1535
1521
|
path: [],
|
|
1536
1522
|
componentId: S
|
|
1537
1523
|
});
|
|
1538
|
-
const z = nt(t),
|
|
1524
|
+
const z = nt(t), c = at(z?.localStorage?.key) ? z?.localStorage?.key(M) : z?.localStorage?.key, B = `${g}-${t}-${c}`;
|
|
1539
1525
|
B && localStorage.removeItem(B);
|
|
1540
1526
|
const J = e.getState().getShadowMetadata(t, []);
|
|
1541
1527
|
return J && J?.components?.forEach((H) => {
|
|
1542
1528
|
H.forceUpdate();
|
|
1543
|
-
}),
|
|
1529
|
+
}), M;
|
|
1544
1530
|
},
|
|
1545
1531
|
updateInitialState: (I) => {
|
|
1546
|
-
y.clear(),
|
|
1532
|
+
y.clear(), w++;
|
|
1547
1533
|
const i = Dt(
|
|
1548
1534
|
t,
|
|
1549
1535
|
n,
|
|
1550
1536
|
S,
|
|
1551
1537
|
g
|
|
1552
|
-
), h = e.getState().initialStateGlobal[t],
|
|
1553
|
-
return localStorage.getItem(
|
|
1538
|
+
), h = e.getState().initialStateGlobal[t], M = nt(t), z = at(M?.localStorage?.key) ? M?.localStorage?.key(h) : M?.localStorage?.key, c = `${g}-${t}-${z}`;
|
|
1539
|
+
return localStorage.getItem(c) && localStorage.removeItem(c), Rt(() => {
|
|
1554
1540
|
_t(t, I), e.getState().initializeShadowState(t, I);
|
|
1555
1541
|
const B = e.getState().getShadowMetadata(t, []);
|
|
1556
1542
|
B && B?.components?.forEach((J) => {
|
|
@@ -1561,7 +1547,7 @@ function Dt(t, n, S, g) {
|
|
|
1561
1547
|
};
|
|
1562
1548
|
}
|
|
1563
1549
|
};
|
|
1564
|
-
return
|
|
1550
|
+
return u({
|
|
1565
1551
|
currentState: e.getState().getShadowValue(t, []),
|
|
1566
1552
|
componentId: S,
|
|
1567
1553
|
path: []
|
|
@@ -1574,16 +1560,16 @@ function qt({
|
|
|
1574
1560
|
proxy: t,
|
|
1575
1561
|
rebuildStateShape: n
|
|
1576
1562
|
}) {
|
|
1577
|
-
const S = q(null), g = q(`map-${crypto.randomUUID()}`), y = q(!1),
|
|
1563
|
+
const S = q(null), g = q(`map-${crypto.randomUUID()}`), y = q(!1), w = q(/* @__PURE__ */ new Map());
|
|
1578
1564
|
Z(() => {
|
|
1579
|
-
const
|
|
1580
|
-
if (!
|
|
1565
|
+
const u = S.current;
|
|
1566
|
+
if (!u || y.current) return;
|
|
1581
1567
|
const f = setTimeout(() => {
|
|
1582
1568
|
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, I = A.mapWrappers || [];
|
|
1583
1569
|
I.push({
|
|
1584
1570
|
instanceId: g.current,
|
|
1585
1571
|
mapFn: t._mapFn,
|
|
1586
|
-
containerRef:
|
|
1572
|
+
containerRef: u,
|
|
1587
1573
|
rebuildStateShape: n,
|
|
1588
1574
|
path: t._path,
|
|
1589
1575
|
componentId: g.current,
|
|
@@ -1591,7 +1577,7 @@ function qt({
|
|
|
1591
1577
|
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1592
1578
|
...A,
|
|
1593
1579
|
mapWrappers: I
|
|
1594
|
-
}), y.current = !0,
|
|
1580
|
+
}), y.current = !0, T();
|
|
1595
1581
|
}, 0);
|
|
1596
1582
|
return () => {
|
|
1597
1583
|
if (clearTimeout(f), g.current) {
|
|
@@ -1600,12 +1586,12 @@ function qt({
|
|
|
1600
1586
|
(I) => I.instanceId !== g.current
|
|
1601
1587
|
), e.getState().setShadowMetadata(t._stateKey, t._path, A));
|
|
1602
1588
|
}
|
|
1603
|
-
|
|
1589
|
+
w.current.forEach((A) => A.unmount());
|
|
1604
1590
|
};
|
|
1605
1591
|
}, []);
|
|
1606
|
-
const
|
|
1607
|
-
const
|
|
1608
|
-
if (!
|
|
1592
|
+
const T = () => {
|
|
1593
|
+
const u = S.current;
|
|
1594
|
+
if (!u) return;
|
|
1609
1595
|
const f = e.getState().getShadowValue(
|
|
1610
1596
|
[t._stateKey, ...t._path].join("."),
|
|
1611
1597
|
t._meta?.validIds
|
|
@@ -1618,13 +1604,13 @@ function qt({
|
|
|
1618
1604
|
meta: t._meta
|
|
1619
1605
|
});
|
|
1620
1606
|
f.forEach((i, h) => {
|
|
1621
|
-
const
|
|
1622
|
-
if (!
|
|
1623
|
-
const z = rt(),
|
|
1624
|
-
|
|
1625
|
-
const B = At(
|
|
1626
|
-
|
|
1627
|
-
const J =
|
|
1607
|
+
const M = A[h];
|
|
1608
|
+
if (!M) return;
|
|
1609
|
+
const z = rt(), c = document.createElement("div");
|
|
1610
|
+
c.setAttribute("data-item-path", M), u.appendChild(c);
|
|
1611
|
+
const B = At(c);
|
|
1612
|
+
w.current.set(M, B);
|
|
1613
|
+
const J = M.split(".").slice(1);
|
|
1628
1614
|
B.render(
|
|
1629
1615
|
lt(Mt, {
|
|
1630
1616
|
stateKey: t._stateKey,
|
|
@@ -1643,47 +1629,47 @@ function qt({
|
|
|
1643
1629
|
function Gt({
|
|
1644
1630
|
proxy: t
|
|
1645
1631
|
}) {
|
|
1646
|
-
const n = q(null), S = q(null), g = q(!1), y = `${t._stateKey}-${t._path.join(".")}`,
|
|
1632
|
+
const n = q(null), S = q(null), g = q(!1), y = `${t._stateKey}-${t._path.join(".")}`, w = e.getState().getShadowValue(
|
|
1647
1633
|
[t._stateKey, ...t._path].join("."),
|
|
1648
1634
|
t._meta?.validIds
|
|
1649
1635
|
);
|
|
1650
1636
|
return Z(() => {
|
|
1651
|
-
const
|
|
1652
|
-
if (!
|
|
1653
|
-
const
|
|
1654
|
-
if (!
|
|
1637
|
+
const T = n.current;
|
|
1638
|
+
if (!T || g.current) return;
|
|
1639
|
+
const u = setTimeout(() => {
|
|
1640
|
+
if (!T.parentElement) {
|
|
1655
1641
|
console.warn("Parent element not found for signal", y);
|
|
1656
1642
|
return;
|
|
1657
1643
|
}
|
|
1658
|
-
const f =
|
|
1644
|
+
const f = T.parentElement, I = Array.from(f.childNodes).indexOf(T);
|
|
1659
1645
|
let i = f.getAttribute("data-parent-id");
|
|
1660
1646
|
i || (i = `parent-${crypto.randomUUID()}`, f.setAttribute("data-parent-id", i)), S.current = `instance-${crypto.randomUUID()}`;
|
|
1661
|
-
const h = e.getState().getShadowMetadata(t._stateKey, t._path) || {},
|
|
1662
|
-
|
|
1647
|
+
const h = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, M = h.signals || [];
|
|
1648
|
+
M.push({
|
|
1663
1649
|
instanceId: S.current,
|
|
1664
1650
|
parentId: i,
|
|
1665
1651
|
position: I,
|
|
1666
1652
|
effect: t._effect
|
|
1667
1653
|
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1668
1654
|
...h,
|
|
1669
|
-
signals:
|
|
1655
|
+
signals: M
|
|
1670
1656
|
});
|
|
1671
|
-
let z =
|
|
1657
|
+
let z = w;
|
|
1672
1658
|
if (t._effect)
|
|
1673
1659
|
try {
|
|
1674
1660
|
z = new Function(
|
|
1675
1661
|
"state",
|
|
1676
1662
|
`return (${t._effect})(state)`
|
|
1677
|
-
)(
|
|
1663
|
+
)(w);
|
|
1678
1664
|
} catch (B) {
|
|
1679
1665
|
console.error("Error evaluating effect function:", B);
|
|
1680
1666
|
}
|
|
1681
1667
|
z !== null && typeof z == "object" && (z = JSON.stringify(z));
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1668
|
+
const c = document.createTextNode(String(z ?? ""));
|
|
1669
|
+
T.replaceWith(c), g.current = !0;
|
|
1684
1670
|
}, 0);
|
|
1685
1671
|
return () => {
|
|
1686
|
-
if (clearTimeout(
|
|
1672
|
+
if (clearTimeout(u), S.current) {
|
|
1687
1673
|
const f = e.getState().getShadowMetadata(t._stateKey, t._path) || {};
|
|
1688
1674
|
f.signals && (f.signals = f.signals.filter(
|
|
1689
1675
|
(A) => A.instanceId !== S.current
|
|
@@ -1712,14 +1698,14 @@ const Mt = Ut(
|
|
|
1712
1698
|
return;
|
|
1713
1699
|
}
|
|
1714
1700
|
let y = 0;
|
|
1715
|
-
const
|
|
1701
|
+
const w = () => {
|
|
1716
1702
|
y++, y === g.length && S(!0);
|
|
1717
1703
|
};
|
|
1718
|
-
return g.forEach((
|
|
1719
|
-
|
|
1704
|
+
return g.forEach((T) => {
|
|
1705
|
+
T.complete ? w() : (T.addEventListener("load", w), T.addEventListener("error", w));
|
|
1720
1706
|
}), () => {
|
|
1721
|
-
g.forEach((
|
|
1722
|
-
|
|
1707
|
+
g.forEach((T) => {
|
|
1708
|
+
T.removeEventListener("load", w), T.removeEventListener("error", w);
|
|
1723
1709
|
});
|
|
1724
1710
|
};
|
|
1725
1711
|
}, [t.current]), n;
|
|
@@ -1730,11 +1716,11 @@ function Yt({
|
|
|
1730
1716
|
itemPath: S,
|
|
1731
1717
|
localIndex: g,
|
|
1732
1718
|
arraySetter: y,
|
|
1733
|
-
rebuildStateShape:
|
|
1734
|
-
renderFn:
|
|
1719
|
+
rebuildStateShape: w,
|
|
1720
|
+
renderFn: T
|
|
1735
1721
|
}) {
|
|
1736
|
-
const [,
|
|
1737
|
-
$t(t, n,
|
|
1722
|
+
const [, u] = K({}), { ref: f, inView: A } = jt(), I = q(null), i = Jt(I), h = q(!1), M = [t, ...S].join(".");
|
|
1723
|
+
$t(t, n, u);
|
|
1738
1724
|
const z = ct(
|
|
1739
1725
|
(W) => {
|
|
1740
1726
|
I.current = W, f(W);
|
|
@@ -1742,8 +1728,8 @@ function Yt({
|
|
|
1742
1728
|
[f]
|
|
1743
1729
|
);
|
|
1744
1730
|
Z(() => {
|
|
1745
|
-
e.getState().subscribeToPath(
|
|
1746
|
-
|
|
1731
|
+
e.getState().subscribeToPath(M, (W) => {
|
|
1732
|
+
u({});
|
|
1747
1733
|
});
|
|
1748
1734
|
}, []), Z(() => {
|
|
1749
1735
|
if (!A || !i || h.current)
|
|
@@ -1766,14 +1752,14 @@ function Yt({
|
|
|
1766
1752
|
});
|
|
1767
1753
|
}
|
|
1768
1754
|
}, [A, i, t, S]);
|
|
1769
|
-
const
|
|
1755
|
+
const c = [t, ...S].join("."), B = e.getState().getShadowValue(c);
|
|
1770
1756
|
if (B === void 0)
|
|
1771
1757
|
return null;
|
|
1772
|
-
const J =
|
|
1758
|
+
const J = w({
|
|
1773
1759
|
currentState: B,
|
|
1774
1760
|
path: S,
|
|
1775
1761
|
componentId: n
|
|
1776
|
-
}), H =
|
|
1762
|
+
}), H = T(J, g, y);
|
|
1777
1763
|
return /* @__PURE__ */ ot("div", { ref: z, children: H });
|
|
1778
1764
|
}
|
|
1779
1765
|
function Zt({
|
|
@@ -1782,27 +1768,27 @@ function Zt({
|
|
|
1782
1768
|
rebuildStateShape: S,
|
|
1783
1769
|
renderFn: g,
|
|
1784
1770
|
formOpts: y,
|
|
1785
|
-
setState:
|
|
1771
|
+
setState: w
|
|
1786
1772
|
}) {
|
|
1787
|
-
const [
|
|
1788
|
-
$t(t,
|
|
1789
|
-
const A = e.getState().getShadowValue(f), [I, i] = K(A), h = q(!1),
|
|
1773
|
+
const [T] = K(() => rt()), [, u] = K({}), f = [t, ...n].join(".");
|
|
1774
|
+
$t(t, T, u);
|
|
1775
|
+
const A = e.getState().getShadowValue(f), [I, i] = K(A), h = q(!1), M = q(null);
|
|
1790
1776
|
Z(() => {
|
|
1791
1777
|
!h.current && !st(A, I) && i(A);
|
|
1792
1778
|
}, [A]), Z(() => {
|
|
1793
1779
|
const H = e.getState().subscribeToPath(f, (W) => {
|
|
1794
|
-
!h.current && I !== W &&
|
|
1780
|
+
!h.current && I !== W && u({});
|
|
1795
1781
|
});
|
|
1796
1782
|
return () => {
|
|
1797
|
-
H(),
|
|
1783
|
+
H(), M.current && (clearTimeout(M.current), h.current = !1);
|
|
1798
1784
|
};
|
|
1799
1785
|
}, []);
|
|
1800
1786
|
const z = ct(
|
|
1801
1787
|
(H) => {
|
|
1802
|
-
typeof A === "number" && typeof H == "string" && (H = H === "" ? 0 : Number(H)), i(H), h.current = !0,
|
|
1788
|
+
typeof A === "number" && typeof H == "string" && (H = H === "" ? 0 : Number(H)), i(H), h.current = !0, M.current && clearTimeout(M.current);
|
|
1803
1789
|
const m = y?.debounceTime ?? 200;
|
|
1804
|
-
|
|
1805
|
-
h.current = !1,
|
|
1790
|
+
M.current = setTimeout(() => {
|
|
1791
|
+
h.current = !1, w(H, n, { updateType: "update" });
|
|
1806
1792
|
const { getInitialOptions: Y, setShadowMetadata: Q, getShadowMetadata: X } = e.getState(), s = Y(t)?.validation, o = s?.zodSchemaV4 || s?.zodSchemaV3;
|
|
1807
1793
|
if (o) {
|
|
1808
1794
|
const r = e.getState().getShadowValue(t), a = o.safeParse(r), d = X(t, n) || {};
|
|
@@ -1816,7 +1802,7 @@ function Zt({
|
|
|
1816
1802
|
});
|
|
1817
1803
|
else {
|
|
1818
1804
|
const p = ("issues" in a.error ? a.error.issues : a.error.errors).filter(
|
|
1819
|
-
(
|
|
1805
|
+
(E) => JSON.stringify(E.path) === JSON.stringify(n)
|
|
1820
1806
|
);
|
|
1821
1807
|
p.length > 0 ? Q(t, n, {
|
|
1822
1808
|
...d,
|
|
@@ -1834,11 +1820,11 @@ function Zt({
|
|
|
1834
1820
|
});
|
|
1835
1821
|
}
|
|
1836
1822
|
}
|
|
1837
|
-
}, m),
|
|
1823
|
+
}, m), u({});
|
|
1838
1824
|
},
|
|
1839
|
-
[
|
|
1840
|
-
),
|
|
1841
|
-
console.log("handleBlur triggered"),
|
|
1825
|
+
[w, n, y?.debounceTime, t]
|
|
1826
|
+
), c = ct(async () => {
|
|
1827
|
+
console.log("handleBlur triggered"), M.current && (clearTimeout(M.current), M.current = null, h.current = !1, w(I, n, { updateType: "update" }));
|
|
1842
1828
|
const { getInitialOptions: H } = e.getState(), W = H(t)?.validation, m = W?.zodSchemaV4 || W?.zodSchemaV3;
|
|
1843
1829
|
if (!m) return;
|
|
1844
1830
|
const Y = e.getState().getShadowMetadata(t, n);
|
|
@@ -1866,11 +1852,11 @@ function Zt({
|
|
|
1866
1852
|
console.log("Detected array path with ULID");
|
|
1867
1853
|
const d = n[0].startsWith("id:") ? [] : n.slice(0, -1);
|
|
1868
1854
|
console.log("Parent path:", d);
|
|
1869
|
-
const
|
|
1870
|
-
if (console.log("Array metadata:",
|
|
1871
|
-
const p = [t, ...n.slice(0, -1)].join("."),
|
|
1872
|
-
console.log("Item key:", p, "Index:",
|
|
1873
|
-
const _ = [...d,
|
|
1855
|
+
const l = e.getState().getShadowMetadata(t, d);
|
|
1856
|
+
if (console.log("Array metadata:", l), l?.arrayKeys) {
|
|
1857
|
+
const p = [t, ...n.slice(0, -1)].join("."), E = l.arrayKeys.indexOf(p);
|
|
1858
|
+
console.log("Item key:", p, "Index:", E);
|
|
1859
|
+
const _ = [...d, E, ...n.slice(-1)], O = JSON.stringify(r.path) === JSON.stringify(_);
|
|
1874
1860
|
return console.log("Zod path comparison:", {
|
|
1875
1861
|
zodPath: _,
|
|
1876
1862
|
errorPath: r.path,
|
|
@@ -1894,11 +1880,11 @@ function Zt({
|
|
|
1894
1880
|
}
|
|
1895
1881
|
});
|
|
1896
1882
|
}
|
|
1897
|
-
|
|
1898
|
-
}, [t, n, I,
|
|
1883
|
+
u({});
|
|
1884
|
+
}, [t, n, I, w]), B = S({
|
|
1899
1885
|
currentState: A,
|
|
1900
1886
|
path: n,
|
|
1901
|
-
componentId:
|
|
1887
|
+
componentId: T
|
|
1902
1888
|
}), J = new Proxy(B, {
|
|
1903
1889
|
get(H, W) {
|
|
1904
1890
|
return W === "inputProps" ? {
|
|
@@ -1907,23 +1893,23 @@ function Zt({
|
|
|
1907
1893
|
z(m.target.value);
|
|
1908
1894
|
},
|
|
1909
1895
|
// 5. Wire the new onBlur handler to the input props.
|
|
1910
|
-
onBlur:
|
|
1896
|
+
onBlur: c,
|
|
1911
1897
|
ref: vt.getState().getFormRef(t + "." + n.join("."))
|
|
1912
1898
|
} : H[W];
|
|
1913
1899
|
}
|
|
1914
1900
|
});
|
|
1915
|
-
return /* @__PURE__ */ ot(
|
|
1901
|
+
return /* @__PURE__ */ ot(kt, { formOpts: y, path: n, stateKey: t, children: g(J) });
|
|
1916
1902
|
}
|
|
1917
1903
|
function $t(t, n, S) {
|
|
1918
1904
|
const g = `${t}////${n}`;
|
|
1919
1905
|
dt(() => {
|
|
1920
|
-
const { registerComponent: y, unregisterComponent:
|
|
1906
|
+
const { registerComponent: y, unregisterComponent: w } = e.getState();
|
|
1921
1907
|
return y(t, g, {
|
|
1922
1908
|
forceUpdate: () => S({}),
|
|
1923
1909
|
paths: /* @__PURE__ */ new Set(),
|
|
1924
1910
|
reactiveType: ["component"]
|
|
1925
1911
|
}), () => {
|
|
1926
|
-
|
|
1912
|
+
w(t, g);
|
|
1927
1913
|
};
|
|
1928
1914
|
}, [t, g]);
|
|
1929
1915
|
}
|