@berenjena/react-dev-panel 2.0.0 → 2.1.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 (128) hide show
  1. package/README.md +75 -52
  2. package/dist/assets/index.css +1 -1
  3. package/dist/assets/index11.css +1 -0
  4. package/dist/assets/index12.css +1 -0
  5. package/dist/assets/index13.css +1 -0
  6. package/dist/assets/index2.css +1 -0
  7. package/dist/assets/index6.css +1 -0
  8. package/dist/assets/index7.css +1 -0
  9. package/dist/assets/{RangeControl.css → index9.css} +1 -1
  10. package/dist/components/ControlRenderer/controls/BooleanControl/index.d.ts +32 -1
  11. package/dist/components/ControlRenderer/controls/BooleanControl/index.js +24 -2
  12. package/dist/components/ControlRenderer/controls/ButtonControl/index.d.ts +33 -1
  13. package/dist/components/ControlRenderer/controls/ButtonControl/index.js +8 -2
  14. package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.d.ts +37 -1
  15. package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.js +20 -2
  16. package/dist/components/ControlRenderer/controls/ColorControl/index.d.ts +23 -1
  17. package/dist/components/ControlRenderer/controls/ColorControl/index.js +67 -2
  18. package/dist/components/ControlRenderer/controls/DateControl/index.d.ts +41 -1
  19. package/dist/components/ControlRenderer/controls/DateControl/index.js +29 -2
  20. package/dist/components/ControlRenderer/controls/MultiSelectControl/index.d.ts +28 -1
  21. package/dist/components/ControlRenderer/controls/MultiSelectControl/index.js +16 -2
  22. package/dist/components/ControlRenderer/controls/NumberControl/index.d.ts +45 -1
  23. package/dist/components/ControlRenderer/controls/NumberControl/index.js +30 -2
  24. package/dist/components/ControlRenderer/controls/RangeControl/index.d.ts +46 -1
  25. package/dist/components/ControlRenderer/controls/RangeControl/index.js +38 -2
  26. package/dist/components/ControlRenderer/controls/SelectControl/index.d.ts +39 -1
  27. package/dist/components/ControlRenderer/controls/SelectControl/index.js +6 -2
  28. package/dist/components/ControlRenderer/controls/SeparatorControl/index.d.ts +39 -1
  29. package/dist/components/ControlRenderer/controls/SeparatorControl/index.js +12 -2
  30. package/dist/components/ControlRenderer/controls/TextControl/index.d.ts +40 -1
  31. package/dist/components/ControlRenderer/controls/TextControl/index.js +28 -2
  32. package/dist/components/ControlRenderer/index.d.ts +6 -1
  33. package/dist/components/ControlRenderer/index.js +50 -2
  34. package/dist/components/DevPanel/index.d.ts +11 -1
  35. package/dist/components/DevPanel/index.js +69 -2
  36. package/dist/components/DevPanel/types.d.ts +13 -6
  37. package/dist/components/DevPanelPortal/index.d.ts +9 -1
  38. package/dist/components/DevPanelPortal/index.js +15 -2
  39. package/dist/components/EmptyContent/index.d.ts +1 -1
  40. package/dist/components/EmptyContent/index.js +17 -2
  41. package/dist/components/Icon/index.d.ts +3 -3
  42. package/dist/components/Input/index.d.ts +1 -1
  43. package/dist/components/Input/index.js +8 -2
  44. package/dist/components/Section/index.d.ts +7 -1
  45. package/dist/components/Section/index.js +23 -2
  46. package/dist/components/Select/index.d.ts +15 -1
  47. package/dist/components/Select/index.js +176 -2
  48. package/dist/components/index.js +3 -3
  49. package/dist/hooks/useDebounceCallback/index.d.ts +8 -1
  50. package/dist/hooks/useDebounceCallback/index.js +15 -2
  51. package/dist/hooks/useDevPanel/index.d.ts +29 -1
  52. package/dist/hooks/useDevPanel/index.js +22 -2
  53. package/dist/hooks/useDragAndDrop/index.d.ts +20 -1
  54. package/dist/hooks/useDragAndDrop/index.js +53 -2
  55. package/dist/hooks/{useHotkeys/useHotkey.d.ts → useHotKey/index.d.ts} +1 -1
  56. package/dist/hooks/{useHotkeys/useHotkey.js → useHotKey/index.js} +1 -1
  57. package/dist/hooks/useHotkeys/index.d.ts +37 -2
  58. package/dist/hooks/useHotkeys/index.js +29 -4
  59. package/dist/index.js +1 -1
  60. package/dist/store/UIStore.d.ts +78 -2
  61. package/dist/store/UIStore.js +95 -34
  62. package/dist/utils/getPositionAdjustment/getPositionAdjustment.d.ts +3 -2
  63. package/dist/utils/getPositionAdjustment/getPositionAdjustment.js +1 -4
  64. package/package.json +43 -29
  65. package/dist/assets/BooleanControl.css +0 -1
  66. package/dist/assets/ButtonControl.css +0 -1
  67. package/dist/assets/ButtonGroupControl.css +0 -1
  68. package/dist/assets/DevPanel.css +0 -1
  69. package/dist/assets/Input.css +0 -1
  70. package/dist/assets/MultiSelectControl.css +0 -1
  71. package/dist/assets/Select.css +0 -1
  72. package/dist/components/ControlRenderer/ControlRenderer.d.ts +0 -6
  73. package/dist/components/ControlRenderer/ControlRenderer.js +0 -52
  74. package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.d.ts +0 -32
  75. package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.js +0 -26
  76. package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.d.ts +0 -33
  77. package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.js +0 -10
  78. package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.d.ts +0 -37
  79. package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.js +0 -22
  80. package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.d.ts +0 -23
  81. package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.js +0 -69
  82. package/dist/components/ControlRenderer/controls/DateControl/DateControl.d.ts +0 -41
  83. package/dist/components/ControlRenderer/controls/DateControl/DateControl.js +0 -31
  84. package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.d.ts +0 -28
  85. package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.js +0 -131
  86. package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.d.ts +0 -45
  87. package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.js +0 -32
  88. package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.d.ts +0 -46
  89. package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.js +0 -40
  90. package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.d.ts +0 -39
  91. package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.js +0 -11
  92. package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.d.ts +0 -39
  93. package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.js +0 -14
  94. package/dist/components/ControlRenderer/controls/TextControl/TextControl.d.ts +0 -40
  95. package/dist/components/ControlRenderer/controls/TextControl/TextControl.js +0 -30
  96. package/dist/components/DevPanel/DevPanel.d.ts +0 -11
  97. package/dist/components/DevPanel/DevPanel.js +0 -72
  98. package/dist/components/DevPanelPortal/DevPanelPortal.d.ts +0 -8
  99. package/dist/components/DevPanelPortal/DevPanelPortal.js +0 -17
  100. package/dist/components/EmptyContent/EmptyContent.d.ts +0 -1
  101. package/dist/components/EmptyContent/EmptyContent.js +0 -18
  102. package/dist/components/Input/Input.d.ts +0 -1
  103. package/dist/components/Input/Input.js +0 -10
  104. package/dist/components/Section/Section.d.ts +0 -7
  105. package/dist/components/Section/Section.js +0 -25
  106. package/dist/components/Select/Select.d.ts +0 -1
  107. package/dist/components/Select/Select.js +0 -10
  108. package/dist/hooks/useDebounceCallback/useDebounceCallback.d.ts +0 -8
  109. package/dist/hooks/useDebounceCallback/useDebounceCallback.js +0 -17
  110. package/dist/hooks/useDevPanel/useDevPanel.d.ts +0 -29
  111. package/dist/hooks/useDevPanel/useDevPanel.js +0 -25218
  112. package/dist/hooks/useDragAndDrop/useDragAndDrop.d.ts +0 -20
  113. package/dist/hooks/useDragAndDrop/useDragAndDrop.js +0 -55
  114. package/dist/hooks/useHotkeys/useHotkeys.d.ts +0 -37
  115. package/dist/hooks/useHotkeys/useHotkeys.js +0 -31
  116. package/dist/managers/index.d.ts +0 -1
  117. package/dist/managers/index.js +0 -4
  118. package/dist/store/ThemeStore.d.ts +0 -68
  119. package/dist/store/ThemeStore.js +0 -102
  120. package/dist/store/index.d.ts +0 -4
  121. package/dist/store/index.js +0 -18
  122. package/dist/utils/index.d.ts +0 -9
  123. package/dist/utils/index.js +0 -20
  124. /package/dist/assets/{ColorControl.css → index10.css} +0 -0
  125. /package/dist/assets/{EmptyContent.css → index3.css} +0 -0
  126. /package/dist/assets/{Section.css → index4.css} +0 -0
  127. /package/dist/assets/{ControlRenderer.css → index5.css} +0 -0
  128. /package/dist/assets/{SeparatorControl.css → index8.css} +0 -0
