cogsbox-state 0.5.474 → 0.5.475-canary.0
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 +11 -11
- package/dist/CogsState.d.ts +26 -17
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +383 -380
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.jsx +231 -225
- package/dist/Components.jsx.map +1 -1
- package/dist/PluginRunner.d.ts.map +1 -1
- package/dist/PluginRunner.jsx +82 -67
- package/dist/PluginRunner.jsx.map +1 -1
- package/dist/index.js +17 -16
- package/dist/plugins.d.ts +98 -980
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +48 -36
- package/dist/plugins.js.map +1 -1
- package/dist/store.js +168 -169
- package/dist/store.js.map +1 -1
- package/package.json +4 -3
- package/src/CogsState.tsx +233 -550
- package/src/Components.tsx +43 -34
- package/src/PluginRunner.tsx +24 -6
- package/src/plugins.ts +93 -127
- package/src/store.ts +1 -1
package/dist/CogsState.jsx
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as ne, Fragment as Ue } from "react/jsx-runtime";
|
|
3
3
|
import { pluginStore as Q } from "./pluginStore.js";
|
|
4
|
-
import { useState as ee, useRef as F, useCallback as
|
|
5
|
-
import { transformStateFunc as Oe, isFunction as G, isDeepEqual as
|
|
4
|
+
import { useState as ee, useRef as F, useCallback as pe, useEffect as z, useLayoutEffect as le, useMemo as Te, createElement as Ee, startTransition as _e } from "react";
|
|
5
|
+
import { transformStateFunc as Oe, isFunction as G, isDeepEqual as ae, isArray as je, getDifferences as Ne } from "./utility.js";
|
|
6
6
|
import { ValidationWrapper as Fe, IsolatedComponentWrapper as xe, FormElementWrapper as Re, MemoizedCogsItemWrapper as Be } from "./Components.jsx";
|
|
7
7
|
import Le from "superjson";
|
|
8
|
-
import { v4 as
|
|
8
|
+
import { v4 as se } from "uuid";
|
|
9
9
|
import { getGlobalStore as T, updateShadowTypeInfo as Ie } from "./store.js";
|
|
10
10
|
import { useCogsConfig as Pe } from "./CogsStateClient.jsx";
|
|
11
11
|
import { runValidation as ze } from "./validation.js";
|
|
12
12
|
const {
|
|
13
|
-
getInitialOptions:
|
|
13
|
+
getInitialOptions: q,
|
|
14
14
|
updateInitialStateGlobal: ke,
|
|
15
|
-
getShadowMetadata:
|
|
15
|
+
getShadowMetadata: A,
|
|
16
16
|
setShadowMetadata: J,
|
|
17
17
|
getShadowValue: x,
|
|
18
|
-
initializeShadowState:
|
|
18
|
+
initializeShadowState: ie,
|
|
19
19
|
initializeAndMergeShadowState: We,
|
|
20
20
|
updateShadowAtPath: qe,
|
|
21
21
|
insertShadowArrayElement: He,
|
|
22
22
|
insertManyShadowArrayElements: Ce,
|
|
23
23
|
removeShadowArrayElement: Ge,
|
|
24
|
-
setInitialStateOptions:
|
|
24
|
+
setInitialStateOptions: be,
|
|
25
25
|
setServerStateUpdate: $e,
|
|
26
|
-
markAsDirty:
|
|
26
|
+
markAsDirty: fe,
|
|
27
27
|
addPathComponent: Je,
|
|
28
28
|
clearSelectedIndexesForState: Ye,
|
|
29
29
|
addStateLog: Ze,
|
|
@@ -37,13 +37,13 @@ const {
|
|
|
37
37
|
// Note: The old functions are no longer imported under their original names
|
|
38
38
|
} = T.getState(), { notifyUpdate: nt } = Q.getState();
|
|
39
39
|
function L(e, n, l) {
|
|
40
|
-
const s =
|
|
40
|
+
const s = A(e, n);
|
|
41
41
|
if (!!!s?.arrayKeys)
|
|
42
42
|
return { isArray: !1, value: T.getState().getShadowValue(e, n), keys: [] };
|
|
43
43
|
const i = n.length > 0 ? n.join(".") : "root", h = l?.arrayViews?.[i] ?? s.arrayKeys;
|
|
44
44
|
return Array.isArray(h) && h.length === 0 ? { isArray: !0, value: [], keys: [] } : { isArray: !0, value: T.getState().getShadowValue(e, n, h), keys: h ?? [] };
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function he(e, n, l) {
|
|
47
47
|
for (let s = 0; s < e.length; s++)
|
|
48
48
|
if (l(e[s], s)) {
|
|
49
49
|
const g = n[s];
|
|
@@ -52,32 +52,32 @@ function ve(e, n, l) {
|
|
|
52
52
|
}
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function ve(e, n) {
|
|
56
56
|
const s = {
|
|
57
|
-
...
|
|
57
|
+
...q(e) || {},
|
|
58
58
|
...n
|
|
59
59
|
};
|
|
60
|
-
(s.validation?.zodSchemaV4 || s.validation?.zodSchemaV3) && !s.validation?.onBlur && (s.validation.onBlur = "error"),
|
|
60
|
+
(s.validation?.zodSchemaV4 || s.validation?.zodSchemaV3) && !s.validation?.onBlur && (s.validation.onBlur = "error"), be(e, s);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function Me({
|
|
63
63
|
stateKey: e,
|
|
64
64
|
options: n,
|
|
65
65
|
initialOptionsPart: l
|
|
66
66
|
}) {
|
|
67
|
-
const s =
|
|
67
|
+
const s = q(e) || {}, g = l[e] || {};
|
|
68
68
|
let i = { ...g, ...s }, h = !1;
|
|
69
69
|
if (n) {
|
|
70
|
-
const
|
|
70
|
+
const d = (t, a) => {
|
|
71
71
|
for (const S in a)
|
|
72
|
-
a.hasOwnProperty(S) && (a[S] instanceof Object && !Array.isArray(a[S]) && t[S] instanceof Object ?
|
|
72
|
+
a.hasOwnProperty(S) && (a[S] instanceof Object && !Array.isArray(a[S]) && t[S] instanceof Object ? ae(t[S], a[S]) || (d(t[S], a[S]), h = !0) : t[S] !== a[S] && (t[S] = a[S], h = !0));
|
|
73
73
|
return t;
|
|
74
74
|
};
|
|
75
|
-
i =
|
|
75
|
+
i = d(i, n);
|
|
76
76
|
}
|
|
77
77
|
if (i.validation && (n?.validation?.hasOwnProperty("onBlur") || s?.validation?.hasOwnProperty("onBlur") || g?.validation?.hasOwnProperty("onBlur") || (i.validation.onBlur = "error", h = !0)), h) {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
!
|
|
78
|
+
be(e, i);
|
|
79
|
+
const d = s?.validation?.zodSchemaV4 || s?.validation?.zodSchemaV3, t = i.validation?.zodSchemaV4 && !s?.validation?.zodSchemaV4, a = i.validation?.zodSchemaV3 && !s?.validation?.zodSchemaV3;
|
|
80
|
+
!d && (t || a) && (t ? Ie(
|
|
81
81
|
e,
|
|
82
82
|
i.validation.zodSchemaV4,
|
|
83
83
|
"zod4"
|
|
@@ -99,8 +99,8 @@ function kt(e, n) {
|
|
|
99
99
|
const Ct = (e, n) => {
|
|
100
100
|
n?.plugins && Q.getState().setRegisteredPlugins(n.plugins);
|
|
101
101
|
const [l, s] = Oe(e);
|
|
102
|
-
Object.keys(l).forEach((
|
|
103
|
-
let t = s[
|
|
102
|
+
Object.keys(l).forEach((d) => {
|
|
103
|
+
let t = s[d] || {};
|
|
104
104
|
const a = {
|
|
105
105
|
...t
|
|
106
106
|
};
|
|
@@ -111,8 +111,8 @@ const Ct = (e, n) => {
|
|
|
111
111
|
onBlur: "error",
|
|
112
112
|
...n?.validation,
|
|
113
113
|
...t.validation || {}
|
|
114
|
-
}, n?.validation?.key && !t.validation?.key && (a.validation.key = `${n.validation.key}.${
|
|
115
|
-
const S =
|
|
114
|
+
}, n?.validation?.key && !t.validation?.key && (a.validation.key = `${n.validation.key}.${d}`);
|
|
115
|
+
const S = q(d), E = S ? {
|
|
116
116
|
...S,
|
|
117
117
|
...a,
|
|
118
118
|
formElements: {
|
|
@@ -124,58 +124,57 @@ const Ct = (e, n) => {
|
|
|
124
124
|
...a.validation
|
|
125
125
|
}
|
|
126
126
|
} : a;
|
|
127
|
-
|
|
128
|
-
}), Object.keys(l).forEach((
|
|
129
|
-
|
|
127
|
+
be(d, E);
|
|
128
|
+
}), Object.keys(l).forEach((d) => {
|
|
129
|
+
ie(d, l[d]);
|
|
130
130
|
});
|
|
131
|
-
const g = (
|
|
132
|
-
const [a] = ee(t?.componentId ??
|
|
133
|
-
stateKey:
|
|
131
|
+
const g = (d, t) => {
|
|
132
|
+
const [a] = ee(t?.componentId ?? se()), S = Me({
|
|
133
|
+
stateKey: d,
|
|
134
134
|
options: t,
|
|
135
135
|
initialOptionsPart: s
|
|
136
|
-
}),
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
136
|
+
}), E = F(S);
|
|
137
|
+
E.current = S;
|
|
138
|
+
const V = x(d, []) || l[d], U = yt(
|
|
139
|
+
V,
|
|
140
|
+
{
|
|
141
|
+
stateKey: d,
|
|
142
|
+
syncUpdate: t?.syncUpdate,
|
|
143
|
+
componentId: a,
|
|
144
|
+
localStorage: t?.localStorage,
|
|
145
|
+
middleware: t?.middleware,
|
|
146
|
+
reactiveType: t?.reactiveType,
|
|
147
|
+
reactiveDeps: t?.reactiveDeps,
|
|
148
|
+
defaultState: t?.defaultState,
|
|
149
|
+
dependencies: t?.dependencies,
|
|
150
|
+
serverState: t?.serverState
|
|
151
|
+
}
|
|
152
|
+
);
|
|
150
153
|
return z(() => {
|
|
151
|
-
t && Q.getState().setPluginOptionsForState(
|
|
152
|
-
}, [
|
|
153
|
-
Q.getState().stateHandlers.delete(
|
|
154
|
-
}), [
|
|
154
|
+
t && Q.getState().setPluginOptionsForState(d, t);
|
|
155
|
+
}, [d, t]), z(() => (Q.getState().stateHandlers.set(d, U), () => {
|
|
156
|
+
Q.getState().stateHandlers.delete(d);
|
|
157
|
+
}), [d, U]), U;
|
|
155
158
|
};
|
|
156
|
-
function i(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
function h(u) {
|
|
160
|
-
const a = Q.getState().registeredPlugins.map((M) => u.hasOwnProperty(M.name) ? {
|
|
161
|
-
...M,
|
|
162
|
-
formWrapper: u[M.name]
|
|
163
|
-
} : M);
|
|
164
|
-
Q.getState().setRegisteredPlugins(a), Object.keys(l).forEach((M) => {
|
|
165
|
-
const E = W(M) || {}, C = {
|
|
159
|
+
function i(d, t) {
|
|
160
|
+
if (Me({ stateKey: d, options: t, initialOptionsPart: s }), t.localStorage && at(d, t), t.formElements) {
|
|
161
|
+
const S = Q.getState().registeredPlugins.map((E) => t.formElements.hasOwnProperty(E.name) ? {
|
|
166
162
|
...E,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
formWrapper: t.formElements[E.name]
|
|
164
|
+
} : E);
|
|
165
|
+
Q.getState().setRegisteredPlugins(S);
|
|
166
|
+
}
|
|
167
|
+
K(d);
|
|
168
|
+
}
|
|
169
|
+
function h(d) {
|
|
170
|
+
Object.keys(l).forEach((a) => {
|
|
171
|
+
i(a, d);
|
|
173
172
|
});
|
|
174
173
|
}
|
|
175
174
|
return {
|
|
176
175
|
useCogsState: g,
|
|
177
176
|
setCogsOptionsByKey: i,
|
|
178
|
-
|
|
177
|
+
setCogsOptions: h
|
|
179
178
|
};
|
|
180
179
|
}, ot = (e, n, l, s, g) => {
|
|
181
180
|
l?.log && console.log(
|
|
@@ -187,15 +186,15 @@ const Ct = (e, n) => {
|
|
|
187
186
|
const i = G(l?.localStorage?.key) ? l.localStorage?.key(e) : l?.localStorage?.key;
|
|
188
187
|
if (i && s) {
|
|
189
188
|
const h = `${s}-${n}-${i}`;
|
|
190
|
-
let
|
|
189
|
+
let d;
|
|
191
190
|
try {
|
|
192
|
-
|
|
191
|
+
d = ge(h)?.lastSyncedWithServer;
|
|
193
192
|
} catch {
|
|
194
193
|
}
|
|
195
|
-
const t =
|
|
194
|
+
const t = A(n, []), a = {
|
|
196
195
|
state: e,
|
|
197
196
|
lastUpdated: Date.now(),
|
|
198
|
-
lastSyncedWithServer:
|
|
197
|
+
lastSyncedWithServer: d,
|
|
199
198
|
stateSource: t?.stateSource,
|
|
200
199
|
baseServerState: t?.baseServerState
|
|
201
200
|
}, S = Le.serialize(a);
|
|
@@ -204,7 +203,7 @@ const Ct = (e, n) => {
|
|
|
204
203
|
JSON.stringify(S.json)
|
|
205
204
|
);
|
|
206
205
|
}
|
|
207
|
-
},
|
|
206
|
+
}, ge = (e) => {
|
|
208
207
|
if (!e) return null;
|
|
209
208
|
try {
|
|
210
209
|
const n = window.localStorage.getItem(e);
|
|
@@ -215,7 +214,7 @@ const Ct = (e, n) => {
|
|
|
215
214
|
}, at = (e, n) => {
|
|
216
215
|
const l = x(e, []), { sessionId: s } = Pe(), g = G(n?.localStorage?.key) ? n.localStorage.key(l) : n?.localStorage?.key;
|
|
217
216
|
if (g && s) {
|
|
218
|
-
const i =
|
|
217
|
+
const i = ge(
|
|
219
218
|
`${s}-${e}-${g}`
|
|
220
219
|
);
|
|
221
220
|
if (i && i.lastUpdated > (i.lastSyncedWithServer || 0))
|
|
@@ -223,7 +222,7 @@ const Ct = (e, n) => {
|
|
|
223
222
|
}
|
|
224
223
|
return !1;
|
|
225
224
|
}, K = (e) => {
|
|
226
|
-
const n =
|
|
225
|
+
const n = A(e, []);
|
|
227
226
|
if (!n) return;
|
|
228
227
|
const l = /* @__PURE__ */ new Set();
|
|
229
228
|
n?.components?.forEach((s) => {
|
|
@@ -232,18 +231,18 @@ const Ct = (e, n) => {
|
|
|
232
231
|
l.forEach((s) => s());
|
|
233
232
|
});
|
|
234
233
|
};
|
|
235
|
-
function
|
|
236
|
-
const g =
|
|
234
|
+
function ue(e, n, l, s) {
|
|
235
|
+
const g = A(e, n);
|
|
237
236
|
if (J(e, n, {
|
|
238
237
|
...g,
|
|
239
238
|
isDirty: !1,
|
|
240
239
|
stateSource: "server",
|
|
241
240
|
lastServerSync: s || Date.now()
|
|
242
241
|
}), Array.isArray(l)) {
|
|
243
|
-
const i =
|
|
244
|
-
i?.arrayKeys && i.arrayKeys.forEach((h,
|
|
245
|
-
const t = [...n, h], a = l[
|
|
246
|
-
a !== void 0 &&
|
|
242
|
+
const i = A(e, n);
|
|
243
|
+
i?.arrayKeys && i.arrayKeys.forEach((h, d) => {
|
|
244
|
+
const t = [...n, h], a = l[d];
|
|
245
|
+
a !== void 0 && ue(
|
|
247
246
|
e,
|
|
248
247
|
t,
|
|
249
248
|
a,
|
|
@@ -251,13 +250,13 @@ function de(e, n, l, s) {
|
|
|
251
250
|
);
|
|
252
251
|
});
|
|
253
252
|
} else l && typeof l == "object" && l.constructor === Object && Object.keys(l).forEach((i) => {
|
|
254
|
-
const h = [...n, i],
|
|
255
|
-
|
|
253
|
+
const h = [...n, i], d = l[i];
|
|
254
|
+
ue(e, h, d, s);
|
|
256
255
|
});
|
|
257
256
|
}
|
|
258
|
-
let
|
|
257
|
+
let de = [], Ae = !1;
|
|
259
258
|
function st() {
|
|
260
|
-
|
|
259
|
+
Ae || (Ae = !0, console.log("Scheduling flush"), queueMicrotask(() => {
|
|
261
260
|
console.log("Actually flushing"), gt();
|
|
262
261
|
}));
|
|
263
262
|
}
|
|
@@ -267,45 +266,45 @@ function it(e, n) {
|
|
|
267
266
|
if (!i) return;
|
|
268
267
|
const h = Array.from(i.childNodes);
|
|
269
268
|
if (!h[s]) return;
|
|
270
|
-
let
|
|
269
|
+
let d = n;
|
|
271
270
|
if (g && n !== null)
|
|
272
271
|
try {
|
|
273
|
-
|
|
272
|
+
d = new Function("state", `return (${g})(state)`)(
|
|
274
273
|
n
|
|
275
274
|
);
|
|
276
275
|
} catch (t) {
|
|
277
276
|
console.error("Error evaluating effect function:", t);
|
|
278
277
|
}
|
|
279
|
-
|
|
278
|
+
d !== null && typeof d == "object" && (d = JSON.stringify(d)), h[s].textContent = String(d ?? "");
|
|
280
279
|
});
|
|
281
280
|
}
|
|
282
281
|
function ct(e, n, l) {
|
|
283
|
-
const s =
|
|
282
|
+
const s = A(e, []);
|
|
284
283
|
if (!s?.components)
|
|
285
284
|
return /* @__PURE__ */ new Set();
|
|
286
285
|
const g = /* @__PURE__ */ new Set();
|
|
287
286
|
if (l.type === "update") {
|
|
288
287
|
let i = [...n];
|
|
289
288
|
for (; ; ) {
|
|
290
|
-
const h =
|
|
291
|
-
if (h?.pathComponents && h.pathComponents.forEach((
|
|
292
|
-
const t = s.components?.get(
|
|
289
|
+
const h = A(e, i);
|
|
290
|
+
if (h?.pathComponents && h.pathComponents.forEach((d) => {
|
|
291
|
+
const t = s.components?.get(d);
|
|
293
292
|
t && ((Array.isArray(t.reactiveType) ? t.reactiveType : [t.reactiveType || "component"]).includes("none") || g.add(t));
|
|
294
293
|
}), i.length === 0) break;
|
|
295
294
|
i.pop();
|
|
296
295
|
}
|
|
297
|
-
l.newValue && typeof l.newValue == "object" && !je(l.newValue) && Ne(l.newValue, l.oldValue).forEach((
|
|
298
|
-
const t =
|
|
299
|
-
S?.pathComponents && S.pathComponents.forEach((
|
|
300
|
-
const
|
|
301
|
-
|
|
296
|
+
l.newValue && typeof l.newValue == "object" && !je(l.newValue) && Ne(l.newValue, l.oldValue).forEach((d) => {
|
|
297
|
+
const t = d.split("."), a = [...n, ...t], S = A(e, a);
|
|
298
|
+
S?.pathComponents && S.pathComponents.forEach((E) => {
|
|
299
|
+
const V = s.components?.get(E);
|
|
300
|
+
V && ((Array.isArray(V.reactiveType) ? V.reactiveType : [V.reactiveType || "component"]).includes("none") || g.add(V));
|
|
302
301
|
});
|
|
303
302
|
});
|
|
304
303
|
} else if (l.type === "insert" || l.type === "cut" || l.type === "insert_many") {
|
|
305
304
|
let h = [...l.type === "insert" ? n : n.slice(0, -1)];
|
|
306
305
|
for (; ; ) {
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
306
|
+
const d = A(e, h);
|
|
307
|
+
if (d?.pathComponents && d.pathComponents.forEach((t) => {
|
|
309
308
|
const a = s.components?.get(t);
|
|
310
309
|
a && g.add(a);
|
|
311
310
|
}), h.length === 0) break;
|
|
@@ -316,8 +315,10 @@ function ct(e, n, l) {
|
|
|
316
315
|
}
|
|
317
316
|
function lt(e, n, l) {
|
|
318
317
|
const s = T.getState().getShadowValue(e, n), g = G(l) ? l(s) : l;
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
if (ae(s, g))
|
|
319
|
+
return null;
|
|
320
|
+
qe(e, n, g), fe(e, n, { bubble: !0 });
|
|
321
|
+
const i = A(e, n);
|
|
321
322
|
return {
|
|
322
323
|
type: "update",
|
|
323
324
|
oldValue: s,
|
|
@@ -326,8 +327,8 @@ function lt(e, n, l) {
|
|
|
326
327
|
};
|
|
327
328
|
}
|
|
328
329
|
function ut(e, n, l) {
|
|
329
|
-
Ce(e, n, l),
|
|
330
|
-
const s =
|
|
330
|
+
Ce(e, n, l), fe(e, n, { bubble: !0 });
|
|
331
|
+
const s = A(e, n);
|
|
331
332
|
return {
|
|
332
333
|
type: "insert_many",
|
|
333
334
|
count: l.length,
|
|
@@ -349,13 +350,13 @@ function dt(e, n, l, s, g) {
|
|
|
349
350
|
s,
|
|
350
351
|
g
|
|
351
352
|
);
|
|
352
|
-
|
|
353
|
-
const
|
|
353
|
+
fe(e, n, { bubble: !0 });
|
|
354
|
+
const d = A(e, n);
|
|
354
355
|
let t;
|
|
355
|
-
return
|
|
356
|
+
return d?.arrayKeys && s !== void 0 && s > 0 && (t = d.arrayKeys[s - 1]), {
|
|
356
357
|
type: "insert",
|
|
357
358
|
newValue: i,
|
|
358
|
-
shadowMeta:
|
|
359
|
+
shadowMeta: d,
|
|
359
360
|
path: n,
|
|
360
361
|
itemId: h,
|
|
361
362
|
insertAfterId: t
|
|
@@ -363,11 +364,11 @@ function dt(e, n, l, s, g) {
|
|
|
363
364
|
}
|
|
364
365
|
function ft(e, n) {
|
|
365
366
|
const l = n.slice(0, -1), s = x(e, n);
|
|
366
|
-
return Ge(e, n),
|
|
367
|
+
return Ge(e, n), fe(e, l, { bubble: !0 }), { type: "cut", oldValue: s, parentPath: l };
|
|
367
368
|
}
|
|
368
369
|
function gt() {
|
|
369
370
|
const e = /* @__PURE__ */ new Set(), n = [], l = [];
|
|
370
|
-
for (const s of
|
|
371
|
+
for (const s of de) {
|
|
371
372
|
if (s.status && s.updateType) {
|
|
372
373
|
l.push(s);
|
|
373
374
|
continue;
|
|
@@ -377,23 +378,23 @@ function gt() {
|
|
|
377
378
|
g.stateKey,
|
|
378
379
|
g.path,
|
|
379
380
|
g
|
|
380
|
-
).forEach((
|
|
381
|
-
e.add(
|
|
381
|
+
).forEach((d) => {
|
|
382
|
+
e.add(d);
|
|
382
383
|
});
|
|
383
384
|
}
|
|
384
385
|
l.length > 0 && Ze(l), n.forEach(({ shadowMeta: s, displayValue: g }) => {
|
|
385
386
|
it(s, g);
|
|
386
387
|
}), e.forEach((s) => {
|
|
387
388
|
s.forceUpdate();
|
|
388
|
-
}),
|
|
389
|
+
}), de = [], Ae = !1;
|
|
389
390
|
}
|
|
390
391
|
function St(e, n, l) {
|
|
391
392
|
return (g, i, h) => {
|
|
392
393
|
s(e, i, g, h);
|
|
393
394
|
};
|
|
394
|
-
function s(g, i, h,
|
|
395
|
+
function s(g, i, h, d) {
|
|
395
396
|
let t;
|
|
396
|
-
switch (
|
|
397
|
+
switch (d.updateType) {
|
|
397
398
|
case "update":
|
|
398
399
|
t = lt(g, i, h);
|
|
399
400
|
break;
|
|
@@ -402,8 +403,8 @@ function St(e, n, l) {
|
|
|
402
403
|
g,
|
|
403
404
|
i,
|
|
404
405
|
h,
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
d.index,
|
|
407
|
+
d.itemId
|
|
407
408
|
);
|
|
408
409
|
break;
|
|
409
410
|
case "insert_many":
|
|
@@ -413,25 +414,27 @@ function St(e, n, l) {
|
|
|
413
414
|
t = ft(g, i);
|
|
414
415
|
break;
|
|
415
416
|
}
|
|
416
|
-
|
|
417
|
+
if (t === null)
|
|
418
|
+
return;
|
|
419
|
+
t.stateKey = g, t.path = i, de.push(t), st();
|
|
417
420
|
const a = {
|
|
418
421
|
timeStamp: Date.now(),
|
|
419
422
|
stateKey: g,
|
|
420
423
|
path: i,
|
|
421
|
-
updateType:
|
|
424
|
+
updateType: d.updateType,
|
|
422
425
|
status: "new",
|
|
423
426
|
oldValue: t.oldValue,
|
|
424
427
|
newValue: t.newValue ?? null,
|
|
425
428
|
itemId: t.itemId,
|
|
426
429
|
insertAfterId: t.insertAfterId,
|
|
427
|
-
metaData:
|
|
430
|
+
metaData: d.metaData
|
|
428
431
|
};
|
|
429
|
-
|
|
432
|
+
de.push(a), t.newValue !== void 0 && ot(
|
|
430
433
|
t.newValue,
|
|
431
434
|
g,
|
|
432
435
|
l.current,
|
|
433
436
|
n
|
|
434
|
-
), l.current?.middleware && l.current.middleware({ update: a }), ze(a,
|
|
437
|
+
), l.current?.middleware && l.current.middleware({ update: a }), ze(a, d.validationTrigger || "programmatic"), nt(a);
|
|
435
438
|
}
|
|
436
439
|
}
|
|
437
440
|
function yt(e, {
|
|
@@ -441,30 +444,30 @@ function yt(e, {
|
|
|
441
444
|
reactiveDeps: g,
|
|
442
445
|
reactiveType: i,
|
|
443
446
|
componentId: h,
|
|
444
|
-
defaultState:
|
|
447
|
+
defaultState: d,
|
|
445
448
|
dependencies: t,
|
|
446
449
|
serverState: a
|
|
447
450
|
} = {}) {
|
|
448
|
-
const [S,
|
|
449
|
-
let
|
|
450
|
-
const [w] = ee(n ??
|
|
451
|
+
const [S, E] = ee({}), { sessionId: V } = Pe();
|
|
452
|
+
let U = !n;
|
|
453
|
+
const [w] = ee(n ?? se()), W = F(h ?? se()), R = F(
|
|
451
454
|
null
|
|
452
455
|
);
|
|
453
|
-
R.current =
|
|
454
|
-
const y =
|
|
456
|
+
R.current = q(w) ?? null;
|
|
457
|
+
const y = pe(
|
|
455
458
|
(o) => {
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
459
|
+
const u = o ? { ...q(w), ...o } : q(w), f = u?.defaultState || d || e;
|
|
460
|
+
if (u?.serverState?.status === "success" && u?.serverState?.data !== void 0)
|
|
458
461
|
return {
|
|
459
|
-
value:
|
|
462
|
+
value: u.serverState.data,
|
|
460
463
|
source: "server",
|
|
461
|
-
timestamp:
|
|
464
|
+
timestamp: u.serverState.timestamp || Date.now()
|
|
462
465
|
};
|
|
463
|
-
if (
|
|
464
|
-
const v = G(
|
|
465
|
-
`${
|
|
466
|
+
if (u?.localStorage?.key && V) {
|
|
467
|
+
const v = G(u.localStorage.key) ? u.localStorage.key(f) : u.localStorage.key, p = ge(
|
|
468
|
+
`${V}-${w}-${v}`
|
|
466
469
|
);
|
|
467
|
-
if (p && p.lastUpdated > (
|
|
470
|
+
if (p && p.lastUpdated > (u?.serverState?.timestamp || 0))
|
|
468
471
|
return {
|
|
469
472
|
value: p.state,
|
|
470
473
|
source: "localStorage",
|
|
@@ -477,17 +480,17 @@ function yt(e, {
|
|
|
477
480
|
timestamp: Date.now()
|
|
478
481
|
};
|
|
479
482
|
},
|
|
480
|
-
[w,
|
|
483
|
+
[w, d, e, V]
|
|
481
484
|
);
|
|
482
485
|
z(() => {
|
|
483
486
|
a && a.status === "success" && a.data !== void 0 && $e(w, a);
|
|
484
487
|
}, [a, w]), z(() => T.getState().subscribeToPath(w, (c) => {
|
|
485
488
|
if (c?.type === "SERVER_STATE_UPDATE") {
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
489
|
+
const u = c.serverState;
|
|
490
|
+
if (u?.status !== "success" || u.data === void 0)
|
|
488
491
|
return;
|
|
489
|
-
|
|
490
|
-
const f = typeof
|
|
492
|
+
ve(w, { serverState: u });
|
|
493
|
+
const f = typeof u.merge == "object" ? u.merge : u.merge === !0 ? { strategy: "append", key: "id" } : null, m = x(w, []), v = u.data;
|
|
491
494
|
if (f && f.strategy === "append" && "key" in f && Array.isArray(m) && Array.isArray(v)) {
|
|
492
495
|
const p = f.key;
|
|
493
496
|
if (!p) {
|
|
@@ -496,25 +499,25 @@ function yt(e, {
|
|
|
496
499
|
);
|
|
497
500
|
return;
|
|
498
501
|
}
|
|
499
|
-
const
|
|
500
|
-
m.map((
|
|
501
|
-
),
|
|
502
|
-
(
|
|
502
|
+
const M = new Set(
|
|
503
|
+
m.map((D) => D[p])
|
|
504
|
+
), I = v.filter(
|
|
505
|
+
(D) => !M.has(D[p])
|
|
503
506
|
);
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
+
I.length > 0 && Ce(w, [], I);
|
|
508
|
+
const C = x(w, []);
|
|
509
|
+
ue(
|
|
507
510
|
w,
|
|
508
511
|
[],
|
|
509
|
-
|
|
510
|
-
|
|
512
|
+
C,
|
|
513
|
+
u.timestamp || Date.now()
|
|
511
514
|
);
|
|
512
515
|
} else
|
|
513
|
-
|
|
516
|
+
ie(w, v), ue(
|
|
514
517
|
w,
|
|
515
518
|
[],
|
|
516
519
|
v,
|
|
517
|
-
|
|
520
|
+
u.timestamp || Date.now()
|
|
518
521
|
);
|
|
519
522
|
K(w);
|
|
520
523
|
}
|
|
@@ -522,35 +525,35 @@ function yt(e, {
|
|
|
522
525
|
const o = T.getState().getShadowMetadata(w, []);
|
|
523
526
|
if (o && o.stateSource)
|
|
524
527
|
return;
|
|
525
|
-
const c =
|
|
528
|
+
const c = q(w), u = {
|
|
526
529
|
localStorageEnabled: !!c?.localStorage?.key
|
|
527
530
|
};
|
|
528
531
|
if (J(w, [], {
|
|
529
532
|
...o,
|
|
530
|
-
features:
|
|
531
|
-
}), c?.defaultState !== void 0 ||
|
|
532
|
-
const p = c?.defaultState ||
|
|
533
|
-
c?.defaultState ||
|
|
533
|
+
features: u
|
|
534
|
+
}), c?.defaultState !== void 0 || d !== void 0) {
|
|
535
|
+
const p = c?.defaultState || d;
|
|
536
|
+
c?.defaultState || ve(w, {
|
|
534
537
|
defaultState: p
|
|
535
538
|
});
|
|
536
539
|
}
|
|
537
540
|
const { value: f, source: m, timestamp: v } = y();
|
|
538
|
-
|
|
541
|
+
ie(w, f), J(w, [], {
|
|
539
542
|
stateSource: m,
|
|
540
543
|
lastServerSync: m === "server" ? v : void 0,
|
|
541
544
|
isDirty: m === "server" ? !1 : void 0,
|
|
542
545
|
baseServerState: m === "server" ? f : void 0
|
|
543
546
|
}), m === "server" && a && $e(w, a), K(w);
|
|
544
|
-
}, [w, ...t || []]),
|
|
545
|
-
|
|
547
|
+
}, [w, ...t || []]), le(() => {
|
|
548
|
+
U && ve(w, {
|
|
546
549
|
formElements: s,
|
|
547
|
-
defaultState:
|
|
550
|
+
defaultState: d,
|
|
548
551
|
localStorage: l,
|
|
549
552
|
middleware: R.current?.middleware
|
|
550
553
|
});
|
|
551
|
-
const o = `${w}////${
|
|
552
|
-
return
|
|
553
|
-
forceUpdate: () =>
|
|
554
|
+
const o = `${w}////${W.current}`, c = A(w, []), u = c?.components || /* @__PURE__ */ new Map();
|
|
555
|
+
return u.set(o, {
|
|
556
|
+
forceUpdate: () => E({}),
|
|
554
557
|
reactiveType: i ?? ["component"],
|
|
555
558
|
paths: /* @__PURE__ */ new Set(),
|
|
556
559
|
depsFunction: g || void 0,
|
|
@@ -558,67 +561,67 @@ function yt(e, {
|
|
|
558
561
|
prevDeps: g ? g(x(w, [])) : []
|
|
559
562
|
}), J(w, [], {
|
|
560
563
|
...c,
|
|
561
|
-
components:
|
|
562
|
-
}),
|
|
563
|
-
const f =
|
|
564
|
+
components: u
|
|
565
|
+
}), E({}), () => {
|
|
566
|
+
const f = A(w, []), m = f?.components?.get(o);
|
|
564
567
|
m?.paths && m.paths.forEach((v) => {
|
|
565
|
-
const
|
|
566
|
-
|
|
568
|
+
const M = v.split(".").slice(1), I = T.getState().getShadowMetadata(w, M);
|
|
569
|
+
I?.pathComponents && I.pathComponents.size === 0 && (delete I.pathComponents, T.getState().setShadowMetadata(w, M, I));
|
|
567
570
|
}), f?.components && J(w, [], f);
|
|
568
571
|
};
|
|
569
572
|
}, []);
|
|
570
573
|
const te = St(
|
|
571
574
|
w,
|
|
572
|
-
|
|
575
|
+
V,
|
|
573
576
|
R
|
|
574
577
|
);
|
|
575
|
-
return T.getState().initialStateGlobal[w] || ke(w, e),
|
|
578
|
+
return T.getState().initialStateGlobal[w] || ke(w, e), Te(() => De(
|
|
576
579
|
w,
|
|
577
580
|
te,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
), [w,
|
|
581
|
+
W.current,
|
|
582
|
+
V
|
|
583
|
+
), [w, V]);
|
|
581
584
|
}
|
|
582
585
|
const mt = (e, n, l) => {
|
|
583
|
-
let s =
|
|
586
|
+
let s = A(e, n)?.arrayKeys || [];
|
|
584
587
|
const g = l?.transforms;
|
|
585
588
|
if (!g || g.length === 0)
|
|
586
589
|
return s;
|
|
587
590
|
for (const i of g)
|
|
588
591
|
if (i.type === "filter") {
|
|
589
592
|
const h = [];
|
|
590
|
-
s.forEach((
|
|
591
|
-
const a = x(e, [...n,
|
|
592
|
-
i.fn(a, t) && h.push(
|
|
593
|
+
s.forEach((d, t) => {
|
|
594
|
+
const a = x(e, [...n, d]);
|
|
595
|
+
i.fn(a, t) && h.push(d);
|
|
593
596
|
}), s = h;
|
|
594
|
-
} else i.type === "sort" && s.sort((h,
|
|
595
|
-
const t = x(e, [...n, h]), a = x(e, [...n,
|
|
597
|
+
} else i.type === "sort" && s.sort((h, d) => {
|
|
598
|
+
const t = x(e, [...n, h]), a = x(e, [...n, d]);
|
|
596
599
|
return i.fn(t, a);
|
|
597
600
|
});
|
|
598
601
|
return s;
|
|
599
|
-
},
|
|
600
|
-
const s = `${e}////${n}`, i =
|
|
602
|
+
}, we = (e, n, l) => {
|
|
603
|
+
const s = `${e}////${n}`, i = A(e, [])?.components?.get(s);
|
|
601
604
|
!i || i.reactiveType === "none" || !(Array.isArray(i.reactiveType) ? i.reactiveType : [i.reactiveType]).includes("component") || Je(e, l, s);
|
|
602
605
|
}, oe = (e, n, l) => {
|
|
603
|
-
const s =
|
|
604
|
-
s?.components && s.components.forEach((h,
|
|
605
|
-
(Array.isArray(h.reactiveType) ? h.reactiveType : [h.reactiveType || "component"]).includes("all") && (h.forceUpdate(), g.add(
|
|
606
|
-
}),
|
|
606
|
+
const s = A(e, []), g = /* @__PURE__ */ new Set();
|
|
607
|
+
s?.components && s.components.forEach((h, d) => {
|
|
608
|
+
(Array.isArray(h.reactiveType) ? h.reactiveType : [h.reactiveType || "component"]).includes("all") && (h.forceUpdate(), g.add(d));
|
|
609
|
+
}), A(e, [
|
|
607
610
|
...n,
|
|
608
611
|
"getSelected"
|
|
609
612
|
])?.pathComponents?.forEach((h) => {
|
|
610
613
|
s?.components?.get(h)?.forceUpdate();
|
|
611
614
|
});
|
|
612
|
-
const i =
|
|
615
|
+
const i = A(e, n);
|
|
613
616
|
for (let h of i?.arrayKeys || []) {
|
|
614
|
-
const
|
|
617
|
+
const d = h + ".selected", t = A(e, d.split(".").slice(1));
|
|
615
618
|
h == l && t?.pathComponents?.forEach((a) => {
|
|
616
619
|
s?.components?.get(a)?.forceUpdate();
|
|
617
620
|
});
|
|
618
621
|
}
|
|
619
622
|
};
|
|
620
623
|
function X(e, n, l) {
|
|
621
|
-
const s =
|
|
624
|
+
const s = A(e, n), g = n.length > 0 ? n.join(".") : "root", i = l?.arrayViews?.[g];
|
|
622
625
|
if (Array.isArray(i) && i.length === 0)
|
|
623
626
|
return {
|
|
624
627
|
shadowMeta: s,
|
|
@@ -639,10 +642,10 @@ function De(e, n, l, s) {
|
|
|
639
642
|
meta: a,
|
|
640
643
|
componentId: S
|
|
641
644
|
}) {
|
|
642
|
-
const
|
|
643
|
-
if (g.has(
|
|
644
|
-
return g.get(
|
|
645
|
-
const
|
|
645
|
+
const E = a ? JSON.stringify(a.arrayViews || a.transforms) : "", V = t.join(".") + ":" + S + ":" + E;
|
|
646
|
+
if (g.has(V))
|
|
647
|
+
return g.get(V);
|
|
648
|
+
const U = [e, ...t].join("."), w = {
|
|
646
649
|
get(R, y) {
|
|
647
650
|
if (typeof y != "string")
|
|
648
651
|
return Reflect.get(R, y);
|
|
@@ -663,7 +666,7 @@ function De(e, n, l, s) {
|
|
|
663
666
|
const r = T.getState().getInitialOptions(e), o = r?.sync;
|
|
664
667
|
if (!o)
|
|
665
668
|
return console.error(`No mutation defined for state key "${e}"`), { success: !1, error: "No mutation defined" };
|
|
666
|
-
const c = T.getState().getShadowValue(e, []),
|
|
669
|
+
const c = T.getState().getShadowValue(e, []), u = r?.validation?.key;
|
|
667
670
|
try {
|
|
668
671
|
const f = await o.action(c);
|
|
669
672
|
if (f && !f.success && f.errors, f?.success) {
|
|
@@ -691,8 +694,8 @@ function De(e, n, l, s) {
|
|
|
691
694
|
}
|
|
692
695
|
if (y === "$removeStorage")
|
|
693
696
|
return () => {
|
|
694
|
-
const r = T.getState().initialStateGlobal[e], o =
|
|
695
|
-
|
|
697
|
+
const r = T.getState().initialStateGlobal[e], o = q(e), c = G(o?.localStorage?.key) ? o.localStorage.key(r) : o?.localStorage?.key, u = `${s}-${e}-${c}`;
|
|
698
|
+
u && localStorage.removeItem(u);
|
|
696
699
|
};
|
|
697
700
|
if (y === "$showValidationErrors")
|
|
698
701
|
return () => {
|
|
@@ -702,15 +705,15 @@ function De(e, n, l, s) {
|
|
|
702
705
|
if (y === "$getSelected")
|
|
703
706
|
return () => {
|
|
704
707
|
const r = [e, ...t].join(".");
|
|
705
|
-
|
|
708
|
+
we(e, S, [
|
|
706
709
|
...t,
|
|
707
710
|
"getSelected"
|
|
708
711
|
]);
|
|
709
712
|
const o = T.getState().selectedIndicesMap.get(r);
|
|
710
713
|
if (!o)
|
|
711
714
|
return;
|
|
712
|
-
const c = t.join("."),
|
|
713
|
-
if (!(
|
|
715
|
+
const c = t.join("."), u = a?.arrayViews?.[c], f = o.split(".").pop();
|
|
716
|
+
if (!(u && !u.includes(f) || x(
|
|
714
717
|
e,
|
|
715
718
|
o.split(".").slice(1)
|
|
716
719
|
) === void 0))
|
|
@@ -730,8 +733,8 @@ function De(e, n, l, s) {
|
|
|
730
733
|
const { keys: c } = L(e, t, a);
|
|
731
734
|
if (!c)
|
|
732
735
|
return -1;
|
|
733
|
-
const
|
|
734
|
-
return c.indexOf(
|
|
736
|
+
const u = o.split(".").pop();
|
|
737
|
+
return c.indexOf(u);
|
|
735
738
|
};
|
|
736
739
|
if (y === "$clearSelected")
|
|
737
740
|
return oe(e, t), () => {
|
|
@@ -744,69 +747,69 @@ function De(e, n, l, s) {
|
|
|
744
747
|
const {
|
|
745
748
|
itemHeight: o = 50,
|
|
746
749
|
overscan: c = 6,
|
|
747
|
-
stickToBottom:
|
|
750
|
+
stickToBottom: u = !1,
|
|
748
751
|
scrollStickTolerance: f = 75
|
|
749
752
|
} = r, m = F(null), [v, p] = ee({
|
|
750
753
|
startIndex: 0,
|
|
751
754
|
endIndex: 10
|
|
752
|
-
}), [
|
|
755
|
+
}), [M, I] = ee({}), C = F(!0);
|
|
753
756
|
z(() => {
|
|
754
757
|
const k = setInterval(() => {
|
|
755
|
-
|
|
758
|
+
I({});
|
|
756
759
|
}, 1e3);
|
|
757
760
|
return () => clearInterval(k);
|
|
758
761
|
}, []);
|
|
759
|
-
const
|
|
762
|
+
const D = F({
|
|
760
763
|
isUserScrolling: !1,
|
|
761
764
|
lastScrollTop: 0,
|
|
762
765
|
scrollUpCount: 0,
|
|
763
766
|
isNearBottom: !0
|
|
764
767
|
}), O = F(
|
|
765
768
|
/* @__PURE__ */ new Map()
|
|
766
|
-
), { keys:
|
|
769
|
+
), { keys: b } = L(e, t, a);
|
|
767
770
|
z(() => {
|
|
768
|
-
const k = [e, ...t].join("."),
|
|
771
|
+
const k = [e, ...t].join("."), $ = T.getState().subscribeToPath(k, (j) => {
|
|
769
772
|
j.type !== "GET_SELECTED" && j.type;
|
|
770
773
|
});
|
|
771
774
|
return () => {
|
|
772
|
-
|
|
775
|
+
$();
|
|
773
776
|
};
|
|
774
|
-
}, [S, e, t.join(".")]),
|
|
775
|
-
if (
|
|
776
|
-
const k = m.current,
|
|
777
|
+
}, [S, e, t.join(".")]), le(() => {
|
|
778
|
+
if (u && b.length > 0 && m.current && !D.current.isUserScrolling && C.current) {
|
|
779
|
+
const k = m.current, $ = () => {
|
|
777
780
|
if (k.clientHeight > 0) {
|
|
778
781
|
const j = Math.ceil(
|
|
779
782
|
k.clientHeight / o
|
|
780
|
-
), B =
|
|
783
|
+
), B = b.length - 1, _ = Math.max(
|
|
781
784
|
0,
|
|
782
785
|
B - j - c
|
|
783
786
|
);
|
|
784
787
|
p({ startIndex: _, endIndex: B }), requestAnimationFrame(() => {
|
|
785
|
-
Z("instant"),
|
|
788
|
+
Z("instant"), C.current = !1;
|
|
786
789
|
});
|
|
787
790
|
} else
|
|
788
|
-
requestAnimationFrame(
|
|
791
|
+
requestAnimationFrame($);
|
|
789
792
|
};
|
|
790
|
-
|
|
793
|
+
$();
|
|
791
794
|
}
|
|
792
|
-
}, [
|
|
795
|
+
}, [b.length, u, o, c]);
|
|
793
796
|
const P = F(v);
|
|
794
|
-
|
|
797
|
+
le(() => {
|
|
795
798
|
P.current = v;
|
|
796
799
|
}, [v]);
|
|
797
|
-
const N = F(
|
|
798
|
-
|
|
799
|
-
N.current =
|
|
800
|
-
}, [
|
|
801
|
-
const
|
|
800
|
+
const N = F(b);
|
|
801
|
+
le(() => {
|
|
802
|
+
N.current = b;
|
|
803
|
+
}, [b]);
|
|
804
|
+
const ce = pe(() => {
|
|
802
805
|
const k = m.current;
|
|
803
806
|
if (!k) return;
|
|
804
|
-
const
|
|
805
|
-
_.isNearBottom = re <= f,
|
|
807
|
+
const $ = k.scrollTop, { scrollHeight: j, clientHeight: B } = k, _ = D.current, re = j - ($ + B), Se = _.isNearBottom;
|
|
808
|
+
_.isNearBottom = re <= f, $ < _.lastScrollTop ? (_.scrollUpCount++, _.scrollUpCount > 3 && Se && (_.isUserScrolling = !0, console.log("User scrolled away from bottom"))) : _.isNearBottom && (_.isUserScrolling = !1, _.scrollUpCount = 0), _.lastScrollTop = $;
|
|
806
809
|
let Y = 0;
|
|
807
|
-
for (let H = 0; H <
|
|
808
|
-
const
|
|
809
|
-
if (
|
|
810
|
+
for (let H = 0; H < b.length; H++) {
|
|
811
|
+
const ye = b[H], me = O.current.get(ye);
|
|
812
|
+
if (me && me.offset + me.height > $) {
|
|
810
813
|
Y = H;
|
|
811
814
|
break;
|
|
812
815
|
}
|
|
@@ -821,13 +824,13 @@ function De(e, n, l, s) {
|
|
|
821
824
|
p({
|
|
822
825
|
startIndex: Math.max(0, Y - c),
|
|
823
826
|
endIndex: Math.min(
|
|
824
|
-
|
|
827
|
+
b.length - 1,
|
|
825
828
|
Y + H + c
|
|
826
829
|
)
|
|
827
830
|
});
|
|
828
831
|
}
|
|
829
832
|
}, [
|
|
830
|
-
|
|
833
|
+
b.length,
|
|
831
834
|
v.startIndex,
|
|
832
835
|
o,
|
|
833
836
|
c,
|
|
@@ -836,27 +839,27 @@ function De(e, n, l, s) {
|
|
|
836
839
|
z(() => {
|
|
837
840
|
const k = m.current;
|
|
838
841
|
if (k)
|
|
839
|
-
return k.addEventListener("scroll",
|
|
842
|
+
return k.addEventListener("scroll", ce, {
|
|
840
843
|
passive: !0
|
|
841
844
|
}), () => {
|
|
842
|
-
k.removeEventListener("scroll",
|
|
845
|
+
k.removeEventListener("scroll", ce);
|
|
843
846
|
};
|
|
844
|
-
}, [
|
|
845
|
-
const Z =
|
|
847
|
+
}, [ce, u]);
|
|
848
|
+
const Z = pe(
|
|
846
849
|
(k = "smooth") => {
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
849
|
-
|
|
850
|
+
const $ = m.current;
|
|
851
|
+
if (!$) return;
|
|
852
|
+
D.current.isUserScrolling = !1, D.current.isNearBottom = !0, D.current.scrollUpCount = 0;
|
|
850
853
|
const j = () => {
|
|
851
854
|
const B = (_ = 0) => {
|
|
852
855
|
if (_ > 5) return;
|
|
853
|
-
const re =
|
|
854
|
-
|
|
856
|
+
const re = $.scrollHeight, Se = $.scrollTop, Y = $.clientHeight;
|
|
857
|
+
Se + Y >= re - 1 || ($.scrollTo({
|
|
855
858
|
top: re,
|
|
856
859
|
behavior: k
|
|
857
860
|
}), setTimeout(() => {
|
|
858
|
-
const H =
|
|
859
|
-
(H !== re ||
|
|
861
|
+
const H = $.scrollHeight, ye = $.scrollTop;
|
|
862
|
+
(H !== re || ye + Y < H - 1) && B(_ + 1);
|
|
860
863
|
}, 50));
|
|
861
864
|
};
|
|
862
865
|
B();
|
|
@@ -868,41 +871,41 @@ function De(e, n, l, s) {
|
|
|
868
871
|
[]
|
|
869
872
|
);
|
|
870
873
|
return z(() => {
|
|
871
|
-
if (!
|
|
872
|
-
const k = m.current,
|
|
874
|
+
if (!u || !m.current) return;
|
|
875
|
+
const k = m.current, $ = D.current;
|
|
873
876
|
let j;
|
|
874
877
|
const B = () => {
|
|
875
878
|
clearTimeout(j), j = setTimeout(() => {
|
|
876
|
-
|
|
877
|
-
|
|
879
|
+
!$.isUserScrolling && $.isNearBottom && Z(
|
|
880
|
+
C.current ? "instant" : "smooth"
|
|
878
881
|
);
|
|
879
882
|
}, 100);
|
|
880
883
|
}, _ = new MutationObserver(() => {
|
|
881
|
-
|
|
884
|
+
$.isUserScrolling || B();
|
|
882
885
|
});
|
|
883
886
|
return _.observe(k, {
|
|
884
887
|
childList: !0,
|
|
885
888
|
subtree: !0,
|
|
886
889
|
attributes: !0,
|
|
887
890
|
attributeFilter: ["style", "class"]
|
|
888
|
-
}),
|
|
891
|
+
}), C.current ? setTimeout(() => {
|
|
889
892
|
Z("instant");
|
|
890
893
|
}, 0) : B(), () => {
|
|
891
894
|
clearTimeout(j), _.disconnect();
|
|
892
895
|
};
|
|
893
|
-
}, [
|
|
894
|
-
virtualState:
|
|
895
|
-
const k = Array.isArray(
|
|
896
|
+
}, [u, b.length, Z]), {
|
|
897
|
+
virtualState: Te(() => {
|
|
898
|
+
const k = Array.isArray(b) ? b.slice(v.startIndex, v.endIndex + 1) : [], $ = t.length > 0 ? t.join(".") : "root";
|
|
896
899
|
return i({
|
|
897
900
|
path: t,
|
|
898
901
|
componentId: S,
|
|
899
902
|
meta: {
|
|
900
903
|
...a,
|
|
901
|
-
arrayViews: { [
|
|
904
|
+
arrayViews: { [$]: k },
|
|
902
905
|
serverStateIsUpStream: !0
|
|
903
906
|
}
|
|
904
907
|
});
|
|
905
|
-
}, [v.startIndex, v.endIndex,
|
|
908
|
+
}, [v.startIndex, v.endIndex, b, a]),
|
|
906
909
|
virtualizerProps: {
|
|
907
910
|
outer: {
|
|
908
911
|
ref: m,
|
|
@@ -919,15 +922,15 @@ function De(e, n, l, s) {
|
|
|
919
922
|
},
|
|
920
923
|
list: {
|
|
921
924
|
style: {
|
|
922
|
-
transform: `translateY(${O.current.get(
|
|
925
|
+
transform: `translateY(${O.current.get(b[v.startIndex])?.offset || 0}px)`
|
|
923
926
|
}
|
|
924
927
|
}
|
|
925
928
|
},
|
|
926
929
|
scrollToBottom: Z,
|
|
927
|
-
scrollToIndex: (k,
|
|
928
|
-
if (m.current &&
|
|
929
|
-
const j = O.current.get(
|
|
930
|
-
m.current.scrollTo({ top: j, behavior:
|
|
930
|
+
scrollToIndex: (k, $ = "smooth") => {
|
|
931
|
+
if (m.current && b[k]) {
|
|
932
|
+
const j = O.current.get(b[k])?.offset || 0;
|
|
933
|
+
m.current.scrollTo({ top: j, behavior: $ });
|
|
931
934
|
}
|
|
932
935
|
}
|
|
933
936
|
};
|
|
@@ -939,9 +942,9 @@ function De(e, n, l, s) {
|
|
|
939
942
|
t,
|
|
940
943
|
a
|
|
941
944
|
);
|
|
942
|
-
if (
|
|
945
|
+
if (we(e, S, t), !c || !Array.isArray(o))
|
|
943
946
|
return [];
|
|
944
|
-
const
|
|
947
|
+
const u = i({
|
|
945
948
|
path: t,
|
|
946
949
|
componentId: S,
|
|
947
950
|
meta: a
|
|
@@ -949,26 +952,26 @@ function De(e, n, l, s) {
|
|
|
949
952
|
return o.map((f, m) => {
|
|
950
953
|
const v = c[m];
|
|
951
954
|
if (!v) return;
|
|
952
|
-
const p = [...t, v],
|
|
955
|
+
const p = [...t, v], M = i({
|
|
953
956
|
path: p,
|
|
954
957
|
// This now correctly points to the item in the shadow store.
|
|
955
958
|
componentId: S,
|
|
956
959
|
meta: a
|
|
957
960
|
});
|
|
958
|
-
return r(
|
|
961
|
+
return r(M, m, u);
|
|
959
962
|
});
|
|
960
963
|
};
|
|
961
964
|
if (y === "$stateFilter")
|
|
962
965
|
return (r) => {
|
|
963
|
-
const o = t.length > 0 ? t.join(".") : "root", { keys: c, value:
|
|
966
|
+
const o = t.length > 0 ? t.join(".") : "root", { keys: c, value: u } = L(
|
|
964
967
|
e,
|
|
965
968
|
t,
|
|
966
969
|
a
|
|
967
970
|
);
|
|
968
|
-
if (!Array.isArray(
|
|
971
|
+
if (!Array.isArray(u))
|
|
969
972
|
throw new Error("stateFilter can only be used on arrays");
|
|
970
973
|
const f = [];
|
|
971
|
-
return
|
|
974
|
+
return u.forEach((m, v) => {
|
|
972
975
|
if (r(m, v)) {
|
|
973
976
|
const p = c[v];
|
|
974
977
|
p && f.push(p);
|
|
@@ -991,16 +994,16 @@ function De(e, n, l, s) {
|
|
|
991
994
|
};
|
|
992
995
|
if (y === "$stateSort")
|
|
993
996
|
return (r) => {
|
|
994
|
-
const o = t.length > 0 ? t.join(".") : "root", { value: c, keys:
|
|
997
|
+
const o = t.length > 0 ? t.join(".") : "root", { value: c, keys: u } = L(
|
|
995
998
|
e,
|
|
996
999
|
t,
|
|
997
1000
|
a
|
|
998
1001
|
);
|
|
999
|
-
if (!Array.isArray(c) || !
|
|
1002
|
+
if (!Array.isArray(c) || !u)
|
|
1000
1003
|
throw new Error("No array keys found for sorting");
|
|
1001
1004
|
const f = c.map((v, p) => ({
|
|
1002
1005
|
item: v,
|
|
1003
|
-
key:
|
|
1006
|
+
key: u[p]
|
|
1004
1007
|
}));
|
|
1005
1008
|
f.sort((v, p) => r(v.item, p.item));
|
|
1006
1009
|
const m = f.map((v) => v.key);
|
|
@@ -1025,20 +1028,20 @@ function De(e, n, l, s) {
|
|
|
1025
1028
|
const {
|
|
1026
1029
|
bufferSize: o = 100,
|
|
1027
1030
|
flushInterval: c = 100,
|
|
1028
|
-
bufferStrategy:
|
|
1031
|
+
bufferStrategy: u = "accumulate",
|
|
1029
1032
|
store: f,
|
|
1030
1033
|
onFlush: m
|
|
1031
1034
|
} = r;
|
|
1032
|
-
let v = [], p = !1,
|
|
1033
|
-
const
|
|
1035
|
+
let v = [], p = !1, M = null;
|
|
1036
|
+
const I = (P) => {
|
|
1034
1037
|
if (!p) {
|
|
1035
|
-
if (
|
|
1038
|
+
if (u === "sliding" && v.length >= o)
|
|
1036
1039
|
v.shift();
|
|
1037
|
-
else if (
|
|
1040
|
+
else if (u === "dropping" && v.length >= o)
|
|
1038
1041
|
return;
|
|
1039
|
-
v.push(P), v.length >= o &&
|
|
1042
|
+
v.push(P), v.length >= o && C();
|
|
1040
1043
|
}
|
|
1041
|
-
},
|
|
1044
|
+
}, C = () => {
|
|
1042
1045
|
if (v.length === 0) return;
|
|
1043
1046
|
const P = [...v];
|
|
1044
1047
|
if (v = [], f) {
|
|
@@ -1056,43 +1059,43 @@ function De(e, n, l, s) {
|
|
|
1056
1059
|
});
|
|
1057
1060
|
m?.(P);
|
|
1058
1061
|
};
|
|
1059
|
-
c > 0 && (
|
|
1060
|
-
const
|
|
1061
|
-
return
|
|
1062
|
+
c > 0 && (M = setInterval(C, c));
|
|
1063
|
+
const D = se(), O = A(e, t) || {}, b = O.streams || /* @__PURE__ */ new Map();
|
|
1064
|
+
return b.set(D, { buffer: v, flushTimer: M }), J(e, t, {
|
|
1062
1065
|
...O,
|
|
1063
|
-
streams:
|
|
1066
|
+
streams: b
|
|
1064
1067
|
}), {
|
|
1065
|
-
write: (P) =>
|
|
1066
|
-
writeMany: (P) => P.forEach(
|
|
1067
|
-
flush: () =>
|
|
1068
|
+
write: (P) => I(P),
|
|
1069
|
+
writeMany: (P) => P.forEach(I),
|
|
1070
|
+
flush: () => C(),
|
|
1068
1071
|
pause: () => {
|
|
1069
1072
|
p = !0;
|
|
1070
1073
|
},
|
|
1071
1074
|
resume: () => {
|
|
1072
|
-
p = !1, v.length > 0 &&
|
|
1075
|
+
p = !1, v.length > 0 && C();
|
|
1073
1076
|
},
|
|
1074
1077
|
close: () => {
|
|
1075
|
-
|
|
1078
|
+
C(), M && clearInterval(M);
|
|
1076
1079
|
const P = T.getState().getShadowMetadata(e, t);
|
|
1077
|
-
P?.streams && P.streams.delete(
|
|
1080
|
+
P?.streams && P.streams.delete(D);
|
|
1078
1081
|
}
|
|
1079
1082
|
};
|
|
1080
1083
|
};
|
|
1081
1084
|
if (y === "$stateList")
|
|
1082
1085
|
return (r) => /* @__PURE__ */ ne(() => {
|
|
1083
|
-
const c = F(/* @__PURE__ */ new Map()), [
|
|
1086
|
+
const c = F(/* @__PURE__ */ new Map()), [u, f] = ee({}), m = t.length > 0 ? t.join(".") : "root", v = mt(e, t, a), p = Te(() => ({
|
|
1084
1087
|
...a,
|
|
1085
1088
|
arrayViews: {
|
|
1086
1089
|
...a?.arrayViews || {},
|
|
1087
1090
|
[m]: v
|
|
1088
1091
|
}
|
|
1089
|
-
}), [a, m, v]), { value:
|
|
1092
|
+
}), [a, m, v]), { value: M } = L(
|
|
1090
1093
|
e,
|
|
1091
1094
|
t,
|
|
1092
1095
|
p
|
|
1093
1096
|
);
|
|
1094
1097
|
if (z(() => {
|
|
1095
|
-
const
|
|
1098
|
+
const D = T.getState().subscribeToPath(U, (O) => {
|
|
1096
1099
|
if (O.type === "GET_SELECTED")
|
|
1097
1100
|
return;
|
|
1098
1101
|
const P = T.getState().getShadowMetadata(e, t)?.transformCaches;
|
|
@@ -1102,39 +1105,39 @@ function De(e, n, l, s) {
|
|
|
1102
1105
|
(O.type === "INSERT" || O.type === "INSERT_MANY" || O.type === "REMOVE" || O.type === "CLEAR_SELECTION" || O.type === "SERVER_STATE_UPDATE" && !a?.serverStateIsUpStream) && f({});
|
|
1103
1106
|
});
|
|
1104
1107
|
return () => {
|
|
1105
|
-
|
|
1108
|
+
D();
|
|
1106
1109
|
};
|
|
1107
|
-
}, [S,
|
|
1110
|
+
}, [S, U]), !Array.isArray(M))
|
|
1108
1111
|
return null;
|
|
1109
|
-
const
|
|
1112
|
+
const I = i({
|
|
1110
1113
|
path: t,
|
|
1111
1114
|
componentId: S,
|
|
1112
1115
|
meta: p
|
|
1113
1116
|
// Use updated meta here
|
|
1114
|
-
}),
|
|
1115
|
-
const
|
|
1116
|
-
if (!
|
|
1117
|
+
}), C = M.map((D, O) => {
|
|
1118
|
+
const b = v[O];
|
|
1119
|
+
if (!b)
|
|
1117
1120
|
return null;
|
|
1118
|
-
let P = c.current.get(
|
|
1119
|
-
P || (P =
|
|
1120
|
-
const N = [...t,
|
|
1121
|
+
let P = c.current.get(b);
|
|
1122
|
+
P || (P = se(), c.current.set(b, P));
|
|
1123
|
+
const N = [...t, b];
|
|
1121
1124
|
return Ee(Be, {
|
|
1122
|
-
key:
|
|
1125
|
+
key: b,
|
|
1123
1126
|
stateKey: e,
|
|
1124
1127
|
itemComponentId: P,
|
|
1125
1128
|
itemPath: N,
|
|
1126
1129
|
localIndex: O,
|
|
1127
|
-
arraySetter:
|
|
1130
|
+
arraySetter: I,
|
|
1128
1131
|
rebuildStateShape: i,
|
|
1129
1132
|
renderFn: r
|
|
1130
1133
|
});
|
|
1131
1134
|
});
|
|
1132
|
-
return /* @__PURE__ */ ne(Ue, { children:
|
|
1135
|
+
return /* @__PURE__ */ ne(Ue, { children: C });
|
|
1133
1136
|
}, {});
|
|
1134
1137
|
if (y === "$stateFlattenOn")
|
|
1135
1138
|
return (r) => {
|
|
1136
|
-
const o = t.length > 0 ? t.join(".") : "root", c = a?.arrayViews?.[o],
|
|
1137
|
-
return Array.isArray(
|
|
1139
|
+
const o = t.length > 0 ? t.join(".") : "root", c = a?.arrayViews?.[o], u = T.getState().getShadowValue(e, t, c);
|
|
1140
|
+
return Array.isArray(u) ? i({
|
|
1138
1141
|
path: [...t, "[*]", r],
|
|
1139
1142
|
componentId: S,
|
|
1140
1143
|
meta: a
|
|
@@ -1151,9 +1154,9 @@ function De(e, n, l, s) {
|
|
|
1151
1154
|
meta: a
|
|
1152
1155
|
}) : void 0;
|
|
1153
1156
|
}
|
|
1154
|
-
const
|
|
1155
|
-
if (!
|
|
1156
|
-
const f =
|
|
1157
|
+
const u = A(e, t);
|
|
1158
|
+
if (!u?.arrayKeys) return;
|
|
1159
|
+
const f = u.arrayKeys[r];
|
|
1157
1160
|
if (f)
|
|
1158
1161
|
return i({
|
|
1159
1162
|
path: [...t, f],
|
|
@@ -1191,36 +1194,36 @@ function De(e, n, l, s) {
|
|
|
1191
1194
|
};
|
|
1192
1195
|
if (y === "$uniqueInsert")
|
|
1193
1196
|
return (r, o, c) => {
|
|
1194
|
-
const { value:
|
|
1197
|
+
const { value: u } = X(
|
|
1195
1198
|
e,
|
|
1196
1199
|
t,
|
|
1197
1200
|
a
|
|
1198
|
-
), f = G(r) ? r(
|
|
1201
|
+
), f = G(r) ? r(u) : r;
|
|
1199
1202
|
let m = null;
|
|
1200
|
-
if (!
|
|
1201
|
-
const
|
|
1202
|
-
(
|
|
1203
|
-
) :
|
|
1204
|
-
return
|
|
1203
|
+
if (!u.some((p) => {
|
|
1204
|
+
const M = o ? o.every(
|
|
1205
|
+
(I) => ae(p[I], f[I])
|
|
1206
|
+
) : ae(p, f);
|
|
1207
|
+
return M && (m = p), M;
|
|
1205
1208
|
}))
|
|
1206
1209
|
n(f, t, { updateType: "insert" });
|
|
1207
1210
|
else if (c && m) {
|
|
1208
|
-
const p = c(m),
|
|
1209
|
-
(
|
|
1211
|
+
const p = c(m), M = u.map(
|
|
1212
|
+
(I) => ae(I, m) ? p : I
|
|
1210
1213
|
);
|
|
1211
|
-
n(
|
|
1214
|
+
n(M, t, {
|
|
1212
1215
|
updateType: "update"
|
|
1213
1216
|
});
|
|
1214
1217
|
}
|
|
1215
1218
|
};
|
|
1216
1219
|
if (y === "$cut")
|
|
1217
1220
|
return (r, o) => {
|
|
1218
|
-
const c =
|
|
1221
|
+
const c = A(e, t);
|
|
1219
1222
|
if (console.log("shadowMeta ->>>>>>>>>>>>>>>>", c), !c?.arrayKeys || c.arrayKeys.length === 0)
|
|
1220
1223
|
return;
|
|
1221
|
-
const
|
|
1222
|
-
console.log("indexToCut ->>>>>>>>>>>>>>>>",
|
|
1223
|
-
const f = c.arrayKeys[
|
|
1224
|
+
const u = r === -1 ? c.arrayKeys.length - 1 : r !== void 0 ? r : c.arrayKeys.length - 1;
|
|
1225
|
+
console.log("indexToCut ->>>>>>>>>>>>>>>>", u);
|
|
1226
|
+
const f = c.arrayKeys[u];
|
|
1224
1227
|
f && (console.log("idToCut ->>>>>>>>>>>>>>>>", f), n(null, [...t, f], {
|
|
1225
1228
|
updateType: "cut"
|
|
1226
1229
|
}));
|
|
@@ -1233,8 +1236,8 @@ function De(e, n, l, s) {
|
|
|
1233
1236
|
const c = T.getState().selectedIndicesMap.get(r);
|
|
1234
1237
|
if (!c)
|
|
1235
1238
|
return;
|
|
1236
|
-
const
|
|
1237
|
-
if (!o.includes(
|
|
1239
|
+
const u = c.split(".").pop();
|
|
1240
|
+
if (!o.includes(u))
|
|
1238
1241
|
return;
|
|
1239
1242
|
const f = c.split(".").slice(1);
|
|
1240
1243
|
T.getState().clearSelectedIndex({ arrayKey: r });
|
|
@@ -1248,10 +1251,10 @@ function De(e, n, l, s) {
|
|
|
1248
1251
|
const {
|
|
1249
1252
|
isArray: o,
|
|
1250
1253
|
value: c,
|
|
1251
|
-
keys:
|
|
1254
|
+
keys: u
|
|
1252
1255
|
} = L(e, t, a);
|
|
1253
1256
|
if (!o) return;
|
|
1254
|
-
const f =
|
|
1257
|
+
const f = he(c, u, (m) => m === r);
|
|
1255
1258
|
f && n(null, [...t, f.key], {
|
|
1256
1259
|
updateType: "cut"
|
|
1257
1260
|
});
|
|
@@ -1261,10 +1264,10 @@ function De(e, n, l, s) {
|
|
|
1261
1264
|
const {
|
|
1262
1265
|
isArray: o,
|
|
1263
1266
|
value: c,
|
|
1264
|
-
keys:
|
|
1267
|
+
keys: u
|
|
1265
1268
|
} = L(e, t, a);
|
|
1266
1269
|
if (!o) return;
|
|
1267
|
-
const f =
|
|
1270
|
+
const f = he(c, u, (m) => m === r);
|
|
1268
1271
|
if (f) {
|
|
1269
1272
|
const m = [...t, f.key];
|
|
1270
1273
|
n(null, m, {
|
|
@@ -1275,11 +1278,11 @@ function De(e, n, l, s) {
|
|
|
1275
1278
|
};
|
|
1276
1279
|
if (y === "$findWith")
|
|
1277
1280
|
return (r, o) => {
|
|
1278
|
-
const { isArray: c, value:
|
|
1281
|
+
const { isArray: c, value: u, keys: f } = L(e, t, a);
|
|
1279
1282
|
if (!c)
|
|
1280
1283
|
throw new Error("findWith can only be used on arrays");
|
|
1281
|
-
const m =
|
|
1282
|
-
|
|
1284
|
+
const m = he(
|
|
1285
|
+
u,
|
|
1283
1286
|
f,
|
|
1284
1287
|
(v) => v?.[r] === o
|
|
1285
1288
|
);
|
|
@@ -1297,7 +1300,7 @@ function De(e, n, l, s) {
|
|
|
1297
1300
|
}
|
|
1298
1301
|
if (y === "$get")
|
|
1299
1302
|
return () => {
|
|
1300
|
-
|
|
1303
|
+
we(e, S, t);
|
|
1301
1304
|
const { value: r } = X(e, t, a);
|
|
1302
1305
|
return r;
|
|
1303
1306
|
};
|
|
@@ -1315,19 +1318,19 @@ function De(e, n, l, s) {
|
|
|
1315
1318
|
return Xe(r);
|
|
1316
1319
|
}
|
|
1317
1320
|
if (y == "getLocalStorage")
|
|
1318
|
-
return (r) =>
|
|
1321
|
+
return (r) => ge(s + "-" + e + "-" + r);
|
|
1319
1322
|
if (y === "$isSelected") {
|
|
1320
1323
|
const r = t.slice(0, -1);
|
|
1321
|
-
if (
|
|
1322
|
-
const c = e + "." + r.join("."),
|
|
1323
|
-
return
|
|
1324
|
+
if (A(e, r)?.arrayKeys) {
|
|
1325
|
+
const c = e + "." + r.join("."), u = T.getState().selectedIndicesMap.get(c), f = e + "." + t.join(".");
|
|
1326
|
+
return u === f;
|
|
1324
1327
|
}
|
|
1325
1328
|
return;
|
|
1326
1329
|
}
|
|
1327
1330
|
if (y === "$setSelected")
|
|
1328
1331
|
return (r) => {
|
|
1329
|
-
const o = t.slice(0, -1), c = e + "." + o.join("."),
|
|
1330
|
-
oe(e, o, void 0), T.getState().selectedIndicesMap.get(c), r && T.getState().setSelectedIndex(c,
|
|
1332
|
+
const o = t.slice(0, -1), c = e + "." + o.join("."), u = e + "." + t.join(".");
|
|
1333
|
+
oe(e, o, void 0), T.getState().selectedIndicesMap.get(c), r && T.getState().setSelectedIndex(c, u);
|
|
1331
1334
|
};
|
|
1332
1335
|
if (y === "$toggleSelected")
|
|
1333
1336
|
return () => {
|
|
@@ -1339,7 +1342,7 @@ function De(e, n, l, s) {
|
|
|
1339
1342
|
if (t.length == 0) {
|
|
1340
1343
|
if (y === "$setOptions")
|
|
1341
1344
|
return (r) => {
|
|
1342
|
-
|
|
1345
|
+
Me({ stateKey: e, options: r, initialOptionsPart: {} });
|
|
1343
1346
|
};
|
|
1344
1347
|
if (y === "$_applyUpdate")
|
|
1345
1348
|
return (r, o, c = "update") => {
|
|
@@ -1356,9 +1359,9 @@ function De(e, n, l, s) {
|
|
|
1356
1359
|
if (y === "$addZodValidation")
|
|
1357
1360
|
return (r, o) => {
|
|
1358
1361
|
r.forEach((c) => {
|
|
1359
|
-
const
|
|
1362
|
+
const u = T.getState().getShadowMetadata(e, c.path) || {};
|
|
1360
1363
|
T.getState().setShadowMetadata(e, c.path, {
|
|
1361
|
-
...
|
|
1364
|
+
...u,
|
|
1362
1365
|
validation: {
|
|
1363
1366
|
status: "INVALID",
|
|
1364
1367
|
errors: [
|
|
@@ -1379,7 +1382,7 @@ function De(e, n, l, s) {
|
|
|
1379
1382
|
return (r) => {
|
|
1380
1383
|
if (!r)
|
|
1381
1384
|
throw new Error("clearZodValidation requires a path");
|
|
1382
|
-
const o =
|
|
1385
|
+
const o = A(e, r) || {};
|
|
1383
1386
|
J(e, r, {
|
|
1384
1387
|
...o,
|
|
1385
1388
|
validation: {
|
|
@@ -1397,9 +1400,9 @@ function De(e, n, l, s) {
|
|
|
1397
1400
|
);
|
|
1398
1401
|
let c;
|
|
1399
1402
|
if (r.insertAfterId && r.updateType === "insert") {
|
|
1400
|
-
const
|
|
1401
|
-
if (
|
|
1402
|
-
const f =
|
|
1403
|
+
const u = A(e, r.path);
|
|
1404
|
+
if (u?.arrayKeys) {
|
|
1405
|
+
const f = u.arrayKeys.indexOf(
|
|
1403
1406
|
r.insertAfterId
|
|
1404
1407
|
);
|
|
1405
1408
|
f !== -1 && (c = f + 1);
|
|
@@ -1417,46 +1420,46 @@ function De(e, n, l, s) {
|
|
|
1417
1420
|
return (r) => {
|
|
1418
1421
|
const o = T.getState(), c = o.getShadowMetadata(e, []);
|
|
1419
1422
|
if (!c?.components) return;
|
|
1420
|
-
const
|
|
1423
|
+
const u = (m) => !m || m === "/" ? [] : m.split("/").slice(1).map((v) => v.replace(/~1/g, "/").replace(/~0/g, "~")), f = /* @__PURE__ */ new Set();
|
|
1421
1424
|
for (const m of r) {
|
|
1422
|
-
const v =
|
|
1425
|
+
const v = u(m.path);
|
|
1423
1426
|
switch (m.op) {
|
|
1424
1427
|
case "add":
|
|
1425
1428
|
case "replace": {
|
|
1426
1429
|
const { value: p } = m;
|
|
1427
1430
|
o.updateShadowAtPath(e, v, p), o.markAsDirty(e, v, { bubble: !0 });
|
|
1428
|
-
let
|
|
1431
|
+
let M = [...v];
|
|
1429
1432
|
for (; ; ) {
|
|
1430
|
-
const
|
|
1433
|
+
const I = o.getShadowMetadata(
|
|
1431
1434
|
e,
|
|
1432
|
-
|
|
1435
|
+
M
|
|
1433
1436
|
);
|
|
1434
|
-
if (
|
|
1435
|
-
if (!f.has(
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1437
|
+
if (I?.pathComponents && I.pathComponents.forEach((C) => {
|
|
1438
|
+
if (!f.has(C)) {
|
|
1439
|
+
const D = c.components?.get(C);
|
|
1440
|
+
D && (D.forceUpdate(), f.add(C));
|
|
1438
1441
|
}
|
|
1439
|
-
}),
|
|
1440
|
-
|
|
1442
|
+
}), M.length === 0) break;
|
|
1443
|
+
M.pop();
|
|
1441
1444
|
}
|
|
1442
1445
|
break;
|
|
1443
1446
|
}
|
|
1444
1447
|
case "remove": {
|
|
1445
1448
|
const p = v.slice(0, -1);
|
|
1446
1449
|
o.removeShadowArrayElement(e, v), o.markAsDirty(e, p, { bubble: !0 });
|
|
1447
|
-
let
|
|
1450
|
+
let M = [...p];
|
|
1448
1451
|
for (; ; ) {
|
|
1449
|
-
const
|
|
1452
|
+
const I = o.getShadowMetadata(
|
|
1450
1453
|
e,
|
|
1451
|
-
|
|
1454
|
+
M
|
|
1452
1455
|
);
|
|
1453
|
-
if (
|
|
1454
|
-
if (!f.has(
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1456
|
+
if (I?.pathComponents && I.pathComponents.forEach((C) => {
|
|
1457
|
+
if (!f.has(C)) {
|
|
1458
|
+
const D = c.components?.get(C);
|
|
1459
|
+
D && (D.forceUpdate(), f.add(C));
|
|
1457
1460
|
}
|
|
1458
|
-
}),
|
|
1459
|
-
|
|
1461
|
+
}), M.length === 0) break;
|
|
1462
|
+
M.pop();
|
|
1460
1463
|
}
|
|
1461
1464
|
break;
|
|
1462
1465
|
}
|
|
@@ -1464,7 +1467,7 @@ function De(e, n, l, s) {
|
|
|
1464
1467
|
}
|
|
1465
1468
|
};
|
|
1466
1469
|
if (y === "$getComponents")
|
|
1467
|
-
return () =>
|
|
1470
|
+
return () => A(e, [])?.components;
|
|
1468
1471
|
}
|
|
1469
1472
|
if (y === "$validationWrapper")
|
|
1470
1473
|
return ({
|
|
@@ -1541,19 +1544,19 @@ function De(e, n, l, s) {
|
|
|
1541
1544
|
meta: a
|
|
1542
1545
|
});
|
|
1543
1546
|
}
|
|
1544
|
-
},
|
|
1545
|
-
return g.set(
|
|
1547
|
+
}, W = new Proxy({}, w);
|
|
1548
|
+
return g.set(V, W), W;
|
|
1546
1549
|
}
|
|
1547
1550
|
const h = {
|
|
1548
1551
|
$revertToInitialState: (t) => {
|
|
1549
1552
|
const a = T.getState().getShadowMetadata(e, []);
|
|
1550
1553
|
let S;
|
|
1551
|
-
a?.stateSource === "server" && a.baseServerState ? S = a.baseServerState : S = T.getState().initialStateGlobal[e], Ye(e),
|
|
1554
|
+
a?.stateSource === "server" && a.baseServerState ? S = a.baseServerState : S = T.getState().initialStateGlobal[e], Ye(e), ie(e, S), i({
|
|
1552
1555
|
path: [],
|
|
1553
1556
|
componentId: l
|
|
1554
1557
|
});
|
|
1555
|
-
const
|
|
1556
|
-
return
|
|
1558
|
+
const E = q(e), V = G(E?.localStorage?.key) ? E?.localStorage?.key(S) : E?.localStorage?.key, U = `${s}-${e}-${V}`;
|
|
1559
|
+
return U && localStorage.removeItem(U), K(e), S;
|
|
1557
1560
|
},
|
|
1558
1561
|
$initializeAndMergeShadowState: (t) => {
|
|
1559
1562
|
We(e, t), K(e);
|
|
@@ -1564,12 +1567,12 @@ function De(e, n, l, s) {
|
|
|
1564
1567
|
n,
|
|
1565
1568
|
l,
|
|
1566
1569
|
s
|
|
1567
|
-
), S = T.getState().initialStateGlobal[e],
|
|
1568
|
-
return localStorage.getItem(
|
|
1569
|
-
ke(e, t),
|
|
1570
|
+
), S = T.getState().initialStateGlobal[e], E = q(e), V = G(E?.localStorage?.key) ? E?.localStorage?.key(S) : E?.localStorage?.key, U = `${s}-${e}-${V}`;
|
|
1571
|
+
return localStorage.getItem(U) && localStorage.removeItem(U), _e(() => {
|
|
1572
|
+
ke(e, t), ie(e, t);
|
|
1570
1573
|
const w = T.getState().getShadowMetadata(e, []);
|
|
1571
|
-
w && w?.components?.forEach((
|
|
1572
|
-
|
|
1574
|
+
w && w?.components?.forEach((W) => {
|
|
1575
|
+
W.forceUpdate();
|
|
1573
1576
|
});
|
|
1574
1577
|
}), {
|
|
1575
1578
|
fetchId: (w) => a.$get()[w]
|
|
@@ -1587,7 +1590,7 @@ function Ve(e) {
|
|
|
1587
1590
|
function ht({
|
|
1588
1591
|
proxy: e
|
|
1589
1592
|
}) {
|
|
1590
|
-
const n = F(null), l = F(null), s = F(!1), g = `${e._stateKey}-${e._path.join(".")}`, i = e._path.length > 0 ? e._path.join(".") : "root", h = e._meta?.arrayViews?.[i],
|
|
1593
|
+
const n = F(null), l = F(null), s = F(!1), g = `${e._stateKey}-${e._path.join(".")}`, i = e._path.length > 0 ? e._path.join(".") : "root", h = e._meta?.arrayViews?.[i], d = x(e._stateKey, e._path, h);
|
|
1591
1594
|
return z(() => {
|
|
1592
1595
|
const t = n.current;
|
|
1593
1596
|
if (!t || s.current) return;
|
|
@@ -1596,26 +1599,26 @@ function ht({
|
|
|
1596
1599
|
console.warn("Parent element not found for signal", g);
|
|
1597
1600
|
return;
|
|
1598
1601
|
}
|
|
1599
|
-
const S = t.parentElement,
|
|
1600
|
-
let
|
|
1601
|
-
|
|
1602
|
-
const w = T.getState().getShadowMetadata(e._stateKey, e._path) || {},
|
|
1603
|
-
|
|
1602
|
+
const S = t.parentElement, V = Array.from(S.childNodes).indexOf(t);
|
|
1603
|
+
let U = S.getAttribute("data-parent-id");
|
|
1604
|
+
U || (U = `parent-${crypto.randomUUID()}`, S.setAttribute("data-parent-id", U)), l.current = `instance-${crypto.randomUUID()}`;
|
|
1605
|
+
const w = T.getState().getShadowMetadata(e._stateKey, e._path) || {}, W = w.signals || [];
|
|
1606
|
+
W.push({
|
|
1604
1607
|
instanceId: l.current,
|
|
1605
|
-
parentId:
|
|
1606
|
-
position:
|
|
1608
|
+
parentId: U,
|
|
1609
|
+
position: V,
|
|
1607
1610
|
effect: e._effect
|
|
1608
1611
|
}), T.getState().setShadowMetadata(e._stateKey, e._path, {
|
|
1609
1612
|
...w,
|
|
1610
|
-
signals:
|
|
1613
|
+
signals: W
|
|
1611
1614
|
});
|
|
1612
|
-
let R =
|
|
1615
|
+
let R = d;
|
|
1613
1616
|
if (e._effect)
|
|
1614
1617
|
try {
|
|
1615
1618
|
R = new Function(
|
|
1616
1619
|
"state",
|
|
1617
1620
|
`return (${e._effect})(state)`
|
|
1618
|
-
)(
|
|
1621
|
+
)(d);
|
|
1619
1622
|
} catch (te) {
|
|
1620
1623
|
console.error("Error evaluating effect function:", te);
|
|
1621
1624
|
}
|
|
@@ -1627,7 +1630,7 @@ function ht({
|
|
|
1627
1630
|
if (clearTimeout(a), l.current) {
|
|
1628
1631
|
const S = T.getState().getShadowMetadata(e._stateKey, e._path) || {};
|
|
1629
1632
|
S.signals && (S.signals = S.signals.filter(
|
|
1630
|
-
(
|
|
1633
|
+
(E) => E.instanceId !== l.current
|
|
1631
1634
|
), T.getState().setShadowMetadata(e._stateKey, e._path, S));
|
|
1632
1635
|
}
|
|
1633
1636
|
};
|