@povio/ui 2.2.12 → 2.3.0-rc.10
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/assets/icons/AlignCenter.js +26 -11
- package/dist/assets/icons/AlignLeft.js +26 -11
- package/dist/assets/icons/AlignLeftRight.js +26 -11
- package/dist/assets/icons/AlignRight.js +26 -11
- package/dist/assets/icons/ArrowDropDown.js +26 -11
- package/dist/assets/icons/ArrowDropUp.js +26 -11
- package/dist/assets/icons/ArrowLeft.js +26 -11
- package/dist/assets/icons/ArrowRight.js +26 -11
- package/dist/assets/icons/Bold.js +26 -11
- package/dist/assets/icons/BulletedList.js +26 -11
- package/dist/assets/icons/Calendar.js +28 -13
- package/dist/assets/icons/Check.js +28 -13
- package/dist/assets/icons/CheckCircle.js +26 -11
- package/dist/assets/icons/CheckboxCheckmark.js +29 -14
- package/dist/assets/icons/CheckboxIndeterminate.js +29 -14
- package/dist/assets/icons/ChevronDown.js +28 -13
- package/dist/assets/icons/ChevronLeft.js +28 -13
- package/dist/assets/icons/ChevronRight.js +28 -13
- package/dist/assets/icons/ChevronUp.js +28 -13
- package/dist/assets/icons/ChevronsLeft.js +28 -13
- package/dist/assets/icons/ChevronsRight.js +28 -13
- package/dist/assets/icons/Clock.js +26 -11
- package/dist/assets/icons/Close.js +26 -11
- package/dist/assets/icons/DateTime.js +35 -14
- package/dist/assets/icons/DragIndicator.js +26 -11
- package/dist/assets/icons/File.js +28 -13
- package/dist/assets/icons/Highlight.js +26 -11
- package/dist/assets/icons/HighlightOn.js +49 -15
- package/dist/assets/icons/Home.js +26 -11
- package/dist/assets/icons/Info.js +37 -16
- package/dist/assets/icons/Italic.js +26 -11
- package/dist/assets/icons/Link.js +26 -11
- package/dist/assets/icons/Menu.js +26 -11
- package/dist/assets/icons/NumberedList.js +26 -11
- package/dist/assets/icons/PointerHorizontal.js +26 -11
- package/dist/assets/icons/PointerVertical.js +26 -11
- package/dist/assets/icons/Search.js +26 -11
- package/dist/assets/icons/Send.js +28 -13
- package/dist/assets/icons/Strikethrough.js +26 -11
- package/dist/assets/icons/TextColor.js +48 -14
- package/dist/assets/icons/Today.js +26 -11
- package/dist/assets/icons/Underlined.js +28 -13
- package/dist/assets/icons/Upload.js +35 -14
- package/dist/assets/icons/Visibility.js +26 -11
- package/dist/assets/icons/VisibilityOff.js +26 -11
- package/dist/assets/icons/WarningFilled.js +28 -13
- package/dist/components/Breadcrumbs/Breadcrumbs.js +207 -56
- package/dist/components/Menu/Menu.js +18 -2
- package/dist/components/Menu/MenuDesktop.js +41 -7
- package/dist/components/Menu/MenuItem.js +32 -9
- package/dist/components/Menu/MenuMobile.js +97 -38
- package/dist/components/Menu/MenuPopover.js +105 -29
- package/dist/components/buttons/IconButton/IconButton.js +40 -8
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +34 -9
- package/dist/components/buttons/PillButton/PillButton.js +55 -17
- package/dist/components/buttons/SplitButton/SplitButton.js +103 -18
- package/dist/components/buttons/TextButton/TextButton.js +30 -8
- package/dist/components/buttons/ToggleButton/ToggleButton.js +28 -8
- package/dist/components/buttons/shared/ButtonContent.js +80 -22
- package/dist/components/inputs/Checkbox/Checkbox.js +172 -35
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +24 -10
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +121 -20
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +215 -111
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +11 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +123 -19
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +448 -104
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +330 -119
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +283 -102
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +142 -33
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +249 -93
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +318 -137
- package/dist/components/inputs/DateTime/shared/DateField.js +296 -112
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +355 -135
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +97 -11
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +81 -27
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +59 -10
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +103 -58
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +193 -82
- package/dist/components/inputs/DateTime/shared/TimeField.js +27 -8
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +279 -110
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +207 -65
- package/dist/components/inputs/DateTime/shared/YearPicker.js +119 -68
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +31 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +1 -0
- package/dist/components/inputs/File/FileUpload.js +87 -44
- package/dist/components/inputs/File/FileUploadContainer.js +15 -7
- package/dist/components/inputs/File/InputUpload.js +317 -79
- package/dist/components/inputs/File/shared/FileCard.js +104 -41
- package/dist/components/inputs/File/shared/FileCardList.js +47 -12
- package/dist/components/inputs/File/shared/FileUploadContent.js +175 -44
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +149 -46
- package/dist/components/inputs/File/shared/FileUploadContentError.js +234 -93
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +230 -97
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +199 -55
- package/dist/components/inputs/File/shared/InputUploadContent.js +148 -34
- package/dist/components/inputs/File/shared/InputUploadFilled.js +49 -8
- package/dist/components/inputs/File/shared/ProgressBar.js +48 -9
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormField.js +119 -37
- package/dist/components/inputs/FormField/FormFieldError.js +25 -5
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +81 -22
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +31 -7
- package/dist/components/inputs/FormField/FormFieldHelper.js +26 -6
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.js +40 -9
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +332 -81
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +571 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +479 -0
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +48 -9
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +305 -90
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +321 -80
- package/dist/components/inputs/Input/shared/InputContent.js +192 -59
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/Form.js +40 -11
- package/dist/components/inputs/Inputs/InputItem.d.ts +15 -21
- package/dist/components/inputs/Inputs/InputItem.js +69 -14
- package/dist/components/inputs/Inputs/Inputs.js +37 -11
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +352 -60
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +109 -7
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +34 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +36 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +122 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +132 -5
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +69 -18
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +393 -138
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +337 -115
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +99 -25
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +164 -52
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +85 -35
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +69 -16
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +70 -21
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +58 -9
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +9 -3
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +9 -0
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +47 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +57 -34
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +5 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/useSelectItems.js +109 -49
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +79 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +526 -0
- package/dist/components/inputs/Slider/Slider.js +250 -74
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +447 -98
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +37 -11
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +102 -30
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +194 -45
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +88 -28
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +48 -14
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +66 -19
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +49 -15
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +92 -32
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +126 -54
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +141 -38
- package/dist/components/inputs/Toggle/Toggle.js +189 -37
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +21 -11
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +79 -10
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +50 -11
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +32 -4
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +14 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +100 -0
- package/dist/components/navigation/Accordion/Accordion.js +69 -22
- package/dist/components/navigation/Accordion/AccordionItem.js +86 -41
- package/dist/components/navigation/Stepper/Stepper.js +67 -22
- package/dist/components/navigation/Stepper/StepperItem.js +104 -31
- package/dist/components/navigation/Stepper/StepperSeparator.js +23 -5
- package/dist/components/overlays/ActionModal/ActionModal.js +169 -35
- package/dist/components/overlays/BottomSheet/BottomSheet.js +96 -23
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +48 -8
- package/dist/components/overlays/Drawer/Drawer.js +62 -20
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +83 -27
- package/dist/components/overlays/Tooltip/Tooltip.js +137 -28
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +37 -12
- package/dist/components/segment/Segment.js +218 -57
- package/dist/components/segment/SegmentItem.js +67 -10
- package/dist/components/shared/pagination/Pagination.js +108 -22
- package/dist/components/shared/pagination/PaginationList.js +167 -64
- package/dist/components/status/Alert/Alert.js +97 -30
- package/dist/components/status/Loader/Loader.js +77 -22
- package/dist/components/status/Toast/Toast.js +21 -13
- package/dist/components/status/Toast/useToast.js +62 -57
- package/dist/components/table/ColumnConfig.js +158 -54
- package/dist/components/table/InfiniteTable.js +67 -16
- package/dist/components/table/PaginatedTable.js +84 -18
- package/dist/components/table/Table.js +28 -27
- package/dist/components/text/Link/Link.js +19 -7
- package/dist/components/text/Typography/Typography.js +23 -8
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +23 -9
- package/dist/config/router.context.d.ts +3 -4
- package/dist/config/router.context.js +42 -18
- package/dist/config/theme.context.js +98 -45
- package/dist/config/uiConfig.context.d.ts +15 -3
- package/dist/config/uiConfig.context.js +55 -11
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/config/uiStyle.context.js +15 -5
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useBreakpoint.js +16 -3
- package/dist/hooks/useDebounceCallback.js +51 -17
- package/dist/hooks/useFilters.js +145 -80
- package/dist/hooks/useForm.js +42 -8
- package/dist/hooks/useFormAutosave.js +101 -30
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +91 -24
- package/dist/hooks/useLocalStorage.js +43 -10
- package/dist/hooks/useLongPressRepeat.js +55 -20
- package/dist/hooks/usePagination.js +51 -17
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +57 -0
- package/dist/hooks/useScrollableListBox.js +37 -16
- package/dist/hooks/useSorting.js +71 -27
- package/dist/hooks/useStateAndRef.js +21 -7
- package/dist/hooks/useTableColumnConfig.js +124 -31
- package/dist/hooks/useTranslationMemo.js +25 -5
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -3
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +31 -10
- package/dist/utils/date-time.utils.js +117 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/routing.utils.d.ts +1 -0
- package/dist/utils/routing.utils.js +14 -0
- package/package.json +2 -2
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
1
2
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
4
|
import "../../../../config/i18n.js";
|
|
4
5
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
6
|
+
import { datePickerInputContentRow } from "../shared/datePickerInput.cva.js";
|
|
7
|
+
import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
5
8
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
6
9
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
7
10
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
11
|
+
import { getStaticDateRangeSegments } from "../shared/staticDateTimeSegments.js";
|
|
8
12
|
import { FormField } from "../../FormField/FormField.js";
|
|
9
13
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
14
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
15
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
16
|
+
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
10
17
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
11
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
19
|
import { clsx } from "clsx";
|
|
@@ -15,7 +22,7 @@ import { Button } from "react-aria-components";
|
|
|
15
22
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
16
23
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
24
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
import { Controller } from "react-hook-form";
|
|
25
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
19
26
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
20
27
|
import { DateTime } from "luxon";
|
|
21
28
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
@@ -23,7 +30,18 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
23
30
|
var DateRangePickerBase = (props) => {
|
|
24
31
|
const ui = UIConfig.useConfig();
|
|
25
32
|
const { t } = useTranslation();
|
|
26
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel
|
|
33
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, autoFixYear: autoFixYearProp, ...rest } = props;
|
|
34
|
+
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
35
|
+
const variant = variantProp ?? ui.input.variant;
|
|
36
|
+
const as = asProp ?? ui.input.as;
|
|
37
|
+
const size = sizeProp ?? ui.input.size;
|
|
38
|
+
const isClearable = isClearableProp ?? ui.input.isClearable;
|
|
39
|
+
const todayIcon = todayIconProp ?? ui.dateInput.todayIcon;
|
|
40
|
+
const todayIconButtonSize = todayIconButtonSizeProp ?? ui.dateInput.todayIconButtonSize;
|
|
41
|
+
const todayIconPlacement = todayIconPlacementProp ?? ui.dateInput.todayIconPlacement;
|
|
42
|
+
const shouldForceLeadingZeros = shouldForceLeadingZerosProp ?? ui.dateInput.shouldForceLeadingZeros;
|
|
43
|
+
const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
|
|
44
|
+
const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
|
|
27
45
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
28
46
|
const datePickerInputRef = useRef(null);
|
|
29
47
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -43,6 +61,7 @@ var DateRangePickerBase = (props) => {
|
|
|
43
61
|
if (isValidRange(newValue)) return;
|
|
44
62
|
onChange?.(newValue);
|
|
45
63
|
handleCalendarStatesChange(newValue);
|
|
64
|
+
debouncedBlur(newValue);
|
|
46
65
|
},
|
|
47
66
|
shouldCloseOnSelect: false
|
|
48
67
|
});
|
|
@@ -57,9 +76,16 @@ var DateRangePickerBase = (props) => {
|
|
|
57
76
|
shouldForceLeadingZeros
|
|
58
77
|
}, dialogState, dateRangePickerRef);
|
|
59
78
|
const { locale } = useLocale$1();
|
|
60
|
-
useImperativeHandle(ref, () => ({
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
useImperativeHandle(ref, () => ({
|
|
80
|
+
clear: () => {
|
|
81
|
+
datePickerInputRef.current?.clear();
|
|
82
|
+
},
|
|
83
|
+
getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
|
|
84
|
+
}));
|
|
85
|
+
const handleBlur = (newValue_0) => {
|
|
86
|
+
onBlur?.({ target: { value: newValue_0 } });
|
|
87
|
+
};
|
|
88
|
+
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
63
89
|
const formFieldProps = {
|
|
64
90
|
error: error || validationRangeError,
|
|
65
91
|
label,
|
|
@@ -110,10 +136,10 @@ var DateRangePickerBase = (props) => {
|
|
|
110
136
|
className: headerClassName,
|
|
111
137
|
labelProps
|
|
112
138
|
};
|
|
113
|
-
const isValidRange = useCallback((
|
|
114
|
-
if (
|
|
115
|
-
const startDate =
|
|
116
|
-
if (
|
|
139
|
+
const isValidRange = useCallback((newValue_1) => {
|
|
140
|
+
if (newValue_1?.start && newValue_1?.end) {
|
|
141
|
+
const startDate = newValue_1.start;
|
|
142
|
+
if (newValue_1.end.compare(startDate) < 0) {
|
|
117
143
|
setValidationRangeError(t(($) => $.ui.datePicker.errors.endDateBeforeStart, { ns: "ui" }));
|
|
118
144
|
return true;
|
|
119
145
|
}
|
|
@@ -121,20 +147,20 @@ var DateRangePickerBase = (props) => {
|
|
|
121
147
|
} else setValidationRangeError(void 0);
|
|
122
148
|
return false;
|
|
123
149
|
}, [t]);
|
|
124
|
-
const handleCalendarStatesChange = (
|
|
125
|
-
if (
|
|
126
|
-
if (isValidRange(
|
|
127
|
-
dialogState.setValue(
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
leftCalendarState.setFocusedDate(
|
|
131
|
-
if (
|
|
132
|
-
else rightCalendarState.setFocusedDate(
|
|
133
|
-
leftCalendarState.setValue(
|
|
134
|
-
rightCalendarState.setValue(
|
|
150
|
+
const handleCalendarStatesChange = (newValue_2) => {
|
|
151
|
+
if (newValue_2) {
|
|
152
|
+
if (isValidRange(newValue_2)) return;
|
|
153
|
+
dialogState.setValue(newValue_2);
|
|
154
|
+
const startDate_0 = newValue_2.start;
|
|
155
|
+
const endDate_0 = newValue_2.end;
|
|
156
|
+
leftCalendarState.setFocusedDate(startDate_0);
|
|
157
|
+
if (startDate_0.year === endDate_0.year && startDate_0.month === endDate_0.month) rightCalendarState.setFocusedDate(startDate_0.add({ months: 1 }));
|
|
158
|
+
else rightCalendarState.setFocusedDate(endDate_0);
|
|
159
|
+
leftCalendarState.setValue(newValue_2);
|
|
160
|
+
rightCalendarState.setValue(newValue_2);
|
|
135
161
|
setRangeSelection({
|
|
136
|
-
start:
|
|
137
|
-
end:
|
|
162
|
+
start: newValue_2.start,
|
|
163
|
+
end: newValue_2.end,
|
|
138
164
|
isSelecting: false
|
|
139
165
|
});
|
|
140
166
|
setHoverDate(null);
|
|
@@ -158,27 +184,27 @@ var DateRangePickerBase = (props) => {
|
|
|
158
184
|
setHoverDate(date);
|
|
159
185
|
});
|
|
160
186
|
}, []);
|
|
161
|
-
const handleDateHover = useCallback((
|
|
162
|
-
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(
|
|
187
|
+
const handleDateHover = useCallback((date_0) => {
|
|
188
|
+
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(date_0);
|
|
163
189
|
}, [
|
|
164
190
|
rangeSelection.isSelecting,
|
|
165
191
|
rangeSelection.start,
|
|
166
192
|
throttledSetHoverDate
|
|
167
193
|
]);
|
|
168
|
-
const handleDateSelection = useCallback((
|
|
194
|
+
const handleDateSelection = useCallback((date_1, calendarSide) => {
|
|
169
195
|
if (calendarSide) {
|
|
170
196
|
const currentVisibleMonth = (calendarSide === "left" ? leftCalendarState : rightCalendarState).visibleRange.start;
|
|
171
|
-
if (
|
|
172
|
-
leftCalendarState.setFocusedDate(
|
|
173
|
-
rightCalendarState.setFocusedDate(
|
|
197
|
+
if (date_1.month !== currentVisibleMonth.month || date_1.year !== currentVisibleMonth.year) if (calendarSide === "left") {
|
|
198
|
+
leftCalendarState.setFocusedDate(date_1);
|
|
199
|
+
rightCalendarState.setFocusedDate(date_1.add({ months: 1 }));
|
|
174
200
|
} else {
|
|
175
|
-
rightCalendarState.setFocusedDate(
|
|
176
|
-
leftCalendarState.setFocusedDate(
|
|
201
|
+
rightCalendarState.setFocusedDate(date_1);
|
|
202
|
+
leftCalendarState.setFocusedDate(date_1.subtract({ months: 1 }));
|
|
177
203
|
}
|
|
178
204
|
}
|
|
179
205
|
if (!rangeSelection.isSelecting || !rangeSelection.start) {
|
|
180
206
|
setRangeSelection({
|
|
181
|
-
start:
|
|
207
|
+
start: date_1,
|
|
182
208
|
end: null,
|
|
183
209
|
isSelecting: true
|
|
184
210
|
});
|
|
@@ -187,7 +213,7 @@ var DateRangePickerBase = (props) => {
|
|
|
187
213
|
rightCalendarState.setValue(null);
|
|
188
214
|
} else {
|
|
189
215
|
const { start } = rangeSelection;
|
|
190
|
-
const end =
|
|
216
|
+
const end = date_1;
|
|
191
217
|
const finalStart = start.compare(end) <= 0 ? start : end;
|
|
192
218
|
const finalEnd = start.compare(end) <= 0 ? end : start;
|
|
193
219
|
const newRange = {
|
|
@@ -211,16 +237,16 @@ var DateRangePickerBase = (props) => {
|
|
|
211
237
|
rightCalendarState,
|
|
212
238
|
dialogState
|
|
213
239
|
]);
|
|
214
|
-
const handleKeyboardNavigation = useCallback((event,
|
|
215
|
-
const
|
|
216
|
-
const otherState =
|
|
240
|
+
const handleKeyboardNavigation = useCallback((event, date_2, calendarSide_0) => {
|
|
241
|
+
const currentState_0 = calendarSide_0 === "left" ? leftCalendarState : rightCalendarState;
|
|
242
|
+
const otherState = calendarSide_0 === "left" ? rightCalendarState : leftCalendarState;
|
|
217
243
|
let shouldPreventDefault = false;
|
|
218
244
|
switch (event.key) {
|
|
219
245
|
case "ArrowRight": {
|
|
220
|
-
const nextDate =
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
246
|
+
const nextDate = date_2.add({ days: 1 });
|
|
247
|
+
const currentMonth_2 = currentState_0.visibleRange.start;
|
|
248
|
+
const otherMonth_2 = otherState.visibleRange.start;
|
|
249
|
+
if (calendarSide_0 === "left" && nextDate.month !== currentMonth_2.month) if (nextDate.year === otherMonth_2.year && nextDate.month === otherMonth_2.month) {
|
|
224
250
|
otherState.setFocusedDate(nextDate);
|
|
225
251
|
shouldPreventDefault = true;
|
|
226
252
|
} else {
|
|
@@ -230,10 +256,10 @@ var DateRangePickerBase = (props) => {
|
|
|
230
256
|
break;
|
|
231
257
|
}
|
|
232
258
|
case "ArrowLeft": {
|
|
233
|
-
const prevDate =
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
259
|
+
const prevDate = date_2.subtract({ days: 1 });
|
|
260
|
+
const currentMonth_1 = currentState_0.visibleRange.start;
|
|
261
|
+
const otherMonth_1 = otherState.visibleRange.start;
|
|
262
|
+
if (calendarSide_0 === "right" && prevDate.month !== currentMonth_1.month) if (prevDate.year === otherMonth_1.year && prevDate.month === otherMonth_1.month) {
|
|
237
263
|
otherState.setFocusedDate(prevDate);
|
|
238
264
|
shouldPreventDefault = true;
|
|
239
265
|
} else {
|
|
@@ -243,10 +269,10 @@ var DateRangePickerBase = (props) => {
|
|
|
243
269
|
break;
|
|
244
270
|
}
|
|
245
271
|
case "ArrowDown": {
|
|
246
|
-
const nextWeekDate =
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
272
|
+
const nextWeekDate = date_2.add({ weeks: 1 });
|
|
273
|
+
const currentMonth_0 = currentState_0.visibleRange.start;
|
|
274
|
+
const otherMonth_0 = otherState.visibleRange.start;
|
|
275
|
+
if (calendarSide_0 === "left" && nextWeekDate.month !== currentMonth_0.month) if (nextWeekDate.year === otherMonth_0.year && nextWeekDate.month === otherMonth_0.month) {
|
|
250
276
|
otherState.setFocusedDate(nextWeekDate);
|
|
251
277
|
shouldPreventDefault = true;
|
|
252
278
|
} else {
|
|
@@ -256,10 +282,10 @@ var DateRangePickerBase = (props) => {
|
|
|
256
282
|
break;
|
|
257
283
|
}
|
|
258
284
|
case "ArrowUp": {
|
|
259
|
-
const prevWeekDate =
|
|
260
|
-
const currentMonth =
|
|
285
|
+
const prevWeekDate = date_2.subtract({ weeks: 1 });
|
|
286
|
+
const currentMonth = currentState_0.visibleRange.start;
|
|
261
287
|
const otherMonth = otherState.visibleRange.start;
|
|
262
|
-
if (
|
|
288
|
+
if (calendarSide_0 === "right" && prevWeekDate.month !== currentMonth.month) if (prevWeekDate.year === otherMonth.year && prevWeekDate.month === otherMonth.month) {
|
|
263
289
|
otherState.setFocusedDate(prevWeekDate);
|
|
264
290
|
shouldPreventDefault = true;
|
|
265
291
|
} else {
|
|
@@ -270,7 +296,7 @@ var DateRangePickerBase = (props) => {
|
|
|
270
296
|
}
|
|
271
297
|
case "Enter":
|
|
272
298
|
case " ":
|
|
273
|
-
handleDateSelection(
|
|
299
|
+
handleDateSelection(date_2);
|
|
274
300
|
shouldPreventDefault = true;
|
|
275
301
|
break;
|
|
276
302
|
case "Escape":
|
|
@@ -294,14 +320,14 @@ var DateRangePickerBase = (props) => {
|
|
|
294
320
|
rightCalendarState,
|
|
295
321
|
handleDateSelection
|
|
296
322
|
]);
|
|
297
|
-
const syncCalendarStates = useCallback((
|
|
298
|
-
if (isValidRange(
|
|
299
|
-
leftCalendarState.setValue(
|
|
300
|
-
rightCalendarState.setValue(
|
|
301
|
-
dialogState.setValue(
|
|
302
|
-
if (
|
|
303
|
-
start:
|
|
304
|
-
end:
|
|
323
|
+
const syncCalendarStates = useCallback((newValue_3) => {
|
|
324
|
+
if (isValidRange(newValue_3)) return;
|
|
325
|
+
leftCalendarState.setValue(newValue_3);
|
|
326
|
+
rightCalendarState.setValue(newValue_3);
|
|
327
|
+
dialogState.setValue(newValue_3);
|
|
328
|
+
if (newValue_3) setRangeSelection({
|
|
329
|
+
start: newValue_3.start,
|
|
330
|
+
end: newValue_3.end,
|
|
305
331
|
isSelecting: false
|
|
306
332
|
});
|
|
307
333
|
else setRangeSelection({
|
|
@@ -321,7 +347,10 @@ var DateRangePickerBase = (props) => {
|
|
|
321
347
|
start: rangeSelection.start,
|
|
322
348
|
end: rangeSelection.end
|
|
323
349
|
} : dialogState.value;
|
|
324
|
-
if (valueToApply)
|
|
350
|
+
if (valueToApply) {
|
|
351
|
+
state.setValue(valueToApply);
|
|
352
|
+
handleBlur(valueToApply);
|
|
353
|
+
}
|
|
325
354
|
state.toggle();
|
|
326
355
|
};
|
|
327
356
|
const onTodayPress = () => {
|
|
@@ -340,11 +369,11 @@ var DateRangePickerBase = (props) => {
|
|
|
340
369
|
dialogState.setValue(state.value);
|
|
341
370
|
leftCalendarState.setValue(state.value);
|
|
342
371
|
rightCalendarState.setValue(state.value);
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
leftCalendarState.setFocusedDate(
|
|
346
|
-
if (
|
|
347
|
-
else rightCalendarState.setFocusedDate(
|
|
372
|
+
const startDate_1 = state.value.start || today(getLocalTimeZone());
|
|
373
|
+
const endDate_1 = state.value.end || today(getLocalTimeZone()).add({ months: 1 });
|
|
374
|
+
leftCalendarState.setFocusedDate(startDate_1);
|
|
375
|
+
if (startDate_1.year === endDate_1.year && startDate_1.month === endDate_1.month) rightCalendarState.setFocusedDate(startDate_1.add({ months: 1 }));
|
|
376
|
+
else rightCalendarState.setFocusedDate(endDate_1);
|
|
348
377
|
setRangeSelection({
|
|
349
378
|
start: state.value.start,
|
|
350
379
|
end: state.value.end,
|
|
@@ -353,87 +382,87 @@ var DateRangePickerBase = (props) => {
|
|
|
353
382
|
}
|
|
354
383
|
}
|
|
355
384
|
};
|
|
356
|
-
const
|
|
385
|
+
const todayDate_0 = today(getLocalTimeZone());
|
|
357
386
|
const getThisWeekRange = () => {
|
|
358
387
|
return {
|
|
359
|
-
start: startOfWeek(
|
|
360
|
-
end: endOfWeek(
|
|
388
|
+
start: startOfWeek(todayDate_0, locale),
|
|
389
|
+
end: endOfWeek(todayDate_0, locale)
|
|
361
390
|
};
|
|
362
391
|
};
|
|
363
392
|
const getLastWeekRange = () => {
|
|
364
|
-
const thisWeekStart = startOfWeek(
|
|
393
|
+
const thisWeekStart = startOfWeek(todayDate_0, locale);
|
|
365
394
|
return {
|
|
366
395
|
start: thisWeekStart.subtract({ weeks: 1 }),
|
|
367
396
|
end: thisWeekStart.subtract({ days: 1 })
|
|
368
397
|
};
|
|
369
398
|
};
|
|
370
399
|
const getThisAndLastWeekRange = () => {
|
|
371
|
-
const thisWeekEnd = endOfWeek(
|
|
400
|
+
const thisWeekEnd = endOfWeek(todayDate_0, locale);
|
|
372
401
|
return {
|
|
373
|
-
start: startOfWeek(
|
|
402
|
+
start: startOfWeek(todayDate_0, locale).subtract({ weeks: 1 }),
|
|
374
403
|
end: thisWeekEnd
|
|
375
404
|
};
|
|
376
405
|
};
|
|
377
406
|
const getThisMonthRange = () => {
|
|
378
407
|
return {
|
|
379
|
-
start: startOfMonth(
|
|
380
|
-
end: endOfMonth(
|
|
408
|
+
start: startOfMonth(todayDate_0),
|
|
409
|
+
end: endOfMonth(todayDate_0)
|
|
381
410
|
};
|
|
382
411
|
};
|
|
383
412
|
const getThisAndLastMonthRange = () => {
|
|
384
|
-
const thisMonthEnd = endOfMonth(
|
|
413
|
+
const thisMonthEnd = endOfMonth(todayDate_0);
|
|
385
414
|
return {
|
|
386
|
-
start: startOfMonth(
|
|
415
|
+
start: startOfMonth(todayDate_0).subtract({ months: 1 }),
|
|
387
416
|
end: thisMonthEnd
|
|
388
417
|
};
|
|
389
418
|
};
|
|
390
419
|
const presets = [
|
|
391
420
|
{
|
|
392
|
-
label: t(($) =>
|
|
421
|
+
label: t(($_0) => $_0.ui.datePicker.presets.thisWeek, { ns: "ui" }),
|
|
393
422
|
getValue: getThisWeekRange
|
|
394
423
|
},
|
|
395
424
|
{
|
|
396
|
-
label: t(($) =>
|
|
425
|
+
label: t(($_1) => $_1.ui.datePicker.presets.lastWeek, { ns: "ui" }),
|
|
397
426
|
getValue: getLastWeekRange
|
|
398
427
|
},
|
|
399
428
|
{
|
|
400
|
-
label: t(($) =>
|
|
429
|
+
label: t(($_2) => $_2.ui.datePicker.presets.thisAndLastWeek, { ns: "ui" }),
|
|
401
430
|
getValue: getThisAndLastWeekRange
|
|
402
431
|
},
|
|
403
432
|
{
|
|
404
|
-
label: t(($) =>
|
|
433
|
+
label: t(($_3) => $_3.ui.datePicker.presets.thisMonth, { ns: "ui" }),
|
|
405
434
|
getValue: getThisMonthRange
|
|
406
435
|
},
|
|
407
436
|
{
|
|
408
|
-
label: t(($) =>
|
|
437
|
+
label: t(($_4) => $_4.ui.datePicker.presets.thisAndLastMonth, { ns: "ui" }),
|
|
409
438
|
getValue: getThisAndLastMonthRange
|
|
410
439
|
},
|
|
411
440
|
{
|
|
412
|
-
label: t(($) =>
|
|
441
|
+
label: t(($_5) => $_5.ui.datePicker.presets.thisYear, { ns: "ui" }),
|
|
413
442
|
getValue: () => ({
|
|
414
|
-
start: startOfYear(
|
|
415
|
-
end:
|
|
443
|
+
start: startOfYear(todayDate_0),
|
|
444
|
+
end: todayDate_0
|
|
416
445
|
})
|
|
417
446
|
},
|
|
418
447
|
{
|
|
419
|
-
label: t(($) =>
|
|
448
|
+
label: t(($_6) => $_6.ui.datePicker.presets.lastYear, { ns: "ui" }),
|
|
420
449
|
getValue: () => ({
|
|
421
|
-
start: startOfYear(
|
|
422
|
-
end: endOfYear(
|
|
450
|
+
start: startOfYear(todayDate_0.subtract({ years: 1 })),
|
|
451
|
+
end: endOfYear(todayDate_0.subtract({ years: 1 }))
|
|
423
452
|
})
|
|
424
453
|
},
|
|
425
454
|
{
|
|
426
|
-
label: t(($) =>
|
|
455
|
+
label: t(($_7) => $_7.ui.datePicker.presets.thisAndLastYear, { ns: "ui" }),
|
|
427
456
|
getValue: () => ({
|
|
428
|
-
start: startOfYear(
|
|
429
|
-
end:
|
|
457
|
+
start: startOfYear(todayDate_0.subtract({ years: 1 })),
|
|
458
|
+
end: todayDate_0
|
|
430
459
|
})
|
|
431
460
|
},
|
|
432
461
|
{
|
|
433
|
-
label: t(($) =>
|
|
462
|
+
label: t(($_8) => $_8.ui.datePicker.presets.soFar, { ns: "ui" }),
|
|
434
463
|
getValue: () => ({
|
|
435
|
-
start: startOfYear(
|
|
436
|
-
end:
|
|
464
|
+
start: startOfYear(todayDate_0),
|
|
465
|
+
end: todayDate_0
|
|
437
466
|
})
|
|
438
467
|
}
|
|
439
468
|
];
|
|
@@ -441,12 +470,12 @@ var DateRangePickerBase = (props) => {
|
|
|
441
470
|
setActivePreset(preset.label);
|
|
442
471
|
const presetValue = preset.getValue();
|
|
443
472
|
syncCalendarStates(presetValue);
|
|
444
|
-
const
|
|
445
|
-
leftCalendarState.setFocusedDate(
|
|
446
|
-
const
|
|
447
|
-
if ((
|
|
473
|
+
const startDate_2 = presetValue.start;
|
|
474
|
+
leftCalendarState.setFocusedDate(startDate_2);
|
|
475
|
+
const endDate_2 = presetValue.end;
|
|
476
|
+
if ((endDate_2.year - startDate_2.year) * 12 + (endDate_2.month - startDate_2.month) > 2) rightCalendarState.setFocusedDate(endDate_2);
|
|
448
477
|
else {
|
|
449
|
-
const rightCalendarMonth =
|
|
478
|
+
const rightCalendarMonth = startDate_2.add({ months: 1 });
|
|
450
479
|
rightCalendarState.setFocusedDate(rightCalendarMonth);
|
|
451
480
|
}
|
|
452
481
|
};
|
|
@@ -475,27 +504,29 @@ var DateRangePickerBase = (props) => {
|
|
|
475
504
|
isClearable,
|
|
476
505
|
headerProps,
|
|
477
506
|
todayIcon,
|
|
507
|
+
todayIconButtonSize,
|
|
508
|
+
todayIconPlacement,
|
|
478
509
|
isDirty,
|
|
479
510
|
disableManualEntry,
|
|
511
|
+
autoFixYear,
|
|
480
512
|
placeholder,
|
|
481
513
|
className: inputClassName,
|
|
482
|
-
onOpenDropdown: () => state.toggle()
|
|
483
|
-
autoFixYear
|
|
514
|
+
onOpenDropdown: () => state.toggle()
|
|
484
515
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
485
516
|
hideSidebar,
|
|
486
517
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
487
518
|
className: "flex w-full flex-row overflow-auto border-elevation-outline-default-1 border-solid [-ms-overflow-style:none] [scrollbar-width:none] md:w-[156px] md:flex-col md:border-r [&::-webkit-scrollbar]:hidden",
|
|
488
|
-
children: presets.map((
|
|
489
|
-
onClick: () => selectPreset(
|
|
490
|
-
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item", activePreset !==
|
|
519
|
+
children: presets.map((preset_0) => /* @__PURE__ */ jsx(Button, {
|
|
520
|
+
onClick: () => selectPreset(preset_0),
|
|
521
|
+
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item", activePreset !== preset_0.label && "text-interactive-text-secondary-idle hover:text-interactive-text-secondary-hover", activePreset === preset_0.label && "bg-interactive-contained-primary-idle text-interactive-text-secondary-idle-inverted"),
|
|
491
522
|
children: /* @__PURE__ */ jsx(Typography, {
|
|
492
523
|
size: "label-2",
|
|
493
524
|
sizeMobile: "label-3",
|
|
494
525
|
as: "span",
|
|
495
526
|
className: "whitespace-nowrap",
|
|
496
|
-
children:
|
|
527
|
+
children: preset_0.label
|
|
497
528
|
})
|
|
498
|
-
},
|
|
529
|
+
}, preset_0.label))
|
|
499
530
|
}),
|
|
500
531
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
501
532
|
isDisabled,
|
|
@@ -530,7 +561,29 @@ var DateRangePickerBase = (props) => {
|
|
|
530
561
|
})
|
|
531
562
|
});
|
|
532
563
|
};
|
|
533
|
-
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
564
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
|
|
565
|
+
const ui = UIConfig.useConfig();
|
|
566
|
+
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
567
|
+
const { locale } = useLocale$1();
|
|
568
|
+
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
569
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
570
|
+
const inputRef = useRef(null);
|
|
571
|
+
const { renderRealInput } = useStaticInputHandoff({
|
|
572
|
+
inputRef,
|
|
573
|
+
renderInput,
|
|
574
|
+
setRenderInput,
|
|
575
|
+
getFocusTarget: (input) => {
|
|
576
|
+
const container = input.getContainer?.() ?? input;
|
|
577
|
+
return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
581
|
+
control: props.formControl.control,
|
|
582
|
+
name: props.formControl.name
|
|
583
|
+
}) : props.value;
|
|
584
|
+
let isFormControlDisabled = false;
|
|
585
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
586
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
534
587
|
const formatDateRange = (range) => {
|
|
535
588
|
if (!range?.start || !range?.end) return null;
|
|
536
589
|
if (fullIso) return {
|
|
@@ -550,10 +603,10 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
550
603
|
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
551
604
|
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
552
605
|
};
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(
|
|
556
|
-
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(
|
|
606
|
+
const startDate_0 = DateTime.fromISO(formattedRange.start).toJSDate();
|
|
607
|
+
const endDate_0 = DateTime.fromISO(formattedRange.end).toJSDate();
|
|
608
|
+
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate_0);
|
|
609
|
+
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate_0);
|
|
557
610
|
return {
|
|
558
611
|
start: toCalendarDate(startZonedDateTime),
|
|
559
612
|
end: toCalendarDate(endZonedDateTime)
|
|
@@ -569,6 +622,56 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
569
622
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
570
623
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
571
624
|
};
|
|
625
|
+
if (!renderInput) {
|
|
626
|
+
const startDateValue = parseCalendarDate(rawValue?.start ?? null);
|
|
627
|
+
const endDateValue = parseCalendarDate(rawValue?.end ?? null);
|
|
628
|
+
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
629
|
+
const as = props.as ?? ui.input.as;
|
|
630
|
+
const size = props.size ?? ui.input.size;
|
|
631
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
632
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
633
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
634
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
635
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
636
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
637
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
638
|
+
const staticSegments = getStaticDateRangeSegments({
|
|
639
|
+
start: startDateValue,
|
|
640
|
+
end: endDateValue,
|
|
641
|
+
locale,
|
|
642
|
+
shouldForceLeadingZeros,
|
|
643
|
+
isDisabled,
|
|
644
|
+
hidePlaceholder: as === "floating" && !hasProvidedRangeValue
|
|
645
|
+
});
|
|
646
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
647
|
+
...props,
|
|
648
|
+
isDisabled,
|
|
649
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
650
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
651
|
+
contentClassName: "pr-0!",
|
|
652
|
+
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
653
|
+
labelPlacement: "content-row",
|
|
654
|
+
dataAttributes: {
|
|
655
|
+
dataIsEmpty: !hasProvidedRangeValue,
|
|
656
|
+
dataIsFilled: hasProvidedRangeValue,
|
|
657
|
+
dataIsDirty: props.isDirty,
|
|
658
|
+
dataIsRequired: props.isRequired,
|
|
659
|
+
dataIsDisabled: isDisabled,
|
|
660
|
+
dataDisabled: isDisabled,
|
|
661
|
+
dataInvalid: !!props.error,
|
|
662
|
+
dataHasSelection: hasProvidedRangeValue
|
|
663
|
+
},
|
|
664
|
+
renderStatic: true,
|
|
665
|
+
onStaticInteract: renderRealInput,
|
|
666
|
+
actionContent: staticTodayIcon,
|
|
667
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
668
|
+
wrapContentAndTrailing: true,
|
|
669
|
+
contentAndTrailingClassName: "gap-2!",
|
|
670
|
+
trailingClassName: "py-0! pl-0!",
|
|
671
|
+
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
672
|
+
children: staticSegments
|
|
673
|
+
});
|
|
674
|
+
}
|
|
572
675
|
if ("formControl" in props && props.formControl) {
|
|
573
676
|
const { formControl, ref, ...innerProps } = props;
|
|
574
677
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -577,7 +680,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
577
680
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
578
681
|
...innerProps,
|
|
579
682
|
...dateLimits,
|
|
580
|
-
ref: mergeRefs(ref, field.ref),
|
|
683
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
581
684
|
value: parseDateRange(field.value),
|
|
582
685
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
583
686
|
onBlur: field.onBlur,
|
|
@@ -590,8 +693,9 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
|
590
693
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
591
694
|
...props,
|
|
592
695
|
...dateLimits,
|
|
696
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
593
697
|
value: parseDateRange(props.value),
|
|
594
|
-
onChange: (
|
|
698
|
+
onChange: (value_0) => props.onChange?.(formatDateRange(value_0))
|
|
595
699
|
});
|
|
596
700
|
};
|
|
597
701
|
//#endregion
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
1
|
+
import { FocusEvent, Ref } from 'react';
|
|
2
2
|
import { DateValue } from 'react-aria';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
6
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
7
8
|
import { ControlProps } from '../../shared/form.types';
|
|
8
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
|
-
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
10
|
+
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
|
|
10
11
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
11
12
|
disableDropdown?: boolean;
|
|
12
13
|
isTimeOptional?: boolean;
|
|
13
14
|
isClearable?: boolean;
|
|
14
|
-
todayIcon?:
|
|
15
|
+
todayIcon?: DatePickerTodayIcon;
|
|
16
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
15
18
|
isDirty?: boolean;
|
|
16
19
|
disableManualEntry?: boolean;
|
|
20
|
+
autoFixYear?: boolean;
|
|
21
|
+
setDateValueOnDateSelection?: boolean;
|
|
17
22
|
placeholder?: string;
|
|
18
23
|
inputClassName?: string;
|
|
19
24
|
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
20
25
|
timeZone?: string;
|
|
21
|
-
autoFixYear?: boolean;
|
|
22
26
|
format?: string;
|
|
27
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
23
28
|
}
|
|
24
29
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
25
30
|
value?: string | null;
|
|
26
31
|
onChange?: (value: string | null) => void;
|
|
27
32
|
fullIso?: boolean;
|
|
33
|
+
renderStaticInput?: boolean;
|
|
28
34
|
timeZone?: string;
|
|
29
35
|
}
|
|
30
36
|
export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
|
|
31
|
-
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
32
38
|
export {};
|