@mui/x-date-pickers 7.22.3 → 8.0.0-alpha.1
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 +1 -1
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +3 -3
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -1
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +1 -1
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
- package/AdapterLuxon/AdapterLuxon.d.ts +2 -2
- package/AdapterMoment/AdapterMoment.d.ts +2 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +2 -2
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +2 -2
- package/CHANGELOG.md +348 -12
- package/DateCalendar/DateCalendar.d.ts +1 -2
- package/DateCalendar/DateCalendar.js +21 -22
- package/DateCalendar/DateCalendar.types.d.ts +21 -31
- package/DateCalendar/DayCalendar.d.ts +25 -24
- package/DateCalendar/DayCalendar.js +13 -10
- package/DateCalendar/index.d.ts +1 -0
- package/DateCalendar/useCalendarState.d.ts +16 -16
- package/DateCalendar/useIsDateDisabled.d.ts +2 -2
- package/DateField/DateField.d.ts +1 -2
- package/DateField/DateField.js +8 -10
- package/DateField/DateField.types.d.ts +8 -9
- package/DateField/index.d.ts +1 -1
- package/DateField/useDateField.d.ts +1 -2
- package/DatePicker/DatePicker.d.ts +1 -2
- package/DatePicker/DatePicker.js +15 -14
- package/DatePicker/DatePicker.types.d.ts +10 -11
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -4
- package/DatePicker/shared.d.ts +11 -11
- package/DateTimeField/DateTimeField.d.ts +1 -2
- package/DateTimeField/DateTimeField.js +9 -12
- package/DateTimeField/DateTimeField.types.d.ts +9 -14
- package/DateTimeField/index.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -2
- package/DateTimePicker/DateTimePicker.d.ts +1 -2
- package/DateTimePicker/DateTimePicker.js +16 -16
- package/DateTimePicker/DateTimePicker.types.d.ts +10 -13
- package/DateTimePicker/DateTimePickerTabs.d.ts +1 -2
- package/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -5
- package/DateTimePicker/DateTimePickerToolbar.js +8 -7
- package/DateTimePicker/shared.d.ts +12 -12
- package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -2
- package/DesktopDatePicker/DesktopDatePicker.js +17 -16
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -7
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +8 -8
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
- package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -2
- package/DesktopTimePicker/DesktopTimePicker.js +11 -6
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +8 -8
- package/DigitalClock/DigitalClock.d.ts +1 -2
- package/DigitalClock/DigitalClock.js +8 -6
- package/DigitalClock/DigitalClock.types.d.ts +4 -4
- package/LocalizationProvider/LocalizationProvider.d.ts +12 -12
- package/MobileDatePicker/MobileDatePicker.d.ts +1 -2
- package/MobileDatePicker/MobileDatePicker.js +17 -16
- package/MobileDatePicker/MobileDatePicker.types.d.ts +7 -7
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +7 -7
- package/MobileTimePicker/MobileTimePicker.d.ts +2 -2
- package/MobileTimePicker/MobileTimePicker.js +11 -6
- package/MobileTimePicker/MobileTimePicker.types.d.ts +7 -7
- package/MonthCalendar/MonthCalendar.d.ts +3 -4
- package/MonthCalendar/MonthCalendar.js +18 -14
- package/MonthCalendar/MonthCalendar.types.d.ts +14 -15
- package/MonthCalendar/PickersMonth.js +17 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.d.ts +1 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +3 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +9 -9
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +2 -3
- package/PickersActionBar/PickersActionBar.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.d.ts +1 -2
- package/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +9 -9
- package/PickersDay/PickersDay.d.ts +8 -8
- package/PickersLayout/PickersLayout.d.ts +2 -3
- package/PickersLayout/PickersLayout.js +0 -2
- package/PickersLayout/PickersLayout.types.d.ts +16 -19
- package/PickersLayout/index.d.ts +1 -1
- package/PickersLayout/usePickerLayout.d.ts +1 -2
- package/PickersLayout/usePickerLayout.js +18 -23
- package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/PickersTextField/PickersTextField.js +2 -2
- package/README.md +4 -4
- package/StaticDatePicker/StaticDatePicker.d.ts +1 -2
- package/StaticDatePicker/StaticDatePicker.js +14 -13
- package/StaticDatePicker/StaticDatePicker.types.d.ts +7 -7
- package/StaticDateTimePicker/StaticDateTimePicker.d.ts +1 -2
- package/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +7 -7
- package/StaticTimePicker/StaticTimePicker.d.ts +1 -2
- package/StaticTimePicker/StaticTimePicker.js +8 -3
- package/StaticTimePicker/StaticTimePicker.types.d.ts +7 -7
- package/TimeClock/Clock.d.ts +4 -5
- package/TimeClock/Clock.js +4 -3
- package/TimeClock/ClockNumbers.d.ts +5 -5
- package/TimeClock/TimeClock.d.ts +1 -2
- package/TimeClock/TimeClock.js +8 -6
- package/TimeClock/TimeClock.types.d.ts +4 -4
- package/TimeField/TimeField.d.ts +1 -2
- package/TimeField/TimeField.js +6 -6
- package/TimeField/TimeField.types.d.ts +9 -14
- package/TimeField/index.d.ts +1 -1
- package/TimeField/useTimeField.d.ts +1 -2
- package/TimePicker/TimePicker.d.ts +1 -2
- package/TimePicker/TimePicker.js +9 -4
- package/TimePicker/TimePicker.types.d.ts +10 -13
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.js +8 -7
- package/TimePicker/shared.d.ts +10 -10
- package/YearCalendar/PickersYear.js +17 -13
- package/YearCalendar/YearCalendar.d.ts +1 -2
- package/YearCalendar/YearCalendar.js +18 -14
- package/YearCalendar/YearCalendar.types.d.ts +14 -15
- package/dateViewRenderers/dateViewRenderers.d.ts +3 -3
- package/hooks/index.d.ts +2 -2
- package/hooks/index.js +2 -2
- package/hooks/useClearableField.js +4 -3
- package/hooks/useParsedFormat.d.ts +2 -3
- package/hooks/useParsedFormat.js +2 -2
- package/hooks/usePickerContext.d.ts +4 -0
- package/hooks/usePickerContext.js +15 -0
- package/hooks/usePickerTranslations.d.ts +1 -0
- package/{modern/hooks/usePickersTranslations.js → hooks/usePickerTranslations.js} +1 -1
- package/hooks/useSplitFieldProps.d.ts +3 -3
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +67 -0
- package/internals/components/PickerProvider.js +40 -0
- package/internals/hooks/date-helpers-hooks.d.ts +6 -6
- package/internals/hooks/defaultizedFieldProps.d.ts +7 -8
- package/internals/hooks/useClockReferenceDate.d.ts +5 -5
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +15 -15
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +5 -5
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.js +1 -1
- package/internals/hooks/useField/useField.types.d.ts +40 -50
- package/internals/hooks/useField/useField.utils.d.ts +15 -15
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +4 -4
- package/internals/hooks/useField/useFieldState.d.ts +4 -4
- package/internals/hooks/useField/useFieldState.js +4 -3
- package/internals/hooks/useField/useFieldV7TextField.js +4 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +12 -12
- package/internals/hooks/usePicker/usePicker.d.ts +2 -2
- package/internals/hooks/usePicker/usePicker.js +15 -10
- package/internals/hooks/usePicker/usePicker.types.d.ts +9 -7
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +6 -8
- package/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/internals/hooks/usePicker/usePickerProvider.d.ts +26 -0
- package/internals/hooks/usePicker/usePickerProvider.js +77 -0
- package/internals/hooks/usePicker/usePickerValue.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerValue.js +7 -10
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -39
- package/internals/hooks/usePicker/usePickerViews.d.ts +7 -11
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/internals/hooks/usePickerPrivateContext.d.ts +4 -0
- package/internals/hooks/usePickerPrivateContext.js +9 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +6 -6
- package/internals/hooks/useUtils.d.ts +7 -7
- package/internals/hooks/useValueWithTimezone.d.ts +19 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/hooks/useViews.d.ts +3 -3
- package/internals/hooks/useViews.js +1 -1
- package/internals/index.d.ts +7 -5
- package/internals/index.js +2 -1
- package/internals/models/common.d.ts +2 -1
- package/internals/models/fields.d.ts +32 -7
- package/internals/models/formProps.d.ts +14 -0
- package/internals/models/helpers.d.ts +0 -4
- package/internals/models/index.d.ts +2 -0
- package/internals/models/index.js +3 -1
- package/internals/models/props/basePickerProps.d.ts +5 -6
- package/internals/models/props/{clock.d.ts → time.d.ts} +10 -17
- package/internals/models/props/toolbar.d.ts +0 -2
- package/internals/models/validation.d.ts +21 -25
- package/internals/models/value.d.ts +3 -0
- package/internals/models/value.js +1 -0
- package/internals/utils/date-time-utils.d.ts +7 -7
- package/internals/utils/date-utils.d.ts +17 -17
- package/internals/utils/getDefaultReferenceDate.d.ts +10 -10
- package/internals/utils/time-utils.d.ts +5 -5
- package/internals/utils/valueManagers.d.ts +3 -3
- package/locales/beBY.d.ts +3 -3
- package/locales/beBY.js +3 -3
- package/locales/bgBG.d.ts +3 -3
- package/locales/bgBG.js +3 -3
- package/locales/caES.d.ts +3 -3
- package/locales/caES.js +3 -3
- package/locales/csCZ.d.ts +3 -3
- package/locales/csCZ.js +3 -3
- package/locales/daDK.d.ts +3 -3
- package/locales/daDK.js +3 -3
- package/locales/deDE.d.ts +3 -3
- package/locales/deDE.js +3 -3
- package/locales/elGR.d.ts +3 -3
- package/locales/elGR.js +12 -13
- package/locales/enUS.d.ts +4 -4
- package/locales/enUS.js +3 -3
- package/locales/esES.d.ts +3 -3
- package/locales/esES.js +3 -3
- package/locales/eu.d.ts +3 -3
- package/locales/eu.js +3 -3
- package/locales/faIR.d.ts +3 -3
- package/locales/faIR.js +3 -3
- package/locales/fiFI.d.ts +3 -3
- package/locales/fiFI.js +3 -3
- package/locales/frFR.d.ts +3 -3
- package/locales/frFR.js +3 -3
- package/locales/heIL.d.ts +3 -3
- package/locales/heIL.js +3 -3
- package/locales/hrHR.d.ts +3 -3
- package/locales/hrHR.js +3 -3
- package/locales/huHU.d.ts +3 -3
- package/locales/huHU.js +3 -3
- package/locales/isIS.d.ts +3 -3
- package/locales/isIS.js +3 -3
- package/locales/itIT.d.ts +3 -3
- package/locales/itIT.js +3 -3
- package/locales/jaJP.d.ts +3 -3
- package/locales/jaJP.js +3 -3
- package/locales/koKR.d.ts +3 -3
- package/locales/koKR.js +3 -3
- package/locales/kzKZ.d.ts +3 -3
- package/locales/kzKZ.js +3 -3
- package/locales/mk.d.ts +3 -3
- package/locales/mk.js +3 -3
- package/locales/nbNO.d.ts +3 -3
- package/locales/nbNO.js +3 -3
- package/locales/nlNL.d.ts +3 -3
- package/locales/nlNL.js +3 -3
- package/locales/nnNO.d.ts +3 -3
- package/locales/nnNO.js +3 -3
- package/locales/plPL.d.ts +3 -3
- package/locales/plPL.js +3 -3
- package/locales/ptBR.d.ts +3 -3
- package/locales/ptBR.js +5 -3
- package/locales/ptPT.d.ts +3 -3
- package/locales/ptPT.js +3 -3
- package/locales/roRO.d.ts +3 -3
- package/locales/roRO.js +3 -3
- package/locales/ruRU.d.ts +3 -3
- package/locales/ruRU.js +3 -3
- package/locales/skSK.d.ts +3 -3
- package/locales/skSK.js +3 -3
- package/locales/svSE.d.ts +3 -3
- package/locales/svSE.js +3 -3
- package/locales/trTR.d.ts +3 -3
- package/locales/trTR.js +3 -3
- package/locales/ukUA.d.ts +3 -3
- package/locales/ukUA.js +3 -3
- package/locales/urPK.d.ts +3 -3
- package/locales/urPK.js +3 -3
- package/locales/utils/getPickersLocalization.d.ts +9 -9
- package/locales/utils/getPickersLocalization.js +1 -1
- package/locales/utils/pickersLocaleTextApi.d.ts +12 -36
- package/locales/viVN.d.ts +3 -3
- package/locales/viVN.js +3 -3
- package/locales/zhCN.d.ts +3 -3
- package/locales/zhCN.js +3 -3
- package/locales/zhHK.d.ts +3 -3
- package/locales/zhHK.js +3 -3
- package/models/adapters.d.ts +151 -202
- package/models/common.d.ts +1 -0
- package/models/fields.d.ts +9 -42
- package/models/pickers.d.ts +28 -6
- package/modern/DateCalendar/DateCalendar.js +21 -22
- package/modern/DateCalendar/DayCalendar.js +13 -10
- package/modern/DateField/DateField.js +8 -10
- package/modern/DatePicker/DatePicker.js +15 -14
- package/modern/DatePicker/DatePickerToolbar.js +2 -4
- package/modern/DateTimeField/DateTimeField.js +9 -12
- package/modern/DateTimePicker/DateTimePicker.js +16 -16
- package/modern/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/modern/DateTimePicker/DateTimePickerToolbar.js +8 -7
- package/modern/DesktopDatePicker/DesktopDatePicker.js +17 -16
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
- package/modern/DesktopTimePicker/DesktopTimePicker.js +11 -6
- package/modern/DigitalClock/DigitalClock.js +8 -6
- package/modern/MobileDatePicker/MobileDatePicker.js +17 -16
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
- package/modern/MobileTimePicker/MobileTimePicker.js +11 -6
- package/modern/MonthCalendar/MonthCalendar.js +18 -14
- package/modern/MonthCalendar/PickersMonth.js +17 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
- package/modern/PickersActionBar/PickersActionBar.js +2 -2
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
- package/modern/PickersLayout/PickersLayout.js +0 -2
- package/modern/PickersLayout/usePickerLayout.js +18 -23
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/modern/PickersTextField/PickersTextField.js +2 -2
- package/modern/StaticDatePicker/StaticDatePicker.js +14 -13
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
- package/modern/StaticTimePicker/StaticTimePicker.js +8 -3
- package/modern/TimeClock/Clock.js +4 -3
- package/modern/TimeClock/TimeClock.js +8 -6
- package/modern/TimeField/TimeField.js +6 -6
- package/modern/TimePicker/TimePicker.js +9 -4
- package/modern/TimePicker/TimePickerToolbar.js +8 -7
- package/modern/YearCalendar/PickersYear.js +17 -13
- package/modern/YearCalendar/YearCalendar.js +18 -14
- package/modern/hooks/index.js +2 -2
- package/modern/hooks/useClearableField.js +4 -3
- package/modern/hooks/useParsedFormat.js +2 -2
- package/modern/hooks/usePickerContext.js +15 -0
- package/{hooks/usePickersTranslations.js → modern/hooks/usePickerTranslations.js} +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +40 -0
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
- package/modern/internals/hooks/useField/useField.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +4 -3
- package/modern/internals/hooks/useField/useFieldV7TextField.js +4 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
- package/modern/internals/hooks/usePicker/usePicker.js +15 -10
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/modern/internals/hooks/usePicker/usePickerProvider.js +77 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +7 -10
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/internals/hooks/usePickerPrivateContext.js +9 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
- package/modern/internals/hooks/useValueWithTimezone.js +13 -1
- package/modern/internals/hooks/useViews.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/internals/models/formProps.js +1 -0
- package/modern/internals/models/index.js +3 -1
- package/modern/internals/models/props/time.js +1 -0
- package/modern/internals/models/value.js +1 -0
- package/modern/locales/beBY.js +3 -3
- package/modern/locales/bgBG.js +3 -3
- package/modern/locales/caES.js +3 -3
- package/modern/locales/csCZ.js +3 -3
- package/modern/locales/daDK.js +3 -3
- package/modern/locales/deDE.js +3 -3
- package/modern/locales/elGR.js +12 -13
- package/modern/locales/enUS.js +3 -3
- package/modern/locales/esES.js +3 -3
- package/modern/locales/eu.js +3 -3
- package/modern/locales/faIR.js +3 -3
- package/modern/locales/fiFI.js +3 -3
- package/modern/locales/frFR.js +3 -3
- package/modern/locales/heIL.js +3 -3
- package/modern/locales/hrHR.js +3 -3
- package/modern/locales/huHU.js +3 -3
- package/modern/locales/isIS.js +3 -3
- package/modern/locales/itIT.js +3 -3
- package/modern/locales/jaJP.js +3 -3
- package/modern/locales/koKR.js +3 -3
- package/modern/locales/kzKZ.js +3 -3
- package/modern/locales/mk.js +3 -3
- package/modern/locales/nbNO.js +3 -3
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/nnNO.js +3 -3
- package/modern/locales/plPL.js +3 -3
- package/modern/locales/ptBR.js +5 -3
- package/modern/locales/ptPT.js +3 -3
- package/modern/locales/roRO.js +3 -3
- package/modern/locales/ruRU.js +3 -3
- package/modern/locales/skSK.js +3 -3
- package/modern/locales/svSE.js +3 -3
- package/modern/locales/trTR.js +3 -3
- package/modern/locales/ukUA.js +3 -3
- package/modern/locales/urPK.js +3 -3
- package/modern/locales/utils/getPickersLocalization.js +1 -1
- package/modern/locales/viVN.js +3 -3
- package/modern/locales/zhCN.js +3 -3
- package/modern/locales/zhHK.js +3 -3
- package/modern/validation/useValidation.js +2 -3
- package/modern/validation/validateDate.js +5 -0
- package/modern/validation/validateDateTime.js +5 -0
- package/modern/validation/validateTime.js +5 -0
- package/node/DateCalendar/DateCalendar.js +21 -22
- package/node/DateCalendar/DayCalendar.js +13 -10
- package/node/DateField/DateField.js +8 -10
- package/node/DatePicker/DatePicker.js +15 -14
- package/node/DatePicker/DatePickerToolbar.js +2 -4
- package/node/DateTimeField/DateTimeField.js +9 -12
- package/node/DateTimePicker/DateTimePicker.js +16 -16
- package/node/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/node/DateTimePicker/DateTimePickerToolbar.js +8 -7
- package/node/DesktopDatePicker/DesktopDatePicker.js +17 -16
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
- package/node/DesktopTimePicker/DesktopTimePicker.js +11 -6
- package/node/DigitalClock/DigitalClock.js +8 -6
- package/node/MobileDatePicker/MobileDatePicker.js +17 -16
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
- package/node/MobileTimePicker/MobileTimePicker.js +11 -6
- package/node/MonthCalendar/MonthCalendar.js +18 -14
- package/node/MonthCalendar/PickersMonth.js +17 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
- package/node/PickersActionBar/PickersActionBar.js +2 -2
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
- package/node/PickersLayout/PickersLayout.js +0 -2
- package/node/PickersLayout/usePickerLayout.js +18 -23
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/node/PickersTextField/PickersTextField.js +2 -2
- package/node/StaticDatePicker/StaticDatePicker.js +14 -13
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
- package/node/StaticTimePicker/StaticTimePicker.js +8 -3
- package/node/TimeClock/Clock.js +4 -3
- package/node/TimeClock/TimeClock.js +8 -6
- package/node/TimeField/TimeField.js +6 -6
- package/node/TimePicker/TimePicker.js +9 -4
- package/node/TimePicker/TimePickerToolbar.js +8 -7
- package/node/YearCalendar/PickersYear.js +17 -13
- package/node/YearCalendar/YearCalendar.js +18 -14
- package/node/hooks/index.js +6 -6
- package/node/hooks/useClearableField.js +4 -3
- package/node/hooks/useParsedFormat.js +2 -2
- package/node/hooks/usePickerContext.js +21 -0
- package/node/hooks/usePickerTranslations.js +10 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +48 -0
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
- package/node/internals/hooks/useField/useField.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +4 -3
- package/node/internals/hooks/useField/useFieldV7TextField.js +4 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
- package/node/internals/hooks/usePicker/usePicker.js +15 -10
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
- package/node/internals/hooks/usePicker/usePickerProvider.js +87 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +6 -10
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/internals/hooks/usePickerPrivateContext.js +15 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- package/node/internals/hooks/useViews.js +3 -3
- package/node/internals/index.js +14 -7
- package/node/internals/models/index.js +22 -0
- package/node/internals/models/props/time.js +5 -0
- package/node/internals/models/value.js +5 -0
- package/node/locales/beBY.js +3 -3
- package/node/locales/bgBG.js +3 -3
- package/node/locales/caES.js +3 -3
- package/node/locales/csCZ.js +3 -3
- package/node/locales/daDK.js +3 -3
- package/node/locales/deDE.js +3 -3
- package/node/locales/elGR.js +12 -13
- package/node/locales/enUS.js +3 -3
- package/node/locales/esES.js +3 -3
- package/node/locales/eu.js +3 -3
- package/node/locales/faIR.js +3 -3
- package/node/locales/fiFI.js +3 -3
- package/node/locales/frFR.js +3 -3
- package/node/locales/heIL.js +3 -3
- package/node/locales/hrHR.js +3 -3
- package/node/locales/huHU.js +3 -3
- package/node/locales/isIS.js +3 -3
- package/node/locales/itIT.js +3 -3
- package/node/locales/jaJP.js +3 -3
- package/node/locales/koKR.js +3 -3
- package/node/locales/kzKZ.js +3 -3
- package/node/locales/mk.js +3 -3
- package/node/locales/nbNO.js +3 -3
- package/node/locales/nlNL.js +3 -3
- package/node/locales/nnNO.js +3 -3
- package/node/locales/plPL.js +3 -3
- package/node/locales/ptBR.js +5 -3
- package/node/locales/ptPT.js +3 -3
- package/node/locales/roRO.js +3 -3
- package/node/locales/ruRU.js +3 -3
- package/node/locales/skSK.js +3 -3
- package/node/locales/svSE.js +3 -3
- package/node/locales/trTR.js +3 -3
- package/node/locales/ukUA.js +3 -3
- package/node/locales/urPK.js +3 -3
- package/node/locales/utils/getPickersLocalization.js +1 -1
- package/node/locales/viVN.js +3 -3
- package/node/locales/zhCN.js +3 -3
- package/node/locales/zhHK.js +3 -3
- package/node/validation/useValidation.js +2 -3
- package/node/validation/validateDate.js +4 -0
- package/node/validation/validateDateTime.js +4 -0
- package/node/validation/validateTime.js +4 -0
- package/package.json +5 -5
- package/themeAugmentation/props.d.ts +28 -28
- package/timeViewRenderers/timeViewRenderers.d.ts +6 -6
- package/validation/extractValidationProps.d.ts +4 -4
- package/validation/useValidation.d.ts +9 -10
- package/validation/useValidation.js +2 -3
- package/validation/validateDate.d.ts +7 -2
- package/validation/validateDate.js +5 -0
- package/validation/validateDateTime.d.ts +10 -4
- package/validation/validateDateTime.js +5 -0
- package/validation/validateTime.d.ts +7 -2
- package/validation/validateTime.js +5 -0
- package/hooks/usePickersContext.d.ts +0 -4
- package/hooks/usePickersContext.js +0 -15
- package/hooks/usePickersTranslations.d.ts +0 -2
- package/internals/components/PickersProvider.d.ts +0 -34
- package/internals/components/PickersProvider.js +0 -26
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -9
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -13
- package/modern/hooks/usePickersContext.js +0 -15
- package/modern/internals/components/PickersProvider.js +0 -26
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -13
- package/node/hooks/usePickersContext.js +0 -21
- package/node/hooks/usePickersTranslations.js +0 -10
- package/node/internals/components/PickersProvider.js +0 -34
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -20
- /package/internals/models/{props/clock.js → formProps.js} +0 -0
- /package/{modern/internals/models/props/clock.js → internals/models/props/time.js} +0 -0
- /package/node/internals/models/{props/clock.js → formProps.js} +0 -0
|
@@ -2,17 +2,18 @@ import { warnOnce } from '@mui/x-internals/warning';
|
|
|
2
2
|
import { usePickerValue } from "./usePickerValue.js";
|
|
3
3
|
import { usePickerViews } from "./usePickerViews.js";
|
|
4
4
|
import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
|
|
5
|
-
import {
|
|
5
|
+
import { usePickerProvider } from "./usePickerProvider.js";
|
|
6
6
|
export const usePicker = ({
|
|
7
7
|
props,
|
|
8
8
|
valueManager,
|
|
9
9
|
valueType,
|
|
10
|
-
|
|
10
|
+
variant,
|
|
11
11
|
additionalViewProps,
|
|
12
12
|
validator,
|
|
13
13
|
autoFocusView,
|
|
14
14
|
rendererInterceptor,
|
|
15
|
-
fieldRef
|
|
15
|
+
fieldRef,
|
|
16
|
+
localeText
|
|
16
17
|
}) => {
|
|
17
18
|
if (process.env.NODE_ENV !== 'production') {
|
|
18
19
|
if (props.renderInput != null) {
|
|
@@ -23,7 +24,7 @@ export const usePicker = ({
|
|
|
23
24
|
props,
|
|
24
25
|
valueManager,
|
|
25
26
|
valueType,
|
|
26
|
-
|
|
27
|
+
variant,
|
|
27
28
|
validator
|
|
28
29
|
});
|
|
29
30
|
const pickerViewsResponse = usePickerViews({
|
|
@@ -36,13 +37,17 @@ export const usePicker = ({
|
|
|
36
37
|
});
|
|
37
38
|
const pickerLayoutResponse = usePickerLayoutProps({
|
|
38
39
|
props,
|
|
39
|
-
|
|
40
|
+
variant,
|
|
40
41
|
propsFromPickerValue: pickerValueResponse.layoutProps,
|
|
41
42
|
propsFromPickerViews: pickerViewsResponse.layoutProps
|
|
42
43
|
});
|
|
43
|
-
const
|
|
44
|
+
const providerProps = usePickerProvider({
|
|
44
45
|
props,
|
|
45
|
-
pickerValueResponse
|
|
46
|
+
pickerValueResponse,
|
|
47
|
+
localeText,
|
|
48
|
+
valueManager,
|
|
49
|
+
variant,
|
|
50
|
+
views: pickerViewsResponse.views
|
|
46
51
|
});
|
|
47
52
|
return {
|
|
48
53
|
// Picker value
|
|
@@ -55,9 +60,9 @@ export const usePicker = ({
|
|
|
55
60
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
56
61
|
// Picker layout
|
|
57
62
|
layoutProps: pickerLayoutResponse.layoutProps,
|
|
58
|
-
// Picker
|
|
59
|
-
|
|
63
|
+
// Picker provider
|
|
64
|
+
providerProps,
|
|
60
65
|
// Picker owner state
|
|
61
|
-
ownerState:
|
|
66
|
+
ownerState: providerProps.privateContextValue.ownerState
|
|
62
67
|
};
|
|
63
68
|
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { UsePickerValueParams, UsePickerValueProps, UsePickerValueBaseProps, UsePickerValueResponse } from './usePickerValue.types';
|
|
2
2
|
import { UsePickerViewsProps, UsePickerViewParams, UsePickerViewsResponse, UsePickerViewsBaseProps } from './usePickerViews';
|
|
3
|
-
import {
|
|
4
|
-
import { FieldSection, PickerOwnerState
|
|
3
|
+
import { UsePickerLayoutPropsResponse } from './usePickerLayoutProps';
|
|
4
|
+
import { FieldSection, PickerOwnerState } from '../../../models';
|
|
5
5
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
6
|
+
import { UsePickerProviderParameters, UsePickerProviderProps, UsePickerProviderReturnValue } from './usePickerProvider';
|
|
6
7
|
/**
|
|
7
8
|
* Props common to all picker headless implementations.
|
|
8
9
|
*/
|
|
9
|
-
export interface UsePickerBaseProps<TValue,
|
|
10
|
+
export interface UsePickerBaseProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueBaseProps<TValue, TError>, UsePickerViewsBaseProps<TValue, TView, TExternalProps, TAdditionalProps>, UsePickerProviderProps {
|
|
10
11
|
}
|
|
11
|
-
export interface UsePickerProps<TValue,
|
|
12
|
+
export interface UsePickerProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TView, TExternalProps, TAdditionalProps>, UsePickerProviderProps {
|
|
12
13
|
}
|
|
13
|
-
export interface UsePickerParams<TValue,
|
|
14
|
+
export interface UsePickerParams<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'variant' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TSection, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'autoFocusView' | 'rendererInterceptor' | 'fieldRef'>, Pick<UsePickerProviderParameters<TValue>, 'localeText'> {
|
|
14
15
|
props: TExternalProps;
|
|
15
16
|
}
|
|
16
|
-
export interface UsePickerResponse<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError> extends Omit<UsePickerValueResponse<TValue, TSection, TError>, 'viewProps' | 'layoutProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps'>, UsePickerLayoutPropsResponse<TValue, TView> {
|
|
17
|
-
ownerState: PickerOwnerState
|
|
17
|
+
export interface UsePickerResponse<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError> extends Omit<UsePickerValueResponse<TValue, TSection, TError>, 'viewProps' | 'layoutProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps' | 'views'>, UsePickerLayoutPropsResponse<TValue, TView> {
|
|
18
|
+
ownerState: PickerOwnerState;
|
|
19
|
+
providerProps: UsePickerProviderReturnValue;
|
|
18
20
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { UsePickerValueLayoutResponse } from './usePickerValue.types';
|
|
2
2
|
import { UsePickerViewsLayoutResponse } from './usePickerViews';
|
|
3
|
-
import { DateOrTimeViewWithMeridiem,
|
|
3
|
+
import { DateOrTimeViewWithMeridiem, PickerVariant } from '../../models/common';
|
|
4
4
|
/**
|
|
5
5
|
* Props used to create the layout of the views.
|
|
6
|
-
* Those props are exposed on all the pickers.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
readOnly?: boolean;
|
|
7
|
+
interface UsePickerLayoutProps {
|
|
11
8
|
/**
|
|
12
9
|
* Force rendering in particular orientation.
|
|
13
10
|
*/
|
|
@@ -16,7 +13,7 @@ export interface UsePickerLayoutProps {
|
|
|
16
13
|
export interface UsePickerLayoutPropsResponseLayoutProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends UsePickerValueLayoutResponse<TValue>, UsePickerViewsLayoutResponse<TView>, UsePickerLayoutProps {
|
|
17
14
|
isLandscape: boolean;
|
|
18
15
|
isRtl: boolean;
|
|
19
|
-
wrapperVariant:
|
|
16
|
+
wrapperVariant: PickerVariant;
|
|
20
17
|
isValid: (value: TValue) => boolean;
|
|
21
18
|
}
|
|
22
19
|
export interface UsePickerLayoutPropsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
@@ -26,9 +23,10 @@ export interface UsePickerLayoutPropsParams<TValue, TView extends DateOrTimeView
|
|
|
26
23
|
props: UsePickerLayoutProps;
|
|
27
24
|
propsFromPickerValue: UsePickerValueLayoutResponse<TValue>;
|
|
28
25
|
propsFromPickerViews: UsePickerViewsLayoutResponse<TView>;
|
|
29
|
-
|
|
26
|
+
variant: PickerVariant;
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
33
30
|
*/
|
|
34
|
-
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews,
|
|
31
|
+
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews, variant, }: UsePickerLayoutPropsParams<TValue, TView>) => UsePickerLayoutPropsResponse<TValue, TView>;
|
|
32
|
+
export {};
|
|
@@ -4,7 +4,6 @@ import { useIsLandscape } from "../useIsLandscape.js";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Props used to create the layout of the views.
|
|
7
|
-
* Those props are exposed on all the pickers.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -14,7 +13,7 @@ export const usePickerLayoutProps = ({
|
|
|
14
13
|
props,
|
|
15
14
|
propsFromPickerValue,
|
|
16
15
|
propsFromPickerViews,
|
|
17
|
-
|
|
16
|
+
variant
|
|
18
17
|
}) => {
|
|
19
18
|
const {
|
|
20
19
|
orientation
|
|
@@ -24,9 +23,7 @@ export const usePickerLayoutProps = ({
|
|
|
24
23
|
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
25
24
|
isLandscape,
|
|
26
25
|
isRtl,
|
|
27
|
-
wrapperVariant
|
|
28
|
-
disabled: props.disabled,
|
|
29
|
-
readOnly: props.readOnly
|
|
26
|
+
wrapperVariant: variant
|
|
30
27
|
});
|
|
31
28
|
return {
|
|
32
29
|
layoutProps
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FieldSection } from '../../../models';
|
|
2
|
+
import { PickerValueManager, UsePickerValueResponse } from './usePickerValue.types';
|
|
3
|
+
import { PickerProviderProps } from '../../components/PickerProvider';
|
|
4
|
+
import type { UsePickerProps } from './usePicker.types';
|
|
5
|
+
import { DateOrTimeViewWithMeridiem, FormProps, PickerOrientation, PickerVariant } from '../../models';
|
|
6
|
+
export declare const usePickerOrientation: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined) => PickerOrientation;
|
|
7
|
+
export declare function usePickerProvider<TValue>(parameters: UsePickerProviderParameters<TValue>): UsePickerProviderReturnValue;
|
|
8
|
+
export interface UsePickerProviderParameters<TValue> extends Pick<PickerProviderProps, 'localeText'> {
|
|
9
|
+
props: UsePickerProps<TValue, any, any, any, any>;
|
|
10
|
+
pickerValueResponse: UsePickerValueResponse<TValue, FieldSection, any>;
|
|
11
|
+
valueManager: PickerValueManager<TValue, any>;
|
|
12
|
+
variant: PickerVariant;
|
|
13
|
+
views: readonly DateOrTimeViewWithMeridiem[];
|
|
14
|
+
}
|
|
15
|
+
export interface UsePickerProviderReturnValue extends Omit<PickerProviderProps, 'children'> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props used to create the private context.
|
|
19
|
+
* Those props are exposed on all the pickers.
|
|
20
|
+
*/
|
|
21
|
+
export interface UsePickerProviderProps extends FormProps {
|
|
22
|
+
/**
|
|
23
|
+
* Force rendering in particular orientation.
|
|
24
|
+
*/
|
|
25
|
+
orientation?: PickerOrientation;
|
|
26
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
3
|
+
import { useUtils } from "../useUtils.js";
|
|
4
|
+
import { arrayIncludes } from "../../utils/utils.js";
|
|
5
|
+
function getOrientation() {
|
|
6
|
+
if (typeof window === 'undefined') {
|
|
7
|
+
return 'portrait';
|
|
8
|
+
}
|
|
9
|
+
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
|
10
|
+
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Support IOS safari
|
|
14
|
+
if (window.orientation) {
|
|
15
|
+
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
|
16
|
+
}
|
|
17
|
+
return 'portrait';
|
|
18
|
+
}
|
|
19
|
+
export const usePickerOrientation = (views, customOrientation) => {
|
|
20
|
+
const [orientation, setOrientation] = React.useState(getOrientation);
|
|
21
|
+
useEnhancedEffect(() => {
|
|
22
|
+
const eventHandler = () => {
|
|
23
|
+
setOrientation(getOrientation());
|
|
24
|
+
};
|
|
25
|
+
window.addEventListener('orientationchange', eventHandler);
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener('orientationchange', eventHandler);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
|
|
31
|
+
// could not display 13:34:44 in landscape mode
|
|
32
|
+
return 'portrait';
|
|
33
|
+
}
|
|
34
|
+
return customOrientation ?? orientation;
|
|
35
|
+
};
|
|
36
|
+
export function usePickerProvider(parameters) {
|
|
37
|
+
const {
|
|
38
|
+
props,
|
|
39
|
+
pickerValueResponse,
|
|
40
|
+
valueManager,
|
|
41
|
+
localeText,
|
|
42
|
+
variant,
|
|
43
|
+
views
|
|
44
|
+
} = parameters;
|
|
45
|
+
const utils = useUtils();
|
|
46
|
+
const orientation = usePickerOrientation(views, props.orientation);
|
|
47
|
+
const ownerState = React.useMemo(() => ({
|
|
48
|
+
isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
|
|
49
|
+
isPickerOpen: pickerValueResponse.open,
|
|
50
|
+
isPickerDisabled: props.disabled ?? false,
|
|
51
|
+
isPickerReadOnly: props.readOnly ?? false,
|
|
52
|
+
pickerOrientation: orientation,
|
|
53
|
+
pickerVariant: variant
|
|
54
|
+
}), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, orientation, variant, props.disabled, props.readOnly]);
|
|
55
|
+
const contextValue = React.useMemo(() => ({
|
|
56
|
+
onOpen: pickerValueResponse.actions.onOpen,
|
|
57
|
+
onClose: pickerValueResponse.actions.onClose,
|
|
58
|
+
open: pickerValueResponse.open,
|
|
59
|
+
disabled: props.disabled ?? false,
|
|
60
|
+
readOnly: props.readOnly ?? false,
|
|
61
|
+
variant,
|
|
62
|
+
orientation
|
|
63
|
+
}), [pickerValueResponse.actions.onOpen, pickerValueResponse.actions.onClose, pickerValueResponse.open, variant, orientation, props.disabled, props.readOnly]);
|
|
64
|
+
const privateContextValue = React.useMemo(() => ({
|
|
65
|
+
ownerState
|
|
66
|
+
}), [ownerState]);
|
|
67
|
+
return {
|
|
68
|
+
localeText,
|
|
69
|
+
contextValue,
|
|
70
|
+
privateContextValue
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Props used to create the private context.
|
|
76
|
+
* Those props are exposed on all the pickers.
|
|
77
|
+
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldSection,
|
|
1
|
+
import { FieldSection, InferError } from '../../../models';
|
|
2
2
|
import { UsePickerValueProps, UsePickerValueParams, UsePickerValueResponse } from './usePickerValue.types';
|
|
3
3
|
/**
|
|
4
4
|
* Manage the value lifecycle of all the pickers.
|
|
5
5
|
*/
|
|
6
|
-
export declare const usePickerValue: <TValue,
|
|
6
|
+
export declare const usePickerValue: <TValue, TSection extends FieldSection, TExternalProps extends UsePickerValueProps<TValue, any>>({ props, valueManager, valueType, variant, validator, }: UsePickerValueParams<TValue, TExternalProps>) => UsePickerValueResponse<TValue, TSection, InferError<TExternalProps>>;
|
|
@@ -5,6 +5,7 @@ import { useOpenState } from "../useOpenState.js";
|
|
|
5
5
|
import { useLocalizationContext, useUtils } from "../useUtils.js";
|
|
6
6
|
import { useValidation } from "../../../validation/index.js";
|
|
7
7
|
import { useValueWithTimezone } from "../useValueWithTimezone.js";
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* Decide if the new value should be published
|
|
10
11
|
* The published value will be passed to `onChange` if defined.
|
|
@@ -112,7 +113,7 @@ export const usePickerValue = ({
|
|
|
112
113
|
props,
|
|
113
114
|
valueManager,
|
|
114
115
|
valueType,
|
|
115
|
-
|
|
116
|
+
variant,
|
|
116
117
|
validator
|
|
117
118
|
}) => {
|
|
118
119
|
const {
|
|
@@ -120,8 +121,9 @@ export const usePickerValue = ({
|
|
|
120
121
|
onChange,
|
|
121
122
|
value: inValueWithoutRenderTimezone,
|
|
122
123
|
defaultValue: inDefaultValue,
|
|
123
|
-
closeOnSelect =
|
|
124
|
-
timezone: timezoneProp
|
|
124
|
+
closeOnSelect = variant === 'desktop',
|
|
125
|
+
timezone: timezoneProp,
|
|
126
|
+
referenceDate
|
|
125
127
|
} = props;
|
|
126
128
|
const {
|
|
127
129
|
current: defaultValue
|
|
@@ -160,6 +162,7 @@ export const usePickerValue = ({
|
|
|
160
162
|
timezone: timezoneProp,
|
|
161
163
|
value: inValueWithoutRenderTimezone,
|
|
162
164
|
defaultValue,
|
|
165
|
+
referenceDate,
|
|
163
166
|
onChange,
|
|
164
167
|
valueManager
|
|
165
168
|
});
|
|
@@ -343,17 +346,11 @@ export const usePickerValue = ({
|
|
|
343
346
|
onSelectShortcut: handleSelectShortcut,
|
|
344
347
|
isValid
|
|
345
348
|
});
|
|
346
|
-
const contextValue = React.useMemo(() => ({
|
|
347
|
-
onOpen: handleOpen,
|
|
348
|
-
onClose: handleClose,
|
|
349
|
-
open: isOpen
|
|
350
|
-
}), [isOpen, handleClose, handleOpen]);
|
|
351
349
|
return {
|
|
352
350
|
open: isOpen,
|
|
353
351
|
fieldProps: fieldResponse,
|
|
354
352
|
viewProps: viewResponse,
|
|
355
353
|
layoutProps: layoutResponse,
|
|
356
|
-
actions
|
|
357
|
-
contextValue
|
|
354
|
+
actions
|
|
358
355
|
};
|
|
359
356
|
};
|
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
import { FieldChangeHandlerContext, UseFieldInternalProps } from '../useField';
|
|
2
2
|
import { Validator } from '../../../validation';
|
|
3
|
-
import {
|
|
4
|
-
import { FieldSection,
|
|
3
|
+
import { PickerVariant } from '../../models/common';
|
|
4
|
+
import { FieldSection, TimezoneProps, MuiPickersAdapter, PickersTimezone, PickerChangeHandlerContext, PickerValidDate, OnErrorProps, InferError, PickerValueType } from '../../../models';
|
|
5
5
|
import { GetDefaultReferenceDateProps } from '../../utils/getDefaultReferenceDate';
|
|
6
6
|
import { PickerShortcutChangeImportance, PickersShortcutsItemContext } from '../../../PickersShortcuts';
|
|
7
|
-
|
|
8
|
-
export interface PickerValueManager<TValue, TDate extends PickerValidDate, TError> {
|
|
7
|
+
export interface PickerValueManager<TValue, TError> {
|
|
9
8
|
/**
|
|
10
9
|
* Determines if two values are equal.
|
|
11
|
-
* @template
|
|
12
|
-
* @param {MuiPickersAdapter
|
|
10
|
+
* @template TValue
|
|
11
|
+
* @param {MuiPickersAdapter} utils The adapter.
|
|
13
12
|
* @param {TValue} valueLeft The first value to compare.
|
|
14
13
|
* @param {TValue} valueRight The second value to compare.
|
|
15
14
|
* @returns {boolean} A boolean indicating if the two values are equal.
|
|
16
15
|
*/
|
|
17
|
-
areValuesEqual: (utils: MuiPickersAdapter
|
|
16
|
+
areValuesEqual: (utils: MuiPickersAdapter, valueLeft: TValue, valueRight: TValue) => boolean;
|
|
18
17
|
/**
|
|
19
18
|
* Value to set when clicking the "Clear" button.
|
|
20
19
|
*/
|
|
21
20
|
emptyValue: TValue;
|
|
22
21
|
/**
|
|
23
22
|
* Method returning the value to set when clicking the "Today" button
|
|
24
|
-
* @template
|
|
25
|
-
* @param {MuiPickersAdapter
|
|
23
|
+
* @template TValue
|
|
24
|
+
* @param {MuiPickersAdapter} utils The adapter.
|
|
26
25
|
* @param {PickersTimezone} timezone The current timezone.
|
|
27
|
-
* @param {
|
|
26
|
+
* @param {PickerValueType} valueType The type of the value being edited.
|
|
28
27
|
* @returns {TValue} The value to set when clicking the "Today" button.
|
|
29
28
|
*/
|
|
30
|
-
getTodayValue: (utils: MuiPickersAdapter
|
|
29
|
+
getTodayValue: (utils: MuiPickersAdapter, timezone: PickersTimezone, valueType: PickerValueType) => TValue;
|
|
31
30
|
/**
|
|
32
|
-
* @template
|
|
31
|
+
* @template TValue
|
|
33
32
|
* Method returning the reference value to use when mounting the component.
|
|
34
33
|
* @param {object} params The params of the method.
|
|
35
|
-
* @param {
|
|
34
|
+
* @param {PickerValidDate | undefined} params.referenceDate The referenceDate provided by the user.
|
|
36
35
|
* @param {TValue} params.value The value provided by the user.
|
|
37
|
-
* @param {GetDefaultReferenceDateProps
|
|
38
|
-
* @param {MuiPickersAdapter
|
|
36
|
+
* @param {GetDefaultReferenceDateProps} params.props The validation props needed to compute the reference value.
|
|
37
|
+
* @param {MuiPickersAdapter} params.utils The adapter.
|
|
39
38
|
* @param {number} params.granularity The granularity of the selection possible on this component.
|
|
40
39
|
* @param {PickersTimezone} params.timezone The current timezone.
|
|
41
|
-
* @param {() =>
|
|
40
|
+
* @param {() => PickerValidDate} params.getTodayDate The reference date to use if no reference date is passed to the component.
|
|
42
41
|
* @returns {TValue} The reference value to use for non-provided dates.
|
|
43
42
|
*/
|
|
44
43
|
getInitialReferenceValue: (params: {
|
|
45
|
-
referenceDate:
|
|
44
|
+
referenceDate: PickerValidDate | undefined;
|
|
46
45
|
value: TValue;
|
|
47
|
-
props: GetDefaultReferenceDateProps
|
|
48
|
-
utils: MuiPickersAdapter
|
|
46
|
+
props: GetDefaultReferenceDateProps;
|
|
47
|
+
utils: MuiPickersAdapter;
|
|
49
48
|
granularity: number;
|
|
50
49
|
timezone: PickersTimezone;
|
|
51
|
-
getTodayDate?: () =>
|
|
50
|
+
getTodayDate?: () => PickerValidDate;
|
|
52
51
|
}) => TValue;
|
|
53
52
|
/**
|
|
54
53
|
* Method parsing the input value to replace all invalid dates by `null`.
|
|
55
|
-
* @template
|
|
56
|
-
* @param {MuiPickersAdapter
|
|
54
|
+
* @template TValue
|
|
55
|
+
* @param {MuiPickersAdapter} utils The adapter.
|
|
57
56
|
* @param {TValue} value The value to parse.
|
|
58
57
|
* @returns {TValue} The value without invalid date.
|
|
59
58
|
*/
|
|
60
|
-
cleanValue: (utils: MuiPickersAdapter
|
|
59
|
+
cleanValue: (utils: MuiPickersAdapter, value: TValue) => TValue;
|
|
61
60
|
/**
|
|
62
61
|
* Generates the new value, given the previous value and the new proposed value.
|
|
63
|
-
* @template
|
|
64
|
-
* @param {MuiPickersAdapter
|
|
62
|
+
* @template TValue
|
|
63
|
+
* @param {MuiPickersAdapter} utils The adapter.
|
|
65
64
|
* @param {TValue} lastValidDateValue The last valid value.
|
|
66
65
|
* @param {TValue} value The proposed value.
|
|
67
66
|
* @returns {TValue} The new value.
|
|
68
67
|
*/
|
|
69
|
-
valueReducer?: (utils: MuiPickersAdapter
|
|
68
|
+
valueReducer?: (utils: MuiPickersAdapter, lastValidDateValue: TValue, value: TValue) => TValue;
|
|
70
69
|
/**
|
|
71
70
|
* Compare two errors to know if they are equal.
|
|
72
71
|
* @template TError
|
|
@@ -89,21 +88,21 @@ export interface PickerValueManager<TValue, TDate extends PickerValidDate, TErro
|
|
|
89
88
|
/**
|
|
90
89
|
* Return the timezone of the date inside a value.
|
|
91
90
|
* Throw an error on range picker if both values don't have the same timezone.
|
|
92
|
-
@template TValue
|
|
93
|
-
@param {MuiPickersAdapter
|
|
91
|
+
@template TValue
|
|
92
|
+
@param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
94
93
|
@param {TValue} value The current value.
|
|
95
94
|
@returns {string | null} The timezone of the current value.
|
|
96
95
|
*/
|
|
97
|
-
getTimezone: (utils: MuiPickersAdapter
|
|
96
|
+
getTimezone: (utils: MuiPickersAdapter, value: TValue) => string | null;
|
|
98
97
|
/**
|
|
99
98
|
* Change the timezone of the dates inside a value.
|
|
100
|
-
@template TValue
|
|
101
|
-
@param {MuiPickersAdapter
|
|
99
|
+
@template TValue
|
|
100
|
+
@param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
102
101
|
@param {PickersTimezone} timezone The current timezone.
|
|
103
102
|
@param {TValue} value The value to convert.
|
|
104
103
|
@returns {TValue} The value with the new dates in the new timezone.
|
|
105
104
|
*/
|
|
106
|
-
setTimezone: (utils: MuiPickersAdapter
|
|
105
|
+
setTimezone: (utils: MuiPickersAdapter, timezone: PickersTimezone, value: TValue) => TValue;
|
|
107
106
|
}
|
|
108
107
|
export type PickerSelectionState = 'partial' | 'shallow' | 'finish';
|
|
109
108
|
export interface UsePickerValueState<TValue> {
|
|
@@ -227,13 +226,14 @@ export interface UsePickerValueNonStaticProps {
|
|
|
227
226
|
* Props used to handle the value of the pickers.
|
|
228
227
|
*/
|
|
229
228
|
export interface UsePickerValueProps<TValue, TError> extends UsePickerValueBaseProps<TValue, TError>, UsePickerValueNonStaticProps, TimezoneProps {
|
|
229
|
+
referenceDate?: PickerValidDate;
|
|
230
230
|
}
|
|
231
|
-
export interface UsePickerValueParams<TValue,
|
|
231
|
+
export interface UsePickerValueParams<TValue, TExternalProps extends UsePickerValueProps<TValue, any>> {
|
|
232
232
|
props: TExternalProps;
|
|
233
|
-
valueManager: PickerValueManager<TValue,
|
|
234
|
-
valueType:
|
|
235
|
-
|
|
236
|
-
validator: Validator<TValue,
|
|
233
|
+
valueManager: PickerValueManager<TValue, InferError<TExternalProps>>;
|
|
234
|
+
valueType: PickerValueType;
|
|
235
|
+
variant: PickerVariant;
|
|
236
|
+
validator: Validator<TValue, InferError<TExternalProps>, TExternalProps>;
|
|
237
237
|
}
|
|
238
238
|
export interface UsePickerValueActions {
|
|
239
239
|
onAccept: () => void;
|
|
@@ -244,7 +244,7 @@ export interface UsePickerValueActions {
|
|
|
244
244
|
onOpen: (event: React.UIEvent) => void;
|
|
245
245
|
onClose: (event?: React.UIEvent) => void;
|
|
246
246
|
}
|
|
247
|
-
export type UsePickerValueFieldResponse<TValue, TSection extends FieldSection, TError> = Required<Pick<UseFieldInternalProps<TValue,
|
|
247
|
+
export type UsePickerValueFieldResponse<TValue, TSection extends FieldSection, TError> = Required<Pick<UseFieldInternalProps<TValue, TSection, any, TError>, 'value' | 'onChange'>>;
|
|
248
248
|
/**
|
|
249
249
|
* Props passed to `usePickerViews`.
|
|
250
250
|
*/
|
|
@@ -269,5 +269,4 @@ export interface UsePickerValueResponse<TValue, TSection extends FieldSection, T
|
|
|
269
269
|
viewProps: UsePickerValueViewsResponse<TValue>;
|
|
270
270
|
fieldProps: UsePickerValueFieldResponse<TValue, TSection, TError>;
|
|
271
271
|
layoutProps: UsePickerValueLayoutResponse<TValue>;
|
|
272
|
-
contextValue: PickersContextValue;
|
|
273
272
|
}
|
|
@@ -5,7 +5,7 @@ import { UseViewsOptions } from '../useViews';
|
|
|
5
5
|
import type { UsePickerValueViewsResponse } from './usePickerValue.types';
|
|
6
6
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
7
7
|
import { FieldRef, FieldSection, PickerValidDate, TimezoneProps } from '../../../models';
|
|
8
|
-
interface PickerViewsRendererBaseExternalProps<TView extends DateOrTimeViewWithMeridiem> extends Omit<UsePickerViewsProps<any,
|
|
8
|
+
interface PickerViewsRendererBaseExternalProps<TView extends DateOrTimeViewWithMeridiem> extends Omit<UsePickerViewsProps<any, TView, any, any>, 'openTo' | 'viewRenderers'> {
|
|
9
9
|
}
|
|
10
10
|
export type PickerViewsRendererProps<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends PickerViewsRendererBaseExternalProps<TView>, TAdditionalProps extends {}> = Omit<TExternalProps, 'className' | 'sx'> & TAdditionalProps & UsePickerValueViewsResponse<TValue> & {
|
|
11
11
|
view: TView;
|
|
@@ -22,12 +22,7 @@ export type PickerViewRendererLookup<TValue, TView extends DateOrTimeViewWithMer
|
|
|
22
22
|
/**
|
|
23
23
|
* Props used to handle the views that are common to all pickers.
|
|
24
24
|
*/
|
|
25
|
-
export interface UsePickerViewsBaseProps<TValue,
|
|
26
|
-
/**
|
|
27
|
-
* If `true`, the picker and text field are disabled.
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
disabled?: boolean;
|
|
25
|
+
export interface UsePickerViewsBaseProps<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends Omit<UseViewsOptions<any, TView>, 'onChange' | 'onFocusedViewChange' | 'focusedView'>, TimezoneProps {
|
|
31
26
|
/**
|
|
32
27
|
* If `null`, the section will only have field editing.
|
|
33
28
|
* If `undefined`, internally defined view will be used.
|
|
@@ -42,7 +37,7 @@ export interface UsePickerViewsBaseProps<TValue, TDate extends PickerValidDate,
|
|
|
42
37
|
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
43
38
|
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
44
39
|
*/
|
|
45
|
-
referenceDate?:
|
|
40
|
+
referenceDate?: PickerValidDate;
|
|
46
41
|
}
|
|
47
42
|
/**
|
|
48
43
|
* Props used to handle the views of the pickers.
|
|
@@ -57,11 +52,11 @@ export interface UsePickerViewsNonStaticProps {
|
|
|
57
52
|
/**
|
|
58
53
|
* Props used to handle the value of the pickers.
|
|
59
54
|
*/
|
|
60
|
-
export interface UsePickerViewsProps<TValue,
|
|
55
|
+
export interface UsePickerViewsProps<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerViewsBaseProps<TValue, TView, TExternalProps, TAdditionalProps> {
|
|
61
56
|
className?: string;
|
|
62
57
|
sx?: SxProps<Theme>;
|
|
63
58
|
}
|
|
64
|
-
export interface UsePickerViewParams<TValue,
|
|
59
|
+
export interface UsePickerViewParams<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerViewsProps<TValue, TView, TExternalProps, TAdditionalProps>, TAdditionalProps extends {}> {
|
|
65
60
|
props: TExternalProps;
|
|
66
61
|
propsFromPickerValue: UsePickerValueViewsResponse<TValue>;
|
|
67
62
|
additionalViewProps: TAdditionalProps;
|
|
@@ -82,6 +77,7 @@ export interface UsePickerViewsResponse<TView extends DateOrTimeViewWithMeridiem
|
|
|
82
77
|
* Indicates if the the picker has at least one view that should be rendered in UI.
|
|
83
78
|
*/
|
|
84
79
|
hasUIView: boolean;
|
|
80
|
+
views: readonly TView[];
|
|
85
81
|
renderCurrentView: () => React.ReactNode;
|
|
86
82
|
shouldRestoreFocus: () => boolean;
|
|
87
83
|
layoutProps: UsePickerViewsLayoutResponse<TView>;
|
|
@@ -97,5 +93,5 @@ export interface UsePickerViewsLayoutResponse<TView extends DateOrTimeViewWithMe
|
|
|
97
93
|
* - Handles the switch between UI views and field views
|
|
98
94
|
* - Handles the focus management when switching views
|
|
99
95
|
*/
|
|
100
|
-
export declare const usePickerViews: <TValue,
|
|
96
|
+
export declare const usePickerViews: <TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}>({ props, propsFromPickerValue, additionalViewProps, autoFocusView, rendererInterceptor, fieldRef, }: UsePickerViewParams<TValue, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerViewsResponse<TView>;
|
|
101
97
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PickerPrivateContext } from "../components/PickerProvider.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the private context passed by the picker that wraps the current component.
|
|
8
|
+
*/
|
|
9
|
+
export const usePickerPrivateContext = () => React.useContext(PickerPrivateContext);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { UseStaticPickerParams, UseStaticPickerProps } from './useStaticPicker.types';
|
|
3
|
-
import { PickerValidDate } from '../../../models';
|
|
4
3
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
5
4
|
/**
|
|
6
5
|
* Hook managing all the single-date static pickers:
|
|
@@ -8,6 +7,6 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
|
8
7
|
* - StaticDateTimePicker
|
|
9
8
|
* - StaticTimePicker
|
|
10
9
|
*/
|
|
11
|
-
export declare const useStaticPicker: <
|
|
10
|
+
export declare const useStaticPicker: <TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticPickerProps<TView, any, TExternalProps>>({ props, ref, ...pickerParams }: UseStaticPickerParams<TView, TExternalProps>) => {
|
|
12
11
|
renderPicker: () => React.JSX.Element;
|
|
13
12
|
};
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
7
|
import { usePicker } from "../usePicker/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { PickerProvider } from "../../components/PickerProvider.js";
|
|
9
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
10
10
|
import { DIALOG_WIDTH } from "../../constants/dimensions.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -40,17 +40,18 @@ export const useStaticPicker = _ref => {
|
|
|
40
40
|
} = props;
|
|
41
41
|
const {
|
|
42
42
|
layoutProps,
|
|
43
|
+
providerProps,
|
|
43
44
|
renderCurrentView
|
|
44
45
|
} = usePicker(_extends({}, pickerParams, {
|
|
45
46
|
props,
|
|
46
47
|
autoFocusView: autoFocus ?? false,
|
|
47
48
|
fieldRef: undefined,
|
|
49
|
+
localeText,
|
|
48
50
|
additionalViewProps: {},
|
|
49
|
-
|
|
51
|
+
variant: displayStaticWrapperAs
|
|
50
52
|
}));
|
|
51
53
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
52
|
-
const renderPicker = () => /*#__PURE__*/_jsx(
|
|
53
|
-
localeText: localeText,
|
|
54
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
54
55
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
55
56
|
slots: slots,
|
|
56
57
|
slotProps: slotProps,
|
|
@@ -59,7 +60,7 @@ export const useStaticPicker = _ref => {
|
|
|
59
60
|
ref: ref,
|
|
60
61
|
children: renderCurrentView()
|
|
61
62
|
}))
|
|
62
|
-
});
|
|
63
|
+
}));
|
|
63
64
|
return {
|
|
64
65
|
renderPicker
|
|
65
66
|
};
|