@berenjena/react-dev-panel 0.0.1-beta.2 → 0.0.1-beta.4

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.
@@ -0,0 +1,10 @@
1
+ import { BaseControl } from '../types';
2
+ export interface BooleanControl extends BaseControl {
3
+ type: "boolean";
4
+ value: boolean;
5
+ onChange: (value: boolean) => void;
6
+ }
7
+
8
+ export interface BooleanControlProps {
9
+ control: BooleanControl;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseControl } from '../types';
2
+ export interface ButtonControl extends BaseControl {
3
+ type: "button";
4
+ label: string;
5
+ onClick: () => void;
6
+ }
7
+
8
+ export interface ButtonControlProps {
9
+ control: ButtonControl;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseControl } from '../types';
2
+ export interface ColorControl extends BaseControl {
3
+ type: "color";
4
+ value: string;
5
+ onChange: (value: string) => void;
6
+ }
7
+
8
+ export interface ColorControlProps {
9
+ control: ColorControl;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseControl } from '../types';
2
+ export interface NumberControl extends BaseControl {
3
+ type: "number";
4
+ value: number;
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ onChange: (value: number) => void;
9
+ }
10
+
11
+ export interface NumberControlProps {
12
+ control: NumberControl;
13
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseControl } from '../types';
2
+ export interface SelectControl extends BaseControl {
3
+ type: "select";
4
+ value: string;
5
+ options: string[] | { label: string; value: string }[];
6
+ onChange: (value: string) => void;
7
+ }
8
+
9
+ export interface SelectControlProps {
10
+ control: SelectControl;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseControl } from '../types';
2
+ export interface TextControl extends BaseControl {
3
+ type: "text";
4
+ value: string;
5
+ placeholder?: string;
6
+ onChange: (value: string) => void;
7
+ }
8
+
9
+ export interface TextControlProps {
10
+ control: TextControl;
11
+ }
@@ -1,36 +1,37 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { lazy as n, Suspense as c } from "react";
1
+ import { Suspense as c, lazy as o } from "react";
2
+ import { jsxs as i, jsx as n } from "react/jsx-runtime";
3
3
  import { className as d } from "../../../utils/className/className.js";
4
4
  import "../../../utils/store/store.js";
