@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.
Files changed (41) hide show
  1. package/README.md +97 -239
  2. package/dist/assets/index11.css +1 -1
  3. package/dist/assets/index12.css +1 -1
  4. package/dist/assets/index13.css +1 -1
  5. package/dist/assets/index14.css +1 -1
  6. package/dist/assets/index15.css +1 -1
  7. package/dist/assets/index16.css +1 -0
  8. package/dist/assets/index5.css +1 -1
  9. package/dist/assets/index7.css +1 -1
  10. package/dist/components/ControlRenderer/controls/BooleanControl/index.js +1 -1
  11. package/dist/components/ControlRenderer/controls/ButtonControl/index.js +1 -1
  12. package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.js +1 -1
  13. package/dist/components/ControlRenderer/controls/ColorControl/index.js +1 -1
  14. package/dist/components/ControlRenderer/controls/DragAndDropControl/index.js +1 -1
  15. package/dist/components/ControlRenderer/controls/LocalStorageControl/index.d.ts +23 -0
  16. package/dist/components/ControlRenderer/controls/LocalStorageControl/index.js +252 -0
  17. package/dist/components/ControlRenderer/controls/LocalStorageControl/types.d.ts +14 -0
  18. package/dist/components/ControlRenderer/controls/SelectControl/index.js +15 -5
  19. package/dist/components/ControlRenderer/controls/SelectControl/types.d.ts +2 -0
  20. package/dist/components/ControlRenderer/controls/index.d.ts +1 -0
  21. package/dist/components/ControlRenderer/controls/index.js +2 -1
  22. package/dist/components/ControlRenderer/controls/types.d.ts +3 -0
  23. package/dist/components/ControlRenderer/index.js +23 -23
  24. package/dist/components/Select/index.d.ts +3 -1
  25. package/dist/components/Select/index.js +132 -97
  26. package/dist/hooks/useDevPanel/index.js +45 -17
  27. package/dist/store/ControlPersistenceService.d.ts +33 -0
  28. package/dist/store/ControlPersistenceService.js +61 -0
  29. package/dist/utils/copyToClipboard/copyToClipboard.d.ts +17 -0
  30. package/dist/utils/copyToClipboard/copyToClipboard.js +10 -0
  31. package/dist/utils/copyToClipboard/index.d.ts +1 -0
  32. package/dist/utils/copyToClipboard/index.js +4 -0
  33. package/dist/utils/getStringPreview/getStringPreview.d.ts +14 -0
  34. package/dist/utils/getStringPreview/getStringPreview.js +6 -0
  35. package/dist/utils/getStringPreview/index.d.ts +1 -0
  36. package/dist/utils/getStringPreview/index.js +4 -0
  37. package/dist/utils/prettifyJson/index.d.ts +1 -0
  38. package/dist/utils/prettifyJson/index.js +4 -0
  39. package/dist/utils/prettifyJson/prettifyJson.d.ts +13 -0
  40. package/dist/utils/prettifyJson/prettifyJson.js +11 -0
  41. package/package.json +9 -3
@@ -1,50 +1,50 @@
1
- import { jsxs as t, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as t, jsx as o } from "react/jsx-runtime";
2
2
  import { Suspense as c } from "react";
