@zuzjs/ui 0.5.6 → 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 (213) hide show
  1. package/dist/bin.js +0 -0
  2. package/dist/comps/Accordion/index.d.ts +6 -0
  3. package/dist/comps/Accordion/index.js +12 -0
  4. package/dist/comps/Accordion/types.d.ts +10 -0
  5. package/dist/comps/Actionbar/index.d.ts +21 -0
  6. package/dist/comps/Actionbar/index.js +58 -0
  7. package/dist/comps/Actionbar/item.d.ts +6 -0
  8. package/dist/comps/Actionbar/item.js +7 -0
  9. package/dist/comps/Actionbar/types.d.ts +29 -0
  10. package/dist/comps/Actionbar/types.js +1 -0
  11. package/dist/comps/Avatar/index.d.ts +19 -0
  12. package/dist/comps/Avatar/index.js +35 -0
  13. package/dist/comps/Box/index.d.ts +7 -0
  14. package/dist/comps/Box/index.js +24 -0
  15. package/dist/comps/Button/index.d.ts +10 -0
  16. package/dist/comps/Button/index.js +12 -0
  17. package/dist/comps/CheckBox/index.d.ts +7 -0
  18. package/dist/comps/{checkbox.js → CheckBox/index.js} +10 -9
  19. package/dist/comps/CheckBox/types.d.ts +10 -0
  20. package/dist/comps/CheckBox/types.js +1 -0
  21. package/dist/comps/ContextMenu/index.d.ts +6 -0
  22. package/dist/comps/ContextMenu/index.js +37 -0
  23. package/dist/comps/ContextMenu/item.d.ts +3 -0
  24. package/dist/comps/ContextMenu/item.js +11 -0
  25. package/dist/comps/ContextMenu/types.d.ts +20 -0
  26. package/dist/comps/ContextMenu/types.js +1 -0
  27. package/dist/comps/Cover/index.d.ts +17 -0
  28. package/dist/comps/Cover/index.js +19 -0
  29. package/dist/comps/Drawer/index.d.ts +12 -0
  30. package/dist/comps/{drawer.js → Drawer/index.js} +8 -10
  31. package/dist/comps/{drawer.d.ts → Drawer/types.d.ts} +4 -5
  32. package/dist/comps/Drawer/types.js +1 -0
  33. package/dist/comps/Editor/Timeline/index.d.ts +3 -0
  34. package/dist/comps/Editor/Timeline/index.js +57 -0
  35. package/dist/comps/Editor/Timeline/layer.d.ts +3 -0
  36. package/dist/comps/Editor/Timeline/layer.js +67 -0
  37. package/dist/comps/Editor/Timeline/prop.d.ts +3 -0
  38. package/dist/comps/Editor/Timeline/prop.js +33 -0
  39. package/dist/comps/Editor/index.d.ts +4 -0
  40. package/dist/comps/Editor/index.js +9 -0
  41. package/dist/comps/Editor/selectionBox.d.ts +4 -0
  42. package/dist/comps/Editor/selectionBox.js +48 -0
  43. package/dist/comps/Editor/types.d.ts +58 -0
  44. package/dist/comps/Editor/types.js +15 -0
  45. package/dist/comps/Editor/withEditor.d.ts +3 -0
  46. package/dist/comps/Editor/withEditor.js +13 -0
  47. package/dist/comps/{form.d.ts → Form/index.d.ts} +34 -10
  48. package/dist/comps/{form.js → Form/index.js} +11 -15
  49. package/dist/comps/Icon/index.d.ts +11 -0
  50. package/dist/comps/Icon/index.js +11 -0
  51. package/dist/comps/Image/index.d.ts +4 -0
  52. package/dist/comps/Image/index.js +9 -0
  53. package/dist/comps/Input/index.d.ts +8 -0
  54. package/dist/comps/Input/index.js +15 -0
  55. package/dist/comps/Label/index.d.ts +4 -0
  56. package/dist/comps/Label/index.js +9 -0
  57. package/dist/comps/Overlay/index.d.ts +8 -0
  58. package/dist/comps/Overlay/index.js +12 -0
  59. package/dist/comps/Password/index.d.ts +4 -0
  60. package/dist/comps/Password/index.js +18 -0
  61. package/dist/comps/PinInput/index.d.ts +12 -0
  62. package/dist/comps/{otp → PinInput}/index.js +10 -18
  63. package/dist/comps/ProgressBar/index.d.ts +7 -0
  64. package/dist/comps/ProgressBar/index.js +21 -0
  65. package/dist/comps/ProgressBar/types.d.ts +9 -0
  66. package/dist/comps/ProgressBar/types.js +1 -0
  67. package/dist/comps/Search/index.d.ts +14 -0
  68. package/dist/comps/{search → Search}/index.js +9 -19
  69. package/dist/comps/Segmented/index.d.ts +26 -0
  70. package/dist/comps/{segmented → Segmented}/index.js +3 -9
  71. package/dist/comps/Segmented/item.d.ts +3 -0
  72. package/dist/comps/{segmented → Segmented}/item.js +3 -9
  73. package/dist/comps/Segmented/types.d.ts +31 -0
  74. package/dist/comps/Segmented/types.js +1 -0
  75. package/dist/comps/Select/index.d.ts +13 -0
  76. package/dist/comps/Select/index.js +60 -0
  77. package/dist/comps/Select/optionItem.d.ts +3 -0
  78. package/dist/comps/Select/optionItem.js +6 -0
  79. package/dist/comps/Select/types.d.ts +53 -0
  80. package/dist/comps/Select/types.js +1 -0
  81. package/dist/comps/{sheet.d.ts → Sheet/index.d.ts} +16 -5
  82. package/dist/comps/Sheet/index.js +175 -0
  83. package/dist/comps/Slider/index.d.ts +21 -0
  84. package/dist/comps/Slider/index.js +81 -0
  85. package/dist/comps/Span/index.d.ts +4 -0
  86. package/dist/comps/Span/index.js +10 -0
  87. package/dist/comps/Spinner/index.d.ts +21 -0
  88. package/dist/comps/Spinner/index.js +31 -0
  89. package/dist/comps/Switch/index.d.ts +7 -0
  90. package/dist/comps/Switch/index.js +8 -0
  91. package/dist/comps/TabView/index.d.ts +9 -0
  92. package/dist/comps/TabView/index.js +41 -0
  93. package/dist/comps/TabView/tab.d.ts +3 -0
  94. package/dist/comps/TabView/tab.js +9 -0
  95. package/dist/comps/{tabview.d.ts → TabView/types.d.ts} +10 -5
  96. package/dist/comps/TabView/types.js +1 -0
  97. package/dist/comps/Text/index.d.ts +11 -0
  98. package/dist/comps/Text/index.js +12 -0
  99. package/dist/comps/TextWheel/index.d.ts +8 -0
  100. package/dist/comps/{textwheel.js → TextWheel/index.js} +9 -9
  101. package/dist/comps/TextWheel/types.d.ts +10 -0
  102. package/dist/comps/TextWheel/types.js +1 -0
  103. package/dist/comps/Tooltip/index.d.ts +4 -0
  104. package/dist/comps/Tooltip/index.js +19 -0
  105. package/dist/comps/Treeview/index.d.ts +11 -0
  106. package/dist/comps/{treeview → Treeview}/index.js +3 -3
  107. package/dist/comps/Treeview/item.d.ts +11 -0
  108. package/dist/comps/Treeview/item.js +26 -0
  109. package/dist/comps/{treeview/index.d.ts → Treeview/types.d.ts} +14 -5
  110. package/dist/comps/Treeview/types.js +1 -0
  111. package/dist/comps/index.d.ts +48 -0
  112. package/dist/comps/index.js +48 -0
  113. package/dist/comps/svgicons.d.ts +26 -2
  114. package/dist/comps/svgicons.js +44 -5
  115. package/dist/funs/css.js +52 -6
  116. package/dist/funs/index.d.ts +18 -17
  117. package/dist/funs/index.js +70 -69
  118. package/dist/funs/stylesheet.d.ts +3 -2
  119. package/dist/funs/stylesheet.js +26 -1
  120. package/dist/hooks/index.d.ts +7 -3
  121. package/dist/hooks/index.js +8 -3
  122. package/dist/hooks/useBase.d.ts +8 -0
  123. package/dist/{comps/useBase/index.js → hooks/useBase.js} +24 -6
  124. package/dist/hooks/useContextMenu.d.ts +7 -0
  125. package/dist/hooks/useContextMenu.js +21 -0
  126. package/dist/hooks/useDebounce.d.ts +2 -0
  127. package/dist/hooks/useDebounce.js +14 -0
  128. package/dist/hooks/useDrag.d.ts +21 -0
  129. package/dist/hooks/useDrag.js +71 -0
  130. package/dist/index.d.ts +5 -31
  131. package/dist/index.js +5 -32
  132. package/dist/styles.css +1 -1
  133. package/dist/types/enums.d.ts +9 -0
  134. package/dist/types/enums.js +11 -0
  135. package/dist/types/index.d.ts +54 -20
  136. package/dist/types/interfaces.d.ts +45 -51
  137. package/package.json +3 -4
  138. package/dist/comps/accordion.d.ts +0 -12
  139. package/dist/comps/accordion.js +0 -10
  140. package/dist/comps/alert.d.ts +0 -15
  141. package/dist/comps/alert.js +0 -15
  142. package/dist/comps/animate.d.ts +0 -6
  143. package/dist/comps/animate.js +0 -8
  144. package/dist/comps/avatar.d.ts +0 -13
  145. package/dist/comps/avatar.js +0 -11
  146. package/dist/comps/base.d.ts +0 -15
  147. package/dist/comps/base.js +0 -68
  148. package/dist/comps/box.d.ts +0 -6
  149. package/dist/comps/box.js +0 -12
  150. package/dist/comps/button.d.ts +0 -7
  151. package/dist/comps/button.js +0 -19
  152. package/dist/comps/checkbox.d.ts +0 -18
  153. package/dist/comps/contextmenu.d.ts +0 -15
  154. package/dist/comps/contextmenu.js +0 -9
  155. package/dist/comps/cover.d.ts +0 -15
  156. package/dist/comps/cover.js +0 -31
  157. package/dist/comps/dialog.d.ts +0 -0
  158. package/dist/comps/dialog.js +0 -1
  159. package/dist/comps/editor.d.ts +0 -12
  160. package/dist/comps/editor.js +0 -92
  161. package/dist/comps/grid/index.d.ts +0 -10
  162. package/dist/comps/grid/index.js +0 -16
  163. package/dist/comps/heading.d.ts +0 -8
  164. package/dist/comps/heading.js +0 -16
  165. package/dist/comps/icon.d.ts +0 -7
  166. package/dist/comps/icon.js +0 -23
  167. package/dist/comps/image.d.ts +0 -13
  168. package/dist/comps/image.js +0 -8
  169. package/dist/comps/input.d.ts +0 -6
  170. package/dist/comps/input.js +0 -19
  171. package/dist/comps/otp/index.d.ts +0 -6
  172. package/dist/comps/password.d.ts +0 -3
  173. package/dist/comps/password.js +0 -30
  174. package/dist/comps/progressbar.d.ts +0 -11
  175. package/dist/comps/progressbar.js +0 -14
  176. package/dist/comps/search/index.d.ts +0 -7
  177. package/dist/comps/segmented/index.d.ts +0 -46
  178. package/dist/comps/segmented/item.d.ts +0 -8
  179. package/dist/comps/select/index.d.ts +0 -15
  180. package/dist/comps/select/index.js +0 -79
  181. package/dist/comps/select/select.d.ts +0 -0
  182. package/dist/comps/select/select.js +0 -1
  183. package/dist/comps/sheet.js +0 -229
  184. package/dist/comps/span.d.ts +0 -6
  185. package/dist/comps/span.js +0 -12
  186. package/dist/comps/spinner.d.ts +0 -16
  187. package/dist/comps/spinner.js +0 -42
  188. package/dist/comps/tabview.js +0 -64
  189. package/dist/comps/textwheel.d.ts +0 -15
  190. package/dist/comps/treeview/item.d.ts +0 -15
  191. package/dist/comps/treeview/item.js +0 -23
  192. package/dist/comps/useBase/base.types.d.ts +0 -80
  193. package/dist/comps/useBase/index.d.ts +0 -10
  194. package/dist/funs/lexer.d.ts +0 -3
  195. package/dist/funs/lexer.js +0 -37
  196. package/dist/hooks/useCompEditor.d.ts +0 -2
  197. package/dist/hooks/useCompEditor.js +0 -5
  198. package/dist/hooks/useInteractionObserver.d.ts +0 -8
  199. package/dist/hooks/useInteractionObserver.js +0 -21
  200. package/dist/hooks/usePub.d.ts +0 -0
  201. package/dist/hooks/usePub.js +0 -1
  202. package/dist/hooks/usePubSub.d.ts +0 -3
  203. package/dist/hooks/usePubSub.js +0 -19
  204. package/dist/hooks/useSub.d.ts +0 -3
  205. package/dist/hooks/useSub.js +0 -17
  206. package/dist/hooks/useToast.d.ts +0 -2
  207. package/dist/hooks/useToast.js +0 -10
  208. package/dist/hooks/useWindowFocus.d.ts +0 -2
  209. package/dist/hooks/useWindowFocus.js +0 -11
  210. package/dist/media/edit-ui.d.ts +0 -2
  211. package/dist/media/edit-ui.js +0 -2
  212. package/dist/mixins.css +0 -1
  213. /package/dist/comps/{useBase/base.types.js → Accordion/types.js} +0 -0
