@zuzjs/ui 0.5.7 → 0.5.9

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.
Files changed (70) hide show
  1. package/dist/comps/Alert/index.d.ts +11 -0
  2. package/dist/comps/Alert/index.js +13 -0
  3. package/dist/comps/Alert/types.d.ts +13 -0
  4. package/dist/comps/Alert/types.js +1 -0
  5. package/dist/comps/Box/index.js +13 -2
  6. package/dist/comps/Button/index.js +1 -1
  7. package/dist/comps/CheckBox/index.d.ts +2 -1
  8. package/dist/comps/CheckBox/index.js +3 -3
  9. package/dist/comps/CheckBox/types.d.ts +17 -1
  10. package/dist/comps/ContextMenu/index.d.ts +2 -2
  11. package/dist/comps/ContextMenu/index.js +8 -4
  12. package/dist/comps/ContextMenu/types.d.ts +3 -2
  13. package/dist/comps/Editor/Timeline/index.d.ts +3 -0
  14. package/dist/comps/Editor/Timeline/index.js +57 -0
  15. package/dist/comps/Editor/Timeline/layer.d.ts +3 -0
  16. package/dist/comps/Editor/Timeline/layer.js +67 -0
  17. package/dist/comps/Editor/Timeline/prop.d.ts +3 -0
  18. package/dist/comps/Editor/Timeline/prop.js +33 -0
  19. package/dist/comps/Editor/index.d.ts +4 -0
  20. package/dist/comps/Editor/index.js +9 -0
  21. package/dist/comps/Editor/selectionBox.d.ts +4 -0
  22. package/dist/comps/Editor/selectionBox.js +48 -0
  23. package/dist/comps/Editor/types.d.ts +58 -0
  24. package/dist/comps/Editor/types.js +15 -0
  25. package/dist/comps/Editor/withEditor.d.ts +3 -0
  26. package/dist/comps/Editor/withEditor.js +13 -0
  27. package/dist/comps/Select/index.d.ts +1 -1
  28. package/dist/comps/Select/index.js +9 -5
  29. package/dist/comps/Select/types.d.ts +9 -8
  30. package/dist/comps/Slider/index.d.ts +21 -0
  31. package/dist/comps/Slider/index.js +81 -0
  32. package/dist/comps/Switch/index.d.ts +1 -0
  33. package/dist/comps/Text/index.js +2 -7
  34. package/dist/comps/TextArea/index.d.ts +8 -0
  35. package/dist/comps/TextArea/index.js +12 -0
  36. package/dist/comps/Tooltip/index.d.ts +4 -0
  37. package/dist/comps/Tooltip/index.js +19 -0
  38. package/dist/comps/index.d.ts +12 -2
  39. package/dist/comps/index.js +12 -2
  40. package/dist/comps/svgicons.d.ts +21 -0
  41. package/dist/comps/svgicons.js +42 -1
  42. package/dist/funs/css.js +68 -18
  43. package/dist/funs/index.d.ts +2 -1
  44. package/dist/funs/index.js +2 -1
  45. package/dist/funs/stylesheet.d.ts +3 -2
  46. package/dist/funs/stylesheet.js +28 -1
  47. package/dist/hooks/index.d.ts +3 -0
  48. package/dist/hooks/index.js +2 -0
  49. package/dist/hooks/useBase.js +3 -2
  50. package/dist/hooks/useContextMenu.d.ts +2 -2
  51. package/dist/hooks/useContextMenu.js +4 -6
  52. package/dist/hooks/useDebounce.d.ts +2 -0
  53. package/dist/hooks/useDebounce.js +14 -0
  54. package/dist/hooks/useDrag.d.ts +12 -1
  55. package/dist/hooks/useDrag.js +30 -4
  56. package/dist/styles.css +1 -1
  57. package/dist/types/enums.d.ts +19 -4
  58. package/dist/types/enums.js +22 -4
  59. package/dist/types/index.d.ts +20 -2
  60. package/package.json +1 -1
  61. package/dist/comps/Accordion/item.d.ts +0 -0
  62. package/dist/comps/Accordion/item.js +0 -1
  63. package/dist/comps/Otp/index.d.ts +0 -4
  64. package/dist/comps/Otp/index.js +0 -30
  65. package/dist/comps/Select/option.d.ts +0 -2
  66. package/dist/comps/Select/option.js +0 -8
  67. package/dist/comps/TabView/head.d.ts +0 -0
  68. package/dist/comps/TabView/head.js +0 -1
  69. package/dist/comps/TabView/item.d.ts +0 -0
  70. package/dist/comps/TabView/item.js +0 -1
