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