@berenjena/react-dev-panel 1.0.4 → 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/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 -19
- 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 +46 -41
- package/dist/components/DevPanel/types.d.ts +24 -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 +16 -15
- 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/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/SectionsStore.js +112 -5
- package/dist/store/ThemeStore.d.ts +68 -0
- package/dist/store/ThemeStore.js +102 -0
- package/dist/store/UIStore.js +115 -9
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +16 -11
- package/package.json +12 -3
- package/dist/UIStore-CQdr4U-2.js +0 -227
- package/dist/assets/index2.css +0 -1
- package/dist/components/Logger/index.d.ts +0 -20
- package/dist/components/Logger/index.js +0 -85
|
@@ -1,2 +1,37 @@
|
|
|
1
1
|
import { ButtonGroupControlProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a group of related buttons in a horizontal layout
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The button group control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'buttonGroup'
|
|
8
|
+
* @param props.control.buttons - Array of button configurations to render
|
|
9
|
+
* @param props.control.buttons[].label - The text label displayed on the button
|
|
10
|
+
* @param props.control.buttons[].onClick - Callback function triggered when button is clicked
|
|
11
|
+
* @param props.control.buttons[].disabled - Optional flag to disable individual buttons
|
|
12
|
+
* @returns JSX element representing a group of buttons
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* <ButtonGroupControl control={{
|
|
17
|
+
* type: 'buttonGroup',
|
|
18
|
+
* buttons: [
|
|
19
|
+
* { label: 'Save', onClick: () => save() },
|
|
20
|
+
* { label: 'Cancel', onClick: () => cancel() },
|
|
21
|
+
* { label: 'Delete', onClick: () => delete(), disabled: true }
|
|
22
|
+
* ]
|
|
23
|
+
* }} />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* <ButtonGroupControl control={{
|
|
29
|
+
* type: 'buttonGroup',
|
|
30
|
+
* buttons: [
|
|
31
|
+
* { label: 'Previous', onClick: () => goToPrevious() },
|
|
32
|
+
* { label: 'Next', onClick: () => goToNext() }
|
|
33
|
+
* ]
|
|
34
|
+
* }} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
2
37
|
export declare function ButtonGroupControl({ control }: ButtonGroupControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { ButtonControl as e } from "../ButtonControl/ButtonControl.js";
|
|
3
|
-
import '../../../../assets/ButtonGroupControl.css';const l = "
|
|
3
|
+
import '../../../../assets/ButtonGroupControl.css';const l = "_buttonGroupContainer_1642u_132", u = {
|
|
4
4
|
buttonGroupContainer: l
|
|
5
5
|
};
|
|
6
6
|
function p({ control: n }) {
|
|
7
|
-
return /* @__PURE__ */ t("div", { className:
|
|
7
|
+
return /* @__PURE__ */ t("div", { className: u.buttonGroupContainer, children: n.buttons.map((o, r) => /* @__PURE__ */ t(
|
|
8
8
|
e,
|
|
9
9
|
{
|
|
10
10
|
control: {
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { ColorControlProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Component that renders a color control
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
3
|
+
* Component that renders a color control with both visual color picker and text input
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The color control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'color'
|
|
8
|
+
* @param props.control.value - The current color value (hex, rgb, hsl, or named color)
|
|
9
|
+
* @param props.control.onChange - Callback function triggered when color value changes
|
|
10
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
11
|
+
* @returns JSX element representing the color control with picker and text input
|
|
6
12
|
*
|
|
7
13
|
* @example
|
|
8
14
|
* ```typescript
|
|
9
15
|
* <ColorControl control={{
|
|
10
16
|
* type: 'color',
|
|
11
|
-
* value: '#
|
|
12
|
-
* onChange: (value) =>
|
|
13
|
-
*
|
|
17
|
+
* value: '#ff0000',
|
|
18
|
+
* onChange: (value) => setColor(value),
|
|
19
|
+
* disabled: false
|
|
20
|
+
* }}/>
|
|
14
21
|
* ```
|
|
15
22
|
*/
|
|
16
23
|
export declare function ColorControl({ control }: ColorControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,27 +1,69 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useEffect as C } from "react";
|
|
3
|
+
import { Input as p } from "../../../Input/Input.js";
|
|
4
|
+
import { useDebouncedCallback as b } from "../../../../hooks/useDebounceCallback/useDebounceCallback.js";
|
|
5
|
+
import '../../../../assets/ColorControl.css';const y = "_container_1oo6z_1", x = "_colorPreview_1oo6z_7", V = "_errorMessage_1oo6z_52", c = {
|
|
6
|
+
container: y,
|
|
7
|
+
colorPreview: x,
|
|
8
|
+
errorMessage: V
|
|
6
9
|
};
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function P({ control: n }) {
|
|
11
|
+
const [r, o] = v(n.value), [s, i] = v(!0), u = b(n.onChange, 300);
|
|
12
|
+
function d(e) {
|
|
13
|
+
if (!e) return !1;
|
|
14
|
+
const t = document.createElement("div");
|
|
15
|
+
return t.style.color = e, t.style.color !== "";
|
|
16
|
+
}
|
|
17
|
+
function f(e) {
|
|
18
|
+
if (!e) return "#000000";
|
|
19
|
+
if (e.startsWith("#") && (e.length === 4 || e.length === 7))
|
|
20
|
+
return e.length === 4 ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : e;
|
|
21
|
+
try {
|
|
22
|
+
const a = document.createElement("canvas").getContext("2d");
|
|
23
|
+
return a ? (a.fillStyle = e, a.fillStyle) : "#000000";
|
|
24
|
+
} catch {
|
|
25
|
+
return "#000000";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function g(e) {
|
|
29
|
+
const t = e.target.value;
|
|
30
|
+
o(t), i(!0), u(t);
|
|
31
|
+
}
|
|
32
|
+
function h(e) {
|
|
33
|
+
const t = e.target.value;
|
|
34
|
+
o(t);
|
|
35
|
+
const a = d(t);
|
|
36
|
+
i(a), (a || t === "") && u(t);
|
|
37
|
+
}
|
|
38
|
+
return C(() => {
|
|
39
|
+
o(n.value), i(d(n.value));
|
|
40
|
+
}, [n.value]), /* @__PURE__ */ m("div", { className: c.container, children: [
|
|
41
|
+
/* @__PURE__ */ l("div", { className: c.colorPreview, style: { backgroundColor: s ? r : "transparent" }, children: /* @__PURE__ */ l(
|
|
42
|
+
"input",
|
|
43
|
+
{
|
|
44
|
+
type: "color",
|
|
45
|
+
value: f(r),
|
|
46
|
+
disabled: n.disabled,
|
|
47
|
+
onChange: g,
|
|
48
|
+
title: "Open color picker"
|
|
49
|
+
}
|
|
50
|
+
) }),
|
|
51
|
+
/* @__PURE__ */ l(
|
|
52
|
+
p,
|
|
15
53
|
{
|
|
16
54
|
type: "text",
|
|
17
|
-
value:
|
|
18
|
-
disabled:
|
|
19
|
-
onChange:
|
|
20
|
-
placeholder: "Enter color value"
|
|
55
|
+
value: r || "",
|
|
56
|
+
disabled: n.disabled,
|
|
57
|
+
onChange: h,
|
|
58
|
+
placeholder: "Enter color value (hex, rgb, hsl, named)",
|
|
59
|
+
style: {
|
|
60
|
+
borderColor: !s && r ? "var(--dev-panel-danger-color)" : void 0
|
|
61
|
+
}
|
|
21
62
|
}
|
|
22
|
-
)
|
|
63
|
+
),
|
|
64
|
+
!s && r && /* @__PURE__ */ l("div", { className: c.errorMessage, children: "Invalid color format" })
|
|
23
65
|
] });
|
|
24
66
|
}
|
|
25
67
|
export {
|
|
26
|
-
|
|
68
|
+
P as ColorControl
|
|
27
69
|
};
|
|
@@ -3,6 +3,20 @@ export interface ColorControl extends BaseControl {
|
|
|
3
3
|
type: "color";
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Format to display/parse colors
|
|
8
|
+
* @default "any" - Accepts any valid CSS color format
|
|
9
|
+
*/
|
|
10
|
+
format?: "hex" | "rgb" | "hsl" | "any";
|
|
11
|
+
/**
|
|
12
|
+
* Predefined color palette for quick selection
|
|
13
|
+
*/
|
|
14
|
+
presets?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Allow transparency/alpha values
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
allowAlpha?: boolean;
|
|
6
20
|
}
|
|
7
21
|
|
|
8
22
|
export interface ColorControlProps {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { DateControlProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Component that renders a date control with configurable event handling
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The date control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'date'
|
|
8
|
+
* @param props.control.value - The current date value in ISO format (YYYY-MM-DD)
|
|
9
|
+
* @param props.control.min - Optional minimum allowed date in ISO format
|
|
10
|
+
* @param props.control.max - Optional maximum allowed date in ISO format
|
|
11
|
+
* @param props.control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onBlur"
|
|
12
|
+
* @param props.control.onChange - Callback function triggered when date value changes
|
|
13
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
14
|
+
* @returns JSX element representing the date input control
|
|
7
15
|
*
|
|
8
16
|
* @example
|
|
9
17
|
* ```typescript
|
|
@@ -14,15 +22,19 @@ import { DateControlProps } from './types';
|
|
|
14
22
|
* min: '2025-01-01',
|
|
15
23
|
* max: '2025-12-31',
|
|
16
24
|
* event: 'onChange',
|
|
17
|
-
* onChange: (value) =>
|
|
25
|
+
* onChange: (value) => setSelectedDate(value),
|
|
26
|
+
* disabled: false
|
|
18
27
|
* }} />
|
|
28
|
+
* ```
|
|
19
29
|
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
20
32
|
* // Updates only when losing focus (default)
|
|
21
33
|
* <DateControl control={{
|
|
22
34
|
* type: 'date',
|
|
23
35
|
* value: '2025-07-26',
|
|
24
36
|
* event: 'onBlur',
|
|
25
|
-
* onChange: (value) =>
|
|
37
|
+
* onChange: (value) => console.log('Date changed:', value)
|
|
26
38
|
* }} />
|
|
27
39
|
* ```
|
|
28
40
|
*/
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { useState as o, useEffect as
|
|
3
|
-
import { Input as
|
|
2
|
+
import { useState as o, useEffect as s } from "react";
|
|
3
|
+
import { Input as r } from "../../../Input/Input.js";
|
|
4
4
|
function h({ control: e }) {
|
|
5
5
|
const n = e.event || "onBlur", [l, t] = o(e.value);
|
|
6
|
-
|
|
7
|
-
t(e.value);
|
|
8
|
-
}, [e.value]);
|
|
9
|
-
const s = (u) => {
|
|
6
|
+
function i(u) {
|
|
10
7
|
const a = u.target.value;
|
|
11
8
|
t(a), n === "onChange" && e.onChange(a);
|
|
12
|
-
}
|
|
9
|
+
}
|
|
10
|
+
function f(u) {
|
|
13
11
|
const a = u.target.value;
|
|
14
12
|
n === "onBlur" && e.onChange(a);
|
|
15
|
-
}
|
|
16
|
-
return
|
|
17
|
-
|
|
13
|
+
}
|
|
14
|
+
return s(() => {
|
|
15
|
+
t(e.value);
|
|
16
|
+
}, [e.value]), /* @__PURE__ */ m(
|
|
17
|
+
r,
|
|
18
18
|
{
|
|
19
19
|
type: "date",
|
|
20
20
|
value: l,
|
|
21
21
|
min: e.min,
|
|
22
22
|
max: e.max,
|
|
23
23
|
disabled: e.disabled,
|
|
24
|
-
onChange:
|
|
25
|
-
...n === "onBlur" && { onBlur:
|
|
24
|
+
onChange: i,
|
|
25
|
+
...n === "onBlur" && { onBlur: f }
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MultiSelectControlProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a multi-select control with checkbox options
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The multi-select control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'multiselect'
|
|
8
|
+
* @param props.control.value - Array of currently selected option values
|
|
9
|
+
* @param props.control.options - Array of available options (strings or objects with label/value)
|
|
10
|
+
* @param props.control.onChange - Callback function triggered when selection changes
|
|
11
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
12
|
+
* @returns JSX element representing the multi-select control
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* <MultiSelectControl control={{
|
|
17
|
+
* type: 'multiselect',
|
|
18
|
+
* value: ['red', 'blue'],
|
|
19
|
+
* options: [
|
|
20
|
+
* { label: 'Red Color', value: 'red' },
|
|
21
|
+
* { label: 'Blue Color', value: 'blue' },
|
|
22
|
+
* { label: 'Green Color', value: 'green' }
|
|
23
|
+
* ],
|
|
24
|
+
* onChange: (values) => setSelectedColors(values)
|
|
25
|
+
* }} />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function MultiSelectControl({ control }: MultiSelectControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsxs as f, Fragment as O, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useRef as _, useCallback as R, useEffect as v } from "react";
|
|
3
|
+
import { createPortal as S } from "react-dom";
|
|
4
|
+
import { Icon as N } from "../../../Icon/index.js";
|
|
5
|
+
import "../../../../store/SectionsStore.js";
|
|
6
|
+
import "../../../../store/ThemeStore.js";
|
|
7
|
+
import { useDevPanelPosition as z } from "../../../../store/UIStore.js";
|
|
8
|
+
import { className as B } from "../../../../utils/className/className.js";
|
|
9
|
+
import '../../../../assets/MultiSelectControl.css';const I = "_multiselect_1agkw_1", $ = "_trigger_1agkw_6", j = "_open_1agkw_36", A = "_value_1agkw_40", T = "_arrow_1agkw_53", V = "_dropdownPortal_1agkw_68", W = "_dropdown_1agkw_68", q = "_option_1agkw_115", F = "_disabled_1agkw_127", U = "_checkbox_1agkw_134", G = "_checkmark_1agkw_139", J = "_label_1agkw_170", n = {
|
|
10
|
+
multiselect: I,
|
|
11
|
+
trigger: $,
|
|
12
|
+
open: j,
|
|
13
|
+
value: A,
|
|
14
|
+
arrow: T,
|
|
15
|
+
dropdownPortal: V,
|
|
16
|
+
dropdown: W,
|
|
17
|
+
option: q,
|
|
18
|
+
disabled: F,
|
|
19
|
+
checkbox: U,
|
|
20
|
+
checkmark: G,
|
|
21
|
+
label: J
|
|
22
|
+
};
|
|
23
|
+
function oe({ control: t }) {
|
|
24
|
+
const c = z(), [a, u] = y(!1), [d, b] = y({
|
|
25
|
+
top: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
width: 0,
|
|
28
|
+
maxHeight: 200
|
|
29
|
+
}), p = _(null), w = _(null), k = _(null), s = R(() => {
|
|
30
|
+
a && b(x());
|
|
31
|
+
}, [a]);
|
|
32
|
+
function x() {
|
|
33
|
+
if (!w.current)
|
|
34
|
+
return { top: 0, left: 0, width: 0, maxHeight: 200 };
|
|
35
|
+
const e = w.current.getBoundingClientRect(), i = window.innerHeight, o = window.innerWidth, l = 200, m = 4, g = i - e.bottom - m, h = e.top - m, P = g < l && h > g, H = P ? e.top - Math.min(l, h) : e.bottom + m, D = Math.max(8, Math.min(e.left, o - e.width - 8)), M = P ? Math.min(l, h) : Math.min(l, g);
|
|
36
|
+
return {
|
|
37
|
+
top: H,
|
|
38
|
+
left: D,
|
|
39
|
+
width: e.width,
|
|
40
|
+
maxHeight: M
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function L(e) {
|
|
44
|
+
const i = t.value.includes(e) ? t.value.filter((o) => o !== e) : [...t.value, e];
|
|
45
|
+
t.onChange(i);
|
|
46
|
+
}
|
|
47
|
+
function C() {
|
|
48
|
+
if (t.value.length === 0)
|
|
49
|
+
return "Select options...";
|
|
50
|
+
if (t.value.length === 1) {
|
|
51
|
+
const e = t.options.find((o) => (typeof o == "string" ? o : o.value) === t.value[0]);
|
|
52
|
+
return (typeof e == "string" ? e : e?.label) || t.value[0];
|
|
53
|
+
}
|
|
54
|
+
return `${t.value.length} selected`;
|
|
55
|
+
}
|
|
56
|
+
function E() {
|
|
57
|
+
t.disabled || (a ? u(!1) : (b(x()), u(!0)));
|
|
58
|
+
}
|
|
59
|
+
return v(() => {
|
|
60
|
+
if (a)
|
|
61
|
+
return s(), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0), () => {
|
|
62
|
+
window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0);
|
|
63
|
+
};
|
|
64
|
+
}, [a, s]), v(() => {
|
|
65
|
+
const e = k.current;
|
|
66
|
+
(!e || e.x !== c.x || e.y !== c.y) && (k.current = c, s());
|
|
67
|
+
}, [c, s]), v(() => {
|
|
68
|
+
function e(i) {
|
|
69
|
+
if (p.current && !p.current.contains(i.target)) {
|
|
70
|
+
const o = document.querySelector(`.${n.dropdownPortal}`);
|
|
71
|
+
if (o && o.contains(i.target))
|
|
72
|
+
return;
|
|
73
|
+
u(!1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return document.addEventListener("mousedown", e), () => {
|
|
77
|
+
document.removeEventListener("mousedown", e);
|
|
78
|
+
};
|
|
79
|
+
}, []), /* @__PURE__ */ f(O, { children: [
|
|
80
|
+
/* @__PURE__ */ r(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
ref: p,
|
|
84
|
+
...B(n.multiselect, {
|
|
85
|
+
[n.disabled]: !!t.disabled,
|
|
86
|
+
[n.open]: a
|
|
87
|
+
}),
|
|
88
|
+
children: /* @__PURE__ */ f("button", { ref: w, type: "button", className: n.trigger, onClick: E, disabled: t.disabled, children: [
|
|
89
|
+
/* @__PURE__ */ r("span", { className: n.value, children: C() }),
|
|
90
|
+
/* @__PURE__ */ r(N, { name: "ArrowDown", className: n.arrow })
|
|
91
|
+
] })
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
typeof window < "u" && S(
|
|
95
|
+
a && !t.disabled && /* @__PURE__ */ r(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
className: `${n.dropdownPortal}`,
|
|
99
|
+
style: {
|
|
100
|
+
position: "fixed",
|
|
101
|
+
top: d.top,
|
|
102
|
+
left: d.left,
|
|
103
|
+
width: d.width,
|
|
104
|
+
maxHeight: d.maxHeight,
|
|
105
|
+
zIndex: 9999
|
|
106
|
+
},
|
|
107
|
+
children: /* @__PURE__ */ r("div", { className: n.dropdown, children: t.options.map((e) => {
|
|
108
|
+
const i = typeof e == "string" ? e : e.value, o = typeof e == "string" ? e : e.label, l = t.value.includes(i);
|
|
109
|
+
return /* @__PURE__ */ f("label", { className: n.option, children: [
|
|
110
|
+
/* @__PURE__ */ r(
|
|
111
|
+
"input",
|
|
112
|
+
{
|
|
113
|
+
type: "checkbox",
|
|
114
|
+
checked: l,
|
|
115
|
+
onChange: () => L(i),
|
|
116
|
+
className: n.checkbox
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ r(N, { name: "Check", className: n.checkmark }),
|
|
120
|
+
/* @__PURE__ */ r("span", { className: n.label, children: o })
|
|
121
|
+
] }, i);
|
|
122
|
+
}) })
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
document.body
|
|
126
|
+
)
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
oe as MultiSelectControl
|
|
131
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MultiSelectControl';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseControl } from '../types';
|
|
2
|
+
export interface MultiSelectControl extends BaseControl {
|
|
3
|
+
type: "multiselect";
|
|
4
|
+
value: string[];
|
|
5
|
+
options: string[] | { label: string; value: string }[];
|
|
6
|
+
onChange: (value: string[]) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface MultiSelectControlProps {
|
|
10
|
+
control: MultiSelectControl;
|
|
11
|
+
}
|
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
import { NumberControlProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Component that renders a number control with configurable event handling
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The number control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'number'
|
|
8
|
+
* @param props.control.value - The current numeric value
|
|
9
|
+
* @param props.control.min - Optional minimum allowed value
|
|
10
|
+
* @param props.control.max - Optional maximum allowed value
|
|
11
|
+
* @param props.control.step - Optional step increment for the number input (defaults to 1)
|
|
12
|
+
* @param props.control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onChange"
|
|
13
|
+
* @param props.control.onChange - Callback function triggered when numeric value changes
|
|
14
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
15
|
+
* @returns JSX element representing the number input control
|
|
7
16
|
*
|
|
8
17
|
* @example
|
|
9
18
|
* ```typescript
|
|
10
|
-
* // Real-time updates
|
|
19
|
+
* // Real-time updates with constraints
|
|
11
20
|
* <NumberControl control={{
|
|
12
21
|
* type: 'number',
|
|
13
|
-
* value:
|
|
22
|
+
* value: 50,
|
|
14
23
|
* min: 0,
|
|
15
24
|
* max: 100,
|
|
16
|
-
* step:
|
|
25
|
+
* step: 5,
|
|
17
26
|
* event: 'onChange',
|
|
18
|
-
* onChange: (value) =>
|
|
27
|
+
* onChange: (value) => setProgress(value),
|
|
28
|
+
* disabled: false
|
|
19
29
|
* }} />
|
|
30
|
+
* ```
|
|
20
31
|
*
|
|
21
|
-
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Updates only when losing focus
|
|
22
35
|
* <NumberControl control={{
|
|
23
36
|
* type: 'number',
|
|
24
|
-
* value:
|
|
25
|
-
*
|
|
26
|
-
*
|
|
37
|
+
* value: 42,
|
|
38
|
+
* min: 1,
|
|
39
|
+
* step: 0.1,
|
|
40
|
+
* event: 'onBlur',
|
|
41
|
+
* onChange: (value) => console.log('Value changed:', value)
|
|
27
42
|
* }} />
|
|
28
43
|
* ```
|
|
29
44
|
*/
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Input as
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r, useEffect as f } from "react";
|
|
3
|
+
import { Input as p } from "../../../Input/Input.js";
|
|
4
4
|
function v({ control: e }) {
|
|
5
|
-
const n = e.event || "onChange", [m, t] =
|
|
6
|
-
|
|
7
|
-
t(e.value);
|
|
8
|
-
}, [e.value]);
|
|
9
|
-
const s = (u) => {
|
|
5
|
+
const n = e.event || "onChange", [m, t] = r(e.value);
|
|
6
|
+
function l(u) {
|
|
10
7
|
const a = Number(u.target.value);
|
|
11
8
|
t(a), n === "onChange" && e.onChange(a);
|
|
12
|
-
}
|
|
9
|
+
}
|
|
10
|
+
function i(u) {
|
|
13
11
|
const a = Number(u.target.value);
|
|
14
12
|
n === "onBlur" && e.onChange(a);
|
|
15
|
-
}
|
|
16
|
-
return
|
|
17
|
-
|
|
13
|
+
}
|
|
14
|
+
return f(() => {
|
|
15
|
+
t(e.value);
|
|
16
|
+
}, [e.value]), /* @__PURE__ */ s(
|
|
17
|
+
p,
|
|
18
18
|
{
|
|
19
19
|
type: "number",
|
|
20
20
|
value: m,
|
|
@@ -22,8 +22,8 @@ function v({ control: e }) {
|
|
|
22
22
|
max: e.max,
|
|
23
23
|
step: e.step,
|
|
24
24
|
disabled: e.disabled,
|
|
25
|
-
onChange:
|
|
26
|
-
...n === "onBlur" && { onBlur:
|
|
25
|
+
onChange: l,
|
|
26
|
+
...n === "onBlur" && { onBlur: i }
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
29
|
}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
import { RangeControlProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Component that renders a range/slider control with configurable event handling
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
3
|
+
* Component that renders a range/slider control with configurable event handling and visual value display
|
|
4
|
+
*
|
|
5
|
+
* @param props - The component props
|
|
6
|
+
* @param props.control - The range control configuration object
|
|
7
|
+
* @param props.control.type - The control type, must be 'range'
|
|
8
|
+
* @param props.control.value - The current numeric value of the slider
|
|
9
|
+
* @param props.control.min - Optional minimum allowed value (defaults to 0)
|
|
10
|
+
* @param props.control.max - Optional maximum allowed value (defaults to 100)
|
|
11
|
+
* @param props.control.step - Optional step increment for the slider (defaults to 1)
|
|
12
|
+
* @param props.control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onChange"
|
|
13
|
+
* @param props.control.onChange - Callback function triggered when slider value changes
|
|
14
|
+
* @param props.control.disabled - Optional flag to disable the control
|
|
15
|
+
* @returns JSX element representing the range slider control with value display
|
|
7
16
|
*
|
|
8
17
|
* @example
|
|
9
18
|
* ```typescript
|
|
10
|
-
* // Real-time updates (default)
|
|
19
|
+
* // Real-time updates with custom range (default behavior)
|
|
11
20
|
* <RangeControl control={{
|
|
12
21
|
* type: 'range',
|
|
13
|
-
* value:
|
|
22
|
+
* value: 75,
|
|
14
23
|
* min: 0,
|
|
15
24
|
* max: 100,
|
|
16
|
-
* step:
|
|
25
|
+
* step: 5,
|
|
17
26
|
* event: 'onChange',
|
|
18
|
-
* onChange: (value) =>
|
|
27
|
+
* onChange: (value) => setVolume(value),
|
|
28
|
+
* disabled: false
|
|
19
29
|
* }} />
|
|
30
|
+
* ```
|
|
20
31
|
*
|
|
21
|
-
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Updates only when losing focus with decimal steps
|
|
22
35
|
* <RangeControl control={{
|
|
23
36
|
* type: 'range',
|
|
24
|
-
* value:
|
|
37
|
+
* value: 2.5,
|
|
38
|
+
* min: 0,
|
|
39
|
+
* max: 5,
|
|
40
|
+
* step: 0.1,
|
|
25
41
|
* event: 'onBlur',
|
|
26
|
-
* onChange: (value) =>
|
|
42
|
+
* onChange: (value) => console.log('Rating changed:', value)
|
|
27
43
|
* }} />
|
|
28
44
|
* ```
|
|
29
45
|
*/
|