cogsbox-state 0.5.435 → 0.5.436
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 +31 -25
- package/dist/CogsState.jsx +1237 -1141
- package/dist/CogsState.jsx.map +1 -1
- package/dist/CogsStateClient.jsx.map +1 -1
- package/dist/Functions.d.ts +1 -5
- package/dist/Functions.jsx +17 -48
- package/dist/Functions.jsx.map +1 -1
- package/dist/TRPCValidationLink.js.map +1 -1
- package/dist/store.d.ts +11 -0
- package/dist/store.js +245 -185
- package/dist/store.js.map +1 -1
- package/dist/utility.js.map +1 -1
- package/package.json +6 -5
- package/src/CogsState.tsx +417 -176
- package/src/Functions.tsx +8 -241
- package/src/TRPCValidationLink.ts +12 -12
- package/src/store.ts +195 -38
- package/dist/useValidateZodPath.d.ts +0 -34
- package/src/useValidateZodPath.ts +0 -231
package/dist/store.js
CHANGED
|
@@ -1,213 +1,273 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
import { ulid as
|
|
3
|
-
const
|
|
1
|
+
import { create as b } from "zustand";
|
|
2
|
+
import { ulid as u } from "ulid";
|
|
3
|
+
const A = b((c, f) => ({
|
|
4
4
|
formRefs: /* @__PURE__ */ new Map(),
|
|
5
|
-
registerFormRef: (
|
|
6
|
-
const e = new Map(
|
|
7
|
-
return e.set(
|
|
5
|
+
registerFormRef: (t, n) => c((o) => {
|
|
6
|
+
const e = new Map(o.formRefs);
|
|
7
|
+
return e.set(t, n), { formRefs: e };
|
|
8
8
|
}),
|
|
9
|
-
getFormRef: (
|
|
10
|
-
removeFormRef: (
|
|
11
|
-
const
|
|
12
|
-
return
|
|
9
|
+
getFormRef: (t) => f().formRefs.get(t),
|
|
10
|
+
removeFormRef: (t) => c((n) => {
|
|
11
|
+
const o = new Map(n.formRefs);
|
|
12
|
+
return o.delete(t), { formRefs: o };
|
|
13
13
|
}),
|
|
14
14
|
// Get all refs that start with the stateKey prefix
|
|
15
|
-
getFormRefsByStateKey: (
|
|
16
|
-
const
|
|
17
|
-
return
|
|
18
|
-
(
|
|
15
|
+
getFormRefsByStateKey: (t) => {
|
|
16
|
+
const n = f().formRefs, o = t + ".", e = /* @__PURE__ */ new Map();
|
|
17
|
+
return n.forEach((s, r) => {
|
|
18
|
+
(r.startsWith(o) || r === t) && e.set(r, s);
|
|
19
19
|
}), e;
|
|
20
20
|
}
|
|
21
|
-
})),
|
|
22
|
-
|
|
21
|
+
})), m = (c) => c === null || typeof c != "object" || c instanceof Uint8Array || c instanceof Int8Array || c instanceof Uint16Array || c instanceof Int16Array || c instanceof Uint32Array || c instanceof Int32Array || c instanceof Float32Array || c instanceof Float64Array || c instanceof ArrayBuffer || c instanceof Date || c instanceof RegExp || c instanceof Map || c instanceof Set ? !1 : Array.isArray(c) || c.constructor === Object, E = b((c, f) => ({
|
|
22
|
+
addPathComponent: (t, n, o) => {
|
|
23
|
+
c((e) => {
|
|
24
|
+
const s = new Map(e.shadowStateStore), r = [t, ...n].join("."), i = s.get(r) || {}, d = new Set(i.pathComponents);
|
|
25
|
+
d.add(o), s.set(r, { ...i, pathComponents: d });
|
|
26
|
+
const a = s.get(t) || {}, p = a.components?.get(o);
|
|
27
|
+
if (p) {
|
|
28
|
+
const S = new Set(p.paths);
|
|
29
|
+
S.add(r);
|
|
30
|
+
const h = { ...p, paths: S }, l = new Map(a.components);
|
|
31
|
+
l.set(o, h), s.set(t, {
|
|
32
|
+
...a,
|
|
33
|
+
components: l
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return { shadowStateStore: s };
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
registerComponent: (t, n, o) => {
|
|
40
|
+
c((e) => {
|
|
41
|
+
const s = new Map(e.shadowStateStore), r = s.get(t) || {}, i = new Map(r.components);
|
|
42
|
+
return i.set(n, o), s.set(t, { ...r, components: i }), { shadowStateStore: s };
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
unregisterComponent: (t, n) => {
|
|
46
|
+
c((o) => {
|
|
47
|
+
const e = new Map(o.shadowStateStore), s = e.get(t);
|
|
48
|
+
if (!s?.components)
|
|
49
|
+
return o;
|
|
50
|
+
const r = new Map(s.components);
|
|
51
|
+
return r.delete(n) ? (e.set(t, { ...s, components: r }), { shadowStateStore: e }) : o;
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
markAsDirty: (t, n, o = { bubble: !0 }) => {
|
|
23
55
|
const e = new Map(f().shadowStateStore);
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
const d = [
|
|
27
|
-
|
|
56
|
+
let s = !1;
|
|
57
|
+
const r = (i) => {
|
|
58
|
+
const d = [t, ...i].join("."), a = e.get(d);
|
|
59
|
+
a && a.isDirty !== !0 ? (e.set(d, { ...a, isDirty: !0 }), s = !0) : a || (e.set(d, { isDirty: !0 }), s = !0);
|
|
28
60
|
};
|
|
29
|
-
if (
|
|
30
|
-
let i = [...
|
|
61
|
+
if (r(n), o.bubble) {
|
|
62
|
+
let i = [...n];
|
|
31
63
|
for (; i.length > 0; )
|
|
32
|
-
i.pop(),
|
|
64
|
+
i.pop(), r(i);
|
|
33
65
|
}
|
|
34
|
-
|
|
66
|
+
s && c({ shadowStateStore: e });
|
|
35
67
|
},
|
|
36
68
|
serverStateUpdates: /* @__PURE__ */ new Map(),
|
|
37
|
-
setServerStateUpdate: (
|
|
38
|
-
|
|
39
|
-
const e = new Map(
|
|
40
|
-
return e.set(
|
|
41
|
-
}), f().notifyPathSubscribers(
|
|
69
|
+
setServerStateUpdate: (t, n) => {
|
|
70
|
+
c((o) => {
|
|
71
|
+
const e = new Map(o.serverStateUpdates);
|
|
72
|
+
return e.set(t, n), { serverStateUpdates: e };
|
|
73
|
+
}), f().notifyPathSubscribers(t, {
|
|
42
74
|
type: "SERVER_STATE_UPDATE",
|
|
43
|
-
serverState:
|
|
75
|
+
serverState: n
|
|
44
76
|
});
|
|
45
77
|
},
|
|
46
78
|
shadowStateStore: /* @__PURE__ */ new Map(),
|
|
47
79
|
pathSubscribers: /* @__PURE__ */ new Map(),
|
|
48
|
-
subscribeToPath: (
|
|
49
|
-
const
|
|
50
|
-
return e.add(
|
|
51
|
-
const
|
|
52
|
-
|
|
80
|
+
subscribeToPath: (t, n) => {
|
|
81
|
+
const o = f().pathSubscribers, e = o.get(t) || /* @__PURE__ */ new Set();
|
|
82
|
+
return e.add(n), o.set(t, e), () => {
|
|
83
|
+
const s = f().pathSubscribers.get(t);
|
|
84
|
+
s && (s.delete(n), s.size === 0 && f().pathSubscribers.delete(t));
|
|
53
85
|
};
|
|
54
86
|
},
|
|
55
|
-
notifyPathSubscribers: (
|
|
56
|
-
const e = f().pathSubscribers.get(
|
|
57
|
-
e && e.forEach((
|
|
87
|
+
notifyPathSubscribers: (t, n) => {
|
|
88
|
+
const e = f().pathSubscribers.get(t);
|
|
89
|
+
e && e.forEach((s) => s(n));
|
|
58
90
|
},
|
|
59
|
-
initializeShadowState: (
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
initializeShadowState: (t, n) => {
|
|
92
|
+
c((o) => {
|
|
93
|
+
const e = new Map(o.shadowStateStore), r = e.get(t)?.components, i = t + ".";
|
|
94
|
+
for (const a of Array.from(e.keys()))
|
|
95
|
+
(a === t || a.startsWith(i)) && e.delete(a);
|
|
96
|
+
const d = (a, p) => {
|
|
97
|
+
const S = [t, ...p].join(".");
|
|
98
|
+
if (Array.isArray(a)) {
|
|
99
|
+
const h = [];
|
|
100
|
+
a.forEach(() => {
|
|
101
|
+
const l = `id:${u()}`;
|
|
102
|
+
h.push(S + "." + l);
|
|
103
|
+
}), e.set(S, { arrayKeys: h }), a.forEach((l, y) => {
|
|
104
|
+
const w = h[y].split(".").pop();
|
|
105
|
+
d(l, [...p, w]);
|
|
106
|
+
});
|
|
107
|
+
} else if (m(a)) {
|
|
108
|
+
const h = Object.fromEntries(
|
|
109
|
+
Object.keys(a).map((l) => [l, S + "." + l])
|
|
110
|
+
);
|
|
111
|
+
e.set(S, { fields: h }), Object.keys(a).forEach((l) => {
|
|
112
|
+
d(a[l], [...p, l]);
|
|
113
|
+
});
|
|
114
|
+
} else
|
|
115
|
+
e.set(S, { value: a });
|
|
116
|
+
};
|
|
117
|
+
if (d(n, []), r) {
|
|
118
|
+
const a = e.get(t) || {};
|
|
119
|
+
e.set(t, {
|
|
120
|
+
...a,
|
|
121
|
+
components: r
|
|
77
122
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
e(s, []), a({ shadowStateStore: t });
|
|
123
|
+
}
|
|
124
|
+
return { shadowStateStore: e };
|
|
125
|
+
});
|
|
82
126
|
},
|
|
83
|
-
getShadowValue: (
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
88
|
-
if (
|
|
89
|
-
return (
|
|
90
|
-
if (
|
|
127
|
+
getShadowValue: (t, n) => {
|
|
128
|
+
const o = f().shadowStateStore.get(t);
|
|
129
|
+
if (o) {
|
|
130
|
+
if (o.value !== void 0)
|
|
131
|
+
return o.value;
|
|
132
|
+
if (o.arrayKeys)
|
|
133
|
+
return (n ?? o.arrayKeys).map((r) => f().getShadowValue(r));
|
|
134
|
+
if (o.fields) {
|
|
91
135
|
const e = {};
|
|
92
|
-
return Object.entries(
|
|
93
|
-
e[
|
|
136
|
+
return Object.entries(o.fields).forEach(([s, r]) => {
|
|
137
|
+
e[s] = f().getShadowValue(r);
|
|
94
138
|
}), e;
|
|
95
139
|
}
|
|
96
140
|
}
|
|
97
141
|
},
|
|
98
|
-
getShadowMetadata: (
|
|
99
|
-
const e = [
|
|
142
|
+
getShadowMetadata: (t, n, o) => {
|
|
143
|
+
const e = [t, ...n].join(".");
|
|
100
144
|
return f().shadowStateStore.get(e), f().shadowStateStore.get(e);
|
|
101
145
|
},
|
|
102
|
-
setShadowMetadata: (
|
|
103
|
-
const e = [
|
|
104
|
-
|
|
146
|
+
setShadowMetadata: (t, n, o) => {
|
|
147
|
+
const e = [t, ...n].join("."), s = f().shadowStateStore.get(e);
|
|
148
|
+
s?.components && !o.components && (console.group(
|
|
149
|
+
"%c🚨 RACE CONDITION DETECTED! 🚨",
|
|
150
|
+
"color: red; font-size: 18px; font-weight: bold;"
|
|
151
|
+
), console.error(
|
|
152
|
+
`An overwrite is about to happen on stateKey: "${t}" at path: [${n.join(", ")}]`
|
|
153
|
+
), console.log(
|
|
154
|
+
"The EXISTING metadata had a components map:",
|
|
155
|
+
s.components
|
|
156
|
+
), console.log(
|
|
157
|
+
"The NEW metadata is trying to save WITHOUT a components map:",
|
|
158
|
+
o
|
|
159
|
+
), console.log(
|
|
160
|
+
"%cStack trace to the function that caused this overwrite:",
|
|
161
|
+
"font-weight: bold;"
|
|
162
|
+
), console.trace(), console.groupEnd());
|
|
163
|
+
const r = new Map(f().shadowStateStore), i = { ...s || {}, ...o };
|
|
164
|
+
r.set(e, i), c({ shadowStateStore: r });
|
|
105
165
|
},
|
|
106
|
-
setTransformCache: (
|
|
107
|
-
const
|
|
108
|
-
i.transformCaches || (i.transformCaches = /* @__PURE__ */ new Map()), i.transformCaches.set(
|
|
166
|
+
setTransformCache: (t, n, o, e) => {
|
|
167
|
+
const s = [t, ...n].join("."), r = new Map(f().shadowStateStore), i = r.get(s) || {};
|
|
168
|
+
i.transformCaches || (i.transformCaches = /* @__PURE__ */ new Map()), i.transformCaches.set(o, e), r.set(s, i), c({ shadowStateStore: r });
|
|
109
169
|
},
|
|
110
|
-
insertShadowArrayElement: (
|
|
111
|
-
const e = new Map(f().shadowStateStore),
|
|
112
|
-
if (!
|
|
113
|
-
const i = `id:${
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
const
|
|
170
|
+
insertShadowArrayElement: (t, n, o) => {
|
|
171
|
+
const e = new Map(f().shadowStateStore), s = [t, ...n].join("."), r = e.get(s);
|
|
172
|
+
if (!r || !r.arrayKeys) return;
|
|
173
|
+
const i = `id:${u()}`, d = s + "." + i, a = [...r.arrayKeys];
|
|
174
|
+
a.push(d), e.set(s, { ...r, arrayKeys: a });
|
|
175
|
+
const p = (S, h) => {
|
|
176
|
+
const l = [t, ...h].join(".");
|
|
117
177
|
if (!Array.isArray(S)) if (typeof S == "object" && S !== null) {
|
|
118
|
-
const
|
|
119
|
-
Object.keys(S).map((
|
|
178
|
+
const y = Object.fromEntries(
|
|
179
|
+
Object.keys(S).map((w) => [w, l + "." + w])
|
|
120
180
|
);
|
|
121
|
-
e.set(
|
|
122
|
-
|
|
181
|
+
e.set(l, { fields: y }), Object.entries(S).forEach(([w, M]) => {
|
|
182
|
+
p(M, [...h, w]);
|
|
123
183
|
});
|
|
124
184
|
} else
|
|
125
|
-
e.set(
|
|
185
|
+
e.set(l, { value: S });
|
|
126
186
|
};
|
|
127
|
-
|
|
187
|
+
p(o, [...n, i]), c({ shadowStateStore: e }), f().notifyPathSubscribers(s, {
|
|
128
188
|
type: "INSERT",
|
|
129
|
-
path:
|
|
189
|
+
path: s,
|
|
130
190
|
itemKey: d
|
|
131
191
|
});
|
|
132
192
|
},
|
|
133
|
-
removeShadowArrayElement: (
|
|
134
|
-
const
|
|
193
|
+
removeShadowArrayElement: (t, n) => {
|
|
194
|
+
const o = new Map(f().shadowStateStore), e = [t, ...n].join("."), s = n.slice(0, -1), r = [t, ...s].join("."), i = o.get(r);
|
|
135
195
|
if (i && i.arrayKeys && i.arrayKeys.findIndex(
|
|
136
|
-
(
|
|
196
|
+
(a) => a === e
|
|
137
197
|
) !== -1) {
|
|
138
|
-
const
|
|
198
|
+
const a = i.arrayKeys.filter(
|
|
139
199
|
(S) => S !== e
|
|
140
200
|
);
|
|
141
|
-
|
|
201
|
+
o.set(r, {
|
|
142
202
|
...i,
|
|
143
|
-
arrayKeys:
|
|
203
|
+
arrayKeys: a
|
|
144
204
|
});
|
|
145
|
-
const
|
|
146
|
-
for (const S of Array.from(
|
|
147
|
-
(S === e || S.startsWith(
|
|
205
|
+
const p = e + ".";
|
|
206
|
+
for (const S of Array.from(o.keys()))
|
|
207
|
+
(S === e || S.startsWith(p)) && o.delete(S);
|
|
148
208
|
}
|
|
149
|
-
|
|
209
|
+
c({ shadowStateStore: o }), f().notifyPathSubscribers(r, {
|
|
150
210
|
type: "REMOVE",
|
|
151
|
-
path:
|
|
211
|
+
path: r,
|
|
152
212
|
itemKey: e
|
|
153
213
|
// The exact ID of the removed item
|
|
154
214
|
});
|
|
155
215
|
},
|
|
156
|
-
updateShadowAtPath: (
|
|
157
|
-
const e = new Map(f().shadowStateStore),
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
for (const
|
|
161
|
-
if (Object.prototype.hasOwnProperty.call(d,
|
|
162
|
-
const S =
|
|
163
|
-
S &&
|
|
216
|
+
updateShadowAtPath: (t, n, o) => {
|
|
217
|
+
const e = new Map(f().shadowStateStore), s = [t, ...n].join("."), r = (i, d) => {
|
|
218
|
+
const a = e.get(i);
|
|
219
|
+
if (m(d) && a && a.fields) {
|
|
220
|
+
for (const p in d)
|
|
221
|
+
if (Object.prototype.hasOwnProperty.call(d, p)) {
|
|
222
|
+
const S = a.fields[p], h = d[p];
|
|
223
|
+
S && r(S, h);
|
|
164
224
|
}
|
|
165
225
|
} else {
|
|
166
|
-
const
|
|
167
|
-
e.set(i, { ...
|
|
226
|
+
const p = e.get(i) || {};
|
|
227
|
+
e.set(i, { ...p, value: d });
|
|
168
228
|
}
|
|
169
229
|
};
|
|
170
|
-
|
|
230
|
+
r(s, o), f().notifyPathSubscribers(s, { type: "UPDATE", newValue: o }), c({ shadowStateStore: e });
|
|
171
231
|
},
|
|
172
232
|
selectedIndicesMap: /* @__PURE__ */ new Map(),
|
|
173
|
-
getSelectedIndex: (
|
|
174
|
-
const
|
|
175
|
-
if (!
|
|
176
|
-
const e =
|
|
177
|
-
return e ? e.indexOf(
|
|
233
|
+
getSelectedIndex: (t, n) => {
|
|
234
|
+
const o = f().selectedIndicesMap.get(t);
|
|
235
|
+
if (!o) return -1;
|
|
236
|
+
const e = n || E.getState().getShadowMetadata(t, [])?.arrayKeys;
|
|
237
|
+
return e ? e.indexOf(o) : -1;
|
|
178
238
|
},
|
|
179
|
-
setSelectedIndex: (
|
|
180
|
-
|
|
181
|
-
const e =
|
|
182
|
-
return
|
|
239
|
+
setSelectedIndex: (t, n) => {
|
|
240
|
+
c((o) => {
|
|
241
|
+
const e = o.selectedIndicesMap;
|
|
242
|
+
return n === void 0 ? e.delete(t) : (e.has(t) && f().notifyPathSubscribers(e.get(t), {
|
|
183
243
|
type: "THIS_UNSELECTED"
|
|
184
|
-
}), e.set(
|
|
244
|
+
}), e.set(t, n), f().notifyPathSubscribers(n, {
|
|
185
245
|
type: "THIS_SELECTED"
|
|
186
|
-
})), f().notifyPathSubscribers(
|
|
246
|
+
})), f().notifyPathSubscribers(t, {
|
|
187
247
|
type: "GET_SELECTED"
|
|
188
248
|
}), {
|
|
189
|
-
...
|
|
249
|
+
...o,
|
|
190
250
|
selectedIndicesMap: e
|
|
191
251
|
};
|
|
192
252
|
});
|
|
193
253
|
},
|
|
194
|
-
clearSelectedIndex: ({ arrayKey:
|
|
195
|
-
|
|
196
|
-
const
|
|
254
|
+
clearSelectedIndex: ({ arrayKey: t }) => {
|
|
255
|
+
c((n) => {
|
|
256
|
+
const o = n.selectedIndicesMap, e = o.get(t);
|
|
197
257
|
return e && f().notifyPathSubscribers(e, {
|
|
198
258
|
type: "CLEAR_SELECTION"
|
|
199
|
-
}),
|
|
259
|
+
}), o.delete(t), f().notifyPathSubscribers(t, {
|
|
200
260
|
type: "CLEAR_SELECTION"
|
|
201
261
|
}), {
|
|
202
|
-
...
|
|
203
|
-
selectedIndicesMap:
|
|
262
|
+
...n,
|
|
263
|
+
selectedIndicesMap: o
|
|
204
264
|
};
|
|
205
265
|
});
|
|
206
266
|
},
|
|
207
|
-
clearSelectedIndexesForState: (
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
return
|
|
267
|
+
clearSelectedIndexesForState: (t) => {
|
|
268
|
+
c((n) => {
|
|
269
|
+
const o = new Map(n.selectedIndicesMap);
|
|
270
|
+
return o.delete(t) ? { selectedIndicesMap: o } : {};
|
|
211
271
|
});
|
|
212
272
|
},
|
|
213
273
|
initialStateOptions: {},
|
|
@@ -216,98 +276,98 @@ const g = u((a, f) => ({
|
|
|
216
276
|
stateLog: {},
|
|
217
277
|
initialStateGlobal: {},
|
|
218
278
|
validationErrors: /* @__PURE__ */ new Map(),
|
|
219
|
-
setStateLog: (
|
|
220
|
-
|
|
221
|
-
const e =
|
|
279
|
+
setStateLog: (t, n) => {
|
|
280
|
+
c((o) => {
|
|
281
|
+
const e = o.stateLog[t] ?? [], s = n(e);
|
|
222
282
|
return {
|
|
223
283
|
stateLog: {
|
|
224
|
-
...
|
|
225
|
-
[
|
|
284
|
+
...o.stateLog,
|
|
285
|
+
[t]: s
|
|
226
286
|
}
|
|
227
287
|
};
|
|
228
288
|
});
|
|
229
289
|
},
|
|
230
|
-
addValidationError: (
|
|
231
|
-
|
|
232
|
-
const e = new Map(
|
|
233
|
-
return console.log("addValidationError",
|
|
290
|
+
addValidationError: (t, n) => {
|
|
291
|
+
c((o) => {
|
|
292
|
+
const e = new Map(o.validationErrors), s = e.get(t) || [];
|
|
293
|
+
return console.log("addValidationError", t, n, s), e.set(t, [...s, n]), { validationErrors: e };
|
|
234
294
|
});
|
|
235
295
|
},
|
|
236
|
-
removeValidationError: (
|
|
237
|
-
|
|
238
|
-
const
|
|
296
|
+
removeValidationError: (t) => {
|
|
297
|
+
c((n) => {
|
|
298
|
+
const o = new Map(n.validationErrors);
|
|
239
299
|
let e = !1;
|
|
240
|
-
const
|
|
241
|
-
return Array.from(
|
|
242
|
-
const i =
|
|
243
|
-
if (i.length >=
|
|
300
|
+
const s = t.split(".");
|
|
301
|
+
return Array.from(o.keys()).forEach((r) => {
|
|
302
|
+
const i = r.split(".");
|
|
303
|
+
if (i.length >= s.length) {
|
|
244
304
|
let d = !0;
|
|
245
|
-
for (let
|
|
246
|
-
if (i[
|
|
305
|
+
for (let a = 0; a < s.length; a++)
|
|
306
|
+
if (i[a] !== s[a]) {
|
|
247
307
|
d = !1;
|
|
248
308
|
break;
|
|
249
309
|
}
|
|
250
|
-
d && (e = !0,
|
|
310
|
+
d && (e = !0, o.delete(r));
|
|
251
311
|
}
|
|
252
|
-
}), e ? { validationErrors:
|
|
312
|
+
}), e ? { validationErrors: o } : n;
|
|
253
313
|
});
|
|
254
314
|
},
|
|
255
|
-
getValidationErrors: (
|
|
256
|
-
const
|
|
257
|
-
return Array.from(
|
|
258
|
-
const i =
|
|
315
|
+
getValidationErrors: (t) => {
|
|
316
|
+
const n = [], o = f().validationErrors, e = t.split("."), s = (r, i) => r === "[*]" ? !0 : Array.isArray(r) ? r.includes(parseInt(i)) : r === i;
|
|
317
|
+
return Array.from(o.keys()).forEach((r) => {
|
|
318
|
+
const i = r.split(".");
|
|
259
319
|
if (i.length >= e.length) {
|
|
260
320
|
let d = !0;
|
|
261
|
-
for (let
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
const
|
|
265
|
-
if (isNaN(
|
|
321
|
+
for (let a = 0; a < e.length; a++) {
|
|
322
|
+
const p = e[a], S = i[a];
|
|
323
|
+
if (p === "[*]" || Array.isArray(p)) {
|
|
324
|
+
const h = parseInt(S);
|
|
325
|
+
if (isNaN(h)) {
|
|
266
326
|
d = !1;
|
|
267
327
|
break;
|
|
268
328
|
}
|
|
269
|
-
if (!
|
|
329
|
+
if (!s(p, S)) {
|
|
270
330
|
d = !1;
|
|
271
331
|
break;
|
|
272
332
|
}
|
|
273
|
-
} else if (
|
|
333
|
+
} else if (p !== S) {
|
|
274
334
|
d = !1;
|
|
275
335
|
break;
|
|
276
336
|
}
|
|
277
337
|
}
|
|
278
338
|
if (d) {
|
|
279
|
-
const
|
|
280
|
-
|
|
339
|
+
const a = o.get(r);
|
|
340
|
+
a && n.push(...a);
|
|
281
341
|
}
|
|
282
342
|
}
|
|
283
|
-
}),
|
|
343
|
+
}), n;
|
|
284
344
|
},
|
|
285
|
-
getInitialOptions: (
|
|
286
|
-
setInitialStateOptions: (
|
|
287
|
-
|
|
345
|
+
getInitialOptions: (t) => f().initialStateOptions[t],
|
|
346
|
+
setInitialStateOptions: (t, n) => {
|
|
347
|
+
c((o) => ({
|
|
288
348
|
initialStateOptions: {
|
|
289
|
-
...
|
|
290
|
-
[
|
|
349
|
+
...o.initialStateOptions,
|
|
350
|
+
[t]: n
|
|
291
351
|
}
|
|
292
352
|
}));
|
|
293
353
|
},
|
|
294
|
-
updateInitialStateGlobal: (
|
|
295
|
-
|
|
354
|
+
updateInitialStateGlobal: (t, n) => {
|
|
355
|
+
c((o) => ({
|
|
296
356
|
initialStateGlobal: {
|
|
297
|
-
...
|
|
298
|
-
[
|
|
357
|
+
...o.initialStateGlobal,
|
|
358
|
+
[t]: n
|
|
299
359
|
}
|
|
300
360
|
}));
|
|
301
361
|
},
|
|
302
362
|
syncInfoStore: /* @__PURE__ */ new Map(),
|
|
303
|
-
setSyncInfo: (
|
|
304
|
-
const e = new Map(
|
|
305
|
-
return e.set(
|
|
363
|
+
setSyncInfo: (t, n) => c((o) => {
|
|
364
|
+
const e = new Map(o.syncInfoStore);
|
|
365
|
+
return e.set(t, n), { ...o, syncInfoStore: e };
|
|
306
366
|
}),
|
|
307
|
-
getSyncInfo: (
|
|
367
|
+
getSyncInfo: (t) => f().syncInfoStore.get(t) || null
|
|
308
368
|
}));
|
|
309
369
|
export {
|
|
310
|
-
|
|
311
|
-
|
|
370
|
+
A as formRefStore,
|
|
371
|
+
E as getGlobalStore
|
|
312
372
|
};
|
|
313
373
|
//# sourceMappingURL=store.js.map
|