@povio/ui 2.2.9-rc.2 → 2.2.9-rc.20

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 (92) hide show
  1. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -1
  2. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
  3. package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
  4. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
  5. package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
  6. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +9 -4
  7. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +96 -9
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +9 -4
  9. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +114 -7
  10. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +10 -4
  11. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
  12. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
  13. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +80 -6
  14. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
  15. package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
  16. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
  17. package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
  18. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
  19. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +5 -2
  20. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +21 -12
  21. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +7 -3
  22. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +3 -0
  23. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
  24. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
  25. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  26. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
  27. package/dist/components/inputs/FormField/FormField.d.ts +3 -3
  28. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  29. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  30. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  31. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  32. package/dist/components/inputs/Input/NumberInput/NumberInput.js +92 -8
  33. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  34. package/dist/components/inputs/Input/TextInput/TextInput.js +95 -8
  35. package/dist/components/inputs/Inputs/InputItem.d.ts +14 -18
  36. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  37. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  38. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  39. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  40. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +86 -6
  41. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  42. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  43. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  44. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -2
  45. package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -3
  46. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  47. package/dist/components/inputs/Selection/Select/Select.js +84 -4
  48. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  49. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  50. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  51. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  52. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  53. package/dist/components/inputs/Selection/shared/SelectInput.js +12 -2
  54. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  55. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  56. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  57. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  58. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  59. package/dist/components/inputs/Selection/shared/select.context.js +22 -4
  60. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  61. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  62. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  63. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  64. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +35 -0
  65. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  66. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  67. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  68. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  69. package/dist/components/inputs/shared/CheckContent.js +3 -4
  70. package/dist/components/inputs/shared/StaticInput.d.ts +34 -0
  71. package/dist/components/inputs/shared/StaticInput.js +88 -0
  72. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  73. package/dist/components/inputs/shared/input.cva.d.ts +5 -0
  74. package/dist/components/inputs/shared/input.cva.js +10 -1
  75. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  76. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  77. package/dist/config/uiConfig.context.d.ts +8 -2
  78. package/dist/config/uiConfig.context.js +11 -1
  79. package/dist/config/uiStyle.context.d.ts +19 -3
  80. package/dist/helpers/dynamicInputs.d.ts +5 -5
  81. package/dist/helpers/dynamicInputs.js +3 -0
  82. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  83. package/dist/hooks/useIntersectionObserver.js +29 -10
  84. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  85. package/dist/hooks/useQueryAutocomplete.js +13 -3
  86. package/dist/index.d.ts +5 -0
  87. package/dist/index.js +3 -2
  88. package/dist/utils/date-time.utils.d.ts +10 -0
  89. package/dist/utils/date-time.utils.js +87 -1
  90. package/dist/utils/query.utils.d.ts +4 -0
  91. package/dist/utils/query.utils.js +8 -0
  92. package/package.json +1 -1
@@ -1,22 +1,27 @@
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";
6
9
  import { FormField } from "../../FormField/FormField.js";
10
+ import { StaticInput } from "../../shared/StaticInput.js";
7
11
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
12
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
8
13
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
9
14
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
15
+ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
11
16
  import { useDatePicker, useLocale } from "react-aria";
12
17
  import { mergeRefs } from "@react-aria/utils";
13
- import { Controller } from "react-hook-form";
18
+ import { Controller, useWatch } from "react-hook-form";
14
19
  import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
15
20
  import { useCalendarState, useDatePickerState } from "react-stately";
