@povio/ui 2.2.9-rc.9 → 2.2.10

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 (88) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +2 -2
  2. package/dist/components/buttons/Button/Button.js +1 -1
  3. package/dist/components/buttons/PillButton/PillButton.d.ts +2 -2
  4. package/dist/components/buttons/PillButton/PillButton.js +1 -1
  5. package/dist/components/buttons/TextButton/TextButton.d.ts +2 -1
  6. package/dist/components/buttons/ToggleButton/ToggleButton.d.ts +2 -1
  7. package/dist/components/buttons/shared/ButtonContent.d.ts +3 -3
  8. package/dist/components/buttons/shared/ButtonContent.js +2 -2
  9. package/dist/components/inputs/Checkbox/Checkbox.js +1 -6
  10. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +0 -3
  11. package/dist/components/inputs/Checkbox/checkbox.cva.js +1 -2
  12. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -8
  13. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +59 -33
  14. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +4 -7
  15. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +4 -14
  16. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +7 -7
  17. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +40 -22
  18. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -3
  19. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +13 -20
  20. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +4 -1
  21. package/dist/components/inputs/DateTime/shared/Calendar.js +75 -12
  22. package/dist/components/inputs/DateTime/shared/CalendarHeader.d.ts +2 -1
  23. package/dist/components/inputs/DateTime/shared/CalendarHeader.js +28 -4
  24. package/dist/components/inputs/DateTime/shared/DateField.d.ts +3 -1
  25. package/dist/components/inputs/DateTime/shared/DateField.js +41 -7
  26. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -5
  27. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +16 -18
  28. package/dist/components/inputs/DateTime/shared/MonthPicker.d.ts +3 -1
  29. package/dist/components/inputs/DateTime/shared/MonthPicker.js +4 -3
  30. package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
  31. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +2 -7
  32. package/dist/components/inputs/DateTime/shared/YearPicker.d.ts +3 -1
  33. package/dist/components/inputs/DateTime/shared/YearPicker.js +4 -3
  34. package/dist/components/inputs/FormField/FormFieldHeader.js +1 -3
  35. package/dist/components/inputs/Input/NumberInput/NumberInput.js +0 -1
  36. package/dist/components/inputs/Input/TextInput/TextInput.js +0 -3
  37. package/dist/components/inputs/Inputs/InputItem.d.ts +16 -10
  38. package/dist/components/inputs/Inputs/InputItem.js +0 -4
  39. package/dist/components/inputs/RadioGroup/RadioGroup.js +1 -6
  40. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +0 -3
  41. package/dist/components/inputs/RadioGroup/radio.cva.js +1 -2
  42. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -3
  43. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +3 -4
  44. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
  45. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +7 -23
  46. package/dist/components/inputs/Selection/Select/Select.d.ts +2 -4
  47. package/dist/components/inputs/Selection/Select/Select.js +3 -4
  48. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -8
  49. package/dist/components/inputs/Selection/shared/SelectBase.js +1 -3
  50. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  51. package/dist/components/inputs/Selection/shared/SelectDesktop.js +2 -8
  52. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  53. package/dist/components/inputs/Selection/shared/SelectInput.js +3 -23
  54. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  55. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -10
  56. package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -3
  57. package/dist/components/inputs/Selection/shared/select.context.js +4 -22
  58. package/dist/components/inputs/Selection/shared/select.types.d.ts +2 -2
  59. package/dist/components/inputs/TextEditor/TextEditor.d.ts +0 -1
  60. package/dist/components/inputs/TextEditor/TextEditor.js +3 -7
  61. package/dist/components/inputs/Toggle/Toggle.js +1 -6
  62. package/dist/components/inputs/Toggle/toggle.cva.d.ts +0 -3
  63. package/dist/components/inputs/Toggle/toggle.cva.js +1 -2
  64. package/dist/components/inputs/shared/CheckContent.d.ts +1 -2
  65. package/dist/components/inputs/shared/CheckContent.js +4 -3
  66. package/dist/components/overlays/BottomSheet/BottomSheet.js +1 -2
  67. package/dist/components/overlays/Tooltip/TooltipEllipsis.d.ts +2 -2
  68. package/dist/config/link.context.js +4 -2
  69. package/dist/config/uiConfig.context.d.ts +2 -8
  70. package/dist/config/uiConfig.context.js +3 -5
  71. package/dist/config/uiStyle.context.d.ts +1 -6
  72. package/dist/helpers/dynamicInputs.d.ts +5 -5
  73. package/dist/helpers/dynamicInputs.js +0 -3
  74. package/dist/index.d.ts +0 -4
  75. package/dist/index.js +3 -4
  76. package/dist/utils/date-time.utils.d.ts +7 -6
  77. package/dist/utils/date-time.utils.js +66 -16
  78. package/package.json +1 -1
  79. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +0 -3
  80. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +0 -6
  81. package/dist/components/inputs/FormField/formFieldHeader.cva.js +0 -11
  82. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +0 -30
  83. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +0 -14
  84. package/dist/components/inputs/Selection/Select/QuerySelect.js +0 -56
  85. package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -6
  86. package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -13
  87. package/dist/hooks/useQueryAutocomplete.d.ts +0 -25
  88. package/dist/hooks/useQueryAutocomplete.js +0 -41
