@berenjena/react-dev-panel 2.2.0 → 2.4.0
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 +97 -239
- package/dist/assets/index11.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index13.css +1 -1
- package/dist/assets/index14.css +1 -1
- package/dist/assets/index15.css +1 -1
- package/dist/assets/index16.css +1 -0
- package/dist/assets/index5.css +1 -1
- package/dist/assets/index7.css +1 -1
- package/dist/components/ControlRenderer/controls/BooleanControl/index.js +1 -1
- package/dist/components/ControlRenderer/controls/ButtonControl/index.js +1 -1
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.js +1 -1
- package/dist/components/ControlRenderer/controls/ColorControl/index.js +1 -1
- package/dist/components/ControlRenderer/controls/DragAndDropControl/index.js +1 -1
- package/dist/components/ControlRenderer/controls/LocalStorageControl/index.d.ts +23 -0
- package/dist/components/ControlRenderer/controls/LocalStorageControl/index.js +252 -0
- package/dist/components/ControlRenderer/controls/LocalStorageControl/types.d.ts +14 -0
- package/dist/components/ControlRenderer/controls/SelectControl/index.js +15 -5
- package/dist/components/ControlRenderer/controls/SelectControl/types.d.ts +2 -0
- package/dist/components/ControlRenderer/controls/index.d.ts +1 -0
- package/dist/components/ControlRenderer/controls/index.js +2 -1
- package/dist/components/ControlRenderer/controls/types.d.ts +3 -0
- package/dist/components/ControlRenderer/index.js +23 -23
- package/dist/components/Select/index.d.ts +3 -1
- package/dist/components/Select/index.js +132 -97
- package/dist/hooks/useDevPanel/index.js +45 -17
- package/dist/store/ControlPersistenceService.d.ts +33 -0
- package/dist/store/ControlPersistenceService.js +61 -0
- package/dist/utils/copyToClipboard/copyToClipboard.d.ts +17 -0
- package/dist/utils/copyToClipboard/copyToClipboard.js +10 -0
- package/dist/utils/copyToClipboard/index.d.ts +1 -0
- package/dist/utils/copyToClipboard/index.js +4 -0
- package/dist/utils/getStringPreview/getStringPreview.d.ts +14 -0
- package/dist/utils/getStringPreview/getStringPreview.js +6 -0
- package/dist/utils/getStringPreview/index.d.ts +1 -0
- package/dist/utils/getStringPreview/index.js +4 -0
- package/dist/utils/prettifyJson/index.d.ts +1 -0
- package/dist/utils/prettifyJson/index.js +4 -0
- package/dist/utils/prettifyJson/prettifyJson.d.ts +13 -0
- package/dist/utils/prettifyJson/prettifyJson.js +11 -0
- package/package.json +9 -3
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { jsxs as t, jsx as
|
|
1
|
+
import { jsxs as t, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { Suspense as c } from "react";
|
|
3
|
-
import { className as
|
|
3
|
+
import { className as l } from "../../utils/className/className.js";
|
|
4
4
|
import { controls as d } from "./controls/index.js";
|
|
5
|
-
import '../../assets/index5.css';const p = "
|
|
5
|
+
import '../../assets/index5.css';const p = "_controlRendererContainer_jru2l_1", u = "_controlContainer_jru2l_5", _ = "_hoverable_jru2l_15", f = "_fullWidth_jru2l_18", h = "_label_jru2l_21", b = "_controlWrapper_jru2l_24", j = "_justifyStart_jru2l_30", C = "_description_jru2l_46", m = "_loading_jru2l_55", y = "_error_jru2l_74", e = {
|
|
6
6
|
controlRendererContainer: p,
|
|
7
|
-
controlContainer:
|
|
8
|
-
hoverable:
|
|
9
|
-
fullWidth:
|
|
10
|
-
label:
|
|
11
|
-
controlWrapper:
|
|
12
|
-
justifyStart:
|
|
7
|
+
controlContainer: u,
|
|
8
|
+
hoverable: _,
|
|
9
|
+
fullWidth: f,
|
|
10
|
+
label: h,
|
|
11
|
+
controlWrapper: b,
|
|
12
|
+
justifyStart: j,
|
|
13
13
|
description: C,
|
|
14
14
|
loading: m,
|
|
15
15
|
error: y
|
|
16
|
-
}, g = ["button", "buttonGroup", "separator", "dragAndDrop"],
|
|
17
|
-
function A({ name:
|
|
18
|
-
const i = r?.label ||
|
|
19
|
-
function
|
|
16
|
+
}, g = ["button", "buttonGroup", "separator", "dragAndDrop", "localStorage"], v = ["separator", "dragAndDrop", "localStorage"], S = ["button", "separator", "dragAndDrop", "localStorage"];
|
|
17
|
+
function A({ name: a, control: r }) {
|
|
18
|
+
const i = r?.label || a;
|
|
19
|
+
function s() {
|
|
20
20
|
if (!r || !r.type)
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
const
|
|
23
|
-
return
|
|
21
|
+
return /* @__PURE__ */ o("div", { className: e.error, children: "Control type is not defined" });
|
|
22
|
+
const n = d[r.type];
|
|
23
|
+
return n ? /* @__PURE__ */ o(c, { fallback: /* @__PURE__ */ o("div", { className: e.loading, children: "Loading control..." }), children: /* @__PURE__ */ o(n, { control: r }) }) : /* @__PURE__ */ o("div", { children: "Unknown control type" });
|
|
24
24
|
}
|
|
25
25
|
return /* @__PURE__ */ t("div", { className: e.controlRendererContainer, children: [
|
|
26
26
|
/* @__PURE__ */ t(
|
|
27
27
|
"div",
|
|
28
28
|
{
|
|
29
|
-
...
|
|
29
|
+
...l(e.controlContainer, {
|
|
30
30
|
[e.fullWidth]: g.includes(r.type),
|
|
31
|
-
[e.hoverable]: !
|
|
31
|
+
[e.hoverable]: !v.includes(r.type)
|
|
32
32
|
}),
|
|
33
33
|
children: [
|
|
34
|
-
!
|
|
35
|
-
/* @__PURE__ */
|
|
34
|
+
!S.includes(r.type) && /* @__PURE__ */ o("label", { className: e.label, children: i }),
|
|
35
|
+
/* @__PURE__ */ o(
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
|
-
...
|
|
38
|
+
...l(e.controlWrapper, {
|
|
39
39
|
[e.justifyStart]: r.type === "separator"
|
|
40
40
|
}),
|
|
41
|
-
children:
|
|
41
|
+
children: s()
|
|
42
42
|
}
|
|
43
43
|
)
|
|
44
44
|
]
|
|
45
45
|
}
|
|
46
46
|
),
|
|
47
|
-
r?.description && /* @__PURE__ */
|
|
47
|
+
r?.description && /* @__PURE__ */ o("span", { className: e.description, children: r.description })
|
|
48
48
|
] });
|
|
49
49
|
}
|
|
50
50
|
export {
|
|
@@ -7,9 +7,11 @@ export interface SelectProps {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
multiple?: boolean;
|
|
9
9
|
placeholder?: string;
|
|
10
|
+
searchable?: boolean;
|
|
11
|
+
searchPlaceholder?: string;
|
|
10
12
|
onChange: (value: string | string[]) => void;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Unified Select component that can handle both single and multiple selection
|
|
14
16
|
*/
|
|
15
|
-
export declare function Select({ value, options, onChange, disabled, multiple, placeholder }: SelectProps): React.ReactNode;
|
|
17
|
+
export declare function Select({ value, options, onChange, disabled, multiple, placeholder, searchable, searchPlaceholder, }: SelectProps): React.ReactNode;
|
|
@@ -1,83 +1,104 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { useDevPanelPosition as
|
|
6
|
-
import { className as
|
|
7
|
-
import '../../assets/index7.css';const
|
|
8
|
-
select:
|
|
9
|
-
trigger:
|
|
10
|
-
open:
|
|
11
|
-
value:
|
|
12
|
-
placeholder:
|
|
13
|
-
arrow:
|
|
14
|
-
dropdownPortal:
|
|
15
|
-
dropdown:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsxs as x, Fragment as W, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as P, useState as N, useMemo as U, useCallback as G, useEffect as R } from "react";
|
|
3
|
+
import { createPortal as J } from "react-dom";
|
|
4
|
+
import { Icon as K } from "../Icon/index.js";
|
|
5
|
+
import { useDevPanelPosition as X } from "../../store/UIStore.js";
|
|
6
|
+
import { className as Y } from "../../utils/className/className.js";
|
|
7
|
+
import '../../assets/index7.css';const Z = "_select_15gl5_217", ee = "_trigger_15gl5_222", te = "_open_15gl5_271", ne = "_value_15gl5_275", oe = "_placeholder_15gl5_284", re = "_arrow_15gl5_288", se = "_dropdownPortal_15gl5_303", ce = "_dropdown_15gl5_303", ie = "_searchContainer_15gl5_323", le = "_searchInput_15gl5_329", ae = "_optionsList_15gl5_371", de = "_noResults_15gl5_397", ue = "_option_15gl5_371", pe = "_selected_15gl5_423", he = "_checkbox_15gl5_432", fe = "_label_15gl5_453", r = {
|
|
8
|
+
select: Z,
|
|
9
|
+
trigger: ee,
|
|
10
|
+
open: te,
|
|
11
|
+
value: ne,
|
|
12
|
+
placeholder: oe,
|
|
13
|
+
arrow: re,
|
|
14
|
+
dropdownPortal: se,
|
|
15
|
+
dropdown: ce,
|
|
16
|
+
searchContainer: ie,
|
|
17
|
+
searchInput: le,
|
|
18
|
+
optionsList: ae,
|
|
19
|
+
noResults: de,
|
|
20
|
+
option: ue,
|
|
21
|
+
selected: pe,
|
|
22
|
+
checkbox: he,
|
|
23
|
+
label: fe
|
|
20
24
|
};
|
|
21
|
-
function
|
|
22
|
-
|
|
25
|
+
function ye({
|
|
26
|
+
value: f,
|
|
27
|
+
options: h,
|
|
28
|
+
onChange: k,
|
|
29
|
+
disabled: g = !1,
|
|
30
|
+
multiple: u = !1,
|
|
31
|
+
placeholder: I = "Select...",
|
|
32
|
+
searchable: w = !1,
|
|
33
|
+
searchPlaceholder: V = "Search..."
|
|
34
|
+
}) {
|
|
35
|
+
const m = X(), _ = P(null), p = P(null), O = P(null), E = P(null), [l, v] = N(!1), [b, L] = N(""), [y, S] = N({
|
|
23
36
|
top: 0,
|
|
24
37
|
left: 0,
|
|
25
38
|
width: 0,
|
|
26
39
|
maxHeight: 200
|
|
27
|
-
}), d = u ? Array.isArray(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
}), d = u ? Array.isArray(f) ? f : [] : typeof f == "string" ? f : "", $ = T(), q = u ? d.length === 0 : !d, H = U(() => {
|
|
41
|
+
if (!w || !b)
|
|
42
|
+
return h;
|
|
43
|
+
const e = b.toLowerCase();
|
|
44
|
+
return h.filter((t) => (typeof t == "string" ? t : t.label).toLowerCase().includes(e));
|
|
45
|
+
}, [h, w, b]), c = G(() => {
|
|
46
|
+
l && S(D());
|
|
47
|
+
}, [l]);
|
|
48
|
+
function D() {
|
|
49
|
+
if (!p.current)
|
|
32
50
|
return {
|
|
33
51
|
top: 0,
|
|
34
52
|
left: 0,
|
|
35
53
|
width: 0,
|
|
36
54
|
maxHeight: 200
|
|
37
55
|
};
|
|
38
|
-
const e =
|
|
56
|
+
const e = p.current.getBoundingClientRect(), t = window.innerHeight, n = window.innerWidth, o = 200, a = 4, s = t - e.bottom - a, C = e.top - a, M = s < o && C > s, B = M ? e.top - Math.min(o, C) : e.bottom + a, F = Math.max(8, Math.min(e.left, n - e.width - 8)), Q = M ? Math.min(o, C) : Math.min(o, s);
|
|
39
57
|
return {
|
|
40
|
-
top:
|
|
41
|
-
left:
|
|
58
|
+
top: B,
|
|
59
|
+
left: F,
|
|
42
60
|
width: e.width,
|
|
43
|
-
maxHeight:
|
|
61
|
+
maxHeight: Q
|
|
44
62
|
};
|
|
45
63
|
}
|
|
46
|
-
function
|
|
64
|
+
function A(e) {
|
|
47
65
|
if (u) {
|
|
48
66
|
const t = d, n = t.includes(e) ? t.filter((o) => o !== e) : [...t, e];
|
|
49
|
-
|
|
67
|
+
k(n);
|
|
50
68
|
} else
|
|
51
|
-
|
|
69
|
+
k(e), v(!1);
|
|
52
70
|
}
|
|
53
|
-
function
|
|
71
|
+
function T() {
|
|
54
72
|
if (u) {
|
|
55
73
|
const e = d;
|
|
56
74
|
if (e.length === 0)
|
|
57
|
-
return
|
|
75
|
+
return I;
|
|
58
76
|
if (e.length === 1) {
|
|
59
|
-
const t =
|
|
77
|
+
const t = h.find((o) => (typeof o == "string" ? o : o.value) === e[0]);
|
|
60
78
|
return (typeof t == "string" ? t : t?.label) || e[0];
|
|
61
79
|
}
|
|
62
80
|
return `${e.length} selected`;
|
|
63
81
|
} else {
|
|
64
82
|
const e = d;
|
|
65
83
|
if (!e)
|
|
66
|
-
return
|
|
67
|
-
const t =
|
|
84
|
+
return I;
|
|
85
|
+
const t = h.find((o) => (typeof o == "string" ? o : o.value) === e);
|
|
68
86
|
return (typeof t == "string" ? t : t?.label) || e;
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
89
|
+
function z() {
|
|
90
|
+
g || (l ? (v(!1), L("")) : (S(D()), v(!0), L(""), w && setTimeout(() => O.current?.focus(), 0)));
|
|
73
91
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
function j(e) {
|
|
93
|
+
L(e.target.value);
|
|
94
|
+
}
|
|
95
|
+
return R(() => {
|
|
96
|
+
if (!l) return;
|
|
97
|
+
c(), window.addEventListener("resize", c), window.addEventListener("scroll", c, !0);
|
|
98
|
+
const e = _.current?.closest("[data-dev-panel]") || document.querySelector("[data-dev-panel]");
|
|
99
|
+
e && e.addEventListener("scroll", c, !0);
|
|
79
100
|
let t = null;
|
|
80
|
-
if (
|
|
101
|
+
if (p.current && "IntersectionObserver" in window) {
|
|
81
102
|
const n = {
|
|
82
103
|
top: 0,
|
|
83
104
|
left: 0,
|
|
@@ -86,87 +107,101 @@ function ae({ value: p, options: _, onChange: z, disabled: f = !1, multiple: u =
|
|
|
86
107
|
};
|
|
87
108
|
t = new IntersectionObserver(
|
|
88
109
|
(o) => {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
(
|
|
110
|
+
const a = o[0];
|
|
111
|
+
if (a && a.target === p.current) {
|
|
112
|
+
const s = a.boundingClientRect;
|
|
113
|
+
(s.top !== n.top || s.left !== n.left || s.width !== n.width || s.height !== n.height) && (n.top = s.top, n.left = s.left, n.width = s.width, n.height = s.height, c());
|
|
93
114
|
}
|
|
94
115
|
},
|
|
95
116
|
{
|
|
96
117
|
threshold: [0, 0.1, 0.5, 1]
|
|
97
118
|
}
|
|
98
|
-
), t.observe(
|
|
119
|
+
), t.observe(p.current);
|
|
99
120
|
}
|
|
100
121
|
return () => {
|
|
101
|
-
window.removeEventListener("resize",
|
|
122
|
+
window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0), e && e.removeEventListener("scroll", c, !0), t && t.disconnect();
|
|
102
123
|
};
|
|
103
|
-
}, [
|
|
104
|
-
const e =
|
|
105
|
-
(!e || e.x !==
|
|
106
|
-
}, [
|
|
124
|
+
}, [l, c]), R(() => {
|
|
125
|
+
const e = E.current;
|
|
126
|
+
(!e || e.x !== m.x || e.y !== m.y) && (E.current = m, l && requestAnimationFrame(c));
|
|
127
|
+
}, [l, m, c]), R(() => {
|
|
107
128
|
function e(t) {
|
|
108
|
-
if (
|
|
129
|
+
if (_.current && !_.current.contains(t.target)) {
|
|
109
130
|
const n = document.querySelector(`.${r.dropdownPortal}`);
|
|
110
131
|
if (n && n.contains(t.target))
|
|
111
132
|
return;
|
|
112
|
-
|
|
133
|
+
v(!1);
|
|
113
134
|
}
|
|
114
135
|
}
|
|
115
136
|
return document.addEventListener("mousedown", e), () => {
|
|
116
137
|
document.removeEventListener("mousedown", e);
|
|
117
138
|
};
|
|
118
|
-
}, []), /* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
139
|
+
}, []), /* @__PURE__ */ x(W, { children: [
|
|
140
|
+
/* @__PURE__ */ i(
|
|
120
141
|
"div",
|
|
121
142
|
{
|
|
122
|
-
ref:
|
|
123
|
-
...
|
|
124
|
-
[r.disabled]:
|
|
125
|
-
[r.open]:
|
|
143
|
+
ref: _,
|
|
144
|
+
...Y(r.select, {
|
|
145
|
+
[r.disabled]: g,
|
|
146
|
+
[r.open]: l
|
|
126
147
|
}),
|
|
127
|
-
children: /* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
148
|
+
children: /* @__PURE__ */ x("button", { ref: p, type: "button", className: r.trigger, onClick: z, disabled: g, children: [
|
|
149
|
+
/* @__PURE__ */ i("span", { className: `${r.value} ${q ? r.placeholder : ""}`, children: $ }),
|
|
150
|
+
/* @__PURE__ */ i(K, { name: "ArrowDown", className: r.arrow })
|
|
130
151
|
] })
|
|
131
152
|
}
|
|
132
153
|
),
|
|
133
|
-
typeof window < "u" &&
|
|
134
|
-
|
|
154
|
+
typeof window < "u" && J(
|
|
155
|
+
l && !g && /* @__PURE__ */ i(
|
|
135
156
|
"div",
|
|
136
157
|
{
|
|
137
158
|
className: r.dropdownPortal,
|
|
138
159
|
style: {
|
|
139
160
|
position: "fixed",
|
|
140
|
-
top:
|
|
141
|
-
left:
|
|
142
|
-
width:
|
|
143
|
-
maxHeight:
|
|
161
|
+
top: y.top,
|
|
162
|
+
left: y.left,
|
|
163
|
+
width: y.width,
|
|
164
|
+
maxHeight: y.maxHeight,
|
|
144
165
|
zIndex: 9999
|
|
145
166
|
},
|
|
146
|
-
children: /* @__PURE__ */
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/* @__PURE__ */ a(
|
|
150
|
-
"input",
|
|
151
|
-
{
|
|
152
|
-
type: "checkbox",
|
|
153
|
-
checked: o,
|
|
154
|
-
onChange: () => O(t),
|
|
155
|
-
className: r.checkbox
|
|
156
|
-
}
|
|
157
|
-
),
|
|
158
|
-
/* @__PURE__ */ a("span", { className: r.label, children: n })
|
|
159
|
-
] }, t) : /* @__PURE__ */ a(
|
|
160
|
-
"button",
|
|
167
|
+
children: /* @__PURE__ */ x("div", { className: r.dropdown, children: [
|
|
168
|
+
w && /* @__PURE__ */ i("div", { className: r.searchContainer, children: /* @__PURE__ */ i(
|
|
169
|
+
"input",
|
|
161
170
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
ref: O,
|
|
172
|
+
type: "text",
|
|
173
|
+
className: r.searchInput,
|
|
174
|
+
placeholder: V,
|
|
175
|
+
value: b,
|
|
176
|
+
onChange: j,
|
|
177
|
+
onClick: (e) => e.stopPropagation()
|
|
178
|
+
}
|
|
179
|
+
) }),
|
|
180
|
+
/* @__PURE__ */ i("div", { className: r.optionsList, children: H.length === 0 ? /* @__PURE__ */ i("div", { className: r.noResults, children: "No results found" }) : H.map((e) => {
|
|
181
|
+
const t = typeof e == "string" ? e : e.value, n = typeof e == "string" ? e : e.label, o = u ? d.includes(t) : d === t;
|
|
182
|
+
return u ? /* @__PURE__ */ x("label", { className: r.option, children: [
|
|
183
|
+
/* @__PURE__ */ i(
|
|
184
|
+
"input",
|
|
185
|
+
{
|
|
186
|
+
type: "checkbox",
|
|
187
|
+
checked: o,
|
|
188
|
+
onChange: () => A(t),
|
|
189
|
+
className: r.checkbox
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ i("span", { className: r.label, children: n })
|
|
193
|
+
] }, t) : /* @__PURE__ */ i(
|
|
194
|
+
"button",
|
|
195
|
+
{
|
|
196
|
+
type: "button",
|
|
197
|
+
className: `${r.option} ${o ? r.selected : ""}`,
|
|
198
|
+
onClick: () => A(t),
|
|
199
|
+
children: n
|
|
200
|
+
},
|
|
201
|
+
t
|
|
202
|
+
);
|
|
203
|
+
}) })
|
|
204
|
+
] })
|
|
170
205
|
}
|
|
171
206
|
),
|
|
172
207
|
document.body
|
|
@@ -174,5 +209,5 @@ function ae({ value: p, options: _, onChange: z, disabled: f = !1, multiple: u =
|
|
|
174
209
|
] });
|
|
175
210
|
}
|
|
176
211
|
export {
|
|
177
|
-
|
|
212
|
+
ye as Select
|
|
178
213
|
};
|
|
@@ -1,24 +1,52 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { DevPanelPortal as
|
|
4
|
-
import { DevPanelManager as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { useRef as d, useEffect as s, createElement as v } from "react";
|
|
2
|
+
import { createRoot as S } from "react-dom/client";
|
|
3
|
+
import { DevPanelPortal as E } from "../../components/DevPanelPortal/index.js";
|
|
4
|
+
import { DevPanelManager as P } from "../../managers/DevPanelManager.js";
|
|
5
|
+
import { controlPersistenceService as m } from "../../store/ControlPersistenceService.js";
|
|
6
|
+
import { useDevPanelSections as w, useDevPanelSectionActions as D } from "../../store/SectionsStore.js";
|
|
7
|
+
import { hasControlsChanged as R } from "../../utils/hasControlChanged/hasControlChanged.js";
|
|
8
|
+
function j(t, o, i) {
|
|
9
|
+
const p = w(), { registerSection: g, unregisterSection: h } = D(), C = d(void 0), c = d(null), f = d(/* @__PURE__ */ new Set());
|
|
10
|
+
c.current || (c.current = P.getInstance()), s(() => {
|
|
11
|
+
Object.entries(o).forEach(([e, n]) => {
|
|
12
|
+
const r = `${t}-${e}`;
|
|
13
|
+
if (n.persist && !f.current.has(r)) {
|
|
14
|
+
const a = m.getPersistedValue(t, e);
|
|
15
|
+
a !== void 0 && "onChange" in n && typeof n.onChange == "function" && n.onChange(a), f.current.add(r);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}, [t, o]);
|
|
19
|
+
const u = d({});
|
|
20
|
+
s(() => {
|
|
21
|
+
const e = {};
|
|
22
|
+
Object.entries(o).forEach(([n, r]) => {
|
|
23
|
+
if (r.persist && "onChange" in r && typeof r.onChange == "function") {
|
|
24
|
+
const a = r.onChange;
|
|
25
|
+
e[n] = {
|
|
26
|
+
...r,
|
|
27
|
+
onChange: (l) => {
|
|
28
|
+
m.setPersistedValue(t, n, l), a(l);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
} else
|
|
32
|
+
e[n] = r;
|
|
33
|
+
}), u.current = e;
|
|
34
|
+
}, [t, o]), s(() => {
|
|
35
|
+
const e = c.current, n = p[t] !== void 0;
|
|
36
|
+
R(u.current, C.current) || !n ? (g(t, u.current), C.current = u.current, e.addSection(t, i)) : i && e.updateProps(i);
|
|
37
|
+
}, [t, o, i, p, g]), s(() => {
|
|
38
|
+
const e = f.current;
|
|
39
|
+
return () => {
|
|
40
|
+
const n = c.current;
|
|
41
|
+
h(t), n.removeSection(t), e.clear();
|
|
42
|
+
};
|
|
43
|
+
}, [t, h]), s(() => {
|
|
16
44
|
if (window.__devPanelAutoMounted) return;
|
|
17
45
|
window.__devPanelAutoMounted = !0;
|
|
18
46
|
const e = document.createElement("div");
|
|
19
|
-
e.id = "dev-panel-portal-container", e.style.display = "none", document.body.appendChild(e),
|
|
47
|
+
e.id = "dev-panel-portal-container", e.style.display = "none", document.body.appendChild(e), S(e).render(v(E));
|
|
20
48
|
}, []);
|
|
21
49
|
}
|
|
22
50
|
export {
|
|
23
|
-
|
|
51
|
+
j as useDevPanel
|
|
24
52
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for persisting individual control values
|
|
3
|
+
*/
|
|
4
|
+
declare class ControlPersistenceService {
|
|
5
|
+
private readonly storageKey;
|
|
6
|
+
/**
|
|
7
|
+
* Gets persisted value for a control
|
|
8
|
+
* @param sectionName - Name of the section
|
|
9
|
+
* @param controlKey - Key of the control within the section
|
|
10
|
+
* @returns Persisted value or undefined if not found
|
|
11
|
+
*/
|
|
12
|
+
getPersistedValue(sectionName: string, controlKey: string): unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Sets persisted value for a control
|
|
15
|
+
* @param sectionName - Name of the section
|
|
16
|
+
* @param controlKey - Key of the control within the section
|
|
17
|
+
* @param value - Value to persist
|
|
18
|
+
*/
|
|
19
|
+
setPersistedValue(sectionName: string, controlKey: string, value: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Removes persisted value for a control
|
|
22
|
+
* @param sectionName - Name of the section
|
|
23
|
+
* @param controlKey - Key of the control within the section
|
|
24
|
+
*/
|
|
25
|
+
removePersistedValue(sectionName: string, controlKey: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Removes all persisted values for a section
|
|
28
|
+
* @param sectionName - Name of the section
|
|
29
|
+
*/
|
|
30
|
+
removeSection(sectionName: string): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const controlPersistenceService: ControlPersistenceService;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class a {
|
|
2
|
+
storageKey = "dev-panel-controls-persistence";
|
|
3
|
+
/**
|
|
4
|
+
* Gets persisted value for a control
|
|
5
|
+
* @param sectionName - Name of the section
|
|
6
|
+
* @param controlKey - Key of the control within the section
|
|
7
|
+
* @returns Persisted value or undefined if not found
|
|
8
|
+
*/
|
|
9
|
+
getPersistedValue(e, s) {
|
|
10
|
+
try {
|
|
11
|
+
const t = localStorage.getItem(this.storageKey);
|
|
12
|
+
return t ? JSON.parse(t)[e]?.[s] : void 0;
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sets persisted value for a control
|
|
19
|
+
* @param sectionName - Name of the section
|
|
20
|
+
* @param controlKey - Key of the control within the section
|
|
21
|
+
* @param value - Value to persist
|
|
22
|
+
*/
|
|
23
|
+
setPersistedValue(e, s, t) {
|
|
24
|
+
try {
|
|
25
|
+
const r = localStorage.getItem(this.storageKey), o = r ? JSON.parse(r) : {};
|
|
26
|
+
o[e] || (o[e] = {}), o[e][s] = t, localStorage.setItem(this.storageKey, JSON.stringify(o));
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Removes persisted value for a control
|
|
32
|
+
* @param sectionName - Name of the section
|
|
33
|
+
* @param controlKey - Key of the control within the section
|
|
34
|
+
*/
|
|
35
|
+
removePersistedValue(e, s) {
|
|
36
|
+
try {
|
|
37
|
+
const t = localStorage.getItem(this.storageKey);
|
|
38
|
+
if (!t) return;
|
|
39
|
+
const r = JSON.parse(t);
|
|
40
|
+
r[e] && (delete r[e][s], Object.keys(r[e]).length === 0 && delete r[e], localStorage.setItem(this.storageKey, JSON.stringify(r)));
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Removes all persisted values for a section
|
|
46
|
+
* @param sectionName - Name of the section
|
|
47
|
+
*/
|
|
48
|
+
removeSection(e) {
|
|
49
|
+
try {
|
|
50
|
+
const s = localStorage.getItem(this.storageKey);
|
|
51
|
+
if (!s) return;
|
|
52
|
+
const t = JSON.parse(s);
|
|
53
|
+
delete t[e], localStorage.setItem(this.storageKey, JSON.stringify(t));
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const l = new a();
|
|
59
|
+
export {
|
|
60
|
+
l as controlPersistenceService
|
|
61
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies text to clipboard with optional feedback timing
|
|
3
|
+
*
|
|
4
|
+
* @param text - The text to copy to clipboard
|
|
5
|
+
* @returns Promise that resolves when text is copied, rejects if copy fails
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* try {
|
|
10
|
+
* await copyToClipboard("Hello World", 2000);
|
|
11
|
+
* console.log("Copied!");
|
|
12
|
+
* } catch {
|
|
13
|
+
* console.error("Failed to copy");
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function copyToClipboard(text: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { copyToClipboard } from './copyToClipboard';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a truncated preview of a string with ellipsis suffix if it exceeds max length
|
|
3
|
+
*
|
|
4
|
+
* @param text - The text to get preview from
|
|
5
|
+
* @param maxLength - Maximum length before truncating (default: 100)
|
|
6
|
+
* @returns Truncated text with "..." suffix if longer than maxLength, original text otherwise
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* getStringPreview("Hello World", 5) // Returns "Hello..."
|
|
11
|
+
* getStringPreview("Hi", 5) // Returns "Hi"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function getStringPreview(text: string, maxLength?: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStringPreview } from './getStringPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { prettifyJson } from './prettifyJson';
|