@povio/ui 2.2.9-rc.25 → 2.2.9-rc.27
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/Button/Button.d.ts +2 -1
- package/dist/components/buttons/Button/Button.js +41 -32
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -0
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +34 -29
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +33 -47
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +35 -29
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +29 -25
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +51 -45
- 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/datePicker.types.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -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 +76 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +39 -40
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +1 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +40 -40
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +24 -15
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
- package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -34
- package/dist/components/inputs/Selection/Select/Select.js +27 -17
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +54 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +167 -0
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/config/uiConfig.context.d.ts +1 -1
- package/dist/config/uiConfig.context.js +1 -0
- package/dist/index.js +1 -1
- package/dist/utils/date-time.utils.d.ts +7 -0
- package/dist/utils/date-time.utils.js +16 -0
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ export type ButtonProps<IconOnly extends boolean = false> = ButtonVariantProps &
|
|
|
23
23
|
noDisableWhenLoading?: boolean;
|
|
24
24
|
iconClassName?: string;
|
|
25
25
|
contentRef?: Ref<HTMLElement>;
|
|
26
|
+
staticRender?: boolean;
|
|
26
27
|
};
|
|
27
|
-
export declare const Button: <IconOnly extends boolean = false>({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, ...props }: ButtonProps<IconOnly>) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const Button: <IconOnly extends boolean = false>({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, staticRender, ...props }: ButtonProps<IconOnly>) => import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
export {};
|
|
@@ -7,10 +7,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { Button, Link, ToggleButton } from "react-aria-components";
|
|
9
9
|
//#region src/components/buttons/Button/Button.tsx
|
|
10
|
-
var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, ...props }) => {
|
|
10
|
+
var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, staticRender, ...props }) => {
|
|
11
11
|
const linkContext = LinkContext.useLinkContext();
|
|
12
12
|
const uiConfig = UIConfig.useConfig();
|
|
13
|
-
const
|
|
13
|
+
const variant = props.variant ?? uiConfig.button.variant;
|
|
14
|
+
const size = props.size ?? uiConfig.button.size;
|
|
14
15
|
const buttonCva = UIStyle.useCva("button.cva", button);
|
|
15
16
|
const buttonSizeCva = UIStyle.useCva("button.sizeCva", buttonSize);
|
|
16
17
|
const buttonContentCva = UIStyle.useCva("button.contentCva", buttonContent);
|
|
@@ -22,45 +23,53 @@ var Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link
|
|
|
22
23
|
return Button;
|
|
23
24
|
})();
|
|
24
25
|
if (link && !link.to && link.href) link.to = link.href;
|
|
25
|
-
|
|
26
|
+
const resolvedClassName = clsx(buttonCva({
|
|
26
27
|
...props,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
className
|
|
28
|
+
variant,
|
|
29
|
+
size,
|
|
30
|
+
className
|
|
31
|
+
}), buttonSizeCva({
|
|
32
|
+
...props,
|
|
33
|
+
variant,
|
|
34
|
+
size
|
|
35
|
+
}), buttonContentCva({
|
|
36
|
+
...props,
|
|
37
|
+
variant,
|
|
38
|
+
size,
|
|
39
|
+
iconPosition: !Icon ? "none" : iconPosition
|
|
40
|
+
}));
|
|
41
|
+
const content = /* @__PURE__ */ jsx(ButtonContent, {
|
|
42
|
+
ref: contentRef,
|
|
43
|
+
isLoading,
|
|
44
|
+
icon: Icon,
|
|
45
|
+
text: children,
|
|
46
|
+
hideText: props.iconOnly,
|
|
47
|
+
iconPosition,
|
|
48
|
+
iconClassName: buttonIconSizeCva({
|
|
30
49
|
...props,
|
|
31
50
|
variant,
|
|
32
51
|
size,
|
|
33
|
-
className
|
|
34
|
-
}),
|
|
52
|
+
className: iconClassName
|
|
53
|
+
}),
|
|
54
|
+
typography: typographyMap({
|
|
35
55
|
...props,
|
|
36
56
|
variant,
|
|
37
57
|
size
|
|
38
|
-
}), buttonContentCva({
|
|
39
|
-
...props,
|
|
40
|
-
variant,
|
|
41
|
-
size,
|
|
42
|
-
iconPosition: !Icon ? "none" : iconPosition
|
|
43
|
-
})),
|
|
44
|
-
children: /* @__PURE__ */ jsx(ButtonContent, {
|
|
45
|
-
ref: contentRef,
|
|
46
|
-
isLoading,
|
|
47
|
-
icon: Icon,
|
|
48
|
-
text: children,
|
|
49
|
-
hideText: props.iconOnly,
|
|
50
|
-
iconPosition,
|
|
51
|
-
iconClassName: buttonIconSizeCva({
|
|
52
|
-
...props,
|
|
53
|
-
variant,
|
|
54
|
-
size,
|
|
55
|
-
className: iconClassName
|
|
56
|
-
}),
|
|
57
|
-
typography: typographyMap({
|
|
58
|
-
...props,
|
|
59
|
-
variant,
|
|
60
|
-
size
|
|
61
|
-
})
|
|
62
58
|
})
|
|
63
59
|
});
|
|
60
|
+
if (staticRender) return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
"aria-label": props.iconOnly ? children : void 0,
|
|
62
|
+
"aria-disabled": props.isDisabled || void 0,
|
|
63
|
+
className: resolvedClassName,
|
|
64
|
+
children: content
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
67
|
+
...props,
|
|
68
|
+
...link,
|
|
69
|
+
isDisabled: props.isDisabled || isLoading && !noDisableWhenLoading,
|
|
70
|
+
className: resolvedClassName,
|
|
71
|
+
children: content
|
|
72
|
+
});
|
|
64
73
|
};
|
|
65
74
|
//#endregion
|
|
66
75
|
export { Button$1 as Button };
|
|
@@ -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
13
|
export declare const InlineIconButton: ({ label, size, ...props }: InlineIconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { FocusEvent, Ref } from 'react';
|
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
7
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
8
|
import { ControlProps } from '../../shared/form.types';
|
|
9
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -14,6 +14,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
|
|
|
14
14
|
className?: string;
|
|
15
15
|
todayIcon?: DatePickerTodayIcon;
|
|
16
16
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
17
18
|
isDirty?: boolean;
|
|
18
19
|
disableManualEntry?: boolean;
|
|
19
20
|
autoFixYear?: boolean;
|
|
@@ -6,11 +6,12 @@ import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
|
6
6
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
7
7
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
8
8
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
9
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
|
+
import { getStaticCalendarDateSegments } from "../shared/staticDateTimeSegments.js";
|
|
9
11
|
import { FormField } from "../../FormField/FormField.js";
|
|
10
|
-
import { StaticInput } from "../../shared/StaticInput.js";
|
|
11
12
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
13
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
12
14
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
13
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
16
|
import { clsx } from "clsx";
|
|
16
17
|
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
@@ -24,7 +25,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
24
25
|
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
25
26
|
var DatePickerBase = (props) => {
|
|
26
27
|
const ui = UIConfig.useConfig();
|
|
27
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
28
|
+
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, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
28
29
|
const formFieldProps = {
|
|
29
30
|
error,
|
|
30
31
|
label,
|
|
@@ -144,6 +145,7 @@ var DatePickerBase = (props) => {
|
|
|
144
145
|
headerProps,
|
|
145
146
|
todayIcon,
|
|
146
147
|
todayIconButtonSize,
|
|
148
|
+
todayIconPlacement,
|
|
147
149
|
onOpenDropdown: () => state.toggle(),
|
|
148
150
|
placeholder,
|
|
149
151
|
className: inputClassName
|
|
@@ -207,51 +209,54 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
207
209
|
setShouldFocus(false);
|
|
208
210
|
}, [renderInput, shouldFocus]);
|
|
209
211
|
if (!renderInput) {
|
|
212
|
+
const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
210
213
|
const as = props.as ?? ui.input.as;
|
|
211
214
|
const size = props.size ?? ui.input.size;
|
|
212
215
|
const variant = props.variant ?? ui.input.variant;
|
|
213
216
|
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
214
217
|
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
215
|
-
|
|
216
|
-
if (isFormControlDisabled) isDisabled = true;
|
|
218
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
217
219
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
218
220
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
219
221
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
220
222
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
const staticSegments = getStaticCalendarDateSegments({
|
|
224
|
+
value: dateValue,
|
|
225
|
+
locale,
|
|
226
|
+
placeholder: props.placeholder,
|
|
227
|
+
shouldForceLeadingZeros,
|
|
228
|
+
isDisabled,
|
|
229
|
+
hidePlaceholder: as === "floating" && !dateValue
|
|
230
|
+
});
|
|
231
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
225
232
|
...props,
|
|
226
|
-
onInteract: (focus) => {
|
|
227
|
-
setShouldFocus(focus);
|
|
228
|
-
setRenderInput(true);
|
|
229
|
-
},
|
|
230
|
-
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
231
|
-
as,
|
|
232
|
-
size,
|
|
233
|
-
variant,
|
|
234
|
-
applyMinInputWidth: true,
|
|
235
|
-
hideLabel,
|
|
236
233
|
isHeaderHidden,
|
|
234
|
+
hideLabel,
|
|
237
235
|
isDisabled,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
237
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
238
|
+
contentClassName: datePickerInputContentRowCva({ size }),
|
|
241
239
|
dataAttributes: {
|
|
242
|
-
dataIsEmpty:
|
|
243
|
-
dataIsFilled:
|
|
240
|
+
dataIsEmpty: dateValue === null,
|
|
241
|
+
dataIsFilled: dateValue !== null,
|
|
244
242
|
dataIsDirty: props.isDirty,
|
|
245
243
|
dataIsRequired: props.isRequired,
|
|
246
244
|
dataIsDisabled: isDisabled,
|
|
247
245
|
dataDisabled: isDisabled,
|
|
248
246
|
dataInvalid: !!props.error,
|
|
249
|
-
dataHasSelection:
|
|
247
|
+
dataHasSelection: dateValue !== null
|
|
248
|
+
},
|
|
249
|
+
renderStatic: true,
|
|
250
|
+
onStaticInteract: (focus) => {
|
|
251
|
+
setShouldFocus(focus);
|
|
252
|
+
setRenderInput(true);
|
|
250
253
|
},
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
as,
|
|
255
|
+
size,
|
|
256
|
+
variant,
|
|
257
|
+
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
258
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
259
|
+
children: staticSegments
|
|
255
260
|
});
|
|
256
261
|
}
|
|
257
262
|
if ("formControl" in props && props.formControl) {
|
|
@@ -4,7 +4,7 @@ import { DateValue } from 'react-aria';
|
|
|
4
4
|
import { FieldValues } from 'react-hook-form';
|
|
5
5
|
import { DateRangePickerStateOptions } from 'react-stately';
|
|
6
6
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
7
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
7
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
8
8
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
9
9
|
import { ControlProps } from '../../shared/form.types';
|
|
10
10
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -16,6 +16,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
|
|
|
16
16
|
className?: string;
|
|
17
17
|
todayIcon?: DatePickerTodayIcon;
|
|
18
18
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
19
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
19
20
|
isDirty?: boolean;
|
|
20
21
|
disableManualEntry?: boolean;
|
|
21
22
|
autoFixYear?: boolean;
|
|
@@ -7,11 +7,12 @@ import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
|
7
7
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
8
8
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
9
9
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
10
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
11
|
+
import { getStaticDateRangeSegments } from "../shared/staticDateTimeSegments.js";
|
|
10
12
|
import { FormField } from "../../FormField/FormField.js";
|
|
11
|
-
import { StaticInput } from "../../shared/StaticInput.js";
|
|
12
13
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
14
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
13
15
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
14
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
15
16
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
16
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
18
|
import { clsx } from "clsx";
|
|
@@ -28,7 +29,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
28
29
|
var DateRangePickerBase = (props) => {
|
|
29
30
|
const ui = UIConfig.useConfig();
|
|
30
31
|
const { t } = useTranslation();
|
|
31
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
32
|
+
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;
|
|
32
33
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
33
34
|
const datePickerInputRef = useRef(null);
|
|
34
35
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -489,6 +490,7 @@ var DateRangePickerBase = (props) => {
|
|
|
489
490
|
headerProps,
|
|
490
491
|
todayIcon,
|
|
491
492
|
todayIconButtonSize,
|
|
493
|
+
todayIconPlacement,
|
|
492
494
|
isDirty,
|
|
493
495
|
disableManualEntry,
|
|
494
496
|
autoFixYear,
|
|
@@ -605,59 +607,36 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
605
607
|
setShouldFocus(false);
|
|
606
608
|
}, [renderInput, shouldFocus]);
|
|
607
609
|
if (!renderInput) {
|
|
610
|
+
const startDateValue = parseCalendarDate(rawValue?.start ?? null);
|
|
611
|
+
const endDateValue = parseCalendarDate(rawValue?.end ?? null);
|
|
612
|
+
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
608
613
|
const as = props.as ?? ui.input.as;
|
|
609
614
|
const size = props.size ?? ui.input.size;
|
|
610
615
|
const variant = props.variant ?? ui.input.variant;
|
|
611
616
|
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
612
617
|
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
613
|
-
|
|
614
|
-
if (isFormControlDisabled) isDisabled = true;
|
|
618
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
615
619
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
616
620
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
617
621
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
618
622
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
const start = formatStaticDate(rawValue?.start ?? null);
|
|
628
|
-
const end = formatStaticDate(rawValue?.end ?? null);
|
|
629
|
-
const displayValue = /* @__PURE__ */ jsxs("div", {
|
|
630
|
-
className: datePickerInputContentRowCva({ size }),
|
|
631
|
-
children: [
|
|
632
|
-
/* @__PURE__ */ jsx("span", {
|
|
633
|
-
className: rawValue?.start ? "" : "text-text-default-3",
|
|
634
|
-
children: rawValue?.start ? start : defaultDatePlaceholder
|
|
635
|
-
}),
|
|
636
|
-
/* @__PURE__ */ jsx("span", {
|
|
637
|
-
className: "pointer-events-none select-none",
|
|
638
|
-
children: "–"
|
|
639
|
-
}),
|
|
640
|
-
/* @__PURE__ */ jsx("span", {
|
|
641
|
-
className: rawValue?.end ? "" : "text-text-default-3",
|
|
642
|
-
children: rawValue?.end ? end : defaultDatePlaceholder
|
|
643
|
-
})
|
|
644
|
-
]
|
|
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
|
|
645
631
|
});
|
|
646
|
-
return /* @__PURE__ */ jsx(
|
|
632
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
647
633
|
...props,
|
|
648
|
-
onInteract: (focus) => {
|
|
649
|
-
setShouldFocus(focus);
|
|
650
|
-
setRenderInput(true);
|
|
651
|
-
},
|
|
652
|
-
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
653
|
-
as,
|
|
654
|
-
size,
|
|
655
|
-
variant,
|
|
656
|
-
applyMinInputWidth: true,
|
|
657
|
-
hideLabel,
|
|
658
634
|
isHeaderHidden,
|
|
635
|
+
hideLabel,
|
|
659
636
|
isDisabled,
|
|
660
|
-
|
|
637
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
638
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
639
|
+
contentClassName: datePickerInputContentRowCva({ size }),
|
|
661
640
|
dataAttributes: {
|
|
662
641
|
dataIsEmpty: !hasProvidedRangeValue,
|
|
663
642
|
dataIsFilled: hasProvidedRangeValue,
|
|
@@ -668,10 +647,17 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
668
647
|
dataInvalid: !!props.error,
|
|
669
648
|
dataHasSelection: hasProvidedRangeValue
|
|
670
649
|
},
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
650
|
+
renderStatic: true,
|
|
651
|
+
onStaticInteract: (focus) => {
|
|
652
|
+
setShouldFocus(focus);
|
|
653
|
+
setRenderInput(true);
|
|
654
|
+
},
|
|
655
|
+
as,
|
|
656
|
+
size,
|
|
657
|
+
variant,
|
|
658
|
+
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
659
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
660
|
+
children: staticSegments
|
|
675
661
|
});
|
|
676
662
|
}
|
|
677
663
|
if ("formControl" in props && props.formControl) {
|
|
@@ -3,7 +3,7 @@ import { DateValue } from 'react-aria';
|
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
7
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
8
|
import { ControlProps } from '../../shared/form.types';
|
|
9
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -14,6 +14,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
|
|
|
14
14
|
isClearable?: boolean;
|
|
15
15
|
todayIcon?: DatePickerTodayIcon;
|
|
16
16
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
17
18
|
isDirty?: boolean;
|
|
18
19
|
disableManualEntry?: boolean;
|
|
19
20
|
autoFixYear?: boolean;
|
|
@@ -6,12 +6,14 @@ import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
|
6
6
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
7
7
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
8
8
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
9
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
|
+
import { getStaticCalendarDateTimeSegments } from "../shared/staticDateTimeSegments.js";
|
|
9
11
|
import { FormField } from "../../FormField/FormField.js";
|
|
10
|
-
import { StaticInput } from "../../shared/StaticInput.js";
|
|
11
12
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
13
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
12
14
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
13
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { clsx } from "clsx";
|
|
15
17
|
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
16
18
|
import { useDatePicker, useLocale } from "react-aria";
|
|
17
19
|
import { mergeRefs } from "@react-aria/utils";
|
|
@@ -21,7 +23,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
21
23
|
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
22
24
|
var DateTimePickerBase = (props) => {
|
|
23
25
|
const ui = UIConfig.useConfig();
|
|
24
|
-
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, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
|
|
26
|
+
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, todayIconButtonSize = ui.dateInput.todayIconButtonSize, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
|
|
25
27
|
const formFieldProps = {
|
|
26
28
|
error,
|
|
27
29
|
label,
|
|
@@ -158,6 +160,7 @@ var DateTimePickerBase = (props) => {
|
|
|
158
160
|
headerProps,
|
|
159
161
|
todayIcon,
|
|
160
162
|
todayIconButtonSize,
|
|
163
|
+
todayIconPlacement,
|
|
161
164
|
isRequired,
|
|
162
165
|
disableManualEntry,
|
|
163
166
|
autoFixYear,
|
|
@@ -220,51 +223,54 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
220
223
|
setShouldFocus(false);
|
|
221
224
|
}, [renderInput, shouldFocus]);
|
|
222
225
|
if (!renderInput) {
|
|
226
|
+
const dateTimeValue = rawValue ? parseDateValue(rawValue) : null;
|
|
223
227
|
const as = props.as ?? ui.input.as;
|
|
224
228
|
const size = props.size ?? ui.input.size;
|
|
225
229
|
const variant = props.variant ?? ui.input.variant;
|
|
226
230
|
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
227
231
|
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
228
|
-
|
|
229
|
-
if (isFormControlDisabled) isDisabled = true;
|
|
232
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
230
233
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
231
234
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
232
235
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
233
236
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
const staticSegments = getStaticCalendarDateTimeSegments({
|
|
238
|
+
value: dateTimeValue,
|
|
239
|
+
locale,
|
|
240
|
+
placeholder: props.placeholder,
|
|
241
|
+
shouldForceLeadingZeros,
|
|
242
|
+
isDisabled,
|
|
243
|
+
hidePlaceholder: as === "floating" && !dateTimeValue
|
|
244
|
+
});
|
|
245
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
238
246
|
...props,
|
|
239
|
-
onInteract: (focus) => {
|
|
240
|
-
setShouldFocus(focus);
|
|
241
|
-
setRenderInput(true);
|
|
242
|
-
},
|
|
243
|
-
className: props.className ? `relative inline-flex w-full flex-col text-left ${props.className}` : "relative inline-flex w-full flex-col text-left",
|
|
244
|
-
as,
|
|
245
|
-
size,
|
|
246
|
-
variant,
|
|
247
|
-
applyMinInputWidth: true,
|
|
248
|
-
hideLabel,
|
|
249
247
|
isHeaderHidden,
|
|
248
|
+
hideLabel,
|
|
250
249
|
isDisabled,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
251
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
252
|
+
contentClassName: datePickerInputContentRowCva({ size }),
|
|
254
253
|
dataAttributes: {
|
|
255
|
-
dataIsEmpty:
|
|
256
|
-
dataIsFilled:
|
|
254
|
+
dataIsEmpty: dateTimeValue === null,
|
|
255
|
+
dataIsFilled: dateTimeValue !== null,
|
|
257
256
|
dataIsDirty: props.isDirty,
|
|
258
257
|
dataIsRequired: props.isRequired,
|
|
259
258
|
dataIsDisabled: isDisabled,
|
|
260
259
|
dataDisabled: isDisabled,
|
|
261
260
|
dataInvalid: !!props.error,
|
|
262
|
-
dataHasSelection:
|
|
261
|
+
dataHasSelection: dateTimeValue !== null
|
|
263
262
|
},
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
263
|
+
renderStatic: true,
|
|
264
|
+
onStaticInteract: (focus) => {
|
|
265
|
+
setShouldFocus(focus);
|
|
266
|
+
setRenderInput(true);
|
|
267
|
+
},
|
|
268
|
+
as,
|
|
269
|
+
size,
|
|
270
|
+
variant,
|
|
271
|
+
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
272
|
+
trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
|
|
273
|
+
children: staticSegments
|
|
268
274
|
});
|
|
269
275
|
}
|
|
270
276
|
if ("formControl" in props && props.formControl) {
|
|
@@ -2,11 +2,12 @@ import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
|
2
2
|
import { TimePickerForm } from "../shared/TimePickerForm.js";
|
|
3
3
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
4
4
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
5
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
6
|
+
import { getStaticTimeSegments } from "../shared/staticDateTimeSegments.js";
|
|
5
7
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
|
-
import { StaticInput } from "../../shared/StaticInput.js";
|
|
7
8
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
9
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
8
10
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
9
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
11
|
import { TimePickerInput } from "../shared/TimePickerInput.js";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { clsx } from "clsx";
|
|
@@ -168,46 +169,49 @@ var TimePicker = ({ renderStaticInput, ...props }) => {
|
|
|
168
169
|
setShouldFocus(false);
|
|
169
170
|
}, [renderInput, shouldFocus]);
|
|
170
171
|
if (!renderInput) {
|
|
172
|
+
const timeValue = rawValue ? parseTimeValue(rawValue) : null;
|
|
171
173
|
const as = props.as ?? ui.input.as;
|
|
172
174
|
const size = props.size ?? ui.input.size;
|
|
173
175
|
const variant = props.variant ?? ui.input.variant;
|
|
174
176
|
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
175
177
|
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
176
|
-
|
|
177
|
-
if (isFormControlDisabled) isDisabled = true;
|
|
178
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
178
179
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
179
180
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
const staticSegments = getStaticTimeSegments({
|
|
182
|
+
value: timeValue,
|
|
183
|
+
locale,
|
|
184
|
+
placeholder: props.placeholder,
|
|
185
|
+
isDisabled,
|
|
186
|
+
hidePlaceholder: as === "floating" && !timeValue
|
|
187
|
+
});
|
|
188
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
184
189
|
...props,
|
|
185
|
-
onInteract: (focus) => {
|
|
186
|
-
setShouldFocus(focus);
|
|
187
|
-
setRenderInput(true);
|
|
188
|
-
},
|
|
189
|
-
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
190
|
-
as,
|
|
191
|
-
size,
|
|
192
|
-
variant,
|
|
193
|
-
applyMinInputWidth: true,
|
|
194
|
-
hideLabel,
|
|
195
190
|
isHeaderHidden,
|
|
191
|
+
hideLabel,
|
|
196
192
|
isDisabled,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
isEmpty: !displayValue,
|
|
193
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
194
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
200
195
|
dataAttributes: {
|
|
201
|
-
dataIsEmpty:
|
|
202
|
-
dataIsFilled:
|
|
196
|
+
dataIsEmpty: timeValue === null,
|
|
197
|
+
dataIsFilled: timeValue !== null,
|
|
203
198
|
dataIsDirty: props.isDirty,
|
|
204
199
|
dataIsRequired: props.isRequired,
|
|
205
200
|
dataIsDisabled: isDisabled,
|
|
206
201
|
dataDisabled: isDisabled,
|
|
207
202
|
dataInvalid: !!props.error,
|
|
208
|
-
dataHasSelection:
|
|
203
|
+
dataHasSelection: timeValue !== null
|
|
204
|
+
},
|
|
205
|
+
renderStatic: true,
|
|
206
|
+
onStaticInteract: (focus) => {
|
|
207
|
+
setShouldFocus(focus);
|
|
208
|
+
setRenderInput(true);
|
|
209
209
|
},
|
|
210
|
-
|
|
210
|
+
as,
|
|
211
|
+
size,
|
|
212
|
+
variant,
|
|
213
|
+
trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0,
|
|
214
|
+
children: staticSegments
|
|
211
215
|
});
|
|
212
216
|
}
|
|
213
217
|
if ("formControl" in props && props.formControl) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateSegmentItem } from "./DateSegmentItem.js";
|
|
2
|
+
import { getTimeSegmentValue } from "./dateSegment.utils.js";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
import { clsx } from "clsx";
|
|
4
5
|
import { useEffect, useImperativeHandle, useRef } from "react";
|
|
@@ -31,16 +32,8 @@ var DateField = ({ ref, onClearChange, hidePlaceholder, isDisabled, disableManua
|
|
|
31
32
|
const isDayFilled = daySegment && !daySegment.isPlaceholder;
|
|
32
33
|
const isYearEmpty = yearSegment && !(parseInt(yearSegment.text) && yearSegment.text?.length === 4);
|
|
33
34
|
const isHourEmpty = hourSegment && !parseInt(hourSegment.text);
|
|
34
|
-
if (minuteSegment && !parseInt(minuteSegment.text))
|
|
35
|
-
|
|
36
|
-
if (minuteSegment?.text?.length && minuteSegment?.text?.length > 0) minute = parseInt(minuteSegment?.text ?? "00");
|
|
37
|
-
state.setSegment("minute", minute);
|
|
38
|
-
}
|
|
39
|
-
if (isHourEmpty) {
|
|
40
|
-
let hour = hourSegment?.value || 0;
|
|
41
|
-
if (hourSegment?.text?.length && hourSegment?.text?.length > 0) hour = parseInt(hourSegment?.text ?? "00");
|
|
42
|
-
state.setSegment("hour", hour);
|
|
43
|
-
}
|
|
35
|
+
if (minuteSegment && !parseInt(minuteSegment.text)) state.setSegment("minute", getTimeSegmentValue(minuteSegment));
|
|
36
|
+
if (isHourEmpty) state.setSegment("hour", getTimeSegmentValue(hourSegment));
|
|
44
37
|
if (isMonthFilled && isDayFilled && isYearEmpty) {
|
|
45
38
|
let year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
46
39
|
if (yearSegment?.text?.length && yearSegment?.text?.length === 2) year = parseInt(`20${yearSegment?.text}`);
|