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