@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.
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +9 -4
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +96 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +9 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +114 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +10 -4
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +80 -6
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +21 -12
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +7 -3
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +3 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +92 -8
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +95 -8
- package/dist/components/inputs/Inputs/InputItem.d.ts +14 -18
- package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +86 -6
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -2
- package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -3
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +84 -4
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +12 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +22 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +35 -0
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +3 -4
- package/dist/components/inputs/shared/StaticInput.d.ts +34 -0
- package/dist/components/inputs/shared/StaticInput.js +88 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +5 -0
- package/dist/components/inputs/shared/input.cva.js +10 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/config/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +11 -1
- package/dist/config/uiStyle.context.d.ts +19 -3
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +29 -10
- package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
- package/dist/hooks/useQueryAutocomplete.js +13 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -2
- package/dist/utils/date-time.utils.d.ts +10 -0
- package/dist/utils/date-time.utils.js +87 -1
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/package.json +1 -1
|
@@ -9,4 +9,4 @@ export interface InlineIconButtonProps extends Omit<AriaButtonProps, "children">
|
|
|
9
9
|
ref?: RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
|
|
10
10
|
disableTooltip?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare const InlineIconButton: ({ label, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const InlineIconButton: ({ label, size, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Button } from "../Button/Button.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/buttons/InlineIconButton/InlineIconButton.tsx
|
|
4
|
-
var InlineIconButton = ({ label, ...props }) => {
|
|
4
|
+
var InlineIconButton = ({ label, size = "none", ...props }) => {
|
|
5
5
|
return /* @__PURE__ */ jsx(Button, {
|
|
6
6
|
...props,
|
|
7
7
|
iconOnly: true,
|
|
8
8
|
variant: "text",
|
|
9
|
-
size
|
|
9
|
+
size,
|
|
10
10
|
width: "hug",
|
|
11
11
|
children: label
|
|
12
12
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
|
-
import { checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
|
|
3
|
+
import { checkboxContentClassName, checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
|
|
4
4
|
import { FormFieldError } from "../FormField/FormFieldError.js";
|
|
5
5
|
import { CheckContent } from "../shared/CheckContent.js";
|
|
6
6
|
import { CheckboxCheckmark } from "./CheckboxCheckmark.js";
|
|
@@ -13,6 +13,7 @@ import { Controller } from "react-hook-form";
|
|
|
13
13
|
var CheckboxBase = (props) => {
|
|
14
14
|
const ui = UIConfig.useConfig();
|
|
15
15
|
const checkboxTypographyMap = UIStyle.useMapper("checkbox.typography", checkboxTypography);
|
|
16
|
+
const checkboxContentClassNameMap = UIStyle.useMapper("checkbox.contentClassName", checkboxContentClassName);
|
|
16
17
|
const { className, children, isDisabled, error, variant = ui.checkbox.variant, hideLabel = ui.input.hideLabel, ...rest } = props;
|
|
17
18
|
const formFieldErrorProps = {
|
|
18
19
|
error,
|
|
@@ -34,6 +35,10 @@ var CheckboxBase = (props) => {
|
|
|
34
35
|
variant,
|
|
35
36
|
...rest
|
|
36
37
|
}),
|
|
38
|
+
contentClassName: checkboxContentClassNameMap({
|
|
39
|
+
variant,
|
|
40
|
+
...rest
|
|
41
|
+
}),
|
|
37
42
|
children
|
|
38
43
|
})]
|
|
39
44
|
}), /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps })] });
|
|
@@ -9,6 +9,9 @@ export declare const checkboxIndicatorClass = "group flex items-center gap-2";
|
|
|
9
9
|
export declare const checkboxTypography: (props: {
|
|
10
10
|
variant?: "default" | null | undefined;
|
|
11
11
|
}) => TypographyVariantProps | undefined;
|
|
12
|
+
export declare const checkboxContentClassName: (props: {
|
|
13
|
+
variant?: "default" | null | undefined;
|
|
14
|
+
}) => string | undefined;
|
|
12
15
|
export declare const checkboxIcon: (props?: ({
|
|
13
16
|
iconVariant?: "selected" | "indeterminate" | null | undefined;
|
|
14
17
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
@@ -39,6 +39,7 @@ var checkboxTypography = compoundMapper({ default: {
|
|
|
39
39
|
sizeMobile: "label-1",
|
|
40
40
|
variant: "default"
|
|
41
41
|
} });
|
|
42
|
+
var checkboxContentClassName = compoundMapper({ default: "text-text-default-2" });
|
|
42
43
|
var checkboxIcon = cva(["absolute hidden size-3"], {
|
|
43
44
|
variants: { iconVariant: {
|
|
44
45
|
selected: ["group-selected:block"],
|
|
@@ -47,4 +48,4 @@ var checkboxIcon = cva(["absolute hidden size-3"], {
|
|
|
47
48
|
defaultVariants: { iconVariant: "selected" }
|
|
48
49
|
});
|
|
49
50
|
//#endregion
|
|
50
|
-
export { checkbox, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
|
|
51
|
+
export { checkbox, checkboxContentClassName, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { CalendarDate, DateValue } from '@internationalized/date';
|
|
2
|
-
import { Ref } from 'react';
|
|
2
|
+
import { FocusEvent, Ref } from 'react';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
7
8
|
import { ControlProps } from '../../shared/form.types';
|
|
8
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
|
-
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
10
|
+
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
10
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
11
12
|
disableDropdown?: boolean;
|
|
12
13
|
isClearable?: boolean;
|
|
13
14
|
className?: string;
|
|
14
|
-
todayIcon?:
|
|
15
|
+
todayIcon?: DatePickerTodayIcon;
|
|
16
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
15
17
|
isDirty?: boolean;
|
|
16
18
|
disableManualEntry?: boolean;
|
|
19
|
+
autoFixYear?: boolean;
|
|
17
20
|
placeholder?: string;
|
|
18
21
|
inputClassName?: string;
|
|
22
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
19
23
|
}
|
|
20
24
|
export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
21
25
|
value?: string | null;
|
|
@@ -23,7 +27,8 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
|
|
|
23
27
|
fullIso?: boolean;
|
|
24
28
|
minValue?: DateValue | string;
|
|
25
29
|
maxValue?: DateValue | string;
|
|
30
|
+
renderStaticInput?: boolean;
|
|
26
31
|
}
|
|
27
32
|
export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
|
|
28
|
-
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;
|
|
29
34
|
export {};
|
|
@@ -1,24 +1,30 @@
|
|
|
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
15
|
import { clsx } from "clsx";
|
|
11
|
-
import { useImperativeHandle, useMemo, useRef } from "react";
|
|
16
|
+
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
12
17
|
import { useDatePicker, useLocale } from "react-aria";
|
|
13
18
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
|
-
import { Controller } from "react-hook-form";
|
|
15
|
-
import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
19
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
20
|
+
import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
16
21
|
import { DateTime } from "luxon";
|
|
17
22
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
18
23
|
//#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
|
|
24
|
+
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
19
25
|
var DatePickerBase = (props) => {
|
|
20
26
|
const ui = UIConfig.useConfig();
|
|
21
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
27
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
22
28
|
const formFieldProps = {
|
|
23
29
|
error,
|
|
24
30
|
label,
|
|
@@ -39,6 +45,10 @@ var DatePickerBase = (props) => {
|
|
|
39
45
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
40
46
|
datePickerInputRef.current?.clear();
|
|
41
47
|
} }));
|
|
48
|
+
const handleBlur = (val) => {
|
|
49
|
+
onBlur?.({ target: { value: val } });
|
|
50
|
+
};
|
|
51
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
42
52
|
const dialogState = useDatePickerState({
|
|
43
53
|
...rest,
|
|
44
54
|
defaultValue: value || rest.defaultValue,
|
|
@@ -57,6 +67,7 @@ var DatePickerBase = (props) => {
|
|
|
57
67
|
onChange?.(val);
|
|
58
68
|
dialogState.setValue(val);
|
|
59
69
|
calendarState.setFocusedDate(val || today(getLocalTimeZone()));
|
|
70
|
+
debouncedBlur(val);
|
|
60
71
|
},
|
|
61
72
|
shouldCloseOnSelect: false
|
|
62
73
|
});
|
|
@@ -88,8 +99,10 @@ var DatePickerBase = (props) => {
|
|
|
88
99
|
labelProps
|
|
89
100
|
};
|
|
90
101
|
const onApply = () => {
|
|
91
|
-
|
|
102
|
+
const newValue = dialogState.value;
|
|
103
|
+
state.setValue(newValue);
|
|
92
104
|
state.toggle();
|
|
105
|
+
handleBlur(newValue);
|
|
93
106
|
};
|
|
94
107
|
const onTodayPress = () => {
|
|
95
108
|
dialogState.setValue(today(getLocalTimeZone()));
|
|
@@ -114,11 +127,15 @@ var DatePickerBase = (props) => {
|
|
|
114
127
|
ref: mergeRefs(ref, datePickerInputRef),
|
|
115
128
|
as,
|
|
116
129
|
groupProps,
|
|
117
|
-
fieldProps
|
|
130
|
+
fieldProps: {
|
|
131
|
+
...fieldProps,
|
|
132
|
+
placeholderValue: PLACEHOLDER_VALUE
|
|
133
|
+
},
|
|
118
134
|
buttonProps,
|
|
119
135
|
isDirty,
|
|
120
136
|
isDisabled,
|
|
121
137
|
disableManualEntry,
|
|
138
|
+
autoFixYear,
|
|
122
139
|
isInvalid: !!error,
|
|
123
140
|
disableDropdown,
|
|
124
141
|
variant,
|
|
@@ -126,10 +143,11 @@ var DatePickerBase = (props) => {
|
|
|
126
143
|
isClearable,
|
|
127
144
|
headerProps,
|
|
128
145
|
todayIcon,
|
|
146
|
+
todayIconButtonSize,
|
|
129
147
|
onOpenDropdown: () => state.toggle(),
|
|
130
148
|
placeholder,
|
|
131
149
|
className: inputClassName
|
|
132
|
-
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
150
|
+
}), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
133
151
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
134
152
|
isDisabled,
|
|
135
153
|
isValid: !dialogState.isInvalid && !!dialogState.value,
|
|
@@ -150,7 +168,20 @@ var DatePickerBase = (props) => {
|
|
|
150
168
|
})
|
|
151
169
|
});
|
|
152
170
|
};
|
|
153
|
-
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;
|
|
154
185
|
const formatCalendarDate = (calendarDate) => {
|
|
155
186
|
if (calendarDate === null) return null;
|
|
156
187
|
if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
|
|
@@ -167,6 +198,61 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
167
198
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
168
199
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
169
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 staticDateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
221
|
+
const displayValue = staticDateValue ? DateTimeUtils.formatCalendarDateLocalized(staticDateValue, locale) : "";
|
|
222
|
+
const staticPlaceholder = rawValue ? "" : props.placeholder ?? DateTimeUtils.getDatePlaceholder(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
|
+
dataAttributes: {
|
|
241
|
+
dataIsEmpty: staticDateValue === null,
|
|
242
|
+
dataIsFilled: staticDateValue !== null,
|
|
243
|
+
dataIsDirty: props.isDirty,
|
|
244
|
+
dataIsRequired: props.isRequired,
|
|
245
|
+
dataIsDisabled: isDisabled,
|
|
246
|
+
dataDisabled: isDisabled,
|
|
247
|
+
dataInvalid: !!props.error,
|
|
248
|
+
dataHasSelection: staticDateValue !== null
|
|
249
|
+
},
|
|
250
|
+
contentRowClassName: datePickerInputContentRowCva({ size }),
|
|
251
|
+
leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
252
|
+
leadingContentClassName: "ml-0!",
|
|
253
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
|
|
254
|
+
});
|
|
255
|
+
}
|
|
170
256
|
if ("formControl" in props && props.formControl) {
|
|
171
257
|
const { formControl, ref, ...innerProps } = props;
|
|
172
258
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -175,7 +261,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
175
261
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
|
|
176
262
|
...innerProps,
|
|
177
263
|
...dateLimits,
|
|
178
|
-
ref: mergeRefs(ref, field.ref),
|
|
264
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
179
265
|
value: parseCalendarDate(field.value),
|
|
180
266
|
onChange: (value) => field.onChange(formatCalendarDate(value)),
|
|
181
267
|
onBlur: field.onBlur,
|
|
@@ -188,6 +274,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
188
274
|
return /* @__PURE__ */ jsx(DatePickerBase, {
|
|
189
275
|
...props,
|
|
190
276
|
...dateLimits,
|
|
277
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
191
278
|
value: parseCalendarDate(props.value),
|
|
192
279
|
onChange: (value) => props.onChange?.(formatCalendarDate(value))
|
|
193
280
|
});
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { CalendarDate } from '@internationalized/date';
|
|
2
|
-
import { Ref } from 'react';
|
|
2
|
+
import { FocusEvent, Ref } from 'react';
|
|
3
3
|
import { DateValue } from 'react-aria';
|
|
4
4
|
import { FieldValues } from 'react-hook-form';
|
|
5
5
|
import { DateRangePickerStateOptions } from 'react-stately';
|
|
6
6
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
7
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
7
8
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
9
|
import { ControlProps } from '../../shared/form.types';
|
|
9
10
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
10
|
-
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
11
|
+
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
11
12
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
13
|
disableDropdown?: boolean;
|
|
13
14
|
isClearable?: boolean;
|
|
14
15
|
hideSidebar?: boolean;
|
|
15
16
|
className?: string;
|
|
16
|
-
todayIcon?:
|
|
17
|
+
todayIcon?: DatePickerTodayIcon;
|
|
18
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
19
|
isDirty?: boolean;
|
|
18
20
|
disableManualEntry?: boolean;
|
|
21
|
+
autoFixYear?: boolean;
|
|
19
22
|
placeholder?: string;
|
|
20
23
|
inputClassName?: string;
|
|
24
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
21
25
|
}
|
|
22
26
|
export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
23
27
|
value?: {
|
|
@@ -31,7 +35,8 @@ export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "va
|
|
|
31
35
|
fullIso?: boolean;
|
|
32
36
|
minValue?: DateValue | string;
|
|
33
37
|
maxValue?: DateValue | string;
|
|
38
|
+
renderStaticInput?: boolean;
|
|
34
39
|
}
|
|
35
40
|
export type ControlledDateRangePickerProps<TFieldValues extends FieldValues> = ControlProps<DateRangePickerProps, TFieldValues>;
|
|
36
|
-
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;
|
|
37
42
|
export {};
|
|
@@ -1,21 +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";
|
|
13
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
9
14
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
15
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
17
|
import { clsx } from "clsx";
|
|
13
|
-
import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
18
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
14
19
|
import { Button } from "react-aria-components";
|
|
15
20
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
16
21
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
22
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
import { Controller } from "react-hook-form";
|
|
23
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
19
24
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
20
25
|
import { DateTime } from "luxon";
|
|
21
26
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
@@ -23,7 +28,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
23
28
|
var DateRangePickerBase = (props) => {
|
|
24
29
|
const ui = UIConfig.useConfig();
|
|
25
30
|
const { t } = useTranslation();
|
|
26
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
31
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
27
32
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
28
33
|
const datePickerInputRef = useRef(null);
|
|
29
34
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -43,6 +48,7 @@ var DateRangePickerBase = (props) => {
|
|
|
43
48
|
if (isValidRange(newValue)) return;
|
|
44
49
|
onChange?.(newValue);
|
|
45
50
|
handleCalendarStatesChange(newValue);
|
|
51
|
+
debouncedBlur(newValue);
|
|
46
52
|
},
|
|
47
53
|
shouldCloseOnSelect: false
|
|
48
54
|
});
|
|
@@ -60,6 +66,10 @@ var DateRangePickerBase = (props) => {
|
|
|
60
66
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
61
67
|
datePickerInputRef.current?.clear();
|
|
62
68
|
} }));
|
|
69
|
+
const handleBlur = (newValue) => {
|
|
70
|
+
onBlur?.({ target: { value: newValue } });
|
|
71
|
+
};
|
|
72
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
63
73
|
const formFieldProps = {
|
|
64
74
|
error: error || validationRangeError,
|
|
65
75
|
label,
|
|
@@ -321,7 +331,10 @@ var DateRangePickerBase = (props) => {
|
|
|
321
331
|
start: rangeSelection.start,
|
|
322
332
|
end: rangeSelection.end
|
|
323
333
|
} : dialogState.value;
|
|
324
|
-
if (valueToApply)
|
|
334
|
+
if (valueToApply) {
|
|
335
|
+
state.setValue(valueToApply);
|
|
336
|
+
handleBlur(valueToApply);
|
|
337
|
+
}
|
|
325
338
|
state.toggle();
|
|
326
339
|
};
|
|
327
340
|
const onTodayPress = () => {
|
|
@@ -475,8 +488,10 @@ var DateRangePickerBase = (props) => {
|
|
|
475
488
|
isClearable,
|
|
476
489
|
headerProps,
|
|
477
490
|
todayIcon,
|
|
491
|
+
todayIconButtonSize,
|
|
478
492
|
isDirty,
|
|
479
493
|
disableManualEntry,
|
|
494
|
+
autoFixYear,
|
|
480
495
|
placeholder,
|
|
481
496
|
className: inputClassName,
|
|
482
497
|
onOpenDropdown: () => state.toggle()
|
|
@@ -529,7 +544,20 @@ var DateRangePickerBase = (props) => {
|
|
|
529
544
|
})
|
|
530
545
|
});
|
|
531
546
|
};
|
|
532
|
-
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;
|
|
533
561
|
const formatDateRange = (range) => {
|
|
534
562
|
if (!range?.start || !range?.end) return null;
|
|
535
563
|
if (fullIso) return {
|
|
@@ -568,6 +596,84 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
568
596
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
569
597
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
570
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 = !!(rawValue?.start || rawValue?.end) ? "" : props.placeholder ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
620
|
+
/* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder }),
|
|
621
|
+
/* @__PURE__ */ jsx("span", {
|
|
622
|
+
className: "pointer-events-none select-none",
|
|
623
|
+
children: "–"
|
|
624
|
+
}),
|
|
625
|
+
/* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder })
|
|
626
|
+
] });
|
|
627
|
+
const formatStaticDate = (value) => {
|
|
628
|
+
if (!value) return "";
|
|
629
|
+
const parsedDate = parseCalendarDate(value);
|
|
630
|
+
if (!parsedDate) return "";
|
|
631
|
+
return DateTimeUtils.formatCalendarDateLocalized(parsedDate, locale);
|
|
632
|
+
};
|
|
633
|
+
const start = formatStaticDate(rawValue?.start ?? null);
|
|
634
|
+
const end = formatStaticDate(rawValue?.end ?? null);
|
|
635
|
+
const hasRangeValue = !!(start && end);
|
|
636
|
+
const displayValue = hasRangeValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
637
|
+
/* @__PURE__ */ jsx("span", { children: start }),
|
|
638
|
+
/* @__PURE__ */ jsx("span", {
|
|
639
|
+
className: "pointer-events-none select-none",
|
|
640
|
+
children: "–"
|
|
641
|
+
}),
|
|
642
|
+
/* @__PURE__ */ jsx("span", { children: end })
|
|
643
|
+
] }) : void 0;
|
|
644
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
645
|
+
...props,
|
|
646
|
+
onInteract: (focus) => {
|
|
647
|
+
setShouldFocus(focus);
|
|
648
|
+
setRenderInput(true);
|
|
649
|
+
},
|
|
650
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
651
|
+
as,
|
|
652
|
+
size,
|
|
653
|
+
variant,
|
|
654
|
+
applyMinInputWidth: true,
|
|
655
|
+
hideLabel,
|
|
656
|
+
isHeaderHidden,
|
|
657
|
+
isDisabled,
|
|
658
|
+
placeholder: staticPlaceholder,
|
|
659
|
+
displayValue,
|
|
660
|
+
isEmpty: !hasRangeValue,
|
|
661
|
+
dataAttributes: {
|
|
662
|
+
dataIsEmpty: !hasRangeValue,
|
|
663
|
+
dataIsFilled: hasRangeValue,
|
|
664
|
+
dataIsDirty: props.isDirty,
|
|
665
|
+
dataIsRequired: props.isRequired,
|
|
666
|
+
dataIsDisabled: isDisabled,
|
|
667
|
+
dataDisabled: isDisabled,
|
|
668
|
+
dataInvalid: !!props.error,
|
|
669
|
+
dataHasSelection: hasRangeValue
|
|
670
|
+
},
|
|
671
|
+
contentRowClassName: datePickerInputContentRowCva({ size }),
|
|
672
|
+
leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
673
|
+
leadingContentClassName: "ml-0!",
|
|
674
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
|
|
675
|
+
});
|
|
676
|
+
}
|
|
571
677
|
if ("formControl" in props && props.formControl) {
|
|
572
678
|
const { formControl, ref, ...innerProps } = props;
|
|
573
679
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -576,7 +682,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
576
682
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
577
683
|
...innerProps,
|
|
578
684
|
...dateLimits,
|
|
579
|
-
ref: mergeRefs(ref, field.ref),
|
|
685
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
580
686
|
value: parseDateRange(field.value),
|
|
581
687
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
582
688
|
onBlur: field.onBlur,
|
|
@@ -589,6 +695,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
589
695
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
590
696
|
...props,
|
|
591
697
|
...dateLimits,
|
|
698
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
592
699
|
value: parseDateRange(props.value),
|
|
593
700
|
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
594
701
|
});
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
1
|
+
import { FocusEvent, Ref } from 'react';
|
|
2
2
|
import { DateValue } from 'react-aria';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
7
8
|
import { ControlProps } from '../../shared/form.types';
|
|
8
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
|
-
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
10
|
+
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
10
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
11
12
|
disableDropdown?: boolean;
|
|
12
13
|
isTimeOptional?: boolean;
|
|
13
14
|
isClearable?: boolean;
|
|
14
|
-
todayIcon?:
|
|
15
|
+
todayIcon?: DatePickerTodayIcon;
|
|
16
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
15
17
|
isDirty?: boolean;
|
|
16
18
|
disableManualEntry?: boolean;
|
|
19
|
+
autoFixYear?: boolean;
|
|
20
|
+
setDateValueOnDateSelection?: boolean;
|
|
17
21
|
placeholder?: string;
|
|
18
22
|
inputClassName?: string;
|
|
23
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
19
24
|
}
|
|
20
25
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
21
26
|
value?: string | null;
|
|
22
27
|
onChange?: (value: string | null) => void;
|
|
23
28
|
fullIso?: boolean;
|
|
29
|
+
renderStaticInput?: boolean;
|
|
24
30
|
}
|
|
25
31
|
export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
|
|
26
|
-
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;
|
|
27
33
|
export {};
|