@berenjena/react-dev-panel 0.0.1-beta.4 → 0.0.1-beta.5
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 -0
- package/dist/assets/ColorControl.css +1 -1
- package/dist/assets/DevPanel.css +1 -1
- package/dist/assets/Input.css +1 -0
- package/dist/assets/Section.css +1 -1
- package/dist/assets/Select.css +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/components/ControlRenderer/controls/BooleanControl/BooleanControl.js +14 -13
- package/dist/components/ControlRenderer/controls/ButtonControl/ButtonControl.js +4 -4
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.d.ts +2 -0
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/ButtonGroupControl.js +22 -0
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.d.ts +1 -0
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/index.js +4 -0
- package/dist/components/ControlRenderer/controls/ButtonGroupControl/types.d.ts +14 -0
- package/dist/components/ControlRenderer/controls/ColorControl/ColorControl.js +19 -15
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.d.ts +15 -1
- package/dist/components/ControlRenderer/controls/NumberControl/NumberControl.js +21 -11
- package/dist/components/ControlRenderer/controls/NumberControl/types.d.ts +2 -2
- package/dist/components/ControlRenderer/controls/SelectControl/SelectControl.js +9 -8
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.d.ts +13 -1
- package/dist/components/ControlRenderer/controls/TextControl/TextControl.js +23 -13
- package/dist/components/ControlRenderer/controls/TextControl/types.d.ts +2 -3
- package/dist/components/ControlRenderer/controls/index.d.ts +1 -0
- package/dist/components/ControlRenderer/controls/index.js +32 -28
- package/dist/components/ControlRenderer/controls/types.d.ts +7 -0
- package/dist/components/DevPanel/DevPanel.js +27 -36
- package/dist/components/Input/Input.d.ts +1 -0
- package/dist/components/Input/Input.js +10 -0
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/Section/Section.js +5 -5
- package/dist/components/Select/Select.d.ts +1 -0
- package/dist/components/Select/Select.js +10 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/index.js +4 -0
- package/package.json +3 -3
- package/dist/assets/NumberControl.css +0 -1
- package/dist/assets/TextControl.css +0 -1
- package/dist/hooks/useHotkeys/example.d.ts +0 -5
- package/dist/hooks/useHotkeys/example.js +0 -266
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._switch_1i71a_1{--width: 42px;--height: 20px;--thumb-size: 12px;--thumb-offset: 3px;--thumb-checked-offset: calc(var(--width) - var(--thumb-size) - calc(var(--thumb-offset) * 2) - calc(var(--thumb-offset) / 2));--track-background: var(--dev-panel-input-background-color);--track-border: color-mix(in srgb, var(--dev-panel-border-color) 50%, transparent);--thumb-background: var(--dev-panel-text-color);--thumb-checked-background: white;--focus-ring-color: var(--dev-panel-accent-color);position:relative;display:inline-block;width:var(--width);height:var(--height)}._switch_1i71a_1 input{position:absolute;opacity:0;width:0;height:0;margin:0;pointer-events:none}._switch_1i71a_1 input:checked+._slider_1i71a_25{background-color:var(--focus-ring-color)}._switch_1i71a_1 input:checked+._slider_1i71a_25:before{transform:translate(var(--thumb-checked-offset));background-color:var(--thumb-checked-background)}._switch_1i71a_1 input:focus+._slider_1i71a_25{box-shadow:none;outline:none}._switch_1i71a_1 input:disabled+._slider_1i71a_25{opacity:.5;cursor:not-allowed}._switch_1i71a_1 input:disabled+._slider_1i71a_25:before{opacity:.7}._switch_1i71a_1 ._slider_1i71a_25{position:absolute;inset:0;background-color:var(--dev-panel-input-background-color);border:1px solid color-mix(in srgb,var(--dev-panel-border-color) 20%,transparent);border-radius:var(--dev-panel-border-radius);cursor:pointer;transition:var(--dev-panel-transition)}._switch_1i71a_1 ._slider_1i71a_25:before{content:"";position:absolute;top:var(--thumb-offset);left:var(--thumb-offset);width:var(--thumb-size);height:var(--thumb-size);background-color:var(--thumb-background);border-radius:calc(var(--dev-panel-border-radius) - 2px);transition:var(--dev-panel-transition);transform:scale(.95)}._switch_1i71a_1 ._slider_1i71a_25:hover{border-color:var(--dev-panel-accent-color)}._switch_1i71a_1 ._slider_1i71a_25:hover:before{box-shadow:0 2px 6px #00000026}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._button_e2m3l_1{width:100%;padding:var(--dev-panel-spacing-xs) var(--dev-panel-spacing-sm);height:var(--dev-panel-inputs-height);border:none;border-radius:4px;font-size:11px;font-weight:500;background-color:var(--dev-panel-accent-color);color:var(--dev-panel-text-color-highlight);cursor:pointer;transition:var(--dev-panel-transition)}._button_e2m3l_1:hover:not(:disabled){background-color:color-mix(in srgb,var(--dev-panel-accent-color) 80%,transparent)}._button_e2m3l_1:disabled{background-color:color-mix(in srgb,var(--dev-panel-accent-color) 20%,var(--dev-panel-background-color));cursor:not-allowed}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._buttonGroupContainer_99d3t_1{width:100%;display:grid;grid-auto-columns:1fr;grid-auto-flow:column;gap:1px}._buttonGroupContainer_99d3t_1 button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}._buttonGroupContainer_99d3t_1 button:not(:last-child):not(:first-child){border-radius:0}._buttonGroupContainer_99d3t_1 button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._container_ds1no_1{display:grid;grid-template-columns:var(--dev-panel-inputs-height) 1fr;gap:8px}._container_ds1no_1 label{overflow:hidden;width:auto;height:var(--dev-panel-inputs-height);cursor:pointer;border-radius:var(--dev-panel-border-radius)}._container_ds1no_1 input[type=color]{background:none;border:0;width:150%;height:150%;margin:-25%}._container_ds1no_1 input[type=color]:focus{border-radius:0;outline:none}
|
package/dist/assets/DevPanel.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--dev-panel-font-family: Helvetica, Arial, Sans-Serif;--dev-panel-primary-color: #
|
|
1
|
+
:root{--dev-panel-font-family: Helvetica, Arial, Sans-Serif;--dev-panel-font-size-xs: 12px;--dev-panel-font-size-sm: 14px;--dev-panel-font-size-md: 16px;--dev-panel-font-size-lg: 18px;--dev-panel-accent-color: #6663fd;--dev-panel-primary-color: #6663fd;--dev-panel-secondary-color: #1c1c1c;--dev-panel-background-color: #3e3d40;--dev-panel-highlight-color: #f0f0f0;--dev-panel-foreground-color: #313133;--dev-panel-border-color: #a1a1a1;--dev-panel-text-color: #e0e0e0;--dev-panel-text-color-muted: #b0b0b0;--dev-panel-input-background-color: #302f32;--dev-panel-text-color-highlight: #fbfffa;--dev-panel-spacing-xs: 4px;--dev-panel-spacing-sm: 8px;--dev-panel-spacing-md: 10px;--dev-panel-spacing-lg: 14px;--dev-panel-shadow: 0 8px 24px rgba(0, 0, 0, .2);--dev-panel-max-width: 320px;--dev-panel-max-height: 80vh;--dev-panel-inputs-height: 24px;--dev-panel-border-radius: 6px;--dev-panel-transition: all .2s cubic-bezier(.4, 0, .2, 1)}._devPanelContainer_12zm6_30{position:fixed;z-index:9998;border-radius:var(--dev-panel-border-radius);box-shadow:0 8px 24px #0003;width:var(--dev-panel-max-width);max-height:var(--dev-panel-max-height);overflow:hidden;-webkit-user-select:none;user-select:none;font-family:var(--dev-panel-font-family)}._devPanelContainer_12zm6_30 ._header_12zm6_41{display:flex;align-items:center;justify-content:space-between;padding:var(--dev-panel-spacing-xs);background:var(--dev-panel-foreground-color);cursor:move;color:var(--dev-panel-text-color)}._devPanelContainer_12zm6_30 ._title_12zm6_50{font-size:var(--dev-panel-font-size-xs);font-weight:600;display:flex;align-items:center;gap:var(--dev-panel-spacing-sm);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._devPanelContainer_12zm6_30 ._button_12zm6_60{background:none;border:none;color:inherit;font-size:var(--dev-panel-font-size-sm);cursor:pointer;padding:var(--dev-panel-spacing-xs) var(--dev-panel-spacing-sm);border-radius:4px;transition:all .2s ease}._devPanelContainer_12zm6_30 ._button_12zm6_60:hover{background:#dee2e6;color:#333}._devPanelContainer_12zm6_30 ._button_12zm6_60:active{transform:scale(.95)}._content_12zm6_78{max-height:calc(var(--dev-panel-max-height) - 48px);overflow-y:auto;background-color:var(--dev-panel-background-color)}._content_12zm6_78::-webkit-scrollbar{width:6px}._content_12zm6_78::-webkit-scrollbar-track{background:#f1f1f1}._content_12zm6_78::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}._content_12zm6_78::-webkit-scrollbar-thumb:hover{background:#a8a8a8}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._input_w2bi0_1{width:100%;height:var(--dev-panel-inputs-height);border:0;border-radius:var(--dev-panel-border-radius);cursor:pointer;padding:0;background-color:transparent;color:var(--dev-panel-text-color-highlight)}._input_w2bi0_1:last-of-type{background-color:var(--dev-panel-input-background-color);padding-left:var(--dev-panel-spacing-xs)}._input_w2bi0_1:focus{outline:none}._input_w2bi0_1:disabled{cursor:not-allowed;opacity:.6}._input_w2bi0_1::placeholder{color:var(--dev-panel-text-color-muted)}
|
package/dist/assets/Section.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._section_1wq66_1{padding:var(--dev-panel-spacing-sm);overflow:hidden}._section_1wq66_1:last-child{margin-bottom:0}._section_1wq66_1 ._header_1wq66_8{display:flex;align-items:center;justify-content:space-between;cursor:pointer;transition:background .2s ease}._section_1wq66_1 ._header_1wq66_8 ._title_1wq66_15{font-size:11px;font-weight:600;color:var(--dev-panel-text-color)}._section_1wq66_1 ._header_1wq66_8 ._toggle_1wq66_20{font-size:10px;color:var(--dev-panel-border-color);transition:transform .2s ease}._section_1wq66_1 ._content_1wq66_25{position:relative;padding:var(--dev-panel-spacing-sm) 0 0 var(--dev-panel-spacing-sm);display:grid;grid-template-columns:100%;row-gap:var(--dev-panel-spacing-sm);transition:opacity .25s}._section_1wq66_1 ._content_1wq66_25:after{content:"";position:absolute;left:0;bottom:0;width:2px;height:calc(100% - var(--dev-panel-spacing-sm));background-color:var(--dev-panel-border-color);transform:translate(-50%)}@media (prefers-color-scheme: dark){._section_1wq66_1,._section_1wq66_1 ._header_1wq66_8{border-color:#555}._section_1wq66_1 ._header_1wq66_8 ._title_1wq66_15{color:#e0e0e0}._section_1wq66_1 ._toggle_1wq66_20{color:#b0b0b0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._select_12f91_1{width:100%;height:var(--dev-panel-inputs-height);border:0;border-radius:var(--dev-panel-border-radius);cursor:pointer;padding:0;background-color:transparent;color:var(--dev-panel-text-color-highlight)}._select_12f91_1:last-of-type{background-color:var(--dev-panel-input-background-color);padding-left:var(--dev-panel-spacing-xs)}._select_12f91_1:focus{outline:none}._select_12f91_1:disabled{cursor:not-allowed;opacity:.6}._select_12f91_1::placeholder{color:var(--dev-panel-text-color-muted)}
|
package/dist/assets/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._controlContainer_sxvbd_1{gap:var(--dev-panel-spacing-sm);display:grid;height:100%;align-items:center;overflow:hidden;color:var(--dev-panel-text-color)}._controlContainer_sxvbd_1:not(._fullWidth_sxvbd_9){grid-template-columns:100px 1fr}._controlContainer_sxvbd_1 ._controlWrapper_sxvbd_12{display:flex;justify-content:flex-end}._controlContainer_sxvbd_1 ._label_sxvbd_16{font-weight:500;font-size:var(--dev-panel-font-size-xs);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._description_sxvbd_24,._loading_sxvbd_25{font-size:var(--dev-panel-font-size-xs);color:var(--dev-panel-text-color-muted)}._description_sxvbd_24{text-align:right}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { className as t } from "../../../../utils/className/className.js";
|
|
3
|
+
import "../../../../utils/store/store.js";
|
|
4
|
+
import '../../../../assets/BooleanControl.css';const l = "_slider_1i71a_25", e = {
|
|
5
|
+
switch: "_switch_1i71a_1",
|
|
6
|
+
slider: l
|
|
6
7
|
};
|
|
7
|
-
function
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */
|
|
8
|
+
function d({ control: s }) {
|
|
9
|
+
return /* @__PURE__ */ c("label", { className: e.switch, children: [
|
|
10
|
+
/* @__PURE__ */ a(
|
|
10
11
|
"input",
|
|
11
12
|
{
|
|
12
13
|
type: "checkbox",
|
|
13
|
-
checked:
|
|
14
|
-
disabled:
|
|
15
|
-
onChange: (
|
|
14
|
+
checked: s.value,
|
|
15
|
+
disabled: s.disabled,
|
|
16
|
+
onChange: (i) => s.onChange(i.target.checked),
|
|
16
17
|
className: e.checkbox
|
|
17
18
|
}
|
|
18
19
|
),
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
+
/* @__PURE__ */ a("span", { ...t(e.slider, e.round) })
|
|
20
21
|
] });
|
|
21
22
|
}
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
d as BooleanControl
|
|
24
25
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import '../../../../assets/ButtonControl.css';const o = "
|
|
2
|
+
import '../../../../assets/ButtonControl.css';const o = "_button_e2m3l_1", e = {
|
|
3
3
|
button: o
|
|
4
4
|
};
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */ n("button", { onClick: t.onClick, disabled: t.disabled, className:
|
|
5
|
+
function s({ control: t }) {
|
|
6
|
+
return /* @__PURE__ */ n("button", { onClick: t.onClick, disabled: t.disabled, className: e.button, children: t.label });
|
|
7
7
|
}
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
s as ButtonControl
|
|
10
10
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonControl as e } from "../ButtonControl/ButtonControl.js";
|
|
3
|
+
import '../../../../assets/ButtonGroupControl.css';const l = "_buttonGroupContainer_99d3t_1", i = {
|
|
4
|
+
buttonGroupContainer: l
|
|
5
|
+
};
|
|
6
|
+
function p({ control: n }) {
|
|
7
|
+
return /* @__PURE__ */ t("div", { className: i.buttonGroupContainer, children: n.buttons.map((o, r) => /* @__PURE__ */ t(
|
|
8
|
+
e,
|
|
9
|
+
{
|
|
10
|
+
control: {
|
|
11
|
+
type: "button",
|
|
12
|
+
label: o.label,
|
|
13
|
+
onClick: o.onClick,
|
|
14
|
+
disabled: o.disabled
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
r
|
|
18
|
+
)) });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
p as ButtonGroupControl
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonGroupControl';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ButtonControl } from '../ButtonControl/types';
|
|
2
|
+
import { BaseControl } from '../types';
|
|
3
|
+
export interface ButtonGroupControl extends BaseControl {
|
|
4
|
+
type: "buttonGroup";
|
|
5
|
+
buttons: {
|
|
6
|
+
label: ButtonControl["label"];
|
|
7
|
+
onClick: ButtonControl["onClick"];
|
|
8
|
+
disabled?: ButtonControl["disabled"];
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ButtonGroupControlProps {
|
|
13
|
+
control: ButtonGroupControl;
|
|
14
|
+
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { jsxs as t, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Input as l } from "../../../Input/Input.js";
|
|
3
|
+
import '../../../../assets/ColorControl.css';const o = "_container_ds1no_1", r = {
|
|
4
|
+
container: o
|
|
4
5
|
};
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
function d({ control: e }) {
|
|
7
|
+
return /* @__PURE__ */ t("div", { className: r.container, children: [
|
|
8
|
+
/* @__PURE__ */ n("label", { children: /* @__PURE__ */ n(l, { type: "color", value: e.value, disabled: e.disabled, onChange: (a) => e.onChange(a.target.value) }) }),
|
|
9
|
+
/* @__PURE__ */ n(
|
|
10
|
+
l,
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
value: e.value,
|
|
14
|
+
disabled: e.disabled,
|
|
15
|
+
onChange: (a) => e.onChange(a.target.value),
|
|
16
|
+
placeholder: "Enter color value"
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
] });
|
|
16
20
|
}
|
|
17
21
|
export {
|
|
18
|
-
|
|
22
|
+
d as ColorControl
|
|
19
23
|
};
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { NumberControlProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Component that renders a number control
|
|
3
|
+
* Component that renders a number control with configurable event handling
|
|
4
4
|
* @param control - The control to render
|
|
5
|
+
* @param control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onBlur"
|
|
5
6
|
* @returns The number control component
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
10
|
+
* // Real-time updates
|
|
9
11
|
* <NumberControl control={{
|
|
10
12
|
* type: 'number',
|
|
11
13
|
* value: 10,
|
|
14
|
+
* min: 0,
|
|
15
|
+
* max: 100,
|
|
16
|
+
* step: 1,
|
|
17
|
+
* event: 'onChange',
|
|
18
|
+
* onChange: (value) => setValue(value)
|
|
19
|
+
* }} />
|
|
20
|
+
*
|
|
21
|
+
* // Updates only when losing focus (default behavior)
|
|
22
|
+
* <NumberControl control={{
|
|
23
|
+
* type: 'number',
|
|
24
|
+
* value: 10,
|
|
25
|
+
* event: 'onBlur', // or omit for default
|
|
12
26
|
* onChange: (value) => setValue(value)
|
|
13
27
|
* }} />
|
|
14
28
|
* ```
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as i, useEffect as p } from "react";
|
|
3
|
+
import { Input as f } from "../../../Input/Input.js";
|
|
4
|
+
function h({ control: e }) {
|
|
5
|
+
const n = e.event || "onBlur", [l, t] = i(e.value);
|
|
6
|
+
p(() => {
|
|
7
|
+
t(e.value);
|
|
8
|
+
}, [e.value]);
|
|
9
|
+
const m = (u) => {
|
|
10
|
+
const a = Number(u.target.value);
|
|
11
|
+
t(a), n === "onChange" && e.onChange(a);
|
|
12
|
+
}, s = (u) => {
|
|
13
|
+
const a = Number(u.target.value);
|
|
14
|
+
n === "onBlur" && e.onChange(a);
|
|
15
|
+
};
|
|
16
|
+
return /* @__PURE__ */ r(
|
|
17
|
+
f,
|
|
8
18
|
{
|
|
9
19
|
type: "number",
|
|
10
|
-
value:
|
|
20
|
+
value: l,
|
|
11
21
|
min: e.min,
|
|
12
22
|
max: e.max,
|
|
13
23
|
step: e.step,
|
|
14
24
|
disabled: e.disabled,
|
|
15
|
-
onChange:
|
|
16
|
-
|
|
25
|
+
onChange: m,
|
|
26
|
+
...n === "onBlur" && { onBlur: s }
|
|
17
27
|
}
|
|
18
28
|
);
|
|
19
29
|
}
|
|
20
30
|
export {
|
|
21
|
-
|
|
31
|
+
h as NumberControl
|
|
22
32
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { Select as n } from "../../../Select/Select.js";
|
|
3
|
+
import '../../../../assets/SelectControl.css';const r = "_select_1w3k9_1", c = {
|
|
4
|
+
select: r
|
|
4
5
|
};
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
const
|
|
8
|
-
return /* @__PURE__ */
|
|
6
|
+
function o({ control: t }) {
|
|
7
|
+
return /* @__PURE__ */ s(n, { value: t.value, disabled: t.disabled, onChange: (e) => t.onChange(e.target.value), className: c.select, children: t.options.map((e) => {
|
|
8
|
+
const l = typeof e == "string" ? e : e.value, a = typeof e == "string" ? e : e.label;
|
|
9
|
+
return /* @__PURE__ */ s("option", { value: l, children: a }, l);
|
|
9
10
|
}) });
|
|
10
11
|
}
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
+
o as SelectControl
|
|
13
14
|
};
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import { TextControlProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Component that renders a text control
|
|
3
|
+
* Component that renders a text control with configurable event handling
|
|
4
4
|
* @param control - The control to render
|
|
5
|
+
* @param control.event - When to trigger onChange: "onChange" (real-time) or "onBlur" (on focus loss). Defaults to "onBlur"
|
|
5
6
|
* @returns The text control component
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
10
|
+
* // Real-time updates
|
|
9
11
|
* <TextControl control={{
|
|
10
12
|
* type: 'text',
|
|
11
13
|
* value: 'Hello',
|
|
12
14
|
* placeholder: 'Enter your name',
|
|
15
|
+
* event: 'onChange',
|
|
16
|
+
* onChange: (value) => setValue(value)
|
|
17
|
+
* }} />
|
|
18
|
+
*
|
|
19
|
+
* // Updates only when losing focus (default behavior)
|
|
20
|
+
* <TextControl control={{
|
|
21
|
+
* type: 'text',
|
|
22
|
+
* value: 'Hello',
|
|
23
|
+
* placeholder: 'Enter your name',
|
|
24
|
+
* event: 'onBlur', // or omit for default
|
|
13
25
|
* onChange: (value) => setValue(value)
|
|
14
26
|
* }} />
|
|
15
27
|
* ```
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as p } from "react";
|
|
3
|
+
import { Input as d } from "../../../Input/Input.js";
|
|
4
|
+
function g({ control: e }) {
|
|
5
|
+
const n = e.event || "onBlur", [u, l] = h(e.value);
|
|
6
|
+
p(() => {
|
|
7
|
+
l(e.value);
|
|
8
|
+
}, [e.value]);
|
|
9
|
+
const o = (t) => {
|
|
10
|
+
const a = t.target.value;
|
|
11
|
+
l(a), n === "onChange" && e.onChange(a);
|
|
12
|
+
}, r = (t) => {
|
|
13
|
+
const a = t.target.value;
|
|
14
|
+
n === "onBlur" && e.onChange(a);
|
|
15
|
+
};
|
|
16
|
+
return /* @__PURE__ */ s(
|
|
17
|
+
d,
|
|
8
18
|
{
|
|
9
19
|
type: "text",
|
|
10
|
-
value:
|
|
11
|
-
placeholder:
|
|
12
|
-
disabled:
|
|
13
|
-
onChange:
|
|
14
|
-
|
|
20
|
+
value: u,
|
|
21
|
+
placeholder: e.placeholder,
|
|
22
|
+
disabled: e.disabled,
|
|
23
|
+
onChange: o,
|
|
24
|
+
...n === "onBlur" && { onBlur: r }
|
|
15
25
|
}
|
|
16
26
|
);
|
|
17
27
|
}
|
|
18
28
|
export {
|
|
19
|
-
|
|
29
|
+
g as TextControl
|
|
20
30
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface TextControl extends
|
|
1
|
+
import { BaseInputControl } from '../types';
|
|
2
|
+
export interface TextControl extends BaseInputControl {
|
|
3
3
|
type: "text";
|
|
4
4
|
value: string;
|
|
5
5
|
placeholder?: string;
|
|
6
|
-
onChange: (value: string) => void;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export interface TextControlProps {
|
|
@@ -9,5 +9,6 @@ export declare const controls: Readonly<{
|
|
|
9
9
|
number: import('react').LazyExoticComponent<typeof import('./NumberControl').NumberControl>;
|
|
10
10
|
select: import('react').LazyExoticComponent<typeof import('./SelectControl').SelectControl>;
|
|
11
11
|
text: import('react').LazyExoticComponent<typeof import('./TextControl').TextControl>;
|
|
12
|
+
buttonGroup: import('react').LazyExoticComponent<typeof import('./ButtonGroupControl').ButtonGroupControl>;
|
|
12
13
|
}>;
|
|
13
14
|
export { ControlRenderer } from '..';
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
import { Suspense as
|
|
2
|
-
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
3
|
-
import { className as
|
|
1
|
+
import { Suspense as a, lazy as e } from "react";
|
|
2
|
+
import { jsxs as i, Fragment as c, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { className as p } from "../../../utils/className/className.js";
|
|
4
4
|
import "../../../utils/store/store.js";
|
|
5
|
-
import '../../../assets/index.css';const
|
|
6
|
-
controlContainer:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import '../../../assets/index.css';const u = "_controlContainer_sxvbd_1", m = "_fullWidth_sxvbd_9", b = "_controlWrapper_sxvbd_12", f = "_label_sxvbd_16", h = "_description_sxvbd_24", C = "_loading_sxvbd_25", r = {
|
|
6
|
+
controlContainer: u,
|
|
7
|
+
fullWidth: m,
|
|
8
|
+
controlWrapper: b,
|
|
9
|
+
label: f,
|
|
10
|
+
description: h,
|
|
11
|
+
loading: C
|
|
12
|
+
}, _ = ["button", "buttonGroup"];
|
|
13
|
+
function g({ name: t, control: o }) {
|
|
14
|
+
const s = o?.label || t;
|
|
15
|
+
function d() {
|
|
16
|
+
if (!o || !o.type)
|
|
14
17
|
return /* @__PURE__ */ n("div", { className: r.error, children: "Control type is not defined" });
|
|
15
|
-
const l =
|
|
16
|
-
return l ? /* @__PURE__ */ n(
|
|
18
|
+
const l = v[o.type];
|
|
19
|
+
return l ? /* @__PURE__ */ n(a, { fallback: /* @__PURE__ */ n("div", { className: r.loading, children: "Loading control..." }), children: /* @__PURE__ */ n(l, { control: o }) }) : /* @__PURE__ */ n("div", { children: "Unknown control type" });
|
|
17
20
|
}
|
|
18
|
-
return /* @__PURE__ */ i(
|
|
19
|
-
|
|
20
|
-
s,
|
|
21
|
-
|
|
21
|
+
return /* @__PURE__ */ i(c, { children: [
|
|
22
|
+
/* @__PURE__ */ i("div", { ...p(r.controlContainer, { [r.fullWidth]: _.includes(o.type) }), children: [
|
|
23
|
+
o?.type !== "button" && /* @__PURE__ */ n("label", { className: r.label, children: s }),
|
|
24
|
+
/* @__PURE__ */ n("div", { className: r.controlWrapper, children: d() })
|
|
22
25
|
] }),
|
|
23
|
-
|
|
26
|
+
o?.description && /* @__PURE__ */ n("span", { className: r.description, children: o.description })
|
|
24
27
|
] });
|
|
25
28
|
}
|
|
26
|
-
const
|
|
27
|
-
boolean:
|
|
28
|
-
button:
|
|
29
|
-
color:
|
|
30
|
-
number:
|
|
31
|
-
select:
|
|
32
|
-
text:
|
|
29
|
+
const v = Object.freeze({
|
|
30
|
+
boolean: e(() => import("./BooleanControl/index.js").then((t) => ({ default: t.BooleanControl }))),
|
|
31
|
+
button: e(() => import("./ButtonControl/index.js").then((t) => ({ default: t.ButtonControl }))),
|
|
32
|
+
color: e(() => import("./ColorControl/index.js").then((t) => ({ default: t.ColorControl }))),
|
|
33
|
+
number: e(() => import("./NumberControl/index.js").then((t) => ({ default: t.NumberControl }))),
|
|
34
|
+
select: e(() => import("./SelectControl/index.js").then((t) => ({ default: t.SelectControl }))),
|
|
35
|
+
text: e(() => import("./TextControl/index.js").then((t) => ({ default: t.TextControl }))),
|
|
36
|
+
buttonGroup: e(() => import("./ButtonGroupControl/index.js").then((t) => ({ default: t.ButtonGroupControl })))
|
|
33
37
|
});
|
|
34
38
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
g as ControlRenderer,
|
|
40
|
+
v as controls
|
|
37
41
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BooleanControl } from './BooleanControl/types';
|
|
2
2
|
import { ButtonControl } from './ButtonControl/types';
|
|
3
|
+
import { ButtonGroupControl } from './ButtonGroupControl/types';
|
|
3
4
|
import { ColorControl } from './ColorControl/types';
|
|
4
5
|
import { NumberControl } from './NumberControl/types';
|
|
5
6
|
import { SelectControl } from './SelectControl/types';
|
|
@@ -10,6 +11,11 @@ export interface BaseControl {
|
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export interface BaseInputControl extends BaseControl {
|
|
15
|
+
event?: "onBlur" | "onChange";
|
|
16
|
+
onChange: (value: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
export type Controls = {
|
|
14
20
|
color: ColorControl;
|
|
15
21
|
boolean: BooleanControl;
|
|
@@ -17,6 +23,7 @@ export type Controls = {
|
|
|
17
23
|
text: TextControl;
|
|
18
24
|
button: ButtonControl;
|
|
19
25
|
number: NumberControl;
|
|
26
|
+
buttonGroup: ButtonGroupControl;
|
|
20
27
|
};
|
|
21
28
|
|
|
22
29
|
export type ControlsNames = keyof Controls;
|
|
@@ -1,74 +1,65 @@
|
|
|
1
1
|
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as
|
|
2
|
+
import { useCallback as C } from "react";
|
|
3
3
|
import { useDragAndDrop as _ } from "../../hooks/useDragAndDrop/useDragAndDrop.js";
|
|
4
|
-
import { useHotkey as
|
|
5
|
-
import { className as
|
|
6
|
-
import { useDevPanelVisible as
|
|
7
|
-
import { EmptyContent as
|
|
4
|
+
import { useHotkey as D } from "../../hooks/useHotkeys/useHotkey.js";
|
|
5
|
+
import { className as P } from "../../utils/className/className.js";
|
|
6
|
+
import { useDevPanelVisible as b, useDevPanelCollapsed as g, useDevPanelPosition as y, useDevPanelSections as N, useDevPanelActions as K } from "../../utils/store/store.js";
|
|
7
|
+
import { EmptyContent as k } from "../EmptyContent/EmptyContent.js";
|
|
8
8
|
import { Section as x } from "../Section/Section.js";
|
|
9
|
-
import '../../assets/DevPanel.css';const
|
|
10
|
-
devPanelContainer:
|
|
9
|
+
import '../../assets/DevPanel.css';const z = "_devPanelContainer_12zm6_30", E = "_header_12zm6_41", V = "_title_12zm6_50", j = "_button_12zm6_60", w = "_content_12zm6_78", e = {
|
|
10
|
+
devPanelContainer: z,
|
|
11
11
|
header: E,
|
|
12
12
|
title: V,
|
|
13
|
-
|
|
14
|
-
content: w
|
|
15
|
-
|
|
16
|
-
}, A = {
|
|
13
|
+
button: j,
|
|
14
|
+
content: w
|
|
15
|
+
}, S = {
|
|
17
16
|
key: "f",
|
|
18
17
|
shiftKey: !0,
|
|
19
18
|
altKey: !0,
|
|
20
19
|
ctrlKey: !1,
|
|
21
20
|
metaKey: !1
|
|
22
21
|
};
|
|
23
|
-
function
|
|
24
|
-
const i =
|
|
22
|
+
function F({ panelTitle: c = "Dev panel", ...m }) {
|
|
23
|
+
const i = b(), n = g(), l = y(), d = N(), o = K(), u = C(
|
|
25
24
|
(s) => {
|
|
26
25
|
o.setPosition(s);
|
|
27
26
|
},
|
|
28
27
|
[o]
|
|
29
|
-
), { isDragging:
|
|
28
|
+
), { isDragging: p, elementRef: f, handleMouseDown: h } = _({
|
|
30
29
|
onPositionChange: u
|
|
31
30
|
});
|
|
32
|
-
if (
|
|
31
|
+
if (D({
|
|
33
32
|
description: "Show Dev Panel",
|
|
34
33
|
preventDefault: !0,
|
|
35
34
|
action: () => o.setVisible(!i),
|
|
36
|
-
...
|
|
37
|
-
...
|
|
35
|
+
...S,
|
|
36
|
+
...m.hotKeyConfig
|
|
38
37
|
}), process.env.NODE_ENV !== "development" || !i)
|
|
39
38
|
return null;
|
|
40
|
-
const
|
|
39
|
+
const a = Object.entries(d);
|
|
41
40
|
return /* @__PURE__ */ r(
|
|
42
41
|
"div",
|
|
43
42
|
{
|
|
44
|
-
ref:
|
|
45
|
-
...
|
|
46
|
-
[e.dragging]:
|
|
43
|
+
ref: f,
|
|
44
|
+
...P(e.devPanelContainer, {
|
|
45
|
+
[e.dragging]: p
|
|
47
46
|
}),
|
|
48
47
|
style: {
|
|
49
|
-
left:
|
|
50
|
-
top:
|
|
48
|
+
left: l.x,
|
|
49
|
+
top: l.y,
|
|
51
50
|
height: n ? "auto" : void 0
|
|
52
51
|
},
|
|
53
52
|
children: [
|
|
54
|
-
/* @__PURE__ */ r("div", { className: e.header, onMouseDown:
|
|
55
|
-
/* @__PURE__ */ t(
|
|
56
|
-
"button",
|
|
57
|
-
{
|
|
58
|
-
className: e.headerButton,
|
|
59
|
-
onClick: () => o.setCollapsed(!n),
|
|
60
|
-
title: n ? "Expand" : "Collapse",
|
|
61
|
-
children: n ? "▼" : "▲"
|
|
62
|
-
}
|
|
63
|
-
),
|
|
53
|
+
/* @__PURE__ */ r("div", { className: e.header, onMouseDown: h, children: [
|
|
54
|
+
/* @__PURE__ */ t("button", { className: e.button, onClick: () => o.setCollapsed(!n), title: n ? "Expand" : "Collapse", children: n ? "▼" : "▲" }),
|
|
64
55
|
/* @__PURE__ */ t("div", { className: e.title, children: c }),
|
|
65
|
-
/* @__PURE__ */ t("button", { className: e.
|
|
56
|
+
/* @__PURE__ */ t("button", { className: e.button, onClick: () => o.setVisible(!1), title: "Close", children: "✕" })
|
|
66
57
|
] }),
|
|
67
|
-
!n && /* @__PURE__ */ t("div", { className: e.content, children:
|
|
58
|
+
!n && /* @__PURE__ */ t("div", { className: e.content, children: a.length ? a.map(([s, v]) => /* @__PURE__ */ t(x, { sectionName: s, section: v }, `section-${s}`)) : /* @__PURE__ */ t(k, {}) })
|
|
68
59
|
]
|
|
69
60
|
}
|
|
70
61
|
);
|
|
71
62
|
}
|
|
72
63
|
export {
|
|
73
|
-
|
|
64
|
+
F as DevPanel
|
|
74
65
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Input(props: React.InputHTMLAttributes<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Input';
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsxs as s, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { ControlRenderer as
|
|
2
|
+
import { ControlRenderer as a } from "../ControlRenderer/controls/index.js";
|
|
3
3
|
import { useDevPanelActions as r } from "../../utils/store/store.js";
|
|
4
|
-
import '../../assets/Section.css';const d = "
|
|
4
|
+
import '../../assets/Section.css';const d = "_section_1wq66_1", _ = "_header_1wq66_8", m = "_title_1wq66_15", g = "_toggle_1wq66_20", p = "_content_1wq66_25", e = {
|
|
5
5
|
section: d,
|
|
6
6
|
header: _,
|
|
7
7
|
title: m,
|
|
8
8
|
toggle: g,
|
|
9
9
|
content: p
|
|
10
10
|
};
|
|
11
|
-
function
|
|
11
|
+
function C({ sectionName: c, section: t }) {
|
|
12
12
|
const l = r();
|
|
13
13
|
return /* @__PURE__ */ s("div", { className: e.section, children: [
|
|
14
14
|
/* @__PURE__ */ s("div", { className: e.header, onClick: () => l.toggleSectionCollapse(c), children: [
|
|
15
15
|
/* @__PURE__ */ n("span", { className: e.title, children: t.name }),
|
|
16
16
|
/* @__PURE__ */ n("span", { className: e.toggle, children: t.isCollapsed ? "▶" : "▼" })
|
|
17
17
|
] }),
|
|
18
|
-
!t.isCollapsed && /* @__PURE__ */ n("div", { className: e.content, children: Object.entries(t.controls).map(([o,
|
|
18
|
+
!t.isCollapsed && /* @__PURE__ */ n("div", { className: e.content, children: Object.entries(t.controls).map(([o, i]) => /* @__PURE__ */ n(a, { name: o, control: i }, o)) })
|
|
19
19
|
] });
|
|
20
20
|
}
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
C as Section
|
|
23
23
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Select(props: React.SelectHTMLAttributes<HTMLSelectElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Select';
|
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.
|
|
18
|
+
"version": "0.0.1-beta.5",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"test": "vitest"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"react": "
|
|
64
|
-
"react-dom": "
|
|
63
|
+
"react": ">=18.0.0",
|
|
64
|
+
"react-dom": ">=18.0.0",
|
|
65
65
|
"zustand": "^5.0.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._numberInput_pm0en_1{width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:4px;font-size:14px;background-color:#fff}._numberInput_pm0en_1:focus{outline:none;border-color:#4caf50;box-shadow:0 0 0 2px #4caf5033}._numberInput_pm0en_1:disabled{background-color:#f5f5f5;cursor:not-allowed}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._textInput_w4cvv_1{width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:4px;font-size:14px;background-color:#fff}._textInput_w4cvv_1:focus{outline:none;border-color:#4caf50;box-shadow:0 0 0 2px #4caf5033}._textInput_w4cvv_1:disabled{background-color:#f5f5f5;cursor:not-allowed}._textInput_w4cvv_1::placeholder{color:#999}
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useState as p, useCallback as o } from "react";
|
|
3
|
-
import { createHotkey as y } from "../../utils/createHotkey/createHotkey.js";
|
|
4
|
-
import { useHotkeys as m } from "./useHotkeys.js";
|
|
5
|
-
function w() {
|
|
6
|
-
const [d, s] = p(""), [l, a] = p(!1), [r, f] = p([]), [n, u] = p(-1), g = o(() => {
|
|
7
|
-
if (d.trim()) {
|
|
8
|
-
const t = [...r, d];
|
|
9
|
-
f(t), u(t.length - 1), alert(`Guardado: "${d}"`);
|
|
10
|
-
}
|
|
11
|
-
}, [d, r]), h = o(() => {
|
|
12
|
-
s(""), a(!1);
|
|
13
|
-
}, []), x = o(() => {
|
|
14
|
-
if (n > 0) {
|
|
15
|
-
const t = n - 1;
|
|
16
|
-
s(r[t]), u(t);
|
|
17
|
-
}
|
|
18
|
-
}, [r, n]), k = o(() => {
|
|
19
|
-
if (n < r.length - 1) {
|
|
20
|
-
const t = n + 1;
|
|
21
|
-
s(r[t]), u(t);
|
|
22
|
-
}
|
|
23
|
-
}, [r, n]), b = o(() => {
|
|
24
|
-
l && a(!1);
|
|
25
|
-
}, [l]), E = o(() => {
|
|
26
|
-
a(!l);
|
|
27
|
-
}, [l]), K = o(() => {
|
|
28
|
-
const t = document.getElementById("example-input");
|
|
29
|
-
t && t.focus();
|
|
30
|
-
}, []);
|
|
31
|
-
m(
|
|
32
|
-
[
|
|
33
|
-
{
|
|
34
|
-
key: "s",
|
|
35
|
-
ctrlKey: !0,
|
|
36
|
-
action: g,
|
|
37
|
-
description: "Guardar",
|
|
38
|
-
preventDefault: !0
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
key: "z",
|
|
42
|
-
ctrlKey: !0,
|
|
43
|
-
action: x,
|
|
44
|
-
description: "Deshacer",
|
|
45
|
-
preventDefault: !0
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
key: "z",
|
|
49
|
-
ctrlKey: !0,
|
|
50
|
-
shiftKey: !0,
|
|
51
|
-
action: k,
|
|
52
|
-
description: "Rehacer",
|
|
53
|
-
preventDefault: !0
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
key: "Escape",
|
|
57
|
-
action: b,
|
|
58
|
-
description: "Cancelar edición"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
key: "e",
|
|
62
|
-
ctrlKey: !0,
|
|
63
|
-
action: E,
|
|
64
|
-
description: "Alternar edición",
|
|
65
|
-
preventDefault: !0
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
key: "l",
|
|
69
|
-
ctrlKey: !0,
|
|
70
|
-
action: h,
|
|
71
|
-
description: "Limpiar",
|
|
72
|
-
preventDefault: !0
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
key: "f",
|
|
76
|
-
ctrlKey: !0,
|
|
77
|
-
action: K,
|
|
78
|
-
description: "Enfocar input",
|
|
79
|
-
preventDefault: !0
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
{
|
|
83
|
-
enabled: !0,
|
|
84
|
-
target: window
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
const v = y(
|
|
88
|
-
"k",
|
|
89
|
-
() => {
|
|
90
|
-
alert("Función de búsqueda activada!");
|
|
91
|
-
},
|
|
92
|
-
{ meta: !0 },
|
|
93
|
-
{ description: "Buscar" }
|
|
94
|
-
), C = y(
|
|
95
|
-
"Delete",
|
|
96
|
-
() => {
|
|
97
|
-
h();
|
|
98
|
-
},
|
|
99
|
-
{},
|
|
100
|
-
{ description: "Eliminar todo", enabled: l }
|
|
101
|
-
);
|
|
102
|
-
m([v, C]);
|
|
103
|
-
const H = [
|
|
104
|
-
{ key: "s", ctrlKey: !0, description: "Guardar" },
|
|
105
|
-
{ key: "z", ctrlKey: !0, description: "Deshacer" },
|
|
106
|
-
{ key: "z", ctrlKey: !0, shiftKey: !0, description: "Rehacer" },
|
|
107
|
-
{ key: "e", ctrlKey: !0, description: "Alternar edición" },
|
|
108
|
-
{ key: "l", ctrlKey: !0, description: "Limpiar" },
|
|
109
|
-
{ key: "f", ctrlKey: !0, description: "Enfocar input" },
|
|
110
|
-
{ key: "k", metaKey: !0, description: "Buscar" },
|
|
111
|
-
{ key: "Delete", description: "Eliminar todo (solo en modo edición)" },
|
|
112
|
-
{ key: "Escape", description: "Cancelar edición" }
|
|
113
|
-
];
|
|
114
|
-
return /* @__PURE__ */ i("div", { style: { padding: "20px", maxWidth: "600px", margin: "0 auto" }, children: [
|
|
115
|
-
/* @__PURE__ */ e("h2", { children: "Ejemplo de useHotkeys Hook" }),
|
|
116
|
-
/* @__PURE__ */ i("div", { style: { marginBottom: "20px" }, children: [
|
|
117
|
-
/* @__PURE__ */ e("label", { htmlFor: "example-input", children: "Texto:" }),
|
|
118
|
-
/* @__PURE__ */ e(
|
|
119
|
-
"input",
|
|
120
|
-
{
|
|
121
|
-
id: "example-input",
|
|
122
|
-
type: "text",
|
|
123
|
-
value: d,
|
|
124
|
-
onChange: (t) => s(t.target.value),
|
|
125
|
-
onFocus: () => a(!0),
|
|
126
|
-
onBlur: () => a(!1),
|
|
127
|
-
style: {
|
|
128
|
-
width: "100%",
|
|
129
|
-
padding: "10px",
|
|
130
|
-
margin: "5px 0",
|
|
131
|
-
border: l ? "2px solid blue" : "1px solid gray",
|
|
132
|
-
borderRadius: "4px"
|
|
133
|
-
},
|
|
134
|
-
placeholder: "Escribe algo aquí..."
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
] }),
|
|
138
|
-
/* @__PURE__ */ i("div", { style: { marginBottom: "20px" }, children: [
|
|
139
|
-
/* @__PURE__ */ i("p", { children: [
|
|
140
|
-
/* @__PURE__ */ e("strong", { children: "Estado:" }),
|
|
141
|
-
" ",
|
|
142
|
-
l ? "Editando" : "No editando"
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ i("p", { children: [
|
|
145
|
-
/* @__PURE__ */ e("strong", { children: "Historial:" }),
|
|
146
|
-
" ",
|
|
147
|
-
r.length,
|
|
148
|
-
" elementos"
|
|
149
|
-
] }),
|
|
150
|
-
/* @__PURE__ */ i("p", { children: [
|
|
151
|
-
/* @__PURE__ */ e("strong", { children: "Posición en historial:" }),
|
|
152
|
-
" ",
|
|
153
|
-
n + 1,
|
|
154
|
-
" ",
|
|
155
|
-
"de ",
|
|
156
|
-
r.length
|
|
157
|
-
] })
|
|
158
|
-
] }),
|
|
159
|
-
/* @__PURE__ */ i("div", { style: { marginBottom: "20px" }, children: [
|
|
160
|
-
/* @__PURE__ */ e("h3", { children: "Hotkeys disponibles:" }),
|
|
161
|
-
/* @__PURE__ */ e("ul", { style: { listStyle: "none", padding: 0 }, children: H.map((t, c) => /* @__PURE__ */ i(
|
|
162
|
-
"li",
|
|
163
|
-
{
|
|
164
|
-
style: {
|
|
165
|
-
padding: "5px 0",
|
|
166
|
-
borderBottom: "1px solid #eee",
|
|
167
|
-
display: "flex",
|
|
168
|
-
justifyContent: "space-between"
|
|
169
|
-
},
|
|
170
|
-
children: [
|
|
171
|
-
/* @__PURE__ */ e("span", { children: t.description }),
|
|
172
|
-
/* @__PURE__ */ e(
|
|
173
|
-
"code",
|
|
174
|
-
{
|
|
175
|
-
style: {
|
|
176
|
-
backgroundColor: "#f5f5f5",
|
|
177
|
-
padding: "2px 6px",
|
|
178
|
-
borderRadius: "3px",
|
|
179
|
-
fontSize: "12px"
|
|
180
|
-
},
|
|
181
|
-
children: [
|
|
182
|
-
t.ctrlKey && "Ctrl",
|
|
183
|
-
t.altKey && "Alt",
|
|
184
|
-
t.shiftKey && "Shift",
|
|
185
|
-
t.metaKey && "⌘",
|
|
186
|
-
t.key.toUpperCase()
|
|
187
|
-
].filter(Boolean).join("+")
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
]
|
|
191
|
-
},
|
|
192
|
-
c
|
|
193
|
-
)) })
|
|
194
|
-
] }),
|
|
195
|
-
/* @__PURE__ */ i("div", { style: { marginBottom: "20px" }, children: [
|
|
196
|
-
/* @__PURE__ */ e("h3", { children: "Historial:" }),
|
|
197
|
-
/* @__PURE__ */ e("ul", { children: r.map((t, c) => /* @__PURE__ */ e(
|
|
198
|
-
"li",
|
|
199
|
-
{
|
|
200
|
-
style: {
|
|
201
|
-
padding: "5px 0",
|
|
202
|
-
opacity: c === n ? 1 : 0.6,
|
|
203
|
-
fontWeight: c === n ? "bold" : "normal"
|
|
204
|
-
},
|
|
205
|
-
children: t
|
|
206
|
-
},
|
|
207
|
-
c
|
|
208
|
-
)) })
|
|
209
|
-
] }),
|
|
210
|
-
/* @__PURE__ */ i(
|
|
211
|
-
"div",
|
|
212
|
-
{
|
|
213
|
-
style: {
|
|
214
|
-
backgroundColor: "#f9f9f9",
|
|
215
|
-
padding: "15px",
|
|
216
|
-
borderRadius: "5px",
|
|
217
|
-
fontSize: "14px"
|
|
218
|
-
},
|
|
219
|
-
children: [
|
|
220
|
-
/* @__PURE__ */ e("p", { children: /* @__PURE__ */ e("strong", { children: "Instrucciones:" }) }),
|
|
221
|
-
/* @__PURE__ */ i("ul", { children: [
|
|
222
|
-
/* @__PURE__ */ e("li", { children: "Escribe algo en el input" }),
|
|
223
|
-
/* @__PURE__ */ i("li", { children: [
|
|
224
|
-
"Usa ",
|
|
225
|
-
/* @__PURE__ */ e("code", { children: "Ctrl+S" }),
|
|
226
|
-
" para guardar"
|
|
227
|
-
] }),
|
|
228
|
-
/* @__PURE__ */ i("li", { children: [
|
|
229
|
-
"Usa ",
|
|
230
|
-
/* @__PURE__ */ e("code", { children: "Ctrl+Z" }),
|
|
231
|
-
" para deshacer"
|
|
232
|
-
] }),
|
|
233
|
-
/* @__PURE__ */ i("li", { children: [
|
|
234
|
-
"Usa ",
|
|
235
|
-
/* @__PURE__ */ e("code", { children: "Ctrl+Shift+Z" }),
|
|
236
|
-
" para rehacer"
|
|
237
|
-
] }),
|
|
238
|
-
/* @__PURE__ */ i("li", { children: [
|
|
239
|
-
"Usa ",
|
|
240
|
-
/* @__PURE__ */ e("code", { children: "Ctrl+E" }),
|
|
241
|
-
" para alternar modo edición"
|
|
242
|
-
] }),
|
|
243
|
-
/* @__PURE__ */ i("li", { children: [
|
|
244
|
-
"Usa ",
|
|
245
|
-
/* @__PURE__ */ e("code", { children: "Ctrl+L" }),
|
|
246
|
-
" para limpiar"
|
|
247
|
-
] }),
|
|
248
|
-
/* @__PURE__ */ i("li", { children: [
|
|
249
|
-
"Usa ",
|
|
250
|
-
/* @__PURE__ */ e("code", { children: "Escape" }),
|
|
251
|
-
" para cancelar edición"
|
|
252
|
-
] }),
|
|
253
|
-
/* @__PURE__ */ i("li", { children: [
|
|
254
|
-
"Usa ",
|
|
255
|
-
/* @__PURE__ */ e("code", { children: "Delete" }),
|
|
256
|
-
" para eliminar todo (solo en modo edición)"
|
|
257
|
-
] })
|
|
258
|
-
] })
|
|
259
|
-
]
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
] });
|
|
263
|
-
}
|
|
264
|
-
export {
|
|
265
|
-
w as HotkeysExample
|
|
266
|
-
};
|