@@ -0,0 +1,11 @@
1
+ import { AlertHandler } from "./types";
2
+ import { ALERT } from "../../types/enums";
3
+ import { BoxProps } from "../Box";
4
+ declare const Alert: import("react").ForwardRefExoticComponent<BoxProps & {
5
+ type?: ALERT;
6
+ icon?: string;
7
+ iconSize?: number;
8
+ message?: string;
9
+ title: string;
10
+ } & import("react").RefAttributes<AlertHandler>>;
11
+ export default Alert;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useBase } from "../../hooks";
4
+ import { ALERT } from "../../types/enums";
5
+ import Box from "../Box";
6
+ import SVGIcons from "../svgicons";
7
+ import Text from "../Text";
8
+ const Alert = forwardRef((props, ref) => {
9
+ const { type, icon, title, message, iconSize, ...pops } = props;
10
+ const { className, style, rest } = useBase(pops);
11
+ return _jsxs(Box, { className: `--alert --${(type || ALERT.Info)} flex aic ${className}`.trim(), style: style, ...rest, children: [_jsx(Box, { className: `--icon icon-${icon || `auto-matic`}`, style: iconSize ? { width: iconSize, height: iconSize } : {}, children: !icon && SVGIcons[type || ALERT.Info] }), _jsxs(Text, { className: `--meta flex cols`, children: [_jsx(Text, { className: `--title ${message ? `--tm` : ``}`, children: title || `Lorem ipsum dolor sit amet, consectetur adipiscing elit.` }), message && _jsx(Text, { className: `--message`, h: 2, children: message })] })] });
12
+ });
13
+ export default Alert;
@@ -0,0 +1,13 @@
1
+ import { ALERT } from "../../types/enums";
2
+ import { BoxProps } from "../Box";
3
+ export type AlertProps = BoxProps & {
4
+ type?: ALERT;
5
+ icon?: string;
6
+ iconSize?: number;
7
+ message?: string;
8
+ title: string;
9
+ };
10
+ export interface AlertHandler {
11
+ open: () => void;
12
+ close: () => void;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { useBase } from "../../hooks";
5
5
  const Box = forwardRef((props, ref) => {
6
- const { style, ...pops } = props;
6
+ const { style, withEditor, ...pops } = props;
7
7
  const { style: _style, className, rest } = useBase(pops);
8
- return _jsx("div", { ref: ref, className: className, style: {
8
+ const handleInternalClick = (e) => {
9
+ // if ( withEditor && isBrowser ) {
10
+ // // window.dispatchEvent(new CustomEvent(`ZUZ_COMP_SELECTED`, {
11
+ // // detail: {
12
+ // // compName: 'Box',
13
+ // // target: e.target,
14
+ // // props
15
+ // // }
16
+ // // }))
17
+ // }
18
+ };
19
+ return _jsx("div", { ref: ref, onClick: handleInternalClick, className: `${className} ${withEditor ? `--with-zuz-editor` : ``}`.trim(), style: {
9
20
  ..._style,
10
21
  ...(style || {})
11
22
  }, ...rest });
@@ -7,6 +7,6 @@ import Span from '../Span';
7
7
  const Button = forwardRef((props, ref) => {
8
8
  const { icon, children, withLabel, ...pops } = props;
9
9
  const { style, className, rest } = useBase(pops);
10
- return _jsxs("button", { className: `${className} flex aic ${icon ? `ico-btn` : ``}`, style: style, ref: ref, ...rest, children: [icon && _jsx(Icon, { name: `icon-${icon}` }), withLabel === true ? _jsx(Span, { children: children }) : children] });
10
+ return _jsxs("button", { className: `${className} flex aic jcc ${icon ? `ico-btn` : ``}`, style: style, ref: ref, ...rest, children: [icon && _jsx(Icon, { name: icon }), withLabel === true ? _jsx(Span, { children: children }) : children] });
11
11
  });
12
12
  export default Button;
@@ -1,7 +1,8 @@
1
- import { CHECKBOX } from "../../types/enums";
1
+ import { CHECKBOX, Size } from "../../types/enums";
2
2
  import { CheckboxHandler } from "./types";
3
3
  declare const CheckBox: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
4
4
  type?: CHECKBOX;
5
+ size?: Size;
5
6
  onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
6
7
  } & import("react").RefAttributes<CheckboxHandler>>;
7
8
  export default CheckBox;
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useImperativeHandle, useRef, useState } from "react";
4
- import { CHECKBOX } from "../../types/enums";
4
+ import { CHECKBOX, Size } from "../../types/enums";
5
5
  import Label from "../Label";
6
6
  import Input from "../Input";
7
7
  import SVGIcons from "../svgicons";
8
8
  const CheckBox = forwardRef((props, ref) => {
9
- const { name, required, type, value, checked: defaultCheck, onChange, ...pops } = props;
9
+ const { name, required, type, value, size, checked: defaultCheck, onChange, ...pops } = props;
10
10
  const [checked, _setChecked] = useState(defaultCheck || false);
11
11
  const bRef = useRef(null);
12
12
  useImperativeHandle(ref, () => ({
@@ -26,7 +26,7 @@ const CheckBox = forwardRef((props, ref) => {
26
26
  _setChecked(!checked);
27
27
  }
28
28
  }));
29
- return _jsxs(Label, { className: `--${(type || CHECKBOX.Default).toLowerCase()} ${!type || type == CHECKBOX.Default ? `--checkbox` : `--switch`} flex aic jcc ${checked ? `is-checked` : ``} rel`.trim(), ...pops, children: [(!type || type == CHECKBOX.Default) && SVGIcons.check, _jsx(Input, { ...{}, ref: bRef, defaultChecked: checked, value: value || `cb`, type: `checkbox`, className: `abs`, name: name, required: required || false, onChange: (e) => {
29
+ return _jsxs(Label, { className: `--${(type || CHECKBOX.Default).toLowerCase()} ${!type || type == CHECKBOX.Default ? `--checkbox` : `--switch`} --${size || Size.Default} flex aic jcc ${checked ? `is-checked` : ``} rel`.trim(), ...pops, children: [(!type || type == CHECKBOX.Default) && SVGIcons.check, _jsx(Input, { ...{}, ref: bRef, defaultChecked: checked, value: value || `cb`, type: `checkbox`, className: `abs`, name: name, required: required || false, onChange: (e) => {
30
30
  onChange && onChange(e.target.checked, value || `cb`);
31
31
  _setChecked(e.target.checked);
32
32
  } })] });
@@ -1,9 +1,25 @@
1
1
  import { Props } from "../../types";
2
- import { CHECKBOX } from "../../types/enums";
2
+ import { CHECKBOX, Size } from "../../types/enums";
3
+ /**
4
+ * Props for the CheckBox component.
5
+ *
6
+ * @typedef {Object} CheckBoxProps
7
+ * @property {CHECKBOX} [type] - The type of the checkbox.
8
+ * @property {Size} [size] - The size of the checkbox.
9
+ * @property {(checked: boolean, value: string | number | readonly string[]) => void} [onChange] - Callback function triggered when the checkbox state changes.
10
+ */
3
11
  export type CheckBoxProps = Props<"input"> & {
4
12
  type?: CHECKBOX;
13
+ size?: Size;
5
14
  onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
6
15
  };
16
+ /**
17
+ * Interface for handling checkbox state.
18
+ *
19
+ * @interface CheckboxHandler
20
+ * @property {(mode: boolean, triggerChange?: boolean) => void} setChecked - Sets the checked state of the checkbox.
21
+ * @property {(triggerChange?: boolean) => void} toggle - Toggles the checked state of the checkbox.
22
+ */
7
23
  export interface CheckboxHandler {
8
24
  setChecked: (mode: boolean, triggerChange?: boolean) => void;
9
25
  toggle: (triggerChange?: boolean) => void;
@@ -1,6 +1,6 @@
1
1
  import { BoxProps } from "../Box";
2
- import { ContextMenuHandler } from "./types";
2
+ import { ContextItem, ContextMenuHandler } from "./types";
3
3
  declare const ContextMenu: import("react").ForwardRefExoticComponent<BoxProps & {
4
- items: import("./types").ContextItem[];
4
+ items?: ContextItem[];
5
5
  } & import("react").RefAttributes<ContextMenuHandler>>;
6
6
  export default ContextMenu;
@@ -4,13 +4,13 @@ import Box from "../Box";
4
4
  import { useBase } from "../../hooks";
5
5
  import MenuItem from "./item";
6
6
  const ContextMenu = forwardRef((props, ref) => {
7
- const { as, items, ...pops } = props;
7
+ const { as, items: _items, ...pops } = props;
8
8
  const { className, style, rest } = useBase(pops);
9
9
  const [visible, setVisible] = useState(false);
10
10
  const [position, setPosition] = useState({ x: 0, y: 0 });
11
+ const [items, setItems] = useState(_items || []);
11
12
  useImperativeHandle(ref, () => ({
12
- show: (e) => {
13
- // console.log(e)
13
+ show: (e, menuItems) => {
14
14
  if (e instanceof MouseEvent) {
15
15
  setPosition({ x: e.clientX, y: e.clientY });
16
16
  }
@@ -21,11 +21,15 @@ const ContextMenu = forwardRef((props, ref) => {
21
21
  const { clientX: x, clientY: y } = e;
22
22
  setPosition({ x, y });
23
23
  }
24
+ if (menuItems) {
25
+ setItems(menuItems);
26
+ }
24
27
  setVisible(true);
25
28
  },
26
29
  hide: (e) => setVisible(false),
27
30
  }));
28
- useEffect(() => { }, [visible, position]);
31
+ useEffect(() => {
32
+ }, [visible, position, items]);
29
33
  if (!visible)
30
34
  return null;
31
35
  return _jsx(Box, { className: `--contextmenu abs flex cols ${className}`.trim(), style: {
@@ -5,16 +5,17 @@ export interface ContextItem {
5
5
  icon?: string;
6
6
  iconColor?: string;
7
7
  className?: string;
8
+ enabled?: boolean;
8
9
  onSelect: () => void;
9
10
  }
10
11
  export type ContextMenuProps = BoxProps & {
11
- items: ContextItem[];
12
+ items?: ContextItem[];
12
13
  };
13
14
  export type MenuItemProps = ContextItem & {
14
15
  index: number;
15
16
  className: string;
16
17
  };
17
18
  export interface ContextMenuHandler {
18
- show: (e: MouseEvent | TouchEvent) => void;
19
+ show: (e: MouseEvent | TouchEvent, items?: ContextItem[]) => void;
19
20
  hide: (e: MouseEvent | TouchEvent) => void;
20
21
  }
@@ -0,0 +1,3 @@
1
+ import { TimeLineProps } from "../types";
2
+ declare const Timeline: import("react").ForwardRefExoticComponent<TimeLineProps & import("react").RefAttributes<HTMLDivElement>>;
3
+ export default Timeline;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useRef, useState } from "react";
3
+ import Box from "../../Box";
4
+ import Button from "../../Button";
5
+ import SVGIcons from "../../svgicons";
6
+ import Text from "../../Text";
7
+ import Layer from "./layer";
8
+ import Slider from "../../Slider";
9
+ import { DRAG_DIRECTION, SLIDER } from "../../../types/enums";
10
+ import ToolTip from "../../Tooltip";
11
+ const Timeline = forwardRef((props, ref) => {
12
+ const { layers } = props;
13
+ const [selected, setSelected] = useState([]);
14
+ const [duration, setDuration] = useState(1);
15
+ const sideBar = useRef(null);
16
+ const cursorLimit = useRef({ left: 0, right: 0, snap: 1 });
17
+ const onLayerSelect = (layer) => {
18
+ const { src } = layer;
19
+ if (src) {
20
+ const { width, height, x, y } = src.current.getBoundingClientRect();
21
+ src.current.classList.add(`--with-timeline`);
22
+ }
23
+ if (selected.includes(layer)) {
24
+ setSelected(selected.filter(a => a !== layer));
25
+ }
26
+ else {
27
+ setSelected([...selected, layer]);
28
+ }
29
+ };
30
+ const buildTimelineStamps = (step = 0.1) => {
31
+ const stamps = [];
32
+ for (let i = 0; i < duration; i += step) {
33
+ stamps.push(_jsx(Text, { className: `--stmp`, children: i.toFixed(1) }, `tstmp-${i}`));
34
+ }
35
+ return stamps;
36
+ };
37
+ useEffect(() => {
38
+ if (sideBar.current) {
39
+ const w = document.querySelector(`.--head .--track .--stamps .--stmp`).getBoundingClientRect().width;
40
+ cursorLimit.current = {
41
+ left: 0, //sideBar.current.offsetLeft,
42
+ right: window.innerWidth - sideBar.current.offsetWidth - 10,
43
+ snap: w
44
+ };
45
+ }
46
+ }, [duration]);
47
+ // console.log(cursorLimit.current)
48
+ return _jsxs(Box, { className: `--timeline fixed flex`, children: [_jsxs(Box, { className: `--layers flex cols`, children: [_jsxs(Box, { className: `--layer --head flex aic`, children: [_jsxs(Box, { ref: sideBar, className: `--meta flex aic jcc`, children: [_jsxs(Box, { className: `--buns flex aic`, children: [_jsx(Button, { className: `--pbtn`, children: SVGIcons.prev }), _jsx(Button, { className: `--pbtn`, children: SVGIcons.play }), _jsx(Button, { className: `--pbtn`, children: SVGIcons.next })] }), _jsxs(Box, { className: `--bus flex aic`, children: [_jsx(ToolTip, { title: `Duration`, children: _jsxs(Box, { className: `--choose-time flex aic jcc`, children: [_jsx(Slider, { onChange: e => setDuration(e), value: 1, type: SLIDER.Text, min: 1, max: 10, step: 1 }), _jsx(Text, { className: `--duration`, children: "s" })] }) }), _jsx(ToolTip, { title: `Add Style`, children: _jsx(Button, { className: `--pbtn`, children: SVGIcons.add }) })] })] }), _jsx(Box, { className: `--track flex aic`, children: _jsx(Box, { as: `--stamps flex aic`, children: buildTimelineStamps() }) })] }), layers && layers.length > 0 && layers.map((a, i) => _jsx(Layer, { meta: a, index: i + 1, selected: selected.includes(a), onSelect: onLayerSelect }, `layer-track-${i}`))] }), _jsx(Box, { draggable: true, dragOptions: {
49
+ direction: DRAG_DIRECTION.x,
50
+ snap: cursorLimit.current.snap,
51
+ limits: {
52
+ left: cursorLimit.current.left,
53
+ right: cursorLimit.current.right
54
+ }
55
+ }, className: `--cursor abs` })] });
56
+ });
57
+ export default Timeline;
@@ -0,0 +1,3 @@
1
+ import { LayerProps } from "../types";
2
+ declare const Layer: (props: LayerProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default Layer;
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect, useRef } from "react";
3
+ import Box from "../../Box";
4
+ import Button from "../../Button";
5
+ import SVGIcons from "../../svgicons";
6
+ import Text from "../../Text";
7
+ import Prop from "./prop";
8
+ import { cssWithKeys } from "../../../funs/stylesheet";
9
+ const Layer = (props) => {
10
+ const { meta, index, onSelect } = props;
11
+ const { src, label } = meta;
12
+ const style = useRef([
13
+ { x: 0, unit: 'px' },
14
+ { y: 0, unit: 'px' },
15
+ { z: 0, unit: 'px' },
16
+ { rx: 0, unit: 'deg' },
17
+ { ry: 0, unit: 'deg' },
18
+ { rz: 0, unit: 'deg' },
19
+ ]);
20
+ const [expanded, setExpanded] = useState(false);
21
+ const [keyframes, setKeyframes] = useState([]);
22
+ const applyStyle = (source) => {
23
+ if (src.current) {
24
+ const _transform = [];
25
+ const list = source || style.current;
26
+ list.forEach((c, i) => {
27
+ const [k, u] = Object.keys(c);
28
+ // _css.makeUnit(k, c[k as cssShortKey])
29
+ _transform.push(`${cssWithKeys[k]}(${c[k]}${c.unit})`);
30
+ });
31
+ src.current.style.transform = _transform.join(' ');
32
+ }
33
+ };
34
+ const updateStyle = (meta) => {
35
+ const [key] = Object.keys(meta);
36
+ // console.log(key, meta)
37
+ const newList = style.current.map(item => {
38
+ if (key in item) {
39
+ return meta; //{ ...item, [key]: meta[key as cssShortKey] };
40
+ }
41
+ return item;
42
+ });
43
+ if (!newList.some(item => key in item)) {
44
+ newList.push(meta);
45
+ }
46
+ style.current = newList;
47
+ // console.log(style.current)
48
+ applyStyle(newList);
49
+ };
50
+ const addKeyframe = () => {
51
+ setKeyframes([
52
+ ...keyframes,
53
+ {
54
+ stamp: 0,
55
+ props: style.current
56
+ }
57
+ ]);
58
+ console.log(keyframes);
59
+ };
60
+ // const updateStyleDebounced = useDebounce(updateStyle, 100)
61
+ useEffect(() => {
62
+ applyStyle();
63
+ setTimeout(() => setExpanded(true), 200);
64
+ }, []);
65
+ return _jsxs(Box, { onClick: e => onSelect(meta), className: `--layer flex aic`, children: [_jsxs(Box, { className: `--meta flex cols`, children: [_jsxs(Box, { className: `--prop flex aic`, children: [_jsx(Button, { onClick: e => setExpanded(!expanded), className: `--chevron`, children: expanded ? SVGIcons.chevronBottom : SVGIcons.chevronRight }), _jsx(Box, { className: `--icon` }), _jsx(Text, { className: `--label bold`, children: label || `Layer ${index}` })] }), expanded && style.current.map((a, i) => _jsx(Prop, { onChange: v => updateStyle(v), addKeyframe: addKeyframe, meta: a }, `layer-${a}-${i}`))] }), _jsxs(Box, { className: `--track flex cols`, children: [_jsx(Box, { className: `--bar` }), expanded && Object.keys(style.current).map((a, i) => _jsx(Box, { className: `--bar --sub` }, `bar-style-${a}-${i}`))] })] });
66
+ };
67
+ export default Layer;
@@ -0,0 +1,3 @@
1
+ import { PropProps } from "../types";
2
+ declare const Prop: (props: PropProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default Prop;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { cssWithKeys } from "../../../funs/stylesheet";
4
+ import { SLIDER } from "../../../types/enums";
5
+ import Box from "../../Box";
6
+ import Button from "../../Button";
7
+ import Select from "../../Select";
8
+ import Slider from "../../Slider";
9
+ import SVGIcons from "../../svgicons";
10
+ import Text from "../../Text";
11
+ const Prop = (props) => {
12
+ const { meta, onChange, addKeyframe } = props;
13
+ const [k, u] = Object.keys(meta);
14
+ const [unit, setUnit] = useState(meta.unit);
15
+ const [value, setValue] = useState(meta[k]);
16
+ const handleChange = (e) => {
17
+ onChange({
18
+ [k]: e || value,
19
+ unit: unit
20
+ });
21
+ };
22
+ return _jsxs(Box, { className: `--sub-prop flex aic`, children: [_jsx(Button, { onClick: e => addKeyframe(), className: `--add-key`, children: SVGIcons.addKey }), _jsx(Text, { className: `--plbl`, children: cssWithKeys[k] }), _jsxs(Box, { className: `--value flex aic jce`, children: [_jsx(Slider, { onChange: e => handleChange(e), min: -100, max: 100, step: 1, roundValue: true, type: SLIDER.Text }), _jsx(Select, { onChange: (v) => {
23
+ setUnit(v.value);
24
+ handleChange((+v.value));
25
+ }, selected: meta.unit, options: [
26
+ { label: `px`, value: `px` },
27
+ { label: `vw`, value: `vw` },
28
+ { label: `vh`, value: `vh` },
29
+ { label: `%`, value: `%` },
30
+ { label: `deg`, value: `deg` },
31
+ ] })] })] });
32
+ };
33
+ export default Prop;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { EditorHandler } from './types';
3
+ declare const Editor: React.ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../..").ZuzProps> & React.RefAttributes<EditorHandler>>;
4
+ export default Editor;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { forwardRef } from 'react';
3
+ import { EditorMode } from './types';
4
+ import Box from '../Box';
5
+ const Editor = forwardRef((props, ref) => {
6
+ const [mode, setMode] = React.useState(EditorMode.Select);
7
+ return _jsx(Box, { as: `--ui-builder rel` });
8
+ });
9
+ export default Editor;
@@ -0,0 +1,4 @@
1
+ import './styles.scss';
2
+ import { SelectionProps } from './types';
3
+ declare const SelectionBox: (props: SelectionProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default SelectionBox;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SelectionBox.tsx
3
+ import { useState, useCallback } from 'react';
4
+ import './styles.scss';
5
+ const SelectionBox = (props) => {
6
+ const [rect, setRect] = useState(props || { x: 10, y: 10, width: 200, height: 150 });
7
+ const handleMouseDown = useCallback((e, position) => {
8
+ const startX = e.clientX;
9
+ const startY = e.clientY;
10
+ const startWidth = rect.width;
11
+ const startHeight = rect.height;
12
+ const handleMouseMove = (moveEvent) => {
13
+ const deltaX = moveEvent.clientX - startX;
14
+ const deltaY = moveEvent.clientY - startY;
15
+ setRect((prevRect) => {
16
+ let newWidth = startWidth;
17
+ let newHeight = startHeight;
18
+ if (position.includes('right')) {
19
+ newWidth = startWidth + deltaX;
20
+ }
21
+ else if (position.includes('left')) {
22
+ newWidth = startWidth - deltaX;
23
+ prevRect.x += deltaX;
24
+ }
25
+ if (position.includes('bottom')) {
26
+ newHeight = startHeight + deltaY;
27
+ }
28
+ else if (position.includes('top')) {
29
+ newHeight = startHeight - deltaY;
30
+ prevRect.y += deltaY;
31
+ }
32
+ return {
33
+ ...prevRect,
34
+ width: newWidth,
35
+ height: newHeight,
36
+ };
37
+ });
38
+ };
39
+ const handleMouseUp = () => {
40
+ window.removeEventListener('mousemove', handleMouseMove);
41
+ window.removeEventListener('mouseup', handleMouseUp);
42
+ };
43
+ window.addEventListener('mousemove', handleMouseMove);
44
+ window.addEventListener('mouseup', handleMouseUp);
45
+ }, [rect]);
46
+ return (_jsxs("svg", { className: "selection-box", width: "100%", height: "100%", children: [_jsx("rect", { className: "selection-rect", x: rect.x, y: rect.y, width: rect.width, height: rect.height }), _jsx("circle", { className: "handle", cx: rect.x, cy: rect.y, r: "5", onMouseDown: (e) => handleMouseDown(e, 'top-left') }), _jsx("circle", { className: "handle", cx: rect.x + rect.width / 2, cy: rect.y, r: "5", onMouseDown: (e) => handleMouseDown(e, 'top') }), _jsx("circle", { className: "handle", cx: rect.x + rect.width, cy: rect.y, r: "5", onMouseDown: (e) => handleMouseDown(e, 'top-right') }), _jsx("circle", { className: "handle", cx: rect.x, cy: rect.y + rect.height / 2, r: "5", onMouseDown: (e) => handleMouseDown(e, 'left') }), _jsx("circle", { className: "handle", cx: rect.x + rect.width, cy: rect.y + rect.height / 2, r: "5", onMouseDown: (e) => handleMouseDown(e, 'right') }), _jsx("circle", { className: "handle", cx: rect.x, cy: rect.y + rect.height, r: "5", onMouseDown: (e) => handleMouseDown(e, 'bottom-left') }), _jsx("circle", { className: "handle", cx: rect.x + rect.width / 2, cy: rect.y + rect.height, r: "5", onMouseDown: (e) => handleMouseDown(e, 'bottom') }), _jsx("circle", { className: "handle", cx: rect.x + rect.width, cy: rect.y + rect.height, r: "5", onMouseDown: (e) => handleMouseDown(e, 'bottom-right') })] }));
47
+ };
48
+ export default SelectionBox;
@@ -0,0 +1,58 @@
1
+ import { RefObject } from "react";
2
+ import { cssShortKey, Props } from "../../types";
3
+ export declare enum EditorMode {
4
+ Select = "SELECT",
5
+ Move = "MOVE",
6
+ Rotate = "ROTATE",
7
+ Scale = "SCALE",
8
+ Animation = "ANIMATION",
9
+ Keyframe = "KEYFRAMING",
10
+ Play = "PLAY"
11
+ }
12
+ export declare enum LayerType {
13
+ Meta = "META",
14
+ Track = "TRACK"
15
+ }
16
+ export type LayerProps = {
17
+ index: number;
18
+ meta: TimeLineLayer;
19
+ selected: boolean;
20
+ onSelect: (layer: TimeLineLayer) => void;
21
+ };
22
+ export type TimeLineLayer = {
23
+ src: RefObject<HTMLElement>;
24
+ label?: string;
25
+ };
26
+ export type TimeLineProps = {
27
+ layers: TimeLineLayer[];
28
+ };
29
+ export type StyleItem = {
30
+ [key in cssShortKey]?: string | number;
31
+ } & {
32
+ unit: string;
33
+ };
34
+ export type PropProps = {
35
+ meta: StyleItem;
36
+ onChange: (v: StyleItem) => void;
37
+ addKeyframe: () => void;
38
+ };
39
+ export interface KeyFrame {
40
+ stamp: number;
41
+ props: StyleItem[];
42
+ }
43
+ export interface WithEditorProps {
44
+ withEditor?: boolean;
45
+ }
46
+ export type EditorProps = Props<`div`> & {};
47
+ export interface EditorHandler {
48
+ show: () => void;
49
+ }
50
+ export interface BuilderStore {
51
+ mode: EditorMode;
52
+ }
53
+ export type SelectionProps = {
54
+ x: number;
55
+ y: number;
56
+ width: number;
57
+ height: number;
58
+ };
@@ -0,0 +1,15 @@
1
+ export var EditorMode;
2
+ (function (EditorMode) {
3
+ EditorMode["Select"] = "SELECT";
4
+ EditorMode["Move"] = "MOVE";
5
+ EditorMode["Rotate"] = "ROTATE";
6
+ EditorMode["Scale"] = "SCALE";
7
+ EditorMode["Animation"] = "ANIMATION";
8
+ EditorMode["Keyframe"] = "KEYFRAMING";
9
+ EditorMode["Play"] = "PLAY";
10
+ })(EditorMode || (EditorMode = {}));
11
+ export var LayerType;
12
+ (function (LayerType) {
13
+ LayerType["Meta"] = "META";
14
+ LayerType["Track"] = "TRACK";
15
+ })(LayerType || (LayerType = {}));
@@ -0,0 +1,3 @@
1
+ import { EditorHandler, WithEditorProps } from "./types";
2
+ declare const withEditor: <P extends object>(Component: React.ComponentType<P>) => import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P & WithEditorProps> & import("react").RefAttributes<EditorHandler>>;
3
+ export default withEditor;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import Editor from ".";
4
+ const withEditor = (Component) => {
5
+ return forwardRef((props, ref) => {
6
+ const { withEditor, ...rest } = props;
7
+ if (withEditor) {
8
+ return _jsx(Editor, { ref: ref, children: _jsx(Component, { ...rest }) });
9
+ }
10
+ return _jsx(Component, { ref: ref, ...rest });
11
+ });
12
+ };
13
+ export default withEditor;
@@ -5,7 +5,7 @@ declare const Select: import("react").ForwardRefExoticComponent<BoxProps & {
5
5
  required?: FORMVALIDATION;
6
6
  options: Option[];
7
7
  label?: string;
8
- selected?: Option;
8
+ selected?: string | Option;
9
9
  search?: boolean;
10
10
  onChange?: (v: Option) => void;
11
11
  searchPlaceholder?: string;
@@ -10,7 +10,9 @@ import Input from "../Input";
10
10
  import OptionItem from "./optionItem";
11
11
  const Select = forwardRef((props, ref) => {
12
12
  const { selected, options, label, name, search: withSearch, searchPlaceholder, onChange, ...pops } = props;
13
- const [value, setValue] = useState(selected || options[0]);
13
+ const [value, setValue] = useState(selected ?
14
+ typeof selected === `string` ? options.find(fo => fo.value === selected) : selected
15
+ : options[0]);
14
16
  const [choosing, setChoosing] = useState(false);
15
17
  const [query, setQuery] = useState(null);
16
18
  const _ref = useRef(null);
@@ -37,7 +39,7 @@ const Select = forwardRef((props, ref) => {
37
39
  setQuery(null);
38
40
  }
39
41
  }, [choosing]);
40
- return _jsxs(Box, { className: `--select rel`, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, ref: _ref, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(true), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, style: {
42
+ return _jsxs(Box, { className: `--select rel`, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, ref: _ref, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(prev => !prev), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, style: {
41
43
  pointerEvents: choosing ? `auto` : `none`,
42
44
  }, animate: {
43
45
  from: { y: 5, opacity: 0 },
@@ -47,9 +49,11 @@ const Select = forwardRef((props, ref) => {
47
49
  }, children: [withSearch && _jsx(Input, { ref: _search, onChange: (e) => {
48
50
  setQuery(e.target.value == `` ? null : e.target.value);
49
51
  }, className: `--select-search`, placeholder: searchPlaceholder || `Search...` }), (query == null ? options : options.filter((o) => {
50
- return `string` == typeof o ?
51
- o.toLowerCase().includes(query.toLowerCase())
52
- : o.label.toLowerCase().includes(query.toLowerCase()) || o.value.toLowerCase().includes(query.toLowerCase());
52
+ // return
53
+ // `string` == typeof o ?
54
+ // o.toLowerCase().includes(query.toLowerCase())
55
+ // :
56
+ return o.label.toLowerCase().includes(query.toLowerCase()) || o.value.toLowerCase().includes(query.toLowerCase());
53
57
  }))
54
58
  .map((o) => _jsx(OptionItem, { updateValue: updateValue, value: value, o: o }, `option-${(`string` == typeof o ? o : o.label).replace(/\s+/g, `-`)}-${`string` == typeof o ? o : o.value}`))] })] });
55
59
  });
@@ -1,21 +1,22 @@
1
+ import { FormEventHandler } from "react";
1
2
  import { FORMVALIDATION } from "../../types/enums";
2
3
  import { BoxProps } from "../Box";
3
4
  /**
4
- * Represents an option object with a label and value.
5
+ * Represents an option which can be either a string or an OptionObject.
5
6
  */
6
- export interface OptionObject {
7
+ export type Option = {
7
8
  label: string;
8
9
  value: string;
9
- }
10
+ };
11
+ /**
12
+ * Represents an option object with a label and value.
13
+ */
14
+ export type Value = FormEventHandler<HTMLDivElement> & Option;
10
15
  export interface OptionItemProps {
11
16
  updateValue: (o: Option) => void;
12
17
  o: Option;
13
18
  value: Option;
14
19
  }
15
- /**
16
- * Represents an option which can be either a string or an OptionObject.
17
- */
18
- export type Option = string | OptionObject;
19
20
  /**
20
21
  * Props for the Select component.
21
22
  */
@@ -35,7 +36,7 @@ export type SelectProps = BoxProps & {
35
36
  /**
36
37
  * The currently selected option.
37
38
  */
38
- selected?: Option;
39
+ selected?: string | Option;
39
40
  /**
40
41
  * Enables the search functionality within the select dropdown.
41
42
  */