@povio/ui 3.0.0-rc.3 → 3.1.0
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/README.md +39 -0
- package/dist/assets/icons/AlignCenter.js +11 -26
- package/dist/assets/icons/AlignLeft.js +11 -26
- package/dist/assets/icons/AlignLeftRight.js +11 -26
- package/dist/assets/icons/AlignRight.js +11 -26
- package/dist/assets/icons/ArrowDropDown.js +11 -26
- package/dist/assets/icons/ArrowDropUp.js +11 -26
- package/dist/assets/icons/ArrowLeft.js +11 -26
- package/dist/assets/icons/ArrowRight.js +11 -26
- package/dist/assets/icons/Bold.js +11 -26
- package/dist/assets/icons/BulletedList.js +11 -26
- package/dist/assets/icons/Calendar.js +13 -28
- package/dist/assets/icons/Check.js +13 -28
- package/dist/assets/icons/CheckCircle.js +11 -26
- package/dist/assets/icons/CheckboxCheckmark.js +14 -29
- package/dist/assets/icons/CheckboxIndeterminate.js +14 -29
- package/dist/assets/icons/ChevronDown.js +13 -28
- package/dist/assets/icons/ChevronLeft.js +13 -28
- package/dist/assets/icons/ChevronRight.js +13 -28
- package/dist/assets/icons/ChevronUp.js +13 -28
- package/dist/assets/icons/ChevronsLeft.js +13 -28
- package/dist/assets/icons/ChevronsRight.js +13 -28
- package/dist/assets/icons/Clock.js +11 -26
- package/dist/assets/icons/Close.js +11 -26
- package/dist/assets/icons/DateTime.js +14 -35
- package/dist/assets/icons/DragIndicator.js +11 -26
- package/dist/assets/icons/File.js +13 -28
- package/dist/assets/icons/Highlight.js +11 -26
- package/dist/assets/icons/HighlightOn.js +15 -49
- package/dist/assets/icons/Home.js +11 -26
- package/dist/assets/icons/Info.js +16 -37
- package/dist/assets/icons/Italic.js +11 -26
- package/dist/assets/icons/Link.js +11 -26
- package/dist/assets/icons/Menu.js +11 -26
- package/dist/assets/icons/NumberedList.js +11 -26
- package/dist/assets/icons/PointerHorizontal.js +11 -26
- package/dist/assets/icons/PointerVertical.js +11 -26
- package/dist/assets/icons/Search.js +11 -26
- package/dist/assets/icons/Send.js +13 -28
- package/dist/assets/icons/Strikethrough.js +11 -26
- package/dist/assets/icons/TextColor.js +14 -48
- package/dist/assets/icons/Today.js +11 -26
- package/dist/assets/icons/Underlined.js +13 -28
- package/dist/assets/icons/Upload.js +14 -35
- package/dist/assets/icons/Visibility.js +11 -26
- package/dist/assets/icons/VisibilityOff.js +11 -26
- package/dist/assets/icons/WarningFilled.js +13 -28
- package/dist/components/Breadcrumbs/Breadcrumbs.js +56 -207
- package/dist/components/Menu/Menu.d.ts +4 -0
- package/dist/components/Menu/Menu.js +2 -18
- package/dist/components/Menu/MenuDesktop.js +7 -41
- package/dist/components/Menu/MenuItem.js +9 -32
- package/dist/components/Menu/MenuMobile.d.ts +1 -1
- package/dist/components/Menu/MenuMobile.js +39 -97
- package/dist/components/Menu/MenuPopover.js +29 -105
- package/dist/components/buttons/IconButton/IconButton.js +8 -40
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -2
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/PillButton/PillButton.js +17 -55
- package/dist/components/buttons/SplitButton/SplitButton.js +18 -103
- package/dist/components/buttons/TextButton/TextButton.js +8 -30
- package/dist/components/buttons/ToggleButton/ToggleButton.js +8 -28
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/inputs/Checkbox/Checkbox.js +35 -201
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- 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 +5 -12
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +75 -373
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +5 -12
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +186 -492
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +5 -14
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +47 -273
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +121 -611
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +3 -5
- package/dist/components/inputs/DateTime/shared/Calendar.js +120 -338
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +2 -4
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +103 -310
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +2 -4
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +33 -150
- package/dist/components/inputs/DateTime/shared/CalendarHeader.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +98 -249
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +137 -318
- package/dist/components/inputs/DateTime/shared/DateField.js +112 -286
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -14
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +129 -356
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +0 -15
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +11 -96
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.d.ts +4 -1
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +28 -81
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +58 -103
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +82 -193
- package/dist/components/inputs/DateTime/shared/TimeField.js +8 -27
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +110 -279
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -4
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +65 -210
- package/dist/components/inputs/DateTime/shared/YearPicker.js +68 -119
- package/dist/components/inputs/File/FileUpload.js +45 -88
- package/dist/components/inputs/File/FileUploadContainer.js +7 -15
- package/dist/components/inputs/File/InputUpload.js +79 -317
- package/dist/components/inputs/File/shared/FileCard.js +41 -104
- package/dist/components/inputs/File/shared/FileCardList.js +12 -47
- package/dist/components/inputs/File/shared/FileUploadContent.js +44 -175
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +46 -149
- package/dist/components/inputs/File/shared/FileUploadContentError.js +93 -234
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +97 -230
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +55 -199
- package/dist/components/inputs/File/shared/InputUploadContent.js +34 -148
- package/dist/components/inputs/File/shared/InputUploadFilled.js +8 -49
- package/dist/components/inputs/File/shared/ProgressBar.d.ts +2 -2
- package/dist/components/inputs/File/shared/ProgressBar.js +20 -53
- package/dist/components/inputs/File/shared/fileUpload.cva.d.ts +1 -1
- package/dist/components/inputs/File/shared/fileUpload.cva.js +1 -1
- package/dist/components/inputs/File/shared/progressBar.cva.d.ts +38 -0
- package/dist/components/inputs/File/shared/progressBar.cva.js +28 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormField.js +37 -119
- package/dist/components/inputs/FormField/FormFieldError.js +5 -25
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +22 -81
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +7 -31
- package/dist/components/inputs/FormField/FormFieldHelper.js +6 -26
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.js +9 -40
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +2 -5
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +97 -447
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +9 -48
- package/dist/components/inputs/Input/TextArea/TextArea.js +90 -305
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +1 -3
- package/dist/components/inputs/Input/TextInput/TextInput.js +90 -419
- package/dist/components/inputs/Input/shared/InputContent.js +59 -192
- package/dist/components/inputs/Inputs/Form.js +11 -40
- package/dist/components/inputs/Inputs/InputItem.d.ts +21 -15
- package/dist/components/inputs/Inputs/InputItem.js +14 -69
- package/dist/components/inputs/Inputs/Inputs.js +11 -37
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -3
- package/dist/components/inputs/RadioGroup/RadioGroup.js +61 -353
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +0 -45
- package/dist/components/inputs/RadioGroup/radio.cva.js +1 -48
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +2 -6
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +22 -217
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +8 -107
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -7
- package/dist/components/inputs/Selection/Select/Select.js +18 -227
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +3 -8
- package/dist/components/inputs/Selection/shared/SelectBase.js +18 -69
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +138 -393
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +116 -397
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +25 -99
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +52 -164
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +35 -85
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +16 -69
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +21 -70
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +9 -58
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +6 -11
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -3
- package/dist/components/inputs/Selection/shared/select.context.js +36 -67
- package/dist/components/inputs/Selection/shared/select.types.d.ts +2 -3
- package/dist/components/inputs/Selection/shared/useSelectItems.js +49 -109
- package/dist/components/inputs/Slider/Slider.d.ts +1 -2
- package/dist/components/inputs/Slider/Slider.js +76 -265
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +0 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +98 -447
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +11 -37
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +30 -102
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +45 -194
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +28 -88
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +14 -48
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +19 -66
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +15 -49
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +32 -92
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +54 -126
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +38 -141
- package/dist/components/inputs/Toggle/Toggle.d.ts +0 -1
- package/dist/components/inputs/Toggle/Toggle.js +37 -214
- 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 +11 -21
- package/dist/components/inputs/shared/InputClear.d.ts +1 -2
- package/dist/components/inputs/shared/InputClear.js +12 -88
- package/dist/components/inputs/shared/TooltipWrapper.js +11 -50
- package/dist/components/inputs/shared/input.cva.d.ts +0 -28
- package/dist/components/inputs/shared/input.cva.js +4 -38
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/navigation/Stepper/StepperItem.js +31 -104
- package/dist/components/navigation/Stepper/StepperSeparator.js +5 -23
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/BottomSheet/BottomSheet.js +25 -98
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +8 -48
- package/dist/components/overlays/Drawer/Drawer.js +22 -64
- package/dist/components/overlays/Modal/modal.cva.js +1 -1
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.d.ts +5 -1
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +28 -83
- package/dist/components/overlays/Tooltip/Tooltip.js +28 -137
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +12 -37
- package/dist/components/segment/Segment.js +57 -218
- package/dist/components/segment/SegmentItem.js +10 -67
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/shared/pagination/PaginationList.js +64 -167
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/status/Loader/Loader.js +22 -77
- package/dist/components/status/Toast/Toast.js +17 -22
- package/dist/components/status/Toast/toast.cva.d.ts +14 -3
- package/dist/components/status/Toast/toast.cva.js +12 -10
- package/dist/components/status/Toast/useToast.js +57 -62
- package/dist/components/table/ColumnConfig.js +54 -158
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/PaginatedTable.js +18 -84
- package/dist/components/table/Table.js +30 -30
- package/dist/components/table/table.cva.d.ts +7 -0
- package/dist/components/table/table.cva.js +2 -1
- package/dist/components/text/Link/Link.js +7 -19
- package/dist/components/text/Pill/Pill.d.ts +15 -0
- package/dist/components/text/Pill/Pill.js +44 -0
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +9 -23
- package/dist/config/router.context.js +16 -42
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.d.ts +10 -21
- package/dist/config/uiConfig.context.js +18 -69
- package/dist/config/uiOverrides.context.d.ts +10 -20
- package/dist/config/uiOverrides.context.js +14 -54
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +0 -3
- package/dist/hooks/useAutosave.d.ts +1 -2
- package/dist/hooks/useAutosave.js +4 -12
- package/dist/hooks/useBreakpoint.js +3 -16
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useFilters.js +64 -125
- package/dist/hooks/useForm.js +8 -42
- package/dist/hooks/useFormAutosave.d.ts +1 -3
- package/dist/hooks/useFormAutosave.js +30 -122
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +24 -91
- package/dist/hooks/useLocalStorage.js +10 -43
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/hooks/usePagination.js +19 -49
- package/dist/hooks/useScrollableListBox.js +16 -37
- package/dist/hooks/useSorting.js +28 -69
- package/dist/hooks/useStateAndRef.js +7 -21
- package/dist/hooks/useTableColumnConfig.js +31 -124
- package/dist/hooks/useTranslationMemo.js +5 -25
- package/dist/index.d.ts +7 -16
- package/dist/index.js +6 -13
- package/dist/tw-ui-plugin.js +0 -6
- package/dist/utils/date-time.utils.d.ts +10 -38
- package/dist/utils/date-time.utils.js +22 -136
- package/package.json +1 -1
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +0 -5
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +0 -16
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +0 -16
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +0 -15
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +0 -32
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +0 -2
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +0 -1
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +0 -40
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +0 -85
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +0 -1
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +0 -13
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +0 -14
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +0 -45
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +0 -571
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +0 -35
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +0 -575
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +0 -8
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +0 -5
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +0 -1
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +0 -7
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +0 -37
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +0 -14
- package/dist/components/inputs/Selection/Select/QuerySelect.js +0 -178
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +0 -9
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +0 -47
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -14
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -43
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +0 -6
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +0 -5
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +0 -12
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +0 -8
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +0 -23
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +0 -54
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +0 -1
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +0 -82
- package/dist/components/inputs/Skeleton/InputFrame.js +0 -548
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +0 -8
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +0 -5
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +0 -14
- package/dist/components/inputs/shared/useStaticInputHandoff.js +0 -100
- package/dist/hooks/useAutosave.spec.d.ts +0 -1
- package/dist/hooks/useFormAutosave.spec.d.ts +0 -1
- package/dist/hooks/useKeyInteractions.d.ts +0 -20
- package/dist/hooks/useKeyInteractions.js +0 -54
- package/dist/hooks/useKeyInteractions.spec.d.ts +0 -1
- package/dist/hooks/useQueryAutocomplete.d.ts +0 -14
- package/dist/hooks/useQueryAutocomplete.js +0 -72
- package/dist/utils/query.utils.d.ts +0 -4
- package/dist/utils/query.utils.js +0 -8
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { UIOverrides } from "../../../../config/uiOverrides.context.js";
|
|
2
1
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
3
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
4
3
|
import "../../../../config/i18n.js";
|
|
5
4
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
6
|
-
import { datePickerInputContentRowDefinition } from "../shared/datePickerInput.cva.js";
|
|
7
|
-
import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
8
5
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
9
6
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
10
7
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
11
|
-
import { getStaticDateRangeSegments } from "../shared/staticDateTimeSegments.js";
|
|
12
8
|
import { FormField } from "../../FormField/FormField.js";
|
|
13
9
|
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";
|
|
17
10
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
18
|
-
import { c } from "react/compiler-runtime";
|
|
19
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
12
|
import { clsx } from "clsx";
|
|
21
13
|
import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
@@ -31,32 +23,15 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
31
23
|
var DateRangePickerBase = (props) => {
|
|
32
24
|
const ui = UIConfig.useConfig();
|
|
33
25
|
const { t } = useTranslation();
|
|
34
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange,
|
|
35
|
-
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
36
|
-
const variant = variantProp ?? ui.input.variant;
|
|
37
|
-
const as = asProp ?? ui.input.as;
|
|
38
|
-
const size = sizeProp ?? ui.input.size;
|
|
39
|
-
const isClearable = isClearableProp ?? ui.input.isClearable;
|
|
40
|
-
const todayIcon = todayIconProp ?? ui.dateInput.todayIcon;
|
|
41
|
-
const todayIconButtonSize = todayIconButtonSizeProp ?? ui.dateInput.todayIconButtonSize;
|
|
42
|
-
const todayIconButtonComponent = todayIconButtonComponentProp ?? ui.dateInput.todayIconButtonComponent;
|
|
43
|
-
const todayIconPlacement = todayIconPlacementProp ?? ui.dateInput.todayIconPlacement;
|
|
44
|
-
const shouldForceLeadingZeros = shouldForceLeadingZerosProp ?? ui.dateInput.shouldForceLeadingZeros;
|
|
45
|
-
const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
|
|
46
|
-
const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
|
|
47
|
-
const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
|
|
48
|
-
const timeZone = ui.dateInput.timeZone;
|
|
49
|
-
let effectiveTimeZone = getLocalTimeZone();
|
|
50
|
-
if (timeZone !== "clientLocal") effectiveTimeZone = timeZone;
|
|
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, minValue, maxValue, ...rest } = props;
|
|
51
27
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
52
28
|
const datePickerInputRef = useRef(null);
|
|
53
29
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
54
30
|
return datePickerInputRef.current?.getContainer?.() || null;
|
|
55
31
|
} }), []);
|
|
56
|
-
const normalizedValue = value ?? null;
|
|
57
32
|
const dialogState = useDateRangePickerState({
|
|
58
33
|
...rest,
|
|
59
|
-
value
|
|
34
|
+
value,
|
|
60
35
|
shouldCloseOnSelect: false,
|
|
61
36
|
shouldForceLeadingZeros,
|
|
62
37
|
minValue,
|
|
@@ -65,15 +40,13 @@ var DateRangePickerBase = (props) => {
|
|
|
65
40
|
const state = useDateRangePickerState({
|
|
66
41
|
...rest,
|
|
67
42
|
shouldForceLeadingZeros,
|
|
68
|
-
value
|
|
43
|
+
value,
|
|
69
44
|
minValue,
|
|
70
45
|
maxValue,
|
|
71
46
|
onChange: (newValue) => {
|
|
72
|
-
|
|
47
|
+
if (isValidRange(newValue)) return;
|
|
73
48
|
onChange?.(newValue);
|
|
74
|
-
if (isInvalidRange) return;
|
|
75
49
|
handleCalendarStatesChange(newValue);
|
|
76
|
-
if (fireBlurOnChange) debouncedBlur(newValue);
|
|
77
50
|
},
|
|
78
51
|
shouldCloseOnSelect: false
|
|
79
52
|
});
|
|
@@ -92,16 +65,9 @@ var DateRangePickerBase = (props) => {
|
|
|
92
65
|
maxValue
|
|
93
66
|
}, dialogState, dateRangePickerRef);
|
|
94
67
|
const { locale } = useLocale$1();
|
|
95
|
-
useImperativeHandle(ref, () => ({
|
|
96
|
-
clear
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
|
|
100
|
-
}));
|
|
101
|
-
const handleBlur = (newValue_0) => {
|
|
102
|
-
onBlur?.({ target: { value: newValue_0 } });
|
|
103
|
-
};
|
|
104
|
-
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
68
|
+
useImperativeHandle(ref, () => ({ clear: () => {
|
|
69
|
+
datePickerInputRef.current?.clear();
|
|
70
|
+
} }));
|
|
105
71
|
const formFieldProps = {
|
|
106
72
|
error: error || validationRangeError,
|
|
107
73
|
label,
|
|
@@ -130,7 +96,7 @@ var DateRangePickerBase = (props) => {
|
|
|
130
96
|
createCalendar,
|
|
131
97
|
pageBehavior: "single",
|
|
132
98
|
visibleDuration: { months: 1 },
|
|
133
|
-
defaultFocusedValue: today(
|
|
99
|
+
defaultFocusedValue: today(getLocalTimeZone()).add({ months: 1 }),
|
|
134
100
|
minValue,
|
|
135
101
|
maxValue
|
|
136
102
|
});
|
|
@@ -173,15 +139,15 @@ var DateRangePickerBase = (props) => {
|
|
|
173
139
|
end: endDate
|
|
174
140
|
};
|
|
175
141
|
}, [minValue, maxValue]);
|
|
176
|
-
const isRangeWithinBounds = useCallback((
|
|
177
|
-
if (minValue &&
|
|
178
|
-
if (maxValue &&
|
|
142
|
+
const isRangeWithinBounds = useCallback((range) => {
|
|
143
|
+
if (minValue && range.start.compare(minValue) < 0) return false;
|
|
144
|
+
if (maxValue && range.end.compare(maxValue) > 0) return false;
|
|
179
145
|
return true;
|
|
180
146
|
}, [minValue, maxValue]);
|
|
181
|
-
const isValidRange = useCallback((
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
147
|
+
const isValidRange = useCallback((newValue) => {
|
|
148
|
+
if (newValue?.start && newValue?.end) {
|
|
149
|
+
const startDate = newValue.start;
|
|
150
|
+
if (newValue.end.compare(startDate) < 0) {
|
|
185
151
|
setValidationRangeError(t(($) => $.ui.datePicker.errors.endDateBeforeStart, { ns: "ui" }));
|
|
186
152
|
return true;
|
|
187
153
|
}
|
|
@@ -189,17 +155,17 @@ var DateRangePickerBase = (props) => {
|
|
|
189
155
|
} else setValidationRangeError(void 0);
|
|
190
156
|
return false;
|
|
191
157
|
}, [t]);
|
|
192
|
-
const handleCalendarStatesChange = (
|
|
193
|
-
if (
|
|
194
|
-
const clampedValue = clampRangeToBounds(
|
|
158
|
+
const handleCalendarStatesChange = (newValue) => {
|
|
159
|
+
if (newValue) {
|
|
160
|
+
const clampedValue = clampRangeToBounds(newValue);
|
|
195
161
|
if (!clampedValue) return;
|
|
196
162
|
if (isValidRange(clampedValue)) return;
|
|
197
163
|
dialogState.setValue(clampedValue);
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
leftCalendarState.setFocusedDate(
|
|
201
|
-
if (
|
|
202
|
-
else rightCalendarState.setFocusedDate(
|
|
164
|
+
const startDate = clampedValue.start;
|
|
165
|
+
const endDate = clampedValue.end;
|
|
166
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
167
|
+
if (startDate.year === endDate.year && startDate.month === endDate.month) rightCalendarState.setFocusedDate(startDate.add({ months: 1 }));
|
|
168
|
+
else rightCalendarState.setFocusedDate(endDate);
|
|
203
169
|
leftCalendarState.setValue(clampedValue);
|
|
204
170
|
rightCalendarState.setValue(clampedValue);
|
|
205
171
|
setRangeSelection({
|
|
@@ -223,33 +189,33 @@ var DateRangePickerBase = (props) => {
|
|
|
223
189
|
setActivePreset(null);
|
|
224
190
|
}
|
|
225
191
|
};
|
|
226
|
-
const throttledSetHoverDate = useCallback((
|
|
192
|
+
const throttledSetHoverDate = useCallback((date) => {
|
|
227
193
|
requestAnimationFrame(() => {
|
|
228
|
-
setHoverDate(
|
|
194
|
+
setHoverDate(date);
|
|
229
195
|
});
|
|
230
196
|
}, []);
|
|
231
|
-
const handleDateHover = useCallback((
|
|
232
|
-
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(
|
|
197
|
+
const handleDateHover = useCallback((date) => {
|
|
198
|
+
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(date);
|
|
233
199
|
}, [
|
|
234
200
|
rangeSelection.isSelecting,
|
|
235
201
|
rangeSelection.start,
|
|
236
202
|
throttledSetHoverDate
|
|
237
203
|
]);
|
|
238
|
-
const handleDateSelection = useCallback((
|
|
204
|
+
const handleDateSelection = useCallback((date, calendarSide) => {
|
|
239
205
|
if (calendarSide) {
|
|
240
206
|
const currentVisibleMonth = (calendarSide === "left" ? leftCalendarState : rightCalendarState).visibleRange.start;
|
|
241
|
-
if (
|
|
242
|
-
leftCalendarState.setFocusedDate(
|
|
243
|
-
rightCalendarState.setFocusedDate(
|
|
207
|
+
if (date.month !== currentVisibleMonth.month || date.year !== currentVisibleMonth.year) if (calendarSide === "left") {
|
|
208
|
+
leftCalendarState.setFocusedDate(date);
|
|
209
|
+
rightCalendarState.setFocusedDate(date.add({ months: 1 }));
|
|
244
210
|
} else {
|
|
245
|
-
rightCalendarState.setFocusedDate(
|
|
246
|
-
leftCalendarState.setFocusedDate(
|
|
211
|
+
rightCalendarState.setFocusedDate(date);
|
|
212
|
+
leftCalendarState.setFocusedDate(date.subtract({ months: 1 }));
|
|
247
213
|
}
|
|
248
214
|
}
|
|
249
|
-
if (isDateOutsideBounds(
|
|
215
|
+
if (isDateOutsideBounds(date)) return;
|
|
250
216
|
if (!rangeSelection.isSelecting || !rangeSelection.start) {
|
|
251
217
|
setRangeSelection({
|
|
252
|
-
start:
|
|
218
|
+
start: date,
|
|
253
219
|
end: null,
|
|
254
220
|
isSelecting: true
|
|
255
221
|
});
|
|
@@ -258,7 +224,7 @@ var DateRangePickerBase = (props) => {
|
|
|
258
224
|
rightCalendarState.setValue(null);
|
|
259
225
|
} else {
|
|
260
226
|
const { start } = rangeSelection;
|
|
261
|
-
const end =
|
|
227
|
+
const end = date;
|
|
262
228
|
const clampedRange = clampRangeToBounds({
|
|
263
229
|
start: start.compare(end) <= 0 ? start : end,
|
|
264
230
|
end: start.compare(end) <= 0 ? end : start
|
|
@@ -283,16 +249,16 @@ var DateRangePickerBase = (props) => {
|
|
|
283
249
|
isDateOutsideBounds,
|
|
284
250
|
clampRangeToBounds
|
|
285
251
|
]);
|
|
286
|
-
const handleKeyboardNavigation = useCallback((event,
|
|
287
|
-
const
|
|
288
|
-
const otherState =
|
|
252
|
+
const handleKeyboardNavigation = useCallback((event, date, calendarSide) => {
|
|
253
|
+
const currentState = calendarSide === "left" ? leftCalendarState : rightCalendarState;
|
|
254
|
+
const otherState = calendarSide === "left" ? rightCalendarState : leftCalendarState;
|
|
289
255
|
let shouldPreventDefault = false;
|
|
290
256
|
switch (event.key) {
|
|
291
257
|
case "ArrowRight": {
|
|
292
|
-
const nextDate =
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
258
|
+
const nextDate = date.add({ days: 1 });
|
|
259
|
+
const currentMonth = currentState.visibleRange.start;
|
|
260
|
+
const otherMonth = otherState.visibleRange.start;
|
|
261
|
+
if (calendarSide === "left" && nextDate.month !== currentMonth.month) if (nextDate.year === otherMonth.year && nextDate.month === otherMonth.month) {
|
|
296
262
|
otherState.setFocusedDate(nextDate);
|
|
297
263
|
shouldPreventDefault = true;
|
|
298
264
|
} else {
|
|
@@ -302,10 +268,10 @@ var DateRangePickerBase = (props) => {
|
|
|
302
268
|
break;
|
|
303
269
|
}
|
|
304
270
|
case "ArrowLeft": {
|
|
305
|
-
const prevDate =
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
271
|
+
const prevDate = date.subtract({ days: 1 });
|
|
272
|
+
const currentMonth = currentState.visibleRange.start;
|
|
273
|
+
const otherMonth = otherState.visibleRange.start;
|
|
274
|
+
if (calendarSide === "right" && prevDate.month !== currentMonth.month) if (prevDate.year === otherMonth.year && prevDate.month === otherMonth.month) {
|
|
309
275
|
otherState.setFocusedDate(prevDate);
|
|
310
276
|
shouldPreventDefault = true;
|
|
311
277
|
} else {
|
|
@@ -315,10 +281,10 @@ var DateRangePickerBase = (props) => {
|
|
|
315
281
|
break;
|
|
316
282
|
}
|
|
317
283
|
case "ArrowDown": {
|
|
318
|
-
const nextWeekDate =
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
284
|
+
const nextWeekDate = date.add({ weeks: 1 });
|
|
285
|
+
const currentMonth = currentState.visibleRange.start;
|
|
286
|
+
const otherMonth = otherState.visibleRange.start;
|
|
287
|
+
if (calendarSide === "left" && nextWeekDate.month !== currentMonth.month) if (nextWeekDate.year === otherMonth.year && nextWeekDate.month === otherMonth.month) {
|
|
322
288
|
otherState.setFocusedDate(nextWeekDate);
|
|
323
289
|
shouldPreventDefault = true;
|
|
324
290
|
} else {
|
|
@@ -328,10 +294,10 @@ var DateRangePickerBase = (props) => {
|
|
|
328
294
|
break;
|
|
329
295
|
}
|
|
330
296
|
case "ArrowUp": {
|
|
331
|
-
const prevWeekDate =
|
|
332
|
-
const currentMonth =
|
|
297
|
+
const prevWeekDate = date.subtract({ weeks: 1 });
|
|
298
|
+
const currentMonth = currentState.visibleRange.start;
|
|
333
299
|
const otherMonth = otherState.visibleRange.start;
|
|
334
|
-
if (
|
|
300
|
+
if (calendarSide === "right" && prevWeekDate.month !== currentMonth.month) if (prevWeekDate.year === otherMonth.year && prevWeekDate.month === otherMonth.month) {
|
|
335
301
|
otherState.setFocusedDate(prevWeekDate);
|
|
336
302
|
shouldPreventDefault = true;
|
|
337
303
|
} else {
|
|
@@ -342,7 +308,7 @@ var DateRangePickerBase = (props) => {
|
|
|
342
308
|
}
|
|
343
309
|
case "Enter":
|
|
344
310
|
case " ":
|
|
345
|
-
handleDateSelection(
|
|
311
|
+
handleDateSelection(date);
|
|
346
312
|
shouldPreventDefault = true;
|
|
347
313
|
break;
|
|
348
314
|
case "Escape":
|
|
@@ -366,8 +332,8 @@ var DateRangePickerBase = (props) => {
|
|
|
366
332
|
rightCalendarState,
|
|
367
333
|
handleDateSelection
|
|
368
334
|
]);
|
|
369
|
-
const syncCalendarStates = useCallback((
|
|
370
|
-
if (
|
|
335
|
+
const syncCalendarStates = useCallback((newValue) => {
|
|
336
|
+
if (newValue === null) {
|
|
371
337
|
setValidationRangeError(void 0);
|
|
372
338
|
leftCalendarState.setValue(null);
|
|
373
339
|
rightCalendarState.setValue(null);
|
|
@@ -380,15 +346,15 @@ var DateRangePickerBase = (props) => {
|
|
|
380
346
|
setHoverDate(null);
|
|
381
347
|
return;
|
|
382
348
|
}
|
|
383
|
-
const
|
|
384
|
-
if (!
|
|
385
|
-
if (isValidRange(
|
|
386
|
-
leftCalendarState.setValue(
|
|
387
|
-
rightCalendarState.setValue(
|
|
388
|
-
dialogState.setValue(
|
|
349
|
+
const clampedValue = clampRangeToBounds(newValue);
|
|
350
|
+
if (!clampedValue) return;
|
|
351
|
+
if (isValidRange(clampedValue)) return;
|
|
352
|
+
leftCalendarState.setValue(clampedValue);
|
|
353
|
+
rightCalendarState.setValue(clampedValue);
|
|
354
|
+
dialogState.setValue(clampedValue);
|
|
389
355
|
setRangeSelection({
|
|
390
|
-
start:
|
|
391
|
-
end:
|
|
356
|
+
start: clampedValue.start,
|
|
357
|
+
end: clampedValue.end,
|
|
392
358
|
isSelecting: false
|
|
393
359
|
});
|
|
394
360
|
setHoverDate(null);
|
|
@@ -405,43 +371,24 @@ var DateRangePickerBase = (props) => {
|
|
|
405
371
|
start: rangeSelection.start,
|
|
406
372
|
end: rangeSelection.end
|
|
407
373
|
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (clampedValue_1) {
|
|
411
|
-
valueToApply = clampedValue_1;
|
|
412
|
-
state.setValue(clampedValue_1);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
374
|
+
const clampedValue = clampRangeToBounds(valueToApply);
|
|
375
|
+
if (clampedValue) state.setValue(clampedValue);
|
|
415
376
|
state.toggle();
|
|
416
|
-
if (fireBlurOnChange) handleBlur(valueToApply);
|
|
417
377
|
};
|
|
418
378
|
const onTodayPress = () => {
|
|
419
|
-
const todayDate = today(
|
|
379
|
+
const todayDate = today(getLocalTimeZone());
|
|
420
380
|
const clampedTodayRange = clampRangeToBounds({
|
|
421
381
|
start: todayDate,
|
|
422
382
|
end: todayDate
|
|
423
383
|
});
|
|
424
384
|
if (!clampedTodayRange) return;
|
|
425
|
-
const
|
|
426
|
-
const
|
|
427
|
-
leftCalendarState.setFocusedDate(
|
|
428
|
-
if (
|
|
429
|
-
else rightCalendarState.setFocusedDate(
|
|
385
|
+
const startDate = clampedTodayRange.start;
|
|
386
|
+
const endDate = clampedTodayRange.end;
|
|
387
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
388
|
+
if (startDate.year === endDate.year && startDate.month === endDate.month) rightCalendarState.setFocusedDate(startDate.add({ months: 1 }));
|
|
389
|
+
else rightCalendarState.setFocusedDate(endDate);
|
|
430
390
|
syncCalendarStates(clampedTodayRange);
|
|
431
391
|
};
|
|
432
|
-
const onInputClear = () => {
|
|
433
|
-
onChange?.(null);
|
|
434
|
-
dialogState.setValue(null);
|
|
435
|
-
leftCalendarState.setValue(null);
|
|
436
|
-
rightCalendarState.setValue(null);
|
|
437
|
-
setRangeSelection({
|
|
438
|
-
start: null,
|
|
439
|
-
end: null,
|
|
440
|
-
isSelecting: false
|
|
441
|
-
});
|
|
442
|
-
setHoverDate(null);
|
|
443
|
-
if (fireBlurOnChange) handleBlur(null);
|
|
444
|
-
};
|
|
445
392
|
const onOpenChange = (isOpen) => {
|
|
446
393
|
state.toggle();
|
|
447
394
|
if (!isOpen) {
|
|
@@ -449,11 +396,11 @@ var DateRangePickerBase = (props) => {
|
|
|
449
396
|
dialogState.setValue(state.value);
|
|
450
397
|
leftCalendarState.setValue(state.value);
|
|
451
398
|
rightCalendarState.setValue(state.value);
|
|
452
|
-
const
|
|
453
|
-
const
|
|
454
|
-
leftCalendarState.setFocusedDate(
|
|
455
|
-
if (
|
|
456
|
-
else rightCalendarState.setFocusedDate(
|
|
399
|
+
const startDate = state.value.start || today(getLocalTimeZone());
|
|
400
|
+
const endDate = state.value.end || today(getLocalTimeZone()).add({ months: 1 });
|
|
401
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
402
|
+
if (startDate.year === endDate.year && startDate.month === endDate.month) rightCalendarState.setFocusedDate(startDate.add({ months: 1 }));
|
|
403
|
+
else rightCalendarState.setFocusedDate(endDate);
|
|
457
404
|
setRangeSelection({
|
|
458
405
|
start: state.value.start,
|
|
459
406
|
end: state.value.end,
|
|
@@ -462,110 +409,110 @@ var DateRangePickerBase = (props) => {
|
|
|
462
409
|
}
|
|
463
410
|
}
|
|
464
411
|
};
|
|
465
|
-
const
|
|
412
|
+
const todayDate = today(getLocalTimeZone());
|
|
466
413
|
const getThisWeekRange = () => {
|
|
467
414
|
return {
|
|
468
|
-
start: startOfWeek(
|
|
469
|
-
end: endOfWeek(
|
|
415
|
+
start: startOfWeek(todayDate, locale),
|
|
416
|
+
end: endOfWeek(todayDate, locale)
|
|
470
417
|
};
|
|
471
418
|
};
|
|
472
419
|
const getLastWeekRange = () => {
|
|
473
|
-
const thisWeekStart = startOfWeek(
|
|
420
|
+
const thisWeekStart = startOfWeek(todayDate, locale);
|
|
474
421
|
return {
|
|
475
422
|
start: thisWeekStart.subtract({ weeks: 1 }),
|
|
476
423
|
end: thisWeekStart.subtract({ days: 1 })
|
|
477
424
|
};
|
|
478
425
|
};
|
|
479
426
|
const getThisAndLastWeekRange = () => {
|
|
480
|
-
const thisWeekEnd = endOfWeek(
|
|
427
|
+
const thisWeekEnd = endOfWeek(todayDate, locale);
|
|
481
428
|
return {
|
|
482
|
-
start: startOfWeek(
|
|
429
|
+
start: startOfWeek(todayDate, locale).subtract({ weeks: 1 }),
|
|
483
430
|
end: thisWeekEnd
|
|
484
431
|
};
|
|
485
432
|
};
|
|
486
433
|
const getThisMonthRange = () => {
|
|
487
434
|
return {
|
|
488
|
-
start: startOfMonth(
|
|
489
|
-
end: endOfMonth(
|
|
435
|
+
start: startOfMonth(todayDate),
|
|
436
|
+
end: endOfMonth(todayDate)
|
|
490
437
|
};
|
|
491
438
|
};
|
|
492
439
|
const getThisAndLastMonthRange = () => {
|
|
493
|
-
const thisMonthEnd = endOfMonth(
|
|
440
|
+
const thisMonthEnd = endOfMonth(todayDate);
|
|
494
441
|
return {
|
|
495
|
-
start: startOfMonth(
|
|
442
|
+
start: startOfMonth(todayDate).subtract({ months: 1 }),
|
|
496
443
|
end: thisMonthEnd
|
|
497
444
|
};
|
|
498
445
|
};
|
|
499
446
|
const createPreset = (params) => {
|
|
500
|
-
let
|
|
501
|
-
let
|
|
447
|
+
let clampedValue = clampRangeToBounds(params.getValue());
|
|
448
|
+
let isDisabled = false;
|
|
502
449
|
if (params.keepEnabledUnlessFutureMin) {
|
|
503
450
|
let minDateIsInFuture = false;
|
|
504
|
-
if (minValue && minValue.compare(
|
|
451
|
+
if (minValue && minValue.compare(todayDate) > 0) minDateIsInFuture = true;
|
|
505
452
|
if (minDateIsInFuture) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
} else if (!
|
|
453
|
+
isDisabled = true;
|
|
454
|
+
clampedValue = null;
|
|
455
|
+
} else if (!clampedValue && maxValue) clampedValue = {
|
|
509
456
|
start: maxValue,
|
|
510
457
|
end: maxValue
|
|
511
458
|
};
|
|
512
459
|
}
|
|
513
|
-
if (!
|
|
514
|
-
if (
|
|
460
|
+
if (!clampedValue) isDisabled = true;
|
|
461
|
+
if (clampedValue && !isRangeWithinBounds(clampedValue)) isDisabled = true;
|
|
515
462
|
return {
|
|
516
463
|
label: params.label,
|
|
517
464
|
getValue: params.getValue,
|
|
518
|
-
clampedValue
|
|
519
|
-
isDisabled
|
|
465
|
+
clampedValue,
|
|
466
|
+
isDisabled
|
|
520
467
|
};
|
|
521
468
|
};
|
|
522
469
|
const presets = [
|
|
523
470
|
createPreset({
|
|
524
|
-
label: t(($
|
|
471
|
+
label: t(($) => $.ui.datePicker.presets.thisWeek, { ns: "ui" }),
|
|
525
472
|
getValue: getThisWeekRange
|
|
526
473
|
}),
|
|
527
474
|
createPreset({
|
|
528
|
-
label: t(($
|
|
475
|
+
label: t(($) => $.ui.datePicker.presets.lastWeek, { ns: "ui" }),
|
|
529
476
|
getValue: getLastWeekRange
|
|
530
477
|
}),
|
|
531
478
|
createPreset({
|
|
532
|
-
label: t(($
|
|
479
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastWeek, { ns: "ui" }),
|
|
533
480
|
getValue: getThisAndLastWeekRange
|
|
534
481
|
}),
|
|
535
482
|
createPreset({
|
|
536
|
-
label: t(($
|
|
483
|
+
label: t(($) => $.ui.datePicker.presets.thisMonth, { ns: "ui" }),
|
|
537
484
|
getValue: getThisMonthRange
|
|
538
485
|
}),
|
|
539
486
|
createPreset({
|
|
540
|
-
label: t(($
|
|
487
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastMonth, { ns: "ui" }),
|
|
541
488
|
getValue: getThisAndLastMonthRange
|
|
542
489
|
}),
|
|
543
490
|
createPreset({
|
|
544
|
-
label: t(($
|
|
491
|
+
label: t(($) => $.ui.datePicker.presets.thisYear, { ns: "ui" }),
|
|
545
492
|
getValue: () => ({
|
|
546
|
-
start: startOfYear(
|
|
547
|
-
end:
|
|
493
|
+
start: startOfYear(todayDate),
|
|
494
|
+
end: todayDate
|
|
548
495
|
})
|
|
549
496
|
}),
|
|
550
497
|
createPreset({
|
|
551
|
-
label: t(($
|
|
498
|
+
label: t(($) => $.ui.datePicker.presets.lastYear, { ns: "ui" }),
|
|
552
499
|
getValue: () => ({
|
|
553
|
-
start: startOfYear(
|
|
554
|
-
end: endOfYear(
|
|
500
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
501
|
+
end: endOfYear(todayDate.subtract({ years: 1 }))
|
|
555
502
|
})
|
|
556
503
|
}),
|
|
557
504
|
createPreset({
|
|
558
|
-
label: t(($
|
|
505
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastYear, { ns: "ui" }),
|
|
559
506
|
getValue: () => ({
|
|
560
|
-
start: startOfYear(
|
|
561
|
-
end:
|
|
507
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
508
|
+
end: todayDate
|
|
562
509
|
})
|
|
563
510
|
}),
|
|
564
511
|
createPreset({
|
|
565
|
-
label: t(($
|
|
512
|
+
label: t(($) => $.ui.datePicker.presets.soFar, { ns: "ui" }),
|
|
566
513
|
getValue: () => ({
|
|
567
|
-
start: startOfYear(
|
|
568
|
-
end:
|
|
514
|
+
start: startOfYear(todayDate),
|
|
515
|
+
end: todayDate
|
|
569
516
|
}),
|
|
570
517
|
keepEnabledUnlessFutureMin: true
|
|
571
518
|
})
|
|
@@ -575,12 +522,12 @@ var DateRangePickerBase = (props) => {
|
|
|
575
522
|
setActivePreset(preset.label);
|
|
576
523
|
const presetValue = preset.clampedValue;
|
|
577
524
|
syncCalendarStates(presetValue);
|
|
578
|
-
const
|
|
579
|
-
leftCalendarState.setFocusedDate(
|
|
580
|
-
const
|
|
581
|
-
if ((
|
|
525
|
+
const startDate = presetValue.start;
|
|
526
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
527
|
+
const endDate = presetValue.end;
|
|
528
|
+
if ((endDate.year - startDate.year) * 12 + (endDate.month - startDate.month) > 2) rightCalendarState.setFocusedDate(endDate);
|
|
582
529
|
else {
|
|
583
|
-
const rightCalendarMonth =
|
|
530
|
+
const rightCalendarMonth = startDate.add({ months: 1 });
|
|
584
531
|
rightCalendarState.setFocusedDate(rightCalendarMonth);
|
|
585
532
|
}
|
|
586
533
|
};
|
|
@@ -598,24 +545,8 @@ var DateRangePickerBase = (props) => {
|
|
|
598
545
|
ref: mergeRefs(ref, datePickerInputRef),
|
|
599
546
|
as,
|
|
600
547
|
groupProps,
|
|
601
|
-
fieldProps:
|
|
602
|
-
|
|
603
|
-
onBlur: (event_0) => {
|
|
604
|
-
startFieldProps.onBlur?.(event_0);
|
|
605
|
-
handleBlur(state.value);
|
|
606
|
-
}
|
|
607
|
-
},
|
|
608
|
-
endFieldProps: {
|
|
609
|
-
...endFieldProps,
|
|
610
|
-
onBlur: (event_1) => {
|
|
611
|
-
endFieldProps.onBlur?.(event_1);
|
|
612
|
-
handleBlur(state.value);
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
fieldValue: normalizedValue?.start ?? null,
|
|
616
|
-
endFieldValue: normalizedValue?.end ?? null,
|
|
617
|
-
isValueControlled: true,
|
|
618
|
-
hasValue: normalizedValue?.start != null || normalizedValue?.end != null,
|
|
548
|
+
fieldProps: startFieldProps,
|
|
549
|
+
endFieldProps,
|
|
619
550
|
buttonProps,
|
|
620
551
|
isDisabled,
|
|
621
552
|
isInvalid: !!error,
|
|
@@ -625,34 +556,28 @@ var DateRangePickerBase = (props) => {
|
|
|
625
556
|
isClearable,
|
|
626
557
|
headerProps,
|
|
627
558
|
todayIcon,
|
|
628
|
-
todayIconButtonSize,
|
|
629
|
-
todayIconButtonComponent,
|
|
630
|
-
todayIconPlacement,
|
|
631
559
|
isDirty,
|
|
632
560
|
disableManualEntry,
|
|
633
|
-
autoFixYear,
|
|
634
561
|
placeholder,
|
|
635
562
|
className: inputClassName,
|
|
636
563
|
onOpenDropdown: () => state.toggle(),
|
|
637
|
-
|
|
638
|
-
fireBlurOnChange,
|
|
639
|
-
onClear: onInputClear
|
|
564
|
+
autoFixYear
|
|
640
565
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
641
566
|
hideSidebar,
|
|
642
567
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
643
568
|
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",
|
|
644
|
-
children: presets.map((
|
|
645
|
-
isDisabled:
|
|
646
|
-
onClick: () => selectPreset(
|
|
647
|
-
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item disabled:text-interactive-text-secondary-disabled!", activePreset !==
|
|
569
|
+
children: presets.map((preset) => /* @__PURE__ */ jsx(Button, {
|
|
570
|
+
isDisabled: preset.isDisabled,
|
|
571
|
+
onClick: () => selectPreset(preset),
|
|
572
|
+
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item disabled:text-interactive-text-secondary-disabled!", activePreset !== preset.label && "text-interactive-text-secondary-idle hover:text-interactive-text-secondary-hover", activePreset === preset.label && "bg-interactive-contained-primary-idle text-interactive-text-secondary-idle-inverted"),
|
|
648
573
|
children: /* @__PURE__ */ jsx(Typography, {
|
|
649
574
|
size: "label-2",
|
|
650
575
|
sizeMobile: "label-3",
|
|
651
576
|
as: "span",
|
|
652
577
|
className: "whitespace-nowrap",
|
|
653
|
-
children:
|
|
578
|
+
children: preset.label
|
|
654
579
|
})
|
|
655
|
-
},
|
|
580
|
+
}, preset.label))
|
|
656
581
|
}),
|
|
657
582
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
658
583
|
isDisabled,
|
|
@@ -687,300 +612,69 @@ var DateRangePickerBase = (props) => {
|
|
|
687
612
|
})
|
|
688
613
|
});
|
|
689
614
|
};
|
|
690
|
-
var
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const { locale } = useLocale$1();
|
|
697
|
-
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
698
|
-
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
699
|
-
const inputRef = useRef(null);
|
|
700
|
-
const { renderRealInput } = useStaticInputHandoff({
|
|
701
|
-
inputRef,
|
|
702
|
-
renderInput,
|
|
703
|
-
setRenderInput,
|
|
704
|
-
getFocusTarget: _temp
|
|
705
|
-
});
|
|
706
|
-
const normalizedValue = props.value ?? null;
|
|
707
|
-
let t2;
|
|
708
|
-
if ($[0] !== fullIso) {
|
|
709
|
-
t2 = (range) => {
|
|
710
|
-
if (!range?.start || !range?.end) return null;
|
|
711
|
-
if (fullIso) return {
|
|
712
|
-
start: DateTimeUtils.fromCalendarDateToUTCISO(range.start),
|
|
713
|
-
end: DateTimeUtils.fromCalendarDateToUTCISO(range.end, { endOfDay: true })
|
|
714
|
-
};
|
|
715
|
-
const startDate = DateTimeUtils.fromDateValueToLocal(range.start, "UTC");
|
|
716
|
-
const endDate = DateTimeUtils.fromDateValueToLocal(range.end, "UTC");
|
|
717
|
-
return {
|
|
718
|
-
start: DateTime.fromJSDate(startDate, { zone: "UTC" }).toISODate(),
|
|
719
|
-
end: DateTime.fromJSDate(endDate, { zone: "UTC" }).toISODate()
|
|
720
|
-
};
|
|
615
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
616
|
+
const formatDateRange = (range) => {
|
|
617
|
+
if (!range?.start || !range?.end) return null;
|
|
618
|
+
if (fullIso) return {
|
|
619
|
+
start: DateTimeUtils.fromCalendarDateToUTCISO(range.start),
|
|
620
|
+
end: DateTimeUtils.fromCalendarDateToUTCISO(range.end, { endOfDay: true })
|
|
721
621
|
};
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
if ($[2] !== fullIso) {
|
|
728
|
-
t3 = (formattedRange) => {
|
|
729
|
-
if (!formattedRange?.start || !formattedRange?.end) return null;
|
|
730
|
-
if (fullIso) return {
|
|
731
|
-
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
732
|
-
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
733
|
-
};
|
|
734
|
-
const startDate_0 = DateTime.fromISO(formattedRange.start, { zone: "UTC" }).toJSDate();
|
|
735
|
-
const endDate_0 = DateTime.fromISO(formattedRange.end, { zone: "UTC" }).toJSDate();
|
|
736
|
-
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate_0, "UTC");
|
|
737
|
-
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate_0, "UTC");
|
|
738
|
-
return {
|
|
739
|
-
start: toCalendarDate(startZonedDateTime),
|
|
740
|
-
end: toCalendarDate(endZonedDateTime)
|
|
741
|
-
};
|
|
622
|
+
const startDate = DateTimeUtils.fromDateValueToLocal(range.start);
|
|
623
|
+
const endDate = DateTimeUtils.fromDateValueToLocal(range.end);
|
|
624
|
+
return {
|
|
625
|
+
start: DateTime.fromJSDate(startDate).toISODate(),
|
|
626
|
+
end: DateTime.fromJSDate(endDate).toISODate()
|
|
742
627
|
};
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
t4 = (formattedDate) => {
|
|
750
|
-
if (formattedDate == null) return null;
|
|
751
|
-
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
752
|
-
const date = DateTime.fromISO(formattedDate, { zone: "UTC" }).toJSDate();
|
|
753
|
-
return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date, "UTC"));
|
|
628
|
+
};
|
|
629
|
+
const parseDateRange = (formattedRange) => {
|
|
630
|
+
if (!formattedRange?.start || !formattedRange?.end) return formattedRange;
|
|
631
|
+
if (fullIso) return {
|
|
632
|
+
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
633
|
+
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
754
634
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
$[6] = minValue;
|
|
763
|
-
$[7] = parseCalendarDate;
|
|
764
|
-
$[8] = t5;
|
|
765
|
-
} else t5 = $[8];
|
|
766
|
-
let t6;
|
|
767
|
-
if ($[9] !== maxValue || $[10] !== parseCalendarDate) {
|
|
768
|
-
t6 = typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue;
|
|
769
|
-
$[9] = maxValue;
|
|
770
|
-
$[10] = parseCalendarDate;
|
|
771
|
-
$[11] = t6;
|
|
772
|
-
} else t6 = $[11];
|
|
773
|
-
let t7;
|
|
774
|
-
if ($[12] !== t5 || $[13] !== t6) {
|
|
775
|
-
t7 = {
|
|
776
|
-
minValue: t5,
|
|
777
|
-
maxValue: t6
|
|
635
|
+
const startDate = DateTime.fromISO(formattedRange.start).toJSDate();
|
|
636
|
+
const endDate = DateTime.fromISO(formattedRange.end).toJSDate();
|
|
637
|
+
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate);
|
|
638
|
+
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate);
|
|
639
|
+
return {
|
|
640
|
+
start: toCalendarDate(startZonedDateTime),
|
|
641
|
+
end: toCalendarDate(endZonedDateTime)
|
|
778
642
|
};
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
791
|
-
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
792
|
-
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
793
|
-
const todayIconButtonComponent = props.todayIconButtonComponent ?? ui.dateInput.todayIconButtonComponent;
|
|
794
|
-
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
795
|
-
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, {
|
|
796
|
-
isDisabled,
|
|
797
|
-
renderStatic: true,
|
|
798
|
-
size: todayIconButtonSize,
|
|
799
|
-
todayIconButtonComponent
|
|
800
|
-
});
|
|
801
|
-
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
802
|
-
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
803
|
-
const staticSegments = getStaticDateRangeSegments({
|
|
804
|
-
start: startDateValue,
|
|
805
|
-
end: endDateValue,
|
|
806
|
-
locale,
|
|
807
|
-
shouldForceLeadingZeros,
|
|
808
|
-
isDisabled,
|
|
809
|
-
hidePlaceholder: as === "floating" && !hasProvidedRangeValue,
|
|
810
|
-
disableManualEntry,
|
|
811
|
-
placeholder: props.placeholder
|
|
812
|
-
});
|
|
813
|
-
return /* @__PURE__ */ jsx(InputFrame, {
|
|
814
|
-
...props,
|
|
815
|
-
isDisabled,
|
|
816
|
-
className: clsx("group relative inline-flex w-full flex-col text-left", props.className),
|
|
817
|
-
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
818
|
-
contentClassName: "pr-0!",
|
|
819
|
-
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
820
|
-
contentGroup: "date-picker",
|
|
821
|
-
labelPlacement: "content-row",
|
|
822
|
-
dataAttributes: {
|
|
823
|
-
dataIsEmpty: !hasProvidedRangeValue,
|
|
824
|
-
dataIsFilled: hasProvidedRangeValue,
|
|
825
|
-
dataIsDirty: props.isDirty,
|
|
826
|
-
dataIsRequired: props.isRequired,
|
|
827
|
-
dataIsDisabled: isDisabled,
|
|
828
|
-
dataDisabled: isDisabled,
|
|
829
|
-
dataInvalid: !!props.error,
|
|
830
|
-
dataHasSelection: hasProvidedRangeValue
|
|
831
|
-
},
|
|
832
|
-
renderStatic: true,
|
|
833
|
-
onStaticInteract: renderRealInput,
|
|
834
|
-
actionContent: staticTodayIcon,
|
|
835
|
-
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
836
|
-
showClear: hasProvidedRangeValue,
|
|
837
|
-
wrapContentAndTrailing: true,
|
|
838
|
-
contentAndTrailingClassName: "gap-2!",
|
|
839
|
-
trailingClassName: "py-0! pl-0!",
|
|
840
|
-
action: showDropdown ? {
|
|
841
|
-
icon: ui.dateInput.calendarIcon,
|
|
842
|
-
onClick: _temp2,
|
|
843
|
-
altText: ""
|
|
844
|
-
} : void 0,
|
|
845
|
-
children: staticSegments
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
const T0 = DateRangePickerBase;
|
|
849
|
-
const t8 = mergeRefs(props.ref, inputRef);
|
|
850
|
-
const t9 = parseDateRange(normalizedValue);
|
|
851
|
-
let t10;
|
|
852
|
-
if ($[15] !== formatDateRange || $[16] !== props) {
|
|
853
|
-
t10 = (value) => props.onChange?.(formatDateRange(value));
|
|
854
|
-
$[15] = formatDateRange;
|
|
855
|
-
$[16] = props;
|
|
856
|
-
$[17] = t10;
|
|
857
|
-
} else t10 = $[17];
|
|
858
|
-
let t11;
|
|
859
|
-
if ($[18] !== T0 || $[19] !== dateLimits || $[20] !== props || $[21] !== t10 || $[22] !== t8 || $[23] !== t9) {
|
|
860
|
-
t11 = /* @__PURE__ */ jsx(T0, {
|
|
861
|
-
...props,
|
|
862
|
-
...dateLimits,
|
|
863
|
-
ref: t8,
|
|
864
|
-
value: t9,
|
|
865
|
-
onChange: t10
|
|
866
|
-
});
|
|
867
|
-
$[18] = T0;
|
|
868
|
-
$[19] = dateLimits;
|
|
869
|
-
$[20] = props;
|
|
870
|
-
$[21] = t10;
|
|
871
|
-
$[22] = t8;
|
|
872
|
-
$[23] = t9;
|
|
873
|
-
$[24] = t11;
|
|
874
|
-
} else t11 = $[24];
|
|
875
|
-
return t11;
|
|
876
|
-
};
|
|
877
|
-
var DateRangePicker = (t0) => {
|
|
878
|
-
const $ = c(30);
|
|
879
|
-
let maxValue;
|
|
880
|
-
let minValue;
|
|
881
|
-
let props;
|
|
882
|
-
let renderStaticInput;
|
|
883
|
-
let t1;
|
|
884
|
-
if ($[0] !== t0) {
|
|
885
|
-
({fullIso: t1, minValue, maxValue, renderStaticInput, ...props} = t0);
|
|
886
|
-
$[0] = t0;
|
|
887
|
-
$[1] = maxValue;
|
|
888
|
-
$[2] = minValue;
|
|
889
|
-
$[3] = props;
|
|
890
|
-
$[4] = renderStaticInput;
|
|
891
|
-
$[5] = t1;
|
|
892
|
-
} else {
|
|
893
|
-
maxValue = $[1];
|
|
894
|
-
minValue = $[2];
|
|
895
|
-
props = $[3];
|
|
896
|
-
renderStaticInput = $[4];
|
|
897
|
-
t1 = $[5];
|
|
898
|
-
}
|
|
899
|
-
const fullIso = t1 === void 0 ? true : t1;
|
|
643
|
+
};
|
|
644
|
+
const parseCalendarDate = (formattedDate) => {
|
|
645
|
+
if (formattedDate == null) return formattedDate;
|
|
646
|
+
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
647
|
+
const date = DateTime.fromISO(formattedDate).toJSDate();
|
|
648
|
+
return toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date));
|
|
649
|
+
};
|
|
650
|
+
const dateLimits = {
|
|
651
|
+
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
652
|
+
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
653
|
+
};
|
|
900
654
|
if ("formControl" in props && props.formControl) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
({
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
let t2;
|
|
917
|
-
if ($[10] !== controlWithOptions._options?.disabled || $[11] !== fullIso || $[12] !== innerProps || $[13] !== maxValue || $[14] !== minValue || $[15] !== props.error || $[16] !== props.isDisabled || $[17] !== ref || $[18] !== renderStaticInput) {
|
|
918
|
-
t2 = (t3) => {
|
|
919
|
-
const { field, fieldState: t4 } = t3;
|
|
920
|
-
const { error, isDirty } = t4;
|
|
921
|
-
return /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
922
|
-
...innerProps,
|
|
923
|
-
ref: mergeRefs(ref, field.ref),
|
|
924
|
-
value: field.value ?? null,
|
|
925
|
-
onChange: field.onChange,
|
|
926
|
-
onBlur: field.onBlur,
|
|
927
|
-
isDirty,
|
|
928
|
-
isDisabled: field.disabled || props.isDisabled,
|
|
929
|
-
isFormControlDisabled: !!controlWithOptions._options?.disabled,
|
|
930
|
-
error: props.error ?? error?.message,
|
|
931
|
-
fullIso,
|
|
932
|
-
minValue,
|
|
933
|
-
maxValue,
|
|
934
|
-
renderStaticInput
|
|
935
|
-
});
|
|
936
|
-
};
|
|
937
|
-
$[10] = controlWithOptions._options?.disabled;
|
|
938
|
-
$[11] = fullIso;
|
|
939
|
-
$[12] = innerProps;
|
|
940
|
-
$[13] = maxValue;
|
|
941
|
-
$[14] = minValue;
|
|
942
|
-
$[15] = props.error;
|
|
943
|
-
$[16] = props.isDisabled;
|
|
944
|
-
$[17] = ref;
|
|
945
|
-
$[18] = renderStaticInput;
|
|
946
|
-
$[19] = t2;
|
|
947
|
-
} else t2 = $[19];
|
|
948
|
-
let t3;
|
|
949
|
-
if ($[20] !== formControl.control || $[21] !== formControl.name || $[22] !== t2) {
|
|
950
|
-
t3 = /* @__PURE__ */ jsx(Controller, {
|
|
951
|
-
control: formControl.control,
|
|
952
|
-
name: formControl.name,
|
|
953
|
-
render: t2
|
|
954
|
-
});
|
|
955
|
-
$[20] = formControl.control;
|
|
956
|
-
$[21] = formControl.name;
|
|
957
|
-
$[22] = t2;
|
|
958
|
-
$[23] = t3;
|
|
959
|
-
} else t3 = $[23];
|
|
960
|
-
return t3;
|
|
961
|
-
}
|
|
962
|
-
let t2;
|
|
963
|
-
if ($[24] !== fullIso || $[25] !== maxValue || $[26] !== minValue || $[27] !== props || $[28] !== renderStaticInput) {
|
|
964
|
-
t2 = /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
965
|
-
...props,
|
|
966
|
-
fullIso,
|
|
967
|
-
minValue,
|
|
968
|
-
maxValue,
|
|
969
|
-
renderStaticInput
|
|
655
|
+
const { formControl, ref, ...innerProps } = props;
|
|
656
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
657
|
+
control: formControl.control,
|
|
658
|
+
name: formControl.name,
|
|
659
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
660
|
+
...innerProps,
|
|
661
|
+
...dateLimits,
|
|
662
|
+
ref: mergeRefs(ref, field.ref),
|
|
663
|
+
value: parseDateRange(field.value),
|
|
664
|
+
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
665
|
+
onBlur: field.onBlur,
|
|
666
|
+
isDirty,
|
|
667
|
+
isDisabled: field.disabled || props.isDisabled,
|
|
668
|
+
error: props.error ?? error?.message
|
|
669
|
+
})
|
|
970
670
|
});
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
return t2;
|
|
671
|
+
}
|
|
672
|
+
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
673
|
+
...props,
|
|
674
|
+
...dateLimits,
|
|
675
|
+
value: parseDateRange(props.value),
|
|
676
|
+
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
677
|
+
});
|
|
979
678
|
};
|
|
980
|
-
function _temp(input) {
|
|
981
|
-
const container = input.getContainer?.() ?? input;
|
|
982
|
-
return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
|
|
983
|
-
}
|
|
984
|
-
function _temp2() {}
|
|
985
679
|
//#endregion
|
|
986
680
|
export { DateRangePicker };
|