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