@zuzjs/ui 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/cjs/comps/Calendar/index.d.ts +3 -0
  2. package/dist/cjs/comps/Calendar/index.js +109 -0
  3. package/dist/cjs/comps/Calendar/types.d.ts +6 -0
  4. package/dist/cjs/comps/Calendar/types.js +1 -0
  5. package/dist/cjs/comps/Cover/index.d.ts +3 -1
  6. package/dist/cjs/comps/Cover/index.js +3 -3
  7. package/dist/cjs/comps/Crumb/index.d.ts +1 -1
  8. package/dist/cjs/comps/DatePicker/index.d.ts +11 -0
  9. package/dist/cjs/comps/DatePicker/index.js +73 -0
  10. package/dist/cjs/comps/DatePicker/types.d.ts +6 -0
  11. package/dist/cjs/comps/DatePicker/types.js +1 -0
  12. package/dist/cjs/comps/Icon/index.d.ts +2 -0
  13. package/dist/cjs/comps/Icon/index.js +5 -2
  14. package/dist/cjs/comps/List/index.d.ts +1 -1
  15. package/dist/cjs/comps/Password/index.d.ts +1 -1
  16. package/dist/cjs/comps/Search/index.d.ts +4 -0
  17. package/dist/cjs/comps/Search/index.js +7 -3
  18. package/dist/cjs/comps/Search/types.d.ts +5 -0
  19. package/dist/cjs/comps/Select/index.d.ts +2 -0
  20. package/dist/cjs/comps/Select/index.js +5 -2
  21. package/dist/cjs/comps/Select/optionItem.d.ts +2 -1
  22. package/dist/cjs/comps/Select/optionItem.js +3 -2
  23. package/dist/cjs/comps/Select/types.d.ts +5 -1
  24. package/dist/cjs/comps/Spinner/index.d.ts +3 -1
  25. package/dist/cjs/comps/Spinner/index.js +11 -4
  26. package/dist/cjs/comps/Table/index.js +2 -2
  27. package/dist/cjs/comps/Table/row.js +2 -2
  28. package/dist/cjs/comps/Table/types.d.ts +2 -0
  29. package/dist/cjs/comps/TextArea/commands.d.ts +12 -0
  30. package/dist/cjs/comps/TextArea/commands.js +16 -0
  31. package/dist/cjs/comps/TextArea/index.d.ts +13 -6
  32. package/dist/cjs/comps/TextArea/index.js +88 -6
  33. package/dist/cjs/comps/TextArea/types.d.ts +21 -0
  34. package/dist/cjs/comps/TextArea/types.js +1 -0
  35. package/dist/cjs/comps/index.d.ts +5 -1
  36. package/dist/cjs/comps/index.js +3 -0
  37. package/dist/cjs/comps/svgicons.d.ts +1 -0
  38. package/dist/cjs/comps/svgicons.js +1 -0
  39. package/dist/cjs/funs/index.d.ts +5 -0
  40. package/dist/cjs/funs/index.js +42 -0
  41. package/dist/cjs/funs/stylesheet.js +4 -1
  42. package/dist/cjs/hooks/index.d.ts +2 -0
  43. package/dist/cjs/hooks/index.js +2 -0
  44. package/dist/cjs/hooks/useCommandActions.d.ts +29 -0
  45. package/dist/cjs/hooks/useCommandActions.js +104 -0
  46. package/dist/cjs/hooks/usePosition.d.ts +2 -1
  47. package/dist/cjs/hooks/usePushNotifications.d.ts +45 -0
  48. package/dist/cjs/hooks/usePushNotifications.js +166 -0
  49. package/dist/cjs/hooks/useSlider.d.ts +1 -1
  50. package/dist/css/styles.css +1 -1
  51. package/dist/esm/comps/Calendar/index.d.ts +3 -0
  52. package/dist/esm/comps/Calendar/index.js +109 -0
  53. package/dist/esm/comps/Calendar/types.d.ts +6 -0
  54. package/dist/esm/comps/Calendar/types.js +1 -0
  55. package/dist/esm/comps/Cover/index.d.ts +3 -1
  56. package/dist/esm/comps/Cover/index.js +3 -3
  57. package/dist/esm/comps/Crumb/index.d.ts +1 -1
  58. package/dist/esm/comps/DatePicker/index.d.ts +11 -0
  59. package/dist/esm/comps/DatePicker/index.js +73 -0
  60. package/dist/esm/comps/DatePicker/types.d.ts +6 -0
  61. package/dist/esm/comps/DatePicker/types.js +1 -0
  62. package/dist/esm/comps/Icon/index.d.ts +2 -0
  63. package/dist/esm/comps/Icon/index.js +5 -2
  64. package/dist/esm/comps/List/index.d.ts +1 -1
  65. package/dist/esm/comps/Password/index.d.ts +1 -1
  66. package/dist/esm/comps/Search/index.d.ts +4 -0
  67. package/dist/esm/comps/Search/index.js +7 -3
  68. package/dist/esm/comps/Search/types.d.ts +5 -0
  69. package/dist/esm/comps/Select/index.d.ts +2 -0
  70. package/dist/esm/comps/Select/index.js +5 -2
  71. package/dist/esm/comps/Select/optionItem.d.ts +2 -1
  72. package/dist/esm/comps/Select/optionItem.js +3 -2
  73. package/dist/esm/comps/Select/types.d.ts +5 -1
  74. package/dist/esm/comps/Spinner/index.d.ts +3 -1
  75. package/dist/esm/comps/Spinner/index.js +11 -4
  76. package/dist/esm/comps/Table/index.js +2 -2
  77. package/dist/esm/comps/Table/row.js +2 -2
  78. package/dist/esm/comps/Table/types.d.ts +2 -0
  79. package/dist/esm/comps/TextArea/commands.d.ts +12 -0
  80. package/dist/esm/comps/TextArea/commands.js +16 -0
  81. package/dist/esm/comps/TextArea/index.d.ts +13 -6
  82. package/dist/esm/comps/TextArea/index.js +88 -6
  83. package/dist/esm/comps/TextArea/types.d.ts +21 -0
  84. package/dist/esm/comps/TextArea/types.js +1 -0
  85. package/dist/esm/comps/index.d.ts +5 -1
  86. package/dist/esm/comps/index.js +3 -0
  87. package/dist/esm/comps/svgicons.d.ts +1 -0
  88. package/dist/esm/comps/svgicons.js +1 -0
  89. package/dist/esm/funs/index.d.ts +5 -0
  90. package/dist/esm/funs/index.js +42 -0
  91. package/dist/esm/funs/stylesheet.js +4 -1
  92. package/dist/esm/hooks/index.d.ts +2 -0
  93. package/dist/esm/hooks/index.js +2 -0
  94. package/dist/esm/hooks/useCommandActions.d.ts +29 -0
  95. package/dist/esm/hooks/useCommandActions.js +104 -0
  96. package/dist/esm/hooks/usePosition.d.ts +2 -1
  97. package/dist/esm/hooks/usePushNotifications.d.ts +45 -0
  98. package/dist/esm/hooks/usePushNotifications.js +166 -0
  99. package/dist/esm/hooks/useSlider.d.ts +1 -1
  100. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  101. package/dist/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +3 -2
