@povio/ui 2.2.9-rc.4 → 2.2.9-rc.41

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 (124) 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 +81 -6
  10. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
  11. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -5
  12. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +84 -7
  14. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  15. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +60 -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.d.ts +2 -2
  41. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  42. package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
  43. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  44. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  45. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  46. package/dist/components/inputs/Input/NumberInput/NumberInput.js +78 -7
  47. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
  48. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
  49. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
  50. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +233 -0
  51. package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
  52. package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
  53. package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
  54. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  55. package/dist/components/inputs/Input/TextInput/TextInput.js +77 -7
  56. package/dist/components/inputs/Input/shared/InputContent.js +7 -6
  57. package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
  58. package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
  59. package/dist/components/inputs/Inputs/InputItem.d.ts +12 -9
  60. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  61. package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
  62. package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
  63. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
  64. package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
  65. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  66. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +95 -6
  67. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  68. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +20 -11
  69. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  70. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
  71. package/dist/components/inputs/Selection/Select/QuerySelect.js +22 -36
  72. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  73. package/dist/components/inputs/Selection/Select/Select.js +108 -4
  74. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  75. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  76. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  77. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  78. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  79. package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
  80. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  81. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  82. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  83. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  84. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  85. package/dist/components/inputs/Selection/shared/select.context.js +27 -4
  86. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  87. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  88. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  89. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  90. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
  91. package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
  92. package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
  93. package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
  94. package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
  95. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  96. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  97. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  98. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  99. package/dist/components/inputs/shared/CheckContent.js +3 -4
  100. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  101. package/dist/components/inputs/shared/InputClear.js +13 -1
  102. package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
  103. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  104. package/dist/components/inputs/shared/input.cva.d.ts +10 -0
  105. package/dist/components/inputs/shared/input.cva.js +19 -1
  106. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  107. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  108. package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
  109. package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
  110. package/dist/config/uiConfig.context.d.ts +8 -2
  111. package/dist/config/uiConfig.context.js +12 -1
  112. package/dist/config/uiStyle.context.d.ts +27 -4
  113. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  114. package/dist/hooks/useIntersectionObserver.js +29 -10
  115. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  116. package/dist/hooks/useQueryAutocomplete.js +20 -5
  117. package/dist/index.d.ts +5 -0
  118. package/dist/index.js +3 -2
  119. package/dist/tw-ui-plugin.js +2 -0
  120. package/dist/utils/date-time.utils.d.ts +30 -9
  121. package/dist/utils/date-time.utils.js +113 -1
  122. package/dist/utils/query.utils.d.ts +4 -0
  123. package/dist/utils/query.utils.js +8 -0
  124. 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,24 @@
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";
14
+ import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
8
15
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
- import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
16
  import { jsx, jsxs } from "react/jsx-runtime";
11
17
  import { clsx } from "clsx";
12
- import { useImperativeHandle, useMemo, useRef } from "react";
18
+ import { useImperativeHandle, useMemo, useRef, useState } from "react";
13
19
  import { useDatePicker, useLocale } from "react-aria";
14
20
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller } from "react-hook-form";
21
+ import { Controller, useWatch } from "react-hook-form";
16
22
  import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
17
23
  import { DateTime } from "luxon";
18
24
  import { useCalendarState, useDatePickerState } from "react-stately";
@@ -20,7 +26,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
20
26
  var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
21
27
  var DatePickerBase = (props) => {
22
28
  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;
29
+ 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
30
  const formFieldProps = {
25
31
  error,
26
32
  label,
@@ -131,6 +137,7 @@ var DatePickerBase = (props) => {
131
137
  isDirty,
132
138
  isDisabled,
133
139
  disableManualEntry,
140
+ autoFixYear,
134
141
  isInvalid: !!error,
135
142
  disableDropdown,
136
143
  variant,
@@ -138,6 +145,8 @@ var DatePickerBase = (props) => {
138
145
  isClearable,
139
146
  headerProps,
140
147
  todayIcon,
148
+ todayIconButtonSize,
149
+ todayIconPlacement,
141
150
  onOpenDropdown: () => state.toggle(),
142
151
  placeholder,
143
152
  className: inputClassName
@@ -162,7 +171,28 @@ var DatePickerBase = (props) => {
162
171
  })
163
172
  });
164
173
  };