16
21
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
17
22
  var DateTimePickerBase = (props) => {
18
23
  const ui = UIConfig.useConfig();
19
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, 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;
24
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
20
25
  const formFieldProps = {
21
26
  error,
22
27
  label,
@@ -37,6 +42,10 @@ var DateTimePickerBase = (props) => {
37
42
  useImperativeHandle(ref, () => ({ clear: () => {
38
43
  datePickerInputRef.current?.clear();
39
44
  } }));
45
+ const handleBlur = (val) => {
46
+ onBlur?.({ target: { value: val } });
47
+ };
48
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
40
49
  const dialogState = useDatePickerState({
41
50
  ...rest,
42
51
  defaultValue: value || rest.defaultValue,
@@ -56,6 +65,7 @@ var DateTimePickerBase = (props) => {
56
65
  onChange?.(val);
57
66
  dialogState.setValue(val);
58
67
  calendarState.setFocusedDate(val || today(getLocalTimeZone()));
68
+ debouncedBlur(val);
59
69
  },
60
70
  shouldCloseOnSelect: false,
61
71
  granularity: "minute",
@@ -91,8 +101,10 @@ var DateTimePickerBase = (props) => {
91
101
  labelProps
92
102
  };
93
103
  const onApply = () => {
94
- state.setValue(dialogState.value);
104
+ const newValue = dialogState.value;
105
+ state.setValue(newValue);
95
106
  state.toggle();
107
+ handleBlur(newValue);
96
108
  };
97
109
  const onTodayPress = () => {
98
110
  dialogState.setValue(toCalendarDateTime(now(getLocalTimeZone())));
@@ -145,8 +157,10 @@ var DateTimePickerBase = (props) => {
145
157
  isClearable,
146
158
  headerProps,
147
159
  todayIcon,
160
+ todayIconButtonSize,
148
161
  isRequired,
149
162
  disableManualEntry,
163
+ autoFixYear,
150
164
  placeholder,
151
165
  onOpenDropdown: () => state.toggle(),
152
166
  className: inputClassName
@@ -167,13 +181,27 @@ var DateTimePickerBase = (props) => {
167
181
  calendarProps,
168
182
  includesTime: true,
169
183
  datePickerState: dialogState,
170
- onApply
184
+ onApply,
185
+ setDateValueOnDateSelection
171
186
  })
172
187
  })]
173
188
  })
174
189
  });
175
190
  };
176
- var DateTimePicker = ({ fullIso = true, ...props }) => {
191
+ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
192
+ const ui = UIConfig.useConfig();
193
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
194
+ const { locale } = useLocale();
195
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
196
+ const [shouldFocus, setShouldFocus] = useState(false);
197
+ const inputRef = useRef(null);
198
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
199
+ control: props.formControl.control,
200
+ name: props.formControl.name
201
+ }) : props.value;
202
+ let isFormControlDisabled = false;
203
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
204
+ const rawValue = watchedValue ?? props.value ?? null;
177
205
  const formatDateValue = (dateValue) => {
178
206
  if (dateValue === null) return null;
179
207
  if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
@@ -183,6 +211,61 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
183
211
  if (isoString == null) return isoString;
184
212
  return DateTimeUtils.fromUTCISOToCalendarDateTime(isoString);
185
213
  };
