@povio/ui 2.2.9-rc.15 → 2.2.9-rc.17

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 (35) hide show
  1. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +3 -2
  2. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +66 -4
  3. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
  4. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +95 -4
  5. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
  6. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +66 -4
  7. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  8. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +57 -3
  9. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +6 -5
  10. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +3 -2
  11. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  12. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
  13. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  14. package/dist/components/inputs/Input/NumberInput/NumberInput.js +80 -8
  15. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  16. package/dist/components/inputs/Input/TextInput/TextInput.js +83 -8
  17. package/dist/components/inputs/Inputs/InputItem.d.ts +6 -6
  18. package/dist/components/inputs/RadioGroup/RadioGroup.js +15 -12
  19. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -1
  20. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +69 -3
  21. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -10
  22. package/dist/components/inputs/Selection/Select/Select.d.ts +3 -1
  23. package/dist/components/inputs/Selection/Select/Select.js +69 -3
  24. package/dist/components/inputs/Selection/shared/SelectInput.js +3 -1
  25. package/dist/components/inputs/shared/StaticInput.d.ts +21 -0
  26. package/dist/components/inputs/shared/StaticInput.js +79 -0
  27. package/dist/components/inputs/shared/input.cva.d.ts +5 -0
  28. package/dist/components/inputs/shared/input.cva.js +10 -1
  29. package/dist/components/inputs/shared/tooltipWrapper.cva.js +1 -1
  30. package/dist/config/uiConfig.context.d.ts +5 -1
  31. package/dist/config/uiConfig.context.js +7 -0
  32. package/dist/config/uiStyle.context.d.ts +2 -1
  33. package/dist/utils/date-time.utils.d.ts +10 -0
  34. package/dist/utils/date-time.utils.js +82 -1
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
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';
@@ -27,7 +27,8 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
27
27
  fullIso?: boolean;
28
28
  minValue?: DateValue | string;
29
29
  maxValue?: DateValue | string;
30
+ renderStaticInput?: boolean;
30
31
  }
31
32
  export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
32
- export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
33
34
  export {};
@@ -1,18 +1,22 @@
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";
8
12
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
13
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
14
  import { jsx, jsxs } from "react/jsx-runtime";
11
15
  import { clsx } from "clsx";
12
- import { useImperativeHandle, useMemo, useRef } from "react";
16
+ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
13
17
  import { useDatePicker, useLocale } from "react-aria";
14
18
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller } from "react-hook-form";
19
+ import { Controller, useWatch } from "react-hook-form";
16
20
  import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
17
21
  import { DateTime } from "luxon";
18
22
  import { useCalendarState, useDatePickerState } from "react-stately";
@@ -164,7 +168,20 @@ var DatePickerBase = (props) => {
164
168
  })
165
169
  });
166
170
  };
167
- var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
171
+ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
172
+ const ui = UIConfig.useConfig();
173
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
174
+ const { locale } = useLocale();
175
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
176
+ const [shouldFocus, setShouldFocus] = useState(false);
177
+ const inputRef = useRef(null);
178
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
179
+ control: props.formControl.control,
180
+ name: props.formControl.name
181
+ }) : props.value;
182
+ let isFormControlDisabled = false;
183
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
184
+ const rawValue = watchedValue ?? props.value ?? null;
168
185
  const formatCalendarDate = (calendarDate) => {
169
186
  if (calendarDate === null) return null;
170
187
  if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
@@ -181,6 +198,50 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
181
198
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
182
199
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
183
200
  };
