@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.
- package/README.md +75 -52
- package/dist/assets/index.css +1 -1
- package/dist/assets/index11.css +1 -0
- package/dist/assets/index12.css +1 -0
- package/dist/assets/index13.css +1 -0
- package/dist/assets/index2.css +1 -0
- package/dist/assets/index6.css +1 -0
- package/dist/assets/index7.css +1 -0
- package/dist/assets/{RangeControl.css → index9.css} +1 -1
- package/dist/components/ControlRenderer/controls/BooleanControl/index.d.ts +32 -1
- package/dist/components/ControlRenderer/controls/BooleanControl/index.js +24 -2
- package/dist/components/ControlRenderer/controls/ButtonControl/index.d.ts +33 -1
- package/dist/components/ControlRenderer/controls/ButtonControl/index.js +8 -2
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.d.ts +37 -1
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.js +20 -2
- package/dist/components/ControlRenderer/controls/ColorControl/index.d.ts +23 -1
- package/dist/components/ControlRenderer/controls/ColorControl/index.js +67 -2
- package/dist/components/ControlRenderer/controls/DateControl/index.d.ts +41 -1
- package/dist/components/ControlRenderer/controls/DateControl/index.js +29 -2
- package/dist/components/ControlRenderer/controls/MultiSelectControl/index.d.ts +28 -1
- package/dist/components/ControlRenderer/controls/MultiSelectControl/index.js +16 -2
- package/dist/components/ControlRenderer/controls/NumberControl/index.d.ts +45 -1
- package/dist/components/ControlRenderer/controls/NumberControl/index.js +30 -2
- package/dist/components/ControlRenderer/controls/RangeControl/index.d.ts +46 -1
- package/dist/components/ControlRenderer/controls/RangeControl/index.js +38 -2
- package/dist/components/ControlRenderer/controls/SelectControl/index.d.ts +39 -1
- package/dist/components/ControlRenderer/controls/SelectControl/index.js +6 -2
- package/dist/components/ControlRenderer/controls/SeparatorControl/index.d.ts +39 -1
- package/dist/components/ControlRenderer/controls/SeparatorControl/index.js +12 -2
- package/dist/components/ControlRenderer/controls/TextControl/index.d.ts +40 -1
- package/dist/components/ControlRenderer/controls/TextControl/index.js +28 -2
- package/dist/components/ControlRenderer/index.d.ts +6 -1
- package/dist/components/ControlRenderer/index.js +50 -2
- package/dist/components/DevPanel/index.d.ts +11 -1
- package/dist/components/DevPanel/index.js +69 -2
- package/dist/components/DevPanel/types.d.ts +13 -6
- package/dist/components/DevPanelPortal/index.d.ts +9 -1
- package/dist/components/DevPanelPortal/index.js +15 -2
- package/dist/components/EmptyContent/index.d.ts +1 -1
- package/dist/components/EmptyContent/index.js +17 -2
- package/dist/components/Icon/index.d.ts +3 -3
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Input/index.js +8 -2
- package/dist/components/Section/index.d.ts +7 -1
- package/dist/components/Section/index.js +23 -2
- package/dist/components/Select/index.d.ts +15 -1
- package/dist/components/Select/index.js +176 -2
- package/dist/components/index.js +3 -3
- package/dist/hooks/useDebounceCallback/index.d.ts +8 -1
- package/dist/hooks/useDebounceCallback/index.js +15 -2
- package/dist/hooks/useDevPanel/index.d.ts +29 -1
- package/dist/hooks/useDevPanel/index.js +22 -2
- package/dist/hooks/useDragAndDrop/index.d.ts +20 -1
- package/dist/hooks/useDragAndDrop/index.js +53 -2
- package/dist/hooks/{useHotkeys/useHotkey.d.ts → useHotKey/index.d.ts} +1 -1
- package/dist/hooks/{useHotkeys/useHotkey.js → useHotKey/index.js} +1 -1
- package/dist/hooks/useHotkeys/index.d.ts +37 -2
- package/dist/hooks/useHotkeys/index.js +29 -4
- package/dist/index.js +1 -1
- package/dist/store/UIStore.d.ts +78 -2
- package/dist/store/UIStore.js +95 -34
- package/dist/utils/getPositionAdjustment/getPositionAdjustment.d.ts +3 -2
- package/dist/utils/getPositionAdjustment/getPositionAdjustment.js +1 -4
- package/package.json +43 -29
- package/dist/assets/BooleanControl.css +0 -1
- package/dist/assets/ButtonControl.css +0 -1
- package/dist/assets/ButtonGroupControl.css +0 -1
- package/dist/assets/DevPanel.css +0 -1
- package/dist/assets/Input.css +0 -1
- package/dist/assets/MultiSelectControl.css +0 -1
- package/dist/assets/Select.css +0 -1
- package/dist/components/ControlRenderer/ControlRenderer.d.ts +0 -6
- package/dist/components/ControlRenderer/ControlRenderer.js +0 -52
- package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.d.ts +0 -32
- package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.js +0 -26
- package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.d.ts +0 -33
- package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.js +0 -10
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.d.ts +0 -37
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.js +0 -22
- package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.d.ts +0 -23
- package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.js +0 -69
- package/dist/components/ControlRenderer/controls/DateControl/DateControl.d.ts +0 -41
- package/dist/components/ControlRenderer/controls/DateControl/DateControl.js +0 -31
- package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.d.ts +0 -28
- package/dist/components/ControlRenderer/controls/MultiSelectControl/MultiSelectControl.js +0 -131
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.d.ts +0 -45
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.js +0 -32
- package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.d.ts +0 -46
- package/dist/components/ControlRenderer/controls/RangeControl/RangeControl.js +0 -40
- package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.d.ts +0 -39
- package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.js +0 -11
- package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.d.ts +0 -39
- package/dist/components/ControlRenderer/controls/SeparatorControl/SeparatorControl.js +0 -14
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.d.ts +0 -40
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.js +0 -30
- package/dist/components/DevPanel/DevPanel.d.ts +0 -11
- package/dist/components/DevPanel/DevPanel.js +0 -72
- package/dist/components/DevPanelPortal/DevPanelPortal.d.ts +0 -8
- package/dist/components/DevPanelPortal/DevPanelPortal.js +0 -17
- package/dist/components/EmptyContent/EmptyContent.d.ts +0 -1
- package/dist/components/EmptyContent/EmptyContent.js +0 -18
- package/dist/components/Input/Input.d.ts +0 -1
- package/dist/components/Input/Input.js +0 -10
- package/dist/components/Section/Section.d.ts +0 -7
- package/dist/components/Section/Section.js +0 -25
- package/dist/components/Select/Select.d.ts +0 -1
- package/dist/components/Select/Select.js +0 -10
- package/dist/hooks/useDebounceCallback/useDebounceCallback.d.ts +0 -8
- package/dist/hooks/useDebounceCallback/useDebounceCallback.js +0 -17
- package/dist/hooks/useDevPanel/useDevPanel.d.ts +0 -29
- package/dist/hooks/useDevPanel/useDevPanel.js +0 -25218
- package/dist/hooks/useDragAndDrop/useDragAndDrop.d.ts +0 -20
- package/dist/hooks/useDragAndDrop/useDragAndDrop.js +0 -55
- package/dist/hooks/useHotkeys/useHotkeys.d.ts +0 -37
- package/dist/hooks/useHotkeys/useHotkeys.js +0 -31
- package/dist/managers/index.d.ts +0 -1
- package/dist/managers/index.js +0 -4
- package/dist/store/ThemeStore.d.ts +0 -68
- package/dist/store/ThemeStore.js +0 -102
- package/dist/store/index.d.ts +0 -4
- package/dist/store/index.js +0 -18
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.js +0 -20
- /package/dist/assets/{ColorControl.css → index10.css} +0 -0
- /package/dist/assets/{EmptyContent.css → index3.css} +0 -0
- /package/dist/assets/{Section.css → index4.css} +0 -0
- /package/dist/assets/{ControlRenderer.css → index5.css} +0 -0
- /package/dist/assets/{SeparatorControl.css → index8.css} +0 -0
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { TextControlProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a text input control with configurable event handling
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The text control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'text'
|
|
8
|
+
* @param props.control.value - The current string value of the text input
|
|
9
|
+
* @param props.control.placeholder - Optional placeholder text displayed when input is empty
|
|
10
|
+
* @param props.control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onChange"
|
|
11
|
+
* @param props.control.onChange - Callback function triggered when text value changes
|
|
12
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
13
|
+
* @returns JSX element representing the text input control
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Real-time updates (default behavior)
|
|
18
|
+
* <TextControl control={{
|
|
19
|
+
* type: 'text',
|
|
20
|
+
* value: 'John Doe',
|
|
21
|
+
* placeholder: 'Enter your full name',
|
|
22
|
+
* event: 'onChange',
|
|
23
|
+
* onChange: (value) => setUserName(value),
|
|
24
|
+
* disabled: false
|
|
25
|
+
* }} />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // Updates only when losing focus
|
|
31
|
+
* <TextControl control={{
|
|
32
|
+
* type: 'text',
|
|
33
|
+
* value: 'search query',
|
|
34
|
+
* placeholder: 'Type to search...',
|
|
35
|
+
* event: 'onBlur',
|
|
36
|
+
* onChange: (value) => console.log('Search term:', value)
|
|
37
|
+
* }} />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function TextControl({ control }: TextControlProps): React.ReactNode;
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as i } from "react";
|
|
3
|
+
import { Input as s } from "../../../Input/index.js";
|
|
4
|
+
function v({ control: e }) {
|
|
5
|
+
const n = e.event || "onChange", [l, u] = h(e.value);
|
|
6
|
+
function o(t) {
|
|
7
|
+
const a = t.target.value;
|
|
8
|
+
u(a), n === "onChange" && e.onChange(a);
|
|
9
|
+
}
|
|
10
|
+
function r(t) {
|
|
11
|
+
const a = t.target.value;
|
|
12
|
+
n === "onBlur" && e.onChange(a);
|
|
13
|
+
}
|
|
14
|
+
return i(() => {
|
|
15
|
+
u(e.value);
|
|
16
|
+
}, [e.value]), /* @__PURE__ */ f(
|
|
17
|
+
s,
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
value: l,
|
|
21
|
+
placeholder: e.placeholder,
|
|
22
|
+
disabled: e.disabled,
|
|
23
|
+
onChange: o,
|
|
24
|
+
...n === "onBlur" && { onBlur: r }
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
2
28
|
export {
|
|
3
|
-
|
|
29
|
+
v as TextControl
|
|
4
30
|
};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ControlsNames } from './controls/types';
|
|
2
|
+
import { ControlRendererProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Component that renders different types of controls based on the control type
|
|
5
|
+
*/
|
|
6
|
+
export declare function ControlRenderer<Name extends ControlsNames>({ name, control }: ControlRendererProps<Name>): React.ReactNode;
|
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as t, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense as c } from "react";
|
|
3
|
+
import { className as s } from "../../utils/className/className.js";
|
|
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", r = {
|
|
6
|
+
controlRendererContainer: p,
|
|
7
|
+
controlContainer: _,
|
|
8
|
+
hoverable: u,
|
|
9
|
+
fullWidth: v,
|
|
10
|
+
label: f,
|
|
11
|
+
controlWrapper: h,
|
|
12
|
+
justifyStart: b,
|
|
13
|
+
description: C,
|
|
14
|
+
loading: m,
|
|
15
|
+
error: y
|
|
16
|
+
}, W = ["button", "buttonGroup", "separator"], j = ["separator"], N = ["button", "separator"];
|
|
17
|
+
function L({ name: l, control: e }) {
|
|
18
|
+
const i = e?.label || l;
|
|
19
|
+
function a() {
|
|
20
|
+
if (!e || !e.type)
|
|
21
|
+
return /* @__PURE__ */ n("div", { className: r.error, children: "Control type is not defined" });
|
|
22
|
+
const o = d[e.type];
|
|
23
|
+
return o ? /* @__PURE__ */ n(c, { fallback: /* @__PURE__ */ n("div", { className: r.loading, children: "Loading control..." }), children: /* @__PURE__ */ n(o, { control: e }) }) : /* @__PURE__ */ n("div", { children: "Unknown control type" });
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ t("div", { className: r.controlRendererContainer, children: [
|
|
26
|
+
/* @__PURE__ */ t(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
...s(r.controlContainer, {
|
|
30
|
+
[r.fullWidth]: W.includes(e.type),
|
|
31
|
+
[r.hoverable]: !j.includes(e.type)
|
|
32
|
+
}),
|
|
33
|
+
children: [
|
|
34
|
+
!N.includes(e.type) && /* @__PURE__ */ n("label", { className: r.label, children: i }),
|
|
35
|
+
/* @__PURE__ */ n(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
...s(r.controlWrapper, {
|
|
39
|
+
[r.justifyStart]: e.type === "separator"
|
|
40
|
+
}),
|
|
41
|
+
children: a()
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
e?.description && /* @__PURE__ */ n("span", { className: r.description, children: e.description })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
2
50
|
export {
|
|
3
|
-
|
|
51
|
+
L as ControlRenderer
|
|
4
52
|
};
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { DevPanelProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Development panel component
|
|
4
|
+
* @returns The development panel component, if the environment is not development, it will return null
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* <DevPanel />
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function DevPanel({ panelTitle, ...props }: DevPanelProps): React.ReactNode;
|
|
@@ -1,4 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as D, useEffect as y } from "react";
|
|
3
|
+
import { useDragAndDrop as b } from "../../hooks/useDragAndDrop/index.js";
|
|
4
|
+
import { useHotkey as w } from "../../hooks/useHotKey/index.js";
|
|
5
|
+
import { useDevPanelSections as K } from "../../store/SectionsStore.js";
|
|
6
|
+
import { useDevPanelUI as N, useDevPanelThemeActions as k } from "../../store/UIStore.js";
|
|
7
|
+
import { className as x } from "../../utils/className/className.js";
|
|
8
|
+
import { EmptyContent as E } from "../EmptyContent/index.js";
|
|
9
|
+
import { Icon as f } from "../Icon/index.js";
|
|
10
|
+
import { Section as j } from "../Section/index.js";
|
|
11
|
+
import '../../assets/index2.css';const A = "_devPanelContainer_1089m_217", S = "_header_1089m_256", H = "_title_1089m_271", I = "_button_1089m_282", T = "_collapsed_1089m_318", V = "_content_1089m_325", t = {
|
|
12
|
+
devPanelContainer: A,
|
|
13
|
+
header: S,
|
|
14
|
+
title: H,
|
|
15
|
+
button: I,
|
|
16
|
+
collapsed: T,
|
|
17
|
+
content: V
|
|
18
|
+
}, O = {
|
|
19
|
+
ctrlKey: !0,
|
|
20
|
+
shiftKey: !0,
|
|
21
|
+
key: "a",
|
|
22
|
+
altKey: !1,
|
|
23
|
+
metaKey: !1
|
|
24
|
+
};
|
|
25
|
+
function M({ panelTitle: h = "Dev panel", ...o }) {
|
|
26
|
+
const { isVisible: i, isCollapsed: n, position: l, setVisible: a, setCollapsed: u, setPosition: r } = N(), { setTheme: c } = k(), p = K(), _ = D(
|
|
27
|
+
(s) => {
|
|
28
|
+
r(s);
|
|
29
|
+
},
|
|
30
|
+
[r]
|
|
31
|
+
), { isDragging: v, elementRef: C, handlePointerDown: g } = b({
|
|
32
|
+
onPositionChange: _
|
|
33
|
+
});
|
|
34
|
+
if (w({
|
|
35
|
+
description: "Show Dev Panel",
|
|
36
|
+
preventDefault: !0,
|
|
37
|
+
action: () => a(!i),
|
|
38
|
+
...O,
|
|
39
|
+
...o.hotKeyConfig,
|
|
40
|
+
target: window
|
|
41
|
+
}), y(() => {
|
|
42
|
+
o.theme && c(o.theme);
|
|
43
|
+
}, [o.theme, c]), !i)
|
|
44
|
+
return null;
|
|
45
|
+
const m = Object.entries(p);
|
|
46
|
+
return /* @__PURE__ */ d(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
ref: C,
|
|
50
|
+
...x(t.devPanelContainer, {
|
|
51
|
+
[t.dragging]: v
|
|
52
|
+
}),
|
|
53
|
+
style: {
|
|
54
|
+
left: l.x,
|
|
55
|
+
top: l.y,
|
|
56
|
+
height: n ? "auto" : void 0
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ d("div", { className: t.header, onPointerDown: g, children: [
|
|
60
|
+
/* @__PURE__ */ e("button", { className: t.button, onClick: () => u(!n), title: n ? "Expand" : "Collapse", children: /* @__PURE__ */ e(f, { name: "ArrowDown", className: n ? t.collapsed : void 0 }) }),
|
|
61
|
+
/* @__PURE__ */ e("div", { className: t.title, children: h }),
|
|
62
|
+
/* @__PURE__ */ e("button", { className: t.button, onClick: () => a(!1), title: "Close", children: /* @__PURE__ */ e(f, { name: "Close" }) })
|
|
63
|
+
] }),
|
|
64
|
+
!n && /* @__PURE__ */ e("div", { className: t.content, children: m.length ? m.map(([s, P]) => /* @__PURE__ */ e(j, { sectionName: s, section: P }, `section-${s}`)) : /* @__PURE__ */ e(E, {}) })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
2
69
|
export {
|
|
3
|
-
|
|
70
|
+
M as DevPanel
|
|
4
71
|
};
|
|
@@ -24,22 +24,28 @@ export type BuiltInTheme =
|
|
|
24
24
|
| "volcano";
|
|
25
25
|
|
|
26
26
|
export interface DevPanelProps {
|
|
27
|
+
/**
|
|
28
|
+
* Title of the DevPanel, displayed at the top.
|
|
29
|
+
*/
|
|
27
30
|
panelTitle?: string;
|
|
28
31
|
/**
|
|
29
32
|
* Hotkey configuration for toggling the DevPanel visibility.
|
|
30
33
|
* If not provided, defaults to
|
|
31
34
|
* ```json
|
|
32
35
|
* {
|
|
33
|
-
* key: "f",
|
|
34
|
-
* shiftKey: true,
|
|
35
|
-
* altKey: true,
|
|
36
|
-
* ctrlKey: false,
|
|
37
|
-
* metaKey: false,
|
|
36
|
+
* "key": "f",
|
|
37
|
+
* "shiftKey": true,
|
|
38
|
+
* "altKey": true,
|
|
39
|
+
* "ctrlKey": false,
|
|
40
|
+
* "metaKey": false,
|
|
38
41
|
* }
|
|
39
42
|
* ```
|
|
40
43
|
*/
|
|
41
44
|
hotKeyConfig?: DevPanelHotkeyConfig;
|
|
42
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Theme for the DevPanel.
|
|
47
|
+
* If not provided, defaults to "auto"
|
|
48
|
+
*/
|
|
43
49
|
theme?: BuiltInTheme;
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -54,6 +60,7 @@ export interface DevPanelState {
|
|
|
54
60
|
isCollapsed: boolean;
|
|
55
61
|
sections: Record<string, DevPanelSection>;
|
|
56
62
|
position: Position;
|
|
63
|
+
currentTheme: string;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
export type DevPanelUIState = Omit<DevPanelState, "sections">;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Portal component that renders DevPanel using React's createPortal.
|
|
3
|
+
* Automatically subscribes to DevPanelManager prop changes and renders
|
|
4
|
+
* the DevPanel with merged props into document.body.
|
|
5
|
+
* Dismounts the portal when no sections are active.
|
|
6
|
+
*
|
|
7
|
+
* @returns DevPanel rendered as a portal in document.body or null if no sections
|
|
8
|
+
*/
|
|
9
|
+
export declare function DevPanelPortal(): React.ReactNode;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as n, useEffect as d } from "react";
|
|
3
|
+
import { createPortal as c } from "react-dom";
|
|
4
|
+
import { DevPanelManager as m } from "../../managers/DevPanelManager.js";
|
|
5
|
+
import { DevPanel as p } from "../DevPanel/index.js";
|
|
6
|
+
function v() {
|
|
7
|
+
const [t, r] = n({}), [s, o] = n(!1);
|
|
8
|
+
return d(() => {
|
|
9
|
+
const e = m.getInstance(), l = e.getAllProps(), u = e.shouldRender();
|
|
10
|
+
return r(l), o(u), e.onPropsChange((a) => {
|
|
11
|
+
r(a), o(e.shouldRender());
|
|
12
|
+
});
|
|
13
|
+
}, []), s ? c(/* @__PURE__ */ i(p, { ...t }), document.body) : null;
|
|
14
|
+
}
|
|
2
15
|
export {
|
|
3
|
-
|
|
16
|
+
v as DevPanelPortal
|
|
4
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function EmptyContent(): React.ReactNode;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import '../../assets/index3.css';const n = "_empty_1bkns_1", s = {
|
|
3
|
+
empty: n
|
|
4
|
+
};
|
|
5
|
+
function o() {
|
|
6
|
+
return /* @__PURE__ */ t("div", { className: s.empty, children: [
|
|
7
|
+
/* @__PURE__ */ e("span", { children: "No controls registered yet." }),
|
|
8
|
+
/* @__PURE__ */ e("br", {}),
|
|
9
|
+
/* @__PURE__ */ e("br", {}),
|
|
10
|
+
/* @__PURE__ */ t("span", { children: [
|
|
11
|
+
"Use ",
|
|
12
|
+
/* @__PURE__ */ e("code", { children: "useDevPanel()" }),
|
|
13
|
+
" to add controls."
|
|
14
|
+
] })
|
|
15
|
+
] });
|
|
16
|
+
}
|
|
2
17
|
export {
|
|
3
|
-
|
|
18
|
+
o as EmptyContent
|
|
4
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const availableIcons: {
|
|
2
|
-
ArrowDown: (props: React.SVGProps<SVGSVGElement>) =>
|
|
3
|
-
Close: (props: React.SVGProps<SVGSVGElement>) =>
|
|
4
|
-
Check: (props: React.SVGProps<SVGSVGElement>) =>
|
|
2
|
+
ArrowDown: (props: React.SVGProps<SVGSVGElement>) => React.ReactNode;
|
|
3
|
+
Close: (props: React.SVGProps<SVGSVGElement>) => React.ReactNode;
|
|
4
|
+
Check: (props: React.SVGProps<SVGSVGElement>) => React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
interface IconProps extends React.SVGProps<SVGSVGElement> {
|
|
7
7
|
/** The name of the icon to render */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function Input(props: React.InputHTMLAttributes<HTMLInputElement>): React.ReactNode;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import '../../assets/index7.css';const u = "_input_icuc6_217", i = {
|
|
3
|
+
input: u
|
|
4
|
+
};
|
|
5
|
+
function s(t) {
|
|
6
|
+
return /* @__PURE__ */ n("input", { ...t, className: i.input });
|
|
7
|
+
}
|
|
2
8
|
export {
|
|
3
|
-
|
|
9
|
+
s as Input
|
|
4
10
|
};
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { ControlRenderer as i } from "../ControlRenderer/index.js";
|
|
3
|
+
import { useDevPanelSectionActions as r } from "../../store/SectionsStore.js";
|
|
4
|
+
import { Icon as p } from "../Icon/index.js";
|
|
5
|
+
import '../../assets/index4.css';const d = "_section_plx7y_1", _ = "_header_plx7y_9", m = "_title_plx7y_28", g = "_toggle_plx7y_35", h = "_collapsed_plx7y_45", x = "_content_plx7y_54", e = {
|
|
6
|
+
section: d,
|
|
7
|
+
header: _,
|
|
8
|
+
title: m,
|
|
9
|
+
toggle: g,
|
|
10
|
+
collapsed: h,
|
|
11
|
+
content: x
|
|
12
|
+
};
|
|
13
|
+
function N({ sectionName: s, section: t }) {
|
|
14
|
+
const { toggleSectionCollapse: c } = r();
|
|
15
|
+
return /* @__PURE__ */ n("div", { className: e.section, children: [
|
|
16
|
+
/* @__PURE__ */ n("div", { className: e.header, onClick: () => c(s), children: [
|
|
17
|
+
/* @__PURE__ */ o("span", { className: e.title, children: t.name }),
|
|
18
|
+
/* @__PURE__ */ o("span", { className: e.toggle, children: /* @__PURE__ */ o(p, { name: "ArrowDown", className: t.isCollapsed ? e.collapsed : void 0 }) })
|
|
19
|
+
] }),
|
|
20
|
+
!t.isCollapsed && /* @__PURE__ */ o("div", { className: e.content, children: Object.entries(t.controls).map(([l, a]) => /* @__PURE__ */ o(i, { name: l, control: a }, l)) })
|
|
21
|
+
] });
|
|
22
|
+
}
|
|
2
23
|
export {
|
|
3
|
-
|
|
24
|
+
N as Section
|
|
4
25
|
};
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface SelectProps {
|
|
2
|
+
value?: string | string[];
|
|
3
|
+
options: string[] | {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
onChange: (value: string | string[]) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Unified Select component that can handle both single and multiple selection
|
|
14
|
+
*/
|
|
15
|
+
export declare function Select({ value, options, onChange, disabled, multiple, placeholder }: SelectProps): React.ReactNode;
|
|
@@ -1,4 +1,178 @@
|
|
|
1
|
-
import {
|
|
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/index6.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
|
|
20
|
+
};
|
|
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({
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
width: 0,
|
|
26
|
+
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)
|
|
32
|
+
return {
|
|
33
|
+
top: 0,
|
|
34
|
+
left: 0,
|
|
35
|
+
width: 0,
|
|
36
|
+
maxHeight: 200
|
|
37
|
+
};
|
|
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);
|
|
39
|
+
return {
|
|
40
|
+
top: V,
|
|
41
|
+
left: $,
|
|
42
|
+
width: e.width,
|
|
43
|
+
maxHeight: I
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function O(e) {
|
|
47
|
+
if (u) {
|
|
48
|
+
const t = d, n = t.includes(e) ? t.filter((o) => o !== e) : [...t, e];
|
|
49
|
+
z(n);
|
|
50
|
+
} else
|
|
51
|
+
z(e), m(!1);
|
|
52
|
+
}
|
|
53
|
+
function S() {
|
|
54
|
+
if (u) {
|
|
55
|
+
const e = d;
|
|
56
|
+
if (e.length === 0)
|
|
57
|
+
return L;
|
|
58
|
+
if (e.length === 1) {
|
|
59
|
+
const t = _.find((o) => (typeof o == "string" ? o : o.value) === e[0]);
|
|
60
|
+
return (typeof t == "string" ? t : t?.label) || e[0];
|
|
61
|
+
}
|
|
62
|
+
return `${e.length} selected`;
|
|
63
|
+
} else {
|
|
64
|
+
const e = d;
|
|
65
|
+
if (!e)
|
|
66
|
+
return L;
|
|
67
|
+
const t = _.find((o) => (typeof o == "string" ? o : o.value) === e);
|
|
68
|
+
return (typeof t == "string" ? t : t?.label) || e;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function A() {
|
|
72
|
+
f || (c ? m(!1) : (E(N()), m(!0)));
|
|
73
|
+
}
|
|
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);
|
|
79
|
+
let t = null;
|
|
80
|
+
if (h.current && "IntersectionObserver" in window) {
|
|
81
|
+
const n = {
|
|
82
|
+
top: 0,
|
|
83
|
+
left: 0,
|
|
84
|
+
width: 0,
|
|
85
|
+
height: 0
|
|
86
|
+
};
|
|
87
|
+
t = new IntersectionObserver(
|
|
88
|
+
(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());
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
threshold: [0, 0.1, 0.5, 1]
|
|
97
|
+
}
|
|
98
|
+
), t.observe(h.current);
|
|
99
|
+
}
|
|
100
|
+
return () => {
|
|
101
|
+
window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), e && e.removeEventListener("scroll", s, !0), t && t.disconnect();
|
|
102
|
+
};
|
|
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(() => {
|
|
107
|
+
function e(t) {
|
|
108
|
+
if (g.current && !g.current.contains(t.target)) {
|
|
109
|
+
const n = document.querySelector(`.${r.dropdownPortal}`);
|
|
110
|
+
if (n && n.contains(t.target))
|
|
111
|
+
return;
|
|
112
|
+
m(!1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return document.addEventListener("mousedown", e), () => {
|
|
116
|
+
document.removeEventListener("mousedown", e);
|
|
117
|
+
};
|
|
118
|
+
}, []), /* @__PURE__ */ y(M, { children: [
|
|
119
|
+
/* @__PURE__ */ a(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
ref: g,
|
|
123
|
+
...F(r.select, {
|
|
124
|
+
[r.disabled]: f,
|
|
125
|
+
[r.open]: c
|
|
126
|
+
}),
|
|
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 })
|
|
130
|
+
] })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
typeof window < "u" && T(
|
|
134
|
+
c && !f && /* @__PURE__ */ a(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: r.dropdownPortal,
|
|
138
|
+
style: {
|
|
139
|
+
position: "fixed",
|
|
140
|
+
top: b.top,
|
|
141
|
+
left: b.left,
|
|
142
|
+
width: b.width,
|
|
143
|
+
maxHeight: b.maxHeight,
|
|
144
|
+
zIndex: 9999
|
|
145
|
+
},
|
|
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",
|
|
161
|
+
{
|
|
162
|
+
type: "button",
|
|
163
|
+
className: `${r.option} ${o ? r.selected : ""}`,
|
|
164
|
+
onClick: () => O(t),
|
|
165
|
+
children: n
|
|
166
|
+
},
|
|
167
|
+
t
|
|
168
|
+
);
|
|
169
|
+
}) })
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
document.body
|
|
173
|
+
)
|
|
174
|
+
] });
|
|
175
|
+
}
|
|
2
176
|
export {
|
|
3
|
-
|
|
177
|
+
ae as Select
|
|
4
178
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DevPanel as e } from "./DevPanel/
|
|
2
|
-
import { DevPanelPortal as l } from "./DevPanelPortal/
|
|
3
|
-
import { ControlRenderer as f } from "./ControlRenderer/
|
|
1
|
+
import { DevPanel as e } from "./DevPanel/index.js";
|
|
2
|
+
import { DevPanelPortal as l } from "./DevPanelPortal/index.js";
|
|
3
|
+
import { ControlRenderer as f } from "./ControlRenderer/index.js";
|
|
4
4
|
import { controls as p } from "./ControlRenderer/controls/index.js";
|
|
5
5
|
export {
|
|
6
6
|
f as ControlRenderer,
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced version of a callback.
|
|
3
|
+
*
|
|
4
|
+
* @param callback - Function to debounce
|
|
5
|
+
* @param delay - Delay in ms before calling the callback
|
|
6
|
+
* @returns A debounced version of the callback
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDebouncedCallback<T extends (...args: Parameters<T>) => void>(callback: T, delay: number): (...args: Parameters<T>) => void;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef as n, useEffect as c, useCallback as o } from "react";
|
|
2
|
+
function f(r, t) {
|
|
3
|
+
const e = n(null);
|
|
4
|
+
return c(() => () => {
|
|
5
|
+
e.current && clearTimeout(e.current);
|
|
6
|
+
}, []), o(
|
|
7
|
+
(...u) => {
|
|
8
|
+
e.current && clearTimeout(e.current), e.current = window.setTimeout(() => {
|
|
9
|
+
r(...u);
|
|
10
|
+
}, t);
|
|
11
|
+
},
|
|
12
|
+
[r, t]
|
|
13
|
+
);
|
|
14
|
+
}
|
|
2
15
|
export {
|
|
3
|
-
|
|
16
|
+
f as useDebouncedCallback
|
|
4
17
|
};
|