214
+ useEffect(() => {
215
+ if (!renderInput || !shouldFocus) return;
216
+ requestAnimationFrame(() => {
217
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
218
+ });
219
+ setShouldFocus(false);
220
+ }, [renderInput, shouldFocus]);
221
+ if (!renderInput) {
222
+ const as = props.as ?? ui.input.as;
223
+ const size = props.size ?? ui.input.size;
224
+ const variant = props.variant ?? ui.input.variant;
225
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
226
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
227
+ let isDisabled = !!props.isDisabled;
228
+ if (isFormControlDisabled) isDisabled = true;
229
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
230
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
231
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
232
+ const showDropdown = !props.disableDropdown || disableManualEntry;
233
+ const staticDateTimeValue = rawValue ? parseDateValue(rawValue) : null;
234
+ const displayValue = staticDateTimeValue && "hour" in staticDateTimeValue ? DateTimeUtils.formatCalendarDateTimeLocalized(staticDateTimeValue, locale) : "";
235
+ const staticPlaceholder = rawValue ? "" : props.placeholder ?? DateTimeUtils.getDateTimePlaceholder(locale);
236
+ return /* @__PURE__ */ jsx(StaticInput, {
237
+ ...props,
238
+ onInteract: (focus) => {
239
+ setShouldFocus(focus);
240
+ setRenderInput(true);
241
+ },
242
+ className: props.className ? `relative inline-flex w-full flex-col text-left ${props.className}` : "relative inline-flex w-full flex-col text-left",
243
+ as,
244
+ size,
245
+ variant,
246
+ applyMinInputWidth: true,
247
+ hideLabel,
248
+ isHeaderHidden,
249
+ isDisabled,
250
+ placeholder: staticPlaceholder,
251
+ displayValue,
252
+ isEmpty: !displayValue,
253
+ dataAttributes: {
254
+ dataIsEmpty: staticDateTimeValue === null,
255
+ dataIsFilled: staticDateTimeValue !== null,
256
+ dataIsDirty: props.isDirty,
257
+ dataIsRequired: props.isRequired,
258
+ dataIsDisabled: isDisabled,
259
+ dataDisabled: isDisabled,
260
+ dataInvalid: !!props.error,
261
+ dataHasSelection: staticDateTimeValue !== null
262
+ },
263
+ contentRowClassName: datePickerInputContentRowCva({ size }),
264
+ leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
265
+ leadingContentClassName: "ml-0!",
266
+ trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0
267
+ });
268
+ }
186
269
  if ("formControl" in props && props.formControl) {
187
270
  const { formControl, ref, ...innerProps } = props;
188
271
  return /* @__PURE__ */ jsx(Controller, {
@@ -190,7 +273,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
190
273
  name: formControl.name,
191
274
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
192
275
  ...innerProps,
193
- ref: mergeRefs(ref, field.ref),
276
+ ref: mergeRefs(ref, field.ref, inputRef),
194
277
  value: parseDateValue(field.value),
195
278
  onChange: (value) => field.onChange(formatDateValue(value)),
196
279
  onBlur: field.onBlur,
@@ -202,6 +285,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
202
285
  }
203
286
  return /* @__PURE__ */ jsx(DateTimePickerBase, {
204
287
  ...props,
288
+ ref: mergeRefs(props.ref, inputRef),
205
289
  value: parseDateValue(props.value),
206
290
  onChange: (value) => props.onChange?.(formatDateValue(value))
207
291
  });
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
1
+ import { Ref, FocusEvent } from 'react';
2
2
  import { AriaTimeFieldProps, TimeValue } from 'react-aria';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
5
5
  import { ControlProps } from '../../shared/form.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
7
- interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label"> {
7
+ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label" | "onBlur"> {
8
8
  ref?: Ref<HTMLDivElement>;
9
9
  disableDropdown?: boolean;
10
10
  date?: string | null;
@@ -13,12 +13,14 @@ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Ar
13
13
  disableManualEntry?: boolean;
14
14
  placeholder?: string;
15
15
  inputClassName?: string;
16
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
16
17
  }
17
18
  export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {
18
19
  value?: string | null;
19
20
  onChange?: (value: string | null) => void;
20
21
  fullIso?: boolean;
22
+ renderStaticInput?: boolean;
21
23
  }
22
24
  export type ControlledTimePickerProps<TFieldValues extends FieldValues> = ControlProps<TimePickerProps, TFieldValues>;
23
- export declare const TimePicker: <TFieldValues extends FieldValues>(props: ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const TimePicker: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
24
26
  export {};
@@ -3,7 +3,9 @@ import { TimePickerForm } from "../shared/TimePickerForm.js";
3
3
  import { DateTimeDialog } from "../shared/DateTimeDialog.js";
4
4
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
5
5
  import { FormField } from "../../FormField/FormField.js";
6
+ import { StaticInput } from "../../shared/StaticInput.js";
6
7
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
7
9
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
8
10
  import { TimePickerInput } from "../shared/TimePickerInput.js";
9
11
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -11,14 +13,14 @@ import { clsx } from "clsx";
11
13
  import { useEffect, useRef, useState } from "react";
12
14
  import { useLocale, useTimeField } from "react-aria";
13
15
  import { mergeRefs } from "@react-aria/utils";
14
- import { Controller } from "react-hook-form";
16
+ import { Controller, useWatch } from "react-hook-form";
15
17
  import { getLocalTimeZone, now, toTime } from "@internationalized/date";
16
18
  import { DateTime } from "luxon";
17
19
  import { useTimeFieldState } from "react-stately";
18
20
  //#region src/components/inputs/DateTime/TimePicker/TimePicker.tsx
19
21
  var TimePickerBase = (props) => {
20
22
  const ui = UIConfig.useConfig();
21
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
23
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
22
24
  const formFieldProps = {
23
25
  error,
24
26
  label,
@@ -40,11 +42,18 @@ var TimePickerBase = (props) => {
40
42
  defaultValue: value || rest.defaultValue,
41
43
  locale
42
44
  });
45
+ const handleBlur = (val) => {
46
+ onBlur?.({ target: { value: val } });
47
+ };
48
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
43
49
  const state = useTimeFieldState({
44
50
  ...rest,
45
51
  isDisabled,
46
52
  value,
47
- onChange,
53
+ onChange: (val) => {
54
+ onChange?.(val);
55
+ debouncedBlur(val);
56
+ },
48
57
  locale
49
58
  });
50
59
  useEffect(() => {
@@ -72,8 +81,10 @@ var TimePickerBase = (props) => {
72
81
  labelProps
73
82
  };
74
83
  const onApply = () => {
75
- state.setValue(dialogState.value);
84
+ const newValue = dialogState.value;
85
+ state.setValue(newValue);
76
86
  setIsOpen(false);
87
+ handleBlur(newValue);
77
88
  };
78
89
  const onOpenChange = (open) => {
79
90
  setIsOpen(open);
@@ -126,7 +137,19 @@ var TimePickerBase = (props) => {
126
137
  })
127
138
  });
128
139
  };
129
- var TimePicker = (props) => {
140
+ var TimePicker = ({ renderStaticInput, ...props }) => {
141
+ const ui = UIConfig.useConfig();
142
+ const { locale } = useLocale();
143
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
144
+ const [shouldFocus, setShouldFocus] = useState(false);
145
+ const inputRef = useRef(null);
146
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
147
+ control: props.formControl.control,
148
+ name: props.formControl.name
149
+ }) : props.value;
150
+ let isFormControlDisabled = false;
151
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
152
+ const rawValue = watchedValue ?? props.value ?? null;
130
153
  const formatTimeValue = (timeValue) => {
131
154
  if (timeValue === null) return null;
132
155
  const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
@@ -137,6 +160,56 @@ var TimePicker = (props) => {
137
160
  if (isoString == null) return isoString;
138
161
  return toTime(DateTimeUtils.fromISOtoZonedDateTime(isoString));
139
162
  };
163
+ useEffect(() => {
164
+ if (!renderInput || !shouldFocus) return;
165
+ requestAnimationFrame(() => {
166
+ (inputRef.current?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
167
+ });
168
+ setShouldFocus(false);
169
+ }, [renderInput, shouldFocus]);
170
+ if (!renderInput) {
171
+ const as = props.as ?? ui.input.as;
172
+ const size = props.size ?? ui.input.size;
173
+ const variant = props.variant ?? ui.input.variant;
174
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
175
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
176
+ let isDisabled = !!props.isDisabled;
177
+ if (isFormControlDisabled) isDisabled = true;
178
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
179
+ const showDropdown = !props.disableDropdown || disableManualEntry;
180
+ const staticTimeValue = rawValue ? parseTimeValue(rawValue) : null;
181
+ const displayValue = staticTimeValue ? DateTimeUtils.formatTimeLocalized(staticTimeValue, locale) : "";
182
+ const staticPlaceholder = rawValue ? "" : props.placeholder ?? DateTimeUtils.getTimePlaceholder(locale);
183
+ return /* @__PURE__ */ jsx(StaticInput, {
184
+ ...props,
185
+ onInteract: (focus) => {
186
+ setShouldFocus(focus);
187
+ setRenderInput(true);
188
+ },
189
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
190
+ as,
191
+ size,
192
+ variant,
193
+ applyMinInputWidth: true,
194
+ hideLabel,
195
+ isHeaderHidden,
196
+ isDisabled,
197
+ placeholder: staticPlaceholder,
198
+ displayValue,
199
+ isEmpty: !displayValue,
200
+ dataAttributes: {
201
+ dataIsEmpty: staticTimeValue === null,
202
+ dataIsFilled: staticTimeValue !== null,
203
+ dataIsDirty: props.isDirty,
204
+ dataIsRequired: props.isRequired,
205
+ dataIsDisabled: isDisabled,
206
+ dataDisabled: isDisabled,
207
+ dataInvalid: !!props.error,
208
+ dataHasSelection: staticTimeValue !== null
209
+ },
210
+ trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0
211
+ });
212
+ }
140
213
  if ("formControl" in props && props.formControl) {
141
214
  const { formControl, ref, ...innerProps } = props;
142
215
  return /* @__PURE__ */ jsx(Controller, {
@@ -144,7 +217,7 @@ var TimePicker = (props) => {
144
217
  name: formControl.name,
145
218
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TimePickerBase, {
146
219
  ...innerProps,
147
- ref: mergeRefs(ref, field.ref),
220
+ ref: mergeRefs(ref, field.ref, inputRef),
148
221
  value: parseTimeValue(field.value),
149
222
  onChange: (value) => field.onChange(formatTimeValue(value)),
150
223
  onBlur: field.onBlur,
@@ -156,6 +229,7 @@ var TimePicker = (props) => {
156
229
  }
157
230
  return /* @__PURE__ */ jsx(TimePickerBase, {
158
231
  ...props,
232
+ ref: mergeRefs(props.ref, inputRef),
159
233
  value: parseTimeValue(props.value),
160
234
  onChange: (value) => props.onChange?.(formatTimeValue(value))
161
235
  });
@@ -1,4 +1,5 @@
1
1
  import { CalendarState, CalendarStateOptions } from '@react-stately/calendar';
2
+ import { DateValue } from 'react-aria';
2
3
  import { DatePickerState } from 'react-stately';
3
4
  type DateTimeCalendarProps = {
4
5
  includesTime?: false;
@@ -13,8 +14,10 @@ type CalendarProps = DateTimeCalendarProps & {
13
14
  className?: string;
14
15
  state: CalendarState;
15
16
  calendarProps: Omit<CalendarStateOptions, "locale" | "createCalendar">;
16
- onApply: () => void;
17
+ onApply: (selectedDate?: DateValue) => void;
18
+ onDateSelectionChange?: (selectedDate: DateValue) => void;
19
+ setDateValueOnDateSelection?: boolean;
17
20
  };
18
21
  export type ToggleState = "month" | "year" | "time";
19
- export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, onDateSelectionChange, setDateValueOnDateSelection, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
20
23
  export {};
@@ -5,20 +5,37 @@ import { TimePickerForm } from "./TimePickerForm.js";
5
5
  import { YearPicker } from "./YearPicker.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
- import { useState } from "react";
8
+ import { useCallback, useState } from "react";
9
9
  import { useCalendar } from "@react-aria/calendar";
10
10
  //#region src/components/inputs/DateTime/shared/Calendar.tsx
11
- var Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }) => {
11
+ var Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, onDateSelectionChange, setDateValueOnDateSelection = false, ...props }) => {
12
12
  const [toggleState, setToggleState] = useState(null);
13
13
  const { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(props.calendarProps, props.state);
14
- const handleDateChange = () => {
15
- if (includesTime && !datePickerState.value) setToggleState("time");
16
- else onApply();
14
+ const onDateSelection = useCallback((date) => {
15
+ if (!includesTime || !setDateValueOnDateSelection) return;
16
+ datePickerState.setDateValue(date);
17
+ }, [
18
+ includesTime,
19
+ datePickerState,
20
+ setDateValueOnDateSelection
21
+ ]);
22
+ const handleDateChange = (selectedDate) => {
23
+ const resolvedDate = selectedDate ?? props.state.focusedDate;
24
+ if (includesTime && resolvedDate && setDateValueOnDateSelection) {
25
+ datePickerState.setDateValue(resolvedDate);
26
+ onDateSelectionChange?.(resolvedDate);
27
+ }
28
+ if (includesTime && toggleState !== "time") {
29
+ setToggleState("time");
30
+ return;
31
+ }
32
+ if (datePickerState?.value && !setDateValueOnDateSelection) onApply(resolvedDate);
17
33
  };
18
34
  const getContent = () => {
19
35
  if (!toggleState) return /* @__PURE__ */ jsx(CalendarGrid, {
20
36
  state: props.state,
21
- onApply: handleDateChange
37
+ onApply: handleDateChange,
38
+ onDateSelection
22
39
  });
23
40
  if (toggleState === "month") return /* @__PURE__ */ jsx(MonthPicker, {
24
41
  state: props.state,
@@ -4,7 +4,7 @@ import { KeyboardEvent } from 'react';
4
4
  import { DateValue } from 'react-aria';
5
5
  interface CalendarCellProps extends AriaCalendarCellProps {
6
6
  state: CalendarState | RangeCalendarState;
7
- onApply?: () => void;
7
+ onApply?: (selectedDate?: DateValue) => void;
8
8
  shouldCloseOnSelect?: boolean;
9
9
  onDateSelection?: (date: DateValue) => void;
10
10
  onDateHover?: (date: DateValue | null) => void;
@@ -17,12 +17,12 @@ var CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelectio
17
17
  const onClick = useCallback((event) => {
18
18
  buttonProps.onClick?.(event);
19
19
  if (onDateSelection) onDateSelection(props.date);
20
- if (isSelected && shouldCloseOnSelect) onApply?.();
20
+ if (shouldCloseOnSelect && !isDisabled) onApply?.(props.date);
21
21
  }, [
22
22
  buttonProps,
23
23
  onDateSelection,
24
24
  props.date,
25
- isSelected,
25
+ isDisabled,
26
26
  shouldCloseOnSelect,
27
27
  onApply
28
28
  ]);
@@ -87,7 +87,7 @@ var CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelectio
87
87
  state.setFocusedDate(props.date);
88
88
  }
89
89
  eventHandler?.(event);
90
- if (isSelected && shouldCloseOnSelect) onApply?.();
90
+ if (isSelected && shouldCloseOnSelect) onApply?.(props.date);
91
91
  };
92
92
  const onMouseEnter = useCallback(() => {
93
93
  if (onDateHover && selectionState.isSelectingMode) onDateHover(props.date);
@@ -4,7 +4,7 @@ import { KeyboardEvent } from 'react';
4
4
  import { DateValue } from 'react-aria';
5
5
  interface CalendarGridProps extends AriaCalendarGridProps {
6
6
  state: CalendarState | RangeCalendarState;
7
- onApply?: () => void;
7
+ onApply?: (selectedDate?: DateValue) => void;
8
8
  offset?: {
9
9
  months?: number;
10
10
  };
@@ -1,5 +1,6 @@
1
1
  import { Ref } from 'react';
2
2
  import { DatePickerAria } from 'react-aria';
3
+ import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from './datePicker.types';
3
4
  import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
4
5
  import { InputVariantProps } from '../../shared/input.cva';
5
6
  export interface DatePickerInputHandle {
@@ -18,13 +19,15 @@ interface DatePickerInputProps extends InputVariantProps {
18
19
  isDateTime?: boolean;
19
20
  isClearable?: boolean;
20
21
  headerProps?: FormFieldHeaderProps;
21
- todayIcon?: boolean;
22
+ todayIcon?: DatePickerTodayIcon;
23
+ todayIconButtonSize?: DatePickerTodayIconButtonSize;
22
24
  isDirty?: boolean;
23
25
  isRequired?: boolean;
24
26
  disableManualEntry?: boolean;
27
+ autoFixYear?: boolean;
25
28
  placeholder?: string;
26
29
  className?: string;
27
30
  onOpenDropdown?: () => void;
28
31
  }
29
- export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, placeholder, className, onOpenDropdown, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
30
33
  export {};
@@ -1,11 +1,10 @@
1
- import { CalendarIcon } from "../../../../assets/icons/Calendar.js";
2
- import { DateTimeIcon } from "../../../../assets/icons/DateTime.js";
3
1
  import { UIStyle } from "../../../../config/uiStyle.context.js";
4
2
  import { Typography } from "../../../text/Typography/Typography.js";
5
- import { IconButton } from "../../../buttons/IconButton/IconButton.js";
3
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
6
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
7
- import { TodayIcon } from "../../../../assets/icons/Today.js";
8
5
  import { DateField } from "./DateField.js";
6
+ import { datePickerInputContentRow } from "./datePickerInput.cva.js";
7
+ import { getDatePickerTodayIcon } from "./datePickerTodayIcon.js";
9
8
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
10
9
  import { InputClear } from "../../shared/InputClear.js";
11
10
  import { inputBase, inputSize } from "../../shared/input.cva.js";
@@ -16,15 +15,17 @@ import { Button } from "react-aria-components";
16
15
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
17
16
  import { getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
18
17
  //#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
19
- var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, placeholder, className, onOpenDropdown, ...props }) => {
18
+ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize = "none", isDirty, isRequired, disableManualEntry, autoFixYear = false, placeholder, className, onOpenDropdown, ...props }) => {
19
+ const uiConfig = UIConfig.useConfig();
20
20
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
21
21
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
22
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
22
23
  const [canClear, setCanClear] = useState(false);
23
24
  const { hoverProps, isHovered } = useHover({ isDisabled });
24
25
  const [isFocused, setIsFocused] = useState(false);
25
26
  const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: (isFocusWithin) => {
26
27
  setIsFocused(isFocusWithin);
27
- if (!isFocusWithin) {
28
+ if (!isFocusWithin && autoFixYear) {
28
29
  dateFieldRef.current?.autoFixYear();
29
30
  endDateFieldRef.current?.autoFixYear();
30
31
  }
@@ -41,6 +42,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
41
42
  if (endFieldProps) endFieldProps.onChange?.(null);
42
43
  setCanClear(false);
43
44
  fieldProps.onBlur?.(null);
45
+ endFieldProps?.onBlur?.(null);
44
46
  },
45
47
  getContainer: () => containerRef.current
46
48
  }));
@@ -51,7 +53,10 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
51
53
  dateFieldRef.current?.clearField();
52
54
  fieldProps.onChange?.(null);
53
55
  endDateFieldRef.current?.clearField();
56
+ endFieldProps?.onChange?.(null);
54
57
  setCanClear(false);
58
+ fieldProps.onBlur?.(null);
59
+ endFieldProps?.onBlur?.(null);
55
60
  };
56
61
  const onToday = () => {
57
62
  if (isDateTime) {
@@ -62,8 +67,12 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
62
67
  fieldProps.onChange?.(today(getLocalTimeZone()));
63
68
  if (endFieldProps) endFieldProps.onChange?.(today(getLocalTimeZone()));
64
69
  }
70
+ fieldProps.onBlur?.(null);
71
+ endFieldProps?.onBlur?.(null);
65
72
  };
66
73
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
74
+ const todayIconComponent = getDatePickerTodayIcon(todayIcon);
75
+ const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
67
76
  return /* @__PURE__ */ jsxs("div", {
68
77
  ref: containerRef,
69
78
  className: clsx(inputBaseCva({
@@ -95,19 +104,19 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
95
104
  as,
96
105
  ...headerProps
97
106
  }), /* @__PURE__ */ jsxs("div", {
98
- className: "flex items-center gap-input-gap-input-text-to-elements",
107
+ className: datePickerInputContentRowCva({ size }),
99
108
  children: [
100
109
  disableManualEntry && /* @__PURE__ */ jsx(Button, {
101
110
  onPress: onOpenDropdown,
102
111
  className: "absolute inset-0 z-0",
103
112
  isDisabled
104
113
  }),
105
- todayIcon && /* @__PURE__ */ jsx(IconButton, {
114
+ todayIconComponent && /* @__PURE__ */ jsx(InlineIconButton, {
106
115
  label: "",
107
- icon: TodayIcon,
108
- size: "none",
116
+ icon: todayIconComponent,
117
+ size: todayIconButtonSize,
109
118
  onPress: onToday,
110
- className: "relative z-1"
119
+ className: "relative z-1 !border-none"
111
120
  }),
112
121
  disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
113
122
  size: "label-1",
@@ -147,7 +156,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
147
156
  label: "",
148
157
  color: "secondary",
149
158
  ...buttonProps,
150
- icon: isDateTime ? DateTimeIcon : CalendarIcon,
159
+ icon: pickerIcon,
151
160
  isDisabled,
152
161
  className: "border-0!"
153
162
  })]
@@ -1,6 +1,6 @@
1
- import { ClockIcon } from "../../../../assets/icons/Clock.js";
2
1
  import { UIStyle } from "../../../../config/uiStyle.context.js";
3
2
  import { Typography } from "../../../text/Typography/Typography.js";
3
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
4
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
5
5
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
6
6
  import { InputClear } from "../../shared/InputClear.js";
@@ -13,6 +13,7 @@ import { Button } from "react-aria-components";
13
13
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
14
14
  //#region src/components/inputs/DateTime/shared/TimePickerInput.tsx
15
15
  var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }) => {
16
+ const uiConfig = UIConfig.useConfig();
16
17
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
17
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
18
19
  const { hoverProps, isHovered } = useHover({ isDisabled });
@@ -74,13 +75,16 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
74
75
  as
75
76
  }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
76
77
  children: [isClearable && /* @__PURE__ */ jsx(InputClear, {
77
- onClear: () => state.setValue(null),
78
+ onClear: () => {
79
+ state.setValue(null);
80
+ fieldProps.onBlur?.(null);
81
+ },
78
82
  show: canClear
79
83
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
80
84
  label: "",
81
85
  color: "secondary",
82
86
  onPress,
83
- icon: ClockIcon,
87
+ icon: uiConfig.dateInput.timeIcon,
84
88
  isDisabled,
85
89
  className: "border-0!"
86
90
  })]
@@ -0,0 +1,3 @@
1
+ import { IconButtonProps } from '../../../buttons/IconButton/IconButton';
2
+ export type DatePickerTodayIcon = boolean | IconButtonProps["icon"];
3
+ export type DatePickerTodayIconButtonSize = IconButtonProps["size"];
@@ -0,0 +1,7 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import { InputSizeProps } from '../../shared/input.cva';
3
+ export declare const datePickerInputContentRow: (props?: ({
4
+ size?: "small" | "default" | "extra-small" | "large" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ export interface DatePickerInputContentRowProps extends VariantProps<typeof datePickerInputContentRow>, InputSizeProps {
7
+ }
@@ -0,0 +1,13 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/DateTime/shared/datePickerInput.cva.ts
3
+ var datePickerInputContentRow = cva("flex items-center gap-input-gap-input-text-to-elements", {
4
+ variants: { size: {
5
+ "extra-small": "",
6
+ small: "",
7
+ default: "",
8
+ large: ""
9
+ } },
10
+ defaultVariants: { size: "default" }
11
+ });
12
+ //#endregion
13
+ export { datePickerInputContentRow };