@zuzjs/ui 0.8.7 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/comps/AutoComplete/index.d.ts +1 -0
  2. package/dist/cjs/comps/Crumb/index.d.ts +1 -1
  3. package/dist/cjs/comps/Form/index.js +27 -8
  4. package/dist/cjs/comps/Input/index.d.ts +8 -0
  5. package/dist/cjs/comps/Input/index.js +6 -2
  6. package/dist/cjs/comps/List/index.d.ts +1 -1
  7. package/dist/cjs/comps/PinInput/index.d.ts +1 -0
  8. package/dist/cjs/comps/ProgressBar/index.d.ts +1 -0
  9. package/dist/cjs/comps/ProgressBar/index.js +9 -4
  10. package/dist/cjs/comps/ProgressBar/types.d.ts +2 -1
  11. package/dist/cjs/comps/Search/index.d.ts +2 -0
  12. package/dist/cjs/comps/Search/index.js +4 -2
  13. package/dist/cjs/comps/Search/types.d.ts +1 -0
  14. package/dist/cjs/comps/TextWheel/index.js +1 -1
  15. package/dist/cjs/comps/Toast/types.d.ts +3 -2
  16. package/dist/cjs/funs/css.js +6 -0
  17. package/dist/cjs/funs/stylesheet.js +4 -0
  18. package/dist/cjs/hooks/useBase.js +2 -2
  19. package/dist/cjs/hooks/useSlider.d.ts +1 -1
  20. package/dist/cjs/types/index.d.ts +4 -0
  21. package/dist/css/styles.css +1 -1
  22. package/dist/esm/comps/AutoComplete/index.d.ts +1 -0
  23. package/dist/esm/comps/Crumb/index.d.ts +1 -1
  24. package/dist/esm/comps/Form/index.js +27 -8
  25. package/dist/esm/comps/Input/index.d.ts +8 -0
  26. package/dist/esm/comps/Input/index.js +6 -2
  27. package/dist/esm/comps/List/index.d.ts +1 -1
  28. package/dist/esm/comps/PinInput/index.d.ts +1 -0
  29. package/dist/esm/comps/ProgressBar/index.d.ts +1 -0
  30. package/dist/esm/comps/ProgressBar/index.js +9 -4
  31. package/dist/esm/comps/ProgressBar/types.d.ts +2 -1
  32. package/dist/esm/comps/Search/index.d.ts +2 -0
  33. package/dist/esm/comps/Search/index.js +4 -2
  34. package/dist/esm/comps/Search/types.d.ts +1 -0
  35. package/dist/esm/comps/TextWheel/index.js +1 -1
  36. package/dist/esm/comps/Toast/types.d.ts +3 -2
  37. package/dist/esm/funs/css.js +6 -0
  38. package/dist/esm/funs/stylesheet.js +4 -0
  39. package/dist/esm/hooks/useBase.js +2 -2
  40. package/dist/esm/hooks/useSlider.d.ts +1 -1
  41. package/dist/esm/types/index.d.ts +4 -0
  42. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
