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