@@ -1 +1,29 @@
1
- export * from './useDevPanel';
1
+ import { ControlsGroup } from '../../components/ControlRenderer/controls/types';
2
+ import { DevPanelProps } from '../../components/DevPanel/types';
3
+ /**
4
+ * Hook to register controls in the dev panel with auto-mounting
5
+ * @param sectionName - Section name (e.g: 'Global', 'HomePage')
6
+ * @param controls - Controls configuration object
7
+ * @param devPanelProps - Optional DevPanel configuration (title, hotkey, theme)
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * useDevPanel('Global', {
12
+ * theme: {
13
+ * type: 'select',
14
+ * value: 'light',
15
+ * options: ['light', 'dark'],
16
+ * onChange: setTheme
17
+ * },
18
+ * debugMode: {
19
+ * type: 'boolean',
20
+ * value: false,
21
+ * onChange: setDebugMode
22
+ * }
23
+ * }, {
24
+ * panelTitle: 'My App Controls',
25
+ * theme: 'dark'
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function useDevPanel(sectionName: string, controls: ControlsGroup, devPanelProps?: DevPanelProps): void;
@@ -1,4 +1,24 @@
1
- import { useDevPanel as r } from "./useDevPanel.js";
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(() => {
16
+ if (window.__devPanelAutoMounted) return;
17
+ window.__devPanelAutoMounted = !0;
18
+ 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));
20
+ }, []);
21
+ }
2
22
  export {
3
- r as useDevPanel
23
+ y as useDevPanel
4
24
  };
@@ -1 +1,20 @@
1
- export * from './useDragAndDrop';
1
+ import { Position } from '../../components/DevPanel/types';
2
+ export interface UseDragAndDropProps {
3
+ /**
4
+ * Callback function to handle position changes during dragging
5
+ * @param position - The new position of the draggable element
6
+ */
7
+ onPositionChange: (position: Position) => void;
8
+ }
9
+ /**
10
+ * Custom hook to handle drag and drop functionality
11
+ * Separates the drag logic from the main component
12
+ * Includes boundary constraints and window resize handling
13
+ */
14
+ export declare function useDragAndDrop({ onPositionChange }: UseDragAndDropProps): {
15
+ elementRef: React.RefObject<HTMLDivElement | null>;
16
+ isDragging: boolean;
17
+ handlePointerDown: (e: React.PointerEvent) => void;
18
+ stopDragging: () => void;
19
+ adjustPositionForResize: () => void;
20
+ };
@@ -1,4 +1,55 @@
1
- import { useDragAndDrop as e } from "./useDragAndDrop.js";
1
+ import { useRef as g, useState as p, useCallback as u, useEffect as f } from "react";
2
+ import { debounce as E } from "../../utils/debounce/debounce.js";
3
+ import { getConstrainedPosition as D } from "../../utils/getConstrainedPosition/getConstrainedPosition.js";
4
+ import { getPositionAdjustment as L } from "../../utils/getPositionAdjustment/getPositionAdjustment.js";
5
+ function R({ onPositionChange: s }) {
6
+ const o = g(null), [t, a] = p(!1), [c, l] = p({ x: 0, y: 0 }), d = u(() => {
7
+ const e = o.current;
8
+ if (!e) return;
9
+ const { constrainedPosition: n, needsAdjustment: m } = L(e);
10
+ m && s(n);
11
+ }, [s]), i = u(
12
+ (e) => {
13
+ if (!t || !o.current) return;
14
+ const n = {
15
+ x: e.clientX - c.x,
16
+ y: e.clientY - c.y
17
+ }, m = D(n, o.current);
18
+ s(m);
19
+ },
20
+ [t, c.x, c.y, s]
21
+ ), r = u(() => {
22
+ a(!1);
23
+ }, []), v = u((e) => {
24
+ if (e.target !== e.currentTarget) return;
25
+ e.preventDefault(), a(!0);
26
+ const n = o.current?.getBoundingClientRect();
27
+ n && l({
28
+ x: e.clientX - n.left,
29
+ y: e.clientY - n.top
30
+ });
31
+ }, []);
32
+ return f(() => {
33
+ if (!t) return;
34
+ const e = { passive: !0 };
35
+ return document.addEventListener("pointermove", i, e), document.addEventListener("pointerup", r, e), () => {
36
+ document.removeEventListener("pointermove", i), document.removeEventListener("pointerup", r);
37
+ };
38
+ }, [t, i, r]), f(() => {
39
+ const e = E(d, 100);
40
+ return window.addEventListener("resize", e), () => {
41
+ window.removeEventListener("resize", e);
42
+ };
43
+ }, [d]), f(() => () => {
44
+ t && (document.removeEventListener("pointermove", i), document.removeEventListener("pointerup", r));
45
+ }, [t, i, r]), {
46
+ isDragging: t,
47
+ elementRef: o,
48
+ handlePointerDown: v,
49
+ stopDragging: r,
50
+ adjustPositionForResize: d
51
+ };
52
+ }
2
53
  export {
3
- e as useDragAndDrop
54
+ R as useDragAndDrop
4
55
  };
