@mui/x-date-pickers 7.0.0-beta.2 → 7.0.0-beta.4
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/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +4 -0
- package/AdapterDayjs/AdapterDayjs.d.ts +1 -0
- package/AdapterDayjs/AdapterDayjs.js +6 -0
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -0
- package/AdapterLuxon/AdapterLuxon.js +6 -0
- package/AdapterMoment/AdapterMoment.d.ts +1 -0
- package/AdapterMoment/AdapterMoment.js +4 -0
- package/AdapterMomentHijri/AdapterMomentHijri.js +3 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +3 -0
- package/CHANGELOG.md +298 -23
- package/DateCalendar/DateCalendar.js +3 -1
- package/DateCalendar/DateCalendar.types.d.ts +3 -0
- package/DateCalendar/DayCalendar.d.ts +3 -1
- package/DateCalendar/DayCalendar.js +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +3 -0
- package/DateCalendar/PickersSlideTransition.d.ts +3 -0
- package/DateField/DateField.d.ts +1 -1
- package/DateField/DateField.js +11 -9
- package/DateField/DateField.types.d.ts +12 -15
- package/DateField/index.d.ts +1 -1
- package/DateField/useDateField.d.ts +2 -2
- package/DateField/useDateField.js +1 -15
- package/DatePicker/DatePicker.d.ts +1 -1
- package/DatePicker/DatePicker.js +9 -9
- package/DatePicker/DatePicker.types.d.ts +3 -3
- package/DatePicker/DatePickerToolbar.d.ts +5 -4
- package/DatePicker/DatePickerToolbar.js +11 -3
- package/DateTimeField/DateTimeField.d.ts +1 -1
- package/DateTimeField/DateTimeField.js +11 -9
- package/DateTimeField/DateTimeField.types.d.ts +12 -15
- package/DateTimeField/index.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +2 -2
- package/DateTimeField/useDateTimeField.js +1 -20
- package/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +9 -9
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -2
- package/DateTimePicker/DateTimePickerTabs.js +7 -1
- package/DateTimePicker/DateTimePickerToolbar.d.ts +2 -2
- package/DateTimePicker/DateTimePickerToolbar.js +3 -0
- package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +9 -9
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -9
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +3 -3
- package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.js +9 -8
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +3 -3
- package/LocalizationProvider/LocalizationProvider.js +1 -0
- package/MobileDatePicker/MobileDatePicker.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.js +9 -9
- package/MobileDatePicker/MobileDatePicker.types.d.ts +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +9 -9
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.d.ts +2 -2
- package/MobileTimePicker/MobileTimePicker.js +9 -8
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/PickersLayout/PickersLayout.js +6 -0
- package/PickersLayout/PickersLayout.types.d.ts +6 -0
- package/PickersSectionList/PickersSectionList.d.ts +4 -4
- package/PickersSectionList/PickersSectionList.js +1 -2
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +3 -3
- package/PickersTextField/PickersInput/PickersInput.js +3 -3
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +11 -5
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +3 -3
- package/PickersTextField/PickersTextField.d.ts +1 -1
- package/PickersTextField/PickersTextField.js +9 -5
- package/StaticDatePicker/StaticDatePicker.js +0 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/TimeField/TimeField.d.ts +1 -1
- package/TimeField/TimeField.js +11 -9
- package/TimeField/TimeField.types.d.ts +12 -15
- package/TimeField/index.d.ts +1 -1
- package/TimeField/useTimeField.d.ts +2 -2
- package/TimeField/useTimeField.js +1 -13
- package/TimePicker/TimePicker.d.ts +1 -1
- package/TimePicker/TimePicker.js +9 -8
- package/TimePicker/TimePicker.types.d.ts +3 -3
- package/TimePicker/TimePickerToolbar.d.ts +5 -4
- package/TimePicker/TimePickerToolbar.js +11 -3
- package/hooks/index.d.ts +1 -1
- package/hooks/useClearableField.d.ts +10 -2
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +3 -0
- package/internals/components/PickersPopper.d.ts +3 -0
- package/internals/components/PickersPopper.js +1 -2
- package/internals/demo/DemoContainer.js +6 -5
- package/internals/hooks/defaultizedFieldProps.d.ts +19 -0
- package/internals/hooks/defaultizedFieldProps.js +43 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +13 -5
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -13
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +16 -0
- package/internals/hooks/useField/buildSectionsFromFormat.js +251 -0
- package/internals/hooks/useField/index.d.ts +2 -2
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +4 -4
- package/internals/hooks/useField/useField.js +82 -309
- package/internals/hooks/useField/useField.types.d.ts +92 -56
- package/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/internals/hooks/useField/useField.utils.js +78 -228
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +7 -6
- package/internals/hooks/useField/useFieldCharacterEditing.js +6 -6
- package/internals/hooks/useField/useFieldState.d.ts +13 -11
- package/internals/hooks/useField/useFieldState.js +45 -61
- package/internals/hooks/useField/useFieldV6TextField.d.ts +25 -0
- package/internals/hooks/useField/useFieldV6TextField.js +324 -0
- package/internals/hooks/useField/useFieldV7TextField.d.ts +2 -0
- package/internals/hooks/useField/useFieldV7TextField.js +402 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +13 -5
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +12 -12
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +3 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -18
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +5 -6
- package/internals/hooks/usePicker/usePickerViews.d.ts +4 -4
- package/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +1 -0
- package/internals/index.d.ts +5 -4
- package/internals/index.js +2 -1
- package/internals/models/fields.d.ts +2 -4
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/basePickerProps.d.ts +2 -7
- package/internals/models/props/tabs.d.ts +6 -0
- package/internals/models/props/toolbar.d.ts +3 -0
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +1 -1
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +21 -3
- package/internals/utils/fields.js +1 -1
- package/internals/utils/valueManagers.js +5 -4
- package/locales/beBY.d.ts +9 -0
- package/locales/beBY.js +13 -0
- package/locales/caES.d.ts +9 -0
- package/locales/caES.js +13 -0
- package/locales/csCZ.d.ts +9 -0
- package/locales/csCZ.js +13 -0
- package/locales/daDK.d.ts +9 -0
- package/locales/daDK.js +13 -0
- package/locales/deDE.d.ts +9 -0
- package/locales/deDE.js +13 -0
- package/locales/elGR.d.ts +9 -0
- package/locales/elGR.js +13 -0
- package/locales/enUS.d.ts +9 -0
- package/locales/enUS.js +12 -1
- package/locales/esES.d.ts +9 -0
- package/locales/esES.js +13 -0
- package/locales/eu.d.ts +9 -0
- package/locales/eu.js +13 -0
- package/locales/faIR.d.ts +9 -0
- package/locales/faIR.js +13 -0
- package/locales/fiFI.d.ts +9 -0
- package/locales/fiFI.js +13 -0
- package/locales/frFR.d.ts +9 -0
- package/locales/frFR.js +13 -0
- package/locales/heIL.d.ts +9 -0
- package/locales/heIL.js +13 -0
- package/locales/huHU.d.ts +9 -0
- package/locales/huHU.js +13 -0
- package/locales/isIS.d.ts +9 -0
- package/locales/isIS.js +13 -0
- package/locales/itIT.d.ts +9 -0
- package/locales/itIT.js +13 -0
- package/locales/jaJP.d.ts +9 -0
- package/locales/jaJP.js +13 -0
- package/locales/koKR.d.ts +9 -0
- package/locales/koKR.js +13 -0
- package/locales/kzKZ.d.ts +9 -0
- package/locales/kzKZ.js +13 -0
- package/locales/mk.d.ts +9 -0
- package/locales/mk.js +13 -0
- package/locales/nbNO.d.ts +9 -0
- package/locales/nbNO.js +13 -0
- package/locales/nlNL.d.ts +9 -0
- package/locales/nlNL.js +13 -0
- package/locales/plPL.d.ts +9 -0
- package/locales/plPL.js +13 -0
- package/locales/ptBR.d.ts +9 -0
- package/locales/ptBR.js +13 -0
- package/locales/roRO.d.ts +9 -0
- package/locales/roRO.js +13 -0
- package/locales/ruRU.d.ts +9 -0
- package/locales/ruRU.js +13 -0
- package/locales/skSK.d.ts +9 -0
- package/locales/skSK.js +13 -0
- package/locales/svSE.d.ts +9 -0
- package/locales/svSE.js +13 -0
- package/locales/trTR.d.ts +9 -0
- package/locales/trTR.js +13 -0
- package/locales/ukUA.d.ts +9 -0
- package/locales/ukUA.js +13 -0
- package/locales/urPK.d.ts +9 -0
- package/locales/urPK.js +13 -0
- package/locales/utils/getPickersLocalization.d.ts +9 -0
- package/locales/utils/pickersLocaleTextApi.d.ts +9 -0
- package/locales/viVN.d.ts +9 -0
- package/locales/viVN.js +13 -0
- package/locales/zhCN.d.ts +9 -0
- package/locales/zhCN.js +13 -0
- package/locales/zhHK.d.ts +9 -0
- package/locales/zhHK.js +13 -0
- package/models/adapters.d.ts +13 -0
- package/models/fields.d.ts +47 -32
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -0
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +4 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +6 -0
- package/modern/AdapterLuxon/AdapterLuxon.js +6 -0
- package/modern/AdapterMoment/AdapterMoment.js +4 -0
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +3 -0
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +3 -0
- package/modern/DateCalendar/DateCalendar.js +3 -1
- package/modern/DateCalendar/DayCalendar.js +1 -1
- package/modern/DateField/DateField.js +11 -9
- package/modern/DateField/useDateField.js +1 -14
- package/modern/DatePicker/DatePicker.js +9 -9
- package/modern/DatePicker/DatePickerToolbar.js +11 -3
- package/modern/DateTimeField/DateTimeField.js +11 -9
- package/modern/DateTimeField/useDateTimeField.js +1 -19
- package/modern/DateTimePicker/DateTimePicker.js +9 -9
- package/modern/DateTimePicker/DateTimePickerTabs.js +7 -1
- package/modern/DateTimePicker/DateTimePickerToolbar.js +3 -0
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -9
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -9
- package/modern/DesktopTimePicker/DesktopTimePicker.js +9 -8
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +9 -9
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +9 -9
- package/modern/MobileTimePicker/MobileTimePicker.js +9 -8
- package/modern/PickersLayout/PickersLayout.js +6 -0
- package/modern/PickersSectionList/PickersSectionList.js +1 -2
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +3 -3
- package/modern/PickersTextField/PickersInput/PickersInput.js +3 -3
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +11 -5
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +3 -3
- package/modern/PickersTextField/PickersTextField.js +9 -5
- package/modern/StaticDatePicker/StaticDatePicker.js +0 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/modern/TimeField/TimeField.js +11 -9
- package/modern/TimeField/useTimeField.js +1 -12
- package/modern/TimePicker/TimePicker.js +9 -8
- package/modern/TimePicker/TimePickerToolbar.js +11 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +1 -2
- package/modern/internals/demo/DemoContainer.js +6 -5
- package/modern/internals/hooks/defaultizedFieldProps.js +40 -0
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +13 -5
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +251 -0
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +82 -303
- package/modern/internals/hooks/useField/useField.utils.js +78 -228
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +6 -6
- package/modern/internals/hooks/useField/useFieldState.js +45 -61
- package/modern/internals/hooks/useField/useFieldV6TextField.js +318 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +400 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +13 -5
- package/modern/internals/hooks/usePicker/usePicker.js +3 -3
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -18
- package/modern/internals/hooks/usePicker/usePickerViews.js +4 -6
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -0
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +21 -3
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/valueManagers.js +5 -4
- package/modern/locales/beBY.js +13 -0
- package/modern/locales/caES.js +13 -0
- package/modern/locales/csCZ.js +13 -0
- package/modern/locales/daDK.js +13 -0
- package/modern/locales/deDE.js +13 -0
- package/modern/locales/elGR.js +13 -0
- package/modern/locales/enUS.js +12 -1
- package/modern/locales/esES.js +13 -0
- package/modern/locales/eu.js +13 -0
- package/modern/locales/faIR.js +13 -0
- package/modern/locales/fiFI.js +13 -0
- package/modern/locales/frFR.js +13 -0
- package/modern/locales/heIL.js +13 -0
- package/modern/locales/huHU.js +13 -0
- package/modern/locales/isIS.js +13 -0
- package/modern/locales/itIT.js +13 -0
- package/modern/locales/jaJP.js +13 -0
- package/modern/locales/koKR.js +13 -0
- package/modern/locales/kzKZ.js +13 -0
- package/modern/locales/mk.js +13 -0
- package/modern/locales/nbNO.js +13 -0
- package/modern/locales/nlNL.js +13 -0
- package/modern/locales/plPL.js +13 -0
- package/modern/locales/ptBR.js +13 -0
- package/modern/locales/roRO.js +13 -0
- package/modern/locales/ruRU.js +13 -0
- package/modern/locales/skSK.js +13 -0
- package/modern/locales/svSE.js +13 -0
- package/modern/locales/trTR.js +13 -0
- package/modern/locales/ukUA.js +13 -0
- package/modern/locales/urPK.js +13 -0
- package/modern/locales/viVN.js +13 -0
- package/modern/locales/zhCN.js +13 -0
- package/modern/locales/zhHK.js +13 -0
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -0
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +4 -0
- package/node/AdapterDayjs/AdapterDayjs.js +6 -0
- package/node/AdapterLuxon/AdapterLuxon.js +6 -0
- package/node/AdapterMoment/AdapterMoment.js +4 -0
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +3 -0
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +3 -0
- package/node/DateCalendar/DateCalendar.js +3 -1
- package/node/DateCalendar/DayCalendar.js +1 -1
- package/node/DateField/DateField.js +11 -9
- package/node/DateField/useDateField.js +2 -16
- package/node/DatePicker/DatePicker.js +9 -9
- package/node/DatePicker/DatePickerToolbar.js +11 -3
- package/node/DateTimeField/DateTimeField.js +11 -9
- package/node/DateTimeField/useDateTimeField.js +2 -21
- package/node/DateTimePicker/DateTimePicker.js +9 -9
- package/node/DateTimePicker/DateTimePickerTabs.js +7 -1
- package/node/DateTimePicker/DateTimePickerToolbar.js +3 -0
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -9
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -9
- package/node/DesktopTimePicker/DesktopTimePicker.js +9 -8
- package/node/LocalizationProvider/LocalizationProvider.js +1 -0
- package/node/MobileDatePicker/MobileDatePicker.js +9 -9
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +9 -9
- package/node/MobileTimePicker/MobileTimePicker.js +9 -8
- package/node/PickersLayout/PickersLayout.js +6 -0
- package/node/PickersSectionList/PickersSectionList.js +4 -5
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +3 -3
- package/node/PickersTextField/PickersInput/PickersInput.js +3 -3
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +11 -5
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +3 -3
- package/node/PickersTextField/PickersTextField.js +9 -5
- package/node/StaticDatePicker/StaticDatePicker.js +0 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/node/TimeField/TimeField.js +11 -9
- package/node/TimeField/useTimeField.js +2 -14
- package/node/TimePicker/TimePicker.js +9 -8
- package/node/TimePicker/TimePickerToolbar.js +11 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +1 -2
- package/node/internals/demo/DemoContainer.js +6 -5
- package/node/internals/hooks/defaultizedFieldProps.js +50 -0
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +13 -5
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +259 -0
- package/node/internals/hooks/useField/index.js +4 -10
- package/node/internals/hooks/useField/useField.js +81 -302
- package/node/internals/hooks/useField/useField.utils.js +86 -236
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +6 -6
- package/node/internals/hooks/useField/useFieldState.js +44 -60
- package/node/internals/hooks/useField/useFieldV6TextField.js +329 -0
- package/node/internals/hooks/useField/useFieldV7TextField.js +410 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +13 -5
- package/node/internals/hooks/usePicker/usePicker.js +3 -3
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -18
- package/node/internals/hooks/usePicker/usePickerViews.js +4 -6
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -0
- package/node/internals/index.js +27 -8
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +21 -3
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/valueManagers.js +4 -3
- package/node/locales/beBY.js +13 -0
- package/node/locales/caES.js +13 -0
- package/node/locales/csCZ.js +13 -0
- package/node/locales/daDK.js +13 -0
- package/node/locales/deDE.js +13 -0
- package/node/locales/elGR.js +13 -0
- package/node/locales/enUS.js +12 -1
- package/node/locales/esES.js +13 -0
- package/node/locales/eu.js +13 -0
- package/node/locales/faIR.js +13 -0
- package/node/locales/fiFI.js +13 -0
- package/node/locales/frFR.js +13 -0
- package/node/locales/heIL.js +13 -0
- package/node/locales/huHU.js +13 -0
- package/node/locales/isIS.js +13 -0
- package/node/locales/itIT.js +13 -0
- package/node/locales/jaJP.js +13 -0
- package/node/locales/koKR.js +13 -0
- package/node/locales/kzKZ.js +13 -0
- package/node/locales/mk.js +13 -0
- package/node/locales/nbNO.js +13 -0
- package/node/locales/nlNL.js +13 -0
- package/node/locales/plPL.js +13 -0
- package/node/locales/ptBR.js +13 -0
- package/node/locales/roRO.js +13 -0
- package/node/locales/ruRU.js +13 -0
- package/node/locales/skSK.js +13 -0
- package/node/locales/svSE.js +13 -0
- package/node/locales/trTR.js +13 -0
- package/node/locales/ukUA.js +13 -0
- package/node/locales/urPK.js +13 -0
- package/node/locales/viVN.js +13 -0
- package/node/locales/zhCN.js +13 -0
- package/node/locales/zhHK.js +13 -0
- package/package.json +4 -4
- package/themeAugmentation/props.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.d.ts +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +0 -298
- package/legacy/AdapterDateFns/index.js +0 -1
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +0 -293
- package/legacy/AdapterDateFnsBase/index.js +0 -1
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +0 -547
- package/legacy/AdapterDateFnsJalali/index.js +0 -1
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -306
- package/legacy/AdapterDateFnsV3/index.js +0 -1
- package/legacy/AdapterDayjs/AdapterDayjs.js +0 -568
- package/legacy/AdapterDayjs/index.js +0 -1
- package/legacy/AdapterLuxon/AdapterLuxon.js +0 -508
- package/legacy/AdapterLuxon/index.js +0 -1
- package/legacy/AdapterMoment/AdapterMoment.js +0 -481
- package/legacy/AdapterMoment/index.js +0 -1
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +0 -238
- package/legacy/AdapterMomentHijri/index.js +0 -1
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -235
- package/legacy/AdapterMomentJalaali/index.js +0 -1
- package/legacy/DateCalendar/DateCalendar.js +0 -573
- package/legacy/DateCalendar/DateCalendar.types.js +0 -1
- package/legacy/DateCalendar/DayCalendar.js +0 -515
- package/legacy/DateCalendar/PickersFadeTransitionGroup.js +0 -58
- package/legacy/DateCalendar/PickersSlideTransition.js +0 -118
- package/legacy/DateCalendar/dateCalendarClasses.js +0 -5
- package/legacy/DateCalendar/dayCalendarClasses.js +0 -5
- package/legacy/DateCalendar/index.js +0 -5
- package/legacy/DateCalendar/pickersFadeTransitionGroupClasses.js +0 -5
- package/legacy/DateCalendar/pickersSlideTransitionClasses.js +0 -5
- package/legacy/DateCalendar/useCalendarState.js +0 -124
- package/legacy/DateCalendar/useIsDateDisabled.js +0 -30
- package/legacy/DateField/DateField.js +0 -319
- package/legacy/DateField/DateField.types.js +0 -1
- package/legacy/DateField/index.js +0 -2
- package/legacy/DateField/useDateField.js +0 -33
- package/legacy/DatePicker/DatePicker.js +0 -353
- package/legacy/DatePicker/DatePicker.types.js +0 -1
- package/legacy/DatePicker/DatePickerToolbar.js +0 -132
- package/legacy/DatePicker/datePickerToolbarClasses.js +0 -5
- package/legacy/DatePicker/index.js +0 -3
- package/legacy/DatePicker/shared.js +0 -41
- package/legacy/DateTimeField/DateTimeField.js +0 -360
- package/legacy/DateTimeField/DateTimeField.types.js +0 -1
- package/legacy/DateTimeField/index.js +0 -2
- package/legacy/DateTimeField/useDateTimeField.js +0 -38
- package/legacy/DateTimePicker/DateTimePicker.js +0 -424
- package/legacy/DateTimePicker/DateTimePicker.types.js +0 -1
- package/legacy/DateTimePicker/DateTimePickerTabs.js +0 -142
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +0 -385
- package/legacy/DateTimePicker/dateTimePickerTabsClasses.js +0 -5
- package/legacy/DateTimePicker/dateTimePickerToolbarClasses.js +0 -5
- package/legacy/DateTimePicker/index.js +0 -5
- package/legacy/DateTimePicker/shared.js +0 -56
- package/legacy/DayCalendarSkeleton/DayCalendarSkeleton.js +0 -119
- package/legacy/DayCalendarSkeleton/dayCalendarSkeletonClasses.js +0 -5
- package/legacy/DayCalendarSkeleton/index.js +0 -2
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +0 -372
- package/legacy/DesktopDatePicker/DesktopDatePicker.types.js +0 -1
- package/legacy/DesktopDatePicker/index.js +0 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -480
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.types.js +0 -1
- package/legacy/DesktopDateTimePicker/index.js +0 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +0 -355
- package/legacy/DesktopTimePicker/DesktopTimePicker.types.js +0 -1
- package/legacy/DesktopTimePicker/index.js +0 -1
- package/legacy/DigitalClock/DigitalClock.js +0 -443
- package/legacy/DigitalClock/DigitalClock.types.js +0 -1
- package/legacy/DigitalClock/digitalClockClasses.js +0 -6
- package/legacy/DigitalClock/index.js +0 -2
- package/legacy/LocalizationProvider/LocalizationProvider.js +0 -140
- package/legacy/LocalizationProvider/index.js +0 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +0 -369
- package/legacy/MobileDatePicker/MobileDatePicker.types.js +0 -1
- package/legacy/MobileDatePicker/index.js +0 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +0 -428
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.types.js +0 -1
- package/legacy/MobileDateTimePicker/index.js +0 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +0 -311
- package/legacy/MobileTimePicker/MobileTimePicker.types.js +0 -1
- package/legacy/MobileTimePicker/index.js +0 -1
- package/legacy/MonthCalendar/MonthCalendar.js +0 -338
- package/legacy/MonthCalendar/MonthCalendar.types.js +0 -1
- package/legacy/MonthCalendar/PickersMonth.js +0 -135
- package/legacy/MonthCalendar/index.js +0 -3
- package/legacy/MonthCalendar/monthCalendarClasses.js +0 -5
- package/legacy/MonthCalendar/pickersMonthClasses.js +0 -5
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +0 -521
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.types.js +0 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +0 -76
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +0 -173
- package/legacy/MultiSectionDigitalClock/index.js +0 -3
- package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockClasses.js +0 -6
- package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +0 -6
- package/legacy/PickersActionBar/PickersActionBar.js +0 -86
- package/legacy/PickersActionBar/index.js +0 -1
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +0 -284
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.types.js +0 -1
- package/legacy/PickersCalendarHeader/index.js +0 -2
- package/legacy/PickersCalendarHeader/pickersCalendarHeaderClasses.js +0 -5
- package/legacy/PickersDay/PickersDay.js +0 -367
- package/legacy/PickersDay/index.js +0 -2
- package/legacy/PickersDay/pickersDayClasses.js +0 -5
- package/legacy/PickersLayout/PickersLayout.js +0 -159
- package/legacy/PickersLayout/PickersLayout.types.js +0 -1
- package/legacy/PickersLayout/index.js +0 -3
- package/legacy/PickersLayout/pickersLayoutClasses.js +0 -6
- package/legacy/PickersLayout/usePickerLayout.js +0 -134
- package/legacy/PickersSectionList/PickersSectionList.js +0 -235
- package/legacy/PickersSectionList/PickersSectionList.types.js +0 -1
- package/legacy/PickersSectionList/index.js +0 -2
- package/legacy/PickersSectionList/pickersSectionListClasses.js +0 -6
- package/legacy/PickersShortcuts/PickersShortcuts.js +0 -110
- package/legacy/PickersShortcuts/index.js +0 -1
- package/legacy/PickersTextField/PickersFilledInput/PickersFilledInput.js +0 -234
- package/legacy/PickersTextField/PickersFilledInput/index.js +0 -2
- package/legacy/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +0 -8
- package/legacy/PickersTextField/PickersInput/PickersInput.js +0 -190
- package/legacy/PickersTextField/PickersInput/index.js +0 -2
- package/legacy/PickersTextField/PickersInput/pickersInputClasses.js +0 -8
- package/legacy/PickersTextField/PickersInputBase/PickersInputBase.js +0 -340
- package/legacy/PickersTextField/PickersInputBase/PickersInputBase.types.js +0 -1
- package/legacy/PickersTextField/PickersInputBase/index.js +0 -2
- package/legacy/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +0 -6
- package/legacy/PickersTextField/PickersOutlinedInput/Outline.js +0 -121
- package/legacy/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +0 -183
- package/legacy/PickersTextField/PickersOutlinedInput/index.js +0 -2
- package/legacy/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +0 -8
- package/legacy/PickersTextField/PickersTextField.js +0 -258
- package/legacy/PickersTextField/PickersTextField.types.js +0 -1
- package/legacy/PickersTextField/index.js +0 -6
- package/legacy/PickersTextField/pickersTextFieldClasses.js +0 -6
- package/legacy/StaticDatePicker/StaticDatePicker.js +0 -297
- package/legacy/StaticDatePicker/StaticDatePicker.types.js +0 -1
- package/legacy/StaticDatePicker/index.js +0 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +0 -356
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.types.js +0 -1
- package/legacy/StaticDateTimePicker/index.js +0 -1
- package/legacy/StaticTimePicker/StaticTimePicker.js +0 -238
- package/legacy/StaticTimePicker/StaticTimePicker.types.js +0 -1
- package/legacy/StaticTimePicker/index.js +0 -1
- package/legacy/TimeClock/Clock.js +0 -358
- package/legacy/TimeClock/ClockNumber.js +0 -87
- package/legacy/TimeClock/ClockNumbers.js +0 -73
- package/legacy/TimeClock/ClockPointer.js +0 -106
- package/legacy/TimeClock/TimeClock.js +0 -481
- package/legacy/TimeClock/TimeClock.types.js +0 -1
- package/legacy/TimeClock/clockClasses.js +0 -5
- package/legacy/TimeClock/clockNumberClasses.js +0 -5
- package/legacy/TimeClock/clockPointerClasses.js +0 -5
- package/legacy/TimeClock/index.js +0 -5
- package/legacy/TimeClock/shared.js +0 -53
- package/legacy/TimeClock/timeClockClasses.js +0 -5
- package/legacy/TimeField/TimeField.js +0 -320
- package/legacy/TimeField/TimeField.types.js +0 -1
- package/legacy/TimeField/index.js +0 -2
- package/legacy/TimeField/useTimeField.js +0 -31
- package/legacy/TimePicker/TimePicker.js +0 -314
- package/legacy/TimePicker/TimePicker.types.js +0 -1
- package/legacy/TimePicker/TimePickerToolbar.js +0 -260
- package/legacy/TimePicker/index.js +0 -3
- package/legacy/TimePicker/shared.js +0 -45
- package/legacy/TimePicker/timePickerToolbarClasses.js +0 -5
- package/legacy/YearCalendar/PickersYear.js +0 -137
- package/legacy/YearCalendar/YearCalendar.js +0 -362
- package/legacy/YearCalendar/YearCalendar.types.js +0 -1
- package/legacy/YearCalendar/index.js +0 -3
- package/legacy/YearCalendar/pickersYearClasses.js +0 -5
- package/legacy/YearCalendar/yearCalendarClasses.js +0 -5
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -162
- package/legacy/dateTimeViewRenderers/index.js +0 -1
- package/legacy/dateViewRenderers/dateViewRenderers.js +0 -82
- package/legacy/dateViewRenderers/index.js +0 -1
- package/legacy/hooks/index.js +0 -1
- package/legacy/hooks/useClearableField.js +0 -76
- package/legacy/icons/index.js +0 -68
- package/legacy/index.js +0 -59
- package/legacy/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +0 -5
- package/legacy/internals/components/DateTimeViewWrapper/index.js +0 -1
- package/legacy/internals/components/PickerViewRoot/PickerViewRoot.js +0 -10
- package/legacy/internals/components/PickerViewRoot/index.js +0 -1
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +0 -170
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.js +0 -1
- package/legacy/internals/components/PickersArrowSwitcher/index.js +0 -2
- package/legacy/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js +0 -5
- package/legacy/internals/components/PickersModalDialog.js +0 -42
- package/legacy/internals/components/PickersPopper.js +0 -325
- package/legacy/internals/components/PickersToolbar.js +0 -92
- package/legacy/internals/components/PickersToolbarButton.js +0 -61
- package/legacy/internals/components/PickersToolbarText.js +0 -52
- package/legacy/internals/components/pickersPopperClasses.js +0 -5
- package/legacy/internals/components/pickersToolbarButtonClasses.js +0 -5
- package/legacy/internals/components/pickersToolbarClasses.js +0 -5
- package/legacy/internals/components/pickersToolbarTextClasses.js +0 -5
- package/legacy/internals/constants/dimensions.js +0 -7
- package/legacy/internals/demo/DemoContainer.js +0 -163
- package/legacy/internals/demo/index.js +0 -1
- package/legacy/internals/hooks/date-helpers-hooks.js +0 -37
- package/legacy/internals/hooks/useClockReferenceDate.js +0 -28
- package/legacy/internals/hooks/useDefaultReduceAnimations.js +0 -14
- package/legacy/internals/hooks/useDesktopPicker/index.js +0 -1
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +0 -174
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.types.js +0 -1
- package/legacy/internals/hooks/useField/index.js +0 -2
- package/legacy/internals/hooks/useField/useField.js +0 -470
- package/legacy/internals/hooks/useField/useField.types.js +0 -1
- package/legacy/internals/hooks/useField/useField.utils.js +0 -828
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +0 -277
- package/legacy/internals/hooks/useField/useFieldState.js +0 -321
- package/legacy/internals/hooks/useIsLandscape.js +0 -39
- package/legacy/internals/hooks/useMobilePicker/index.js +0 -1
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +0 -126
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.types.js +0 -1
- package/legacy/internals/hooks/useOpenState.js +0 -38
- package/legacy/internals/hooks/usePicker/index.js +0 -1
- package/legacy/internals/hooks/usePicker/usePicker.js +0 -54
- package/legacy/internals/hooks/usePicker/usePicker.types.js +0 -1
- package/legacy/internals/hooks/usePicker/usePickerLayoutProps.js +0 -28
- package/legacy/internals/hooks/usePicker/usePickerValue.js +0 -365
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/legacy/internals/hooks/usePicker/usePickerViews.js +0 -172
- package/legacy/internals/hooks/useStaticPicker/index.js +0 -1
- package/legacy/internals/hooks/useStaticPicker/useStaticPicker.js +0 -66
- package/legacy/internals/hooks/useStaticPicker/useStaticPicker.types.js +0 -1
- package/legacy/internals/hooks/useUtils.js +0 -38
- package/legacy/internals/hooks/useValidation.js +0 -20
- package/legacy/internals/hooks/useValueWithTimezone.js +0 -81
- package/legacy/internals/hooks/useViews.js +0 -124
- package/legacy/internals/index.js +0 -35
- package/legacy/internals/models/common.js +0 -1
- package/legacy/internals/models/fields.js +0 -1
- package/legacy/internals/models/helpers.js +0 -1
- package/legacy/internals/models/index.js +0 -2
- package/legacy/internals/models/props/basePickerProps.js +0 -1
- package/legacy/internals/models/props/clock.js +0 -1
- package/legacy/internals/models/props/tabs.js +0 -1
- package/legacy/internals/models/props/toolbar.js +0 -1
- package/legacy/internals/models/validation.js +0 -1
- package/legacy/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -24
- package/legacy/internals/utils/date-time-utils.js +0 -71
- package/legacy/internals/utils/date-utils.js +0 -129
- package/legacy/internals/utils/fields.js +0 -28
- package/legacy/internals/utils/getDefaultReferenceDate.js +0 -65
- package/legacy/internals/utils/time-utils.js +0 -63
- package/legacy/internals/utils/utils.js +0 -40
- package/legacy/internals/utils/validation/extractValidationProps.js +0 -16
- package/legacy/internals/utils/validation/validateDate.js +0 -38
- package/legacy/internals/utils/validation/validateDateTime.js +0 -20
- package/legacy/internals/utils/validation/validateTime.js +0 -42
- package/legacy/internals/utils/valueManagers.js +0 -67
- package/legacy/internals/utils/views.js +0 -29
- package/legacy/internals/utils/warning.js +0 -39
- package/legacy/locales/beBY.js +0 -99
- package/legacy/locales/caES.js +0 -100
- package/legacy/locales/csCZ.js +0 -100
- package/legacy/locales/daDK.js +0 -102
- package/legacy/locales/deDE.js +0 -101
- package/legacy/locales/elGR.js +0 -100
- package/legacy/locales/enUS.js +0 -96
- package/legacy/locales/esES.js +0 -99
- package/legacy/locales/eu.js +0 -99
- package/legacy/locales/faIR.js +0 -100
- package/legacy/locales/fiFI.js +0 -100
- package/legacy/locales/frFR.js +0 -98
- package/legacy/locales/heIL.js +0 -100
- package/legacy/locales/huHU.js +0 -99
- package/legacy/locales/index.js +0 -35
- package/legacy/locales/isIS.js +0 -100
- package/legacy/locales/itIT.js +0 -98
- package/legacy/locales/jaJP.js +0 -102
- package/legacy/locales/koKR.js +0 -98
- package/legacy/locales/kzKZ.js +0 -99
- package/legacy/locales/mk.js +0 -96
- package/legacy/locales/nbNO.js +0 -100
- package/legacy/locales/nlNL.js +0 -100
- package/legacy/locales/plPL.js +0 -85
- package/legacy/locales/ptBR.js +0 -100
- package/legacy/locales/roRO.js +0 -99
- package/legacy/locales/ruRU.js +0 -98
- package/legacy/locales/skSK.js +0 -100
- package/legacy/locales/svSE.js +0 -85
- package/legacy/locales/trTR.js +0 -100
- package/legacy/locales/ukUA.js +0 -100
- package/legacy/locales/urPK.js +0 -85
- package/legacy/locales/utils/getPickersLocalization.js +0 -12
- package/legacy/locales/utils/pickersLocaleTextApi.js +0 -1
- package/legacy/locales/viVN.js +0 -100
- package/legacy/locales/zhCN.js +0 -100
- package/legacy/locales/zhHK.js +0 -100
- package/legacy/models/adapters.js +0 -1
- package/legacy/models/common.js +0 -1
- package/legacy/models/fields.js +0 -1
- package/legacy/models/index.js +0 -7
- package/legacy/models/pickers.js +0 -1
- package/legacy/models/timezone.js +0 -1
- package/legacy/models/validation.js +0 -1
- package/legacy/models/views.js +0 -1
- package/legacy/themeAugmentation/index.js +0 -3
- package/legacy/timeViewRenderers/index.js +0 -1
- package/legacy/timeViewRenderers/timeViewRenderers.js +0 -186
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.validateSections = exports.
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
6
|
+
exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionValueText = exports.getSectionValueNow = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForV7HiddenInputFromSections = exports.createDateStrForV6InputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.adjustSectionValue = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
|
|
9
7
|
var _dateUtils = require("../../utils/date-utils");
|
|
10
8
|
const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
11
9
|
const config = utils.formatTokenMap[formatToken];
|
|
@@ -243,95 +241,6 @@ const getSectionVisibleValue = (section, target, localizedDigits) => {
|
|
|
243
241
|
return value;
|
|
244
242
|
};
|
|
245
243
|
exports.getSectionVisibleValue = getSectionVisibleValue;
|
|
246
|
-
const cleanString = dirtyString => dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, '');
|
|
247
|
-
exports.cleanString = cleanString;
|
|
248
|
-
const addPositionPropertiesToSections = (sections, localizedDigits, isRTL) => {
|
|
249
|
-
let position = 0;
|
|
250
|
-
let positionInInput = isRTL ? 1 : 0;
|
|
251
|
-
const newSections = [];
|
|
252
|
-
for (let i = 0; i < sections.length; i += 1) {
|
|
253
|
-
const section = sections[i];
|
|
254
|
-
const renderedValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr', localizedDigits);
|
|
255
|
-
const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;
|
|
256
|
-
const sectionLength = cleanString(sectionStr).length;
|
|
257
|
-
const sectionLengthInInput = sectionStr.length;
|
|
258
|
-
|
|
259
|
-
// The ...InInput values consider the unicode characters but do include them in their indexes
|
|
260
|
-
const cleanedValue = cleanString(renderedValue);
|
|
261
|
-
const startInInput = positionInInput + (cleanedValue === '' ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;
|
|
262
|
-
const endInInput = startInInput + cleanedValue.length;
|
|
263
|
-
newSections.push((0, _extends2.default)({}, section, {
|
|
264
|
-
start: position,
|
|
265
|
-
end: position + sectionLength,
|
|
266
|
-
startInInput,
|
|
267
|
-
endInInput
|
|
268
|
-
}));
|
|
269
|
-
position += sectionLength;
|
|
270
|
-
// Move position to the end of string associated to the current section
|
|
271
|
-
positionInInput += sectionLengthInInput;
|
|
272
|
-
}
|
|
273
|
-
return newSections;
|
|
274
|
-
};
|
|
275
|
-
exports.addPositionPropertiesToSections = addPositionPropertiesToSections;
|
|
276
|
-
const getSectionPlaceholder = (utils, timezone, localeText, sectionConfig, sectionFormat) => {
|
|
277
|
-
switch (sectionConfig.type) {
|
|
278
|
-
case 'year':
|
|
279
|
-
{
|
|
280
|
-
return localeText.fieldYearPlaceholder({
|
|
281
|
-
digitAmount: utils.formatByString(utils.date(undefined, timezone), sectionFormat).length,
|
|
282
|
-
format: sectionFormat
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
case 'month':
|
|
286
|
-
{
|
|
287
|
-
return localeText.fieldMonthPlaceholder({
|
|
288
|
-
contentType: sectionConfig.contentType,
|
|
289
|
-
format: sectionFormat
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
case 'day':
|
|
293
|
-
{
|
|
294
|
-
return localeText.fieldDayPlaceholder({
|
|
295
|
-
format: sectionFormat
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
case 'weekDay':
|
|
299
|
-
{
|
|
300
|
-
return localeText.fieldWeekDayPlaceholder({
|
|
301
|
-
contentType: sectionConfig.contentType,
|
|
302
|
-
format: sectionFormat
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
case 'hours':
|
|
306
|
-
{
|
|
307
|
-
return localeText.fieldHoursPlaceholder({
|
|
308
|
-
format: sectionFormat
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
case 'minutes':
|
|
312
|
-
{
|
|
313
|
-
return localeText.fieldMinutesPlaceholder({
|
|
314
|
-
format: sectionFormat
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
case 'seconds':
|
|
318
|
-
{
|
|
319
|
-
return localeText.fieldSecondsPlaceholder({
|
|
320
|
-
format: sectionFormat
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
case 'meridiem':
|
|
324
|
-
{
|
|
325
|
-
return localeText.fieldMeridiemPlaceholder({
|
|
326
|
-
format: sectionFormat
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
default:
|
|
330
|
-
{
|
|
331
|
-
return sectionFormat;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
244
|
const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) => {
|
|
336
245
|
if (process.env.NODE_ENV !== 'production') {
|
|
337
246
|
if (getDateSectionConfigFromFormatToken(utils, currentFormat).type === 'weekDay') {
|
|
@@ -388,149 +297,12 @@ const doesSectionFormatHaveLeadingZeros = (utils, timezone, contentType, section
|
|
|
388
297
|
}
|
|
389
298
|
}
|
|
390
299
|
};
|
|
391
|
-
exports.doesSectionFormatHaveLeadingZeros = doesSectionFormatHaveLeadingZeros;
|
|
392
|
-
const getEscapedPartsFromFormat = (utils, format) => {
|
|
393
|
-
const escapedParts = [];
|
|
394
|
-
const {
|
|
395
|
-
start: startChar,
|
|
396
|
-
end: endChar
|
|
397
|
-
} = utils.escapedCharacters;
|
|
398
|
-
const regExp = new RegExp(`(\\${startChar}[^\\${endChar}]*\\${endChar})+`, 'g');
|
|
399
|
-
let match = null;
|
|
400
|
-
// eslint-disable-next-line no-cond-assign
|
|
401
|
-
while (match = regExp.exec(format)) {
|
|
402
|
-
escapedParts.push({
|
|
403
|
-
start: match.index,
|
|
404
|
-
end: regExp.lastIndex - 1
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
return escapedParts;
|
|
408
|
-
};
|
|
409
|
-
const splitFormatIntoSections = (utils, timezone, localeText, localizedDigits, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
410
|
-
let startSeparator = '';
|
|
411
|
-
const sections = [];
|
|
412
|
-
const now = utils.date();
|
|
413
|
-
const commitToken = token => {
|
|
414
|
-
if (token === '') {
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
418
|
-
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, timezone, sectionConfig.contentType, sectionConfig.type, token);
|
|
419
|
-
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
420
|
-
const isValidDate = date != null && utils.isValid(date);
|
|
421
|
-
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
422
|
-
let maxLength = null;
|
|
423
|
-
if (hasLeadingZerosInInput) {
|
|
424
|
-
if (hasLeadingZerosInFormat) {
|
|
425
|
-
maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
|
|
426
|
-
} else {
|
|
427
|
-
if (sectionConfig.maxLength == null) {
|
|
428
|
-
throw new Error(`MUI X: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
|
|
429
|
-
}
|
|
430
|
-
maxLength = sectionConfig.maxLength;
|
|
431
|
-
if (isValidDate) {
|
|
432
|
-
sectionValue = applyLocalizedDigits(cleanLeadingZeros(removeLocalizedDigits(sectionValue, localizedDigits), maxLength), localizedDigits);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
sections.push((0, _extends2.default)({}, sectionConfig, {
|
|
437
|
-
format: token,
|
|
438
|
-
maxLength,
|
|
439
|
-
value: sectionValue,
|
|
440
|
-
placeholder: getSectionPlaceholder(utils, timezone, localeText, sectionConfig, token),
|
|
441
|
-
hasLeadingZerosInFormat,
|
|
442
|
-
hasLeadingZerosInInput,
|
|
443
|
-
startSeparator: sections.length === 0 ? startSeparator : '',
|
|
444
|
-
endSeparator: '',
|
|
445
|
-
modified: false
|
|
446
|
-
}));
|
|
447
|
-
return null;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
// Expand the provided format
|
|
451
|
-
let formatExpansionOverflow = 10;
|
|
452
|
-
let prevFormat = format;
|
|
453
|
-
let nextFormat = utils.expandFormat(format);
|
|
454
|
-
while (nextFormat !== prevFormat) {
|
|
455
|
-
prevFormat = nextFormat;
|
|
456
|
-
nextFormat = utils.expandFormat(prevFormat);
|
|
457
|
-
formatExpansionOverflow -= 1;
|
|
458
|
-
if (formatExpansionOverflow < 0) {
|
|
459
|
-
throw new Error('MUI X: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component.');
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
const expandedFormat = nextFormat;
|
|
463
|
-
|
|
464
|
-
// Get start/end indexes of escaped sections
|
|
465
|
-
const escapedParts = getEscapedPartsFromFormat(utils, expandedFormat);
|
|
466
|
-
|
|
467
|
-
// This RegExp test if the beginning of a string correspond to a supported token
|
|
468
|
-
const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length) // Sort to put longest word first
|
|
469
|
-
.join('|')})`, 'g') // used to get access to lastIndex state
|
|
470
|
-
;
|
|
471
|
-
let currentTokenValue = '';
|
|
472
|
-
for (let i = 0; i < expandedFormat.length; i += 1) {
|
|
473
|
-
const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
|
|
474
|
-
const char = expandedFormat[i];
|
|
475
|
-
const isEscapedChar = escapedPartOfCurrentChar != null;
|
|
476
|
-
const potentialToken = `${currentTokenValue}${expandedFormat.slice(i)}`;
|
|
477
|
-
const regExpMatch = isTokenStartRegExp.test(potentialToken);
|
|
478
|
-
if (!isEscapedChar && char.match(/([A-Za-z]+)/) && regExpMatch) {
|
|
479
|
-
currentTokenValue = potentialToken.slice(0, isTokenStartRegExp.lastIndex);
|
|
480
|
-
i += isTokenStartRegExp.lastIndex - 1;
|
|
481
|
-
} else {
|
|
482
|
-
// If we are on the opening or closing character of an escaped part of the format,
|
|
483
|
-
// Then we ignore this character.
|
|
484
|
-
const isEscapeBoundary = isEscapedChar && escapedPartOfCurrentChar?.start === i || escapedPartOfCurrentChar?.end === i;
|
|
485
|
-
if (!isEscapeBoundary) {
|
|
486
|
-
commitToken(currentTokenValue);
|
|
487
|
-
currentTokenValue = '';
|
|
488
|
-
if (sections.length === 0) {
|
|
489
|
-
startSeparator += char;
|
|
490
|
-
} else {
|
|
491
|
-
sections[sections.length - 1].endSeparator += char;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
commitToken(currentTokenValue);
|
|
497
|
-
if (sections.length === 0 && startSeparator.length > 0) {
|
|
498
|
-
sections.push({
|
|
499
|
-
type: 'empty',
|
|
500
|
-
contentType: 'letter',
|
|
501
|
-
maxLength: null,
|
|
502
|
-
format: '',
|
|
503
|
-
value: '',
|
|
504
|
-
placeholder: '',
|
|
505
|
-
hasLeadingZerosInFormat: false,
|
|
506
|
-
hasLeadingZerosInInput: false,
|
|
507
|
-
startSeparator,
|
|
508
|
-
endSeparator: '',
|
|
509
|
-
modified: false
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
return sections.map(section => {
|
|
513
|
-
const cleanSeparator = separator => {
|
|
514
|
-
let cleanedSeparator = separator;
|
|
515
|
-
if (isRTL && cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
516
|
-
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
|
|
517
|
-
}
|
|
518
|
-
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
|
519
|
-
cleanedSeparator = ` ${cleanedSeparator} `;
|
|
520
|
-
}
|
|
521
|
-
return cleanedSeparator;
|
|
522
|
-
};
|
|
523
|
-
section.startSeparator = cleanSeparator(section.startSeparator);
|
|
524
|
-
section.endSeparator = cleanSeparator(section.endSeparator);
|
|
525
|
-
return section;
|
|
526
|
-
});
|
|
527
|
-
};
|
|
528
300
|
|
|
529
301
|
/**
|
|
530
302
|
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
|
531
303
|
* To make sure that the parsing works, we are building a format and a date without any separator.
|
|
532
304
|
*/
|
|
533
|
-
exports.
|
|
305
|
+
exports.doesSectionFormatHaveLeadingZeros = doesSectionFormatHaveLeadingZeros;
|
|
534
306
|
const getDateFromDateSections = (utils, sections, localizedDigits) => {
|
|
535
307
|
// If we have both a day and a weekDay section,
|
|
536
308
|
// Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.
|
|
@@ -551,7 +323,11 @@ const getDateFromDateSections = (utils, sections, localizedDigits) => {
|
|
|
551
323
|
return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
|
|
552
324
|
};
|
|
553
325
|
exports.getDateFromDateSections = getDateFromDateSections;
|
|
554
|
-
const
|
|
326
|
+
const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
|
|
327
|
+
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
|
|
328
|
+
}).join('');
|
|
329
|
+
exports.createDateStrForV7HiddenInputFromSections = createDateStrForV7HiddenInputFromSections;
|
|
330
|
+
const createDateStrForV6InputFromSections = (sections, localizedDigits, isRTL) => {
|
|
555
331
|
const formattedSections = sections.map(section => {
|
|
556
332
|
const dateValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr', localizedDigits);
|
|
557
333
|
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
|
|
@@ -568,7 +344,7 @@ const createDateStrForInputFromSections = (sections, localizedDigits, isRTL) =>
|
|
|
568
344
|
// wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
|
|
569
345
|
return `\u2066${dateStr}\u2069`;
|
|
570
346
|
};
|
|
571
|
-
exports.
|
|
347
|
+
exports.createDateStrForV6InputFromSections = createDateStrForV6InputFromSections;
|
|
572
348
|
const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
573
349
|
const today = utils.date(undefined, timezone);
|
|
574
350
|
const endOfYear = utils.endOfYear(today);
|
|
@@ -652,7 +428,7 @@ const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
652
428
|
}),
|
|
653
429
|
meridiem: () => ({
|
|
654
430
|
minimum: 0,
|
|
655
|
-
maximum:
|
|
431
|
+
maximum: 1
|
|
656
432
|
}),
|
|
657
433
|
empty: () => ({
|
|
658
434
|
minimum: 0,
|
|
@@ -755,10 +531,12 @@ const mergeDateIntoReferenceDate = (utils, timezone, dateToTransferFrom, section
|
|
|
755
531
|
}, referenceDate);
|
|
756
532
|
exports.mergeDateIntoReferenceDate = mergeDateIntoReferenceDate;
|
|
757
533
|
const isAndroid = () => navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
534
|
+
|
|
535
|
+
// TODO v8: Remove if we drop the v6 TextField approach.
|
|
758
536
|
exports.isAndroid = isAndroid;
|
|
759
|
-
const getSectionOrder = (sections,
|
|
537
|
+
const getSectionOrder = (sections, shouldApplyRTL) => {
|
|
760
538
|
const neighbors = {};
|
|
761
|
-
if (!
|
|
539
|
+
if (!shouldApplyRTL) {
|
|
762
540
|
sections.forEach((_, index) => {
|
|
763
541
|
const leftIndex = index === 0 ? null : index - 1;
|
|
764
542
|
const rightIndex = index === sections.length - 1 ? null : index + 1;
|
|
@@ -809,4 +587,76 @@ const getSectionOrder = (sections, isRTL) => {
|
|
|
809
587
|
endIndex: rtl2ltr[sections.length - 1]
|
|
810
588
|
};
|
|
811
589
|
};
|
|
812
|
-
exports.getSectionOrder = getSectionOrder;
|
|
590
|
+
exports.getSectionOrder = getSectionOrder;
|
|
591
|
+
const parseSelectedSections = (selectedSections, sections) => {
|
|
592
|
+
if (selectedSections == null) {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
if (selectedSections === 'all') {
|
|
596
|
+
return 'all';
|
|
597
|
+
}
|
|
598
|
+
if (typeof selectedSections === 'string') {
|
|
599
|
+
return sections.findIndex(section => section.type === selectedSections);
|
|
600
|
+
}
|
|
601
|
+
return selectedSections;
|
|
602
|
+
};
|
|
603
|
+
exports.parseSelectedSections = parseSelectedSections;
|
|
604
|
+
const getSectionValueText = (section, utils) => {
|
|
605
|
+
if (!section.value) {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
switch (section.type) {
|
|
609
|
+
case 'month':
|
|
610
|
+
{
|
|
611
|
+
if (section.contentType === 'digit') {
|
|
612
|
+
return utils.format(utils.setMonth(utils.date(), Number(section.value) - 1), 'month');
|
|
613
|
+
}
|
|
614
|
+
const parsedDate = utils.parse(section.value, section.format);
|
|
615
|
+
return parsedDate ? utils.format(parsedDate, 'month') : undefined;
|
|
616
|
+
}
|
|
617
|
+
case 'day':
|
|
618
|
+
return section.contentType === 'digit' ? utils.format(utils.setDate(utils.startOfYear(utils.date()), Number(section.value)), 'dayOfMonthFull') : section.value;
|
|
619
|
+
case 'weekDay':
|
|
620
|
+
// TODO: improve by providing the label of the week day
|
|
621
|
+
return undefined;
|
|
622
|
+
default:
|
|
623
|
+
return undefined;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
exports.getSectionValueText = getSectionValueText;
|
|
627
|
+
const getSectionValueNow = (section, utils) => {
|
|
628
|
+
if (!section.value) {
|
|
629
|
+
return undefined;
|
|
630
|
+
}
|
|
631
|
+
switch (section.type) {
|
|
632
|
+
case 'weekDay':
|
|
633
|
+
{
|
|
634
|
+
if (section.contentType === 'letter') {
|
|
635
|
+
// TODO: improve by resolving the week day number from a letter week day
|
|
636
|
+
return undefined;
|
|
637
|
+
}
|
|
638
|
+
return Number(section.value);
|
|
639
|
+
}
|
|
640
|
+
case 'meridiem':
|
|
641
|
+
{
|
|
642
|
+
const parsedDate = utils.parse(`01:00 ${section.value}`, `${utils.formats.hours12h}:${utils.formats.minutes} ${section.format}`);
|
|
643
|
+
if (parsedDate) {
|
|
644
|
+
return utils.getHours(parsedDate) >= 12 ? 1 : 0;
|
|
645
|
+
}
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
case 'day':
|
|
649
|
+
return section.contentType === 'digit-with-letter' ? parseInt(section.value, 10) : Number(section.value);
|
|
650
|
+
case 'month':
|
|
651
|
+
{
|
|
652
|
+
if (section.contentType === 'digit') {
|
|
653
|
+
return Number(section.value);
|
|
654
|
+
}
|
|
655
|
+
const parsedDate = utils.parse(section.value, section.format);
|
|
656
|
+
return parsedDate ? utils.getMonth(parsedDate) + 1 : undefined;
|
|
657
|
+
}
|
|
658
|
+
default:
|
|
659
|
+
return section.contentType !== 'letter' ? Number(section.value) : undefined;
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
exports.getSectionValueNow = getSectionValueNow;
|
|
@@ -251,13 +251,13 @@ const useFieldCharacterEditing = ({
|
|
|
251
251
|
})) : applyLetterEditing(params);
|
|
252
252
|
if (response == null) {
|
|
253
253
|
setTempAndroidValueStr(null);
|
|
254
|
-
|
|
255
|
-
updateSectionValue({
|
|
256
|
-
activeSection,
|
|
257
|
-
newSectionValue: response.sectionValue,
|
|
258
|
-
shouldGoToNextSection: response.shouldGoToNextSection
|
|
259
|
-
});
|
|
254
|
+
return;
|
|
260
255
|
}
|
|
256
|
+
updateSectionValue({
|
|
257
|
+
activeSection,
|
|
258
|
+
newSectionValue: response.sectionValue,
|
|
259
|
+
shouldGoToNextSection: response.shouldGoToNextSection
|
|
260
|
+
});
|
|
261
261
|
});
|
|
262
262
|
return {
|
|
263
263
|
applyCharacterEditing,
|
|
@@ -11,6 +11,7 @@ var _useControlled = _interopRequireDefault(require("@mui/utils/useControlled"))
|
|
|
11
11
|
var _styles = require("@mui/material/styles");
|
|
12
12
|
var _useUtils = require("../useUtils");
|
|
13
13
|
var _useField = require("./useField.utils");
|
|
14
|
+
var _buildSectionsFromFormat = require("./buildSectionsFromFormat");
|
|
14
15
|
var _useValueWithTimezone = require("../useValueWithTimezone");
|
|
15
16
|
var _getDefaultReferenceDate = require("../../utils/getDefaultReferenceDate");
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -37,7 +38,8 @@ const useFieldState = params => {
|
|
|
37
38
|
selectedSections: selectedSectionsProp,
|
|
38
39
|
onSelectedSectionsChange,
|
|
39
40
|
shouldRespectLeadingZeros = false,
|
|
40
|
-
timezone: timezoneProp
|
|
41
|
+
timezone: timezoneProp,
|
|
42
|
+
enableAccessibleFieldDOMStructure = false
|
|
41
43
|
}
|
|
42
44
|
} = params;
|
|
43
45
|
const {
|
|
@@ -53,8 +55,18 @@ const useFieldState = params => {
|
|
|
53
55
|
});
|
|
54
56
|
const localizedDigits = React.useMemo(() => (0, _useField.getLocalizedDigits)(utils), [utils]);
|
|
55
57
|
const sectionsValueBoundaries = React.useMemo(() => (0, _useField.getSectionsBoundaries)(utils, localizedDigits, timezone), [utils, localizedDigits, timezone]);
|
|
56
|
-
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections,
|
|
57
|
-
|
|
58
|
+
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, date => (0, _buildSectionsFromFormat.buildSectionsFromFormat)({
|
|
59
|
+
utils,
|
|
60
|
+
timezone,
|
|
61
|
+
localeText,
|
|
62
|
+
localizedDigits,
|
|
63
|
+
format,
|
|
64
|
+
date,
|
|
65
|
+
formatDensity,
|
|
66
|
+
shouldRespectLeadingZeros,
|
|
67
|
+
enableAccessibleFieldDOMStructure,
|
|
68
|
+
isRTL
|
|
69
|
+
})), [fieldValueManager, format, localeText, localizedDigits, isRTL, shouldRespectLeadingZeros, utils, formatDensity, timezone, enableAccessibleFieldDOMStructure]);
|
|
58
70
|
const [state, setState] = React.useState(() => {
|
|
59
71
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
60
72
|
(0, _useField.validateSections)(sections, valueType);
|
|
@@ -81,45 +93,14 @@ const useFieldState = params => {
|
|
|
81
93
|
controlled: selectedSectionsProp,
|
|
82
94
|
default: null,
|
|
83
95
|
name: 'useField',
|
|
84
|
-
state: '
|
|
96
|
+
state: 'selectedSections'
|
|
85
97
|
});
|
|
86
98
|
const setSelectedSections = newSelectedSections => {
|
|
87
99
|
innerSetSelectedSections(newSelectedSections);
|
|
88
100
|
onSelectedSectionsChange?.(newSelectedSections);
|
|
89
|
-
setState(prevState => (0, _extends2.default)({}, prevState, {
|
|
90
|
-
selectedSectionQuery: null
|
|
91
|
-
}));
|
|
92
101
|
};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
if (selectedSections === 'all') {
|
|
98
|
-
return {
|
|
99
|
-
startIndex: 0,
|
|
100
|
-
endIndex: state.sections.length - 1,
|
|
101
|
-
shouldSelectBoundarySelectors: true
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (typeof selectedSections === 'number') {
|
|
105
|
-
return {
|
|
106
|
-
startIndex: selectedSections,
|
|
107
|
-
endIndex: selectedSections,
|
|
108
|
-
shouldSelectBoundarySelectors: state.sections[selectedSections].type === 'empty'
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
if (typeof selectedSections === 'string') {
|
|
112
|
-
const selectedSectionIndex = state.sections.findIndex(section => section.type === selectedSections);
|
|
113
|
-
return {
|
|
114
|
-
startIndex: selectedSectionIndex,
|
|
115
|
-
endIndex: selectedSectionIndex,
|
|
116
|
-
shouldSelectBoundarySelectors: state.sections[selectedSectionIndex].type === 'empty'
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return (0, _extends2.default)({}, selectedSections, {
|
|
120
|
-
shouldSelectBoundarySelectors: selectedSections.startIndex === selectedSections.endIndex && state.sections[selectedSections.startIndex].type === 'empty'
|
|
121
|
-
});
|
|
122
|
-
}, [selectedSections, state.sections]);
|
|
102
|
+
const parsedSelectedSections = React.useMemo(() => (0, _useField.parseSelectedSections)(selectedSections, state.sections), [selectedSections, state.sections]);
|
|
103
|
+
const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;
|
|
123
104
|
const publishValue = ({
|
|
124
105
|
value,
|
|
125
106
|
referenceValue,
|
|
@@ -152,7 +133,7 @@ const useFieldState = params => {
|
|
|
152
133
|
value: newSectionValue,
|
|
153
134
|
modified: true
|
|
154
135
|
});
|
|
155
|
-
return
|
|
136
|
+
return newSections;
|
|
156
137
|
};
|
|
157
138
|
const clearValue = () => {
|
|
158
139
|
publishValue({
|
|
@@ -162,26 +143,19 @@ const useFieldState = params => {
|
|
|
162
143
|
});
|
|
163
144
|
};
|
|
164
145
|
const clearActiveSection = () => {
|
|
165
|
-
if (
|
|
146
|
+
if (activeSectionIndex == null) {
|
|
166
147
|
return;
|
|
167
148
|
}
|
|
168
|
-
const activeSection = state.sections[
|
|
149
|
+
const activeSection = state.sections[activeSectionIndex];
|
|
169
150
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
170
151
|
const nonEmptySectionCountBefore = activeDateManager.getSections(state.sections).filter(section => section.value !== '').length;
|
|
171
152
|
const hasNoOtherNonEmptySections = nonEmptySectionCountBefore === (activeSection.value === '' ? 0 : 1);
|
|
172
|
-
const newSections = setSectionValue(
|
|
153
|
+
const newSections = setSectionValue(activeSectionIndex, '');
|
|
173
154
|
const newActiveDate = hasNoOtherNonEmptySections ? null : utils.getInvalidDate();
|
|
174
155
|
const newValues = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}));
|
|
179
|
-
} else {
|
|
180
|
-
setState(prevState => (0, _extends2.default)({}, prevState, newValues, {
|
|
181
|
-
sections: newSections,
|
|
182
|
-
tempValueStrAndroid: null
|
|
183
|
-
}));
|
|
184
|
-
}
|
|
156
|
+
publishValue((0, _extends2.default)({}, newValues, {
|
|
157
|
+
sections: newSections
|
|
158
|
+
}));
|
|
185
159
|
};
|
|
186
160
|
const updateValueFromValueStr = valueStr => {
|
|
187
161
|
const parseDateStr = (dateStr, referenceDate) => {
|
|
@@ -189,7 +163,18 @@ const useFieldState = params => {
|
|
|
189
163
|
if (date == null || !utils.isValid(date)) {
|
|
190
164
|
return null;
|
|
191
165
|
}
|
|
192
|
-
const sections = (0,
|
|
166
|
+
const sections = (0, _buildSectionsFromFormat.buildSectionsFromFormat)({
|
|
167
|
+
utils,
|
|
168
|
+
timezone,
|
|
169
|
+
localeText,
|
|
170
|
+
localizedDigits,
|
|
171
|
+
format,
|
|
172
|
+
date,
|
|
173
|
+
formatDensity,
|
|
174
|
+
shouldRespectLeadingZeros,
|
|
175
|
+
enableAccessibleFieldDOMStructure,
|
|
176
|
+
isRTL
|
|
177
|
+
});
|
|
193
178
|
return (0, _useField.mergeDateIntoReferenceDate)(utils, timezone, date, sections, referenceDate, false);
|
|
194
179
|
};
|
|
195
180
|
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -208,17 +193,15 @@ const useFieldState = params => {
|
|
|
208
193
|
/**
|
|
209
194
|
* 1. Decide which section should be focused
|
|
210
195
|
*/
|
|
211
|
-
if (shouldGoToNextSection &&
|
|
212
|
-
setSelectedSections(
|
|
213
|
-
} else if (selectedSectionIndexes && selectedSectionIndexes.startIndex !== selectedSectionIndexes.endIndex) {
|
|
214
|
-
setSelectedSections(selectedSectionIndexes.startIndex);
|
|
196
|
+
if (shouldGoToNextSection && activeSectionIndex < state.sections.length - 1) {
|
|
197
|
+
setSelectedSections(activeSectionIndex + 1);
|
|
215
198
|
}
|
|
216
199
|
|
|
217
200
|
/**
|
|
218
201
|
* 2. Try to build a valid date from the new section value
|
|
219
202
|
*/
|
|
220
203
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
221
|
-
const newSections = setSectionValue(
|
|
204
|
+
const newSections = setSectionValue(activeSectionIndex, newSectionValue);
|
|
222
205
|
const newActiveDateSections = activeDateManager.getSections(newSections);
|
|
223
206
|
const newActiveDate = (0, _useField.getDateFromDateSections)(utils, newActiveDateSections, localizedDigits);
|
|
224
207
|
let values;
|
|
@@ -260,7 +243,7 @@ const useFieldState = params => {
|
|
|
260
243
|
setState(prevState => (0, _extends2.default)({}, prevState, {
|
|
261
244
|
sections
|
|
262
245
|
}));
|
|
263
|
-
}, [format, utils.locale]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
246
|
+
}, [format, utils.locale, isRTL]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
264
247
|
|
|
265
248
|
React.useEffect(() => {
|
|
266
249
|
let shouldUpdate;
|
|
@@ -280,16 +263,17 @@ const useFieldState = params => {
|
|
|
280
263
|
|
|
281
264
|
return {
|
|
282
265
|
state,
|
|
283
|
-
|
|
266
|
+
activeSectionIndex,
|
|
267
|
+
parsedSelectedSections,
|
|
284
268
|
setSelectedSections,
|
|
285
269
|
clearValue,
|
|
286
270
|
clearActiveSection,
|
|
287
271
|
updateSectionValue,
|
|
288
272
|
updateValueFromValueStr,
|
|
289
273
|
setTempAndroidValueStr,
|
|
274
|
+
getSectionsFromValue,
|
|
290
275
|
sectionsValueBoundaries,
|
|
291
276
|
localizedDigits,
|
|
292
|
-
placeholder,
|
|
293
277
|
timezone
|
|
294
278
|
};
|
|
295
279
|
};
|