@@ -0,0 +1,3 @@
1
+ import { CalendarProps } from "./types";
2
+ declare const Calendar: import("react").ForwardRefExoticComponent<CalendarProps & import("react").RefAttributes<HTMLInputElement>>;
3
+ export default Calendar;
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { addDays, addHours, addWeeks, eachDayOfInterval, endOfMonth, endOfWeek, format, isSameDay, isSameMonth, isToday, startOfMonth, startOfWeek } from "date-fns";
3
+ import { forwardRef, useMemo, useState } from "react";
4
+ import { useBase } from "../../hooks";
5
+ import Box from "../Box";
6
+ import Button from "../Button";
7
+ import SVGIcons from "../svgicons";
8
+ import Text from "../Text";
9
+ const _quickDateOptions = [
10
+ {
11
+ label: 'Today',
12
+ getDate: () => new Date(),
13
+ getDateFormat: () => format(new Date(), 'EEE'),
14
+ },
15
+ {
16
+ label: 'Later',
17
+ getDate: () => new Date(),
18
+ getDateFormat: () => format(addHours(new Date(), 2), 'hh:mm a'),
19
+ },
20
+ {
21
+ label: 'Tomorrow',
22
+ getDate: () => addDays(new Date(), 1),
23
+ getDateFormat: () => format(addDays(new Date(), 1), 'EEE'),
24
+ },
25
+ {
26
+ label: 'This weekend',
27
+ getDate: () => {
28
+ const today = new Date();
29
+ const day = today.getDay();
30
+ //Saturday
31
+ return addDays(today, (6 - day) % 7 || 6);
32
+ },
33
+ getDateFormat: () => {
34
+ const today = new Date();
35
+ const day = today.getDay();
36
+ return format(addDays(today, (6 - day) % 7 || 6), 'EEE, MMM d');
37
+ },
38
+ },
39
+ {
40
+ label: 'Next week',
41
+ getDateFormat: () => format(addWeeks(new Date(), 1), 'EEE, MMM d'),
42
+ getDate: () => addWeeks(new Date(), 1)
43
+ },
44
+ {
45
+ label: 'Next weekend',
46
+ getDateFormat: () => format(addWeeks(new Date(), 1), 'd MMM'),
47
+ getDate: () => addWeeks(new Date(), 1)
48
+ },
49
+ {
50
+ label: '2 weeks',
51
+ getDateFormat: () => format(addWeeks(new Date(), 2), 'd MMM'),
52
+ getDate: () => addWeeks(new Date(), 2)
53
+ },
54
+ {
55
+ label: '4 weeks',
56
+ getDateFormat: () => format(addWeeks(new Date(), 4), 'd MMM'),
57
+ getDate: () => addWeeks(new Date(), 4)
58
+ },
59
+ ];
60
+ const dedupeByDate = (options) => {
61
+ const seen = new Set(); // ISO strings are safe for day-level comparison
62
+ return options.filter((opt) => {
63
+ if (opt.label == `Later`)
64
+ return true;
65
+ const iso = opt.getDate().toISOString().split('T')[0]; // "2025-10-31"
66
+ if (seen.has(iso))
67
+ return false;
68
+ seen.add(iso);
69
+ return true;
70
+ });
71
+ };
72
+ const Calendar = forwardRef((props, ref) => {
73
+ const { defaultValue, variant, onChange, ...pops } = props;
74
+ const { style, className, rest } = useBase(pops);
75
+ const [current, setCurrent] = useState(defaultValue || new Date());
76
+ const monthStart = startOfMonth(current);
77
+ const monthEnd = endOfMonth(current);
78
+ const startDate = startOfWeek(monthStart);
79
+ const endDate = endOfWeek(monthEnd);
80
+ const days = useMemo(() => eachDayOfInterval({ start: startDate, end: endDate }), [startDate, endDate]);
81
+ const handleDateClick = (date) => {
82
+ onChange?.(date);
83
+ setCurrent(date);
84
+ };
85
+ const gotoPrevMonth = () => {
86
+ setCurrent(prev => new Date(prev.getFullYear(), prev.getMonth() - 1));
87
+ };
88
+ const gotoNextMonth = () => {
89
+ setCurrent(prev => new Date(prev.getFullYear(), prev.getMonth() + 1));
90
+ };
91
+ return _jsxs(Box, { as: `--calendar flex --${variant || `sm`} ${className}`, style: style, children: [_jsx(Box, { as: `--calendar-quick-select flex cols flex:1`, children: dedupeByDate(_quickDateOptions)
92
+ .map((option) => {
93
+ const date = option.getDate();
94
+ return _jsxs(Button, { onClick: () => handleDateClick(date), as: [
95
+ `--calendar-quick-option flex aic gap:5`,
96
+ ], children: [_jsx(Text, { as: `flex:1`, children: option.label }), _jsx(Text, { as: `tar`, children: option.getDateFormat() })] }, `--dtp-option-label-${option.label}`);
97
+ }) }), _jsxs(Box, { as: `--calendar-selector flex cols flex:1`, children: [_jsxs(Box, { as: `--calendar-head flex aic jcc gap:4`, children: [_jsx(Text, { as: `flex:1 --calendar-cm bold`, children: format(current, 'MMMM yyyy') }), _jsx(Button, { onClick: gotoPrevMonth, as: `--calendar-chevron`, children: SVGIcons.chevronUpOutline }), _jsx(Button, { onClick: gotoNextMonth, as: `--calendar-chevron`, children: SVGIcons.chevronDownOutline })] }), _jsxs(Box, { as: `--calendar-days gap:4`, children: [['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(day => _jsx(Text, { as: `--calendar-day`, children: day }, `--calendar-hd-${day}`)), days.map((day, idx) => {
98
+ const isCurrentMonth = isSameMonth(day, current);
99
+ const isSelected = isSameDay(day, current);
100
+ const isCurrentDay = isToday(day);
101
+ return _jsx(Button, { disabled: !isCurrentMonth, onClick: () => handleDateClick(day), as: [
102
+ `--calendar-day --calendar-dd`,
103
+ `${isSelected ? `--calendar-dd-selected` : ``}`,
104
+ `${isCurrentDay ? `--calendar-dd-current` : ``}`,
105
+ ], children: format(day, 'd') }, `--calendar-day-${idx}-${day.getFullYear()}-${day.getMonth()}-${day.getDay()}`);
106
+ })] })] })] });
107
+ });
108
+ Calendar.displayName = `Zuz.Calendar`;
109
+ export default Calendar;
@@ -0,0 +1,6 @@
1
+ import { Variant } from "../../types/enums";
2
+ export type CalendarProps = {
3
+ defaultValue?: Date | null;
4
+ variant?: Variant;
5
+ onChange: (date: Date | null) => void;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,9 @@
1
- import { SPINNER } from "../../types/enums";
1
+ import { SPINNER, Variant } from "../../types/enums";
2
2
  import { BoxProps } from "../Box";
3
3
  export type CoverProps = BoxProps & {
4
4
  message?: string;
5
5
  spinner?: SPINNER;
6
+ spinnerSize?: Variant;
6
7
  color?: string;
7
8
  when?: boolean;
8
9
  hideMessage?: boolean;
@@ -10,6 +11,7 @@ export type CoverProps = BoxProps & {
10
11
  declare const Cover: import("react").ForwardRefExoticComponent<BoxProps & {
11
12
  message?: string;
12
13
  spinner?: SPINNER;
14
+ spinnerSize?: Variant;
13
15
  color?: string;
14
16
  when?: boolean;
15
17
  hideMessage?: boolean;
@@ -2,12 +2,12 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { useBase } from "../../hooks";
5
- import { SPINNER } from "../../types/enums";
5
+ import { SPINNER, Variant } from "../../types/enums";
6
6
  import Box from "../Box";
7
7
  import Spinner from "../Spinner";
8
8
  import Text from "../Text";
9
9
  const Cover = forwardRef((props, ref) => {
10
- const { message, spinner, color, when, hideMessage, ...pops } = props;
10
+ const { message, spinner, spinnerSize, color, when, hideMessage, ...pops } = props;
11
11
  const { className, style, rest } = useBase(pops);
12
12
  if (`when` in props && props.when == false) {
13
13
  return null;
@@ -15,7 +15,7 @@ const Cover = forwardRef((props, ref) => {
15
15
  return _jsxs(Box, { className: `--cover flex aic jcc cols abs fillx nope nous ${className}`.trim(), style: {
16
16
  ...style,
17
17
  backgroundColor: `var(--cover-bg)`
18
- }, ...rest, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), !hideMessage && _jsx(Text, { className: `--label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] });
18
+ }, ...rest, children: [_jsx(Spinner, { variant: spinnerSize || Variant.Small, type: spinner || SPINNER.Simple }), !hideMessage && _jsx(Text, { className: `--label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] });
19
19
  });
20
20
  Cover.displayName = `Zuz.Cover`;
21
21
  export default Cover;
@@ -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<HTMLOListElement | HTMLUListElement>>;
4
+ } & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
5
5
  export default Crumb;
@@ -0,0 +1,11 @@
1
+ declare const DatePicker: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
2
+ numeric?: boolean;
3
+ size?: import("../..").Size;
4
+ variant?: import("../..").Variant;
5
+ with?: import("../..").FORMVALIDATION | `${import("../..").FORMVALIDATION}${string}`;
6
+ onConfirm?: (value: string) => void;
7
+ } & {
8
+ icon?: import("react").ReactNode | string;
9
+ defaultValue?: Date | null;
10
+ } & import("react").RefAttributes<HTMLInputElement>>;
11
+ export default DatePicker;
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { format } from "date-fns";
3
+ import { forwardRef, useEffect, useRef, useState } from "react";
4
+ import { useBase, usePosition } from "../../hooks";
5
+ import { Position } from "../../types/enums";
6
+ import Box from "../Box";
7
+ import Calendar from "../Calendar";
8
+ import Icon from "../Icon";
9
+ import Span from "../Span";
10
+ import SVGIcons from "../svgicons";
11
+ const DatePicker = forwardRef((props, ref) => {
12
+ const { icon, defaultValue, value, size, variant, numeric, type, onConfirm, ...pops } = props;
13
+ const [choosing, setChoosing] = useState(false);
14
+ const [currentDate, setCurrentDate] = useState(defaultValue || null);
15
+ const { style, className, rest } = useBase(pops);
16
+ const _input = useRef(null);
17
+ const _pop = useRef(null);
18
+ const { reposition } = usePosition(_pop, { direction: Position.Bottom, offset: 2 });
19
+ const handleInput = (event) => {
20
+ if (numeric) {
21
+ event.currentTarget.value = event.currentTarget.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');
22
+ }
23
+ };
24
+ useEffect(() => {
25
+ const handleClickOutside = (e) => {
26
+ const target = e.target;
27
+ const clickedInsideInput = _input.current?.contains(target);
28
+ const clickedInsidePop = _pop.current?.contains(target);
29
+ if (!clickedInsideInput && !clickedInsidePop) {
30
+ setChoosing(false);
31
+ }
32
+ };
33
+ if (choosing) {
34
+ document.addEventListener("mousedown", handleClickOutside);
35
+ }
36
+ return () => {
37
+ document.removeEventListener("mousedown", handleClickOutside);
38
+ };
39
+ }, [choosing]);
40
+ useEffect(() => {
41
+ const handleEsc = (e) => {
42
+ if (e.key === "Escape" && choosing) {
43
+ setChoosing(false);
44
+ _input.current?.focus();
45
+ }
46
+ };
47
+ document.addEventListener("keydown", handleEsc);
48
+ return () => document.removeEventListener("keydown", handleEsc);
49
+ }, [choosing]);
50
+ const handleFocus = () => {
51
+ setChoosing(true);
52
+ };
53
+ useEffect(() => {
54
+ if (choosing) {
55
+ reposition();
56
+ }
57
+ }, [choosing, reposition]);
58
+ return _jsx(_Fragment, { children: _jsxs(Box, { as: `--date-picker ${variant ? `--${variant}` : ``} rel flex aic ${className}`, "data-value": currentDate ? currentDate.toISOString() : ``, children: [icon ? `string` === typeof icon ? _jsx(Icon, { as: `mr:10 c:#666`, name: icon }) : icon : _jsx(Span, { as: `--date-picker-icon flex aic jcc`, children: SVGIcons.calendar }), _jsx("input", { ref: _input, value: currentDate ? format(currentDate, `EEE, MMM d YYY hh:mm a`) : (value || ``), className: `--input ${variant ? `--${variant}` : ``} flex`.trim(), style: style, onFocus: handleFocus, onInput: handleInput, autoComplete: "new-password", onKeyDown: (e) => {
59
+ if (e.key == `Enter`) {
60
+ onConfirm?.(e.currentTarget.value);
61
+ }
62
+ }, ...rest }), _jsx(Box, { "aria-hidden": !choosing, ref: _pop, fx: {
63
+ from: { y: 5, opacity: 0 },
64
+ to: { y: 0, opacity: 1 },
65
+ when: choosing,
66
+ duration: .05
67
+ }, as: `--date-picker-chooser flex aic ${variant ? `--${variant}` : ``}`, children: _jsx(Calendar, { defaultValue: currentDate, onChange: dt => {
68
+ setCurrentDate(dt);
69
+ setChoosing(false);
70
+ } }) })] }) });
71
+ });
72
+ DatePicker.displayName = `Zuz.DatePicker`;
73
+ export default DatePicker;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ import { InputProps } from "../Input";
3
+ export type DatePickerProps = InputProps & {
4
+ icon?: ReactNode | string;
5
+ defaultValue?: Date | null;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -5,10 +5,12 @@ export type IconProps = Omit<BoxProps, `name`> & {
5
5
  name: string | ReactNode;
6
6
  pathCount?: number;
7
7
  size?: Size;
8
+ color?: string;
8
9
  };
9
10
  declare const Icon: import("react").ForwardRefExoticComponent<Omit<BoxProps, "name"> & {
10
11
  name: string | ReactNode;
11
12
  pathCount?: number;
12
13
  size?: Size;
14
+ color?: string;
13
15
  } & import("react").RefAttributes<HTMLDivElement>>;
14
16
  export default Icon;
@@ -4,9 +4,12 @@ import { useBase } from "../../hooks";
4
4
  import { Size } from "../../types/enums";
5
5
  import Span from "../Span";
6
6
  const Icon = forwardRef((props, ref) => {
7
- const { name, pathCount, size, ...pops } = props;
7
+ const { name, pathCount, size, color, ...pops } = props;
8
8
  const { className, style, rest } = useBase(pops);
9
- return _jsx("div", { style: style, className: `icon-${name} --icon --${size || Size.Default} ${className}`.trim(), ref: ref, ...rest, children: Array(pathCount || 0).fill(0).map((p, i) => _jsx(Span, { className: `path${i + 1}` }, `${name}-layer-${i}`)) });
9
+ return _jsx("div", { style: {
10
+ color,
11
+ ...style,
12
+ }, className: `icon-${name} --icon --${size || Size.Default} ${className}`.trim(), ref: ref, ...rest, children: Array(pathCount || 0).fill(0).map((p, i) => _jsx(Span, { className: `path${i + 1}` }, `${name}-layer-${i}`)) });
10
13
  });
11
14
  Icon.displayName = `Zuz.Icon`;
12
15
  export default Icon;
@@ -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<HTMLOListElement | HTMLUListElement>>;
9
+ } & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
10
10
  export default List;
@@ -2,7 +2,7 @@ import { InputProps } from '../Input';
2
2
  export type PasswordProps = Omit<InputProps, `type` | `numeric`> & {
3
3
  strenthMeter?: boolean;
4
4
  };
5
- declare const Password: import("react").ForwardRefExoticComponent<Omit<InputProps, "numeric" | "type"> & {
5
+ declare const Password: import("react").ForwardRefExoticComponent<Omit<InputProps, "type" | "numeric"> & {
6
6
  strenthMeter?: boolean;
7
7
  } & import("react").RefAttributes<HTMLInputElement>>;
8
8
  export default Password;
@@ -13,5 +13,9 @@ declare const Search: import("react").ForwardRefExoticComponent<import("../..").
13
13
  withStyle?: string;
14
14
  shortcut?: import("..").KeyCombination;
15
15
  reverse?: boolean;
16
+ searchIcon?: string | import("react").ReactNode;
17
+ hideSearchIcon?: boolean;
18
+ clearIcon?: string | import("react").ReactNode;
19
+ hideClearIcon?: boolean;
16
20
  } & import("react").RefAttributes<SearchHandler>>;
17
21
  export default Search;
@@ -1,19 +1,23 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
+ import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
4
  import { useBase } from '../../hooks';
5
5
  import { Variant } from '../../types/enums';
6
6
  import Box from '../Box';
7
7
  import Button from '../Button';
8
+ import Icon from '../Icon';
8
9
  import Input from '../Input';
9
10
  import KeyBoardKeys from '../KeyboardKeys';
10
11
  import SVGIcons from '../svgicons';
11
12
  const Search = forwardRef((props, ref) => {
12
- const { fx, animate, withStyle, as, reverse, onChange, onClear, ...pops } = props;
13
+ const { fx, animate, withStyle, as, reverse = false, searchIcon = SVGIcons.search, hideSearchIcon = false, clearIcon = SVGIcons.close, hideClearIcon = false, onChange, onClear, ...pops } = props;
13
14
  const { style, className } = useBase({ as: props.as });
14
15
  // const { className : searchStyle } = useBase({ as: withStyle || `` } as Props<`div`>)
15
16
  const [query, setQuery] = useState(``);
16
17
  const innerRef = useRef(null);
18
+ const actionBtn = useMemo(() => _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ?
19
+ !hideClearIcon && (`string` === typeof clearIcon ? _jsx(Icon, { name: clearIcon, as: `--search-action` }) : clearIcon) :
20
+ !hideSearchIcon && (`string` === typeof searchIcon ? _jsx(Icon, { name: searchIcon, as: `--search-action` }) : searchIcon) }), [reverse, searchIcon, hideClearIcon, clearIcon, hideSearchIcon]);
17
21
  if (`type` in props) {
18
22
  delete props[`type`];
19
23
  }
@@ -38,7 +42,7 @@ const Search = forwardRef((props, ref) => {
38
42
  value: () => innerRef.current?.value
39
43
  }));
40
44
  useEffect(() => { }, []);
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 })] });
45
+ 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 && actionBtn, _jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.variant || Variant.Small}`, ...pops }), props.shortcut && _jsx(KeyBoardKeys, { keys: props.shortcut, as: `abs` }), !reverse && actionBtn] });
42
46
  });
43
47
  Search.displayName = `Zuz.Search`;
44
48
  export default Search;
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from "react";
1
2
  import { KeyCombination } from "../..";
2
3
  import { InputProps } from "../Input";
3
4
  export type SearchProps = InputProps & {
@@ -7,6 +8,10 @@ export type SearchProps = InputProps & {
7
8
  withStyle?: string;
8
9
  shortcut?: KeyCombination;
9
10
  reverse?: boolean;
11
+ searchIcon?: string | ReactNode;
12
+ hideSearchIcon?: boolean;
13
+ clearIcon?: string | ReactNode;
14
+ hideClearIcon?: boolean;
10
15
  };
11
16
  export interface SearchHandler {
12
17
  focus: () => void;
@@ -9,5 +9,7 @@ declare const Select: import("react").ForwardRefExoticComponent<Omit<import(".."
9
9
  onChange?: (v: Option) => void;
10
10
  searchPlaceholder?: string;
11
11
  maxHeight?: number;
12
+ arrowDownIcon?: string | import("react").ReactNode;
13
+ arrowUpIcon?: string | import("react").ReactNode;
12
14
  } & import("react").RefAttributes<HTMLDivElement>>;
13
15
  export default Select;
@@ -5,12 +5,13 @@ import { useBase, usePosition } from "../../hooks";
5
5
  import { Position } from "../../types/enums";
6
6
  import Box from "../Box";
7
7
  import Button from "../Button";
8
+ import Icon from "../Icon";
8
9
  import Input from "../Input";
9
10
  import SVGIcons from "../svgicons";
10
11
  import Text from "../Text";
11
12
  import OptionItem from "./optionItem";
12
13
  const Select = forwardRef((props, ref) => {
13
- const { selected, options, label, name, variant, search: withSearch, searchPlaceholder, maxHeight, onChange, ...pops } = props;
14
+ const { selected, options, label, name, variant, search: withSearch, searchPlaceholder, maxHeight, arrowDownIcon = SVGIcons.arrowDown, arrowUpIcon = SVGIcons.arrowUp, onChange, ...pops } = props;
14
15
  const [value, setValue] = useState(selected ?
15
16
  typeof selected === `string` ? options.find(fo => fo.value === selected) : selected
16
17
  : options[0]);
@@ -45,7 +46,9 @@ const Select = forwardRef((props, ref) => {
45
46
  }
46
47
  reposition();
47
48
  }, [choosing]);
48
- return _jsxs(Box, { className: `--select ${variant ? `--${variant}` : ``} ${name ? `--${name}` : ``} rel`.trim(), name: _id, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(prev => !prev), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, "aria-hidden": !choosing, style: {
49
+ return _jsxs(Box, { className: `--select ${variant ? `--${variant}` : ``} ${name ? `--${name}` : ``} rel`.trim(), name: _id, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(prev => !prev), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ?
50
+ `string` === typeof arrowUpIcon ? _jsx(Icon, { name: arrowUpIcon, as: `--search-action` }) : arrowUpIcon :
51
+ `string` === typeof arrowDownIcon ? _jsx(Icon, { name: arrowDownIcon, as: `--search-action` }) : arrowDownIcon })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, "aria-hidden": !choosing, style: {
49
52
  maxHeight: maxHeight || `auto`
50
53
  }, ref: _pop, fx: {
51
54
  from: { y: 5, opacity: 0 },
@@ -1,6 +1,7 @@
1
+ import React from "react";
1
2
  import { OptionItemProps } from "./types";
2
3
  declare const OptionItem: {
3
- ({ value, updateValue, o }: OptionItemProps): import("react/jsx-runtime").JSX.Element;
4
+ ({ value, updateValue, o }: OptionItemProps): React.ReactElement;
4
5
  displayName: string;
5
6
  };
6
7
  export default OptionItem;
@@ -1,7 +1,8 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon, Text } from "..";
2
3
  import Button from "../Button";
3
4
  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
+ return _jsxs(Button, { onClick: (e) => updateValue(o), as: `--select-option-item`, className: value && (`string` == typeof o ? o : o.value) == (`string` == typeof value ? value : value.value) ? `selected` : ``, children: [o.icon && _jsx(Icon, { name: o.icon, as: `--select-option-icon --icon-${o.value}`, color: o.iconColor || undefined }), _jsx(Text, { children: `string` == typeof o ? o : o.label })] });
5
6
  };
6
7
  OptionItem.displayName = `Option`;
7
8
  export default OptionItem;
@@ -1,10 +1,12 @@
1
- import { FormEventHandler } from "react";
1
+ import { FormEventHandler, ReactNode } from "react";
2
2
  import { FORMVALIDATION, Variant } from "../../types/enums";
3
3
  import { BoxProps } from "../Box";
4
4
  /**
5
5
  * Represents an option which can be either a string or an OptionObject.
6
6
  */
7
7
  export type Option = {
8
+ icon?: string | ReactNode;
9
+ iconColor?: string;
8
10
  label: string;
9
11
  value: string;
10
12
  };
@@ -59,4 +61,6 @@ export type SelectProps = Omit<BoxProps, "onChange"> & {
59
61
  * Max Height
60
62
  */
61
63
  maxHeight?: number;
64
+ arrowDownIcon?: string | ReactNode;
65
+ arrowUpIcon?: string | ReactNode;
62
66
  };
@@ -1,8 +1,9 @@
1
- import { Size, SPINNER } from "../../types/enums";
1
+ import { Size, SPINNER, Variant } from "../../types/enums";
2
2
  import { BoxProps } from "../Box";
3
3
  export type SpinnerProps = BoxProps & {
4
4
  type?: SPINNER;
5
5
  size?: Size | number;
6
+ variant?: Variant | number;
6
7
  width?: number;
7
8
  color?: string;
8
9
  background?: string;
@@ -12,6 +13,7 @@ export type SpinnerProps = BoxProps & {
12
13
  declare const Spinner: import("react").ForwardRefExoticComponent<BoxProps & {
13
14
  type?: SPINNER;
14
15
  size?: Size | number;
16
+ variant?: Variant | number;
15
17
  width?: number;
16
18
  color?: string;
17
19
  background?: string;
@@ -2,10 +2,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { forwardRef } from "react";
3
3
  import { hexToRgba } from "../../funs";
4
4
  import { useBase } from "../../hooks";
5
- import { Size, SPINNER } from "../../types/enums";
5
+ import { Size, SPINNER, Variant } from "../../types/enums";
6
6
  import Box from "../Box";
7
7
  const Spinner = forwardRef((props, ref) => {
8
- const { type, size, width, speed, color, background, foreground, ...pops } = props;
8
+ const { type, size, variant, width, speed, color, background, foreground, ...pops } = props;
9
9
  const defaultColor = `#000000`;