@@ -1,4 +1,4 @@
1
- import { HotkeyConfig, UseHotkeysOptions } from './types';
1
+ import { HotkeyConfig, UseHotkeysOptions } from '../useHotkeys/types';
2
2
  /**
3
3
  * Hook for handling a single hotkey combination
4
4
  *
@@ -1,4 +1,4 @@
1
- import { useHotkeys as t } from "./useHotkeys.js";
1
+ import { useHotkeys as t } from "../useHotkeys/index.js";
2
2
  function s(o, e = {}) {
3
3
  t([o], e);
4
4
  }
@@ -1,2 +1,37 @@
1
- export * from './useHotkey';
2
- export * from './useHotkeys';
1
+ import { HotkeyConfig, UseHotkeysOptions } from './types';
2
+ /**
3
+ * Hook for handling keyboard shortcuts (hotkeys) with support for modifier keys
4
+ * and multiple key combinations.
5
+ *
6
+ * @param hotkeys - Array of hotkey configurations
7
+ * @param options - Global options for all hotkeys
8
+ *
9
+ * @example
10
+ * // Basic usage
11
+ * useHotkeys([
12
+ * { key: 'Enter', action: handleSubmit },
13
+ * { key: 'Escape', action: handleCancel }
14
+ * ]);
15
+ *
16
+ * @example
17
+ * // With modifier keys
18
+ * useHotkeys([
19
+ * { key: 's', ctrlKey: true, action: handleSave, description: 'Save' },
20
+ * { key: 'k', metaKey: true, action: handleSearch, description: 'Search' },
21
+ * { key: 'z', ctrlKey: true, action: handleUndo, description: 'Undo' },
22
+ * { key: 'z', ctrlKey: true, shiftKey: true, action: handleRedo, description: 'Redo' }
23
+ * ]);
24
+ *
25
+ * @example
26
+ * // With individual configuration
27
+ * useHotkeys([
28
+ * {
29
+ * key: 'Delete',
30
+ * action: handleDelete,
31
+ * preventDefault: true,
32
+ * enabled: canDelete,
33
+ * description: 'Delete item'
34
+ * }
35
+ * ]);
36
+ */
37
+ export declare function useHotkeys(hotkeys: HotkeyConfig[], options?: UseHotkeysOptions): void;
@@ -1,6 +1,31 @@
1
- import { useHotkey as r } from "./useHotkey.js";
2
- import { useHotkeys as s } from "./useHotkeys.js";
1
+ import { useRef as K, useCallback as y, useEffect as w } from "react";
2
+ function M(h, p = {}) {
3
+ const { enabled: a = !0, target: c = window, preventDefault: f = !1, stopPropagation: l = !1 } = p, u = K([]);
4
+ u.current = h;
5
+ const i = y((t, e) => {
6
+ const o = t.key.toLowerCase() === e.key.toLowerCase(), n = !!e.ctrlKey === t.ctrlKey, s = !!e.shiftKey === t.shiftKey, d = !!e.altKey === t.altKey, k = !!e.metaKey === t.metaKey;
7
+ return o && n && s && d && k;
8
+ }, []), r = y(
9
+ (t) => {
10
+ if (!a) return;
11
+ const e = t;
12
+ for (const o of u.current)
13
+ if (o.enabled !== !1 && i(e, o)) {
14
+ const n = o.preventDefault ?? f, s = o.stopPropagation ?? l;
15
+ n && t.preventDefault(), s && t.stopPropagation(), o.action(e);
16
+ break;
17
+ }
18
+ },
19
+ [a, f, l, i]
20
+ );
21
+ w(() => {
22
+ const t = c;
23
+ if (!(!t || !a))
24
+ return t.addEventListener("keydown", r), () => {
25
+ t.removeEventListener("keydown", r);
26
+ };
27
+ }, [c, a, r]);
28
+ }
3
29
  export {
4
- r as useHotkey,
5
- s as useHotkeys
30
+ M as useHotkeys
6
31
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useDevPanel as r } from "./hooks/useDevPanel/useDevPanel.js";
1
+ import { useDevPanel as r } from "./hooks/useDevPanel/index.js";
2
2
  import './assets/index.css';export {
3
3
  r as useDevPanel
4
4
  };
