@povio/ui 2.2.9-rc.9 → 2.2.11
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 -2
- package/dist/components/buttons/Button/Button.js +1 -1
- package/dist/components/buttons/PillButton/PillButton.d.ts +2 -2
- package/dist/components/buttons/PillButton/PillButton.js +1 -1
- package/dist/components/buttons/TextButton/TextButton.d.ts +2 -1
- package/dist/components/buttons/ToggleButton/ToggleButton.d.ts +2 -1
- package/dist/components/buttons/shared/ButtonContent.d.ts +3 -3
- package/dist/components/buttons/shared/ButtonContent.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +1 -6
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +0 -3
- package/dist/components/inputs/Checkbox/checkbox.cva.js +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +9 -8
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +82 -35
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +4 -7
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +5 -15
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +42 -23
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +14 -21
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +6 -1
- package/dist/components/inputs/DateTime/shared/Calendar.js +85 -12
- package/dist/components/inputs/DateTime/shared/CalendarHeader.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +28 -4
- package/dist/components/inputs/DateTime/shared/DateField.d.ts +5 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +54 -14
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +7 -5
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +20 -18
- package/dist/components/inputs/DateTime/shared/MonthPicker.d.ts +5 -1
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +40 -8
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +2 -7
- package/dist/components/inputs/DateTime/shared/YearPicker.d.ts +5 -1
- package/dist/components/inputs/DateTime/shared/YearPicker.js +42 -8
- package/dist/components/inputs/FormField/FormFieldHeader.js +1 -3
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +0 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +0 -3
- package/dist/components/inputs/Inputs/InputItem.d.ts +16 -10
- package/dist/components/inputs/Inputs/InputItem.js +0 -4
- package/dist/components/inputs/RadioGroup/RadioGroup.js +1 -6
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +0 -3
- package/dist/components/inputs/RadioGroup/radio.cva.js +1 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -3
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +3 -4
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +7 -23
- package/dist/components/inputs/Selection/Select/Select.d.ts +2 -4
- package/dist/components/inputs/Selection/Select/Select.js +3 -4
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -8
- package/dist/components/inputs/Selection/shared/SelectBase.js +1 -3
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +2 -8
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +3 -23
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -10
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -3
- package/dist/components/inputs/Selection/shared/select.context.js +4 -22
- package/dist/components/inputs/Selection/shared/select.types.d.ts +2 -2
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +0 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +3 -7
- package/dist/components/inputs/Toggle/Toggle.js +1 -6
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +0 -3
- package/dist/components/inputs/Toggle/toggle.cva.js +1 -2
- package/dist/components/inputs/shared/CheckContent.d.ts +1 -2
- package/dist/components/inputs/shared/CheckContent.js +4 -3
- package/dist/components/overlays/BottomSheet/BottomSheet.js +1 -2
- package/dist/components/overlays/Tooltip/TooltipEllipsis.d.ts +2 -2
- package/dist/config/link.context.js +4 -2
- package/dist/config/uiConfig.context.d.ts +2 -8
- package/dist/config/uiConfig.context.js +3 -5
- package/dist/config/uiStyle.context.d.ts +1 -6
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +0 -3
- package/dist/index.d.ts +0 -4
- package/dist/index.js +4 -5
- package/dist/utils/date-time.utils.d.ts +7 -6
- package/dist/utils/date-time.utils.js +66 -16
- package/package.json +1 -1
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +0 -3
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +0 -6
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +0 -11
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +0 -30
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +0 -14
- package/dist/components/inputs/Selection/Select/QuerySelect.js +0 -56
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -6
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -13
- package/dist/hooks/useQueryAutocomplete.d.ts +0 -25
- package/dist/hooks/useQueryAutocomplete.js +0 -41
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, ReactElement, Ref, SVGProps } from 'react';
|
|
1
|
+
import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
|
|
2
2
|
import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
|
|
3
3
|
import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
|
|
4
4
|
import { LinkNavigationProps } from '../../text/Link/Link';
|
|
@@ -17,7 +17,7 @@ type ToggleButtonProps = {
|
|
|
17
17
|
isSelected?: boolean;
|
|
18
18
|
} & AriaToggleButtonProps);
|
|
19
19
|
export type ButtonProps<IconOnly extends boolean = false> = ButtonVariantProps & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<IconOnly> & ToggleButtonProps & {
|
|
20
|
-
children:
|
|
20
|
+
children: ReactNode;
|
|
21
21
|
isLoading?: boolean;
|
|
22
22
|
link?: LinkNavigationProps;
|
|
23
23
|
noDisableWhenLoading?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FC, Ref, SVGProps } from 'react';
|
|
1
|
+
import { FC, ReactNode, Ref, SVGProps } from 'react';
|
|
2
2
|
import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
|
|
3
3
|
import { PillButtonVariants } from './pillButton.cva';
|
|
4
4
|
import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
|
|
5
5
|
export interface PillButtonProps extends AriaButtonProps, Omit<AriaToggleButtonProps, keyof AriaButtonProps>, ButtonContentVariantProps, PillButtonVariants {
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode;
|
|
7
7
|
dismissable?: boolean;
|
|
8
8
|
toggle?: boolean;
|
|
9
9
|
icon?: FC<SVGProps<SVGSVGElement>>;
|
|
@@ -22,7 +22,7 @@ var PillButton = ({ children, dismissable, toggle, icon, iconPosition, contentRe
|
|
|
22
22
|
}), pillButtonContent({ iconPosition: getIconPosition() })),
|
|
23
23
|
children: /* @__PURE__ */ jsx(ButtonContent, {
|
|
24
24
|
ref: contentRef,
|
|
25
|
-
|
|
25
|
+
content: children,
|
|
26
26
|
icon: dismissable ? CloseIcon : icon,
|
|
27
27
|
iconPosition: dismissable ? "right" : iconPosition,
|
|
28
28
|
iconClassName: pillButtonIconSize,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ButtonProps as AriaButtonProps } from 'react-aria-components';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { ButtonIconProps } from '../Button/Button';
|
|
3
4
|
import { ButtonVariantProps } from '../Button/button.cva';
|
|
4
5
|
import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
|
|
5
6
|
import { LinkNavigationProps } from '../../text/Link/Link';
|
|
6
7
|
export type TextButtonProps = Omit<ButtonVariantProps, "variant"> & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<true | false> & {
|
|
7
|
-
children:
|
|
8
|
+
children: ReactNode;
|
|
8
9
|
isLoading?: boolean;
|
|
9
10
|
link?: LinkNavigationProps;
|
|
10
11
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { ButtonIconProps } from '../Button/Button';
|
|
3
4
|
import { ButtonVariantProps } from '../Button/button.cva';
|
|
4
5
|
import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
|
|
5
6
|
export type ToggleButtonProps = ButtonVariantProps & ButtonContentVariantProps & AriaToggleButtonProps & ButtonIconProps<true | false> & {
|
|
6
|
-
children:
|
|
7
|
+
children: ReactNode;
|
|
7
8
|
};
|
|
8
9
|
export declare const ToggleButton: ({ children, ...props }: ToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FC, ReactElement, Ref, SVGProps } from 'react';
|
|
1
|
+
import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
|
|
2
2
|
import { ButtonContentVariantProps } from './buttonContent.cva';
|
|
3
3
|
import { TypographyVariantProps } from '../../text/Typography/typography.cva';
|
|
4
4
|
interface ButtonContentProps extends ButtonContentVariantProps {
|
|
5
5
|
ref?: Ref<HTMLElement>;
|
|
6
|
-
|
|
6
|
+
content: ReactNode;
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
icon?: FC<SVGProps<SVGSVGElement>> | ReactElement;
|
|
9
9
|
iconClassName?: string;
|
|
10
10
|
hideText?: boolean;
|
|
11
11
|
typography?: TypographyVariantProps;
|
|
12
12
|
}
|
|
13
|
-
export declare const ButtonContent: ({ ref,
|
|
13
|
+
export declare const ButtonContent: ({ ref, content, isLoading, icon: Icon, iconClassName, hideText, iconPosition, typography: typographyOverrides, }: ButtonContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export {};
|
|
@@ -6,7 +6,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import { clsx } from "clsx";
|
|
7
7
|
import { isValidElement } from "react";
|
|
8
8
|
//#region src/components/buttons/shared/ButtonContent.tsx
|
|
9
|
-
var ButtonContent = ({ ref,
|
|
9
|
+
var ButtonContent = ({ ref, content, isLoading, icon: Icon, iconClassName, hideText, iconPosition = "left", typography: typographyOverrides }) => {
|
|
10
10
|
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
11
11
|
let iconOrLoader = null;
|
|
12
12
|
if (isLoading) iconOrLoader = /* @__PURE__ */ jsx(Loader, { className: "shrink-0" });
|
|
@@ -28,7 +28,7 @@ var ButtonContent = ({ ref, text, isLoading, icon: Icon, iconClassName, hideText
|
|
|
28
28
|
hideText: !!hideText
|
|
29
29
|
})),
|
|
30
30
|
ref,
|
|
31
|
-
children:
|
|
31
|
+
children: content
|
|
32
32
|
}),
|
|
33
33
|
iconOrLoader && iconPosition === "right" && iconOrLoader
|
|
34
34
|
] });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
|
-
import {
|
|
3
|
+
import { checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
|
|
4
4
|
import { FormFieldError } from "../FormField/FormFieldError.js";
|
|
5
5
|
import { CheckContent } from "../shared/CheckContent.js";
|
|
6
6
|
import { CheckboxCheckmark } from "./CheckboxCheckmark.js";
|
|
@@ -13,7 +13,6 @@ import { Controller } from "react-hook-form";
|
|
|
13
13
|
var CheckboxBase = (props) => {
|
|
14
14
|
const ui = UIConfig.useConfig();
|
|
15
15
|
const checkboxTypographyMap = UIStyle.useMapper("checkbox.typography", checkboxTypography);
|
|
16
|
-
const checkboxContentClassNameMap = UIStyle.useMapper("checkbox.contentClassName", checkboxContentClassName);
|
|
17
16
|
const { className, children, isDisabled, error, variant = ui.checkbox.variant, hideLabel = ui.input.hideLabel, ...rest } = props;
|
|
18
17
|
const formFieldErrorProps = {
|
|
19
18
|
error,
|
|
@@ -35,10 +34,6 @@ var CheckboxBase = (props) => {
|
|
|
35
34
|
variant,
|
|
36
35
|
...rest
|
|
37
36
|
}),
|
|
38
|
-
contentClassName: checkboxContentClassNameMap({
|
|
39
|
-
variant,
|
|
40
|
-
...rest
|
|
41
|
-
}),
|
|
42
37
|
children
|
|
43
38
|
})]
|
|
44
39
|
}), /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps })] });
|
|
@@ -9,9 +9,6 @@ export declare const checkboxIndicatorClass = "group flex items-center gap-2";
|
|
|
9
9
|
export declare const checkboxTypography: (props: {
|
|
10
10
|
variant?: "default" | null | undefined;
|
|
11
11
|
}) => TypographyVariantProps | undefined;
|
|
12
|
-
export declare const checkboxContentClassName: (props: {
|
|
13
|
-
variant?: "default" | null | undefined;
|
|
14
|
-
}) => string | undefined;
|
|
15
12
|
export declare const checkboxIcon: (props?: ({
|
|
16
13
|
iconVariant?: "selected" | "indeterminate" | null | undefined;
|
|
17
14
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
@@ -39,7 +39,6 @@ var checkboxTypography = compoundMapper({ default: {
|
|
|
39
39
|
sizeMobile: "label-1",
|
|
40
40
|
variant: "default"
|
|
41
41
|
} });
|
|
42
|
-
var checkboxContentClassName = compoundMapper({ default: "text-text-default-2" });
|
|
43
42
|
var checkboxIcon = cva(["absolute hidden size-3"], {
|
|
44
43
|
variants: { iconVariant: {
|
|
45
44
|
selected: ["group-selected:block"],
|
|
@@ -48,4 +47,4 @@ var checkboxIcon = cva(["absolute hidden size-3"], {
|
|
|
48
47
|
defaultVariants: { iconVariant: "selected" }
|
|
49
48
|
});
|
|
50
49
|
//#endregion
|
|
51
|
-
export { checkbox,
|
|
50
|
+
export { checkbox, checkboxIcon, checkboxIndicatorClass, checkboxTypography };
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { CalendarDate, DateValue } from '@internationalized/date';
|
|
2
|
-
import { Ref
|
|
2
|
+
import { 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';
|
|
7
6
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
7
|
import { ControlProps } from '../../shared/form.types';
|
|
9
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
10
|
-
|
|
9
|
+
type DatePickerGranularity = "day" | "month" | "year";
|
|
10
|
+
interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
11
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
12
|
disableDropdown?: boolean;
|
|
13
13
|
isClearable?: boolean;
|
|
14
14
|
className?: string;
|
|
15
|
-
todayIcon?:
|
|
16
|
-
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
15
|
+
todayIcon?: boolean;
|
|
17
16
|
isDirty?: boolean;
|
|
18
17
|
disableManualEntry?: boolean;
|
|
19
|
-
autoFixYear?: boolean;
|
|
20
18
|
placeholder?: string;
|
|
21
19
|
inputClassName?: string;
|
|
22
|
-
|
|
20
|
+
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
21
|
+
granularity?: DatePickerGranularity;
|
|
22
|
+
autoFixYear?: boolean;
|
|
23
|
+
format?: string;
|
|
23
24
|
}
|
|
24
25
|
export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
25
26
|
value?: string | null;
|
|
@@ -29,5 +30,5 @@ export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "on
|
|
|
29
30
|
maxValue?: DateValue | string;
|
|
30
31
|
}
|
|
31
32
|
export type ControlledDatePickerProps<TFieldValues extends FieldValues> = ControlProps<DatePickerProps, TFieldValues>;
|
|
32
|
-
export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const DatePicker: <TFieldValues extends FieldValues>({ fullIso, granularity, minValue, maxValue, ...props }: ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
33
34
|
export {};
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
2
|
import { Calendar } from "../shared/Calendar.js";
|
|
3
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
3
4
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
4
5
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
5
6
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
6
7
|
import { FormField } from "../../FormField/FormField.js";
|
|
7
8
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
8
|
-
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
9
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { clsx } from "clsx";
|
|
12
|
-
import { useImperativeHandle, useMemo, useRef } from "react";
|
|
11
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
13
12
|
import { useDatePicker, useLocale } from "react-aria";
|
|
14
13
|
import { mergeRefs } from "@react-aria/utils";
|
|
15
14
|
import { Controller } from "react-hook-form";
|
|
16
|
-
import {
|
|
15
|
+
import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
|
|
17
16
|
import { DateTime } from "luxon";
|
|
18
17
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
19
18
|
//#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
|
|
20
|
-
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
21
19
|
var DatePickerBase = (props) => {
|
|
22
20
|
const ui = UIConfig.useConfig();
|
|
23
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange,
|
|
21
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange, granularity = ui.dateInput.granularity, autoFixYear = ui.dateInput.autoFixYear, format, ...rest } = props;
|
|
22
|
+
const normalizeByGranularity = useCallback((date) => {
|
|
23
|
+
if (granularity === "year") return date.set({
|
|
24
|
+
month: 1,
|
|
25
|
+
day: 1
|
|
26
|
+
});
|
|
27
|
+
if (granularity === "month") return date.set({ day: 1 });
|
|
28
|
+
return date;
|
|
29
|
+
}, [granularity]);
|
|
24
30
|
const formFieldProps = {
|
|
25
31
|
error,
|
|
26
32
|
label,
|
|
@@ -41,10 +47,6 @@ var DatePickerBase = (props) => {
|
|
|
41
47
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
42
48
|
datePickerInputRef.current?.clear();
|
|
43
49
|
} }));
|
|
44
|
-
const handleBlur = (val) => {
|
|
45
|
-
onBlur?.({ target: { value: val } });
|
|
46
|
-
};
|
|
47
|
-
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
48
50
|
const dialogState = useDatePickerState({
|
|
49
51
|
...rest,
|
|
50
52
|
defaultValue: value || rest.defaultValue,
|
|
@@ -56,14 +58,19 @@ var DatePickerBase = (props) => {
|
|
|
56
58
|
shouldForceLeadingZeros,
|
|
57
59
|
value,
|
|
58
60
|
onChange: (val) => {
|
|
59
|
-
|
|
61
|
+
let normalizedValue = val;
|
|
62
|
+
if (val) normalizedValue = normalizeByGranularity(val);
|
|
63
|
+
if (normalizedValue && (rest.minValue && normalizedValue < rest?.minValue || rest?.maxValue && normalizedValue > rest?.maxValue)) {
|
|
60
64
|
state.setValue(state.value);
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
onChange?.(
|
|
64
|
-
dialogState.setValue(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
onChange?.(normalizedValue);
|
|
68
|
+
dialogState.setValue(normalizedValue);
|
|
69
|
+
if (normalizedValue) {
|
|
70
|
+
calendarState.setFocusedDate(normalizedValue);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
calendarState.setFocusedDate(today(getLocalTimeZone()));
|
|
67
74
|
},
|
|
68
75
|
shouldCloseOnSelect: false
|
|
69
76
|
});
|
|
@@ -95,18 +102,46 @@ var DatePickerBase = (props) => {
|
|
|
95
102
|
labelProps
|
|
96
103
|
};
|
|
97
104
|
const onApply = () => {
|
|
98
|
-
|
|
99
|
-
state.setValue(
|
|
105
|
+
if (dialogState.value) state.setValue(normalizeByGranularity(dialogState.value));
|
|
106
|
+
if (!dialogState.value) state.setValue(dialogState.value);
|
|
100
107
|
state.toggle();
|
|
101
|
-
|
|
108
|
+
};
|
|
109
|
+
const onMonthYearChange = (selectedDate) => {
|
|
110
|
+
if (!(shouldUpdateDateOnMonthYearChange || granularity !== "day")) return;
|
|
111
|
+
const updatedDate = normalizeByGranularity((dialogState.value || state.value || today(getLocalTimeZone())).set({
|
|
112
|
+
year: selectedDate.year,
|
|
113
|
+
month: selectedDate.month
|
|
114
|
+
}));
|
|
115
|
+
dialogState.setValue(updatedDate);
|
|
116
|
+
calendarState.setFocusedDate(updatedDate);
|
|
117
|
+
};
|
|
118
|
+
const onMonthYearCommit = () => {
|
|
119
|
+
onApply();
|
|
102
120
|
};
|
|
103
121
|
const onTodayPress = () => {
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
const todayValue = normalizeByGranularity(today(getLocalTimeZone()));
|
|
123
|
+
dialogState.setValue(todayValue);
|
|
124
|
+
calendarState.setFocusedDate(todayValue);
|
|
106
125
|
};
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!state.isOpen) return;
|
|
128
|
+
if (granularity !== "year") return;
|
|
129
|
+
if (dialogState.value) return;
|
|
130
|
+
const defaultYearValue = normalizeByGranularity(today(getLocalTimeZone()));
|
|
131
|
+
dialogState.setValue(defaultYearValue);
|
|
132
|
+
calendarState.setFocusedDate(defaultYearValue);
|
|
133
|
+
}, [
|
|
134
|
+
state.isOpen,
|
|
135
|
+
granularity,
|
|
136
|
+
dialogState.value,
|
|
137
|
+
dialogState,
|
|
138
|
+
calendarState,
|
|
139
|
+
normalizeByGranularity
|
|
140
|
+
]);
|
|
107
141
|
const onOpenChange = (isOpen) => {
|
|
108
142
|
state.toggle();
|
|
109
|
-
calendarState.setFocusedDate(state.value
|
|
143
|
+
if (state.value) calendarState.setFocusedDate(normalizeByGranularity(state.value));
|
|
144
|
+
if (!state.value) calendarState.setFocusedDate(today(getLocalTimeZone()));
|
|
110
145
|
if (!isOpen) dialogState.setValue(state.value);
|
|
111
146
|
};
|
|
112
147
|
return /* @__PURE__ */ jsx(TooltipWrapper, {
|
|
@@ -123,15 +158,11 @@ var DatePickerBase = (props) => {
|
|
|
123
158
|
ref: mergeRefs(ref, datePickerInputRef),
|
|
124
159
|
as,
|
|
125
160
|
groupProps,
|
|
126
|
-
fieldProps
|
|
127
|
-
...fieldProps,
|
|
128
|
-
placeholderValue: PLACEHOLDER_VALUE
|
|
129
|
-
},
|
|
161
|
+
fieldProps,
|
|
130
162
|
buttonProps,
|
|
131
163
|
isDirty,
|
|
132
164
|
isDisabled,
|
|
133
165
|
disableManualEntry,
|
|
134
|
-
autoFixYear,
|
|
135
166
|
isInvalid: !!error,
|
|
136
167
|
disableDropdown,
|
|
137
168
|
variant,
|
|
@@ -139,11 +170,13 @@ var DatePickerBase = (props) => {
|
|
|
139
170
|
isClearable,
|
|
140
171
|
headerProps,
|
|
141
172
|
todayIcon,
|
|
142
|
-
todayIconButtonSize,
|
|
143
173
|
onOpenDropdown: () => state.toggle(),
|
|
144
174
|
placeholder,
|
|
145
|
-
className: inputClassName
|
|
146
|
-
|
|
175
|
+
className: inputClassName,
|
|
176
|
+
dateGranularity: granularity,
|
|
177
|
+
autoFixYear,
|
|
178
|
+
format
|
|
179
|
+
}), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
147
180
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
148
181
|
isDisabled,
|
|
149
182
|
isValid: !dialogState.isInvalid && !!dialogState.value,
|
|
@@ -158,24 +191,37 @@ var DatePickerBase = (props) => {
|
|
|
158
191
|
children: /* @__PURE__ */ jsx(Calendar, {
|
|
159
192
|
state: calendarState,
|
|
160
193
|
calendarProps,
|
|
161
|
-
onApply
|
|
194
|
+
onApply,
|
|
195
|
+
onMonthYearChange,
|
|
196
|
+
onMonthYearCommit,
|
|
197
|
+
selectedDate: dialogState.value ?? null,
|
|
198
|
+
granularity
|
|
162
199
|
})
|
|
163
200
|
})]
|
|
164
201
|
})
|
|
165
202
|
});
|
|
166
203
|
};
|
|
167
|
-
var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
204
|
+
var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ...props }) => {
|
|
205
|
+
const normalizeByGranularity = (date) => {
|
|
206
|
+
if (granularity === "year") return date.set({
|
|
207
|
+
month: 1,
|
|
208
|
+
day: 1
|
|
209
|
+
});
|
|
210
|
+
if (granularity === "month") return date.set({ day: 1 });
|
|
211
|
+
return date;
|
|
212
|
+
};
|
|
168
213
|
const formatCalendarDate = (calendarDate) => {
|
|
169
214
|
if (calendarDate === null) return null;
|
|
170
|
-
|
|
171
|
-
|
|
215
|
+
const normalizedDate = normalizeByGranularity(calendarDate);
|
|
216
|
+
if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(normalizedDate);
|
|
217
|
+
const date = DateTimeUtils.fromDateValueToLocal(normalizedDate);
|
|
172
218
|
return DateTime.fromJSDate(date).toISODate();
|
|
173
219
|
};
|
|
174
220
|
const parseCalendarDate = (formattedDate) => {
|
|
175
221
|
if (formattedDate == null) return formattedDate;
|
|
176
|
-
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
222
|
+
if (fullIso) return normalizeByGranularity(DateTimeUtils.fromUTCISOToCalendarDate(formattedDate));
|
|
177
223
|
const date = DateTime.fromISO(formattedDate).toJSDate();
|
|
178
|
-
return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date));
|
|
224
|
+
return normalizeByGranularity(toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date)));
|
|
179
225
|
};
|
|
180
226
|
const dateLimits = {
|
|
181
227
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
@@ -202,6 +248,7 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
202
248
|
return /* @__PURE__ */ jsx(DatePickerBase, {
|
|
203
249
|
...props,
|
|
204
250
|
...dateLimits,
|
|
251
|
+
granularity,
|
|
205
252
|
value: parseCalendarDate(props.value),
|
|
206
253
|
onChange: (value) => props.onChange?.(formatCalendarDate(value))
|
|
207
254
|
});
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { CalendarDate } from '@internationalized/date';
|
|
2
|
-
import {
|
|
2
|
+
import { Ref } from 'react';
|
|
3
3
|
import { DateValue } from 'react-aria';
|
|
4
4
|
import { FieldValues } from 'react-hook-form';
|
|
5
5
|
import { DateRangePickerStateOptions } from 'react-stately';
|
|
6
6
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
7
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
8
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
9
8
|
import { ControlProps } from '../../shared/form.types';
|
|
10
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
11
|
-
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"
|
|
10
|
+
interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
12
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
13
12
|
disableDropdown?: boolean;
|
|
14
13
|
isClearable?: boolean;
|
|
15
14
|
hideSidebar?: boolean;
|
|
16
15
|
className?: string;
|
|
17
|
-
todayIcon?:
|
|
18
|
-
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
16
|
+
todayIcon?: boolean;
|
|
19
17
|
isDirty?: boolean;
|
|
20
18
|
disableManualEntry?: boolean;
|
|
21
|
-
autoFixYear?: boolean;
|
|
22
19
|
placeholder?: string;
|
|
23
20
|
inputClassName?: string;
|
|
24
|
-
|
|
21
|
+
autoFixYear?: boolean;
|
|
25
22
|
}
|
|
26
23
|
export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
27
24
|
value?: {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
3
|
import "../../../../config/i18n.js";
|
|
4
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
4
5
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
5
6
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
6
7
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
7
8
|
import { FormField } from "../../FormField/FormField.js";
|
|
8
9
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
9
|
-
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
10
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
11
10
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
12
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
12
|
import { clsx } from "clsx";
|
|
@@ -24,7 +23,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
24
23
|
var DateRangePickerBase = (props) => {
|
|
25
24
|
const ui = UIConfig.useConfig();
|
|
26
25
|
const { t } = useTranslation();
|
|
27
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange,
|
|
26
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
28
27
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
29
28
|
const datePickerInputRef = useRef(null);
|
|
30
29
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -44,7 +43,6 @@ var DateRangePickerBase = (props) => {
|
|
|
44
43
|
if (isValidRange(newValue)) return;
|
|
45
44
|
onChange?.(newValue);
|
|
46
45
|
handleCalendarStatesChange(newValue);
|
|
47
|
-
debouncedBlur(newValue);
|
|
48
46
|
},
|
|
49
47
|
shouldCloseOnSelect: false
|
|
50
48
|
});
|
|
@@ -62,10 +60,6 @@ var DateRangePickerBase = (props) => {
|
|
|
62
60
|
useImperativeHandle(ref, () => ({ clear: () => {
|
|
63
61
|
datePickerInputRef.current?.clear();
|
|
64
62
|
} }));
|
|
65
|
-
const handleBlur = (newValue) => {
|
|
66
|
-
onBlur?.({ target: { value: newValue } });
|
|
67
|
-
};
|
|
68
|
-
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
69
63
|
const formFieldProps = {
|
|
70
64
|
error: error || validationRangeError,
|
|
71
65
|
label,
|
|
@@ -327,10 +321,7 @@ var DateRangePickerBase = (props) => {
|
|
|
327
321
|
start: rangeSelection.start,
|
|
328
322
|
end: rangeSelection.end
|
|
329
323
|
} : dialogState.value;
|
|
330
|
-
if (valueToApply)
|
|
331
|
-
state.setValue(valueToApply);
|
|
332
|
-
handleBlur(valueToApply);
|
|
333
|
-
}
|
|
324
|
+
if (valueToApply) state.setValue(valueToApply);
|
|
334
325
|
state.toggle();
|
|
335
326
|
};
|
|
336
327
|
const onTodayPress = () => {
|
|
@@ -484,13 +475,12 @@ var DateRangePickerBase = (props) => {
|
|
|
484
475
|
isClearable,
|
|
485
476
|
headerProps,
|
|
486
477
|
todayIcon,
|
|
487
|
-
todayIconButtonSize,
|
|
488
478
|
isDirty,
|
|
489
479
|
disableManualEntry,
|
|
490
|
-
autoFixYear,
|
|
491
480
|
placeholder,
|
|
492
481
|
className: inputClassName,
|
|
493
|
-
onOpenDropdown: () => state.toggle()
|
|
482
|
+
onOpenDropdown: () => state.toggle(),
|
|
483
|
+
autoFixYear
|
|
494
484
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
495
485
|
hideSidebar,
|
|
496
486
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'react';
|
|
2
2
|
import { DateValue } from 'react-aria';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
7
6
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
7
|
import { ControlProps } from '../../shared/form.types';
|
|
9
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
10
|
-
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"
|
|
9
|
+
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
11
10
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
11
|
disableDropdown?: boolean;
|
|
13
12
|
isTimeOptional?: boolean;
|
|
14
13
|
isClearable?: boolean;
|
|
15
|
-
todayIcon?:
|
|
16
|
-
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
14
|
+
todayIcon?: boolean;
|
|
17
15
|
isDirty?: boolean;
|
|
18
16
|
disableManualEntry?: boolean;
|
|
19
|
-
autoFixYear?: boolean;
|
|
20
17
|
placeholder?: string;
|
|
21
18
|
inputClassName?: string;
|
|
22
|
-
|
|
19
|
+
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
20
|
+
timeZone?: string;
|
|
21
|
+
autoFixYear?: boolean;
|
|
22
|
+
format?: string;
|
|
23
23
|
}
|
|
24
24
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
25
25
|
value?: string | null;
|
|
26
26
|
onChange?: (value: string | null) => void;
|
|
27
27
|
fullIso?: boolean;
|
|
28
|
+
timeZone?: string;
|
|
28
29
|
}
|
|
29
30
|
export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
|
|
30
31
|
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|