@povio/ui 2.2.9-rc.3 → 2.2.9-rc.30

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 (116) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +2 -1
  2. package/dist/components/buttons/Button/Button.js +41 -32
  3. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
  4. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
  5. package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
  6. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
  7. package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
  8. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -3
  9. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +88 -6
  10. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
  11. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +91 -6
  12. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
  14. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  15. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +73 -4
  16. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
  17. package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
  18. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
  19. package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
  20. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
  21. package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
  22. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
  23. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
  24. package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
  25. package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
  26. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -2
  27. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
  28. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
  29. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
  30. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  31. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
  32. package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
  33. package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
  34. package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
  35. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
  36. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
  37. package/dist/components/inputs/File/FileUpload.js +1 -0
  38. package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
  39. package/dist/components/inputs/FormField/FormField.d.ts +3 -3
  40. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  41. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  42. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  43. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  44. package/dist/components/inputs/Input/NumberInput/NumberInput.js +85 -7
  45. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +38 -0
  46. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
  47. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  48. package/dist/components/inputs/Input/TextInput/TextInput.js +88 -7
  49. package/dist/components/inputs/Input/shared/InputContent.js +7 -6
  50. package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
  51. package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
  52. package/dist/components/inputs/Inputs/InputItem.d.ts +15 -18
  53. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  54. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  55. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  56. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  57. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  58. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +104 -6
  59. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  60. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  61. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  62. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -4
  63. package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
  64. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  65. package/dist/components/inputs/Selection/Select/Select.js +119 -4
  66. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  67. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  68. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  69. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  70. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  71. package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
  72. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  73. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  74. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  75. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  76. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  77. package/dist/components/inputs/Selection/shared/select.context.js +27 -4
  78. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  79. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  80. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  81. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  82. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
  83. package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
  84. package/dist/components/inputs/Skeleton/InputFrame.d.ts +68 -0
  85. package/dist/components/inputs/Skeleton/InputFrame.js +171 -0
  86. package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
  87. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  88. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  89. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  90. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  91. package/dist/components/inputs/shared/CheckContent.js +3 -4
  92. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  93. package/dist/components/inputs/shared/InputClear.js +13 -1
  94. package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
  95. package/dist/components/inputs/shared/StaticInput.js +104 -0
  96. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  97. package/dist/components/inputs/shared/input.cva.d.ts +10 -0
  98. package/dist/components/inputs/shared/input.cva.js +19 -1
  99. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  100. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  101. package/dist/config/uiConfig.context.d.ts +8 -2
  102. package/dist/config/uiConfig.context.js +12 -1
  103. package/dist/config/uiStyle.context.d.ts +20 -3
  104. package/dist/helpers/dynamicInputs.d.ts +1 -1
  105. package/dist/helpers/dynamicInputs.js +3 -0
  106. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  107. package/dist/hooks/useIntersectionObserver.js +29 -10
  108. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  109. package/dist/hooks/useQueryAutocomplete.js +13 -3
  110. package/dist/index.d.ts +7 -0
  111. package/dist/index.js +4 -2
  112. package/dist/utils/date-time.utils.d.ts +30 -9
  113. package/dist/utils/date-time.utils.js +113 -1
  114. package/dist/utils/query.utils.d.ts +4 -0
  115. package/dist/utils/query.utils.js +8 -0
  116. package/package.json +1 -1
@@ -23,6 +23,7 @@ export type ButtonProps<IconOnly extends boolean = false> = ButtonVariantProps &
23
23
  noDisableWhenLoading?: boolean;
24
24
  iconClassName?: string;
25
25
  contentRef?: Ref<HTMLElement>;
26
+ staticRender?: boolean;
26
27
  };
27
- export declare const Button: <IconOnly extends boolean = false>({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, ...props }: ButtonProps<IconOnly>) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const Button: <IconOnly extends boolean = false>({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, staticRender, ...props }: ButtonProps<IconOnly>) => import("react/jsx-runtime").JSX.Element;
28
29
  export {};
@@ -7,10 +7,11 @@ import { jsx } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { Button, Link, ToggleButton } from "react-aria-components";
9
9
  //#region src/components/buttons/Button/Button.tsx