3
- import { className as s } from "../../utils/className/className.js";
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 = "_controlRendererContainer_1s60v_1", _ = "_controlContainer_1s60v_4", u = "_hoverable_1s60v_13", v = "_fullWidth_1s60v_16", f = "_label_1s60v_19", h = "_controlWrapper_1s60v_22", b = "_justifyStart_1s60v_26", C = "_description_1s60v_42", m = "_loading_1s60v_51", y = "_error_1s60v_70", e = {
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: u,
9
- fullWidth: v,
10
- label: f,
11
- controlWrapper: h,
12
- justifyStart: b,
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"], W = ["separator", "dragAndDrop"], j = ["button", "separator", "dragAndDrop"];
17
- function A({ name: l, control: r }) {
18
- const i = r?.label || l;
19
- function a() {
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__ */ n("div", { className: e.error, children: "Control type is not defined" });
22
- const o = d[r.type];
23
- return o ? /* @__PURE__ */ n(c, { fallback: /* @__PURE__ */ n("div", { className: e.loading, children: "Loading control..." }), children: /* @__PURE__ */ n(o, { control: r }) }) : /* @__PURE__ */ n("div", { children: "Unknown control type" });
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
- ...s(e.controlContainer, {
29
+ ...l(e.controlContainer, {
30
30
  [e.fullWidth]: g.includes(r.type),
31
- [e.hoverable]: !W.includes(r.type)
31
+ [e.hoverable]: !v.includes(r.type)
32
32
  }),
33
33
  children: [
34
- !j.includes(r.type) && /* @__PURE__ */ n("label", { className: e.label, children: i }),
35
- /* @__PURE__ */ n(
34
+ !S.includes(r.type) && /* @__PURE__ */ o("label", { className: e.label, children: i }),
35
+ /* @__PURE__ */ o(
36
36
  "div",
37
37
  {
38
- ...s(e.controlWrapper, {
38
+ ...l(e.controlWrapper, {
39
39
  [e.justifyStart]: r.type === "separator"
40
40
  }),
41
- children: a()
41
+ children: s()
42
42
  }
43
43
  )
44
44
  ]
45
45
  }
46
46
  ),
47
- r?.description && /* @__PURE__ */ n("span", { className: e.description, children: r.description })
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 y, Fragment as M, jsx as a } from "react/jsx-runtime";
2
- import { useRef as x, useState as H, useCallback as q, useEffect as P } from "react";
3
- import { createPortal as T } from "react-dom";
4
- import { Icon as j } from "../Icon/index.js";
5
- import { useDevPanelPosition as B } from "../../store/UIStore.js";
6
- import { className as F } from "../../utils/className/className.js";
7
- import '../../assets/index7.css';const W = "_select_1hbiz_217", U = "_trigger_1hbiz_222", G = "_open_1hbiz_271", J = "_value_1hbiz_275", K = "_placeholder_1hbiz_284", Q = "_arrow_1hbiz_288", X = "_dropdownPortal_1hbiz_303", Y = "_dropdown_1hbiz_303", Z = "_option_1hbiz_342", ee = "_selected_1hbiz_360", te = "_checkbox_1hbiz_369", ne = "_label_1hbiz_390", r = {
8
- select: W,
9
- trigger: U,
10
- open: G,
11
- value: J,
12
- placeholder: K,
13
- arrow: Q,
14
- dropdownPortal: X,
15
- dropdown: Y,
16
- option: Z,
17
- selected: ee,
18
- checkbox: te,
19
- label: ne
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 ae({ value: p, options: _, onChange: z, disabled: f = !1, multiple: u = !1, placeholder: L = "Select..." }) {
22
- const w = B(), g = x(null), h = x(null), k = x(null), [c, m] = H(!1), [b, E] = H({
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(p) ? p : [] : typeof p == "string" ? p : "", C = S(), D = u ? d.length === 0 : !d, s = q(() => {
28
- c && E(N());
29
- }, [c]);
30
- function N() {
31
- if (!h.current)
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 = h.current.getBoundingClientRect(), t = window.innerHeight, n = window.innerWidth, o = 200, l = 4, i = t - e.bottom - l, v = e.top - l, R = i < o && v > i, V = R ? e.top - Math.min(o, v) : e.bottom + l, $ = Math.max(8, Math.min(e.left, n - e.width - 8)), I = R ? Math.min(o, v) : Math.min(o, i);
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: V,
41
- left: $,
58
+ top: B,
59
+ left: F,
42
60
  width: e.width,
43
- maxHeight: I
61
+ maxHeight: Q
44
62
  };
45
63
  }
46
- function O(e) {
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
- z(n);
67
+ k(n);
50
68
  } else
51
- z(e), m(!1);
69
+ k(e), v(!1);
52
70
  }
53
- function S() {
71
+ function T() {
54
72
  if (u) {
55
73
  const e = d;
56
74
  if (e.length === 0)
57
- return L;
75
+ return I;
58
76
  if (e.length === 1) {
59
- const t = _.find((o) => (typeof o == "string" ? o : o.value) === e[0]);
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 L;
67
- const t = _.find((o) => (typeof o == "string" ? o : o.value) === e);
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 A() {
72
- f || (c ? m(!1) : (E(N()), m(!0)));
89
+ function z() {
90
+ g || (l ? (v(!1), L("")) : (S(D()), v(!0), L(""), w && setTimeout(() => O.current?.focus(), 0)));
73
91
  }
74
- return P(() => {
75
- if (!c) return;
76
- s(), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0);
77
- const e = g.current?.closest("[data-dev-panel]") || document.querySelector("[data-dev-panel]");
78
- e && e.addEventListener("scroll", s, !0);
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 (h.current && "IntersectionObserver" in window) {
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 l = o[0];
90
- if (l && l.target === h.current) {
91
- const i = l.boundingClientRect;
92
- (i.top !== n.top || i.left !== n.left || i.width !== n.width || i.height !== n.height) && (n.top = i.top, n.left = i.left, n.width = i.width, n.height = i.height, s());
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(h.current);
119
+ ), t.observe(p.current);
99
120
  }
100
121
  return () => {
101
- window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), e && e.removeEventListener("scroll", s, !0), t && t.disconnect();
122
+ window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0), e && e.removeEventListener("scroll", c, !0), t && t.disconnect();
102
123
  };
103
- }, [c, s]), P(() => {
104
- const e = k.current;
105
- (!e || e.x !== w.x || e.y !== w.y) && (k.current = w, c && requestAnimationFrame(s));
106
- }, [c, w, s]), P(() => {
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 (g.current && !g.current.contains(t.target)) {
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
- m(!1);
133
+ v(!1);
113
134
  }
114
135
  }
115
136
  return document.addEventListener("mousedown", e), () => {
116
137
  document.removeEventListener("mousedown", e);
117
138
  };
118
- }, []), /* @__PURE__ */ y(M, { children: [
119
- /* @__PURE__ */ a(
139
+ }, []), /* @__PURE__ */ x(W, { children: [
140
+ /* @__PURE__ */ i(
120
141
  "div",
121
142
  {
122
- ref: g,
123
- ...F(r.select, {
124
- [r.disabled]: f,
125
- [r.open]: c
143
+ ref: _,
144
+ ...Y(r.select, {
145
+ [r.disabled]: g,
146
+ [r.open]: l
126
147
  }),
127
- children: /* @__PURE__ */ y("button", { ref: h, type: "button", className: r.trigger, onClick: A, disabled: f, children: [
128
- /* @__PURE__ */ a("span", { className: `${r.value} ${D ? r.placeholder : ""}`, children: C }),
129
- /* @__PURE__ */ a(j, { name: "ArrowDown", className: r.arrow })
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" && T(
134
- c && !f && /* @__PURE__ */ a(
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: b.top,
141
- left: b.left,
142
- width: b.width,
143
- maxHeight: b.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__ */ a("div", { className: r.dropdown, children: _.map((e) => {
147
- const t = typeof e == "string" ? e : e.value, n = typeof e == "string" ? e : e.label, o = u ? d.includes(t) : d === t;
148
- return u ? /* @__PURE__ */ y("label", { className: r.option, children: [
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
- type: "button",
163
- className: `${r.option} ${o ? r.selected : ""}`,
164
- onClick: () => O(t),
165
- children: n
166
- },
167
- t
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
- ae as Select
212
+ ye as Select
178
213
  };
@@ -1,24 +1,52 @@
1
- import { useRef as f, useEffect as i, createElement as l } from "react";
2
- import { createRoot as m } from "react-dom/client";
3
- import { DevPanelPortal as p } from "../../components/DevPanelPortal/index.js";
4
- import { DevPanelManager as v } from "../../managers/DevPanelManager.js";
5
- import { useDevPanelSections as g, useDevPanelSectionActions as S } from "../../store/SectionsStore.js";
6
- import { hasControlsChanged as D } from "../../utils/hasControlChanged/hasControlChanged.js";
7
- function y(t, n, r) {
8
- const c = g(), { registerSection: u, unregisterSection: a } = S(), s = f(void 0), o = f(null);
9
- o.current || (o.current = v.getInstance()), i(() => {
10
- const e = o.current, d = c[t] !== void 0;
11
- D(n, s.current) || !d ? (u(t, n), s.current = n, e.addSection(t, r)) : r && e.updateProps(r);
12
- }, [t, n, r, c, u]), i(() => () => {
13
- const e = o.current;
14
- a(t), e.removeSection(t);
15
- }, [t, a]), i(() => {
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), m(e).render(l(p));
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
- y as useDevPanel
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,10 @@
1
+ async function t(o) {
2
+ try {
3
+ await navigator.clipboard.writeText(o);
4
+ } catch (r) {
5
+ throw new Error(`Failed to copy to clipboard: ${r instanceof Error ? r.message : String(r)}`);
6
+ }
7
+ }
8
+ export {
9
+ t as copyToClipboard
10
+ };
@@ -0,0 +1 @@
1
+ export { copyToClipboard } from './copyToClipboard';
@@ -0,0 +1,4 @@
1
+ import { copyToClipboard as r } from "./copyToClipboard.js";
2
+ export {
3
+ r as copyToClipboard
4
+ };
@@ -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,6 @@
1
+ function i(r, e = 100) {
2
+ return r.length <= e ? r : r.slice(0, e) + "...";
3
+ }
4
+ export {
5
+ i as getStringPreview
6
+ };
@@ -0,0 +1 @@
1
+ export { getStringPreview } from './getStringPreview';
@@ -0,0 +1,4 @@
1
+ import { getStringPreview as t } from "./getStringPreview.js";
2
+ export {
3
+ t as getStringPreview
4
+ };
@@ -0,0 +1 @@
1
+ export { prettifyJson } from './prettifyJson';