cogsbox-state 0.5.427 → 0.5.429
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.d.ts +1 -1
- package/dist/CogsState.jsx +762 -830
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Functions.jsx +134 -136
- package/dist/Functions.jsx.map +1 -1
- package/dist/index.js +9 -8
- package/dist/store.d.ts +15 -18
- package/dist/store.js +165 -186
- package/dist/store.js.map +1 -1
- package/dist/useValidateZodPath.d.ts +1 -1
- package/dist/utility.d.ts +1 -0
- package/dist/utility.js +165 -121
- package/dist/utility.js.map +1 -1
- package/package.json +6 -2
- package/src/CogsState.tsx +423 -729
- package/src/Functions.tsx +47 -39
- package/src/store.ts +171 -205
- package/src/utility.ts +88 -10
package/dist/store.js
CHANGED
|
@@ -1,137 +1,112 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
|
|
1
|
+
import { create as h } from "zustand";
|
|
2
|
+
import { ulid as u } from "ulid";
|
|
3
|
+
const b = h((a, l) => ({
|
|
3
4
|
formRefs: /* @__PURE__ */ new Map(),
|
|
4
|
-
registerFormRef: (e, r) =>
|
|
5
|
+
registerFormRef: (e, r) => a((t) => {
|
|
5
6
|
const n = new Map(t.formRefs);
|
|
6
7
|
return n.set(e, r), { formRefs: n };
|
|
7
8
|
}),
|
|
8
|
-
getFormRef: (e) =>
|
|
9
|
-
removeFormRef: (e) =>
|
|
9
|
+
getFormRef: (e) => l().formRefs.get(e),
|
|
10
|
+
removeFormRef: (e) => a((r) => {
|
|
10
11
|
const t = new Map(r.formRefs);
|
|
11
12
|
return t.delete(e), { formRefs: t };
|
|
12
13
|
}),
|
|
13
14
|
// Get all refs that start with the stateKey prefix
|
|
14
15
|
getFormRefsByStateKey: (e) => {
|
|
15
|
-
const r =
|
|
16
|
-
return r.forEach((
|
|
17
|
-
(o.startsWith(t) || o === e) && n.set(o,
|
|
16
|
+
const r = l().formRefs, t = e + ".", n = /* @__PURE__ */ new Map();
|
|
17
|
+
return r.forEach((s, o) => {
|
|
18
|
+
(o.startsWith(t) || o === e) && n.set(o, s);
|
|
18
19
|
}), n;
|
|
19
20
|
}
|
|
20
|
-
})),
|
|
21
|
-
shadowStateStore:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
})), I = h((a, l) => ({
|
|
22
|
+
shadowStateStore: /* @__PURE__ */ new Map(),
|
|
23
|
+
shadowStateSubscribers: /* @__PURE__ */ new Map(),
|
|
24
|
+
subscribeToShadowState: (e, r) => (a((t) => {
|
|
25
|
+
const n = new Map(t.shadowStateSubscribers), s = n.get(e) || /* @__PURE__ */ new Set();
|
|
26
|
+
return s.add(r), n.set(e, s), { shadowStateSubscribers: n };
|
|
27
|
+
}), () => {
|
|
28
|
+
a((t) => {
|
|
29
|
+
const n = new Map(t.shadowStateSubscribers), s = n.get(e);
|
|
30
|
+
return s && (s.delete(r), s.size === 0 && n.delete(e)), { shadowStateSubscribers: n };
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
30
33
|
initializeShadowState: (e, r) => {
|
|
31
|
-
const t = (n) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const t = /* @__PURE__ */ new Map(), n = (s, o) => {
|
|
35
|
+
const d = [e, ...o].join(".");
|
|
36
|
+
if (Array.isArray(s)) {
|
|
37
|
+
const i = [];
|
|
38
|
+
s.forEach((c) => {
|
|
39
|
+
typeof c == "object" && c !== null && !c.id && (c.id = u());
|
|
40
|
+
const f = `id:${c.id}`;
|
|
41
|
+
i.push(f);
|
|
42
|
+
const p = [...o, f];
|
|
43
|
+
n(c, p);
|
|
44
|
+
});
|
|
45
|
+
const S = {
|
|
46
|
+
id: u(),
|
|
47
|
+
arrayKeys: i
|
|
48
|
+
};
|
|
49
|
+
t.set(d, S);
|
|
50
|
+
} else typeof s == "object" && s !== null ? (t.set(d, { id: u() }), Object.keys(s).forEach((i) => {
|
|
51
|
+
n(s[i], [...o, i]);
|
|
52
|
+
})) : t.set(d, { id: u() });
|
|
41
53
|
};
|
|
42
|
-
|
|
43
|
-
shadowStateStore: {
|
|
44
|
-
...n.shadowStateStore,
|
|
45
|
-
[e]: t(r)
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
54
|
+
n(r, []), a({ shadowStateStore: t });
|
|
48
55
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!a[e]) return n;
|
|
53
|
-
let o = a[e];
|
|
54
|
-
const i = [...r], l = i.pop();
|
|
55
|
-
for (const c of i)
|
|
56
|
-
o[c] || (o[c] = {}), o = o[c];
|
|
57
|
-
return l !== void 0 && (Array.isArray(t) ? o[l] = new Array(t.length) : typeof t == "object" && t !== null ? o[l] = {} : o[l] = o[l] || {}), { shadowStateStore: a };
|
|
58
|
-
});
|
|
56
|
+
getShadowMetadata: (e, r) => {
|
|
57
|
+
const t = [e, ...r].join(".");
|
|
58
|
+
return l().shadowStateStore.get(t);
|
|
59
59
|
},
|
|
60
|
-
|
|
61
|
-
s((n)
|
|
62
|
-
|
|
63
|
-
if (!a[e]) return n;
|
|
64
|
-
a[e] = JSON.parse(JSON.stringify(a[e]));
|
|
65
|
-
let o = a[e];
|
|
66
|
-
for (const i of r)
|
|
67
|
-
if (o = o[i], !o) return n;
|
|
68
|
-
if (Array.isArray(o)) {
|
|
69
|
-
const i = (l) => {
|
|
70
|
-
if (Array.isArray(l))
|
|
71
|
-
return l.map((c) => i(c));
|
|
72
|
-
if (typeof l == "object" && l !== null) {
|
|
73
|
-
const c = {};
|
|
74
|
-
for (const d in l)
|
|
75
|
-
c[d] = i(l[d]);
|
|
76
|
-
return c;
|
|
77
|
-
}
|
|
78
|
-
return {};
|
|
79
|
-
};
|
|
80
|
-
o.push(i(t));
|
|
81
|
-
}
|
|
82
|
-
return { shadowStateStore: a };
|
|
83
|
-
});
|
|
60
|
+
setShadowMetadata: (e, r, t) => {
|
|
61
|
+
const n = [e, ...r].join("."), s = new Map(l().shadowStateStore), o = s.get(n) || { id: u() };
|
|
62
|
+
s.set(n, { ...o, ...t }), a({ shadowStateStore: s }), t.virtualizer?.itemHeight && l().shadowStateSubscribers.get(e)?.forEach((i) => i());
|
|
84
63
|
},
|
|
85
|
-
|
|
86
|
-
s((
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
insertShadowArrayElement: (e, r, t) => {
|
|
65
|
+
const n = new Map(l().shadowStateStore), s = [e, ...r].join("."), o = n.get(s), d = l().getNestedState(e, r);
|
|
66
|
+
if (!o || !o.arrayKeys) return;
|
|
67
|
+
const i = `id:${t.id}`, S = d.findIndex((p) => p.id === t.id);
|
|
68
|
+
if (S === -1) return;
|
|
69
|
+
const c = [...o.arrayKeys];
|
|
70
|
+
c.splice(S, 0, i), n.set(s, { ...o, arrayKeys: c });
|
|
71
|
+
const f = (p, w) => {
|
|
72
|
+
const g = [e, ...w].join(".");
|
|
73
|
+
typeof p == "object" && p !== null ? (n.set(g, { id: u() }), Object.keys(p).forEach((y) => {
|
|
74
|
+
f(p[y], [...w, y]);
|
|
75
|
+
})) : n.set(g, { id: u() });
|
|
76
|
+
};
|
|
77
|
+
f(t, [...r, i]), a({ shadowStateStore: n });
|
|
93
78
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const n = new Map(t.shadowStateSubscribers), a = n.get(e);
|
|
102
|
-
return a && a.delete(r), { shadowStateSubscribers: n };
|
|
103
|
-
});
|
|
104
|
-
}),
|
|
105
|
-
setShadowMetadata: (e, r, t) => {
|
|
106
|
-
let n = !1;
|
|
107
|
-
if (s((a) => {
|
|
108
|
-
const o = { ...a.shadowStateStore };
|
|
109
|
-
if (!o[e]) return a;
|
|
110
|
-
o[e] = JSON.parse(JSON.stringify(o[e]));
|
|
111
|
-
let i = o[e];
|
|
112
|
-
for (const d of r)
|
|
113
|
-
i[d] || (i[d] = {}), i = i[d];
|
|
114
|
-
const l = i.virtualizer?.itemHeight, c = t.virtualizer?.itemHeight;
|
|
115
|
-
return c && l !== c && (n = !0, i.virtualizer || (i.virtualizer = {}), i.virtualizer.itemHeight = c), { shadowStateStore: o };
|
|
116
|
-
}), n) {
|
|
117
|
-
const a = S().shadowStateSubscribers.get(e);
|
|
118
|
-
a && a.forEach((o) => o());
|
|
79
|
+
removeShadowArrayElement: (e, r) => {
|
|
80
|
+
const t = new Map(l().shadowStateStore), n = [e, ...r].join("."), s = r[r.length - 1], o = r.slice(0, -1), d = [e, ...o].join("."), i = t.get(d);
|
|
81
|
+
if (i && i.arrayKeys) {
|
|
82
|
+
const c = i.arrayKeys.filter(
|
|
83
|
+
(f) => f !== s
|
|
84
|
+
);
|
|
85
|
+
t.set(d, { ...i, arrayKeys: c });
|
|
119
86
|
}
|
|
87
|
+
const S = n + ".";
|
|
88
|
+
for (const c of Array.from(t.keys()))
|
|
89
|
+
(c === n || c.startsWith(S)) && t.delete(c);
|
|
90
|
+
a({ shadowStateStore: t });
|
|
91
|
+
},
|
|
92
|
+
updateShadowAtPath: (e, r, t) => {
|
|
93
|
+
const n = [e, ...r].join("."), s = new Map(l().shadowStateStore), o = s.get(n) || { id: u() };
|
|
94
|
+
s.set(n, { ...o, lastUpdated: Date.now() }), a({ shadowStateStore: s });
|
|
120
95
|
},
|
|
121
96
|
selectedIndicesMap: /* @__PURE__ */ new Map(),
|
|
122
97
|
// Add the new methods
|
|
123
98
|
getSelectedIndex: (e, r) => {
|
|
124
|
-
const t =
|
|
99
|
+
const t = l().selectedIndicesMap.get(e);
|
|
125
100
|
if (t)
|
|
126
101
|
return t.get(r);
|
|
127
102
|
},
|
|
128
103
|
setSelectedIndex: (e, r, t) => {
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
let o =
|
|
132
|
-
return o || (o = /* @__PURE__ */ new Map(),
|
|
104
|
+
a((n) => {
|
|
105
|
+
const s = new Map(n.selectedIndicesMap);
|
|
106
|
+
let o = s.get(e);
|
|
107
|
+
return o || (o = /* @__PURE__ */ new Map(), s.set(e, o)), t === void 0 ? o.delete(r) : o.set(r, t), {
|
|
133
108
|
...n,
|
|
134
|
-
selectedIndicesMap:
|
|
109
|
+
selectedIndicesMap: s
|
|
135
110
|
};
|
|
136
111
|
});
|
|
137
112
|
},
|
|
@@ -139,18 +114,18 @@ const w = u((s, S) => ({
|
|
|
139
114
|
stateKey: e,
|
|
140
115
|
path: r
|
|
141
116
|
}) => {
|
|
142
|
-
|
|
143
|
-
const n = new Map(t.selectedIndicesMap),
|
|
144
|
-
if (!
|
|
117
|
+
a((t) => {
|
|
118
|
+
const n = new Map(t.selectedIndicesMap), s = n.get(e);
|
|
119
|
+
if (!s) return t;
|
|
145
120
|
const o = r.join(".");
|
|
146
|
-
return
|
|
121
|
+
return s.delete(o), {
|
|
147
122
|
...t,
|
|
148
123
|
selectedIndicesMap: n
|
|
149
124
|
};
|
|
150
125
|
});
|
|
151
126
|
},
|
|
152
127
|
clearSelectedIndexesForState: (e) => {
|
|
153
|
-
|
|
128
|
+
a((r) => {
|
|
154
129
|
const t = new Map(r.selectedIndicesMap);
|
|
155
130
|
return t.delete(e) ? (console.log(
|
|
156
131
|
`Cleared selected indices map entry for stateKey: ${e}`
|
|
@@ -158,16 +133,16 @@ const w = u((s, S) => ({
|
|
|
158
133
|
});
|
|
159
134
|
},
|
|
160
135
|
stateComponents: /* @__PURE__ */ new Map(),
|
|
161
|
-
subscribe: (e) =>
|
|
136
|
+
subscribe: (e) => l().subscribe(e),
|
|
162
137
|
reactiveDeps: {},
|
|
163
|
-
setReactiveDeps: (e, r) =>
|
|
138
|
+
setReactiveDeps: (e, r) => a((t) => ({
|
|
164
139
|
...t,
|
|
165
140
|
reactiveDeps: {
|
|
166
141
|
...t.reactiveDeps,
|
|
167
142
|
[e]: r
|
|
168
143
|
}
|
|
169
144
|
})),
|
|
170
|
-
deleteReactiveDeps: (e) =>
|
|
145
|
+
deleteReactiveDeps: (e) => a((r) => {
|
|
171
146
|
const { [e]: t, ...n } = r.reactiveDeps;
|
|
172
147
|
return {
|
|
173
148
|
...r,
|
|
@@ -177,14 +152,14 @@ const w = u((s, S) => ({
|
|
|
177
152
|
reRenderTriggerPrevValue: {},
|
|
178
153
|
signalDomElements: /* @__PURE__ */ new Map(),
|
|
179
154
|
addSignalElement: (e, r) => {
|
|
180
|
-
const t =
|
|
181
|
-
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(r),
|
|
155
|
+
const t = l().signalDomElements;
|
|
156
|
+
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(r), a({ signalDomElements: new Map(t) });
|
|
182
157
|
},
|
|
183
158
|
removeSignalElement: (e, r) => {
|
|
184
|
-
const t =
|
|
185
|
-
n && n.forEach((
|
|
186
|
-
|
|
187
|
-
}),
|
|
159
|
+
const t = l().signalDomElements, n = t.get(e);
|
|
160
|
+
n && n.forEach((s) => {
|
|
161
|
+
s.instanceId === r && n.delete(s);
|
|
162
|
+
}), a({ signalDomElements: new Map(t) });
|
|
188
163
|
},
|
|
189
164
|
initialStateOptions: {},
|
|
190
165
|
updaterState: {},
|
|
@@ -195,7 +170,7 @@ const w = u((s, S) => ({
|
|
|
195
170
|
initialStateGlobal: {},
|
|
196
171
|
iniitialCreatedState: {},
|
|
197
172
|
updateInitialCreatedState: (e, r) => {
|
|
198
|
-
|
|
173
|
+
a((t) => ({
|
|
199
174
|
iniitialCreatedState: {
|
|
200
175
|
...t.iniitialCreatedState,
|
|
201
176
|
[e]: r
|
|
@@ -208,7 +183,7 @@ const w = u((s, S) => ({
|
|
|
208
183
|
serverSyncLog: {},
|
|
209
184
|
serverSideOrNot: {},
|
|
210
185
|
setServerSyncLog: (e, r) => {
|
|
211
|
-
|
|
186
|
+
a((t) => ({
|
|
212
187
|
serverSyncLog: {
|
|
213
188
|
...t.serverSyncLog,
|
|
214
189
|
[e]: [...t.serverSyncLog[e] ?? [], r]
|
|
@@ -216,17 +191,17 @@ const w = u((s, S) => ({
|
|
|
216
191
|
}));
|
|
217
192
|
},
|
|
218
193
|
setServerSideOrNot: (e, r) => {
|
|
219
|
-
|
|
194
|
+
a((t) => ({
|
|
220
195
|
serverSideOrNot: {
|
|
221
196
|
...t.serverSideOrNot,
|
|
222
197
|
[e]: r
|
|
223
198
|
}
|
|
224
199
|
}));
|
|
225
200
|
},
|
|
226
|
-
getServerSideOrNot: (e) =>
|
|
227
|
-
getThisLocalUpdate: (e) =>
|
|
201
|
+
getServerSideOrNot: (e) => l().serverSideOrNot[e],
|
|
202
|
+
getThisLocalUpdate: (e) => l().stateLog[e],
|
|
228
203
|
setServerState: (e, r) => {
|
|
229
|
-
|
|
204
|
+
a((t) => ({
|
|
230
205
|
serverState: {
|
|
231
206
|
...t.serverState,
|
|
232
207
|
[e]: r
|
|
@@ -234,18 +209,18 @@ const w = u((s, S) => ({
|
|
|
234
209
|
}));
|
|
235
210
|
},
|
|
236
211
|
setStateLog: (e, r) => {
|
|
237
|
-
|
|
238
|
-
const n = t.stateLog[e] ?? [],
|
|
212
|
+
a((t) => {
|
|
213
|
+
const n = t.stateLog[e] ?? [], s = r(n);
|
|
239
214
|
return {
|
|
240
215
|
stateLog: {
|
|
241
216
|
...t.stateLog,
|
|
242
|
-
[e]:
|
|
217
|
+
[e]: s
|
|
243
218
|
}
|
|
244
219
|
};
|
|
245
220
|
});
|
|
246
221
|
},
|
|
247
222
|
setIsLoadingGlobal: (e, r) => {
|
|
248
|
-
|
|
223
|
+
a((t) => ({
|
|
249
224
|
isLoadingGlobal: {
|
|
250
225
|
...t.isLoadingGlobal,
|
|
251
226
|
[e]: r
|
|
@@ -253,7 +228,7 @@ const w = u((s, S) => ({
|
|
|
253
228
|
}));
|
|
254
229
|
},
|
|
255
230
|
setServerSyncActions: (e, r) => {
|
|
256
|
-
|
|
231
|
+
a((t) => ({
|
|
257
232
|
serverSyncActions: {
|
|
258
233
|
...t.serverSyncActions,
|
|
259
234
|
[e]: r
|
|
@@ -261,84 +236,88 @@ const w = u((s, S) => ({
|
|
|
261
236
|
}));
|
|
262
237
|
},
|
|
263
238
|
addValidationError: (e, r) => {
|
|
264
|
-
console.log("addValidationError---"),
|
|
265
|
-
const n = new Map(t.validationErrors),
|
|
266
|
-
return console.log("addValidationError", e, r,
|
|
239
|
+
console.log("addValidationError---"), a((t) => {
|
|
240
|
+
const n = new Map(t.validationErrors), s = n.get(e) || [];
|
|
241
|
+
return console.log("addValidationError", e, r, s), n.set(e, [...s, r]), { validationErrors: n };
|
|
267
242
|
});
|
|
268
243
|
},
|
|
269
244
|
removeValidationError: (e) => {
|
|
270
|
-
|
|
245
|
+
a((r) => {
|
|
271
246
|
const t = new Map(r.validationErrors);
|
|
272
247
|
let n = !1;
|
|
273
|
-
const
|
|
248
|
+
const s = e.split(".");
|
|
274
249
|
return Array.from(t.keys()).forEach((o) => {
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
let
|
|
278
|
-
for (let
|
|
279
|
-
if (
|
|
280
|
-
|
|
250
|
+
const d = o.split(".");
|
|
251
|
+
if (d.length >= s.length) {
|
|
252
|
+
let i = !0;
|
|
253
|
+
for (let S = 0; S < s.length; S++)
|
|
254
|
+
if (d[S] !== s[S]) {
|
|
255
|
+
i = !1;
|
|
281
256
|
break;
|
|
282
257
|
}
|
|
283
|
-
|
|
258
|
+
i && (n = !0, t.delete(o));
|
|
284
259
|
}
|
|
285
260
|
}), n ? { validationErrors: t } : r;
|
|
286
261
|
});
|
|
287
262
|
},
|
|
288
263
|
getValidationErrors: (e) => {
|
|
289
|
-
const r = [], t =
|
|
264
|
+
const r = [], t = l().validationErrors, n = e.split("."), s = (o, d) => o === "[*]" ? !0 : Array.isArray(o) ? o.includes(parseInt(d)) : o === d;
|
|
290
265
|
return Array.from(t.keys()).forEach((o) => {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
let
|
|
294
|
-
for (let
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
266
|
+
const d = o.split(".");
|
|
267
|
+
if (d.length >= n.length) {
|
|
268
|
+
let i = !0;
|
|
269
|
+
for (let S = 0; S < n.length; S++) {
|
|
270
|
+
const c = n[S], f = d[S];
|
|
271
|
+
if (c === "[*]" || Array.isArray(c)) {
|
|
297
272
|
const p = parseInt(f);
|
|
298
273
|
if (isNaN(p)) {
|
|
299
|
-
|
|
274
|
+
i = !1;
|
|
300
275
|
break;
|
|
301
276
|
}
|
|
302
|
-
if (!
|
|
303
|
-
|
|
277
|
+
if (!s(c, f)) {
|
|
278
|
+
i = !1;
|
|
304
279
|
break;
|
|
305
280
|
}
|
|
306
|
-
} else if (
|
|
307
|
-
|
|
281
|
+
} else if (c !== f) {
|
|
282
|
+
i = !1;
|
|
308
283
|
break;
|
|
309
284
|
}
|
|
310
285
|
}
|
|
311
|
-
if (
|
|
312
|
-
const
|
|
313
|
-
|
|
286
|
+
if (i) {
|
|
287
|
+
const S = t.get(o);
|
|
288
|
+
S && r.push(...S);
|
|
314
289
|
}
|
|
315
290
|
}
|
|
316
291
|
}), r;
|
|
317
292
|
},
|
|
318
|
-
getInitialOptions: (e) =>
|
|
293
|
+
getInitialOptions: (e) => l().initialStateOptions[e],
|
|
319
294
|
getNestedState: (e, r) => {
|
|
320
|
-
const t =
|
|
321
|
-
if (o.length === 0
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
295
|
+
const t = l().cogsStateStore[e], n = (s, o) => {
|
|
296
|
+
if (o.length === 0 || s === void 0)
|
|
297
|
+
return s;
|
|
298
|
+
const d = o[0], i = o.slice(1);
|
|
299
|
+
if (Array.isArray(s) && typeof d == "string" && d.startsWith("id:")) {
|
|
300
|
+
const c = d.split(":")[1], f = s.find(
|
|
301
|
+
(p) => p && String(p.id) === c
|
|
302
|
+
);
|
|
303
|
+
return n(f, i);
|
|
304
|
+
}
|
|
305
|
+
if (d === "[*]") {
|
|
306
|
+
if (!Array.isArray(s)) {
|
|
325
307
|
console.warn("Asterisk notation used on non-array value");
|
|
326
308
|
return;
|
|
327
309
|
}
|
|
328
|
-
if (
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
);
|
|
332
|
-
return Array.isArray(d[0]) ? d.flat() : d;
|
|
310
|
+
if (i.length === 0) return s;
|
|
311
|
+
const c = s.map((f) => n(f, i));
|
|
312
|
+
return Array.isArray(c[0]) ? c.flat() : c;
|
|
333
313
|
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
return n(c, l);
|
|
314
|
+
const S = s[d];
|
|
315
|
+
return n(S, i);
|
|
337
316
|
};
|
|
338
317
|
return n(t, r);
|
|
339
318
|
},
|
|
340
319
|
setInitialStateOptions: (e, r) => {
|
|
341
|
-
|
|
320
|
+
a((t) => ({
|
|
342
321
|
initialStateOptions: {
|
|
343
322
|
...t.initialStateOptions,
|
|
344
323
|
[e]: r
|
|
@@ -346,21 +325,21 @@ const w = u((s, S) => ({
|
|
|
346
325
|
}));
|
|
347
326
|
},
|
|
348
327
|
updateInitialStateGlobal: (e, r) => {
|
|
349
|
-
|
|
328
|
+
a((t) => ({
|
|
350
329
|
initialStateGlobal: {
|
|
351
330
|
...t.initialStateGlobal,
|
|
352
331
|
[e]: r
|
|
353
332
|
}
|
|
354
333
|
}));
|
|
355
334
|
},
|
|
356
|
-
getUpdaterState: (e) =>
|
|
335
|
+
getUpdaterState: (e) => l().updaterState[e],
|
|
357
336
|
setUpdaterState: (e, r) => {
|
|
358
|
-
const t =
|
|
359
|
-
!e || !r ||
|
|
337
|
+
const t = l().updaterState;
|
|
338
|
+
!e || !r || a({ updaterState: { ...t ?? {}, [e]: r } });
|
|
360
339
|
},
|
|
361
|
-
getKeyState: (e) =>
|
|
340
|
+
getKeyState: (e) => l().cogsStateStore[e],
|
|
362
341
|
setState: (e, r) => {
|
|
363
|
-
|
|
342
|
+
a((t) => ({
|
|
364
343
|
cogsStateStore: {
|
|
365
344
|
...t.cogsStateStore,
|
|
366
345
|
[e]: typeof r == "function" ? r(t.cogsStateStore[e]) : r
|
|
@@ -368,7 +347,7 @@ const w = u((s, S) => ({
|
|
|
368
347
|
}));
|
|
369
348
|
},
|
|
370
349
|
setInitialStates: (e) => {
|
|
371
|
-
|
|
350
|
+
a((r) => ({
|
|
372
351
|
cogsStateStore: {
|
|
373
352
|
...r.cogsStateStore,
|
|
374
353
|
...e
|
|
@@ -376,7 +355,7 @@ const w = u((s, S) => ({
|
|
|
376
355
|
}));
|
|
377
356
|
},
|
|
378
357
|
setCreatedState: (e) => {
|
|
379
|
-
|
|
358
|
+
a((r) => ({
|
|
380
359
|
iniitialCreatedState: {
|
|
381
360
|
...r.cogsStateStore,
|
|
382
361
|
...e
|
|
@@ -384,14 +363,14 @@ const w = u((s, S) => ({
|
|
|
384
363
|
}));
|
|
385
364
|
},
|
|
386
365
|
syncInfoStore: /* @__PURE__ */ new Map(),
|
|
387
|
-
setSyncInfo: (e, r) =>
|
|
366
|
+
setSyncInfo: (e, r) => a((t) => {
|
|
388
367
|
const n = new Map(t.syncInfoStore);
|
|
389
368
|
return n.set(e, r), { ...t, syncInfoStore: n };
|
|
390
369
|
}),
|
|
391
|
-
getSyncInfo: (e) =>
|
|
370
|
+
getSyncInfo: (e) => l().syncInfoStore.get(e) || null
|
|
392
371
|
}));
|
|
393
372
|
export {
|
|
394
|
-
|
|
395
|
-
|
|
373
|
+
b as formRefStore,
|
|
374
|
+
I as getGlobalStore
|
|
396
375
|
};
|
|
397
376
|
//# sourceMappingURL=store.js.map
|