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