@mui/x-date-pickers 8.0.0-alpha.1 → 8.0.0-alpha.11
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/AdapterDateFns/AdapterDateFns.d.ts +2 -4
- package/AdapterDateFns/AdapterDateFns.js +49 -47
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -1
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -4
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts} +2 -2
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/AdapterDateFnsJalaliV2/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV2/index.js +1 -0
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
- package/{AdapterDateFnsV3/AdapterDateFnsV3.d.ts → AdapterDateFnsV2/AdapterDateFnsV2.d.ts} +2 -2
- package/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/AdapterDateFnsV2/index.d.ts +1 -0
- package/AdapterDateFnsV2/index.js +1 -0
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +2007 -230
- package/DateCalendar/DateCalendar.js +41 -22
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/DayCalendar.d.ts +1 -2
- package/DateCalendar/DayCalendar.js +12 -36
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.js +12 -5
- package/DateCalendar/useCalendarState.d.ts +13 -27
- package/DateCalendar/useCalendarState.js +65 -55
- package/DateField/DateField.js +29 -33
- package/DateField/DateField.types.d.ts +7 -15
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +14 -11
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +7 -3
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +17 -33
- package/DatePicker/shared.d.ts +6 -5
- package/DateTimeField/DateTimeField.js +29 -33
- package/DateTimeField/DateTimeField.types.d.ts +7 -16
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +14 -11
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DateTimePicker/DateTimePicker.types.d.ts +4 -5
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/DateTimePicker/DateTimePickerToolbar.d.ts +16 -5
- package/DateTimePicker/DateTimePickerToolbar.js +88 -80
- package/DateTimePicker/shared.d.ts +8 -8
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +9 -34
- package/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/DigitalClock/DigitalClock.js +13 -11
- package/DigitalClock/DigitalClock.types.d.ts +8 -2
- package/MobileDatePicker/MobileDatePicker.js +4 -14
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.js +4 -14
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/MonthCalendar/MonthCalendar.d.ts +1 -1
- package/MonthCalendar/MonthCalendar.js +31 -11
- package/MonthCalendar/MonthCalendar.types.d.ts +2 -2
- package/MonthCalendar/MonthCalendarButton.d.ts +24 -0
- package/{modern/MonthCalendar/PickersMonth.js → MonthCalendar/MonthCalendarButton.js} +20 -61
- package/MonthCalendar/index.d.ts +0 -3
- package/MonthCalendar/index.js +1 -2
- package/MonthCalendar/monthCalendarClasses.d.ts +7 -1
- package/MonthCalendar/monthCalendarClasses.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -10
- package/PickersActionBar/PickersActionBar.d.ts +6 -7
- package/PickersActionBar/PickersActionBar.js +26 -17
- package/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +4 -6
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +23 -42
- package/PickersLayout/PickersLayout.types.d.ts +20 -22
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +26 -53
- package/PickersSectionList/PickersSectionList.js +21 -16
- package/PickersSectionList/PickersSectionList.types.d.ts +13 -6
- package/PickersShortcuts/PickersShortcuts.d.ts +9 -11
- package/PickersShortcuts/PickersShortcuts.js +21 -11
- package/PickersShortcuts/index.d.ts +1 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +7 -0
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +1 -1
- package/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/PickersTextField/PickersInput/pickersInputClasses.d.ts +3 -2
- package/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +3 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
- package/PickersTextField/PickersOutlinedInput/Outline.d.ts +0 -1
- package/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/PickersTextField/PickersTextField.js +75 -62
- package/PickersTextField/PickersTextField.types.d.ts +43 -4
- package/PickersTextField/usePickerTextFieldOwnerState.d.ts +4 -0
- package/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/README.md +8 -5
- package/StaticDatePicker/StaticDatePicker.js +2 -2
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.js +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimeClock/Clock.d.ts +4 -0
- package/TimeClock/Clock.js +27 -27
- package/TimeClock/ClockNumber.js +15 -11
- package/TimeClock/ClockPointer.d.ts +6 -1
- package/TimeClock/ClockPointer.js +16 -10
- package/TimeClock/TimeClock.js +30 -12
- package/TimeField/TimeField.js +28 -32
- package/TimeField/TimeField.types.d.ts +7 -16
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +14 -11
- package/TimePicker/TimePicker.js +2 -2
- package/TimePicker/TimePicker.types.d.ts +4 -5
- package/TimePicker/TimePickerToolbar.d.ts +1 -3
- package/TimePicker/TimePickerToolbar.js +36 -51
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +46 -13
- package/YearCalendar/YearCalendar.types.d.ts +2 -2
- package/YearCalendar/YearCalendarButton.d.ts +23 -0
- package/{modern/YearCalendar/PickersYear.js → YearCalendar/YearCalendarButton.js} +20 -59
- package/YearCalendar/index.d.ts +0 -3
- package/YearCalendar/index.js +1 -2
- package/YearCalendar/yearCalendarClasses.d.ts +7 -1
- package/YearCalendar/yearCalendarClasses.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -1
- package/hooks/useClearableField.d.ts +5 -3
- package/hooks/useClearableField.js +4 -2
- package/hooks/useIsValidValue.d.ts +7 -0
- package/hooks/useIsValidValue.js +11 -0
- package/hooks/useParsedFormat.d.ts +9 -7
- package/hooks/useParsedFormat.js +11 -13
- package/hooks/usePickerActionsContext.d.ts +7 -0
- package/hooks/usePickerActionsContext.js +15 -0
- package/hooks/usePickerContext.d.ts +5 -1
- package/hooks/usePickerContext.js +2 -2
- package/hooks/useSplitFieldProps.d.ts +12 -3
- package/hooks/useSplitFieldProps.js +8 -3
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/PickerFieldUI.d.ts +133 -0
- package/internals/components/PickerFieldUI.js +317 -0
- package/internals/components/{PickersPopper.d.ts → PickerPopper/PickerPopper.d.ts} +26 -25
- package/{modern/internals/components/PickersPopper.js → internals/components/PickerPopper/PickerPopper.js} +47 -47
- package/internals/components/PickerPopper/index.d.ts +4 -0
- package/internals/components/PickerPopper/index.js +2 -0
- package/internals/components/PickerPopper/pickerPopperClasses.d.ts +9 -0
- package/internals/components/PickerPopper/pickerPopperClasses.js +6 -0
- package/internals/components/PickerProvider.d.ts +86 -32
- package/internals/components/PickerProvider.js +25 -7
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersToolbar.d.ts +2 -3
- package/internals/components/PickersToolbar.js +15 -12
- package/internals/components/PickersToolbarButton.js +4 -6
- package/internals/components/PickersToolbarText.js +11 -13
- package/internals/hooks/date-helpers-hooks.js +4 -3
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +35 -120
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +16 -38
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/index.d.ts +2 -0
- package/internals/hooks/useField/index.js +2 -1
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.js +17 -4
- package/internals/hooks/useField/useField.types.d.ts +55 -48
- package/internals/hooks/useField/useField.utils.d.ts +4 -3
- package/internals/hooks/useField/useField.utils.js +2 -2
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +15 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +47 -0
- package/internals/hooks/useField/useFieldState.d.ts +9 -8
- package/internals/hooks/useField/useFieldState.js +2 -3
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +16 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +34 -68
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +15 -22
- package/internals/hooks/useNullablePickerContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerContext.js +10 -0
- package/internals/hooks/useOpenState.d.ts +3 -2
- package/internals/hooks/useOpenState.js +11 -9
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +3 -4
- package/internals/hooks/usePicker/usePicker.js +4 -20
- package/internals/hooks/usePicker/usePicker.types.d.ts +10 -10
- package/internals/hooks/usePicker/usePickerProvider.d.ts +45 -10
- package/internals/hooks/usePicker/usePickerProvider.js +50 -16
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +84 -214
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +130 -75
- package/internals/hooks/usePicker/usePickerViews.d.ts +59 -41
- package/internals/hooks/usePicker/usePickerViews.js +31 -20
- package/internals/hooks/useReduceAnimations.d.ts +2 -0
- package/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +5 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +7 -13
- package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
- package/internals/hooks/useToolbarOwnerState.js +13 -0
- package/internals/hooks/useUtils.d.ts +4 -3
- package/internals/hooks/useUtils.js +1 -1
- package/internals/hooks/useValueWithTimezone.d.ts +5 -4
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +27 -18
- package/internals/index.js +13 -8
- package/internals/models/common.d.ts +1 -1
- package/internals/models/fields.d.ts +8 -24
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/manager.d.ts +15 -0
- package/internals/models/manager.js +1 -0
- package/internals/models/pickers.d.ts +1 -0
- package/internals/models/pickers.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +3 -33
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/time.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +1 -19
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +1 -1
- package/internals/utils/date-utils.js +1 -1
- package/internals/utils/utils.d.ts +3 -0
- package/internals/utils/utils.js +11 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- package/internals/utils/valueManagers.js +4 -4
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/nbNO.js +15 -19
- package/locales/nlNL.js +7 -7
- package/locales/roRO.js +15 -18
- package/locales/utils/getPickersLocalization.d.ts +0 -7
- package/locales/utils/getPickersLocalization.js +0 -13
- package/locales/zhTW.d.ts +80 -0
- package/locales/zhTW.js +73 -0
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateManager.d.ts +27 -0
- package/managers/useDateManager.js +55 -0
- package/managers/useDateTimeManager.d.ts +28 -0
- package/managers/useDateTimeManager.js +60 -0
- package/managers/useTimeManager.d.ts +28 -0
- package/managers/useTimeManager.js +51 -0
- package/models/adapters.d.ts +5 -5
- package/models/fields.d.ts +33 -9
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/manager.d.ts +87 -0
- package/models/manager.js +1 -0
- package/models/pickers.d.ts +7 -0
- package/models/validation.d.ts +2 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +49 -47
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/modern/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/modern/AdapterDateFnsJalaliV2/index.js +1 -0
- package/modern/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/modern/AdapterDateFnsV2/index.js +1 -0
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +41 -22
- package/modern/DateCalendar/DayCalendar.js +12 -36
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateCalendar/useCalendarState.js +65 -55
- package/modern/DateField/DateField.js +29 -33
- package/modern/DateField/useDateField.js +14 -11
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +17 -33
- package/modern/DateTimeField/DateTimeField.js +29 -33
- package/modern/DateTimeField/useDateTimeField.js +14 -11
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/modern/DateTimePicker/DateTimePickerToolbar.js +88 -80
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +9 -34
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/modern/DigitalClock/DigitalClock.js +13 -11
- package/modern/MobileDatePicker/MobileDatePicker.js +4 -14
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/modern/MobileTimePicker/MobileTimePicker.js +4 -14
- package/modern/MonthCalendar/MonthCalendar.js +31 -11
- package/{MonthCalendar/PickersMonth.js → modern/MonthCalendar/MonthCalendarButton.js} +20 -61
- package/modern/MonthCalendar/index.js +1 -2
- package/modern/MonthCalendar/monthCalendarClasses.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -10
- package/modern/PickersActionBar/PickersActionBar.js +26 -17
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/modern/PickersLayout/PickersLayout.js +23 -42
- package/modern/PickersLayout/usePickerLayout.js +26 -53
- package/modern/PickersSectionList/PickersSectionList.js +21 -16
- package/modern/PickersShortcuts/PickersShortcuts.js +21 -11
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/modern/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/modern/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/modern/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/modern/PickersTextField/PickersTextField.js +75 -62
- package/modern/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -2
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -2
- package/modern/TimeClock/Clock.js +27 -27
- package/modern/TimeClock/ClockNumber.js +15 -11
- package/modern/TimeClock/ClockPointer.js +16 -10
- package/modern/TimeClock/TimeClock.js +30 -12
- package/modern/TimeField/TimeField.js +28 -32
- package/modern/TimeField/useTimeField.js +14 -11
- package/modern/TimePicker/TimePicker.js +2 -2
- package/modern/TimePicker/TimePickerToolbar.js +36 -51
- package/modern/YearCalendar/YearCalendar.js +46 -13
- package/{YearCalendar/PickersYear.js → modern/YearCalendar/YearCalendarButton.js} +20 -59
- package/modern/YearCalendar/index.js +1 -2
- package/modern/YearCalendar/yearCalendarClasses.js +1 -1
- package/modern/hooks/index.js +3 -1
- package/modern/hooks/useClearableField.js +4 -2
- package/modern/hooks/useIsValidValue.js +11 -0
- package/modern/hooks/useParsedFormat.js +11 -13
- package/modern/hooks/usePickerActionsContext.js +15 -0
- package/modern/hooks/usePickerContext.js +2 -2
- package/modern/hooks/useSplitFieldProps.js +8 -3
- package/modern/index.js +3 -2
- package/modern/internals/components/PickerFieldUI.js +317 -0
- package/{internals/components/PickersPopper.js → modern/internals/components/PickerPopper/PickerPopper.js} +47 -47
- package/modern/internals/components/PickerPopper/index.js +2 -0
- package/modern/internals/components/PickerPopper/pickerPopperClasses.js +6 -0
- package/modern/internals/components/PickerProvider.js +25 -7
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersToolbar.js +15 -12
- package/modern/internals/components/PickersToolbarButton.js +4 -6
- package/modern/internals/components/PickersToolbarText.js +11 -13
- package/modern/internals/hooks/date-helpers-hooks.js +4 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +35 -120
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/index.js +2 -1
- package/modern/internals/hooks/useField/useField.js +17 -4
- package/modern/internals/hooks/useField/useField.utils.js +2 -2
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +47 -0
- package/modern/internals/hooks/useField/useFieldState.js +2 -3
- package/modern/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/modern/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/modern/internals/hooks/useFieldOwnerState.js +16 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +34 -68
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/useOpenState.js +11 -9
- package/modern/internals/hooks/usePicker/usePicker.js +4 -20
- package/modern/internals/hooks/usePicker/usePickerProvider.js +50 -16
- package/modern/internals/hooks/usePicker/usePickerValue.js +84 -214
- package/modern/internals/hooks/usePicker/usePickerViews.js +31 -20
- package/modern/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +5 -2
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/index.js +13 -8
- package/modern/internals/models/index.js +2 -1
- package/modern/internals/models/manager.js +1 -0
- package/modern/internals/models/pickers.js +1 -0
- package/modern/internals/utils/date-utils.js +1 -1
- package/modern/internals/utils/utils.js +11 -1
- package/modern/internals/utils/valueManagers.js +4 -4
- package/modern/locales/index.js +1 -0
- package/modern/locales/nbNO.js +15 -19
- package/modern/locales/nlNL.js +7 -7
- package/modern/locales/roRO.js +15 -18
- package/modern/locales/utils/getPickersLocalization.js +0 -13
- package/modern/locales/zhTW.js +73 -0
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateManager.js +55 -0
- package/modern/managers/useDateTimeManager.js +60 -0
- package/modern/managers/useTimeManager.js +51 -0
- package/modern/models/index.js +1 -0
- package/modern/models/manager.js +1 -0
- package/modern/validation/useValidation.js +1 -1
- package/modern/validation/validateDate.js +8 -0
- package/modern/validation/validateDateTime.js +8 -0
- package/modern/validation/validateTime.js +8 -0
- package/node/AdapterDateFns/AdapterDateFns.js +97 -97
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +97 -96
- package/node/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +94 -101
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/AdapterDateFnsV2/AdapterDateFnsV2.js +291 -0
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/DateCalendar.js +41 -22
- package/node/DateCalendar/DayCalendar.js +12 -37
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateCalendar/useCalendarState.js +66 -57
- package/node/DateField/DateField.js +29 -33
- package/node/DateField/useDateField.js +13 -10
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +17 -33
- package/node/DateTimeField/DateTimeField.js +29 -33
- package/node/DateTimeField/useDateTimeField.js +13 -10
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/node/DateTimePicker/DateTimePickerToolbar.js +89 -80
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -35
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/node/DigitalClock/DigitalClock.js +13 -11
- package/node/MobileDatePicker/MobileDatePicker.js +4 -14
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/node/MobileTimePicker/MobileTimePicker.js +4 -14
- package/node/MonthCalendar/MonthCalendar.js +31 -11
- package/node/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/node/MonthCalendar/index.js +1 -8
- package/node/MonthCalendar/monthCalendarClasses.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/node/PickersActionBar/PickersActionBar.js +28 -19
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/node/PickersLayout/PickersLayout.js +23 -42
- package/node/PickersLayout/usePickerLayout.js +30 -57
- package/node/PickersSectionList/PickersSectionList.js +21 -16
- package/node/PickersShortcuts/PickersShortcuts.js +21 -11
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/node/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/node/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/node/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/node/PickersTextField/PickersTextField.js +75 -62
- package/node/PickersTextField/usePickerTextFieldOwnerState.js +18 -0
- package/node/StaticDatePicker/StaticDatePicker.js +2 -2
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/node/StaticTimePicker/StaticTimePicker.js +2 -2
- package/node/TimeClock/Clock.js +27 -27
- package/node/TimeClock/ClockNumber.js +15 -11
- package/node/TimeClock/ClockPointer.js +15 -10
- package/node/TimeClock/TimeClock.js +30 -12
- package/node/TimeField/TimeField.js +28 -32
- package/node/TimeField/useTimeField.js +13 -10
- package/node/TimePicker/TimePicker.js +2 -2
- package/node/TimePicker/TimePickerToolbar.js +36 -51
- package/node/YearCalendar/YearCalendar.js +45 -12
- package/node/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/node/YearCalendar/index.js +1 -8
- package/node/YearCalendar/yearCalendarClasses.js +1 -1
- package/node/hooks/index.js +15 -1
- package/node/hooks/useClearableField.js +4 -2
- package/node/hooks/useIsValidValue.js +18 -0
- package/node/hooks/useParsedFormat.js +11 -13
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/hooks/usePickerContext.js +5 -4
- package/node/hooks/useSplitFieldProps.js +7 -2
- package/node/index.js +13 -1
- package/node/internals/components/PickerFieldUI.js +329 -0
- package/node/internals/components/{PickersPopper.js → PickerPopper/PickerPopper.js} +48 -48
- package/node/internals/components/PickerPopper/index.js +25 -0
- package/node/internals/components/PickerPopper/pickerPopperClasses.js +14 -0
- package/node/internals/components/PickerProvider.js +27 -9
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersToolbar.js +15 -12
- package/node/internals/components/PickersToolbarButton.js +4 -6
- package/node/internals/components/PickersToolbarText.js +10 -12
- package/node/internals/hooks/date-helpers-hooks.js +4 -3
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +37 -122
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/node/internals/hooks/useField/index.js +8 -1
- package/node/internals/hooks/useField/useField.js +16 -3
- package/node/internals/hooks/useField/useField.utils.js +2 -2
- package/node/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +56 -0
- package/node/internals/hooks/useField/useFieldState.js +2 -3
- package/node/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/node/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/node/internals/hooks/useFieldOwnerState.js +24 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +35 -69
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/useOpenState.js +12 -9
- package/node/internals/hooks/usePicker/usePicker.js +4 -20
- package/node/internals/hooks/usePicker/usePickerProvider.js +51 -17
- package/node/internals/hooks/usePicker/usePickerValue.js +84 -213
- package/node/internals/hooks/usePicker/usePickerViews.js +31 -21
- package/node/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +7 -4
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/node/internals/hooks/useToolbarOwnerState.js +21 -0
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/index.js +87 -34
- package/node/internals/models/index.js +11 -0
- package/node/internals/models/manager.js +5 -0
- package/node/internals/models/pickers.js +5 -0
- package/node/internals/utils/date-utils.js +1 -1
- package/node/internals/utils/utils.js +14 -2
- package/node/internals/utils/valueManagers.js +4 -4
- package/node/locales/index.js +11 -0
- package/node/locales/nbNO.js +15 -19
- package/node/locales/nlNL.js +7 -7
- package/node/locales/roRO.js +15 -18
- package/node/locales/utils/getPickersLocalization.js +2 -16
- package/node/locales/zhTW.js +79 -0
- package/node/managers/index.js +26 -0
- package/node/managers/useDateManager.js +63 -0
- package/node/managers/useDateTimeManager.js +68 -0
- package/node/managers/useTimeManager.js +59 -0
- package/node/models/index.js +11 -0
- package/node/models/manager.js +5 -0
- package/node/validation/useValidation.js +1 -1
- package/node/validation/validateDate.js +8 -0
- package/node/validation/validateDateTime.js +8 -0
- package/node/validation/validateTime.js +8 -0
- package/package.json +5 -5
- package/themeAugmentation/components.d.ts +3 -11
- package/themeAugmentation/overrides.d.ts +5 -7
- package/themeAugmentation/props.d.ts +7 -9
- package/validation/extractValidationProps.d.ts +1 -1
- package/validation/useValidation.d.ts +7 -6
- package/validation/useValidation.js +1 -1
- package/validation/validateDate.d.ts +12 -3
- package/validation/validateDate.js +8 -0
- package/validation/validateDateTime.d.ts +12 -4
- package/validation/validateDateTime.js +8 -0
- package/validation/validateTime.d.ts +12 -3
- package/validation/validateTime.js +8 -0
- package/AdapterDateFnsJalaliV3/index.d.ts +0 -1
- package/AdapterDateFnsJalaliV3/index.js +0 -1
- package/AdapterDateFnsV3/index.d.ts +0 -1
- package/AdapterDateFnsV3/index.js +0 -1
- package/MonthCalendar/PickersMonth.d.ts +0 -28
- package/MonthCalendar/pickersMonthClasses.d.ts +0 -13
- package/MonthCalendar/pickersMonthClasses.js +0 -5
- package/YearCalendar/PickersYear.d.ts +0 -27
- package/YearCalendar/pickersYearClasses.d.ts +0 -13
- package/YearCalendar/pickersYearClasses.js +0 -5
- package/internals/components/pickersPopperClasses.d.ts +0 -9
- package/internals/components/pickersPopperClasses.js +0 -5
- package/internals/hooks/defaultizedFieldProps.d.ts +0 -18
- package/internals/hooks/defaultizedFieldProps.js +0 -40
- package/internals/hooks/useDefaultReduceAnimations.d.ts +0 -2
- package/internals/hooks/useIsLandscape.d.ts +0 -4
- package/internals/hooks/useIsLandscape.js +0 -35
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -32
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +0 -3
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/modern/AdapterDateFnsJalaliV3/index.js +0 -1
- package/modern/AdapterDateFnsV3/index.js +0 -1
- package/modern/MonthCalendar/pickersMonthClasses.js +0 -5
- package/modern/YearCalendar/pickersYearClasses.js +0 -5
- package/modern/internals/components/pickersPopperClasses.js +0 -5
- package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
- package/node/MonthCalendar/pickersMonthClasses.js +0 -12
- package/node/YearCalendar/pickersYearClasses.js +0 -12
- package/node/internals/components/pickersPopperClasses.js +0 -12
- package/node/internals/hooks/defaultizedFieldProps.js +0 -50
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -38
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -19,7 +19,7 @@ import { useViews } from "../internals/hooks/useViews.js";
|
|
|
19
19
|
import { PickersCalendarHeader } from "../PickersCalendarHeader/index.js";
|
|
20
20
|
import { findClosestEnabledDate, applyDefaultDate, mergeDateAndTime } from "../internals/utils/date-utils.js";
|
|
21
21
|
import { PickerViewRoot } from "../internals/components/PickerViewRoot/index.js";
|
|
22
|
-
import {
|
|
22
|
+
import { useReduceAnimations } from "../internals/hooks/useReduceAnimations.js";
|
|
23
23
|
import { getDateCalendarUtilityClass } from "./dateCalendarClasses.js";
|
|
24
24
|
import { useControlledValueWithTimezone } from "../internals/hooks/useValueWithTimezone.js";
|
|
25
25
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
@@ -36,18 +36,18 @@ const useUtilityClasses = classes => {
|
|
|
36
36
|
function useDateCalendarDefaultizedProps(props, name) {
|
|
37
37
|
const utils = useUtils();
|
|
38
38
|
const defaultDates = useDefaultDates();
|
|
39
|
-
const defaultReduceAnimations = useDefaultReduceAnimations();
|
|
40
39
|
const themeProps = useThemeProps({
|
|
41
40
|
props,
|
|
42
41
|
name
|
|
43
42
|
});
|
|
43
|
+
const reduceAnimations = useReduceAnimations(themeProps.reduceAnimations);
|
|
44
44
|
return _extends({}, themeProps, {
|
|
45
45
|
loading: themeProps.loading ?? false,
|
|
46
46
|
disablePast: themeProps.disablePast ?? false,
|
|
47
47
|
disableFuture: themeProps.disableFuture ?? false,
|
|
48
48
|
openTo: themeProps.openTo ?? 'day',
|
|
49
49
|
views: themeProps.views ?? ['year', 'day'],
|
|
50
|
-
reduceAnimations
|
|
50
|
+
reduceAnimations,
|
|
51
51
|
renderLoading: themeProps.renderLoading ?? (() => /*#__PURE__*/_jsx("span", {
|
|
52
52
|
children: "..."
|
|
53
53
|
})),
|
|
@@ -96,7 +96,6 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
96
96
|
disableFuture,
|
|
97
97
|
disablePast,
|
|
98
98
|
onChange,
|
|
99
|
-
onYearChange,
|
|
100
99
|
onMonthChange,
|
|
101
100
|
reduceAnimations,
|
|
102
101
|
shouldDisableDate,
|
|
@@ -112,7 +111,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
112
111
|
minDate,
|
|
113
112
|
maxDate,
|
|
114
113
|
disableHighlightToday,
|
|
115
|
-
focusedView:
|
|
114
|
+
focusedView: focusedViewProp,
|
|
116
115
|
onFocusedViewChange,
|
|
117
116
|
showDaysOutsideCurrentMonth,
|
|
118
117
|
fixedWeekNumber,
|
|
@@ -155,15 +154,13 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
155
154
|
onChange: handleValueChange,
|
|
156
155
|
onViewChange,
|
|
157
156
|
autoFocus,
|
|
158
|
-
focusedView:
|
|
157
|
+
focusedView: focusedViewProp,
|
|
159
158
|
onFocusedViewChange
|
|
160
159
|
});
|
|
161
160
|
const {
|
|
162
161
|
referenceDate,
|
|
163
162
|
calendarState,
|
|
164
|
-
|
|
165
|
-
changeMonth,
|
|
166
|
-
handleChangeMonth,
|
|
163
|
+
setVisibleDate,
|
|
167
164
|
isDateDisabled,
|
|
168
165
|
onMonthSwitchingAnimationEnd
|
|
169
166
|
} = useCalendarState({
|
|
@@ -176,7 +173,13 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
176
173
|
shouldDisableDate,
|
|
177
174
|
disablePast,
|
|
178
175
|
disableFuture,
|
|
179
|
-
timezone
|
|
176
|
+
timezone,
|
|
177
|
+
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
178
|
+
if (utils.isSameMonth(visibleDate, prevMonth)) {
|
|
179
|
+
return prevMonth;
|
|
180
|
+
}
|
|
181
|
+
return utils.startOfMonth(visibleDate);
|
|
182
|
+
}
|
|
180
183
|
});
|
|
181
184
|
|
|
182
185
|
// When disabled, limit the view to the selected date
|
|
@@ -193,9 +196,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
193
196
|
view,
|
|
194
197
|
currentMonth: calendarState.currentMonth,
|
|
195
198
|
onViewChange: setView,
|
|
196
|
-
onMonthChange:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
onMonthChange: month => setVisibleDate({
|
|
200
|
+
target: month,
|
|
201
|
+
reason: 'header-navigation'
|
|
199
202
|
}),
|
|
200
203
|
minDate: minDateWithDisabled,
|
|
201
204
|
maxDate: maxDateWithDisabled,
|
|
@@ -223,12 +226,17 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
223
226
|
}) : newDate;
|
|
224
227
|
if (closestEnabledDate) {
|
|
225
228
|
setValueAndGoToNextView(closestEnabledDate, 'finish');
|
|
226
|
-
|
|
229
|
+
setVisibleDate({
|
|
230
|
+
target: closestEnabledDate,
|
|
231
|
+
reason: 'cell-interaction'
|
|
232
|
+
});
|
|
227
233
|
} else {
|
|
228
234
|
goToNextView();
|
|
229
|
-
|
|
235
|
+
setVisibleDate({
|
|
236
|
+
target: startOfMonth,
|
|
237
|
+
reason: 'cell-interaction'
|
|
238
|
+
});
|
|
230
239
|
}
|
|
231
|
-
changeFocusedDay(closestEnabledDate, true);
|
|
232
240
|
});
|
|
233
241
|
const handleDateYearChange = useEventCallback(newDate => {
|
|
234
242
|
const startOfYear = utils.startOfYear(newDate);
|
|
@@ -245,12 +253,17 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
245
253
|
}) : newDate;
|
|
246
254
|
if (closestEnabledDate) {
|
|
247
255
|
setValueAndGoToNextView(closestEnabledDate, 'finish');
|
|
248
|
-
|
|
256
|
+
setVisibleDate({
|
|
257
|
+
target: closestEnabledDate,
|
|
258
|
+
reason: 'cell-interaction'
|
|
259
|
+
});
|
|
249
260
|
} else {
|
|
250
261
|
goToNextView();
|
|
251
|
-
|
|
262
|
+
setVisibleDate({
|
|
263
|
+
target: startOfYear,
|
|
264
|
+
reason: 'cell-interaction'
|
|
265
|
+
});
|
|
252
266
|
}
|
|
253
|
-
changeFocusedDay(closestEnabledDate, true);
|
|
254
267
|
});
|
|
255
268
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
256
269
|
if (day) {
|
|
@@ -260,8 +273,11 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
260
273
|
return handleValueChange(day, 'finish', view);
|
|
261
274
|
});
|
|
262
275
|
React.useEffect(() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
276
|
+
if (utils.isValid(value)) {
|
|
277
|
+
setVisibleDate({
|
|
278
|
+
target: value,
|
|
279
|
+
reason: 'controlled-value-change'
|
|
280
|
+
});
|
|
265
281
|
}
|
|
266
282
|
}, [value]); // eslint-disable-line
|
|
267
283
|
|
|
@@ -328,7 +344,10 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
328
344
|
referenceDate: referenceDate
|
|
329
345
|
})), view === 'day' && /*#__PURE__*/_jsx(DayCalendar, _extends({}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
330
346
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
331
|
-
onFocusedDayChange:
|
|
347
|
+
onFocusedDayChange: focusedDate => setVisibleDate({
|
|
348
|
+
target: focusedDate,
|
|
349
|
+
reason: 'cell-interaction'
|
|
350
|
+
}),
|
|
332
351
|
reduceAnimations: reduceAnimations,
|
|
333
352
|
selectedDays: selectedDays,
|
|
334
353
|
onSelectedDaysChange: handleSelectedDayChange,
|
|
@@ -13,6 +13,7 @@ import { ExportedYearCalendarProps, YearCalendarSlots, YearCalendarSlotProps } f
|
|
|
13
13
|
import { ExportedMonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps } from '../MonthCalendar/MonthCalendar.types';
|
|
14
14
|
import { ExportedValidateDateProps } from '../validation/validateDate';
|
|
15
15
|
import { FormProps } from '../internals/models/formProps';
|
|
16
|
+
import { PickerValue } from '../internals/models';
|
|
16
17
|
export interface DateCalendarSlots extends PickersCalendarHeaderSlots, DayCalendarSlots, MonthCalendarSlots, YearCalendarSlots {
|
|
17
18
|
/**
|
|
18
19
|
* Custom component for calendar header.
|
|
@@ -47,7 +48,7 @@ export interface ExportedDateCalendarProps extends ExportedDayCalendarProps, Exp
|
|
|
47
48
|
*/
|
|
48
49
|
onMonthChange?: (month: PickerValidDate) => void;
|
|
49
50
|
}
|
|
50
|
-
export interface DateCalendarProps extends ExportedDateCalendarProps, ExportedUseViewsOptions<
|
|
51
|
+
export interface DateCalendarProps extends ExportedDateCalendarProps, ExportedUseViewsOptions<PickerValue, DateView> {
|
|
51
52
|
/**
|
|
52
53
|
* The selected value.
|
|
53
54
|
* Used when the component is controlled.
|
|
@@ -54,7 +54,6 @@ export interface ExportedDayCalendarProps extends ExportedPickersDayProps {
|
|
|
54
54
|
fixedWeekNumber?: number;
|
|
55
55
|
}
|
|
56
56
|
export interface DayCalendarProps extends ExportedDayCalendarProps, DayValidationProps, MonthValidationProps, YearValidationProps, Required<BaseDateValidationProps>, DefaultizedProps<TimezoneProps, 'timezone'>, FormProps {
|
|
57
|
-
autoFocus?: boolean;
|
|
58
57
|
className?: string;
|
|
59
58
|
currentMonth: PickerValidDate;
|
|
60
59
|
selectedDays: (PickerValidDate | null)[];
|
|
@@ -66,7 +65,7 @@ export interface DayCalendarProps extends ExportedDayCalendarProps, DayValidatio
|
|
|
66
65
|
reduceAnimations: boolean;
|
|
67
66
|
slideDirection: SlideDirection;
|
|
68
67
|
TransitionProps?: Partial<SlideTransitionProps>;
|
|
69
|
-
hasFocus
|
|
68
|
+
hasFocus: boolean;
|
|
70
69
|
onFocusedViewChange?: (newHasFocus: boolean) => void;
|
|
71
70
|
gridLabelId?: string;
|
|
72
71
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["parentProps", "day", "
|
|
5
|
+
const _excluded = ["parentProps", "day", "focusedDay", "selectedDays", "isDateDisabled", "currentMonthNumber", "isViewFocused"],
|
|
4
6
|
_excluded2 = ["ownerState"];
|
|
5
7
|
import * as React from 'react';
|
|
6
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
@@ -8,7 +10,7 @@ import Typography from '@mui/material/Typography';
|
|
|
8
10
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
11
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
12
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
|
-
import
|
|
13
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
12
14
|
import clsx from 'clsx';
|
|
13
15
|
import { PickersDay } from "../PickersDay/PickersDay.js";
|
|
14
16
|
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
@@ -135,7 +137,7 @@ function WrappedDay(_ref) {
|
|
|
135
137
|
let {
|
|
136
138
|
parentProps,
|
|
137
139
|
day,
|
|
138
|
-
|
|
140
|
+
focusedDay,
|
|
139
141
|
selectedDays,
|
|
140
142
|
isDateDisabled,
|
|
141
143
|
currentMonthNumber,
|
|
@@ -156,7 +158,8 @@ function WrappedDay(_ref) {
|
|
|
156
158
|
const {
|
|
157
159
|
ownerState
|
|
158
160
|
} = usePickerPrivateContext();
|
|
159
|
-
const isFocusableDay =
|
|
161
|
+
const isFocusableDay = focusedDay != null && utils.isSameDay(day, focusedDay);
|
|
162
|
+
const isFocusedDay = isViewFocused && isFocusableDay;
|
|
160
163
|
const isSelected = selectedDays.some(selectedDay => utils.isSameDay(selectedDay, day));
|
|
161
164
|
const isToday = utils.isSameDay(day, now);
|
|
162
165
|
const isDisabled = React.useMemo(() => disabled || isDateDisabled(day), [disabled, isDateDisabled, day]);
|
|
@@ -198,7 +201,7 @@ function WrappedDay(_ref) {
|
|
|
198
201
|
return /*#__PURE__*/_jsx(Day, _extends({}, dayProps, {
|
|
199
202
|
day: day,
|
|
200
203
|
disabled: isDisabled,
|
|
201
|
-
autoFocus:
|
|
204
|
+
autoFocus: !outsideCurrentMonth && isFocusedDay,
|
|
202
205
|
today: isToday,
|
|
203
206
|
outsideCurrentMonth: outsideCurrentMonth,
|
|
204
207
|
isFirstVisibleCell: isFirstVisibleCell,
|
|
@@ -249,7 +252,6 @@ export function DayCalendar(inProps) {
|
|
|
249
252
|
gridLabelId,
|
|
250
253
|
displayWeekNumber,
|
|
251
254
|
fixedWeekNumber,
|
|
252
|
-
autoFocus,
|
|
253
255
|
timezone
|
|
254
256
|
} = props;
|
|
255
257
|
const now = useNow(timezone);
|
|
@@ -266,13 +268,6 @@ export function DayCalendar(inProps) {
|
|
|
266
268
|
timezone
|
|
267
269
|
});
|
|
268
270
|
const translations = usePickerTranslations();
|
|
269
|
-
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
270
|
-
name: 'DayCalendar',
|
|
271
|
-
state: 'hasFocus',
|
|
272
|
-
controlled: hasFocus,
|
|
273
|
-
default: autoFocus ?? false
|
|
274
|
-
});
|
|
275
|
-
const [internalFocusedDay, setInternalFocusedDay] = React.useState(() => focusedDay || now);
|
|
276
271
|
const handleDaySelect = useEventCallback(day => {
|
|
277
272
|
if (readOnly) {
|
|
278
273
|
return;
|
|
@@ -282,9 +277,7 @@ export function DayCalendar(inProps) {
|
|
|
282
277
|
const focusDay = day => {
|
|
283
278
|
if (!isDateDisabled(day)) {
|
|
284
279
|
onFocusedDayChange(day);
|
|
285
|
-
setInternalFocusedDay(day);
|
|
286
280
|
onFocusedViewChange?.(true);
|
|
287
|
-
setInternalHasFocus(true);
|
|
288
281
|
}
|
|
289
282
|
};
|
|
290
283
|
const handleKeyDown = useEventCallback((event, day) => {
|
|
@@ -351,7 +344,7 @@ export function DayCalendar(inProps) {
|
|
|
351
344
|
});
|
|
352
345
|
const handleFocus = useEventCallback((event, day) => focusDay(day));
|
|
353
346
|
const handleBlur = useEventCallback((event, day) => {
|
|
354
|
-
if (
|
|
347
|
+
if (focusedDay != null && utils.isSameDay(focusedDay, day)) {
|
|
355
348
|
onFocusedViewChange?.(false);
|
|
356
349
|
}
|
|
357
350
|
});
|
|
@@ -363,23 +356,6 @@ export function DayCalendar(inProps) {
|
|
|
363
356
|
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
|
|
364
357
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
365
358
|
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
|
366
|
-
const focusableDay = React.useMemo(() => {
|
|
367
|
-
const startOfMonth = utils.startOfMonth(currentMonth);
|
|
368
|
-
const endOfMonth = utils.endOfMonth(currentMonth);
|
|
369
|
-
if (isDateDisabled(internalFocusedDay) || utils.isAfterDay(internalFocusedDay, endOfMonth) || utils.isBeforeDay(internalFocusedDay, startOfMonth)) {
|
|
370
|
-
return findClosestEnabledDate({
|
|
371
|
-
utils,
|
|
372
|
-
date: internalFocusedDay,
|
|
373
|
-
minDate: startOfMonth,
|
|
374
|
-
maxDate: endOfMonth,
|
|
375
|
-
disablePast,
|
|
376
|
-
disableFuture,
|
|
377
|
-
isDateDisabled,
|
|
378
|
-
timezone
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
return internalFocusedDay;
|
|
382
|
-
}, [currentMonth, disableFuture, disablePast, internalFocusedDay, isDateDisabled, utils, timezone]);
|
|
383
359
|
const weeksToDisplay = React.useMemo(() => {
|
|
384
360
|
const toDisplay = utils.getWeekArray(currentMonth);
|
|
385
361
|
let nextMonth = utils.addMonths(currentMonth, 1);
|
|
@@ -446,14 +422,14 @@ export function DayCalendar(inProps) {
|
|
|
446
422
|
parentProps: props,
|
|
447
423
|
day: day,
|
|
448
424
|
selectedDays: validSelectedDays,
|
|
449
|
-
|
|
425
|
+
isViewFocused: hasFocus,
|
|
426
|
+
focusedDay: focusedDay,
|
|
450
427
|
onKeyDown: handleKeyDown,
|
|
451
428
|
onFocus: handleFocus,
|
|
452
429
|
onBlur: handleBlur,
|
|
453
430
|
onDaySelect: handleDaySelect,
|
|
454
431
|
isDateDisabled: isDateDisabled,
|
|
455
|
-
currentMonthNumber: currentMonthNumber
|
|
456
|
-
isViewFocused: internalHasFocus
|
|
432
|
+
currentMonthNumber: currentMonthNumber
|
|
457
433
|
// fix issue of announcing column 1 as column 2 when `displayWeekNumber` is enabled
|
|
458
434
|
,
|
|
459
435
|
"aria-colindex": dayIndex + 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickersFadeTransitionGroupClasses } from './pickersFadeTransitionGroupClasses';
|
|
3
3
|
export interface PickersFadeTransitionGroupProps {
|
|
4
|
-
children: React.ReactElement
|
|
4
|
+
children: React.ReactElement<any>;
|
|
5
5
|
className?: string;
|
|
6
6
|
reduceAnimations: boolean;
|
|
7
7
|
transKey: React.Key;
|
|
@@ -6,10 +6,7 @@ import { styled, useTheme, useThemeProps } from '@mui/material/styles';
|
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
7
|
import { getPickersFadeTransitionGroupUtilityClass } from "./pickersFadeTransitionGroupClasses.js";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
const useUtilityClasses =
|
|
10
|
-
const {
|
|
11
|
-
classes
|
|
12
|
-
} = ownerState;
|
|
9
|
+
const useUtilityClasses = classes => {
|
|
13
10
|
const slots = {
|
|
14
11
|
root: ['root']
|
|
15
12
|
};
|
|
@@ -36,9 +33,10 @@ export function PickersFadeTransitionGroup(inProps) {
|
|
|
36
33
|
children,
|
|
37
34
|
className,
|
|
38
35
|
reduceAnimations,
|
|
39
|
-
transKey
|
|
36
|
+
transKey,
|
|
37
|
+
classes: classesProp
|
|
40
38
|
} = props;
|
|
41
|
-
const classes = useUtilityClasses(
|
|
39
|
+
const classes = useUtilityClasses(classesProp);
|
|
42
40
|
const theme = useTheme();
|
|
43
41
|
if (reduceAnimations) {
|
|
44
42
|
return children;
|
|
@@ -9,7 +9,7 @@ export interface ExportedSlideTransitionProps {
|
|
|
9
9
|
classes?: Partial<PickersSlideTransitionClasses>;
|
|
10
10
|
}
|
|
11
11
|
export interface SlideTransitionProps extends Omit<CSSTransitionProps, 'timeout'>, ExportedSlideTransitionProps {
|
|
12
|
-
children: React.ReactElement
|
|
12
|
+
children: React.ReactElement<any>;
|
|
13
13
|
className?: string;
|
|
14
14
|
reduceAnimations: boolean;
|
|
15
15
|
slideDirection: SlideDirection;
|
|
@@ -7,10 +7,10 @@ import { styled, useTheme, useThemeProps } from '@mui/material/styles';
|
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
|
9
9
|
import { getPickersSlideTransitionUtilityClass, pickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
|
|
10
|
+
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const useUtilityClasses = ownerState => {
|
|
12
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
12
13
|
const {
|
|
13
|
-
classes,
|
|
14
14
|
slideDirection
|
|
15
15
|
} = ownerState;
|
|
16
16
|
const slots = {
|
|
@@ -99,11 +99,18 @@ export function PickersSlideTransition(inProps) {
|
|
|
99
99
|
children,
|
|
100
100
|
className,
|
|
101
101
|
reduceAnimations,
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
slideDirection,
|
|
103
|
+
transKey,
|
|
104
|
+
classes: classesProp
|
|
104
105
|
} = props,
|
|
105
106
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
106
|
-
const
|
|
107
|
+
const {
|
|
108
|
+
ownerState: pickerOwnerState
|
|
109
|
+
} = usePickerPrivateContext();
|
|
110
|
+
const ownerState = _extends({}, pickerOwnerState, {
|
|
111
|
+
slideDirection
|
|
112
|
+
});
|
|
113
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
107
114
|
const theme = useTheme();
|
|
108
115
|
if (reduceAnimations) {
|
|
109
116
|
return /*#__PURE__*/_jsx("div", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlideDirection } from './PickersSlideTransition';
|
|
2
|
-
import {
|
|
2
|
+
import { PickersTimezone, PickerValidDate } from '../models';
|
|
3
3
|
import { DateCalendarDefaultizedProps } from './DateCalendar.types';
|
|
4
4
|
interface CalendarState {
|
|
5
5
|
currentMonth: PickerValidDate;
|
|
@@ -7,35 +7,21 @@ interface CalendarState {
|
|
|
7
7
|
isMonthSwitchingAnimating: boolean;
|
|
8
8
|
slideDirection: SlideDirection;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} & TAdditional;
|
|
13
|
-
interface ChangeMonthPayload {
|
|
14
|
-
direction: SlideDirection;
|
|
15
|
-
newMonth: PickerValidDate;
|
|
16
|
-
}
|
|
17
|
-
interface ChangeFocusedDayPayload {
|
|
18
|
-
focusedDay: PickerValidDate | null;
|
|
19
|
-
/**
|
|
20
|
-
* The update does not trigger month switching animation.
|
|
21
|
-
* For example: when selecting month from the month view.
|
|
22
|
-
*/
|
|
23
|
-
withoutMonthSwitchingAnimation?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare const createCalendarStateReducer: (reduceAnimations: boolean, disableSwitchToMonthOnDayFocus: boolean, utils: MuiPickersAdapter) => (state: CalendarState, action: ReducerAction<"finishMonthSwitchingAnimation"> | ReducerAction<"changeMonth", ChangeMonthPayload> | ReducerAction<"changeMonthTimezone", {
|
|
26
|
-
newTimezone: string;
|
|
27
|
-
}> | ReducerAction<"changeFocusedDay", ChangeFocusedDayPayload>) => CalendarState;
|
|
28
|
-
interface UseCalendarStateParams extends Pick<DateCalendarDefaultizedProps, 'value' | 'referenceDate' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'reduceAnimations' | 'shouldDisableDate'> {
|
|
29
|
-
disableSwitchToMonthOnDayFocus?: boolean;
|
|
10
|
+
interface UseCalendarStateParameters extends Pick<DateCalendarDefaultizedProps, 'referenceDate' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'onYearChange' | 'reduceAnimations' | 'shouldDisableDate'> {
|
|
11
|
+
value: PickerValidDate | null;
|
|
30
12
|
timezone: PickersTimezone;
|
|
13
|
+
getCurrentMonthFromVisibleDate: (focusedDay: PickerValidDate, prevMonth: PickerValidDate) => PickerValidDate;
|
|
31
14
|
}
|
|
32
|
-
|
|
33
|
-
referenceDate:
|
|
15
|
+
interface UseCalendarStateReturnValue {
|
|
16
|
+
referenceDate: PickerValidDate;
|
|
34
17
|
calendarState: CalendarState;
|
|
35
|
-
|
|
36
|
-
changeFocusedDay: (newFocusedDate: PickerValidDate | null, withoutMonthSwitchingAnimation?: boolean) => void;
|
|
18
|
+
setVisibleDate: (parameters: SetVisibleDateParameters) => void;
|
|
37
19
|
isDateDisabled: (day: PickerValidDate | null) => boolean;
|
|
38
20
|
onMonthSwitchingAnimationEnd: () => void;
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
}
|
|
22
|
+
export declare const useCalendarState: (params: UseCalendarStateParameters) => UseCalendarStateReturnValue;
|
|
23
|
+
interface SetVisibleDateParameters {
|
|
24
|
+
target: PickerValidDate;
|
|
25
|
+
reason: 'header-navigation' | 'cell-interaction' | 'controlled-value-change';
|
|
26
|
+
}
|
|
41
27
|
export {};
|
|
@@ -7,13 +7,15 @@ import { useIsDateDisabled } from "./useIsDateDisabled.js";
|
|
|
7
7
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { SECTION_TYPE_GRANULARITY } from "../internals/utils/getDefaultReferenceDate.js";
|
|
10
|
-
|
|
10
|
+
import { findClosestEnabledDate } from "../internals/utils/date-utils.js";
|
|
11
|
+
const createCalendarStateReducer = (reduceAnimations, utils) => (state, action) => {
|
|
11
12
|
switch (action.type) {
|
|
12
|
-
case '
|
|
13
|
+
case 'setVisibleDate':
|
|
13
14
|
return _extends({}, state, {
|
|
14
15
|
slideDirection: action.direction,
|
|
15
|
-
currentMonth: action.
|
|
16
|
-
isMonthSwitchingAnimating: !reduceAnimations
|
|
16
|
+
currentMonth: action.month,
|
|
17
|
+
isMonthSwitchingAnimating: !utils.isSameMonth(action.month, state.currentMonth) && !reduceAnimations && !action.skipAnimation,
|
|
18
|
+
focusedDay: action.focusedDay
|
|
17
19
|
});
|
|
18
20
|
case 'changeMonthTimezone':
|
|
19
21
|
{
|
|
@@ -33,19 +35,6 @@ export const createCalendarStateReducer = (reduceAnimations, disableSwitchToMont
|
|
|
33
35
|
return _extends({}, state, {
|
|
34
36
|
isMonthSwitchingAnimating: false
|
|
35
37
|
});
|
|
36
|
-
case 'changeFocusedDay':
|
|
37
|
-
{
|
|
38
|
-
if (state.focusedDay != null && action.focusedDay != null && utils.isSameDay(action.focusedDay, state.focusedDay)) {
|
|
39
|
-
return state;
|
|
40
|
-
}
|
|
41
|
-
const needMonthSwitch = action.focusedDay != null && !disableSwitchToMonthOnDayFocus && !utils.isSameMonth(state.currentMonth, action.focusedDay);
|
|
42
|
-
return _extends({}, state, {
|
|
43
|
-
focusedDay: action.focusedDay,
|
|
44
|
-
isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations && !action.withoutMonthSwitchingAnimation,
|
|
45
|
-
currentMonth: needMonthSwitch ? utils.startOfMonth(action.focusedDay) : state.currentMonth,
|
|
46
|
-
slideDirection: action.focusedDay != null && utils.isAfterDay(action.focusedDay, state.currentMonth) ? 'left' : 'right'
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
38
|
default:
|
|
50
39
|
throw new Error('missing support');
|
|
51
40
|
}
|
|
@@ -56,16 +45,17 @@ export const useCalendarState = params => {
|
|
|
56
45
|
referenceDate: referenceDateProp,
|
|
57
46
|
disableFuture,
|
|
58
47
|
disablePast,
|
|
59
|
-
disableSwitchToMonthOnDayFocus = false,
|
|
60
48
|
maxDate,
|
|
61
49
|
minDate,
|
|
62
50
|
onMonthChange,
|
|
51
|
+
onYearChange,
|
|
63
52
|
reduceAnimations,
|
|
64
53
|
shouldDisableDate,
|
|
65
|
-
timezone
|
|
54
|
+
timezone,
|
|
55
|
+
getCurrentMonthFromVisibleDate
|
|
66
56
|
} = params;
|
|
67
57
|
const utils = useUtils();
|
|
68
|
-
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations),
|
|
58
|
+
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), utils)).current;
|
|
69
59
|
const referenceDate = React.useMemo(() => {
|
|
70
60
|
return singleItemValueManager.getInitialReferenceValue({
|
|
71
61
|
value,
|
|
@@ -85,6 +75,14 @@ export const useCalendarState = params => {
|
|
|
85
75
|
currentMonth: utils.startOfMonth(referenceDate),
|
|
86
76
|
slideDirection: 'left'
|
|
87
77
|
});
|
|
78
|
+
const isDateDisabled = useIsDateDisabled({
|
|
79
|
+
shouldDisableDate,
|
|
80
|
+
minDate,
|
|
81
|
+
maxDate,
|
|
82
|
+
disableFuture,
|
|
83
|
+
disablePast,
|
|
84
|
+
timezone
|
|
85
|
+
});
|
|
88
86
|
|
|
89
87
|
// Ensure that `calendarState.currentMonth` timezone is updated when `referenceDate` (or timezone changes)
|
|
90
88
|
// https://github.com/mui/mui-x/issues/10804
|
|
@@ -94,53 +92,65 @@ export const useCalendarState = params => {
|
|
|
94
92
|
newTimezone: utils.getTimezone(referenceDate)
|
|
95
93
|
});
|
|
96
94
|
}, [referenceDate, utils]);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
onMonthChange(payload.newMonth);
|
|
103
|
-
}
|
|
104
|
-
}, [onMonthChange]);
|
|
105
|
-
const changeMonth = React.useCallback(newDate => {
|
|
106
|
-
const newDateRequested = newDate;
|
|
107
|
-
if (utils.isSameMonth(newDateRequested, calendarState.currentMonth)) {
|
|
95
|
+
const setVisibleDate = useEventCallback(({
|
|
96
|
+
target,
|
|
97
|
+
reason
|
|
98
|
+
}) => {
|
|
99
|
+
if (reason === 'cell-interaction' && calendarState.focusedDay != null && utils.isSameDay(target, calendarState.focusedDay)) {
|
|
108
100
|
return;
|
|
109
101
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
const skipAnimation = reason === 'cell-interaction';
|
|
103
|
+
let month;
|
|
104
|
+
let focusedDay;
|
|
105
|
+
if (reason === 'cell-interaction') {
|
|
106
|
+
month = getCurrentMonthFromVisibleDate(target, calendarState.currentMonth);
|
|
107
|
+
focusedDay = target;
|
|
108
|
+
} else {
|
|
109
|
+
month = utils.isSameMonth(target, calendarState.currentMonth) ? calendarState.currentMonth : utils.startOfMonth(target);
|
|
110
|
+
focusedDay = target;
|
|
111
|
+
|
|
112
|
+
// If the date is disabled, we try to find a non-disabled date inside the same month.
|
|
113
|
+
if (isDateDisabled(focusedDay)) {
|
|
114
|
+
const startOfMonth = utils.startOfMonth(target);
|
|
115
|
+
const endOfMonth = utils.endOfMonth(target);
|
|
116
|
+
focusedDay = findClosestEnabledDate({
|
|
117
|
+
utils,
|
|
118
|
+
date: focusedDay,
|
|
119
|
+
minDate: utils.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
|
120
|
+
maxDate: utils.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
|
121
|
+
disablePast,
|
|
122
|
+
disableFuture,
|
|
123
|
+
isDateDisabled,
|
|
124
|
+
timezone
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const hasChangedMonth = !utils.isSameMonth(calendarState.currentMonth, month);
|
|
129
|
+
const hasChangedYear = !utils.isSameYear(calendarState.currentMonth, month);
|
|
130
|
+
if (hasChangedMonth) {
|
|
131
|
+
onMonthChange?.(month);
|
|
132
|
+
}
|
|
133
|
+
if (hasChangedYear) {
|
|
134
|
+
onYearChange?.(utils.startOfYear(month));
|
|
135
|
+
}
|
|
136
|
+
dispatch({
|
|
137
|
+
type: 'setVisibleDate',
|
|
138
|
+
month,
|
|
139
|
+
direction: utils.isAfterDay(month, calendarState.currentMonth) ? 'left' : 'right',
|
|
140
|
+
focusedDay: calendarState.focusedDay != null && focusedDay != null && utils.isSameDay(focusedDay, calendarState.focusedDay) ? calendarState.focusedDay : focusedDay,
|
|
141
|
+
skipAnimation
|
|
113
142
|
});
|
|
114
|
-
}, [calendarState.currentMonth, handleChangeMonth, utils]);
|
|
115
|
-
const isDateDisabled = useIsDateDisabled({
|
|
116
|
-
shouldDisableDate,
|
|
117
|
-
minDate,
|
|
118
|
-
maxDate,
|
|
119
|
-
disableFuture,
|
|
120
|
-
disablePast,
|
|
121
|
-
timezone
|
|
122
143
|
});
|
|
123
144
|
const onMonthSwitchingAnimationEnd = React.useCallback(() => {
|
|
124
145
|
dispatch({
|
|
125
146
|
type: 'finishMonthSwitchingAnimation'
|
|
126
147
|
});
|
|
127
148
|
}, []);
|
|
128
|
-
const changeFocusedDay = useEventCallback((newFocusedDate, withoutMonthSwitchingAnimation) => {
|
|
129
|
-
if (!isDateDisabled(newFocusedDate)) {
|
|
130
|
-
dispatch({
|
|
131
|
-
type: 'changeFocusedDay',
|
|
132
|
-
focusedDay: newFocusedDate,
|
|
133
|
-
withoutMonthSwitchingAnimation
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
149
|
return {
|
|
138
150
|
referenceDate,
|
|
139
151
|
calendarState,
|
|
140
|
-
|
|
141
|
-
changeFocusedDay,
|
|
152
|
+
setVisibleDate,
|
|
142
153
|
isDateDisabled,
|
|
143
|
-
onMonthSwitchingAnimationEnd
|
|
144
|
-
handleChangeMonth
|
|
154
|
+
onMonthSwitchingAnimationEnd
|
|
145
155
|
};
|
|
146
156
|
};
|