@mezzanine-ui/react 0.16.0 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion/AccordionControlContext.js +1 -0
- package/Accordion/AccordionDetails.js +1 -0
- package/Accordion/AccordionSummary.js +10 -10
- package/Accordion/index.d.ts +6 -3
- package/Alert/index.d.ts +3 -2
- package/AlertBanner/AlertBanner.d.ts +93 -0
- package/AlertBanner/AlertBanner.js +154 -0
- package/AlertBanner/index.d.ts +2 -0
- package/AlertBanner/index.js +1 -0
- package/Anchor/Anchor.js +1 -1
- package/Anchor/index.d.ts +2 -1
- package/AppBar/index.d.ts +8 -4
- package/{Overlay/Overlay.d.ts → Backdrop/Backdrop.d.ts} +12 -16
- package/Backdrop/Backdrop.js +40 -0
- package/Backdrop/index.d.ts +2 -0
- package/Backdrop/index.js +1 -0
- package/Badge/Badge.d.ts +20 -14
- package/Badge/Badge.js +14 -16
- package/Badge/BadgeContainer.d.ts +1 -1
- package/Badge/BadgeContainer.js +1 -1
- package/Badge/index.d.ts +3 -2
- package/Badge/typings.d.ts +48 -0
- package/Breadcrumb/Breadcrumb.d.ts +6 -0
- package/Breadcrumb/Breadcrumb.js +25 -0
- package/Breadcrumb/BreadcrumbItem.d.ts +4 -0
- package/Breadcrumb/BreadcrumbItem.js +45 -0
- package/Breadcrumb/index.d.ts +2 -0
- package/Breadcrumb/index.js +1 -0
- package/Breadcrumb/typings.d.ts +70 -0
- package/Button/Button.js +24 -19
- package/Button/ButtonGroup.d.ts +6 -28
- package/Button/ButtonGroup.js +7 -16
- package/Button/index.d.ts +4 -10
- package/Button/index.js +2 -3
- package/Button/typings.d.ts +11 -26
- package/Calendar/Calendar.d.ts +31 -2
- package/Calendar/Calendar.js +74 -19
- package/Calendar/CalendarCell.d.ts +4 -0
- package/Calendar/CalendarCell.js +3 -3
- package/Calendar/CalendarConfigProviderDayjs.d.ts +21 -0
- package/Calendar/CalendarConfigProviderDayjs.js +15 -0
- package/Calendar/CalendarConfigProviderLuxon.d.ts +21 -0
- package/Calendar/CalendarConfigProviderLuxon.js +15 -0
- package/Calendar/CalendarConfigProviderMoment.d.ts +21 -0
- package/Calendar/CalendarConfigProviderMoment.js +15 -0
- package/Calendar/CalendarContext.d.ts +14 -7
- package/Calendar/CalendarContext.js +8 -13
- package/Calendar/CalendarControls.d.ts +16 -0
- package/Calendar/CalendarControls.js +3 -7
- package/Calendar/CalendarDayOfWeek.js +4 -3
- package/Calendar/CalendarDays.d.ts +9 -1
- package/Calendar/CalendarDays.js +63 -38
- package/Calendar/CalendarFooterActions.d.ts +13 -0
- package/Calendar/CalendarFooterActions.js +14 -0
- package/Calendar/CalendarFooterControl.d.ts +16 -0
- package/Calendar/CalendarFooterControl.js +14 -0
- package/Calendar/CalendarHalfYears.d.ts +39 -0
- package/Calendar/CalendarHalfYears.js +62 -0
- package/Calendar/CalendarMonths.js +16 -4
- package/Calendar/CalendarQuarters.d.ts +37 -0
- package/Calendar/CalendarQuarters.js +64 -0
- package/Calendar/CalendarQuickSelect.d.ts +21 -0
- package/Calendar/CalendarQuickSelect.js +15 -0
- package/Calendar/CalendarWeeks.d.ts +1 -1
- package/Calendar/CalendarWeeks.js +89 -44
- package/Calendar/CalendarYears.js +13 -3
- package/Calendar/RangeCalendar.d.ts +59 -0
- package/Calendar/RangeCalendar.js +232 -0
- package/Calendar/index.d.ts +33 -10
- package/Calendar/index.js +7 -0
- package/Calendar/useCalendarControlModifiers.d.ts +4 -4
- package/Calendar/useCalendarControlModifiers.js +40 -8
- package/Calendar/useCalendarControls.d.ts +2 -0
- package/Calendar/useCalendarControls.js +19 -2
- package/Calendar/useCalendarModeStack.js +1 -0
- package/Calendar/useRangeCalendarControls.d.ts +18 -0
- package/Calendar/useRangeCalendarControls.js +115 -0
- package/Card/CardActions.js +1 -1
- package/Card/index.d.ts +4 -2
- package/Checkbox/CheckAll.d.ts +16 -6
- package/Checkbox/CheckAll.js +40 -26
- package/Checkbox/Checkbox.d.ts +100 -22
- package/Checkbox/Checkbox.js +73 -16
- package/Checkbox/CheckboxGroup.d.ts +100 -18
- package/Checkbox/CheckboxGroup.js +169 -24
- package/Checkbox/CheckboxGroupContext.d.ts +0 -2
- package/Checkbox/CheckboxGroupContext.js +1 -0
- package/Checkbox/index.d.ts +16 -4
- package/Checkbox/index.js +6 -2
- package/Checkbox/typings.d.ts +37 -0
- package/ClearActions/ClearActions.d.ts +41 -0
- package/ClearActions/ClearActions.js +23 -0
- package/ClearActions/index.d.ts +3 -0
- package/ClearActions/index.js +5 -0
- package/ConfirmActions/ConfirmActions.d.ts +2 -1
- package/ConfirmActions/index.d.ts +2 -1
- package/DatePicker/DatePicker.d.ts +12 -1
- package/DatePicker/DatePicker.js +41 -9
- package/DatePicker/DatePickerCalendar.d.ts +2 -5
- package/DatePicker/DatePickerCalendar.js +37 -37
- package/DatePicker/index.d.ts +4 -2
- package/DateRangePicker/DateRangePicker.d.ts +18 -2
- package/DateRangePicker/DateRangePicker.js +143 -100
- package/DateRangePicker/DateRangePickerCalendar.d.ts +13 -9
- package/DateRangePicker/DateRangePickerCalendar.js +7 -94
- package/DateRangePicker/index.d.ts +6 -3
- package/DateRangePicker/useDateRangeCalendarControls.js +11 -6
- package/DateRangePicker/useDateRangePickerValue.d.ts +38 -15
- package/DateRangePicker/useDateRangePickerValue.js +142 -63
- package/DateTimePicker/DateTimePicker.d.ts +31 -10
- package/DateTimePicker/DateTimePicker.js +179 -94
- package/DateTimePicker/index.d.ts +2 -2
- package/DateTimePicker/index.js +0 -1
- package/Drawer/Drawer.js +2 -2
- package/Drawer/index.d.ts +2 -1
- package/Dropdown/Dropdown.js +12 -22
- package/Dropdown/index.d.ts +2 -1
- package/Empty/Empty.d.ts +1 -16
- package/Empty/Empty.js +36 -7
- package/Empty/icons/EmptyMainInitialDataIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainInitialDataIcon.js +9 -0
- package/Empty/icons/EmptyMainResultIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainResultIcon.js +9 -0
- package/Empty/icons/EmptyMainSystemIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainSystemIcon.js +9 -0
- package/Empty/index.d.ts +2 -1
- package/Empty/typings.d.ts +52 -0
- package/Form/FormControlContext.js +1 -0
- package/Form/FormHintText.d.ts +18 -0
- package/Form/FormHintText.js +17 -0
- package/Form/FormLabel.js +1 -0
- package/Form/index.d.ts +9 -5
- package/Form/index.js +1 -1
- package/Form/useAutoCompleteValueControl.js +2 -0
- package/Form/useCheckboxControlValue.js +0 -1
- package/Form/useSelectValueControl.js +2 -0
- package/InlineMessage/InlineMessage.d.ts +33 -0
- package/InlineMessage/InlineMessage.js +42 -0
- package/InlineMessage/InlineMessageGroup.d.ts +24 -0
- package/InlineMessage/InlineMessageGroup.js +21 -0
- package/InlineMessage/index.d.ts +4 -0
- package/InlineMessage/index.js +2 -0
- package/Input/ActionButton/ActionButton.d.ts +26 -0
- package/Input/ActionButton/ActionButton.js +14 -0
- package/Input/ActionButton/index.d.ts +2 -0
- package/Input/ActionButton/index.js +1 -0
- package/Input/Input.d.ts +147 -42
- package/Input/Input.js +195 -27
- package/Input/PasswordStrengthIndicator/PasswordStrengthIndicator.d.ts +31 -0
- package/Input/PasswordStrengthIndicator/PasswordStrengthIndicator.js +18 -0
- package/Input/PasswordStrengthIndicator/index.d.ts +2 -0
- package/Input/PasswordStrengthIndicator/index.js +1 -0
- package/Input/SelectButton/SelectButton.d.ts +20 -0
- package/Input/SelectButton/SelectButton.js +21 -0
- package/Input/SelectButton/index.d.ts +2 -0
- package/Input/SelectButton/index.js +1 -0
- package/Input/SpinnerButton/SpinnerButton.d.ts +19 -0
- package/Input/SpinnerButton/SpinnerButton.js +14 -0
- package/Input/SpinnerButton/index.d.ts +2 -0
- package/Input/SpinnerButton/index.js +1 -0
- package/Input/index.d.ts +3 -2
- package/Menu/Menu.js +1 -0
- package/Menu/index.d.ts +8 -4
- package/Message/Message.d.ts +6 -4
- package/Message/Message.js +86 -9
- package/Message/MessageTimerController.d.ts +14 -0
- package/Message/MessageTimerController.js +27 -0
- package/Message/index.d.ts +3 -2
- package/Modal/Modal.js +2 -2
- package/Modal/ModalActions.js +1 -0
- package/Modal/ModalControl.js +1 -0
- package/Modal/ModalHeader.js +1 -0
- package/Modal/index.d.ts +10 -5
- package/Modal/useModalContainer.d.ts +1 -1
- package/Modal/useModalContainer.js +2 -4
- package/Navigation/Navigation.js +37 -34
- package/Navigation/NavigationContext.js +1 -0
- package/Navigation/NavigationItem.js +1 -0
- package/Navigation/NavigationSubMenu.js +16 -26
- package/Navigation/index.d.ts +8 -4
- package/Notification/Notification.js +0 -1
- package/Notification/index.d.ts +3 -2
- package/Notifier/NotifierManager.d.ts +15 -2
- package/Notifier/NotifierManager.js +60 -18
- package/Notifier/createNotifier.d.ts +9 -0
- package/Notifier/createNotifier.js +3 -2
- package/Notifier/typings.d.ts +3 -1
- package/OverflowTooltip/OverflowCounterTag.d.ts +12 -0
- package/OverflowTooltip/OverflowCounterTag.js +48 -0
- package/OverflowTooltip/OverflowTooltip.d.ts +34 -0
- package/OverflowTooltip/OverflowTooltip.js +53 -0
- package/OverflowTooltip/index.d.ts +2 -0
- package/OverflowTooltip/index.js +2 -0
- package/PageFooter/PageFooter.d.ts +73 -8
- package/PageFooter/PageFooter.js +34 -3
- package/PageFooter/index.d.ts +2 -1
- package/PageHeader/PageHeader.d.ts +36 -0
- package/PageHeader/PageHeader.js +65 -0
- package/PageHeader/index.d.ts +2 -0
- package/PageHeader/index.js +1 -0
- package/PageToolbar/PageToolbar.d.ts +67 -0
- package/PageToolbar/PageToolbar.js +114 -0
- package/PageToolbar/index.d.ts +2 -0
- package/PageToolbar/index.js +1 -0
- package/Pagination/Pagination.d.ts +23 -29
- package/Pagination/Pagination.js +3 -4
- package/Pagination/PaginationItem.d.ts +1 -1
- package/Pagination/PaginationItem.js +6 -3
- package/Pagination/PaginationJumper.d.ts +7 -9
- package/Pagination/PaginationJumper.js +3 -5
- package/Pagination/PaginationPageSize.d.ts +8 -11
- package/Pagination/PaginationPageSize.js +5 -4
- package/Pagination/index.d.ts +8 -4
- package/Pagination/usePagination.d.ts +3 -1
- package/Pagination/usePagination.js +30 -21
- package/Picker/FormattedInput.d.ts +17 -0
- package/Picker/FormattedInput.js +74 -0
- package/Picker/MaskFormat.d.ts +39 -0
- package/Picker/MaskFormat.js +94 -0
- package/Picker/PickerTrigger.d.ts +13 -3
- package/Picker/PickerTrigger.js +17 -2
- package/Picker/PickerTriggerWithSeparator.d.ts +124 -0
- package/Picker/PickerTriggerWithSeparator.js +80 -0
- package/Picker/RangePickerTrigger.d.ts +55 -4
- package/Picker/RangePickerTrigger.js +65 -7
- package/Picker/formatUtils.d.ts +34 -0
- package/Picker/formatUtils.js +124 -0
- package/Picker/index.d.ts +17 -6
- package/Picker/index.js +4 -1
- package/Picker/useDateInputFormatter.d.ts +52 -0
- package/Picker/useDateInputFormatter.js +382 -0
- package/Picker/usePickerValue.d.ts +1 -2
- package/Picker/usePickerValue.js +8 -13
- package/Popconfirm/Popconfirm.js +1 -1
- package/Popconfirm/index.d.ts +2 -1
- package/Popover/Popover.js +4 -8
- package/Popover/index.d.ts +2 -1
- package/Popper/Popper.d.ts +15 -10
- package/Popper/Popper.js +88 -17
- package/Popper/index.d.ts +2 -1
- package/Portal/Portal.d.ts +13 -5
- package/Portal/Portal.js +25 -10
- package/Portal/index.d.ts +4 -1
- package/Portal/index.js +1 -0
- package/Portal/portalRegistry.d.ts +17 -0
- package/Portal/portalRegistry.js +92 -0
- package/Progress/Progress.d.ts +23 -30
- package/Progress/Progress.js +71 -21
- package/Progress/index.d.ts +3 -2
- package/Provider/ConfigProvider.d.ts +1 -0
- package/Provider/ConfigProvider.js +1 -0
- package/Provider/context.js +1 -0
- package/Radio/Radio.d.ts +1 -1
- package/Radio/Radio.js +2 -1
- package/Radio/RadioGroup.d.ts +1 -1
- package/Radio/RadioGroup.js +1 -1
- package/Radio/RadioGroupContext.js +1 -0
- package/Radio/index.d.ts +4 -2
- package/ResultState/ResultState.d.ts +52 -0
- package/ResultState/ResultState.js +24 -0
- package/ResultState/index.d.ts +2 -0
- package/ResultState/index.js +1 -0
- package/Select/AutoComplete.d.ts +1 -1
- package/Select/AutoComplete.js +2 -1
- package/Select/Option.js +1 -0
- package/Select/Select.d.ts +1 -1
- package/Select/Select.js +2 -1
- package/Select/SelectControlContext.js +1 -0
- package/Select/SelectTrigger.d.ts +1 -87
- package/Select/SelectTrigger.js +26 -21
- package/Select/SelectTriggerTags.d.ts +1 -1
- package/Select/SelectTriggerTags.js +47 -18
- package/Select/TreeSelect.d.ts +1 -1
- package/Select/TreeSelect.js +2 -1
- package/Select/index.d.ts +14 -7
- package/Select/typings.d.ts +99 -0
- package/Select/useSelectTriggerTags.d.ts +15 -8
- package/Select/useSelectTriggerTags.js +83 -44
- package/Selection/Selection.d.ts +98 -0
- package/Selection/Selection.js +46 -0
- package/Selection/index.d.ts +12 -0
- package/Selection/index.js +5 -0
- package/Skeleton/Skeleton.d.ts +10 -3
- package/Skeleton/Skeleton.js +12 -4
- package/Skeleton/index.d.ts +2 -1
- package/Slider/Slider.d.ts +44 -7
- package/Slider/Slider.js +17 -13
- package/Slider/index.d.ts +5 -3
- package/Spin/Spin.d.ts +39 -0
- package/{Loading/Loading.js → Spin/Spin.js} +9 -9
- package/Spin/index.d.ts +2 -0
- package/Spin/index.js +1 -0
- package/Stepper/Step.d.ts +1 -35
- package/Stepper/Step.js +43 -8
- package/Stepper/Stepper.d.ts +1 -14
- package/Stepper/Stepper.js +49 -15
- package/Stepper/index.d.ts +5 -2
- package/Stepper/index.js +1 -0
- package/Stepper/typings.d.ts +77 -0
- package/Stepper/useStepDistance.d.ts +10 -0
- package/Stepper/useStepDistance.js +81 -0
- package/Stepper/useStepper.d.ts +21 -0
- package/Stepper/useStepper.js +26 -0
- package/Table/Table.js +2 -2
- package/Table/TableBody.js +3 -2
- package/Table/TableBodyRow.js +1 -0
- package/Table/TableContext.js +1 -0
- package/Table/TableExpandedTable.js +1 -0
- package/Table/TableHeader.js +1 -0
- package/Table/editable/TableEditRenderWrapper.js +1 -0
- package/Table/expandable/TableExpandable.js +1 -1
- package/Table/index.d.ts +7 -4
- package/Table/pagination/TablePagination.js +1 -0
- package/Table/pagination/useTablePagination.js +1 -0
- package/Table/refresh/TableRefresh.js +3 -1
- package/Table/rowSelection/TableRowSelection.js +3 -2
- package/Table/sorting/TableSortingIcon.js +2 -1
- package/Table/sorting/useTableSorting.js +1 -0
- package/Table/useTableFetchMore.js +1 -1
- package/Table/useTableScroll.d.ts +4 -8
- package/Table/useTableScroll.js +9 -7
- package/Tabs/TabPane.js +1 -0
- package/Tabs/Tabs.js +9 -4
- package/Tabs/index.d.ts +6 -3
- package/Tabs/useTabsOverflow.js +4 -3
- package/Tag/Tag.d.ts +2 -25
- package/Tag/Tag.js +23 -13
- package/Tag/TagGroup.d.ts +12 -0
- package/Tag/TagGroup.js +41 -0
- package/Tag/index.d.ts +2 -1
- package/Tag/typings.d.ts +78 -0
- package/TextField/TextField.d.ts +78 -19
- package/TextField/TextField.js +58 -22
- package/TextField/index.d.ts +2 -1
- package/Textarea/Textarea.d.ts +19 -51
- package/Textarea/Textarea.js +13 -19
- package/Textarea/index.d.ts +2 -2
- package/TimePanel/TimePanel.d.ts +1 -22
- package/TimePanel/TimePanel.js +31 -26
- package/TimePanel/TimePanelAction.d.ts +2 -8
- package/TimePanel/TimePanelAction.js +2 -2
- package/TimePanel/TimePanelColumn.d.ts +0 -13
- package/TimePanel/TimePanelColumn.js +9 -11
- package/TimePanel/index.d.ts +6 -3
- package/TimePicker/TimePicker.d.ts +10 -1
- package/TimePicker/TimePicker.js +86 -35
- package/TimePicker/TimePickerPanel.d.ts +1 -2
- package/TimePicker/TimePickerPanel.js +2 -2
- package/TimePicker/index.d.ts +4 -2
- package/Toggle/Toggle.d.ts +46 -0
- package/Toggle/Toggle.js +29 -0
- package/Toggle/index.d.ts +3 -0
- package/Toggle/index.js +1 -0
- package/Tooltip/Tooltip.d.ts +13 -2
- package/Tooltip/Tooltip.js +56 -10
- package/Tooltip/index.d.ts +2 -1
- package/Tooltip/useDelayMouseEnterLeave.d.ts +1 -2
- package/Tooltip/useDelayMouseEnterLeave.js +10 -13
- package/Transition/Collapse.d.ts +2 -0
- package/Transition/Collapse.js +5 -6
- package/Transition/Fade.js +4 -4
- package/Transition/Rotate.d.ts +42 -0
- package/Transition/Rotate.js +30 -0
- package/Transition/Scale.d.ts +13 -0
- package/Transition/{Grow.js → Scale.js} +19 -16
- package/Transition/Slide.d.ts +7 -0
- package/Transition/{Zoom.js → Slide.js} +14 -12
- package/Transition/SlideFade.d.ts +3 -0
- package/Transition/SlideFade.js +5 -4
- package/Transition/Transition.d.ts +2 -2
- package/Transition/Translate.d.ts +14 -0
- package/Transition/Translate.js +94 -0
- package/Transition/index.d.ts +16 -6
- package/Transition/index.js +4 -2
- package/Transition/useAutoTransitionDuration.d.ts +1 -1
- package/Transition/useAutoTransitionDuration.js +3 -3
- package/Transition/useSetNodeTransition.js +0 -2
- package/Tree/TreeNode.js +7 -6
- package/Tree/index.d.ts +10 -5
- package/Typography/Typography.d.ts +6 -9
- package/Typography/Typography.js +7 -9
- package/Typography/index.d.ts +2 -5
- package/Upload/Upload.d.ts +175 -0
- package/Upload/Upload.js +279 -0
- package/Upload/UploadItem.d.ts +82 -0
- package/Upload/UploadItem.js +118 -0
- package/Upload/UploadPictureCard.d.ts +110 -0
- package/Upload/UploadPictureCard.js +101 -0
- package/Upload/Uploader.d.ts +161 -0
- package/Upload/Uploader.js +120 -0
- package/Upload/index.d.ts +8 -6
- package/Upload/index.js +4 -5
- package/Upload/upload-utils.d.ts +41 -0
- package/Upload/upload-utils.js +65 -0
- package/_internal/InputCheck/index.d.ts +4 -2
- package/_internal/InputTriggerPopper/InputTriggerPopper.js +15 -25
- package/_internal/InputTriggerPopper/index.d.ts +2 -1
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +2 -2
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +4 -27
- package/_internal/SlideFadeOverlay/index.d.ts +2 -1
- package/_internal/SlideFadeOverlay/useTopStack.js +1 -0
- package/dayjs.d.ts +21 -0
- package/dayjs.js +2 -0
- package/hooks/useComposeRefs.js +1 -1
- package/hooks/useLastCallback.js +3 -1
- package/hooks/useScrollLock.d.ts +28 -0
- package/hooks/useScrollLock.js +134 -0
- package/index.d.ts +126 -58
- package/index.js +93 -80
- package/luxon.d.ts +21 -0
- package/luxon.js +2 -0
- package/moment.d.ts +21 -0
- package/moment.js +2 -0
- package/package.json +13 -17
- package/utils/composeRefs.js +0 -1
- package/utils/get-css-variable-value.d.ts +1 -0
- package/utils/get-css-variable-value.js +9 -0
- package/Button/IconButton.d.ts +0 -21
- package/Button/IconButton.js +0 -13
- package/DateTimePicker/DateTimePickerPanel.d.ts +0 -28
- package/DateTimePicker/DateTimePickerPanel.js +0 -49
- package/Form/FormMessage.d.ts +0 -7
- package/Form/FormMessage.js +0 -18
- package/Form/useInputWithTagsModeValue.js +0 -86
- package/Loading/Loading.d.ts +0 -33
- package/Loading/index.d.ts +0 -1
- package/Loading/index.js +0 -1
- package/Overlay/Overlay.js +0 -31
- package/Overlay/index.d.ts +0 -1
- package/Overlay/index.js +0 -1
- package/Picker/useRangePickerValue.d.ts +0 -23
- package/Picker/useRangePickerValue.js +0 -99
- package/Switch/Switch.d.ts +0 -43
- package/Switch/Switch.js +0 -28
- package/Switch/index.d.ts +0 -2
- package/Switch/index.js +0 -1
- package/Transition/Grow.d.ts +0 -12
- package/Transition/Zoom.d.ts +0 -7
- package/Upload/UploadButton.d.ts +0 -9
- package/Upload/UploadButton.js +0 -23
- package/Upload/UploadInput.d.ts +0 -20
- package/Upload/UploadInput.js +0 -24
- package/Upload/UploadPicture.d.ts +0 -49
- package/Upload/UploadPicture.js +0 -51
- package/Upload/UploadPictureBlock.d.ts +0 -20
- package/Upload/UploadPictureBlock.js +0 -81
- package/Upload/UploadPictureWall.d.ts +0 -81
- package/Upload/UploadPictureWall.js +0 -168
- package/Upload/UploadPictureWallItem.d.ts +0 -15
- package/Upload/UploadPictureWallItem.js +0 -18
- package/Upload/UploadResult.d.ts +0 -35
- package/Upload/UploadResult.js +0 -29
- package/utils/scroll-lock.d.ts +0 -2
- package/utils/scroll-lock.js +0 -24
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DateType } from '@mezzanine-ui/core/calendar';
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
export interface CalendarQuartersProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onClick' | 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* Provide if you have a custom disabling logic.
|
|
6
|
+
* The method takes the date object as its parameter.
|
|
7
|
+
*/
|
|
8
|
+
isQuarterDisabled?: (date: DateType) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Provide if you have a custom logic for checking if the quarter is in range.
|
|
11
|
+
* The method takes the date object as its parameter.
|
|
12
|
+
*/
|
|
13
|
+
isQuarterInRange?: (date: DateType) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Click handler for the button of each quarter.
|
|
16
|
+
* The method takes the date object as its parameter.
|
|
17
|
+
*/
|
|
18
|
+
onClick?: (target: DateType) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Mouse enter handler for the button of each quarter.
|
|
21
|
+
* The method takes the date object as its parameter.
|
|
22
|
+
*/
|
|
23
|
+
onQuarterHover?: (target: DateType) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The reference date for getting the quarters range and computing the date object.
|
|
26
|
+
*/
|
|
27
|
+
referenceDate: DateType;
|
|
28
|
+
/**
|
|
29
|
+
* The quarter will be marked as active if it matches the same quarter of any value in the array.
|
|
30
|
+
*/
|
|
31
|
+
value?: DateType[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The react component for `mezzanine` calendar quarters.
|
|
35
|
+
*/
|
|
36
|
+
declare function CalendarQuarters(props: CalendarQuartersProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export default CalendarQuarters;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { getYearRange, calendarQuarterYearsCount, calendarQuarters, calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { useCalendarContext } from './CalendarContext.js';
|
|
6
|
+
import CalendarCell from './CalendarCell.js';
|
|
7
|
+
import cx from 'clsx';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The react component for `mezzanine` calendar quarters.
|
|
11
|
+
*/
|
|
12
|
+
function CalendarQuarters(props) {
|
|
13
|
+
const { getYear, getCurrentQuarterFirstDate, isQuarterIncluded, setYear, setMonth, } = useCalendarContext();
|
|
14
|
+
const { className, isQuarterDisabled, isQuarterInRange, onClick: onClickProp, onQuarterHover, referenceDate, value, ...rest } = props;
|
|
15
|
+
const currentYear = getYear(referenceDate);
|
|
16
|
+
const [start] = useMemo(() => getYearRange(currentYear, calendarQuarterYearsCount), [currentYear]);
|
|
17
|
+
const years = useMemo(() => {
|
|
18
|
+
return Array.from({ length: calendarQuarterYearsCount }, (_, i) => start + i);
|
|
19
|
+
}, [start]);
|
|
20
|
+
return (jsx("div", { className: cx(calendarClasses.board, className), ...rest, children: years.map((year, yearIndex) => {
|
|
21
|
+
return (jsxs("div", { className: cx(calendarClasses.row, {
|
|
22
|
+
[calendarClasses.rowWithBorder]: yearIndex > 0,
|
|
23
|
+
}), children: [jsx(CalendarCell, { disabled: true, children: year }), calendarQuarters.map((quarter) => {
|
|
24
|
+
const quarterStartMonth = (quarter - 1) * 3;
|
|
25
|
+
const quarterDate = setMonth(setYear(getCurrentQuarterFirstDate(getCurrentQuarterFirstDate(referenceDate)), year), quarterStartMonth);
|
|
26
|
+
const active = value && isQuarterIncluded(quarterDate, value);
|
|
27
|
+
const disabled = isQuarterDisabled && isQuarterDisabled(quarterDate);
|
|
28
|
+
const inRange = isQuarterInRange && isQuarterInRange(quarterDate);
|
|
29
|
+
const onClick = onClickProp
|
|
30
|
+
? () => {
|
|
31
|
+
onClickProp(quarterDate);
|
|
32
|
+
}
|
|
33
|
+
: undefined;
|
|
34
|
+
const onMouseEnter = onQuarterHover
|
|
35
|
+
? () => {
|
|
36
|
+
onQuarterHover(quarterDate);
|
|
37
|
+
}
|
|
38
|
+
: undefined;
|
|
39
|
+
// Accessible quarter label for screen readers
|
|
40
|
+
const quarterMonths = [
|
|
41
|
+
['January', 'February', 'March'],
|
|
42
|
+
['April', 'May', 'June'],
|
|
43
|
+
['July', 'August', 'September'],
|
|
44
|
+
['October', 'November', 'December'],
|
|
45
|
+
];
|
|
46
|
+
const monthNames = quarterMonths[quarter - 1].join(', ');
|
|
47
|
+
const ariaLabel = [
|
|
48
|
+
`Quarter ${quarter}, ${year}`,
|
|
49
|
+
`${monthNames}`,
|
|
50
|
+
active && 'Selected',
|
|
51
|
+
disabled && 'Not available',
|
|
52
|
+
]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join(', ');
|
|
55
|
+
return (jsxs("button", { type: "button", disabled: disabled, "aria-disabled": disabled, "aria-label": ariaLabel, "aria-pressed": active, className: cx(calendarClasses.button, {
|
|
56
|
+
[calendarClasses.buttonActive]: active,
|
|
57
|
+
[calendarClasses.buttonInRange]: inRange,
|
|
58
|
+
[calendarClasses.buttonDisabled]: disabled,
|
|
59
|
+
}), onClick: onClick, onMouseEnter: onMouseEnter, children: ["Q", quarter] }, quarter));
|
|
60
|
+
})] }, year));
|
|
61
|
+
}) }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { CalendarQuarters as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
export interface CalendarQuickSelectProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onClick'> {
|
|
3
|
+
/**
|
|
4
|
+
* The id of active quick select button.
|
|
5
|
+
*/
|
|
6
|
+
activeId?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The options for quick select buttons.
|
|
9
|
+
*/
|
|
10
|
+
options: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onClick: VoidFunction;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The react component for `mezzanine` calendar quick select.
|
|
19
|
+
*/
|
|
20
|
+
declare function CalendarQuickSelect(props: CalendarQuickSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export default CalendarQuickSelect;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
3
|
+
import { CheckedIcon } from '@mezzanine-ui/icons';
|
|
4
|
+
import Icon from '../Icon/Icon.js';
|
|
5
|
+
import cx from 'clsx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The react component for `mezzanine` calendar quick select.
|
|
9
|
+
*/
|
|
10
|
+
function CalendarQuickSelect(props) {
|
|
11
|
+
const { className, activeId, options, ...restElementProps } = props;
|
|
12
|
+
return (jsx("div", { ...restElementProps, className: cx(calendarClasses.quickSelect, className), children: options.map(({ id, name, disabled, onClick }) => (jsxs("button", { type: "button", disabled: disabled, "aria-disabled": disabled, className: cx(calendarClasses.quickSelectButton, id === activeId && calendarClasses.quickSelectButtonActive), onClick: onClick, children: [jsx("span", { children: name }), id === activeId && jsx(Icon, { icon: CheckedIcon, size: 16 })] }, id))) }));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { CalendarQuickSelect as default };
|
|
@@ -25,7 +25,7 @@ export interface CalendarWeeksProps extends Pick<CalendarDayOfWeekProps, 'displa
|
|
|
25
25
|
*/
|
|
26
26
|
onWeekHover?: (firstDateOfWeek: DateType) => void;
|
|
27
27
|
/**
|
|
28
|
-
* The
|
|
28
|
+
* The reference date for getting the dates of calendar.
|
|
29
29
|
*/
|
|
30
30
|
referenceDate: DateType;
|
|
31
31
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
3
|
import { calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
3
4
|
import { useMemo } from 'react';
|
|
@@ -12,50 +13,94 @@ import cx from 'clsx';
|
|
|
12
13
|
* You may use it to compose your own calendar.
|
|
13
14
|
*/
|
|
14
15
|
function CalendarWeeks(props) {
|
|
15
|
-
const {
|
|
16
|
-
const { className, displayWeekDayLocale =
|
|
17
|
-
const daysGrid = useMemo(() => getCalendarGrid(referenceDate), [getCalendarGrid, referenceDate]);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
16
|
+
const { locale, getCalendarGrid, getWeek, getDate, getMonth, getNow, isInMonth, isSameDate, isWeekIncluded, setDate, setMonth, setHour, setMinute, setSecond, setMillisecond, getCurrentWeekFirstDate, } = useCalendarContext();
|
|
17
|
+
const { className, displayWeekDayLocale = locale, isYearDisabled, isMonthDisabled, isWeekDisabled, isWeekInRange, onClick: onClickProp, onWeekHover, referenceDate, value, ...rest } = props;
|
|
18
|
+
const daysGrid = useMemo(() => getCalendarGrid(referenceDate, displayWeekDayLocale), [getCalendarGrid, referenceDate, displayWeekDayLocale]);
|
|
19
|
+
const weekFirstDates = useMemo(() => {
|
|
20
|
+
return daysGrid.map((week, index) => {
|
|
21
|
+
const dateNum = week[0];
|
|
22
|
+
const isPrevMonth = index === 0 && dateNum > 7;
|
|
23
|
+
const isNextMonth = index > 3 && dateNum <= 14;
|
|
24
|
+
const thisMonth = getMonth(referenceDate);
|
|
25
|
+
const month = isPrevMonth
|
|
26
|
+
? thisMonth - 1
|
|
27
|
+
: isNextMonth
|
|
28
|
+
? thisMonth + 1
|
|
29
|
+
: thisMonth;
|
|
30
|
+
const weekFirstDate = setDate(setMonth(referenceDate, month), dateNum);
|
|
31
|
+
return getCurrentWeekFirstDate(weekFirstDate, displayWeekDayLocale);
|
|
32
|
+
});
|
|
33
|
+
}, [
|
|
34
|
+
daysGrid,
|
|
35
|
+
getMonth,
|
|
36
|
+
referenceDate,
|
|
37
|
+
setDate,
|
|
38
|
+
setMonth,
|
|
39
|
+
getCurrentWeekFirstDate,
|
|
40
|
+
displayWeekDayLocale,
|
|
41
|
+
]);
|
|
42
|
+
return (jsxs("div", { ...rest, className: cx(calendarClasses.board, className), children: [jsx("div", { className: calendarClasses.week, children: weekFirstDates.map((firstDate, idx) => (jsx("div", { className: calendarClasses.weekRow, children: jsx(CalendarCell, { disabled: true, children: getWeek(firstDate, displayWeekDayLocale) }) }, idx))) }), jsxs("div", { className: calendarClasses.daysGrid, children: [jsx(CalendarDayOfWeek, { displayWeekDayLocale: displayWeekDayLocale }), daysGrid.map((week, index) => {
|
|
43
|
+
const dates = [];
|
|
44
|
+
const weekStartInPrevMonth = index === 0 && week[0] > 7;
|
|
45
|
+
const weekStartInNextMonth = index > 3 && week[0] <= 14;
|
|
46
|
+
week.forEach((dateNum) => {
|
|
47
|
+
const isPrevMonth = index === 0 && dateNum > 7;
|
|
48
|
+
const isNextMonth = index > 3 && dateNum <= 14;
|
|
49
|
+
const thisMonth = getMonth(referenceDate);
|
|
50
|
+
const month = isPrevMonth
|
|
51
|
+
? thisMonth - 1
|
|
52
|
+
: isNextMonth
|
|
53
|
+
? thisMonth + 1
|
|
54
|
+
: thisMonth;
|
|
55
|
+
const date = setMillisecond(setSecond(setMinute(setHour(setDate(setMonth(referenceDate, month), dateNum), 0), 0), 0), 0);
|
|
56
|
+
dates.push(date);
|
|
57
|
+
});
|
|
58
|
+
const disabled = (isYearDisabled === null || isYearDisabled === void 0 ? void 0 : isYearDisabled(dates[0])) ||
|
|
59
|
+
(isMonthDisabled === null || isMonthDisabled === void 0 ? void 0 : isMonthDisabled(dates[0])) ||
|
|
60
|
+
(isWeekDisabled === null || isWeekDisabled === void 0 ? void 0 : isWeekDisabled(dates[0])) ||
|
|
61
|
+
false;
|
|
62
|
+
const inactive = !disabled && (weekStartInPrevMonth || weekStartInNextMonth);
|
|
63
|
+
const active = !disabled &&
|
|
64
|
+
!inactive &&
|
|
65
|
+
value &&
|
|
66
|
+
isWeekIncluded(dates[0], value, displayWeekDayLocale);
|
|
67
|
+
const inRange = !disabled && !inactive && isWeekInRange && isWeekInRange(dates[0]);
|
|
68
|
+
const onMouseEnter = onWeekHover
|
|
69
|
+
? () => {
|
|
70
|
+
onWeekHover(getCurrentWeekFirstDate(dates[0], displayWeekDayLocale));
|
|
71
|
+
}
|
|
72
|
+
: undefined;
|
|
73
|
+
const onClick = onClickProp
|
|
74
|
+
? () => {
|
|
75
|
+
onClickProp(getCurrentWeekFirstDate(dates[0], displayWeekDayLocale));
|
|
76
|
+
}
|
|
77
|
+
: undefined;
|
|
78
|
+
// Accessible week label for screen readers
|
|
79
|
+
const firstDate = new Date(dates[0]);
|
|
80
|
+
const lastDate = new Date(dates[dates.length - 1]);
|
|
81
|
+
const weekNum = getWeek(dates[0], displayWeekDayLocale);
|
|
82
|
+
const startMonth = firstDate.toLocaleDateString(displayWeekDayLocale, { month: 'short' });
|
|
83
|
+
const endMonth = lastDate.toLocaleDateString(displayWeekDayLocale, {
|
|
84
|
+
month: 'short',
|
|
85
|
+
});
|
|
86
|
+
const startDay = firstDate.getDate();
|
|
87
|
+
const endDay = lastDate.getDate();
|
|
88
|
+
const ariaLabel = [
|
|
89
|
+
`Week ${weekNum}`,
|
|
90
|
+
`${startMonth} ${startDay} to ${endMonth} ${endDay}`,
|
|
91
|
+
active && 'Selected',
|
|
92
|
+
disabled && 'Not available',
|
|
93
|
+
inactive && 'Outside current month',
|
|
94
|
+
]
|
|
95
|
+
.filter(Boolean)
|
|
96
|
+
.join(', ');
|
|
97
|
+
return (jsx("button", { type: "button", className: cx(calendarClasses.button, calendarClasses.row, {
|
|
98
|
+
[calendarClasses.buttonActive]: active,
|
|
99
|
+
[calendarClasses.buttonInRange]: inRange,
|
|
100
|
+
[calendarClasses.buttonDisabled]: disabled,
|
|
101
|
+
}), disabled: disabled, "aria-disabled": disabled, "aria-label": ariaLabel, "aria-pressed": active, onClick: onClick, onMouseEnter: onMouseEnter, children: week.map((dateNum, dateIndex) => (jsx(CalendarCell, { today: isSameDate(dates[dateIndex], getNow()), disabled: disabled ||
|
|
102
|
+
!isInMonth(dates[dateIndex], getMonth(referenceDate)), active: active, children: dateNum }, `${getMonth(dates[dateIndex])}/${getDate(dates[dateIndex])}`))) }, `CALENDAR_WEEKS/WEEK_OF/${index}`));
|
|
103
|
+
})] })] }));
|
|
59
104
|
}
|
|
60
105
|
|
|
61
106
|
export { CalendarWeeks as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
import { getCalendarYearRange, calendarYearsBase, calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
3
4
|
import { useMemo } from 'react';
|
|
@@ -10,12 +11,12 @@ import cx from 'clsx';
|
|
|
10
11
|
* You may use it to compose your own calendar.
|
|
11
12
|
*/
|
|
12
13
|
function CalendarYears(props) {
|
|
13
|
-
const { getNow, getYear, isYearIncluded, setYear } = useCalendarContext();
|
|
14
|
+
const { getNow, getYear, isYearIncluded, setYear, getCurrentYearFirstDate } = useCalendarContext();
|
|
14
15
|
const { className, isYearDisabled, isYearInRange, onClick: onClickProp, onYearHover, referenceDate, value, ...rest } = props;
|
|
15
16
|
const [start] = useMemo(() => getCalendarYearRange(getYear(referenceDate)), [getYear, referenceDate]);
|
|
16
17
|
return (jsx("div", { className: cx(calendarClasses.board, className), ...rest, children: jsx("div", { className: calendarClasses.twelveGrid, children: calendarYearsBase.map((base) => {
|
|
17
18
|
const thisYear = base + start;
|
|
18
|
-
const yearDateType = setYear(getNow(), thisYear);
|
|
19
|
+
const yearDateType = setYear(getCurrentYearFirstDate(getNow()), thisYear);
|
|
19
20
|
const disabled = isYearDisabled && isYearDisabled(yearDateType);
|
|
20
21
|
const inactive = !disabled && (base === 0 || base === 11);
|
|
21
22
|
const active = !disabled &&
|
|
@@ -33,7 +34,16 @@ function CalendarYears(props) {
|
|
|
33
34
|
onYearHover(yearDateType);
|
|
34
35
|
}
|
|
35
36
|
: undefined;
|
|
36
|
-
|
|
37
|
+
// Accessible year label for screen readers
|
|
38
|
+
const ariaLabel = [
|
|
39
|
+
`Year ${thisYear}`,
|
|
40
|
+
active && 'Selected',
|
|
41
|
+
disabled && 'Not available',
|
|
42
|
+
inactive && 'Outside range',
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join(', ');
|
|
46
|
+
return (jsx("button", { type: "button", "aria-disabled": disabled, disabled: disabled, "aria-label": ariaLabel, "aria-pressed": active, className: cx(calendarClasses.button, {
|
|
37
47
|
[calendarClasses.buttonActive]: active,
|
|
38
48
|
[calendarClasses.buttonInRange]: inRange,
|
|
39
49
|
[calendarClasses.buttonDisabled]: disabled,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CalendarMode, DateType } from '@mezzanine-ui/core/calendar';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
|
+
import { CalendarProps } from './Calendar';
|
|
5
|
+
import { CalendarFooterActionsProps } from './CalendarFooterActions';
|
|
6
|
+
import { CalendarQuickSelectProps } from './CalendarQuickSelect';
|
|
7
|
+
export interface RangeCalendarProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onChange' | 'children'>, Pick<CalendarProps, 'renderAnnotations' | 'isDateDisabled' | 'isDateInRange' | 'onDateHover' | 'displayWeekDayLocale' | 'isMonthDisabled' | 'isMonthInRange' | 'onMonthHover' | 'displayMonthLocale' | 'isWeekDisabled' | 'isWeekInRange' | 'onWeekHover' | 'isYearDisabled' | 'isYearInRange' | 'onYearHover' | 'isQuarterDisabled' | 'isQuarterInRange' | 'onQuarterHover' | 'isHalfYearDisabled' | 'isHalfYearInRange' | 'onHalfYearHover' | 'disabledMonthSwitch' | 'disabledYearSwitch' | 'disableOnNext' | 'disableOnPrev' | 'disableOnDoubleNext' | 'disableOnDoublePrev'> {
|
|
8
|
+
/**
|
|
9
|
+
* Footer action buttons props
|
|
10
|
+
*/
|
|
11
|
+
actions?: CalendarFooterActionsProps['actions'];
|
|
12
|
+
/**
|
|
13
|
+
* Other props you may provide to each `Calendar`
|
|
14
|
+
*/
|
|
15
|
+
calendarProps?: Omit<CalendarProps, 'mode' | 'value' | 'onChange' | 'referenceDate' | 'renderAnnotations' | 'onNext' | 'onPrev' | 'onDoubleNext' | 'onDoublePrev' | 'onMonthControlClick' | 'onYearControlClick'>;
|
|
16
|
+
/**
|
|
17
|
+
* React Ref for the first (left) calendar
|
|
18
|
+
*/
|
|
19
|
+
firstCalendarRef?: RefObject<HTMLDivElement | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Use this prop to switch calendars.
|
|
22
|
+
* @default 'day'
|
|
23
|
+
*/
|
|
24
|
+
mode?: CalendarMode;
|
|
25
|
+
/**
|
|
26
|
+
* Click handler for every cell on calendars.
|
|
27
|
+
* When completing a range (second click), returns normalized [start, end].
|
|
28
|
+
* When starting a new range (first click), returns the clicked date.
|
|
29
|
+
* The normalization ensures start is beginning of period and end is end of period based on mode.
|
|
30
|
+
*/
|
|
31
|
+
onChange?: (value: [DateType, DateType | undefined]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Quick select options for range calendar.
|
|
34
|
+
* Provide options for users to quickly select specific date ranges.
|
|
35
|
+
*/
|
|
36
|
+
quickSelect?: Pick<CalendarQuickSelectProps, 'activeId' | 'options'>;
|
|
37
|
+
/**
|
|
38
|
+
* The reference date for getting the calendar.
|
|
39
|
+
* **The type of `referenceDate` should be the same as your declared `DateType`.**
|
|
40
|
+
*/
|
|
41
|
+
referenceDate: DateType;
|
|
42
|
+
/**
|
|
43
|
+
* React Ref for the second (right) calendar
|
|
44
|
+
*/
|
|
45
|
+
secondCalendarRef?: RefObject<HTMLDivElement | null>;
|
|
46
|
+
/**
|
|
47
|
+
* The displaying cells will be marked as active
|
|
48
|
+
* if the single value of it matches any date object in the array.
|
|
49
|
+
* **The type of `value` should be the same as your declared `DateType`.**
|
|
50
|
+
*/
|
|
51
|
+
value?: DateType | DateType[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The react component for `mezzanine` range calendar.
|
|
55
|
+
* Displays two calendars side by side for range selection.
|
|
56
|
+
* Notice that any component related to calendar should be used along with `CalendarContext`.
|
|
57
|
+
*/
|
|
58
|
+
declare const RangeCalendar: import("react").ForwardRefExoticComponent<RangeCalendarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
59
|
+
export default RangeCalendar;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
4
|
+
import castArray from 'lodash/castArray';
|
|
5
|
+
import { forwardRef, useCallback } from 'react';
|
|
6
|
+
import Calendar from './Calendar.js';
|
|
7
|
+
import { useCalendarContext } from './CalendarContext.js';
|
|
8
|
+
import { useRangeCalendarControls } from './useRangeCalendarControls.js';
|
|
9
|
+
import CalendarFooterActions from './CalendarFooterActions.js';
|
|
10
|
+
import CalendarQuickSelect from './CalendarQuickSelect.js';
|
|
11
|
+
import cx from 'clsx';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The react component for `mezzanine` range calendar.
|
|
15
|
+
* Displays two calendars side by side for range selection.
|
|
16
|
+
* Notice that any component related to calendar should be used along with `CalendarContext`.
|
|
17
|
+
*/
|
|
18
|
+
const RangeCalendar = forwardRef(function RangeCalendar(props, ref) {
|
|
19
|
+
const { locale, getMonth, getYear, setMonth, setYear, getCurrentWeekFirstDate, getCurrentMonthFirstDate, getCurrentYearFirstDate, getCurrentQuarterFirstDate, getCurrentHalfYearFirstDate, addSecond, addDay, addMonth, addYear, setHour, setMinute, setSecond, setMillisecond, isBefore, } = useCalendarContext();
|
|
20
|
+
const { actions, renderAnnotations, calendarProps, className, disabledMonthSwitch, disabledYearSwitch, disableOnNext, disableOnPrev, disableOnDoubleNext, disableOnDoublePrev, displayMonthLocale = locale, displayWeekDayLocale = locale, firstCalendarRef, isDateDisabled, isDateInRange, isMonthDisabled, isMonthInRange, isWeekDisabled, isWeekInRange, isYearDisabled, isYearInRange, isQuarterDisabled, isQuarterInRange, isHalfYearDisabled, isHalfYearInRange, mode = 'day', onChange: onChangeProp, onDateHover, onMonthHover, onWeekHover, onYearHover, onQuarterHover, onHalfYearHover, quickSelect, referenceDate: referenceDateProp, secondCalendarRef, value: valueProp, ...restProps } = props;
|
|
21
|
+
const value = valueProp ? castArray(valueProp) : undefined;
|
|
22
|
+
const { currentMode, onMonthControlClick, onFirstPrev, onFirstDoublePrev, onSecondNext, onSecondDoubleNext, onYearControlClick, popModeStack, referenceDates, updateFirstReferenceDate, updateSecondReferenceDate, } = useRangeCalendarControls(referenceDateProp, mode);
|
|
23
|
+
const normalizeRangeStart = useCallback((date) => {
|
|
24
|
+
switch (mode) {
|
|
25
|
+
case 'day':
|
|
26
|
+
return setMillisecond(setSecond(setMinute(setHour(date, 0), 0), 0), 0);
|
|
27
|
+
case 'week':
|
|
28
|
+
return getCurrentWeekFirstDate(date, displayWeekDayLocale);
|
|
29
|
+
case 'month':
|
|
30
|
+
return getCurrentMonthFirstDate(date);
|
|
31
|
+
case 'year':
|
|
32
|
+
return getCurrentYearFirstDate(date);
|
|
33
|
+
case 'quarter':
|
|
34
|
+
return getCurrentQuarterFirstDate(date);
|
|
35
|
+
case 'half-year':
|
|
36
|
+
return getCurrentHalfYearFirstDate(date);
|
|
37
|
+
default:
|
|
38
|
+
return date;
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
displayWeekDayLocale,
|
|
42
|
+
mode,
|
|
43
|
+
getCurrentWeekFirstDate,
|
|
44
|
+
getCurrentMonthFirstDate,
|
|
45
|
+
getCurrentYearFirstDate,
|
|
46
|
+
getCurrentQuarterFirstDate,
|
|
47
|
+
getCurrentHalfYearFirstDate,
|
|
48
|
+
setHour,
|
|
49
|
+
setMinute,
|
|
50
|
+
setSecond,
|
|
51
|
+
setMillisecond,
|
|
52
|
+
]);
|
|
53
|
+
const normalizeRangeEnd = useCallback((date) => {
|
|
54
|
+
switch (mode) {
|
|
55
|
+
case 'day':
|
|
56
|
+
return setMillisecond(setSecond(setMinute(setHour(date, 23), 59), 59), 999);
|
|
57
|
+
case 'week': {
|
|
58
|
+
const weekStart = getCurrentWeekFirstDate(date, displayWeekDayLocale);
|
|
59
|
+
const weekEnd = addSecond(addDay(weekStart, 7), -1);
|
|
60
|
+
return setMillisecond(setSecond(setMinute(setHour(weekEnd, 23), 59), 59), 999);
|
|
61
|
+
}
|
|
62
|
+
case 'month': {
|
|
63
|
+
const nextMonth = addSecond(addMonth(getCurrentMonthFirstDate(date), 1), -1);
|
|
64
|
+
return setMillisecond(setSecond(setMinute(setHour(nextMonth, 23), 59), 59), 999);
|
|
65
|
+
}
|
|
66
|
+
case 'year': {
|
|
67
|
+
const nextYear = addSecond(addYear(getCurrentYearFirstDate(date), 1), -1);
|
|
68
|
+
return setMillisecond(setSecond(setMinute(setHour(nextYear, 23), 59), 59), 999);
|
|
69
|
+
}
|
|
70
|
+
case 'quarter': {
|
|
71
|
+
const nextQuarter = addSecond(addMonth(getCurrentQuarterFirstDate(date), 3), -1);
|
|
72
|
+
return setMillisecond(setSecond(setMinute(setHour(nextQuarter, 23), 59), 59), 999);
|
|
73
|
+
}
|
|
74
|
+
case 'half-year': {
|
|
75
|
+
const nextHalfYear = addSecond(addMonth(getCurrentHalfYearFirstDate(date), 6), -1);
|
|
76
|
+
return setMillisecond(setSecond(setMinute(setHour(nextHalfYear, 23), 59), 59), 999);
|
|
77
|
+
}
|
|
78
|
+
default:
|
|
79
|
+
return date;
|
|
80
|
+
}
|
|
81
|
+
}, [
|
|
82
|
+
displayWeekDayLocale,
|
|
83
|
+
mode,
|
|
84
|
+
getCurrentWeekFirstDate,
|
|
85
|
+
getCurrentMonthFirstDate,
|
|
86
|
+
getCurrentYearFirstDate,
|
|
87
|
+
getCurrentQuarterFirstDate,
|
|
88
|
+
getCurrentHalfYearFirstDate,
|
|
89
|
+
addSecond,
|
|
90
|
+
addDay,
|
|
91
|
+
addMonth,
|
|
92
|
+
addYear,
|
|
93
|
+
setHour,
|
|
94
|
+
setMinute,
|
|
95
|
+
setSecond,
|
|
96
|
+
setMillisecond,
|
|
97
|
+
]);
|
|
98
|
+
const hasDisabledDateInRange = useCallback((start, end) => {
|
|
99
|
+
var _a, _b, _c, _d, _e, _f;
|
|
100
|
+
const [rangeStart, rangeEnd] = isBefore(start, end)
|
|
101
|
+
? [start, end]
|
|
102
|
+
: [end, start];
|
|
103
|
+
let current = rangeStart;
|
|
104
|
+
while (isBefore(current, rangeEnd) || current === rangeEnd) {
|
|
105
|
+
// Check disabled based on current mode
|
|
106
|
+
let isDisabled = false;
|
|
107
|
+
switch (mode) {
|
|
108
|
+
case 'day':
|
|
109
|
+
isDisabled = (_a = isDateDisabled === null || isDateDisabled === void 0 ? void 0 : isDateDisabled(current)) !== null && _a !== void 0 ? _a : false;
|
|
110
|
+
break;
|
|
111
|
+
case 'week':
|
|
112
|
+
isDisabled = (_b = isWeekDisabled === null || isWeekDisabled === void 0 ? void 0 : isWeekDisabled(current)) !== null && _b !== void 0 ? _b : false;
|
|
113
|
+
break;
|
|
114
|
+
case 'month':
|
|
115
|
+
isDisabled = (_c = isMonthDisabled === null || isMonthDisabled === void 0 ? void 0 : isMonthDisabled(current)) !== null && _c !== void 0 ? _c : false;
|
|
116
|
+
break;
|
|
117
|
+
case 'year':
|
|
118
|
+
isDisabled = (_d = isYearDisabled === null || isYearDisabled === void 0 ? void 0 : isYearDisabled(current)) !== null && _d !== void 0 ? _d : false;
|
|
119
|
+
break;
|
|
120
|
+
case 'quarter':
|
|
121
|
+
isDisabled = (_e = isQuarterDisabled === null || isQuarterDisabled === void 0 ? void 0 : isQuarterDisabled(current)) !== null && _e !== void 0 ? _e : false;
|
|
122
|
+
break;
|
|
123
|
+
case 'half-year':
|
|
124
|
+
isDisabled = (_f = isHalfYearDisabled === null || isHalfYearDisabled === void 0 ? void 0 : isHalfYearDisabled(current)) !== null && _f !== void 0 ? _f : false;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (isDisabled) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
current = addDay(current, 1);
|
|
131
|
+
// Break if we've passed the end date (safety check)
|
|
132
|
+
if (isBefore(rangeEnd, current)) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}, [
|
|
138
|
+
mode,
|
|
139
|
+
isBefore,
|
|
140
|
+
addDay,
|
|
141
|
+
isDateDisabled,
|
|
142
|
+
isWeekDisabled,
|
|
143
|
+
isMonthDisabled,
|
|
144
|
+
isYearDisabled,
|
|
145
|
+
isQuarterDisabled,
|
|
146
|
+
isHalfYearDisabled,
|
|
147
|
+
]);
|
|
148
|
+
const handleRangeSelection = useCallback((target) => {
|
|
149
|
+
if (!onChangeProp)
|
|
150
|
+
return;
|
|
151
|
+
const [existingStart, existingEnd] = value || [];
|
|
152
|
+
if (!existingStart || (existingStart && existingEnd)) {
|
|
153
|
+
// 未選取起始日期,或已完成區間選取,重新開始選取
|
|
154
|
+
onChangeProp([target, undefined]);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const rawStart = existingStart;
|
|
158
|
+
const rawEnd = target;
|
|
159
|
+
// 檢查是否有不可選日期
|
|
160
|
+
if (hasDisabledDateInRange(rawStart, rawEnd)) {
|
|
161
|
+
onChangeProp([target, undefined]);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const isEndBeforeStart = isBefore(rawEnd, rawStart);
|
|
165
|
+
const [start, end] = isEndBeforeStart
|
|
166
|
+
? [rawEnd, rawStart]
|
|
167
|
+
: [rawStart, rawEnd];
|
|
168
|
+
const normalizedStart = normalizeRangeStart(start);
|
|
169
|
+
const normalizedEnd = normalizeRangeEnd(end);
|
|
170
|
+
onChangeProp([normalizedStart, normalizedEnd]);
|
|
171
|
+
}
|
|
172
|
+
}, [
|
|
173
|
+
value,
|
|
174
|
+
onChangeProp,
|
|
175
|
+
isBefore,
|
|
176
|
+
normalizeRangeStart,
|
|
177
|
+
normalizeRangeEnd,
|
|
178
|
+
hasDisabledDateInRange,
|
|
179
|
+
]);
|
|
180
|
+
const getTargetValue = useCallback((target, targetDate) => {
|
|
181
|
+
if (currentMode === mode) {
|
|
182
|
+
return target;
|
|
183
|
+
}
|
|
184
|
+
if (currentMode === 'month') {
|
|
185
|
+
return setMonth(targetDate, getMonth(target));
|
|
186
|
+
}
|
|
187
|
+
if (currentMode === 'year') {
|
|
188
|
+
return setYear(targetDate, getYear(target));
|
|
189
|
+
}
|
|
190
|
+
return target;
|
|
191
|
+
}, [currentMode, mode, getMonth, getYear, setMonth, setYear]);
|
|
192
|
+
const onChangeFactory = useCallback((calendar) => {
|
|
193
|
+
const targetDate = referenceDates[calendar];
|
|
194
|
+
const updateReferenceDate = calendar
|
|
195
|
+
? updateSecondReferenceDate
|
|
196
|
+
: updateFirstReferenceDate;
|
|
197
|
+
return (target) => {
|
|
198
|
+
if (currentMode === mode) {
|
|
199
|
+
const resultValue = getTargetValue(target, targetDate);
|
|
200
|
+
handleRangeSelection(resultValue);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const resultValue = getTargetValue(target, targetDate);
|
|
204
|
+
updateReferenceDate(resultValue);
|
|
205
|
+
popModeStack();
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}, [
|
|
209
|
+
currentMode,
|
|
210
|
+
mode,
|
|
211
|
+
referenceDates,
|
|
212
|
+
updateFirstReferenceDate,
|
|
213
|
+
updateSecondReferenceDate,
|
|
214
|
+
popModeStack,
|
|
215
|
+
getTargetValue,
|
|
216
|
+
handleRangeSelection,
|
|
217
|
+
]);
|
|
218
|
+
return (jsxs("div", { ...restProps, ref: ref, role: "application", "aria-label": `Range calendar, ${mode} view`, className: cx(calendarClasses.host, className), children: [quickSelect && (jsx(CalendarQuickSelect, { activeId: quickSelect.activeId, options: quickSelect.options })), jsxs("div", { className: calendarClasses.mainWithFooter, children: [jsxs("div", { style: { display: 'inline-flex', flexFlow: 'row' }, children: [jsx(Calendar, { ...calendarProps, renderAnnotations: renderAnnotations, className: cx(calendarClasses.noShadowHost, calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.className), ref: firstCalendarRef, mode: currentMode, value: value, onChange: onChangeFactory(0), referenceDate: referenceDates[0], onPrev: onFirstPrev, onDoublePrev: onFirstDoublePrev, onMonthControlClick: onMonthControlClick, onYearControlClick: onYearControlClick, disabledFooterControl: true, disabledMonthSwitch: disabledMonthSwitch, disabledYearSwitch: disabledYearSwitch, disableOnPrev: disableOnPrev, disableOnDoublePrev: disableOnDoublePrev, displayMonthLocale: displayMonthLocale, displayWeekDayLocale: displayWeekDayLocale, isDateDisabled: isDateDisabled, isDateInRange: isDateInRange, onDateHover: onDateHover, isMonthDisabled: isMonthDisabled, isMonthInRange: isMonthInRange, onMonthHover: onMonthHover, isWeekDisabled: isWeekDisabled, isWeekInRange: isWeekInRange, onWeekHover: onWeekHover, isYearDisabled: isYearDisabled, isYearInRange: isYearInRange, onYearHover: onYearHover, isQuarterDisabled: isQuarterDisabled, isQuarterInRange: isQuarterInRange, onQuarterHover: onQuarterHover, isHalfYearDisabled: isHalfYearDisabled, isHalfYearInRange: isHalfYearInRange, onHalfYearHover: onHalfYearHover }), jsx(Calendar, { ...calendarProps, renderAnnotations: renderAnnotations, className: cx(calendarClasses.noShadowHost, calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.className), ref: secondCalendarRef, mode: currentMode, value: value, onChange: onChangeFactory(1), referenceDate: referenceDates[1], onNext: onSecondNext, onDoubleNext: onSecondDoubleNext, onMonthControlClick: onMonthControlClick, onYearControlClick: onYearControlClick, disabledFooterControl: true, disabledMonthSwitch: disabledMonthSwitch, disabledYearSwitch: disabledYearSwitch, disableOnNext: disableOnNext, disableOnDoubleNext: disableOnDoubleNext, displayMonthLocale: displayMonthLocale, displayWeekDayLocale: displayWeekDayLocale, isDateDisabled: isDateDisabled, isDateInRange: isDateInRange, onDateHover: onDateHover, isMonthDisabled: isMonthDisabled, isMonthInRange: isMonthInRange, onMonthHover: onMonthHover, isWeekDisabled: isWeekDisabled, isWeekInRange: isWeekInRange, onWeekHover: onWeekHover, isYearDisabled: isYearDisabled, isYearInRange: isYearInRange, onYearHover: onYearHover, isQuarterDisabled: isQuarterDisabled, isQuarterInRange: isQuarterInRange, onQuarterHover: onQuarterHover, isHalfYearDisabled: isHalfYearDisabled, isHalfYearInRange: isHalfYearInRange, onHalfYearHover: onHalfYearHover })] }), actions && (jsx(CalendarFooterActions, { actions: {
|
|
219
|
+
secondaryButtonProps: {
|
|
220
|
+
children: 'Cancel',
|
|
221
|
+
disabled: false,
|
|
222
|
+
...actions === null || actions === void 0 ? void 0 : actions.secondaryButtonProps,
|
|
223
|
+
},
|
|
224
|
+
primaryButtonProps: {
|
|
225
|
+
children: 'Ok',
|
|
226
|
+
disabled: false,
|
|
227
|
+
...actions === null || actions === void 0 ? void 0 : actions.primaryButtonProps,
|
|
228
|
+
},
|
|
229
|
+
} }))] })] }));
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
export { RangeCalendar as default };
|