@@ -4,6 +4,7 @@ declare const AutoComplete: import("react").ForwardRefExoticComponent<import("..
4
4
  size?: Size;
5
5
  variant?: import("../..").Variant;
6
6
  with?: import("../..").FORMVALIDATION | `${import("../..").FORMVALIDATION}${string}`;
7
+ onConfirm?: (value: string) => void;
7
8
  } & {
8
9
  action?: string;
9
10
  data?: string[];
@@ -1,5 +1,5 @@
1
1
  declare const Crumb: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
2
2
  items: import("./types").CrumbItem[];
3
3
  maxItems?: number;
4
- } & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
4
+ } & import("react").RefAttributes<HTMLOListElement | HTMLUListElement>>;
5
5
  export default Crumb;
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { withPost } from "@zuzjs/core";
4
4
  import { forwardRef, startTransition, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
5
5
  import { addPropsToChildren, isEmail, isEmpty } from "../../funs";
6
- import { useBase } from "../../hooks";
7
- import { FORMVALIDATION, SHEET } from "../../types/enums";
6
+ import { useBase, useToast } from "../../hooks";
7
+ import { FORMVALIDATION } from "../../types/enums";
8
8
  import Box from "../Box";
9
9
  import Cover from "../Cover";
10
10
  import Sheet, { isSheetHandler } from "../Sheet";
@@ -24,6 +24,7 @@ const Form = forwardRef((props, ref) => {
24
24
  const innerRef = useRef(null);
25
25
  const sheet = useRef(null);
26
26
  const submit = useRef(null);
27
+ const toast = useToast();
27
28
  /**
28
29
  * Utility function to select multiple DOM elements within the form based on a CSS query.
29
30
  * @param query - CSS selector to match elements inside the form.
@@ -188,7 +189,8 @@ const Form = forwardRef((props, ref) => {
188
189
  const _onSubmit = useCallback(() => {
189
190
  const { error, errorMsg, payload } = _buildFormData();
190
191
  if (error) {
191
- sheet.current.error(errorMsg);
192
+ toast.error(errorMsg);
193
+ // sheet.current!.error(errorMsg)
192
194
  }
193
195
  else if (action) {
194
196
  // If `action` is defined, submit the form data to the specified endpoint
@@ -199,7 +201,8 @@ const Form = forwardRef((props, ref) => {
199
201
  }
200
202
  else
201
203
  setLoading(true);
202
- sheet.current.hide();
204
+ // sheet.current!.hide()
205
+ toast.clearAll();
203
206
  // submit.current?.setState(ButtonState.Loading)
204
207
  withPost(action, { ...payload, ...(withData || {}) })
205
208
  .then(_resp => {
@@ -219,8 +222,10 @@ const Form = forwardRef((props, ref) => {
219
222
  if (onSuccess)
220
223
  onSuccess(resp);
221
224
  else {
222
- sheet.current.hide();
223
- sheet.current.success(resp.message || `Redirecting..`);
225
+ toast.clearAll();
226
+ // sheet.current!.hide()
227
+ // sheet.current!.success(resp.message || `Redirecting..`)
228
+ toast.success(resp.message || `Redirecting...`);
224
229
  }
225
230
  })
226
231
  .catch(err => {
@@ -234,7 +239,8 @@ const Form = forwardRef((props, ref) => {
234
239
  if (onError)
235
240
  onError(err);
236
241
  else
237
- sheet.current.show(err.message || `We cannot process your request at this time.`, 4, SHEET.Error);
242
+ toast.error(err.message || `We cannot process your request at this time.`);
243
+ // sheet.current!.show(err.message || `We cannot process your request at this time.`, 4, SHEET.Error)
238
244
  });
239
245
  });
240
246
  }
@@ -261,14 +267,27 @@ const Form = forwardRef((props, ref) => {
261
267
  setLoading(mod) {
262
268
  if (mod) {
263
269
  sheet.current.hide();
270
+ try {
271
+ toast.clearAll();
272
+ }
273
+ catch (e) { }
264
274
  }
265
275
  setLoading(mod);
266
276
  },
267
277
  showError(errorMsg) {
268
- sheet.current.error(errorMsg, 4);
278
+ if (typeof errorMsg == `string`) {
279
+ toast.error(errorMsg);
280
+ }
281
+ else {
282
+ sheet.current.error(errorMsg, 4);
283
+ }
269
284
  },
270
285
  hideError() {
271
286
  sheet.current.hide();
287
+ try {
288
+ toast.clearAll();
289
+ }
290
+ catch (e) { }
272
291
  },
273
292
  init() {
274
293
  _init();
@@ -5,11 +5,19 @@ export type InputProps = Props<`input`> & {
5
5
  size?: Size;
6
6
  variant?: Variant;
7
7
  with?: FORMVALIDATION | `${FORMVALIDATION}${string}`;
8
+ /**
9
+ * Triggers when Enter / Return is Pressed
10
+ */
11
+ onConfirm?: (value: string) => void;
8
12
  };
9
13
  declare const Input: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
10
14
  numeric?: boolean;
11
15
  size?: Size;
12
16
  variant?: Variant;
13
17
  with?: FORMVALIDATION | `${FORMVALIDATION}${string}`;
18
+ /**
19
+ * Triggers when Enter / Return is Pressed
20
+ */
21
+ onConfirm?: (value: string) => void;
14
22
  } & import("react").RefAttributes<HTMLInputElement>>;
15
23
  export default Input;
@@ -3,14 +3,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { forwardRef } from 'react';
4
4
  import { useBase } from '../../hooks';
5
5
  const Input = forwardRef((props, ref) => {
6
- const { size, variant, numeric, ...pops } = props;
6
+ const { size, variant, numeric, onConfirm, ...pops } = props;
7
7
  const { style, className, rest } = useBase(pops);
8
8
  const handleInput = (event) => {
9
9
  if (numeric) {
10
10
  event.currentTarget.value = event.currentTarget.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');
11
11
  }
12
12
  };
13
- return _jsx("input", { className: `--input ${size || variant ? `--${size || variant}` : ``} flex ${className}`.trim(), style: style, onInput: handleInput, ref: ref, ...rest });
13
+ return _jsx("input", { className: `--input ${size || variant ? `--${size || variant}` : ``} flex ${className}`.trim(), style: style, onInput: handleInput, onKeyDown: (e) => {
14
+ if (e.key == `Enter`) {
15
+ onConfirm?.(e.currentTarget.value);
16
+ }
17
+ }, ref: ref, ...rest });
14
18
  });
15
19
  Input.displayName = `Zuz.Input`;
16
20
  export default Input;
@@ -6,5 +6,5 @@ declare const List: import("react").ForwardRefExoticComponent<import("../..").Zu
6
6
  direction?: "cols" | "rows";
7
7
  seperator?: import("react").ReactNode;
8
8
  ol?: boolean;
9
- } & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
9
+ } & import("react").RefAttributes<HTMLOListElement | HTMLUListElement>>;
10
10
  export default List;