5
- import '../../../assets/index.css';const p = Object.freeze({
6
- boolean: n(() => import("./BooleanControl/index.js").then((e) => ({ default: e.BooleanControl }))),
7
- button: n(() => import("./ButtonControl/index.js").then((e) => ({ default: e.ButtonControl }))),
8
- color: n(() => import("./ColorControl/index.js").then((e) => ({ default: e.ColorControl }))),
9
- number: n(() => import("./NumberControl/index.js").then((e) => ({ default: e.NumberControl }))),
10
- select: n(() => import("./SelectControl/index.js").then((e) => ({ default: e.SelectControl }))),
11
- text: n(() => import("./TextControl/index.js").then((e) => ({ default: e.TextControl })))
12
- }), m = "_controlContainer_xw58o_1", u = "_label_xw58o_10", f = "_description_xw58o_24", r = {
13
- controlContainer: m,
14
- label: u,
15
- description: f
5
+ import '../../../assets/index.css';const p = "_controlContainer_xw58o_1", m = "_label_xw58o_10", u = "_description_xw58o_24", r = {
6
+ controlContainer: p,
7
+ label: m,
8
+ description: u
16
9
  };
17
10
  function x({ name: e, control: t }) {
18
11
  const s = t?.label || e;
19
12
  function a() {
20
13
  if (!t || !t.type)
21
- return /* @__PURE__ */ o("div", { className: r.error, children: "Control type is not defined" });
22
- const l = p[t.type];
23
- return l ? /* @__PURE__ */ o(c, { fallback: /* @__PURE__ */ o("div", { children: "Loading control..." }), children: /* @__PURE__ */ o(l, { control: t }) }) : /* @__PURE__ */ o("div", { children: "Unknown control type" });
14
+ return /* @__PURE__ */ n("div", { className: r.error, children: "Control type is not defined" });
15
+ const l = f[t.type];
16
+ return l ? /* @__PURE__ */ n(c, { fallback: /* @__PURE__ */ n("div", { children: "Loading control..." }), children: /* @__PURE__ */ n(l, { control: t }) }) : /* @__PURE__ */ n("div", { children: "Unknown control type" });
24
17
  }
25
18
  return /* @__PURE__ */ i("div", { ...d(r.controlContainer), children: [
26
19
  t?.type !== "button" && /* @__PURE__ */ i("label", { className: r.label, children: [
27
20
  s,
28
- t?.description && /* @__PURE__ */ o("span", { className: r.description, children: t.description })
21
+ t?.description && /* @__PURE__ */ n("span", { className: r.description, children: t.description })
29
22
  ] }),
30
23
  a()
31
24
  ] });
32
25
  }
26
+ const f = Object.freeze({
27
+ boolean: o(() => import("./BooleanControl/index.js").then((e) => ({ default: e.BooleanControl }))),
28
+ button: o(() => import("./ButtonControl/index.js").then((e) => ({ default: e.ButtonControl }))),
29
+ color: o(() => import("./ColorControl/index.js").then((e) => ({ default: e.ColorControl }))),
30
+ number: o(() => import("./NumberControl/index.js").then((e) => ({ default: e.NumberControl }))),
31
+ select: o(() => import("./SelectControl/index.js").then((e) => ({ default: e.SelectControl }))),
32
+ text: o(() => import("./TextControl/index.js").then((e) => ({ default: e.TextControl })))
33
+ });
33
34
  export {
34
35
  x as ControlRenderer,
35
- p as controls
36
+ f as controls
36
37
  };
@@ -0,0 +1,26 @@
1
+ import { BooleanControl } from './BooleanControl/types';
2
+ import { ButtonControl } from './ButtonControl/types';
3
+ import { ColorControl } from './ColorControl/types';
4
+ import { NumberControl } from './NumberControl/types';
5
+ import { SelectControl } from './SelectControl/types';
6
+ import { TextControl } from './TextControl/types';
7
+ export interface BaseControl {
8
+ label?: string;
9
+ description?: string;
10
+ disabled?: boolean;
11
+ }
12
+
13
+ export type Controls = {
14
+ color: ColorControl;
15
+ boolean: BooleanControl;
16
+ select: SelectControl;
17
+ text: TextControl;
18
+ button: ButtonControl;
19
+ number: NumberControl;
20
+ };
21
+
22
+ export type ControlsNames = keyof Controls;
23
+
24
+ export type Control<Name extends ControlsNames> = Controls[Name];
25
+
26
+ export type ControlsGroup = Record<string, Control<ControlsNames>>;
@@ -0,0 +1,5 @@
1
+ import { Control, ControlsNames } from './controls/types';
2
+ export interface ControlRendererProps<Name extends ControlsNames> {
3
+ name: string;
4
+ control: Control<Name>;
5
+ }
@@ -0,0 +1,47 @@
1
+ import { ControlsGroup } from '../ControlRenderer/controls/types';
2
+ import { HotkeyConfig, Position } from '../../types';
3
+ export type DevPanelHoyKeyConfig = Pick<HotkeyConfig, "key" | "shiftKey" | "altKey" | "ctrlKey" | "metaKey">;
4
+
5
+ export interface DevPanelProps {
6
+ theme?: "light" | "dark";
7
+ panelTitle?: string;
8
+ /**
9
+ * Hotkey configuration for toggling the DevPanel visibility.
10
+ * If not provided, defaults to
11
+ * ```json
12
+ * {
13
+ * key: "f",
14
+ * shiftKey: true,
15
+ * altKey: true,
16
+ * ctrlKey: false,
17
+ * metaKey: false,
18
+ * }
19
+ * ```
20
+ */
21
+ hotKeyConfig?: DevPanelHoyKeyConfig;
22
+ }
23
+
24
+ export interface DevPanelSection {
25
+ name: string;
26
+ controls: ControlsGroup;
27
+ isCollapsed?: boolean;
28
+ }
29
+
30
+ export interface DevPanelState {
31
+ isVisible: boolean;
32
+ isCollapsed: boolean;
33
+ sections: Record<string, DevPanelSection>;
34
+ position: Position;
35
+ }
36
+
37
+ export interface DevPanelActions {
38
+ setVisible: (visible: boolean) => void;
39
+ setCollapsed: (collapsed: boolean) => void;
40
+ setPosition: (position: Position) => void;
41
+ registerSection: (name: string, controls: ControlsGroup) => void;
42
+ unregisterSection: (name: string) => void;
43
+ toggleSectionCollapse: (name: string) => void;
44
+ reset: () => void;
45
+ }
46
+
47
+ export type DevPanelStore = DevPanelState & DevPanelActions;
@@ -0,0 +1,6 @@
1
+ export interface UseHotkeysOptions {
2
+ enabled?: boolean;
3
+ target?: HTMLElement | Window | Document;
4
+ preventDefault?: boolean;
5
+ stopPropagation?: boolean;
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { DevPanel } from './components/DevPanel';
1
+ export * from './components';
2
2
  export { useDevPanel } from './hooks/useDevPanel';
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
- import { DevPanel as r } from "./components/DevPanel/DevPanel.js";
2
- import { useDevPanel as f } from "./hooks/useDevPanel/useDevPanel.js";
1
+ import { ControlRenderer as r, controls as n } from "./components/ControlRenderer/controls/index.js";
2
+ import { DevPanel as l } from "./components/DevPanel/DevPanel.js";
3
+ import { useDevPanel as m } from "./hooks/useDevPanel/useDevPanel.js";
3
4
  export {
4
- r as DevPanel,
5
- f as useDevPanel
5
+ r as ControlRenderer,
6
+ l as DevPanel,
7
+ n as controls,
8
+ m as useDevPanel
6
9
  };
@@ -0,0 +1,18 @@
1
+ export interface Position {
2
+ x: number;
3
+ y: number;
4
+ }
5
+
6
+ export interface HotkeyConfig {
7
+ key: string;
8
+ description?: string;
9
+ ctrlKey?: boolean;
10
+ shiftKey?: boolean;
11
+ altKey?: boolean;
12
+ metaKey?: boolean;
13
+ preventDefault?: boolean;
14
+ stopPropagation?: boolean;
15
+ enabled?: boolean;
16
+ target?: HTMLElement | Window | Document;
17
+ action: (event: KeyboardEvent) => void;
18
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "url": "git+https://github.com/Berenjenas/react-dev-panel.git"
16
16
  },
17
17
  "private": false,
18
- "version": "0.0.1-beta.2",
18
+ "version": "0.0.1-beta.4",
19
19
  "type": "module",
20
20
  "files": [
21
21
  "dist"