cogsbox-state 0.5.361 → 0.5.362
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CogsState.jsx +244 -244
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +9 -5
package/dist/CogsState.jsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as ee, useRef as J, useEffect as oe, useLayoutEffect as ie, useMemo as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import { pushFunc as
|
|
6
|
-
import
|
|
7
|
-
import { v4 as
|
|
2
|
+
import { jsx as Ie } from "react/jsx-runtime";
|
|
3
|
+
import { useState as ee, useRef as J, useEffect as oe, useLayoutEffect as ie, useMemo as pe, createElement as ce, useSyncExternalStore as Oe, startTransition as Re, useCallback as $e } from "react";
|
|
4
|
+
import { transformStateFunc as Ue, isDeepEqual as B, isFunction as X, getNestedValue as q, getDifferences as we, debounce as je } from "./utility.js";
|
|
5
|
+
import { pushFunc as ye, updateFn as se, cutFunc as ue, ValidationWrapper as Fe, FormControlComponent as De } from "./Functions.jsx";
|
|
6
|
+
import Le from "superjson";
|
|
7
|
+
import { v4 as Ee } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as r, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
9
|
+
import { getGlobalStore as r, formRefStore as ke } from "./store.js";
|
|
10
|
+
import { useCogsConfig as Pe } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as Ge } from "fast-json-patch";
|
|
12
12
|
import We from "react-use-measure";
|
|
13
|
-
function
|
|
13
|
+
function Ne(e, i) {
|
|
14
14
|
const S = r.getState().getInitialOptions, g = r.getState().setInitialStateOptions, y = S(e) || {};
|
|
15
15
|
g(e, {
|
|
16
16
|
...y,
|
|
@@ -22,20 +22,20 @@ function be({
|
|
|
22
22
|
options: i,
|
|
23
23
|
initialOptionsPart: S
|
|
24
24
|
}) {
|
|
25
|
-
const g = re(e) || {}, y = S[e] || {},
|
|
25
|
+
const g = re(e) || {}, y = S[e] || {}, b = r.getState().setInitialStateOptions, w = { ...y, ...g };
|
|
26
26
|
let I = !1;
|
|
27
27
|
if (i)
|
|
28
28
|
for (const a in i)
|
|
29
29
|
w.hasOwnProperty(a) ? (a == "localStorage" && i[a] && w[a].key !== i[a]?.key && (I = !0, w[a] = i[a]), a == "initialState" && i[a] && w[a] !== i[a] && // Different references
|
|
30
30
|
!B(w[a], i[a]) && (I = !0, w[a] = i[a])) : (I = !0, w[a] = i[a]);
|
|
31
|
-
I &&
|
|
31
|
+
I && b(e, w);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ut(e, { formElements: i, validation: S }) {
|
|
34
34
|
return { initialState: e, formElements: i, validation: S };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const gt = (e, i) => {
|
|
37
37
|
let S = e;
|
|
38
|
-
const [g, y] =
|
|
38
|
+
const [g, y] = Ue(S);
|
|
39
39
|
(Object.keys(y).length > 0 || i && Object.keys(i).length > 0) && Object.keys(y).forEach((I) => {
|
|
40
40
|
y[I] = y[I] || {}, y[I].formElements = {
|
|
41
41
|
...i?.formElements,
|
|
@@ -45,14 +45,14 @@ const ut = (e, i) => {
|
|
|
45
45
|
// State-specific overrides
|
|
46
46
|
}, re(I) || r.getState().setInitialStateOptions(I, y[I]);
|
|
47
47
|
}), r.getState().setInitialStates(g), r.getState().setCreatedState(g);
|
|
48
|
-
const
|
|
49
|
-
const [v] = ee(a?.componentId ??
|
|
48
|
+
const b = (I, a) => {
|
|
49
|
+
const [v] = ee(a?.componentId ?? Ee());
|
|
50
50
|
be({
|
|
51
51
|
stateKey: I,
|
|
52
52
|
options: a,
|
|
53
53
|
initialOptionsPart: y
|
|
54
54
|
});
|
|
55
|
-
const n = r.getState().cogsStateStore[I] || g[I], f = a?.modifyState ? a.modifyState(n) : n, [
|
|
55
|
+
const n = r.getState().cogsStateStore[I] || g[I], f = a?.modifyState ? a.modifyState(n) : n, [W, U] = Ze(
|
|
56
56
|
f,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -71,20 +71,20 @@ const ut = (e, i) => {
|
|
|
71
71
|
return U;
|
|
72
72
|
};
|
|
73
73
|
function w(I, a) {
|
|
74
|
-
be({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage &&
|
|
74
|
+
be({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Je(I, a), me(I);
|
|
75
75
|
}
|
|
76
|
-
return { useCogsState:
|
|
76
|
+
return { useCogsState: b, setCogsOptions: w };
|
|
77
77
|
}, {
|
|
78
78
|
setUpdaterState: ge,
|
|
79
79
|
setState: te,
|
|
80
80
|
getInitialOptions: re,
|
|
81
81
|
getKeyState: Ve,
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
82
|
+
getValidationErrors: He,
|
|
83
|
+
setStateLog: ze,
|
|
84
|
+
updateInitialStateGlobal: Ae,
|
|
85
|
+
addValidationError: Be,
|
|
86
86
|
removeValidationError: Z,
|
|
87
|
-
setServerSyncActions:
|
|
87
|
+
setServerSyncActions: qe
|
|
88
88
|
} = r.getState(), Ce = (e, i, S, g, y) => {
|
|
89
89
|
S?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
@@ -92,9 +92,9 @@ const ut = (e, i) => {
|
|
|
92
92
|
S.localStorage?.key,
|
|
93
93
|
g
|
|
94
94
|
);
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const w = `${g}-${i}-${
|
|
95
|
+
const b = X(S?.localStorage?.key) ? S.localStorage?.key(e) : S?.localStorage?.key;
|
|
96
|
+
if (b && g) {
|
|
97
|
+
const w = `${g}-${i}-${b}`;
|
|
98
98
|
let I;
|
|
99
99
|
try {
|
|
100
100
|
I = Se(w)?.lastSyncedWithServer;
|
|
@@ -104,7 +104,7 @@ const ut = (e, i) => {
|
|
|
104
104
|
state: e,
|
|
105
105
|
lastUpdated: Date.now(),
|
|
106
106
|
lastSyncedWithServer: y ?? I
|
|
107
|
-
}, v =
|
|
107
|
+
}, v = Le.serialize(a);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
w,
|
|
110
110
|
JSON.stringify(v.json)
|
|
@@ -118,28 +118,28 @@ const ut = (e, i) => {
|
|
|
118
118
|
} catch (i) {
|
|
119
119
|
return console.error("Error loading from localStorage:", i), null;
|
|
120
120
|
}
|
|
121
|
-
},
|
|
122
|
-
const S = r.getState().cogsStateStore[e], { sessionId: g } =
|
|
121
|
+
}, Je = (e, i) => {
|
|
122
|
+
const S = r.getState().cogsStateStore[e], { sessionId: g } = Pe(), y = X(i?.localStorage?.key) ? i.localStorage.key(S) : i?.localStorage?.key;
|
|
123
123
|
if (y && g) {
|
|
124
|
-
const
|
|
124
|
+
const b = Se(
|
|
125
125
|
`${g}-${e}-${y}`
|
|
126
126
|
);
|
|
127
|
-
if (
|
|
128
|
-
return te(e,
|
|
127
|
+
if (b && b.lastUpdated > (b.lastSyncedWithServer || 0))
|
|
128
|
+
return te(e, b.state), me(e), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, _e = (e, i, S, g, y, b) => {
|
|
132
132
|
const w = {
|
|
133
133
|
initialState: i,
|
|
134
134
|
updaterState: fe(
|
|
135
135
|
e,
|
|
136
136
|
g,
|
|
137
137
|
y,
|
|
138
|
-
|
|
138
|
+
b
|
|
139
139
|
),
|
|
140
140
|
state: S
|
|
141
141
|
};
|
|
142
|
-
|
|
142
|
+
Ae(e, w.initialState), ge(e, w.updaterState), te(e, w.state);
|
|
143
143
|
}, me = (e) => {
|
|
144
144
|
const i = r.getState().stateComponents.get(e);
|
|
145
145
|
if (!i) return;
|
|
@@ -149,7 +149,7 @@ const ut = (e, i) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
S.forEach((g) => g());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, ft = (e, i) => {
|
|
153
153
|
const S = r.getState().stateComponents.get(e);
|
|
154
154
|
if (S) {
|
|
155
155
|
const g = `${e}////${i}`, y = S.components.get(g);
|
|
@@ -157,7 +157,7 @@ const ut = (e, i) => {
|
|
|
157
157
|
return;
|
|
158
158
|
y && y.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Ye = (e, i, S, g) => {
|
|
161
161
|
switch (e) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
@@ -180,12 +180,12 @@ const ut = (e, i) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Ze(e, {
|
|
184
184
|
stateKey: i,
|
|
185
185
|
serverSync: S,
|
|
186
186
|
localStorage: g,
|
|
187
187
|
formElements: y,
|
|
188
|
-
reactiveDeps:
|
|
188
|
+
reactiveDeps: b,
|
|
189
189
|
reactiveType: w,
|
|
190
190
|
componentId: I,
|
|
191
191
|
initialState: a,
|
|
@@ -193,9 +193,9 @@ function Ye(e, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: f
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
196
|
+
const [W, U] = ee({}), { sessionId: j } = Pe();
|
|
197
197
|
let H = !i;
|
|
198
|
-
const [m] = ee(i ??
|
|
198
|
+
const [m] = ee(i ?? Ee()), l = r.getState().stateLog[m], le = J(/* @__PURE__ */ new Set()), Q = J(I ?? Ee()), _ = J(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
201
|
_.current = re(m) ?? null, oe(() => {
|
|
@@ -212,7 +212,7 @@ function Ye(e, {
|
|
|
212
212
|
}
|
|
213
213
|
}, [v]), oe(() => {
|
|
214
214
|
if (a) {
|
|
215
|
-
|
|
215
|
+
Ne(m, {
|
|
216
216
|
initialState: a
|
|
217
217
|
});
|
|
218
218
|
const t = _.current, s = t?.serverState?.id !== void 0 && t?.serverState?.status === "success" && t?.serverState?.data, c = r.getState().initialStateGlobal[m];
|
|
@@ -222,8 +222,8 @@ function Ye(e, {
|
|
|
222
222
|
const p = X(t?.localStorage?.key) ? t?.localStorage?.key(a) : t?.localStorage?.key;
|
|
223
223
|
p && j && (d = Se(`${j}-${m}-${p}`));
|
|
224
224
|
let E = a, A = !1;
|
|
225
|
-
const
|
|
226
|
-
s &&
|
|
225
|
+
const V = s ? Date.now() : 0, P = d?.lastUpdated || 0, M = d?.lastSyncedWithServer || 0;
|
|
226
|
+
s && V > P ? (E = t.serverState.data, A = !0) : d && P > M && (E = d.state, t?.localStorage?.onChange && t?.localStorage?.onChange(E)), r.getState().initializeShadowState(m, a), _e(
|
|
227
227
|
m,
|
|
228
228
|
a,
|
|
229
229
|
E,
|
|
@@ -238,7 +238,7 @@ function Ye(e, {
|
|
|
238
238
|
f?.data,
|
|
239
239
|
...n || []
|
|
240
240
|
]), ie(() => {
|
|
241
|
-
H &&
|
|
241
|
+
H && Ne(m, {
|
|
242
242
|
serverSync: S,
|
|
243
243
|
formElements: y,
|
|
244
244
|
initialState: a,
|
|
@@ -252,7 +252,7 @@ function Ye(e, {
|
|
|
252
252
|
forceUpdate: () => U({}),
|
|
253
253
|
paths: /* @__PURE__ */ new Set(),
|
|
254
254
|
deps: [],
|
|
255
|
-
depsFunction:
|
|
255
|
+
depsFunction: b || void 0,
|
|
256
256
|
reactiveType: w ?? ["component", "deps"]
|
|
257
257
|
}), r.getState().stateComponents.set(m, o), U({}), () => {
|
|
258
258
|
o && (o.components.delete(t), o.components.size === 0 && r.getState().stateComponents.delete(m));
|
|
@@ -267,26 +267,26 @@ function Ye(e, {
|
|
|
267
267
|
te(m, (d) => {
|
|
268
268
|
const p = X(t) ? t(d) : t, E = `${m}-${o.join(".")}`;
|
|
269
269
|
if (E) {
|
|
270
|
-
let
|
|
271
|
-
if ((!
|
|
272
|
-
const
|
|
270
|
+
let T = !1, C = h.signalDomElements.get(E);
|
|
271
|
+
if ((!C || C.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
|
|
272
|
+
const x = o.slice(0, -1), L = q(p, x);
|
|
273
273
|
if (Array.isArray(L)) {
|
|
274
|
-
|
|
275
|
-
const k = `${m}-${
|
|
276
|
-
|
|
274
|
+
T = !0;
|
|
275
|
+
const k = `${m}-${x.join(".")}`;
|
|
276
|
+
C = h.signalDomElements.get(k);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
279
|
+
if (C) {
|
|
280
|
+
const x = T ? q(p, o.slice(0, -1)) : q(p, o);
|
|
281
|
+
C.forEach(({ parentId: L, position: k, effect: F }) => {
|
|
282
282
|
const O = document.querySelector(
|
|
283
283
|
`[data-parent-id="${L}"]`
|
|
284
284
|
);
|
|
285
285
|
if (O) {
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
289
|
-
|
|
286
|
+
const $ = Array.from(O.childNodes);
|
|
287
|
+
if ($[k]) {
|
|
288
|
+
const N = F ? new Function("state", `return (${F})(state)`)(x) : x;
|
|
289
|
+
$[k].textContent = String(N);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
@@ -298,22 +298,22 @@ function Ye(e, {
|
|
|
298
298
|
const A = o.slice(0, o.length - 1);
|
|
299
299
|
s.updateType === "cut" && _.current?.validation?.key && Z(
|
|
300
300
|
_.current?.validation?.key + "." + A.join(".")
|
|
301
|
-
), s.updateType === "insert" && _.current?.validation?.key &&
|
|
301
|
+
), s.updateType === "insert" && _.current?.validation?.key && He(
|
|
302
302
|
_.current?.validation?.key + "." + A.join(".")
|
|
303
|
-
).filter(([
|
|
304
|
-
let L =
|
|
305
|
-
if (
|
|
306
|
-
let k =
|
|
307
|
-
Z(
|
|
303
|
+
).filter(([C, x]) => {
|
|
304
|
+
let L = C?.split(".").length;
|
|
305
|
+
if (C == A.join(".") && L == A.length - 1) {
|
|
306
|
+
let k = C + "." + A;
|
|
307
|
+
Z(C), Be(k, x);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
310
|
+
const V = h.stateComponents.get(m);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", V), V) {
|
|
312
|
+
const T = we(d, p), C = new Set(T), x = s.updateType === "update" ? o.join(".") : o.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
314
|
L,
|
|
315
315
|
k
|
|
316
|
-
] of
|
|
316
|
+
] of V.components.entries()) {
|
|
317
317
|
let F = !1;
|
|
318
318
|
const O = Array.isArray(k.reactiveType) ? k.reactiveType : [k.reactiveType || "component"];
|
|
319
319
|
if (console.log("component", k), !O.includes("none")) {
|
|
@@ -321,81 +321,81 @@ function Ye(e, {
|
|
|
321
321
|
k.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (O.includes("component") && ((k.paths.has(
|
|
325
|
-
for (const
|
|
326
|
-
let
|
|
324
|
+
if (O.includes("component") && ((k.paths.has(x) || k.paths.has("")) && (F = !0), !F))
|
|
325
|
+
for (const $ of C) {
|
|
326
|
+
let N = $;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (k.paths.has(
|
|
328
|
+
if (k.paths.has(N)) {
|
|
329
329
|
F = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
const D =
|
|
332
|
+
const D = N.lastIndexOf(".");
|
|
333
333
|
if (D !== -1) {
|
|
334
|
-
const R =
|
|
334
|
+
const R = N.substring(
|
|
335
335
|
0,
|
|
336
336
|
D
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
|
-
Number(
|
|
339
|
+
Number(N.substring(D + 1))
|
|
340
340
|
) && k.paths.has(R)) {
|
|
341
341
|
F = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
N = R;
|
|
345
345
|
} else
|
|
346
|
-
|
|
347
|
-
if (
|
|
346
|
+
N = "";
|
|
347
|
+
if (N === "")
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
350
|
if (F) break;
|
|
351
351
|
}
|
|
352
352
|
if (!F && O.includes("deps") && k.depsFunction) {
|
|
353
|
-
const
|
|
354
|
-
let
|
|
355
|
-
typeof
|
|
353
|
+
const $ = k.depsFunction(p);
|
|
354
|
+
let N = !1;
|
|
355
|
+
typeof $ == "boolean" ? $ && (N = !0) : B(k.deps, $) || (k.deps = $, N = !0), N && (F = !0);
|
|
356
356
|
}
|
|
357
357
|
F && k.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
const
|
|
362
|
-
o = o.map((
|
|
363
|
-
const
|
|
364
|
-
return
|
|
361
|
+
const P = Date.now();
|
|
362
|
+
o = o.map((T, C) => {
|
|
363
|
+
const x = o.slice(0, -1), L = q(p, x);
|
|
364
|
+
return C === o.length - 1 && ["insert", "cut"].includes(s.updateType) ? (L.length - 1).toString() : T;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue: M, newValue:
|
|
366
|
+
const { oldValue: M, newValue: G } = Ye(
|
|
367
367
|
s.updateType,
|
|
368
368
|
d,
|
|
369
369
|
p,
|
|
370
370
|
o
|
|
371
371
|
), z = {
|
|
372
|
-
timeStamp:
|
|
372
|
+
timeStamp: P,
|
|
373
373
|
stateKey: m,
|
|
374
374
|
path: o,
|
|
375
375
|
updateType: s.updateType,
|
|
376
376
|
status: "new",
|
|
377
377
|
oldValue: M,
|
|
378
|
-
newValue:
|
|
378
|
+
newValue: G
|
|
379
379
|
};
|
|
380
380
|
switch (s.updateType) {
|
|
381
381
|
case "update":
|
|
382
382
|
h.updateShadowAtPath(m, o, p);
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
h.insertShadowArrayElement(m,
|
|
385
|
+
const T = o.slice(0, -1);
|
|
386
|
+
h.insertShadowArrayElement(m, T, G);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
|
-
const
|
|
390
|
-
h.removeShadowArrayElement(m,
|
|
389
|
+
const C = o.slice(0, -1), x = parseInt(o[o.length - 1]);
|
|
390
|
+
h.removeShadowArrayElement(m, C, x);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
393
|
+
if (ze(m, (T) => {
|
|
394
|
+
const x = [...T ?? [], z].reduce((L, k) => {
|
|
395
395
|
const F = `${k.stateKey}:${JSON.stringify(k.path)}`, O = L.get(F);
|
|
396
396
|
return O ? (O.timeStamp = Math.max(O.timeStamp, k.timeStamp), O.newValue = k.newValue, O.oldValue = O.oldValue ?? k.oldValue, O.updateType = k.updateType) : L.set(F, { ...k }), L;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
|
-
return Array.from(
|
|
398
|
+
return Array.from(x.values());
|
|
399
399
|
}), Ce(
|
|
400
400
|
p,
|
|
401
401
|
m,
|
|
@@ -405,11 +405,11 @@ function Ye(e, {
|
|
|
405
405
|
updateLog: l,
|
|
406
406
|
update: z
|
|
407
407
|
}), _.current?.serverSync) {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
syncKey: typeof
|
|
411
|
-
rollBackState:
|
|
412
|
-
actionTimeStamp: Date.now() + (
|
|
408
|
+
const T = h.serverState[m], C = _.current?.serverSync;
|
|
409
|
+
qe(m, {
|
|
410
|
+
syncKey: typeof C.syncKey == "string" ? C.syncKey : C.syncKey({ state: p }),
|
|
411
|
+
rollBackState: T,
|
|
412
|
+
actionTimeStamp: Date.now() + (C.debounce ?? 3e3),
|
|
413
413
|
status: "waiting"
|
|
414
414
|
});
|
|
415
415
|
}
|
|
@@ -424,8 +424,8 @@ function Ye(e, {
|
|
|
424
424
|
Q.current,
|
|
425
425
|
j
|
|
426
426
|
)
|
|
427
|
-
), r.getState().cogsStateStore[m] || te(m, e), r.getState().initialStateGlobal[m] ||
|
|
428
|
-
const u =
|
|
427
|
+
), r.getState().cogsStateStore[m] || te(m, e), r.getState().initialStateGlobal[m] || Ae(m, e));
|
|
428
|
+
const u = pe(() => fe(
|
|
429
429
|
m,
|
|
430
430
|
ae,
|
|
431
431
|
Q.current,
|
|
@@ -435,12 +435,12 @@ function Ye(e, {
|
|
|
435
435
|
}
|
|
436
436
|
function fe(e, i, S, g) {
|
|
437
437
|
const y = /* @__PURE__ */ new Map();
|
|
438
|
-
let
|
|
438
|
+
let b = 0;
|
|
439
439
|
const w = (v) => {
|
|
440
440
|
const n = v.join(".");
|
|
441
441
|
for (const [f] of y)
|
|
442
442
|
(f === n || f.startsWith(n + ".")) && y.delete(f);
|
|
443
|
-
|
|
443
|
+
b++;
|
|
444
444
|
}, I = {
|
|
445
445
|
removeValidation: (v) => {
|
|
446
446
|
v?.validationKey && Z(v.validationKey);
|
|
@@ -449,24 +449,24 @@ function fe(e, i, S, g) {
|
|
|
449
449
|
const n = r.getState().getInitialOptions(e)?.validation;
|
|
450
450
|
n?.key && Z(n?.key), v?.validationKey && Z(v.validationKey);
|
|
451
451
|
const f = r.getState().initialStateGlobal[e];
|
|
452
|
-
r.getState().clearSelectedIndexesForState(e), y.clear(),
|
|
453
|
-
const
|
|
454
|
-
H && localStorage.removeItem(H), ge(e,
|
|
452
|
+
r.getState().clearSelectedIndexesForState(e), y.clear(), b++;
|
|
453
|
+
const W = a(f, []), U = re(e), j = X(U?.localStorage?.key) ? U?.localStorage?.key(f) : U?.localStorage?.key, H = `${g}-${e}-${j}`;
|
|
454
|
+
H && localStorage.removeItem(H), ge(e, W), te(e, f);
|
|
455
455
|
const m = r.getState().stateComponents.get(e);
|
|
456
456
|
return m && m.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
458
458
|
}), f;
|
|
459
459
|
},
|
|
460
460
|
updateInitialState: (v) => {
|
|
461
|
-
y.clear(),
|
|
461
|
+
y.clear(), b++;
|
|
462
462
|
const n = fe(
|
|
463
463
|
e,
|
|
464
464
|
i,
|
|
465
465
|
S,
|
|
466
466
|
g
|
|
467
|
-
), f = r.getState().initialStateGlobal[e],
|
|
468
|
-
return localStorage.getItem(j) && localStorage.removeItem(j),
|
|
469
|
-
|
|
467
|
+
), f = r.getState().initialStateGlobal[e], W = re(e), U = X(W?.localStorage?.key) ? W?.localStorage?.key(f) : W?.localStorage?.key, j = `${g}-${e}-${U}`;
|
|
468
|
+
return localStorage.getItem(j) && localStorage.removeItem(j), Re(() => {
|
|
469
|
+
Ae(e, v), r.getState().initializeShadowState(e, v), ge(e, n), te(e, v);
|
|
470
470
|
const H = r.getState().stateComponents.get(e);
|
|
471
471
|
H && H.components.forEach((m) => {
|
|
472
472
|
m.forceUpdate();
|
|
@@ -484,8 +484,8 @@ function fe(e, i, S, g) {
|
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(v, n = [], f) {
|
|
487
|
-
const
|
|
488
|
-
y.get(
|
|
487
|
+
const W = n.map(String).join(".");
|
|
488
|
+
y.get(W);
|
|
489
489
|
const U = function() {
|
|
490
490
|
return r().getNestedState(e, n);
|
|
491
491
|
};
|
|
@@ -540,7 +540,7 @@ function fe(e, i, S, g) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => we(
|
|
544
544
|
r.getState().cogsStateStore[e],
|
|
545
545
|
r.getState().initialStateGlobal[e]
|
|
546
546
|
);
|
|
@@ -625,50 +625,50 @@ function fe(e, i, S, g) {
|
|
|
625
625
|
} = t, d = J(null), [p, E] = ee({
|
|
626
626
|
startIndex: 0,
|
|
627
627
|
endIndex: 10
|
|
628
|
-
}), A = J(c),
|
|
628
|
+
}), A = J(c), V = J(!1), P = J(0), [M, G] = ee(0);
|
|
629
629
|
oe(() => r.getState().subscribeToShadowState(e, () => {
|
|
630
|
-
|
|
630
|
+
G((N) => N + 1);
|
|
631
631
|
}), [e]);
|
|
632
632
|
const z = r().getNestedState(
|
|
633
633
|
e,
|
|
634
634
|
n
|
|
635
|
-
),
|
|
636
|
-
const
|
|
637
|
-
let
|
|
635
|
+
), T = z.length, { totalHeight: C, positions: x } = pe(() => {
|
|
636
|
+
const $ = r.getState().getShadowMetadata(e, n) || [];
|
|
637
|
+
let N = 0;
|
|
638
638
|
const D = [];
|
|
639
|
-
for (let R = 0; R <
|
|
640
|
-
D[R] =
|
|
641
|
-
const Y =
|
|
642
|
-
|
|
639
|
+
for (let R = 0; R < T; R++) {
|
|
640
|
+
D[R] = N;
|
|
641
|
+
const Y = $[R]?.virtualizer?.itemHeight;
|
|
642
|
+
N += Y || o;
|
|
643
643
|
}
|
|
644
|
-
return { totalHeight:
|
|
644
|
+
return { totalHeight: N, positions: D };
|
|
645
645
|
}, [
|
|
646
|
-
|
|
646
|
+
T,
|
|
647
647
|
e,
|
|
648
648
|
n.join("."),
|
|
649
649
|
o,
|
|
650
650
|
M
|
|
651
|
-
]), L =
|
|
652
|
-
const
|
|
653
|
-
{ length:
|
|
654
|
-
(Y, ne) =>
|
|
651
|
+
]), L = pe(() => {
|
|
652
|
+
const $ = Math.max(0, p.startIndex), N = Math.min(T, p.endIndex), D = Array.from(
|
|
653
|
+
{ length: N - $ },
|
|
654
|
+
(Y, ne) => $ + ne
|
|
655
655
|
), R = D.map((Y) => z[Y]);
|
|
656
656
|
return a(R, n, {
|
|
657
657
|
...f,
|
|
658
658
|
validIndices: D
|
|
659
659
|
});
|
|
660
|
-
}, [p.startIndex, p.endIndex, z,
|
|
660
|
+
}, [p.startIndex, p.endIndex, z, T]);
|
|
661
661
|
ie(() => {
|
|
662
|
-
const
|
|
663
|
-
A.current &&
|
|
662
|
+
const $ = T > P.current;
|
|
663
|
+
A.current && $ && (console.log(
|
|
664
664
|
"PHASE 1: Auto-scroll needed. Setting range to render the last item."
|
|
665
665
|
), E({
|
|
666
|
-
startIndex: Math.max(0,
|
|
667
|
-
endIndex:
|
|
668
|
-
})),
|
|
669
|
-
}, [
|
|
670
|
-
const
|
|
671
|
-
if (
|
|
666
|
+
startIndex: Math.max(0, T - 10 - s),
|
|
667
|
+
endIndex: T
|
|
668
|
+
})), P.current = T;
|
|
669
|
+
}, [T]), ie(() => {
|
|
670
|
+
const $ = d.current, N = p.endIndex === T && T > 0;
|
|
671
|
+
if (!$ || !A.current || !N)
|
|
672
672
|
return;
|
|
673
673
|
console.log(
|
|
674
674
|
"PHASE 2: Range is at the end. Starting the measurement loop."
|
|
@@ -676,66 +676,66 @@ function fe(e, i, S, g) {
|
|
|
676
676
|
let D = 0;
|
|
677
677
|
const R = setInterval(() => {
|
|
678
678
|
D++, console.log(`LOOP ${D}: Checking last item...`);
|
|
679
|
-
const Y =
|
|
679
|
+
const Y = T - 1, K = (r.getState().getShadowMetadata(e, n) || [])[Y]?.virtualizer?.itemHeight || 0;
|
|
680
680
|
K > 0 ? (console.log(
|
|
681
681
|
`%cSUCCESS: Last item height is ${K}. Scrolling now.`,
|
|
682
682
|
"color: green; font-weight: bold;"
|
|
683
|
-
), clearInterval(R),
|
|
684
|
-
top:
|
|
683
|
+
), clearInterval(R), V.current = !0, $.scrollTo({
|
|
684
|
+
top: $.scrollHeight,
|
|
685
685
|
behavior: "smooth"
|
|
686
686
|
}), setTimeout(() => {
|
|
687
|
-
|
|
687
|
+
V.current = !1;
|
|
688
688
|
}, 1e3)) : D > 20 ? (console.error(
|
|
689
689
|
"LOOP TIMEOUT: Last item was never measured. Stopping loop."
|
|
690
690
|
), clearInterval(R)) : console.log("...WAITING. Height is not ready.");
|
|
691
691
|
}, 100);
|
|
692
692
|
return () => clearInterval(R);
|
|
693
|
-
}, [p.endIndex,
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
693
|
+
}, [p.endIndex, T, x]), oe(() => {
|
|
694
|
+
const $ = d.current;
|
|
695
|
+
if (!$) return;
|
|
696
696
|
console.log(
|
|
697
697
|
"DEPENDENCY CHANGE: Resetting scroll lock and initial view."
|
|
698
698
|
), A.current = c;
|
|
699
|
-
const
|
|
700
|
-
const { scrollTop: R, clientHeight: Y } =
|
|
701
|
-
let ne = 0, K =
|
|
699
|
+
const N = () => {
|
|
700
|
+
const { scrollTop: R, clientHeight: Y } = $;
|
|
701
|
+
let ne = 0, K = T - 1;
|
|
702
702
|
for (; ne <= K; ) {
|
|
703
|
-
const
|
|
704
|
-
|
|
703
|
+
const ve = Math.floor((ne + K) / 2);
|
|
704
|
+
x[ve] < R ? ne = ve + 1 : K = ve - 1;
|
|
705
705
|
}
|
|
706
|
-
const
|
|
707
|
-
let de =
|
|
708
|
-
const
|
|
709
|
-
for (; de <
|
|
706
|
+
const he = Math.max(0, K - s);
|
|
707
|
+
let de = he;
|
|
708
|
+
const Me = R + Y;
|
|
709
|
+
for (; de < T && x[de] < Me; )
|
|
710
710
|
de++;
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
});
|
|
711
|
+
const Te = Math.min(T, de + s);
|
|
712
|
+
console.log(
|
|
713
|
+
`RANGE UPDATE: Start: ${he}, End: ${Te}, Total: ${T}`
|
|
714
|
+
), E({ startIndex: he, endIndex: Te });
|
|
715
715
|
}, D = () => {
|
|
716
|
-
if (
|
|
717
|
-
|
|
716
|
+
if (V.current) return;
|
|
717
|
+
$.scrollHeight - $.scrollTop - $.clientHeight < 1 || (A.current = !1), N();
|
|
718
718
|
};
|
|
719
|
-
return
|
|
719
|
+
return $.addEventListener("scroll", D, {
|
|
720
720
|
passive: !0
|
|
721
|
-
}),
|
|
722
|
-
}, [...h]);
|
|
723
|
-
const k =
|
|
724
|
-
(
|
|
721
|
+
}), N(), () => $.removeEventListener("scroll", D);
|
|
722
|
+
}, [...h, T, x]);
|
|
723
|
+
const k = $e(
|
|
724
|
+
($ = "smooth") => {
|
|
725
725
|
d.current && (A.current = !0, d.current.scrollTo({
|
|
726
726
|
top: d.current.scrollHeight,
|
|
727
|
-
behavior:
|
|
727
|
+
behavior: $
|
|
728
728
|
}));
|
|
729
729
|
},
|
|
730
730
|
[]
|
|
731
|
-
), F =
|
|
732
|
-
(
|
|
733
|
-
d.current &&
|
|
734
|
-
top:
|
|
735
|
-
behavior:
|
|
731
|
+
), F = $e(
|
|
732
|
+
($, N = "smooth") => {
|
|
733
|
+
d.current && x[$] !== void 0 && (A.current = !1, d.current.scrollTo({
|
|
734
|
+
top: x[$],
|
|
735
|
+
behavior: N
|
|
736
736
|
}));
|
|
737
737
|
},
|
|
738
|
-
[
|
|
738
|
+
[x]
|
|
739
739
|
), O = {
|
|
740
740
|
outer: {
|
|
741
741
|
ref: d,
|
|
@@ -743,13 +743,13 @@ function fe(e, i, S, g) {
|
|
|
743
743
|
},
|
|
744
744
|
inner: {
|
|
745
745
|
style: {
|
|
746
|
-
height: `${
|
|
746
|
+
height: `${C}px`,
|
|
747
747
|
position: "relative"
|
|
748
748
|
}
|
|
749
749
|
},
|
|
750
750
|
list: {
|
|
751
751
|
style: {
|
|
752
|
-
transform: `translateY(${
|
|
752
|
+
transform: `translateY(${x[p.startIndex] || 0}px)`
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
};
|
|
@@ -791,19 +791,19 @@ function fe(e, i, S, g) {
|
|
|
791
791
|
const d = o[c], p = [...n, c.toString()], E = a(d, p, f);
|
|
792
792
|
return t(d, E, {
|
|
793
793
|
register: () => {
|
|
794
|
-
const [,
|
|
794
|
+
const [, V] = ee({}), P = `${S}-${n.join(".")}-${c}`;
|
|
795
795
|
ie(() => {
|
|
796
|
-
const M = `${e}////${
|
|
796
|
+
const M = `${e}////${P}`, G = r.getState().stateComponents.get(e) || {
|
|
797
797
|
components: /* @__PURE__ */ new Map()
|
|
798
798
|
};
|
|
799
|
-
return
|
|
800
|
-
forceUpdate: () =>
|
|
799
|
+
return G.components.set(M, {
|
|
800
|
+
forceUpdate: () => V({}),
|
|
801
801
|
paths: /* @__PURE__ */ new Set([p.join(".")])
|
|
802
|
-
}), r.getState().stateComponents.set(e,
|
|
802
|
+
}), r.getState().stateComponents.set(e, G), () => {
|
|
803
803
|
const z = r.getState().stateComponents.get(e);
|
|
804
804
|
z && z.components.delete(M);
|
|
805
805
|
};
|
|
806
|
-
}, [e,
|
|
806
|
+
}, [e, P]);
|
|
807
807
|
},
|
|
808
808
|
index: h,
|
|
809
809
|
originalIndex: c
|
|
@@ -827,7 +827,7 @@ function fe(e, i, S, g) {
|
|
|
827
827
|
);
|
|
828
828
|
});
|
|
829
829
|
if (l === "$stateMap")
|
|
830
|
-
return (t) => ce(
|
|
830
|
+
return (t) => ce(Xe, {
|
|
831
831
|
proxy: {
|
|
832
832
|
_stateKey: e,
|
|
833
833
|
_path: n,
|
|
@@ -841,7 +841,7 @@ function fe(e, i, S, g) {
|
|
|
841
841
|
const o = r.getState().getNestedState(e, n);
|
|
842
842
|
return Array.isArray(o) ? (f?.validIndices || Array.from({ length: o.length }, (c, h) => h)).map((c, h) => {
|
|
843
843
|
const d = o[c], p = [...n, c.toString()], E = a(d, p, f), A = `${S}-${n.join(".")}-${c}`;
|
|
844
|
-
return ce(
|
|
844
|
+
return ce(Ke, {
|
|
845
845
|
key: c,
|
|
846
846
|
stateKey: e,
|
|
847
847
|
itemComponentId: A,
|
|
@@ -861,7 +861,7 @@ function fe(e, i, S, g) {
|
|
|
861
861
|
if (l === "stateFlattenOn")
|
|
862
862
|
return (t) => {
|
|
863
863
|
const o = v;
|
|
864
|
-
y.clear(),
|
|
864
|
+
y.clear(), b++;
|
|
865
865
|
const s = o.flatMap(
|
|
866
866
|
(c) => c[t] ?? []
|
|
867
867
|
);
|
|
@@ -884,7 +884,7 @@ function fe(e, i, S, g) {
|
|
|
884
884
|
return a(s, c);
|
|
885
885
|
};
|
|
886
886
|
if (l === "insert")
|
|
887
|
-
return (t) => (w(n),
|
|
887
|
+
return (t) => (w(n), ye(i, t, n, e), a(
|
|
888
888
|
r.getState().getNestedState(e, n),
|
|
889
889
|
n
|
|
890
890
|
));
|
|
@@ -894,18 +894,18 @@ function fe(e, i, S, g) {
|
|
|
894
894
|
let d = null;
|
|
895
895
|
if (!c.some((E) => {
|
|
896
896
|
if (o) {
|
|
897
|
-
const
|
|
898
|
-
(
|
|
897
|
+
const V = o.every(
|
|
898
|
+
(P) => B(E[P], h[P])
|
|
899
899
|
);
|
|
900
|
-
return
|
|
900
|
+
return V && (d = E), V;
|
|
901
901
|
}
|
|
902
902
|
const A = B(E, h);
|
|
903
903
|
return A && (d = E), A;
|
|
904
904
|
}))
|
|
905
|
-
w(n),
|
|
905
|
+
w(n), ye(i, h, n, e);
|
|
906
906
|
else if (s && d) {
|
|
907
907
|
const E = s(d), A = c.map(
|
|
908
|
-
(
|
|
908
|
+
(V) => B(V, d) ? E : V
|
|
909
909
|
);
|
|
910
910
|
w(n), se(i, A, n);
|
|
911
911
|
}
|
|
@@ -926,7 +926,7 @@ function fe(e, i, S, g) {
|
|
|
926
926
|
if (l === "toggleByValue")
|
|
927
927
|
return (t) => {
|
|
928
928
|
const o = v.findIndex((s) => s === t);
|
|
929
|
-
o > -1 ? ue(i, n, e, o) :
|
|
929
|
+
o > -1 ? ue(i, n, e, o) : ye(i, t, n, e);
|
|
930
930
|
};
|
|
931
931
|
if (l === "stateFind")
|
|
932
932
|
return (t) => {
|
|
@@ -967,13 +967,13 @@ function fe(e, i, S, g) {
|
|
|
967
967
|
return r.getState().getNestedState(e, n);
|
|
968
968
|
};
|
|
969
969
|
if (l === "$derive")
|
|
970
|
-
return (u) =>
|
|
970
|
+
return (u) => xe({
|
|
971
971
|
_stateKey: e,
|
|
972
972
|
_path: n,
|
|
973
973
|
_effect: u.toString()
|
|
974
974
|
});
|
|
975
975
|
if (l === "$get")
|
|
976
|
-
return () =>
|
|
976
|
+
return () => xe({
|
|
977
977
|
_stateKey: e,
|
|
978
978
|
_path: n
|
|
979
979
|
});
|
|
@@ -1008,8 +1008,8 @@ function fe(e, i, S, g) {
|
|
|
1008
1008
|
if (n.length == 0) {
|
|
1009
1009
|
if (l === "applyJsonPatch")
|
|
1010
1010
|
return (u) => {
|
|
1011
|
-
const t = r.getState().cogsStateStore[e], s =
|
|
1012
|
-
|
|
1011
|
+
const t = r.getState().cogsStateStore[e], s = Ge(t, u).newDocument;
|
|
1012
|
+
_e(
|
|
1013
1013
|
e,
|
|
1014
1014
|
r.getState().initialStateGlobal[e],
|
|
1015
1015
|
s,
|
|
@@ -1019,55 +1019,55 @@ function fe(e, i, S, g) {
|
|
|
1019
1019
|
);
|
|
1020
1020
|
const c = r.getState().stateComponents.get(e);
|
|
1021
1021
|
if (c) {
|
|
1022
|
-
const h =
|
|
1022
|
+
const h = we(t, s), d = new Set(h);
|
|
1023
1023
|
for (const [
|
|
1024
1024
|
p,
|
|
1025
1025
|
E
|
|
1026
1026
|
] of c.components.entries()) {
|
|
1027
1027
|
let A = !1;
|
|
1028
|
-
const
|
|
1029
|
-
if (!
|
|
1030
|
-
if (
|
|
1028
|
+
const V = Array.isArray(E.reactiveType) ? E.reactiveType : [E.reactiveType || "component"];
|
|
1029
|
+
if (!V.includes("none")) {
|
|
1030
|
+
if (V.includes("all")) {
|
|
1031
1031
|
E.forceUpdate();
|
|
1032
1032
|
continue;
|
|
1033
1033
|
}
|
|
1034
|
-
if (
|
|
1035
|
-
for (const
|
|
1036
|
-
if (E.paths.has(
|
|
1034
|
+
if (V.includes("component") && (E.paths.has("") && (A = !0), !A))
|
|
1035
|
+
for (const P of d) {
|
|
1036
|
+
if (E.paths.has(P)) {
|
|
1037
1037
|
A = !0;
|
|
1038
1038
|
break;
|
|
1039
1039
|
}
|
|
1040
|
-
let M =
|
|
1040
|
+
let M = P.lastIndexOf(".");
|
|
1041
1041
|
for (; M !== -1; ) {
|
|
1042
|
-
const
|
|
1043
|
-
if (E.paths.has(
|
|
1042
|
+
const G = P.substring(0, M);
|
|
1043
|
+
if (E.paths.has(G)) {
|
|
1044
1044
|
A = !0;
|
|
1045
1045
|
break;
|
|
1046
1046
|
}
|
|
1047
|
-
const z =
|
|
1047
|
+
const z = P.substring(
|
|
1048
1048
|
M + 1
|
|
1049
1049
|
);
|
|
1050
1050
|
if (!isNaN(Number(z))) {
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
const
|
|
1051
|
+
const T = G.lastIndexOf(".");
|
|
1052
|
+
if (T !== -1) {
|
|
1053
|
+
const C = G.substring(
|
|
1054
1054
|
0,
|
|
1055
|
-
|
|
1055
|
+
T
|
|
1056
1056
|
);
|
|
1057
|
-
if (E.paths.has(
|
|
1057
|
+
if (E.paths.has(C)) {
|
|
1058
1058
|
A = !0;
|
|
1059
1059
|
break;
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
|
-
M =
|
|
1063
|
+
M = G.lastIndexOf(".");
|
|
1064
1064
|
}
|
|
1065
1065
|
if (A) break;
|
|
1066
1066
|
}
|
|
1067
|
-
if (!A &&
|
|
1068
|
-
const
|
|
1067
|
+
if (!A && V.includes("deps") && E.depsFunction) {
|
|
1068
|
+
const P = E.depsFunction(s);
|
|
1069
1069
|
let M = !1;
|
|
1070
|
-
typeof
|
|
1070
|
+
typeof P == "boolean" ? P && (M = !0) : B(E.deps, P) || (E.deps = P, M = !0), M && (A = !0);
|
|
1071
1071
|
}
|
|
1072
1072
|
A && E.forceUpdate();
|
|
1073
1073
|
}
|
|
@@ -1101,7 +1101,7 @@ function fe(e, i, S, g) {
|
|
|
1101
1101
|
if (l === "getComponents")
|
|
1102
1102
|
return () => r().stateComponents.get(e);
|
|
1103
1103
|
if (l === "getAllFormRefs")
|
|
1104
|
-
return () =>
|
|
1104
|
+
return () => ke.getState().getFormRefsByStateKey(e);
|
|
1105
1105
|
if (l === "_initialState")
|
|
1106
1106
|
return r.getState().initialStateGlobal[e];
|
|
1107
1107
|
if (l === "_serverState")
|
|
@@ -1114,13 +1114,13 @@ function fe(e, i, S, g) {
|
|
|
1114
1114
|
if (l === "removeValidation") return I.removeValidation;
|
|
1115
1115
|
}
|
|
1116
1116
|
if (l === "getFormRef")
|
|
1117
|
-
return () =>
|
|
1117
|
+
return () => ke.getState().getFormRef(e + "." + n.join("."));
|
|
1118
1118
|
if (l === "validationWrapper")
|
|
1119
1119
|
return ({
|
|
1120
1120
|
children: u,
|
|
1121
1121
|
hideMessage: t
|
|
1122
|
-
}) => /* @__PURE__ */
|
|
1123
|
-
|
|
1122
|
+
}) => /* @__PURE__ */ Ie(
|
|
1123
|
+
Fe,
|
|
1124
1124
|
{
|
|
1125
1125
|
formOpts: t ? { validation: { message: "" } } : void 0,
|
|
1126
1126
|
path: n,
|
|
@@ -1136,7 +1136,7 @@ function fe(e, i, S, g) {
|
|
|
1136
1136
|
if (l === "update")
|
|
1137
1137
|
return (u, t) => {
|
|
1138
1138
|
if (t?.debounce)
|
|
1139
|
-
|
|
1139
|
+
je(() => {
|
|
1140
1140
|
se(i, u, n, "");
|
|
1141
1141
|
const o = r.getState().getNestedState(e, n);
|
|
1142
1142
|
t?.afterUpdate && t.afterUpdate(o);
|
|
@@ -1149,8 +1149,8 @@ function fe(e, i, S, g) {
|
|
|
1149
1149
|
w(n);
|
|
1150
1150
|
};
|
|
1151
1151
|
if (l === "formElement")
|
|
1152
|
-
return (u, t) => /* @__PURE__ */
|
|
1153
|
-
|
|
1152
|
+
return (u, t) => /* @__PURE__ */ Ie(
|
|
1153
|
+
De,
|
|
1154
1154
|
{
|
|
1155
1155
|
setState: i,
|
|
1156
1156
|
stateKey: e,
|
|
@@ -1163,19 +1163,19 @@ function fe(e, i, S, g) {
|
|
|
1163
1163
|
return a(ae, _, f);
|
|
1164
1164
|
}
|
|
1165
1165
|
}, H = new Proxy(U, j);
|
|
1166
|
-
return y.set(
|
|
1166
|
+
return y.set(W, {
|
|
1167
1167
|
proxy: H,
|
|
1168
|
-
stateVersion:
|
|
1168
|
+
stateVersion: b
|
|
1169
1169
|
}), H;
|
|
1170
1170
|
}
|
|
1171
1171
|
return a(
|
|
1172
1172
|
r.getState().getNestedState(e, [])
|
|
1173
1173
|
);
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1176
|
-
return ce(
|
|
1175
|
+
function xe(e) {
|
|
1176
|
+
return ce(Qe, { proxy: e });
|
|
1177
1177
|
}
|
|
1178
|
-
function
|
|
1178
|
+
function Xe({
|
|
1179
1179
|
proxy: e,
|
|
1180
1180
|
rebuildStateShape: i
|
|
1181
1181
|
}) {
|
|
@@ -1184,10 +1184,10 @@ function Ze({
|
|
|
1184
1184
|
S,
|
|
1185
1185
|
e._path
|
|
1186
1186
|
).stateMapNoRender(
|
|
1187
|
-
(y,
|
|
1187
|
+
(y, b, w, I, a) => e._mapFn(y, b, w, I, a)
|
|
1188
1188
|
) : null;
|
|
1189
1189
|
}
|
|
1190
|
-
function
|
|
1190
|
+
function Qe({
|
|
1191
1191
|
proxy: e
|
|
1192
1192
|
}) {
|
|
1193
1193
|
const i = J(null), S = `${e._stateKey}-${e._path.join(".")}`;
|
|
@@ -1218,16 +1218,16 @@ function Xe({
|
|
|
1218
1218
|
else
|
|
1219
1219
|
f = n;
|
|
1220
1220
|
f !== null && typeof f == "object" && (f = JSON.stringify(f));
|
|
1221
|
-
const
|
|
1222
|
-
g.replaceWith(
|
|
1221
|
+
const W = document.createTextNode(String(f));
|
|
1222
|
+
g.replaceWith(W);
|
|
1223
1223
|
}, [e._stateKey, e._path.join("."), e._effect]), ce("span", {
|
|
1224
1224
|
ref: i,
|
|
1225
1225
|
style: { display: "none" },
|
|
1226
1226
|
"data-signal-id": S
|
|
1227
1227
|
});
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1230
|
-
const i =
|
|
1229
|
+
function St(e) {
|
|
1230
|
+
const i = Oe(
|
|
1231
1231
|
(S) => {
|
|
1232
1232
|
const g = r.getState().stateComponents.get(e._stateKey) || {
|
|
1233
1233
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1241,13 +1241,13 @@ function ft(e) {
|
|
|
1241
1241
|
);
|
|
1242
1242
|
return ce("text", {}, String(i));
|
|
1243
1243
|
}
|
|
1244
|
-
function
|
|
1244
|
+
function Ke({
|
|
1245
1245
|
stateKey: e,
|
|
1246
1246
|
itemComponentId: i,
|
|
1247
1247
|
itemPath: S,
|
|
1248
1248
|
children: g
|
|
1249
1249
|
}) {
|
|
1250
|
-
const [, y] = ee({}), [
|
|
1250
|
+
const [, y] = ee({}), [b, w] = We(), I = J(null);
|
|
1251
1251
|
return oe(() => {
|
|
1252
1252
|
w.height > 0 && w.height !== I.current && (I.current = w.height, r.getState().setShadowMetadata(e, S, {
|
|
1253
1253
|
virtualizer: {
|
|
@@ -1265,14 +1265,14 @@ function Qe({
|
|
|
1265
1265
|
const n = r.getState().stateComponents.get(e);
|
|
1266
1266
|
n && n.components.delete(a);
|
|
1267
1267
|
};
|
|
1268
|
-
}, [e, i, S.join(".")]), /* @__PURE__ */
|
|
1268
|
+
}, [e, i, S.join(".")]), /* @__PURE__ */ Ie("div", { ref: b, children: g });
|
|
1269
1269
|
}
|
|
1270
1270
|
export {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1271
|
+
xe as $cogsSignal,
|
|
1272
|
+
St as $cogsSignalStore,
|
|
1273
|
+
ut as addStateOptions,
|
|
1274
|
+
gt as createCogsState,
|
|
1275
|
+
ft as notifyComponent,
|
|
1276
|
+
Ze as useCogsStateFn
|
|
1277
1277
|
};
|
|
1278
1278
|
//# sourceMappingURL=CogsState.jsx.map
|