@@ -11,8 +11,10 @@ import { DevPanelUIState, Position } from '../components/DevPanel/types';
11
11
  * const {
12
12
  * isVisible,
13
13
  * position,
14
+ * currentTheme,
14
15
  * setVisible,
15
- * setPosition
16
+ * setPosition,
17
+ * setTheme
16
18
  * } = useDevPanelUI();
17
19
  * ```
18
20
  */
@@ -20,6 +22,9 @@ export declare function useDevPanelUI(): DevPanelUIState & {
20
22
  setVisible: (visible: boolean) => void;
21
23
  setCollapsed: (collapsed: boolean) => void;
22
24
  setPosition: (position: Position) => void;
25
+ setTheme: (theme: string) => void;
26
+ resetTheme: () => void;
27
+ getCurrentTheme: () => string;
23
28
  reset: () => void;
24
29
  };
25
30
  /**
@@ -59,6 +64,46 @@ export declare function useDevPanelCollapsed(): boolean;
59
64
  * ```
60
65
  */
61
66
  export declare function useDevPanelPosition(): Position;
67
+ /**
68
+ * React hook that subscribes only to the current theme state.
69
+ * Optimized for components that only need to know the current theme.
70
+ *
71
+ * @returns String indicating the current theme name
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const currentTheme = useCurrentTheme();
76
+ * console.log(`Current theme is: ${currentTheme}`);
77
+ * ```
78
+ */
79
+ export declare function useCurrentTheme(): string;
80
+ /**
81
+ * React hook that provides access to the complete dev panel theme state and actions.
82
+ * Uses useSyncExternalStore for optimal performance and React 18 compatibility.
83
+ *
84
+ * @returns Object containing the current theme state and all available theme actions
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const {
89
+ * currentTheme,
90
+ * setTheme,
91
+ * resetTheme
92
+ * } = useDevPanelTheme();
93
+ *
94
+ * // Set a specific theme
95
+ * setTheme("dark");
96
+ *
97
+ * // Reset to auto theme
98
+ * resetTheme();
99
+ * ```
100
+ */
101
+ export declare function useDevPanelTheme(): {
102
+ currentTheme: string;
103
+ setTheme: (theme: string) => void;
104
+ resetTheme: () => void;
105
+ getCurrentTheme: () => string;
106
+ };
62
107
  /**
63
108
  * React hook that provides access to all dev panel UI actions without subscribing to state.
64
109
  * Ideal for components that only need to trigger UI actions without rendering on state changes.
@@ -67,7 +112,7 @@ export declare function useDevPanelPosition(): Position;
67
112
  *
68
113
  * @example
69
114
  * ```typescript
70
- * const { setVisible, setPosition, reset } = useDevPanelUIActions();
115
+ * const { setVisible, setPosition, setTheme, reset } = useDevPanelUIActions();
71
116
  *
72
117
  * // Toggle panel visibility
73
118
  * setVisible(true);
@@ -75,6 +120,9 @@ export declare function useDevPanelPosition(): Position;
75
120
  * // Update position
76
121
  * setPosition({ x: 100, y: 100 });
77
122
  *
123
+ * // Set theme
124
+ * setTheme("dark");
125
+ *
78
126
  * // Reset UI state
79
127
  * reset();
80
128
  * ```
@@ -83,6 +131,34 @@ export declare function useDevPanelUIActions(): {
83
131
  setVisible: (visible: boolean) => void;
84
132
  setCollapsed: (collapsed: boolean) => void;
85
133
  setPosition: (position: Position) => void;
134
+ setTheme: (theme: string) => void;
135
+ resetTheme: () => void;
136
+ getCurrentTheme: () => string;
86
137
  reset: () => void;
87
138
  };
139
+ /**
140
+ * React hook that provides access to all dev panel theme actions without subscribing to state.
141
+ * Ideal for components that only need to trigger theme actions without rendering on state changes.
142
+ *
143
+ * @returns Object containing all available theme actions
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const { setTheme, resetTheme } = useDevPanelThemeActions();
148
+ *
149
+ * // Switch to dark theme
150
+ * setTheme("dark");
151
+ *
152
+ * // Switch to neon theme
153
+ * setTheme("neon");
154
+ *
155
+ * // Reset to auto theme
156
+ * resetTheme();
157
+ * ```
158
+ */
159
+ export declare function useDevPanelThemeActions(): {
160
+ setTheme: (theme: string) => void;
161
+ resetTheme: () => void;
162
+ getCurrentTheme: () => string;
163
+ };
88
164
  export declare const useDevPanelStore: typeof useDevPanelUI;
