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