@zuzjs/ui 0.5.5 → 0.5.7

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 (194) hide show
  1. package/dist/bin.js +8 -2
  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 +13 -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/{form.d.ts → Form/index.d.ts} +38 -10
  34. package/dist/comps/{form.js → Form/index.js} +64 -25
  35. package/dist/comps/Icon/index.d.ts +11 -0
  36. package/dist/comps/Icon/index.js +11 -0
  37. package/dist/comps/Image/index.d.ts +4 -0
  38. package/dist/comps/Image/index.js +9 -0
  39. package/dist/comps/Input/index.d.ts +8 -0
  40. package/dist/comps/Input/index.js +15 -0
  41. package/dist/comps/Label/index.d.ts +4 -0
  42. package/dist/comps/Label/index.js +9 -0
  43. package/dist/comps/Otp/index.d.ts +4 -0
  44. package/dist/comps/Otp/index.js +30 -0
  45. package/dist/comps/Overlay/index.d.ts +8 -0
  46. package/dist/comps/Overlay/index.js +12 -0
  47. package/dist/comps/Password/index.d.ts +4 -0
  48. package/dist/comps/Password/index.js +18 -0
  49. package/dist/comps/PinInput/index.d.ts +12 -0
  50. package/dist/comps/PinInput/index.js +42 -0
  51. package/dist/comps/ProgressBar/index.d.ts +7 -0
  52. package/dist/comps/ProgressBar/index.js +21 -0
  53. package/dist/comps/ProgressBar/types.d.ts +9 -0
  54. package/dist/comps/ProgressBar/types.js +1 -0
  55. package/dist/comps/Search/index.d.ts +14 -0
  56. package/dist/comps/Search/index.js +36 -0
  57. package/dist/comps/Segmented/index.d.ts +26 -0
  58. package/dist/comps/Segmented/index.js +53 -0
  59. package/dist/comps/Segmented/item.d.ts +3 -0
  60. package/dist/comps/Segmented/item.js +20 -0
  61. package/dist/comps/Segmented/types.d.ts +31 -0
  62. package/dist/comps/Segmented/types.js +1 -0
  63. package/dist/comps/Select/index.d.ts +13 -0
  64. package/dist/comps/Select/index.js +56 -0
  65. package/dist/comps/Select/option.d.ts +2 -0
  66. package/dist/comps/Select/option.js +8 -0
  67. package/dist/comps/Select/optionItem.d.ts +3 -0
  68. package/dist/comps/Select/optionItem.js +6 -0
  69. package/dist/comps/Select/types.d.ts +52 -0
  70. package/dist/comps/Select/types.js +1 -0
  71. package/dist/comps/Sheet/index.d.ts +37 -0
  72. package/dist/comps/Sheet/index.js +175 -0
  73. package/dist/comps/Span/index.d.ts +4 -0
  74. package/dist/comps/Span/index.js +10 -0
  75. package/dist/comps/Spinner/index.d.ts +21 -0
  76. package/dist/comps/Spinner/index.js +31 -0
  77. package/dist/comps/Switch/index.d.ts +7 -0
  78. package/dist/comps/Switch/index.js +8 -0
  79. package/dist/comps/TabView/index.d.ts +9 -0
  80. package/dist/comps/TabView/index.js +41 -0
  81. package/dist/comps/TabView/item.d.ts +0 -0
  82. package/dist/comps/TabView/item.js +1 -0
  83. package/dist/comps/TabView/tab.d.ts +3 -0
  84. package/dist/comps/TabView/tab.js +9 -0
  85. package/dist/comps/{tabview.d.ts → TabView/types.d.ts} +10 -5
  86. package/dist/comps/TabView/types.js +1 -0
  87. package/dist/comps/Text/index.d.ts +11 -0
  88. package/dist/comps/Text/index.js +17 -0
  89. package/dist/comps/TextWheel/index.d.ts +8 -0
  90. package/dist/comps/{textwheel.js → TextWheel/index.js} +9 -9
  91. package/dist/comps/TextWheel/types.d.ts +10 -0
  92. package/dist/comps/TextWheel/types.js +1 -0
  93. package/dist/comps/Treeview/index.d.ts +11 -0
  94. package/dist/comps/{treeview → Treeview}/index.js +3 -3
  95. package/dist/comps/Treeview/item.d.ts +11 -0
  96. package/dist/comps/Treeview/item.js +26 -0
  97. package/dist/comps/{treeview/index.d.ts → Treeview/types.d.ts} +14 -5
  98. package/dist/comps/Treeview/types.js +1 -0
  99. package/dist/comps/index.d.ts +41 -0
  100. package/dist/comps/index.js +41 -0
  101. package/dist/comps/svgicons.d.ts +10 -0
  102. package/dist/comps/svgicons.js +11 -0
  103. package/dist/funs/css.d.ts +3 -1
  104. package/dist/funs/css.js +55 -14
  105. package/dist/funs/events.d.ts +4 -2
  106. package/dist/funs/events.js +7 -7
  107. package/dist/funs/index.d.ts +22 -17
  108. package/dist/funs/index.js +84 -50
  109. package/dist/funs/stylesheet.js +1 -1
  110. package/dist/hooks/index.d.ts +5 -3
  111. package/dist/hooks/index.js +7 -3
  112. package/dist/hooks/useBase.d.ts +8 -0
  113. package/dist/{comps/useBase/index.js → hooks/useBase.js} +23 -6
  114. package/dist/hooks/useContextMenu.d.ts +7 -0
  115. package/dist/hooks/useContextMenu.js +21 -0
  116. package/dist/hooks/useDB.d.ts +25 -0
  117. package/dist/hooks/useDB.js +101 -0
  118. package/dist/hooks/useDrag.d.ts +10 -0
  119. package/dist/hooks/useDrag.js +45 -0
  120. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  121. package/dist/hooks/useIntersectionObserver.js +28 -11
  122. package/dist/index.d.ts +5 -26
  123. package/dist/index.js +5 -26
  124. package/dist/styles.css +1 -1
  125. package/dist/types/index.d.ts +36 -20
  126. package/dist/types/interfaces.d.ts +48 -29
  127. package/package.json +3 -4
  128. package/dist/comps/accordion.d.ts +0 -12
  129. package/dist/comps/accordion.js +0 -13
  130. package/dist/comps/alert.d.ts +0 -15
  131. package/dist/comps/alert.js +0 -15
  132. package/dist/comps/animate.d.ts +0 -6
  133. package/dist/comps/animate.js +0 -8
  134. package/dist/comps/avatar.d.ts +0 -13
  135. package/dist/comps/avatar.js +0 -11
  136. package/dist/comps/base.d.ts +0 -15
  137. package/dist/comps/base.js +0 -68
  138. package/dist/comps/box.d.ts +0 -3
  139. package/dist/comps/box.js +0 -15
  140. package/dist/comps/button.d.ts +0 -6
  141. package/dist/comps/button.js +0 -17
  142. package/dist/comps/checkbox.d.ts +0 -18
  143. package/dist/comps/contextmenu.d.ts +0 -15
  144. package/dist/comps/contextmenu.js +0 -9
  145. package/dist/comps/cover.d.ts +0 -15
  146. package/dist/comps/cover.js +0 -31
  147. package/dist/comps/editor.d.ts +0 -12
  148. package/dist/comps/editor.js +0 -92
  149. package/dist/comps/heading.d.ts +0 -7
  150. package/dist/comps/heading.js +0 -23
  151. package/dist/comps/icon.d.ts +0 -6
  152. package/dist/comps/icon.js +0 -20
  153. package/dist/comps/image.d.ts +0 -13
  154. package/dist/comps/image.js +0 -8
  155. package/dist/comps/input.d.ts +0 -3
  156. package/dist/comps/input.js +0 -9
  157. package/dist/comps/password.d.ts +0 -3
  158. package/dist/comps/password.js +0 -30
  159. package/dist/comps/progressbar.d.ts +0 -11
  160. package/dist/comps/progressbar.js +0 -14
  161. package/dist/comps/select.d.ts +0 -19
  162. package/dist/comps/select.js +0 -56
  163. package/dist/comps/sheet.d.ts +0 -25
  164. package/dist/comps/sheet.js +0 -202
  165. package/dist/comps/spinner.d.ts +0 -16
  166. package/dist/comps/spinner.js +0 -42
  167. package/dist/comps/tabview.js +0 -64
  168. package/dist/comps/textwheel.d.ts +0 -15
  169. package/dist/comps/treeview/item.d.ts +0 -15
  170. package/dist/comps/treeview/item.js +0 -23
  171. package/dist/comps/useBase/base.types.d.ts +0 -64
  172. package/dist/comps/useBase/index.d.ts +0 -10
  173. package/dist/funs/lexer.d.ts +0 -3
  174. package/dist/funs/lexer.js +0 -37
  175. package/dist/hooks/useCompEditor.d.ts +0 -2
  176. package/dist/hooks/useCompEditor.js +0 -5
  177. package/dist/hooks/useInteractionObserver.d.ts +0 -8
  178. package/dist/hooks/useInteractionObserver.js +0 -21
  179. package/dist/hooks/usePubSub.d.ts +0 -3
  180. package/dist/hooks/usePubSub.js +0 -19
  181. package/dist/hooks/useSub.d.ts +0 -3
  182. package/dist/hooks/useSub.js +0 -17
  183. package/dist/hooks/useToast.d.ts +0 -2
  184. package/dist/hooks/useToast.js +0 -10
  185. package/dist/hooks/useWindowFocus.d.ts +0 -2
  186. package/dist/hooks/useWindowFocus.js +0 -11
  187. package/dist/media/edit-ui.d.ts +0 -2
  188. package/dist/media/edit-ui.js +0 -2
  189. package/dist/mixins.css +0 -1
  190. /package/dist/comps/{dialog.d.ts → Accordion/item.d.ts} +0 -0
  191. /package/dist/comps/{dialog.js → Accordion/item.js} +0 -0
  192. /package/dist/comps/{useBase/base.types.js → Accordion/types.js} +0 -0
  193. /package/dist/{hooks/usePub.d.ts → comps/TabView/head.d.ts} +0 -0
  194. /package/dist/{hooks/usePub.js → comps/TabView/head.js} +0 -0
