@povio/ui 2.2.12 → 2.3.0-rc.1
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 +2 -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 +10 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +89 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +95 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +11 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +95 -9
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +77 -7
- 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 +6 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +78 -61
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +11 -4
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -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 +21 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/File/FileUpload.js +1 -0
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- 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 +81 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +235 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +82 -7
- package/dist/components/inputs/Input/shared/InputContent.js +7 -6
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/InputItem.d.ts +16 -21
- package/dist/components/inputs/Inputs/InputItem.js +6 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +102 -7
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +33 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +36 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +42 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +115 -5
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +11 -3
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +27 -4
- 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 +9 -3
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +27 -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 +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +8 -3
- 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/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +19 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
- package/dist/config/router.context.d.ts +3 -4
- package/dist/config/router.context.js +1 -3
- package/dist/config/uiConfig.context.d.ts +15 -3
- package/dist/config/uiConfig.context.js +16 -3
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useFilters.js +27 -23
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +27 -14
- package/dist/hooks/usePagination.js +8 -4
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +56 -0
- package/dist/hooks/useSorting.js +7 -4
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -3
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +31 -10
- package/dist/utils/date-time.utils.js +123 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/routing.utils.d.ts +1 -0
- package/dist/utils/routing.utils.js +14 -0
- package/package.json +2 -2
|
@@ -8,5 +8,6 @@ export interface InlineIconButtonProps extends Omit<AriaButtonProps, "children">
|
|
|
8
8
|
link?: LinkNavigationProps;
|
|
9
9
|
ref?: RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
|
|
10
10
|
disableTooltip?: boolean;
|
|
11
|
+
staticRender?: boolean;
|
|
11
12
|
}
|
|
12
|
-
export declare const InlineIconButton: ({ label, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
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,25 +1,29 @@
|
|
|
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, DatePickerTodayIconPlacement } 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
10
|
type DatePickerGranularity = "day" | "month" | "year";
|
|
10
|
-
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
11
|
+
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
11
12
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
13
|
disableDropdown?: boolean;
|
|
13
14
|
isClearable?: boolean;
|
|
14
15
|
className?: string;
|
|
15
|
-
todayIcon?:
|
|
16
|
+
todayIcon?: DatePickerTodayIcon;
|
|
17
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
18
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
16
19
|
isDirty?: boolean;
|
|
17
20
|
disableManualEntry?: boolean;
|
|
21
|
+
autoFixYear?: boolean;
|
|
18
22
|
placeholder?: string;
|
|
19
23
|
inputClassName?: string;
|
|
24
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
20
25
|
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
21
26
|
granularity?: DatePickerGranularity;
|
|
22
|
-
autoFixYear?: boolean;
|
|
23
27
|
format?: string;
|
|
24
28
|
}
|
|
25
29
|
export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
@@ -28,7 +32,8 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
|
|
|
28
32
|
fullIso?: boolean;
|
|
29
33
|
minValue?: DateValue | string;
|
|
30
34
|
maxValue?: DateValue | string;
|
|
35
|
+
renderStaticInput?: boolean;
|
|
31
36
|
}
|
|
32
37
|
export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
|
|
33
|
-
export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, granularity, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, granularity, minValue, maxValue, renderStaticInput, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
34
39
|
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";
|
|
3
4
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.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";
|
|
10
|
+
import { getStaticCalendarDateSegments } from "../shared/staticDateTimeSegments.js";
|
|
7
11
|
import { FormField } from "../../FormField/FormField.js";
|
|
8
12
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
13
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
14
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
9
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
16
|
import { clsx } from "clsx";
|
|
11
|
-
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
17
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
12
18
|
import { useDatePicker, useLocale } from "react-aria";
|
|
13
19
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
|
-
import { Controller } from "react-hook-form";
|
|
20
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
15
21
|
import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
16
22
|
import { DateTime } from "luxon";
|
|
17
23
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
18
24
|
//#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
|
|
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, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange, granularity = ui.dateInput.granularity, autoFixYear = ui.dateInput.autoFixYear, format, ...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, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange, granularity = ui.dateInput.granularity, autoFixYear = ui.dateInput.autoFixYear, format, ...rest } = props;
|
|
22
28
|
const normalizeByGranularity = useCallback((date) => {
|
|
23
29
|
if (granularity === "year") return date.set({
|
|
24
30
|
month: 1,
|
|
@@ -47,6 +53,9 @@ var DatePickerBase = (props) => {
|
|
|
47
53
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
48
54
|
datePickerInputRef.current?.clear();
|
|
49
55
|
} }));
|
|
56
|
+
const handleBlur = (val) => {
|
|
57
|
+
onBlur?.({ target: { value: val } });
|
|
58
|
+
};
|
|
50
59
|
const dialogState = useDatePickerState({
|
|
51
60
|
...rest,
|
|
52
61
|
defaultValue: value || rest.defaultValue,
|
|
@@ -102,9 +111,10 @@ var DatePickerBase = (props) => {
|
|
|
102
111
|
labelProps
|
|
103
112
|
};
|
|
104
113
|
const onApply = () => {
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
const newValue = dialogState.value ? normalizeByGranularity(dialogState.value) : dialogState.value;
|
|
115
|
+
state.setValue(newValue);
|
|
107
116
|
state.toggle();
|
|
117
|
+
handleBlur(newValue);
|
|
108
118
|
};
|
|
109
119
|
const onMonthYearChange = (selectedDate) => {
|
|
110
120
|
if (!(shouldUpdateDateOnMonthYearChange || granularity !== "day")) return;
|
|
@@ -163,6 +173,7 @@ var DatePickerBase = (props) => {
|
|
|
163
173
|
isDirty,
|
|
164
174
|
isDisabled,
|
|
165
175
|
disableManualEntry,
|
|
176
|
+
autoFixYear,
|
|
166
177
|
isInvalid: !!error,
|
|
167
178
|
disableDropdown,
|
|
168
179
|
variant,
|
|
@@ -170,13 +181,14 @@ var DatePickerBase = (props) => {
|
|
|
170
181
|
isClearable,
|
|
171
182
|
headerProps,
|
|
172
183
|
todayIcon,
|
|
184
|
+
todayIconButtonSize,
|
|
185
|
+
todayIconPlacement,
|
|
173
186
|
onOpenDropdown: () => state.toggle(),
|
|
174
187
|
placeholder,
|
|
175
188
|
className: inputClassName,
|
|
176
189
|
dateGranularity: granularity,
|
|
177
|
-
autoFixYear,
|
|
178
190
|
format
|
|
179
|
-
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
191
|
+
}), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
180
192
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
181
193
|
isDisabled,
|
|
182
194
|
isValid: !dialogState.isInvalid && !!dialogState.value,
|
|
@@ -201,7 +213,28 @@ var DatePickerBase = (props) => {
|
|
|
201
213
|
})
|
|
202
214
|
});
|
|
203
215
|
};
|
|
204
|
-
var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...props }) => {
|
|
216
|
+
var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, renderStaticInput, ...props }) => {
|
|
217
|
+
const ui = UIConfig.useConfig();
|
|
218
|
+
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
219
|
+
const { locale } = useLocale();
|
|
220
|
+
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
221
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
222
|
+
const inputRef = useRef(null);
|
|
223
|
+
const { renderRealInput } = useStaticInputHandoff({
|
|
224
|
+
inputRef,
|
|
225
|
+
renderInput,
|
|
226
|
+
setRenderInput,
|
|
227
|
+
getFocusTarget: (input) => {
|
|
228
|
+
return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
232
|
+
control: props.formControl.control,
|
|
233
|
+
name: props.formControl.name
|
|
234
|
+
}) : props.value;
|
|
235
|
+
let isFormControlDisabled = false;
|
|
236
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
237
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
205
238
|
const normalizeByGranularity = (date) => {
|
|
206
239
|
if (granularity === "year") return date.set({
|
|
207
240
|
month: 1,
|
|
@@ -227,6 +260,52 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...
|
|
|
227
260
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
228
261
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
229
262
|
};
|
|
263
|
+
if (!renderInput) {
|
|
264
|
+
const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
265
|
+
const as = props.as ?? ui.input.as;
|
|
266
|
+
const size = props.size ?? ui.input.size;
|
|
267
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
268
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
269
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
270
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
271
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
272
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
273
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
274
|
+
const staticSegments = getStaticCalendarDateSegments({
|
|
275
|
+
value: dateValue,
|
|
276
|
+
locale,
|
|
277
|
+
placeholder: props.placeholder,
|
|
278
|
+
shouldForceLeadingZeros,
|
|
279
|
+
isDisabled,
|
|
280
|
+
hidePlaceholder: as === "floating" && !dateValue
|
|
281
|
+
});
|
|
282
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
283
|
+
...props,
|
|
284
|
+
isDisabled,
|
|
285
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
286
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
287
|
+
contentClassName: "pr-0!",
|
|
288
|
+
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
289
|
+
labelPlacement: "content-row",
|
|
290
|
+
dataAttributes: {
|
|
291
|
+
dataIsEmpty: dateValue === null,
|
|
292
|
+
dataIsFilled: dateValue !== null,
|
|
293
|
+
dataIsDirty: props.isDirty,
|
|
294
|
+
dataIsRequired: props.isRequired,
|
|
295
|
+
dataIsDisabled: isDisabled,
|
|
296
|
+
dataDisabled: isDisabled,
|
|
297
|
+
dataInvalid: !!props.error,
|
|
298
|
+
dataHasSelection: dateValue !== null
|
|
299
|
+
},
|
|
300
|
+
renderStatic: true,
|
|
301
|
+
onStaticInteract: renderRealInput,
|
|
302
|
+
actionContent: staticTodayIcon,
|
|
303
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
304
|
+
trailingClassName: "py-0! pl-0!",
|
|
305
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
306
|
+
children: staticSegments
|
|
307
|
+
});
|
|
308
|
+
}
|
|
230
309
|
if ("formControl" in props && props.formControl) {
|
|
231
310
|
const { formControl, ref, ...innerProps } = props;
|
|
232
311
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -235,7 +314,7 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...
|
|
|
235
314
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
|
|
236
315
|
...innerProps,
|
|
237
316
|
...dateLimits,
|
|
238
|
-
ref: mergeRefs(ref, field.ref),
|
|
317
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
239
318
|
value: parseCalendarDate(field.value),
|
|
240
319
|
onChange: (value) => field.onChange(formatCalendarDate(value)),
|
|
241
320
|
onBlur: field.onBlur,
|
|
@@ -248,6 +327,7 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...
|
|
|
248
327
|
return /* @__PURE__ */ jsx(DatePickerBase, {
|
|
249
328
|
...props,
|
|
250
329
|
...dateLimits,
|
|
330
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
251
331
|
granularity,
|
|
252
332
|
value: parseCalendarDate(props.value),
|
|
253
333
|
onChange: (value) => props.onChange?.(formatCalendarDate(value))
|
|
@@ -1,24 +1,28 @@
|
|
|
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, DatePickerTodayIconPlacement } 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;
|
|
19
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
17
20
|
isDirty?: boolean;
|
|
18
21
|
disableManualEntry?: boolean;
|
|
22
|
+
autoFixYear?: boolean;
|
|
19
23
|
placeholder?: string;
|
|
20
24
|
inputClassName?: string;
|
|
21
|
-
|
|
25
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
22
26
|
}
|
|
23
27
|
export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
24
28
|
value?: {
|
|
@@ -32,7 +36,8 @@ export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "va
|
|
|
32
36
|
fullIso?: boolean;
|
|
33
37
|
minValue?: DateValue | string;
|
|
34
38
|
maxValue?: DateValue | string;
|
|
39
|
+
renderStaticInput?: boolean;
|
|
35
40
|
}
|
|
36
41
|
export type ControlledDateRangePickerProps<TFieldValues extends FieldValues> = ControlProps<DateRangePickerProps, TFieldValues>;
|
|
37
|
-
export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const DateRangePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
38
43
|
export {};
|
|
@@ -1,12 +1,19 @@
|
|
|
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";
|
|
4
5
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
6
|
+
import { datePickerInputContentRow } from "../shared/datePickerInput.cva.js";
|
|
7
|
+
import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
5
8
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
6
9
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
7
10
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
11
|
+
import { getStaticDateRangeSegments } from "../shared/staticDateTimeSegments.js";
|
|
8
12
|
import { FormField } from "../../FormField/FormField.js";
|
|
9
13
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
14
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
15
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
16
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
10
17
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
11
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
19
|
import { clsx } from "clsx";
|
|
@@ -15,7 +22,7 @@ import { Button } from "react-aria-components";
|
|
|
15
22
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
16
23
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
24
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
import { Controller } from "react-hook-form";
|
|
25
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
19
26
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
20
27
|
import { DateTime } from "luxon";
|
|
21
28
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
@@ -23,7 +30,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
23
30
|
var DateRangePickerBase = (props) => {
|
|
24
31
|
const ui = UIConfig.useConfig();
|
|
25
32
|
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, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
33
|
+
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, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
27
34
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
28
35
|
const datePickerInputRef = useRef(null);
|
|
29
36
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -43,6 +50,7 @@ var DateRangePickerBase = (props) => {
|
|
|
43
50
|
if (isValidRange(newValue)) return;
|
|
44
51
|
onChange?.(newValue);
|
|
45
52
|
handleCalendarStatesChange(newValue);
|
|
53
|
+
debouncedBlur(newValue);
|
|
46
54
|
},
|
|
47
55
|
shouldCloseOnSelect: false
|
|
48
56
|
});
|
|
@@ -60,6 +68,10 @@ var DateRangePickerBase = (props) => {
|
|
|
60
68
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
61
69
|
datePickerInputRef.current?.clear();
|
|
62
70
|
} }));
|
|
71
|
+
const handleBlur = (newValue) => {
|
|
72
|
+
onBlur?.({ target: { value: newValue } });
|
|
73
|
+
};
|
|
74
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
63
75
|
const formFieldProps = {
|
|
64
76
|
error: error || validationRangeError,
|
|
65
77
|
label,
|
|
@@ -321,7 +333,10 @@ var DateRangePickerBase = (props) => {
|
|
|
321
333
|
start: rangeSelection.start,
|
|
322
334
|
end: rangeSelection.end
|
|
323
335
|
} : dialogState.value;
|
|
324
|
-
if (valueToApply)
|
|
336
|
+
if (valueToApply) {
|
|
337
|
+
state.setValue(valueToApply);
|
|
338
|
+
handleBlur(valueToApply);
|
|
339
|
+
}
|
|
325
340
|
state.toggle();
|
|
326
341
|
};
|
|
327
342
|
const onTodayPress = () => {
|
|
@@ -475,12 +490,14 @@ var DateRangePickerBase = (props) => {
|
|
|
475
490
|
isClearable,
|
|
476
491
|
headerProps,
|
|
477
492
|
todayIcon,
|
|
493
|
+
todayIconButtonSize,
|
|
494
|
+
todayIconPlacement,
|
|
478
495
|
isDirty,
|
|
479
496
|
disableManualEntry,
|
|
497
|
+
autoFixYear,
|
|
480
498
|
placeholder,
|
|
481
499
|
className: inputClassName,
|
|
482
|
-
onOpenDropdown: () => state.toggle()
|
|
483
|
-
autoFixYear
|
|
500
|
+
onOpenDropdown: () => state.toggle()
|
|
484
501
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
485
502
|
hideSidebar,
|
|
486
503
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
@@ -530,7 +547,28 @@ var DateRangePickerBase = (props) => {
|
|
|
530
547
|
})
|
|
531
548
|
});
|
|
532
549
|
};
|
|
533
|
-
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
550
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
|
|
551
|
+
const ui = UIConfig.useConfig();
|
|
552
|
+
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
553
|
+
const { locale } = useLocale$1();
|
|
554
|
+
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
555
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
556
|
+
const inputRef = useRef(null);
|
|
557
|
+
const { renderRealInput } = useStaticInputHandoff({
|
|
558
|
+
inputRef,
|
|
559
|
+
renderInput,
|
|
560
|
+
setRenderInput,
|
|
561
|
+
getFocusTarget: (input) => {
|
|
562
|
+
return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
566
|
+
control: props.formControl.control,
|
|
567
|
+
name: props.formControl.name
|
|
568
|
+
}) : props.value;
|
|
569
|
+
let isFormControlDisabled = false;
|
|
570
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
571
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
534
572
|
const formatDateRange = (range) => {
|
|
535
573
|
if (!range?.start || !range?.end) return null;
|
|
536
574
|
if (fullIso) return {
|
|
@@ -569,6 +607,55 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
569
607
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
570
608
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
571
609
|
};
|
|
610
|
+
if (!renderInput) {
|
|
611
|
+
const startDateValue = parseCalendarDate(rawValue?.start ?? null);
|
|
612
|
+
const endDateValue = parseCalendarDate(rawValue?.end ?? null);
|
|
613
|
+
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
614
|
+
const as = props.as ?? ui.input.as;
|
|
615
|
+
const size = props.size ?? ui.input.size;
|
|
616
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
617
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
618
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
619
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
620
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
621
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
622
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
623
|
+
const staticSegments = getStaticDateRangeSegments({
|
|
624
|
+
start: startDateValue,
|
|
625
|
+
end: endDateValue,
|
|
626
|
+
locale,
|
|
627
|
+
placeholder: props.placeholder,
|
|
628
|
+
shouldForceLeadingZeros,
|
|
629
|
+
isDisabled,
|
|
630
|
+
hidePlaceholder: as === "floating" && !hasProvidedRangeValue
|
|
631
|
+
});
|
|
632
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
633
|
+
...props,
|
|
634
|
+
isDisabled,
|
|
635
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
636
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
637
|
+
contentClassName: "pr-0!",
|
|
638
|
+
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
639
|
+
labelPlacement: "content-row",
|
|
640
|
+
dataAttributes: {
|
|
641
|
+
dataIsEmpty: !hasProvidedRangeValue,
|
|
642
|
+
dataIsFilled: hasProvidedRangeValue,
|
|
643
|
+
dataIsDirty: props.isDirty,
|
|
644
|
+
dataIsRequired: props.isRequired,
|
|
645
|
+
dataIsDisabled: isDisabled,
|
|
646
|
+
dataDisabled: isDisabled,
|
|
647
|
+
dataInvalid: !!props.error,
|
|
648
|
+
dataHasSelection: hasProvidedRangeValue
|
|
649
|
+
},
|
|
650
|
+
renderStatic: true,
|
|
651
|
+
onStaticInteract: renderRealInput,
|
|
652
|
+
actionContent: staticTodayIcon,
|
|
653
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
654
|
+
trailingClassName: "py-0! pl-0!",
|
|
655
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
656
|
+
children: staticSegments
|
|
657
|
+
});
|
|
658
|
+
}
|
|
572
659
|
if ("formControl" in props && props.formControl) {
|
|
573
660
|
const { formControl, ref, ...innerProps } = props;
|
|
574
661
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -577,7 +664,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
577
664
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
578
665
|
...innerProps,
|
|
579
666
|
...dateLimits,
|
|
580
|
-
ref: mergeRefs(ref, field.ref),
|
|
667
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
581
668
|
value: parseDateRange(field.value),
|
|
582
669
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
583
670
|
onBlur: field.onBlur,
|
|
@@ -590,6 +677,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
590
677
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
591
678
|
...props,
|
|
592
679
|
...dateLimits,
|
|
680
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
593
681
|
value: parseDateRange(props.value),
|
|
594
682
|
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
595
683
|
});
|
|
@@ -1,32 +1,38 @@
|
|
|
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, DatePickerTodayIconPlacement } 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;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
15
18
|
isDirty?: boolean;
|
|
16
19
|
disableManualEntry?: boolean;
|
|
20
|
+
autoFixYear?: boolean;
|
|
21
|
+
setDateValueOnDateSelection?: boolean;
|
|
17
22
|
placeholder?: string;
|
|
18
23
|
inputClassName?: string;
|
|
19
24
|
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
20
25
|
timeZone?: string;
|
|
21
|
-
autoFixYear?: boolean;
|
|
22
26
|
format?: string;
|
|
27
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
23
28
|
}
|
|
24
29
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
25
30
|
value?: string | null;
|
|
26
31
|
onChange?: (value: string | null) => void;
|
|
27
32
|
fullIso?: boolean;
|
|
33
|
+
renderStaticInput?: boolean;
|
|
28
34
|
timeZone?: string;
|
|
29
35
|
}
|
|
30
36
|
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;
|
|
37
|
+
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
32
38
|
export {};
|