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