@registrucentras/rc-ses-react-components 2.7.3 → 3.0.0-rc.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/dist/assets/icons/phosphorIcons.d.ts +4 -0
- package/dist/components/common/Accordion/hooks/useAccordionController.d.ts +2 -1
- package/dist/components/common/Accordion/index.d.ts +18 -4
- package/dist/components/common/Accordion/types/AccordionControllerState.d.ts +1 -0
- package/dist/components/common/Card/index.d.ts +3 -0
- package/dist/components/common/CheckboxMark/index.d.ts +8 -0
- package/dist/components/common/DataPagination/components/ExpandButton.d.ts +7 -0
- package/dist/components/common/DataPagination/components/PaginationButton.d.ts +2 -1
- package/dist/components/common/DataPagination/index.d.ts +13 -3
- package/dist/components/common/DataPagination/paginationModel.d.ts +4 -0
- package/dist/components/common/Divider/index.d.ts +6 -0
- package/dist/components/common/EmptyState/index.d.ts +21 -0
- package/dist/components/common/IconWithSquareBackground/index.d.ts +2 -2
- package/dist/components/common/ImageCard/index.d.ts +5 -0
- package/dist/components/common/LinkTile/index.d.ts +11 -0
- package/dist/components/common/RadioMark/index.d.ts +8 -0
- package/dist/components/common/StepCard/StepCardFooter/index.d.ts +1 -1
- package/dist/components/common/TitleBlock/types.d.ts +4 -2
- package/dist/components/form/components/FormControlWrapper/index.d.ts +2 -1
- package/dist/components/form/inputs/Datepicker/RangeDatepicker.d.ts +23 -0
- package/dist/components/form/inputs/Datepicker/SingleDatepicker.d.ts +24 -0
- package/dist/components/form/inputs/Datepicker/components/CalendarViewsHeader.d.ts +18 -0
- package/dist/components/form/inputs/Datepicker/index.d.ts +10 -14
- package/dist/components/form/inputs/Datepicker/rangeModel.d.ts +4 -0
- package/dist/components/form/inputs/FileDropzone.d.ts +2 -2
- package/dist/components/form/inputs/RadioButtonGroup.d.ts +1 -0
- package/dist/components/form/inputs/Select/Select.styles.d.ts +84 -0
- package/dist/components/form/inputs/Select/components/OptionCheckbox.d.ts +2 -1
- package/dist/components/form/inputs/TextField.d.ts +27 -12
- package/dist/components/form/inputs/TextField.styles.d.ts +101 -0
- package/dist/components/layout/ServiceWizardStepper/stepperTokens.d.ts +5 -0
- package/dist/components/loaders/Loader/index.d.ts +12 -9
- package/dist/components/overlays/BottomSheet/index.d.ts +3 -2
- package/dist/components/overlays/Dialog/index.d.ts +1 -1
- package/dist/components/storybook/FileUploadTokenPreview.d.ts +4 -0
- package/dist/components/storybook/TabsTokenPreview.d.ts +3 -0
- package/dist/components/storybook/TokenDocs.d.ts +74 -0
- package/dist/library/index.d.ts +30 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +2 -2
- package/dist/registrucentras-rc-ses-react-components.js +11143 -8378
- package/dist/theme/backdropTokens.d.ts +6 -0
- package/dist/theme/borderTokens.d.ts +33 -0
- package/dist/theme/cards.d.ts +42 -73
- package/dist/theme/colorTokens.d.ts +146 -0
- package/dist/theme/effectTokens.d.ts +9 -0
- package/dist/theme/layoutTokens.d.ts +12 -0
- package/dist/theme/light/MuiAccordion.d.ts +2 -2
- package/dist/theme/light/MuiAccordionSummary.d.ts +19 -0
- package/dist/theme/light/MuiButton.d.ts +7 -0
- package/dist/theme/light/MuiInputBase.d.ts +2 -0
- package/dist/theme/light/MuiPickerPopper.d.ts +3 -0
- package/dist/theme/light/MuiTypography.d.ts +0 -14
- package/dist/theme/palette.d.ts +8 -0
- package/dist/theme/sizeTokens.d.ts +20 -0
- package/dist/theme/spacingRoleBasedTokens.d.ts +38 -0
- package/dist/theme/spacingTokens.d.ts +97 -0
- package/dist/theme/tokenTheme.d.ts +13 -0
- package/dist/theme/typographyTokens.d.ts +104 -0
- package/package.json +2 -2
- package/src/assets/icons/phosphorIcons.ts +1 -0
- package/src/components/common/Accordion/hooks/useAccordionController.tsx +39 -7
- package/src/components/common/Accordion/index.test.tsx +132 -0
- package/src/components/common/Accordion/index.tsx +302 -25
- package/src/components/common/Accordion/types/AccordionControllerState.ts +1 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +3 -3
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +8 -3
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +3 -2
- package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +3 -3
- package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +23 -19
- package/src/components/common/AdvancedList/index.test.tsx +4 -2
- package/src/components/common/Alert/index.tsx +10 -6
- package/src/components/common/Badge/index.tsx +50 -37
- package/src/components/common/Button/index.tsx +12 -10
- package/src/components/common/Card/index.tsx +6 -1
- package/src/components/common/CardShell/index.test.tsx +16 -6
- package/src/components/common/CheckboxMark/index.tsx +86 -0
- package/src/components/common/DataPagination/components/DataPaginationSkeleton.tsx +9 -7
- package/src/components/common/DataPagination/components/ExpandButton.tsx +48 -0
- package/src/components/common/DataPagination/components/PaginationButton.tsx +48 -21
- package/src/components/common/DataPagination/index.test.tsx +229 -12
- package/src/components/common/DataPagination/index.tsx +135 -60
- package/src/components/common/DataPagination/paginationModel.ts +35 -0
- package/src/components/common/Divider/index.test.tsx +33 -0
- package/src/components/common/Divider/index.tsx +52 -0
- package/src/components/common/EmptyState/index.test.tsx +56 -0
- package/src/components/common/EmptyState/index.tsx +211 -0
- package/src/components/common/FilterChip/index.tsx +24 -19
- package/src/components/common/IconWithCircularBackground.tsx +24 -6
- package/src/components/common/IconWithSquareBackground/index.test.tsx +14 -2
- package/src/components/common/IconWithSquareBackground/index.tsx +36 -17
- package/src/components/common/ImageCard/index.test.tsx +16 -0
- package/src/components/common/ImageCard/index.tsx +54 -1
- package/src/components/common/LinkTile/index.test.tsx +57 -0
- package/src/components/common/LinkTile/index.tsx +136 -0
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +39 -23
- package/src/components/common/ListWithIcons/index.test.tsx +20 -9
- package/src/components/common/ListWithIcons/index.tsx +6 -6
- package/src/components/common/Popover/index.tsx +11 -1
- package/src/components/common/RadioMark/index.tsx +76 -0
- package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +49 -25
- package/src/components/common/SegmentedControl/index.tsx +10 -6
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +7 -5
- package/src/components/common/SelectableCardList/index.test.tsx +8 -6
- package/src/components/common/SelectionMarks.test.tsx +92 -0
- package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +20 -11
- package/src/components/common/ServiceLinks/index.tsx +3 -3
- package/src/components/common/SideNav/SideNavLayout.tsx +6 -1
- package/src/components/common/SideNav/components/SideNavPill.tsx +24 -12
- package/src/components/common/SideNav/components/SideNavPillList.tsx +18 -12
- package/src/components/common/SideNav/components/SideNavRow.tsx +22 -15
- package/src/components/common/SideNav/index.tsx +10 -9
- package/src/components/common/Snackbar/config.ts +27 -8
- package/src/components/common/Snackbar/index.tsx +39 -16
- package/src/components/common/StepCard/StepCardFooter/index.tsx +28 -6
- package/src/components/common/StepCard/index.tsx +18 -6
- package/src/components/common/Switch/index.tsx +10 -4
- package/src/components/common/Tabs/TabPanel.tsx +6 -3
- package/src/components/common/Tabs/TabsWrapper.tsx +15 -7
- package/src/components/common/TitleBlock/index.test.tsx +14 -17
- package/src/components/common/TitleBlock/index.tsx +120 -15
- package/src/components/common/TitleBlock/types.ts +4 -2
- package/src/components/common/Tooltip/index.tsx +32 -3
- package/src/components/form/components/FormControlWrapper/index.tsx +43 -14
- package/src/components/form/inputs/CheckboxFormControl.tsx +25 -13
- package/src/components/form/inputs/Datepicker/RangeDatepicker.tsx +356 -0
- package/src/components/form/inputs/Datepicker/SingleDatepicker.tsx +207 -0
- package/src/components/form/inputs/Datepicker/components/CalendarViewsHeader.tsx +335 -0
- package/src/components/form/inputs/Datepicker/components/RcSesDatepickerCalendarHeader.tsx +22 -10
- package/src/components/form/inputs/Datepicker/index.test.tsx +23 -18
- package/src/components/form/inputs/Datepicker/index.tsx +20 -150
- package/src/components/form/inputs/Datepicker/rangeModel.test.ts +35 -0
- package/src/components/form/inputs/Datepicker/rangeModel.ts +25 -0
- package/src/components/form/inputs/FileDropzone.tsx +73 -46
- package/src/components/form/inputs/FileUpload.tsx +25 -16
- package/src/components/form/inputs/NumberStepper.tsx +36 -14
- package/src/components/form/inputs/PhoneInputFormControl/components/AutocompleteInput.tsx +10 -5
- package/src/components/form/inputs/PhoneInputFormControl/components/ListboxComponent.tsx +7 -1
- package/src/components/form/inputs/PhoneInputFormControl/components/PopperComponent.tsx +5 -2
- package/src/components/form/inputs/PhoneInputFormControl/components/RowComponent.tsx +9 -5
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +48 -24
- package/src/components/form/inputs/RadioButtonGroup.tsx +14 -6
- package/src/components/form/inputs/Select/Select.styles.ts +76 -0
- package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +6 -33
- package/src/components/form/inputs/Select/index.tsx +124 -86
- package/src/components/form/inputs/SimpleCheckbox.tsx +10 -3
- package/src/components/form/inputs/TextField.presets.test.tsx +284 -0
- package/src/components/form/inputs/TextField.styles.ts +96 -0
- package/src/components/form/inputs/TextField.test.tsx +153 -0
- package/src/components/form/inputs/TextField.tsx +315 -42
- package/src/components/layout/Footer/index.test.tsx +1 -1
- package/src/components/layout/Footer/index.tsx +17 -7
- package/src/components/layout/ServiceFormActions.tsx +5 -1
- package/src/components/layout/ServiceFormContainer/AccordionFormContainer/index.tsx +3 -3
- package/src/components/layout/ServiceHeader.tsx +19 -19
- package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +10 -10
- package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +8 -5
- package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.tsx +22 -7
- package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.tsx +15 -11
- package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +28 -11
- package/src/components/layout/ServiceWizardStepper/stepperTokens.ts +8 -0
- package/src/components/loaders/FullPageLoader/index.test.tsx +18 -7
- package/src/components/loaders/FullPageLoader/index.tsx +14 -9
- package/src/components/loaders/Loader/index.tsx +48 -17
- package/src/components/overlays/BottomSheet/index.test.tsx +36 -3
- package/src/components/overlays/BottomSheet/index.tsx +54 -21
- package/src/components/overlays/Dialog/index.tsx +5 -23
- package/src/components/overlays/Drawer/index.tsx +29 -14
- package/src/components/overlays/Modal/index.tsx +46 -8
- package/src/components/storybook/FileUploadTokenPreview.tsx +68 -0
- package/src/components/storybook/TabsTokenPreview.tsx +58 -0
- package/src/components/storybook/TokenDocs.tsx +347 -0
- package/src/examples/MultipleStepForm/components/TermsAndConditionsForm.tsx +5 -1
- package/src/i18n/namespaces/input/en.json +48 -4
- package/src/i18n/namespaces/input/lt.json +48 -4
- package/src/library/index.ts +50 -0
- package/src/stories/atoms/Badge.stories.tsx +2 -1
- package/src/stories/atoms/Button.stories.tsx +124 -6
- package/src/stories/atoms/CheckboxMark.stories.tsx +79 -0
- package/src/stories/atoms/Divider.stories.tsx +129 -0
- package/src/stories/atoms/FilterChip.stories.tsx +9 -1
- package/src/stories/atoms/IconWithSquareBackground.stories.tsx +7 -7
- package/src/stories/atoms/Icons.stories.tsx +1 -1
- package/src/stories/atoms/NumberStepper.stories.tsx +44 -0
- package/src/stories/atoms/PhoneInput.stories.tsx +42 -0
- package/src/stories/atoms/RadioMark.stories.tsx +132 -0
- package/src/stories/atoms/Select.stories.tsx +139 -2
- package/src/stories/atoms/SimpleCheckbox.stories.tsx +74 -0
- package/src/stories/atoms/Switch.stories.tsx +46 -1
- package/src/stories/atoms/TextField.stories.tsx +508 -0
- package/src/stories/atoms/Tooltip.stories.tsx +5 -0
- package/src/stories/fixtures/foundations/Borders.stories.tsx +84 -0
- package/src/stories/fixtures/foundations/Effects.stories.tsx +204 -0
- package/src/stories/fixtures/foundations/Layout.stories.tsx +76 -0
- package/src/stories/fixtures/foundations/Sizes.stories.tsx +42 -0
- package/src/stories/fixtures/foundations/Spacing.stories.tsx +48 -0
- package/src/stories/fixtures/foundations/Typography.stories.tsx +49 -0
- package/src/stories/foundations/Borders.stories.tsx +179 -0
- package/src/stories/foundations/Colors.stories.tsx +253 -0
- package/src/stories/foundations/Effects.stories.tsx +116 -0
- package/src/stories/foundations/Layout.stories.tsx +177 -0
- package/src/stories/foundations/Sizes.stories.tsx +123 -0
- package/src/stories/foundations/Spacing.stories.tsx +159 -0
- package/src/stories/foundations/ThemeAdapter.stories.tsx +389 -0
- package/src/stories/foundations/Typography.stories.tsx +148 -0
- package/src/stories/molecules/Alert.stories.tsx +18 -0
- package/src/stories/molecules/Breadcrumbs.stories.tsx +51 -0
- package/src/stories/molecules/Card.stories.tsx +1 -1
- package/src/stories/molecules/CardShell.stories.tsx +1 -0
- package/src/stories/molecules/DatePicker.stories.tsx +133 -3
- package/src/stories/molecules/EmptyState.stories.tsx +106 -0
- package/src/stories/molecules/FormControlWrapper.stories.tsx +59 -0
- package/src/stories/molecules/LinkTile.stories.tsx +151 -0
- package/src/stories/molecules/ListWithIcons.stories.tsx +27 -2
- package/src/stories/molecules/RadioButtonGroup.stories.tsx +23 -0
- package/src/stories/molecules/SegmentedControl.stories.tsx +62 -1
- package/src/stories/molecules/Tabs.stories.tsx +4 -0
- package/src/stories/molecules/TitleBlock.stories.tsx +16 -16
- package/src/stories/organisms/Accordion.stories.tsx +132 -0
- package/src/stories/organisms/AdvancedListItemShell.stories.tsx +63 -23
- package/src/stories/organisms/BottomSheet.stories.tsx +48 -1
- package/src/stories/organisms/DataPagination.stories.tsx +127 -3
- package/src/stories/organisms/Dialog.stories.tsx +13 -0
- package/src/stories/organisms/FileDropzone.stories.tsx +6 -0
- package/src/stories/organisms/FileUpload.stories.tsx +4 -0
- package/src/stories/organisms/Footer.stories.tsx +20 -0
- package/src/stories/organisms/Modal.stories.tsx +53 -0
- package/src/stories/organisms/ServiceHeader.stories.tsx +25 -3
- package/src/stories/organisms/ServiceLinks.stories.tsx +1 -1
- package/src/stories/organisms/ServiceWizardStepper.stories.tsx +37 -1
- package/src/stories/organisms/SideNav.stories.tsx +8 -1
- package/src/theme/backdropTokens.test.ts +11 -0
- package/src/theme/backdropTokens.ts +11 -0
- package/src/theme/borderTokens.test.ts +59 -0
- package/src/theme/borderTokens.ts +36 -0
- package/src/theme/cards.ts +28 -28
- package/src/theme/colorTokens.test.ts +66 -0
- package/src/theme/colorTokens.ts +87 -0
- package/src/theme/effectTokens.test.ts +29 -0
- package/src/theme/effectTokens.ts +11 -0
- package/src/theme/layoutTokens.test.ts +42 -0
- package/src/theme/layoutTokens.ts +14 -0
- package/src/theme/light/MuiAccordion.tsx +30 -26
- package/src/theme/light/MuiAccordionDetails.ts +10 -5
- package/src/theme/light/MuiAccordionSummary.tsx +31 -17
- package/src/theme/light/MuiAlert.tsx +42 -65
- package/src/theme/light/MuiAutocomplete.ts +14 -7
- package/src/theme/light/MuiBreadcrumbs.tsx +17 -9
- package/src/theme/light/MuiButton.tsx +213 -204
- package/src/theme/light/MuiCard.tsx +5 -4
- package/src/theme/light/MuiCheckbox.ts +45 -14
- package/src/theme/light/MuiChip.tsx +3 -1
- package/src/theme/light/MuiDialog.ts +45 -6
- package/src/theme/light/MuiFormControl.ts +19 -9
- package/src/theme/light/MuiFormControlLabel.ts +16 -25
- package/src/theme/light/MuiFormGroup.ts +29 -26
- package/src/theme/light/MuiFormHelperText.ts +15 -4
- package/src/theme/light/MuiFormLabel.ts +20 -20
- package/src/theme/light/MuiInputBase.ts +49 -84
- package/src/theme/light/MuiOutlinedInput.ts +50 -6
- package/src/theme/light/MuiPagination.ts +21 -21
- package/src/theme/light/MuiPickerPopper.ts +17 -0
- package/src/theme/light/MuiPickersLayout.ts +63 -34
- package/src/theme/light/MuiPickersOutlinedInput.ts +38 -38
- package/src/theme/light/MuiPopover.ts +3 -1
- package/src/theme/light/MuiRadio.tsx +35 -52
- package/src/theme/light/MuiStepper.ts +21 -17
- package/src/theme/light/MuiSwitch.tsx +27 -23
- package/src/theme/light/MuiTab.tsx +27 -18
- package/src/theme/light/MuiTableCell.ts +4 -2
- package/src/theme/light/MuiTabs.tsx +11 -9
- package/src/theme/light/MuiTooltip.ts +2 -1
- package/src/theme/light/MuiTypography.tsx +0 -17
- package/src/theme/light/index.tsx +2 -0
- package/src/theme/light/themePalette.tsx +1 -0
- package/src/theme/palette.tsx +9 -0
- package/src/theme/sizeTokens.test.ts +37 -0
- package/src/theme/sizeTokens.ts +21 -0
- package/src/theme/spacingRoleBasedTokens.ts +41 -0
- package/src/theme/spacingTokens.test.ts +58 -0
- package/src/theme/spacingTokens.ts +114 -0
- package/src/theme/tokenTheme.test.tsx +402 -0
- package/src/theme/tokenTheme.ts +429 -0
- package/src/theme/tokens.css +476 -0
- package/src/theme/tokens.test.ts +174 -0
- package/src/theme/typographyTokens.test.ts +120 -0
- package/src/theme/typographyTokens.ts +119 -0
- package/dist/theme/spacing.d.ts +0 -4
- package/src/stories/foundations/Colors.mdx +0 -127
- package/src/theme/spacing.ts +0 -5
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { IconButton, InputAdornment } from '@mui/material'
|
|
2
|
+
import type { DatePickerProps } from '@mui/x-date-pickers/DatePicker'
|
|
3
|
+
import { DatePicker } from '@mui/x-date-pickers/DatePicker'
|
|
4
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks'
|
|
5
|
+
import { parseISO } from 'date-fns'
|
|
6
|
+
import { fromZonedTime } from 'date-fns-tz'
|
|
7
|
+
import React, { useEffect, useMemo } from 'react'
|
|
8
|
+
import { UseControllerProps, useController } from 'react-hook-form'
|
|
9
|
+
import { useTranslation } from 'react-i18next'
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
11
|
+
|
|
12
|
+
import { CalendarBlankIcon, XCircleFillIcon } from '@/assets/icons/phosphorIcons'
|
|
13
|
+
import { borderTokens } from '@/theme/borderTokens'
|
|
14
|
+
import { spacingRoleBasedTokens } from '@/theme/spacingRoleBasedTokens'
|
|
15
|
+
|
|
16
|
+
import RcSesFormControlWrapper, {
|
|
17
|
+
RcSesFormControlWrapperProps,
|
|
18
|
+
} from '../../components/FormControlWrapper'
|
|
19
|
+
import CalendarViewsHeader, {
|
|
20
|
+
calendarViewsStyles,
|
|
21
|
+
} from './components/CalendarViewsHeader'
|
|
22
|
+
import RcSesDatepickerActionBar from './components/RcSesDatepickerActionBar'
|
|
23
|
+
|
|
24
|
+
type TFieldProps = UseControllerProps<any, any>
|
|
25
|
+
type TWrapperProps = RcSesFormControlWrapperProps
|
|
26
|
+
type ImmediateWrapperProps = 'label' | 'errors'
|
|
27
|
+
|
|
28
|
+
export type SingleDatepickerProps = TFieldProps &
|
|
29
|
+
Pick<TWrapperProps, ImmediateWrapperProps> & {
|
|
30
|
+
id?: string
|
|
31
|
+
clearable?: boolean
|
|
32
|
+
slotProps?: {
|
|
33
|
+
datepicker?: DatePickerProps
|
|
34
|
+
wrapper?: Partial<Omit<TWrapperProps, ImmediateWrapperProps>>
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const RcSesDatepicker = React.forwardRef<HTMLInputElement, SingleDatepickerProps>(
|
|
39
|
+
(props, ref) => {
|
|
40
|
+
const { t } = useTranslation('input', { keyPrefix: 'components.RcSesDatepicker' })
|
|
41
|
+
|
|
42
|
+
const { id: idProp, clearable, errors, label, slotProps, ...controllerProps } = props
|
|
43
|
+
|
|
44
|
+
// v9 no longer exports MuiPickersAdapterContext from LocalizationProvider;
|
|
45
|
+
// usePickerAdapter is the public replacement for the `utils` adapter.
|
|
46
|
+
const dateAdapter = usePickerAdapter()
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
field: { onChange, value, disabled },
|
|
50
|
+
} = useController(controllerProps)
|
|
51
|
+
|
|
52
|
+
const id = useMemo(() => idProp ?? uuidv4(), [idProp])
|
|
53
|
+
|
|
54
|
+
const [modelValue, setModelValue] = React.useState<Date | null>(
|
|
55
|
+
value ? parseISO(value) : null,
|
|
56
|
+
)
|
|
57
|
+
const [open, setOpen] = React.useState(false)
|
|
58
|
+
const handleOpen = () => {
|
|
59
|
+
setOpen(true)
|
|
60
|
+
slotProps?.datepicker?.onOpen?.()
|
|
61
|
+
}
|
|
62
|
+
const handleClose = () => {
|
|
63
|
+
setOpen(false)
|
|
64
|
+
slotProps?.datepicker?.onClose?.()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleOnChange = (newValue: Date | null) => {
|
|
68
|
+
try {
|
|
69
|
+
onChange((newValue && fromZonedTime(newValue, 'UTC').toISOString()) ?? '')
|
|
70
|
+
} catch {
|
|
71
|
+
onChange(null)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (value !== modelValue) setModelValue(value ? parseISO(value) : null)
|
|
77
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
+
}, [value])
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<RcSesFormControlWrapper
|
|
82
|
+
id={id}
|
|
83
|
+
errors={errors}
|
|
84
|
+
label={label}
|
|
85
|
+
required={!!props?.rules?.required}
|
|
86
|
+
{...slotProps?.wrapper}
|
|
87
|
+
>
|
|
88
|
+
<DatePicker
|
|
89
|
+
inputRef={ref}
|
|
90
|
+
closeOnSelect
|
|
91
|
+
dayOfWeekFormatter={(date: Date) =>
|
|
92
|
+
dateAdapter.format(date, 'weekdayShort').substring(0, 2)
|
|
93
|
+
}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
onChange={handleOnChange}
|
|
96
|
+
format={dateAdapter.formats.keyboardDate}
|
|
97
|
+
views={['day']}
|
|
98
|
+
openTo='day'
|
|
99
|
+
showDaysOutsideCurrentMonth
|
|
100
|
+
slots={{
|
|
101
|
+
actionBar: RcSesDatepickerActionBar,
|
|
102
|
+
calendarHeader: CalendarViewsHeader,
|
|
103
|
+
openPickerIcon: CalendarBlankIcon,
|
|
104
|
+
}}
|
|
105
|
+
{...(slotProps?.datepicker ?? {})}
|
|
106
|
+
open={slotProps?.datepicker?.open ?? open}
|
|
107
|
+
onOpen={handleOpen}
|
|
108
|
+
onClose={handleClose}
|
|
109
|
+
slotProps={{
|
|
110
|
+
mobilePaper: {
|
|
111
|
+
...slotProps?.datepicker?.slotProps?.mobilePaper,
|
|
112
|
+
sx: [
|
|
113
|
+
{
|
|
114
|
+
'&&': {
|
|
115
|
+
minWidth: '340px',
|
|
116
|
+
maxWidth: 'calc(100vw - 32px)',
|
|
117
|
+
margin: spacingRoleBasedTokens['space-16'],
|
|
118
|
+
borderRadius: borderTokens['radius-12'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
...(Array.isArray(slotProps?.datepicker?.slotProps?.mobilePaper?.sx)
|
|
122
|
+
? slotProps.datepicker.slotProps.mobilePaper.sx
|
|
123
|
+
: [slotProps?.datepicker?.slotProps?.mobilePaper?.sx ?? {}]),
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
field: {
|
|
127
|
+
openPickerButtonPosition: 'start',
|
|
128
|
+
...(slotProps?.datepicker?.slotProps?.field ?? {}),
|
|
129
|
+
},
|
|
130
|
+
layout: {
|
|
131
|
+
...slotProps?.datepicker?.slotProps?.layout,
|
|
132
|
+
sx: [
|
|
133
|
+
{ '.MuiDateCalendar-root': calendarViewsStyles, minWidth: '340px' },
|
|
134
|
+
...(Array.isArray(slotProps?.datepicker?.slotProps?.layout?.sx)
|
|
135
|
+
? slotProps.datepicker.slotProps.layout.sx
|
|
136
|
+
: [slotProps?.datepicker?.slotProps?.layout?.sx ?? {}]),
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
actionBar: {
|
|
140
|
+
actions: [],
|
|
141
|
+
...(slotProps?.datepicker?.slotProps?.actionBar ?? {}),
|
|
142
|
+
},
|
|
143
|
+
inputAdornment: {
|
|
144
|
+
position: 'start',
|
|
145
|
+
sx: { mr: spacingRoleBasedTokens['space-0'] },
|
|
146
|
+
...(slotProps?.datepicker?.slotProps?.inputAdornment ?? {}),
|
|
147
|
+
},
|
|
148
|
+
textField: (ownerState) => {
|
|
149
|
+
const consumerProps = slotProps?.datepicker?.slotProps?.textField
|
|
150
|
+
const textFieldProps =
|
|
151
|
+
typeof consumerProps === 'function'
|
|
152
|
+
? consumerProps(ownerState)
|
|
153
|
+
: consumerProps
|
|
154
|
+
return {
|
|
155
|
+
id,
|
|
156
|
+
error: !!errors,
|
|
157
|
+
fullWidth: true,
|
|
158
|
+
...textFieldProps,
|
|
159
|
+
onClick: (event) => {
|
|
160
|
+
textFieldProps?.onClick?.(event)
|
|
161
|
+
if (
|
|
162
|
+
!event.defaultPrevented &&
|
|
163
|
+
!disabled &&
|
|
164
|
+
!slotProps?.datepicker?.disabled &&
|
|
165
|
+
!slotProps?.datepicker?.disableOpenPicker &&
|
|
166
|
+
!(event.target as Element).closest('button')
|
|
167
|
+
) {
|
|
168
|
+
handleOpen()
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
slotProps: {
|
|
173
|
+
input: {
|
|
174
|
+
endAdornment: !!value && clearable && (
|
|
175
|
+
<InputAdornment position='end'>
|
|
176
|
+
<IconButton
|
|
177
|
+
aria-label={t('aria.clearValue')}
|
|
178
|
+
onClick={(event) => {
|
|
179
|
+
event.stopPropagation()
|
|
180
|
+
handleOnChange(null)
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<XCircleFillIcon />
|
|
184
|
+
</IconButton>
|
|
185
|
+
</InputAdornment>
|
|
186
|
+
),
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
toolbar: { hidden: true },
|
|
192
|
+
}}
|
|
193
|
+
value={modelValue}
|
|
194
|
+
sx={{
|
|
195
|
+
'.MuiInputBase-input': {
|
|
196
|
+
paddingLeft: spacingRoleBasedTokens['space-0'],
|
|
197
|
+
paddingRight: spacingRoleBasedTokens['space-0'],
|
|
198
|
+
},
|
|
199
|
+
...(slotProps?.datepicker?.sx ?? {}),
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
202
|
+
</RcSesFormControlWrapper>
|
|
203
|
+
)
|
|
204
|
+
},
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
export default RcSesDatepicker
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { Box, IconButton } from '@mui/material'
|
|
2
|
+
import { PickerDay } from '@mui/x-date-pickers/PickerDay'
|
|
3
|
+
import type { PickersCalendarHeaderProps } from '@mui/x-date-pickers/PickersCalendarHeader'
|
|
4
|
+
import { usePickerAdapter, usePickerTranslations } from '@mui/x-date-pickers/hooks'
|
|
5
|
+
import { addMonths, endOfMonth, endOfYear, startOfMonth } from 'date-fns'
|
|
6
|
+
import React, { useLayoutEffect, useRef, useState } from 'react'
|
|
7
|
+
import { useTranslation } from 'react-i18next'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
CaretDownIcon,
|
|
11
|
+
CaretLeftIcon,
|
|
12
|
+
CaretRightIcon,
|
|
13
|
+
} from '@/assets/icons/phosphorIcons'
|
|
14
|
+
import Button from '@/components/common/Button'
|
|
15
|
+
import { borderTokens } from '@/theme/borderTokens'
|
|
16
|
+
import { colorTokens } from '@/theme/colorTokens'
|
|
17
|
+
import { effectTokens } from '@/theme/effectTokens'
|
|
18
|
+
import { spacingRoleBasedTokens } from '@/theme/spacingRoleBasedTokens'
|
|
19
|
+
import { spacingTokens } from '@/theme/spacingTokens'
|
|
20
|
+
import { typographyTokens } from '@/theme/typographyTokens'
|
|
21
|
+
|
|
22
|
+
// A six-week calendar with 44px days determines the shared height for all views.
|
|
23
|
+
export const calendarViewsStyles = {
|
|
24
|
+
position: 'relative',
|
|
25
|
+
width: '340px',
|
|
26
|
+
maxWidth: '100%',
|
|
27
|
+
height: '388px',
|
|
28
|
+
minHeight: '388px',
|
|
29
|
+
maxHeight: '388px',
|
|
30
|
+
boxSizing: 'border-box',
|
|
31
|
+
// Contain outgoing month slides; the inner padding leaves room for focus rings.
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
padding: spacingRoleBasedTokens['space-16'],
|
|
34
|
+
'&:has([data-calendar-view="months"]) [role="grid"]:not([data-calendar-options]), &:has([data-calendar-view="years"]) [role="grid"]:not([data-calendar-options])':
|
|
35
|
+
{ display: 'none' },
|
|
36
|
+
} as const
|
|
37
|
+
|
|
38
|
+
type View = 'calendar' | 'months' | 'years'
|
|
39
|
+
|
|
40
|
+
function CalendarViewsHeader(props: PickersCalendarHeaderProps) {
|
|
41
|
+
const {
|
|
42
|
+
currentMonth,
|
|
43
|
+
onMonthChange,
|
|
44
|
+
minDate,
|
|
45
|
+
maxDate,
|
|
46
|
+
disablePast,
|
|
47
|
+
disableFuture,
|
|
48
|
+
disabled,
|
|
49
|
+
labelId,
|
|
50
|
+
} = props
|
|
51
|
+
const adapter = usePickerAdapter()
|
|
52
|
+
const translations = usePickerTranslations()
|
|
53
|
+
const { t } = useTranslation('input', { keyPrefix: 'components.RcSesDatepicker.views' })
|
|
54
|
+
const [view, setView] = useState<View>('calendar')
|
|
55
|
+
const year = currentMonth.getFullYear()
|
|
56
|
+
const month = currentMonth.getMonth()
|
|
57
|
+
const [block, setBlock] = useState(() => Math.floor(year / 10) * 10)
|
|
58
|
+
const [focused, setFocused] = useState(month)
|
|
59
|
+
const grid = useRef<HTMLDivElement>(null)
|
|
60
|
+
const root = useRef<HTMLDivElement>(null)
|
|
61
|
+
const previousView = useRef<View>('calendar')
|
|
62
|
+
const now = new Date()
|
|
63
|
+
const lower = disablePast && now > minDate ? now : minDate
|
|
64
|
+
const upper = disableFuture && now < maxDate ? now : maxDate
|
|
65
|
+
|
|
66
|
+
const isDisabled = (index: number) => {
|
|
67
|
+
const date =
|
|
68
|
+
view === 'years' ? new Date(block + index, 0, 1) : new Date(year, index, 1)
|
|
69
|
+
const end = view === 'years' ? endOfYear(date) : endOfMonth(date)
|
|
70
|
+
return !!disabled || date > upper || end < lower
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
if (view !== 'calendar') {
|
|
75
|
+
grid.current?.querySelector<HTMLButtonElement>('button[tabindex="0"]')?.focus()
|
|
76
|
+
} else if (previousView.current !== 'calendar') {
|
|
77
|
+
// Restore focus in the same commit that removes the month grid. Waiting
|
|
78
|
+
// for an animation frame can send the next Escape to the document body.
|
|
79
|
+
const calendar = root.current?.closest('.MuiDateCalendar-root')
|
|
80
|
+
const day =
|
|
81
|
+
calendar?.querySelector<HTMLButtonElement>(
|
|
82
|
+
'button[data-timestamp][tabindex="0"]:not(.MuiPickerDay-dayOutsideMonth)',
|
|
83
|
+
) ??
|
|
84
|
+
calendar?.querySelector<HTMLButtonElement>(
|
|
85
|
+
'button[data-timestamp]:not(:disabled):not(.MuiPickerDay-dayOutsideMonth)',
|
|
86
|
+
)
|
|
87
|
+
day?.focus()
|
|
88
|
+
}
|
|
89
|
+
previousView.current = view
|
|
90
|
+
}, [view, block])
|
|
91
|
+
|
|
92
|
+
const goTo = (next: View) => {
|
|
93
|
+
if (next === 'years') {
|
|
94
|
+
setBlock(Math.floor(year / 10) * 10)
|
|
95
|
+
setFocused(year - Math.floor(year / 10) * 10)
|
|
96
|
+
}
|
|
97
|
+
if (next === 'months') setFocused(month)
|
|
98
|
+
setView(next)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const select = (index: number) => {
|
|
102
|
+
if (isDisabled(index)) return
|
|
103
|
+
const date =
|
|
104
|
+
view === 'years' ? new Date(block + index, month, 1) : new Date(year, index, 1)
|
|
105
|
+
// Navigation changes the visible period, never the selected day/range.
|
|
106
|
+
onMonthChange(date)
|
|
107
|
+
goTo(view === 'years' ? 'months' : 'calendar')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const keyDown = (event: React.KeyboardEvent<HTMLButtonElement>, index: number) => {
|
|
111
|
+
const offsets: Record<string, number> = {
|
|
112
|
+
ArrowLeft: -1,
|
|
113
|
+
ArrowRight: 1,
|
|
114
|
+
ArrowUp: -3,
|
|
115
|
+
ArrowDown: 3,
|
|
116
|
+
Home: -(index % 3),
|
|
117
|
+
End: 2 - (index % 3),
|
|
118
|
+
}
|
|
119
|
+
if (!(event.key in offsets)) return
|
|
120
|
+
event.preventDefault()
|
|
121
|
+
let next = index + offsets[event.key]
|
|
122
|
+
const step = offsets[event.key] < 0 ? -1 : 1
|
|
123
|
+
while (next >= 0 && next < 12 && isDisabled(next)) next += step
|
|
124
|
+
if (next < 0 || next > 11) return
|
|
125
|
+
setFocused(next)
|
|
126
|
+
grid.current
|
|
127
|
+
?.querySelector<HTMLButtonElement>(`button[data-index="${next}"]`)
|
|
128
|
+
?.focus()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const previousDisabled =
|
|
132
|
+
view === 'years'
|
|
133
|
+
? block <= lower.getFullYear()
|
|
134
|
+
: view === 'months' || endOfMonth(addMonths(currentMonth, -1)) < lower
|
|
135
|
+
const nextDisabled =
|
|
136
|
+
view === 'years'
|
|
137
|
+
? block + 11 >= upper.getFullYear()
|
|
138
|
+
: view === 'months' || startOfMonth(addMonths(currentMonth, 1)) > upper
|
|
139
|
+
const navigate = (direction: number) => {
|
|
140
|
+
if (view === 'years') {
|
|
141
|
+
setBlock(block + direction * 12)
|
|
142
|
+
setFocused(direction > 0 ? 0 : 11)
|
|
143
|
+
} else onMonthChange(addMonths(currentMonth, direction))
|
|
144
|
+
}
|
|
145
|
+
let heading = `${adapter.format(currentMonth, 'month')} ${adapter.format(currentMonth, 'year')}`
|
|
146
|
+
if (view === 'months') heading = String(year)
|
|
147
|
+
if (view === 'years') heading = `${block} - ${block + 11}`
|
|
148
|
+
const viewName = t(view)
|
|
149
|
+
const selectedIndex = view === 'years' ? year - block : month
|
|
150
|
+
let tabStop = focused
|
|
151
|
+
if (isDisabled(tabStop))
|
|
152
|
+
tabStop = Array.from({ length: 12 }, (_, i) => i).find((i) => !isDisabled(i)) ?? -1
|
|
153
|
+
|
|
154
|
+
let headerAction = t('chooseMonth')
|
|
155
|
+
let nextView: View = 'months'
|
|
156
|
+
if (view === 'months') {
|
|
157
|
+
headerAction = t('chooseYear')
|
|
158
|
+
nextView = 'years'
|
|
159
|
+
}
|
|
160
|
+
if (view === 'years') headerAction = t('returnMonths')
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Box
|
|
164
|
+
ref={root}
|
|
165
|
+
data-calendar-view={view}
|
|
166
|
+
onKeyDown={(event) => {
|
|
167
|
+
if (event.key === 'Escape' && view !== 'calendar') {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
event.stopPropagation()
|
|
170
|
+
goTo(view === 'years' ? 'months' : 'calendar')
|
|
171
|
+
}
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
<Box
|
|
175
|
+
sx={{
|
|
176
|
+
display: 'flex',
|
|
177
|
+
alignItems: 'center',
|
|
178
|
+
justifyContent: 'space-between',
|
|
179
|
+
height: '44px',
|
|
180
|
+
mb: spacingRoleBasedTokens['space-12'],
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<IconButton
|
|
184
|
+
className='MuiPickersArrowSwitcher-button'
|
|
185
|
+
aria-label={view === 'years' ? t('previousYears') : translations.previousMonth}
|
|
186
|
+
disabled={!!disabled || previousDisabled}
|
|
187
|
+
onClick={() => navigate(-1)}
|
|
188
|
+
sx={{
|
|
189
|
+
width: '44px',
|
|
190
|
+
height: '44px',
|
|
191
|
+
color: colorTokens['action-link-text'],
|
|
192
|
+
visibility: view === 'months' ? 'hidden' : 'visible',
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
<CaretLeftIcon size={24} />
|
|
196
|
+
</IconButton>
|
|
197
|
+
<Button
|
|
198
|
+
variant='link'
|
|
199
|
+
aria-label={headerAction}
|
|
200
|
+
onClick={() => goTo(nextView)}
|
|
201
|
+
disabled={disabled}
|
|
202
|
+
sx={{
|
|
203
|
+
minHeight: '44px',
|
|
204
|
+
p: spacingTokens['spacing-aliases-button-padding-x-link'],
|
|
205
|
+
gap: spacingTokens['spacing-aliases-button-icon-text-gap-regular'],
|
|
206
|
+
color: colorTokens['action-link-text'],
|
|
207
|
+
fontSize: typographyTokens['font-size-button-regular'],
|
|
208
|
+
lineHeight: typographyTokens['line-height-button-regular'],
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
<span id={labelId}>{heading}</span>
|
|
212
|
+
<CaretDownIcon size={24} />
|
|
213
|
+
</Button>
|
|
214
|
+
<IconButton
|
|
215
|
+
className='MuiPickersArrowSwitcher-button'
|
|
216
|
+
aria-label={view === 'years' ? t('nextYears') : translations.nextMonth}
|
|
217
|
+
disabled={!!disabled || nextDisabled}
|
|
218
|
+
onClick={() => navigate(1)}
|
|
219
|
+
sx={{
|
|
220
|
+
width: '44px',
|
|
221
|
+
height: '44px',
|
|
222
|
+
color: colorTokens['action-link-text'],
|
|
223
|
+
visibility: view === 'months' ? 'hidden' : 'visible',
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
<CaretRightIcon size={24} />
|
|
227
|
+
</IconButton>
|
|
228
|
+
</Box>
|
|
229
|
+
<Box
|
|
230
|
+
role='status'
|
|
231
|
+
aria-live='polite'
|
|
232
|
+
aria-atomic='true'
|
|
233
|
+
sx={{
|
|
234
|
+
position: 'absolute',
|
|
235
|
+
width: '1px',
|
|
236
|
+
height: '1px',
|
|
237
|
+
overflow: 'hidden',
|
|
238
|
+
clipPath: 'inset(50%)',
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
{viewName}: {heading}
|
|
242
|
+
</Box>
|
|
243
|
+
{view !== 'calendar' && (
|
|
244
|
+
<Box
|
|
245
|
+
ref={grid}
|
|
246
|
+
data-calendar-options
|
|
247
|
+
role='grid'
|
|
248
|
+
aria-label={viewName}
|
|
249
|
+
sx={{
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
// Below the panel padding, the 44px header and its bottom margin.
|
|
252
|
+
top: `calc(${spacingRoleBasedTokens['space-16']} + 44px + ${spacingRoleBasedTokens['space-12']})`,
|
|
253
|
+
bottom: spacingRoleBasedTokens['space-16'],
|
|
254
|
+
left: spacingRoleBasedTokens['space-16'],
|
|
255
|
+
right: spacingRoleBasedTokens['space-16'],
|
|
256
|
+
display: 'flex',
|
|
257
|
+
flexDirection: 'column',
|
|
258
|
+
justifyContent: 'space-between',
|
|
259
|
+
py: spacingRoleBasedTokens['space-12'],
|
|
260
|
+
}}
|
|
261
|
+
>
|
|
262
|
+
{Array.from({ length: 4 }, (_, row) => (
|
|
263
|
+
<Box
|
|
264
|
+
key={row}
|
|
265
|
+
role='row'
|
|
266
|
+
sx={{
|
|
267
|
+
display: 'grid',
|
|
268
|
+
gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
|
|
269
|
+
gap: spacingRoleBasedTokens['space-10'],
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
{Array.from({ length: 3 }, (unused, column) => {
|
|
273
|
+
const index = row * 3 + column
|
|
274
|
+
const date =
|
|
275
|
+
view === 'years'
|
|
276
|
+
? new Date(block + index, 0, 1)
|
|
277
|
+
: new Date(year, index, 1)
|
|
278
|
+
const monthLabel = adapter.format(date, 'month')
|
|
279
|
+
const label =
|
|
280
|
+
view === 'years'
|
|
281
|
+
? String(block + index)
|
|
282
|
+
: monthLabel.charAt(0).toLocaleUpperCase() + monthLabel.slice(1)
|
|
283
|
+
return (
|
|
284
|
+
<PickerDay
|
|
285
|
+
key={index}
|
|
286
|
+
day={date}
|
|
287
|
+
today={false}
|
|
288
|
+
selected={index === selectedIndex}
|
|
289
|
+
disabled={isDisabled(index)}
|
|
290
|
+
role='gridcell'
|
|
291
|
+
aria-label={label}
|
|
292
|
+
aria-selected={index === selectedIndex}
|
|
293
|
+
data-index={index}
|
|
294
|
+
tabIndex={index === tabStop ? 0 : -1}
|
|
295
|
+
onDaySelect={() => select(index)}
|
|
296
|
+
onKeyDown={(event) => keyDown(event, index)}
|
|
297
|
+
sx={{
|
|
298
|
+
'&&': {
|
|
299
|
+
width: '100%',
|
|
300
|
+
minWidth: '44px',
|
|
301
|
+
height: '48px',
|
|
302
|
+
margin: 0,
|
|
303
|
+
transition: 'none',
|
|
304
|
+
borderRadius: borderTokens['radius-8'],
|
|
305
|
+
color: colorTokens['text-default'],
|
|
306
|
+
fontSize: typographyTokens['font-size-body-regular'],
|
|
307
|
+
lineHeight: typographyTokens['line-height-body-regular'],
|
|
308
|
+
'&:hover': { backgroundColor: colorTokens['surface-muted'] },
|
|
309
|
+
'&.Mui-selected, &.Mui-selected:hover, &.Mui-selected:focus': {
|
|
310
|
+
backgroundColor: colorTokens['control-selected'],
|
|
311
|
+
color: colorTokens['text-inverse'],
|
|
312
|
+
},
|
|
313
|
+
'&.Mui-disabled': { color: colorTokens['text-disabled'] },
|
|
314
|
+
'&.Mui-selected.Mui-focusVisible': {
|
|
315
|
+
boxShadow: `0 0 0 2px ${colorTokens['surface-base']}, 0 0 0 4px ${colorTokens['border-focus']}`,
|
|
316
|
+
},
|
|
317
|
+
'&.Mui-focusVisible': {
|
|
318
|
+
boxShadow: effectTokens['focus-ring-default'],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
323
|
+
{label}
|
|
324
|
+
</PickerDay>
|
|
325
|
+
)
|
|
326
|
+
})}
|
|
327
|
+
</Box>
|
|
328
|
+
))}
|
|
329
|
+
</Box>
|
|
330
|
+
)}
|
|
331
|
+
</Box>
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export default CalendarViewsHeader
|
|
@@ -13,33 +13,38 @@ import {
|
|
|
13
13
|
CaretLeftBoldIcon,
|
|
14
14
|
CaretRightBoldIcon,
|
|
15
15
|
} from '@/assets/icons/phosphorIcons'
|
|
16
|
-
import
|
|
16
|
+
import { borderTokens } from '@/theme/borderTokens'
|
|
17
|
+
import { colorTokens } from '@/theme/colorTokens'
|
|
18
|
+
import { effectTokens } from '@/theme/effectTokens'
|
|
19
|
+
import { spacingRoleBasedTokens } from '@/theme/spacingRoleBasedTokens'
|
|
20
|
+
import { typographyTokens } from '@/theme/typographyTokens'
|
|
17
21
|
|
|
18
22
|
const CustomCalendarHeaderRoot = styled('div')({
|
|
19
23
|
alignItems: 'center',
|
|
20
|
-
borderBottomColor:
|
|
24
|
+
borderBottomColor: colorTokens['border-subtle'],
|
|
21
25
|
borderBottomStyle: 'solid',
|
|
22
|
-
borderBottomWidth: '
|
|
26
|
+
borderBottomWidth: borderTokens['stroke-1'],
|
|
23
27
|
display: 'flex',
|
|
24
28
|
justifyContent: 'space-between',
|
|
25
|
-
marginBottom: '
|
|
26
|
-
padding: '
|
|
29
|
+
marginBottom: spacingRoleBasedTokens['space-8'],
|
|
30
|
+
padding: `${spacingRoleBasedTokens['space-4']} ${spacingRoleBasedTokens['space-8']}`,
|
|
27
31
|
})
|
|
28
32
|
|
|
29
33
|
const StepperButton = styled(IconButton)({
|
|
30
|
-
height: '
|
|
31
|
-
padding: '0
|
|
34
|
+
height: spacingRoleBasedTokens['space-48'],
|
|
35
|
+
padding: `${spacingRoleBasedTokens['space-0']} ${spacingRoleBasedTokens['space-4']}`,
|
|
32
36
|
|
|
33
37
|
path: {
|
|
34
|
-
fill:
|
|
38
|
+
fill: colorTokens['text-secondary'],
|
|
35
39
|
},
|
|
36
40
|
|
|
37
41
|
'&:hover, &:focus, &:active': {
|
|
38
42
|
backgroundColor: 'transparent',
|
|
39
43
|
path: {
|
|
40
|
-
fill:
|
|
44
|
+
fill: colorTokens['text-default'],
|
|
41
45
|
},
|
|
42
46
|
},
|
|
47
|
+
'&.Mui-focusVisible': { boxShadow: effectTokens['focus-ring-default'] },
|
|
43
48
|
})
|
|
44
49
|
|
|
45
50
|
// PickersCalendarHeaderProps is no longer generic in x-date-pickers 9.
|
|
@@ -77,7 +82,14 @@ function RcSesDatepickerCalendarHeader(props: PickersCalendarHeaderProps) {
|
|
|
77
82
|
|
|
78
83
|
<Typography
|
|
79
84
|
variant='body2'
|
|
80
|
-
sx={{
|
|
85
|
+
sx={{
|
|
86
|
+
flexGrow: 1,
|
|
87
|
+
fontSize: typographyTokens['font-size-body-regular'],
|
|
88
|
+
lineHeight: typographyTokens['line-height-body-regular'],
|
|
89
|
+
color: colorTokens['text-default'],
|
|
90
|
+
fontWeight: typographyTokens['font-weight-body-regular'],
|
|
91
|
+
textAlign: 'center',
|
|
92
|
+
}}
|
|
81
93
|
>
|
|
82
94
|
{monthLabel.charAt(0).toLocaleUpperCase() + monthLabel.substring(1)}{' '}
|
|
83
95
|
{utils.format(currentMonth, 'year')}
|