165
- var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
174
+ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
175
+ const ui = UIConfig.useConfig();
176
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
177
+ const { locale } = useLocale();
178
+ const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
179
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
180
+ const inputRef = useRef(null);
181
+ const { renderRealInput } = useStaticInputHandoff({
182
+ inputRef,
183
+ renderInput,
184
+ setRenderInput,
185
+ getFocusTarget: (input) => {
186
+ return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
187
+ }
188
+ });
189
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
190
+ control: props.formControl.control,
191
+ name: props.formControl.name
192
+ }) : props.value;
193
+ let isFormControlDisabled = false;
194
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
195
+ const rawValue = watchedValue ?? props.value ?? null;
166
196
  const formatCalendarDate = (calendarDate) => {
167
197
  if (calendarDate === null) return null;
168
198
  if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
@@ -179,6 +209,50 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
179
209
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
180
210
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
181
211
  };
212
+ if (!renderInput) {
213
+ const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
214
+ const as = props.as ?? ui.input.as;
215
+ const size = props.size ?? ui.input.size;
216
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
217
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
218
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
219
+ const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
220
+ const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, 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
+ isDisabled,
234
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
235
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
236
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
237
+ labelPlacement: "content-row",
238
+ dataAttributes: {
239
+ dataIsEmpty: dateValue === null,
240
+ dataIsFilled: dateValue !== null,
241
+ dataIsDirty: props.isDirty,
242
+ dataIsRequired: props.isRequired,
243
+ dataIsDisabled: isDisabled,
244
+ dataDisabled: isDisabled,
245
+ dataInvalid: !!props.error,
246
+ dataHasSelection: dateValue !== null
247
+ },
248
+ renderStatic: true,
249
+ onStaticInteract: renderRealInput,
250
+ actionContent: staticTodayIcon,
251
+ actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
252
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
253
+ children: staticSegments
254
+ });
255
+ }
182
256
  if ("formControl" in props && props.formControl) {
183
257
  const { formControl, ref, ...innerProps } = props;
184
258
  return /* @__PURE__ */ jsx(Controller, {
@@ -187,7 +261,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
187
261
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
188
262
  ...innerProps,
189
263
  ...dateLimits,
190
- ref: mergeRefs(ref, field.ref),
264
+ ref: mergeRefs(ref, field.ref, inputRef),
191
265
  value: parseCalendarDate(field.value),
192
266
  onChange: (value) => field.onChange(formatCalendarDate(value)),
193
267
  onBlur: field.onBlur,
@@ -200,6 +274,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
200
274
  return /* @__PURE__ */ jsx(DatePickerBase, {
201
275
  ...props,
202
276
  ...dateLimits,
277
+ ref: mergeRefs(props.ref, inputRef),
203
278
  value: parseCalendarDate(props.value),
204
279
  onChange: (value) => props.onChange?.(formatCalendarDate(value))
205
280
  });
@@ -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,13 +1,19 @@
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";
15
+ import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
9
16
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
10
- import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
11
17
  import { RangeCalendar } from "../shared/RangeCalendar.js";
12
18
  import { jsx, jsxs } from "react/jsx-runtime";
13
19
  import { clsx } from "clsx";
@@ -16,7 +22,7 @@ import { Button } from "react-aria-components";
16
22
  import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
17
23
  import { mergeRefs } from "@react-aria/utils";
18
24
  import { useTranslation } from "react-i18next";
19
- import { Controller } from "react-hook-form";
25
+ import { Controller, useWatch } from "react-hook-form";
20
26
  import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
21
27
  import { DateTime } from "luxon";
22
28
  import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
@@ -24,7 +30,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
24
30
  var DateRangePickerBase = (props) => {
25
31
  const ui = UIConfig.useConfig();
26
32
  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;
33
+ 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
34
  const [validationRangeError, setValidationRangeError] = useState();
29
35
  const datePickerInputRef = useRef(null);
30
36
  const dateRangePickerRef = useMemo(() => ({ get current() {
@@ -484,8 +490,11 @@ var DateRangePickerBase = (props) => {
484
490
  isClearable,
485
491
  headerProps,
486
492
  todayIcon,
493
+ todayIconButtonSize,
494
+ todayIconPlacement,
487
495
  isDirty,
488
496
  disableManualEntry,
497
+ autoFixYear,
489
498
  placeholder,
490
499
  className: inputClassName,
491
500
  onOpenDropdown: () => state.toggle()
@@ -538,7 +547,28 @@ var DateRangePickerBase = (props) => {
538
547
  })
539
548
  });
540
549
  };
541
- var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
550
+ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
551
+ const ui = UIConfig.useConfig();
552
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
553
+ const { locale } = useLocale$1();
554
+ const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
555
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
556
+ const inputRef = useRef(null);
557
+ const { renderRealInput } = useStaticInputHandoff({
558
+ inputRef,
559
+ renderInput,
560
+ setRenderInput,
561
+ getFocusTarget: (input) => {
562
+ return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
563
+ }
564
+ });
565
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
566
+ control: props.formControl.control,
567
+ name: props.formControl.name
568
+ }) : props.value;
569
+ let isFormControlDisabled = false;
570
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
571
+ const rawValue = watchedValue ?? props.value ?? null;
542
572
  const formatDateRange = (range) => {
543
573
  if (!range?.start || !range?.end) return null;
544
574
  if (fullIso) return {
@@ -577,6 +607,53 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
577
607
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
578
608
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
579
609
  };
610
+ if (!renderInput) {
611
+ const startDateValue = parseCalendarDate(rawValue?.start ?? null);
612
+ const endDateValue = parseCalendarDate(rawValue?.end ?? null);
613
+ const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
614
+ const as = props.as ?? ui.input.as;
615
+ const size = props.size ?? ui.input.size;
616
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
617
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
618
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
619
+ const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
620
+ const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, 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
+ isDisabled,
635
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
636
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
637
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
638
+ labelPlacement: "content-row",
639
+ dataAttributes: {
640
+ dataIsEmpty: !hasProvidedRangeValue,
641
+ dataIsFilled: hasProvidedRangeValue,
642
+ dataIsDirty: props.isDirty,
643
+ dataIsRequired: props.isRequired,
644
+ dataIsDisabled: isDisabled,
645
+ dataDisabled: isDisabled,
646
+ dataInvalid: !!props.error,
647
+ dataHasSelection: hasProvidedRangeValue
648
+ },
649
+ renderStatic: true,
650
+ onStaticInteract: renderRealInput,
651
+ actionContent: staticTodayIcon,
652
+ actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
653
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
654
+ children: staticSegments
655
+ });
656
+ }
580
657
  if ("formControl" in props && props.formControl) {
581
658
  const { formControl, ref, ...innerProps } = props;
582
659
  return /* @__PURE__ */ jsx(Controller, {
@@ -585,7 +662,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
585
662
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
586
663
  ...innerProps,
587
664
  ...dateLimits,
588
- ref: mergeRefs(ref, field.ref),
665
+ ref: mergeRefs(ref, field.ref, inputRef),
589
666
  value: parseDateRange(field.value),
590
667
  onChange: (value) => field.onChange(formatDateRange(value)),
591
668
  onBlur: field.onBlur,
@@ -598,6 +675,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
598
675
  return /* @__PURE__ */ jsx(DateRangePickerBase, {
599
676
  ...props,
600
677
  ...dateLimits,
678
+ ref: mergeRefs(props.ref, inputRef),
601
679
  value: parseDateRange(props.value),
602
680
  onChange: (value) => props.onChange?.(formatDateRange(value))
603
681
  });
@@ -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 {};