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