cogsbox-state 0.5.425 → 0.5.427
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 +521 -520
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Functions.d.ts +4 -3
- package/dist/Functions.jsx.map +1 -1
- package/dist/store.d.ts +21 -8
- package/dist/store.js.map +1 -1
- package/dist/useValidateZodPath.d.ts +1 -1
- package/package.json +2 -1
- package/src/CogsState.tsx +38 -21
- package/src/Functions.tsx +8 -8
- package/src/store.ts +33 -22
package/dist/CogsState.jsx
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import Ht from "
|
|
7
|
-
import
|
|
2
|
+
import { jsx as At } from "react/jsx-runtime";
|
|
3
|
+
import { ulid as Dt } from "ulid";
|
|
4
|
+
import { useState as st, useRef as J, useEffect as rt, useLayoutEffect as Ct, useMemo as Et, createElement as ut, useSyncExternalStore as Ut, startTransition as Ft, useCallback as mt } from "react";
|
|
5
|
+
import { transformStateFunc as Lt, isDeepEqual as Y, isFunction as et, getNestedValue as Z, getDifferences as Tt, debounce as Gt } from "./utility.js";
|
|
6
|
+
import { pushFunc as pt, updateFn as dt, cutFunc as St, ValidationWrapper as Wt, FormControlComponent as Ht } from "./Functions.jsx";
|
|
7
|
+
import zt from "superjson";
|
|
8
|
+
import { v4 as kt } from "uuid";
|
|
8
9
|
import "zod";
|
|
9
10
|
import { getGlobalStore as r, formRefStore as bt } from "./store.js";
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
11
|
+
import { useCogsConfig as _t } from "./CogsStateClient.jsx";
|
|
12
|
+
import { applyPatch as Bt } from "fast-json-patch";
|
|
13
|
+
import qt from "react-use-measure";
|
|
13
14
|
function Vt(t, i) {
|
|
14
|
-
const
|
|
15
|
-
|
|
15
|
+
const S = r.getState().getInitialOptions, f = r.getState().setInitialStateOptions, h = S(t) || {};
|
|
16
|
+
f(t, {
|
|
16
17
|
...h,
|
|
17
18
|
...i
|
|
18
19
|
});
|
|
@@ -20,22 +21,22 @@ function Vt(t, i) {
|
|
|
20
21
|
function $t({
|
|
21
22
|
stateKey: t,
|
|
22
23
|
options: i,
|
|
23
|
-
initialOptionsPart:
|
|
24
|
+
initialOptionsPart: S
|
|
24
25
|
}) {
|
|
25
|
-
const
|
|
26
|
+
const f = at(t) || {}, h = S[t] || {}, b = r.getState().setInitialStateOptions, p = { ...h, ...f };
|
|
26
27
|
let y = !1;
|
|
27
28
|
if (i)
|
|
28
29
|
for (const s in i)
|
|
29
30
|
p.hasOwnProperty(s) ? (s == "localStorage" && i[s] && p[s].key !== i[s]?.key && (y = !0, p[s] = i[s]), s == "initialState" && i[s] && p[s] !== i[s] && // Different references
|
|
30
31
|
!Y(p[s], i[s]) && (y = !0, p[s] = i[s])) : (y = !0, p[s] = i[s]);
|
|
31
|
-
y &&
|
|
32
|
+
y && b(t, p);
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
return { initialState: t, formElements: i, validation:
|
|
34
|
+
function me(t, { formElements: i, validation: S }) {
|
|
35
|
+
return { initialState: t, formElements: i, validation: S };
|
|
35
36
|
}
|
|
36
|
-
const
|
|
37
|
-
let
|
|
38
|
-
const [
|
|
37
|
+
const he = (t, i) => {
|
|
38
|
+
let S = t;
|
|
39
|
+
const [f, h] = Lt(S);
|
|
39
40
|
(Object.keys(h).length > 0 || i && Object.keys(i).length > 0) && Object.keys(h).forEach((y) => {
|
|
40
41
|
h[y] = h[y] || {}, h[y].formElements = {
|
|
41
42
|
...i?.formElements,
|
|
@@ -43,17 +44,17 @@ const Se = (t, i) => {
|
|
|
43
44
|
...i?.validation,
|
|
44
45
|
...h[y].formElements || {}
|
|
45
46
|
// State-specific overrides
|
|
46
|
-
},
|
|
47
|
-
}), r.getState().setInitialStates(
|
|
48
|
-
const
|
|
49
|
-
const [m] =
|
|
47
|
+
}, at(y) || r.getState().setInitialStateOptions(y, h[y]);
|
|
48
|
+
}), r.getState().setInitialStates(f), r.getState().setCreatedState(f);
|
|
49
|
+
const b = (y, s) => {
|
|
50
|
+
const [m] = st(s?.componentId ?? kt());
|
|
50
51
|
$t({
|
|
51
52
|
stateKey: y,
|
|
52
53
|
options: s,
|
|
53
54
|
initialOptionsPart: h
|
|
54
55
|
});
|
|
55
|
-
const n = r.getState().cogsStateStore[y] ||
|
|
56
|
-
|
|
56
|
+
const n = r.getState().cogsStateStore[y] || f[y], u = s?.modifyState ? s.modifyState(n) : n, [G, R] = Kt(
|
|
57
|
+
u,
|
|
57
58
|
{
|
|
58
59
|
stateKey: y,
|
|
59
60
|
syncUpdate: s?.syncUpdate,
|
|
@@ -68,49 +69,49 @@ const Se = (t, i) => {
|
|
|
68
69
|
serverState: s?.serverState
|
|
69
70
|
}
|
|
70
71
|
);
|
|
71
|
-
return
|
|
72
|
+
return R;
|
|
72
73
|
};
|
|
73
74
|
function p(y, s) {
|
|
74
|
-
$t({ stateKey: y, options: s, initialOptionsPart: h }), s.localStorage &&
|
|
75
|
+
$t({ stateKey: y, options: s, initialOptionsPart: h }), s.localStorage && Xt(y, s), ft(y);
|
|
75
76
|
}
|
|
76
|
-
return { useCogsState:
|
|
77
|
+
return { useCogsState: b, setCogsOptions: p };
|
|
77
78
|
}, {
|
|
78
|
-
setUpdaterState:
|
|
79
|
+
setUpdaterState: ht,
|
|
79
80
|
setState: ot,
|
|
80
|
-
getInitialOptions:
|
|
81
|
-
getKeyState:
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
81
|
+
getInitialOptions: at,
|
|
82
|
+
getKeyState: Rt,
|
|
83
|
+
getValidationErrors: Jt,
|
|
84
|
+
setStateLog: Yt,
|
|
85
|
+
updateInitialStateGlobal: xt,
|
|
86
|
+
addValidationError: Mt,
|
|
86
87
|
removeValidationError: Q,
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = r.getState(), Nt = (t, i,
|
|
89
|
-
|
|
88
|
+
setServerSyncActions: Zt
|
|
89
|
+
} = r.getState(), Nt = (t, i, S, f, h) => {
|
|
90
|
+
S?.log && console.log(
|
|
90
91
|
"saving to localstorage",
|
|
91
92
|
i,
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
S.localStorage?.key,
|
|
94
|
+
f
|
|
94
95
|
);
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const p = `${
|
|
96
|
+
const b = et(S?.localStorage?.key) ? S.localStorage?.key(t) : S?.localStorage?.key;
|
|
97
|
+
if (b && f) {
|
|
98
|
+
const p = `${f}-${i}-${b}`;
|
|
98
99
|
let y;
|
|
99
100
|
try {
|
|
100
|
-
y =
|
|
101
|
+
y = It(p)?.lastSyncedWithServer;
|
|
101
102
|
} catch {
|
|
102
103
|
}
|
|
103
104
|
const s = {
|
|
104
105
|
state: t,
|
|
105
106
|
lastUpdated: Date.now(),
|
|
106
107
|
lastSyncedWithServer: h ?? y
|
|
107
|
-
}, m =
|
|
108
|
+
}, m = zt.serialize(s);
|
|
108
109
|
window.localStorage.setItem(
|
|
109
110
|
p,
|
|
110
111
|
JSON.stringify(m.json)
|
|
111
112
|
);
|
|
112
113
|
}
|
|
113
|
-
},
|
|
114
|
+
}, It = (t) => {
|
|
114
115
|
if (!t) return null;
|
|
115
116
|
try {
|
|
116
117
|
const i = window.localStorage.getItem(t);
|
|
@@ -118,61 +119,61 @@ const Se = (t, i) => {
|
|
|
118
119
|
} catch (i) {
|
|
119
120
|
return console.error("Error loading from localStorage:", i), null;
|
|
120
121
|
}
|
|
121
|
-
},
|
|
122
|
-
const
|
|
123
|
-
if (h &&
|
|
124
|
-
const
|
|
125
|
-
`${
|
|
122
|
+
}, Xt = (t, i) => {
|
|
123
|
+
const S = r.getState().cogsStateStore[t], { sessionId: f } = _t(), h = et(i?.localStorage?.key) ? i.localStorage.key(S) : i?.localStorage?.key;
|
|
124
|
+
if (h && f) {
|
|
125
|
+
const b = It(
|
|
126
|
+
`${f}-${t}-${h}`
|
|
126
127
|
);
|
|
127
|
-
if (
|
|
128
|
-
return ot(t,
|
|
128
|
+
if (b && b.lastUpdated > (b.lastSyncedWithServer || 0))
|
|
129
|
+
return ot(t, b.state), ft(t), !0;
|
|
129
130
|
}
|
|
130
131
|
return !1;
|
|
131
|
-
},
|
|
132
|
+
}, Ot = (t, i, S, f, h, b) => {
|
|
132
133
|
const p = {
|
|
133
134
|
initialState: i,
|
|
134
|
-
updaterState:
|
|
135
|
+
updaterState: yt(
|
|
135
136
|
t,
|
|
136
|
-
|
|
137
|
+
f,
|
|
137
138
|
h,
|
|
138
|
-
|
|
139
|
+
b
|
|
139
140
|
),
|
|
140
|
-
state:
|
|
141
|
+
state: S
|
|
141
142
|
};
|
|
142
|
-
|
|
143
|
-
},
|
|
143
|
+
xt(t, p.initialState), ht(t, p.updaterState), ot(t, p.state);
|
|
144
|
+
}, ft = (t) => {
|
|
144
145
|
const i = r.getState().stateComponents.get(t);
|
|
145
146
|
if (!i) return;
|
|
146
|
-
const
|
|
147
|
-
i.components.forEach((
|
|
148
|
-
(
|
|
147
|
+
const S = /* @__PURE__ */ new Set();
|
|
148
|
+
i.components.forEach((f) => {
|
|
149
|
+
(f ? Array.isArray(f.reactiveType) ? f.reactiveType : [f.reactiveType || "component"] : null)?.includes("none") || S.add(() => f.forceUpdate());
|
|
149
150
|
}), queueMicrotask(() => {
|
|
150
|
-
|
|
151
|
+
S.forEach((f) => f());
|
|
151
152
|
});
|
|
152
|
-
},
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
const
|
|
153
|
+
}, ye = (t, i) => {
|
|
154
|
+
const S = r.getState().stateComponents.get(t);
|
|
155
|
+
if (S) {
|
|
156
|
+
const f = `${t}////${i}`, h = S.components.get(f);
|
|
156
157
|
if ((h ? Array.isArray(h.reactiveType) ? h.reactiveType : [h.reactiveType || "component"] : null)?.includes("none"))
|
|
157
158
|
return;
|
|
158
159
|
h && h.forceUpdate();
|
|
159
160
|
}
|
|
160
|
-
},
|
|
161
|
+
}, Qt = (t, i, S, f) => {
|
|
161
162
|
switch (t) {
|
|
162
163
|
case "update":
|
|
163
164
|
return {
|
|
164
|
-
oldValue: Z(i,
|
|
165
|
-
newValue: Z(
|
|
165
|
+
oldValue: Z(i, f),
|
|
166
|
+
newValue: Z(S, f)
|
|
166
167
|
};
|
|
167
168
|
case "insert":
|
|
168
169
|
return {
|
|
169
170
|
oldValue: null,
|
|
170
171
|
// or undefined
|
|
171
|
-
newValue: Z(
|
|
172
|
+
newValue: Z(S, f)
|
|
172
173
|
};
|
|
173
174
|
case "cut":
|
|
174
175
|
return {
|
|
175
|
-
oldValue: Z(i,
|
|
176
|
+
oldValue: Z(i, f),
|
|
176
177
|
newValue: null
|
|
177
178
|
// or undefined
|
|
178
179
|
};
|
|
@@ -180,27 +181,27 @@ const Se = (t, i) => {
|
|
|
180
181
|
return { oldValue: null, newValue: null };
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
|
-
function
|
|
184
|
+
function Kt(t, {
|
|
184
185
|
stateKey: i,
|
|
185
|
-
serverSync:
|
|
186
|
-
localStorage:
|
|
186
|
+
serverSync: S,
|
|
187
|
+
localStorage: f,
|
|
187
188
|
formElements: h,
|
|
188
|
-
reactiveDeps:
|
|
189
|
+
reactiveDeps: b,
|
|
189
190
|
reactiveType: p,
|
|
190
191
|
componentId: y,
|
|
191
192
|
initialState: s,
|
|
192
193
|
syncUpdate: m,
|
|
193
194
|
dependencies: n,
|
|
194
|
-
serverState:
|
|
195
|
+
serverState: u
|
|
195
196
|
} = {}) {
|
|
196
|
-
const [
|
|
197
|
-
let
|
|
198
|
-
const [
|
|
197
|
+
const [G, R] = st({}), { sessionId: L } = _t();
|
|
198
|
+
let z = !i;
|
|
199
|
+
const [g] = st(i ?? kt()), c = r.getState().stateLog[g], gt = J(/* @__PURE__ */ new Set()), nt = J(y ?? kt()), j = J(
|
|
199
200
|
null
|
|
200
201
|
);
|
|
201
|
-
|
|
202
|
-
if (m && m.stateKey ===
|
|
203
|
-
ot(
|
|
202
|
+
j.current = at(g) ?? null, rt(() => {
|
|
203
|
+
if (m && m.stateKey === g && m.path?.[0]) {
|
|
204
|
+
ot(g, (o) => ({
|
|
204
205
|
...o,
|
|
205
206
|
[m.path[0]]: m.newValue
|
|
206
207
|
}));
|
|
@@ -212,235 +213,235 @@ function Qt(t, {
|
|
|
212
213
|
}
|
|
213
214
|
}, [m]), rt(() => {
|
|
214
215
|
if (s) {
|
|
215
|
-
Vt(
|
|
216
|
+
Vt(g, {
|
|
216
217
|
initialState: s
|
|
217
218
|
});
|
|
218
|
-
const e =
|
|
219
|
+
const e = j.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, d = r.getState().initialStateGlobal[g];
|
|
219
220
|
if (!(d && !Y(d, s) || !d) && !a)
|
|
220
221
|
return;
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
let
|
|
225
|
-
const
|
|
226
|
-
a &&
|
|
227
|
-
|
|
222
|
+
let I = null;
|
|
223
|
+
const E = et(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
|
|
224
|
+
E && L && (I = It(`${L}-${g}-${E}`));
|
|
225
|
+
let A = s, k = !1;
|
|
226
|
+
const P = a ? Date.now() : 0, $ = I?.lastUpdated || 0, O = I?.lastSyncedWithServer || 0;
|
|
227
|
+
a && P > $ ? (A = e.serverState.data, k = !0) : I && $ > O && (A = I.state, e?.localStorage?.onChange && e?.localStorage?.onChange(A)), r.getState().initializeShadowState(g, s), Ot(
|
|
228
|
+
g,
|
|
228
229
|
s,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
), k &&
|
|
230
|
+
A,
|
|
231
|
+
it,
|
|
232
|
+
nt.current,
|
|
233
|
+
L
|
|
234
|
+
), k && E && L && Nt(A, g, e, L, Date.now()), ft(g), (Array.isArray(p) ? p : [p || "component"]).includes("none") || R({});
|
|
234
235
|
}
|
|
235
236
|
}, [
|
|
236
237
|
s,
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
u?.status,
|
|
239
|
+
u?.data,
|
|
239
240
|
...n || []
|
|
240
241
|
]), Ct(() => {
|
|
241
|
-
|
|
242
|
-
serverSync:
|
|
242
|
+
z && Vt(g, {
|
|
243
|
+
serverSync: S,
|
|
243
244
|
formElements: h,
|
|
244
245
|
initialState: s,
|
|
245
|
-
localStorage:
|
|
246
|
-
middleware:
|
|
246
|
+
localStorage: f,
|
|
247
|
+
middleware: j.current?.middleware
|
|
247
248
|
});
|
|
248
|
-
const e = `${
|
|
249
|
+
const e = `${g}////${nt.current}`, o = r.getState().stateComponents.get(g) || {
|
|
249
250
|
components: /* @__PURE__ */ new Map()
|
|
250
251
|
};
|
|
251
252
|
return o.components.set(e, {
|
|
252
|
-
forceUpdate: () =>
|
|
253
|
+
forceUpdate: () => R({}),
|
|
253
254
|
paths: /* @__PURE__ */ new Set(),
|
|
254
255
|
deps: [],
|
|
255
|
-
depsFunction:
|
|
256
|
+
depsFunction: b || void 0,
|
|
256
257
|
reactiveType: p ?? ["component", "deps"]
|
|
257
|
-
}), r.getState().stateComponents.set(
|
|
258
|
-
o && (o.components.delete(e), o.components.size === 0 && r.getState().stateComponents.delete(
|
|
258
|
+
}), r.getState().stateComponents.set(g, o), R({}), () => {
|
|
259
|
+
o && (o.components.delete(e), o.components.size === 0 && r.getState().stateComponents.delete(g));
|
|
259
260
|
};
|
|
260
261
|
}, []);
|
|
261
|
-
const
|
|
262
|
+
const it = (e, o, a, d) => {
|
|
262
263
|
if (Array.isArray(o)) {
|
|
263
|
-
const
|
|
264
|
-
gt.current.add(
|
|
264
|
+
const I = `${g}-${o.join(".")}`;
|
|
265
|
+
gt.current.add(I);
|
|
265
266
|
}
|
|
266
|
-
const
|
|
267
|
-
ot(
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
let
|
|
271
|
-
if ((!
|
|
272
|
-
const
|
|
273
|
-
if (Array.isArray(
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
267
|
+
const v = r.getState();
|
|
268
|
+
ot(g, (I) => {
|
|
269
|
+
const E = et(e) ? e(I) : e, A = `${g}-${o.join(".")}`;
|
|
270
|
+
if (A) {
|
|
271
|
+
let C = !1, w = v.signalDomElements.get(A);
|
|
272
|
+
if ((!w || w.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
|
|
273
|
+
const D = o.slice(0, -1), V = Z(E, D);
|
|
274
|
+
if (Array.isArray(V)) {
|
|
275
|
+
C = !0;
|
|
276
|
+
const T = `${g}-${D.join(".")}`;
|
|
277
|
+
w = v.signalDomElements.get(T);
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
`[data-parent-id="${
|
|
280
|
+
if (w) {
|
|
281
|
+
const D = C ? Z(E, o.slice(0, -1)) : Z(E, o);
|
|
282
|
+
w.forEach(({ parentId: V, position: T, effect: U }) => {
|
|
283
|
+
const F = document.querySelector(
|
|
284
|
+
`[data-parent-id="${V}"]`
|
|
284
285
|
);
|
|
285
|
-
if (
|
|
286
|
-
const B = Array.from(
|
|
287
|
-
if (B[
|
|
288
|
-
const
|
|
289
|
-
B[
|
|
286
|
+
if (F) {
|
|
287
|
+
const B = Array.from(F.childNodes);
|
|
288
|
+
if (B[T]) {
|
|
289
|
+
const W = U ? new Function("state", `return (${U})(state)`)(D) : D;
|
|
290
|
+
B[T].textContent = String(W);
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
|
-
console.log("shadowState",
|
|
296
|
-
(d ||
|
|
296
|
+
console.log("shadowState", v.shadowStateStore), a.updateType === "update" && (d || j.current?.validation?.key) && o && Q(
|
|
297
|
+
(d || j.current?.validation?.key) + "." + o.join(".")
|
|
297
298
|
);
|
|
298
299
|
const k = o.slice(0, o.length - 1);
|
|
299
|
-
a.updateType === "cut" &&
|
|
300
|
-
|
|
301
|
-
), a.updateType === "insert" &&
|
|
302
|
-
|
|
303
|
-
).filter(([
|
|
304
|
-
let
|
|
305
|
-
if (
|
|
306
|
-
let
|
|
307
|
-
Q(
|
|
300
|
+
a.updateType === "cut" && j.current?.validation?.key && Q(
|
|
301
|
+
j.current?.validation?.key + "." + k.join(".")
|
|
302
|
+
), a.updateType === "insert" && j.current?.validation?.key && Jt(
|
|
303
|
+
j.current?.validation?.key + "." + k.join(".")
|
|
304
|
+
).filter(([w, D]) => {
|
|
305
|
+
let V = w?.split(".").length;
|
|
306
|
+
if (w == k.join(".") && V == k.length - 1) {
|
|
307
|
+
let T = w + "." + k;
|
|
308
|
+
Q(w), Mt(T, D);
|
|
308
309
|
}
|
|
309
310
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const
|
|
311
|
+
const P = v.stateComponents.get(g);
|
|
312
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", P), P) {
|
|
313
|
+
const C = Tt(I, E), w = new Set(C), D = a.updateType === "update" ? o.join(".") : o.slice(0, -1).join(".") || "";
|
|
313
314
|
for (const [
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
] of
|
|
317
|
-
let
|
|
318
|
-
const
|
|
319
|
-
if (console.log("component",
|
|
320
|
-
if (
|
|
321
|
-
|
|
315
|
+
V,
|
|
316
|
+
T
|
|
317
|
+
] of P.components.entries()) {
|
|
318
|
+
let U = !1;
|
|
319
|
+
const F = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
|
|
320
|
+
if (console.log("component", T), !F.includes("none")) {
|
|
321
|
+
if (F.includes("all")) {
|
|
322
|
+
T.forceUpdate();
|
|
322
323
|
continue;
|
|
323
324
|
}
|
|
324
|
-
if (
|
|
325
|
-
for (const B of
|
|
326
|
-
let
|
|
325
|
+
if (F.includes("component") && ((T.paths.has(D) || T.paths.has("")) && (U = !0), !U))
|
|
326
|
+
for (const B of w) {
|
|
327
|
+
let W = B;
|
|
327
328
|
for (; ; ) {
|
|
328
|
-
if (
|
|
329
|
-
|
|
329
|
+
if (T.paths.has(W)) {
|
|
330
|
+
U = !0;
|
|
330
331
|
break;
|
|
331
332
|
}
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
const
|
|
333
|
+
const x = W.lastIndexOf(".");
|
|
334
|
+
if (x !== -1) {
|
|
335
|
+
const _ = W.substring(
|
|
335
336
|
0,
|
|
336
|
-
|
|
337
|
+
x
|
|
337
338
|
);
|
|
338
339
|
if (!isNaN(
|
|
339
|
-
Number(
|
|
340
|
-
) &&
|
|
341
|
-
|
|
340
|
+
Number(W.substring(x + 1))
|
|
341
|
+
) && T.paths.has(_)) {
|
|
342
|
+
U = !0;
|
|
342
343
|
break;
|
|
343
344
|
}
|
|
344
|
-
|
|
345
|
+
W = _;
|
|
345
346
|
} else
|
|
346
|
-
|
|
347
|
-
if (
|
|
347
|
+
W = "";
|
|
348
|
+
if (W === "")
|
|
348
349
|
break;
|
|
349
350
|
}
|
|
350
|
-
if (
|
|
351
|
+
if (U) break;
|
|
351
352
|
}
|
|
352
|
-
if (!
|
|
353
|
-
const B =
|
|
354
|
-
let
|
|
355
|
-
typeof B == "boolean" ? B && (
|
|
353
|
+
if (!U && F.includes("deps") && T.depsFunction) {
|
|
354
|
+
const B = T.depsFunction(E);
|
|
355
|
+
let W = !1;
|
|
356
|
+
typeof B == "boolean" ? B && (W = !0) : Y(T.deps, B) || (T.deps = B, W = !0), W && (U = !0);
|
|
356
357
|
}
|
|
357
|
-
|
|
358
|
+
U && T.forceUpdate();
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
362
|
const $ = Date.now();
|
|
362
|
-
o = o.map((
|
|
363
|
-
const
|
|
364
|
-
return
|
|
363
|
+
o = o.map((C, w) => {
|
|
364
|
+
const D = o.slice(0, -1), V = Z(E, D);
|
|
365
|
+
return w === o.length - 1 && ["insert", "cut"].includes(a.updateType) ? (V.length - 1).toString() : C;
|
|
365
366
|
});
|
|
366
|
-
const { oldValue:
|
|
367
|
+
const { oldValue: O, newValue: H } = Qt(
|
|
367
368
|
a.updateType,
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
I,
|
|
370
|
+
E,
|
|
370
371
|
o
|
|
371
372
|
), K = {
|
|
372
373
|
timeStamp: $,
|
|
373
|
-
stateKey:
|
|
374
|
+
stateKey: g,
|
|
374
375
|
path: o,
|
|
375
376
|
updateType: a.updateType,
|
|
376
377
|
status: "new",
|
|
377
|
-
oldValue:
|
|
378
|
-
newValue:
|
|
378
|
+
oldValue: O,
|
|
379
|
+
newValue: H
|
|
379
380
|
};
|
|
380
381
|
switch (a.updateType) {
|
|
381
382
|
case "update":
|
|
382
|
-
|
|
383
|
+
v.updateShadowAtPath(g, o, E);
|
|
383
384
|
break;
|
|
384
385
|
case "insert":
|
|
385
|
-
const
|
|
386
|
-
|
|
386
|
+
const C = o.slice(0, -1), D = { _cogsId: H.id ?? H.key ?? Dt() };
|
|
387
|
+
v.insertShadowArrayElement(g, C, D);
|
|
387
388
|
break;
|
|
388
389
|
case "cut":
|
|
389
|
-
const
|
|
390
|
-
|
|
390
|
+
const V = o.slice(0, -1), T = parseInt(o[o.length - 1]);
|
|
391
|
+
v.removeShadowArrayElement(g, V, T);
|
|
391
392
|
break;
|
|
392
393
|
}
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
return
|
|
394
|
+
if (Yt(g, (C) => {
|
|
395
|
+
const D = [...C ?? [], K].reduce((V, T) => {
|
|
396
|
+
const U = `${T.stateKey}:${JSON.stringify(T.path)}`, F = V.get(U);
|
|
397
|
+
return F ? (F.timeStamp = Math.max(F.timeStamp, T.timeStamp), F.newValue = T.newValue, F.oldValue = F.oldValue ?? T.oldValue, F.updateType = T.updateType) : V.set(U, { ...T }), V;
|
|
397
398
|
}, /* @__PURE__ */ new Map());
|
|
398
|
-
return Array.from(
|
|
399
|
+
return Array.from(D.values());
|
|
399
400
|
}), Nt(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
),
|
|
401
|
+
E,
|
|
402
|
+
g,
|
|
403
|
+
j.current,
|
|
404
|
+
L
|
|
405
|
+
), j.current?.middleware && j.current.middleware({
|
|
405
406
|
updateLog: c,
|
|
406
407
|
update: K
|
|
407
|
-
}),
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
syncKey: typeof
|
|
411
|
-
rollBackState:
|
|
412
|
-
actionTimeStamp: Date.now() + (
|
|
408
|
+
}), j.current?.serverSync) {
|
|
409
|
+
const C = v.serverState[g], w = j.current?.serverSync;
|
|
410
|
+
Zt(g, {
|
|
411
|
+
syncKey: typeof w.syncKey == "string" ? w.syncKey : w.syncKey({ state: E }),
|
|
412
|
+
rollBackState: C,
|
|
413
|
+
actionTimeStamp: Date.now() + (w.debounce ?? 3e3),
|
|
413
414
|
status: "waiting"
|
|
414
415
|
});
|
|
415
416
|
}
|
|
416
|
-
return
|
|
417
|
+
return E;
|
|
417
418
|
});
|
|
418
419
|
};
|
|
419
|
-
r.getState().updaterState[
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
r.getState().updaterState[g] || (ht(
|
|
421
|
+
g,
|
|
422
|
+
yt(
|
|
423
|
+
g,
|
|
424
|
+
it,
|
|
425
|
+
nt.current,
|
|
426
|
+
L
|
|
426
427
|
)
|
|
427
|
-
), r.getState().cogsStateStore[
|
|
428
|
-
const l = Et(() =>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
), [
|
|
434
|
-
return [
|
|
428
|
+
), r.getState().cogsStateStore[g] || ot(g, t), r.getState().initialStateGlobal[g] || xt(g, t));
|
|
429
|
+
const l = Et(() => yt(
|
|
430
|
+
g,
|
|
431
|
+
it,
|
|
432
|
+
nt.current,
|
|
433
|
+
L
|
|
434
|
+
), [g, L]);
|
|
435
|
+
return [Rt(g), l];
|
|
435
436
|
}
|
|
436
|
-
function
|
|
437
|
+
function yt(t, i, S, f) {
|
|
437
438
|
const h = /* @__PURE__ */ new Map();
|
|
438
|
-
let
|
|
439
|
+
let b = 0;
|
|
439
440
|
const p = (m) => {
|
|
440
441
|
const n = m.join(".");
|
|
441
|
-
for (const [
|
|
442
|
-
(
|
|
443
|
-
|
|
442
|
+
for (const [u] of h)
|
|
443
|
+
(u === n || u.startsWith(n + ".")) && h.delete(u);
|
|
444
|
+
b++;
|
|
444
445
|
}, y = {
|
|
445
446
|
removeValidation: (m) => {
|
|
446
447
|
m?.validationKey && Q(m.validationKey);
|
|
@@ -448,31 +449,31 @@ function ht(t, i, f, u) {
|
|
|
448
449
|
revertToInitialState: (m) => {
|
|
449
450
|
const n = r.getState().getInitialOptions(t)?.validation;
|
|
450
451
|
n?.key && Q(n?.key), m?.validationKey && Q(m.validationKey);
|
|
451
|
-
const
|
|
452
|
-
r.getState().clearSelectedIndexesForState(t), h.clear(),
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
const
|
|
456
|
-
return
|
|
452
|
+
const u = r.getState().initialStateGlobal[t];
|
|
453
|
+
r.getState().clearSelectedIndexesForState(t), h.clear(), b++;
|
|
454
|
+
const G = s(u, []), R = at(t), L = et(R?.localStorage?.key) ? R?.localStorage?.key(u) : R?.localStorage?.key, z = `${f}-${t}-${L}`;
|
|
455
|
+
z && localStorage.removeItem(z), ht(t, G), ot(t, u);
|
|
456
|
+
const g = r.getState().stateComponents.get(t);
|
|
457
|
+
return g && g.components.forEach((c) => {
|
|
457
458
|
c.forceUpdate();
|
|
458
|
-
}),
|
|
459
|
+
}), u;
|
|
459
460
|
},
|
|
460
461
|
updateInitialState: (m) => {
|
|
461
|
-
h.clear(),
|
|
462
|
-
const n =
|
|
462
|
+
h.clear(), b++;
|
|
463
|
+
const n = yt(
|
|
463
464
|
t,
|
|
464
465
|
i,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
),
|
|
468
|
-
return localStorage.getItem(
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
466
|
+
S,
|
|
467
|
+
f
|
|
468
|
+
), u = r.getState().initialStateGlobal[t], G = at(t), R = et(G?.localStorage?.key) ? G?.localStorage?.key(u) : G?.localStorage?.key, L = `${f}-${t}-${R}`;
|
|
469
|
+
return localStorage.getItem(L) && localStorage.removeItem(L), Ft(() => {
|
|
470
|
+
xt(t, m), r.getState().initializeShadowState(t, m), ht(t, n), ot(t, m);
|
|
471
|
+
const z = r.getState().stateComponents.get(t);
|
|
472
|
+
z && z.components.forEach((g) => {
|
|
473
|
+
g.forceUpdate();
|
|
473
474
|
});
|
|
474
475
|
}), {
|
|
475
|
-
fetchId: (
|
|
476
|
+
fetchId: (z) => n.get()[z]
|
|
476
477
|
};
|
|
477
478
|
},
|
|
478
479
|
_initialState: r.getState().initialStateGlobal[t],
|
|
@@ -480,26 +481,26 @@ function ht(t, i, f, u) {
|
|
|
480
481
|
_isLoading: r.getState().isLoadingGlobal[t],
|
|
481
482
|
_isServerSynced: () => {
|
|
482
483
|
const m = r.getState().serverState[t];
|
|
483
|
-
return !!(m && Y(m,
|
|
484
|
+
return !!(m && Y(m, Rt(t)));
|
|
484
485
|
}
|
|
485
486
|
};
|
|
486
|
-
function s(m, n = [],
|
|
487
|
-
const
|
|
488
|
-
h.get(
|
|
489
|
-
const
|
|
487
|
+
function s(m, n = [], u) {
|
|
488
|
+
const G = n.map(String).join(".");
|
|
489
|
+
h.get(G);
|
|
490
|
+
const R = function() {
|
|
490
491
|
return r().getNestedState(t, n);
|
|
491
492
|
};
|
|
492
|
-
Object.keys(y).forEach((
|
|
493
|
-
|
|
493
|
+
Object.keys(y).forEach((g) => {
|
|
494
|
+
R[g] = y[g];
|
|
494
495
|
});
|
|
495
|
-
const
|
|
496
|
-
apply(
|
|
496
|
+
const L = {
|
|
497
|
+
apply(g, c, gt) {
|
|
497
498
|
return console.log(
|
|
498
499
|
`PROXY APPLY TRAP HIT: stateKey=${t}, path=${n.join(".")}`
|
|
499
500
|
), console.trace("Apply trap stack trace"), r().getNestedState(t, n);
|
|
500
501
|
},
|
|
501
|
-
get(
|
|
502
|
-
|
|
502
|
+
get(g, c) {
|
|
503
|
+
u?.validIndices && !Array.isArray(m) && (u = { ...u, validIndices: void 0 });
|
|
503
504
|
const gt = /* @__PURE__ */ new Set([
|
|
504
505
|
"insert",
|
|
505
506
|
"cut",
|
|
@@ -524,14 +525,14 @@ function ht(t, i, f, u) {
|
|
|
524
525
|
"getComponents"
|
|
525
526
|
]);
|
|
526
527
|
if (c !== "then" && !c.startsWith("$") && c !== "stateMapNoRender" && !gt.has(c)) {
|
|
527
|
-
const l = `${t}////${
|
|
528
|
+
const l = `${t}////${S}`, e = r.getState().stateComponents.get(t);
|
|
528
529
|
if (e) {
|
|
529
530
|
const o = e.components.get(l);
|
|
530
531
|
if (o && !o.paths.has("")) {
|
|
531
532
|
const a = n.join(".");
|
|
532
533
|
let d = !0;
|
|
533
|
-
for (const
|
|
534
|
-
if (a.startsWith(
|
|
534
|
+
for (const v of o.paths)
|
|
535
|
+
if (a.startsWith(v) && (a === v || a[v.length] === ".")) {
|
|
535
536
|
d = !1;
|
|
536
537
|
break;
|
|
537
538
|
}
|
|
@@ -553,13 +554,13 @@ function ht(t, i, f, u) {
|
|
|
553
554
|
try {
|
|
554
555
|
const d = await e.action(o);
|
|
555
556
|
if (d && !d.success && d.errors && a) {
|
|
556
|
-
r.getState().removeValidationError(a), d.errors.forEach((
|
|
557
|
-
const
|
|
558
|
-
r.getState().addValidationError(
|
|
557
|
+
r.getState().removeValidationError(a), d.errors.forEach((I) => {
|
|
558
|
+
const E = [a, ...I.path].join(".");
|
|
559
|
+
r.getState().addValidationError(E, I.message);
|
|
559
560
|
});
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
561
|
+
const v = r.getState().stateComponents.get(t);
|
|
562
|
+
v && v.components.forEach((I) => {
|
|
563
|
+
I.forceUpdate();
|
|
563
564
|
});
|
|
564
565
|
}
|
|
565
566
|
return d?.success && e.onSuccess ? e.onSuccess(d.data) : !d?.success && e.onError && e.onError(d.error), d;
|
|
@@ -581,7 +582,7 @@ function ht(t, i, f, u) {
|
|
|
581
582
|
};
|
|
582
583
|
if (c === "removeStorage")
|
|
583
584
|
return () => {
|
|
584
|
-
const l = r.getState().initialStateGlobal[t], e =
|
|
585
|
+
const l = r.getState().initialStateGlobal[t], e = at(t), o = et(e?.localStorage?.key) ? e?.localStorage?.key(l) : e?.localStorage?.key, a = `${f}-${t}-${o}`;
|
|
585
586
|
a && localStorage.removeItem(a);
|
|
586
587
|
};
|
|
587
588
|
if (c === "showValidationErrors")
|
|
@@ -592,9 +593,9 @@ function ht(t, i, f, u) {
|
|
|
592
593
|
return r.getState().getValidationErrors(l.key + "." + n.join("."));
|
|
593
594
|
};
|
|
594
595
|
if (Array.isArray(m)) {
|
|
595
|
-
const l = () =>
|
|
596
|
+
const l = () => u?.validIndices ? m.map((o, a) => ({
|
|
596
597
|
item: o,
|
|
597
|
-
originalIndex:
|
|
598
|
+
originalIndex: u.validIndices[a]
|
|
598
599
|
})) : r.getState().getNestedState(t, n).map((o, a) => ({
|
|
599
600
|
item: o,
|
|
600
601
|
originalIndex: a
|
|
@@ -606,7 +607,7 @@ function ht(t, i, f, u) {
|
|
|
606
607
|
return s(
|
|
607
608
|
m[e],
|
|
608
609
|
[...n, e.toString()],
|
|
609
|
-
|
|
610
|
+
u
|
|
610
611
|
);
|
|
611
612
|
};
|
|
612
613
|
if (c === "clearSelected")
|
|
@@ -621,50 +622,50 @@ function ht(t, i, f, u) {
|
|
|
621
622
|
itemHeight: o = 50,
|
|
622
623
|
overscan: a = 6,
|
|
623
624
|
stickToBottom: d = !1,
|
|
624
|
-
dependencies:
|
|
625
|
-
} = e,
|
|
625
|
+
dependencies: v = []
|
|
626
|
+
} = e, I = J(null), [E, A] = st({
|
|
626
627
|
startIndex: 0,
|
|
627
628
|
endIndex: 10
|
|
628
|
-
}), [k,
|
|
629
|
+
}), [k, P] = st(0), $ = J(!0), O = J(!1), H = J(0), K = J(E);
|
|
629
630
|
rt(() => r.getState().subscribeToShadowState(t, () => {
|
|
630
|
-
|
|
631
|
+
P((_) => _ + 1);
|
|
631
632
|
}), [t]);
|
|
632
|
-
const
|
|
633
|
+
const C = r().getNestedState(
|
|
633
634
|
t,
|
|
634
635
|
n
|
|
635
|
-
),
|
|
636
|
-
const
|
|
637
|
-
let
|
|
638
|
-
const
|
|
639
|
-
for (let
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
|
|
636
|
+
), w = C.length, { totalHeight: D, positions: V } = Et(() => {
|
|
637
|
+
const x = r.getState().getShadowMetadata(t, n), _ = Array.isArray(x) ? x : [];
|
|
638
|
+
let N = 0;
|
|
639
|
+
const q = [];
|
|
640
|
+
for (let M = 0; M < w; M++) {
|
|
641
|
+
q[M] = N;
|
|
642
|
+
const tt = _[M]?.virtualizer?.itemHeight;
|
|
643
|
+
N += tt || o;
|
|
643
644
|
}
|
|
644
|
-
return { totalHeight:
|
|
645
|
+
return { totalHeight: N, positions: q };
|
|
645
646
|
}, [
|
|
646
|
-
|
|
647
|
+
w,
|
|
647
648
|
t,
|
|
648
649
|
n.join("."),
|
|
649
650
|
o,
|
|
650
651
|
k
|
|
651
|
-
]),
|
|
652
|
-
const
|
|
653
|
-
{ length:
|
|
654
|
-
(
|
|
655
|
-
),
|
|
656
|
-
return s(
|
|
657
|
-
...
|
|
658
|
-
validIndices:
|
|
652
|
+
]), T = Et(() => {
|
|
653
|
+
const x = Math.max(0, E.startIndex), _ = Math.min(w, E.endIndex), N = Array.from(
|
|
654
|
+
{ length: _ - x },
|
|
655
|
+
(M, tt) => x + tt
|
|
656
|
+
), q = N.map((M) => C[M]);
|
|
657
|
+
return s(q, n, {
|
|
658
|
+
...u,
|
|
659
|
+
validIndices: N
|
|
659
660
|
});
|
|
660
|
-
}, [
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
return
|
|
661
|
+
}, [E.startIndex, E.endIndex, C, w]), U = mt(() => {
|
|
662
|
+
const x = r.getState().getShadowMetadata(t, n), _ = Array.isArray(x) ? x : [], N = w - 1;
|
|
663
|
+
if (N >= 0) {
|
|
664
|
+
const q = _[N];
|
|
665
|
+
if (q?.virtualizer?.domRef) {
|
|
666
|
+
const M = q.virtualizer.domRef;
|
|
667
|
+
if (M && M.scrollIntoView)
|
|
668
|
+
return M.scrollIntoView({
|
|
668
669
|
behavior: "auto",
|
|
669
670
|
block: "end",
|
|
670
671
|
inline: "nearest"
|
|
@@ -672,128 +673,128 @@ function ht(t, i, f, u) {
|
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
675
|
return !1;
|
|
675
|
-
}, [t, n,
|
|
676
|
+
}, [t, n, w]);
|
|
676
677
|
rt(() => {
|
|
677
|
-
if (!d ||
|
|
678
|
-
const
|
|
679
|
-
if ((
|
|
680
|
-
const
|
|
681
|
-
(
|
|
682
|
-
),
|
|
678
|
+
if (!d || w === 0) return;
|
|
679
|
+
const x = w > H.current, _ = H.current === 0 && w > 0;
|
|
680
|
+
if ((x || _) && $.current && !O.current) {
|
|
681
|
+
const N = Math.ceil(
|
|
682
|
+
(I.current?.clientHeight || 0) / o
|
|
683
|
+
), q = {
|
|
683
684
|
startIndex: Math.max(
|
|
684
685
|
0,
|
|
685
|
-
|
|
686
|
+
w - N - a
|
|
686
687
|
),
|
|
687
|
-
endIndex:
|
|
688
|
+
endIndex: w
|
|
688
689
|
};
|
|
689
|
-
|
|
690
|
-
const
|
|
691
|
-
B(
|
|
690
|
+
A(q);
|
|
691
|
+
const M = setTimeout(() => {
|
|
692
|
+
B(w - 1, "smooth");
|
|
692
693
|
}, 50);
|
|
693
|
-
return () => clearTimeout(
|
|
694
|
+
return () => clearTimeout(M);
|
|
694
695
|
}
|
|
695
|
-
|
|
696
|
-
}, [
|
|
697
|
-
const
|
|
698
|
-
if (!
|
|
699
|
-
const
|
|
700
|
-
const { scrollTop:
|
|
701
|
-
$.current =
|
|
702
|
-
let
|
|
703
|
-
for (let X = 0; X <
|
|
704
|
-
if (
|
|
705
|
-
|
|
696
|
+
H.current = w;
|
|
697
|
+
}, [w, o, a]), rt(() => {
|
|
698
|
+
const x = I.current;
|
|
699
|
+
if (!x) return;
|
|
700
|
+
const _ = () => {
|
|
701
|
+
const { scrollTop: N, scrollHeight: q, clientHeight: M } = x, tt = q - N - M;
|
|
702
|
+
$.current = tt < 5, tt > 100 && (O.current = !0), tt < 5 && (O.current = !1);
|
|
703
|
+
let ct = 0;
|
|
704
|
+
for (let X = 0; X < V.length; X++)
|
|
705
|
+
if (V[X] > N - o * a) {
|
|
706
|
+
ct = Math.max(0, X - 1);
|
|
706
707
|
break;
|
|
707
708
|
}
|
|
708
|
-
let
|
|
709
|
-
const
|
|
710
|
-
for (let X =
|
|
711
|
-
|
|
712
|
-
const vt = Math.max(0,
|
|
713
|
-
|
|
714
|
-
|
|
709
|
+
let lt = ct;
|
|
710
|
+
const jt = N + M;
|
|
711
|
+
for (let X = ct; X < V.length && !(V[X] > jt + o * a); X++)
|
|
712
|
+
lt = X;
|
|
713
|
+
const vt = Math.max(0, ct), wt = Math.min(
|
|
714
|
+
w,
|
|
715
|
+
lt + 1 + a
|
|
715
716
|
);
|
|
716
|
-
(vt !== K.current.startIndex ||
|
|
717
|
+
(vt !== K.current.startIndex || wt !== K.current.endIndex) && (K.current = {
|
|
717
718
|
startIndex: vt,
|
|
718
|
-
endIndex:
|
|
719
|
-
},
|
|
719
|
+
endIndex: wt
|
|
720
|
+
}, A({
|
|
720
721
|
startIndex: vt,
|
|
721
|
-
endIndex:
|
|
722
|
+
endIndex: wt
|
|
722
723
|
}));
|
|
723
724
|
};
|
|
724
|
-
if (
|
|
725
|
+
if (x.addEventListener("scroll", _, {
|
|
725
726
|
passive: !0
|
|
726
|
-
}), d &&
|
|
727
|
-
const { scrollTop:
|
|
728
|
-
|
|
727
|
+
}), d && w > 0 && !O.current) {
|
|
728
|
+
const { scrollTop: N } = x;
|
|
729
|
+
N === 0 && (x.scrollTop = x.scrollHeight, $.current = !0);
|
|
729
730
|
}
|
|
730
|
-
return
|
|
731
|
-
|
|
731
|
+
return _(), () => {
|
|
732
|
+
x.removeEventListener("scroll", _);
|
|
732
733
|
};
|
|
733
|
-
}, [
|
|
734
|
-
const
|
|
735
|
-
$.current = !0,
|
|
736
|
-
}, [
|
|
737
|
-
(
|
|
738
|
-
const
|
|
739
|
-
if (!
|
|
740
|
-
if (
|
|
741
|
-
|
|
742
|
-
top:
|
|
743
|
-
behavior:
|
|
734
|
+
}, [V, w, o, a, d]);
|
|
735
|
+
const F = mt(() => {
|
|
736
|
+
$.current = !0, O.current = !1, !U() && I.current && (I.current.scrollTop = I.current.scrollHeight);
|
|
737
|
+
}, [U]), B = mt(
|
|
738
|
+
(x, _ = "smooth") => {
|
|
739
|
+
const N = I.current;
|
|
740
|
+
if (!N) return;
|
|
741
|
+
if (x === w - 1) {
|
|
742
|
+
N.scrollTo({
|
|
743
|
+
top: N.scrollHeight,
|
|
744
|
+
behavior: _
|
|
744
745
|
});
|
|
745
746
|
return;
|
|
746
747
|
}
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
behavior:
|
|
748
|
+
const M = r.getState().getShadowMetadata(t, n), lt = (Array.isArray(M) ? M : [])[x]?.virtualizer?.domRef;
|
|
749
|
+
lt ? lt.scrollIntoView({
|
|
750
|
+
behavior: _,
|
|
750
751
|
block: "center"
|
|
751
|
-
}) :
|
|
752
|
-
top:
|
|
753
|
-
behavior:
|
|
752
|
+
}) : V[x] !== void 0 && N.scrollTo({
|
|
753
|
+
top: V[x],
|
|
754
|
+
behavior: _
|
|
754
755
|
});
|
|
755
756
|
},
|
|
756
|
-
[
|
|
757
|
+
[V, t, n, w]
|
|
757
758
|
// Add totalCount to the dependencies
|
|
758
|
-
),
|
|
759
|
+
), W = {
|
|
759
760
|
outer: {
|
|
760
|
-
ref:
|
|
761
|
+
ref: I,
|
|
761
762
|
style: { overflowY: "auto", height: "100%" }
|
|
762
763
|
},
|
|
763
764
|
inner: {
|
|
764
765
|
style: {
|
|
765
|
-
height: `${
|
|
766
|
+
height: `${D}px`,
|
|
766
767
|
position: "relative"
|
|
767
768
|
}
|
|
768
769
|
},
|
|
769
770
|
list: {
|
|
770
771
|
style: {
|
|
771
|
-
transform: `translateY(${
|
|
772
|
+
transform: `translateY(${V[E.startIndex] || 0}px)`
|
|
772
773
|
}
|
|
773
774
|
}
|
|
774
775
|
};
|
|
775
776
|
return {
|
|
776
|
-
virtualState:
|
|
777
|
-
virtualizerProps:
|
|
778
|
-
scrollToBottom:
|
|
777
|
+
virtualState: T,
|
|
778
|
+
virtualizerProps: W,
|
|
779
|
+
scrollToBottom: F,
|
|
779
780
|
scrollToIndex: B
|
|
780
781
|
};
|
|
781
782
|
};
|
|
782
783
|
if (c === "stateMapNoRender")
|
|
783
784
|
return (e) => m.map((a, d) => {
|
|
784
|
-
let
|
|
785
|
-
|
|
786
|
-
const
|
|
785
|
+
let v;
|
|
786
|
+
u?.validIndices && u.validIndices[d] !== void 0 ? v = u.validIndices[d] : v = d;
|
|
787
|
+
const I = [...n, v.toString()], E = s(a, I, u);
|
|
787
788
|
return e(
|
|
788
789
|
a,
|
|
789
|
-
|
|
790
|
+
E,
|
|
790
791
|
d,
|
|
791
792
|
m,
|
|
792
|
-
s(m, n,
|
|
793
|
+
s(m, n, u)
|
|
793
794
|
);
|
|
794
795
|
});
|
|
795
796
|
if (c === "$stateMap")
|
|
796
|
-
return (e) =>
|
|
797
|
+
return (e) => ut(te, {
|
|
797
798
|
proxy: {
|
|
798
799
|
_stateKey: t,
|
|
799
800
|
_path: n,
|
|
@@ -805,20 +806,20 @@ function ht(t, i, f, u) {
|
|
|
805
806
|
if (c === "stateList")
|
|
806
807
|
return (e, o) => {
|
|
807
808
|
const a = r.getState().getNestedState(t, n);
|
|
808
|
-
return Array.isArray(a) ? (
|
|
809
|
-
const
|
|
810
|
-
return
|
|
811
|
-
key:
|
|
809
|
+
return Array.isArray(a) ? (u?.validIndices || Array.from({ length: a.length }, (v, I) => I)).map((v, I) => {
|
|
810
|
+
const E = a[v], A = [...n, v.toString()], k = s(E, A, u), P = `${S}-${n.join(".")}-${v}`;
|
|
811
|
+
return ut(ne, {
|
|
812
|
+
key: v,
|
|
812
813
|
stateKey: t,
|
|
813
|
-
itemComponentId:
|
|
814
|
+
itemComponentId: P,
|
|
814
815
|
formOpts: o,
|
|
815
|
-
itemPath:
|
|
816
|
+
itemPath: A,
|
|
816
817
|
children: e(
|
|
817
|
-
|
|
818
|
+
E,
|
|
818
819
|
k,
|
|
819
|
-
{ localIndex:
|
|
820
|
+
{ localIndex: I, originalIndex: v },
|
|
820
821
|
a,
|
|
821
|
-
s(a, n,
|
|
822
|
+
s(a, n, u)
|
|
822
823
|
)
|
|
823
824
|
});
|
|
824
825
|
}) : (console.warn(
|
|
@@ -828,14 +829,14 @@ function ht(t, i, f, u) {
|
|
|
828
829
|
if (c === "stateFlattenOn")
|
|
829
830
|
return (e) => {
|
|
830
831
|
const o = m;
|
|
831
|
-
h.clear(),
|
|
832
|
+
h.clear(), b++;
|
|
832
833
|
const a = o.flatMap(
|
|
833
834
|
(d) => d[e] ?? []
|
|
834
835
|
);
|
|
835
836
|
return s(
|
|
836
837
|
a,
|
|
837
838
|
[...n, "[*]", e],
|
|
838
|
-
|
|
839
|
+
u
|
|
839
840
|
);
|
|
840
841
|
};
|
|
841
842
|
if (c === "index")
|
|
@@ -851,36 +852,36 @@ function ht(t, i, f, u) {
|
|
|
851
852
|
return s(a, d);
|
|
852
853
|
};
|
|
853
854
|
if (c === "insert")
|
|
854
|
-
return (e) => (p(n),
|
|
855
|
+
return (e) => (p(n), pt(i, e, n, t), s(
|
|
855
856
|
r.getState().getNestedState(t, n),
|
|
856
857
|
n
|
|
857
858
|
));
|
|
858
859
|
if (c === "uniqueInsert")
|
|
859
860
|
return (e, o, a) => {
|
|
860
|
-
const d = r.getState().getNestedState(t, n),
|
|
861
|
-
let
|
|
862
|
-
if (!d.some((
|
|
861
|
+
const d = r.getState().getNestedState(t, n), v = et(e) ? e(d) : e;
|
|
862
|
+
let I = null;
|
|
863
|
+
if (!d.some((A) => {
|
|
863
864
|
if (o) {
|
|
864
|
-
const
|
|
865
|
-
($) => Y(
|
|
865
|
+
const P = o.every(
|
|
866
|
+
($) => Y(A[$], v[$])
|
|
866
867
|
);
|
|
867
|
-
return
|
|
868
|
+
return P && (I = A), P;
|
|
868
869
|
}
|
|
869
|
-
const k = Y(
|
|
870
|
-
return k && (
|
|
870
|
+
const k = Y(A, v);
|
|
871
|
+
return k && (I = A), k;
|
|
871
872
|
}))
|
|
872
|
-
p(n),
|
|
873
|
-
else if (a &&
|
|
874
|
-
const
|
|
875
|
-
(
|
|
873
|
+
p(n), pt(i, v, n, t);
|
|
874
|
+
else if (a && I) {
|
|
875
|
+
const A = a(I), k = d.map(
|
|
876
|
+
(P) => Y(P, I) ? A : P
|
|
876
877
|
);
|
|
877
|
-
p(n),
|
|
878
|
+
p(n), dt(i, k, n);
|
|
878
879
|
}
|
|
879
880
|
};
|
|
880
881
|
if (c === "cut")
|
|
881
882
|
return (e, o) => {
|
|
882
883
|
if (!o?.waitForSync)
|
|
883
|
-
return p(n),
|
|
884
|
+
return p(n), St(i, n, t, e), s(
|
|
884
885
|
r.getState().getNestedState(t, n),
|
|
885
886
|
n
|
|
886
887
|
);
|
|
@@ -888,48 +889,48 @@ function ht(t, i, f, u) {
|
|
|
888
889
|
if (c === "cutByValue")
|
|
889
890
|
return (e) => {
|
|
890
891
|
for (let o = 0; o < m.length; o++)
|
|
891
|
-
m[o] === e &&
|
|
892
|
+
m[o] === e && St(i, n, t, o);
|
|
892
893
|
};
|
|
893
894
|
if (c === "toggleByValue")
|
|
894
895
|
return (e) => {
|
|
895
896
|
const o = m.findIndex((a) => a === e);
|
|
896
|
-
o > -1 ?
|
|
897
|
+
o > -1 ? St(i, n, t, o) : pt(i, e, n, t);
|
|
897
898
|
};
|
|
898
899
|
if (c === "stateFind")
|
|
899
900
|
return (e) => {
|
|
900
901
|
const a = l().find(
|
|
901
|
-
({ item:
|
|
902
|
+
({ item: v }, I) => e(v, I)
|
|
902
903
|
);
|
|
903
904
|
if (!a) return;
|
|
904
905
|
const d = [...n, a.originalIndex.toString()];
|
|
905
|
-
return s(a.item, d,
|
|
906
|
+
return s(a.item, d, u);
|
|
906
907
|
};
|
|
907
908
|
if (c === "findWith")
|
|
908
909
|
return (e, o) => {
|
|
909
910
|
const d = l().find(
|
|
910
|
-
({ item:
|
|
911
|
+
({ item: I }) => I[e] === o
|
|
911
912
|
);
|
|
912
913
|
if (!d) return;
|
|
913
|
-
const
|
|
914
|
-
return s(d.item,
|
|
914
|
+
const v = [...n, d.originalIndex.toString()];
|
|
915
|
+
return s(d.item, v, u);
|
|
915
916
|
};
|
|
916
917
|
}
|
|
917
|
-
const
|
|
918
|
-
if (!isNaN(Number(
|
|
918
|
+
const nt = n[n.length - 1];
|
|
919
|
+
if (!isNaN(Number(nt))) {
|
|
919
920
|
const l = n.slice(0, -1), e = r.getState().getNestedState(t, l);
|
|
920
921
|
if (Array.isArray(e) && c === "cut")
|
|
921
|
-
return () =>
|
|
922
|
+
return () => St(
|
|
922
923
|
i,
|
|
923
924
|
l,
|
|
924
925
|
t,
|
|
925
|
-
Number(
|
|
926
|
+
Number(nt)
|
|
926
927
|
);
|
|
927
928
|
}
|
|
928
929
|
if (c === "get")
|
|
929
930
|
return () => {
|
|
930
|
-
if (
|
|
931
|
+
if (u?.validIndices && Array.isArray(m)) {
|
|
931
932
|
const l = r.getState().getNestedState(t, n);
|
|
932
|
-
return
|
|
933
|
+
return u.validIndices.map((e) => l[e]);
|
|
933
934
|
}
|
|
934
935
|
return r.getState().getNestedState(t, n);
|
|
935
936
|
};
|
|
@@ -949,7 +950,7 @@ function ht(t, i, f, u) {
|
|
|
949
950
|
return r.getState().getSyncInfo(l);
|
|
950
951
|
}
|
|
951
952
|
if (c == "getLocalStorage")
|
|
952
|
-
return (l) =>
|
|
953
|
+
return (l) => It(f + "-" + t + "-" + l);
|
|
953
954
|
if (c === "_selected") {
|
|
954
955
|
const l = n.slice(0, -1), e = l.join("."), o = r.getState().getNestedState(t, l);
|
|
955
956
|
return Array.isArray(o) ? Number(n[n.length - 1]) === r.getState().getSelectedIndex(t, e) : void 0;
|
|
@@ -959,7 +960,7 @@ function ht(t, i, f, u) {
|
|
|
959
960
|
const e = n.slice(0, -1), o = Number(n[n.length - 1]), a = e.join(".");
|
|
960
961
|
l ? r.getState().setSelectedIndex(t, a, o) : r.getState().setSelectedIndex(t, a, void 0);
|
|
961
962
|
const d = r.getState().getNestedState(t, [...e]);
|
|
962
|
-
|
|
963
|
+
dt(i, d, e), p(e);
|
|
963
964
|
};
|
|
964
965
|
if (c === "toggleSelected")
|
|
965
966
|
return () => {
|
|
@@ -970,7 +971,7 @@ function ht(t, i, f, u) {
|
|
|
970
971
|
a === e ? void 0 : e
|
|
971
972
|
);
|
|
972
973
|
const d = r.getState().getNestedState(t, [...l]);
|
|
973
|
-
|
|
974
|
+
dt(i, d, l), p(l);
|
|
974
975
|
};
|
|
975
976
|
if (n.length == 0) {
|
|
976
977
|
if (c === "addValidation")
|
|
@@ -980,73 +981,73 @@ function ht(t, i, f, u) {
|
|
|
980
981
|
throw new Error("Validation key not found");
|
|
981
982
|
Q(e.key), console.log("addValidationError", l), l.forEach((o) => {
|
|
982
983
|
const a = [e.key, ...o.path].join(".");
|
|
983
|
-
console.log("fullErrorPath", a),
|
|
984
|
-
}),
|
|
984
|
+
console.log("fullErrorPath", a), Mt(a, o.message);
|
|
985
|
+
}), ft(t);
|
|
985
986
|
};
|
|
986
987
|
if (c === "applyJsonPatch")
|
|
987
988
|
return (l) => {
|
|
988
|
-
const e = r.getState().cogsStateStore[t], a =
|
|
989
|
-
|
|
989
|
+
const e = r.getState().cogsStateStore[t], a = Bt(e, l).newDocument;
|
|
990
|
+
Ot(
|
|
990
991
|
t,
|
|
991
992
|
r.getState().initialStateGlobal[t],
|
|
992
993
|
a,
|
|
993
994
|
i,
|
|
994
|
-
|
|
995
|
-
|
|
995
|
+
S,
|
|
996
|
+
f
|
|
996
997
|
);
|
|
997
998
|
const d = r.getState().stateComponents.get(t);
|
|
998
999
|
if (d) {
|
|
999
|
-
const
|
|
1000
|
+
const v = Tt(e, a), I = new Set(v);
|
|
1000
1001
|
for (const [
|
|
1001
|
-
|
|
1002
|
-
|
|
1002
|
+
E,
|
|
1003
|
+
A
|
|
1003
1004
|
] of d.components.entries()) {
|
|
1004
1005
|
let k = !1;
|
|
1005
|
-
const
|
|
1006
|
-
if (!
|
|
1007
|
-
if (
|
|
1008
|
-
|
|
1006
|
+
const P = Array.isArray(A.reactiveType) ? A.reactiveType : [A.reactiveType || "component"];
|
|
1007
|
+
if (!P.includes("none")) {
|
|
1008
|
+
if (P.includes("all")) {
|
|
1009
|
+
A.forceUpdate();
|
|
1009
1010
|
continue;
|
|
1010
1011
|
}
|
|
1011
|
-
if (
|
|
1012
|
-
for (const $ of
|
|
1013
|
-
if (
|
|
1012
|
+
if (P.includes("component") && (A.paths.has("") && (k = !0), !k))
|
|
1013
|
+
for (const $ of I) {
|
|
1014
|
+
if (A.paths.has($)) {
|
|
1014
1015
|
k = !0;
|
|
1015
1016
|
break;
|
|
1016
1017
|
}
|
|
1017
|
-
let
|
|
1018
|
-
for (;
|
|
1019
|
-
const
|
|
1020
|
-
if (
|
|
1018
|
+
let O = $.lastIndexOf(".");
|
|
1019
|
+
for (; O !== -1; ) {
|
|
1020
|
+
const H = $.substring(0, O);
|
|
1021
|
+
if (A.paths.has(H)) {
|
|
1021
1022
|
k = !0;
|
|
1022
1023
|
break;
|
|
1023
1024
|
}
|
|
1024
1025
|
const K = $.substring(
|
|
1025
|
-
|
|
1026
|
+
O + 1
|
|
1026
1027
|
);
|
|
1027
1028
|
if (!isNaN(Number(K))) {
|
|
1028
|
-
const
|
|
1029
|
-
if (
|
|
1030
|
-
const
|
|
1029
|
+
const C = H.lastIndexOf(".");
|
|
1030
|
+
if (C !== -1) {
|
|
1031
|
+
const w = H.substring(
|
|
1031
1032
|
0,
|
|
1032
|
-
|
|
1033
|
+
C
|
|
1033
1034
|
);
|
|
1034
|
-
if (
|
|
1035
|
+
if (A.paths.has(w)) {
|
|
1035
1036
|
k = !0;
|
|
1036
1037
|
break;
|
|
1037
1038
|
}
|
|
1038
1039
|
}
|
|
1039
1040
|
}
|
|
1040
|
-
|
|
1041
|
+
O = H.lastIndexOf(".");
|
|
1041
1042
|
}
|
|
1042
1043
|
if (k) break;
|
|
1043
1044
|
}
|
|
1044
|
-
if (!k &&
|
|
1045
|
-
const $ =
|
|
1046
|
-
let
|
|
1047
|
-
typeof $ == "boolean" ? $ && (
|
|
1045
|
+
if (!k && P.includes("deps") && A.depsFunction) {
|
|
1046
|
+
const $ = A.depsFunction(a);
|
|
1047
|
+
let O = !1;
|
|
1048
|
+
typeof $ == "boolean" ? $ && (O = !0) : Y(A.deps, $) || (A.deps = $, O = !0), O && (k = !0);
|
|
1048
1049
|
}
|
|
1049
|
-
k &&
|
|
1050
|
+
k && A.forceUpdate();
|
|
1050
1051
|
}
|
|
1051
1052
|
}
|
|
1052
1053
|
}
|
|
@@ -1062,19 +1063,19 @@ function ht(t, i, f, u) {
|
|
|
1062
1063
|
const o = r.getState().cogsStateStore[t];
|
|
1063
1064
|
try {
|
|
1064
1065
|
const a = r.getState().getValidationErrors(l.key);
|
|
1065
|
-
a && a.length > 0 && a.forEach(([
|
|
1066
|
-
|
|
1066
|
+
a && a.length > 0 && a.forEach(([v]) => {
|
|
1067
|
+
v && v.startsWith(l.key) && Q(v);
|
|
1067
1068
|
});
|
|
1068
1069
|
const d = l.zodSchema.safeParse(o);
|
|
1069
|
-
return d.success ? !0 : (d.error.errors.forEach((
|
|
1070
|
-
const
|
|
1071
|
-
e(k,
|
|
1072
|
-
}),
|
|
1070
|
+
return d.success ? !0 : (d.error.errors.forEach((I) => {
|
|
1071
|
+
const E = I.path, A = I.message, k = [l.key, ...E].join(".");
|
|
1072
|
+
e(k, A);
|
|
1073
|
+
}), ft(t), !1);
|
|
1073
1074
|
} catch (a) {
|
|
1074
1075
|
return console.error("Zod schema validation failed", a), !1;
|
|
1075
1076
|
}
|
|
1076
1077
|
};
|
|
1077
|
-
if (c === "_componentId") return
|
|
1078
|
+
if (c === "_componentId") return S;
|
|
1078
1079
|
if (c === "getComponents")
|
|
1079
1080
|
return () => r().stateComponents.get(t);
|
|
1080
1081
|
if (c === "getAllFormRefs")
|
|
@@ -1096,13 +1097,13 @@ function ht(t, i, f, u) {
|
|
|
1096
1097
|
return ({
|
|
1097
1098
|
children: l,
|
|
1098
1099
|
hideMessage: e
|
|
1099
|
-
}) => /* @__PURE__ */
|
|
1100
|
-
|
|
1100
|
+
}) => /* @__PURE__ */ At(
|
|
1101
|
+
Wt,
|
|
1101
1102
|
{
|
|
1102
1103
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1103
1104
|
path: n,
|
|
1104
1105
|
stateKey: t,
|
|
1105
|
-
validIndices:
|
|
1106
|
+
validIndices: u?.validIndices,
|
|
1106
1107
|
children: l
|
|
1107
1108
|
}
|
|
1108
1109
|
);
|
|
@@ -1113,20 +1114,20 @@ function ht(t, i, f, u) {
|
|
|
1113
1114
|
return (l, e) => {
|
|
1114
1115
|
if (e?.debounce)
|
|
1115
1116
|
Gt(() => {
|
|
1116
|
-
|
|
1117
|
+
dt(i, l, n, "");
|
|
1117
1118
|
const o = r.getState().getNestedState(t, n);
|
|
1118
1119
|
e?.afterUpdate && e.afterUpdate(o);
|
|
1119
1120
|
}, e.debounce);
|
|
1120
1121
|
else {
|
|
1121
|
-
|
|
1122
|
+
dt(i, l, n, "");
|
|
1122
1123
|
const o = r.getState().getNestedState(t, n);
|
|
1123
1124
|
e?.afterUpdate && e.afterUpdate(o);
|
|
1124
1125
|
}
|
|
1125
1126
|
p(n);
|
|
1126
1127
|
};
|
|
1127
1128
|
if (c === "formElement")
|
|
1128
|
-
return (l, e) => /* @__PURE__ */
|
|
1129
|
-
|
|
1129
|
+
return (l, e) => /* @__PURE__ */ At(
|
|
1130
|
+
Ht,
|
|
1130
1131
|
{
|
|
1131
1132
|
setState: i,
|
|
1132
1133
|
stateKey: t,
|
|
@@ -1135,42 +1136,42 @@ function ht(t, i, f, u) {
|
|
|
1135
1136
|
formOpts: e
|
|
1136
1137
|
}
|
|
1137
1138
|
);
|
|
1138
|
-
const
|
|
1139
|
-
return s(
|
|
1139
|
+
const j = [...n, c], it = r.getState().getNestedState(t, j);
|
|
1140
|
+
return s(it, j, u);
|
|
1140
1141
|
}
|
|
1141
|
-
},
|
|
1142
|
-
return h.set(
|
|
1143
|
-
proxy:
|
|
1144
|
-
stateVersion:
|
|
1145
|
-
}),
|
|
1142
|
+
}, z = new Proxy(R, L);
|
|
1143
|
+
return h.set(G, {
|
|
1144
|
+
proxy: z,
|
|
1145
|
+
stateVersion: b
|
|
1146
|
+
}), z;
|
|
1146
1147
|
}
|
|
1147
1148
|
return s(
|
|
1148
1149
|
r.getState().getNestedState(t, [])
|
|
1149
1150
|
);
|
|
1150
1151
|
}
|
|
1151
1152
|
function Pt(t) {
|
|
1152
|
-
return
|
|
1153
|
+
return ut(ee, { proxy: t });
|
|
1153
1154
|
}
|
|
1154
|
-
function
|
|
1155
|
+
function te({
|
|
1155
1156
|
proxy: t,
|
|
1156
1157
|
rebuildStateShape: i
|
|
1157
1158
|
}) {
|
|
1158
|
-
const
|
|
1159
|
-
return Array.isArray(
|
|
1160
|
-
|
|
1159
|
+
const S = r().getNestedState(t._stateKey, t._path);
|
|
1160
|
+
return Array.isArray(S) ? i(
|
|
1161
|
+
S,
|
|
1161
1162
|
t._path
|
|
1162
1163
|
).stateMapNoRender(
|
|
1163
|
-
(h,
|
|
1164
|
+
(h, b, p, y, s) => t._mapFn(h, b, p, y, s)
|
|
1164
1165
|
) : null;
|
|
1165
1166
|
}
|
|
1166
|
-
function
|
|
1167
|
+
function ee({
|
|
1167
1168
|
proxy: t
|
|
1168
1169
|
}) {
|
|
1169
|
-
const i =
|
|
1170
|
+
const i = J(null), S = `${t._stateKey}-${t._path.join(".")}`;
|
|
1170
1171
|
return rt(() => {
|
|
1171
|
-
const
|
|
1172
|
-
if (!
|
|
1173
|
-
const h =
|
|
1172
|
+
const f = i.current;
|
|
1173
|
+
if (!f || !f.parentElement) return;
|
|
1174
|
+
const h = f.parentElement, p = Array.from(h.childNodes).indexOf(f);
|
|
1174
1175
|
let y = h.getAttribute("data-parent-id");
|
|
1175
1176
|
y || (y = `parent-${crypto.randomUUID()}`, h.setAttribute("data-parent-id", y));
|
|
1176
1177
|
const m = {
|
|
@@ -1179,84 +1180,84 @@ function te({
|
|
|
1179
1180
|
position: p,
|
|
1180
1181
|
effect: t._effect
|
|
1181
1182
|
};
|
|
1182
|
-
r.getState().addSignalElement(
|
|
1183
|
+
r.getState().addSignalElement(S, m);
|
|
1183
1184
|
const n = r.getState().getNestedState(t._stateKey, t._path);
|
|
1184
|
-
let
|
|
1185
|
+
let u;
|
|
1185
1186
|
if (t._effect)
|
|
1186
1187
|
try {
|
|
1187
|
-
|
|
1188
|
+
u = new Function(
|
|
1188
1189
|
"state",
|
|
1189
1190
|
`return (${t._effect})(state)`
|
|
1190
1191
|
)(n);
|
|
1191
|
-
} catch (
|
|
1192
|
-
console.error("Error evaluating effect function during mount:",
|
|
1192
|
+
} catch (R) {
|
|
1193
|
+
console.error("Error evaluating effect function during mount:", R), u = n;
|
|
1193
1194
|
}
|
|
1194
1195
|
else
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1196
|
+
u = n;
|
|
1197
|
+
u !== null && typeof u == "object" && (u = JSON.stringify(u));
|
|
1198
|
+
const G = document.createTextNode(String(u));
|
|
1199
|
+
f.replaceWith(G);
|
|
1200
|
+
}, [t._stateKey, t._path.join("."), t._effect]), ut("span", {
|
|
1200
1201
|
ref: i,
|
|
1201
1202
|
style: { display: "none" },
|
|
1202
|
-
"data-signal-id":
|
|
1203
|
+
"data-signal-id": S
|
|
1203
1204
|
});
|
|
1204
1205
|
}
|
|
1205
|
-
function
|
|
1206
|
-
const i =
|
|
1207
|
-
(
|
|
1208
|
-
const
|
|
1206
|
+
function Ie(t) {
|
|
1207
|
+
const i = Ut(
|
|
1208
|
+
(S) => {
|
|
1209
|
+
const f = r.getState().stateComponents.get(t._stateKey) || {
|
|
1209
1210
|
components: /* @__PURE__ */ new Map()
|
|
1210
1211
|
};
|
|
1211
|
-
return
|
|
1212
|
-
forceUpdate:
|
|
1212
|
+
return f.components.set(t._stateKey, {
|
|
1213
|
+
forceUpdate: S,
|
|
1213
1214
|
paths: /* @__PURE__ */ new Set([t._path.join(".")])
|
|
1214
|
-
}), () =>
|
|
1215
|
+
}), () => f.components.delete(t._stateKey);
|
|
1215
1216
|
},
|
|
1216
1217
|
() => r.getState().getNestedState(t._stateKey, t._path)
|
|
1217
1218
|
);
|
|
1218
|
-
return
|
|
1219
|
+
return ut("text", {}, String(i));
|
|
1219
1220
|
}
|
|
1220
|
-
function
|
|
1221
|
+
function ne({
|
|
1221
1222
|
stateKey: t,
|
|
1222
1223
|
itemComponentId: i,
|
|
1223
|
-
itemPath:
|
|
1224
|
-
formOpts:
|
|
1224
|
+
itemPath: S,
|
|
1225
|
+
formOpts: f,
|
|
1225
1226
|
children: h
|
|
1226
1227
|
}) {
|
|
1227
|
-
const [,
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
p(n), s.current = n;
|
|
1228
|
+
const [, b] = st({}), [p, y] = qt(), s = J(null), m = J(null), n = mt(
|
|
1229
|
+
(u) => {
|
|
1230
|
+
p(u), s.current = u;
|
|
1231
1231
|
},
|
|
1232
1232
|
[p]
|
|
1233
|
-
)
|
|
1234
|
-
|
|
1233
|
+
);
|
|
1234
|
+
return rt(() => {
|
|
1235
|
+
y.height > 0 && y.height !== m.current && (m.current = y.height, r.getState().setShadowMetadata(t, S, {
|
|
1235
1236
|
virtualizer: {
|
|
1236
1237
|
itemHeight: y.height,
|
|
1237
1238
|
domRef: s.current
|
|
1238
1239
|
// Store the actual DOM element reference
|
|
1239
1240
|
}
|
|
1240
1241
|
}));
|
|
1241
|
-
}, [y.height, t,
|
|
1242
|
-
const
|
|
1242
|
+
}, [y.height, t, S]), Ct(() => {
|
|
1243
|
+
const u = `${t}////${i}`, G = r.getState().stateComponents.get(t) || {
|
|
1243
1244
|
components: /* @__PURE__ */ new Map()
|
|
1244
1245
|
};
|
|
1245
|
-
return
|
|
1246
|
-
forceUpdate: () =>
|
|
1247
|
-
paths: /* @__PURE__ */ new Set([
|
|
1248
|
-
}), r.getState().stateComponents.set(t,
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1246
|
+
return G.components.set(u, {
|
|
1247
|
+
forceUpdate: () => b({}),
|
|
1248
|
+
paths: /* @__PURE__ */ new Set([S.join(".")])
|
|
1249
|
+
}), r.getState().stateComponents.set(t, G), () => {
|
|
1250
|
+
const R = r.getState().stateComponents.get(t);
|
|
1251
|
+
R && R.components.delete(u);
|
|
1251
1252
|
};
|
|
1252
|
-
}, [t, i,
|
|
1253
|
+
}, [t, i, S.join(".")]), /* @__PURE__ */ At("div", { ref: n, children: h });
|
|
1253
1254
|
}
|
|
1254
1255
|
export {
|
|
1255
1256
|
Pt as $cogsSignal,
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1257
|
+
Ie as $cogsSignalStore,
|
|
1258
|
+
me as addStateOptions,
|
|
1259
|
+
he as createCogsState,
|
|
1260
|
+
ye as notifyComponent,
|
|
1261
|
+
Kt as useCogsStateFn
|
|
1261
1262
|
};
|
|
1262
1263
|
//# sourceMappingURL=CogsState.jsx.map
|