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

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 (117) 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 +80 -6
  10. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
  11. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -6
  12. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +83 -7
  14. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  15. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +64 -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 +76 -7
  45. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
  46. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
  47. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
  48. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +232 -0
  49. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  50. package/dist/components/inputs/Input/TextInput/TextInput.js +79 -7
  51. package/dist/components/inputs/Input/shared/InputContent.js +7 -6
  52. package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
  53. package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
  54. package/dist/components/inputs/Inputs/InputItem.d.ts +15 -18
  55. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  56. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  57. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  58. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  59. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  60. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +99 -6
  61. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  62. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  63. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  64. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -4
  65. package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
  66. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  67. package/dist/components/inputs/Selection/Select/Select.js +112 -4
  68. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  69. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  70. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  71. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  72. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  73. package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
  74. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  75. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  76. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  77. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  78. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  79. package/dist/components/inputs/Selection/shared/select.context.js +27 -4
  80. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  81. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  82. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  83. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  84. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
  85. package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
  86. package/dist/components/inputs/Skeleton/InputFrame.d.ts +68 -0
  87. package/dist/components/inputs/Skeleton/InputFrame.js +178 -0
  88. package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
  89. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  90. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  91. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  92. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  93. package/dist/components/inputs/shared/CheckContent.js +3 -4
  94. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  95. package/dist/components/inputs/shared/InputClear.js +13 -1
  96. package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
  97. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  98. package/dist/components/inputs/shared/input.cva.d.ts +10 -0
  99. package/dist/components/inputs/shared/input.cva.js +19 -1
  100. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  101. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  102. package/dist/config/uiConfig.context.d.ts +8 -2
  103. package/dist/config/uiConfig.context.js +12 -1
  104. package/dist/config/uiStyle.context.d.ts +20 -3
  105. package/dist/helpers/dynamicInputs.d.ts +1 -1
  106. package/dist/helpers/dynamicInputs.js +3 -0
  107. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  108. package/dist/hooks/useIntersectionObserver.js +29 -10
  109. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  110. package/dist/hooks/useQueryAutocomplete.js +13 -3
  111. package/dist/index.d.ts +7 -0
  112. package/dist/index.js +4 -2
  113. package/dist/utils/date-time.utils.d.ts +30 -9
  114. package/dist/utils/date-time.utils.js +113 -1
  115. package/dist/utils/query.utils.d.ts +4 -0
  116. package/dist/utils/query.utils.js +8 -0
  117. 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,57 @@ 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 isDisabled = isFormControlDisabled || !!props.isDisabled;
216
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
217
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
218
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
219
+ const showDropdown = !props.disableDropdown || disableManualEntry;
220
+ const staticSegments = getStaticCalendarDateSegments({
221
+ value: dateValue,
222
+ locale,
223
+ placeholder: props.placeholder,
224
+ shouldForceLeadingZeros,
225
+ isDisabled,
226
+ hidePlaceholder: as === "floating" && !dateValue
227
+ });
228
+ return /* @__PURE__ */ jsx(InputFrame, {
229
+ ...props,
230
+ isDisabled,
231
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
232
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
233
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
234
+ labelPlacement: "content-row",
235
+ dataAttributes: {
236
+ dataIsEmpty: dateValue === null,
237
+ dataIsFilled: dateValue !== null,
238
+ dataIsDirty: props.isDirty,
239
+ dataIsRequired: props.isRequired,
240
+ dataIsDisabled: isDisabled,
241
+ dataDisabled: isDisabled,
242
+ dataInvalid: !!props.error,
243
+ dataHasSelection: dateValue !== null
244
+ },
245
+ renderStatic: true,
246
+ onStaticInteract: (focus) => {
247
+ setShouldFocus(focus);
248
+ setRenderInput(true);
249
+ },
250
+ actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
251
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
252
+ children: staticSegments
253
+ });
254
+ }
182
255
  if ("formControl" in props && props.formControl) {
183
256
  const { formControl, ref, ...innerProps } = props;
184
257
  return /* @__PURE__ */ jsx(Controller, {
@@ -187,7 +260,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
187
260
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
188
261
  ...innerProps,
189
262
  ...dateLimits,
190
- ref: mergeRefs(ref, field.ref),
263
+ ref: mergeRefs(ref, field.ref, inputRef),
191
264
  value: parseCalendarDate(field.value),
192
265
  onChange: (value) => field.onChange(formatCalendarDate(value)),
193
266
  onBlur: field.onBlur,
@@ -200,6 +273,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
200
273
  return /* @__PURE__ */ jsx(DatePickerBase, {
201
274
  ...props,
202
275
  ...dateLimits,
276
+ ref: mergeRefs(props.ref, inputRef),
203
277
  value: parseCalendarDate(props.value),
204
278
  onChange: (value) => props.onChange?.(formatCalendarDate(value))
205
279
  });
@@ -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,60 @@ 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 isDisabled = isFormControlDisabled || !!props.isDisabled;
616
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
617
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
618
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
619
+ const showDropdown = !props.disableDropdown || disableManualEntry;
620
+ const staticSegments = getStaticDateRangeSegments({
621
+ start: startDateValue,
622
+ end: endDateValue,
623
+ locale,
624
+ placeholder: props.placeholder,
625
+ shouldForceLeadingZeros,
626
+ isDisabled,
627
+ hidePlaceholder: as === "floating" && !hasProvidedRangeValue
628
+ });
629
+ return /* @__PURE__ */ jsx(InputFrame, {
630
+ ...props,
631
+ isDisabled,
632
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
633
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
634
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
635
+ labelPlacement: "content-row",
636
+ dataAttributes: {
637
+ dataIsEmpty: !hasProvidedRangeValue,
638
+ dataIsFilled: hasProvidedRangeValue,
639
+ dataIsDirty: props.isDirty,
640
+ dataIsRequired: props.isRequired,
641
+ dataIsDisabled: isDisabled,
642
+ dataDisabled: isDisabled,
643
+ dataInvalid: !!props.error,
644
+ dataHasSelection: hasProvidedRangeValue
645
+ },
646
+ renderStatic: true,
647
+ onStaticInteract: (focus) => {
648
+ setShouldFocus(focus);
649
+ setRenderInput(true);
650
+ },
651
+ actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
652
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
653
+ children: staticSegments
654
+ });
655
+ }
580
656
  if ("formControl" in props && props.formControl) {
581
657
  const { formControl, ref, ...innerProps } = props;
582
658
  return /* @__PURE__ */ jsx(Controller, {
@@ -585,7 +661,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
585
661
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
586
662
  ...innerProps,
587
663
  ...dateLimits,
588
- ref: mergeRefs(ref, field.ref),
664
+ ref: mergeRefs(ref, field.ref, inputRef),
589
665
  value: parseDateRange(field.value),
590
666
  onChange: (value) => field.onChange(formatDateRange(value)),
591
667
  onBlur: field.onBlur,
@@ -598,6 +674,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
598
674
  return /* @__PURE__ */ jsx(DateRangePickerBase, {
599
675
  ...props,
600
676
  ...dateLimits,
677
+ ref: mergeRefs(props.ref, inputRef),
601
678
  value: parseDateRange(props.value),
602
679
  onChange: (value) => props.onChange?.(formatDateRange(value))
603
680
  });
@@ -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 {};