@zuzjs/ui 0.5.7 → 0.5.8

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 (55) hide show
  1. package/dist/bin.js +0 -0
  2. package/dist/comps/Box/index.js +13 -2
  3. package/dist/comps/Editor/Timeline/index.d.ts +3 -0
  4. package/dist/comps/Editor/Timeline/index.js +57 -0
  5. package/dist/comps/Editor/Timeline/layer.d.ts +3 -0
  6. package/dist/comps/Editor/Timeline/layer.js +67 -0
  7. package/dist/comps/Editor/Timeline/prop.d.ts +3 -0
  8. package/dist/comps/Editor/Timeline/prop.js +33 -0
  9. package/dist/comps/Editor/index.d.ts +4 -0
  10. package/dist/comps/Editor/index.js +9 -0
  11. package/dist/comps/Editor/selectionBox.d.ts +4 -0
  12. package/dist/comps/Editor/selectionBox.js +48 -0
  13. package/dist/comps/Editor/types.d.ts +58 -0
  14. package/dist/comps/Editor/types.js +15 -0
  15. package/dist/comps/Editor/withEditor.d.ts +3 -0
  16. package/dist/comps/Editor/withEditor.js +13 -0
  17. package/dist/comps/Select/index.d.ts +1 -1
  18. package/dist/comps/Select/index.js +9 -5
  19. package/dist/comps/Select/types.d.ts +9 -8
  20. package/dist/comps/Slider/index.d.ts +21 -0
  21. package/dist/comps/Slider/index.js +81 -0
  22. package/dist/comps/Text/index.js +2 -7
  23. package/dist/comps/Tooltip/index.d.ts +4 -0
  24. package/dist/comps/Tooltip/index.js +19 -0
  25. package/dist/comps/index.d.ts +7 -0
  26. package/dist/comps/index.js +7 -0
  27. package/dist/comps/svgicons.d.ts +17 -0
  28. package/dist/comps/svgicons.js +37 -1
  29. package/dist/funs/css.js +52 -6
  30. package/dist/funs/index.d.ts +2 -1
  31. package/dist/funs/index.js +2 -1
  32. package/dist/funs/stylesheet.d.ts +3 -2
  33. package/dist/funs/stylesheet.js +26 -1
  34. package/dist/hooks/index.d.ts +3 -0
  35. package/dist/hooks/index.js +2 -0
  36. package/dist/hooks/useBase.js +3 -2
  37. package/dist/hooks/useDebounce.d.ts +2 -0
  38. package/dist/hooks/useDebounce.js +14 -0
  39. package/dist/hooks/useDrag.d.ts +12 -1
  40. package/dist/hooks/useDrag.js +30 -4
  41. package/dist/styles.css +1 -1
  42. package/dist/types/enums.d.ts +9 -0
  43. package/dist/types/enums.js +11 -0
  44. package/dist/types/index.d.ts +20 -2
  45. package/package.json +1 -1
  46. package/dist/comps/Accordion/item.d.ts +0 -0
  47. package/dist/comps/Accordion/item.js +0 -1
  48. package/dist/comps/Otp/index.d.ts +0 -4
  49. package/dist/comps/Otp/index.js +0 -30
  50. package/dist/comps/Select/option.d.ts +0 -2
  51. package/dist/comps/Select/option.js +0 -8
  52. package/dist/comps/TabView/head.d.ts +0 -0
  53. package/dist/comps/TabView/head.js +0 -1
  54. package/dist/comps/TabView/item.d.ts +0 -0
  55. package/dist/comps/TabView/item.js +0 -1
package/dist/bin.js CHANGED
File without changes
@@ -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 });
@@ -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
  */
