cogsbox-state 0.5.282 → 0.5.283
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 +31 -31
- package/dist/CogsState.jsx.map +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.js +65 -49
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +2 -1
- package/src/store.ts +33 -5
package/dist/CogsState.jsx
CHANGED
|
@@ -52,7 +52,7 @@ const ae = (t, c) => {
|
|
|
52
52
|
options: a,
|
|
53
53
|
initialOptionsPart: v
|
|
54
54
|
});
|
|
55
|
-
const r = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(r) : r, [
|
|
55
|
+
const r = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(r) : r, [W, O] = Lt(
|
|
56
56
|
S,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -193,8 +193,8 @@ function Lt(t, {
|
|
|
193
193
|
dependencies: r,
|
|
194
194
|
serverState: S
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
197
|
-
let
|
|
196
|
+
const [W, O] = K({}), { sessionId: R } = $t();
|
|
197
|
+
let G = !c;
|
|
198
198
|
const [m] = K(c ?? yt()), l = o.getState().stateLog[m], ot = q(/* @__PURE__ */ new Set()), Y = q(I ?? yt()), j = q(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
@@ -238,7 +238,7 @@ function Lt(t, {
|
|
|
238
238
|
S?.data,
|
|
239
239
|
...r || []
|
|
240
240
|
]), it(() => {
|
|
241
|
-
|
|
241
|
+
G && pt(m, {
|
|
242
242
|
serverSync: h,
|
|
243
243
|
formElements: v,
|
|
244
244
|
initialState: a,
|
|
@@ -363,7 +363,7 @@ function Lt(t, {
|
|
|
363
363
|
const T = n.slice(0, -1), _ = z(E, T);
|
|
364
364
|
return N === n.length - 1 && ["insert", "cut"].includes(s.updateType) ? (_.length - 1).toString() : M;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue: V, newValue:
|
|
366
|
+
const { oldValue: V, newValue: D } = Gt(
|
|
367
367
|
s.updateType,
|
|
368
368
|
u,
|
|
369
369
|
E,
|
|
@@ -375,7 +375,7 @@ function Lt(t, {
|
|
|
375
375
|
updateType: s.updateType,
|
|
376
376
|
status: "new",
|
|
377
377
|
oldValue: V,
|
|
378
|
-
newValue:
|
|
378
|
+
newValue: D
|
|
379
379
|
};
|
|
380
380
|
switch (s.updateType) {
|
|
381
381
|
case "update":
|
|
@@ -383,7 +383,7 @@ function Lt(t, {
|
|
|
383
383
|
break;
|
|
384
384
|
case "insert":
|
|
385
385
|
const M = n.slice(0, -1);
|
|
386
|
-
g.insertShadowArrayElement(m, M);
|
|
386
|
+
g.insertShadowArrayElement(m, M, D);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
389
|
const N = n.slice(0, -1), T = parseInt(n[n.length - 1]);
|
|
@@ -450,8 +450,8 @@ function lt(t, c, h, f) {
|
|
|
450
450
|
r?.key && H(r?.key), y?.validationKey && H(y.validationKey);
|
|
451
451
|
const S = o.getState().initialStateGlobal[t];
|
|
452
452
|
o.getState().clearSelectedIndexesForState(t), v.clear(), k++;
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const W = a(S, []), O = Q(t), R = J(O?.localStorage?.key) ? O?.localStorage?.key(S) : O?.localStorage?.key, G = `${f}-${t}-${R}`;
|
|
454
|
+
G && localStorage.removeItem(G), ct(t, W), Z(t, S);
|
|
455
455
|
const m = o.getState().stateComponents.get(t);
|
|
456
456
|
return m && m.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -464,15 +464,15 @@ function lt(t, c, h, f) {
|
|
|
464
464
|
c,
|
|
465
465
|
h,
|
|
466
466
|
f
|
|
467
|
-
), S = o.getState().initialStateGlobal[t],
|
|
467
|
+
), S = o.getState().initialStateGlobal[t], W = Q(t), O = J(W?.localStorage?.key) ? W?.localStorage?.key(S) : W?.localStorage?.key, R = `${f}-${t}-${O}`;
|
|
468
468
|
return localStorage.getItem(R) && localStorage.removeItem(R), Vt(() => {
|
|
469
469
|
vt(t, y), o.getState().initializeShadowState(t, y), ct(t, r), Z(t, y);
|
|
470
|
-
const
|
|
471
|
-
|
|
470
|
+
const G = o.getState().stateComponents.get(t);
|
|
471
|
+
G && G.components.forEach((m) => {
|
|
472
472
|
m.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (G) => r.get()[G]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: o.getState().initialStateGlobal[t],
|
|
@@ -484,8 +484,8 @@ function lt(t, c, h, f) {
|
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(y, r = [], S) {
|
|
487
|
-
const
|
|
488
|
-
v.get(
|
|
487
|
+
const W = r.map(String).join(".");
|
|
488
|
+
v.get(W);
|
|
489
489
|
const O = function() {
|
|
490
490
|
return o().getNestedState(t, r);
|
|
491
491
|
};
|
|
@@ -629,7 +629,7 @@ function lt(t, c, h, f) {
|
|
|
629
629
|
const w = q(i), $ = q(0), x = q(!0), C = o().getNestedState(
|
|
630
630
|
t,
|
|
631
631
|
r
|
|
632
|
-
), V = C.length,
|
|
632
|
+
), V = C.length, D = Tt(() => {
|
|
633
633
|
const T = Math.max(0, u.startIndex), _ = Math.min(V, u.endIndex), A = Array.from(
|
|
634
634
|
{ length: _ - T },
|
|
635
635
|
(b, U) => T + U
|
|
@@ -702,7 +702,7 @@ function lt(t, c, h, f) {
|
|
|
702
702
|
}
|
|
703
703
|
};
|
|
704
704
|
return {
|
|
705
|
-
virtualState:
|
|
705
|
+
virtualState: D,
|
|
706
706
|
virtualizerProps: N,
|
|
707
707
|
scrollToBottom: B,
|
|
708
708
|
scrollToIndex: M
|
|
@@ -741,13 +741,13 @@ function lt(t, c, h, f) {
|
|
|
741
741
|
register: () => {
|
|
742
742
|
const [, x] = K({}), C = `${h}-${r.join(".")}-${i}`;
|
|
743
743
|
it(() => {
|
|
744
|
-
const V = `${t}////${C}`,
|
|
744
|
+
const V = `${t}////${C}`, D = o.getState().stateComponents.get(t) || {
|
|
745
745
|
components: /* @__PURE__ */ new Map()
|
|
746
746
|
};
|
|
747
|
-
return
|
|
747
|
+
return D.components.set(V, {
|
|
748
748
|
forceUpdate: () => x({}),
|
|
749
749
|
paths: /* @__PURE__ */ new Set([E.join(".")])
|
|
750
|
-
}), o.getState().stateComponents.set(t,
|
|
750
|
+
}), o.getState().stateComponents.set(t, D), () => {
|
|
751
751
|
const B = o.getState().stateComponents.get(t);
|
|
752
752
|
B && B.components.delete(V);
|
|
753
753
|
};
|
|
@@ -987,8 +987,8 @@ function lt(t, c, h, f) {
|
|
|
987
987
|
}
|
|
988
988
|
let V = C.lastIndexOf(".");
|
|
989
989
|
for (; V !== -1; ) {
|
|
990
|
-
const
|
|
991
|
-
if (w.paths.has(
|
|
990
|
+
const D = C.substring(0, V);
|
|
991
|
+
if (w.paths.has(D)) {
|
|
992
992
|
$ = !0;
|
|
993
993
|
break;
|
|
994
994
|
}
|
|
@@ -996,9 +996,9 @@ function lt(t, c, h, f) {
|
|
|
996
996
|
V + 1
|
|
997
997
|
);
|
|
998
998
|
if (!isNaN(Number(B))) {
|
|
999
|
-
const M =
|
|
999
|
+
const M = D.lastIndexOf(".");
|
|
1000
1000
|
if (M !== -1) {
|
|
1001
|
-
const N =
|
|
1001
|
+
const N = D.substring(
|
|
1002
1002
|
0,
|
|
1003
1003
|
M
|
|
1004
1004
|
);
|
|
@@ -1008,7 +1008,7 @@ function lt(t, c, h, f) {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
|
-
V =
|
|
1011
|
+
V = D.lastIndexOf(".");
|
|
1012
1012
|
}
|
|
1013
1013
|
if ($) break;
|
|
1014
1014
|
}
|
|
@@ -1110,11 +1110,11 @@ function lt(t, c, h, f) {
|
|
|
1110
1110
|
const j = [...r, l], tt = o.getState().getNestedState(t, j);
|
|
1111
1111
|
return a(tt, j, S);
|
|
1112
1112
|
}
|
|
1113
|
-
},
|
|
1114
|
-
return v.set(
|
|
1115
|
-
proxy:
|
|
1113
|
+
}, G = new Proxy(O, R);
|
|
1114
|
+
return v.set(W, {
|
|
1115
|
+
proxy: G,
|
|
1116
1116
|
stateVersion: k
|
|
1117
|
-
}),
|
|
1117
|
+
}), G;
|
|
1118
1118
|
}
|
|
1119
1119
|
return a(
|
|
1120
1120
|
o.getState().getNestedState(t, [])
|
|
@@ -1166,8 +1166,8 @@ function Bt({
|
|
|
1166
1166
|
else
|
|
1167
1167
|
S = r;
|
|
1168
1168
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1169
|
-
const
|
|
1170
|
-
f.replaceWith(
|
|
1169
|
+
const W = document.createTextNode(String(S));
|
|
1170
|
+
f.replaceWith(W);
|
|
1171
1171
|
}, [t._stateKey, t._path.join("."), t._effect]), rt("span", {
|
|
1172
1172
|
ref: c,
|
|
1173
1173
|
style: { display: "none" },
|