@povio/ui 2.2.9-rc.2 → 2.2.9-rc.3
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/inputs/DateTime/DatePicker/DatePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +17 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +11 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +10 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +13 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +6 -0
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -1
- package/dist/components/inputs/Selection/shared/select.context.js +1 -1
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CalendarDate, DateValue } from '@internationalized/date';
|
|
2
|
-
import { Ref } from 'react';
|
|
2
|
+
import { Ref, FocusEvent } 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
6
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
7
7
|
import { ControlProps } from '../../shared/form.types';
|
|
8
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
|
-
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
9
|
+
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
10
10
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
11
11
|
disableDropdown?: boolean;
|
|
12
12
|
isClearable?: boolean;
|
|
@@ -16,6 +16,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
|
|
|
16
16
|
disableManualEntry?: boolean;
|
|
17
17
|
placeholder?: string;
|
|
18
18
|
inputClassName?: string;
|
|
19
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
19
20
|
}
|
|
20
21
|
export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
21
22
|
value?: string | null;
|
|
@@ -5,6 +5,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
|
5
5
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
6
6
|
import { FormField } from "../../FormField/FormField.js";
|
|
7
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
8
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
8
9
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { clsx } from "clsx";
|
|
@@ -12,13 +13,14 @@ import { useImperativeHandle, useMemo, useRef } from "react";
|
|
|
12
13
|
import { useDatePicker, useLocale } from "react-aria";
|
|
13
14
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
15
|
import { Controller } from "react-hook-form";
|
|
15
|
-
import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
16
|
+
import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
16
17
|
import { DateTime } from "luxon";
|
|
17
18
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
18
19
|
//#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
|
|
20
|
+
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
19
21
|
var DatePickerBase = (props) => {
|
|
20
22
|
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;
|
|
23
|
+
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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
22
24
|
const formFieldProps = {
|
|
23
25
|
error,
|
|
24
26
|
label,
|
|
@@ -39,6 +41,10 @@ var DatePickerBase = (props) => {
|
|
|
39
41
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
40
42
|
datePickerInputRef.current?.clear();
|
|
41
43
|
} }));
|
|
44
|
+
const handleBlur = (val) => {
|
|
45
|
+
onBlur?.({ target: { value: val } });
|
|
46
|
+
};
|
|
47
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
42
48
|
const dialogState = useDatePickerState({
|
|
43
49
|
...rest,
|
|
44
50
|
defaultValue: value || rest.defaultValue,
|
|
@@ -57,6 +63,7 @@ var DatePickerBase = (props) => {
|
|
|
57
63
|
onChange?.(val);
|
|
58
64
|
dialogState.setValue(val);
|
|
59
65
|
calendarState.setFocusedDate(val || today(getLocalTimeZone()));
|
|
66
|
+
debouncedBlur(val);
|
|
60
67
|
},
|
|
61
68
|
shouldCloseOnSelect: false
|
|
62
69
|
});
|
|
@@ -88,8 +95,10 @@ var DatePickerBase = (props) => {
|
|
|
88
95
|
labelProps
|
|
89
96
|
};
|
|
90
97
|
const onApply = () => {
|
|
91
|
-
|
|
98
|
+
const newValue = dialogState.value;
|
|
99
|
+
state.setValue(newValue);
|
|
92
100
|
state.toggle();
|
|
101
|
+
handleBlur(newValue);
|
|
93
102
|
};
|
|
94
103
|
const onTodayPress = () => {
|
|
95
104
|
dialogState.setValue(today(getLocalTimeZone()));
|
|
@@ -114,7 +123,10 @@ var DatePickerBase = (props) => {
|
|
|
114
123
|
ref: mergeRefs(ref, datePickerInputRef),
|
|
115
124
|
as,
|
|
116
125
|
groupProps,
|
|
117
|
-
fieldProps
|
|
126
|
+
fieldProps: {
|
|
127
|
+
...fieldProps,
|
|
128
|
+
placeholderValue: PLACEHOLDER_VALUE
|
|
129
|
+
},
|
|
118
130
|
buttonProps,
|
|
119
131
|
isDirty,
|
|
120
132
|
isDisabled,
|
|
@@ -129,7 +141,7 @@ var DatePickerBase = (props) => {
|
|
|
129
141
|
onOpenDropdown: () => state.toggle(),
|
|
130
142
|
placeholder,
|
|
131
143
|
className: inputClassName
|
|
132
|
-
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
144
|
+
}), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
133
145
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
134
146
|
isDisabled,
|
|
135
147
|
isValid: !dialogState.isInvalid && !!dialogState.value,
|
|
@@ -1,5 +1,5 @@
|
|
|
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';
|
|
@@ -7,7 +7,7 @@ import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
|
7
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
8
|
import { ControlProps } from '../../shared/form.types';
|
|
9
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
10
|
-
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
10
|
+
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
11
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
12
|
disableDropdown?: boolean;
|
|
13
13
|
isClearable?: boolean;
|
|
@@ -18,6 +18,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
|
|
|
18
18
|
disableManualEntry?: boolean;
|
|
19
19
|
placeholder?: string;
|
|
20
20
|
inputClassName?: string;
|
|
21
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
21
22
|
}
|
|
22
23
|
export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
23
24
|
value?: {
|
|
@@ -6,6 +6,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
|
6
6
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
7
7
|
import { FormField } from "../../FormField/FormField.js";
|
|
8
8
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
9
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
9
10
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
11
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -23,7 +24,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
23
24
|
var DateRangePickerBase = (props) => {
|
|
24
25
|
const ui = UIConfig.useConfig();
|
|
25
26
|
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;
|
|
27
|
+
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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
27
28
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
28
29
|
const datePickerInputRef = useRef(null);
|
|
29
30
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -43,6 +44,7 @@ var DateRangePickerBase = (props) => {
|
|
|
43
44
|
if (isValidRange(newValue)) return;
|
|
44
45
|
onChange?.(newValue);
|
|
45
46
|
handleCalendarStatesChange(newValue);
|
|
47
|
+
debouncedBlur(newValue);
|
|
46
48
|
},
|
|
47
49
|
shouldCloseOnSelect: false
|
|
48
50
|
});
|
|
@@ -60,6 +62,10 @@ var DateRangePickerBase = (props) => {
|
|
|
60
62
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
61
63
|
datePickerInputRef.current?.clear();
|
|
62
64
|
} }));
|
|
65
|
+
const handleBlur = (newValue) => {
|
|
66
|
+
onBlur?.({ target: { value: newValue } });
|
|
67
|
+
};
|
|
68
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
63
69
|
const formFieldProps = {
|
|
64
70
|
error: error || validationRangeError,
|
|
65
71
|
label,
|
|
@@ -321,7 +327,10 @@ var DateRangePickerBase = (props) => {
|
|
|
321
327
|
start: rangeSelection.start,
|
|
322
328
|
end: rangeSelection.end
|
|
323
329
|
} : dialogState.value;
|
|
324
|
-
if (valueToApply)
|
|
330
|
+
if (valueToApply) {
|
|
331
|
+
state.setValue(valueToApply);
|
|
332
|
+
handleBlur(valueToApply);
|
|
333
|
+
}
|
|
325
334
|
state.toggle();
|
|
326
335
|
};
|
|
327
336
|
const onTodayPress = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -6,7 +6,7 @@ import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
|
6
6
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
7
7
|
import { ControlProps } from '../../shared/form.types';
|
|
8
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
|
-
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
9
|
+
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
10
10
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
11
11
|
disableDropdown?: boolean;
|
|
12
12
|
isTimeOptional?: boolean;
|
|
@@ -16,6 +16,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
|
|
|
16
16
|
disableManualEntry?: boolean;
|
|
17
17
|
placeholder?: string;
|
|
18
18
|
inputClassName?: string;
|
|
19
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
19
20
|
}
|
|
20
21
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
21
22
|
value?: string | null;
|
|
@@ -5,6 +5,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
|
5
5
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
6
6
|
import { FormField } from "../../FormField/FormField.js";
|
|
7
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
8
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
8
9
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
@@ -16,7 +17,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
16
17
|
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
17
18
|
var DateTimePickerBase = (props) => {
|
|
18
19
|
const ui = UIConfig.useConfig();
|
|
19
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
20
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
20
21
|
const formFieldProps = {
|
|
21
22
|
error,
|
|
22
23
|
label,
|
|
@@ -37,6 +38,10 @@ var DateTimePickerBase = (props) => {
|
|
|
37
38
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
38
39
|
datePickerInputRef.current?.clear();
|
|
39
40
|
} }));
|
|
41
|
+
const handleBlur = (val) => {
|
|
42
|
+
onBlur?.({ target: { value: val } });
|
|
43
|
+
};
|
|
44
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
40
45
|
const dialogState = useDatePickerState({
|
|
41
46
|
...rest,
|
|
42
47
|
defaultValue: value || rest.defaultValue,
|
|
@@ -56,6 +61,7 @@ var DateTimePickerBase = (props) => {
|
|
|
56
61
|
onChange?.(val);
|
|
57
62
|
dialogState.setValue(val);
|
|
58
63
|
calendarState.setFocusedDate(val || today(getLocalTimeZone()));
|
|
64
|
+
debouncedBlur(val);
|
|
59
65
|
},
|
|
60
66
|
shouldCloseOnSelect: false,
|
|
61
67
|
granularity: "minute",
|
|
@@ -91,8 +97,10 @@ var DateTimePickerBase = (props) => {
|
|
|
91
97
|
labelProps
|
|
92
98
|
};
|
|
93
99
|
const onApply = () => {
|
|
94
|
-
|
|
100
|
+
const newValue = dialogState.value;
|
|
101
|
+
state.setValue(newValue);
|
|
95
102
|
state.toggle();
|
|
103
|
+
handleBlur(newValue);
|
|
96
104
|
};
|
|
97
105
|
const onTodayPress = () => {
|
|
98
106
|
dialogState.setValue(toCalendarDateTime(now(getLocalTimeZone())));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
1
|
+
import { Ref, FocusEvent } from 'react';
|
|
2
2
|
import { AriaTimeFieldProps, TimeValue } from 'react-aria';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
5
5
|
import { ControlProps } from '../../shared/form.types';
|
|
6
6
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
7
|
-
interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label"> {
|
|
7
|
+
interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label" | "onBlur"> {
|
|
8
8
|
ref?: Ref<HTMLDivElement>;
|
|
9
9
|
disableDropdown?: boolean;
|
|
10
10
|
date?: string | null;
|
|
@@ -13,6 +13,7 @@ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Ar
|
|
|
13
13
|
disableManualEntry?: boolean;
|
|
14
14
|
placeholder?: string;
|
|
15
15
|
inputClassName?: string;
|
|
16
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
16
17
|
}
|
|
17
18
|
export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {
|
|
18
19
|
value?: string | null;
|
|
@@ -4,6 +4,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
|
4
4
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
5
5
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
6
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
7
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
7
8
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
8
9
|
import { TimePickerInput } from "../shared/TimePickerInput.js";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -18,7 +19,7 @@ import { useTimeFieldState } from "react-stately";
|
|
|
18
19
|
//#region src/components/inputs/DateTime/TimePicker/TimePicker.tsx
|
|
19
20
|
var TimePickerBase = (props) => {
|
|
20
21
|
const ui = UIConfig.useConfig();
|
|
21
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
22
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
22
23
|
const formFieldProps = {
|
|
23
24
|
error,
|
|
24
25
|
label,
|
|
@@ -40,11 +41,18 @@ var TimePickerBase = (props) => {
|
|
|
40
41
|
defaultValue: value || rest.defaultValue,
|
|
41
42
|
locale
|
|
42
43
|
});
|
|
44
|
+
const handleBlur = (val) => {
|
|
45
|
+
onBlur?.({ target: { value: val } });
|
|
46
|
+
};
|
|
47
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
43
48
|
const state = useTimeFieldState({
|
|
44
49
|
...rest,
|
|
45
50
|
isDisabled,
|
|
46
51
|
value,
|
|
47
|
-
onChange
|
|
52
|
+
onChange: (val) => {
|
|
53
|
+
onChange?.(val);
|
|
54
|
+
debouncedBlur(val);
|
|
55
|
+
},
|
|
48
56
|
locale
|
|
49
57
|
});
|
|
50
58
|
useEffect(() => {
|
|
@@ -72,8 +80,10 @@ var TimePickerBase = (props) => {
|
|
|
72
80
|
labelProps
|
|
73
81
|
};
|
|
74
82
|
const onApply = () => {
|
|
75
|
-
|
|
83
|
+
const newValue = dialogState.value;
|
|
84
|
+
state.setValue(newValue);
|
|
76
85
|
setIsOpen(false);
|
|
86
|
+
handleBlur(newValue);
|
|
77
87
|
};
|
|
78
88
|
const onOpenChange = (open) => {
|
|
79
89
|
setIsOpen(open);
|
|
@@ -41,6 +41,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
41
41
|
if (endFieldProps) endFieldProps.onChange?.(null);
|
|
42
42
|
setCanClear(false);
|
|
43
43
|
fieldProps.onBlur?.(null);
|
|
44
|
+
endFieldProps?.onBlur?.(null);
|
|
44
45
|
},
|
|
45
46
|
getContainer: () => containerRef.current
|
|
46
47
|
}));
|
|
@@ -51,7 +52,10 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
51
52
|
dateFieldRef.current?.clearField();
|
|
52
53
|
fieldProps.onChange?.(null);
|
|
53
54
|
endDateFieldRef.current?.clearField();
|
|
55
|
+
endFieldProps?.onChange?.(null);
|
|
54
56
|
setCanClear(false);
|
|
57
|
+
fieldProps.onBlur?.(null);
|
|
58
|
+
endFieldProps?.onBlur?.(null);
|
|
55
59
|
};
|
|
56
60
|
const onToday = () => {
|
|
57
61
|
if (isDateTime) {
|
|
@@ -62,6 +66,8 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
62
66
|
fieldProps.onChange?.(today(getLocalTimeZone()));
|
|
63
67
|
if (endFieldProps) endFieldProps.onChange?.(today(getLocalTimeZone()));
|
|
64
68
|
}
|
|
69
|
+
fieldProps.onBlur?.(null);
|
|
70
|
+
endFieldProps?.onBlur?.(null);
|
|
65
71
|
};
|
|
66
72
|
const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
|
|
67
73
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -74,7 +74,10 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
|
|
|
74
74
|
as
|
|
75
75
|
}), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
|
|
76
76
|
children: [isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
77
|
-
onClear: () =>
|
|
77
|
+
onClear: () => {
|
|
78
|
+
state.setValue(null);
|
|
79
|
+
fieldProps.onBlur?.(null);
|
|
80
|
+
},
|
|
78
81
|
show: canClear
|
|
79
82
|
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
|
|
80
83
|
label: "",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useSelectItems } from "./useSelectItems.js";
|
|
2
1
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
2
|
+
import { useSelectItems } from "./useSelectItems.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
//#region src/components/inputs/Selection/shared/select.context.tsx
|
|
@@ -21,14 +21,14 @@ export type AllowedComponentType<TZodType extends z.ZodType> = ZodUtils.ZodTypeS
|
|
|
21
21
|
datetime: "datePicker" | "dateTimePicker" | "timePicker";
|
|
22
22
|
dateRange: "dateRangePicker";
|
|
23
23
|
boolean: "toggle" | "checkbox";
|
|
24
|
-
number: "numberInput" | "slider" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
25
|
-
enum: "select" | "autocomplete" | "segment";
|
|
26
|
-
string: "textInput" | "passwordInput" | "textArea" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
24
|
+
number: "numberInput" | "slider" | "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
25
|
+
enum: "select" | "querySelect" | "autocomplete" | "segment";
|
|
26
|
+
string: "textInput" | "passwordInput" | "textArea" | "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
27
27
|
email: "textInput";
|
|
28
|
-
array: "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
28
|
+
array: "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
29
29
|
object: InputComponentType;
|
|
30
30
|
unknown: InputComponentType;
|
|
31
|
-
uuid: "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
31
|
+
uuid: "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
32
32
|
}>;
|
|
33
33
|
interface DynamicInputDefBase<TProps> {
|
|
34
34
|
label?: string;
|
package/dist/index.js
CHANGED
|
@@ -68,10 +68,10 @@ import { Checkbox } from "./components/inputs/Checkbox/Checkbox.js";
|
|
|
68
68
|
import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
|
|
69
69
|
import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
|
|
70
70
|
import { FormField } from "./components/inputs/FormField/FormField.js";
|
|
71
|
+
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
71
72
|
import { DateTimeUtils } from "./utils/date-time.utils.js";
|
|
72
73
|
import { DatePicker } from "./components/inputs/DateTime/DatePicker/DatePicker.js";
|
|
73
74
|
import { Tag } from "./components/text/Tag/Tag.js";
|
|
74
|
-
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
75
75
|
import { useIntersectionObserver } from "./hooks/useIntersectionObserver.js";
|
|
76
76
|
import { TextInput } from "./components/inputs/Input/TextInput/TextInput.js";
|
|
77
77
|
import { Select } from "./components/inputs/Selection/Select/Select.js";
|