react-state-custom 1.0.20 → 1.0.22
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/DevToolState.d.ts +4 -0
- package/dist/index.es.js +97 -94
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/react-state-custom.css +1 -1
- package/package.json +1 -1
- package/src/DevTool.css +24 -5
- package/src/DevToolState.tsx +15 -12
- package/src/Test.tsx +21 -2
package/dist/DevToolState.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export declare const DevToolState: ({}: {}) => import("react/jsx-runtime").JSX.E
|
|
|
3
3
|
export declare const StateView: React.FC<{
|
|
4
4
|
dataKey: string;
|
|
5
5
|
}>;
|
|
6
|
+
export declare const ChangeFlashWrappper: React.FC<React.ComponentProps<'div'> & {
|
|
7
|
+
value: any;
|
|
8
|
+
deepCompare?: boolean;
|
|
9
|
+
}>;
|
|
6
10
|
export declare const JSONView: React.FC<{
|
|
7
11
|
value: any;
|
|
8
12
|
name?: string;
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { jsx as o, Fragment as
|
|
3
|
-
function
|
|
1
|
+
import { useRef as O, useMemo as g, useEffect as f, useState as v, useCallback as A, Fragment as G, createElement as J } from "react";
|
|
2
|
+
import { jsx as o, Fragment as y, jsxs as m } from "react/jsx-runtime";
|
|
3
|
+
function w(t, e) {
|
|
4
4
|
let n = null, a = function(...r) {
|
|
5
5
|
n && clearTimeout(n), n = setTimeout(() => {
|
|
6
6
|
t(...r);
|
|
@@ -8,7 +8,7 @@ function C(t, e) {
|
|
|
8
8
|
};
|
|
9
9
|
return a.cancel = () => clearTimeout(n), a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function H(t) {
|
|
12
12
|
const e = /* @__PURE__ */ new Map(), n = function(...a) {
|
|
13
13
|
const r = JSON.stringify(a);
|
|
14
14
|
if (e.has(r))
|
|
@@ -18,8 +18,8 @@ function J(t) {
|
|
|
18
18
|
};
|
|
19
19
|
return n.cache = e, n;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const { current: { computedHash: e } } =
|
|
21
|
+
const D = () => Math.random().toString().slice(2), L = (t) => {
|
|
22
|
+
const { current: { computedHash: e } } = O({
|
|
23
23
|
/**
|
|
24
24
|
* Getter for the computed hash function.
|
|
25
25
|
*
|
|
@@ -28,21 +28,21 @@ const V = () => Math.random().toString().slice(2), H = (t) => {
|
|
|
28
28
|
* - Updates the hash if any difference is detected.
|
|
29
29
|
*/
|
|
30
30
|
get computedHash() {
|
|
31
|
-
let n = [], a =
|
|
31
|
+
let n = [], a = D();
|
|
32
32
|
return (r) => {
|
|
33
33
|
let s = !1;
|
|
34
|
-
return s = s || !r != !n, s = s || r?.length != n?.length, s = s || r.some((c, l) => c != n[l]), n = r, s && (a =
|
|
34
|
+
return s = s || !r != !n, s = s || r?.length != n?.length, s = s || r.some((c, l) => c != n[l]), n = r, s && (a = D()), a;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
return e(t);
|
|
39
39
|
};
|
|
40
|
-
class
|
|
40
|
+
class W extends Event {
|
|
41
41
|
constructor(e, n) {
|
|
42
42
|
super(e), this.event = e, this.value = n;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class _ extends EventTarget {
|
|
46
46
|
/**
|
|
47
47
|
* Create a new Context instance.
|
|
48
48
|
* @param name - The name of the context (for debugging).
|
|
@@ -65,7 +65,7 @@ class W extends EventTarget {
|
|
|
65
65
|
* @param value - The new value.
|
|
66
66
|
*/
|
|
67
67
|
publish(e, n) {
|
|
68
|
-
n != this.data[e] && (this.data[e] = n, this.dispatchEvent(new
|
|
68
|
+
n != this.data[e] && (this.data[e] = n, this.dispatchEvent(new W(String(e), n)));
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Subscribe to changes for a specific key in the context.
|
|
@@ -80,7 +80,7 @@ class W extends EventTarget {
|
|
|
80
80
|
return this.addEventListener(String(e), a), e in this.data && n(this.data[e]), () => (this.removeEventListener(String(e), a), void 0);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const T = H((t) => new _(t)), E = (t = "noname") => g(() => T(t), [t]), $ = (t, ...e) => {
|
|
84
84
|
const n = new Error("[ctx] useRegistryChecker failed " + JSON.stringify({ names: e, ctx: t?.name ?? "undefined" }));
|
|
85
85
|
f(
|
|
86
86
|
() => {
|
|
@@ -91,21 +91,21 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
91
91
|
},
|
|
92
92
|
[t, e.length]
|
|
93
93
|
);
|
|
94
|
-
},
|
|
94
|
+
}, ae = (t, e, n) => {
|
|
95
95
|
f(() => {
|
|
96
96
|
t && t.data[e] != n && t.publish(e, n);
|
|
97
|
-
}, [e, n, t]),
|
|
98
|
-
},
|
|
97
|
+
}, [e, n, t]), $(t, e);
|
|
98
|
+
}, I = (t, e, n = 0) => {
|
|
99
99
|
const [{ value: a }, r] = v(() => ({ value: t?.data?.[e] }));
|
|
100
100
|
return f(() => {
|
|
101
101
|
if (t) {
|
|
102
|
-
let s = n == 0 ? (l) => r({ value: l }) :
|
|
102
|
+
let s = n == 0 ? (l) => r({ value: l }) : w((l) => r({ value: l }), n), c = t.subscribe(e, s);
|
|
103
103
|
return a != t.data[e] && r({ value: t.data[e] }), () => {
|
|
104
104
|
c();
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
}, [e, t]), t?.data[e];
|
|
108
|
-
},
|
|
108
|
+
}, re = (t, e, n) => {
|
|
109
109
|
const [, a] = v(0), r = g(
|
|
110
110
|
() => n(t?.data[e]),
|
|
111
111
|
[n, t?.data[e]]
|
|
@@ -124,13 +124,13 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
124
124
|
if (t)
|
|
125
125
|
for (let [n, a] of e)
|
|
126
126
|
t.data[n] != a && t.publish(n, a);
|
|
127
|
-
}, [t,
|
|
128
|
-
},
|
|
127
|
+
}, [t, L(e.flat())]), $(t, ...e.map((n) => n[0]));
|
|
128
|
+
}, se = (t, ...e) => {
|
|
129
129
|
const [, n] = v(0), a = e.map((r) => t?.data?.[r]);
|
|
130
130
|
return f(() => {
|
|
131
131
|
if (t) {
|
|
132
132
|
let r = a;
|
|
133
|
-
const s =
|
|
133
|
+
const s = w(() => {
|
|
134
134
|
let i = e.map((u) => t?.data?.[u]);
|
|
135
135
|
e.some((u, d) => r[d] != i[d]) && (r = i, n((u) => u + 1));
|
|
136
136
|
}, 1);
|
|
@@ -140,12 +140,12 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
}, [t, ...e]), Object.fromEntries(e.map((r, s) => [r, a[s]]));
|
|
143
|
-
},
|
|
143
|
+
}, ce = (t, e = 50, ...n) => {
|
|
144
144
|
const [, a] = v(0), r = n.map((s) => t?.data?.[s]);
|
|
145
145
|
return f(() => {
|
|
146
146
|
if (t) {
|
|
147
147
|
let s = r;
|
|
148
|
-
const c =
|
|
148
|
+
const c = w(() => {
|
|
149
149
|
let u = n.map((d) => t?.data?.[d]);
|
|
150
150
|
n.some((d, p) => s[p] != u[p]) && (s = u, a((d) => d + 1));
|
|
151
151
|
}, e);
|
|
@@ -155,7 +155,7 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
}, [t, ...n]), r;
|
|
158
|
-
},
|
|
158
|
+
}, le = (t, e) => {
|
|
159
159
|
const n = (s) => [
|
|
160
160
|
t,
|
|
161
161
|
...Object.entries(s ?? {}).sort((c, l) => c[0].localeCompare(l[0])).flat()
|
|
@@ -174,7 +174,7 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
174
174
|
return a.add(l), () => {
|
|
175
175
|
a.delete(l);
|
|
176
176
|
};
|
|
177
|
-
}), /* @__PURE__ */ o(
|
|
177
|
+
}), /* @__PURE__ */ o(y, {});
|
|
178
178
|
};
|
|
179
179
|
return r.displayName = `State[${e?.name ?? "??"}]`, {
|
|
180
180
|
resolveCtxName: n,
|
|
@@ -208,18 +208,18 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
208
208
|
}, [a.has(c)]), E(c);
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
|
-
},
|
|
211
|
+
}, K = /* @__PURE__ */ function() {
|
|
212
212
|
const t = /* @__PURE__ */ new WeakMap();
|
|
213
213
|
return (e) => {
|
|
214
214
|
let n = t.get(e);
|
|
215
215
|
return n || t.set(e, n = (e?.name ?? "") + Math.random().toString()), n;
|
|
216
216
|
};
|
|
217
|
-
}(),
|
|
217
|
+
}(), q = (t) => [
|
|
218
218
|
...Object.entries(t ?? {}).sort((e, n) => e[0].localeCompare(n[0])).flat()
|
|
219
|
-
].join("-"),
|
|
220
|
-
const e = E("auto-ctx"), [n, a] = v({}), r =
|
|
219
|
+
].join("-"), ie = ({ Wrapper: t = G }) => {
|
|
220
|
+
const e = E("auto-ctx"), [n, a] = v({}), r = A(
|
|
221
221
|
(s, c) => {
|
|
222
|
-
const l =
|
|
222
|
+
const l = K(s), i = q(c);
|
|
223
223
|
return a(({
|
|
224
224
|
[l]: {
|
|
225
225
|
Component: u = s,
|
|
@@ -272,12 +272,12 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
272
272
|
e,
|
|
273
273
|
["subscribe", r],
|
|
274
274
|
["state", n]
|
|
275
|
-
), /* @__PURE__ */ o(
|
|
275
|
+
), /* @__PURE__ */ o(y, { children: Object.entries(n).flatMap(
|
|
276
276
|
([s, { Component: c, subState: l }]) => Object.entries(l).map(([i, { counter: u, params: d }]) => ({ key: s + i, Component: c, params: d, counter: u })).filter((i) => i.counter > 0).map(({ key: i, params: u, Component: d }) => /* @__PURE__ */ o(t, { children: /* @__PURE__ */ o(d, { ...u }) }, i))
|
|
277
277
|
) });
|
|
278
|
-
},
|
|
278
|
+
}, oe = ({ Root: t, useCtxState: e, useCtxStateStrict: n, resolveCtxName: a }, r = 0) => ({
|
|
279
279
|
useCtxState: (s) => {
|
|
280
|
-
const c = a(s), l =
|
|
280
|
+
const c = a(s), l = I(E("auto-ctx"), "subscribe");
|
|
281
281
|
return f(() => {
|
|
282
282
|
if (r == 0)
|
|
283
283
|
return l?.(t, s);
|
|
@@ -287,7 +287,7 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
287
287
|
}
|
|
288
288
|
}, [l, c]), E(c);
|
|
289
289
|
}
|
|
290
|
-
}),
|
|
290
|
+
}), ue = (t) => {
|
|
291
291
|
const [, e] = v(0), { proxy: n, finalGetter: a, openGetter: r, clean: s } = g(
|
|
292
292
|
() => {
|
|
293
293
|
const c = /* @__PURE__ */ new Set(), l = {}, i = /* @__PURE__ */ new Map(), u = new Proxy(
|
|
@@ -300,7 +300,7 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
);
|
|
303
|
-
let d = !0, p =
|
|
303
|
+
let d = !0, p = w(() => {
|
|
304
304
|
[...c.values()].some((h) => l[h] != t?.data?.[h]) && e((h) => h + 1);
|
|
305
305
|
}, 0), b = () => {
|
|
306
306
|
d = !0, c.clear();
|
|
@@ -321,10 +321,10 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
321
321
|
() => () => s(),
|
|
322
322
|
[s]
|
|
323
323
|
), n;
|
|
324
|
-
},
|
|
324
|
+
}, z = T.cache, B = ({}) => {
|
|
325
325
|
const [t, e] = v("");
|
|
326
326
|
return /* @__PURE__ */ m("div", { className: "main-panel", children: [
|
|
327
|
-
/* @__PURE__ */ o("div", { className: "state-list", children: [...
|
|
327
|
+
/* @__PURE__ */ o("div", { className: "state-list", children: [...z.keys()].map((n) => JSON.parse(n)?.[0]).filter((n) => n != "auto-ctx").map((n) => /* @__PURE__ */ o(
|
|
328
328
|
"div",
|
|
329
329
|
{
|
|
330
330
|
className: "state-key",
|
|
@@ -333,10 +333,10 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
333
333
|
children: n
|
|
334
334
|
}
|
|
335
335
|
)) }),
|
|
336
|
-
/* @__PURE__ */ o("div", { className: "state-view", children: /* @__PURE__ */ o(
|
|
336
|
+
/* @__PURE__ */ o("div", { className: "state-view", children: /* @__PURE__ */ o(P, { dataKey: t }, t) })
|
|
337
337
|
] });
|
|
338
|
-
},
|
|
339
|
-
const e =
|
|
338
|
+
}, P = ({ dataKey: t }) => {
|
|
339
|
+
const e = T(t), [n, a] = v({ ...e?.data });
|
|
340
340
|
return f(() => {
|
|
341
341
|
let r = { ...n }, s = setInterval(() => {
|
|
342
342
|
let c = !1;
|
|
@@ -346,21 +346,24 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
346
346
|
}, 200);
|
|
347
347
|
return () => clearInterval(s);
|
|
348
348
|
}, [e]), /* @__PURE__ */ o(
|
|
349
|
-
|
|
349
|
+
ee,
|
|
350
350
|
{
|
|
351
351
|
value: n,
|
|
352
|
-
name:
|
|
352
|
+
name: t,
|
|
353
353
|
expandLevel: 1,
|
|
354
|
-
style: {
|
|
354
|
+
style: {}
|
|
355
355
|
}
|
|
356
356
|
);
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
)
|
|
357
|
+
}, V = (t) => {
|
|
358
|
+
let e = t.length < 120 ? 10 : 100;
|
|
359
|
+
return Object.fromEntries(
|
|
360
|
+
new Array(Math.ceil((t.length + 1) / e)).fill(0).map(
|
|
361
|
+
(n, a, r) => new Array(a == r.length - 1 ? t.length % e : e).fill(0).map((s, c) => a * e + c)
|
|
362
|
+
).filter((n) => n.length).map((n) => [`${n.at(0)}..${n.at(-1)}`, Object.fromEntries(
|
|
363
|
+
n.map((a) => [a, t[a]])
|
|
364
|
+
)])
|
|
365
|
+
);
|
|
366
|
+
}, Q = (t, e = 25) => {
|
|
364
367
|
const n = Object.keys(t);
|
|
365
368
|
return Object.fromEntries(
|
|
366
369
|
Array(Math.ceil((n.length + 1) / e)).fill(0).map(
|
|
@@ -372,17 +375,17 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
372
375
|
]
|
|
373
376
|
)
|
|
374
377
|
);
|
|
375
|
-
},
|
|
378
|
+
}, x = ({ path: t, expandLevel: e, expandRoot: n, setExpandRoot: a }) => {
|
|
376
379
|
const r = t?.join("%") ?? "", s = typeof e == "boolean" ? e : typeof e == "number" && e > 0, c = g(
|
|
377
380
|
() => n?.[r] ?? s,
|
|
378
381
|
[n?.[r], r]
|
|
379
|
-
), l =
|
|
382
|
+
), l = A(
|
|
380
383
|
(i) => a((u) => ({ ...u, [r]: i })),
|
|
381
384
|
[n, r]
|
|
382
385
|
);
|
|
383
386
|
return { isExpand: c, setExpand: l };
|
|
384
|
-
},
|
|
385
|
-
const a =
|
|
387
|
+
}, C = ({ value: t, deepCompare: e = !1, ...n }) => {
|
|
388
|
+
const a = O(void 0), r = O(t);
|
|
386
389
|
return f(() => {
|
|
387
390
|
if (a.current && (e && t && r.current ? Object.keys(t).length != Object.keys(r.current).length || Object.keys(t).some((c) => t[c] != r.current[c]) : t != r.current)) {
|
|
388
391
|
r.current = t, a.current.classList.add("jv-updated");
|
|
@@ -390,7 +393,7 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
390
393
|
return () => cancelAnimationFrame(c);
|
|
391
394
|
}
|
|
392
395
|
}, [t, e, a]), /* @__PURE__ */ o("div", { ...n, ref: a });
|
|
393
|
-
},
|
|
396
|
+
}, U = (t) => {
|
|
394
397
|
const {
|
|
395
398
|
currentField: e,
|
|
396
399
|
value: n,
|
|
@@ -400,11 +403,11 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
400
403
|
setExpandRoot: c,
|
|
401
404
|
expandLevel: l,
|
|
402
405
|
isGrouped: i
|
|
403
|
-
} = t, u = n instanceof Array, { isExpand: d, setExpand: p } =
|
|
404
|
-
() => j ? n instanceof Array ?
|
|
405
|
-
[n, j,
|
|
406
|
+
} = t, u = n instanceof Array, { isExpand: d, setExpand: p } = x(t), b = typeof l == "number" ? l - 1 : l, j = Object.entries(n).length > (n instanceof Array ? 10 : 25), N = Object.entries(n).length > 0, h = g(
|
|
407
|
+
() => j ? n instanceof Array ? V(n) : Q(n, 25) : n,
|
|
408
|
+
[n, j, V]
|
|
406
409
|
);
|
|
407
|
-
return d ? /* @__PURE__ */ m(
|
|
410
|
+
return d && N ? /* @__PURE__ */ m(C, { className: "jv-field jv-field-obj", value: n, deepCompare: i, children: [
|
|
408
411
|
e && /* @__PURE__ */ o("div", { children: /* @__PURE__ */ m("div", { onClick: () => p(!1), children: [
|
|
409
412
|
/* @__PURE__ */ o("span", { className: "jv-name", children: e }),
|
|
410
413
|
/* @__PURE__ */ o("span", { children: ":" }),
|
|
@@ -419,17 +422,17 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
419
422
|
" "
|
|
420
423
|
] })
|
|
421
424
|
] }) }),
|
|
422
|
-
/* @__PURE__ */ o("div", { className: "jv-value", children: Object.entries(
|
|
425
|
+
/* @__PURE__ */ o("div", { className: "jv-value", children: Object.entries(h).map(([S, F], R) => /* @__PURE__ */ J(
|
|
423
426
|
M,
|
|
424
427
|
{
|
|
425
428
|
name: r,
|
|
426
429
|
expandRoot: s,
|
|
427
430
|
setExpandRoot: c,
|
|
428
431
|
expandLevel: b,
|
|
429
|
-
value:
|
|
432
|
+
value: F,
|
|
430
433
|
isGrouped: j,
|
|
431
|
-
key: [...a, j ? R :
|
|
432
|
-
path: [...a,
|
|
434
|
+
key: [...a, j ? R : S].join("%"),
|
|
435
|
+
path: [...a, S]
|
|
433
436
|
}
|
|
434
437
|
)) }),
|
|
435
438
|
e && /* @__PURE__ */ o("div", { children: /* @__PURE__ */ m("span", { children: [
|
|
@@ -437,10 +440,10 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
437
440
|
u ? "]" : "}",
|
|
438
441
|
" "
|
|
439
442
|
] }) })
|
|
440
|
-
] }) : /* @__PURE__ */ o(
|
|
443
|
+
] }) : /* @__PURE__ */ o(C, { className: "jv-field jv-field-obj", value: n, deepCompare: i, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ m("div", { onClick: () => N && p(!0), children: [
|
|
441
444
|
/* @__PURE__ */ o("span", { className: "jv-name", children: e }),
|
|
442
445
|
e && /* @__PURE__ */ o("span", { children: ":" }),
|
|
443
|
-
e && /* @__PURE__ */ o("span", { children: "[+]" }),
|
|
446
|
+
e && N && /* @__PURE__ */ o("span", { children: "[+]" }),
|
|
444
447
|
/* @__PURE__ */ m("span", { className: "jv-type", children: [
|
|
445
448
|
Object.keys(n).length,
|
|
446
449
|
" items "
|
|
@@ -450,17 +453,17 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
450
453
|
u ? "[" : "{",
|
|
451
454
|
" "
|
|
452
455
|
] }),
|
|
453
|
-
/* @__PURE__ */ o("span", { children: " ... " }),
|
|
456
|
+
N && /* @__PURE__ */ o("span", { children: " ... " }),
|
|
454
457
|
/* @__PURE__ */ m("span", { children: [
|
|
455
458
|
" ",
|
|
456
459
|
u ? "]" : "}",
|
|
457
460
|
" "
|
|
458
461
|
] })
|
|
459
462
|
] }) }) });
|
|
460
|
-
},
|
|
461
|
-
const { currentType: e, currentField: n, value: a } = t, { isExpand: r, setExpand: s } =
|
|
463
|
+
}, X = (t) => {
|
|
464
|
+
const { currentType: e, currentField: n, value: a } = t, { isExpand: r, setExpand: s } = x(t), c = String(a).length > 50, l = c && !r ? `${String(a).slice(0, 15)}...${String(a).slice(-15, -1)}` : String(a);
|
|
462
465
|
return /* @__PURE__ */ m(
|
|
463
|
-
|
|
466
|
+
C,
|
|
464
467
|
{
|
|
465
468
|
value: t.value,
|
|
466
469
|
className: `jv-field jv-field-${e} ${c ? "jv-cursor" : ""}`,
|
|
@@ -482,10 +485,10 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
482
485
|
]
|
|
483
486
|
}
|
|
484
487
|
);
|
|
485
|
-
},
|
|
486
|
-
const { currentType: e, currentField: n, value: a } = t, { isExpand: r, setExpand: s } =
|
|
488
|
+
}, Y = (t) => {
|
|
489
|
+
const { currentType: e, currentField: n, value: a } = t, { isExpand: r, setExpand: s } = x(t), c = String(a).length > 50, l = c && !r ? `${String(a).slice(0, 15)}...${String(a).slice(-15, -1)}` : String(a);
|
|
487
490
|
return /* @__PURE__ */ m(
|
|
488
|
-
|
|
491
|
+
C,
|
|
489
492
|
{
|
|
490
493
|
value: t.value,
|
|
491
494
|
className: `jv-field jv-field-${e} ${c ? "jv-cursor" : ""}`,
|
|
@@ -503,10 +506,10 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
503
506
|
]
|
|
504
507
|
}
|
|
505
508
|
);
|
|
506
|
-
},
|
|
509
|
+
}, Z = (t) => {
|
|
507
510
|
const { currentType: e, currentField: n, value: a } = t;
|
|
508
511
|
return /* @__PURE__ */ m(
|
|
509
|
-
|
|
512
|
+
C,
|
|
510
513
|
{
|
|
511
514
|
value: t.value,
|
|
512
515
|
className: `jv-field jv-field-${e}`,
|
|
@@ -523,20 +526,20 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
523
526
|
const { value: e, path: n = [], name: a } = t, r = n.at(-1) ?? a ?? void 0, s = typeof e;
|
|
524
527
|
switch (s) {
|
|
525
528
|
case "object":
|
|
526
|
-
return /* @__PURE__ */ o(Q, { ...t, currentField: r, currentType: s });
|
|
527
|
-
case "string":
|
|
528
529
|
return /* @__PURE__ */ o(U, { ...t, currentField: r, currentType: s });
|
|
529
|
-
case "
|
|
530
|
+
case "string":
|
|
530
531
|
return /* @__PURE__ */ o(X, { ...t, currentField: r, currentType: s });
|
|
532
|
+
case "function":
|
|
533
|
+
return /* @__PURE__ */ o(Y, { ...t, currentField: r, currentType: s });
|
|
531
534
|
case "number":
|
|
532
535
|
case "boolean":
|
|
533
536
|
case "bigint":
|
|
534
537
|
case "symbol":
|
|
535
538
|
case "undefined":
|
|
536
539
|
default:
|
|
537
|
-
return /* @__PURE__ */ o(
|
|
540
|
+
return /* @__PURE__ */ o(Z, { ...t, currentField: r, currentType: s });
|
|
538
541
|
}
|
|
539
|
-
},
|
|
542
|
+
}, ee = ({ value: t, name: e, style: n, expandLevel: a = !1 }) => {
|
|
540
543
|
const [r, s] = v({});
|
|
541
544
|
return /* @__PURE__ */ o("div", { className: "jv-root", style: n, children: /* @__PURE__ */ o(
|
|
542
545
|
M,
|
|
@@ -549,31 +552,31 @@ const y = J((t) => new W(t)), E = (t = "noname") => g(() => y(t), [t]), A = (t,
|
|
|
549
552
|
expandLevel: a
|
|
550
553
|
}
|
|
551
554
|
) });
|
|
552
|
-
},
|
|
555
|
+
}, de = ({ toggleButton: t = "[x]", ...e }) => {
|
|
553
556
|
const [n, a] = v(!1);
|
|
554
|
-
return /* @__PURE__ */ m(
|
|
557
|
+
return /* @__PURE__ */ m(y, { children: [
|
|
555
558
|
/* @__PURE__ */ o("button", { className: "react-state-dev-btn", "data-active": n, onClick: () => a(!0), ...e, children: e?.children ?? "Toggle Dev Tool" }),
|
|
556
559
|
/* @__PURE__ */ m("div", { className: "react-state-dev-container", "data-active": n, children: [
|
|
557
560
|
/* @__PURE__ */ o("button", { className: "close-btn", onClick: () => a(!1), children: "[x]" }),
|
|
558
|
-
/* @__PURE__ */ o(
|
|
561
|
+
/* @__PURE__ */ o(B, {})
|
|
559
562
|
] })
|
|
560
563
|
] });
|
|
561
564
|
};
|
|
562
565
|
export {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
566
|
+
ie as AutoRootCtx,
|
|
567
|
+
_ as Context,
|
|
568
|
+
de as DevToolContainer,
|
|
569
|
+
oe as createAutoCtx,
|
|
570
|
+
le as createRootCtx,
|
|
571
|
+
T as getContext,
|
|
572
|
+
L as useArrayHash,
|
|
570
573
|
E as useDataContext,
|
|
571
|
-
|
|
574
|
+
ae as useDataSource,
|
|
572
575
|
k as useDataSourceMultiple,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
I as useDataSubscribe,
|
|
577
|
+
se as useDataSubscribeMultiple,
|
|
578
|
+
ce as useDataSubscribeMultipleWithDebounce,
|
|
579
|
+
re as useDataSubscribeWithTransform,
|
|
580
|
+
ue as useQuickSubscribe
|
|
578
581
|
};
|
|
579
582
|
//# sourceMappingURL=index.es.js.map
|