@@ -0,0 +1,21 @@
1
+ import { BoxProps } from "../Box";
2
+ import { SLIDER } from "../../types/enums";
3
+ export type SliderProps = BoxProps & {
4
+ type?: SLIDER;
5
+ value?: number;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ roundValue?: boolean;
10
+ onChange?: (value: number) => void;
11
+ };
12
+ declare const Slider: import("react").ForwardRefExoticComponent<BoxProps & {
13
+ type?: SLIDER;
14
+ value?: number;
15
+ min?: number;
16
+ max?: number;
17
+ step?: number;
18
+ roundValue?: boolean;
19
+ onChange?: (value: number) => void;
20
+ } & import("react").RefAttributes<HTMLInputElement>>;
21
+ export default Slider;
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useRef, useState } from "react";
4
+ import Box from "../Box";
5
+ import { SLIDER } from "../../types/enums";
6
+ import { useBase } from "../../hooks";
7
+ import Input from "../Input";
8
+ import Text from "../Text";
9
+ const Slider = forwardRef((props, ref) => {
10
+ const { type, value: _value, min: _min, max: _max, step: _step, onChange, roundValue, ...pops } = props;
11
+ const { className, style, rest } = useBase(pops);
12
+ const step = useRef(_step || 0.01).current;
13
+ const min = useRef(_min || 0).current;
14
+ const max = useRef(_max || 1).current;
15
+ const value = useRef(_value || 0).current;
16
+ const input = useRef(null);
17
+ const slider = useRef(null);
18
+ const knob = useRef(null);
19
+ const fill = useRef(null);
20
+ const track = useRef(null);
21
+ const text = useRef(null);
22
+ const percent = (value, min, max) => ((value - min) / (max - min)) * 100;
23
+ const handleInput = (e) => {
24
+ if (slider.current) {
25
+ const value = parseFloat(e.currentTarget.value);
26
+ const percentage = percent(value, parseFloat(e.currentTarget.min), parseFloat(e.currentTarget.max));
27
+ slider.current.style.setProperty(`--value`, `${percentage}`);
28
+ slider.current.setAttribute(`data-value`, `${value}`);
29
+ onChange && onChange(roundValue ? +value.toFixed(2) : value);
30
+ }
31
+ };
32
+ const [isDragging, setIsDragging] = useState(false);
33
+ const [startX, setStartX] = useState(0);
34
+ const [startValue, setStartValue] = useState(0);
35
+ const handleMouseDown = (e) => {
36
+ setIsDragging(true);
37
+ setStartX(e.clientX);
38
+ setStartValue(slider.current ? parseFloat(slider.current.getAttribute(`data-value`)) : 0);
39
+ document.body.style.cursor = `ew-resize`;
40
+ };
41
+ const handleMouseMove = (e) => {
42
+ if (isDragging) {
43
+ const deltaX = e.clientX - startX;
44
+ const newValue = Math.max(min, Math.min(startValue + deltaX * step, max)); // Adjust sensitivity as needed
45
+ if (slider.current) {
46
+ slider.current.setAttribute(`data-value`, `${newValue}`);
47
+ text.current.textContent = roundValue ? newValue.toFixed(2) : newValue.toString();
48
+ onChange && onChange(roundValue ? +newValue.toFixed(2) : newValue);
49
+ }
50
+ }
51
+ };
52
+ const handleMouseUp = () => {
53
+ setIsDragging(false);
54
+ document.body.style.cursor = `auto`;
55
+ };
56
+ useEffect(() => {
57
+ if (slider.current) {
58
+ slider.current
59
+ .style
60
+ .setProperty(`--value`, input.current ?
61
+ `${percent(parseFloat(input.current.value), parseFloat(input.current.min), parseFloat(input.current.max))}`
62
+ : value.toString());
63
+ }
64
+ }, []);
65
+ useEffect(() => {
66
+ if (isDragging) {
67
+ document.addEventListener('mousemove', handleMouseMove);
68
+ document.addEventListener('mouseup', handleMouseUp);
69
+ }
70
+ else {
71
+ document.removeEventListener('mousemove', handleMouseMove);
72
+ document.removeEventListener('mouseup', handleMouseUp);
73
+ }
74
+ return () => {
75
+ document.removeEventListener('mousemove', handleMouseMove);
76
+ document.removeEventListener('mouseup', handleMouseUp);
77
+ };
78
+ }, [isDragging]);
79
+ return _jsx(Box, { ref: slider, "data-value": value || 0, className: `--slider --${type || SLIDER.Default} flex rel ${className}`.trim(), style: { ...style }, children: SLIDER.Text === type ? _jsx(_Fragment, { children: _jsx(Text, { ref: text, onMouseDown: handleMouseDown, className: `--slider-text`, children: value || 0 }) }) : _jsxs(_Fragment, { children: [_jsx(Box, { ref: track, className: `--slider-track abs fill` }), _jsx(Box, { ref: knob, className: `--slider-knob abs` }), _jsx(Input, { ref: input, onInput: handleInput, className: `abs fill`, tabIndex: 0, type: type || SLIDER.Default, defaultValue: value || 0, step: step, max: max, min: min })] }) });
80
+ });
81
+ export default Slider;
@@ -1,17 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createElement, forwardRef } from 'react';
3
+ import { forwardRef } from 'react';
4
4
  import { useBase } from '../../hooks';