@@ -0,0 +1,14 @@
1
+ import { InputProps } from '../Input';
2
+ export type SearchProps = InputProps & {
3
+ onSubmit?: (value: string) => void;
4
+ onChange?: (value: string) => void;
5
+ withStyle?: string;
6
+ };
7
+ declare const Search: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../../types").ZuzProps> & {
8
+ numeric?: boolean;
9
+ } & {
10
+ onSubmit?: (value: string) => void;
11
+ onChange?: (value: string) => void;
12
+ withStyle?: string;
13
+ } & import("react").RefAttributes<HTMLInputElement>>;
14
+ export default Search;
@@ -1,10 +1,11 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useRef, useState } from "react";
3
- import Input from "../input";
4
- import Box from "../box";
5
- import Button from "../button";
6
- import useBase from "../useBase";
7
- import SVGIcons from "../svgicons";
3
+ import { forwardRef, useEffect, useRef, useState } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ import Input from '../Input';
6
+ import Box from '../Box';
7
+ import Button from '../Button';
8
+ import SVGIcons from '../svgicons';
8
9
  const Search = forwardRef((props, ref) => {
9
10
  const { animate, withStyle, onChange, ...pops } = props;
10
11
  const { style } = useBase(pops);
@@ -19,7 +20,7 @@ const Search = forwardRef((props, ref) => {
19
20
  onChange?.(e.target.value);
20
21
  };
21
22
  const handleSubmit = (e) => {
22
- e.preventDefault();
23
+ e?.preventDefault();
23
24
  if (query.trim() !== ``) {
24
25
  setQuery(``);
25
26
  onChange?.(``);
@@ -30,17 +31,6 @@ const Search = forwardRef((props, ref) => {
30
31
  // onSubmit?.(query)
31
32
  };
32
33
  useEffect(() => { }, []);
33
- return _jsxs(Box, { style: style, ...{
34
- className: `--search flex aic rel ${searchStyle}`.trim()
35
- }, children: [_jsx(Input, { ...{
36
- ref: innerRef,
37
- onChange: handleChange,
38
- ...pops
39
- } }), _jsx(Button, { ...{
40
- withLabel: false,
41
- tabIndex: -1,
42
- onClick: handleSubmit,
43
- className: `--send flex aic jcc abs`
44
- }, children: query !== `` ? SVGIcons.Close : SVGIcons.Search })] });
34
+ return _jsxs(Box, { style: style, className: `--search flex aic rel ${searchStyle}`.trim(), children: [_jsx(Input, { ref: innerRef, onChange: handleChange, ...pops }), _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc abs`, children: query !== `` ? SVGIcons.close : SVGIcons.search })] });
45
35
  });
46
36
  export default Search;
@@ -0,0 +1,26 @@
1
+ import { Segment } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ /**
4
+ * `SelectTabs` component is a segmented control that allows switching between segments.
5
+ *
6
+ * @component
7
+ * @param {SegmentProps} props - Props for the segmented control component.
8
+ * @param {React.Ref<HTMLDivElement>} ref - Ref for the root div element.
9
+ * @returns {JSX.Element} The rendered segmented control.
10
+ *
11
+ * @example
12
+ * // Usage example
13
+ * const segments = [
14
+ * { index: 0, label: "Home", icon: "home_icon" },
15
+ * { index: 1, label: "Profile", icon: "profile_icon" },
16
+ * { index: 2, label: "Settings", icon: "settings_icon" }
17
+ * ];
18
+ *
19
+ * <SelectTabs selected={1} items={segments} />
20
+ */
21
+ declare const Segmented: import("react").ForwardRefExoticComponent<BoxProps & {
22
+ selected?: number;
23
+ onSwitch?: (segment: Segment) => void;
24
+ items: Segment[];
25
+ } & import("react").RefAttributes<HTMLDivElement>>;
26
+ export default Segmented;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useRef, useState } from "react";
3
- import useBase from "../useBase";
4
- import Box from "../box";
3
+ import { useBase } from "../../hooks";
4
+ import Box from "../Box";
5
5
  import SegmentItem from "./item";
6
6
  /**
7
7
  * `SelectTabs` component is a segmented control that allows switching between segments.
@@ -45,13 +45,7 @@ const Segmented = forwardRef((props, ref) => {
45
45
  }
46
46
  };
47
47
  useEffect(() => { }, []);
48
- return _jsxs(Box, { ref: _segmented, ...{
49
- className: `${className} --segmented flex aic rel`,
50
- style,
51
- ...rest
52
- }, children: [_jsx(Box, { ref: _tab, ...{
53
- className: `--segment-tab abs`,
54
- } }), items.map((item, i) => _jsx(SegmentItem, { onSelect: handleSelect, selected: _selected == i, meta: {
48
+ return _jsxs(Box, { ref: _segmented, className: `${className} --segmented flex aic rel`, style: style, ...rest, children: [_jsx(Box, { ref: _tab, className: `--segment-tab abs` }), items.map((item, i) => _jsx(SegmentItem, { onSelect: handleSelect, selected: _selected == i, meta: {
55
49
  ...item,
56
50
  index: i
57
51
  } }, `segment-${item.label}-${i}`))] });
@@ -0,0 +1,3 @@
1
+ import { SegmentItemProps } from "./types";
2
+ declare const SegmentItem: ({ onSelect, meta, selected }: SegmentItemProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SegmentItem;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
- import Box from "../box";
4
- import Button from "../button";
3
+ import Button from "../Button";
4
+ import Box from "../Box";
5
5
  const SegmentItem = ({ onSelect, meta, selected }) => {
6
6
  const ref = useRef(null);
7
7
  const { index, icon, label } = meta;
@@ -15,12 +15,6 @@ const SegmentItem = ({ onSelect, meta, selected }) => {
15
15
  onSelect(index, pos.width, pos.x, meta);
16
16
  }
17
17
  }, [ref.current]);
18
- return _jsxs(Button, { onClick: () => onSelect(index, pos.width, pos.x, meta), ref: ref, ...{
19
- className: `--segment-item flex aic rel ${selected ? `--segement-active` : ``}`.trim(),
20
- }, children: [icon && _jsx(Box, { ...{
21
- className: `--segment-icon icon-${icon}`
22
- } }), _jsx(Box, { ...{
23
- className: `--segment-label`
24
- }, children: label || `Item ${index}` })] });
18
+ return _jsxs(Button, { onClick: () => onSelect(index, pos.width, pos.x, meta), ref: ref, className: `--segment-item flex aic rel ${selected ? `--segement-active` : ``}`.trim(), children: [icon && _jsx(Box, { className: `--segment-icon icon-${icon}` }), _jsx(Box, { className: `--segment-label`, children: label || `Item ${index}` })] });
25
19
  };
26
20
  export default SegmentItem;
@@ -0,0 +1,31 @@
1
+ import { BoxProps } from "../Box";
2
+ /**
3
+ * Individual segment in the `SelectTabs` component.
4
+ * @typedef {Object} Segment
5
+ * @property {number} index - The index of the segment.
6
+ * @property {string} [icon] - The optional icon to display for the segment.
7
+ * @property {string} [label] - The optional label to display for the segment.
8
+ */
9
+ export interface Segment {
10
+ tag?: string;
11
+ index: number;
12
+ icon?: string;
13
+ label?: string;
14
+ }
15
+ /**
16
+ * Props for the `SelectTabs` component.
17
+ * @typedef {Object} SegmentProps
18
+ * @extends {Props<'div'>}
19
+ * @property {number} [selected] - The index of the initially selected segment.
20
+ * @property {Segment[]} items - Array of segments to display.
21
+ */
22
+ export type SegmentProps = BoxProps & {
23
+ selected?: number;
24
+ onSwitch?: (segment: Segment) => void;
25
+ items: Segment[];
26
+ };
27
+ export type SegmentItemProps = {
28
+ meta: Segment;
29
+ selected: boolean;
30
+ onSelect: (index: number, width: number, x: number, segment: Segment) => void;
31
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { FORMVALIDATION } from "../../types/enums";
2
+ import { BoxProps } from "../Box";
3
+ import { Option } from "./types";
4
+ declare const Select: import("react").ForwardRefExoticComponent<BoxProps & {
5
+ required?: FORMVALIDATION;
6
+ options: Option[];
7
+ label?: string;
8
+ selected?: string | Option;
9
+ search?: boolean;
10
+ onChange?: (v: Option) => void;
11
+ searchPlaceholder?: string;
12
+ } & import("react").RefAttributes<HTMLDivElement>>;
13
+ export default Select;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
+ import SVGIcons from "../svgicons";
4
+ import { uuid } from "../../funs";
5
+ import Box from "../Box";
6
+ import { useBase } from "../../hooks";
7
+ import Button from "../Button";
8
+ import Text from "../Text";
9
+ import Input from "../Input";
10
+ import OptionItem from "./optionItem";
11
+ const Select = forwardRef((props, ref) => {
12
+ const { selected, options, label, name, search: withSearch, searchPlaceholder, onChange, ...pops } = props;
13
+ const [value, setValue] = useState(selected ?
14
+ typeof selected === `string` ? options.find(fo => fo.value === selected) : selected
15
+ : options[0]);
16
+ const [choosing, setChoosing] = useState(false);
17
+ const [query, setQuery] = useState(null);
18
+ const _ref = useRef(null);
19
+ const _search = useRef(null);
20
+ const _id = useMemo(() => name || uuid(), []);
21
+ const { className, style, rest } = useBase(pops);
22
+ const updateValue = (o) => {
23
+ setValue(o);
24
+ onChange && onChange(o);
25
+ };
26
+ useEffect(() => {
27
+ document.body.addEventListener(`click`, (e) => {
28
+ setChoosing(false);
29
+ });
30
+ }, []);
31
+ useEffect(() => {
32
+ if (choosing) {
33
+ _search.current && _search.current.focus();
34
+ }
35
+ else {
36
+ if (_search.current) {
37
+ _search.current.value = ``;
38
+ }
39
+ setQuery(null);
40
+ }
41
+ }, [choosing]);
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: {
43
+ pointerEvents: choosing ? `auto` : `none`,
44
+ }, animate: {
45
+ from: { y: 5, opacity: 0 },
46
+ to: { y: 0, opacity: 1 },
47
+ when: choosing,
48
+ duration: .05
49
+ }, children: [withSearch && _jsx(Input, { ref: _search, onChange: (e) => {
50
+ setQuery(e.target.value == `` ? null : e.target.value);
51
+ }, className: `--select-search`, placeholder: searchPlaceholder || `Search...` }), (query == null ? options : options.filter((o) => {
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());
57
+ }))
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}`))] })] });
59
+ });
60
+ export default Select;
@@ -0,0 +1,3 @@
1
+ import { OptionItemProps } from "./types";
2
+ declare const OptionItem: ({ value, updateValue, o }: OptionItemProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default OptionItem;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Button from "../Button";
3
+ const OptionItem = ({ value, updateValue, o }) => {
4
+ return _jsx(Button, { onClick: (e) => updateValue(o), className: value && (`string` == typeof o ? o : o.value) == (`string` == typeof value ? value : value.value) ? `selected` : ``, children: `string` == typeof o ? o : o.label });
5
+ };
6
+ export default OptionItem;
@@ -0,0 +1,53 @@
1
+ import { FormEventHandler } from "react";
2
+ import { FORMVALIDATION } from "../../types/enums";
3
+ import { BoxProps } from "../Box";
4
+ /**
5
+ * Represents an option which can be either a string or an OptionObject.
6
+ */
7
+ export type Option = {
8
+ label: string;
9
+ value: string;
10
+ };
11
+ /**
12
+ * Represents an option object with a label and value.
13
+ */
14
+ export type Value = FormEventHandler<HTMLDivElement> & Option;
15
+ export interface OptionItemProps {
16
+ updateValue: (o: Option) => void;
17
+ o: Option;
18
+ value: Option;
19
+ }
20
+ /**
21
+ * Props for the Select component.
22
+ */
23
+ export type SelectProps = BoxProps & {
24
+ /**
25
+ * Indicates if the select field is required and its validation type.
26
+ */
27
+ required?: FORMVALIDATION;
28
+ /**
29
+ * Array of options to be displayed in the select dropdown.
30
+ */
31
+ options: Option[];
32
+ /**
33
+ * Label for the select field.
34
+ */
35
+ label?: string;
36
+ /**
37
+ * The currently selected option.
38
+ */
39
+ selected?: string | Option;
40
+ /**
41
+ * Enables the search functionality within the select dropdown.
42
+ */
43
+ search?: boolean;
44
+ /**
45
+ * Callback function triggered when the selected option changes.
46
+ * @param v - The newly selected option.
47
+ */
48
+ onChange?: (v: Option) => void;
49
+ /**
50
+ * Placeholder text for the search input field.
51
+ */
52
+ searchPlaceholder?: string;
53
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
- import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
3
- import { BaseProps } from "../types/interfaces";
4
- export interface SheetProps {
2
+ import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
3
+ import { ZuzProps } from "../../types";
4
+ export type SheetProps = ZuzProps & {
5
5
  title?: string;
6
6
  message?: string | ReactNode;
7
7
  transition?: TRANSITIONS;
@@ -9,7 +9,7 @@ export interface SheetProps {
9
9
  speed?: Number;
10
10
  type?: SHEET;
11
11
  actionPosition?: SHEET_ACTION_POSITION;
12
- }
12
+ };
13
13
  export interface SheetActionHandler {
14
14
  key?: string;
15
15
  label: string;
@@ -20,7 +20,18 @@ export interface SheetHandler {
20
20
  showDialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
21
21
  dialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
22
22
  show: (message: string | ReactNode, duration?: number, type?: SHEET) => void;
23
+ success: (message: string | ReactNode, duration?: number) => void;
24
+ error: (message: string | ReactNode, duration?: number) => void;
25
+ warn: (message: string | ReactNode, duration?: number) => void;
23
26
  hide: () => void;
24
27
  }
25
- declare const Sheet: import("react").ForwardRefExoticComponent<SheetProps & BaseProps & import("react").RefAttributes<SheetHandler>>;
28
+ declare const Sheet: import("react").ForwardRefExoticComponent<ZuzProps & {
29
+ title?: string;
30
+ message?: string | ReactNode;
31
+ transition?: TRANSITIONS;
32
+ curve?: TRANSITION_CURVES;
33
+ speed?: Number;
34
+ type?: SHEET;
35
+ actionPosition?: SHEET_ACTION_POSITION;
36
+ } & import("react").RefAttributes<SheetHandler>>;
26
37
  export default Sheet;
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
4
+ import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES } from "../../types/enums";
5
+ import Box from "../Box";
6
+ import { useBase } from "../../hooks";
7
+ import { uuid } from "../../funs";
8
+ import { animationTransition } from "../../funs/css";
9
+ import Button from "../Button";
10
+ import Cover from "../Cover";
11
+ import Overlay from "../Overlay";
12
+ let _sheetTimeout = null;
13
+ let _sheetWobbleTimeout = null;
14
+ const Sheet = forwardRef((props, ref) => {
15
+ const { title: _title, message, transition, curve, speed, type, actionPosition, ...pops } = props;
16
+ const { className, style, rest } = useBase(pops);
17
+ const [title, setTitle] = useState(``);
18
+ const [msg, setMsg] = useState(``);
19
+ const [action, setAction] = useState(null);
20
+ const [sheetType, setSheetType] = useState(type || SHEET.Default);
21
+ const sheetID = useMemo(() => uuid(), []);
22
+ const [visible, setVisible] = useState(false);
23
+ const innerRef = useRef(null);
24
+ const lastTransform = useRef(null);
25
+ const [loading, setLoading] = useState(false);
26
+ const [render, setRender] = useState(true);
27
+ const _render = useRef(null);
28
+ useImperativeHandle(ref, () => ({
29
+ setLoading(mode) {
30
+ setLoading(mode);
31
+ },
32
+ showDialog(title, message, action, onShow) {
33
+ if (_sheetTimeout) {
34
+ clearTimeout(_sheetTimeout);
35
+ if (_sheetWobbleTimeout) {
36
+ clearTimeout(_sheetWobbleTimeout);
37
+ }
38
+ innerRef.current.classList.remove(`--wobble`);
39
+ setTimeout(() => innerRef.current.classList.add(`--wobble`), 50);
40
+ _sheetWobbleTimeout = setTimeout(() => {
41
+ innerRef.current.classList.remove(`--wobble`);
42
+ _sheetWobbleTimeout = null;
43
+ }, 500);
44
+ }
45
+ setSheetType(SHEET.Dialog);
46
+ setMsg(message);
47
+ setTitle(title);
48
+ if (action)
49
+ setAction(action.reduce((ar, b) => {
50
+ ar.push({
51
+ ...b,
52
+ key: b.key || uuid()
53
+ });
54
+ return ar;
55
+ }, []));
56
+ setVisible(true);
57
+ setTimeout(() => onShow ? onShow() : () => { }, 1000);
58
+ },
59
+ dialog(title, message, action, onShow) {
60
+ if (_sheetTimeout) {
61
+ clearTimeout(_sheetTimeout);
62
+ if (_sheetWobbleTimeout) {
63
+ clearTimeout(_sheetWobbleTimeout);
64
+ }
65
+ innerRef.current.classList.remove(`--wobble`);
66
+ setTimeout(() => innerRef.current.classList.add(`--wobble`), 50);
67
+ _sheetWobbleTimeout = setTimeout(() => {
68
+ innerRef.current.classList.remove(`--wobble`);
69
+ _sheetWobbleTimeout = null;
70
+ }, 500);
71
+ }
72
+ setSheetType(SHEET.Dialog);
73
+ setMsg(message);
74
+ setTitle(title);
75
+ if (action)
76
+ setAction(action.reduce((ar, b) => {
77
+ ar.push({
78
+ ...b,
79
+ key: b.key || uuid()
80
+ });
81
+ return ar;
82
+ }, []));
83
+ setVisible(true);
84
+ setTimeout(() => onShow ? onShow() : () => { }, 1000);
85
+ },
86
+ error(message, duration) {
87
+ this.show(message, duration, SHEET.Error);
88
+ },
89
+ warn(message, duration) {
90
+ this.show(message, duration, SHEET.Warn);
91
+ },
92
+ success(message, duration) {
93
+ this.show(message, duration, SHEET.Success);
94
+ },
95
+ show(message, duration, type) {
96
+ if (_sheetTimeout) {
97
+ clearTimeout(_sheetTimeout);
98
+ if (_sheetWobbleTimeout) {
99
+ clearTimeout(_sheetWobbleTimeout);
100
+ }
101
+ // if ( lastTransform ) innerRef.current!.style.transform = _lastTransform
102
+ lastTransform.current = innerRef.current.style.transform;
103
+ innerRef.current.style.transform = ``;
104
+ innerRef.current.classList.remove(`--wobble`);
105
+ setTimeout(() => {
106
+ innerRef.current.classList.add(`--wobble`);
107
+ innerRef.current.style.transform = `${lastTransform.current} scale(.9)`.trim();
108
+ }, 50);
109
+ _sheetWobbleTimeout = setTimeout(() => {
110
+ innerRef.current.classList.remove(`--wobble`);
111
+ innerRef.current.style.transform = lastTransform.current || ``;
112
+ _sheetWobbleTimeout = null;
113
+ }, 500);
114
+ }
115
+ _sheetTimeout = setTimeout(() => {
116
+ setVisible(false);
117
+ _sheetTimeout = null;
118
+ _sheetWobbleTimeout = null;
119
+ }, (duration || 4) * 1000);
120
+ setSheetType(type || SHEET.Default);
121
+ setMsg(message);
122
+ setVisible(true);
123
+ },
124
+ hide() {
125
+ setVisible(false);
126
+ }
127
+ }));
128
+ const buildAnimation = useCallback(() => {
129
+ const base = {
130
+ when: visible,
131
+ duration: speed || 0.3,
132
+ delay: 0.1,
133
+ };
134
+ if (sheetType == SHEET.Dialog) {
135
+ if (transition) {
136
+ const { from, to } = animationTransition(transition);
137
+ return {
138
+ from: { ...from, x: `-50%`, y: `-50%` },
139
+ to: { ...to, x: `-50%`, y: `-50%` },
140
+ curve: curve || TRANSITION_CURVES.EaseInOut,
141
+ ...base
142
+ };
143
+ }
144
+ return {
145
+ from: { scale: 0, x: `-50%`, y: `-50%`, opacity: 0 },
146
+ to: { scale: 1, x: `-50%`, y: `-50%`, opacity: 1 },
147
+ curve: TRANSITION_CURVES.Spring,
148
+ ...base
149
+ };
150
+ }
151
+ else {
152
+ return {
153
+ from: { scale: 0, x: `-50%`, y: `-10vh`, opacity: 0 },
154
+ to: { scale: 1, x: `-50%`, y: 0, opacity: 1 },
155
+ curve: TRANSITION_CURVES.Spring,
156
+ ...base
157
+ };
158
+ }
159
+ }, [visible]);
160
+ useEffect(() => {
161
+ if (_render.current)
162
+ clearTimeout(_render.current);
163
+ if (!visible) {
164
+ _render.current = setTimeout(() => setRender(false), 1000);
165
+ }
166
+ else {
167
+ setRender(true);
168
+ }
169
+ }, [visible]);
170
+ if (sheetType == SHEET.Dialog) {
171
+ return _jsxs(_Fragment, { children: [_jsx(Overlay, { when: visible }), _jsxs(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} fixed`.trim(), style: style, animate: buildAnimation(), ...rest, ref: innerRef, children: [_jsx(Cover, { when: loading }), _jsxs(Box, { className: `--head flex aic rel`, children: [_jsx(Box, { className: `--${title ? `title` : `dot`} flex aic rel`, children: title || `` }), _jsx(Button, { onClick: (e) => setVisible(false), className: `--closer abs`, children: "\u00D7" })] }), _jsx(Box, { className: `--body flex aic rel ${action ? `` : `--no-action`}`.trim(), children: render ? msg : null }), action && _jsx(Box, { className: `--footer flex aic rel ${actionPosition ? actionPosition == SHEET_ACTION_POSITION.Center ? `jcc` : `` : `jce`}`.trim(), children: action.map((a, i) => _jsx(Button, { onClick: (e) => a.handler ? a.handler() : a.onClick ? a.onClick() : console.log(`onClick Handler missing`), className: `--action`, children: a.label }, `sheet-${sheetID}-action-${a.key}`)) })] })] });
172
+ }
173
+ return _jsx(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} abs`.trim(), style: style, ...rest, animate: buildAnimation(), ref: innerRef, children: visible ? msg : null });
174
+ });
175
+ export default Sheet;
@@ -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;
@@ -0,0 +1,4 @@
1
+ import { Props } from '../../types';
2
+ export type SpanProps = Props<`span`> & {};
3
+ declare const Span: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, keyof import("../../types").ZuzProps> & import("react").RefAttributes<HTMLSpanElement>>;
4
+ export default Span;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ const Span = forwardRef((props, ref) => {
6
+ const { style, ...pops } = props;
7
+ const { style: _style, className, rest } = useBase(pops);
8
+ return _jsx("span", { ref: ref, style: style, className: className, ...rest });
9
+ });
10
+ export default Span;