@zuzjs/ui 0.5.6 → 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 (190) hide show
  1. package/dist/comps/Accordion/index.d.ts +6 -0
  2. package/dist/comps/Accordion/index.js +12 -0
  3. package/dist/comps/Accordion/types.d.ts +10 -0
  4. package/dist/comps/Actionbar/index.d.ts +21 -0
  5. package/dist/comps/Actionbar/index.js +58 -0
  6. package/dist/comps/Actionbar/item.d.ts +6 -0
  7. package/dist/comps/Actionbar/item.js +7 -0
  8. package/dist/comps/Actionbar/types.d.ts +29 -0
  9. package/dist/comps/Actionbar/types.js +1 -0
  10. package/dist/comps/Avatar/index.d.ts +19 -0
  11. package/dist/comps/Avatar/index.js +35 -0
  12. package/dist/comps/Box/index.d.ts +7 -0
  13. package/dist/comps/{box.js → Box/index.js} +3 -2
  14. package/dist/comps/Button/index.d.ts +10 -0
  15. package/dist/comps/Button/index.js +12 -0
  16. package/dist/comps/CheckBox/index.d.ts +7 -0
  17. package/dist/comps/{checkbox.js → CheckBox/index.js} +10 -9
  18. package/dist/comps/CheckBox/types.d.ts +10 -0
  19. package/dist/comps/CheckBox/types.js +1 -0
  20. package/dist/comps/ContextMenu/index.d.ts +6 -0
  21. package/dist/comps/ContextMenu/index.js +37 -0
  22. package/dist/comps/ContextMenu/item.d.ts +3 -0
  23. package/dist/comps/ContextMenu/item.js +11 -0
  24. package/dist/comps/ContextMenu/types.d.ts +20 -0
  25. package/dist/comps/ContextMenu/types.js +1 -0
  26. package/dist/comps/Cover/index.d.ts +17 -0
  27. package/dist/comps/Cover/index.js +19 -0
  28. package/dist/comps/Drawer/index.d.ts +12 -0
  29. package/dist/comps/{drawer.js → Drawer/index.js} +8 -10
  30. package/dist/comps/{drawer.d.ts → Drawer/types.d.ts} +4 -5
  31. package/dist/comps/Drawer/types.js +1 -0
  32. package/dist/comps/{form.d.ts → Form/index.d.ts} +34 -10
  33. package/dist/comps/{form.js → Form/index.js} +11 -15
  34. package/dist/comps/Icon/index.d.ts +11 -0
  35. package/dist/comps/Icon/index.js +11 -0
  36. package/dist/comps/Image/index.d.ts +4 -0
  37. package/dist/comps/Image/index.js +9 -0
  38. package/dist/comps/Input/index.d.ts +8 -0
  39. package/dist/comps/Input/index.js +15 -0
  40. package/dist/comps/Label/index.d.ts +4 -0
  41. package/dist/comps/Label/index.js +9 -0
  42. package/dist/comps/Otp/index.d.ts +4 -0
  43. package/dist/comps/Otp/index.js +30 -0
  44. package/dist/comps/Overlay/index.d.ts +8 -0
  45. package/dist/comps/Overlay/index.js +12 -0
  46. package/dist/comps/Password/index.d.ts +4 -0
  47. package/dist/comps/Password/index.js +18 -0
  48. package/dist/comps/PinInput/index.d.ts +12 -0
  49. package/dist/comps/{otp → PinInput}/index.js +10 -18
  50. package/dist/comps/ProgressBar/index.d.ts +7 -0
  51. package/dist/comps/ProgressBar/index.js +21 -0
  52. package/dist/comps/ProgressBar/types.d.ts +9 -0
  53. package/dist/comps/ProgressBar/types.js +1 -0
  54. package/dist/comps/Search/index.d.ts +14 -0
  55. package/dist/comps/{search → Search}/index.js +9 -19
  56. package/dist/comps/Segmented/index.d.ts +26 -0
  57. package/dist/comps/{segmented → Segmented}/index.js +3 -9
  58. package/dist/comps/Segmented/item.d.ts +3 -0
  59. package/dist/comps/{segmented → Segmented}/item.js +3 -9
  60. package/dist/comps/Segmented/types.d.ts +31 -0
  61. package/dist/comps/Segmented/types.js +1 -0
  62. package/dist/comps/Select/index.d.ts +13 -0
  63. package/dist/comps/Select/index.js +56 -0
  64. package/dist/comps/Select/option.d.ts +2 -0
  65. package/dist/comps/Select/option.js +8 -0
  66. package/dist/comps/Select/optionItem.d.ts +3 -0
  67. package/dist/comps/Select/optionItem.js +6 -0
  68. package/dist/comps/Select/types.d.ts +52 -0
  69. package/dist/comps/Select/types.js +1 -0
  70. package/dist/comps/{sheet.d.ts → Sheet/index.d.ts} +16 -5
  71. package/dist/comps/Sheet/index.js +175 -0
  72. package/dist/comps/Span/index.d.ts +4 -0
  73. package/dist/comps/Span/index.js +10 -0
  74. package/dist/comps/Spinner/index.d.ts +21 -0
  75. package/dist/comps/Spinner/index.js +31 -0
  76. package/dist/comps/Switch/index.d.ts +7 -0
  77. package/dist/comps/Switch/index.js +8 -0
  78. package/dist/comps/TabView/index.d.ts +9 -0
  79. package/dist/comps/TabView/index.js +41 -0
  80. package/dist/comps/TabView/tab.d.ts +3 -0
  81. package/dist/comps/TabView/tab.js +9 -0
  82. package/dist/comps/{tabview.d.ts → TabView/types.d.ts} +10 -5
  83. package/dist/comps/TabView/types.js +1 -0
  84. package/dist/comps/Text/index.d.ts +11 -0
  85. package/dist/comps/Text/index.js +17 -0
  86. package/dist/comps/TextWheel/index.d.ts +8 -0
  87. package/dist/comps/{textwheel.js → TextWheel/index.js} +9 -9
  88. package/dist/comps/TextWheel/types.d.ts +10 -0
  89. package/dist/comps/TextWheel/types.js +1 -0
  90. package/dist/comps/Treeview/index.d.ts +11 -0
  91. package/dist/comps/{treeview → Treeview}/index.js +3 -3
  92. package/dist/comps/Treeview/item.d.ts +11 -0
  93. package/dist/comps/Treeview/item.js +26 -0
  94. package/dist/comps/{treeview/index.d.ts → Treeview/types.d.ts} +14 -5
  95. package/dist/comps/Treeview/types.js +1 -0
  96. package/dist/comps/index.d.ts +41 -0
  97. package/dist/comps/index.js +41 -0
  98. package/dist/comps/svgicons.d.ts +9 -2
  99. package/dist/comps/svgicons.js +8 -5
  100. package/dist/funs/index.d.ts +17 -17
  101. package/dist/funs/index.js +69 -69
  102. package/dist/hooks/index.d.ts +4 -3
  103. package/dist/hooks/index.js +6 -3
  104. package/dist/hooks/useBase.d.ts +8 -0
  105. package/dist/{comps/useBase/index.js → hooks/useBase.js} +23 -6
  106. package/dist/hooks/useContextMenu.d.ts +7 -0
  107. package/dist/hooks/useContextMenu.js +21 -0
  108. package/dist/hooks/useDrag.d.ts +10 -0
  109. package/dist/hooks/useDrag.js +45 -0
  110. package/dist/index.d.ts +5 -31
  111. package/dist/index.js +5 -32
  112. package/dist/styles.css +1 -1
  113. package/dist/types/index.d.ts +36 -20
  114. package/dist/types/interfaces.d.ts +45 -51
  115. package/package.json +3 -4
  116. package/dist/comps/accordion.d.ts +0 -12
  117. package/dist/comps/accordion.js +0 -10
  118. package/dist/comps/alert.d.ts +0 -15
  119. package/dist/comps/alert.js +0 -15
  120. package/dist/comps/animate.d.ts +0 -6
  121. package/dist/comps/animate.js +0 -8
  122. package/dist/comps/avatar.d.ts +0 -13
  123. package/dist/comps/avatar.js +0 -11
  124. package/dist/comps/base.d.ts +0 -15
  125. package/dist/comps/base.js +0 -68
  126. package/dist/comps/box.d.ts +0 -6
  127. package/dist/comps/button.d.ts +0 -7
  128. package/dist/comps/button.js +0 -19
  129. package/dist/comps/checkbox.d.ts +0 -18
  130. package/dist/comps/contextmenu.d.ts +0 -15
  131. package/dist/comps/contextmenu.js +0 -9
  132. package/dist/comps/cover.d.ts +0 -15
  133. package/dist/comps/cover.js +0 -31
  134. package/dist/comps/editor.d.ts +0 -12
  135. package/dist/comps/editor.js +0 -92
  136. package/dist/comps/grid/index.d.ts +0 -10
  137. package/dist/comps/grid/index.js +0 -16
  138. package/dist/comps/heading.d.ts +0 -8
  139. package/dist/comps/heading.js +0 -16
  140. package/dist/comps/icon.d.ts +0 -7
  141. package/dist/comps/icon.js +0 -23
  142. package/dist/comps/image.d.ts +0 -13
  143. package/dist/comps/image.js +0 -8
  144. package/dist/comps/input.d.ts +0 -6
  145. package/dist/comps/input.js +0 -19
  146. package/dist/comps/otp/index.d.ts +0 -6
  147. package/dist/comps/password.d.ts +0 -3
  148. package/dist/comps/password.js +0 -30
  149. package/dist/comps/progressbar.d.ts +0 -11
  150. package/dist/comps/progressbar.js +0 -14
  151. package/dist/comps/search/index.d.ts +0 -7
  152. package/dist/comps/segmented/index.d.ts +0 -46
  153. package/dist/comps/segmented/item.d.ts +0 -8
  154. package/dist/comps/select/index.d.ts +0 -15
  155. package/dist/comps/select/index.js +0 -79
  156. package/dist/comps/sheet.js +0 -229
  157. package/dist/comps/span.d.ts +0 -6
  158. package/dist/comps/span.js +0 -12
  159. package/dist/comps/spinner.d.ts +0 -16
  160. package/dist/comps/spinner.js +0 -42
  161. package/dist/comps/tabview.js +0 -64
  162. package/dist/comps/textwheel.d.ts +0 -15
  163. package/dist/comps/treeview/item.d.ts +0 -15
  164. package/dist/comps/treeview/item.js +0 -23
  165. package/dist/comps/useBase/base.types.d.ts +0 -80
  166. package/dist/comps/useBase/index.d.ts +0 -10
  167. package/dist/funs/lexer.d.ts +0 -3
  168. package/dist/funs/lexer.js +0 -37
  169. package/dist/hooks/useCompEditor.d.ts +0 -2
  170. package/dist/hooks/useCompEditor.js +0 -5
  171. package/dist/hooks/useInteractionObserver.d.ts +0 -8
  172. package/dist/hooks/useInteractionObserver.js +0 -21
  173. package/dist/hooks/usePubSub.d.ts +0 -3
  174. package/dist/hooks/usePubSub.js +0 -19
  175. package/dist/hooks/useSub.d.ts +0 -3
  176. package/dist/hooks/useSub.js +0 -17
  177. package/dist/hooks/useToast.d.ts +0 -2
  178. package/dist/hooks/useToast.js +0 -10
  179. package/dist/hooks/useWindowFocus.d.ts +0 -2
  180. package/dist/hooks/useWindowFocus.js +0 -11
  181. package/dist/media/edit-ui.d.ts +0 -2
  182. package/dist/media/edit-ui.js +0 -2
  183. package/dist/mixins.css +0 -1
  184. /package/dist/comps/{dialog.d.ts → Accordion/item.d.ts} +0 -0
  185. /package/dist/comps/{dialog.js → Accordion/item.js} +0 -0
  186. /package/dist/comps/{useBase/base.types.js → Accordion/types.js} +0 -0
  187. /package/dist/comps/{select/select.d.ts → TabView/head.d.ts} +0 -0
  188. /package/dist/comps/{select/select.js → TabView/head.js} +0 -0
  189. /package/dist/{hooks/usePub.d.ts → comps/TabView/item.d.ts} +0 -0
  190. /package/dist/{hooks/usePub.js → comps/TabView/item.js} +0 -0