@@ -1,4 +1,4 @@
1
- import { FC, ReactElement, Ref, SVGProps } from 'react';
1
+ import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
2
2
  import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
3
3
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
4
4
  import { LinkNavigationProps } from '../../text/Link/Link';
@@ -17,7 +17,7 @@ type ToggleButtonProps = {
17
17
  isSelected?: boolean;
18
18
  } & AriaToggleButtonProps);
19
19
  export type ButtonProps<IconOnly extends boolean = false> = ButtonVariantProps & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<IconOnly> & ToggleButtonProps & {
20
- children: string;
20
+ children: ReactNode;
21
21
  isLoading?: boolean;
22
22
  link?: LinkNavigationProps;
23
23
  noDisableWhenLoading?: boolean;
@@ -45,7 +45,7 @@ var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link
45
45
  ref: contentRef,
46
46
  isLoading,
47
47
  icon: Icon,
48
- text: children,
48
+ content: children,
49
49
  hideText: props.iconOnly,
50
50
  iconPosition,
51
51
  iconClassName: buttonIconSizeCva({
@@ -1,9 +1,9 @@
1
- import { FC, Ref, SVGProps } from 'react';
1
+ import { FC, ReactNode, Ref, SVGProps } from 'react';
2
2
  import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
3
3
  import { PillButtonVariants } from './pillButton.cva';
4
4
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
5
  export interface PillButtonProps extends AriaButtonProps, Omit<AriaToggleButtonProps, keyof AriaButtonProps>, ButtonContentVariantProps, PillButtonVariants {
6
- children: string;
6
+ children: ReactNode;
7
7
  dismissable?: boolean;
8
8
  toggle?: boolean;
9
9
  icon?: FC<SVGProps<SVGSVGElement>>;
@@ -22,7 +22,7 @@ var PillButton = ({ children, dismissable, toggle, icon, iconPosition, contentRe
22
22
  }), pillButtonContent({ iconPosition: getIconPosition() })),
23
23
  children: /* @__PURE__ */ jsx(ButtonContent, {
24
24
  ref: contentRef,
25
- text: children,
25
+ content: children,
26
26
  icon: dismissable ? CloseIcon : icon,
27
27
  iconPosition: dismissable ? "right" : iconPosition,
28
28
  iconClassName: pillButtonIconSize,
@@ -1,10 +1,11 @@
1
1
  import { ButtonProps as AriaButtonProps } from 'react-aria-components';
2
+ import { ReactNode } from 'react';
2
3
  import { ButtonIconProps } from '../Button/Button';
3
4
  import { ButtonVariantProps } from '../Button/button.cva';
4
5
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
6
  import { LinkNavigationProps } from '../../text/Link/Link';
6
7
  export type TextButtonProps = Omit<ButtonVariantProps, "variant"> & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<true | false> & {
7
- children: string;
8
+ children: ReactNode;
8
9
  isLoading?: boolean;
9
10
  link?: LinkNavigationProps;
10
11
  };
@@ -1,8 +1,9 @@
1
1
  import { ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
2
+ import { ReactNode } from 'react';
2
3
  import { ButtonIconProps } from '../Button/Button';
3
4
  import { ButtonVariantProps } from '../Button/button.cva';
4
5
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
6
  export type ToggleButtonProps = ButtonVariantProps & ButtonContentVariantProps & AriaToggleButtonProps & ButtonIconProps<true | false> & {
6
- children: string;
7
+ children: ReactNode;
7
8
  };
8
9
  export declare const ToggleButton: ({ children, ...props }: ToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,14 @@
1
- import { FC, ReactElement, Ref, SVGProps } from 'react';
1
+ import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
2
2
  import { ButtonContentVariantProps } from './buttonContent.cva';
3
3
  import { TypographyVariantProps } from '../../text/Typography/typography.cva';
4
4
  interface ButtonContentProps extends ButtonContentVariantProps {
5
5
  ref?: Ref<HTMLElement>;
6
- text: string;
6
+ content: ReactNode;
7
7
  isLoading?: boolean;
8
8
  icon?: FC<SVGProps<SVGSVGElement>> | ReactElement;
9
9
  iconClassName?: string;
10
10
  hideText?: boolean;
11
11
  typography?: TypographyVariantProps;
12
12
  }
13
- export declare const ButtonContent: ({ ref, text, isLoading, icon: Icon, iconClassName, hideText, iconPosition, typography: typographyOverrides, }: ButtonContentProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const ButtonContent: ({ ref, content, isLoading, icon: Icon, iconClassName, hideText, iconPosition, typography: typographyOverrides, }: ButtonContentProps) => import("react/jsx-runtime").JSX.Element;
14
14
  export {};
@@ -6,7 +6,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { clsx } from "clsx";
7
7
  import { isValidElement } from "react";
8
8
  //#region src/components/buttons/shared/ButtonContent.tsx
9
- var ButtonContent = ({ ref, text, isLoading, icon: Icon, iconClassName, hideText, iconPosition = "left", typography: typographyOverrides }) => {
9
+ var ButtonContent = ({ ref, content, isLoading, icon: Icon, iconClassName, hideText, iconPosition = "left", typography: typographyOverrides }) => {
10
10
  const typographyCva = UIStyle.useCva("typography.cva", typography);
11
11
  let iconOrLoader = null;
12
12
  if (isLoading) iconOrLoader = /* @__PURE__ */ jsx(Loader, { className: "shrink-0" });
@@ -28,7 +28,7 @@ var ButtonContent = ({ ref, text, isLoading, icon: Icon, iconClassName, hideText
28
28
  hideText: !!hideText
29
29
  })),
30
30
  ref,
31
- children: text
31
+ children: content
32
32
  }),
33
33
  iconOrLoader && iconPosition === "right" && iconOrLoader
34
34
  ] });
@@ -1,6 +1,6 @@
1
1
  import { UIStyle } from "../../../config/uiStyle.context.js";
2
2
  import { UIConfig } from "../../../config/uiConfig.context.js";
3
- import { checkboxContentClassName, checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
3
+ import { checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
4
4
  import { FormFieldError } from "../FormField/FormFieldError.js";
5
5
  import { CheckContent } from "../shared/CheckContent.js";
6
6
  import { CheckboxCheckmark } from "./CheckboxCheckmark.js";
@@ -13,7 +13,6 @@ import { Controller } from "react-hook-form";
13
13
  var CheckboxBase = (props) => {
14
14
  const ui = UIConfig.useConfig();
15
15
  const checkboxTypographyMap = UIStyle.useMapper("checkbox.typography", checkboxTypography);
16
- const checkboxContentClassNameMap = UIStyle.useMapper("checkbox.contentClassName", checkboxContentClassName);
17
16
  const { className, children, isDisabled, error, variant = ui.checkbox.variant, hideLabel = ui.input.hideLabel, ...rest } = props;
18
17
  const formFieldErrorProps = {
19
18
  error,
@@ -35,10 +34,6 @@ var CheckboxBase = (props) => {
35
34
  variant,
36
35
  ...rest
37
36
  }),
38
- contentClassName: checkboxContentClassNameMap({
39
- variant,
40
- ...rest
41
- }),
42
37
  children
43
38
  })]
44
39
  }), /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps })] });