201
+ useEffect(() => {
202
+ if (!renderInput || !shouldFocus) return;
203
+ requestAnimationFrame(() => {
204
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
205
+ });
206
+ setShouldFocus(false);
207
+ }, [renderInput, shouldFocus]);
208
+ if (!renderInput) {
209
+ const as = props.as ?? ui.input.as;
210
+ const size = props.size ?? ui.input.size;
211
+ const variant = props.variant ?? ui.input.variant;
212
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
213
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
214
+ let isDisabled = !!props.isDisabled;
215
+ if (isFormControlDisabled) isDisabled = true;
216
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
217
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
218
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
219
+ const showDropdown = !props.disableDropdown || disableManualEntry;
220
+ const staticPlaceholder = props.placeholder ?? DateTimeUtils.getDatePlaceholder(locale);
221
+ const staticDateValue = rawValue ? parseCalendarDate(rawValue) : null;
222
+ const displayValue = staticDateValue ? DateTimeUtils.formatCalendarDateLocalized(staticDateValue, locale) : "";
223
+ return /* @__PURE__ */ jsx(StaticInput, {
224
+ ...props,
225
+ onInteract: (focus) => {
226
+ setShouldFocus(focus);
227
+ setRenderInput(true);
228
+ },
229
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
230
+ as,
231
+ size,
232
+ variant,
233
+ applyMinInputWidth: true,
234
+ hideLabel,
235
+ isHeaderHidden,
236
+ isDisabled,
237
+ placeholder: staticPlaceholder,
238
+ displayValue,
239
+ isEmpty: !displayValue,
240
+ contentRowClassName: datePickerInputContentRowCva({ size }),
241
+ leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
242
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
243
+ });
244
+ }
184
245
  if ("formControl" in props && props.formControl) {
185
246
  const { formControl, ref, ...innerProps } = props;
186
247
  return /* @__PURE__ */ jsx(Controller, {
@@ -189,7 +250,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
189
250
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
190
251
  ...innerProps,
191
252
  ...dateLimits,
192
- ref: mergeRefs(ref, field.ref),
253
+ ref: mergeRefs(ref, field.ref, inputRef),
193
254
  value: parseCalendarDate(field.value),
194
255
  onChange: (value) => field.onChange(formatCalendarDate(value)),
195
256
  onBlur: field.onBlur,
@@ -202,6 +263,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
202
263
  return /* @__PURE__ */ jsx(DatePickerBase, {
203
264
  ...props,
204
265
  ...dateLimits,
266
+ ref: mergeRefs(props.ref, inputRef),
205
267
  value: parseCalendarDate(props.value),
206
268
  onChange: (value) => props.onChange?.(formatCalendarDate(value))
207
269
  });
@@ -35,7 +35,8 @@ export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "va
35
35
  fullIso?: boolean;
36
36
  minValue?: DateValue | string;
37
37
  maxValue?: DateValue | string;
38
+ renderStaticInput?: boolean;
38
39
  }
39
40
  export type ControlledDateRangePickerProps<TFieldValues extends FieldValues> = ControlProps<DateRangePickerProps, TFieldValues>;
40
- export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
41
+ export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
41
42
  export {};
@@ -1,22 +1,26 @@
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";
7
10
  import { FormField } from "../../FormField/FormField.js";
11
+ import { StaticInput } from "../../shared/StaticInput.js";
8
12
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
9
13
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
10
14
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
11
15
  import { RangeCalendar } from "../shared/RangeCalendar.js";
12
16
  import { jsx, jsxs } from "react/jsx-runtime";
13
17
  import { clsx } from "clsx";
14
- import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
18
+ import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
15
19
  import { Button } from "react-aria-components";
16
20
  import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
17
21
  import { mergeRefs } from "@react-aria/utils";
18
22
  import { useTranslation } from "react-i18next";
19
- import { Controller } from "react-hook-form";
23
+ import { Controller, useWatch } from "react-hook-form";
20
24
  import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
21
25
  import { DateTime } from "luxon";
22
26
  import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
@@ -540,7 +544,20 @@ var DateRangePickerBase = (props) => {
540
544
  })
541
545
  });
542
546
  };
