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