@@ -1,16 +1,17 @@
1
- import { useSyncExternalStore as i } from "react";
2
- import { BaseStoreService as r } from "./BaseStoreService.js";
3
- const l = "dev-panel-ui-storage", a = { x: 20, y: 20 }, o = {
1
+ import { useSyncExternalStore as r } from "react";
2
+ import { BaseStoreService as o } from "./BaseStoreService.js";
3
+ const u = "dev-panel-ui-storage", h = { x: 20, y: 20 }, n = {
4
4
  isVisible: !1,
5
5
  isCollapsed: !1,
6
- position: a
6
+ position: h,
7
+ currentTheme: "auto"
7
8
  };
8
- class u extends r {
9
+ class a extends o {
9
10
  /**
10
11
  * Creates a new DevPanelUIService instance and loads persisted state from localStorage.
11
12
  */
12
13
  constructor() {
13
- super(l, o, !0, !0);
14
+ super(u, n, !0, !0), this.applyTheme(this.getSnapshot().currentTheme);
14
15
  }
15
16
  /**
16
17
  * Transforms current state to persistable format.
@@ -19,9 +20,12 @@ class u extends r {
19
20
  * @returns The state in persistable format
20
21
  * @protected
21
22
  */
22
- toPersistableState(s) {
23
+ toPersistableState(t) {
23
24
  return {
24
- ...s
25
+ isVisible: t.isVisible,
26
+ isCollapsed: t.isCollapsed,
27
+ position: t.position,
28
+ currentTheme: t.currentTheme
25
29
  };
26
30
  }
27
31
  /**
@@ -32,10 +36,10 @@ class u extends r {
32
36
  * @returns The state in current format
33
37
  * @protected
34
38
  */
35
- fromPersistedState(s, t) {
39
+ fromPersistedState(t, s) {
36
40
  return {
37
- ...t,
38
- ...s
41
+ ...s,
42
+ ...t
39
43
  };
40
44
  }
41
45
  /**
@@ -47,71 +51,128 @@ class u extends r {
47
51
  getServiceName() {
48
52
  return "UI";
49
53
  }
54
+ /**
55
+ * Applies the theme to the document root element using data attributes.
56
+ *
57
+ * @param theme - Theme name to apply
58
+ * @private
59
+ */
60
+ applyTheme(t) {
61
+ const s = document.documentElement;
62
+ t === "auto" || t === "" ? s.removeAttribute("data-dev-panel-theme") : s.setAttribute("data-dev-panel-theme", t);
63
+ }
50
64
  /**
51
65
  * Sets the visibility state of the dev panel.
52
66
  *
53
67
  * @param visible - Whether the panel should be visible
54
68
  */
55
- setVisible = (s) => {
56
- this.setState((t) => ({ ...t, isVisible: s }));
69
+ setVisible = (t) => {
70
+ this.setState((s) => ({ ...s, isVisible: t }));
57
71
  };
58
72
  /**
59
73
  * Sets the collapsed state of the dev panel.
60
74
  *
61
75
  * @param collapsed - Whether the panel should be collapsed
62
76
  */
63
- setCollapsed = (s) => {
64
- this.setState((t) => ({ ...t, isCollapsed: s }));
77
+ setCollapsed = (t) => {
78
+ this.setState((s) => ({ ...s, isCollapsed: t }));
65
79
  };
66
80
  /**
67
81
  * Updates the position of the dev panel.
68
82
  *
69
83
  * @param position - New position coordinates {x, y}
70
84
  */
71
- setPosition = (s) => {
72
- this.setState((t) => ({ ...t, position: s }));
85
+ setPosition = (t) => {
86
+ this.setState((s) => ({ ...s, position: t }));
87
+ };
88
+ /**
89
+ * Sets the current theme and applies it to the document.
90
+ *
91
+ * @param theme - Theme name to set
92
+ */
93
+ setTheme = (t) => {
94
+ this.setState((s) => ({ ...s, currentTheme: t })), this.applyTheme(t);
95
+ };
96
+ /**
97
+ * Resets the theme to the default "auto" theme.
98
+ */
99
+ resetTheme = () => {
100
+ this.setTheme("auto");
73
101
  };
102
+ /**
103
+ * Gets the current theme name.
104
+ *
105
+ * @returns The current theme name
106
+ */
107
+ getCurrentTheme = () => this.getSnapshot().currentTheme;
74
108
  /**
75
109
  * Resets the dev panel UI to its default state.
76
- * Resets position and sets visibility and collapse to false.
110
+ * Resets position, theme, and sets visibility and collapse to false.
77
111
  */
78
112
  reset = () => {
79
- this.setState(() => ({ ...o }));
113
+ this.setState(() => ({ ...n })), this.applyTheme(n.currentTheme);
80
114
  };
81
115
  }
82
- const e = new u();
83
- function c() {
116
+ const e = new a();
117
+ function l() {
84
118
  return {
85
- ...i(e.subscribe, e.getSnapshot),
119
+ ...r(e.subscribe, e.getSnapshot),
86
120
  setVisible: e.setVisible,
87
121
  setCollapsed: e.setCollapsed,
88
122
  setPosition: e.setPosition,
123
+ setTheme: e.setTheme,
124
+ resetTheme: e.resetTheme,
125
+ getCurrentTheme: e.getCurrentTheme,
89
126
  reset: e.reset
90
127
  };
91
128
  }
129
+ function c() {
130
+ return r(e.subscribe, () => e.getSnapshot().isVisible);
131
+ }
132
+ function p() {
133
+ return r(e.subscribe, () => e.getSnapshot().isCollapsed);
134
+ }
92
135
  function b() {
93
- return i(e.subscribe, () => e.getSnapshot().isVisible);
136
+ return r(e.subscribe, () => e.getSnapshot().position);
94
137
  }
95
- function P() {
96
- return i(e.subscribe, () => e.getSnapshot().isCollapsed);
138
+ function S() {
139
+ return r(e.subscribe, () => e.getSnapshot().currentTheme);
97
140
  }
98
141
  function d() {
99
- return i(e.subscribe, () => e.getSnapshot().position);
142
+ return {
143
+ currentTheme: r(e.subscribe, () => e.getSnapshot().currentTheme),
144
+ setTheme: e.setTheme,
145
+ resetTheme: e.resetTheme,
146
+ getCurrentTheme: e.getCurrentTheme
147
+ };
100
148
  }
101
- function v() {
149
+ function C() {
102
150
  return {
103
151
  setVisible: e.setVisible,
104
152
  setCollapsed: e.setCollapsed,
105
153
  setPosition: e.setPosition,
154
+ setTheme: e.setTheme,
155
+ resetTheme: e.resetTheme,
156
+ getCurrentTheme: e.getCurrentTheme,
106
157
  reset: e.reset
107
158
  };
108
159
  }
109
- const f = c;
160
+ function g() {
161
+ return {
162
+ setTheme: e.setTheme,
163
+ resetTheme: e.resetTheme,
164
+ getCurrentTheme: e.getCurrentTheme
165
+ };
166
+ }
167
+ const P = l;
110
168
  export {
111
- P as useDevPanelCollapsed,
112
- d as useDevPanelPosition,
113
- f as useDevPanelStore,
114
- c as useDevPanelUI,
115
- v as useDevPanelUIActions,
116
- b as useDevPanelVisible
169
+ S as useCurrentTheme,
170
+ p as useDevPanelCollapsed,
171
+ b as useDevPanelPosition,
172
+ P as useDevPanelStore,
173
+ d as useDevPanelTheme,
174
+ g as useDevPanelThemeActions,
175
+ l as useDevPanelUI,
176
+ C as useDevPanelUIActions,
177
+ c as useDevPanelVisible
117
178
  };
@@ -1,10 +1,11 @@
1
+ import { Position } from '../../components/DevPanel/types';
1
2
  /**
2
3
  * Checks if a position adjustment is needed after window resize
3
4
  * @param element - The HTML element to check
4
5
  * @returns Object containing the current position, constrained position, and whether adjustment is needed
5
6
  */
6
7
  export declare function getPositionAdjustment(element: HTMLElement): {
7
- currentPosition: import('../../components/DevPanel/types').Position;
8
- constrainedPosition: import('../../components/DevPanel/types').Position;
8
+ currentPosition: Position;
9
+ constrainedPosition: Position;
9
10
  needsAdjustment: boolean;
10
11
  };
@@ -1,10 +1,7 @@
1
1
  import { getConstrainedPosition as r } from "../getConstrainedPosition/getConstrainedPosition.js";
2
2
  import { getCurrentElementPosition as s } from "../getCurrentElementPosition/getCurrentElementPosition.js";
3
3
  function m(n) {
4
- const t = s(n), o = r(
5
- t,
6
- n
7
- ), i = o.x !== t.x || o.y !== t.y;
4
+ const t = s(n), o = r(t, n), i = o.x !== t.x || o.y !== t.y;
8
5
  return {
9
6
  currentPosition: t,
10
7
  constrainedPosition: o,