543
- var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
547
+ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
548
+ const ui = UIConfig.useConfig();
549
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
550
+ const { locale } = useLocale$1();
551
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
552
+ const [shouldFocus, setShouldFocus] = useState(false);
553
+ const inputRef = useRef(null);
554
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
555
+ control: props.formControl.control,
556
+ name: props.formControl.name
557
+ }) : props.value;
558
+ let isFormControlDisabled = false;
559
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
560
+ const rawValue = watchedValue ?? props.value ?? null;
544
561
  const formatDateRange = (range) => {
545
562
  if (!range?.start || !range?.end) return null;
546
563
  if (fullIso) return {
@@ -579,6 +596,79 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
579
596
  minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
580
597
  maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
581
598
  };
599
+ useEffect(() => {
600
+ if (!renderInput || !shouldFocus) return;
601
+ requestAnimationFrame(() => {
602
+ ((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
603
+ });
604
+ setShouldFocus(false);
605
+ }, [renderInput, shouldFocus]);
606
+ if (!renderInput) {
607
+ const as = props.as ?? ui.input.as;
608
+ const size = props.size ?? ui.input.size;
609
+ const variant = props.variant ?? ui.input.variant;
610
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
611
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
612
+ let isDisabled = !!props.isDisabled;
613
+ if (isFormControlDisabled) isDisabled = true;
614
+ const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
615
+ const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
616
+ const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
617
+ const showDropdown = !props.disableDropdown || disableManualEntry;
618
+ const defaultDatePlaceholder = DateTimeUtils.getDatePlaceholder(locale);
619
+ const staticPlaceholder = props.placeholder ?? /* @__PURE__ */ jsxs("span", {
620
+ className: "inline-flex items-center gap-input-gap-input-text-to-elements",
621
+ children: [
622
+ /* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder }),
623
+ /* @__PURE__ */ jsx("span", {
624
+ className: "pointer-events-none select-none",
625
+ children: "–"
626
+ }),
627
+ /* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder })
628
+ ]
629
+ });
630
+ const formatStaticDate = (value) => {
631
+ if (!value) return "";
632
+ const parsedDate = parseCalendarDate(value);
633
+ if (!parsedDate) return "";
634
+ return DateTimeUtils.formatCalendarDateLocalized(parsedDate, locale);
635
+ };
636
+ const start = formatStaticDate(rawValue?.start ?? null);
637
+ const end = formatStaticDate(rawValue?.end ?? null);
638
+ const hasRangeValue = !!(start && end);
639
+ const displayValue = hasRangeValue ? /* @__PURE__ */ jsxs("span", {
640
+ className: "inline-flex items-center gap-input-gap-input-text-to-elements",
641
+ children: [
642
+ /* @__PURE__ */ jsx("span", { children: start }),
643
+ /* @__PURE__ */ jsx("span", {
644
+ className: "pointer-events-none select-none",
645
+ children: "–"
646
+ }),
647
+ /* @__PURE__ */ jsx("span", { children: end })
648
+ ]
649
+ }) : void 0;
650
+ return /* @__PURE__ */ jsx(StaticInput, {
651
+ ...props,
652
+ onInteract: (focus) => {
653
+ setShouldFocus(focus);
654
+ setRenderInput(true);
655
+ },
656
+ className: clsx("relative inline-flex w-full flex-col text-left", props.className),
657
+ as,
658
+ size,
659
+ variant,
660
+ applyMinInputWidth: true,
661
+ hideLabel,
662
+ isHeaderHidden,
663
+ isDisabled,
664
+ placeholder: staticPlaceholder,
665
+ displayValue,
666
+ isEmpty: !hasRangeValue,
667
+ contentRowClassName: datePickerInputContentRowCva({ size }),
668
+ leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
669
+ trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
670
+ });
671
+ }
582
672
  if ("formControl" in props && props.formControl) {
583
673
  const { formControl, ref, ...innerProps } = props;
584
674
  return /* @__PURE__ */ jsx(Controller, {
@@ -587,7 +677,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
587
677
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
588
678
  ...innerProps,
589
679
  ...dateLimits,
590
- ref: mergeRefs(ref, field.ref),
680
+ ref: mergeRefs(ref, field.ref, inputRef),
591
681
  value: parseDateRange(field.value),
592
682
  onChange: (value) => field.onChange(formatDateRange(value)),
593
683
  onBlur: field.onBlur,
@@ -600,6 +690,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
600
690
  return /* @__PURE__ */ jsx(DateRangePickerBase, {
601
691
  ...props,
602
692
  ...dateLimits,
693
+ ref: mergeRefs(props.ref, inputRef),
603
694
  value: parseDateRange(props.value),
604
695
  onChange: (value) => props.onChange?.(formatDateRange(value))
605
696
  });
@@ -26,7 +26,8 @@ export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "valu
26
26
  value?: string | null;
27
27
  onChange?: (value: string | null) => void;
28
28
  fullIso?: boolean;
29
+ renderStaticInput?: boolean;
29
30
  }
30
31
  export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
31
- export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
32
33
  export {};
@@ -1,17 +1,21 @@
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";
8
12
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
13
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
14
  import { jsx, jsxs } from "react/jsx-runtime";
11
- import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
15
+ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
12
16
  import { useDatePicker, useLocale } from "react-aria";
13
17
  import { mergeRefs } from "@react-aria/utils";
14
- import { Controller } from "react-hook-form";
18
+ import { Controller, useWatch } from "react-hook-form";
15
19
  import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
16
20
  import { useCalendarState, useDatePickerState } from "react-stately";
17
21
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
@@ -184,7 +188,20 @@ var DateTimePickerBase = (props) => {
184
188
  })
185
189
  });
186
190
  };
187
- 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;
188
205
  const formatDateValue = (dateValue) => {
189
206
  if (dateValue === null) return null;
190
207
  if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
@@ -194,6 +211,50 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
194
211
  if (isoString == null) return isoString;
195
212
  return DateTimeUtils.fromUTCISOToCalendarDateTime(isoString);
196
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 staticPlaceholder = props.placeholder ?? DateTimeUtils.getDateTimePlaceholder(locale);
234
+ const staticDateTimeValue = rawValue ? parseDateValue(rawValue) : null;
235
+ const displayValue = staticDateTimeValue && "hour" in staticDateTimeValue ? DateTimeUtils.formatCalendarDateTimeLocalized(staticDateTimeValue, 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
+ contentRowClassName: datePickerInputContentRowCva({ size }),
254
+ leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
255
+ trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0
256
+ });
257
+ }
197
258
  if ("formControl" in props && props.formControl) {
198
259
  const { formControl, ref, ...innerProps } = props;
199
260
  return /* @__PURE__ */ jsx(Controller, {
@@ -201,7 +262,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
201
262
  name: formControl.name,
202
263
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
203
264
  ...innerProps,
204
- ref: mergeRefs(ref, field.ref),
265
+ ref: mergeRefs(ref, field.ref, inputRef),
205
266
  value: parseDateValue(field.value),
206
267
  onChange: (value) => field.onChange(formatDateValue(value)),
207
268
  onBlur: field.onBlur,
@@ -213,6 +274,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
213
274
  }
214
275
  return /* @__PURE__ */ jsx(DateTimePickerBase, {
215
276
  ...props,
277
+ ref: mergeRefs(props.ref, inputRef),
216
278
  value: parseDateValue(props.value),
217
279
  onChange: (value) => props.onChange?.(formatDateValue(value))
218
280
  });
@@ -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 {};
@@ -3,6 +3,7 @@ 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";
7
8
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
8
9
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
@@ -12,7 +13,7 @@ import { clsx } from "clsx";
12
13
  import { useEffect, useRef, useState } from "react";
13
14
  import { useLocale, useTimeField } from "react-aria";
14
15
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller } from "react-hook-form";
16
+ import { Controller, useWatch } from "react-hook-form";
16
17
  import { getLocalTimeZone, now, toTime } from "@internationalized/date";
17
18
  import { DateTime } from "luxon";
18
19
  import { useTimeFieldState } from "react-stately";
@@ -136,7 +137,19 @@ var TimePickerBase = (props) => {
136
137
  })
137
138
  });
138
139
  };