@@ -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?: Option;
9
+ search?: boolean;
10
+ onChange?: (v: Option) => void;
11
+ searchPlaceholder?: string;
12
+ } & import("react").RefAttributes<HTMLDivElement>>;
13
+ export default Select;
@@ -0,0 +1,56 @@
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 || options[0]);
14
+ const [choosing, setChoosing] = useState(false);
15
+ const [query, setQuery] = useState(null);
16
+ const _ref = useRef(null);
17
+ const _search = useRef(null);
18
+ const _id = useMemo(() => name || uuid(), []);
19
+ const { className, style, rest } = useBase(pops);
20
+ const updateValue = (o) => {
21
+ setValue(o);
22
+ onChange && onChange(o);
23
+ };
24
+ useEffect(() => {
25
+ document.body.addEventListener(`click`, (e) => {
26
+ setChoosing(false);
27
+ });
28
+ }, []);
29
+ useEffect(() => {
30
+ if (choosing) {
31
+ _search.current && _search.current.focus();
32
+ }
33
+ else {
34
+ if (_search.current) {
35
+ _search.current.value = ``;
36
+ }
37
+ setQuery(null);
38
+ }
39
+ }, [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: {
41
+ pointerEvents: choosing ? `auto` : `none`,
42
+ }, animate: {
43
+ from: { y: 5, opacity: 0 },
44
+ to: { y: 0, opacity: 1 },
45
+ when: choosing,
46
+ duration: .05
47
+ }, children: [withSearch && _jsx(Input, { ref: _search, onChange: (e) => {
48
+ setQuery(e.target.value == `` ? null : e.target.value);
49
+ }, 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());
53
+ }))
54
+ .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
+ });
56
+ export default Select;
@@ -0,0 +1,2 @@
1
+ declare const Option: (props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default Option;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const Option = props => {
3
+ return _jsx(Button, { ...{
4
+ onClick: (e) => updateValue(o),
5
+ className: value && (`string` == typeof o ? o : o.value) == (`string` == typeof value ? value : value.value) ? `selected` : ``,
6
+ }, children: `string` == typeof o ? o : o.label }, `option-${(`string` == typeof o ? o : o.label).replace(/\s+/g, `-`)}-${`string` == typeof o ? o : o.value}`);
7
+ };
8
+ export default Option;
@@ -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,52 @@
1
+ import { FORMVALIDATION } from "../../types/enums";
2
+ import { BoxProps } from "../Box";
3
+ /**
4
+ * Represents an option object with a label and value.
5
+ */
6
+ export interface OptionObject {
7
+ label: string;
8
+ value: string;
9
+ }
10
+ export interface OptionItemProps {
11
+ updateValue: (o: Option) => void;
12
+ o: Option;
13
+ value: Option;
14
+ }
15
+ /**
16
+ * Represents an option which can be either a string or an OptionObject.
17
+ */
18
+ export type Option = string | OptionObject;
19
+ /**
20
+ * Props for the Select component.
21
+ */
22
+ export type SelectProps = BoxProps & {
23
+ /**
24
+ * Indicates if the select field is required and its validation type.
25
+ */
26
+ required?: FORMVALIDATION;
27
+ /**
28
+ * Array of options to be displayed in the select dropdown.
29
+ */
30
+ options: Option[];
31
+ /**
32
+ * Label for the select field.
33
+ */
34
+ label?: string;
35
+ /**
36
+ * The currently selected option.
37
+ */
38
+ selected?: Option;
39
+ /**
40
+ * Enables the search functionality within the select dropdown.
41
+ */
42
+ search?: boolean;
43
+ /**
44
+ * Callback function triggered when the selected option changes.
45
+ * @param v - The newly selected option.
46
+ */
47
+ onChange?: (v: Option) => void;
48
+ /**
49
+ * Placeholder text for the search input field.
50
+ */
51
+ searchPlaceholder?: string;
52
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from "react";
2
+ import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
3
+ import { ZuzProps } from "../../types";
4
+ export type SheetProps = ZuzProps & {
5
+ title?: string;
6
+ message?: string | ReactNode;
7
+ transition?: TRANSITIONS;
8
+ curve?: TRANSITION_CURVES;
9
+ speed?: Number;
10
+ type?: SHEET;
11
+ actionPosition?: SHEET_ACTION_POSITION;
12
+ };
13
+ export interface SheetActionHandler {
14
+ key?: string;
15
+ label: string;
16
+ handler?: () => void;
17
+ onClick?: () => void;
18
+ }
19
+ export interface SheetHandler {
20
+ showDialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
21
+ dialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
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;
26
+ hide: () => void;
27
+ }
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>>;
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,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;
@@ -0,0 +1,21 @@
1
+ import { BoxProps } from "../Box";
2
+ import { SPINNER } from "../../types/enums";
3
+ export type SpinnerProps = BoxProps & {
4
+ type?: SPINNER;
5
+ size?: number;
6
+ width?: number;
7
+ color?: string;
8
+ background?: string;
9
+ foreground?: string;
10
+ speed?: number;
11
+ };
12
+ declare const Spinner: import("react").ForwardRefExoticComponent<BoxProps & {
13
+ type?: SPINNER;
14
+ size?: number;
15
+ width?: number;
16
+ color?: string;
17
+ background?: string;
18
+ foreground?: string;
19
+ speed?: number;
20
+ } & import("react").RefAttributes<HTMLDivElement>>;
21
+ export default Spinner;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import Box from "../Box";
5
+ import { SPINNER } from "../../types/enums";
6
+ import { useBase } from "../../hooks";
7
+ import { hexToRgba } from "../../funs";
8
+ const Spinner = forwardRef((props, ref) => {
9
+ const { type, size, width, speed, color, background, foreground, ...pops } = props;
10
+ const defaultColor = `#000000`;
11
+ const { className, style, rest } = useBase(pops);
12
+ const build = () => {
13
+ const c = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor);
14
+ const bg = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor, .3);
15
+ const _props = {
16
+ width: size || 30,
17
+ height: size || 30,
18
+ border: `${width || 3}px solid ${bg}`,
19
+ borderRadius: `50%`,
20
+ borderTopColor: c,
21
+ animationDuration: `${speed || .6}s`,
22
+ animationTimingFunction: `linear`
23
+ };
24
+ return _props;
25
+ };
26
+ return _jsx(Box, { className: `${className} --spinner --${(type || SPINNER.Simple).toLowerCase()}`.trim(), style: {
27
+ ...style,
28
+ ...build()
29
+ }, ...rest });
30
+ });
31
+ export default Spinner;
@@ -0,0 +1,7 @@
1
+ import { CheckboxHandler } from "../CheckBox/types";
2
+ import { CHECKBOX } from "../../types/enums";
3
+ declare const Switch: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
4
+ type?: CHECKBOX;
5
+ onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
6
+ } & import("react").RefAttributes<CheckboxHandler>>;
7
+ export default Switch;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import CheckBox from "../CheckBox";
4
+ import { CHECKBOX } from "../../types/enums";
5
+ const Switch = forwardRef((props, ref) => {
6
+ return _jsx(CheckBox, { type: CHECKBOX.Switch, ...props, ref: ref });
7
+ });
8
+ export default Switch;
@@ -0,0 +1,9 @@
1
+ import { Tab, TabViewHandler } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ declare const TabView: import("react").ForwardRefExoticComponent<BoxProps & {
4
+ onChange?: (tab: Tab, index: number) => void;
5
+ speed?: number;
6
+ tabs: Tab[];
7
+ prerender?: boolean;
8
+ } & import("react").RefAttributes<TabViewHandler>>;
9
+ export default TabView;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
+ import { uuid } from "../../funs";
4
+ import { useResizeObserver } from "../../hooks";
5
+ import Box from "../Box";
6
+ import TabItem from "./tab";
7
+ const TabView = forwardRef((props, ref) => {
8
+ const { as, tabs: _tabs, speed, prerender, onChange, ...rest } = props;
9
+ const tabs = useMemo(() => _tabs.reduce((ts, t) => {
10
+ ts.push({
11
+ ...t,
12
+ key: t.key || uuid()
13
+ });
14
+ return ts;
15
+ }, []), [_tabs]);
16
+ const tabview = useRef(null);
17
+ const tabViewID = useMemo(() => uuid(), []);
18
+ const [activeTab, setActiveTab] = useState(0);
19
+ const size = useResizeObserver(tabview);
20
+ const render = useMemo(() => prerender == undefined || prerender == true ? true : false, []);
21
+ const handleTabClick = (index) => {
22
+ setActiveTab(index);
23
+ };
24
+ useEffect(() => {
25
+ onChange && onChange(tabs[0], 0);
26
+ }, []);
27
+ return _jsxs(Box, { ref: tabview, className: `--tabview flex cols`, children: [_jsx(Box, { className: `--head flex aic`, children: tabs.map((tab, index) => _jsx(TabItem, { tab: tab, index: index, activeTab: activeTab, onClick: idx => {
28
+ handleTabClick(idx);
29
+ tab.onSelect && tab.onSelect(tab, idx);
30
+ onChange && onChange(tab, idx);
31
+ } }, `tab-${tabViewID}-${tab.key || index}`)) }), _jsx(Box, { className: `--body rel`, children: _jsx(Box, { className: `--track flex aic`, style: {
32
+ transition: `all ${speed || 0.3}s ease-in-out 0s`, transform: `translate(-${activeTab * size.width}px, 0)`
33
+ }, children: tabs.map((tab, index) => _jsx(Box, { style: {
34
+ width: size.width,
35
+ minWidth: size.width,
36
+ maxWidth: size.width,
37
+ opacity: index === activeTab ? 1 : 0,
38
+ transition: 'opacity 0.5s ease',
39
+ }, className: `--content`, children: (render || activeTab == index) && tab.body })) }) })] });
40
+ });
41
+ export default TabView;
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ import { TabProps } from "./types";
2
+ declare const TabItem: ({ tab, index, activeTab, onClick }: TabProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default TabItem;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Button from "../Button";
3
+ import Icon from "../Icon";
4
+ import Text from "../Text";
5
+ const TabItem = ({ tab, index, activeTab, onClick }) => {
6
+ const { icon, label } = tab;
7
+ return _jsxs(Button, { onClick: e => onClick(index), className: `--tab jcc ${index === activeTab ? '--active' : ''}`.trim(), children: [icon && (typeof icon === 'string' ? _jsx(Icon, { className: `--icon`, name: icon }) : icon), _jsx(Text, { className: `--label rel`, children: label })] });
8
+ };
9
+ export default TabItem;
@@ -1,21 +1,26 @@
1
1
  import { ReactNode } from "react";
2
- import { BaseProps } from "../types/interfaces";
2
+ import { BoxProps } from "../Box";
3
3
  export interface Tab {
4
4
  onSelect: (tab: Tab, index: number) => void;
5
5
  tag?: string;
6
6
  key?: string;
7
+ icon?: string | ReactNode | ReactNode[];
7
8
  label: string | ReactNode | ReactNode[];
8
9
  body: string | ReactNode | ReactNode[];
9
10
  render?: boolean;
10
11
  }
11
- export interface TabViewProps {
12
+ export type TabProps = {
13
+ tab: Tab;
14
+ index: number;
15
+ activeTab: number;
16
+ onClick: (index: number) => void;
17
+ };
18
+ export type TabViewProps = BoxProps & {
12
19
  onChange?: (tab: Tab, index: number) => void;
13
20
  speed?: number;
14
21
  tabs: Tab[];
15
22
  prerender?: boolean;
16
- }
23
+ };
17
24
  export interface TabViewHandler {
18
25
  setTab: (index: number) => void;
19
26
  }
20
- declare const TabView: import("react").ForwardRefExoticComponent<TabViewProps & BaseProps & import("react").RefAttributes<TabViewHandler>>;
21
- export default TabView;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { Props } from '../../types';
3
+ export type TextProps = Props<`h1` | `h2` | `h3` | `h4` | `h5` | `h6`> & {
4
+ h?: number;
5
+ html?: ReactNode | string;
6
+ };
7
+ declare const Text: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, keyof import("../../types").ZuzProps> & {
8
+ h?: number;
9
+ html?: ReactNode | string;
10
+ } & import("react").RefAttributes<HTMLHeadingElement>>;
11
+ export default Text;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createElement, forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ import Span from '../Span';
6
+ const Text = forwardRef((props, ref) => {
7
+ const { h, html, children, ...pops } = props;
8
+ const { style, className, rest } = useBase(pops);
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);
16
+ });
17
+ export default Text;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { TextWheelHandler } from './types';
3
+ declare const TextWheel: React.ForwardRefExoticComponent<Omit<import("../Box").BoxProps, "name"> & {
4
+ value?: number | string;
5
+ color?: string;
6
+ direction?: `up` | `down`;
7
+ } & React.RefAttributes<TextWheelHandler>>;
8
+ export default TextWheel;
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { forwardRef } from 'react';
4
- import With from "./base";
4
+ import Box from '../Box';
5
+ import Span from '../Span';
5
6
  const TextWheel = forwardRef((props, ref) => {
6
7
  const { as, value, color, direction, ...rest } = props;
7
8
  const divRef = useRef(null);
8
9
  const [_value, _setValue] = useState(value || 0);
9
10
  useImperativeHandle(ref, () => ({
10
11
  updateValue(v) {
11
- // console.log(_value != v, _value.toString().length != v.toString().length)
12
12
  if (_value.toString().length != v.toString().length) {
13
13
  _setValue(v);
14
14
  }
@@ -34,18 +34,18 @@ const TextWheel = forwardRef((props, ref) => {
34
34
  // console.log(value)
35
35
  _setValue(value || 0);
36
36
  }, [value]);
37
- return _jsxs(With, { className: `text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
37
+ return _jsxs(Box, { className: `text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
38
38
  if (isNaN(parseInt(char, 10))) {
39
- return _jsx(With, { tag: `span`, className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
39
+ return _jsx(Span, { className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
40
40
  }
41
- return _jsx(With, { tag: `span`, "data-value": char, className: `wheel-char grid ${index > char.toString().split('').length - 3 ? 'wheel-fraction' : ''}`.trim(), children: _jsxs(With, { tag: `span`, className: `wheel-char-track wheel-track-${direction || `down`} grid`, style: {
41
+ return _jsx(Span, { "data-value": char, className: `wheel-char grid ${index > char.toString().split('').length - 3 ? 'wheel-fraction' : ''}`.trim(), children: _jsxs(Span, { className: `wheel-char-track wheel-track-${direction || `down`} grid`, style: {
42
42
  '--v': char
43
- }, children: [_jsx(With, { tag: `span`, children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
43
+ }, children: [_jsx(Span, { children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
44
44
  [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
45
45
  : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).map((val, indx) => {
46
- return _jsx(With, { tag: `span`, children: val }, `${index}--${indx}`);
47
- }), _jsx(With, { tag: `span`, children: !direction || direction == `down` ? 9 : 0 })] }) }, `wheel-char-${index}`);
48
- }), color && _jsx(With, { className: `abs fillx`, style: {
46
+ return _jsx(Span, { children: val }, `${index}--${indx}`);
47
+ }), _jsx(Span, { children: !direction || direction == `down` ? 9 : 0 })] }) }, `wheel-char-${index}`);
48
+ }), color && _jsx(Box, { className: `abs fillx`, style: {
49
49
  zIndex: 1,
50
50
  background: `linear-gradient(0deg, ${color}, transparent, transparent, transparent, ${color})`,
51
51
  } })] });