@@ -9,6 +9,7 @@ declare const PinInput: import("react").ForwardRefExoticComponent<import("../.."
9
9
  size?: import("../..").Size;
10
10
  variant?: import("../..").Variant;
11
11
  with?: import("../..").FORMVALIDATION | `${import("../..").FORMVALIDATION}${string}`;
12
+ onConfirm?: (value: string) => void;
12
13
  } & {
13
14
  mask?: boolean;
14
15
  size?: number;
@@ -3,5 +3,6 @@ import { ProgressHandler } from "./types";
3
3
  declare const ProgressBar: import("react").ForwardRefExoticComponent<BoxProps & {
4
4
  progress?: number;
5
5
  type?: import("../..").PROGRESS;
6
+ animated?: boolean;
6
7
  } & import("react").RefAttributes<ProgressHandler>>;
7
8
  export default ProgressBar;
@@ -4,20 +4,25 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
4
4
  import { useBase } from "../../hooks";
5
5
  import Box from "../Box";
6
6
  const ProgressBar = forwardRef((props, ref) => {
7
- const { progress, type, ...pops } = props;
7
+ const { progress, type, animated, ...pops } = props;
8
8
  const bar = useRef(null);
9
9
  useImperativeHandle(ref, () => ({
10
- setWidth: (p) => {
10
+ setProgress: (p) => {
11
11
  bar.current.style.width = `${p * 100}%`;
12
12
  }
13
13
  }), []);
14
14
  useEffect(() => {
15
+ console.log(`progressChanged`, progress);
15
16
  if (progress && bar.current) {
16
- bar.current.style.width = `${progress * 100}%`;
17
+ if (animated) {
18
+ setTimeout(() => bar.current.style.width = `${progress * 100}%`, 500);
19
+ }
20
+ else
21
+ bar.current.style.width = `${progress * 100}%`;
17
22
  }
18
23
  }, [progress, bar.current]);
19
24
  const { className, style, rest } = useBase(pops);
20
- return _jsx(Box, { className: `--progress flex rel ${className}`.trim(), style: style, ...rest, children: _jsx(Box, { ref: bar, className: `--bar rel` }) });
25
+ return _jsx(Box, { className: `--progress ${animated ? `--animated` : ``} flex rel ${className}`.trim(), style: style, ...rest, children: _jsx(Box, { ref: bar, className: `--bar rel` }) });
21
26
  });
22
27
  ProgressBar.displayName = `Zuz.ProgressBar`;
23
28
  export default ProgressBar;
@@ -3,7 +3,8 @@ import { BoxProps } from "../Box";
3
3
  export type ProgressBarProps = BoxProps & {
4
4
  progress?: number;
5
5
  type?: PROGRESS;
6
+ animated?: boolean;
6
7
  };
7
8
  export interface ProgressHandler {
8
- setWidth?: (w: number) => void;
9
+ setProgress?: (p: number) => void;
9
10
  }
@@ -5,9 +5,11 @@ declare const Search: import("react").ForwardRefExoticComponent<import("../..").
5
5
  size?: import("../..").Size;
6
6
  variant?: Variant;
7
7
  with?: import("../..").FORMVALIDATION | `${import("../..").FORMVALIDATION}${string}`;
8
+ onConfirm?: (value: string) => void;
8
9
  } & {
9
10
  onSubmit?: (value: string) => void;
10
11
  onChange?: (value: string) => void;
12
+ onClear?: () => void;
11
13
  withStyle?: string;
12
14
  shortcut?: import("..").KeyCombination;
13
15
  reverse?: boolean;
@@ -9,7 +9,7 @@ import Input from '../Input';
9
9
  import KeyBoardKeys from '../KeyboardKeys';
10
10
  import SVGIcons from '../svgicons';
11
11
  const Search = forwardRef((props, ref) => {
12
- const { fx, animate, withStyle, as, reverse, onChange, ...pops } = props;
12
+ const { fx, animate, withStyle, as, reverse, onChange, onClear, ...pops } = props;
13
13
  const { style, className } = useBase({ as: props.as });
14
14
  // const { className : searchStyle } = useBase({ as: withStyle || `` } as Props<`div`>)
15
15
  const [query, setQuery] = useState(``);
@@ -28,12 +28,14 @@ const Search = forwardRef((props, ref) => {
28
28
  onChange?.(``);
29
29
  if (innerRef.current) {
30
30
  innerRef.current.value = ``;
31
+ props.onConfirm?.(``);
31
32
  }
32
33
  }
33
34
  // onSubmit?.(query)
34
35
  };
35
36
  useImperativeHandle(ref, () => ({
36
- focus: () => innerRef.current?.focus()
37
+ focus: () => innerRef.current?.focus(),
38
+ value: () => innerRef.current?.value
37
39
  }));
38
40
  useEffect(() => { }, []);
39
41
  return _jsxs(Box, { style: style, className: `--search ${reverse ? `--search-rev` : ``} --${props.variant || Variant.Small} flex aic ${props.as?.includes(`abs`) ? `` : `rel`} ${className}`.trim(), children: [reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search }), _jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.variant || Variant.Small}`, ...pops }), props.shortcut && _jsx(KeyBoardKeys, { keys: props.shortcut, as: `abs` }), !reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search })] });
@@ -3,6 +3,7 @@ import { InputProps } from "../Input";
3
3
  export type SearchProps = InputProps & {
4
4
  onSubmit?: (value: string) => void;
5
5
  onChange?: (value: string) => void;
6
+ onClear?: () => void;
6
7
  withStyle?: string;
7
8
  shortcut?: KeyCombination;
8
9
  reverse?: boolean;
@@ -34,7 +34,7 @@ const TextWheel = forwardRef((props, ref) => {
34
34
  // console.log(value)
35
35
  _setValue(value || 0);
36
36
  }, [value]);
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) => {
37
+ return _jsxs(Box, { className: `--text-wheel flex aic 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
39
  return _jsx(Span, { className: "--wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
40
40
  }
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from "react";
1
2
  import { dynamic } from "../..";
2
3
  import { TRANSITION_CURVES } from "../../types/enums";
3
4
  export declare enum ToastType {
@@ -12,8 +13,8 @@ export interface ToastData {
12
13
  id: number;
13
14
  type: ToastType;
14
15
  icon?: string;
15
- title?: string;
16
- message?: string;
16
+ title?: string | ReactNode;
17
+ message?: string | ReactNode;
17
18
  duration?: number;
18
19
  onClick?: () => void;
19
20
  }
@@ -899,6 +899,12 @@ export const buildWithStyles = (source) => {
899
899
  for (const _prop in source) {
900
900
  let prop = _prop;
901
901
  if (prop in cssWithKeys) {
902
+ // console.log(
903
+ // prop,
904
+ // cssTransformKeys.includes(cssWithKeys[prop].toString()),
905
+ // cssFilterKeys.includes(cssWithKeys[prop].toString()),
906
+ // cssWithKeys[prop]
907
+ // )
902
908
  if (cssTransformKeys.includes(cssWithKeys[prop].toString())) {
903
909
  _transform.push(`${cssWithKeys[prop]}(${source[prop]}${_css.makeUnit(prop, source[prop])})`);
904
910
  }
@@ -453,7 +453,11 @@ export const cssFilterKeys = [
453
453
  ];
454
454
  export const cssWithKeys = {
455
455
  w: `width`,
456
+ minW: `minWidth`,
457
+ maxW: `maxWidth`,
456
458
  h: `height`,
459
+ minH: `minHeight`,
460
+ maxH: `maxHeight`,
457
461
  x: `translateX`,
458
462
  y: `translateY`,
459
463
  z: `translateZ`,
@@ -1,6 +1,6 @@
1
1
  import { cleanProps, css } from "../funs";
2
2
  import { buildWithStyles, getAnimationCurve, getAnimationTransition } from "../funs/css";
3
- import { cssFilterKeys, cssTransformKeys, cssWithKeys } from "../funs/stylesheet";
3
+ import { cssFilterKeys, cssProps, cssTransformKeys, cssWithKeys } from "../funs/stylesheet";
4
4
  let useDrag = null;
5
5
  const buildSkeletonStyle = (s) => {
6
6
  const makeValue = (v, unit = `px`) => {
@@ -76,7 +76,7 @@ const useBase = (props) => {
76
76
  if (prop in cssWithKeys) {
77
77
  _subTrans = cssTransformKeys.includes(cssWithKeys[prop].toString()) ? `transform`
78
78
  : cssFilterKeys.includes(cssWithKeys[prop].toString()) ? `filter`
79
- : _subTrans;
79
+ : _subTrans in cssProps ? cssProps[_subTrans] : _subTrans; //(cssWithKeys[prop] || _subTrans).toString() // _subTrans
80
80
  }
81
81
  else if (cssTransformKeys.includes(prop)) {
82
82
  _subTrans = `transform`;
@@ -2,6 +2,6 @@ declare const useSlider: () => {
2
2
  push: (key: string) => void;
3
3
  goBack: () => void;
4
4
  prevKey: string | null;
5
- direction: "right" | "left";
5
+ direction: "left" | "right";
6
6
  };
7
7
  export default useSlider;
@@ -67,7 +67,11 @@ export type FormInputs = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElem
67
67
  export type cssShortKey = keyof cssShortKeys;
68
68
  export type cssShortKeys = {
69
69
  w: string | number;
70
+ minW: string | number;
71
+ maxW: string | number;
70
72
  h: string | number;
73
+ minH: string | number;
74
+ maxH: string | number;
71
75
  x: string | number;
72
76
  y: string | number;
73
77
  z: string | number;