139
- 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;
140
153
  const formatTimeValue = (timeValue) => {
141
154
  if (timeValue === null) return null;
142
155
  const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
@@ -147,6 +160,46 @@ var TimePicker = (props) => {
147
160
  if (isoString == null) return isoString;
148
161
  return toTime(DateTimeUtils.fromISOtoZonedDateTime(isoString));
149
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 staticPlaceholder = props.placeholder ?? DateTimeUtils.getTimePlaceholder(locale);
181
+ const staticTimeValue = rawValue ? parseTimeValue(rawValue) : null;
182
+ const displayValue = staticTimeValue ? DateTimeUtils.formatTimeLocalized(staticTimeValue, 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
+ trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0
201
+ });
202
+ }
150
203
  if ("formControl" in props && props.formControl) {
151
204
  const { formControl, ref, ...innerProps } = props;
152
205
  return /* @__PURE__ */ jsx(Controller, {
@@ -154,7 +207,7 @@ var TimePicker = (props) => {
154
207
  name: formControl.name,
155
208
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TimePickerBase, {
156
209
  ...innerProps,
157
- ref: mergeRefs(ref, field.ref),
210
+ ref: mergeRefs(ref, field.ref, inputRef),
158
211
  value: parseTimeValue(field.value),
159
212
  onChange: (value) => field.onChange(formatTimeValue(value)),
160
213
  onBlur: field.onBlur,
@@ -166,6 +219,7 @@ var TimePicker = (props) => {
166
219
  }
167
220
  return /* @__PURE__ */ jsx(TimePickerBase, {
168
221
  ...props,
222
+ ref: mergeRefs(props.ref, inputRef),
169
223
  value: parseTimeValue(props.value),
170
224
  onChange: (value) => props.onChange?.(formatTimeValue(value))
171
225
  });
@@ -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";
3
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
5
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
6
- import { TodayIcon } from "../../../../assets/icons/Today.js";
7
5
  import { DateField } from "./DateField.js";
8
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";
@@ -17,6 +16,7 @@ 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
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
22
  const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
@@ -71,7 +71,8 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
71
71
  endFieldProps?.onBlur?.(null);
72
72
  };
73
73
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
74
- const todayIconComponent = todayIcon === true ? TodayIcon : todayIcon || null;
74
+ const todayIconComponent = getDatePickerTodayIcon(todayIcon);
75
+ const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
75
76
  return /* @__PURE__ */ jsxs("div", {
76
77
  ref: containerRef,
77
78
  className: clsx(inputBaseCva({
@@ -155,7 +156,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
155
156
  label: "",
156
157
  color: "secondary",
157
158
  ...buttonProps,
158
- icon: isDateTime ? DateTimeIcon : CalendarIcon,
159
+ icon: pickerIcon,
159
160
  isDisabled,
160
161
  className: "border-0!"
161
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 });
@@ -83,7 +84,7 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
83
84
  label: "",
84
85
  color: "secondary",
85
86
  onPress,
86
- icon: ClockIcon,
87
+ icon: uiConfig.dateInput.timeIcon,
87
88
  isDisabled,
88
89
  className: "border-0!"
89
90
  })]
@@ -0,0 +1,6 @@
1
+ import { FC, ReactElement, SVGProps } from 'react';
2
+ import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from './datePicker.types';
3
+ type TodayIconComponent = FC<SVGProps<SVGSVGElement>> | ReactElement;
4
+ export declare const getDatePickerTodayIcon: (todayIcon: DatePickerTodayIcon | undefined) => TodayIconComponent | null;
5
+ export declare const renderDatePickerTodayIcon: (todayIcon: DatePickerTodayIcon | undefined, size?: DatePickerTodayIconButtonSize, className?: string) => import("react/jsx-runtime").JSX.Element | undefined;
6
+ export {};
@@ -0,0 +1,20 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
2
+ import { buttonIconSize } from "../../../buttons/Button/button.cva.js";
3
+ import { TodayIcon } from "../../../../assets/icons/Today.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { clsx } from "clsx";
6
+ import { isValidElement } from "react";
7
+ //#region src/components/inputs/DateTime/shared/datePickerTodayIcon.tsx
8
+ var getDatePickerTodayIcon = (todayIcon) => {
9
+ if (!todayIcon) return null;
10
+ return todayIcon === true ? TodayIcon : todayIcon;
11
+ };
12
+ var renderDatePickerTodayIcon = (todayIcon, size = "none", className) => {
13
+ const buttonIconSizeCva = UIStyle.useCva("button.iconSize", buttonIconSize);
14
+ const icon = getDatePickerTodayIcon(todayIcon);
15
+ if (!icon) return;
16
+ if (isValidElement(icon)) return icon;
17
+ return /* @__PURE__ */ jsx(icon, { className: clsx(buttonIconSizeCva({ size }), "text-interactive-text-secondary-idle", className) });
18
+ };
19
+ //#endregion
20
+ export { getDatePickerTodayIcon, renderDatePickerTodayIcon };
@@ -13,8 +13,11 @@ interface NumberInputBaseProps extends FormFieldProps, InputVariantProps, Omit<I
13
13
  value?: number | null;
14
14
  onChange?: (value: number | null) => void;
15
15
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
16
+ autoFocusOnMount?: boolean;
16
17
  }
17
- export type NumberInputProps = NumberInputBaseProps;
18
+ export type NumberInputProps = NumberInputBaseProps & {
19
+ renderStaticInput?: boolean;
20
+ };
18
21
  export type ControlledNumberInputProps<TFieldValues extends FieldValues> = ControlProps<NumberInputProps, TFieldValues>;
19
- export declare const NumberInput: <TFieldValues extends FieldValues>(props: ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const NumberInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
20
23
  export {};