@berenjena/react-dev-panel 1.0.3 → 2.0.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 +32 -171
- package/dist/assets/BooleanControl.css +1 -1
- package/dist/assets/ButtonControl.css +1 -1
- package/dist/assets/ButtonGroupControl.css +1 -1
- package/dist/assets/ColorControl.css +1 -1
- package/dist/assets/ControlRenderer.css +1 -1
- package/dist/assets/DevPanel.css +1 -1
- package/dist/assets/EmptyContent.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/MultiSelectControl.css +1 -0
- package/dist/assets/RangeControl.css +1 -1
- package/dist/assets/Section.css +1 -1
- package/dist/assets/Select.css +1 -1
- package/dist/assets/SeparatorControl.css +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/components/ControlRenderer/ControlRenderer.js +38 -18
- package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.d.ts +20 -4
- package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.js +16 -14
- package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.d.ts +22 -5
- package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.js +2 -2
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.d.ts +35 -0
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.js +2 -2
- package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.d.ts +13 -6
- package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.js +61 -15
- package/dist/components/ControlRenderer/controls/ColorControl/types.d.ts +14 -0
- package/dist/components/ControlRenderer/controls/DateControl/DateControl.d.ts +17 -5
- package/dist/components/ControlRenderer/controls/DateControl/DateControl.js +12 -12
- package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.d.ts +28 -0
- package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.js +131 -0
- package/dist/components/ControlRenderer/controls/MultiSelectControl/index.d.ts +1 -0
- package/dist/components/ControlRenderer/controls/MultiSelectControl/index.js +4 -0
- package/dist/components/ControlRenderer/controls/MultiSelectControl/types.d.ts +11 -0
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.d.ts +26 -11
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.js +14 -14
- package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.d.ts +27 -11
- package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.js +19 -19
- package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.d.ts +29 -5
- package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.d.ts +16 -7
- package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.js +6 -6
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.d.ts +24 -13
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.js +15 -15
- package/dist/components/ControlRenderer/controls/index.d.ts +2 -0
- package/dist/components/ControlRenderer/controls/index.js +1 -0
- package/dist/components/ControlRenderer/controls/types.d.ts +2 -0
- package/dist/components/DevPanel/DevPanel.js +45 -40
- package/dist/components/DevPanel/types.d.ts +26 -0
- package/dist/components/DevPanelPortal/DevPanelPortal.d.ts +8 -0
- package/dist/components/DevPanelPortal/DevPanelPortal.js +17 -0
- package/dist/components/DevPanelPortal/index.d.ts +1 -0
- package/dist/components/DevPanelPortal/index.js +4 -0
- package/dist/components/EmptyContent/EmptyContent.js +5 -5
- package/dist/components/Icon/index.d.ts +16 -0
- package/dist/components/Icon/index.js +31 -0
- package/dist/components/Input/Input.js +4 -4
- package/dist/components/Section/Section.js +17 -16
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +8 -6
- package/dist/hooks/useDebounceCallback/index.d.ts +1 -0
- package/dist/hooks/useDebounceCallback/index.js +4 -0
- package/dist/hooks/useDebounceCallback/useDebounceCallback.d.ts +8 -0
- package/dist/hooks/useDebounceCallback/useDebounceCallback.js +17 -0
- package/dist/hooks/useDevPanel/useDevPanel.d.ts +10 -5
- package/dist/hooks/useDevPanel/useDevPanel.js +25215 -12
- package/dist/hooks/useDragAndDrop/useDragAndDrop.d.ts +5 -1
- package/dist/hooks/useDragAndDrop/useDragAndDrop.js +24 -24
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -8
- package/dist/managers/DevPanelManager.d.ts +85 -0
- package/dist/managers/DevPanelManager.js +119 -0
- package/dist/managers/index.d.ts +1 -0
- package/dist/managers/index.js +4 -0
- package/dist/store/BaseStoreService.d.ts +90 -0
- package/dist/store/BaseStoreService.js +90 -0
- package/dist/store/SectionsStore.d.ts +40 -0
- package/dist/store/SectionsStore.js +114 -0
- package/dist/store/ThemeStore.d.ts +68 -0
- package/dist/store/ThemeStore.js +102 -0
- package/dist/store/{store.d.ts → UIStore.d.ts} +17 -35
- package/dist/store/UIStore.js +117 -0
- package/dist/store/index.d.ts +4 -1
- package/dist/store/index.js +16 -7
- package/package.json +12 -3
- package/dist/assets/index2.css +0 -1
- package/dist/components/Logger/index.d.ts +0 -20
- package/dist/components/Logger/index.js +0 -85
- package/dist/store/store.js +0 -239
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
interface ThemeState {
|
|
2
|
+
currentTheme: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* React hook that provides access to the complete dev panel theme state and actions.
|
|
6
|
+
* Uses useSyncExternalStore for optimal performance and React 18 compatibility.
|
|
7
|
+
*
|
|
8
|
+
* @returns Object containing the current theme state and all available theme actions
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const {
|
|
13
|
+
* currentTheme,
|
|
14
|
+
* setTheme,
|
|
15
|
+
* resetTheme
|
|
16
|
+
* } = useDevPanelTheme();
|
|
17
|
+
*
|
|
18
|
+
* // Set a specific theme
|
|
19
|
+
* setTheme("dark");
|
|
20
|
+
*
|
|
21
|
+
* // Reset to auto theme
|
|
22
|
+
* resetTheme();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useDevPanelTheme(): ThemeState & {
|
|
26
|
+
setTheme: (theme: string) => void;
|
|
27
|
+
resetTheme: () => void;
|
|
28
|
+
getCurrentTheme: () => string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* React hook that subscribes only to the current theme state.
|
|
32
|
+
* Optimized for components that only need to know the current theme.
|
|
33
|
+
*
|
|
34
|
+
* @returns String indicating the current theme name
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const currentTheme = useCurrentTheme();
|
|
39
|
+
* console.log(`Current theme is: ${currentTheme}`);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useCurrentTheme(): string;
|
|
43
|
+
/**
|
|
44
|
+
* React hook that provides access to all dev panel theme actions without subscribing to state.
|
|
45
|
+
* Ideal for components that only need to trigger theme actions without rendering on state changes.
|
|
46
|
+
*
|
|
47
|
+
* @returns Object containing all available theme actions
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const { setTheme, resetTheme } = useDevPanelThemeActions();
|
|
52
|
+
*
|
|
53
|
+
* // Switch to dark theme
|
|
54
|
+
* setTheme("dark");
|
|
55
|
+
*
|
|
56
|
+
* // Switch to neon theme
|
|
57
|
+
* setTheme("neon");
|
|
58
|
+
*
|
|
59
|
+
* // Reset to auto theme
|
|
60
|
+
* resetTheme();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function useDevPanelThemeActions(): {
|
|
64
|
+
setTheme: (theme: string) => void;
|
|
65
|
+
resetTheme: () => void;
|
|
66
|
+
getCurrentTheme: () => string;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useSyncExternalStore as n } from "react";
|
|
2
|
+
import { BaseStoreService as h } from "./BaseStoreService.js";
|
|
3
|
+
const m = "dev-panel-theme-storage", u = {
|
|
4
|
+
currentTheme: "auto"
|
|
5
|
+
};
|
|
6
|
+
class o extends h {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new DevPanelThemeService instance and loads persisted theme from localStorage.
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
super(m, u, !0, !0), this.applyTheme(this.getSnapshot().currentTheme);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Transforms current state to persistable format.
|
|
15
|
+
*
|
|
16
|
+
* @param state - The current theme state
|
|
17
|
+
* @returns The state in persistable format
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
20
|
+
toPersistableState(e) {
|
|
21
|
+
return {
|
|
22
|
+
currentTheme: e.currentTheme
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Transforms persisted state back to current state format.
|
|
27
|
+
*
|
|
28
|
+
* @param persistedState - The persisted theme state
|
|
29
|
+
* @param defaultState - The default state to fall back to
|
|
30
|
+
* @returns The state in current format
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
fromPersistedState(e, r) {
|
|
34
|
+
return {
|
|
35
|
+
...r,
|
|
36
|
+
currentTheme: e.currentTheme || r.currentTheme
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the service name for error messages.
|
|
41
|
+
*
|
|
42
|
+
* @returns The service name
|
|
43
|
+
* @protected
|
|
44
|
+
*/
|
|
45
|
+
getServiceName() {
|
|
46
|
+
return "theme";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Applies the theme to the document root element using data attributes.
|
|
50
|
+
*
|
|
51
|
+
* @param theme - Theme name to apply
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
applyTheme(e) {
|
|
55
|
+
const r = document.documentElement;
|
|
56
|
+
e === "auto" || e === "" ? r.removeAttribute("data-dev-panel-theme") : r.setAttribute("data-dev-panel-theme", e);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets the current theme and applies it to the document.
|
|
60
|
+
*
|
|
61
|
+
* @param theme - Theme name to set
|
|
62
|
+
*/
|
|
63
|
+
setTheme = (e) => {
|
|
64
|
+
this.setState((r) => ({ ...r, currentTheme: e })), this.applyTheme(e);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resets the theme to the default "auto" theme.
|
|
68
|
+
*/
|
|
69
|
+
resetTheme = () => {
|
|
70
|
+
this.setTheme("auto");
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Gets the current theme name.
|
|
74
|
+
*
|
|
75
|
+
* @returns The current theme name
|
|
76
|
+
*/
|
|
77
|
+
getCurrentTheme = () => this.getSnapshot().currentTheme;
|
|
78
|
+
}
|
|
79
|
+
const t = new o();
|
|
80
|
+
function c() {
|
|
81
|
+
return {
|
|
82
|
+
...n(t.subscribe, t.getSnapshot),
|
|
83
|
+
setTheme: t.setTheme,
|
|
84
|
+
resetTheme: t.resetTheme,
|
|
85
|
+
getCurrentTheme: t.getCurrentTheme
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function i() {
|
|
89
|
+
return n(t.subscribe, () => t.getSnapshot().currentTheme);
|
|
90
|
+
}
|
|
91
|
+
function p() {
|
|
92
|
+
return {
|
|
93
|
+
setTheme: t.setTheme,
|
|
94
|
+
resetTheme: t.resetTheme,
|
|
95
|
+
getCurrentTheme: t.getCurrentTheme
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
i as useCurrentTheme,
|
|
100
|
+
c as useDevPanelTheme,
|
|
101
|
+
p as useDevPanelThemeActions
|
|
102
|
+
};
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DevPanelState, Position } from '../components/DevPanel/types';
|
|
1
|
+
import { DevPanelUIState, Position } from '../components/DevPanel/types';
|
|
3
2
|
/**
|
|
4
|
-
* React hook that provides access to the complete dev panel state and actions.
|
|
3
|
+
* React hook that provides access to the complete dev panel UI state and actions.
|
|
5
4
|
* Uses useSyncExternalStore for optimal performance and React 18 compatibility.
|
|
5
|
+
* This hook will not re-render when sections state changes.
|
|
6
6
|
*
|
|
7
|
-
* @returns Object containing the current state and all available actions
|
|
7
|
+
* @returns Object containing the current UI state and all available UI actions
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
11
|
* const {
|
|
12
12
|
* isVisible,
|
|
13
|
-
*
|
|
13
|
+
* position,
|
|
14
14
|
* setVisible,
|
|
15
|
-
*
|
|
16
|
-
* } =
|
|
15
|
+
* setPosition
|
|
16
|
+
* } = useDevPanelUI();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function useDevPanelUI(): DevPanelUIState & {
|
|
20
20
|
setVisible: (visible: boolean) => void;
|
|
21
21
|
setCollapsed: (collapsed: boolean) => void;
|
|
22
22
|
setPosition: (position: Position) => void;
|
|
23
|
-
registerSection: (name: string, controls: ControlsGroup) => void;
|
|
24
|
-
unregisterSection: (name: string) => void;
|
|
25
|
-
toggleSectionCollapse: (name: string) => void;
|
|
26
23
|
reset: () => void;
|
|
27
24
|
};
|
|
28
25
|
/**
|
|
@@ -63,44 +60,29 @@ export declare function useDevPanelCollapsed(): boolean;
|
|
|
63
60
|
*/
|
|
64
61
|
export declare function useDevPanelPosition(): Position;
|
|
65
62
|
/**
|
|
66
|
-
* React hook that
|
|
67
|
-
*
|
|
63
|
+
* React hook that provides access to all dev panel UI actions without subscribing to state.
|
|
64
|
+
* Ideal for components that only need to trigger UI actions without rendering on state changes.
|
|
68
65
|
*
|
|
69
|
-
* @returns
|
|
66
|
+
* @returns Object containing all available UI actions
|
|
70
67
|
*
|
|
71
68
|
* @example
|
|
72
69
|
* ```typescript
|
|
73
|
-
* const
|
|
74
|
-
* const sectionNames = Object.keys(sections);
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function useDevPanelSections(): Record<string, import('../components/DevPanel/types').DevPanelSection>;
|
|
78
|
-
/**
|
|
79
|
-
* React hook that provides access to all dev panel actions without subscribing to state.
|
|
80
|
-
* Ideal for components that only need to trigger actions without rendering on state changes.
|
|
81
|
-
*
|
|
82
|
-
* @returns Object containing all available actions
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const { setVisible, registerSection, reset } = useDevPanelActions();
|
|
70
|
+
* const { setVisible, setPosition, reset } = useDevPanelUIActions();
|
|
87
71
|
*
|
|
88
72
|
* // Toggle panel visibility
|
|
89
73
|
* setVisible(true);
|
|
90
74
|
*
|
|
91
|
-
* //
|
|
92
|
-
*
|
|
75
|
+
* // Update position
|
|
76
|
+
* setPosition({ x: 100, y: 100 });
|
|
93
77
|
*
|
|
94
|
-
* // Reset
|
|
78
|
+
* // Reset UI state
|
|
95
79
|
* reset();
|
|
96
80
|
* ```
|
|
97
81
|
*/
|
|
98
|
-
export declare function
|
|
82
|
+
export declare function useDevPanelUIActions(): {
|
|
99
83
|
setVisible: (visible: boolean) => void;
|
|
100
84
|
setCollapsed: (collapsed: boolean) => void;
|
|
101
85
|
setPosition: (position: Position) => void;
|
|
102
|
-
registerSection: (name: string, controls: ControlsGroup) => void;
|
|
103
|
-
unregisterSection: (name: string) => void;
|
|
104
|
-
toggleSectionCollapse: (name: string) => void;
|
|
105
86
|
reset: () => void;
|
|
106
87
|
};
|
|
88
|
+
export declare const useDevPanelStore: typeof useDevPanelUI;
|
|
@@ -0,0 +1,117 @@
|
|
|
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 = {
|
|
4
|
+
isVisible: !1,
|
|
5
|
+
isCollapsed: !1,
|
|
6
|
+
position: a
|
|
7
|
+
};
|
|
8
|
+
class u extends r {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new DevPanelUIService instance and loads persisted state from localStorage.
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super(l, o, !0, !0);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Transforms current state to persistable format.
|
|
17
|
+
*
|
|
18
|
+
* @param state - The current UI state
|
|
19
|
+
* @returns The state in persistable format
|
|
20
|
+
* @protected
|
|
21
|
+
*/
|
|
22
|
+
toPersistableState(s) {
|
|
23
|
+
return {
|
|
24
|
+
...s
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transforms persisted state back to current state format.
|
|
29
|
+
*
|
|
30
|
+
* @param persistedState - The persisted UI state
|
|
31
|
+
* @param defaultState - The default state to fall back to
|
|
32
|
+
* @returns The state in current format
|
|
33
|
+
* @protected
|
|
34
|
+
*/
|
|
35
|
+
fromPersistedState(s, t) {
|
|
36
|
+
return {
|
|
37
|
+
...t,
|
|
38
|
+
...s
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the service name for error messages.
|
|
43
|
+
*
|
|
44
|
+
* @returns The service name
|
|
45
|
+
* @protected
|
|
46
|
+
*/
|
|
47
|
+
getServiceName() {
|
|
48
|
+
return "UI";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the visibility state of the dev panel.
|
|
52
|
+
*
|
|
53
|
+
* @param visible - Whether the panel should be visible
|
|
54
|
+
*/
|
|
55
|
+
setVisible = (s) => {
|
|
56
|
+
this.setState((t) => ({ ...t, isVisible: s }));
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Sets the collapsed state of the dev panel.
|
|
60
|
+
*
|
|
61
|
+
* @param collapsed - Whether the panel should be collapsed
|
|
62
|
+
*/
|
|
63
|
+
setCollapsed = (s) => {
|
|
64
|
+
this.setState((t) => ({ ...t, isCollapsed: s }));
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Updates the position of the dev panel.
|
|
68
|
+
*
|
|
69
|
+
* @param position - New position coordinates {x, y}
|
|
70
|
+
*/
|
|
71
|
+
setPosition = (s) => {
|
|
72
|
+
this.setState((t) => ({ ...t, position: s }));
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Resets the dev panel UI to its default state.
|
|
76
|
+
* Resets position and sets visibility and collapse to false.
|
|
77
|
+
*/
|
|
78
|
+
reset = () => {
|
|
79
|
+
this.setState(() => ({ ...o }));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const e = new u();
|
|
83
|
+
function c() {
|
|
84
|
+
return {
|
|
85
|
+
...i(e.subscribe, e.getSnapshot),
|
|
86
|
+
setVisible: e.setVisible,
|
|
87
|
+
setCollapsed: e.setCollapsed,
|
|
88
|
+
setPosition: e.setPosition,
|
|
89
|
+
reset: e.reset
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function b() {
|
|
93
|
+
return i(e.subscribe, () => e.getSnapshot().isVisible);
|
|
94
|
+
}
|
|
95
|
+
function P() {
|
|
96
|
+
return i(e.subscribe, () => e.getSnapshot().isCollapsed);
|
|
97
|
+
}
|
|
98
|
+
function d() {
|
|
99
|
+
return i(e.subscribe, () => e.getSnapshot().position);
|
|
100
|
+
}
|
|
101
|
+
function v() {
|
|
102
|
+
return {
|
|
103
|
+
setVisible: e.setVisible,
|
|
104
|
+
setCollapsed: e.setCollapsed,
|
|
105
|
+
setPosition: e.setPosition,
|
|
106
|
+
reset: e.reset
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const f = c;
|
|
110
|
+
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
|
|
117
|
+
};
|
package/dist/store/index.d.ts
CHANGED
package/dist/store/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStoreService as o } from "./BaseStoreService.js";
|
|
2
|
+
import { useDevPanelSectionActions as l, useDevPanelSections as r } from "./SectionsStore.js";
|
|
3
|
+
import { useCurrentTheme as a, useDevPanelTheme as u, useDevPanelThemeActions as v } from "./ThemeStore.js";
|
|
4
|
+
import { useDevPanelCollapsed as i, useDevPanelPosition as D, useDevPanelStore as m, useDevPanelUI as c, useDevPanelUIActions as p, useDevPanelVisible as S } from "./UIStore.js";
|
|
2
5
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
o as BaseStoreService,
|
|
7
|
+
a as useCurrentTheme,
|
|
8
|
+
i as useDevPanelCollapsed,
|
|
9
|
+
D as useDevPanelPosition,
|
|
10
|
+
l as useDevPanelSectionActions,
|
|
11
|
+
r as useDevPanelSections,
|
|
12
|
+
m as useDevPanelStore,
|
|
13
|
+
u as useDevPanelTheme,
|
|
14
|
+
v as useDevPanelThemeActions,
|
|
15
|
+
c as useDevPanelUI,
|
|
16
|
+
p as useDevPanelUIActions,
|
|
17
|
+
S as useDevPanelVisible
|
|
9
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"name": "@berenjena/react-dev-panel",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"development",
|
|
11
11
|
"panel",
|
|
12
12
|
"tools",
|
|
13
|
-
"utilities"
|
|
13
|
+
"utilities",
|
|
14
|
+
"gui",
|
|
15
|
+
"devtools"
|
|
14
16
|
],
|
|
15
17
|
"homepage": "https://github.com/Berenjenas/react-dev-panel",
|
|
16
18
|
"bugs": "https://github.com/Berenjenas/react-dev-panel/issues",
|
|
@@ -63,13 +65,20 @@
|
|
|
63
65
|
"test": "vitest",
|
|
64
66
|
"test:ui": "vitest --ui",
|
|
65
67
|
"coverage": "vitest run --coverage",
|
|
66
|
-
"prepublishOnly": "vitest run && npm run build"
|
|
68
|
+
"prepublishOnly": "vitest run && npm run build",
|
|
69
|
+
"changeset": "changeset",
|
|
70
|
+
"prerelease": "vitest run && npm run build",
|
|
71
|
+
"release": "changeset publish"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
67
75
|
},
|
|
68
76
|
"peerDependencies": {
|
|
69
77
|
"react": ">=18.0.0",
|
|
70
78
|
"react-dom": ">=18.0.0"
|
|
71
79
|
},
|
|
72
80
|
"devDependencies": {
|
|
81
|
+
"@changesets/cli": "^2.29.5",
|
|
73
82
|
"@eslint/js": "^9.30.1",
|
|
74
83
|
"@rollup/plugin-terser": "^0.4.4",
|
|
75
84
|
"@storybook/addon-docs": "^9.0.17",
|
package/dist/assets/index2.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._logger_t8a3p_1{position:fixed;bottom:20px;left:20px;width:400px;max-width:calc(100vw - 40px);max-height:calc(100vh - 80px);background:#fff;border:1px solid #e1e5e9;border-radius:8px;box-shadow:0 8px 32px #0000001f;z-index:9999;font-family:system-ui,-apple-system,sans-serif;overflow:hidden;transition:all .3s ease}._logger_t8a3p_1._dark_t8a3p_17{background:#1e1e1e;border-color:#333;color:#e0e0e0}._logger_t8a3p_1._collapsed_t8a3p_22{height:50px;overflow:hidden}._header_t8a3p_27{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#f8f9fa;border-bottom:1px solid #e1e5e9;cursor:pointer;user-select:none;transition:background-color .2s ease}._dark_t8a3p_17 ._header_t8a3p_27{background:#2a2a2a;border-bottom-color:#333}._header_t8a3p_27:hover{background:#e9ecef}._dark_t8a3p_17 ._header_t8a3p_27:hover{background:#333}._title_t8a3p_49{display:flex;align-items:center;gap:.5rem;font-weight:600;font-size:14px;color:#495057;margin:0}._dark_t8a3p_17 ._title_t8a3p_49{color:#e0e0e0}._controls_t8a3p_62{display:flex;align-items:center;gap:8px}._toggleButton_t8a3p_68{background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#6c757d;font-size:16px;display:flex;align-items:center;justify-content:center;transition:all .2s ease}._dark_t8a3p_17 ._toggleButton_t8a3p_68{color:#adb5bd}._toggleButton_t8a3p_68:hover{background:#dee2e6;color:#495057}._dark_t8a3p_17 ._toggleButton_t8a3p_68:hover{background:#495057;color:#e0e0e0}._toggleButton_t8a3p_68>svg{display:block;height:1rem;transition:transform ease .2s}._toggleButton_t8a3p_68>svg._collapsed_t8a3p_22{transform:rotate(180deg)}._toggleButton_t8a3p_68>svg path{fill:currentColor}._closeButton_t8a3p_104{background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#dc3545;font-size:14px;font-weight:700;display:flex;align-items:center;justify-content:center;width:20px;height:20px;transition:all .2s ease}._closeButton_t8a3p_104:hover{background:#f5c6cb;color:#721c24}._dark_t8a3p_17 ._closeButton_t8a3p_104:hover{background:#721c24;color:#f5c6cb}._content_t8a3p_129{padding:16px;overflow:auto;max-height:calc(100vh - 160px);background:#fff}._dark_t8a3p_17 ._content_t8a3p_129{background:#1e1e1e}._jsonDisplay_t8a3p_139{font-family:SF Mono,Monaco,Cascadia Code,Roboto Mono,Consolas,Courier New,monospace;font-size:12px;line-height:1.4;margin:0;white-space:pre-wrap;word-break:break-all;color:#212529}._dark_t8a3p_17 ._jsonDisplay_t8a3p_139{color:#e0e0e0}._empty_t8a3p_152{color:#6c757d;font-style:italic;text-align:center;padding:20px}._dark_t8a3p_17 ._empty_t8a3p_152{color:#adb5bd}._badge_t8a3p_162{display:flex;justify-content:center;align-items:center;background:#007bff;color:#fff;width:1rem;height:1rem;border-radius:50%;padding:4px;font-size:10px;font-weight:600}._badge_t8a3p_162._updated_t8a3p_175{background:#28a745;animation:_pulse_t8a3p_1 .6s ease-in-out}@keyframes _pulse_t8a3p_1{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}._content_t8a3p_129::-webkit-scrollbar{width:6px}._content_t8a3p_129::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}._dark_t8a3p_17 ._content_t8a3p_129::-webkit-scrollbar-track{background:#333}._content_t8a3p_129::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}._dark_t8a3p_17 ._content_t8a3p_129::-webkit-scrollbar-thumb{background:#555}._content_t8a3p_129::-webkit-scrollbar-thumb:hover{background:#a8a8a8}._dark_t8a3p_17 ._content_t8a3p_129::-webkit-scrollbar-thumb:hover{background:#777}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type LoggerProps = {
|
|
2
|
-
/** The data object to display in JSON format */
|
|
3
|
-
items: object;
|
|
4
|
-
/** Optional title for the logger panel */
|
|
5
|
-
title?: string;
|
|
6
|
-
/** Theme preference - 'auto' detects system preference */
|
|
7
|
-
theme?: "light" | "dark" | "auto";
|
|
8
|
-
/** Whether the logger should start collapsed */
|
|
9
|
-
defaultCollapsed?: boolean;
|
|
10
|
-
/** Whether the logger should be visible by default */
|
|
11
|
-
defaultVisible?: boolean;
|
|
12
|
-
/** Callback function called when the logger is closed */
|
|
13
|
-
onClose?: () => void;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* A floating, collapsible logger component that displays object data in JSON format.
|
|
17
|
-
* @returns JSX element or null if not visible
|
|
18
|
-
*/
|
|
19
|
-
export declare function Logger({ items, title, theme, defaultCollapsed, defaultVisible, onClose }: LoggerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useState as l, useRef as D, useEffect as h } from "react";
|
|
3
|
-
import { className as I } from "../../utils/className/className.js";
|
|
4
|
-
import '../../assets/index2.css';const O = "_logger_t8a3p_1", L = "_dark_t8a3p_17", S = "_collapsed_t8a3p_22", J = "_header_t8a3p_27", $ = "_title_t8a3p_49", A = "_controls_t8a3p_62", z = "_toggleButton_t8a3p_68", H = "_closeButton_t8a3p_104", M = "_content_t8a3p_129", R = "_jsonDisplay_t8a3p_139", T = "_empty_t8a3p_152", U = "_badge_t8a3p_162", V = "_updated_t8a3p_175", t = {
|
|
5
|
-
logger: O,
|
|
6
|
-
dark: L,
|
|
7
|
-
collapsed: S,
|
|
8
|
-
header: J,
|
|
9
|
-
title: $,
|
|
10
|
-
controls: A,
|
|
11
|
-
toggleButton: z,
|
|
12
|
-
closeButton: H,
|
|
13
|
-
content: M,
|
|
14
|
-
jsonDisplay: R,
|
|
15
|
-
empty: T,
|
|
16
|
-
badge: U,
|
|
17
|
-
updated: V
|
|
18
|
-
};
|
|
19
|
-
function F({ items: s, title: m = "Logger", theme: c = "auto", defaultCollapsed: f = !0, defaultVisible: y = !0, onClose: p }) {
|
|
20
|
-
const [a, v] = l(f), [N, b] = l(y), [C, d] = l(!1), [k, g] = l(!1), [u, w] = l(0), i = D("");
|
|
21
|
-
function _() {
|
|
22
|
-
v(!a);
|
|
23
|
-
}
|
|
24
|
-
function B() {
|
|
25
|
-
b(!1), p?.();
|
|
26
|
-
}
|
|
27
|
-
function x(o) {
|
|
28
|
-
try {
|
|
29
|
-
return JSON.stringify(o, null, 2);
|
|
30
|
-
} catch (n) {
|
|
31
|
-
return `Error formatting JSON: ${n}`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (h(() => {
|
|
35
|
-
if (c === "auto") {
|
|
36
|
-
const o = window.matchMedia("(prefers-color-scheme: dark)");
|
|
37
|
-
d(o.matches);
|
|
38
|
-
const n = (E) => d(E.matches);
|
|
39
|
-
return o.addEventListener("change", n), () => o.removeEventListener("change", n);
|
|
40
|
-
} else
|
|
41
|
-
d(c === "dark");
|
|
42
|
-
}, [c]), h(() => {
|
|
43
|
-
const o = JSON.stringify(s), n = Object.keys(s).length;
|
|
44
|
-
i.current && i.current !== o && (g(!0), setTimeout(() => g(!1), 600)), w(n), i.current = o;
|
|
45
|
-
}, [s]), !N) return null;
|
|
46
|
-
const j = !s || Object.keys(s).length === 0;
|
|
47
|
-
return /* @__PURE__ */ r("div", { className: `${t.logger} ${C ? t.dark : ""} ${a ? t.collapsed : ""}`, children: [
|
|
48
|
-
/* @__PURE__ */ r("div", { className: t.header, onClick: _, children: [
|
|
49
|
-
/* @__PURE__ */ r("h3", { className: t.title, children: [
|
|
50
|
-
m,
|
|
51
|
-
u > 0 && /* @__PURE__ */ e("span", { ...I(t.badge, { [t.updated]: k }), children: u })
|
|
52
|
-
] }),
|
|
53
|
-
/* @__PURE__ */ r("div", { className: t.controls, children: [
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
"button",
|
|
56
|
-
{
|
|
57
|
-
className: t.toggleButton,
|
|
58
|
-
onClick: _,
|
|
59
|
-
type: "button",
|
|
60
|
-
"aria-label": a ? "Expand logger" : "Collapse logger",
|
|
61
|
-
title: a ? "Expand" : "Collapse",
|
|
62
|
-
children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", className: a ? t.collapsed : void 0, children: /* @__PURE__ */ e("path", { d: "M16.843 10.211A.75.75 0 0 0 16.251 9H7.75a.75.75 0 0 0-.591 1.212l4.258 5.498a.746.746 0 0 0 1.183-.001l4.243-5.498z" }) })
|
|
63
|
-
}
|
|
64
|
-
),
|
|
65
|
-
p && /* @__PURE__ */ e(
|
|
66
|
-
"button",
|
|
67
|
-
{
|
|
68
|
-
className: t.closeButton,
|
|
69
|
-
type: "button",
|
|
70
|
-
"aria-label": "Close logger",
|
|
71
|
-
title: "Close",
|
|
72
|
-
onClick: (o) => {
|
|
73
|
-
o.stopPropagation(), B();
|
|
74
|
-
},
|
|
75
|
-
children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { d: "m12 10.93 5.719-5.72a.749.749 0 1 1 1.062 1.062l-5.72 5.719 5.719 5.719a.75.75 0 1 1-1.061 1.062L12 13.053l-5.719 5.719A.75.75 0 0 1 5.22 17.71l5.719-5.719-5.72-5.719A.752.752 0 0 1 6.281 5.21z" }) })
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
] })
|
|
79
|
-
] }),
|
|
80
|
-
!a && /* @__PURE__ */ e("div", { className: t.content, children: j ? /* @__PURE__ */ e("div", { className: t.empty, children: "No data to display" }) : /* @__PURE__ */ e("pre", { className: t.jsonDisplay, children: /* @__PURE__ */ e("code", { children: x(s) }) }) })
|
|
81
|
-
] });
|
|
82
|
-
}
|
|
83
|
-
export {
|
|
84
|
-
F as Logger
|
|
85
|
-
};
|