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