@povio/ui 2.3.2-rc.3 → 2.3.3
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 +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/assets/locales/sl/translation.json.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.js +56 -207
- 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.js +38 -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 -368
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +5 -12
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +298 -506
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +5 -13
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +56 -273
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -6
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +130 -606
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +2 -5
- package/dist/components/inputs/DateTime/shared/Calendar.js +119 -332
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +2 -3
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +102 -301
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +2 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +33 -146
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +93 -249
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +137 -318
- package/dist/components/inputs/DateTime/shared/DateField.js +112 -311
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -13
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +139 -383
- 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.js +27 -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 +44 -87
- 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.js +9 -48
- 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 -17
- package/dist/components/inputs/RadioGroup/radio.cva.js +1 -42
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +2 -6
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +22 -214
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +8 -104
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -7
- package/dist/components/inputs/Selection/Select/Select.js +18 -225
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -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 -330
- 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 +3 -9
- 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 -10
- package/dist/components/inputs/shared/input.cva.js +4 -32
- 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 +23 -96
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +8 -48
- package/dist/components/overlays/Drawer/Drawer.js +20 -62
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +27 -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 +13 -21
- 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 +27 -28
- package/dist/components/text/Link/Link.js +7 -19
- 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 +6 -19
- package/dist/config/uiConfig.context.js +14 -67
- package/dist/config/uiStyle.context.d.ts +4 -27
- package/dist/config/uiStyle.context.js +5 -15
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +0 -3
- 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.js +30 -101
- 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 +0 -7
- package/dist/index.js +2 -4
- 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 -134
- 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 -7
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +0 -13
- 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 -39
- 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 -6
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +0 -11
- 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 -4
- 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 -36
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +0 -14
- package/dist/components/inputs/Selection/Select/QuerySelect.js +0 -173
- 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 -12
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -36
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +0 -3
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +0 -5
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +0 -5
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +0 -5
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +0 -23
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +0 -37
- 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 -4
- 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/useQueryAutocomplete.d.ts +0 -14
- package/dist/hooks/useQueryAutocomplete.js +0 -57
- package/dist/utils/query.utils.d.ts +0 -4
- package/dist/utils/query.utils.js +0 -8
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { UIStyle } from "../../../../config/uiStyle.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 { datePickerInputContentRow } 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";
|
|
@@ -24,73 +16,58 @@ import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
|
24
16
|
import { mergeRefs } from "@react-aria/utils";
|
|
25
17
|
import { useTranslation } from "react-i18next";
|
|
26
18
|
import { Controller } from "react-hook-form";
|
|
27
|
-
import { createCalendar, endOfMonth, endOfWeek, endOfYear, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
19
|
+
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
28
20
|
import { DateTime } from "luxon";
|
|
29
21
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
30
22
|
//#region src/components/inputs/DateTime/DateRangePicker/DateRangePicker.tsx
|
|
31
|
-
var DATE_PICKER_TIME_ZONE = "UTC";
|
|
32
23
|
var DateRangePickerBase = (props) => {
|
|
33
24
|
const ui = UIConfig.useConfig();
|
|
34
25
|
const { t } = useTranslation();
|
|
35
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange,
|
|
36
|
-
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
37
|
-
const variant = variantProp ?? ui.input.variant;
|
|
38
|
-
const as = asProp ?? ui.input.as;
|
|
39
|
-
const size = sizeProp ?? ui.input.size;
|
|
40
|
-
const isClearable = isClearableProp ?? ui.input.isClearable;
|
|
41
|
-
const todayIcon = todayIconProp ?? ui.dateInput.todayIcon;
|
|
42
|
-
const todayIconButtonSize = todayIconButtonSizeProp ?? ui.dateInput.todayIconButtonSize;
|
|
43
|
-
const todayIconButtonComponent = todayIconButtonComponentProp ?? ui.dateInput.todayIconButtonComponent;
|
|
44
|
-
const todayIconPlacement = todayIconPlacementProp ?? ui.dateInput.todayIconPlacement;
|
|
45
|
-
const shouldForceLeadingZeros = shouldForceLeadingZerosProp ?? ui.dateInput.shouldForceLeadingZeros;
|
|
46
|
-
const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
|
|
47
|
-
const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
|
|
48
|
-
const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
|
|
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;
|
|
49
27
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
50
28
|
const datePickerInputRef = useRef(null);
|
|
51
29
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
52
30
|
return datePickerInputRef.current?.getContainer?.() || null;
|
|
53
31
|
} }), []);
|
|
54
|
-
const normalizedValue = value ?? null;
|
|
55
32
|
const dialogState = useDateRangePickerState({
|
|
56
33
|
...rest,
|
|
57
|
-
value
|
|
34
|
+
value,
|
|
58
35
|
shouldCloseOnSelect: false,
|
|
59
|
-
shouldForceLeadingZeros
|
|
36
|
+
shouldForceLeadingZeros,
|
|
37
|
+
minValue,
|
|
38
|
+
maxValue
|
|
60
39
|
});
|
|
61
40
|
const state = useDateRangePickerState({
|
|
62
41
|
...rest,
|
|
63
42
|
shouldForceLeadingZeros,
|
|
64
|
-
value
|
|
43
|
+
value,
|
|
44
|
+
minValue,
|
|
45
|
+
maxValue,
|
|
65
46
|
onChange: (newValue) => {
|
|
66
47
|
if (isValidRange(newValue)) return;
|
|
67
48
|
onChange?.(newValue);
|
|
68
49
|
handleCalendarStatesChange(newValue);
|
|
69
|
-
if (fireBlurOnChange) debouncedBlur(newValue);
|
|
70
50
|
},
|
|
71
51
|
shouldCloseOnSelect: false
|
|
72
52
|
});
|
|
73
53
|
const { groupProps, labelProps, startFieldProps, endFieldProps, buttonProps, dialogProps } = useDateRangePicker({
|
|
74
54
|
...rest,
|
|
75
55
|
label,
|
|
76
|
-
shouldForceLeadingZeros
|
|
56
|
+
shouldForceLeadingZeros,
|
|
57
|
+
minValue,
|
|
58
|
+
maxValue
|
|
77
59
|
}, state, dateRangePickerRef);
|
|
78
60
|
const { calendarProps } = useDateRangePicker({
|
|
79
61
|
...rest,
|
|
80
62
|
label,
|
|
81
|
-
shouldForceLeadingZeros
|
|
63
|
+
shouldForceLeadingZeros,
|
|
64
|
+
minValue,
|
|
65
|
+
maxValue
|
|
82
66
|
}, dialogState, dateRangePickerRef);
|
|
83
67
|
const { locale } = useLocale$1();
|
|
84
|
-
useImperativeHandle(ref, () => ({
|
|
85
|
-
clear
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
|
|
89
|
-
}));
|
|
90
|
-
const handleBlur = (newValue_0) => {
|
|
91
|
-
onBlur?.({ target: { value: newValue_0 } });
|
|
92
|
-
};
|
|
93
|
-
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
68
|
+
useImperativeHandle(ref, () => ({ clear: () => {
|
|
69
|
+
datePickerInputRef.current?.clear();
|
|
70
|
+
} }));
|
|
94
71
|
const formFieldProps = {
|
|
95
72
|
error: error || validationRangeError,
|
|
96
73
|
label,
|
|
@@ -110,8 +87,8 @@ var DateRangePickerBase = (props) => {
|
|
|
110
87
|
createCalendar,
|
|
111
88
|
pageBehavior: "single",
|
|
112
89
|
visibleDuration: { months: 1 },
|
|
113
|
-
minValue
|
|
114
|
-
maxValue
|
|
90
|
+
minValue,
|
|
91
|
+
maxValue
|
|
115
92
|
});
|
|
116
93
|
const rightCalendarState = useRangeCalendarState({
|
|
117
94
|
...calendarProps,
|
|
@@ -119,9 +96,9 @@ var DateRangePickerBase = (props) => {
|
|
|
119
96
|
createCalendar,
|
|
120
97
|
pageBehavior: "single",
|
|
121
98
|
visibleDuration: { months: 1 },
|
|
122
|
-
defaultFocusedValue: today(
|
|
123
|
-
minValue
|
|
124
|
-
maxValue
|
|
99
|
+
defaultFocusedValue: today(getLocalTimeZone()).add({ months: 1 }),
|
|
100
|
+
minValue,
|
|
101
|
+
maxValue
|
|
125
102
|
});
|
|
126
103
|
const [activePreset, setActivePreset] = useState(null);
|
|
127
104
|
const [rangeSelection, setRangeSelection] = useState({
|
|
@@ -141,10 +118,36 @@ var DateRangePickerBase = (props) => {
|
|
|
141
118
|
className: headerClassName,
|
|
142
119
|
labelProps
|
|
143
120
|
};
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
121
|
+
const isDateOutsideBounds = useCallback((date) => {
|
|
122
|
+
if (minValue && date.compare(minValue) < 0) return true;
|
|
123
|
+
if (maxValue && date.compare(maxValue) > 0) return true;
|
|
124
|
+
return false;
|
|
125
|
+
}, [minValue, maxValue]);
|
|
126
|
+
const clampRangeToBounds = useCallback((range) => {
|
|
127
|
+
if (range === null) return null;
|
|
128
|
+
if (minValue && maxValue && minValue.compare(maxValue) > 0) return null;
|
|
129
|
+
let startDate = range.start;
|
|
130
|
+
let endDate = range.end;
|
|
131
|
+
if (minValue && endDate.compare(minValue) < 0 || maxValue && startDate.compare(maxValue) > 0) return null;
|
|
132
|
+
if (minValue && startDate.compare(minValue) < 0) startDate = minValue;
|
|
133
|
+
if (maxValue && startDate.compare(maxValue) > 0) startDate = maxValue;
|
|
134
|
+
if (minValue && endDate.compare(minValue) < 0) endDate = minValue;
|
|
135
|
+
if (maxValue && endDate.compare(maxValue) > 0) endDate = maxValue;
|
|
136
|
+
if (startDate.compare(endDate) > 0) return null;
|
|
137
|
+
return {
|
|
138
|
+
start: startDate,
|
|
139
|
+
end: endDate
|
|
140
|
+
};
|
|
141
|
+
}, [minValue, 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;
|
|
145
|
+
return true;
|
|
146
|
+
}, [minValue, maxValue]);
|
|
147
|
+
const isValidRange = useCallback((newValue) => {
|
|
148
|
+
if (newValue?.start && newValue?.end) {
|
|
149
|
+
const startDate = newValue.start;
|
|
150
|
+
if (newValue.end.compare(startDate) < 0) {
|
|
148
151
|
setValidationRangeError(t(($) => $.ui.datePicker.errors.endDateBeforeStart, { ns: "ui" }));
|
|
149
152
|
return true;
|
|
150
153
|
}
|
|
@@ -152,20 +155,22 @@ var DateRangePickerBase = (props) => {
|
|
|
152
155
|
} else setValidationRangeError(void 0);
|
|
153
156
|
return false;
|
|
154
157
|
}, [t]);
|
|
155
|
-
const handleCalendarStatesChange = (
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
rightCalendarState.
|
|
158
|
+
const handleCalendarStatesChange = (newValue) => {
|
|
159
|
+
if (newValue) {
|
|
160
|
+
const clampedValue = clampRangeToBounds(newValue);
|
|
161
|
+
if (!clampedValue) return;
|
|
162
|
+
if (isValidRange(clampedValue)) return;
|
|
163
|
+
dialogState.setValue(clampedValue);
|
|
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);
|
|
169
|
+
leftCalendarState.setValue(clampedValue);
|
|
170
|
+
rightCalendarState.setValue(clampedValue);
|
|
166
171
|
setRangeSelection({
|
|
167
|
-
start:
|
|
168
|
-
end:
|
|
172
|
+
start: clampedValue.start,
|
|
173
|
+
end: clampedValue.end,
|
|
169
174
|
isSelecting: false
|
|
170
175
|
});
|
|
171
176
|
setHoverDate(null);
|
|
@@ -189,27 +194,28 @@ var DateRangePickerBase = (props) => {
|
|
|
189
194
|
setHoverDate(date);
|
|
190
195
|
});
|
|
191
196
|
}, []);
|
|
192
|
-
const handleDateHover = useCallback((
|
|
193
|
-
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(
|
|
197
|
+
const handleDateHover = useCallback((date) => {
|
|
198
|
+
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(date);
|
|
194
199
|
}, [
|
|
195
200
|
rangeSelection.isSelecting,
|
|
196
201
|
rangeSelection.start,
|
|
197
202
|
throttledSetHoverDate
|
|
198
203
|
]);
|
|
199
|
-
const handleDateSelection = useCallback((
|
|
204
|
+
const handleDateSelection = useCallback((date, calendarSide) => {
|
|
200
205
|
if (calendarSide) {
|
|
201
206
|
const currentVisibleMonth = (calendarSide === "left" ? leftCalendarState : rightCalendarState).visibleRange.start;
|
|
202
|
-
if (
|
|
203
|
-
leftCalendarState.setFocusedDate(
|
|
204
|
-
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 }));
|
|
205
210
|
} else {
|
|
206
|
-
rightCalendarState.setFocusedDate(
|
|
207
|
-
leftCalendarState.setFocusedDate(
|
|
211
|
+
rightCalendarState.setFocusedDate(date);
|
|
212
|
+
leftCalendarState.setFocusedDate(date.subtract({ months: 1 }));
|
|
208
213
|
}
|
|
209
214
|
}
|
|
215
|
+
if (isDateOutsideBounds(date)) return;
|
|
210
216
|
if (!rangeSelection.isSelecting || !rangeSelection.start) {
|
|
211
217
|
setRangeSelection({
|
|
212
|
-
start:
|
|
218
|
+
start: date,
|
|
213
219
|
end: null,
|
|
214
220
|
isSelecting: true
|
|
215
221
|
});
|
|
@@ -218,19 +224,18 @@ var DateRangePickerBase = (props) => {
|
|
|
218
224
|
rightCalendarState.setValue(null);
|
|
219
225
|
} else {
|
|
220
226
|
const { start } = rangeSelection;
|
|
221
|
-
const end =
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
dialogState.setValue(newRange);
|
|
227
|
+
const end = date;
|
|
228
|
+
const clampedRange = clampRangeToBounds({
|
|
229
|
+
start: start.compare(end) <= 0 ? start : end,
|
|
230
|
+
end: start.compare(end) <= 0 ? end : start
|
|
231
|
+
});
|
|
232
|
+
if (!clampedRange) return;
|
|
233
|
+
leftCalendarState.setValue(clampedRange);
|
|
234
|
+
rightCalendarState.setValue(clampedRange);
|
|
235
|
+
dialogState.setValue(clampedRange);
|
|
231
236
|
setRangeSelection({
|
|
232
|
-
start:
|
|
233
|
-
end:
|
|
237
|
+
start: clampedRange.start,
|
|
238
|
+
end: clampedRange.end,
|
|
234
239
|
isSelecting: false
|
|
235
240
|
});
|
|
236
241
|
setHoverDate(null);
|
|
@@ -240,18 +245,20 @@ var DateRangePickerBase = (props) => {
|
|
|
240
245
|
rangeSelection,
|
|
241
246
|
leftCalendarState,
|
|
242
247
|
rightCalendarState,
|
|
243
|
-
dialogState
|
|
248
|
+
dialogState,
|
|
249
|
+
isDateOutsideBounds,
|
|
250
|
+
clampRangeToBounds
|
|
244
251
|
]);
|
|
245
|
-
const handleKeyboardNavigation = useCallback((event,
|
|
246
|
-
const
|
|
247
|
-
const otherState =
|
|
252
|
+
const handleKeyboardNavigation = useCallback((event, date, calendarSide) => {
|
|
253
|
+
const currentState = calendarSide === "left" ? leftCalendarState : rightCalendarState;
|
|
254
|
+
const otherState = calendarSide === "left" ? rightCalendarState : leftCalendarState;
|
|
248
255
|
let shouldPreventDefault = false;
|
|
249
256
|
switch (event.key) {
|
|
250
257
|
case "ArrowRight": {
|
|
251
|
-
const nextDate =
|
|
252
|
-
const
|
|
253
|
-
const
|
|
254
|
-
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) {
|
|
255
262
|
otherState.setFocusedDate(nextDate);
|
|
256
263
|
shouldPreventDefault = true;
|
|
257
264
|
} else {
|
|
@@ -261,10 +268,10 @@ var DateRangePickerBase = (props) => {
|
|
|
261
268
|
break;
|
|
262
269
|
}
|
|
263
270
|
case "ArrowLeft": {
|
|
264
|
-
const prevDate =
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
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) {
|
|
268
275
|
otherState.setFocusedDate(prevDate);
|
|
269
276
|
shouldPreventDefault = true;
|
|
270
277
|
} else {
|
|
@@ -274,10 +281,10 @@ var DateRangePickerBase = (props) => {
|
|
|
274
281
|
break;
|
|
275
282
|
}
|
|
276
283
|
case "ArrowDown": {
|
|
277
|
-
const nextWeekDate =
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
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) {
|
|
281
288
|
otherState.setFocusedDate(nextWeekDate);
|
|
282
289
|
shouldPreventDefault = true;
|
|
283
290
|
} else {
|
|
@@ -287,10 +294,10 @@ var DateRangePickerBase = (props) => {
|
|
|
287
294
|
break;
|
|
288
295
|
}
|
|
289
296
|
case "ArrowUp": {
|
|
290
|
-
const prevWeekDate =
|
|
291
|
-
const currentMonth =
|
|
297
|
+
const prevWeekDate = date.subtract({ weeks: 1 });
|
|
298
|
+
const currentMonth = currentState.visibleRange.start;
|
|
292
299
|
const otherMonth = otherState.visibleRange.start;
|
|
293
|
-
if (
|
|
300
|
+
if (calendarSide === "right" && prevWeekDate.month !== currentMonth.month) if (prevWeekDate.year === otherMonth.year && prevWeekDate.month === otherMonth.month) {
|
|
294
301
|
otherState.setFocusedDate(prevWeekDate);
|
|
295
302
|
shouldPreventDefault = true;
|
|
296
303
|
} else {
|
|
@@ -301,7 +308,7 @@ var DateRangePickerBase = (props) => {
|
|
|
301
308
|
}
|
|
302
309
|
case "Enter":
|
|
303
310
|
case " ":
|
|
304
|
-
handleDateSelection(
|
|
311
|
+
handleDateSelection(date);
|
|
305
312
|
shouldPreventDefault = true;
|
|
306
313
|
break;
|
|
307
314
|
case "Escape":
|
|
@@ -325,19 +332,29 @@ var DateRangePickerBase = (props) => {
|
|
|
325
332
|
rightCalendarState,
|
|
326
333
|
handleDateSelection
|
|
327
334
|
]);
|
|
328
|
-
const syncCalendarStates = useCallback((
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
const syncCalendarStates = useCallback((newValue) => {
|
|
336
|
+
if (newValue === null) {
|
|
337
|
+
setValidationRangeError(void 0);
|
|
338
|
+
leftCalendarState.setValue(null);
|
|
339
|
+
rightCalendarState.setValue(null);
|
|
340
|
+
dialogState.setValue(null);
|
|
341
|
+
setRangeSelection({
|
|
342
|
+
start: null,
|
|
343
|
+
end: null,
|
|
344
|
+
isSelecting: false
|
|
345
|
+
});
|
|
346
|
+
setHoverDate(null);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
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);
|
|
355
|
+
setRangeSelection({
|
|
356
|
+
start: clampedValue.start,
|
|
357
|
+
end: clampedValue.end,
|
|
341
358
|
isSelecting: false
|
|
342
359
|
});
|
|
343
360
|
setHoverDate(null);
|
|
@@ -345,30 +362,32 @@ var DateRangePickerBase = (props) => {
|
|
|
345
362
|
isValidRange,
|
|
346
363
|
leftCalendarState,
|
|
347
364
|
rightCalendarState,
|
|
348
|
-
dialogState
|
|
365
|
+
dialogState,
|
|
366
|
+
clampRangeToBounds
|
|
349
367
|
]);
|
|
350
368
|
const onApply = () => {
|
|
351
|
-
|
|
369
|
+
let valueToApply = dialogState.value;
|
|
370
|
+
if (rangeSelection.start && rangeSelection.end) valueToApply = {
|
|
352
371
|
start: rangeSelection.start,
|
|
353
372
|
end: rangeSelection.end
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (fireBlurOnChange) handleBlur(valueToApply);
|
|
358
|
-
}
|
|
373
|
+
};
|
|
374
|
+
const clampedValue = clampRangeToBounds(valueToApply);
|
|
375
|
+
if (clampedValue) state.setValue(clampedValue);
|
|
359
376
|
state.toggle();
|
|
360
377
|
};
|
|
361
378
|
const onTodayPress = () => {
|
|
362
|
-
const todayDate = today(
|
|
363
|
-
|
|
364
|
-
rightCalendarState.setFocusedDate(todayDate.add({ months: 1 }));
|
|
365
|
-
syncCalendarStates({
|
|
379
|
+
const todayDate = today(getLocalTimeZone());
|
|
380
|
+
const clampedTodayRange = clampRangeToBounds({
|
|
366
381
|
start: todayDate,
|
|
367
382
|
end: todayDate
|
|
368
383
|
});
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
384
|
+
if (!clampedTodayRange) return;
|
|
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);
|
|
390
|
+
syncCalendarStates(clampedTodayRange);
|
|
372
391
|
};
|
|
373
392
|
const onOpenChange = (isOpen) => {
|
|
374
393
|
state.toggle();
|
|
@@ -377,11 +396,11 @@ var DateRangePickerBase = (props) => {
|
|
|
377
396
|
dialogState.setValue(state.value);
|
|
378
397
|
leftCalendarState.setValue(state.value);
|
|
379
398
|
rightCalendarState.setValue(state.value);
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
leftCalendarState.setFocusedDate(
|
|
383
|
-
if (
|
|
384
|
-
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);
|
|
385
404
|
setRangeSelection({
|
|
386
405
|
start: state.value.start,
|
|
387
406
|
end: state.value.end,
|
|
@@ -390,100 +409,125 @@ var DateRangePickerBase = (props) => {
|
|
|
390
409
|
}
|
|
391
410
|
}
|
|
392
411
|
};
|
|
393
|
-
const
|
|
412
|
+
const todayDate = today(getLocalTimeZone());
|
|
394
413
|
const getThisWeekRange = () => {
|
|
395
414
|
return {
|
|
396
|
-
start: startOfWeek(
|
|
397
|
-
end: endOfWeek(
|
|
415
|
+
start: startOfWeek(todayDate, locale),
|
|
416
|
+
end: endOfWeek(todayDate, locale)
|
|
398
417
|
};
|
|
399
418
|
};
|
|
400
419
|
const getLastWeekRange = () => {
|
|
401
|
-
const thisWeekStart = startOfWeek(
|
|
420
|
+
const thisWeekStart = startOfWeek(todayDate, locale);
|
|
402
421
|
return {
|
|
403
422
|
start: thisWeekStart.subtract({ weeks: 1 }),
|
|
404
423
|
end: thisWeekStart.subtract({ days: 1 })
|
|
405
424
|
};
|
|
406
425
|
};
|
|
407
426
|
const getThisAndLastWeekRange = () => {
|
|
408
|
-
const thisWeekEnd = endOfWeek(
|
|
427
|
+
const thisWeekEnd = endOfWeek(todayDate, locale);
|
|
409
428
|
return {
|
|
410
|
-
start: startOfWeek(
|
|
429
|
+
start: startOfWeek(todayDate, locale).subtract({ weeks: 1 }),
|
|
411
430
|
end: thisWeekEnd
|
|
412
431
|
};
|
|
413
432
|
};
|
|
414
433
|
const getThisMonthRange = () => {
|
|
415
434
|
return {
|
|
416
|
-
start: startOfMonth(
|
|
417
|
-
end: endOfMonth(
|
|
435
|
+
start: startOfMonth(todayDate),
|
|
436
|
+
end: endOfMonth(todayDate)
|
|
418
437
|
};
|
|
419
438
|
};
|
|
420
439
|
const getThisAndLastMonthRange = () => {
|
|
421
|
-
const thisMonthEnd = endOfMonth(
|
|
440
|
+
const thisMonthEnd = endOfMonth(todayDate);
|
|
422
441
|
return {
|
|
423
|
-
start: startOfMonth(
|
|
442
|
+
start: startOfMonth(todayDate).subtract({ months: 1 }),
|
|
424
443
|
end: thisMonthEnd
|
|
425
444
|
};
|
|
426
445
|
};
|
|
446
|
+
const createPreset = (params) => {
|
|
447
|
+
let clampedValue = clampRangeToBounds(params.getValue());
|
|
448
|
+
let isDisabled = false;
|
|
449
|
+
if (params.keepEnabledUnlessFutureMin) {
|
|
450
|
+
let minDateIsInFuture = false;
|
|
451
|
+
if (minValue && minValue.compare(todayDate) > 0) minDateIsInFuture = true;
|
|
452
|
+
if (minDateIsInFuture) {
|
|
453
|
+
isDisabled = true;
|
|
454
|
+
clampedValue = null;
|
|
455
|
+
} else if (!clampedValue && maxValue) clampedValue = {
|
|
456
|
+
start: maxValue,
|
|
457
|
+
end: maxValue
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
if (!clampedValue) isDisabled = true;
|
|
461
|
+
if (clampedValue && !isRangeWithinBounds(clampedValue)) isDisabled = true;
|
|
462
|
+
return {
|
|
463
|
+
label: params.label,
|
|
464
|
+
getValue: params.getValue,
|
|
465
|
+
clampedValue,
|
|
466
|
+
isDisabled
|
|
467
|
+
};
|
|
468
|
+
};
|
|
427
469
|
const presets = [
|
|
428
|
-
{
|
|
429
|
-
label: t(($
|
|
470
|
+
createPreset({
|
|
471
|
+
label: t(($) => $.ui.datePicker.presets.thisWeek, { ns: "ui" }),
|
|
430
472
|
getValue: getThisWeekRange
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
label: t(($
|
|
473
|
+
}),
|
|
474
|
+
createPreset({
|
|
475
|
+
label: t(($) => $.ui.datePicker.presets.lastWeek, { ns: "ui" }),
|
|
434
476
|
getValue: getLastWeekRange
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
label: t(($
|
|
477
|
+
}),
|
|
478
|
+
createPreset({
|
|
479
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastWeek, { ns: "ui" }),
|
|
438
480
|
getValue: getThisAndLastWeekRange
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
label: t(($
|
|
481
|
+
}),
|
|
482
|
+
createPreset({
|
|
483
|
+
label: t(($) => $.ui.datePicker.presets.thisMonth, { ns: "ui" }),
|
|
442
484
|
getValue: getThisMonthRange
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
label: t(($
|
|
485
|
+
}),
|
|
486
|
+
createPreset({
|
|
487
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastMonth, { ns: "ui" }),
|
|
446
488
|
getValue: getThisAndLastMonthRange
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
label: t(($
|
|
489
|
+
}),
|
|
490
|
+
createPreset({
|
|
491
|
+
label: t(($) => $.ui.datePicker.presets.thisYear, { ns: "ui" }),
|
|
450
492
|
getValue: () => ({
|
|
451
|
-
start: startOfYear(
|
|
452
|
-
end:
|
|
493
|
+
start: startOfYear(todayDate),
|
|
494
|
+
end: todayDate
|
|
453
495
|
})
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
label: t(($
|
|
496
|
+
}),
|
|
497
|
+
createPreset({
|
|
498
|
+
label: t(($) => $.ui.datePicker.presets.lastYear, { ns: "ui" }),
|
|
457
499
|
getValue: () => ({
|
|
458
|
-
start: startOfYear(
|
|
459
|
-
end: endOfYear(
|
|
500
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
501
|
+
end: endOfYear(todayDate.subtract({ years: 1 }))
|
|
460
502
|
})
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
label: t(($
|
|
503
|
+
}),
|
|
504
|
+
createPreset({
|
|
505
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastYear, { ns: "ui" }),
|
|
464
506
|
getValue: () => ({
|
|
465
|
-
start: startOfYear(
|
|
466
|
-
end:
|
|
507
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
508
|
+
end: todayDate
|
|
467
509
|
})
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
label: t(($
|
|
510
|
+
}),
|
|
511
|
+
createPreset({
|
|
512
|
+
label: t(($) => $.ui.datePicker.presets.soFar, { ns: "ui" }),
|
|
471
513
|
getValue: () => ({
|
|
472
|
-
start: startOfYear(
|
|
473
|
-
end:
|
|
474
|
-
})
|
|
475
|
-
|
|
514
|
+
start: startOfYear(todayDate),
|
|
515
|
+
end: todayDate
|
|
516
|
+
}),
|
|
517
|
+
keepEnabledUnlessFutureMin: true
|
|
518
|
+
})
|
|
476
519
|
];
|
|
477
520
|
const selectPreset = (preset) => {
|
|
521
|
+
if (preset.isDisabled || !preset.clampedValue) return;
|
|
478
522
|
setActivePreset(preset.label);
|
|
479
|
-
const presetValue = preset.
|
|
523
|
+
const presetValue = preset.clampedValue;
|
|
480
524
|
syncCalendarStates(presetValue);
|
|
481
|
-
const
|
|
482
|
-
leftCalendarState.setFocusedDate(
|
|
483
|
-
const
|
|
484
|
-
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);
|
|
485
529
|
else {
|
|
486
|
-
const rightCalendarMonth =
|
|
530
|
+
const rightCalendarMonth = startDate.add({ months: 1 });
|
|
487
531
|
rightCalendarState.setFocusedDate(rightCalendarMonth);
|
|
488
532
|
}
|
|
489
533
|
};
|
|
@@ -501,24 +545,8 @@ var DateRangePickerBase = (props) => {
|
|
|
501
545
|
ref: mergeRefs(ref, datePickerInputRef),
|
|
502
546
|
as,
|
|
503
547
|
groupProps,
|
|
504
|
-
fieldProps:
|
|
505
|
-
|
|
506
|
-
onBlur: (event_0) => {
|
|
507
|
-
startFieldProps.onBlur?.(event_0);
|
|
508
|
-
handleBlur(state.value);
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
endFieldProps: {
|
|
512
|
-
...endFieldProps,
|
|
513
|
-
onBlur: (event_1) => {
|
|
514
|
-
endFieldProps.onBlur?.(event_1);
|
|
515
|
-
handleBlur(state.value);
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
fieldValue: normalizedValue?.start ?? null,
|
|
519
|
-
endFieldValue: normalizedValue?.end ?? null,
|
|
520
|
-
isValueControlled: true,
|
|
521
|
-
hasValue: normalizedValue?.start != null || normalizedValue?.end != null,
|
|
548
|
+
fieldProps: startFieldProps,
|
|
549
|
+
endFieldProps,
|
|
522
550
|
buttonProps,
|
|
523
551
|
isDisabled,
|
|
524
552
|
isInvalid: !!error,
|
|
@@ -528,33 +556,28 @@ var DateRangePickerBase = (props) => {
|
|
|
528
556
|
isClearable,
|
|
529
557
|
headerProps,
|
|
530
558
|
todayIcon,
|
|
531
|
-
todayIconButtonSize,
|
|
532
|
-
todayIconButtonComponent,
|
|
533
|
-
todayIconPlacement,
|
|
534
559
|
isDirty,
|
|
535
560
|
disableManualEntry,
|
|
536
|
-
autoFixYear,
|
|
537
561
|
placeholder,
|
|
538
562
|
className: inputClassName,
|
|
539
563
|
onOpenDropdown: () => state.toggle(),
|
|
540
|
-
|
|
541
|
-
fireBlurOnChange,
|
|
542
|
-
onClear: onInputClear
|
|
564
|
+
autoFixYear
|
|
543
565
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
544
566
|
hideSidebar,
|
|
545
567
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
546
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",
|
|
547
|
-
children: presets.map((
|
|
548
|
-
|
|
549
|
-
|
|
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"),
|
|
550
573
|
children: /* @__PURE__ */ jsx(Typography, {
|
|
551
574
|
size: "label-2",
|
|
552
575
|
sizeMobile: "label-3",
|
|
553
576
|
as: "span",
|
|
554
577
|
className: "whitespace-nowrap",
|
|
555
|
-
children:
|
|
578
|
+
children: preset.label
|
|
556
579
|
})
|
|
557
|
-
},
|
|
580
|
+
}, preset.label))
|
|
558
581
|
}),
|
|
559
582
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
560
583
|
isDisabled,
|
|
@@ -589,300 +612,69 @@ var DateRangePickerBase = (props) => {
|
|
|
589
612
|
})
|
|
590
613
|
});
|
|
591
614
|
};
|
|
592
|
-
var
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const { locale } = useLocale$1();
|
|
599
|
-
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
600
|
-
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
601
|
-
const inputRef = useRef(null);
|
|
602
|
-
const { renderRealInput } = useStaticInputHandoff({
|
|
603
|
-
inputRef,
|
|
604
|
-
renderInput,
|
|
605
|
-
setRenderInput,
|
|
606
|
-
getFocusTarget: _temp
|
|
607
|
-
});
|
|
608
|
-
const normalizedValue = props.value ?? null;
|
|
609
|
-
let t2;
|
|
610
|
-
if ($[0] !== fullIso) {
|
|
611
|
-
t2 = (range) => {
|
|
612
|
-
if (!range?.start || !range?.end) return null;
|
|
613
|
-
if (fullIso) return {
|
|
614
|
-
start: DateTimeUtils.fromCalendarDateToUTCISO(range.start),
|
|
615
|
-
end: DateTimeUtils.fromCalendarDateToUTCISO(range.end, { endOfDay: true })
|
|
616
|
-
};
|
|
617
|
-
const startDate = DateTimeUtils.fromDateValueToLocal(range.start, "UTC");
|
|
618
|
-
const endDate = DateTimeUtils.fromDateValueToLocal(range.end, "UTC");
|
|
619
|
-
return {
|
|
620
|
-
start: DateTime.fromJSDate(startDate, { zone: "UTC" }).toISODate(),
|
|
621
|
-
end: DateTime.fromJSDate(endDate, { zone: "UTC" }).toISODate()
|
|
622
|
-
};
|
|
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 })
|
|
623
621
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if ($[2] !== fullIso) {
|
|
630
|
-
t3 = (formattedRange) => {
|
|
631
|
-
if (!formattedRange?.start || !formattedRange?.end) return null;
|
|
632
|
-
if (fullIso) return {
|
|
633
|
-
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
634
|
-
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
635
|
-
};
|
|
636
|
-
const startDate_0 = DateTime.fromISO(formattedRange.start, { zone: "UTC" }).toJSDate();
|
|
637
|
-
const endDate_0 = DateTime.fromISO(formattedRange.end, { zone: "UTC" }).toJSDate();
|
|
638
|
-
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate_0, "UTC");
|
|
639
|
-
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate_0, "UTC");
|
|
640
|
-
return {
|
|
641
|
-
start: toCalendarDate(startZonedDateTime),
|
|
642
|
-
end: toCalendarDate(endZonedDateTime)
|
|
643
|
-
};
|
|
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()
|
|
644
627
|
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
t4 = (formattedDate) => {
|
|
652
|
-
if (formattedDate == null) return null;
|
|
653
|
-
if (fullIso) return DateTimeUtils.fromUTCISOToCalendarDate(formattedDate);
|
|
654
|
-
const date = DateTime.fromISO(formattedDate, { zone: "UTC" }).toJSDate();
|
|
655
|
-
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)
|
|
656
634
|
};
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
$[6] = minValue;
|
|
665
|
-
$[7] = parseCalendarDate;
|
|
666
|
-
$[8] = t5;
|
|
667
|
-
} else t5 = $[8];
|
|
668
|
-
let t6;
|
|
669
|
-
if ($[9] !== maxValue || $[10] !== parseCalendarDate) {
|
|
670
|
-
t6 = typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue;
|
|
671
|
-
$[9] = maxValue;
|
|
672
|
-
$[10] = parseCalendarDate;
|
|
673
|
-
$[11] = t6;
|
|
674
|
-
} else t6 = $[11];
|
|
675
|
-
let t7;
|
|
676
|
-
if ($[12] !== t5 || $[13] !== t6) {
|
|
677
|
-
t7 = {
|
|
678
|
-
minValue: t5,
|
|
679
|
-
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)
|
|
680
642
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
693
|
-
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
694
|
-
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
695
|
-
const todayIconButtonComponent = props.todayIconButtonComponent ?? ui.dateInput.todayIconButtonComponent;
|
|
696
|
-
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
697
|
-
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, {
|
|
698
|
-
isDisabled,
|
|
699
|
-
renderStatic: true,
|
|
700
|
-
size: todayIconButtonSize,
|
|
701
|
-
todayIconButtonComponent
|
|
702
|
-
});
|
|
703
|
-
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
704
|
-
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
705
|
-
const staticSegments = getStaticDateRangeSegments({
|
|
706
|
-
start: startDateValue,
|
|
707
|
-
end: endDateValue,
|
|
708
|
-
locale,
|
|
709
|
-
shouldForceLeadingZeros,
|
|
710
|
-
isDisabled,
|
|
711
|
-
hidePlaceholder: as === "floating" && !hasProvidedRangeValue,
|
|
712
|
-
disableManualEntry,
|
|
713
|
-
placeholder: props.placeholder
|
|
714
|
-
});
|
|
715
|
-
return /* @__PURE__ */ jsx(InputFrame, {
|
|
716
|
-
...props,
|
|
717
|
-
isDisabled,
|
|
718
|
-
className: clsx("group relative inline-flex w-full flex-col text-left", props.className),
|
|
719
|
-
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
720
|
-
contentClassName: "pr-0!",
|
|
721
|
-
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
722
|
-
contentGroup: "date-picker",
|
|
723
|
-
labelPlacement: "content-row",
|
|
724
|
-
dataAttributes: {
|
|
725
|
-
dataIsEmpty: !hasProvidedRangeValue,
|
|
726
|
-
dataIsFilled: hasProvidedRangeValue,
|
|
727
|
-
dataIsDirty: props.isDirty,
|
|
728
|
-
dataIsRequired: props.isRequired,
|
|
729
|
-
dataIsDisabled: isDisabled,
|
|
730
|
-
dataDisabled: isDisabled,
|
|
731
|
-
dataInvalid: !!props.error,
|
|
732
|
-
dataHasSelection: hasProvidedRangeValue
|
|
733
|
-
},
|
|
734
|
-
renderStatic: true,
|
|
735
|
-
onStaticInteract: renderRealInput,
|
|
736
|
-
actionContent: staticTodayIcon,
|
|
737
|
-
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
738
|
-
showClear: hasProvidedRangeValue,
|
|
739
|
-
wrapContentAndTrailing: true,
|
|
740
|
-
contentAndTrailingClassName: "gap-2!",
|
|
741
|
-
trailingClassName: "py-0! pl-0!",
|
|
742
|
-
action: showDropdown ? {
|
|
743
|
-
icon: ui.dateInput.calendarIcon,
|
|
744
|
-
onClick: _temp2,
|
|
745
|
-
altText: ""
|
|
746
|
-
} : void 0,
|
|
747
|
-
children: staticSegments
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
const T0 = DateRangePickerBase;
|
|
751
|
-
const t8 = mergeRefs(props.ref, inputRef);
|
|
752
|
-
const t9 = parseDateRange(normalizedValue);
|
|
753
|
-
let t10;
|
|
754
|
-
if ($[15] !== formatDateRange || $[16] !== props) {
|
|
755
|
-
t10 = (value) => props.onChange?.(formatDateRange(value));
|
|
756
|
-
$[15] = formatDateRange;
|
|
757
|
-
$[16] = props;
|
|
758
|
-
$[17] = t10;
|
|
759
|
-
} else t10 = $[17];
|
|
760
|
-
let t11;
|
|
761
|
-
if ($[18] !== T0 || $[19] !== dateLimits || $[20] !== props || $[21] !== t10 || $[22] !== t8 || $[23] !== t9) {
|
|
762
|
-
t11 = /* @__PURE__ */ jsx(T0, {
|
|
763
|
-
...props,
|
|
764
|
-
...dateLimits,
|
|
765
|
-
ref: t8,
|
|
766
|
-
value: t9,
|
|
767
|
-
onChange: t10
|
|
768
|
-
});
|
|
769
|
-
$[18] = T0;
|
|
770
|
-
$[19] = dateLimits;
|
|
771
|
-
$[20] = props;
|
|
772
|
-
$[21] = t10;
|
|
773
|
-
$[22] = t8;
|
|
774
|
-
$[23] = t9;
|
|
775
|
-
$[24] = t11;
|
|
776
|
-
} else t11 = $[24];
|
|
777
|
-
return t11;
|
|
778
|
-
};
|
|
779
|
-
var DateRangePicker = (t0) => {
|
|
780
|
-
const $ = c(30);
|
|
781
|
-
let maxValue;
|
|
782
|
-
let minValue;
|
|
783
|
-
let props;
|
|
784
|
-
let renderStaticInput;
|
|
785
|
-
let t1;
|
|
786
|
-
if ($[0] !== t0) {
|
|
787
|
-
({fullIso: t1, minValue, maxValue, renderStaticInput, ...props} = t0);
|
|
788
|
-
$[0] = t0;
|
|
789
|
-
$[1] = maxValue;
|
|
790
|
-
$[2] = minValue;
|
|
791
|
-
$[3] = props;
|
|
792
|
-
$[4] = renderStaticInput;
|
|
793
|
-
$[5] = t1;
|
|
794
|
-
} else {
|
|
795
|
-
maxValue = $[1];
|
|
796
|
-
minValue = $[2];
|
|
797
|
-
props = $[3];
|
|
798
|
-
renderStaticInput = $[4];
|
|
799
|
-
t1 = $[5];
|
|
800
|
-
}
|
|
801
|
-
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
|
+
};
|
|
802
654
|
if ("formControl" in props && props.formControl) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
({
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
let t2;
|
|
819
|
-
if ($[10] !== controlWithOptions._options?.disabled || $[11] !== fullIso || $[12] !== innerProps || $[13] !== maxValue || $[14] !== minValue || $[15] !== props.error || $[16] !== props.isDisabled || $[17] !== ref || $[18] !== renderStaticInput) {
|
|
820
|
-
t2 = (t3) => {
|
|
821
|
-
const { field, fieldState: t4 } = t3;
|
|
822
|
-
const { error, isDirty } = t4;
|
|
823
|
-
return /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
824
|
-
...innerProps,
|
|
825
|
-
ref: mergeRefs(ref, field.ref),
|
|
826
|
-
value: field.value ?? null,
|
|
827
|
-
onChange: field.onChange,
|
|
828
|
-
onBlur: field.onBlur,
|
|
829
|
-
isDirty,
|
|
830
|
-
isDisabled: field.disabled || props.isDisabled,
|
|
831
|
-
isFormControlDisabled: !!controlWithOptions._options?.disabled,
|
|
832
|
-
error: props.error ?? error?.message,
|
|
833
|
-
fullIso,
|
|
834
|
-
minValue,
|
|
835
|
-
maxValue,
|
|
836
|
-
renderStaticInput
|
|
837
|
-
});
|
|
838
|
-
};
|
|
839
|
-
$[10] = controlWithOptions._options?.disabled;
|
|
840
|
-
$[11] = fullIso;
|
|
841
|
-
$[12] = innerProps;
|
|
842
|
-
$[13] = maxValue;
|
|
843
|
-
$[14] = minValue;
|
|
844
|
-
$[15] = props.error;
|
|
845
|
-
$[16] = props.isDisabled;
|
|
846
|
-
$[17] = ref;
|
|
847
|
-
$[18] = renderStaticInput;
|
|
848
|
-
$[19] = t2;
|
|
849
|
-
} else t2 = $[19];
|
|
850
|
-
let t3;
|
|
851
|
-
if ($[20] !== formControl.control || $[21] !== formControl.name || $[22] !== t2) {
|
|
852
|
-
t3 = /* @__PURE__ */ jsx(Controller, {
|
|
853
|
-
control: formControl.control,
|
|
854
|
-
name: formControl.name,
|
|
855
|
-
render: t2
|
|
856
|
-
});
|
|
857
|
-
$[20] = formControl.control;
|
|
858
|
-
$[21] = formControl.name;
|
|
859
|
-
$[22] = t2;
|
|
860
|
-
$[23] = t3;
|
|
861
|
-
} else t3 = $[23];
|
|
862
|
-
return t3;
|
|
863
|
-
}
|
|
864
|
-
let t2;
|
|
865
|
-
if ($[24] !== fullIso || $[25] !== maxValue || $[26] !== minValue || $[27] !== props || $[28] !== renderStaticInput) {
|
|
866
|
-
t2 = /* @__PURE__ */ jsx(DateRangePickerInner, {
|
|
867
|
-
...props,
|
|
868
|
-
fullIso,
|
|
869
|
-
minValue,
|
|
870
|
-
maxValue,
|
|
871
|
-
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
|
+
})
|
|
872
670
|
});
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
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
|
+
});
|
|
881
678
|
};
|
|
882
|
-
function _temp(input) {
|
|
883
|
-
const container = input.getContainer?.() ?? input;
|
|
884
|
-
return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
|
|
885
|
-
}
|
|
886
|
-
function _temp2() {}
|
|
887
679
|
//#endregion
|
|
888
680
|
export { DateRangePicker };
|