@mezzanine-ui/react 1.0.0-canary.2 → 1.0.0-canary.4
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/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/{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 +1 -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 +2 -2
- package/Calendar/Calendar.d.ts +31 -2
- package/Calendar/Calendar.js +73 -19
- package/Calendar/CalendarCell.d.ts +4 -0
- package/Calendar/CalendarCell.js +3 -3
- package/Calendar/CalendarContext.d.ts +14 -7
- package/Calendar/CalendarContext.js +7 -13
- package/Calendar/CalendarControls.d.ts +16 -0
- package/Calendar/CalendarControls.js +3 -7
- package/Calendar/CalendarDayOfWeek.js +3 -3
- package/Calendar/CalendarDays.d.ts +9 -1
- package/Calendar/CalendarDays.js +62 -37
- 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 +15 -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 +88 -43
- package/Calendar/CalendarYears.js +12 -3
- package/Calendar/RangeCalendar.d.ts +59 -0
- package/Calendar/RangeCalendar.js +232 -0
- package/Calendar/index.d.ts +8 -1
- package/Calendar/index.js +4 -0
- package/Calendar/useCalendarControlModifiers.d.ts +4 -4
- package/Calendar/useCalendarControlModifiers.js +39 -8
- package/Calendar/useCalendarControls.d.ts +2 -0
- package/Calendar/useCalendarControls.js +18 -2
- package/Calendar/useRangeCalendarControls.d.ts +18 -0
- package/Calendar/useRangeCalendarControls.js +115 -0
- package/Checkbox/CheckAll.d.ts +16 -6
- package/Checkbox/CheckAll.js +40 -26
- package/Checkbox/Checkbox.d.ts +100 -22
- package/Checkbox/Checkbox.js +72 -16
- package/Checkbox/CheckboxGroup.d.ts +100 -18
- package/Checkbox/CheckboxGroup.js +169 -24
- package/Checkbox/CheckboxGroupContext.d.ts +0 -2
- package/Checkbox/index.d.ts +15 -6
- 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/DatePicker/DatePicker.d.ts +12 -1
- package/DatePicker/DatePicker.js +40 -9
- package/DatePicker/DatePickerCalendar.d.ts +2 -5
- package/DatePicker/DatePickerCalendar.js +36 -37
- package/DateRangePicker/DateRangePicker.d.ts +18 -2
- package/DateRangePicker/DateRangePicker.js +142 -100
- package/DateRangePicker/DateRangePickerCalendar.d.ts +13 -9
- package/DateRangePicker/DateRangePickerCalendar.js +6 -94
- package/DateRangePicker/useDateRangeCalendarControls.js +6 -2
- package/DateRangePicker/useDateRangePickerValue.d.ts +38 -15
- package/DateRangePicker/useDateRangePickerValue.js +141 -63
- package/DateTimePicker/DateTimePicker.d.ts +31 -10
- package/DateTimePicker/DateTimePicker.js +178 -94
- package/DateTimePicker/index.d.ts +0 -2
- package/DateTimePicker/index.js +0 -1
- package/Drawer/Drawer.js +2 -2
- package/Dropdown/Dropdown.js +12 -22
- 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 +1 -1
- package/Empty/typings.d.ts +52 -0
- package/Form/FormHintText.d.ts +18 -0
- package/Form/FormHintText.js +17 -0
- package/Form/index.d.ts +2 -2
- package/Form/index.js +1 -1
- 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 +194 -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 +2 -2
- 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/Modal/Modal.js +2 -2
- package/Modal/useModalContainer.d.ts +1 -1
- package/Modal/useModalContainer.js +2 -4
- package/Navigation/NavigationSubMenu.js +15 -26
- 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/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/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 +7 -2
- 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/Popover/Popover.js +4 -8
- package/Popper/Popper.d.ts +15 -10
- package/Popper/Popper.js +88 -17
- package/Popper/index.d.ts +1 -1
- package/Portal/Portal.d.ts +13 -5
- package/Portal/Portal.js +25 -10
- package/Portal/index.d.ts +2 -0
- 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 +70 -21
- package/Progress/index.d.ts +2 -2
- package/Provider/ConfigProvider.d.ts +1 -0
- package/Provider/ConfigProvider.js +1 -0
- 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/Select.d.ts +1 -1
- 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/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/Slider/Slider.d.ts +44 -7
- package/Slider/Slider.js +17 -13
- package/Spin/Spin.d.ts +39 -0
- package/{Loading/Loading.js → Spin/Spin.js} +8 -8
- 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 -10
- package/Stepper/Stepper.d.ts +1 -14
- package/Stepper/Stepper.js +49 -15
- package/Stepper/index.d.ts +3 -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 +2 -2
- package/Table/rowSelection/TableRowSelection.js +1 -1
- package/Tag/Tag.d.ts +2 -25
- package/Tag/Tag.js +22 -13
- package/Tag/TagGroup.d.ts +12 -0
- package/Tag/TagGroup.js +41 -0
- package/Tag/index.d.ts +1 -1
- package/Tag/typings.d.ts +78 -0
- package/TextField/TextField.d.ts +78 -19
- package/TextField/TextField.js +57 -20
- package/TextField/index.d.ts +1 -1
- package/Textarea/Textarea.d.ts +19 -51
- package/Textarea/Textarea.js +12 -19
- package/Textarea/index.d.ts +0 -1
- package/TimePanel/TimePanel.d.ts +1 -22
- package/TimePanel/TimePanel.js +30 -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/TimePicker/TimePicker.d.ts +10 -1
- package/TimePicker/TimePicker.js +85 -35
- package/TimePicker/TimePickerPanel.d.ts +1 -2
- package/TimePicker/TimePickerPanel.js +2 -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/useDelayMouseEnterLeave.d.ts +1 -2
- package/Tooltip/useDelayMouseEnterLeave.js +0 -4
- package/Transition/Collapse.d.ts +2 -0
- package/Transition/Collapse.js +3 -2
- 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} +17 -12
- 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 +1 -1
- package/Transition/Translate.d.ts +14 -0
- package/Transition/Translate.js +94 -0
- package/Transition/index.d.ts +8 -4
- package/Transition/index.js +4 -2
- package/Tree/TreeNode.js +6 -6
- 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 -11
- package/Upload/index.js +4 -5
- package/Upload/upload-utils.d.ts +41 -0
- package/Upload/upload-utils.js +65 -0
- package/_internal/InputTriggerPopper/InputTriggerPopper.js +15 -25
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +2 -2
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +4 -27
- package/hooks/useScrollLock.d.ts +28 -0
- package/hooks/useScrollLock.js +134 -0
- package/index.d.ts +99 -84
- package/index.js +92 -78
- package/package.json +7 -7
- package/utils/get-css-variable-value.d.ts +1 -0
- package/utils/get-css-variable-value.js +9 -0
- package/DateTimePicker/DateTimePickerPanel.d.ts +0 -28
- package/DateTimePicker/DateTimePickerPanel.js +0 -50
- package/Form/FormMessage.d.ts +0 -7
- package/Form/FormMessage.js +0 -19
- package/Form/useInputWithTagsModeValue.js +0 -88
- package/Loading/Loading.d.ts +0 -33
- package/Loading/index.d.ts +0 -2
- package/Loading/index.js +0 -1
- package/Overlay/Overlay.js +0 -31
- package/Overlay/index.d.ts +0 -2
- 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 -29
- package/Switch/index.d.ts +0 -3
- 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 -23
- 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 -79
- 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 -30
- package/utils/scroll-lock.d.ts +0 -2
- package/utils/scroll-lock.js +0 -24
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
import { ButtonProps } from '../Button';
|
|
3
|
+
export interface CalendarFooterActionsProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onClick'> {
|
|
4
|
+
actions: {
|
|
5
|
+
secondaryButtonProps: ButtonProps;
|
|
6
|
+
primaryButtonProps: ButtonProps;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The react component for `mezzanine` calendar footer actions.
|
|
11
|
+
*/
|
|
12
|
+
declare function CalendarFooterActions(props: CalendarFooterActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default CalendarFooterActions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
3
|
+
import Button from '../Button/Button.js';
|
|
4
|
+
import cx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The react component for `mezzanine` calendar footer actions.
|
|
8
|
+
*/
|
|
9
|
+
function CalendarFooterActions(props) {
|
|
10
|
+
const { actions, className, ...restElementProps } = props;
|
|
11
|
+
return (jsxs("div", { ...restElementProps, className: cx(calendarClasses.footerActions, className), children: [jsx(Button, { variant: "base-tertiary", size: "minor", ...actions.secondaryButtonProps }), jsx(Button, { variant: "base-primary", size: "minor", ...actions.primaryButtonProps })] }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { CalendarFooterActions as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
export interface CalendarFooterControlProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onClick'> {
|
|
3
|
+
/**
|
|
4
|
+
* The name of children content.
|
|
5
|
+
*/
|
|
6
|
+
children?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The onClick handler for button
|
|
9
|
+
*/
|
|
10
|
+
onClick?: VoidFunction;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The react component for `mezzanine` calendar footer control.
|
|
14
|
+
*/
|
|
15
|
+
declare function CalendarFooterControl(props: CalendarFooterControlProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default CalendarFooterControl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { calendarClasses } from '@mezzanine-ui/core/calendar';
|
|
3
|
+
import Button from '../Button/Button.js';
|
|
4
|
+
import cx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The react component for `mezzanine` calendar footer control.
|
|
8
|
+
*/
|
|
9
|
+
function CalendarFooterControl(props) {
|
|
10
|
+
const { children, className, onClick, ...restElementProps } = props;
|
|
11
|
+
return (jsx("div", { ...restElementProps, className: cx(calendarClasses.footerControl, className), children: jsx(Button, { variant: "base-ghost", size: "minor", onClick: onClick, children: children }) }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { CalendarFooterControl as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DateType } from '@mezzanine-ui/core/calendar';
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
export interface CalendarHalfYearsProps 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
|
+
isHalfYearDisabled?: (date: DateType) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Provide if you have a custom logic for checking if the half-year is in range.
|
|
11
|
+
* The method takes the date object as its parameter.
|
|
12
|
+
*/
|
|
13
|
+
isHalfYearInRange?: (date: DateType) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Click handler for the button of each half-year.
|
|
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 half-year.
|
|
21
|
+
* The method takes the date object as its parameter.
|
|
22
|
+
*/
|
|
23
|
+
onHalfYearHover?: (target: DateType) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The reference date for getting the half-years range and computing the date object.
|
|
26
|
+
*/
|
|
27
|
+
referenceDate: DateType;
|
|
28
|
+
/**
|
|
29
|
+
* The half-year will be marked as active if it matches the same half-year of any value in the array.
|
|
30
|
+
*/
|
|
31
|
+
value?: DateType[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The react component for `mezzanine` calendar half-years.
|
|
35
|
+
* This component displays half-years for 5 years.
|
|
36
|
+
* You may use it to compose your own calendar.
|
|
37
|
+
*/
|
|
38
|
+
declare function CalendarHalfYears(props: CalendarHalfYearsProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export default CalendarHalfYears;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { getYearRange, calendarHalfYearYearsCount, calendarHalfYears, 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 half-years.
|
|
11
|
+
* This component displays half-years for 5 years.
|
|
12
|
+
* You may use it to compose your own calendar.
|
|
13
|
+
*/
|
|
14
|
+
function CalendarHalfYears(props) {
|
|
15
|
+
const { getYear, getCurrentHalfYearFirstDate, isHalfYearIncluded, setYear, setMonth, } = useCalendarContext();
|
|
16
|
+
const { className, isHalfYearDisabled, isHalfYearInRange, onClick: onClickProp, onHalfYearHover, referenceDate, value, ...rest } = props;
|
|
17
|
+
const currentYear = getYear(referenceDate);
|
|
18
|
+
const [start] = useMemo(() => getYearRange(currentYear, calendarHalfYearYearsCount), [currentYear]);
|
|
19
|
+
const years = useMemo(() => {
|
|
20
|
+
return Array.from({ length: calendarHalfYearYearsCount }, (_, i) => start + i);
|
|
21
|
+
}, [start]);
|
|
22
|
+
return (jsx("div", { className: cx(calendarClasses.board, className), ...rest, children: years.map((year, yearIndex) => {
|
|
23
|
+
return (jsxs("div", { className: cx(calendarClasses.row, {
|
|
24
|
+
[calendarClasses.rowWithBorder]: yearIndex > 0,
|
|
25
|
+
}), children: [jsx(CalendarCell, { disabled: true, children: year }), calendarHalfYears.map((halfYear) => {
|
|
26
|
+
const halfYearStartMonth = (halfYear - 1) * 6;
|
|
27
|
+
const halfYearDate = setMonth(setYear(getCurrentHalfYearFirstDate(referenceDate), year), halfYearStartMonth);
|
|
28
|
+
const disabled = isHalfYearDisabled && isHalfYearDisabled(halfYearDate);
|
|
29
|
+
const inRange = !disabled &&
|
|
30
|
+
isHalfYearInRange &&
|
|
31
|
+
isHalfYearInRange(halfYearDate);
|
|
32
|
+
const active = !disabled && value && isHalfYearIncluded(halfYearDate, value);
|
|
33
|
+
const onClick = () => {
|
|
34
|
+
if (disabled)
|
|
35
|
+
return;
|
|
36
|
+
onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(halfYearDate);
|
|
37
|
+
};
|
|
38
|
+
const onMouseEnter = () => {
|
|
39
|
+
if (disabled)
|
|
40
|
+
return;
|
|
41
|
+
onHalfYearHover === null || onHalfYearHover === void 0 ? void 0 : onHalfYearHover(halfYearDate);
|
|
42
|
+
};
|
|
43
|
+
// Accessible half-year label for screen readers
|
|
44
|
+
const halfYearMonths = halfYear === 1 ? 'January to June' : 'July to December';
|
|
45
|
+
const ariaLabel = [
|
|
46
|
+
`Half ${halfYear}, ${year}`,
|
|
47
|
+
halfYearMonths,
|
|
48
|
+
active && 'Selected',
|
|
49
|
+
disabled && 'Not available',
|
|
50
|
+
]
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.join(', ');
|
|
53
|
+
return (jsxs("button", { type: "button", disabled: disabled, "aria-disabled": disabled, "aria-label": ariaLabel, "aria-pressed": active, className: cx(calendarClasses.button, {
|
|
54
|
+
[calendarClasses.buttonDisabled]: disabled,
|
|
55
|
+
[calendarClasses.buttonInRange]: inRange,
|
|
56
|
+
[calendarClasses.buttonActive]: active,
|
|
57
|
+
}), onClick: onClick, onMouseEnter: onMouseEnter, children: ["H", halfYear] }, halfYear));
|
|
58
|
+
})] }, year));
|
|
59
|
+
}) }));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { CalendarHalfYears as default };
|
|
@@ -10,11 +10,11 @@ import cx from 'clsx';
|
|
|
10
10
|
* You may use it to compose your own calendar.
|
|
11
11
|
*/
|
|
12
12
|
function CalendarMonths(props) {
|
|
13
|
-
const {
|
|
14
|
-
const { className, displayMonthLocale =
|
|
13
|
+
const { locale, getMonthShortNames, isMonthIncluded, getCurrentMonthFirstDate, setMonth, } = useCalendarContext();
|
|
14
|
+
const { className, displayMonthLocale = locale, isMonthDisabled, isMonthInRange, isYearDisabled, onClick: onClickProp, onMonthHover, referenceDate, value, ...rest } = props;
|
|
15
15
|
const monthNames = getMonthShortNames(displayMonthLocale);
|
|
16
16
|
return (jsx("div", { className: cx(calendarClasses.board, className), ...rest, children: jsx("div", { className: calendarClasses.twelveGrid, children: calendarMonths.map((month) => {
|
|
17
|
-
const monthDateType = setMonth(referenceDate, month);
|
|
17
|
+
const monthDateType = setMonth(getCurrentMonthFirstDate(referenceDate), month);
|
|
18
18
|
const active = value && isMonthIncluded(monthDateType, value);
|
|
19
19
|
/** @NOTE Current month should be disabled when current year is disabled */
|
|
20
20
|
const disabled = (isYearDisabled === null || isYearDisabled === void 0 ? void 0 : isYearDisabled(monthDateType)) ||
|
|
@@ -31,7 +31,18 @@ function CalendarMonths(props) {
|
|
|
31
31
|
onMonthHover(monthDateType);
|
|
32
32
|
}
|
|
33
33
|
: undefined;
|
|
34
|
-
|
|
34
|
+
// Accessible month label for screen readers
|
|
35
|
+
const monthDate = new Date(monthDateType);
|
|
36
|
+
const fullMonthName = monthDate.toLocaleDateString(displayMonthLocale, { month: 'long' });
|
|
37
|
+
const year = monthDate.getFullYear();
|
|
38
|
+
const ariaLabel = [
|
|
39
|
+
`${fullMonthName} ${year}`,
|
|
40
|
+
active && 'Selected',
|
|
41
|
+
disabled && 'Not available',
|
|
42
|
+
]
|
|
43
|
+
.filter(Boolean)
|
|
44
|
+
.join(', ');
|
|
45
|
+
return (jsx("button", { type: "button", "aria-disabled": disabled, disabled: disabled, "aria-label": ariaLabel, "aria-pressed": active, className: cx(calendarClasses.button, {
|
|
35
46
|
[calendarClasses.buttonActive]: active,
|
|
36
47
|
[calendarClasses.buttonInRange]: inRange,
|
|
37
48
|
[calendarClasses.buttonDisabled]: disabled,
|
|
@@ -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
|
/**
|
|
@@ -13,49 +13,94 @@ import cx from 'clsx';
|
|
|
13
13
|
* You may use it to compose your own calendar.
|
|
14
14
|
*/
|
|
15
15
|
function CalendarWeeks(props) {
|
|
16
|
-
const {
|
|
17
|
-
const { className, displayWeekDayLocale =
|
|
18
|
-
const daysGrid = useMemo(() => getCalendarGrid(referenceDate), [getCalendarGrid, referenceDate]);
|
|
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 };
|
|
@@ -11,12 +11,12 @@ import cx from 'clsx';
|
|
|
11
11
|
* You may use it to compose your own calendar.
|
|
12
12
|
*/
|
|
13
13
|
function CalendarYears(props) {
|
|
14
|
-
const { getNow, getYear, isYearIncluded, setYear } = useCalendarContext();
|
|
14
|
+
const { getNow, getYear, isYearIncluded, setYear, getCurrentYearFirstDate } = useCalendarContext();
|
|
15
15
|
const { className, isYearDisabled, isYearInRange, onClick: onClickProp, onYearHover, referenceDate, value, ...rest } = props;
|
|
16
16
|
const [start] = useMemo(() => getCalendarYearRange(getYear(referenceDate)), [getYear, referenceDate]);
|
|
17
17
|
return (jsx("div", { className: cx(calendarClasses.board, className), ...rest, children: jsx("div", { className: calendarClasses.twelveGrid, children: calendarYearsBase.map((base) => {
|
|
18
18
|
const thisYear = base + start;
|
|
19
|
-
const yearDateType = setYear(getNow(), thisYear);
|
|
19
|
+
const yearDateType = setYear(getCurrentYearFirstDate(getNow()), thisYear);
|
|
20
20
|
const disabled = isYearDisabled && isYearDisabled(yearDateType);
|
|
21
21
|
const inactive = !disabled && (base === 0 || base === 11);
|
|
22
22
|
const active = !disabled &&
|
|
@@ -34,7 +34,16 @@ function CalendarYears(props) {
|
|
|
34
34
|
onYearHover(yearDateType);
|
|
35
35
|
}
|
|
36
36
|
: undefined;
|
|
37
|
-
|
|
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, {
|
|
38
47
|
[calendarClasses.buttonActive]: active,
|
|
39
48
|
[calendarClasses.buttonInRange]: inRange,
|
|
40
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;
|