@mui/x-date-pickers 8.0.0-alpha.1 → 8.0.0-alpha.10
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 +1903 -231
- package/DateCalendar/DateCalendar.js +4 -4
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/DayCalendar.js +2 -0
- 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 +6 -4
- 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 +10 -7
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
- 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 +43 -37
- 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 +4 -4
- package/modern/DateCalendar/DayCalendar.js +2 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- 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 +10 -7
- 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 +43 -37
- 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 +4 -4
- package/node/DateCalendar/DayCalendar.js +1 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- 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 +10 -7
- 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 +43 -37
- 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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { singleItemFieldValueManager, singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
6
|
+
import { validateTime } from "../validation/index.js";
|
|
7
|
+
export function useTimeManager(parameters = {}) {
|
|
8
|
+
const {
|
|
9
|
+
enableAccessibleFieldDOMStructure = true
|
|
10
|
+
} = parameters;
|
|
11
|
+
return React.useMemo(() => ({
|
|
12
|
+
valueType: 'time',
|
|
13
|
+
validator: validateTime,
|
|
14
|
+
internal_valueManager: singleItemValueManager,
|
|
15
|
+
internal_fieldValueManager: singleItemFieldValueManager,
|
|
16
|
+
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
17
|
+
internal_applyDefaultsToFieldInternalProps: ({
|
|
18
|
+
internalProps,
|
|
19
|
+
utils
|
|
20
|
+
}) => _extends({}, internalProps, getTimeFieldInternalPropsDefaults({
|
|
21
|
+
utils,
|
|
22
|
+
internalProps
|
|
23
|
+
})),
|
|
24
|
+
internal_getOpenPickerButtonAriaLabel: ({
|
|
25
|
+
value,
|
|
26
|
+
utils,
|
|
27
|
+
localeText
|
|
28
|
+
}) => {
|
|
29
|
+
const formattedValue = utils.isValid(value) ? utils.format(value, 'fullTime') : null;
|
|
30
|
+
return localeText.openTimePickerDialogue(formattedValue);
|
|
31
|
+
}
|
|
32
|
+
}), [enableAccessibleFieldDOMStructure]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Private utility function to get the default internal props for the fields with time editing.
|
|
37
|
+
* Is used by the `useTimeManager` and `useTimeRangeManager` hooks.
|
|
38
|
+
*/
|
|
39
|
+
export function getTimeFieldInternalPropsDefaults(parameters) {
|
|
40
|
+
const {
|
|
41
|
+
utils,
|
|
42
|
+
internalProps
|
|
43
|
+
} = parameters;
|
|
44
|
+
const ampm = internalProps.ampm ?? utils.is12HourCycleInCurrentLocale();
|
|
45
|
+
const defaultFormat = ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h;
|
|
46
|
+
return {
|
|
47
|
+
disablePast: internalProps.disablePast ?? false,
|
|
48
|
+
disableFuture: internalProps.disableFuture ?? false,
|
|
49
|
+
format: internalProps.format ?? defaultFormat
|
|
50
|
+
};
|
|
51
|
+
}
|
package/models/adapters.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ export interface MuiPickersAdapter<TLocale = any> {
|
|
|
215
215
|
*/
|
|
216
216
|
is12HourCycleInCurrentLocale(): boolean;
|
|
217
217
|
/**
|
|
218
|
-
* Create a format with no meta-token (
|
|
218
|
+
* Create a format with no meta-token (for example: `LLL` or `PP`).
|
|
219
219
|
* @param {string} format The format to expand.
|
|
220
220
|
* @returns {string} The expanded format.
|
|
221
221
|
*/
|
|
@@ -225,7 +225,7 @@ export interface MuiPickersAdapter<TLocale = any> {
|
|
|
225
225
|
* @param {PickerValidDate | null} value The value to test.
|
|
226
226
|
* @returns {boolean} `true` if the value is a valid date according to the date library.
|
|
227
227
|
*/
|
|
228
|
-
isValid(value: PickerValidDate | null):
|
|
228
|
+
isValid(value: PickerValidDate | null): value is PickerValidDate;
|
|
229
229
|
/**
|
|
230
230
|
* Format a date using an adapter format string (see the `AdapterFormats` interface)
|
|
231
231
|
* @param {PickerValidDate} value The date to format.
|
|
@@ -248,7 +248,7 @@ export interface MuiPickersAdapter<TLocale = any> {
|
|
|
248
248
|
*/
|
|
249
249
|
formatNumber(numberToFormat: string): string;
|
|
250
250
|
/**
|
|
251
|
-
* Check if the two dates are equal (
|
|
251
|
+
* Check if the two dates are equal (which means they represent the same timestamp).
|
|
252
252
|
* @param {PickerValidDate | null} value The reference date.
|
|
253
253
|
* @param {PickerValidDate | null} comparing The date to compare with the reference date.
|
|
254
254
|
* @returns {boolean} `true` if the two dates are equal.
|
|
@@ -442,7 +442,7 @@ export interface MuiPickersAdapter<TLocale = any> {
|
|
|
442
442
|
*/
|
|
443
443
|
getMonth(value: PickerValidDate): number;
|
|
444
444
|
/**
|
|
445
|
-
* Get the date (
|
|
445
|
+
* Get the date (day in the month) of the given date.
|
|
446
446
|
* @param {PickerValidDate} value The given date.
|
|
447
447
|
* @returns {number} The date of the given date.
|
|
448
448
|
*/
|
|
@@ -486,7 +486,7 @@ export interface MuiPickersAdapter<TLocale = any> {
|
|
|
486
486
|
*/
|
|
487
487
|
setMonth(value: PickerValidDate, month: number): PickerValidDate;
|
|
488
488
|
/**
|
|
489
|
-
* Set the date (
|
|
489
|
+
* Set the date (day in the month) to the given date.
|
|
490
490
|
* @param {PickerValidDate} value The date to be changed.
|
|
491
491
|
* @param {number} date The date of the new date.
|
|
492
492
|
* @returns {PickerValidDate} The new date with the date set.
|
package/models/fields.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
-
import type {
|
|
4
|
-
import { ExportedPickersSectionListProps } from '../PickersSectionList';
|
|
3
|
+
import type { ExportedPickersSectionListProps } from '../PickersSectionList';
|
|
5
4
|
import type { UseFieldInternalProps, UseFieldResponse } from '../internals/hooks/useField';
|
|
6
5
|
import type { PickersTextFieldProps } from '../PickersTextField';
|
|
7
|
-
import { BaseForwardedSingleInputFieldProps } from '../internals/models';
|
|
6
|
+
import { BaseForwardedSingleInputFieldProps, FieldRangeSection, PickerRangeValue, PickerValidValue } from '../internals/models';
|
|
7
|
+
import { PickerOwnerState } from './pickers';
|
|
8
|
+
import type { ExportedPickerFieldUIProps } from '../internals/components/PickerFieldUI';
|
|
8
9
|
export type FieldSectionType = 'year' | 'month' | 'day' | 'weekDay' | 'hours' | 'minutes' | 'seconds' | 'meridiem' | 'empty';
|
|
9
10
|
export type FieldSectionContentType = 'digit' | 'digit-with-letter' | 'letter';
|
|
10
11
|
export interface FieldSection {
|
|
@@ -69,12 +70,14 @@ export interface FieldSection {
|
|
|
69
70
|
*/
|
|
70
71
|
endSeparator: string;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
74
|
+
export type InferFieldSection<TValue extends PickerValidValue> = IsAny<TValue> extends true ? FieldSection : TValue extends PickerRangeValue ? FieldRangeSection : FieldSection;
|
|
75
|
+
export interface FieldRef<TValue extends PickerValidValue> {
|
|
73
76
|
/**
|
|
74
77
|
* Returns the sections of the current value.
|
|
75
|
-
* @returns {
|
|
78
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the current value.
|
|
76
79
|
*/
|
|
77
|
-
getSections: () =>
|
|
80
|
+
getSections: () => InferFieldSection<TValue>[];
|
|
78
81
|
/**
|
|
79
82
|
* Returns the index of the active section (the first focused section).
|
|
80
83
|
* If no section is active, returns `null`.
|
|
@@ -98,18 +101,39 @@ export interface FieldRef<TSection extends FieldSection> {
|
|
|
98
101
|
isFieldFocused: () => boolean;
|
|
99
102
|
}
|
|
100
103
|
export type FieldSelectedSections = number | FieldSectionType | null | 'all';
|
|
104
|
+
export interface FieldOwnerState extends PickerOwnerState {
|
|
105
|
+
/**
|
|
106
|
+
* `true` if the field is disabled, `false` otherwise.
|
|
107
|
+
*/
|
|
108
|
+
isFieldDisabled: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* `true` if the field is read-only, `false` otherwise.
|
|
111
|
+
*/
|
|
112
|
+
isFieldReadOnly: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* `true` if the field is required, `false` otherwise.
|
|
115
|
+
*/
|
|
116
|
+
isFieldRequired: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The direction of the field.
|
|
119
|
+
* Is equal to "ltr" when the field is in left-to-right direction.
|
|
120
|
+
* Is equal to "rtl" when the field is in right-to-left direction.
|
|
121
|
+
*/
|
|
122
|
+
fieldDirection: 'ltr' | 'rtl';
|
|
123
|
+
}
|
|
101
124
|
/**
|
|
102
125
|
* Props the prop `slotProps.field` of a picker can receive.
|
|
103
126
|
*/
|
|
104
|
-
export type PickerFieldSlotProps<TValue
|
|
127
|
+
export type PickerFieldSlotProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean> = ExportedPickerFieldUIProps & Pick<UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, unknown>, 'shouldRespectLeadingZeros' | 'readOnly'> & React.HTMLAttributes<HTMLDivElement> & {
|
|
105
128
|
ref?: React.Ref<HTMLDivElement>;
|
|
106
129
|
};
|
|
107
130
|
/**
|
|
108
|
-
* Props the text field receives when used
|
|
131
|
+
* Props the text field receives when used inside a single input picker.
|
|
109
132
|
* Only contains what the MUI components are passing to the text field, not what users can pass using the `props.slotProps.field` and `props.slotProps.textField`.
|
|
110
133
|
*/
|
|
111
|
-
export type BaseSingleInputPickersTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> =
|
|
134
|
+
export type BaseSingleInputPickersTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = Omit<UseFieldResponse<TEnableAccessibleFieldDOMStructure, BaseForwardedSingleInputFieldProps>, 'slots' | 'slotProps' | 'clearable' | 'onClear' | 'openPickerButtonPosition' | 'clearButtonPosition' | 'openPickerAriaLabel'>;
|
|
112
135
|
/**
|
|
113
136
|
* Props the built-in text field component can receive.
|
|
114
137
|
*/
|
|
115
138
|
export type BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? Omit<TextFieldProps, 'autoComplete' | 'error' | 'maxRows' | 'minRows' | 'multiline' | 'placeholder' | 'rows' | 'select' | 'SelectProps' | 'type'> : Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps>>;
|
|
139
|
+
export {};
|
package/models/index.d.ts
CHANGED
package/models/index.js
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { FieldValueManager, UseFieldInternalProps } from '../internals/hooks/useField';
|
|
2
|
+
import type { PickerValueManager } from '../internals/hooks/usePicker';
|
|
3
|
+
import type { UseLocalizationContextReturnValue } from '../internals/hooks/useUtils';
|
|
4
|
+
import type { PickerValidValue } from '../internals/models';
|
|
5
|
+
import type { Validator } from '../validation';
|
|
6
|
+
import type { PickerValueType } from './common';
|
|
7
|
+
/**
|
|
8
|
+
* Object that contains all the necessary methods and properties to adapter a picker or a field for a given value type.
|
|
9
|
+
* You should never create your own manager.
|
|
10
|
+
* Instead, use the hooks exported from '@mui/x-date-pickers/managers' and '@mui/x-date-pickers-pro/managers'.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { useDateManager } from '@mui/x-date-pickers/managers';
|
|
14
|
+
* import { useValidation } from '@mui/x-date-pickers/validation';
|
|
15
|
+
*
|
|
16
|
+
* const manager = useDateManager();
|
|
17
|
+
* const { hasValidationError } = useValidation({
|
|
18
|
+
* validator: manager.validator,
|
|
19
|
+
* value,
|
|
20
|
+
* timezone,
|
|
21
|
+
* props,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface PickerManager<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TFieldInternalProps extends {}, TFieldInternalPropsWithDefaults extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError>> {
|
|
26
|
+
/**
|
|
27
|
+
* The type of the value (e.g. 'date', 'date-time', 'time').
|
|
28
|
+
*/
|
|
29
|
+
valueType: PickerValueType;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a value is valid and returns an error code otherwise.
|
|
32
|
+
* It can be passed to the `useValidation` hook to validate a value:
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { useDateManager } from '@mui/x-date-pickers/managers';
|
|
36
|
+
* import { useValidation } from '@mui/x-date-pickers/validation';
|
|
37
|
+
*
|
|
38
|
+
* const manager = useDateManager();
|
|
39
|
+
* const { hasValidationError } = useValidation({
|
|
40
|
+
* validator: manager.validator,
|
|
41
|
+
* value,
|
|
42
|
+
* timezone,
|
|
43
|
+
* props,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
validator: Validator<TValue, TError, TFieldInternalPropsWithDefaults>;
|
|
48
|
+
/**
|
|
49
|
+
* Object containing basic methods to interact with the value of the picker or field.
|
|
50
|
+
* This property is not part of the public API and should not be used directly.
|
|
51
|
+
*/
|
|
52
|
+
internal_valueManager: PickerValueManager<TValue, TError>;
|
|
53
|
+
/**
|
|
54
|
+
* Object containing all the necessary methods to interact with the value of the field.
|
|
55
|
+
* This property is not part of the public API and should not be used directly.
|
|
56
|
+
*/
|
|
57
|
+
internal_fieldValueManager: FieldValueManager<TValue>;
|
|
58
|
+
/**
|
|
59
|
+
* `true` if the field is using the accessible DOM structure.
|
|
60
|
+
* `false` if the field is using the non-accessible DOM structure.
|
|
61
|
+
* This property is not part of the public API and should not be used directly.
|
|
62
|
+
*/
|
|
63
|
+
internal_enableAccessibleFieldDOMStructure: TEnableAccessibleFieldDOMStructure;
|
|
64
|
+
/**
|
|
65
|
+
* Applies the default values to the field internal props.
|
|
66
|
+
* This usually includes:
|
|
67
|
+
* - a default format to display the value in the field
|
|
68
|
+
* - some default validation props that are needed to validate the value (e.g: minDate, maxDate)
|
|
69
|
+
* This property is not part of the public API and should not be used directly.
|
|
70
|
+
* @param {ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps>} parameters The parameters to apply the defaults.
|
|
71
|
+
* @returns {TFieldInternalPropsWithDefaults} The field internal props with the defaults applied.
|
|
72
|
+
*/
|
|
73
|
+
internal_applyDefaultsToFieldInternalProps: (parameters: ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps>) => TFieldInternalPropsWithDefaults;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the aria-label to apply on the button that opens the picker.
|
|
76
|
+
* @param {GetOpenPickerButtonAriaLabelParameters<TValue>} params The parameters to get the aria-label.
|
|
77
|
+
* @returns {string} The aria-label to apply on the button that opens the picker.
|
|
78
|
+
*/
|
|
79
|
+
internal_getOpenPickerButtonAriaLabel: (params: GetOpenPickerButtonAriaLabelParameters<TValue>) => string;
|
|
80
|
+
}
|
|
81
|
+
interface ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps extends {}> extends UseLocalizationContextReturnValue {
|
|
82
|
+
internalProps: TFieldInternalProps;
|
|
83
|
+
}
|
|
84
|
+
interface GetOpenPickerButtonAriaLabelParameters<TValue extends PickerValidValue> extends UseLocalizationContextReturnValue {
|
|
85
|
+
value: TValue;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/models/pickers.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ export interface PickerChangeHandlerContext<TError> {
|
|
|
11
11
|
export interface PickerValidDateLookup {
|
|
12
12
|
}
|
|
13
13
|
export type PickerValidDate = keyof PickerValidDateLookup extends never ? any : PickerValidDateLookup[keyof PickerValidDateLookup];
|
|
14
|
+
/**
|
|
15
|
+
* Importance of the change when picking a value:
|
|
16
|
+
* - "accept": fires `onChange`, fires `onAccept` and closes the picker.
|
|
17
|
+
* - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
|
|
18
|
+
* @default "accept"
|
|
19
|
+
*/
|
|
20
|
+
export type PickerChangeImportance = 'set' | 'accept';
|
|
14
21
|
export interface PickerOwnerState {
|
|
15
22
|
/**
|
|
16
23
|
* `true` if the value of the picker is currently empty.
|
package/models/validation.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PickerValidValue } from '../internals/models';
|
|
1
2
|
/**
|
|
2
3
|
* Validation error types applicable to both date and time validation
|
|
3
4
|
*/
|
|
@@ -5,7 +6,7 @@ type CommonDateTimeValidationError = 'invalidDate' | 'disableFuture' | 'disableP
|
|
|
5
6
|
export type DateValidationError = CommonDateTimeValidationError | 'shouldDisableDate' | 'shouldDisableMonth' | 'shouldDisableYear' | 'minDate' | 'maxDate';
|
|
6
7
|
export type TimeValidationError = CommonDateTimeValidationError | 'minutesStep' | 'minTime' | 'maxTime' | 'shouldDisableTime-hours' | 'shouldDisableTime-minutes' | 'shouldDisableTime-seconds';
|
|
7
8
|
export type DateTimeValidationError = DateValidationError | TimeValidationError;
|
|
8
|
-
export interface OnErrorProps<TValue, TError> {
|
|
9
|
+
export interface OnErrorProps<TValue extends PickerValidValue, TError> {
|
|
9
10
|
/**
|
|
10
11
|
* Callback fired when the error associated with the current value changes.
|
|
11
12
|
* When a validation error is detected, the `error` parameter contains a non-null value.
|
|
@@ -1,49 +1,47 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
import addDays from 'date-fns/addDays';
|
|
3
|
-
import addSeconds from 'date-fns/addSeconds';
|
|
4
|
-
import addMinutes from 'date-fns/addMinutes';
|
|
5
|
-
import addHours from 'date-fns/addHours';
|
|
6
|
-
import addWeeks from 'date-fns/addWeeks';
|
|
7
|
-
import addMonths from 'date-fns/addMonths';
|
|
8
|
-
import addYears from 'date-fns/addYears';
|
|
9
|
-
import endOfDay from 'date-fns/endOfDay';
|
|
10
|
-
import endOfWeek from 'date-fns/endOfWeek';
|
|
11
|
-
import endOfYear from 'date-fns/endOfYear';
|
|
12
|
-
import dateFnsFormat from 'date-fns/format';
|
|
13
|
-
import getDate from 'date-fns/getDate';
|
|
14
|
-
import getDaysInMonth from 'date-fns/getDaysInMonth';
|
|
15
|
-
import getHours from 'date-fns/getHours';
|
|
16
|
-
import getMinutes from 'date-fns/getMinutes';
|
|
17
|
-
import getMonth from 'date-fns/getMonth';
|
|
18
|
-
import getSeconds from 'date-fns/getSeconds';
|
|
19
|
-
import getMilliseconds from 'date-fns/getMilliseconds';
|
|
20
|
-
import getWeek from 'date-fns/getWeek';
|
|
21
|
-
import getYear from 'date-fns/getYear';
|
|
22
|
-
import isAfter from 'date-fns/isAfter';
|
|
23
|
-
import isBefore from 'date-fns/isBefore';
|
|
24
|
-
import isEqual from 'date-fns/isEqual';
|
|
25
|
-
import isSameDay from 'date-fns/isSameDay';
|
|
26
|
-
import isSameYear from 'date-fns/isSameYear';
|
|
27
|
-
import isSameMonth from 'date-fns/isSameMonth';
|
|
28
|
-
import isSameHour from 'date-fns/isSameHour';
|
|
29
|
-
import isValid from 'date-fns/isValid';
|
|
30
|
-
import dateFnsParse from 'date-fns/parse';
|
|
31
|
-
import setDate from 'date-fns/setDate';
|
|
32
|
-
import setHours from 'date-fns/setHours';
|
|
33
|
-
import setMinutes from 'date-fns/setMinutes';
|
|
34
|
-
import setMonth from 'date-fns/setMonth';
|
|
35
|
-
import setSeconds from 'date-fns/setSeconds';
|
|
36
|
-
import setMilliseconds from 'date-fns/setMilliseconds';
|
|
37
|
-
import setYear from 'date-fns/setYear';
|
|
38
|
-
import startOfDay from 'date-fns/startOfDay';
|
|
39
|
-
import startOfMonth from 'date-fns/startOfMonth';
|
|
40
|
-
import endOfMonth from 'date-fns/endOfMonth';
|
|
41
|
-
import startOfWeek from 'date-fns/startOfWeek';
|
|
42
|
-
import startOfYear from 'date-fns/startOfYear';
|
|
43
|
-
import isWithinInterval from 'date-fns/isWithinInterval';
|
|
44
|
-
import
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
import longFormatters from 'date-fns/_lib/format/longFormatters';
|
|
2
|
+
import { addDays } from 'date-fns/addDays';
|
|
3
|
+
import { addSeconds } from 'date-fns/addSeconds';
|
|
4
|
+
import { addMinutes } from 'date-fns/addMinutes';
|
|
5
|
+
import { addHours } from 'date-fns/addHours';
|
|
6
|
+
import { addWeeks } from 'date-fns/addWeeks';
|
|
7
|
+
import { addMonths } from 'date-fns/addMonths';
|
|
8
|
+
import { addYears } from 'date-fns/addYears';
|
|
9
|
+
import { endOfDay } from 'date-fns/endOfDay';
|
|
10
|
+
import { endOfWeek } from 'date-fns/endOfWeek';
|
|
11
|
+
import { endOfYear } from 'date-fns/endOfYear';
|
|
12
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
|
|
13
|
+
import { getDate } from 'date-fns/getDate';
|
|
14
|
+
import { getDaysInMonth } from 'date-fns/getDaysInMonth';
|
|
15
|
+
import { getHours } from 'date-fns/getHours';
|
|
16
|
+
import { getMinutes } from 'date-fns/getMinutes';
|
|
17
|
+
import { getMonth } from 'date-fns/getMonth';
|
|
18
|
+
import { getSeconds } from 'date-fns/getSeconds';
|
|
19
|
+
import { getMilliseconds } from 'date-fns/getMilliseconds';
|
|
20
|
+
import { getWeek } from 'date-fns/getWeek';
|
|
21
|
+
import { getYear } from 'date-fns/getYear';
|
|
22
|
+
import { isAfter } from 'date-fns/isAfter';
|
|
23
|
+
import { isBefore } from 'date-fns/isBefore';
|
|
24
|
+
import { isEqual } from 'date-fns/isEqual';
|
|
25
|
+
import { isSameDay } from 'date-fns/isSameDay';
|
|
26
|
+
import { isSameYear } from 'date-fns/isSameYear';
|
|
27
|
+
import { isSameMonth } from 'date-fns/isSameMonth';
|
|
28
|
+
import { isSameHour } from 'date-fns/isSameHour';
|
|
29
|
+
import { isValid } from 'date-fns/isValid';
|
|
30
|
+
import { parse as dateFnsParse } from 'date-fns/parse';
|
|
31
|
+
import { setDate } from 'date-fns/setDate';
|
|
32
|
+
import { setHours } from 'date-fns/setHours';
|
|
33
|
+
import { setMinutes } from 'date-fns/setMinutes';
|
|
34
|
+
import { setMonth } from 'date-fns/setMonth';
|
|
35
|
+
import { setSeconds } from 'date-fns/setSeconds';
|
|
36
|
+
import { setMilliseconds } from 'date-fns/setMilliseconds';
|
|
37
|
+
import { setYear } from 'date-fns/setYear';
|
|
38
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
39
|
+
import { startOfMonth } from 'date-fns/startOfMonth';
|
|
40
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
41
|
+
import { startOfWeek } from 'date-fns/startOfWeek';
|
|
42
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
43
|
+
import { isWithinInterval } from 'date-fns/isWithinInterval';
|
|
44
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
47
45
|
import { AdapterDateFnsBase } from "../AdapterDateFnsBase/index.js";
|
|
48
46
|
/**
|
|
49
47
|
* Based on `@date-io/date-fns`
|
|
@@ -78,14 +76,18 @@ export class AdapterDateFns extends AdapterDateFnsBase {
|
|
|
78
76
|
/* istanbul ignore next */
|
|
79
77
|
if (process.env.NODE_ENV !== 'production') {
|
|
80
78
|
if (typeof addDays !== 'function') {
|
|
81
|
-
throw new Error(['MUI:
|
|
79
|
+
throw new Error(['MUI: The `date-fns` package v2.x is not compatible with this adapter.', 'Please, install v3.x or v4.x of the package or use the `AdapterDateFnsV2` instead.'].join('\n'));
|
|
80
|
+
}
|
|
81
|
+
if (!longFormatters) {
|
|
82
|
+
throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
super({
|
|
85
|
-
locale: locale ??
|
|
86
|
+
locale: locale ?? enUS,
|
|
86
87
|
formats,
|
|
87
88
|
longFormatters
|
|
88
89
|
});
|
|
90
|
+
// TODO: explicit return types can be removed once there is only one date-fns version supported
|
|
89
91
|
this.parse = (value, format) => {
|
|
90
92
|
if (value === '') {
|
|
91
93
|
return null;
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
/* eslint-disable class-methods-use-this */
|
|
3
|
-
import addSeconds from 'date-fns-jalali/addSeconds';
|
|
4
|
-
import addMinutes from 'date-fns-jalali/addMinutes';
|
|
5
|
-
import addHours from 'date-fns-jalali/addHours';
|
|
6
|
-
import addDays from 'date-fns-jalali/addDays';
|
|
7
|
-
import addWeeks from 'date-fns-jalali/addWeeks';
|
|
8
|
-
import addMonths from 'date-fns-jalali/addMonths';
|
|
9
|
-
import addYears from 'date-fns-jalali/addYears';
|
|
10
|
-
import endOfDay from 'date-fns-jalali/endOfDay';
|
|
11
|
-
import endOfWeek from 'date-fns-jalali/endOfWeek';
|
|
12
|
-
import endOfYear from 'date-fns-jalali/endOfYear';
|
|
13
|
-
import dateFnsFormat from 'date-fns-jalali/format';
|
|
14
|
-
import getHours from 'date-fns-jalali/getHours';
|
|
15
|
-
import getSeconds from 'date-fns-jalali/getSeconds';
|
|
16
|
-
import getMilliseconds from 'date-fns-jalali/getMilliseconds';
|
|
17
|
-
import getWeek from 'date-fns-jalali/getWeek';
|
|
18
|
-
import getYear from 'date-fns-jalali/getYear';
|
|
19
|
-
import getMonth from 'date-fns-jalali/getMonth';
|
|
20
|
-
import getDate from 'date-fns-jalali/getDate';
|
|
21
|
-
import getDaysInMonth from 'date-fns-jalali/getDaysInMonth';
|
|
22
|
-
import getMinutes from 'date-fns-jalali/getMinutes';
|
|
23
|
-
import isAfter from 'date-fns-jalali/isAfter';
|
|
24
|
-
import isBefore from 'date-fns-jalali/isBefore';
|
|
25
|
-
import isEqual from 'date-fns-jalali/isEqual';
|
|
26
|
-
import isSameDay from 'date-fns-jalali/isSameDay';
|
|
27
|
-
import isSameYear from 'date-fns-jalali/isSameYear';
|
|
28
|
-
import isSameMonth from 'date-fns-jalali/isSameMonth';
|
|
29
|
-
import isSameHour from 'date-fns-jalali/isSameHour';
|
|
30
|
-
import isValid from 'date-fns-jalali/isValid';
|
|
31
|
-
import dateFnsParse from 'date-fns-jalali/parse';
|
|
32
|
-
import setDate from 'date-fns-jalali/setDate';
|
|
33
|
-
import setHours from 'date-fns-jalali/setHours';
|
|
34
|
-
import setMinutes from 'date-fns-jalali/setMinutes';
|
|
35
|
-
import setMonth from 'date-fns-jalali/setMonth';
|
|
36
|
-
import setSeconds from 'date-fns-jalali/setSeconds';
|
|
37
|
-
import setMilliseconds from 'date-fns-jalali/setMilliseconds';
|
|
38
|
-
import setYear from 'date-fns-jalali/setYear';
|
|
39
|
-
import startOfDay from 'date-fns-jalali/startOfDay';
|
|
40
|
-
import startOfMonth from 'date-fns-jalali/startOfMonth';
|
|
41
|
-
import endOfMonth from 'date-fns-jalali/endOfMonth';
|
|
42
|
-
import startOfWeek from 'date-fns-jalali/startOfWeek';
|
|
43
|
-
import startOfYear from 'date-fns-jalali/startOfYear';
|
|
44
|
-
import isWithinInterval from 'date-fns-jalali/isWithinInterval';
|
|
45
|
-
import defaultLocale from 'date-fns-jalali/locale/fa-IR';
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
import longFormatters from 'date-fns-jalali/_lib/format/longFormatters';
|
|
3
|
+
import { addSeconds } from 'date-fns-jalali/addSeconds';
|
|
4
|
+
import { addMinutes } from 'date-fns-jalali/addMinutes';
|
|
5
|
+
import { addHours } from 'date-fns-jalali/addHours';
|
|
6
|
+
import { addDays } from 'date-fns-jalali/addDays';
|
|
7
|
+
import { addWeeks } from 'date-fns-jalali/addWeeks';
|
|
8
|
+
import { addMonths } from 'date-fns-jalali/addMonths';
|
|
9
|
+
import { addYears } from 'date-fns-jalali/addYears';
|
|
10
|
+
import { endOfDay } from 'date-fns-jalali/endOfDay';
|
|
11
|
+
import { endOfWeek } from 'date-fns-jalali/endOfWeek';
|
|
12
|
+
import { endOfYear } from 'date-fns-jalali/endOfYear';
|
|
13
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns-jalali/format';
|
|
14
|
+
import { getHours } from 'date-fns-jalali/getHours';
|
|
15
|
+
import { getSeconds } from 'date-fns-jalali/getSeconds';
|
|
16
|
+
import { getMilliseconds } from 'date-fns-jalali/getMilliseconds';
|
|
17
|
+
import { getWeek } from 'date-fns-jalali/getWeek';
|
|
18
|
+
import { getYear } from 'date-fns-jalali/getYear';
|
|
19
|
+
import { getMonth } from 'date-fns-jalali/getMonth';
|
|
20
|
+
import { getDate } from 'date-fns-jalali/getDate';
|
|
21
|
+
import { getDaysInMonth } from 'date-fns-jalali/getDaysInMonth';
|
|
22
|
+
import { getMinutes } from 'date-fns-jalali/getMinutes';
|
|
23
|
+
import { isAfter } from 'date-fns-jalali/isAfter';
|
|
24
|
+
import { isBefore } from 'date-fns-jalali/isBefore';
|
|
25
|
+
import { isEqual } from 'date-fns-jalali/isEqual';
|
|
26
|
+
import { isSameDay } from 'date-fns-jalali/isSameDay';
|
|
27
|
+
import { isSameYear } from 'date-fns-jalali/isSameYear';
|
|
28
|
+
import { isSameMonth } from 'date-fns-jalali/isSameMonth';
|
|
29
|
+
import { isSameHour } from 'date-fns-jalali/isSameHour';
|
|
30
|
+
import { isValid } from 'date-fns-jalali/isValid';
|
|
31
|
+
import { parse as dateFnsParse } from 'date-fns-jalali/parse';
|
|
32
|
+
import { setDate } from 'date-fns-jalali/setDate';
|
|
33
|
+
import { setHours } from 'date-fns-jalali/setHours';
|
|
34
|
+
import { setMinutes } from 'date-fns-jalali/setMinutes';
|
|
35
|
+
import { setMonth } from 'date-fns-jalali/setMonth';
|
|
36
|
+
import { setSeconds } from 'date-fns-jalali/setSeconds';
|
|
37
|
+
import { setMilliseconds } from 'date-fns-jalali/setMilliseconds';
|
|
38
|
+
import { setYear } from 'date-fns-jalali/setYear';
|
|
39
|
+
import { startOfDay } from 'date-fns-jalali/startOfDay';
|
|
40
|
+
import { startOfMonth } from 'date-fns-jalali/startOfMonth';
|
|
41
|
+
import { endOfMonth } from 'date-fns-jalali/endOfMonth';
|
|
42
|
+
import { startOfWeek } from 'date-fns-jalali/startOfWeek';
|
|
43
|
+
import { startOfYear } from 'date-fns-jalali/startOfYear';
|
|
44
|
+
import { isWithinInterval } from 'date-fns-jalali/isWithinInterval';
|
|
45
|
+
import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR';
|
|
48
46
|
import { AdapterDateFnsBase } from "../AdapterDateFnsBase/index.js";
|
|
49
47
|
const defaultFormats = {
|
|
50
48
|
year: 'yyyy',
|
|
@@ -116,7 +114,10 @@ export class AdapterDateFnsJalali extends AdapterDateFnsBase {
|
|
|
116
114
|
/* istanbul ignore next */
|
|
117
115
|
if (process.env.NODE_ENV !== 'production') {
|
|
118
116
|
if (typeof addDays !== 'function') {
|
|
119
|
-
throw new Error(['MUI: The `date-fns-jalali` package
|
|
117
|
+
throw new Error(['MUI: The `date-fns-jalali` package v2.x is not compatible with this adapter.', 'Please, install v3.x or v4.x of the package or use the `AdapterDateFnsJalaliV2` instead.'].join('\n'));
|
|
118
|
+
}
|
|
119
|
+
if (!longFormatters) {
|
|
120
|
+
throw new Error('MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.');
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
super({
|
|
@@ -127,6 +128,7 @@ export class AdapterDateFnsJalali extends AdapterDateFnsBase {
|
|
|
127
128
|
longFormatters,
|
|
128
129
|
lib: 'date-fns-jalali'
|
|
129
130
|
});
|
|
131
|
+
// TODO: explicit return types can be removed once there is only one date-fns version supported
|
|
130
132
|
this.parse = (value, format) => {
|
|
131
133
|
if (value === '') {
|
|
132
134
|
return null;
|