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