cogsbox-state 0.5.448 → 0.5.449
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 +4 -7
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +308 -304
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +17 -17
package/dist/CogsState.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as ot, Fragment as
|
|
3
|
-
import { memo as
|
|
2
|
+
import { jsx as ot, Fragment as Ot } from "react/jsx-runtime";
|
|
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
6
|
import { ValidationWrapper as kt } from "./Functions.jsx";
|
|
@@ -10,8 +10,8 @@ import { getGlobalStore as e, formRefStore as vt } from "./store.js";
|
|
|
10
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
|
-
const
|
|
14
|
-
|
|
13
|
+
const S = e.getState().getInitialOptions, g = e.getState().setInitialStateOptions, y = S(t) || {};
|
|
14
|
+
g(t, {
|
|
15
15
|
...y,
|
|
16
16
|
...n
|
|
17
17
|
});
|
|
@@ -19,22 +19,22 @@ function yt(t, n) {
|
|
|
19
19
|
function Vt({
|
|
20
20
|
stateKey: t,
|
|
21
21
|
options: n,
|
|
22
|
-
initialOptionsPart:
|
|
22
|
+
initialOptionsPart: S
|
|
23
23
|
}) {
|
|
24
|
-
const
|
|
24
|
+
const g = nt(t) || {}, y = S[t] || {}, w = e.getState().setInitialStateOptions, T = { ...y, ...g };
|
|
25
25
|
let u = !1;
|
|
26
26
|
if (n)
|
|
27
27
|
for (const f in n)
|
|
28
|
-
|
|
29
|
-
u &&
|
|
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
|
-
function ie(t, { formElements: n, validation:
|
|
32
|
-
return { initialState: t, formElements: n, validation:
|
|
31
|
+
function ie(t, { formElements: n, validation: S }) {
|
|
32
|
+
return { initialState: t, formElements: n, validation: S };
|
|
33
33
|
}
|
|
34
34
|
const Lt = (t, n) => {
|
|
35
|
-
let
|
|
36
|
-
const [
|
|
37
|
-
n?.__fromSyncSchema && n?.__syncNotifications && e.getState().setInitialStateOptions("__notifications", n.__syncNotifications), Object.keys(
|
|
35
|
+
let S = t;
|
|
36
|
+
const [g, y] = Nt(S);
|
|
37
|
+
n?.__fromSyncSchema && n?.__syncNotifications && e.getState().setInitialStateOptions("__notifications", n.__syncNotifications), Object.keys(g).forEach((u) => {
|
|
38
38
|
let f = y[u] || {};
|
|
39
39
|
const A = {
|
|
40
40
|
...f
|
|
@@ -46,23 +46,23 @@ const Lt = (t, n) => {
|
|
|
46
46
|
...n.validation,
|
|
47
47
|
...f.validation || {}
|
|
48
48
|
}, n.validation.key && !f.validation?.key && (A.validation.key = `${n.validation.key}.${u}`)), Object.keys(A).length > 0) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
...
|
|
49
|
+
const I = nt(u);
|
|
50
|
+
I ? e.getState().setInitialStateOptions(u, {
|
|
51
|
+
...I,
|
|
52
52
|
...A
|
|
53
53
|
}) : e.getState().setInitialStateOptions(u, A);
|
|
54
54
|
}
|
|
55
|
-
}), Object.keys(
|
|
56
|
-
e.getState().initializeShadowState(u,
|
|
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
60
|
Vt({
|
|
61
61
|
stateKey: u,
|
|
62
62
|
options: f,
|
|
63
63
|
initialOptionsPart: y
|
|
64
64
|
});
|
|
65
|
-
const
|
|
65
|
+
const I = e.getState().getShadowValue(u) || g[u], i = f?.modifyState ? f.modifyState(I) : I;
|
|
66
66
|
return zt(i, {
|
|
67
67
|
stateKey: u,
|
|
68
68
|
syncUpdate: f?.syncUpdate,
|
|
@@ -76,21 +76,25 @@ const Lt = (t, n) => {
|
|
|
76
76
|
serverState: f?.serverState
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
-
function
|
|
79
|
+
function T(u, f) {
|
|
80
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
|
-
const n = t.schemas,
|
|
86
|
-
for (const
|
|
87
|
-
const
|
|
88
|
-
|
|
85
|
+
const n = t.schemas, 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
|
+
return {
|
|
95
|
+
useCogsState: (w, T) => g.useCogsState(w, T),
|
|
96
|
+
setCogsOptions: g.setCogsOptions
|
|
97
|
+
};
|
|
94
98
|
}
|
|
95
99
|
const {
|
|
96
100
|
getInitialOptions: nt,
|
|
@@ -99,19 +103,19 @@ const {
|
|
|
99
103
|
updateInitialStateGlobal: _t,
|
|
100
104
|
addValidationError: pt,
|
|
101
105
|
removeValidationError: ut
|
|
102
|
-
} = e.getState(), Ht = (t, n,
|
|
103
|
-
|
|
106
|
+
} = e.getState(), Ht = (t, n, S, g, y) => {
|
|
107
|
+
S?.log && console.log(
|
|
104
108
|
"saving to localstorage",
|
|
105
109
|
n,
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
S.localStorage?.key,
|
|
111
|
+
g
|
|
108
112
|
);
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
113
|
+
const w = at(S?.localStorage?.key) ? S.localStorage?.key(t) : S?.localStorage?.key;
|
|
114
|
+
if (w && g) {
|
|
115
|
+
const T = `${g}-${n}-${w}`;
|
|
112
116
|
let u;
|
|
113
117
|
try {
|
|
114
|
-
u =
|
|
118
|
+
u = St(T)?.lastSyncedWithServer;
|
|
115
119
|
} catch {
|
|
116
120
|
}
|
|
117
121
|
const f = e.getState().getShadowMetadata(n, []), A = {
|
|
@@ -120,13 +124,13 @@ const {
|
|
|
120
124
|
lastSyncedWithServer: u,
|
|
121
125
|
stateSource: f?.stateSource,
|
|
122
126
|
baseServerState: f?.baseServerState
|
|
123
|
-
},
|
|
127
|
+
}, I = Ft.serialize(A);
|
|
124
128
|
window.localStorage.setItem(
|
|
125
|
-
|
|
126
|
-
JSON.stringify(
|
|
129
|
+
T,
|
|
130
|
+
JSON.stringify(I.json)
|
|
127
131
|
);
|
|
128
132
|
}
|
|
129
|
-
},
|
|
133
|
+
}, St = (t) => {
|
|
130
134
|
if (!t) return null;
|
|
131
135
|
try {
|
|
132
136
|
const n = window.localStorage.getItem(t);
|
|
@@ -135,71 +139,71 @@ const {
|
|
|
135
139
|
return console.error("Error loading from localStorage:", n), null;
|
|
136
140
|
}
|
|
137
141
|
}, xt = (t, n) => {
|
|
138
|
-
const
|
|
139
|
-
if (y &&
|
|
140
|
-
const
|
|
141
|
-
`${
|
|
142
|
+
const S = e.getState().getShadowValue(t), { sessionId: g } = Pt(), y = at(n?.localStorage?.key) ? n.localStorage.key(S) : n?.localStorage?.key;
|
|
143
|
+
if (y && g) {
|
|
144
|
+
const w = St(
|
|
145
|
+
`${g}-${t}-${y}`
|
|
142
146
|
);
|
|
143
|
-
if (
|
|
147
|
+
if (w && w.lastUpdated > (w.lastSyncedWithServer || 0))
|
|
144
148
|
return it(t), !0;
|
|
145
149
|
}
|
|
146
150
|
return !1;
|
|
147
151
|
}, it = (t) => {
|
|
148
152
|
const n = e.getState().getShadowMetadata(t, []);
|
|
149
153
|
if (!n) return;
|
|
150
|
-
const
|
|
151
|
-
n?.components?.forEach((
|
|
152
|
-
(
|
|
154
|
+
const S = /* @__PURE__ */ new Set();
|
|
155
|
+
n?.components?.forEach((g) => {
|
|
156
|
+
(g ? Array.isArray(g.reactiveType) ? g.reactiveType : [g.reactiveType || "component"] : null)?.includes("none") || S.add(() => g.forceUpdate());
|
|
153
157
|
}), queueMicrotask(() => {
|
|
154
|
-
|
|
158
|
+
S.forEach((g) => g());
|
|
155
159
|
});
|
|
156
160
|
}, ue = (t, n) => {
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
161
|
+
const S = e.getState().getShadowMetadata(t, []);
|
|
162
|
+
if (S) {
|
|
163
|
+
const g = `${t}////${n}`, y = S?.components?.get(g);
|
|
160
164
|
if ((y ? Array.isArray(y.reactiveType) ? y.reactiveType : [y.reactiveType || "component"] : null)?.includes("none"))
|
|
161
165
|
return;
|
|
162
166
|
y && y.forceUpdate();
|
|
163
167
|
}
|
|
164
168
|
};
|
|
165
|
-
function wt(t, n,
|
|
166
|
-
const y = e.getState(),
|
|
169
|
+
function wt(t, n, S, g) {
|
|
170
|
+
const y = e.getState(), w = y.getShadowMetadata(t, n);
|
|
167
171
|
if (y.setShadowMetadata(t, n, {
|
|
168
|
-
...
|
|
172
|
+
...w,
|
|
169
173
|
isDirty: !1,
|
|
170
174
|
stateSource: "server",
|
|
171
|
-
lastServerSync:
|
|
172
|
-
}), Array.isArray(
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
const A = u.split(".").slice(1),
|
|
176
|
-
|
|
175
|
+
lastServerSync: g || Date.now()
|
|
176
|
+
}), Array.isArray(S)) {
|
|
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];
|
|
180
|
+
I !== void 0 && wt(
|
|
177
181
|
t,
|
|
178
182
|
A,
|
|
179
|
-
|
|
180
|
-
|
|
183
|
+
I,
|
|
184
|
+
g
|
|
181
185
|
);
|
|
182
186
|
});
|
|
183
|
-
} else
|
|
184
|
-
const u = [...n,
|
|
185
|
-
wt(t, u, f,
|
|
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);
|
|
186
190
|
});
|
|
187
191
|
}
|
|
188
192
|
function zt(t, {
|
|
189
193
|
stateKey: n,
|
|
190
|
-
localStorage:
|
|
191
|
-
formElements:
|
|
194
|
+
localStorage: S,
|
|
195
|
+
formElements: g,
|
|
192
196
|
reactiveDeps: y,
|
|
193
|
-
reactiveType:
|
|
194
|
-
componentId:
|
|
197
|
+
reactiveType: w,
|
|
198
|
+
componentId: T,
|
|
195
199
|
defaultState: u,
|
|
196
200
|
syncUpdate: f,
|
|
197
201
|
dependencies: A,
|
|
198
|
-
serverState:
|
|
202
|
+
serverState: I
|
|
199
203
|
} = {}) {
|
|
200
204
|
const [i, h] = K({}), { sessionId: M } = Pt();
|
|
201
205
|
let z = !n;
|
|
202
|
-
const [c] = K(n ?? rt()), B = e.getState().stateLog[c], J = q(/* @__PURE__ */ new Set()), H = q(
|
|
206
|
+
const [c] = K(n ?? rt()), B = e.getState().stateLog[c], J = q(/* @__PURE__ */ new Set()), H = q(T ?? rt()), W = q(
|
|
203
207
|
null
|
|
204
208
|
);
|
|
205
209
|
W.current = nt(c) ?? null, Z(() => {
|
|
@@ -221,7 +225,7 @@ function zt(t, {
|
|
|
221
225
|
timestamp: a.serverState.timestamp || Date.now()
|
|
222
226
|
};
|
|
223
227
|
if (a?.localStorage?.key && M) {
|
|
224
|
-
const p = at(a.localStorage.key) ? a.localStorage.key(d) : a.localStorage.key, E =
|
|
228
|
+
const p = at(a.localStorage.key) ? a.localStorage.key(d) : a.localStorage.key, E = St(
|
|
225
229
|
`${M}-${c}-${p}`
|
|
226
230
|
);
|
|
227
231
|
if (E && E.lastUpdated > (a?.serverState?.timestamp || 0))
|
|
@@ -240,17 +244,17 @@ function zt(t, {
|
|
|
240
244
|
[c, u, t, M]
|
|
241
245
|
);
|
|
242
246
|
Z(() => {
|
|
243
|
-
e.getState().setServerStateUpdate(c,
|
|
244
|
-
}, [
|
|
247
|
+
e.getState().setServerStateUpdate(c, I);
|
|
248
|
+
}, [I, c]), Z(() => e.getState().subscribeToPath(c, (r) => {
|
|
245
249
|
if (r?.type === "SERVER_STATE_UPDATE") {
|
|
246
250
|
const a = r.serverState;
|
|
247
251
|
if (a?.status === "success" && a.data !== void 0) {
|
|
248
252
|
yt(c, { serverState: a });
|
|
249
253
|
const l = typeof a.merge == "object" ? a.merge : a.merge === !0 ? {} : null, p = e.getState().getShadowValue(c), E = a.data;
|
|
250
254
|
if (l && Array.isArray(p) && Array.isArray(E)) {
|
|
251
|
-
const
|
|
252
|
-
p.map((x) => x[
|
|
253
|
-
), F = E.filter((x) => !C.has(x[
|
|
255
|
+
const O = l.key || "id", C = new Set(
|
|
256
|
+
p.map((x) => x[O])
|
|
257
|
+
), F = E.filter((x) => !C.has(x[O]));
|
|
254
258
|
F.length > 0 && F.forEach((x) => {
|
|
255
259
|
e.getState().insertShadowArrayElement(c, [], x);
|
|
256
260
|
const N = e.getState().getShadowMetadata(c, []);
|
|
@@ -265,8 +269,8 @@ function zt(t, {
|
|
|
265
269
|
});
|
|
266
270
|
const k = e.getState().getShadowValue(j);
|
|
267
271
|
k && typeof k == "object" && !Array.isArray(k) && Object.keys(k).forEach((P) => {
|
|
268
|
-
const
|
|
269
|
-
e.getState().setShadowMetadata(c,
|
|
272
|
+
const U = [...b, P];
|
|
273
|
+
e.getState().setShadowMetadata(c, U, {
|
|
270
274
|
isDirty: !1,
|
|
271
275
|
stateSource: "server",
|
|
272
276
|
lastServerSync: a.timestamp || Date.now()
|
|
@@ -311,15 +315,15 @@ function zt(t, {
|
|
|
311
315
|
}
|
|
312
316
|
}, [c, ...A || []]), dt(() => {
|
|
313
317
|
z && yt(c, {
|
|
314
|
-
formElements:
|
|
318
|
+
formElements: g,
|
|
315
319
|
defaultState: u,
|
|
316
|
-
localStorage:
|
|
320
|
+
localStorage: S,
|
|
317
321
|
middleware: W.current?.middleware
|
|
318
322
|
});
|
|
319
323
|
const o = `${c}////${H.current}`, r = e.getState().getShadowMetadata(c, []), a = r?.components || /* @__PURE__ */ new Map();
|
|
320
324
|
return a.set(o, {
|
|
321
325
|
forceUpdate: () => h({}),
|
|
322
|
-
reactiveType:
|
|
326
|
+
reactiveType: w ?? ["component", "deps"],
|
|
323
327
|
paths: /* @__PURE__ */ new Set(),
|
|
324
328
|
depsFunction: y || void 0,
|
|
325
329
|
deps: y ? y(e.getState().getShadowValue(c)) : [],
|
|
@@ -330,8 +334,8 @@ function zt(t, {
|
|
|
330
334
|
}), h({}), () => {
|
|
331
335
|
const d = e.getState().getShadowMetadata(c, []), l = d?.components?.get(o);
|
|
332
336
|
l?.paths && l.paths.forEach((p) => {
|
|
333
|
-
const _ = p.split(".").slice(1),
|
|
334
|
-
|
|
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));
|
|
335
339
|
}), d?.components && e.getState().setShadowMetadata(c, [], d);
|
|
336
340
|
};
|
|
337
341
|
}, []);
|
|
@@ -375,40 +379,40 @@ function zt(t, {
|
|
|
375
379
|
}
|
|
376
380
|
if (a.sync !== !1 && Y.current && Y.current.connected && Y.current.updateState({ operation: C }), p?.signals && p.signals.length > 0) {
|
|
377
381
|
const b = a.updateType === "cut" ? null : _;
|
|
378
|
-
p.signals.forEach(({ parentId: k, position: P, effect:
|
|
382
|
+
p.signals.forEach(({ parentId: k, position: P, effect: U }) => {
|
|
379
383
|
const v = document.querySelector(`[data-parent-id="${k}"]`);
|
|
380
384
|
if (v) {
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
385
|
+
const V = Array.from(v.childNodes);
|
|
386
|
+
if (V[P]) {
|
|
383
387
|
let $ = b;
|
|
384
|
-
if (
|
|
388
|
+
if (U && b !== null)
|
|
385
389
|
try {
|
|
386
390
|
$ = new Function(
|
|
387
391
|
"state",
|
|
388
|
-
`return (${
|
|
392
|
+
`return (${U})(state)`
|
|
389
393
|
)(b);
|
|
390
394
|
} catch (D) {
|
|
391
395
|
console.error("Error evaluating effect function:", D);
|
|
392
396
|
}
|
|
393
|
-
$ != null && typeof $ == "object" && ($ = JSON.stringify($)),
|
|
397
|
+
$ != null && typeof $ == "object" && ($ = JSON.stringify($)), V[P].textContent = String($ ?? "");
|
|
394
398
|
}
|
|
395
399
|
}
|
|
396
400
|
});
|
|
397
401
|
}
|
|
398
402
|
if (a.updateType === "insert" && p?.mapWrappers && p.mapWrappers.length > 0) {
|
|
399
|
-
const b = l.getShadowMetadata(c, r)?.arrayKeys || [], k = b[b.length - 1], P = l.getShadowValue(k),
|
|
403
|
+
const b = l.getShadowMetadata(c, r)?.arrayKeys || [], k = b[b.length - 1], P = l.getShadowValue(k), U = l.getShadowValue(
|
|
400
404
|
[c, ...r].join(".")
|
|
401
405
|
);
|
|
402
406
|
if (!k || P === void 0) return;
|
|
403
407
|
p.mapWrappers.forEach((v) => {
|
|
404
|
-
let
|
|
408
|
+
let V = !0, $ = -1;
|
|
405
409
|
if (v.meta?.transforms && v.meta.transforms.length > 0) {
|
|
406
410
|
for (const D of v.meta.transforms)
|
|
407
411
|
if (D.type === "filter" && !D.fn(P, -1)) {
|
|
408
|
-
|
|
412
|
+
V = !1;
|
|
409
413
|
break;
|
|
410
414
|
}
|
|
411
|
-
if (
|
|
415
|
+
if (V) {
|
|
412
416
|
const D = It(
|
|
413
417
|
c,
|
|
414
418
|
r,
|
|
@@ -428,8 +432,8 @@ function zt(t, {
|
|
|
428
432
|
$ = D.length;
|
|
429
433
|
}
|
|
430
434
|
} else
|
|
431
|
-
|
|
432
|
-
if (
|
|
435
|
+
V = !0, $ = b.length - 1;
|
|
436
|
+
if (V && v.containerRef && v.containerRef.isConnected) {
|
|
433
437
|
const D = document.createElement("div");
|
|
434
438
|
D.setAttribute("data-item-path", k);
|
|
435
439
|
const R = Array.from(v.containerRef.children);
|
|
@@ -439,7 +443,7 @@ function zt(t, {
|
|
|
439
443
|
) : v.containerRef.appendChild(D);
|
|
440
444
|
const L = At(D), G = rt(), tt = k.split(".").slice(1), et = v.rebuildStateShape({
|
|
441
445
|
path: v.path,
|
|
442
|
-
currentState:
|
|
446
|
+
currentState: U,
|
|
443
447
|
componentId: v.componentId,
|
|
444
448
|
meta: v.meta
|
|
445
449
|
});
|
|
@@ -461,10 +465,10 @@ function zt(t, {
|
|
|
461
465
|
const b = r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
462
466
|
k?.mapWrappers && k.mapWrappers.length > 0 && k.mapWrappers.forEach((P) => {
|
|
463
467
|
if (P.containerRef && P.containerRef.isConnected) {
|
|
464
|
-
const
|
|
468
|
+
const U = P.containerRef.querySelector(
|
|
465
469
|
`[data-item-path="${d}"]`
|
|
466
470
|
);
|
|
467
|
-
|
|
471
|
+
U && U.remove();
|
|
468
472
|
}
|
|
469
473
|
});
|
|
470
474
|
}
|
|
@@ -482,15 +486,15 @@ function zt(t, {
|
|
|
482
486
|
if (k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
483
487
|
if (j.has(P))
|
|
484
488
|
return;
|
|
485
|
-
const
|
|
486
|
-
|
|
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)));
|
|
487
491
|
}), b.length === 0)
|
|
488
492
|
break;
|
|
489
493
|
b.pop();
|
|
490
494
|
}
|
|
491
495
|
_ && typeof _ == "object" && !Tt(_) && E && typeof E == "object" && !Tt(E) && Ct(_, E).forEach((P) => {
|
|
492
|
-
const
|
|
493
|
-
|
|
496
|
+
const U = P.split("."), v = [...r, ...U], V = l.getShadowMetadata(c, v);
|
|
497
|
+
V?.pathComponents && V.pathComponents.forEach(($) => {
|
|
494
498
|
if (j.has($))
|
|
495
499
|
return;
|
|
496
500
|
const D = N.components?.get($);
|
|
@@ -500,33 +504,33 @@ function zt(t, {
|
|
|
500
504
|
} else if (a.updateType === "insert" || a.updateType === "cut") {
|
|
501
505
|
const b = a.updateType === "insert" ? r : r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
502
506
|
if (k?.signals && k.signals.length > 0) {
|
|
503
|
-
const P = [c, ...b].join("."),
|
|
504
|
-
k.signals.forEach(({ parentId: v, position:
|
|
507
|
+
const P = [c, ...b].join("."), U = l.getShadowValue(P);
|
|
508
|
+
k.signals.forEach(({ parentId: v, position: V, effect: $ }) => {
|
|
505
509
|
const D = document.querySelector(
|
|
506
510
|
`[data-parent-id="${v}"]`
|
|
507
511
|
);
|
|
508
512
|
if (D) {
|
|
509
513
|
const R = Array.from(D.childNodes);
|
|
510
|
-
if (R[
|
|
511
|
-
let L =
|
|
514
|
+
if (R[V]) {
|
|
515
|
+
let L = U;
|
|
512
516
|
if ($)
|
|
513
517
|
try {
|
|
514
518
|
L = new Function(
|
|
515
519
|
"state",
|
|
516
520
|
`return (${$})(state)`
|
|
517
|
-
)(
|
|
521
|
+
)(U);
|
|
518
522
|
} catch (G) {
|
|
519
|
-
console.error("Error evaluating effect function:", G), L =
|
|
523
|
+
console.error("Error evaluating effect function:", G), L = U;
|
|
520
524
|
}
|
|
521
|
-
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 ?? "");
|
|
522
526
|
}
|
|
523
527
|
}
|
|
524
528
|
});
|
|
525
529
|
}
|
|
526
530
|
k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
527
531
|
if (!j.has(P)) {
|
|
528
|
-
const
|
|
529
|
-
|
|
532
|
+
const U = N.components?.get(P);
|
|
533
|
+
U && (U.forceUpdate(), j.add(P));
|
|
530
534
|
}
|
|
531
535
|
});
|
|
532
536
|
}
|
|
@@ -539,15 +543,15 @@ function zt(t, {
|
|
|
539
543
|
return;
|
|
540
544
|
}
|
|
541
545
|
if (P.includes("deps") && b.depsFunction) {
|
|
542
|
-
const
|
|
543
|
-
let
|
|
544
|
-
v === !0 ?
|
|
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));
|
|
545
549
|
}
|
|
546
550
|
}), j.clear(), Wt(c, (b) => {
|
|
547
551
|
const k = [...b ?? [], C], P = /* @__PURE__ */ new Map();
|
|
548
|
-
return k.forEach((
|
|
549
|
-
const v = `${
|
|
550
|
-
|
|
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 });
|
|
551
555
|
}), Array.from(P.values());
|
|
552
556
|
}), Ht(
|
|
553
557
|
_,
|
|
@@ -560,7 +564,7 @@ function zt(t, {
|
|
|
560
564
|
}), x;
|
|
561
565
|
};
|
|
562
566
|
e.getState().initialStateGlobal[c] || _t(c, t);
|
|
563
|
-
const X =
|
|
567
|
+
const X = gt(() => Dt(
|
|
564
568
|
c,
|
|
565
569
|
Q,
|
|
566
570
|
H.current,
|
|
@@ -576,57 +580,57 @@ function Bt(t) {
|
|
|
576
580
|
)
|
|
577
581
|
).join("");
|
|
578
582
|
}
|
|
579
|
-
const It = (t, n,
|
|
580
|
-
let
|
|
581
|
-
if (!
|
|
582
|
-
return
|
|
583
|
-
let y =
|
|
584
|
-
key:
|
|
585
|
-
value: e.getState().getShadowValue(
|
|
583
|
+
const It = (t, n, S) => {
|
|
584
|
+
let g = e.getState().getShadowMetadata(t, n)?.arrayKeys || [];
|
|
585
|
+
if (!S || S.length === 0)
|
|
586
|
+
return g;
|
|
587
|
+
let y = g.map((w) => ({
|
|
588
|
+
key: w,
|
|
589
|
+
value: e.getState().getShadowValue(w)
|
|
586
590
|
}));
|
|
587
|
-
for (const
|
|
588
|
-
|
|
589
|
-
({ value:
|
|
590
|
-
) :
|
|
591
|
-
return y.map(({ key:
|
|
592
|
-
}, Et = (t, n,
|
|
593
|
-
const
|
|
594
|
-
!u || u.reactiveType === "none" || !(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType]).includes("component") || y(t,
|
|
595
|
-
}, ft = (t, n,
|
|
596
|
-
const
|
|
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);
|
|
599
|
+
}, ft = (t, n, S) => {
|
|
600
|
+
const g = e.getState(), y = g.getShadowMetadata(t, []), w = /* @__PURE__ */ new Set();
|
|
597
601
|
y?.components && y.components.forEach((u, f) => {
|
|
598
|
-
(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType || "component"]).includes("all") && (u.forceUpdate(),
|
|
599
|
-
}),
|
|
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) => {
|
|
600
604
|
y?.components?.get(u)?.forceUpdate();
|
|
601
605
|
});
|
|
602
|
-
const
|
|
603
|
-
for (let u of
|
|
604
|
-
const f = u + ".selected", A =
|
|
606
|
+
const T = g.getShadowMetadata(t, n);
|
|
607
|
+
for (let u of T?.arrayKeys || []) {
|
|
608
|
+
const f = u + ".selected", A = g.getShadowMetadata(
|
|
605
609
|
t,
|
|
606
610
|
f.split(".").slice(1)
|
|
607
611
|
);
|
|
608
|
-
u ==
|
|
609
|
-
y?.components?.get(
|
|
612
|
+
u == S && A?.pathComponents?.forEach((I) => {
|
|
613
|
+
y?.components?.get(I)?.forceUpdate();
|
|
610
614
|
});
|
|
611
615
|
}
|
|
612
616
|
};
|
|
613
|
-
function Dt(t, n,
|
|
617
|
+
function Dt(t, n, S, g) {
|
|
614
618
|
const y = /* @__PURE__ */ new Map();
|
|
615
|
-
let
|
|
616
|
-
const
|
|
617
|
-
const i =
|
|
619
|
+
let w = 0;
|
|
620
|
+
const T = (I) => {
|
|
621
|
+
const i = I.join(".");
|
|
618
622
|
for (const [h] of y)
|
|
619
623
|
(h === i || h.startsWith(i + ".")) && y.delete(h);
|
|
620
|
-
|
|
624
|
+
w++;
|
|
621
625
|
};
|
|
622
626
|
function u({
|
|
623
|
-
currentState:
|
|
627
|
+
currentState: I,
|
|
624
628
|
path: i = [],
|
|
625
629
|
meta: h,
|
|
626
630
|
componentId: M
|
|
627
631
|
}) {
|
|
628
632
|
const z = i.map(String).join("."), c = [t, ...i].join(".");
|
|
629
|
-
|
|
633
|
+
I = e.getState().getShadowValue(c, h?.validIds);
|
|
630
634
|
const B = function() {
|
|
631
635
|
return e().getShadowValue(t, i);
|
|
632
636
|
}, J = {
|
|
@@ -679,7 +683,7 @@ function Dt(t, n, g, S) {
|
|
|
679
683
|
}
|
|
680
684
|
if (m === "removeStorage")
|
|
681
685
|
return () => {
|
|
682
|
-
const s = e.getState().initialStateGlobal[t], o = nt(t), r = at(o?.localStorage?.key) ? o.localStorage.key(s) : o?.localStorage?.key, a = `${
|
|
686
|
+
const s = e.getState().initialStateGlobal[t], o = nt(t), r = at(o?.localStorage?.key) ? o.localStorage.key(s) : o?.localStorage?.key, a = `${g}-${t}-${r}`;
|
|
683
687
|
a && localStorage.removeItem(a);
|
|
684
688
|
};
|
|
685
689
|
if (m === "showValidationErrors")
|
|
@@ -687,7 +691,7 @@ function Dt(t, n, g, S) {
|
|
|
687
691
|
const s = e.getState().getShadowMetadata(t, i);
|
|
688
692
|
return s?.validation?.status === "VALIDATION_FAILED" && s.validation.message ? [s.validation.message] : [];
|
|
689
693
|
};
|
|
690
|
-
if (Array.isArray(
|
|
694
|
+
if (Array.isArray(I)) {
|
|
691
695
|
if (m === "getSelected")
|
|
692
696
|
return () => {
|
|
693
697
|
const s = t + "." + i.join(".");
|
|
@@ -730,7 +734,7 @@ function Dt(t, n, g, S) {
|
|
|
730
734
|
} = s, l = q(null), [p, E] = K({
|
|
731
735
|
startIndex: 0,
|
|
732
736
|
endIndex: 10
|
|
733
|
-
}), [_,
|
|
737
|
+
}), [_, O] = K({}), C = q(!0), F = q({
|
|
734
738
|
isUserScrolling: !1,
|
|
735
739
|
lastScrollTop: 0,
|
|
736
740
|
scrollUpCount: 0,
|
|
@@ -747,20 +751,20 @@ function Dt(t, n, g, S) {
|
|
|
747
751
|
behavior: C.current ? "instant" : "smooth"
|
|
748
752
|
});
|
|
749
753
|
}, [_, a]);
|
|
750
|
-
const N = e.getState().getShadowMetadata(t, i)?.arrayKeys || [], { totalHeight: j, itemOffsets: b } =
|
|
754
|
+
const N = e.getState().getShadowMetadata(t, i)?.arrayKeys || [], { totalHeight: j, itemOffsets: b } = gt(() => {
|
|
751
755
|
let v = 0;
|
|
752
|
-
const
|
|
756
|
+
const V = /* @__PURE__ */ new Map();
|
|
753
757
|
return (e.getState().getShadowMetadata(t, i)?.arrayKeys || []).forEach((D) => {
|
|
754
758
|
const R = D.split(".").slice(1), L = e.getState().getShadowMetadata(t, R)?.virtualizer?.itemHeight || o;
|
|
755
|
-
|
|
759
|
+
V.set(D, {
|
|
756
760
|
height: L,
|
|
757
761
|
offset: v
|
|
758
762
|
}), v += L;
|
|
759
|
-
}), x.current =
|
|
763
|
+
}), x.current = V, { totalHeight: v, itemOffsets: V };
|
|
760
764
|
}, [N.length, o]);
|
|
761
765
|
dt(() => {
|
|
762
766
|
if (a && N.length > 0 && l.current && !F.current.isUserScrolling && C.current) {
|
|
763
|
-
const v = l.current,
|
|
767
|
+
const v = l.current, V = () => {
|
|
764
768
|
if (v.clientHeight > 0) {
|
|
765
769
|
const $ = Math.ceil(
|
|
766
770
|
v.clientHeight / o
|
|
@@ -772,20 +776,20 @@ function Dt(t, n, g, S) {
|
|
|
772
776
|
P("instant"), C.current = !1;
|
|
773
777
|
});
|
|
774
778
|
} else
|
|
775
|
-
requestAnimationFrame(
|
|
779
|
+
requestAnimationFrame(V);
|
|
776
780
|
};
|
|
777
|
-
|
|
781
|
+
V();
|
|
778
782
|
}
|
|
779
783
|
}, [N.length, a, o, r]);
|
|
780
784
|
const k = ct(() => {
|
|
781
785
|
const v = l.current;
|
|
782
786
|
if (!v) return;
|
|
783
|
-
const
|
|
784
|
-
R.isNearBottom = L <= d,
|
|
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;
|
|
785
789
|
let tt = 0;
|
|
786
790
|
for (let et = 0; et < N.length; et++) {
|
|
787
791
|
const ht = N[et], mt = x.current.get(ht);
|
|
788
|
-
if (mt && mt.offset + mt.height >
|
|
792
|
+
if (mt && mt.offset + mt.height > V) {
|
|
789
793
|
tt = et;
|
|
790
794
|
break;
|
|
791
795
|
}
|
|
@@ -818,18 +822,18 @@ function Dt(t, n, g, S) {
|
|
|
818
822
|
}, [k, a]);
|
|
819
823
|
const P = ct(
|
|
820
824
|
(v = "smooth") => {
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
825
|
+
const V = l.current;
|
|
826
|
+
if (!V) return;
|
|
823
827
|
F.current.isUserScrolling = !1, F.current.isNearBottom = !0, F.current.scrollUpCount = 0;
|
|
824
828
|
const $ = () => {
|
|
825
829
|
const D = (R = 0) => {
|
|
826
830
|
if (R > 5) return;
|
|
827
|
-
const L =
|
|
828
|
-
G + tt >= L - 1 || (
|
|
831
|
+
const L = V.scrollHeight, G = V.scrollTop, tt = V.clientHeight;
|
|
832
|
+
G + tt >= L - 1 || (V.scrollTo({
|
|
829
833
|
top: L,
|
|
830
834
|
behavior: v
|
|
831
835
|
}), setTimeout(() => {
|
|
832
|
-
const et =
|
|
836
|
+
const et = V.scrollHeight, ht = V.scrollTop;
|
|
833
837
|
(et !== L || ht + tt < et - 1) && D(R + 1);
|
|
834
838
|
}, 50));
|
|
835
839
|
};
|
|
@@ -843,16 +847,16 @@ function Dt(t, n, g, S) {
|
|
|
843
847
|
);
|
|
844
848
|
return Z(() => {
|
|
845
849
|
if (!a || !l.current) return;
|
|
846
|
-
const v = l.current,
|
|
850
|
+
const v = l.current, V = F.current;
|
|
847
851
|
let $;
|
|
848
852
|
const D = () => {
|
|
849
853
|
clearTimeout($), $ = setTimeout(() => {
|
|
850
|
-
!
|
|
854
|
+
!V.isUserScrolling && V.isNearBottom && P(
|
|
851
855
|
C.current ? "instant" : "smooth"
|
|
852
856
|
);
|
|
853
857
|
}, 100);
|
|
854
858
|
}, R = new MutationObserver(() => {
|
|
855
|
-
|
|
859
|
+
V.isUserScrolling || D();
|
|
856
860
|
});
|
|
857
861
|
R.observe(v, {
|
|
858
862
|
childList: !0,
|
|
@@ -862,7 +866,7 @@ function Dt(t, n, g, S) {
|
|
|
862
866
|
// More specific than just 'height'
|
|
863
867
|
});
|
|
864
868
|
const L = (G) => {
|
|
865
|
-
G.target instanceof HTMLImageElement && !
|
|
869
|
+
G.target instanceof HTMLImageElement && !V.isUserScrolling && D();
|
|
866
870
|
};
|
|
867
871
|
return v.addEventListener("load", L, !0), C.current ? setTimeout(() => {
|
|
868
872
|
P("instant");
|
|
@@ -870,10 +874,10 @@ function Dt(t, n, g, S) {
|
|
|
870
874
|
clearTimeout($), R.disconnect(), v.removeEventListener("load", L, !0);
|
|
871
875
|
};
|
|
872
876
|
}, [a, N.length, P]), {
|
|
873
|
-
virtualState:
|
|
874
|
-
const v = e.getState(),
|
|
877
|
+
virtualState: gt(() => {
|
|
878
|
+
const v = e.getState(), V = v.getShadowValue(
|
|
875
879
|
[t, ...i].join(".")
|
|
876
|
-
), $ = v.getShadowMetadata(t, i)?.arrayKeys || [], D =
|
|
880
|
+
), $ = v.getShadowMetadata(t, i)?.arrayKeys || [], D = V.slice(
|
|
877
881
|
p.startIndex,
|
|
878
882
|
p.endIndex + 1
|
|
879
883
|
), R = $.slice(
|
|
@@ -911,10 +915,10 @@ function Dt(t, n, g, S) {
|
|
|
911
915
|
}
|
|
912
916
|
},
|
|
913
917
|
scrollToBottom: P,
|
|
914
|
-
scrollToIndex: (v,
|
|
918
|
+
scrollToIndex: (v, V = "smooth") => {
|
|
915
919
|
if (l.current && N[v]) {
|
|
916
920
|
const $ = x.current.get(N[v])?.offset || 0;
|
|
917
|
-
l.current.scrollTo({ top: $, behavior:
|
|
921
|
+
l.current.scrollTo({ top: $, behavior: V });
|
|
918
922
|
}
|
|
919
923
|
}
|
|
920
924
|
};
|
|
@@ -981,7 +985,7 @@ function Dt(t, n, g, S) {
|
|
|
981
985
|
const o = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
982
986
|
if (!o)
|
|
983
987
|
throw new Error("No array keys found for filtering.");
|
|
984
|
-
const r = [], a =
|
|
988
|
+
const r = [], a = I.filter(
|
|
985
989
|
(d, l) => s(d, l) ? (r.push(o[l]), !0) : !1
|
|
986
990
|
);
|
|
987
991
|
return u({
|
|
@@ -1005,7 +1009,7 @@ function Dt(t, n, g, S) {
|
|
|
1005
1009
|
const o = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
1006
1010
|
if (!o)
|
|
1007
1011
|
throw new Error("No array keys found for sorting");
|
|
1008
|
-
const r =
|
|
1012
|
+
const r = I.map((a, d) => ({
|
|
1009
1013
|
item: a,
|
|
1010
1014
|
key: o[d]
|
|
1011
1015
|
}));
|
|
@@ -1032,7 +1036,7 @@ function Dt(t, n, g, S) {
|
|
|
1032
1036
|
onFlush: l
|
|
1033
1037
|
} = s;
|
|
1034
1038
|
let p = [], E = !1, _ = null;
|
|
1035
|
-
const
|
|
1039
|
+
const O = (j) => {
|
|
1036
1040
|
if (!E) {
|
|
1037
1041
|
if (a === "sliding" && p.length >= o)
|
|
1038
1042
|
p.shift();
|
|
@@ -1064,8 +1068,8 @@ function Dt(t, n, g, S) {
|
|
|
1064
1068
|
...x,
|
|
1065
1069
|
streams: N
|
|
1066
1070
|
}), {
|
|
1067
|
-
write: (j) =>
|
|
1068
|
-
writeMany: (j) => j.forEach(
|
|
1071
|
+
write: (j) => O(j),
|
|
1072
|
+
writeMany: (j) => j.forEach(O),
|
|
1069
1073
|
flush: () => C(),
|
|
1070
1074
|
pause: () => {
|
|
1071
1075
|
E = !0;
|
|
@@ -1082,10 +1086,10 @@ function Dt(t, n, g, S) {
|
|
|
1082
1086
|
};
|
|
1083
1087
|
if (m === "stateList")
|
|
1084
1088
|
return (s) => /* @__PURE__ */ ot(() => {
|
|
1085
|
-
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 } =
|
|
1086
|
-
const
|
|
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(() => {
|
|
1090
|
+
const O = e.getState().getShadowMetadata(t, i)?.transformCaches?.get(a);
|
|
1087
1091
|
let C;
|
|
1088
|
-
|
|
1092
|
+
O && O.validIds ? C = O.validIds : (C = It(
|
|
1089
1093
|
t,
|
|
1090
1094
|
i,
|
|
1091
1095
|
h?.transforms
|
|
@@ -1101,7 +1105,7 @@ function Dt(t, n, g, S) {
|
|
|
1101
1105
|
};
|
|
1102
1106
|
}, [a, d]);
|
|
1103
1107
|
if (Z(() => {
|
|
1104
|
-
const
|
|
1108
|
+
const O = e.getState().subscribeToPath(c, (C) => {
|
|
1105
1109
|
if (C.type === "GET_SELECTED")
|
|
1106
1110
|
return;
|
|
1107
1111
|
const x = e.getState().getShadowMetadata(t, i)?.transformCaches;
|
|
@@ -1111,7 +1115,7 @@ function Dt(t, n, g, S) {
|
|
|
1111
1115
|
(C.type === "INSERT" || C.type === "REMOVE" || C.type === "CLEAR_SELECTION") && l({});
|
|
1112
1116
|
});
|
|
1113
1117
|
return () => {
|
|
1114
|
-
|
|
1118
|
+
O();
|
|
1115
1119
|
};
|
|
1116
1120
|
}, [M, c]), !Array.isArray(E))
|
|
1117
1121
|
return null;
|
|
@@ -1124,7 +1128,7 @@ function Dt(t, n, g, S) {
|
|
|
1124
1128
|
validIds: p
|
|
1125
1129
|
}
|
|
1126
1130
|
});
|
|
1127
|
-
return /* @__PURE__ */ ot(
|
|
1131
|
+
return /* @__PURE__ */ ot(Ot, { children: E.map((O, C) => {
|
|
1128
1132
|
const F = p[C];
|
|
1129
1133
|
if (!F)
|
|
1130
1134
|
return null;
|
|
@@ -1145,8 +1149,8 @@ function Dt(t, n, g, S) {
|
|
|
1145
1149
|
}, {});
|
|
1146
1150
|
if (m === "stateFlattenOn")
|
|
1147
1151
|
return (s) => {
|
|
1148
|
-
const o =
|
|
1149
|
-
y.clear(),
|
|
1152
|
+
const o = I;
|
|
1153
|
+
y.clear(), w++;
|
|
1150
1154
|
const r = o.flatMap(
|
|
1151
1155
|
(a) => a[s] ?? []
|
|
1152
1156
|
);
|
|
@@ -1196,16 +1200,16 @@ function Dt(t, n, g, S) {
|
|
|
1196
1200
|
let l = null;
|
|
1197
1201
|
if (!a.some((E) => {
|
|
1198
1202
|
const _ = o ? o.every(
|
|
1199
|
-
(
|
|
1203
|
+
(O) => st(E[O], d[O])
|
|
1200
1204
|
) : st(E, d);
|
|
1201
1205
|
return _ && (l = E), _;
|
|
1202
1206
|
}))
|
|
1203
|
-
|
|
1207
|
+
T(i), n(d, i, { updateType: "insert" });
|
|
1204
1208
|
else if (r && l) {
|
|
1205
1209
|
const E = r(l), _ = a.map(
|
|
1206
|
-
(
|
|
1210
|
+
(O) => st(O, l) ? E : O
|
|
1207
1211
|
);
|
|
1208
|
-
|
|
1212
|
+
T(i), n(_, i, {
|
|
1209
1213
|
updateType: "update"
|
|
1210
1214
|
});
|
|
1211
1215
|
}
|
|
@@ -1217,7 +1221,7 @@ function Dt(t, n, g, S) {
|
|
|
1217
1221
|
const a = s == -1 ? r.length - 1 : s !== void 0 ? s : r.length - 1, d = r[a];
|
|
1218
1222
|
if (!d) return;
|
|
1219
1223
|
const l = d.split(".").slice(1);
|
|
1220
|
-
n(
|
|
1224
|
+
n(I, l, {
|
|
1221
1225
|
updateType: "cut"
|
|
1222
1226
|
});
|
|
1223
1227
|
};
|
|
@@ -1236,7 +1240,7 @@ function Dt(t, n, g, S) {
|
|
|
1236
1240
|
const a = s[r == -1 ? s.length - 1 : r]?.split(".").slice(1);
|
|
1237
1241
|
e.getState().clearSelectedIndex({ arrayKey: c });
|
|
1238
1242
|
const d = a?.slice(0, -1);
|
|
1239
|
-
ft(t, d), n(
|
|
1243
|
+
ft(t, d), n(I, a, {
|
|
1240
1244
|
updateType: "cut"
|
|
1241
1245
|
});
|
|
1242
1246
|
};
|
|
@@ -1320,7 +1324,7 @@ function Dt(t, n, g, S) {
|
|
|
1320
1324
|
return e.getState().getSyncInfo(s);
|
|
1321
1325
|
}
|
|
1322
1326
|
if (m == "getLocalStorage")
|
|
1323
|
-
return (s) =>
|
|
1327
|
+
return (s) => St(g + "-" + t + "-" + s);
|
|
1324
1328
|
if (m === "isSelected") {
|
|
1325
1329
|
const s = [t, ...i].slice(0, -1);
|
|
1326
1330
|
if (ft(t, i, void 0), Array.isArray(
|
|
@@ -1368,11 +1372,11 @@ function Dt(t, n, g, S) {
|
|
|
1368
1372
|
o.updateShadowAtPath(t, p, E), o.markAsDirty(t, p, { bubble: !0 });
|
|
1369
1373
|
let _ = [...p];
|
|
1370
1374
|
for (; ; ) {
|
|
1371
|
-
const
|
|
1375
|
+
const O = o.getShadowMetadata(
|
|
1372
1376
|
t,
|
|
1373
1377
|
_
|
|
1374
1378
|
);
|
|
1375
|
-
if (console.log("pathMeta",
|
|
1379
|
+
if (console.log("pathMeta", O), O?.pathComponents && O.pathComponents.forEach((C) => {
|
|
1376
1380
|
if (!d.has(C)) {
|
|
1377
1381
|
const F = r.components?.get(C);
|
|
1378
1382
|
F && (F.forceUpdate(), d.add(C));
|
|
@@ -1387,11 +1391,11 @@ function Dt(t, n, g, S) {
|
|
|
1387
1391
|
o.removeShadowArrayElement(t, p), o.markAsDirty(t, E, { bubble: !0 });
|
|
1388
1392
|
let _ = [...E];
|
|
1389
1393
|
for (; ; ) {
|
|
1390
|
-
const
|
|
1394
|
+
const O = o.getShadowMetadata(
|
|
1391
1395
|
t,
|
|
1392
1396
|
_
|
|
1393
1397
|
);
|
|
1394
|
-
if (
|
|
1398
|
+
if (O?.pathComponents && O.pathComponents.forEach((C) => {
|
|
1395
1399
|
if (!d.has(C)) {
|
|
1396
1400
|
const F = r.components?.get(C);
|
|
1397
1401
|
F && (F.forceUpdate(), d.add(C));
|
|
@@ -1468,7 +1472,7 @@ function Dt(t, n, g, S) {
|
|
|
1468
1472
|
});
|
|
1469
1473
|
if (m === "toggle") {
|
|
1470
1474
|
const s = e.getState().getShadowValue([t, ...i].join("."));
|
|
1471
|
-
if (console.log("currentValueAtPath", s), typeof
|
|
1475
|
+
if (console.log("currentValueAtPath", s), typeof I != "boolean")
|
|
1472
1476
|
throw new Error("toggle() can only be used on boolean values");
|
|
1473
1477
|
return () => {
|
|
1474
1478
|
n(!s, i, {
|
|
@@ -1499,41 +1503,41 @@ function Dt(t, n, g, S) {
|
|
|
1499
1503
|
}, H = new Proxy(B, J);
|
|
1500
1504
|
return y.set(z, {
|
|
1501
1505
|
proxy: H,
|
|
1502
|
-
stateVersion:
|
|
1506
|
+
stateVersion: w
|
|
1503
1507
|
}), H;
|
|
1504
1508
|
}
|
|
1505
1509
|
const f = {
|
|
1506
|
-
removeValidation: (
|
|
1507
|
-
|
|
1510
|
+
removeValidation: (I) => {
|
|
1511
|
+
I?.validationKey && ut(I.validationKey);
|
|
1508
1512
|
},
|
|
1509
|
-
revertToInitialState: (
|
|
1513
|
+
revertToInitialState: (I) => {
|
|
1510
1514
|
const i = e.getState().getInitialOptions(t)?.validation;
|
|
1511
|
-
i?.key && ut(i.key),
|
|
1515
|
+
i?.key && ut(i.key), I?.validationKey && ut(I.validationKey);
|
|
1512
1516
|
const h = e.getState().getShadowMetadata(t, []);
|
|
1513
1517
|
h?.stateSource === "server" && h.baseServerState ? h.baseServerState : e.getState().initialStateGlobal[t];
|
|
1514
1518
|
const M = e.getState().initialStateGlobal[t];
|
|
1515
|
-
e.getState().clearSelectedIndexesForState(t), y.clear(),
|
|
1519
|
+
e.getState().clearSelectedIndexesForState(t), y.clear(), w++, e.getState().initializeShadowState(t, M), u({
|
|
1516
1520
|
currentState: M,
|
|
1517
1521
|
path: [],
|
|
1518
|
-
componentId:
|
|
1522
|
+
componentId: S
|
|
1519
1523
|
});
|
|
1520
|
-
const z = nt(t), c = at(z?.localStorage?.key) ? z?.localStorage?.key(M) : z?.localStorage?.key, B = `${
|
|
1524
|
+
const z = nt(t), c = at(z?.localStorage?.key) ? z?.localStorage?.key(M) : z?.localStorage?.key, B = `${g}-${t}-${c}`;
|
|
1521
1525
|
B && localStorage.removeItem(B);
|
|
1522
1526
|
const J = e.getState().getShadowMetadata(t, []);
|
|
1523
1527
|
return J && J?.components?.forEach((H) => {
|
|
1524
1528
|
H.forceUpdate();
|
|
1525
1529
|
}), M;
|
|
1526
1530
|
},
|
|
1527
|
-
updateInitialState: (
|
|
1528
|
-
y.clear(),
|
|
1531
|
+
updateInitialState: (I) => {
|
|
1532
|
+
y.clear(), w++;
|
|
1529
1533
|
const i = Dt(
|
|
1530
1534
|
t,
|
|
1531
1535
|
n,
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
), h = e.getState().initialStateGlobal[t], M = nt(t), z = at(M?.localStorage?.key) ? M?.localStorage?.key(h) : M?.localStorage?.key, c = `${
|
|
1536
|
+
S,
|
|
1537
|
+
g
|
|
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}`;
|
|
1535
1539
|
return localStorage.getItem(c) && localStorage.removeItem(c), Rt(() => {
|
|
1536
|
-
_t(t,
|
|
1540
|
+
_t(t, I), e.getState().initializeShadowState(t, I);
|
|
1537
1541
|
const B = e.getState().getShadowMetadata(t, []);
|
|
1538
1542
|
B && B?.components?.forEach((J) => {
|
|
1539
1543
|
J.forceUpdate();
|
|
@@ -1545,7 +1549,7 @@ function Dt(t, n, g, S) {
|
|
|
1545
1549
|
};
|
|
1546
1550
|
return u({
|
|
1547
1551
|
currentState: e.getState().getShadowValue(t, []),
|
|
1548
|
-
componentId:
|
|
1552
|
+
componentId: S,
|
|
1549
1553
|
path: []
|
|
1550
1554
|
});
|
|
1551
1555
|
}
|
|
@@ -1556,47 +1560,47 @@ function qt({
|
|
|
1556
1560
|
proxy: t,
|
|
1557
1561
|
rebuildStateShape: n
|
|
1558
1562
|
}) {
|
|
1559
|
-
const
|
|
1563
|
+
const S = q(null), g = q(`map-${crypto.randomUUID()}`), y = q(!1), w = q(/* @__PURE__ */ new Map());
|
|
1560
1564
|
Z(() => {
|
|
1561
|
-
const u =
|
|
1565
|
+
const u = S.current;
|
|
1562
1566
|
if (!u || y.current) return;
|
|
1563
1567
|
const f = setTimeout(() => {
|
|
1564
|
-
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {},
|
|
1565
|
-
|
|
1566
|
-
instanceId:
|
|
1568
|
+
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, I = A.mapWrappers || [];
|
|
1569
|
+
I.push({
|
|
1570
|
+
instanceId: g.current,
|
|
1567
1571
|
mapFn: t._mapFn,
|
|
1568
1572
|
containerRef: u,
|
|
1569
1573
|
rebuildStateShape: n,
|
|
1570
1574
|
path: t._path,
|
|
1571
|
-
componentId:
|
|
1575
|
+
componentId: g.current,
|
|
1572
1576
|
meta: t._meta
|
|
1573
1577
|
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1574
1578
|
...A,
|
|
1575
|
-
mapWrappers:
|
|
1576
|
-
}), y.current = !0,
|
|
1579
|
+
mapWrappers: I
|
|
1580
|
+
}), y.current = !0, T();
|
|
1577
1581
|
}, 0);
|
|
1578
1582
|
return () => {
|
|
1579
|
-
if (clearTimeout(f),
|
|
1583
|
+
if (clearTimeout(f), g.current) {
|
|
1580
1584
|
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {};
|
|
1581
1585
|
A.mapWrappers && (A.mapWrappers = A.mapWrappers.filter(
|
|
1582
|
-
(
|
|
1586
|
+
(I) => I.instanceId !== g.current
|
|
1583
1587
|
), e.getState().setShadowMetadata(t._stateKey, t._path, A));
|
|
1584
1588
|
}
|
|
1585
|
-
|
|
1589
|
+
w.current.forEach((A) => A.unmount());
|
|
1586
1590
|
};
|
|
1587
1591
|
}, []);
|
|
1588
|
-
const
|
|
1589
|
-
const u =
|
|
1592
|
+
const T = () => {
|
|
1593
|
+
const u = S.current;
|
|
1590
1594
|
if (!u) return;
|
|
1591
1595
|
const f = e.getState().getShadowValue(
|
|
1592
1596
|
[t._stateKey, ...t._path].join("."),
|
|
1593
1597
|
t._meta?.validIds
|
|
1594
1598
|
);
|
|
1595
1599
|
if (!Array.isArray(f)) return;
|
|
1596
|
-
const A = t._meta?.validIds ?? e.getState().getShadowMetadata(t._stateKey, t._path)?.arrayKeys ?? [],
|
|
1600
|
+
const A = t._meta?.validIds ?? e.getState().getShadowMetadata(t._stateKey, t._path)?.arrayKeys ?? [], I = n({
|
|
1597
1601
|
currentState: f,
|
|
1598
1602
|
path: t._path,
|
|
1599
|
-
componentId:
|
|
1603
|
+
componentId: g.current,
|
|
1600
1604
|
meta: t._meta
|
|
1601
1605
|
});
|
|
1602
1606
|
f.forEach((i, h) => {
|
|
@@ -1605,7 +1609,7 @@ function qt({
|
|
|
1605
1609
|
const z = rt(), c = document.createElement("div");
|
|
1606
1610
|
c.setAttribute("data-item-path", M), u.appendChild(c);
|
|
1607
1611
|
const B = At(c);
|
|
1608
|
-
|
|
1612
|
+
w.current.set(M, B);
|
|
1609
1613
|
const J = M.split(".").slice(1);
|
|
1610
1614
|
B.render(
|
|
1611
1615
|
lt(Mt, {
|
|
@@ -1613,62 +1617,62 @@ function qt({
|
|
|
1613
1617
|
itemComponentId: z,
|
|
1614
1618
|
itemPath: J,
|
|
1615
1619
|
localIndex: h,
|
|
1616
|
-
arraySetter:
|
|
1620
|
+
arraySetter: I,
|
|
1617
1621
|
rebuildStateShape: n,
|
|
1618
1622
|
renderFn: t._mapFn
|
|
1619
1623
|
})
|
|
1620
1624
|
);
|
|
1621
1625
|
});
|
|
1622
1626
|
};
|
|
1623
|
-
return /* @__PURE__ */ ot("div", { ref:
|
|
1627
|
+
return /* @__PURE__ */ ot("div", { ref: S, "data-map-container": g.current });
|
|
1624
1628
|
}
|
|
1625
1629
|
function Gt({
|
|
1626
1630
|
proxy: t
|
|
1627
1631
|
}) {
|
|
1628
|
-
const n = q(null),
|
|
1632
|
+
const n = q(null), S = q(null), g = q(!1), y = `${t._stateKey}-${t._path.join(".")}`, w = e.getState().getShadowValue(
|
|
1629
1633
|
[t._stateKey, ...t._path].join("."),
|
|
1630
1634
|
t._meta?.validIds
|
|
1631
1635
|
);
|
|
1632
1636
|
return Z(() => {
|
|
1633
|
-
const
|
|
1634
|
-
if (!
|
|
1637
|
+
const T = n.current;
|
|
1638
|
+
if (!T || g.current) return;
|
|
1635
1639
|
const u = setTimeout(() => {
|
|
1636
|
-
if (!
|
|
1640
|
+
if (!T.parentElement) {
|
|
1637
1641
|
console.warn("Parent element not found for signal", y);
|
|
1638
1642
|
return;
|
|
1639
1643
|
}
|
|
1640
|
-
const f =
|
|
1644
|
+
const f = T.parentElement, I = Array.from(f.childNodes).indexOf(T);
|
|
1641
1645
|
let i = f.getAttribute("data-parent-id");
|
|
1642
|
-
i || (i = `parent-${crypto.randomUUID()}`, f.setAttribute("data-parent-id", i)),
|
|
1646
|
+
i || (i = `parent-${crypto.randomUUID()}`, f.setAttribute("data-parent-id", i)), S.current = `instance-${crypto.randomUUID()}`;
|
|
1643
1647
|
const h = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, M = h.signals || [];
|
|
1644
1648
|
M.push({
|
|
1645
|
-
instanceId:
|
|
1649
|
+
instanceId: S.current,
|
|
1646
1650
|
parentId: i,
|
|
1647
|
-
position:
|
|
1651
|
+
position: I,
|
|
1648
1652
|
effect: t._effect
|
|
1649
1653
|
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1650
1654
|
...h,
|
|
1651
1655
|
signals: M
|
|
1652
1656
|
});
|
|
1653
|
-
let z =
|
|
1657
|
+
let z = w;
|
|
1654
1658
|
if (t._effect)
|
|
1655
1659
|
try {
|
|
1656
1660
|
z = new Function(
|
|
1657
1661
|
"state",
|
|
1658
1662
|
`return (${t._effect})(state)`
|
|
1659
|
-
)(
|
|
1663
|
+
)(w);
|
|
1660
1664
|
} catch (B) {
|
|
1661
1665
|
console.error("Error evaluating effect function:", B);
|
|
1662
1666
|
}
|
|
1663
1667
|
z !== null && typeof z == "object" && (z = JSON.stringify(z));
|
|
1664
1668
|
const c = document.createTextNode(String(z ?? ""));
|
|
1665
|
-
|
|
1669
|
+
T.replaceWith(c), g.current = !0;
|
|
1666
1670
|
}, 0);
|
|
1667
1671
|
return () => {
|
|
1668
|
-
if (clearTimeout(u),
|
|
1672
|
+
if (clearTimeout(u), S.current) {
|
|
1669
1673
|
const f = e.getState().getShadowMetadata(t._stateKey, t._path) || {};
|
|
1670
1674
|
f.signals && (f.signals = f.signals.filter(
|
|
1671
|
-
(A) => A.instanceId !==
|
|
1675
|
+
(A) => A.instanceId !== S.current
|
|
1672
1676
|
), e.getState().setShadowMetadata(t._stateKey, t._path, f));
|
|
1673
1677
|
}
|
|
1674
1678
|
};
|
|
@@ -1678,30 +1682,30 @@ function Gt({
|
|
|
1678
1682
|
"data-signal-id": y
|
|
1679
1683
|
});
|
|
1680
1684
|
}
|
|
1681
|
-
const Mt =
|
|
1685
|
+
const Mt = Ut(
|
|
1682
1686
|
Yt,
|
|
1683
1687
|
(t, n) => t.itemPath.join(".") === n.itemPath.join(".") && t.stateKey === n.stateKey && t.itemComponentId === n.itemComponentId && t.localIndex === n.localIndex
|
|
1684
1688
|
), Jt = (t) => {
|
|
1685
|
-
const [n,
|
|
1689
|
+
const [n, S] = K(!1);
|
|
1686
1690
|
return dt(() => {
|
|
1687
1691
|
if (!t.current) {
|
|
1688
|
-
|
|
1692
|
+
S(!0);
|
|
1689
1693
|
return;
|
|
1690
1694
|
}
|
|
1691
|
-
const
|
|
1692
|
-
if (
|
|
1693
|
-
|
|
1695
|
+
const g = Array.from(t.current.querySelectorAll("img"));
|
|
1696
|
+
if (g.length === 0) {
|
|
1697
|
+
S(!0);
|
|
1694
1698
|
return;
|
|
1695
1699
|
}
|
|
1696
1700
|
let y = 0;
|
|
1697
|
-
const
|
|
1698
|
-
y++, y ===
|
|
1701
|
+
const w = () => {
|
|
1702
|
+
y++, y === g.length && S(!0);
|
|
1699
1703
|
};
|
|
1700
|
-
return
|
|
1701
|
-
|
|
1704
|
+
return g.forEach((T) => {
|
|
1705
|
+
T.complete ? w() : (T.addEventListener("load", w), T.addEventListener("error", w));
|
|
1702
1706
|
}), () => {
|
|
1703
|
-
|
|
1704
|
-
|
|
1707
|
+
g.forEach((T) => {
|
|
1708
|
+
T.removeEventListener("load", w), T.removeEventListener("error", w);
|
|
1705
1709
|
});
|
|
1706
1710
|
};
|
|
1707
1711
|
}, [t.current]), n;
|
|
@@ -1709,17 +1713,17 @@ const Mt = Ot(
|
|
|
1709
1713
|
function Yt({
|
|
1710
1714
|
stateKey: t,
|
|
1711
1715
|
itemComponentId: n,
|
|
1712
|
-
itemPath:
|
|
1713
|
-
localIndex:
|
|
1716
|
+
itemPath: S,
|
|
1717
|
+
localIndex: g,
|
|
1714
1718
|
arraySetter: y,
|
|
1715
|
-
rebuildStateShape:
|
|
1716
|
-
renderFn:
|
|
1719
|
+
rebuildStateShape: w,
|
|
1720
|
+
renderFn: T
|
|
1717
1721
|
}) {
|
|
1718
|
-
const [, u] = K({}), { ref: f, inView: A } = jt(),
|
|
1722
|
+
const [, u] = K({}), { ref: f, inView: A } = jt(), I = q(null), i = Jt(I), h = q(!1), M = [t, ...S].join(".");
|
|
1719
1723
|
$t(t, n, u);
|
|
1720
1724
|
const z = ct(
|
|
1721
1725
|
(W) => {
|
|
1722
|
-
|
|
1726
|
+
I.current = W, f(W);
|
|
1723
1727
|
},
|
|
1724
1728
|
[f]
|
|
1725
1729
|
);
|
|
@@ -1730,50 +1734,50 @@ function Yt({
|
|
|
1730
1734
|
}, []), Z(() => {
|
|
1731
1735
|
if (!A || !i || h.current)
|
|
1732
1736
|
return;
|
|
1733
|
-
const W =
|
|
1737
|
+
const W = I.current;
|
|
1734
1738
|
if (W && W.offsetHeight > 0) {
|
|
1735
1739
|
h.current = !0;
|
|
1736
1740
|
const m = W.offsetHeight;
|
|
1737
|
-
e.getState().setShadowMetadata(t,
|
|
1741
|
+
e.getState().setShadowMetadata(t, S, {
|
|
1738
1742
|
virtualizer: {
|
|
1739
1743
|
itemHeight: m,
|
|
1740
1744
|
domRef: W
|
|
1741
1745
|
}
|
|
1742
1746
|
});
|
|
1743
|
-
const Y =
|
|
1747
|
+
const Y = S.slice(0, -1), Q = [t, ...Y].join(".");
|
|
1744
1748
|
e.getState().notifyPathSubscribers(Q, {
|
|
1745
1749
|
type: "ITEMHEIGHT",
|
|
1746
|
-
itemKey:
|
|
1747
|
-
ref:
|
|
1750
|
+
itemKey: S.join("."),
|
|
1751
|
+
ref: I.current
|
|
1748
1752
|
});
|
|
1749
1753
|
}
|
|
1750
|
-
}, [A, i, t,
|
|
1751
|
-
const c = [t, ...
|
|
1754
|
+
}, [A, i, t, S]);
|
|
1755
|
+
const c = [t, ...S].join("."), B = e.getState().getShadowValue(c);
|
|
1752
1756
|
if (B === void 0)
|
|
1753
1757
|
return null;
|
|
1754
|
-
const J =
|
|
1758
|
+
const J = w({
|
|
1755
1759
|
currentState: B,
|
|
1756
|
-
path:
|
|
1760
|
+
path: S,
|
|
1757
1761
|
componentId: n
|
|
1758
|
-
}), H =
|
|
1762
|
+
}), H = T(J, g, y);
|
|
1759
1763
|
return /* @__PURE__ */ ot("div", { ref: z, children: H });
|
|
1760
1764
|
}
|
|
1761
1765
|
function Zt({
|
|
1762
1766
|
stateKey: t,
|
|
1763
1767
|
path: n,
|
|
1764
|
-
rebuildStateShape:
|
|
1765
|
-
renderFn:
|
|
1768
|
+
rebuildStateShape: S,
|
|
1769
|
+
renderFn: g,
|
|
1766
1770
|
formOpts: y,
|
|
1767
|
-
setState:
|
|
1771
|
+
setState: w
|
|
1768
1772
|
}) {
|
|
1769
|
-
const [
|
|
1770
|
-
$t(t,
|
|
1771
|
-
const A = e.getState().getShadowValue(f), [
|
|
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);
|
|
1772
1776
|
Z(() => {
|
|
1773
|
-
!h.current && !st(A,
|
|
1777
|
+
!h.current && !st(A, I) && i(A);
|
|
1774
1778
|
}, [A]), Z(() => {
|
|
1775
1779
|
const H = e.getState().subscribeToPath(f, (W) => {
|
|
1776
|
-
!h.current &&
|
|
1780
|
+
!h.current && I !== W && u({});
|
|
1777
1781
|
});
|
|
1778
1782
|
return () => {
|
|
1779
1783
|
H(), M.current && (clearTimeout(M.current), h.current = !1);
|
|
@@ -1784,7 +1788,7 @@ function Zt({
|
|
|
1784
1788
|
typeof A === "number" && typeof H == "string" && (H = H === "" ? 0 : Number(H)), i(H), h.current = !0, M.current && clearTimeout(M.current);
|
|
1785
1789
|
const m = y?.debounceTime ?? 200;
|
|
1786
1790
|
M.current = setTimeout(() => {
|
|
1787
|
-
h.current = !1,
|
|
1791
|
+
h.current = !1, w(H, n, { updateType: "update" });
|
|
1788
1792
|
const { getInitialOptions: Y, setShadowMetadata: Q, getShadowMetadata: X } = e.getState(), s = Y(t)?.validation, o = s?.zodSchemaV4 || s?.zodSchemaV3;
|
|
1789
1793
|
if (o) {
|
|
1790
1794
|
const r = e.getState().getShadowValue(t), a = o.safeParse(r), d = X(t, n) || {};
|
|
@@ -1818,9 +1822,9 @@ function Zt({
|
|
|
1818
1822
|
}
|
|
1819
1823
|
}, m), u({});
|
|
1820
1824
|
},
|
|
1821
|
-
[
|
|
1825
|
+
[w, n, y?.debounceTime, t]
|
|
1822
1826
|
), c = ct(async () => {
|
|
1823
|
-
console.log("handleBlur triggered"), M.current && (clearTimeout(M.current), M.current = null, h.current = !1, I
|
|
1827
|
+
console.log("handleBlur triggered"), M.current && (clearTimeout(M.current), M.current = null, h.current = !1, w(I, n, { updateType: "update" }));
|
|
1824
1828
|
const { getInitialOptions: H } = e.getState(), W = H(t)?.validation, m = W?.zodSchemaV4 || W?.zodSchemaV3;
|
|
1825
1829
|
if (!m) return;
|
|
1826
1830
|
const Y = e.getState().getShadowMetadata(t, n);
|
|
@@ -1828,7 +1832,7 @@ function Zt({
|
|
|
1828
1832
|
...Y,
|
|
1829
1833
|
validation: {
|
|
1830
1834
|
status: "DIRTY",
|
|
1831
|
-
validatedValue:
|
|
1835
|
+
validatedValue: I
|
|
1832
1836
|
}
|
|
1833
1837
|
});
|
|
1834
1838
|
const Q = e.getState().getShadowValue(t), X = m.safeParse(Q);
|
|
@@ -1837,7 +1841,7 @@ function Zt({
|
|
|
1837
1841
|
...Y,
|
|
1838
1842
|
validation: {
|
|
1839
1843
|
status: "VALID_PENDING_SYNC",
|
|
1840
|
-
validatedValue:
|
|
1844
|
+
validatedValue: I
|
|
1841
1845
|
}
|
|
1842
1846
|
});
|
|
1843
1847
|
else {
|
|
@@ -1852,12 +1856,12 @@ function Zt({
|
|
|
1852
1856
|
if (console.log("Array metadata:", l), l?.arrayKeys) {
|
|
1853
1857
|
const p = [t, ...n.slice(0, -1)].join("."), E = l.arrayKeys.indexOf(p);
|
|
1854
1858
|
console.log("Item key:", p, "Index:", E);
|
|
1855
|
-
const _ = [...d, E, ...n.slice(-1)],
|
|
1859
|
+
const _ = [...d, E, ...n.slice(-1)], O = JSON.stringify(r.path) === JSON.stringify(_);
|
|
1856
1860
|
return console.log("Zod path comparison:", {
|
|
1857
1861
|
zodPath: _,
|
|
1858
1862
|
errorPath: r.path,
|
|
1859
|
-
match:
|
|
1860
|
-
}),
|
|
1863
|
+
match: O
|
|
1864
|
+
}), O;
|
|
1861
1865
|
}
|
|
1862
1866
|
}
|
|
1863
1867
|
const a = JSON.stringify(r.path) === JSON.stringify(n);
|
|
@@ -1872,19 +1876,19 @@ function Zt({
|
|
|
1872
1876
|
validation: {
|
|
1873
1877
|
status: "VALIDATION_FAILED",
|
|
1874
1878
|
message: o[0]?.message,
|
|
1875
|
-
validatedValue:
|
|
1879
|
+
validatedValue: I
|
|
1876
1880
|
}
|
|
1877
1881
|
});
|
|
1878
1882
|
}
|
|
1879
1883
|
u({});
|
|
1880
|
-
}, [t, n,
|
|
1884
|
+
}, [t, n, I, w]), B = S({
|
|
1881
1885
|
currentState: A,
|
|
1882
1886
|
path: n,
|
|
1883
|
-
componentId:
|
|
1887
|
+
componentId: T
|
|
1884
1888
|
}), J = new Proxy(B, {
|
|
1885
1889
|
get(H, W) {
|
|
1886
1890
|
return W === "inputProps" ? {
|
|
1887
|
-
value:
|
|
1891
|
+
value: I ?? "",
|
|
1888
1892
|
onChange: (m) => {
|
|
1889
1893
|
z(m.target.value);
|
|
1890
1894
|
},
|
|
@@ -1894,20 +1898,20 @@ function Zt({
|
|
|
1894
1898
|
} : H[W];
|
|
1895
1899
|
}
|
|
1896
1900
|
});
|
|
1897
|
-
return /* @__PURE__ */ ot(kt, { formOpts: y, path: n, stateKey: t, children:
|
|
1901
|
+
return /* @__PURE__ */ ot(kt, { formOpts: y, path: n, stateKey: t, children: g(J) });
|
|
1898
1902
|
}
|
|
1899
|
-
function $t(t, n,
|
|
1900
|
-
const
|
|
1903
|
+
function $t(t, n, S) {
|
|
1904
|
+
const g = `${t}////${n}`;
|
|
1901
1905
|
dt(() => {
|
|
1902
|
-
const { registerComponent: y, unregisterComponent:
|
|
1903
|
-
return y(t,
|
|
1904
|
-
forceUpdate: () =>
|
|
1906
|
+
const { registerComponent: y, unregisterComponent: w } = e.getState();
|
|
1907
|
+
return y(t, g, {
|
|
1908
|
+
forceUpdate: () => S({}),
|
|
1905
1909
|
paths: /* @__PURE__ */ new Set(),
|
|
1906
1910
|
reactiveType: ["component"]
|
|
1907
1911
|
}), () => {
|
|
1908
|
-
|
|
1912
|
+
w(t, g);
|
|
1909
1913
|
};
|
|
1910
|
-
}, [t,
|
|
1914
|
+
}, [t, g]);
|
|
1911
1915
|
}
|
|
1912
1916
|
export {
|
|
1913
1917
|
bt as $cogsSignal,
|