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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +2 -1
  2. package/dist/components/buttons/Button/Button.js +41 -32
  3. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
  4. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
  5. package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
  6. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
  7. package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
  8. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -3
  9. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +88 -6
  10. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
  11. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +91 -6
  12. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
  14. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  15. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +73 -4
  16. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
  17. package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
  18. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
  19. package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
  20. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
  21. package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
  22. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
  23. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
  24. package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
  25. package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
  26. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -2
  27. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
  28. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
  29. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
  30. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  31. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
  32. package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
  33. package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
  34. package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
  35. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
  36. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
  37. package/dist/components/inputs/File/FileUpload.js +1 -0
  38. package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
  39. package/dist/components/inputs/FormField/FormField.d.ts +3 -3
  40. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  41. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  42. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  43. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  44. package/dist/components/inputs/Input/NumberInput/NumberInput.js +85 -7
  45. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +38 -0
  46. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
  47. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  48. package/dist/components/inputs/Input/TextInput/TextInput.js +88 -7
  49. package/dist/components/inputs/Input/shared/InputContent.js +7 -6
  50. package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
  51. package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
  52. package/dist/components/inputs/Inputs/InputItem.d.ts +15 -18
  53. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  54. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  55. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  56. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  57. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  58. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +104 -6
  59. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  60. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  61. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  62. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -4
  63. package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
  64. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  65. package/dist/components/inputs/Selection/Select/Select.js +119 -4
  66. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  67. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  68. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  69. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  70. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  71. package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
  72. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  73. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  74. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  75. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  76. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  77. package/dist/components/inputs/Selection/shared/select.context.js +27 -4
  78. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  79. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  80. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  81. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  82. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
  83. package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
  84. package/dist/components/inputs/Skeleton/InputFrame.d.ts +68 -0
  85. package/dist/components/inputs/Skeleton/InputFrame.js +171 -0
  86. package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
  87. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  88. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  89. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  90. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  91. package/dist/components/inputs/shared/CheckContent.js +3 -4
  92. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  93. package/dist/components/inputs/shared/InputClear.js +13 -1
  94. package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
  95. package/dist/components/inputs/shared/StaticInput.js +104 -0
  96. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  97. package/dist/components/inputs/shared/input.cva.d.ts +10 -0
  98. package/dist/components/inputs/shared/input.cva.js +19 -1
  99. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  100. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  101. package/dist/config/uiConfig.context.d.ts +8 -2
  102. package/dist/config/uiConfig.context.js +12 -1
  103. package/dist/config/uiStyle.context.d.ts +20 -3
  104. package/dist/helpers/dynamicInputs.d.ts +1 -1
  105. package/dist/helpers/dynamicInputs.js +3 -0
  106. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  107. package/dist/hooks/useIntersectionObserver.js +29 -10
  108. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  109. package/dist/hooks/useQueryAutocomplete.js +13 -3
  110. package/dist/index.d.ts +7 -0
  111. package/dist/index.js +4 -2
  112. package/dist/utils/date-time.utils.d.ts +30 -9
  113. package/dist/utils/date-time.utils.js +113 -1
  114. package/dist/utils/query.utils.d.ts +4 -0
  115. package/dist/utils/query.utils.js +8 -0
  116. package/package.json +1 -1
@@ -1,23 +1,29 @@
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 { getStaticCalendarDateTimeSegments } 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
- import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
16
+ import { clsx } from "clsx";
17
+ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
12
18
  import { useDatePicker, useLocale } from "react-aria";
13
19
  import { mergeRefs } from "@react-aria/utils";
14
- import { Controller } from "react-hook-form";
20
+ import { Controller, useWatch } from "react-hook-form";
15
21
  import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
16
22
  import { useCalendarState, useDatePickerState } from "react-stately";
