@zuzjs/ui 0.8.7 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;