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