10
- var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, ...props }) => {
10
+ var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, staticRender, ...props }) => {
11
11
  const linkContext = LinkContext.useLinkContext();
12
12
  const uiConfig = UIConfig.useConfig();
13
- const { variant = uiConfig.button.variant, size = uiConfig.button.size } = props;
13
+ const variant = props.variant ?? uiConfig.button.variant;
14
+ const size = props.size ?? uiConfig.button.size;
14
15
  const buttonCva = UIStyle.useCva("button.cva", button);
15
16
  const buttonSizeCva = UIStyle.useCva("button.sizeCva", buttonSize);
16
17
  const buttonContentCva = UIStyle.useCva("button.contentCva", buttonContent);
@@ -22,45 +23,53 @@ var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link
22
23
  return Button;
23
24
  })();
24
25
  if (link && !link.to && link.href) link.to = link.href;
25
- return /* @__PURE__ */ jsx(Component, {
26
+ const resolvedClassName = clsx(buttonCva({
26
27
  ...props,
27
- ...link,
28
- isDisabled: props.isDisabled || isLoading && !noDisableWhenLoading,
29
- className: clsx(buttonCva({
28
+ variant,
29
+ size,
30
+ className
31
+ }), buttonSizeCva({
32
+ ...props,
33
+ variant,
34
+ size
35
+ }), buttonContentCva({
36
+ ...props,
37
+ variant,
38
+ size,
39
+ iconPosition: !Icon ? "none" : iconPosition
40
+ }));
41
+ const content = /* @__PURE__ */ jsx(ButtonContent, {
42
+ ref: contentRef,
43
+ isLoading,
44
+ icon: Icon,
45
+ text: children,
46
+ hideText: props.iconOnly,
47
+ iconPosition,
48
+ iconClassName: buttonIconSizeCva({
30
49
  ...props,
31
50
  variant,
32
51
  size,
33
- className
34
- }), buttonSizeCva({
52
+ className: iconClassName
53
+ }),
54
+ typography: typographyMap({
35
55
  ...props,
36
56
  variant,
37
57
  size
38
- }), buttonContentCva({
39
- ...props,
40
- variant,
41
- size,
42
- iconPosition: !Icon ? "none" : iconPosition
43
- })),
44
- children: /* @__PURE__ */ jsx(ButtonContent, {
45
- ref: contentRef,
46
- isLoading,
47
- icon: Icon,
48
- text: children,
49
- hideText: props.iconOnly,
50
- iconPosition,
51
- iconClassName: buttonIconSizeCva({
52
- ...props,
53
- variant,
54
- size,
55
- className: iconClassName
56
- }),
57
- typography: typographyMap({
58
- ...props,
59
- variant,
60
- size
61
- })
62
58
  })
63
59
  });
60
+ if (staticRender) return /* @__PURE__ */ jsx("div", {
61
+ "aria-label": props.iconOnly ? children : void 0,
62
+ "aria-disabled": props.isDisabled || void 0,
63
+ className: resolvedClassName,
64
+ children: content
65
+ });
66
+ return /* @__PURE__ */ jsx(Component, {
67
+ ...props,
68
+ ...link,
69
+ isDisabled: props.isDisabled || isLoading && !noDisableWhenLoading,
70
+ className: resolvedClassName,
71
+ children: content
72
+ });
64
73
  };
65
74
  //#endregion
66
75
  export { Button$1 as Button };
@@ -8,5 +8,6 @@ export interface InlineIconButtonProps extends Omit<AriaButtonProps, "children">
8
8
  link?: LinkNavigationProps;
9
9
  ref?: RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
10
10
  disableTooltip?: boolean;
11
+ staticRender?: boolean;
11
12
  }
12
- export declare const InlineIconButton: ({ label, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const InlineIconButton: ({ label, size, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import { Button } from "../Button/Button.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  //#region src/components/buttons/InlineIconButton/InlineIconButton.tsx
4
- var InlineIconButton = ({ label, ...props }) => {
4
+ var InlineIconButton = ({ label, size = "none", ...props }) => {
5
5
  return /* @__PURE__ */ jsx(Button, {
6
6
  ...props,
7
7
  iconOnly: true,
8
8
  variant: "text",
9
- size: "none",
9
+ size,
10
10
  width: "hug",
11
11
  children: label
12
12
  });
@@ -1,6 +1,6 @@
1
1
  import { UIStyle } from "../../../config/uiStyle.context.js";
2
2
  import { UIConfig } from "../../../config/uiConfig.context.js";
3
- import { checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
3
+ import { checkboxContentClassName, 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,6 +13,7 @@ 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);
16
17
  const { className, children, isDisabled, error, variant = ui.checkbox.variant, hideLabel = ui.input.hideLabel, ...rest } = props;
17
18
  const formFieldErrorProps = {
18
19
  error,
@@ -34,6 +35,10 @@ var CheckboxBase = (props) => {
34
35
  variant,
35
36
  ...rest
36
37
  }),
38
+ contentClassName: checkboxContentClassNameMap({
39
+ variant,
40
+ ...rest
41
+ }),
37
42
  children
38
43
  })]
39
44
  }), /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps })] });