@@ -9,9 +9,6 @@ export declare const checkboxIndicatorClass = "group flex items-center gap-2";
9
9
  export declare const checkboxTypography: (props: {
10
10
  variant?: "default" | null | undefined;
11
11
  }) => TypographyVariantProps | undefined;
12
- export declare const checkboxContentClassName: (props: {
13
- variant?: "default" | null | undefined;
14
- }) => string | undefined;
15
12
  export declare const checkboxIcon: (props?: ({
16
13
  iconVariant?: "selected" | "indeterminate" | null | undefined;
17
14
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -39,7 +39,6 @@ var checkboxTypography = compoundMapper({ default: {
39
39
  sizeMobile: "label-1",
40
40
  variant: "default"
41
41
  } });
42
- var checkboxContentClassName = compoundMapper({ default: "text-text-default-2" });
43
42
  var checkboxIcon = cva(["absolute hidden size-3"], {
44
43
  variants: { iconVariant: {
45
44
  selected: ["group-selected:block"],
@@ -48,4 +47,4 @@ var checkboxIcon = cva(["absolute hidden size-3"], {
48
47
  defaultVariants: { iconVariant: "selected" }
49
48
  });
50
49
  //#endregion
51
- export { checkbox, checkboxContentClassName, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
50
+ export { checkbox, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
@@ -1,25 +1,25 @@
1
1
  import { CalendarDate, DateValue } from '@internationalized/date';
2
- import { Ref, FocusEvent } from 'react';
2
+ import { Ref } from 'react';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { DatePickerStateOptions } from 'react-stately';
5
5
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
6
- import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
7
6
  import { FormFieldProps } from '../../FormField/FormField';
8
7
  import { ControlProps } from '../../shared/form.types';
9
8
  import { InputVariantProps } from '../../shared/input.cva';
10
- interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
9
+ type DatePickerGranularity = "day" | "month" | "year";
10
+ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
11
11
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
12
12
  disableDropdown?: boolean;
13
13
  isClearable?: boolean;
14
14
  className?: string;
15
- todayIcon?: DatePickerTodayIcon;
16
- todayIconButtonSize?: DatePickerTodayIconButtonSize;
15
+ todayIcon?: boolean;
17
16
  isDirty?: boolean;
18
17
  disableManualEntry?: boolean;
19
- autoFixYear?: boolean;
20
18
  placeholder?: string;
21
19
  inputClassName?: string;
22
- onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
20
+ shouldUpdateDateOnMonthYearChange?: boolean;
21
+ granularity?: DatePickerGranularity;
22
+ autoFixYear?: boolean;
23
23
  }
24
24
  export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
25
25
  value?: string | null;
@@ -29,5 +29,5 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
29
29
  maxValue?: DateValue | string;
30
30
  }
31
31
  export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
32
- export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, granularity, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
33
33
  export {};
@@ -5,7 +5,6 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
5
5
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
6
6
  import { FormField } from "../../FormField/FormField.js";
7
7
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
- import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
8
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
9
  import { jsx, jsxs } from "react/jsx-runtime";
11
10
  import { clsx } from "clsx";
@@ -13,14 +12,21 @@ import { useImperativeHandle, useMemo, useRef } from "react";
13
12
  import { useDatePicker, useLocale } from "react-aria";
14
13
  import { mergeRefs } from "@react-aria/utils";
15
14
  import { Controller } from "react-hook-form";
16
- import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
15
+ import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
17
16
  import { DateTime } from "luxon";
18
17
  import { useCalendarState, useDatePickerState } from "react-stately";
19
18
  //#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
20
- var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
21
19
  var DatePickerBase = (props) => {
22
20
  const ui = UIConfig.useConfig();
23
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
21
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange, granularity = ui.dateInput.granularity, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
22
+ const normalizeByGranularity = (date) => {
23
+ if (granularity === "year") return date.set({
24
+ month: 1,
25
+ day: 1
26
+ });
27
+ if (granularity === "month") return date.set({ day: 1 });
28
+ return date;
29
+ };
24
30
  const formFieldProps = {
25
31
  error,
26
32
  label,
@@ -41,10 +47,6 @@ var DatePickerBase = (props) => {
41
47
  useImperativeHandle(ref, () => ({ clear: () => {
42
48
  datePickerInputRef.current?.clear();
43
49
  } }));
44
- const handleBlur = (val) => {
45
- onBlur?.({ target: { value: val } });
46
- };
47
- const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
48
50
  const dialogState = useDatePickerState({
49
51
  ...rest,
50
52
  defaultValue: value || rest.defaultValue,
@@ -56,14 +58,19 @@ var DatePickerBase = (props) => {
56
58
  shouldForceLeadingZeros,
57
59
  value,
58
60
  onChange: (val) => {
59
- if (val && (rest.minValue && val < rest?.minValue || rest?.maxValue && val > rest?.maxValue)) {
61
+ let normalizedValue = val;
62
+ if (val) normalizedValue = normalizeByGranularity(val);
63
+ if (normalizedValue && (rest.minValue && normalizedValue < rest?.minValue || rest?.maxValue && normalizedValue > rest?.maxValue)) {
60
64
  state.setValue(state.value);
61
65
  return;
62
66
  }
63
- onChange?.(val);
64
- dialogState.setValue(val);
65
- calendarState.setFocusedDate(val || today(getLocalTimeZone()));
66
- debouncedBlur(val);
67
+ onChange?.(normalizedValue);
68
+ dialogState.setValue(normalizedValue);
69
+ if (normalizedValue) {
70
+ calendarState.setFocusedDate(normalizedValue);
71
+ return;
72
+ }
73
+ calendarState.setFocusedDate(today(getLocalTimeZone()));
67
74
  },
68
75
  shouldCloseOnSelect: false
69
76
  });
@@ -95,18 +102,28 @@ var DatePickerBase = (props) => {
95
102
  labelProps
96
103
  };
97
104
  const onApply = () => {
98
- const newValue = dialogState.value;
99
- state.setValue(newValue);
105
+ if (dialogState.value) state.setValue(normalizeByGranularity(dialogState.value));
106
+ if (!dialogState.value) state.setValue(dialogState.value);
100
107
  state.toggle();
101
- handleBlur(newValue);
108
+ };
109
+ const onMonthYearChange = (selectedDate) => {
110
+ if (!(shouldUpdateDateOnMonthYearChange || granularity !== "day")) return;
111
+ const updatedDate = normalizeByGranularity((dialogState.value || state.value || today(getLocalTimeZone())).set({
112
+ year: selectedDate.year,
113
+ month: selectedDate.month
114
+ }));
115
+ dialogState.setValue(updatedDate);
116
+ calendarState.setFocusedDate(updatedDate);
102
117
  };
103
118
  const onTodayPress = () => {
104
- dialogState.setValue(today(getLocalTimeZone()));
105
- calendarState.setFocusedDate(today(getLocalTimeZone()));
119
+ const todayValue = normalizeByGranularity(today(getLocalTimeZone()));
120
+ dialogState.setValue(todayValue);
121
+ calendarState.setFocusedDate(todayValue);
106
122
  };
107
123
  const onOpenChange = (isOpen) => {
108
124
  state.toggle();
109
- calendarState.setFocusedDate(state.value || today(getLocalTimeZone()));
125
+ if (state.value) calendarState.setFocusedDate(normalizeByGranularity(state.value));
126
+ if (!state.value) calendarState.setFocusedDate(today(getLocalTimeZone()));
110
127
  if (!isOpen) dialogState.setValue(state.value);
111
128
  };
112
129
  return /* @__PURE__ */ jsx(TooltipWrapper, {
@@ -123,15 +140,11 @@ var DatePickerBase = (props) => {
123
140
  ref: mergeRefs(ref, datePickerInputRef),
124
141
  as,
125
142
  groupProps,
126
- fieldProps: {
127
- ...fieldProps,
128
- placeholderValue: PLACEHOLDER_VALUE
129
- },
143
+ fieldProps,
130
144
  buttonProps,
131
145
  isDirty,
132
146
  isDisabled,
133
147
  disableManualEntry,
134
- autoFixYear,
135
148
  isInvalid: !!error,
136
149
  disableDropdown,
137
150
  variant,
@@ -139,11 +152,12 @@ var DatePickerBase = (props) => {
139
152
  isClearable,
140
153
  headerProps,
141
154
  todayIcon,
142
- todayIconButtonSize,
143
155
  onOpenDropdown: () => state.toggle(),
144
156
  placeholder,
145
- className: inputClassName
146
- }), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
157
+ className: inputClassName,
158
+ dateGranularity: granularity,
159
+ autoFixYear
160
+ }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
147
161
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
148
162
  isDisabled,
149
163
  isValid: !dialogState.isInvalid && !!dialogState.value,
@@ -158,24 +172,35 @@ var DatePickerBase = (props) => {
158
172
  children: /* @__PURE__ */ jsx(Calendar, {
159
173
  state: calendarState,
160
174
  calendarProps,
161
- onApply
175
+ onApply,
176
+ onMonthYearChange,
177
+ granularity
162
178
  })
163
179
  })]
164
180
  })
165
181
  });
166
182
  };
167
- var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
183
+ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...props }) => {
184
+ const normalizeByGranularity = (date) => {
185
+ if (granularity === "year") return date.set({
186
+ month: 1,
187
+ day: 1
188
+ });
189
+ if (granularity === "month") return date.set({ day: 1 });
190
+ return date;
191
+ };
168
192
  const formatCalendarDate = (calendarDate) => {
169
193
  if (calendarDate === null) return null;
170
- if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
171
- const date = DateTimeUtils.fromDateValueToLocal(calendarDate);
194
+ const normalizedDate = normalizeByGranularity(calendarDate);
195
+ if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(normalizedDate);
196
+ const date = DateTimeUtils.fromDateValueToLocal(normalizedDate);
172
197
  return DateTime.fromJSDate(date).toISODate();
173
198
  };
174
199
  const parseCalendarDate = (formattedDate) => {
175
200
  if (formattedDate == null) return formattedDate;
176
- if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
201
+ if (fullIso) return normalizeByGranularity(DateTimeUtils.fromUTCISOToCalendarDate(formattedDate));
177
202
  const date = DateTime.fromISO(formattedDate).toJSDate();
178
- return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date));
203
+ return normalizeByGranularity(toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date)));
179
204
  };
180
205
  const dateLimits = {
181
206
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
@@ -202,6 +227,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
202
227
  return /* @__PURE__ */ jsx(DatePickerBase, {
203
228
  ...props,
204
229
  ...dateLimits,
230
+ granularity,
205
231
  value: parseCalendarDate(props.value),
206
232
  onChange: (value) => props.onChange?.(formatCalendarDate(value))
207
233
  });
@@ -1,27 +1,24 @@
1
1
  import { CalendarDate } from '@internationalized/date';
2
- import { FocusEvent, Ref } from 'react';
2
+ import { Ref } from 'react';
3
3
  import { DateValue } from 'react-aria';
4
4
  import { FieldValues } from 'react-hook-form';
5
5
  import { DateRangePickerStateOptions } from 'react-stately';
6
6
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
7
- import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
8
7
  import { FormFieldProps } from '../../FormField/FormField';
9
8
  import { ControlProps } from '../../shared/form.types';
10
9
  import { InputVariantProps } from '../../shared/input.cva';
11
- interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
10
+ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
12
11
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
13
12
  disableDropdown?: boolean;
14
13
  isClearable?: boolean;
15
14
  hideSidebar?: boolean;
16
15
  className?: string;
17
- todayIcon?: DatePickerTodayIcon;
18
- todayIconButtonSize?: DatePickerTodayIconButtonSize;
16
+ todayIcon?: boolean;
19
17
  isDirty?: boolean;
20
18
  disableManualEntry?: boolean;
21
- autoFixYear?: boolean;
22
19
  placeholder?: string;
23
20
  inputClassName?: string;
24
- onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
21
+ autoFixYear?: boolean;
25
22
  }
26
23
  export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
27
24
  value?: {
@@ -6,7 +6,6 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
6
6
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
7
7
  import { FormField } from "../../FormField/FormField.js";
8
8
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
9
- import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
10
9
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
11
10
  import { RangeCalendar } from "../shared/RangeCalendar.js";
12
11
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -24,7 +23,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
24
23
  var DateRangePickerBase = (props) => {
25
24
  const ui = UIConfig.useConfig();
26
25
  const { t } = useTranslation();
27
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
26
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
28
27
  const [validationRangeError, setValidationRangeError] = useState();
29
28
  const datePickerInputRef = useRef(null);
30
29
  const dateRangePickerRef = useMemo(() => ({ get current() {
@@ -44,7 +43,6 @@ var DateRangePickerBase = (props) => {
44
43
  if (isValidRange(newValue)) return;
45
44
  onChange?.(newValue);
46
45
  handleCalendarStatesChange(newValue);
47
- debouncedBlur(newValue);
48
46
  },
49
47
  shouldCloseOnSelect: false
50
48
  });
@@ -62,10 +60,6 @@ var DateRangePickerBase = (props) => {
62
60
  useImperativeHandle(ref, () => ({ clear: () => {
63
61
  datePickerInputRef.current?.clear();
64
62
  } }));
65
- const handleBlur = (newValue) => {
66
- onBlur?.({ target: { value: newValue } });
67
- };
68
- const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
69
63
  const formFieldProps = {
70
64
  error: error || validationRangeError,
71
65
  label,
@@ -327,10 +321,7 @@ var DateRangePickerBase = (props) => {
327
321
  start: rangeSelection.start,
328
322
  end: rangeSelection.end
329
323
  } : dialogState.value;
330
- if (valueToApply) {
331
- state.setValue(valueToApply);
332
- handleBlur(valueToApply);
333
- }
324
+ if (valueToApply) state.setValue(valueToApply);
334
325
  state.toggle();
335
326
  };
336
327
  const onTodayPress = () => {
@@ -484,13 +475,12 @@ var DateRangePickerBase = (props) => {
484
475
  isClearable,
485
476
  headerProps,
486
477
  todayIcon,
487
- todayIconButtonSize,
488
478
  isDirty,
489
479
  disableManualEntry,
490
- autoFixYear,
491
480
  placeholder,
492
481
  className: inputClassName,
493
- onOpenDropdown: () => state.toggle()
482
+ onOpenDropdown: () => state.toggle(),
483
+ autoFixYear
494
484
  }), /* @__PURE__ */ jsx(DateTimeDialog, {
495
485
  hideSidebar,
496
486
  sidebar: /* @__PURE__ */ jsx("div", {
@@ -1,30 +1,30 @@
1
- import { FocusEvent, Ref } from 'react';
1
+ import { Ref } from 'react';
2
2
  import { DateValue } from 'react-aria';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { DatePickerStateOptions } from 'react-stately';
5
5
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
6
- import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
7
6
  import { FormFieldProps } from '../../FormField/FormField';
8
7
  import { ControlProps } from '../../shared/form.types';
9
8
  import { InputVariantProps } from '../../shared/input.cva';
10
- interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
9
+ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
11
10
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
12
11
  disableDropdown?: boolean;
13
12
  isTimeOptional?: boolean;
14
13
  isClearable?: boolean;
15
- todayIcon?: DatePickerTodayIcon;
16
- todayIconButtonSize?: DatePickerTodayIconButtonSize;
14
+ todayIcon?: boolean;
17
15
  isDirty?: boolean;
18
16
  disableManualEntry?: boolean;
19
- autoFixYear?: boolean;
20
17
  placeholder?: string;
21
18
  inputClassName?: string;
22
- onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
19
+ shouldUpdateDateOnMonthYearChange?: boolean;
20
+ timeZone?: string;
21
+ autoFixYear?: boolean;
23
22
  }
24
23
  export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
25
24
  value?: string | null;
26
25
  onChange?: (value: string | null) => void;
27
26
  fullIso?: boolean;
27
+ timeZone?: string;
28
28
  }
29
29
  export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
30
30
  export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;