@@ -1,11 +1,12 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { forwardRef, startTransition, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
3
- import Box from "./box";
4
- import useBase from "./useBase";
5
- import Sheet from "./sheet";
6
- import Cover from "./cover";
7
- import { FORMVALIDATION, SHEET } from "../types/enums";
8
- import { isEmail, withPost } from "../funs";
4
+ import Box from "../Box";
5
+ import { useBase } from "../../hooks";
6
+ import Sheet from "../Sheet";
7
+ import Cover from "../Cover";
8
+ import { FORMVALIDATION, SHEET } from "../../types/enums";
9
+ import { isEmail, withPost } from "../../funs";
9
10
  /**
10
11
  * {@link Form} is a controlled component designed to handle form data submission, validation, and display of loading or error states.
11
12
  * It allows for optional server-side submission through an action endpoint and customizable success/error handling callbacks.
@@ -19,8 +20,8 @@ const Form = forwardRef((props, ref) => {
19
20
  const { name, cover, spinner, errors, action, children, withData, beforeSubmit, onSubmit, onError, onSuccess, ...pops } = props;
20
21
  const { className, style, rest } = useBase(pops);
21
22
  const [loading, setLoading] = useState(false);
22
- const sheet = useRef(null);
23
23
  const innerRef = useRef(null);
24
+ const sheet = useRef(null);
24
25
  /**
25
26
  * Utility function to select multiple DOM elements within the form based on a CSS query.
26
27
  * @param query - CSS selector to match elements inside the form.
@@ -187,7 +188,7 @@ const Form = forwardRef((props, ref) => {
187
188
  onSuccess(resp);
188
189
  else {
189
190
  sheet.current.hide();
190
- sheet.current.show(resp.message || `Redirecting..`, 4, SHEET.Success);
191
+ sheet.current.success(resp.message || `Redirecting..`);
191
192
  }
192
193
  })
193
194
  .catch(err => {
@@ -226,7 +227,7 @@ const Form = forwardRef((props, ref) => {
226
227
  setLoading(mod);
227
228
  },
228
229
  showError(errorMsg) {
229
- sheet.current.show(errorMsg, 4, SHEET.Error);
230
+ sheet.current.error(errorMsg, 4);
230
231
  },
231
232
  hideError() {
232
233
  sheet.current.hide();
@@ -236,11 +237,6 @@ const Form = forwardRef((props, ref) => {
236
237
  }
237
238
  }));
238
239
  useEffect(_init, []);
239
- return _jsxs(Box, { ...{
240
- className: `${className} rel --form${name ? `-${name.replace(/\s+/g, `-`)}` : ``}`,
241
- style,
242
- propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`],
243
- ...rest
244
- }, ref: innerRef, children: [_jsx(Sheet, { ref: sheet, as: `toast-form` }), loading && _jsx(Cover, { message: cover ? cover.message || undefined : `working`, ...{ spinner, color: cover ? `color` in cover ? cover.color : `#ffffff` : `#ffffff` } }), children] });
240
+ return _jsxs(Box, { ref: innerRef, style: style, className: `--form rel ${className} --form${name ? `-${name.replace(/\s+/g, `-`)}` : ``}`, propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`], children: [_jsx(Sheet, { ref: sheet, as: `--sheet-form` }), _jsx(Cover, { message: cover ? cover.message || undefined : `working`, spinner: spinner, color: cover ? `color` in cover ? cover.color : `#ffffff` : `#ffffff`, when: loading }), children] });
245
241
  });
246
242
  export default Form;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ import { BoxProps } from "../Box";
3
+ export type IconProps = Omit<BoxProps, `name`> & {
4
+ name: string | ReactNode;
5
+ pathCount?: number;
6
+ };
7
+ declare const Icon: import("react").ForwardRefExoticComponent<Omit<BoxProps, "name"> & {
8
+ name: string | ReactNode;
9
+ pathCount?: number;
10
+ } & import("react").RefAttributes<HTMLDivElement>>;
11
+ export default Icon;
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import { useBase } from "../../hooks";
5
+ import Span from "../Span";
6
+ const Icon = forwardRef((props, ref) => {
7
+ const { name, pathCount, ...pops } = props;
8
+ const { className, style, rest } = useBase(pops);
9
+ return _jsx("div", { style: style, className: `icon-${name} ${className}`.trim(), ref: ref, ...rest, children: Array(pathCount || 0).fill(0).map((p, i) => _jsx(Span, { className: `path${i + 1}` }, `${name}-layer-${i}`)) });
10
+ });
11
+ export default Icon;
@@ -0,0 +1,4 @@
1
+ import { Props } from '../../types';
2
+ export type ImageProps = Props<`img`> & {};
3
+ declare const Image: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref">, keyof import("../../types").ZuzProps> & import("react").RefAttributes<HTMLImageElement>>;
4
+ export default Image;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ const Image = forwardRef((props, ref) => {
6
+ const { style, className, rest } = useBase(props);
7
+ return _jsx("img", { ref: ref, style: style, className: `${className} flex`, ...rest });
8
+ });
9
+ export default Image;
@@ -0,0 +1,8 @@
1
+ import { Props } from '../../types';
2
+ export type InputProps = Props<`input`> & {
3
+ numeric?: boolean;
4
+ };
5
+ declare const Input: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../../types").ZuzProps> & {
6
+ numeric?: boolean;
7
+ } & import("react").RefAttributes<HTMLInputElement>>;
8
+ export default Input;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ const Input = forwardRef((props, ref) => {
6
+ const { numeric, ...pops } = props;
7
+ const { style, className, rest } = useBase(pops);
8
+ const handleInput = (event) => {
9
+ if (numeric) {
10
+ event.currentTarget.value = event.currentTarget.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');
11
+ }
12
+ };
13
+ return _jsx("input", { className: `--input flex ${className}`.trim(), style: style, onInput: handleInput, ref: ref, ...rest });
14
+ });
15
+ export default Input;
@@ -0,0 +1,4 @@
1
+ import { Props } from '../../types';
2
+ export type LabelProps = Props<`label`> & {};
3
+ declare const Label: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, keyof import("../../types").ZuzProps> & import("react").RefAttributes<HTMLLabelElement>>;
4
+ export default Label;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ const Label = forwardRef((props, ref) => {
6
+ const { style, className, rest } = useBase(props);
7
+ return _jsx("label", { ref: ref, style: style, className: className, ...rest });
8
+ });
9
+ export default Label;
@@ -0,0 +1,4 @@
1
+ import { InputProps } from '../Input';
2
+ export type PasswordProps = Omit<InputProps, `type` | `numeric`> & {};
3
+ declare const OTP: import("react").ForwardRefExoticComponent<Omit<InputProps, "type" | "numeric"> & import("react").RefAttributes<HTMLInputElement>>;
4
+ export default OTP;
@@ -0,0 +1,30 @@
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 Input from '../Input';
6
+ import Box from '../Box';
7
+ import Button from '../Button';
8
+ import SVGIcons from '../svgicons';
9
+ const OTP = forwardRef((props, ref) => {
10
+ const { ...pops } = props;
11
+ if (`type` in pops) {
12
+ delete pops[`type`];
13
+ }
14
+ const { style, className, rest } = useBase(pops);
15
+ const [visible, setVisible] = useState(false);
16
+ return _jsxs(Box, { ...{
17
+ style,
18
+ className: `--password flex aic rel`
19
+ }, children: [_jsx(Input, { ...{
20
+ ref,
21
+ type: visible ? 'text' : 'password',
22
+ className,
23
+ ...rest
24
+ } }), _jsx(Button, { ...{
25
+ tabIndex: -1,
26
+ onClick: () => setVisible(prev => !prev),
27
+ className: `--toggle flex aic jcc abs`
28
+ }, children: visible ? SVGIcons.eye : SVGIcons.eyeSlash })] });
29
+ });
30
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import { BoxProps } from "../Box";
2
+ export type OverlayProps = BoxProps & {
3
+ when?: boolean;
4
+ };
5
+ export declare const Overlay: import("react").ForwardRefExoticComponent<BoxProps & {
6
+ when?: boolean;
7
+ } & import("react").RefAttributes<HTMLDivElement>>;
8
+ export default Overlay;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import Box from "../Box";
4
+ import { TRANSITIONS } from "../../types/enums";
5
+ export const Overlay = forwardRef((props, ref) => {
6
+ const { when, ...pops } = props;
7
+ return _jsx(Box, { ref: ref, "aria-hidden": !when, className: `--overlay fixed fill`, animate: {
8
+ transition: TRANSITIONS.FadeIn,
9
+ when,
10
+ }, ...pops });
11
+ });
12
+ export default Overlay;
@@ -0,0 +1,4 @@
1
+ import { InputProps } from '../Input';
2
+ export type PasswordProps = Omit<InputProps, `type` | `numeric`> & {};
3
+ declare const Password: import("react").ForwardRefExoticComponent<Omit<InputProps, "type" | "numeric"> & import("react").RefAttributes<HTMLInputElement>>;
4
+ export default Password;
@@ -0,0 +1,18 @@
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 Input from '../Input';
6
+ import Box from '../Box';
7
+ import Button from '../Button';
8
+ import SVGIcons from '../svgicons';
9
+ const Password = forwardRef((props, ref) => {
10
+ const { ...pops } = props;
11
+ if (`type` in pops) {
12
+ delete pops[`type`];
13
+ }
14
+ const { style, className, rest } = useBase(pops);
15
+ const [visible, setVisible] = useState(false);
16
+ return _jsxs(Box, { style: style, className: `--password flex aic rel`, children: [_jsx(Input, { ref: ref, type: visible ? 'text' : 'password', className: className, ...rest }), _jsx(Button, { tabIndex: -1, onClick: () => setVisible(prev => !prev), className: `--toggle flex aic jcc abs`, children: visible ? SVGIcons.eye : SVGIcons.eyeSlash })] });
17
+ });
18
+ export default Password;
@@ -0,0 +1,12 @@
1
+ import { InputProps } from '../Input';
2
+ export type PinInputProps = InputProps & {
3
+ mask?: boolean;
4
+ size?: number;
5
+ };
6
+ declare const PinInput: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../../types").ZuzProps> & {
7
+ numeric?: boolean;
8
+ } & {
9
+ mask?: boolean;
10
+ size?: number;
11
+ } & import("react").RefAttributes<HTMLInputElement>>;
12
+ export default PinInput;
@@ -1,11 +1,11 @@
1
+ "use client";
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useRef } from "react";
3
- import Input from "../input";
4
- import Box from "../box";
5
- import useBase from "../useBase";
6
- const OTP = forwardRef((props, ref) => {
3
+ import { forwardRef, useEffect, useRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ import Input from '../Input';
6
+ import Box from '../Box';
7
+ const PinInput = forwardRef((props, ref) => {
7
8
  const { animate, size, mask, ...pops } = props;
8
- const { style } = useBase(props);
9
9
  const inputs = useRef([]);
10
10
  let name = `pinput`;
11
11
  let required = false;
@@ -20,6 +20,7 @@ const OTP = forwardRef((props, ref) => {
20
20
  required = true;
21
21
  delete pops.required;
22
22
  }
23
+ const { style } = useBase(pops);
23
24
  const handleInput = (event) => {
24
25
  const input = event.currentTarget;
25
26
  const nextInput = inputs.current[parseInt(input.dataset.index) + 1];
@@ -34,17 +35,8 @@ const OTP = forwardRef((props, ref) => {
34
35
  useEffect(() => {
35
36
  inputs.current = inputs.current.slice(0, size);
36
37
  }, [size]);
37
- return _jsx(Box, { ...{ name }, "data-required": required, "data-size": size || 4, style: style, ...{
38
- className: `--otp flex aic rel`
39
- }, children: Array(size || 4).fill(1).map((a, i) => _jsx(Input, { "data-index": i, ref: (el) => {
38
+ return _jsx(Box, { name: name, style: style, className: `--otp flex aic rel`, "data-required": required, "data-size": size || 4, children: Array(size || 4).fill(1).map((a, i) => _jsx(Input, { "data-index": i, ref: (el) => {
40
39
  inputs.current[i] = el;
41
- }, ...{
42
- numeric: true,
43
- onChange: handleInput,
44
- maxLength: 1,
45
- placeholder: `0`,
46
- type: mask ? `password` : 'text',
47
- ...pops
48
- } }, `pin-${i}`)) });
40
+ }, numeric: true, onChange: handleInput, maxLength: 1, placeholder: `0`, type: mask ? `password` : 'text', ...pops }, `pin-${i}`)) });
49
41
  });
50
- export default OTP;
42
+ export default PinInput;
@@ -0,0 +1,7 @@
1
+ import { ProgressHandler } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ declare const ProgressBar: import("react").ForwardRefExoticComponent<BoxProps & {
4
+ progress?: number;
5
+ type?: import("../..").PROGRESS;
6
+ } & import("react").RefAttributes<ProgressHandler>>;
7
+ export default ProgressBar;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
3
+ import Box from "../Box";
4
+ import { useBase } from "../../hooks";
5
+ const ProgressBar = forwardRef((props, ref) => {
6
+ const { progress, type, ...pops } = props;
7
+ const bar = useRef(null);
8
+ useImperativeHandle(ref, () => ({
9
+ setWidth: (p) => {
10
+ bar.current.style.width = `${p * 100}%`;
11
+ }
12
+ }), []);
13
+ useEffect(() => {
14
+ if (progress && bar.current) {
15
+ bar.current.style.width = `${progress * 100}%`;
16
+ }
17
+ }, []);
18
+ const { className, style, rest } = useBase(pops);
19
+ return _jsx(Box, { className: `--progress flex rel ${className}`.trim(), style: style, ...rest, children: _jsx(Box, { ref: bar, className: `--bar rel` }) });
20
+ });
21
+ export default ProgressBar;
@@ -0,0 +1,9 @@
1
+ import { PROGRESS } from "../../types/enums";
2
+ import { BoxProps } from "../Box";
3
+ export type ProgressBarProps = BoxProps & {
4
+ progress?: number;
5
+ type?: PROGRESS;
6
+ };
7
+ export interface ProgressHandler {
8
+ setWidth?: (w: number) => void;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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?: 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;