@povio/ui 2.2.9-rc.2 → 2.2.9-rc.21
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 +97 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +9 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +116 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +10 -4
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +92 -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/NumberRangeInput/NumberRangeInput.d.ts +38 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
- 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 +15 -18
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- 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 +87 -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 +86 -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 +37 -0
- package/dist/components/inputs/shared/StaticInput.js +91 -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 +7 -0
- package/dist/index.js +4 -2
- package/dist/utils/date-time.utils.d.ts +23 -9
- package/dist/utils/date-time.utils.js +97 -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,21 @@ 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 shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
176
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
177
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
178
|
+
const inputRef = useRef(null);
|
|
179
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
180
|
+
control: props.formControl.control,
|
|
181
|
+
name: props.formControl.name
|
|
182
|
+
}) : props.value;
|
|
183
|
+
let isFormControlDisabled = false;
|
|
184
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
185
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
154
186
|
const formatCalendarDate = (calendarDate) => {
|
|
155
187
|
if (calendarDate === null) return null;
|
|
156
188
|
if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(calendarDate);
|
|
@@ -167,6 +199,61 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
167
199
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
168
200
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
169
201
|
};
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!renderInput || !shouldFocus) return;
|
|
204
|
+
requestAnimationFrame(() => {
|
|
205
|
+
((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
206
|
+
});
|
|
207
|
+
setShouldFocus(false);
|
|
208
|
+
}, [renderInput, shouldFocus]);
|
|
209
|
+
if (!renderInput) {
|
|
210
|
+
const as = props.as ?? ui.input.as;
|
|
211
|
+
const size = props.size ?? ui.input.size;
|
|
212
|
+
const variant = props.variant ?? ui.input.variant;
|
|
213
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
214
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
215
|
+
let isDisabled = !!props.isDisabled;
|
|
216
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
217
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
218
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
219
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
220
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
221
|
+
const staticDateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
222
|
+
const displayValue = staticDateValue ? DateTimeUtils.formatCalendarDateLocalized(staticDateValue, locale, { shouldForceLeadingZeros }) : "";
|
|
223
|
+
const staticPlaceholder = props.placeholder ?? DateTimeUtils.getDatePlaceholder(locale, { shouldForceLeadingZeros });
|
|
224
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
225
|
+
...props,
|
|
226
|
+
onInteract: (focus) => {
|
|
227
|
+
setShouldFocus(focus);
|
|
228
|
+
setRenderInput(true);
|
|
229
|
+
},
|
|
230
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
231
|
+
as,
|
|
232
|
+
size,
|
|
233
|
+
variant,
|
|
234
|
+
applyMinInputWidth: true,
|
|
235
|
+
hideLabel,
|
|
236
|
+
isHeaderHidden,
|
|
237
|
+
isDisabled,
|
|
238
|
+
placeholder: staticPlaceholder,
|
|
239
|
+
displayValue,
|
|
240
|
+
isEmpty: !displayValue,
|
|
241
|
+
dataAttributes: {
|
|
242
|
+
dataIsEmpty: staticDateValue === null,
|
|
243
|
+
dataIsFilled: staticDateValue !== null,
|
|
244
|
+
dataIsDirty: props.isDirty,
|
|
245
|
+
dataIsRequired: props.isRequired,
|
|
246
|
+
dataIsDisabled: isDisabled,
|
|
247
|
+
dataDisabled: isDisabled,
|
|
248
|
+
dataInvalid: !!props.error,
|
|
249
|
+
dataHasSelection: staticDateValue !== null
|
|
250
|
+
},
|
|
251
|
+
contentRowClassName: datePickerInputContentRowCva({ size }),
|
|
252
|
+
leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
253
|
+
leadingContentClassName: "ml-0!",
|
|
254
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
|
|
255
|
+
});
|
|
256
|
+
}
|
|
170
257
|
if ("formControl" in props && props.formControl) {
|
|
171
258
|
const { formControl, ref, ...innerProps } = props;
|
|
172
259
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -175,7 +262,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
175
262
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
|
|
176
263
|
...innerProps,
|
|
177
264
|
...dateLimits,
|
|
178
|
-
ref: mergeRefs(ref, field.ref),
|
|
265
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
179
266
|
value: parseCalendarDate(field.value),
|
|
180
267
|
onChange: (value) => field.onChange(formatCalendarDate(value)),
|
|
181
268
|
onBlur: field.onBlur,
|
|
@@ -188,6 +275,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
188
275
|
return /* @__PURE__ */ jsx(DatePickerBase, {
|
|
189
276
|
...props,
|
|
190
277
|
...dateLimits,
|
|
278
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
191
279
|
value: parseCalendarDate(props.value),
|
|
192
280
|
onChange: (value) => props.onChange?.(formatCalendarDate(value))
|
|
193
281
|
});
|
|
@@ -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,21 @@ 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 shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
552
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
553
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
554
|
+
const inputRef = useRef(null);
|
|
555
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
556
|
+
control: props.formControl.control,
|
|
557
|
+
name: props.formControl.name
|
|
558
|
+
}) : props.value;
|
|
559
|
+
let isFormControlDisabled = false;
|
|
560
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
561
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
533
562
|
const formatDateRange = (range) => {
|
|
534
563
|
if (!range?.start || !range?.end) return null;
|
|
535
564
|
if (fullIso) return {
|
|
@@ -568,6 +597,85 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
568
597
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
569
598
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
570
599
|
};
|
|
600
|
+
useEffect(() => {
|
|
601
|
+
if (!renderInput || !shouldFocus) return;
|
|
602
|
+
requestAnimationFrame(() => {
|
|
603
|
+
((inputRef.current?.getContainer?.() ?? inputRef.current)?.querySelector("input, button, [tabindex]:not([tabindex='-1'])"))?.focus();
|
|
604
|
+
});
|
|
605
|
+
setShouldFocus(false);
|
|
606
|
+
}, [renderInput, shouldFocus]);
|
|
607
|
+
if (!renderInput) {
|
|
608
|
+
const as = props.as ?? ui.input.as;
|
|
609
|
+
const size = props.size ?? ui.input.size;
|
|
610
|
+
const variant = props.variant ?? ui.input.variant;
|
|
611
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
612
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
613
|
+
let isDisabled = !!props.isDisabled;
|
|
614
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
615
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
616
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
617
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
618
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
619
|
+
const defaultDatePlaceholder = DateTimeUtils.getDatePlaceholder(locale, { shouldForceLeadingZeros });
|
|
620
|
+
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
621
|
+
const staticPlaceholder = props.placeholder ?? /* @__PURE__ */ jsxs(Fragment, { 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
|
+
const formatStaticDate = (value) => {
|
|
630
|
+
if (!value) return "";
|
|
631
|
+
const parsedDate = parseCalendarDate(value);
|
|
632
|
+
if (!parsedDate) return "";
|
|
633
|
+
return DateTimeUtils.formatCalendarDateLocalized(parsedDate, locale, { shouldForceLeadingZeros });
|
|
634
|
+
};
|
|
635
|
+
const start = formatStaticDate(rawValue?.start ?? null);
|
|
636
|
+
const end = formatStaticDate(rawValue?.end ?? null);
|
|
637
|
+
const hasRangeValue = !!(start && end);
|
|
638
|
+
const displayValue = hasRangeValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
639
|
+
/* @__PURE__ */ jsx("span", { children: start }),
|
|
640
|
+
/* @__PURE__ */ jsx("span", {
|
|
641
|
+
className: "pointer-events-none select-none",
|
|
642
|
+
children: "–"
|
|
643
|
+
}),
|
|
644
|
+
/* @__PURE__ */ jsx("span", { children: end })
|
|
645
|
+
] }) : void 0;
|
|
646
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
647
|
+
...props,
|
|
648
|
+
onInteract: (focus) => {
|
|
649
|
+
setShouldFocus(focus);
|
|
650
|
+
setRenderInput(true);
|
|
651
|
+
},
|
|
652
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
653
|
+
as,
|
|
654
|
+
size,
|
|
655
|
+
variant,
|
|
656
|
+
applyMinInputWidth: true,
|
|
657
|
+
hideLabel,
|
|
658
|
+
isHeaderHidden,
|
|
659
|
+
isDisabled,
|
|
660
|
+
placeholder: staticPlaceholder,
|
|
661
|
+
displayValue,
|
|
662
|
+
isEmpty: !hasProvidedRangeValue,
|
|
663
|
+
dataAttributes: {
|
|
664
|
+
dataIsEmpty: !hasRangeValue,
|
|
665
|
+
dataIsFilled: hasRangeValue,
|
|
666
|
+
dataIsDirty: props.isDirty,
|
|
667
|
+
dataIsRequired: props.isRequired,
|
|
668
|
+
dataIsDisabled: isDisabled,
|
|
669
|
+
dataDisabled: isDisabled,
|
|
670
|
+
dataInvalid: !!props.error,
|
|
671
|
+
dataHasSelection: hasRangeValue
|
|
672
|
+
},
|
|
673
|
+
contentRowClassName: datePickerInputContentRowCva({ size }),
|
|
674
|
+
leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
675
|
+
leadingContentClassName: "ml-0!",
|
|
676
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0
|
|
677
|
+
});
|
|
678
|
+
}
|
|
571
679
|
if ("formControl" in props && props.formControl) {
|
|
572
680
|
const { formControl, ref, ...innerProps } = props;
|
|
573
681
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -576,7 +684,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
576
684
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
577
685
|
...innerProps,
|
|
578
686
|
...dateLimits,
|
|
579
|
-
ref: mergeRefs(ref, field.ref),
|
|
687
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
580
688
|
value: parseDateRange(field.value),
|
|
581
689
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
582
690
|
onBlur: field.onBlur,
|
|
@@ -589,6 +697,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
589
697
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
590
698
|
...props,
|
|
591
699
|
...dateLimits,
|
|
700
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
592
701
|
value: parseDateRange(props.value),
|
|
593
702
|
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
594
703
|
});
|
|
@@ -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 {};
|