@@ -9,6 +9,9 @@ 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;
12
15
  export declare const checkboxIcon: (props?: ({
13
16
  iconVariant?: "selected" | "indeterminate" | null | undefined;
14
17
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -39,6 +39,7 @@ var checkboxTypography = compoundMapper({ default: {
39
39
  sizeMobile: "label-1",
40
40
  variant: "default"
41
41
  } });
42
+ var checkboxContentClassName = compoundMapper({ default: "text-text-default-2" });
42
43
  var checkboxIcon = cva(["absolute hidden size-3"], {
43
44
  variants: { iconVariant: {
44
45
  selected: ["group-selected:block"],
@@ -47,4 +48,4 @@ var checkboxIcon = cva(["absolute hidden size-3"], {
47
48
  defaultVariants: { iconVariant: "selected" }
48
49
  });
49
50
  //#endregion
50
- export { checkbox, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
51
+ export { checkbox, checkboxContentClassName, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
@@ -1,8 +1,9 @@
1
1
  import { CalendarDate, DateValue } from '@internationalized/date';
2
- import { Ref, FocusEvent } from 'react';
2
+ import { FocusEvent, 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, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
6
7
  import { FormFieldProps } from '../../FormField/FormField';
7
8
  import { ControlProps } from '../../shared/form.types';
8
9
  import { InputVariantProps } from '../../shared/input.cva';
@@ -11,9 +12,12 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
11
12
  disableDropdown?: boolean;
12
13
  isClearable?: boolean;
13
14
  className?: string;
14
- todayIcon?: boolean;
15
+ todayIcon?: DatePickerTodayIcon;
16
+ todayIconButtonSize?: DatePickerTodayIconButtonSize;
17
+ todayIconPlacement?: DatePickerTodayIconPlacement;
15
18
  isDirty?: boolean;
16
19
  disableManualEntry?: boolean;
20
+ autoFixYear?: boolean;
17
21
  placeholder?: string;
18
22
  inputClassName?: string;
19
23
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
@@ -24,7 +28,8 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
24
28
  fullIso?: boolean;
25
29
  minValue?: DateValue | string;
26
30
  maxValue?: DateValue | string;
31
+ renderStaticInput?: boolean;
27
32
  }
28
33
  export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
29
- export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
30
35
  export {};
@@ -1,18 +1,23 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
1
2
  import { UIConfig } from "../../../../config/uiConfig.context.js";
2
3
  import { Calendar } from "../shared/Calendar.js";
4
+ import { datePickerInputContentRow } from "../shared/datePickerInput.cva.js";
5
+ import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
3
6
  import { DatePickerInput } from "../shared/DatePickerInput.js";
4
7
  import { DateTimeDialog } from "../shared/DateTimeDialog.js";
5
8
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
9
+ import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
+ import { getStaticCalendarDateSegments } from "../shared/staticDateTimeSegments.js";
6
11
  import { FormField } from "../../FormField/FormField.js";
7
12
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
13
+ import { InputFrame } from "../../Skeleton/InputFrame.js";
8
14
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
- import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
15
  import { jsx, jsxs } from "react/jsx-runtime";
11
16
  import { clsx } from "clsx";
12
- import { useImperativeHandle, useMemo, useRef } from "react";
17
+ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
13
18
  import { useDatePicker, useLocale } from "react-aria";
14
19
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller } from "react-hook-form";
20
+ import { Controller, useWatch } from "react-hook-form";
16
21
  import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
17
22
  import { DateTime } from "luxon";
18
23
  import { useCalendarState, useDatePickerState } from "react-stately";
@@ -20,7 +25,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
20
25
  var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
21
26
  var DatePickerBase = (props) => {
22
27
  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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
28
+ 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, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
24
29
  const formFieldProps = {
25
30
  error,
26
31
  label,
@@ -131,6 +136,7 @@ var DatePickerBase = (props) => {
131
136
  isDirty,
132
137
  isDisabled,
133
138
  disableManualEntry,
139
+ autoFixYear,
134
140
  isInvalid: !!error,
135
141
  disableDropdown,
136
142
  variant,
@@ -138,6 +144,8 @@ var DatePickerBase = (props) => {
138
144
  isClearable,
139
145
  headerProps,
140
146
  todayIcon,
147
+ todayIconButtonSize,
148
+ todayIconPlacement,
141
149
  onOpenDropdown: () => state.toggle(),
142
150
  placeholder,
143
151
  className: inputClassName
@@ -162,7 +170,21 @@ var DatePickerBase = (props) => {
162
170
  })
163
171
  });
164
172
  };
165
- var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
173
+ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
174
+ const ui = UIConfig.useConfig();
175
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
176
+ const { locale } = useLocale();
177
+ const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
178
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
179
+ const [shouldFocus, setShouldFocus] = useState(false);
180
+ const inputRef = useRef(null);
181
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
182
+ control: props.formControl.control,
183
+ name: props.formControl.name
184
+ }) : props.value;
185
+ let isFormControlDisabled = false;
186
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
187
+ const rawValue = watchedValue ?? props.value ?? null;
166
188
  const formatCalendarDate = (calendarDate) => {
167
189
  if (calendarDate === null) return null;
168
190
  if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
@@ -179,6 +201,65 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
179
201
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
180
202
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
181
203
  };
204
+ useEffect(() => {
205
+ if (!renderInput || !shouldFocus) return;
206
+ requestAnimationFrame(() => {
207
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
208
+ });
209
+ setShouldFocus(false);
210
+ }, [renderInput, shouldFocus]);
211
+ if (!renderInput) {
212
+ const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
213
+ const as = props.as ?? ui.input.as;
214
+ const size = props.size ?? ui.input.size;
215
+ const variant = props.variant ?? ui.input.variant;
216
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
217
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
218
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
219
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
220
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
221
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
222
+ const showDropdown = !props.disableDropdown || disableManualEntry;
223
+ const staticSegments = getStaticCalendarDateSegments({
224
+ value: dateValue,
225
+ locale,
226
+ placeholder: props.placeholder,
227
+ shouldForceLeadingZeros,
228
+ isDisabled,
229
+ hidePlaceholder: as === "floating" && !dateValue
230
+ });
231
+ return /* @__PURE__ */ jsx(InputFrame, {
232
+ ...props,
233
+ isHeaderHidden,
234
+ hideLabel,
235
+ isDisabled,
236
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
237
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
238
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
239
+ labelPlacement: "content-row",
240
+ dataAttributes: {
241
+ dataIsEmpty: dateValue === null,
242
+ dataIsFilled: dateValue !== null,
243
+ dataIsDirty: props.isDirty,
244
+ dataIsRequired: props.isRequired,
245
+ dataIsDisabled: isDisabled,
246
+ dataDisabled: isDisabled,
247
+ dataInvalid: !!props.error,
248
+ dataHasSelection: dateValue !== null
249
+ },
250
+ renderStatic: true,
251
+ onStaticInteract: (focus) => {
252
+ setShouldFocus(focus);
253
+ setRenderInput(true);
254
+ },
255
+ as,
256
+ size,
257
+ variant,
258
+ actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
259
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
260
+ children: staticSegments
261
+ });
262
+ }
182
263
  if ("formControl" in props && props.formControl) {
183
264
  const { formControl, ref, ...innerProps } = props;
184
265
  return /* @__PURE__ */ jsx(Controller, {
@@ -187,7 +268,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
187
268
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
188
269
  ...innerProps,
189
270
  ...dateLimits,
190
- ref: mergeRefs(ref, field.ref),
271
+ ref: mergeRefs(ref, field.ref, inputRef),
191
272
  value: parseCalendarDate(field.value),
192
273
  onChange: (value) => field.onChange(formatCalendarDate(value)),
193
274
  onBlur: field.onBlur,
@@ -200,6 +281,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
200
281
  return /* @__PURE__ */ jsx(DatePickerBase, {
201
282
  ...props,
202
283
  ...dateLimits,
284
+ ref: mergeRefs(props.ref, inputRef),
203
285
  value: parseCalendarDate(props.value),
204
286
  onChange: (value) => props.onChange?.(formatCalendarDate(value))
205
287
  });
@@ -4,6 +4,7 @@ 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, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
7
8
  import { FormFieldProps } from '../../FormField/FormField';
8
9
  import { ControlProps } from '../../shared/form.types';
9
10
  import { InputVariantProps } from '../../shared/input.cva';
@@ -13,9 +14,12 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
13
14
  isClearable?: boolean;
14
15
  hideSidebar?: boolean;
15
16
  className?: string;
16
- todayIcon?: boolean;
17
+ todayIcon?: DatePickerTodayIcon;
18
+ todayIconButtonSize?: DatePickerTodayIconButtonSize;
19
+ todayIconPlacement?: DatePickerTodayIconPlacement;
17
20
  isDirty?: boolean;
18
21
  disableManualEntry?: boolean;
22
+ autoFixYear?: boolean;
19
23
  placeholder?: string;
20
24
  inputClassName?: string;
21
25
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
@@ -32,7 +36,8 @@ export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "va
32
36
  fullIso?: boolean;
33
37
  minValue?: DateValue | string;
34
38
  maxValue?: DateValue | string;
39
+ renderStaticInput?: boolean;
35
40
  }
36
41
  export type ControlledDateRangePickerProps<TFieldValues extends FieldValues> = ControlProps<DateRangePickerProps, TFieldValues>;
37
- export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
42
+ export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
38
43
  export {};
@@ -1,22 +1,27 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
1
2
  import { Typography } from "../../../text/Typography/Typography.js";
2
3
  import { UIConfig } from "../../../../config/uiConfig.context.js";
3
4
  import "../../../../config/i18n.js";
5
+ import { datePickerInputContentRow } from "../shared/datePickerInput.cva.js";
6
+ import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
4
7
  import { DatePickerInput } from "../shared/DatePickerInput.js";
5
8
  import { DateTimeDialog } from "../shared/DateTimeDialog.js";
6
9
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
10
+ import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
11
+ import { getStaticDateRangeSegments } from "../shared/staticDateTimeSegments.js";
7
12
  import { FormField } from "../../FormField/FormField.js";
8
13
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
14
+ import { InputFrame } from "../../Skeleton/InputFrame.js";
9
15
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
10
- import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
11
16
  import { RangeCalendar } from "../shared/RangeCalendar.js";
12
17
  import { jsx, jsxs } from "react/jsx-runtime";
13
18
  import { clsx } from "clsx";
14
- import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
19
+ import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
15
20
  import { Button } from "react-aria-components";
16
21
  import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
17
22
  import { mergeRefs } from "@react-aria/utils";
18
23
  import { useTranslation } from "react-i18next";
19
- import { Controller } from "react-hook-form";
24
+ import { Controller, useWatch } from "react-hook-form";
20
25
  import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
21
26
  import { DateTime } from "luxon";
22
27
  import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
@@ -24,7 +29,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
24
29
  var DateRangePickerBase = (props) => {
25
30
  const ui = UIConfig.useConfig();
26
31
  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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
32
+ 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, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
28
33
  const [validationRangeError, setValidationRangeError] = useState();
29
34
  const datePickerInputRef = useRef(null);
30
35
  const dateRangePickerRef = useMemo(() => ({ get current() {
@@ -484,8 +489,11 @@ var DateRangePickerBase = (props) => {
484
489
  isClearable,
485
490
  headerProps,
486
491
  todayIcon,
492
+ todayIconButtonSize,
493
+ todayIconPlacement,
487
494
  isDirty,
488
495
  disableManualEntry,
496
+ autoFixYear,
489
497
  placeholder,
490
498
  className: inputClassName,
491
499
  onOpenDropdown: () => state.toggle()
@@ -538,7 +546,21 @@ var DateRangePickerBase = (props) => {
538
546
  })
539
547
  });
540
548
  };
541
- var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
549
+ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
550
+ const ui = UIConfig.useConfig();
551
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
552
+ const { locale } = useLocale$1();
553
+ const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
554
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
555
+ const [shouldFocus, setShouldFocus] = useState(false);
556
+ const inputRef = useRef(null);
557
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
558
+ control: props.formControl.control,
559
+ name: props.formControl.name
560
+ }) : props.value;
561
+ let isFormControlDisabled = false;
562
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
563
+ const rawValue = watchedValue ?? props.value ?? null;
542
564
  const formatDateRange = (range) => {
543
565
  if (!range?.start || !range?.end) return null;
544
566
  if (fullIso) return {
@@ -577,6 +599,68 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
577
599
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
578
600
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
579
601
  };
602
+ useEffect(() => {
603
+ if (!renderInput || !shouldFocus) return;
604
+ requestAnimationFrame(() => {
605
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
606
+ });
607
+ setShouldFocus(false);
608
+ }, [renderInput, shouldFocus]);
609
+ if (!renderInput) {
610
+ const startDateValue = parseCalendarDate(rawValue?.start ?? null);
611
+ const endDateValue = parseCalendarDate(rawValue?.end ?? null);
612
+ const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
613
+ const as = props.as ?? ui.input.as;
614
+ const size = props.size ?? ui.input.size;
615
+ const variant = props.variant ?? ui.input.variant;
616
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
617
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
618
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
619
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
620
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
621
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
622
+ const showDropdown = !props.disableDropdown || disableManualEntry;
623
+ const staticSegments = getStaticDateRangeSegments({
624
+ start: startDateValue,
625
+ end: endDateValue,
626
+ locale,
627
+ placeholder: props.placeholder,
628
+ shouldForceLeadingZeros,
629
+ isDisabled,
630
+ hidePlaceholder: as === "floating" && !hasProvidedRangeValue
631
+ });
632
+ return /* @__PURE__ */ jsx(InputFrame, {
633
+ ...props,
634
+ isHeaderHidden,
635
+ hideLabel,
636
+ isDisabled,
637
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
638
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
639
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
640
+ labelPlacement: "content-row",
641
+ dataAttributes: {
642
+ dataIsEmpty: !hasProvidedRangeValue,
643
+ dataIsFilled: hasProvidedRangeValue,
644
+ dataIsDirty: props.isDirty,
645
+ dataIsRequired: props.isRequired,
646
+ dataIsDisabled: isDisabled,
647
+ dataDisabled: isDisabled,
648
+ dataInvalid: !!props.error,
649
+ dataHasSelection: hasProvidedRangeValue
650
+ },
651
+ renderStatic: true,
652
+ onStaticInteract: (focus) => {
653
+ setShouldFocus(focus);
654
+ setRenderInput(true);
655
+ },
656
+ as,
657
+ size,
658
+ variant,
659
+ actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
660
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
661
+ children: staticSegments
662
+ });
663
+ }
580
664
  if ("formControl" in props && props.formControl) {
581
665
  const { formControl, ref, ...innerProps } = props;
582
666
  return /* @__PURE__ */ jsx(Controller, {
@@ -585,7 +669,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
585
669
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
586
670
  ...innerProps,
587
671
  ...dateLimits,
588
- ref: mergeRefs(ref, field.ref),
672
+ ref: mergeRefs(ref, field.ref, inputRef),
589
673
  value: parseDateRange(field.value),
590
674
  onChange: (value) => field.onChange(formatDateRange(value)),
591
675
  onBlur: field.onBlur,
@@ -598,6 +682,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
598
682
  return /* @__PURE__ */ jsx(DateRangePickerBase, {
599
683
  ...props,
600
684
  ...dateLimits,
685
+ ref: mergeRefs(props.ref, inputRef),
601
686
  value: parseDateRange(props.value),
602
687
  onChange: (value) => props.onChange?.(formatDateRange(value))
603
688
  });
@@ -3,6 +3,7 @@ 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, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
6
7
  import { FormFieldProps } from '../../FormField/FormField';
7
8
  import { ControlProps } from '../../shared/form.types';
8
9
  import { InputVariantProps } from '../../shared/input.cva';
@@ -11,9 +12,13 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
11
12
  disableDropdown?: boolean;
12
13
  isTimeOptional?: boolean;
13
14
  isClearable?: boolean;
14
- todayIcon?: boolean;
15
+ todayIcon?: DatePickerTodayIcon;
16
+ todayIconButtonSize?: DatePickerTodayIconButtonSize;
17
+ todayIconPlacement?: DatePickerTodayIconPlacement;
15
18
  isDirty?: boolean;
16
19
  disableManualEntry?: boolean;
20
+ autoFixYear?: boolean;
21
+ setDateValueOnDateSelection?: boolean;
17
22
  placeholder?: string;
18
23
  inputClassName?: string;
19
24
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
@@ -22,7 +27,8 @@ export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "valu
22
27
  value?: string | null;
23
28
  onChange?: (value: string | null) => void;
24
29
  fullIso?: boolean;
30
+ renderStaticInput?: boolean;
25
31
  }
26
32
  export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
27
- export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
28
34
  export {};