17
23
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
18
24
  var DateTimePickerBase = (props) => {
19
25
  const ui = UIConfig.useConfig();
20
- 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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
26
+ 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, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
21
27
  const formFieldProps = {
22
28
  error,
23
29
  label,
@@ -153,8 +159,11 @@ var DateTimePickerBase = (props) => {
153
159
  isClearable,
154
160
  headerProps,
155
161
  todayIcon,
162
+ todayIconButtonSize,
163
+ todayIconPlacement,
156
164
  isRequired,
157
165
  disableManualEntry,
166
+ autoFixYear,
158
167
  placeholder,
159
168
  onOpenDropdown: () => state.toggle(),
160
169
  className: inputClassName
@@ -175,13 +184,28 @@ var DateTimePickerBase = (props) => {
175
184
  calendarProps,
176
185
  includesTime: true,
177
186
  datePickerState: dialogState,
178
- onApply
187
+ onApply,
188
+ setDateValueOnDateSelection
179
189
  })
180
190
  })]
181
191
  })
182
192
  });
183
193
  };
184
- var DateTimePicker = ({ fullIso = true, ...props }) => {
194
+ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
195
+ const ui = UIConfig.useConfig();
196
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
197
+ const { locale } = useLocale();
198
+ const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
199
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
200
+ const [shouldFocus, setShouldFocus] = useState(false);
201
+ const inputRef = useRef(null);
202
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
203
+ control: props.formControl.control,
204
+ name: props.formControl.name
205
+ }) : props.value;
206
+ let isFormControlDisabled = false;
207
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
208
+ const rawValue = watchedValue ?? props.value ?? null;
185
209
  const formatDateValue = (dateValue) => {
186
210
  if (dateValue === null) return null;
187
211
  if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
@@ -191,6 +215,65 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
191
215
  if (isoString == null) return isoString;
192
216
  return DateTimeUtils.fromUTCISOToCalendarDateTime(isoString);
193
217
  };
218
+ useEffect(() => {
219
+ if (!renderInput || !shouldFocus) return;
220
+ requestAnimationFrame(() => {
221
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
222
+ });
223
+ setShouldFocus(false);
224
+ }, [renderInput, shouldFocus]);
225
+ if (!renderInput) {
226
+ const dateTimeValue = rawValue ? parseDateValue(rawValue) : null;
227
+ const as = props.as ?? ui.input.as;
228
+ const size = props.size ?? ui.input.size;
229
+ const variant = props.variant ?? ui.input.variant;
230
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
231
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
232
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
233
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
234
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
235
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
236
+ const showDropdown = !props.disableDropdown || disableManualEntry;
237
+ const staticSegments = getStaticCalendarDateTimeSegments({
238
+ value: dateTimeValue,
239
+ locale,
240
+ placeholder: props.placeholder,
241
+ shouldForceLeadingZeros,
242
+ isDisabled,
243
+ hidePlaceholder: as === "floating" && !dateTimeValue
244
+ });
245
+ return /* @__PURE__ */ jsx(InputFrame, {
246
+ ...props,
247
+ isHeaderHidden,
248
+ hideLabel,
249
+ isDisabled,
250
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
251
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
252
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
253
+ labelPlacement: "content-row",
254
+ dataAttributes: {
255
+ dataIsEmpty: dateTimeValue === null,
256
+ dataIsFilled: dateTimeValue !== null,
257
+ dataIsDirty: props.isDirty,
258
+ dataIsRequired: props.isRequired,
259
+ dataIsDisabled: isDisabled,
260
+ dataDisabled: isDisabled,
261
+ dataInvalid: !!props.error,
262
+ dataHasSelection: dateTimeValue !== null
263
+ },
264
+ renderStatic: true,
265
+ onStaticInteract: (focus) => {
266
+ setShouldFocus(focus);
267
+ setRenderInput(true);
268
+ },
269
+ as,
270
+ size,
271
+ variant,
272
+ actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
273
+ trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
274
+ children: staticSegments
275
+ });
276
+ }
194
277
  if ("formControl" in props && props.formControl) {
195
278
  const { formControl, ref, ...innerProps } = props;
196
279
  return /* @__PURE__ */ jsx(Controller, {
@@ -198,7 +281,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
198
281
  name: formControl.name,
199
282
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
200
283
  ...innerProps,
201
- ref: mergeRefs(ref, field.ref),
284
+ ref: mergeRefs(ref, field.ref, inputRef),
202
285
  value: parseDateValue(field.value),
203
286
  onChange: (value) => field.onChange(formatDateValue(value)),
204
287
  onBlur: field.onBlur,
@@ -210,6 +293,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
210
293
  }
211
294
  return /* @__PURE__ */ jsx(DateTimePickerBase, {
212
295
  ...props,
296
+ ref: mergeRefs(props.ref, inputRef),
213
297
  value: parseDateValue(props.value),
214
298
  onChange: (value) => props.onChange?.(formatDateValue(value))
215
299
  });
@@ -19,7 +19,8 @@ export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "on
19
19
  value?: string | null;
20
20
  onChange?: (value: string | null) => void;
21
21
  fullIso?: boolean;
22
+ renderStaticInput?: boolean;
22
23
  }
23
24
  export type ControlledTimePickerProps<TFieldValues extends FieldValues> = ControlProps<TimePickerProps, TFieldValues>;
24
- 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;
25
26
  export {};
@@ -2,17 +2,19 @@ import { UIConfig } from "../../../../config/uiConfig.context.js";
2
2
  import { TimePickerForm } from "../shared/TimePickerForm.js";
3
3
  import { DateTimeDialog } from "../shared/DateTimeDialog.js";
4
4
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
5
+ import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
6
+ import { getStaticTimeSegments } from "../shared/staticDateTimeSegments.js";
5
7
  import { FormField } from "../../FormField/FormField.js";
6
8
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
9
+ import { InputFrame } from "../../Skeleton/InputFrame.js";
7
10
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
8
- import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
9
11
  import { TimePickerInput } from "../shared/TimePickerInput.js";
10
12
  import { jsx, jsxs } from "react/jsx-runtime";
11
13
  import { clsx } from "clsx";
12
14
  import { useEffect, useRef, useState } from "react";
13
15
  import { useLocale, useTimeField } from "react-aria";
14
16
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller } from "react-hook-form";
17
+ import { Controller, useWatch } from "react-hook-form";
16
18
  import { getLocalTimeZone, now, toTime } from "@internationalized/date";