5
5
  import Span from '../Span';
6
6
  const Text = forwardRef((props, ref) => {
7
7
  const { h, html, children, ...pops } = props;
8
8
  const { style, className, rest } = useBase(pops);
9
9
  const Tag = `h${props.h || 1}`;
10
- return createElement(Tag, {
11
- ref,
12
- style,
13
- className,
14
- ...rest
15
- }, html ? _jsx(Span, { dangerouslySetInnerHTML: { __html: html } }) : children);
10
+ return _jsx(Tag, { ref: ref, style: style, className: className, ...rest, children: html ? _jsx(Span, { dangerouslySetInnerHTML: { __html: html } }) : children });
16
11
  });
17
12
  export default Text;
@@ -0,0 +1,4 @@
1
+ import { BoxProps } from '../Box';
2
+ export type ToolTipProps = BoxProps & {};
3
+ declare const ToolTip: import("react").ForwardRefExoticComponent<BoxProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default ToolTip;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useState } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ import Box from '../Box';
6
+ import Text from '../Text';
7
+ import { TRANSITION_CURVES } from '../../types/enums';
8
+ const ToolTip = forwardRef((props, ref) => {
9
+ const { title, children, ...pops } = props;
10
+ const { style, className, rest } = useBase(pops);
11
+ const [hovered, setHovered] = useState(false);
12
+ return _jsxs(Box, { className: `--with-tooltip rel`, onMouseEnter: e => setHovered(true), onMouseLeave: e => setHovered(false), children: [_jsx(Box, { className: `--tooltip abs ${className}`.trim(), animate: {
13
+ from: { opacity: 0, x: `-50%`, y: -5 },
14
+ to: { opacity: 1, x: `-50%`, y: 0 },
15
+ curve: TRANSITION_CURVES.EaseInOut,
16
+ when: hovered
17
+ }, children: _jsx(Text, { className: `--text rel`, children: title }) }), children] });
18
+ });
19
+ export default ToolTip;
@@ -13,6 +13,11 @@ export * from './ContextMenu/types';
13
13
  export { type CoverProps, default as Cover } from './Cover';
14
14
  export { default as Drawer } from './Drawer';
15
15
  export * from './Drawer/types';
16
+ /**Editor */
17
+ export { default as ZuzBuilder } from './Editor';
18
+ export { default as TimeLine } from './Editor/Timeline';
19
+ export * from './Editor/types';
20
+ export { default as withEditor } from './Editor/withEditor';
16
21
  export { type FormProps, default as Form } from './Form';
17
22
  export { type IconProps, default as Icon } from './Icon';
18
23
  export { type ImageProps, default as Image } from './Image';
@@ -29,6 +34,7 @@ export * from './Segmented/types';
29
34
  export { default as Select } from './Select';
30
35
  export * from './Select/types';
31
36
  export { type SheetProps, default as Sheet } from './Sheet';
37
+ export { type SliderProps, default as Slider } from './Slider';
32
38
  export { type SpanProps, default as Span } from './Span';
33
39
  export { type SpinnerProps, default as Spinner } from './Spinner';
34
40
  export { default as Switch } from './Switch';
@@ -37,5 +43,6 @@ export * from './TabView/types';
37
43
  export { type TextProps, default as Text } from './Text';
38
44
  export { default as TextWheel } from './TextWheel';
39
45
  export * from './TextWheel/types';
46
+ export { type ToolTipProps, default as ToolTip } from './Tooltip';
40
47
  export { default as TreeView } from './Treeview';
41
48
  export * from './Treeview/types';