@povio/ui 2.3.0-rc.9 → 2.3.1
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/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.js +35 -172
- 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 -10
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +20 -121
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +5 -10
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +111 -215
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +5 -11
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +19 -123
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -5
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +104 -448
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +2 -5
- package/dist/components/inputs/DateTime/shared/Calendar.js +119 -330
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +102 -283
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +33 -142
- 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 -296
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -6
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +136 -355
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +0 -14
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +11 -97
- 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 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +65 -207
- 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 +88 -334
- 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 +79 -319
- 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 -16
- package/dist/components/inputs/Inputs/InputItem.js +14 -71
- package/dist/components/inputs/Inputs/Inputs.js +11 -37
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +60 -352
- 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 +7 -109
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +8 -34
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -7
- package/dist/components/inputs/Selection/Select/Select.js +5 -132
- 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 -338
- 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 +34 -57
- 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.js +74 -250
- 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.js +37 -189
- 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 +13 -79
- 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 +49 -98
- 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 -16
- package/dist/config/uiConfig.context.js +13 -56
- 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 +3 -5
- package/dist/tw-ui-plugin.js +0 -2
- package/dist/utils/date-time.utils.d.ts +10 -31
- package/dist/utils/date-time.utils.js +22 -123
- package/dist/utils/dom.utils.js +1 -1
- package/package.json +1 -1
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +0 -4
- 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 -6
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +0 -21
- 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 -31
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +0 -80
- 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 -479
- 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 -122
- 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 -6
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -13
- 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 -79
- package/dist/components/inputs/Skeleton/InputFrame.js +0 -526
- package/dist/components/inputs/shared/StaticInput.d.ts +0 -38
- 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,19 +1,12 @@
|
|
|
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
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
12
|
import { clsx } from "clsx";
|
|
@@ -22,7 +15,7 @@ import { Button } from "react-aria-components";
|
|
|
22
15
|
import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
|
|
23
16
|
import { mergeRefs } from "@react-aria/utils";
|
|
24
17
|
import { useTranslation } from "react-i18next";
|
|
25
|
-
import { Controller
|
|
18
|
+
import { Controller } from "react-hook-form";
|
|
26
19
|
import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
|
|
27
20
|
import { DateTime } from "luxon";
|
|
28
21
|
import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
@@ -30,18 +23,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
30
23
|
var DateRangePickerBase = (props) => {
|
|
31
24
|
const ui = UIConfig.useConfig();
|
|
32
25
|
const { t } = useTranslation();
|
|
33
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange,
|
|
34
|
-
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
35
|
-
const variant = variantProp ?? ui.input.variant;
|
|
36
|
-
const as = asProp ?? ui.input.as;
|
|
37
|
-
const size = sizeProp ?? ui.input.size;
|
|
38
|
-
const isClearable = isClearableProp ?? ui.input.isClearable;
|
|
39
|
-
const todayIcon = todayIconProp ?? ui.dateInput.todayIcon;
|
|
40
|
-
const todayIconButtonSize = todayIconButtonSizeProp ?? ui.dateInput.todayIconButtonSize;
|
|
41
|
-
const todayIconPlacement = todayIconPlacementProp ?? ui.dateInput.todayIconPlacement;
|
|
42
|
-
const shouldForceLeadingZeros = shouldForceLeadingZerosProp ?? ui.dateInput.shouldForceLeadingZeros;
|
|
43
|
-
const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
|
|
44
|
-
const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
|
|
26
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
45
27
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
46
28
|
const datePickerInputRef = useRef(null);
|
|
47
29
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -61,7 +43,6 @@ var DateRangePickerBase = (props) => {
|
|
|
61
43
|
if (isValidRange(newValue)) return;
|
|
62
44
|
onChange?.(newValue);
|
|
63
45
|
handleCalendarStatesChange(newValue);
|
|
64
|
-
debouncedBlur(newValue);
|
|
65
46
|
},
|
|
66
47
|
shouldCloseOnSelect: false
|
|
67
48
|
});
|
|
@@ -76,16 +57,9 @@ var DateRangePickerBase = (props) => {
|
|
|
76
57
|
shouldForceLeadingZeros
|
|
77
58
|
}, dialogState, dateRangePickerRef);
|
|
78
59
|
const { locale } = useLocale$1();
|
|
79
|
-
useImperativeHandle(ref, () => ({
|
|
80
|
-
clear
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
|
|
84
|
-
}));
|
|
85
|
-
const handleBlur = (newValue_0) => {
|
|
86
|
-
onBlur?.({ target: { value: newValue_0 } });
|
|
87
|
-
};
|
|
88
|
-
const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
|
|
60
|
+
useImperativeHandle(ref, () => ({ clear: () => {
|
|
61
|
+
datePickerInputRef.current?.clear();
|
|
62
|
+
} }));
|
|
89
63
|
const formFieldProps = {
|
|
90
64
|
error: error || validationRangeError,
|
|
91
65
|
label,
|
|
@@ -136,10 +110,10 @@ var DateRangePickerBase = (props) => {
|
|
|
136
110
|
className: headerClassName,
|
|
137
111
|
labelProps
|
|
138
112
|
};
|
|
139
|
-
const isValidRange = useCallback((
|
|
140
|
-
if (
|
|
141
|
-
const startDate =
|
|
142
|
-
if (
|
|
113
|
+
const isValidRange = useCallback((newValue) => {
|
|
114
|
+
if (newValue?.start && newValue?.end) {
|
|
115
|
+
const startDate = newValue.start;
|
|
116
|
+
if (newValue.end.compare(startDate) < 0) {
|
|
143
117
|
setValidationRangeError(t(($) => $.ui.datePicker.errors.endDateBeforeStart, { ns: "ui" }));
|
|
144
118
|
return true;
|
|
145
119
|
}
|
|
@@ -147,20 +121,20 @@ var DateRangePickerBase = (props) => {
|
|
|
147
121
|
} else setValidationRangeError(void 0);
|
|
148
122
|
return false;
|
|
149
123
|
}, [t]);
|
|
150
|
-
const handleCalendarStatesChange = (
|
|
151
|
-
if (
|
|
152
|
-
if (isValidRange(
|
|
153
|
-
dialogState.setValue(
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
leftCalendarState.setFocusedDate(
|
|
157
|
-
if (
|
|
158
|
-
else rightCalendarState.setFocusedDate(
|
|
159
|
-
leftCalendarState.setValue(
|
|
160
|
-
rightCalendarState.setValue(
|
|
124
|
+
const handleCalendarStatesChange = (newValue) => {
|
|
125
|
+
if (newValue) {
|
|
126
|
+
if (isValidRange(newValue)) return;
|
|
127
|
+
dialogState.setValue(newValue);
|
|
128
|
+
const startDate = newValue.start;
|
|
129
|
+
const endDate = newValue.end;
|
|
130
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
131
|
+
if (startDate.year === endDate.year && startDate.month === endDate.month) rightCalendarState.setFocusedDate(startDate.add({ months: 1 }));
|
|
132
|
+
else rightCalendarState.setFocusedDate(endDate);
|
|
133
|
+
leftCalendarState.setValue(newValue);
|
|
134
|
+
rightCalendarState.setValue(newValue);
|
|
161
135
|
setRangeSelection({
|
|
162
|
-
start:
|
|
163
|
-
end:
|
|
136
|
+
start: newValue.start,
|
|
137
|
+
end: newValue.end,
|
|
164
138
|
isSelecting: false
|
|
165
139
|
});
|
|
166
140
|
setHoverDate(null);
|
|
@@ -184,27 +158,27 @@ var DateRangePickerBase = (props) => {
|
|
|
184
158
|
setHoverDate(date);
|
|
185
159
|
});
|
|
186
160
|
}, []);
|
|
187
|
-
const handleDateHover = useCallback((
|
|
188
|
-
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(
|
|
161
|
+
const handleDateHover = useCallback((date) => {
|
|
162
|
+
if (rangeSelection.isSelecting && rangeSelection.start) throttledSetHoverDate(date);
|
|
189
163
|
}, [
|
|
190
164
|
rangeSelection.isSelecting,
|
|
191
165
|
rangeSelection.start,
|
|
192
166
|
throttledSetHoverDate
|
|
193
167
|
]);
|
|
194
|
-
const handleDateSelection = useCallback((
|
|
168
|
+
const handleDateSelection = useCallback((date, calendarSide) => {
|
|
195
169
|
if (calendarSide) {
|
|
196
170
|
const currentVisibleMonth = (calendarSide === "left" ? leftCalendarState : rightCalendarState).visibleRange.start;
|
|
197
|
-
if (
|
|
198
|
-
leftCalendarState.setFocusedDate(
|
|
199
|
-
rightCalendarState.setFocusedDate(
|
|
171
|
+
if (date.month !== currentVisibleMonth.month || date.year !== currentVisibleMonth.year) if (calendarSide === "left") {
|
|
172
|
+
leftCalendarState.setFocusedDate(date);
|
|
173
|
+
rightCalendarState.setFocusedDate(date.add({ months: 1 }));
|
|
200
174
|
} else {
|
|
201
|
-
rightCalendarState.setFocusedDate(
|
|
202
|
-
leftCalendarState.setFocusedDate(
|
|
175
|
+
rightCalendarState.setFocusedDate(date);
|
|
176
|
+
leftCalendarState.setFocusedDate(date.subtract({ months: 1 }));
|
|
203
177
|
}
|
|
204
178
|
}
|
|
205
179
|
if (!rangeSelection.isSelecting || !rangeSelection.start) {
|
|
206
180
|
setRangeSelection({
|
|
207
|
-
start:
|
|
181
|
+
start: date,
|
|
208
182
|
end: null,
|
|
209
183
|
isSelecting: true
|
|
210
184
|
});
|
|
@@ -213,7 +187,7 @@ var DateRangePickerBase = (props) => {
|
|
|
213
187
|
rightCalendarState.setValue(null);
|
|
214
188
|
} else {
|
|
215
189
|
const { start } = rangeSelection;
|
|
216
|
-
const end =
|
|
190
|
+
const end = date;
|
|
217
191
|
const finalStart = start.compare(end) <= 0 ? start : end;
|
|
218
192
|
const finalEnd = start.compare(end) <= 0 ? end : start;
|
|
219
193
|
const newRange = {
|
|
@@ -237,16 +211,16 @@ var DateRangePickerBase = (props) => {
|
|
|
237
211
|
rightCalendarState,
|
|
238
212
|
dialogState
|
|
239
213
|
]);
|
|
240
|
-
const handleKeyboardNavigation = useCallback((event,
|
|
241
|
-
const
|
|
242
|
-
const otherState =
|
|
214
|
+
const handleKeyboardNavigation = useCallback((event, date, calendarSide) => {
|
|
215
|
+
const currentState = calendarSide === "left" ? leftCalendarState : rightCalendarState;
|
|
216
|
+
const otherState = calendarSide === "left" ? rightCalendarState : leftCalendarState;
|
|
243
217
|
let shouldPreventDefault = false;
|
|
244
218
|
switch (event.key) {
|
|
245
219
|
case "ArrowRight": {
|
|
246
|
-
const nextDate =
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
220
|
+
const nextDate = date.add({ days: 1 });
|
|
221
|
+
const currentMonth = currentState.visibleRange.start;
|
|
222
|
+
const otherMonth = otherState.visibleRange.start;
|
|
223
|
+
if (calendarSide === "left" && nextDate.month !== currentMonth.month) if (nextDate.year === otherMonth.year && nextDate.month === otherMonth.month) {
|
|
250
224
|
otherState.setFocusedDate(nextDate);
|
|
251
225
|
shouldPreventDefault = true;
|
|
252
226
|
} else {
|
|
@@ -256,10 +230,10 @@ var DateRangePickerBase = (props) => {
|
|
|
256
230
|
break;
|
|
257
231
|
}
|
|
258
232
|
case "ArrowLeft": {
|
|
259
|
-
const prevDate =
|
|
260
|
-
const
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
233
|
+
const prevDate = date.subtract({ days: 1 });
|
|
234
|
+
const currentMonth = currentState.visibleRange.start;
|
|
235
|
+
const otherMonth = otherState.visibleRange.start;
|
|
236
|
+
if (calendarSide === "right" && prevDate.month !== currentMonth.month) if (prevDate.year === otherMonth.year && prevDate.month === otherMonth.month) {
|
|
263
237
|
otherState.setFocusedDate(prevDate);
|
|
264
238
|
shouldPreventDefault = true;
|
|
265
239
|
} else {
|
|
@@ -269,10 +243,10 @@ var DateRangePickerBase = (props) => {
|
|
|
269
243
|
break;
|
|
270
244
|
}
|
|
271
245
|
case "ArrowDown": {
|
|
272
|
-
const nextWeekDate =
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
246
|
+
const nextWeekDate = date.add({ weeks: 1 });
|
|
247
|
+
const currentMonth = currentState.visibleRange.start;
|
|
248
|
+
const otherMonth = otherState.visibleRange.start;
|
|
249
|
+
if (calendarSide === "left" && nextWeekDate.month !== currentMonth.month) if (nextWeekDate.year === otherMonth.year && nextWeekDate.month === otherMonth.month) {
|
|
276
250
|
otherState.setFocusedDate(nextWeekDate);
|
|
277
251
|
shouldPreventDefault = true;
|
|
278
252
|
} else {
|
|
@@ -282,10 +256,10 @@ var DateRangePickerBase = (props) => {
|
|
|
282
256
|
break;
|
|
283
257
|
}
|
|
284
258
|
case "ArrowUp": {
|
|
285
|
-
const prevWeekDate =
|
|
286
|
-
const currentMonth =
|
|
259
|
+
const prevWeekDate = date.subtract({ weeks: 1 });
|
|
260
|
+
const currentMonth = currentState.visibleRange.start;
|
|
287
261
|
const otherMonth = otherState.visibleRange.start;
|
|
288
|
-
if (
|
|
262
|
+
if (calendarSide === "right" && prevWeekDate.month !== currentMonth.month) if (prevWeekDate.year === otherMonth.year && prevWeekDate.month === otherMonth.month) {
|
|
289
263
|
otherState.setFocusedDate(prevWeekDate);
|
|
290
264
|
shouldPreventDefault = true;
|
|
291
265
|
} else {
|
|
@@ -296,7 +270,7 @@ var DateRangePickerBase = (props) => {
|
|
|
296
270
|
}
|
|
297
271
|
case "Enter":
|
|
298
272
|
case " ":
|
|
299
|
-
handleDateSelection(
|
|
273
|
+
handleDateSelection(date);
|
|
300
274
|
shouldPreventDefault = true;
|
|
301
275
|
break;
|
|
302
276
|
case "Escape":
|
|
@@ -320,14 +294,14 @@ var DateRangePickerBase = (props) => {
|
|
|
320
294
|
rightCalendarState,
|
|
321
295
|
handleDateSelection
|
|
322
296
|
]);
|
|
323
|
-
const syncCalendarStates = useCallback((
|
|
324
|
-
if (isValidRange(
|
|
325
|
-
leftCalendarState.setValue(
|
|
326
|
-
rightCalendarState.setValue(
|
|
327
|
-
dialogState.setValue(
|
|
328
|
-
if (
|
|
329
|
-
start:
|
|
330
|
-
end:
|
|
297
|
+
const syncCalendarStates = useCallback((newValue) => {
|
|
298
|
+
if (isValidRange(newValue)) return;
|
|
299
|
+
leftCalendarState.setValue(newValue);
|
|
300
|
+
rightCalendarState.setValue(newValue);
|
|
301
|
+
dialogState.setValue(newValue);
|
|
302
|
+
if (newValue) setRangeSelection({
|
|
303
|
+
start: newValue.start,
|
|
304
|
+
end: newValue.end,
|
|
331
305
|
isSelecting: false
|
|
332
306
|
});
|
|
333
307
|
else setRangeSelection({
|
|
@@ -347,10 +321,7 @@ var DateRangePickerBase = (props) => {
|
|
|
347
321
|
start: rangeSelection.start,
|
|
348
322
|
end: rangeSelection.end
|
|
349
323
|
} : dialogState.value;
|
|
350
|
-
if (valueToApply)
|
|
351
|
-
state.setValue(valueToApply);
|
|
352
|
-
handleBlur(valueToApply);
|
|
353
|
-
}
|
|
324
|
+
if (valueToApply) state.setValue(valueToApply);
|
|
354
325
|
state.toggle();
|
|
355
326
|
};
|
|
356
327
|
const onTodayPress = () => {
|
|
@@ -369,11 +340,11 @@ var DateRangePickerBase = (props) => {
|
|
|
369
340
|
dialogState.setValue(state.value);
|
|
370
341
|
leftCalendarState.setValue(state.value);
|
|
371
342
|
rightCalendarState.setValue(state.value);
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
leftCalendarState.setFocusedDate(
|
|
375
|
-
if (
|
|
376
|
-
else rightCalendarState.setFocusedDate(
|
|
343
|
+
const startDate = state.value.start || today(getLocalTimeZone());
|
|
344
|
+
const endDate = state.value.end || today(getLocalTimeZone()).add({ months: 1 });
|
|
345
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
346
|
+
if (startDate.year === endDate.year && startDate.month === endDate.month) rightCalendarState.setFocusedDate(startDate.add({ months: 1 }));
|
|
347
|
+
else rightCalendarState.setFocusedDate(endDate);
|
|
377
348
|
setRangeSelection({
|
|
378
349
|
start: state.value.start,
|
|
379
350
|
end: state.value.end,
|
|
@@ -382,87 +353,87 @@ var DateRangePickerBase = (props) => {
|
|
|
382
353
|
}
|
|
383
354
|
}
|
|
384
355
|
};
|
|
385
|
-
const
|
|
356
|
+
const todayDate = today(getLocalTimeZone());
|
|
386
357
|
const getThisWeekRange = () => {
|
|
387
358
|
return {
|
|
388
|
-
start: startOfWeek(
|
|
389
|
-
end: endOfWeek(
|
|
359
|
+
start: startOfWeek(todayDate, locale),
|
|
360
|
+
end: endOfWeek(todayDate, locale)
|
|
390
361
|
};
|
|
391
362
|
};
|
|
392
363
|
const getLastWeekRange = () => {
|
|
393
|
-
const thisWeekStart = startOfWeek(
|
|
364
|
+
const thisWeekStart = startOfWeek(todayDate, locale);
|
|
394
365
|
return {
|
|
395
366
|
start: thisWeekStart.subtract({ weeks: 1 }),
|
|
396
367
|
end: thisWeekStart.subtract({ days: 1 })
|
|
397
368
|
};
|
|
398
369
|
};
|
|
399
370
|
const getThisAndLastWeekRange = () => {
|
|
400
|
-
const thisWeekEnd = endOfWeek(
|
|
371
|
+
const thisWeekEnd = endOfWeek(todayDate, locale);
|
|
401
372
|
return {
|
|
402
|
-
start: startOfWeek(
|
|
373
|
+
start: startOfWeek(todayDate, locale).subtract({ weeks: 1 }),
|
|
403
374
|
end: thisWeekEnd
|
|
404
375
|
};
|
|
405
376
|
};
|
|
406
377
|
const getThisMonthRange = () => {
|
|
407
378
|
return {
|
|
408
|
-
start: startOfMonth(
|
|
409
|
-
end: endOfMonth(
|
|
379
|
+
start: startOfMonth(todayDate),
|
|
380
|
+
end: endOfMonth(todayDate)
|
|
410
381
|
};
|
|
411
382
|
};
|
|
412
383
|
const getThisAndLastMonthRange = () => {
|
|
413
|
-
const thisMonthEnd = endOfMonth(
|
|
384
|
+
const thisMonthEnd = endOfMonth(todayDate);
|
|
414
385
|
return {
|
|
415
|
-
start: startOfMonth(
|
|
386
|
+
start: startOfMonth(todayDate).subtract({ months: 1 }),
|
|
416
387
|
end: thisMonthEnd
|
|
417
388
|
};
|
|
418
389
|
};
|
|
419
390
|
const presets = [
|
|
420
391
|
{
|
|
421
|
-
label: t(($
|
|
392
|
+
label: t(($) => $.ui.datePicker.presets.thisWeek, { ns: "ui" }),
|
|
422
393
|
getValue: getThisWeekRange
|
|
423
394
|
},
|
|
424
395
|
{
|
|
425
|
-
label: t(($
|
|
396
|
+
label: t(($) => $.ui.datePicker.presets.lastWeek, { ns: "ui" }),
|
|
426
397
|
getValue: getLastWeekRange
|
|
427
398
|
},
|
|
428
399
|
{
|
|
429
|
-
label: t(($
|
|
400
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastWeek, { ns: "ui" }),
|
|
430
401
|
getValue: getThisAndLastWeekRange
|
|
431
402
|
},
|
|
432
403
|
{
|
|
433
|
-
label: t(($
|
|
404
|
+
label: t(($) => $.ui.datePicker.presets.thisMonth, { ns: "ui" }),
|
|
434
405
|
getValue: getThisMonthRange
|
|
435
406
|
},
|
|
436
407
|
{
|
|
437
|
-
label: t(($
|
|
408
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastMonth, { ns: "ui" }),
|
|
438
409
|
getValue: getThisAndLastMonthRange
|
|
439
410
|
},
|
|
440
411
|
{
|
|
441
|
-
label: t(($
|
|
412
|
+
label: t(($) => $.ui.datePicker.presets.thisYear, { ns: "ui" }),
|
|
442
413
|
getValue: () => ({
|
|
443
|
-
start: startOfYear(
|
|
444
|
-
end:
|
|
414
|
+
start: startOfYear(todayDate),
|
|
415
|
+
end: todayDate
|
|
445
416
|
})
|
|
446
417
|
},
|
|
447
418
|
{
|
|
448
|
-
label: t(($
|
|
419
|
+
label: t(($) => $.ui.datePicker.presets.lastYear, { ns: "ui" }),
|
|
449
420
|
getValue: () => ({
|
|
450
|
-
start: startOfYear(
|
|
451
|
-
end: endOfYear(
|
|
421
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
422
|
+
end: endOfYear(todayDate.subtract({ years: 1 }))
|
|
452
423
|
})
|
|
453
424
|
},
|
|
454
425
|
{
|
|
455
|
-
label: t(($
|
|
426
|
+
label: t(($) => $.ui.datePicker.presets.thisAndLastYear, { ns: "ui" }),
|
|
456
427
|
getValue: () => ({
|
|
457
|
-
start: startOfYear(
|
|
458
|
-
end:
|
|
428
|
+
start: startOfYear(todayDate.subtract({ years: 1 })),
|
|
429
|
+
end: todayDate
|
|
459
430
|
})
|
|
460
431
|
},
|
|
461
432
|
{
|
|
462
|
-
label: t(($
|
|
433
|
+
label: t(($) => $.ui.datePicker.presets.soFar, { ns: "ui" }),
|
|
463
434
|
getValue: () => ({
|
|
464
|
-
start: startOfYear(
|
|
465
|
-
end:
|
|
435
|
+
start: startOfYear(todayDate),
|
|
436
|
+
end: todayDate
|
|
466
437
|
})
|
|
467
438
|
}
|
|
468
439
|
];
|
|
@@ -470,12 +441,12 @@ var DateRangePickerBase = (props) => {
|
|
|
470
441
|
setActivePreset(preset.label);
|
|
471
442
|
const presetValue = preset.getValue();
|
|
472
443
|
syncCalendarStates(presetValue);
|
|
473
|
-
const
|
|
474
|
-
leftCalendarState.setFocusedDate(
|
|
475
|
-
const
|
|
476
|
-
if ((
|
|
444
|
+
const startDate = presetValue.start;
|
|
445
|
+
leftCalendarState.setFocusedDate(startDate);
|
|
446
|
+
const endDate = presetValue.end;
|
|
447
|
+
if ((endDate.year - startDate.year) * 12 + (endDate.month - startDate.month) > 2) rightCalendarState.setFocusedDate(endDate);
|
|
477
448
|
else {
|
|
478
|
-
const rightCalendarMonth =
|
|
449
|
+
const rightCalendarMonth = startDate.add({ months: 1 });
|
|
479
450
|
rightCalendarState.setFocusedDate(rightCalendarMonth);
|
|
480
451
|
}
|
|
481
452
|
};
|
|
@@ -504,29 +475,27 @@ var DateRangePickerBase = (props) => {
|
|
|
504
475
|
isClearable,
|
|
505
476
|
headerProps,
|
|
506
477
|
todayIcon,
|
|
507
|
-
todayIconButtonSize,
|
|
508
|
-
todayIconPlacement,
|
|
509
478
|
isDirty,
|
|
510
479
|
disableManualEntry,
|
|
511
|
-
autoFixYear,
|
|
512
480
|
placeholder,
|
|
513
481
|
className: inputClassName,
|
|
514
|
-
onOpenDropdown: () => state.toggle()
|
|
482
|
+
onOpenDropdown: () => state.toggle(),
|
|
483
|
+
autoFixYear
|
|
515
484
|
}), /* @__PURE__ */ jsx(DateTimeDialog, {
|
|
516
485
|
hideSidebar,
|
|
517
486
|
sidebar: /* @__PURE__ */ jsx("div", {
|
|
518
487
|
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",
|
|
519
|
-
children: presets.map((
|
|
520
|
-
onClick: () => selectPreset(
|
|
521
|
-
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item", activePreset !==
|
|
488
|
+
children: presets.map((preset) => /* @__PURE__ */ jsx(Button, {
|
|
489
|
+
onClick: () => selectPreset(preset),
|
|
490
|
+
className: clsx("w-full px-2 py-1 text-left md:px-list-side-item-left md:py-list-height-item", 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"),
|
|
522
491
|
children: /* @__PURE__ */ jsx(Typography, {
|
|
523
492
|
size: "label-2",
|
|
524
493
|
sizeMobile: "label-3",
|
|
525
494
|
as: "span",
|
|
526
495
|
className: "whitespace-nowrap",
|
|
527
|
-
children:
|
|
496
|
+
children: preset.label
|
|
528
497
|
})
|
|
529
|
-
},
|
|
498
|
+
}, preset.label))
|
|
530
499
|
}),
|
|
531
500
|
footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
|
|
532
501
|
isDisabled,
|
|
@@ -561,29 +530,7 @@ var DateRangePickerBase = (props) => {
|
|
|
561
530
|
})
|
|
562
531
|
});
|
|
563
532
|
};
|
|
564
|
-
var DateRangePicker = ({ fullIso = true, minValue, maxValue,
|
|
565
|
-
const ui = UIConfig.useConfig();
|
|
566
|
-
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
567
|
-
const { locale } = useLocale$1();
|
|
568
|
-
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
569
|
-
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
570
|
-
const inputRef = useRef(null);
|
|
571
|
-
const { renderRealInput } = useStaticInputHandoff({
|
|
572
|
-
inputRef,
|
|
573
|
-
renderInput,
|
|
574
|
-
setRenderInput,
|
|
575
|
-
getFocusTarget: (input) => {
|
|
576
|
-
const container = input.getContainer?.() ?? input;
|
|
577
|
-
return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
581
|
-
control: props.formControl.control,
|
|
582
|
-
name: props.formControl.name
|
|
583
|
-
}) : props.value;
|
|
584
|
-
let isFormControlDisabled = false;
|
|
585
|
-
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
586
|
-
const rawValue = watchedValue ?? props.value ?? null;
|
|
533
|
+
var DateRangePicker = ({ fullIso = true, minValue, maxValue, ...props }) => {
|
|
587
534
|
const formatDateRange = (range) => {
|
|
588
535
|
if (!range?.start || !range?.end) return null;
|
|
589
536
|
if (fullIso) return {
|
|
@@ -603,10 +550,10 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
603
550
|
start: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.start),
|
|
604
551
|
end: DateTimeUtils.fromUTCISOToCalendarDate(formattedRange.end)
|
|
605
552
|
};
|
|
606
|
-
const
|
|
607
|
-
const
|
|
608
|
-
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(
|
|
609
|
-
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(
|
|
553
|
+
const startDate = DateTime.fromISO(formattedRange.start).toJSDate();
|
|
554
|
+
const endDate = DateTime.fromISO(formattedRange.end).toJSDate();
|
|
555
|
+
const startZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(startDate);
|
|
556
|
+
const endZonedDateTime = DateTimeUtils.fromLocalToZonedDateTime(endDate);
|
|
610
557
|
return {
|
|
611
558
|
start: toCalendarDate(startZonedDateTime),
|
|
612
559
|
end: toCalendarDate(endZonedDateTime)
|
|
@@ -622,56 +569,6 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
622
569
|
minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
|
|
623
570
|
maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
|
|
624
571
|
};
|
|
625
|
-
if (!renderInput) {
|
|
626
|
-
const startDateValue = parseCalendarDate(rawValue?.start ?? null);
|
|
627
|
-
const endDateValue = parseCalendarDate(rawValue?.end ?? null);
|
|
628
|
-
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
629
|
-
const as = props.as ?? ui.input.as;
|
|
630
|
-
const size = props.size ?? ui.input.size;
|
|
631
|
-
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
632
|
-
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
633
|
-
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
634
|
-
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
635
|
-
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
636
|
-
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
637
|
-
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
638
|
-
const staticSegments = getStaticDateRangeSegments({
|
|
639
|
-
start: startDateValue,
|
|
640
|
-
end: endDateValue,
|
|
641
|
-
locale,
|
|
642
|
-
shouldForceLeadingZeros,
|
|
643
|
-
isDisabled,
|
|
644
|
-
hidePlaceholder: as === "floating" && !hasProvidedRangeValue
|
|
645
|
-
});
|
|
646
|
-
return /* @__PURE__ */ jsx(InputFrame, {
|
|
647
|
-
...props,
|
|
648
|
-
isDisabled,
|
|
649
|
-
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
650
|
-
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
651
|
-
contentClassName: "pr-0!",
|
|
652
|
-
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
653
|
-
labelPlacement: "content-row",
|
|
654
|
-
dataAttributes: {
|
|
655
|
-
dataIsEmpty: !hasProvidedRangeValue,
|
|
656
|
-
dataIsFilled: hasProvidedRangeValue,
|
|
657
|
-
dataIsDirty: props.isDirty,
|
|
658
|
-
dataIsRequired: props.isRequired,
|
|
659
|
-
dataIsDisabled: isDisabled,
|
|
660
|
-
dataDisabled: isDisabled,
|
|
661
|
-
dataInvalid: !!props.error,
|
|
662
|
-
dataHasSelection: hasProvidedRangeValue
|
|
663
|
-
},
|
|
664
|
-
renderStatic: true,
|
|
665
|
-
onStaticInteract: renderRealInput,
|
|
666
|
-
actionContent: staticTodayIcon,
|
|
667
|
-
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
668
|
-
wrapContentAndTrailing: true,
|
|
669
|
-
contentAndTrailingClassName: "gap-2!",
|
|
670
|
-
trailingClassName: "py-0! pl-0!",
|
|
671
|
-
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
672
|
-
children: staticSegments
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
572
|
if ("formControl" in props && props.formControl) {
|
|
676
573
|
const { formControl, ref, ...innerProps } = props;
|
|
677
574
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -680,7 +577,7 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
680
577
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
681
578
|
...innerProps,
|
|
682
579
|
...dateLimits,
|
|
683
|
-
ref: mergeRefs(ref, field.ref
|
|
580
|
+
ref: mergeRefs(ref, field.ref),
|
|
684
581
|
value: parseDateRange(field.value),
|
|
685
582
|
onChange: (value) => field.onChange(formatDateRange(value)),
|
|
686
583
|
onBlur: field.onBlur,
|
|
@@ -693,9 +590,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
693
590
|
return /* @__PURE__ */ jsx(DateRangePickerBase, {
|
|
694
591
|
...props,
|
|
695
592
|
...dateLimits,
|
|
696
|
-
ref: mergeRefs(props.ref, inputRef),
|
|
697
593
|
value: parseDateRange(props.value),
|
|
698
|
-
onChange: (
|
|
594
|
+
onChange: (value) => props.onChange?.(formatDateRange(value))
|
|
699
595
|
});
|
|
700
596
|
};
|
|
701
597
|
//#endregion
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'react';
|
|
2
2
|
import { DateValue } from 'react-aria';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
7
6
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
7
|
import { ControlProps } from '../../shared/form.types';
|
|
9
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
10
|
-
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"
|
|
9
|
+
interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
|
|
11
10
|
ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
|
|
12
11
|
disableDropdown?: boolean;
|
|
13
12
|
isTimeOptional?: boolean;
|
|
14
13
|
isClearable?: boolean;
|
|
15
|
-
todayIcon?:
|
|
16
|
-
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
-
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
14
|
+
todayIcon?: boolean;
|
|
18
15
|
isDirty?: boolean;
|
|
19
16
|
disableManualEntry?: boolean;
|
|
20
|
-
autoFixYear?: boolean;
|
|
21
|
-
setDateValueOnDateSelection?: boolean;
|
|
22
17
|
placeholder?: string;
|
|
23
18
|
inputClassName?: string;
|
|
24
19
|
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
25
20
|
timeZone?: string;
|
|
21
|
+
autoFixYear?: boolean;
|
|
26
22
|
format?: string;
|
|
27
|
-
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
28
23
|
}
|
|
29
24
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
30
25
|
value?: string | null;
|
|
31
26
|
onChange?: (value: string | null) => void;
|
|
32
27
|
fullIso?: boolean;
|
|
33
|
-
renderStaticInput?: boolean;
|
|
34
28
|
timeZone?: string;
|
|
35
29
|
}
|
|
36
30
|
export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
|
|
37
|
-
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso,
|
|
31
|
+
export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
38
32
|
export {};
|