17
19
  import { DateTime } from "luxon";
18
20
  import { useTimeFieldState } from "react-stately";
@@ -136,7 +138,19 @@ var TimePickerBase = (props) => {
136
138
  })
137
139
  });
138
140
  };
139
- var TimePicker = (props) => {
141
+ var TimePicker = ({ renderStaticInput, ...props }) => {
142
+ const ui = UIConfig.useConfig();
143
+ const { locale } = useLocale();
144
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
145
+ const [shouldFocus, setShouldFocus] = useState(false);
146
+ const inputRef = useRef(null);
147
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
148
+ control: props.formControl.control,
149
+ name: props.formControl.name
150
+ }) : props.value;
151
+ let isFormControlDisabled = false;
152
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
153
+ const rawValue = watchedValue ?? props.value ?? null;
140
154
  const formatTimeValue = (timeValue) => {
141
155
  if (timeValue === null) return null;
142
156
  const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
@@ -147,6 +161,60 @@ var TimePicker = (props) => {
147
161
  if (isoString == null) return isoString;
148
162
  return toTime(DateTimeUtils.fromISOtoZonedDateTime(isoString));
149
163
  };
164
+ useEffect(() => {
165
+ if (!renderInput || !shouldFocus) return;
166
+ requestAnimationFrame(() => {
167
+ (inputRef.current?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
168
+ });
169
+ setShouldFocus(false);
170
+ }, [renderInput, shouldFocus]);
171
+ if (!renderInput) {
172
+ const timeValue = rawValue ? parseTimeValue(rawValue) : null;
173
+ const as = props.as ?? ui.input.as;
174
+ const size = props.size ?? ui.input.size;
175
+ const variant = props.variant ?? ui.input.variant;
176
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
177
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
178
+ const isDisabled = isFormControlDisabled || !!props.isDisabled;
179
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
180
+ const showDropdown = !props.disableDropdown || disableManualEntry;
181
+ const staticSegments = getStaticTimeSegments({
182
+ value: timeValue,
183
+ locale,
184
+ placeholder: props.placeholder,
185
+ isDisabled,
186
+ hidePlaceholder: as === "floating" && !timeValue
187
+ });
188
+ return /* @__PURE__ */ jsx(InputFrame, {
189
+ ...props,
190
+ isHeaderHidden,
191
+ hideLabel,
192
+ isDisabled,
193
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
194
+ inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
195
+ labelPlacement: "content-row",
196
+ dataAttributes: {
197
+ dataIsEmpty: timeValue === null,
198
+ dataIsFilled: timeValue !== null,
199
+ dataIsDirty: props.isDirty,
200
+ dataIsRequired: props.isRequired,
201
+ dataIsDisabled: isDisabled,
202
+ dataDisabled: isDisabled,
203
+ dataInvalid: !!props.error,
204
+ dataHasSelection: timeValue !== null
205
+ },
206
+ renderStatic: true,
207
+ onStaticInteract: (focus) => {
208
+ setShouldFocus(focus);
209
+ setRenderInput(true);
210
+ },
211
+ as,
212
+ size,
213
+ variant,
214
+ trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0,
215
+ children: staticSegments
216
+ });
217
+ }
150
218
  if ("formControl" in props && props.formControl) {
151
219
  const { formControl, ref, ...innerProps } = props;
152
220
  return /* @__PURE__ */ jsx(Controller, {
@@ -154,7 +222,7 @@ var TimePicker = (props) => {
154
222
  name: formControl.name,
155
223
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TimePickerBase, {
156
224
  ...innerProps,
157
- ref: mergeRefs(ref, field.ref),
225
+ ref: mergeRefs(ref, field.ref, inputRef),
158
226
  value: parseTimeValue(field.value),
159
227
  onChange: (value) => field.onChange(formatTimeValue(value)),
160
228
  onBlur: field.onBlur,
@@ -166,6 +234,7 @@ var TimePicker = (props) => {
166
234
  }
167
235
  return /* @__PURE__ */ jsx(TimePickerBase, {
168
236
  ...props,
237
+ ref: mergeRefs(props.ref, inputRef),
169
238
  value: parseTimeValue(props.value),
170
239
  onChange: (value) => props.onChange?.(formatTimeValue(value))
171
240
  });
@@ -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,4 +1,5 @@
1
1
  import { DateSegmentItem } from "./DateSegmentItem.js";
2
+ import { getTimeSegmentValue } from "./dateSegment.utils.js";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  import { clsx } from "clsx";
4
5
  import { useEffect, useImperativeHandle, useRef } from "react";
@@ -31,16 +32,8 @@ var DateField = ({ ref, onClearChange, hidePlaceholder, isDisabled, disableManua
31
32
  const isDayFilled = daySegment && !daySegment.isPlaceholder;
32
33
  const isYearEmpty = yearSegment && !(parseInt(yearSegment.text) && yearSegment.text?.length === 4);
33
34
  const isHourEmpty = hourSegment && !parseInt(hourSegment.text);
34
- if (minuteSegment && !parseInt(minuteSegment.text)) {
35
- let minute = minuteSegment?.value || 0;
36
- if (minuteSegment?.text?.length && minuteSegment?.text?.length > 0) minute = parseInt(minuteSegment?.text ?? "00");
37
- state.setSegment("minute", minute);
38
- }
39
- if (isHourEmpty) {
40
- let hour = hourSegment?.value || 0;
41
- if (hourSegment?.text?.length && hourSegment?.text?.length > 0) hour = parseInt(hourSegment?.text ?? "00");
42
- state.setSegment("hour", hour);
43
- }
35
+ if (minuteSegment && !parseInt(minuteSegment.text)) state.setSegment("minute", getTimeSegmentValue(minuteSegment));
36
+ if (isHourEmpty) state.setSegment("hour", getTimeSegmentValue(hourSegment));
44
37
  if (isMonthFilled && isDayFilled && isYearEmpty) {
45
38
  let year = (/* @__PURE__ */ new Date()).getFullYear();
46
39
  if (yearSegment?.text?.length && yearSegment?.text?.length === 2) year = parseInt(`20${yearSegment?.text}`);
@@ -1,5 +1,6 @@
1
1
  import { Ref } from 'react';
2
2
  import { DatePickerAria } from 'react-aria';
3
+ import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } 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,16 @@ 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;
24
+ todayIconPlacement?: DatePickerTodayIconPlacement;
22
25
  isDirty?: boolean;
23
26
  isRequired?: boolean;
24
27
  disableManualEntry?: boolean;
28
+ autoFixYear?: boolean;
25
29
  placeholder?: string;
26
30
  className?: string;
27
31
  onOpenDropdown?: () => void;
28
32
  }
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;
33
+ export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, todayIconPlacement, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
30
34
  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", todayIconPlacement = "content", 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
  }
@@ -70,17 +71,28 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
70
71
  endFieldProps?.onBlur?.(null);
71
72
  };
72
73
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
74
+ const todayIconComponent = getDatePickerTodayIcon(todayIcon);
75
+ const todayIconButton = todayIconComponent ? /* @__PURE__ */ jsx(InlineIconButton, {
76
+ label: "",
77
+ icon: todayIconComponent,
78
+ size: todayIconButtonSize,
79
+ onPress: onToday,
80
+ className: "relative z-1 !border-none"
81
+ }) : null;
82
+ const shouldRenderTodayIconWithFieldLabel = todayIconPlacement === "fieldLabel";
83
+ const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
73
84
  return /* @__PURE__ */ jsxs("div", {
74
85
  ref: containerRef,
75
- className: clsx(inputBaseCva({
86
+ className: clsx("group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", inputBaseCva({
76
87
  variant,
77
88
  as,
78
89
  ...props
79
- }), "group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", className),
90
+ }), className),
80
91
  "data-rac": "",
81
92
  "data-datetime-input": "",
82
93
  "data-hovered": isHovered || void 0,
83
94
  "data-disabled": isDisabled || void 0,
95
+ "data-is-disabled": isDisabled || void 0,
84
96
  "data-invalid": isInvalid || void 0,
85
97
  "data-is-empty": fieldProps.value === null || void 0,
86
98
  "data-focus-within": isFocused || void 0,
@@ -93,54 +105,52 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
93
105
  ...focusWithinProps,
94
106
  ...hoverProps,
95
107
  children: [/* @__PURE__ */ jsxs("div", {
96
- className: clsx(inputSizeCva({
108
+ className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
97
109
  size,
98
110
  as
99
- }), "flex w-full items-center gap-input-gap-input-text-to-elements pr-0!"),
100
- children: [as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
101
- as,
102
- ...headerProps
103
- }), /* @__PURE__ */ jsxs("div", {
104
- className: "flex items-center gap-input-gap-input-text-to-elements",
105
- children: [
106
- disableManualEntry && /* @__PURE__ */ jsx(Button, {
107
- onPress: onOpenDropdown,
108
- className: "absolute inset-0 z-0",
109
- isDisabled
110
- }),
111
- todayIcon && /* @__PURE__ */ jsx(IconButton, {
112
- label: "",
113
- icon: TodayIcon,
114
- size: "none",
115
- onPress: onToday,
116
- className: "relative z-1"
117
- }),
118
- disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
119
- size: "label-1",
120
- className: "text-text-default-3",
121
- children: placeholder
122
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DateField, {
123
- ref: dateFieldRef,
124
- ...fieldProps,
125
- isDisabled,
126
- isInvalid,
127
- onClearChange,
128
- hidePlaceholder,
129
- disableManualEntry
130
- }), endFieldProps && /* @__PURE__ */ jsxs(Fragment, { children: [!((as === "floating" || as === "filter") && hidePlaceholder) && /* @__PURE__ */ jsx("span", {
131
- className: clsx("pointer-events-none select-none", isDisabled && "text-interactive-text-secondary-disabled"),
132
- children: "–"
133
- }), /* @__PURE__ */ jsx(DateField, {
134
- ref: endDateFieldRef,
135
- ...endFieldProps,
136
- isDisabled,
137
- isInvalid,
138
- onClearChange,
139
- hidePlaceholder,
140
- disableManualEntry
141
- })] })] })
142
- ]
143
- })]
111
+ })),
112
+ children: [
113
+ as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
114
+ as,
115
+ ...headerProps
116
+ }),
117
+ shouldRenderTodayIconWithFieldLabel && todayIconButton,
118
+ /* @__PURE__ */ jsxs("div", {
119
+ className: datePickerInputContentRowCva({ size }),
120
+ children: [
121
+ disableManualEntry && /* @__PURE__ */ jsx(Button, {
122
+ onPress: onOpenDropdown,
123
+ className: "absolute inset-0 z-0",
124
+ isDisabled
125
+ }),
126
+ !shouldRenderTodayIconWithFieldLabel && todayIconButton,
127
+ disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
128
+ size: "label-1",
129
+ className: "text-text-default-3",
130
+ children: placeholder
131
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DateField, {
132
+ ref: dateFieldRef,
133
+ ...fieldProps,
134
+ isDisabled,
135
+ isInvalid,
136
+ onClearChange,
137
+ hidePlaceholder,
138
+ disableManualEntry
139
+ }), endFieldProps && /* @__PURE__ */ jsxs(Fragment, { children: [!((as === "floating" || as === "filter") && hidePlaceholder) && /* @__PURE__ */ jsx("span", {
140
+ className: clsx("pointer-events-none select-none", isDisabled && "text-interactive-text-secondary-disabled"),
141
+ children: "–"
142
+ }), /* @__PURE__ */ jsx(DateField, {
143
+ ref: endDateFieldRef,
144
+ ...endFieldProps,
145
+ isDisabled,
146
+ isInvalid,
147
+ onClearChange,
148
+ hidePlaceholder,
149
+ disableManualEntry
150
+ })] })] })
151
+ ]
152
+ })
153
+ ]
144
154
  }), /* @__PURE__ */ jsxs("div", {
145
155
  className: clsx(inputSizeCva({
146
156
  size,
@@ -153,7 +163,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
153
163
  label: "",
154
164
  color: "secondary",
155
165
  ...buttonProps,
156
- icon: isDateTime ? DateTimeIcon : CalendarIcon,
166
+ icon: pickerIcon,
157
167
  isDisabled,
158
168
  className: "border-0!"
159
169
  })]
@@ -1,4 +1,5 @@
1
1
  import { DateFieldState, DateSegment } from '@react-stately/datepicker';
2
+ import { HTMLAttributes, ReactNode, Ref } from 'react';
2
3
  interface DateSegmentProps {
3
4
  state: DateFieldState;
4
5
  segment: DateSegment;
@@ -8,4 +9,17 @@ interface DateSegmentProps {
8
9
  }
9
10
  export declare const getPlaceholder: (segment: DateSegment) => string | null;
10
11
  export declare const DateSegmentItem: ({ segment, state, isDisabled, timePickerOnly, hidePlaceholder }: DateSegmentProps) => import("react/jsx-runtime").JSX.Element;
12
+ interface DateSegmentItemViewProps {
13
+ ref?: Ref<HTMLDivElement>;
14
+ segmentProps?: HTMLAttributes<HTMLDivElement>;
15
+ type?: DateSegment["type"];
16
+ text: ReactNode;
17
+ placeholder?: ReactNode;
18
+ isPlaceholder?: boolean;
19
+ isInputEmpty?: boolean;
20
+ isDisabled?: boolean;
21
+ timePickerOnly?: boolean;
22
+ hidePlaceholder?: boolean;
23
+ }
24
+ export declare const DateSegmentItemView: ({ ref, segmentProps, type, text, placeholder, isPlaceholder, isInputEmpty, isDisabled, timePickerOnly, hidePlaceholder, }: DateSegmentItemViewProps) => import("react/jsx-runtime").JSX.Element;
11
25
  export {};