@povio/ui 2.2.9-rc.2 → 2.2.9-rc.4
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/Inputs/InputItem.d.ts +3 -9
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -2
- package/dist/components/inputs/Selection/shared/select.context.js +1 -1
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -2
- 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: "",
|
|
@@ -11,13 +11,7 @@ declare const componentRegistry: {
|
|
|
11
11
|
readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
readonly select: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Select/Select').ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
readonly querySelect: <TFieldValues extends import('react-hook-form').FieldValues, TQueryFn extends import('../Selection/shared/querySelect.utils').QueryFn, TKey extends import('react-aria').Key = import('react-aria').Key>({ query, queryParams, queryOptions, queryMap, ...props }: import('
|
|
15
|
-
query: TQueryFn;
|
|
16
|
-
queryParams?: Parameters<TQueryFn>[0] | undefined;
|
|
17
|
-
queryOptions?: Parameters<TQueryFn>[1] | undefined;
|
|
18
|
-
queryMap?: ((data: Exclude<ReturnType<TQueryFn>["data"], undefined>) => import('../Selection/shared/select.types').SelectItem<TKey>[]) | undefined;
|
|
19
|
-
isInitialQueryDisabled?: boolean;
|
|
20
|
-
})) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
readonly querySelect: <TFieldValues extends import('react-hook-form').FieldValues, TQueryFn extends import('../Selection/shared/querySelect.utils').QueryFn, TKey extends import('react-aria').Key = import('react-aria').Key>({ query, queryParams, queryOptions, queryMap, ...props }: import('../Selection/Select/QuerySelect.js').QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
21
15
|
readonly autocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Autocomplete/Autocomplete').ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
22
16
|
readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../Selection/shared/select.types').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn<TSelectItem>>({ query, queryParams, queryOptions, queryMap, ...props }: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
23
17
|
readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -54,8 +48,8 @@ type TypeBasedInputDef<TSchemaType extends Record<string, any>, T extends InputC
|
|
|
54
48
|
interface RenderBasedInputDef<TSchemaType extends Record<string, any>, K extends keyof TSchemaType> {
|
|
55
49
|
type?: never;
|
|
56
50
|
name: K;
|
|
57
|
-
label?:
|
|
58
|
-
placeholder?:
|
|
51
|
+
label?: string;
|
|
52
|
+
placeholder?: string;
|
|
59
53
|
props?: never;
|
|
60
54
|
inputWrapper?: never;
|
|
61
55
|
render: (formControl: {
|
|
@@ -4,7 +4,7 @@ import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
|
4
4
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
5
5
|
import { Key } from 'react-aria-components';
|
|
6
6
|
import { FieldValues } from 'react-hook-form';
|
|
7
|
-
type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key> = OmitDiscriminatedUnion<SelectBaseProps<TKey>, "items" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey> & {
|
|
7
|
+
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key> = OmitDiscriminatedUnion<SelectBaseProps<TKey>, "items" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey> & {
|
|
8
8
|
query: TQueryFn;
|
|
9
9
|
queryParams?: Parameters<TQueryFn>[0];
|
|
10
10
|
queryOptions?: Parameters<TQueryFn>[1];
|
|
@@ -12,4 +12,3 @@ type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn
|
|
|
12
12
|
isInitialQueryDisabled?: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const QuerySelect: <TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, queryMap, ...props }: QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -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" | "textEditor" | "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;
|
|
@@ -81,6 +81,7 @@ var getDefaultProps = (componentType, keyType) => {
|
|
|
81
81
|
].includes(componentType)) props.items = getDefaultSelectionItems(unwrappedType);
|
|
82
82
|
if ([
|
|
83
83
|
"select",
|
|
84
|
+
"querySelect",
|
|
84
85
|
"autocomplete",
|
|
85
86
|
"queryAutocomplete",
|
|
86
87
|
"segment"
|
|
@@ -146,6 +147,8 @@ var populateInputDef = (schema, schemaKey, value, options) => {
|
|
|
146
147
|
const inputWrapper = value.inputWrapper ?? options.globalInputWrapper;
|
|
147
148
|
if ("render" in value) return {
|
|
148
149
|
name,
|
|
150
|
+
label,
|
|
151
|
+
placeholder,
|
|
149
152
|
render: value.render
|
|
150
153
|
};
|
|
151
154
|
const schemaKeyType = schema.shape[schemaKey];
|
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,8 @@ export type { RadioVariantProps } from './components/inputs/RadioGroup/radio.cva
|
|
|
94
94
|
export type { AutocompleteProps, ControlledAutocompleteProps, } from './components/inputs/Selection/Autocomplete/Autocomplete';
|
|
95
95
|
export { Autocomplete } from './components/inputs/Selection/Autocomplete/Autocomplete';
|
|
96
96
|
export { QueryAutocomplete } from './components/inputs/Selection/Autocomplete/QueryAutocomplete';
|
|
97
|
+
export type { QuerySelectProps } from './components/inputs/Selection/Select/QuerySelect';
|
|
98
|
+
export { QuerySelect } from './components/inputs/Selection/Select/QuerySelect';
|
|
97
99
|
export type { ControlledSelectProps, SelectProps } from './components/inputs/Selection/Select/Select';
|
|
98
100
|
export { Select } from './components/inputs/Selection/Select/Select';
|
|
99
101
|
export type { ControlledSliderProps, SliderProps } from './components/inputs/Slider/Slider';
|
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";
|
|
@@ -92,6 +92,7 @@ import { QueryAutocomplete } from "./components/inputs/Selection/Autocomplete/Qu
|
|
|
92
92
|
import { Slider } from "./components/inputs/Slider/Slider.js";
|
|
93
93
|
import { Toggle } from "./components/inputs/Toggle/Toggle.js";
|
|
94
94
|
import { Segment } from "./components/segment/Segment.js";
|
|
95
|
+
import { QuerySelect } from "./components/inputs/Selection/Select/QuerySelect.js";
|
|
95
96
|
import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
|
|
96
97
|
import { StringUtils } from "./utils/string.utils.js";
|
|
97
98
|
import { dynamicInputs } from "./helpers/dynamicInputs.js";
|
|
@@ -135,4 +136,4 @@ import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
|
|
|
135
136
|
import { ArrayUtils } from "./utils/array.utils.js";
|
|
136
137
|
import { QueriesUtils } from "./utils/queries.utils.js";
|
|
137
138
|
import { RoutingUtils } from "./utils/routing.utils.js";
|
|
138
|
-
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIRouter, UIStyle, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, compoundMapper, dynamicColumns, dynamicInputs, isEqual, logger, ns, resources, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
|
139
|
+
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIRouter, UIStyle, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, compoundMapper, dynamicColumns, dynamicInputs, isEqual, logger, ns, resources, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|