10
10
  const { className, style, rest } = useBase(pops);
11
11
  const build = () => {
@@ -18,13 +18,20 @@ const Spinner = forwardRef((props, ref) => {
18
18
  default: 20
19
19
  };
20
20
  const _size = size ? Object.values(Size).includes(size) ? sizes[size] : size : sizes.default;
21
+ const variants = {
22
+ [Variant.Small]: 20,
23
+ [Variant.Medium]: 30,
24
+ [Variant.Large]: 50,
25
+ default: 20
26
+ };
27
+ const _variant = variant ? Object.values(Variant).includes(variant) ? variants[variant] : variant : variants.default;
21
28
  const _animationSetting = {
22
29
  animationDuration: `${speed || .6}s`,
23
30
  animationTimingFunction: `linear`
24
31
  };
25
32
  const _props = (type || SPINNER.Simple) == SPINNER.Simple ? {
26
- width: _size,
27
- height: _size,
33
+ width: _variant || _size,
34
+ height: _variant || _size,
28
35
  border: `${width || 3}px solid ${bg}`,
29
36
  borderRadius: `50%`,
30
37
  borderTopColor: c,
@@ -63,7 +63,7 @@ import TRow from "./row";
63
63
  * ```
64
64
  */
65
65
  const Table = (props, ref) => {
66
- const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, loading: _loading, loadingRowCount, loadingMessage, spinner, emptyMessage, onSort, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
66
+ const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, loading: _loading, loadingRowCount, loadingMessage, spinner, emptyMessage, onSort, onRowClick, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
67
67
  const _pagination = useRef(null);
68
68
  const _schemaParsed = useMemo(() => schema.reduce((prev, c) => {
69
69
  prev[c.id] = {
@@ -117,7 +117,7 @@ const Table = (props, ref) => {
117
117
  // _loading.current = mod
118
118
  }
119
119
  }));
120
- return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols rel ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, loading: true, styles: _schemaParsed }), _loading && _jsxs(Box, { as: `center-x flex aic --table-spinner`, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), _loadingMessage && _jsx(Text, { as: `--table-loading-message`, children: _loadingMessage })] }), _loading && Array(loadingRowCount || 5).fill({}).map((row, index) => _jsx(TRow, { tableRef: _tableRef, index: index, pubsub: pubsub, schema: schema, styles: _schemaParsed, loading: true, animate: animateRows }, `--trow-loading-${index}-${schema[0].id}`)), !_loading && rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, loading: false, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys.current[index] || index}-${schema[0].id}`)), isEmpty && renderEmpty(), _jsx(Box, { "aria-hidden": !pagination || !_paginated, ...(animateRows ? { fx: {
120
+ return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols rel ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, loading: true, styles: _schemaParsed }), _loading && _jsxs(Box, { as: `center-x flex aic --table-spinner`, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), _loadingMessage && _jsx(Text, { as: `--table-loading-message`, children: _loadingMessage })] }), _loading && Array(loadingRowCount || 5).fill({}).map((row, index) => _jsx(TRow, { tableRef: _tableRef, index: index, pubsub: pubsub, schema: schema, styles: _schemaParsed, loading: true, animate: animateRows, onRowClick: onRowClick }, `--trow-loading-${index}-${schema[0].id}`)), !_loading && rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, loading: false, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, onRowClick: onRowClick, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys.current[index] || index}-${schema[0].id}`)), isEmpty && renderEmpty(), _jsx(Box, { "aria-hidden": !pagination || !_paginated, ...(animateRows ? { fx: {
121
121
  transition: TRANSITIONS.SlideInBottom,
122
122
  curve: TRANSITION_CURVES.EaseInOut,
123
123
  delay: .02 * (rows.length + 1),
@@ -7,7 +7,7 @@ import CheckBox from "../CheckBox";
7
7
  import Text from "../Text";
8
8
  import TColumn from "./col";
9
9
  const TRow = (props) => {
10
- const { index, pubsub, schema, data, ids, styles, animate, sortBy, selectable, tableRef, loading, rowClassName, onSort, onSelect, onContextMenu } = props;
10
+ const { index, pubsub, schema, data, ids, styles, animate, sortBy, selectable, tableRef, loading, rowClassName, onSort, onRowClick, onSelect, onContextMenu } = props;
11
11
  const mounted = useDelayed();
12
12
  const _animation = useMemo(() => ({
13
13
  transition: TRANSITIONS.SlideInBottom,
@@ -74,7 +74,7 @@ const TRow = (props) => {
74
74
  };
75
75
  }
76
76
  }, []);
77
- return _jsxs(Box, { onContextMenu: e => onContextMenu ? onContextMenu(e, data) : null, ...(animate ? { fx: { ..._animation, when: mounted } } : {}), as: `--row flex aic ${index == -1 ? `--row-head` : ``} ${rowClassName || ``}`, children: [index == -1 && schema.map((c, i) => {
77
+ return _jsxs(Box, { onContextMenu: e => onContextMenu ? onContextMenu(e, data) : null, onClick: e => onRowClick ? onRowClick(e, props.data) : () => { }, ...(animate ? { fx: { ..._animation, when: mounted } } : {}), as: `--row flex aic ${onRowClick ? `--row-clickable` : ``} ${index == -1 ? `--row-head` : ``} ${rowClassName || ``}`, children: [index == -1 && schema.map((c, i) => {
78
78
  const { renderWhenHeader, render, value, ...cc } = c;
79
79
  return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(-1, `--selector-${c.id}`, `all`), _jsx(TColumn, { idx: -1, onSort: onSort, sortBy: sortBy,
80
80
  // value={renderWhenHeader && render ? render!(index == -1 ? c as dynamicObject : data as T, index) : value as string}
@@ -53,6 +53,7 @@ export type Row<T> = {
53
53
  sortBy?: string | null;
54
54
  onSelect?: RowSelectCallback<T>;
55
55
  onSort?: TableSortCallback;
56
+ onRowClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
56
57
  pubsub: PubSub;
57
58
  loading: boolean;
58
59
  tableRef?: RefObject<HTMLDivElement | null>;
@@ -145,6 +146,7 @@ export type TableProps<T> = BoxProps & {
145
146
  spinner?: SPINNER;
146
147
  emptyMessage?: ReactNode | FC;
147
148
  onRowSelectToggle?: RowSelectCallback<T>;
149
+ onRowClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
148
150
  onRowContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
149
151
  onPageChange?: PaginationCallback;
150
152
  onSort?: TableSortCallback;
@@ -0,0 +1,12 @@
1
+ import { FC } from "react";
2
+ import { Command } from "../..";
3
+ declare const CommandBox: FC<{
4
+ position: {
5
+ top: number;
6
+ left: number;
7
+ };
8
+ commands: Command[];
9
+ visible: boolean;
10
+ onSelect: (value: string) => void;
11
+ }>;
12
+ export default CommandBox;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Icon, Text, TRANSITIONS } from "../..";
3
+ import Box from "../Box";
4
+ const CommandItem = ({ meta }) => {
5
+ return _jsxs(Button, { as: `flex aic --command-item`, children: [meta.icon && _jsx(Icon, { name: meta.icon, as: `--command-icon` }), _jsx(Text, { children: meta.label })] });
6
+ };
7
+ const CommandBox = ({ position, onSelect, commands, visible }) => {
8
+ return _jsx(Box, { "aria-hidden": !visible, fx: {
9
+ transition: TRANSITIONS.SlideInBottom,
10
+ duration: 0.1,
11
+ when: visible
12
+ }, className: `--command-box abs grid`, style: {
13
+ ...position
14
+ }, children: commands.map(c => _jsx(CommandItem, { meta: c }, `cmd-${c.label.replace(/\s+/, '-')}`)) });
15
+ };
16
+ export default CommandBox;