@mui/x-date-pickers 8.0.0-beta.1 → 8.0.0-beta.3
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/CHANGELOG.md +235 -0
- package/DateCalendar/DateCalendar.js +4 -8
- package/DateCalendar/DayCalendar.js +2 -2
- package/DateField/DateField.js +4 -4
- package/DatePicker/shared.js +3 -9
- package/DateTimeField/DateTimeField.js +4 -4
- package/DateTimePicker/shared.js +3 -13
- package/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/DesktopTimePicker/DesktopTimePicker.js +2 -1
- package/DigitalClock/DigitalClock.js +1 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/LocalizationProvider/LocalizationProvider.js +2 -2
- package/MobileDatePicker/MobileDatePicker.js +2 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/MobileTimePicker/MobileTimePicker.js +2 -1
- package/MonthCalendar/MonthCalendar.js +4 -9
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -0
- package/PickersActionBar/PickersActionBar.d.ts +1 -1
- package/PickersActionBar/PickersActionBar.js +21 -3
- package/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/StaticDatePicker/StaticDatePicker.js +2 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/StaticTimePicker/StaticTimePicker.js +2 -1
- package/TimeField/TimeField.js +4 -4
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +4 -10
- package/esm/DateCalendar/DateCalendar.js +6 -10
- package/esm/DateCalendar/DayCalendar.js +2 -2
- package/esm/DateField/DateField.js +4 -4
- package/esm/DatePicker/shared.js +3 -9
- package/esm/DateTimeField/DateTimeField.js +4 -4
- package/esm/DateTimePicker/shared.js +4 -14
- package/esm/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/esm/DesktopTimePicker/DesktopTimePicker.js +2 -1
- package/esm/DigitalClock/DigitalClock.js +1 -0
- package/esm/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/esm/LocalizationProvider/LocalizationProvider.js +2 -2
- package/esm/MobileDatePicker/MobileDatePicker.js +2 -1
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/esm/MobileTimePicker/MobileTimePicker.js +2 -1
- package/esm/MonthCalendar/MonthCalendar.js +6 -11
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -0
- package/esm/PickersActionBar/PickersActionBar.d.ts +1 -1
- package/esm/PickersActionBar/PickersActionBar.js +22 -4
- package/esm/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/esm/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/esm/StaticDatePicker/StaticDatePicker.js +2 -1
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/esm/StaticTimePicker/StaticTimePicker.js +2 -1
- package/esm/TimeField/TimeField.js +4 -4
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +5 -11
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerProvider.d.ts +9 -0
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -0
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -3
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -0
- package/esm/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/esm/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/esm/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/esm/internals/hooks/useField/useField.types.d.ts +8 -1
- package/esm/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/esm/internals/hooks/useField/useField.utils.js +0 -57
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/esm/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/esm/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/esm/internals/hooks/useField/useFieldV7TextField.js +76 -307
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -0
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +9 -3
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -0
- package/esm/internals/hooks/usePicker/usePicker.d.ts +2 -1
- package/esm/internals/hooks/usePicker/usePicker.js +14 -4
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +2 -0
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -0
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +9 -3
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +7 -0
- package/esm/internals/index.d.ts +7 -6
- package/esm/internals/index.js +6 -5
- package/esm/internals/utils/createNonRangePickerStepNavigation.d.ts +13 -0
- package/esm/internals/utils/createNonRangePickerStepNavigation.js +24 -0
- package/esm/internals/utils/createStepNavigation.d.ts +32 -0
- package/esm/internals/utils/createStepNavigation.js +34 -0
- package/esm/internals/utils/date-utils.d.ts +1 -0
- package/esm/internals/utils/date-utils.js +2 -2
- package/esm/internals/utils/time-utils.d.ts +2 -0
- package/esm/internals/utils/time-utils.js +4 -3
- package/esm/locales/beBY.d.ts +1 -0
- package/esm/locales/beBY.js +1 -0
- package/esm/locales/bgBG.d.ts +1 -0
- package/esm/locales/bgBG.js +1 -0
- package/esm/locales/bnBD.d.ts +1 -0
- package/esm/locales/bnBD.js +1 -0
- package/esm/locales/caES.d.ts +1 -0
- package/esm/locales/caES.js +1 -0
- package/esm/locales/csCZ.d.ts +1 -0
- package/esm/locales/csCZ.js +1 -0
- package/esm/locales/daDK.d.ts +1 -0
- package/esm/locales/daDK.js +1 -0
- package/esm/locales/deDE.d.ts +1 -0
- package/esm/locales/deDE.js +3 -3
- package/esm/locales/elGR.d.ts +1 -0
- package/esm/locales/elGR.js +1 -0
- package/esm/locales/enUS.d.ts +1 -0
- package/esm/locales/enUS.js +1 -0
- package/esm/locales/esES.d.ts +1 -0
- package/esm/locales/esES.js +1 -0
- package/esm/locales/eu.d.ts +1 -0
- package/esm/locales/eu.js +1 -0
- package/esm/locales/faIR.d.ts +1 -0
- package/esm/locales/faIR.js +1 -0
- package/esm/locales/fiFI.d.ts +1 -0
- package/esm/locales/fiFI.js +1 -0
- package/esm/locales/frFR.d.ts +1 -0
- package/esm/locales/frFR.js +1 -0
- package/esm/locales/heIL.d.ts +1 -0
- package/esm/locales/heIL.js +1 -0
- package/esm/locales/hrHR.d.ts +1 -0
- package/esm/locales/hrHR.js +1 -0
- package/esm/locales/huHU.d.ts +1 -0
- package/esm/locales/huHU.js +1 -0
- package/esm/locales/isIS.d.ts +1 -0
- package/esm/locales/isIS.js +1 -0
- package/esm/locales/itIT.d.ts +1 -0
- package/esm/locales/itIT.js +1 -0
- package/esm/locales/jaJP.d.ts +1 -0
- package/esm/locales/jaJP.js +1 -0
- package/esm/locales/koKR.d.ts +1 -0
- package/esm/locales/koKR.js +1 -0
- package/esm/locales/kzKZ.d.ts +1 -0
- package/esm/locales/kzKZ.js +1 -0
- package/esm/locales/mk.d.ts +1 -0
- package/esm/locales/mk.js +1 -0
- package/esm/locales/nbNO.d.ts +1 -0
- package/esm/locales/nbNO.js +1 -0
- package/esm/locales/nlNL.d.ts +1 -0
- package/esm/locales/nlNL.js +1 -0
- package/esm/locales/nnNO.d.ts +1 -0
- package/esm/locales/nnNO.js +1 -0
- package/esm/locales/plPL.d.ts +1 -0
- package/esm/locales/plPL.js +1 -0
- package/esm/locales/ptBR.d.ts +1 -0
- package/esm/locales/ptBR.js +1 -0
- package/esm/locales/ptPT.d.ts +1 -0
- package/esm/locales/ptPT.js +1 -0
- package/esm/locales/roRO.d.ts +1 -0
- package/esm/locales/roRO.js +1 -0
- package/esm/locales/ruRU.d.ts +1 -0
- package/esm/locales/ruRU.js +1 -0
- package/esm/locales/skSK.d.ts +1 -0
- package/esm/locales/skSK.js +1 -0
- package/esm/locales/svSE.d.ts +1 -0
- package/esm/locales/svSE.js +1 -0
- package/esm/locales/trTR.d.ts +1 -0
- package/esm/locales/trTR.js +1 -0
- package/esm/locales/ukUA.d.ts +1 -0
- package/esm/locales/ukUA.js +1 -0
- package/esm/locales/urPK.d.ts +1 -0
- package/esm/locales/urPK.js +1 -0
- package/esm/locales/utils/getPickersLocalization.d.ts +1 -0
- package/esm/locales/utils/pickersLocaleTextApi.d.ts +1 -0
- package/esm/locales/viVN.d.ts +1 -0
- package/esm/locales/viVN.js +1 -0
- package/esm/locales/zhCN.d.ts +1 -0
- package/esm/locales/zhCN.js +1 -0
- package/esm/locales/zhHK.d.ts +1 -0
- package/esm/locales/zhHK.js +1 -0
- package/esm/locales/zhTW.d.ts +1 -0
- package/esm/locales/zhTW.js +1 -0
- package/esm/managers/useDateManager.d.ts +4 -13
- package/esm/managers/useDateManager.js +18 -28
- package/esm/managers/useDateTimeManager.d.ts +4 -13
- package/esm/managers/useDateTimeManager.js +23 -33
- package/esm/managers/useTimeManager.d.ts +4 -13
- package/esm/managers/useTimeManager.js +14 -24
- package/esm/models/manager.d.ts +3 -8
- package/esm/validation/validateDate.js +3 -4
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +9 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -0
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/internals/hooks/useField/syncSelectionToDOM.js +56 -0
- package/internals/hooks/useField/useField.types.d.ts +8 -1
- package/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/internals/hooks/useField/useField.utils.js +2 -61
- package/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/internals/hooks/useField/useFieldHiddenInputProps.js +39 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/internals/hooks/useField/useFieldRootProps.js +156 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.js +37 -0
- package/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/internals/hooks/useField/useFieldSectionContentProps.js +234 -0
- package/internals/hooks/useField/useFieldV7TextField.js +75 -306
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.js +9 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -0
- package/internals/hooks/usePicker/usePicker.d.ts +2 -1
- package/internals/hooks/usePicker/usePicker.js +14 -4
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +9 -3
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +7 -0
- package/internals/index.d.ts +7 -6
- package/internals/index.js +37 -18
- package/internals/utils/createNonRangePickerStepNavigation.d.ts +13 -0
- package/internals/utils/createNonRangePickerStepNavigation.js +30 -0
- package/internals/utils/createStepNavigation.d.ts +32 -0
- package/internals/utils/createStepNavigation.js +41 -0
- package/internals/utils/date-utils.d.ts +1 -0
- package/internals/utils/date-utils.js +3 -3
- package/internals/utils/time-utils.d.ts +2 -0
- package/internals/utils/time-utils.js +5 -4
- package/locales/beBY.d.ts +1 -0
- package/locales/beBY.js +1 -0
- package/locales/bgBG.d.ts +1 -0
- package/locales/bgBG.js +1 -0
- package/locales/bnBD.d.ts +1 -0
- package/locales/bnBD.js +1 -0
- package/locales/caES.d.ts +1 -0
- package/locales/caES.js +1 -0
- package/locales/csCZ.d.ts +1 -0
- package/locales/csCZ.js +1 -0
- package/locales/daDK.d.ts +1 -0
- package/locales/daDK.js +1 -0
- package/locales/deDE.d.ts +1 -0
- package/locales/deDE.js +3 -3
- package/locales/elGR.d.ts +1 -0
- package/locales/elGR.js +1 -0
- package/locales/enUS.d.ts +1 -0
- package/locales/enUS.js +1 -0
- package/locales/esES.d.ts +1 -0
- package/locales/esES.js +1 -0
- package/locales/eu.d.ts +1 -0
- package/locales/eu.js +1 -0
- package/locales/faIR.d.ts +1 -0
- package/locales/faIR.js +1 -0
- package/locales/fiFI.d.ts +1 -0
- package/locales/fiFI.js +1 -0
- package/locales/frFR.d.ts +1 -0
- package/locales/frFR.js +1 -0
- package/locales/heIL.d.ts +1 -0
- package/locales/heIL.js +1 -0
- package/locales/hrHR.d.ts +1 -0
- package/locales/hrHR.js +1 -0
- package/locales/huHU.d.ts +1 -0
- package/locales/huHU.js +1 -0
- package/locales/isIS.d.ts +1 -0
- package/locales/isIS.js +1 -0
- package/locales/itIT.d.ts +1 -0
- package/locales/itIT.js +1 -0
- package/locales/jaJP.d.ts +1 -0
- package/locales/jaJP.js +1 -0
- package/locales/koKR.d.ts +1 -0
- package/locales/koKR.js +1 -0
- package/locales/kzKZ.d.ts +1 -0
- package/locales/kzKZ.js +1 -0
- package/locales/mk.d.ts +1 -0
- package/locales/mk.js +1 -0
- package/locales/nbNO.d.ts +1 -0
- package/locales/nbNO.js +1 -0
- package/locales/nlNL.d.ts +1 -0
- package/locales/nlNL.js +1 -0
- package/locales/nnNO.d.ts +1 -0
- package/locales/nnNO.js +1 -0
- package/locales/plPL.d.ts +1 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.d.ts +1 -0
- package/locales/ptBR.js +1 -0
- package/locales/ptPT.d.ts +1 -0
- package/locales/ptPT.js +1 -0
- package/locales/roRO.d.ts +1 -0
- package/locales/roRO.js +1 -0
- package/locales/ruRU.d.ts +1 -0
- package/locales/ruRU.js +1 -0
- package/locales/skSK.d.ts +1 -0
- package/locales/skSK.js +1 -0
- package/locales/svSE.d.ts +1 -0
- package/locales/svSE.js +1 -0
- package/locales/trTR.d.ts +1 -0
- package/locales/trTR.js +1 -0
- package/locales/ukUA.d.ts +1 -0
- package/locales/ukUA.js +1 -0
- package/locales/urPK.d.ts +1 -0
- package/locales/urPK.js +1 -0
- package/locales/utils/getPickersLocalization.d.ts +1 -0
- package/locales/utils/pickersLocaleTextApi.d.ts +1 -0
- package/locales/viVN.d.ts +1 -0
- package/locales/viVN.js +1 -0
- package/locales/zhCN.d.ts +1 -0
- package/locales/zhCN.js +1 -0
- package/locales/zhHK.d.ts +1 -0
- package/locales/zhHK.js +1 -0
- package/locales/zhTW.d.ts +1 -0
- package/locales/zhTW.js +1 -0
- package/managers/useDateManager.d.ts +4 -13
- package/managers/useDateManager.js +18 -28
- package/managers/useDateTimeManager.d.ts +4 -13
- package/managers/useDateTimeManager.js +23 -33
- package/managers/useTimeManager.d.ts +4 -13
- package/managers/useTimeManager.js +15 -25
- package/models/manager.d.ts +3 -8
- package/modern/DateCalendar/DateCalendar.js +6 -10
- package/modern/DateCalendar/DayCalendar.js +2 -2
- package/modern/DateField/DateField.js +4 -4
- package/modern/DatePicker/shared.js +3 -9
- package/modern/DateTimeField/DateTimeField.js +4 -4
- package/modern/DateTimePicker/shared.js +4 -14
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +2 -1
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/modern/LocalizationProvider/LocalizationProvider.js +2 -2
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -1
- package/modern/MonthCalendar/MonthCalendar.js +6 -11
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -0
- package/modern/PickersActionBar/PickersActionBar.d.ts +1 -1
- package/modern/PickersActionBar/PickersActionBar.js +22 -4
- package/modern/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/modern/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -1
- package/modern/TimeField/TimeField.js +4 -4
- package/modern/TimePicker/shared.js +3 -3
- package/modern/YearCalendar/YearCalendar.js +5 -11
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.d.ts +9 -0
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -0
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -0
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/modern/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/modern/internals/hooks/useField/useField.types.d.ts +8 -1
- package/modern/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/modern/internals/hooks/useField/useField.utils.js +0 -57
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/modern/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/modern/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/modern/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +76 -307
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +9 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -0
- package/modern/internals/hooks/usePicker/usePicker.d.ts +2 -1
- package/modern/internals/hooks/usePicker/usePicker.js +14 -4
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +2 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +9 -3
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +7 -0
- package/modern/internals/index.d.ts +7 -6
- package/modern/internals/index.js +6 -5
- package/modern/internals/utils/createNonRangePickerStepNavigation.d.ts +13 -0
- package/modern/internals/utils/createNonRangePickerStepNavigation.js +24 -0
- package/modern/internals/utils/createStepNavigation.d.ts +32 -0
- package/modern/internals/utils/createStepNavigation.js +34 -0
- package/modern/internals/utils/date-utils.d.ts +1 -0
- package/modern/internals/utils/date-utils.js +2 -2
- package/modern/internals/utils/time-utils.d.ts +2 -0
- package/modern/internals/utils/time-utils.js +4 -3
- package/modern/locales/beBY.d.ts +1 -0
- package/modern/locales/beBY.js +1 -0
- package/modern/locales/bgBG.d.ts +1 -0
- package/modern/locales/bgBG.js +1 -0
- package/modern/locales/bnBD.d.ts +1 -0
- package/modern/locales/bnBD.js +1 -0
- package/modern/locales/caES.d.ts +1 -0
- package/modern/locales/caES.js +1 -0
- package/modern/locales/csCZ.d.ts +1 -0
- package/modern/locales/csCZ.js +1 -0
- package/modern/locales/daDK.d.ts +1 -0
- package/modern/locales/daDK.js +1 -0
- package/modern/locales/deDE.d.ts +1 -0
- package/modern/locales/deDE.js +3 -3
- package/modern/locales/elGR.d.ts +1 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/enUS.d.ts +1 -0
- package/modern/locales/enUS.js +1 -0
- package/modern/locales/esES.d.ts +1 -0
- package/modern/locales/esES.js +1 -0
- package/modern/locales/eu.d.ts +1 -0
- package/modern/locales/eu.js +1 -0
- package/modern/locales/faIR.d.ts +1 -0
- package/modern/locales/faIR.js +1 -0
- package/modern/locales/fiFI.d.ts +1 -0
- package/modern/locales/fiFI.js +1 -0
- package/modern/locales/frFR.d.ts +1 -0
- package/modern/locales/frFR.js +1 -0
- package/modern/locales/heIL.d.ts +1 -0
- package/modern/locales/heIL.js +1 -0
- package/modern/locales/hrHR.d.ts +1 -0
- package/modern/locales/hrHR.js +1 -0
- package/modern/locales/huHU.d.ts +1 -0
- package/modern/locales/huHU.js +1 -0
- package/modern/locales/isIS.d.ts +1 -0
- package/modern/locales/isIS.js +1 -0
- package/modern/locales/itIT.d.ts +1 -0
- package/modern/locales/itIT.js +1 -0
- package/modern/locales/jaJP.d.ts +1 -0
- package/modern/locales/jaJP.js +1 -0
- package/modern/locales/koKR.d.ts +1 -0
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/kzKZ.d.ts +1 -0
- package/modern/locales/kzKZ.js +1 -0
- package/modern/locales/mk.d.ts +1 -0
- package/modern/locales/mk.js +1 -0
- package/modern/locales/nbNO.d.ts +1 -0
- package/modern/locales/nbNO.js +1 -0
- package/modern/locales/nlNL.d.ts +1 -0
- package/modern/locales/nlNL.js +1 -0
- package/modern/locales/nnNO.d.ts +1 -0
- package/modern/locales/nnNO.js +1 -0
- package/modern/locales/plPL.d.ts +1 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.d.ts +1 -0
- package/modern/locales/ptBR.js +1 -0
- package/modern/locales/ptPT.d.ts +1 -0
- package/modern/locales/ptPT.js +1 -0
- package/modern/locales/roRO.d.ts +1 -0
- package/modern/locales/roRO.js +1 -0
- package/modern/locales/ruRU.d.ts +1 -0
- package/modern/locales/ruRU.js +1 -0
- package/modern/locales/skSK.d.ts +1 -0
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/svSE.d.ts +1 -0
- package/modern/locales/svSE.js +1 -0
- package/modern/locales/trTR.d.ts +1 -0
- package/modern/locales/trTR.js +1 -0
- package/modern/locales/ukUA.d.ts +1 -0
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/urPK.d.ts +1 -0
- package/modern/locales/urPK.js +1 -0
- package/modern/locales/utils/getPickersLocalization.d.ts +1 -0
- package/modern/locales/utils/pickersLocaleTextApi.d.ts +1 -0
- package/modern/locales/viVN.d.ts +1 -0
- package/modern/locales/viVN.js +1 -0
- package/modern/locales/zhCN.d.ts +1 -0
- package/modern/locales/zhCN.js +1 -0
- package/modern/locales/zhHK.d.ts +1 -0
- package/modern/locales/zhHK.js +1 -0
- package/modern/locales/zhTW.d.ts +1 -0
- package/modern/locales/zhTW.js +1 -0
- package/modern/managers/useDateManager.d.ts +4 -13
- package/modern/managers/useDateManager.js +18 -28
- package/modern/managers/useDateTimeManager.d.ts +4 -13
- package/modern/managers/useDateTimeManager.js +23 -33
- package/modern/managers/useTimeManager.d.ts +4 -13
- package/modern/managers/useTimeManager.js +14 -24
- package/modern/models/manager.d.ts +3 -8
- package/modern/validation/validateDate.js +3 -4
- package/package.json +6 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/validateDate.js +3 -4
|
@@ -3,28 +3,24 @@ import * as React from 'react';
|
|
|
3
3
|
import useForkRef from '@mui/utils/useForkRef';
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
|
-
import
|
|
7
|
-
import useId from '@mui/utils/useId';
|
|
8
|
-
import { getSectionValueNow, getSectionValueText, parseSelectedSections } from "./useField.utils.js";
|
|
6
|
+
import { parseSelectedSections } from "./useField.utils.js";
|
|
9
7
|
import { getActiveElement } from "../../utils/utils.js";
|
|
10
8
|
import { useSplitFieldProps } from "../../../hooks/index.js";
|
|
11
|
-
import { usePickerTranslations } from "../../../hooks/usePickerTranslations.js";
|
|
12
|
-
import { useUtils } from "../useUtils.js";
|
|
13
9
|
import { useFieldCharacterEditing } from "./useFieldCharacterEditing.js";
|
|
14
|
-
import { useFieldRootHandleKeyDown } from "./useFieldRootHandleKeyDown.js";
|
|
15
10
|
import { useFieldState } from "./useFieldState.js";
|
|
16
11
|
import { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
12
|
+
import { syncSelectionToDOM } from "./syncSelectionToDOM.js";
|
|
13
|
+
import { useFieldRootProps } from "./useFieldRootProps.js";
|
|
14
|
+
import { useFieldHiddenInputProps } from "./useFieldHiddenInputProps.js";
|
|
15
|
+
import { useFieldSectionContainerProps } from "./useFieldSectionContainerProps.js";
|
|
16
|
+
import { useFieldSectionContentProps } from "./useFieldSectionContentProps.js";
|
|
17
17
|
export const useFieldV7TextField = parameters => {
|
|
18
|
-
const translations = usePickerTranslations();
|
|
19
|
-
const utils = useUtils();
|
|
20
|
-
const id = useId();
|
|
21
18
|
const {
|
|
22
19
|
props,
|
|
23
20
|
manager,
|
|
24
21
|
skipContextFieldRefAssignment,
|
|
25
22
|
manager: {
|
|
26
23
|
valueType,
|
|
27
|
-
internal_fieldValueManager: fieldValueManager,
|
|
28
24
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
29
25
|
}
|
|
30
26
|
} = parameters;
|
|
@@ -57,6 +53,13 @@ export const useFieldV7TextField = parameters => {
|
|
|
57
53
|
} = internalPropsWithDefaults;
|
|
58
54
|
const sectionListRef = React.useRef(null);
|
|
59
55
|
const handleSectionListRef = useForkRef(sectionListRefProp, sectionListRef);
|
|
56
|
+
const domGetters = React.useMemo(() => ({
|
|
57
|
+
isReady: () => sectionListRef.current != null,
|
|
58
|
+
getRoot: () => sectionListRef.current.getRoot(),
|
|
59
|
+
getSectionContainer: sectionIndex => sectionListRef.current.getSectionContainer(sectionIndex),
|
|
60
|
+
getSectionContent: sectionIndex => sectionListRef.current.getSectionContent(sectionIndex),
|
|
61
|
+
getSectionIndexFromDOMElement: element => sectionListRef.current.getSectionIndexFromDOMElement(element)
|
|
62
|
+
}), [sectionListRef]);
|
|
60
63
|
const stateResponse = useFieldState({
|
|
61
64
|
manager,
|
|
62
65
|
internalPropsWithDefaults,
|
|
@@ -68,62 +71,17 @@ export const useFieldV7TextField = parameters => {
|
|
|
68
71
|
error,
|
|
69
72
|
parsedSelectedSections,
|
|
70
73
|
sectionOrder,
|
|
71
|
-
sectionsValueBoundaries,
|
|
72
74
|
state,
|
|
73
75
|
value,
|
|
74
76
|
// Methods to update the states
|
|
75
77
|
clearValue,
|
|
76
|
-
|
|
77
|
-
setCharacterQuery,
|
|
78
|
-
setSelectedSections,
|
|
79
|
-
updateSectionValue,
|
|
80
|
-
updateValueFromValueStr
|
|
78
|
+
setSelectedSections
|
|
81
79
|
} = stateResponse;
|
|
82
80
|
const applyCharacterEditing = useFieldCharacterEditing({
|
|
83
81
|
stateResponse
|
|
84
82
|
});
|
|
85
83
|
const openPickerAriaLabel = useOpenPickerButtonAriaLabel(value);
|
|
86
84
|
const [focused, setFocused] = React.useState(false);
|
|
87
|
-
function syncSelectionToDOM() {
|
|
88
|
-
if (!sectionListRef.current) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const selection = document.getSelection();
|
|
92
|
-
if (!selection) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (parsedSelectedSections == null) {
|
|
96
|
-
// If the selection contains an element inside the field, we reset it.
|
|
97
|
-
if (selection.rangeCount > 0 && sectionListRef.current.getRoot().contains(selection.getRangeAt(0).startContainer)) {
|
|
98
|
-
selection.removeAllRanges();
|
|
99
|
-
}
|
|
100
|
-
if (focused) {
|
|
101
|
-
sectionListRef.current.getRoot().blur();
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// On multi input range pickers we want to update selection range only for the active input
|
|
107
|
-
if (!sectionListRef.current.getRoot().contains(getActiveElement(document))) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const range = new window.Range();
|
|
111
|
-
let target;
|
|
112
|
-
if (parsedSelectedSections === 'all') {
|
|
113
|
-
target = sectionListRef.current.getRoot();
|
|
114
|
-
} else {
|
|
115
|
-
const section = state.sections[parsedSelectedSections];
|
|
116
|
-
if (section.type === 'empty') {
|
|
117
|
-
target = sectionListRef.current.getSectionContainer(parsedSelectedSections);
|
|
118
|
-
} else {
|
|
119
|
-
target = sectionListRef.current.getSectionContent(parsedSelectedSections);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
range.selectNodeContents(target);
|
|
123
|
-
target.focus();
|
|
124
|
-
selection.removeAllRanges();
|
|
125
|
-
selection.addRange(range);
|
|
126
|
-
}
|
|
127
85
|
function focusField(newSelectedSections = 0) {
|
|
128
86
|
if (!sectionListRef.current ||
|
|
129
87
|
// if the field is already focused, we don't need to focus it again
|
|
@@ -134,193 +92,53 @@ export const useFieldV7TextField = parameters => {
|
|
|
134
92
|
setFocused(true);
|
|
135
93
|
sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();
|
|
136
94
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const section = state.sections[sectionIndex];
|
|
147
|
-
sectionListRef.current.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;
|
|
148
|
-
syncSelectionToDOM();
|
|
95
|
+
const rootProps = useFieldRootProps({
|
|
96
|
+
manager,
|
|
97
|
+
internalPropsWithDefaults,
|
|
98
|
+
stateResponse,
|
|
99
|
+
applyCharacterEditing,
|
|
100
|
+
focused,
|
|
101
|
+
setFocused,
|
|
102
|
+
domGetters
|
|
149
103
|
});
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// We avoid this by checking if the call of `handleContainerClick` is actually intended, or a side effect.
|
|
154
|
-
if (event.isDefaultPrevented() || !sectionListRef.current) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
setFocused(true);
|
|
158
|
-
onClick?.(event, ...args);
|
|
159
|
-
if (parsedSelectedSections === 'all') {
|
|
160
|
-
containerClickTimeout.start(0, () => {
|
|
161
|
-
const cursorPosition = document.getSelection().getRangeAt(0).startOffset;
|
|
162
|
-
if (cursorPosition === 0) {
|
|
163
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
let sectionIndex = 0;
|
|
167
|
-
let cursorOnStartOfSection = 0;
|
|
168
|
-
while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {
|
|
169
|
-
const section = state.sections[sectionIndex];
|
|
170
|
-
sectionIndex += 1;
|
|
171
|
-
cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;
|
|
172
|
-
}
|
|
173
|
-
setSelectedSections(sectionIndex - 1);
|
|
174
|
-
});
|
|
175
|
-
} else if (!focused) {
|
|
176
|
-
setFocused(true);
|
|
177
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
178
|
-
} else {
|
|
179
|
-
const hasClickedOnASection = sectionListRef.current.getRoot().contains(event.target);
|
|
180
|
-
if (!hasClickedOnASection) {
|
|
181
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
104
|
+
const hiddenInputProps = useFieldHiddenInputProps({
|
|
105
|
+
manager,
|
|
106
|
+
stateResponse
|
|
184
107
|
});
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
if (!sectionListRef.current || parsedSelectedSections !== 'all') {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const target = event.target;
|
|
191
|
-
const keyPressed = target.textContent ?? '';
|
|
192
|
-
sectionListRef.current.getRoot().innerHTML = state.sections.map(section => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join('');
|
|
193
|
-
syncSelectionToDOM();
|
|
194
|
-
if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {
|
|
195
|
-
clearValue();
|
|
196
|
-
setSelectedSections('all');
|
|
197
|
-
} else if (keyPressed.length > 1) {
|
|
198
|
-
updateValueFromValueStr(keyPressed);
|
|
199
|
-
} else {
|
|
200
|
-
if (parsedSelectedSections === 'all') {
|
|
201
|
-
setSelectedSections(0);
|
|
202
|
-
}
|
|
203
|
-
applyCharacterEditing({
|
|
204
|
-
keyPressed,
|
|
205
|
-
sectionIndex: 0
|
|
206
|
-
});
|
|
207
|
-
}
|
|
108
|
+
const createSectionContainerProps = useFieldSectionContainerProps({
|
|
109
|
+
stateResponse
|
|
208
110
|
});
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
setCharacterQuery(null);
|
|
218
|
-
updateValueFromValueStr(pastedValue);
|
|
111
|
+
const createSectionContentProps = useFieldSectionContentProps({
|
|
112
|
+
manager,
|
|
113
|
+
stateResponse,
|
|
114
|
+
applyCharacterEditing,
|
|
115
|
+
internalPropsWithDefaults,
|
|
116
|
+
domGetters,
|
|
117
|
+
focused
|
|
219
118
|
});
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const activeElement = getActiveElement(document);
|
|
226
|
-
setFocused(true);
|
|
227
|
-
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
|
|
228
|
-
if (!isFocusInsideASection) {
|
|
229
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
230
|
-
}
|
|
119
|
+
const handleRootKeyDown = useEventCallback(event => {
|
|
120
|
+
onKeyDown?.(event);
|
|
121
|
+
rootProps.onKeyDown(event);
|
|
231
122
|
});
|
|
232
|
-
const
|
|
123
|
+
const handleRootBlur = useEventCallback(event => {
|
|
233
124
|
onBlur?.(event);
|
|
234
|
-
|
|
235
|
-
if (!sectionListRef.current) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const activeElement = getActiveElement(document);
|
|
239
|
-
const shouldBlur = !sectionListRef.current.getRoot().contains(activeElement);
|
|
240
|
-
if (shouldBlur) {
|
|
241
|
-
setFocused(false);
|
|
242
|
-
setSelectedSections(null);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
125
|
+
rootProps.onBlur(event);
|
|
245
126
|
});
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (event.isDefaultPrevented()) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
setSelectedSections(sectionIndex);
|
|
253
|
-
});
|
|
254
|
-
const handleInputContentMouseUp = useEventCallback(event => {
|
|
255
|
-
// Without this, the browser will remove the selected when clicking inside an already-selected section.
|
|
256
|
-
event.preventDefault();
|
|
127
|
+
const handleRootFocus = useEventCallback(event => {
|
|
128
|
+
onFocus?.(event);
|
|
129
|
+
rootProps.onFocus(event);
|
|
257
130
|
});
|
|
258
|
-
const
|
|
259
|
-
|
|
131
|
+
const handleRootClick = useEventCallback(event => {
|
|
132
|
+
onClick?.(event);
|
|
133
|
+
rootProps.onClick(event);
|
|
260
134
|
});
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (readOnly || disabled || typeof parsedSelectedSections !== 'number') {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
const activeSection = state.sections[parsedSelectedSections];
|
|
268
|
-
const pastedValue = event.clipboardData.getData('text');
|
|
269
|
-
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
|
270
|
-
const digitsOnly = /^[0-9]+$/.test(pastedValue);
|
|
271
|
-
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
272
|
-
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
273
|
-
if (isValidPastedValue) {
|
|
274
|
-
setCharacterQuery(null);
|
|
275
|
-
updateSectionValue({
|
|
276
|
-
section: activeSection,
|
|
277
|
-
newSectionValue: pastedValue,
|
|
278
|
-
shouldGoToNextSection: true
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
// If the pasted value corresponds to a single section, but not the expected type, we skip the modification
|
|
282
|
-
else if (!lettersOnly && !digitsOnly) {
|
|
283
|
-
setCharacterQuery(null);
|
|
284
|
-
updateValueFromValueStr(pastedValue);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
const handleInputContentDragOver = useEventCallback(event => {
|
|
288
|
-
event.preventDefault();
|
|
289
|
-
event.dataTransfer.dropEffect = 'none';
|
|
135
|
+
const handleRootPaste = useEventCallback(event => {
|
|
136
|
+
onPaste?.(event);
|
|
137
|
+
rootProps.onPaste(event);
|
|
290
138
|
});
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
const target = event.target;
|
|
296
|
-
const keyPressed = target.textContent ?? '';
|
|
297
|
-
const sectionIndex = sectionListRef.current.getSectionIndexFromDOMElement(target);
|
|
298
|
-
const section = state.sections[sectionIndex];
|
|
299
|
-
if (readOnly || !sectionListRef.current) {
|
|
300
|
-
revertDOMSectionChange(sectionIndex);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
if (keyPressed.length === 0) {
|
|
304
|
-
if (section.value === '') {
|
|
305
|
-
revertDOMSectionChange(sectionIndex);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const inputType = event.nativeEvent.inputType;
|
|
309
|
-
if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {
|
|
310
|
-
revertDOMSectionChange(sectionIndex);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
revertDOMSectionChange(sectionIndex);
|
|
314
|
-
clearActiveSection();
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
applyCharacterEditing({
|
|
318
|
-
keyPressed,
|
|
319
|
-
sectionIndex
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// The DOM value needs to remain the one React is expecting.
|
|
323
|
-
revertDOMSectionChange(sectionIndex);
|
|
139
|
+
const handleRootInput = useEventCallback(event => {
|
|
140
|
+
onInput?.(event);
|
|
141
|
+
rootProps.onInput(event);
|
|
324
142
|
});
|
|
325
143
|
const handleClear = useEventCallback((event, ...args) => {
|
|
326
144
|
event.preventDefault();
|
|
@@ -333,67 +151,18 @@ export const useFieldV7TextField = parameters => {
|
|
|
333
151
|
setSelectedSections(sectionOrder.startIndex);
|
|
334
152
|
}
|
|
335
153
|
});
|
|
336
|
-
const handleContainerKeyDown = useFieldRootHandleKeyDown({
|
|
337
|
-
manager,
|
|
338
|
-
internalPropsWithDefaults,
|
|
339
|
-
stateResponse
|
|
340
|
-
});
|
|
341
|
-
const wrappedHandleContainerKeyDown = useEventCallback(event => {
|
|
342
|
-
onKeyDown?.(event);
|
|
343
|
-
handleContainerKeyDown(event);
|
|
344
|
-
});
|
|
345
|
-
const isContainerEditable = parsedSelectedSections === 'all';
|
|
346
154
|
const elements = React.useMemo(() => {
|
|
347
|
-
return state.sections.map((section,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
},
|
|
359
|
-
content: {
|
|
360
|
-
tabIndex: isContainerEditable || index > 0 ? -1 : 0,
|
|
361
|
-
contentEditable: !isContainerEditable && !disabled && !readOnly,
|
|
362
|
-
role: 'spinbutton',
|
|
363
|
-
id: `${id}-${section.type}`,
|
|
364
|
-
'aria-labelledby': `${id}-${section.type}`,
|
|
365
|
-
'aria-readonly': readOnly,
|
|
366
|
-
'aria-valuenow': getSectionValueNow(section, utils),
|
|
367
|
-
'aria-valuemin': sectionBoundaries.minimum,
|
|
368
|
-
'aria-valuemax': sectionBoundaries.maximum,
|
|
369
|
-
'aria-valuetext': section.value ? getSectionValueText(section, utils) : translations.empty,
|
|
370
|
-
'aria-label': translations[section.type],
|
|
371
|
-
'aria-disabled': disabled,
|
|
372
|
-
spellCheck: isEditable ? false : undefined,
|
|
373
|
-
autoCapitalize: isEditable ? 'off' : undefined,
|
|
374
|
-
autoCorrect: isEditable ? 'off' : undefined,
|
|
375
|
-
[parseInt(React.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,
|
|
376
|
-
children: section.value || section.placeholder,
|
|
377
|
-
onInput: handleInputContentInput,
|
|
378
|
-
onPaste: handleInputContentPaste,
|
|
379
|
-
onFocus: getInputContentFocusHandler(index),
|
|
380
|
-
onDragOver: handleInputContentDragOver,
|
|
381
|
-
onMouseUp: handleInputContentMouseUp,
|
|
382
|
-
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
|
383
|
-
},
|
|
384
|
-
before: {
|
|
385
|
-
children: section.startSeparator
|
|
386
|
-
},
|
|
387
|
-
after: {
|
|
388
|
-
children: section.endSeparator
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
});
|
|
392
|
-
}, [disabled, fieldValueManager, getInputContainerClickHandler, getInputContentFocusHandler, handleInputContentDragOver, handleInputContentInput, handleInputContentMouseUp, handleInputContentPaste, id, isContainerEditable, readOnly, sectionsValueBoundaries, state.sections, translations, utils, value]);
|
|
393
|
-
const handleValueStrChange = useEventCallback(event => {
|
|
394
|
-
updateValueFromValueStr(event.target.value);
|
|
395
|
-
});
|
|
396
|
-
const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);
|
|
155
|
+
return state.sections.map((section, sectionIndex) => ({
|
|
156
|
+
container: createSectionContainerProps(sectionIndex),
|
|
157
|
+
content: createSectionContentProps(section, sectionIndex),
|
|
158
|
+
before: {
|
|
159
|
+
children: section.startSeparator
|
|
160
|
+
},
|
|
161
|
+
after: {
|
|
162
|
+
children: section.endSeparator
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
}, [state.sections, createSectionContainerProps, createSectionContentProps]);
|
|
397
166
|
React.useEffect(() => {
|
|
398
167
|
if (sectionListRef.current == null) {
|
|
399
168
|
throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your Picker or Field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\n'));
|
|
@@ -417,7 +186,11 @@ export const useFieldV7TextField = parameters => {
|
|
|
417
186
|
}
|
|
418
187
|
}, [parsedSelectedSections, focused]);
|
|
419
188
|
useEnhancedEffect(() => {
|
|
420
|
-
syncSelectionToDOM(
|
|
189
|
+
syncSelectionToDOM({
|
|
190
|
+
focused,
|
|
191
|
+
domGetters,
|
|
192
|
+
stateResponse
|
|
193
|
+
});
|
|
421
194
|
});
|
|
422
195
|
React.useImperativeHandle(unstableFieldRef, () => ({
|
|
423
196
|
getSections: () => state.sections,
|
|
@@ -434,26 +207,22 @@ export const useFieldV7TextField = parameters => {
|
|
|
434
207
|
focusField,
|
|
435
208
|
isFieldFocused: () => isFieldFocused(sectionListRef)
|
|
436
209
|
}));
|
|
437
|
-
return _extends({}, forwardedProps, {
|
|
210
|
+
return _extends({}, forwardedProps, rootProps, {
|
|
211
|
+
onBlur: handleRootBlur,
|
|
212
|
+
onClick: handleRootClick,
|
|
213
|
+
onFocus: handleRootFocus,
|
|
214
|
+
onInput: handleRootInput,
|
|
215
|
+
onPaste: handleRootPaste,
|
|
216
|
+
onKeyDown: handleRootKeyDown,
|
|
217
|
+
onClear: handleClear
|
|
218
|
+
}, hiddenInputProps, {
|
|
438
219
|
error,
|
|
439
220
|
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
|
|
440
221
|
focused: focusedProp ?? focused,
|
|
441
222
|
sectionListRef: handleSectionListRef,
|
|
442
|
-
onBlur: handleContainerBlur,
|
|
443
|
-
onClick: handleContainerClick,
|
|
444
|
-
onFocus: handleContainerFocus,
|
|
445
|
-
onInput: handleContainerInput,
|
|
446
|
-
onPaste: handleContainerPaste,
|
|
447
|
-
onKeyDown: wrappedHandleContainerKeyDown,
|
|
448
|
-
onClear: handleClear,
|
|
449
223
|
// Additional
|
|
450
224
|
enableAccessibleFieldDOMStructure: true,
|
|
451
225
|
elements,
|
|
452
|
-
// TODO v7: Try to set to undefined when there is a section selected.
|
|
453
|
-
tabIndex: parsedSelectedSections === 0 ? -1 : 0,
|
|
454
|
-
contentEditable: isContainerEditable,
|
|
455
|
-
value: valueStr,
|
|
456
|
-
onChange: handleValueStrChange,
|
|
457
226
|
areAllSectionsEmpty,
|
|
458
227
|
disabled,
|
|
459
228
|
readOnly,
|
|
@@ -9,6 +9,7 @@ import { DateOrTimeViewWithMeridiem } from "../../models/index.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({
|
|
11
11
|
props,
|
|
12
|
+
steps,
|
|
12
13
|
...pickerParams
|
|
13
14
|
}: UseMobilePickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
14
15
|
renderPicker: () => React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["props"],
|
|
3
|
+
const _excluded = ["props", "steps"],
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
@@ -9,6 +9,7 @@ import { usePicker } from "../usePicker/index.js";
|
|
|
9
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
10
10
|
import { PickerProvider } from "../../components/PickerProvider.js";
|
|
11
11
|
import { PickerFieldUIContextProvider } from "../../components/PickerFieldUI.js";
|
|
12
|
+
import { createNonRangePickerStepNavigation } from "../../utils/createNonRangePickerStepNavigation.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Hook managing all the single-date mobile pickers:
|
|
@@ -19,7 +20,8 @@ import { PickerFieldUIContextProvider } from "../../components/PickerFieldUI.js"
|
|
|
19
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
21
|
export const useMobilePicker = _ref => {
|
|
21
22
|
let {
|
|
22
|
-
props
|
|
23
|
+
props,
|
|
24
|
+
steps
|
|
23
25
|
} = _ref,
|
|
24
26
|
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
27
|
const {
|
|
@@ -29,6 +31,9 @@ export const useMobilePicker = _ref => {
|
|
|
29
31
|
inputRef,
|
|
30
32
|
localeText
|
|
31
33
|
} = props;
|
|
34
|
+
const getStepNavigation = createNonRangePickerStepNavigation({
|
|
35
|
+
steps
|
|
36
|
+
});
|
|
32
37
|
const {
|
|
33
38
|
providerProps,
|
|
34
39
|
renderCurrentView,
|
|
@@ -38,7 +43,8 @@ export const useMobilePicker = _ref => {
|
|
|
38
43
|
localeText,
|
|
39
44
|
autoFocusView: true,
|
|
40
45
|
viewContainerRole: 'dialog',
|
|
41
|
-
variant: 'mobile'
|
|
46
|
+
variant: 'mobile',
|
|
47
|
+
getStepNavigation
|
|
42
48
|
}));
|
|
43
49
|
const labelId = providerProps.privateContextValue.labelId;
|
|
44
50
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
@@ -7,6 +7,7 @@ import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js
|
|
|
7
7
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
|
|
8
8
|
import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
|
|
9
9
|
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
|
|
10
|
+
import { PickerStep } from "../../utils/createNonRangePickerStepNavigation.js";
|
|
10
11
|
export interface UseMobilePickerSlots extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
|
11
12
|
/**
|
|
12
13
|
* Component used to enter the date with the keyboard.
|
|
@@ -32,4 +33,10 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
32
33
|
}
|
|
33
34
|
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'ref'> {
|
|
34
35
|
props: TExternalProps;
|
|
36
|
+
/**
|
|
37
|
+
* Steps available for the picker.
|
|
38
|
+
* This will be used to define the behavior of navigation actions.
|
|
39
|
+
* If null, the picker will not have any step navigation.
|
|
40
|
+
*/
|
|
41
|
+
steps: PickerStep[] | null;
|
|
35
42
|
}
|
|
@@ -10,5 +10,6 @@ export declare const usePicker: <TValue extends PickerValidValue, TView extends
|
|
|
10
10
|
autoFocusView,
|
|
11
11
|
rendererInterceptor: RendererInterceptor,
|
|
12
12
|
localeText,
|
|
13
|
-
viewContainerRole
|
|
13
|
+
viewContainerRole,
|
|
14
|
+
getStepNavigation
|
|
14
15
|
}: UsePickerParameters<TValue, TView, TExternalProps>) => UsePickerReturnValue<TValue>;
|
|
@@ -23,7 +23,8 @@ export const usePicker = ({
|
|
|
23
23
|
autoFocusView,
|
|
24
24
|
rendererInterceptor: RendererInterceptor,
|
|
25
25
|
localeText,
|
|
26
|
-
viewContainerRole
|
|
26
|
+
viewContainerRole,
|
|
27
|
+
getStepNavigation
|
|
27
28
|
}) => {
|
|
28
29
|
const {
|
|
29
30
|
// View props
|
|
@@ -190,6 +191,13 @@ export const usePicker = ({
|
|
|
190
191
|
}
|
|
191
192
|
return 'enabled';
|
|
192
193
|
}, [disableOpenPicker, hasUIView, disabled, readOnly]);
|
|
194
|
+
const stepNavigation = getStepNavigation({
|
|
195
|
+
setView,
|
|
196
|
+
view,
|
|
197
|
+
initialView: initialView ?? views[0],
|
|
198
|
+
views
|
|
199
|
+
});
|
|
200
|
+
const wrappedGoToNextStep = useEventCallback(stepNavigation.goToNextStep);
|
|
193
201
|
const actionsContextValue = React.useMemo(() => ({
|
|
194
202
|
setValue,
|
|
195
203
|
setOpen,
|
|
@@ -197,8 +205,9 @@ export const usePicker = ({
|
|
|
197
205
|
setValueToToday,
|
|
198
206
|
acceptValueChanges,
|
|
199
207
|
cancelValueChanges,
|
|
200
|
-
setView
|
|
201
|
-
|
|
208
|
+
setView,
|
|
209
|
+
goToNextStep: wrappedGoToNextStep
|
|
210
|
+
}), [setValue, setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges, setView, wrappedGoToNextStep]);
|
|
202
211
|
const contextValue = React.useMemo(() => _extends({}, actionsContextValue, {
|
|
203
212
|
value,
|
|
204
213
|
timezone,
|
|
@@ -215,13 +224,14 @@ export const usePicker = ({
|
|
|
215
224
|
reduceAnimations,
|
|
216
225
|
triggerRef,
|
|
217
226
|
triggerStatus,
|
|
227
|
+
hasNextStep: stepNavigation.hasNextStep,
|
|
218
228
|
fieldFormat: format ?? '',
|
|
219
229
|
name,
|
|
220
230
|
label,
|
|
221
231
|
rootSx: sx,
|
|
222
232
|
rootRef,
|
|
223
233
|
rootClassName: className
|
|
224
|
-
}), [actionsContextValue, value, rootRef, variant, orientation, reduceAnimations, disabled, readOnly, format, className, name, label, sx, triggerStatus, timezone, state.open, popperView, views, initialView, autoFocus]);
|
|
234
|
+
}), [actionsContextValue, value, rootRef, variant, orientation, reduceAnimations, disabled, readOnly, format, className, name, label, sx, triggerStatus, stepNavigation.hasNextStep, timezone, state.open, popperView, views, initialView, autoFocus]);
|
|
225
235
|
const privateContextValue = React.useMemo(() => ({
|
|
226
236
|
dismissViews,
|
|
227
237
|
ownerState,
|
|
@@ -7,6 +7,7 @@ import { UseViewsOptions } from "../useViews.js";
|
|
|
7
7
|
import { PickerProviderProps } from "../../components/PickerProvider.js";
|
|
8
8
|
import { PickersInputLocaleText } from "../../../locales/index.js";
|
|
9
9
|
import { PickerFieldPrivateContextValue } from "../useNullableFieldPrivateContext.js";
|
|
10
|
+
import { CreateStepNavigationReturnValue } from "../../utils/createStepNavigation.js";
|
|
10
11
|
/**
|
|
11
12
|
* Props common to all Picker headless implementations.
|
|
12
13
|
* Those props are exposed on all the Pickers.
|
|
@@ -130,6 +131,7 @@ export interface UsePickerParameters<TValue extends PickerValidValue, TView exte
|
|
|
130
131
|
*/
|
|
131
132
|
rendererInterceptor?: React.JSXElementConstructor<PickerRendererInterceptorProps<TValue, TView, TExternalProps>>;
|
|
132
133
|
props: TExternalProps;
|
|
134
|
+
getStepNavigation: CreateStepNavigationReturnValue;
|
|
133
135
|
}
|
|
134
136
|
export interface UsePickerReturnValue<TValue extends PickerValidValue> {
|
|
135
137
|
ownerState: PickerOwnerState;
|
|
@@ -9,6 +9,7 @@ import { DateOrTimeViewWithMeridiem } from "../../models/index.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const useStaticPicker: <TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticPickerProps<TView, any, TExternalProps>>({
|
|
11
11
|
props,
|
|
12
|
+
steps,
|
|
12
13
|
...pickerParams
|
|
13
14
|
}: UseStaticPickerParams<TView, TExternalProps>) => {
|
|
14
15
|
renderPicker: () => React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["props"];
|
|
3
|
+
const _excluded = ["props", "steps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
@@ -9,6 +9,7 @@ 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 { mergeSx } from "../../utils/utils.js";
|
|
12
|
+
import { createNonRangePickerStepNavigation } from "../../utils/createNonRangePickerStepNavigation.js";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const PickerStaticLayout = styled(PickersLayout)(({
|
|
14
15
|
theme
|
|
@@ -26,7 +27,8 @@ const PickerStaticLayout = styled(PickersLayout)(({
|
|
|
26
27
|
*/
|
|
27
28
|
export const useStaticPicker = _ref => {
|
|
28
29
|
let {
|
|
29
|
-
props
|
|
30
|
+
props,
|
|
31
|
+
steps
|
|
30
32
|
} = _ref,
|
|
31
33
|
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
34
|
const {
|
|
@@ -36,6 +38,9 @@ export const useStaticPicker = _ref => {
|
|
|
36
38
|
displayStaticWrapperAs,
|
|
37
39
|
autoFocus
|
|
38
40
|
} = props;
|
|
41
|
+
const getStepNavigation = createNonRangePickerStepNavigation({
|
|
42
|
+
steps
|
|
43
|
+
});
|
|
39
44
|
const {
|
|
40
45
|
providerProps,
|
|
41
46
|
renderCurrentView
|
|
@@ -44,7 +49,8 @@ export const useStaticPicker = _ref => {
|
|
|
44
49
|
variant: displayStaticWrapperAs,
|
|
45
50
|
autoFocusView: autoFocus ?? false,
|
|
46
51
|
viewContainerRole: null,
|
|
47
|
-
localeText
|
|
52
|
+
localeText,
|
|
53
|
+
getStepNavigation
|
|
48
54
|
}));
|
|
49
55
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
50
56
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|