@mui/x-date-pickers 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDateFns/AdapterDateFns.d.ts +109 -0
- package/AdapterDateFns/AdapterDateFns.js +598 -0
- package/AdapterDateFns/index.d.ts +1 -13
- package/AdapterDateFns/index.js +1 -149
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +109 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +610 -0
- package/AdapterDateFnsJalali/index.d.ts +1 -13
- package/AdapterDateFnsJalali/index.js +1 -149
- package/AdapterDayjs/AdapterDayjs.d.ts +53 -53
- package/AdapterDayjs/AdapterDayjs.js +146 -111
- package/AdapterLuxon/AdapterLuxon.d.ts +108 -0
- package/AdapterLuxon/AdapterLuxon.js +513 -0
- package/AdapterLuxon/index.d.ts +1 -14
- package/AdapterLuxon/index.js +1 -111
- package/AdapterMoment/AdapterMoment.d.ts +110 -0
- package/AdapterMoment/AdapterMoment.js +416 -0
- package/AdapterMoment/index.d.ts +1 -21
- package/AdapterMoment/index.js +1 -99
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +67 -0
- package/AdapterMomentHijri/AdapterMomentHijri.js +269 -0
- package/AdapterMomentHijri/index.d.ts +1 -18
- package/AdapterMomentHijri/index.js +1 -74
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +74 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +276 -0
- package/AdapterMomentJalaali/index.d.ts +1 -22
- package/AdapterMomentJalaali/index.js +1 -87
- package/CHANGELOG.md +118 -1
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateCalendar/DayCalendar.js +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
- package/DateCalendar/useCalendarState.js +1 -1
- package/DateCalendar/useIsDateDisabled.d.ts +2 -0
- package/DateCalendar/useIsDateDisabled.js +27 -0
- package/DateField/DateField.js +20 -3
- package/DateField/DateField.types.d.ts +2 -2
- package/DateField/useDateField.js +4 -2
- package/DatePicker/DatePickerToolbar.js +1 -1
- package/DateTimeField/DateTimeField.js +21 -3
- package/DateTimeField/DateTimeField.types.d.ts +3 -2
- package/DateTimeField/useDateTimeField.js +4 -2
- package/DateTimePicker/DateTimePicker.js +1 -0
- package/DateTimePicker/shared.d.ts +6 -5
- package/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -1
- package/DesktopTimePicker/DesktopTimePicker.js +51 -8
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +12 -4
- package/DigitalClock/DigitalClock.d.ts +7 -0
- package/DigitalClock/DigitalClock.js +397 -0
- package/DigitalClock/DigitalClock.types.d.ts +47 -0
- package/DigitalClock/digitalClockClasses.d.ts +11 -0
- package/DigitalClock/digitalClockClasses.js +6 -0
- package/DigitalClock/index.d.ts +4 -0
- package/DigitalClock/index.js +2 -0
- package/DigitalClock/package.json +6 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MobileDatePicker/MobileDatePicker.js +2 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +3 -1
- package/MobileTimePicker/MobileTimePicker.js +3 -1
- package/MobileTimePicker/MobileTimePicker.types.d.ts +8 -7
- package/MonthCalendar/MonthCalendar.types.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.d.ts +7 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +479 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +57 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +22 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +65 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +28 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +151 -0
- package/MultiSectionDigitalClock/index.d.ts +7 -0
- package/MultiSectionDigitalClock/index.js +3 -0
- package/MultiSectionDigitalClock/multiSectionDigitalClockClasses.d.ts +7 -0
- package/MultiSectionDigitalClock/multiSectionDigitalClockClasses.js +6 -0
- package/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.d.ts +9 -0
- package/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +6 -0
- package/MultiSectionDigitalClock/package.json +6 -0
- package/PickersDay/PickersDay.js +4 -1
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +2 -2
- package/PickersLayout/PickersLayout.types.d.ts +7 -8
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/README.md +0 -9
- package/StaticDatePicker/StaticDatePicker.js +1 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +5 -3
- package/StaticTimePicker/StaticTimePicker.js +5 -3
- package/StaticTimePicker/StaticTimePicker.types.d.ts +1 -1
- package/TimeClock/TimeClock.js +35 -12
- package/TimeClock/TimeClock.types.d.ts +4 -67
- package/TimeField/TimeField.js +21 -3
- package/TimeField/TimeField.types.d.ts +3 -2
- package/TimeField/useTimeField.js +4 -2
- package/TimePicker/TimePicker.js +25 -2
- package/TimePicker/TimePicker.types.d.ts +4 -3
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.js +2 -2
- package/TimePicker/shared.d.ts +9 -7
- package/YearCalendar/YearCalendar.types.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.d.ts +2 -2
- package/index.d.ts +2 -0
- package/index.js +4 -1
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/constants/dimensions.d.ts +1 -0
- package/internals/constants/dimensions.js +2 -1
- package/internals/demo/DemoContainer.js +4 -1
- package/internals/hooks/date-helpers-hooks.d.ts +3 -2
- package/internals/hooks/date-helpers-hooks.js +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -15
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -6
- package/internals/hooks/useField/useField.js +12 -11
- package/internals/hooks/useField/useField.types.d.ts +19 -5
- package/internals/hooks/useField/useField.utils.d.ts +9 -6
- package/internals/hooks/useField/useField.utils.js +60 -34
- package/internals/hooks/useField/useFieldCharacterEditing.js +18 -10
- package/internals/hooks/useField/useFieldState.js +5 -4
- package/internals/hooks/useIsLandscape.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +10 -10
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -6
- package/internals/hooks/usePicker/usePicker.d.ts +4 -3
- package/internals/hooks/usePicker/usePicker.js +2 -0
- package/internals/hooks/usePicker/usePicker.types.d.ts +6 -5
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +5 -6
- package/internals/hooks/usePicker/usePickerValue.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerValue.js +10 -12
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +5 -3
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -11
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +6 -5
- package/internals/hooks/{validation/useValidation.d.ts → useValidation.d.ts} +1 -1
- package/internals/hooks/{validation/useValidation.js → useValidation.js} +1 -1
- package/internals/hooks/useViews.d.ts +8 -6
- package/internals/hooks/useViews.js +29 -13
- package/internals/index.d.ts +7 -7
- package/internals/index.js +5 -5
- package/internals/models/common.d.ts +3 -0
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/props/basePickerProps.d.ts +3 -3
- package/internals/models/props/clock.d.ts +88 -0
- package/internals/models/props/tabs.d.ts +2 -2
- package/internals/models/props/toolbar.d.ts +3 -3
- package/internals/{hooks/validation/models.d.ts → models/validation.d.ts} +2 -5
- package/internals/models/validation.js +1 -0
- package/internals/utils/time-utils.d.ts +7 -7
- package/internals/utils/time-utils.js +2 -1
- package/internals/{hooks/validation/useDateValidation.d.ts → utils/validation/validateDate.d.ts} +2 -3
- package/internals/{hooks/validation/useDateValidation.js → utils/validation/validateDate.js} +1 -27
- package/internals/{hooks/validation/useDateTimeValidation.d.ts → utils/validation/validateDateTime.d.ts} +3 -3
- package/{modern/internals/hooks/validation/useDateTimeValidation.js → internals/utils/validation/validateDateTime.js} +2 -2
- package/internals/{hooks/validation/useTimeValidation.d.ts → utils/validation/validateTime.d.ts} +2 -2
- package/{modern/internals/hooks/validation/useTimeValidation.js → internals/utils/validation/validateTime.js} +1 -1
- package/internals/utils/valueManagers.js +1 -1
- package/internals/utils/views.d.ts +3 -2
- package/legacy/AdapterDateFns/AdapterDateFns.js +606 -0
- package/legacy/AdapterDateFns/index.js +1 -165
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +620 -0
- package/legacy/AdapterDateFnsJalali/index.js +1 -165
- package/legacy/AdapterDayjs/AdapterDayjs.js +146 -111
- package/legacy/AdapterLuxon/AdapterLuxon.js +524 -0
- package/legacy/AdapterLuxon/index.js +1 -127
- package/legacy/AdapterMoment/AdapterMoment.js +422 -0
- package/legacy/AdapterMoment/index.js +1 -115
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +284 -0
- package/legacy/AdapterMomentHijri/index.js +1 -90
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +291 -0
- package/legacy/AdapterMomentJalaali/index.js +1 -103
- package/legacy/DateCalendar/DayCalendar.js +1 -1
- package/legacy/DateCalendar/useCalendarState.js +1 -1
- package/legacy/DateCalendar/useIsDateDisabled.js +28 -0
- package/legacy/DateField/DateField.js +20 -3
- package/legacy/DateField/useDateField.js +4 -2
- package/legacy/DatePicker/DatePickerToolbar.js +1 -1
- package/legacy/DateTimeField/DateTimeField.js +21 -3
- package/legacy/DateTimeField/useDateTimeField.js +4 -2
- package/legacy/DateTimePicker/DateTimePicker.js +1 -0
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +52 -8
- package/legacy/DigitalClock/DigitalClock.js +419 -0
- package/legacy/DigitalClock/DigitalClock.types.js +1 -0
- package/legacy/DigitalClock/digitalClockClasses.js +6 -0
- package/legacy/DigitalClock/index.js +2 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +2 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +3 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +3 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +508 -0
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.types.js +1 -0
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +65 -0
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +157 -0
- package/legacy/MultiSectionDigitalClock/index.js +3 -0
- package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockClasses.js +6 -0
- package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +6 -0
- package/legacy/PickersDay/PickersDay.js +3 -1
- package/legacy/PickersLayout/PickersLayout.js +2 -2
- package/legacy/StaticDatePicker/StaticDatePicker.js +1 -0
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +5 -3
- package/legacy/StaticTimePicker/StaticTimePicker.js +5 -3
- package/legacy/TimeClock/TimeClock.js +35 -12
- package/legacy/TimeField/TimeField.js +21 -3
- package/legacy/TimeField/useTimeField.js +4 -2
- package/legacy/TimePicker/TimePicker.js +25 -2
- package/legacy/TimePicker/TimePickerToolbar.js +2 -2
- package/legacy/index.js +4 -1
- package/legacy/internals/constants/dimensions.js +2 -1
- package/legacy/internals/demo/DemoContainer.js +4 -1
- package/legacy/internals/hooks/date-helpers-hooks.js +3 -3
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +10 -11
- package/legacy/internals/hooks/useField/useField.js +11 -10
- package/legacy/internals/hooks/useField/useField.utils.js +58 -34
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +18 -10
- package/legacy/internals/hooks/useField/useFieldState.js +7 -5
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +5 -6
- package/legacy/internals/hooks/usePicker/usePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +10 -14
- package/legacy/internals/hooks/useStaticPicker/useStaticPicker.js +7 -8
- package/legacy/internals/hooks/{validation/useValidation.js → useValidation.js} +1 -1
- package/legacy/internals/hooks/useViews.js +30 -14
- package/legacy/internals/index.js +5 -5
- package/legacy/internals/models/index.js +2 -1
- package/legacy/internals/models/props/clock.js +1 -0
- package/legacy/internals/models/validation.js +1 -0
- package/legacy/internals/utils/time-utils.js +2 -1
- package/legacy/internals/{hooks/validation/useDateValidation.js → utils/validation/validateDate.js} +1 -28
- package/legacy/internals/{hooks/validation/useDateTimeValidation.js → utils/validation/validateDateTime.js} +2 -2
- package/legacy/internals/{hooks/validation/useTimeValidation.js → utils/validation/validateTime.js} +1 -1
- package/legacy/internals/utils/valueManagers.js +2 -2
- package/legacy/locales/beBY.js +5 -3
- package/legacy/locales/caES.js +6 -1
- package/legacy/locales/csCZ.js +6 -4
- package/legacy/locales/daDK.js +6 -2
- package/legacy/locales/deDE.js +6 -2
- package/legacy/locales/enUS.js +4 -0
- package/legacy/locales/esES.js +6 -1
- package/legacy/locales/faIR.js +11 -1
- package/legacy/locales/fiFI.js +6 -1
- package/legacy/locales/frFR.js +6 -1
- package/legacy/locales/heIL.js +6 -1
- package/legacy/locales/huHU.js +6 -2
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/isIS.js +11 -1
- package/legacy/locales/itIT.js +6 -1
- package/legacy/locales/jaJP.js +6 -2
- package/legacy/locales/koKR.js +6 -1
- package/legacy/locales/kzKZ.js +6 -2
- package/legacy/locales/nbNO.js +11 -1
- package/legacy/locales/nlNL.js +11 -1
- package/legacy/locales/plPL.js +11 -1
- package/legacy/locales/ptBR.js +11 -1
- package/legacy/locales/ruRU.js +6 -2
- package/legacy/locales/svSE.js +11 -1
- package/legacy/locales/trTR.js +22 -7
- package/legacy/locales/ukUA.js +11 -1
- package/legacy/locales/urPK.js +11 -1
- package/legacy/locales/zhCN.js +44 -23
- package/legacy/models/common.js +1 -0
- package/legacy/models/index.js +2 -1
- package/legacy/tests/describeAdapters/describeAdapters.js +1 -3
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +29 -26
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +2 -2
- package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +23 -0
- package/legacy/tests/describeHijriAdapter/describeHijriAdapter.types.js +1 -0
- package/legacy/tests/describeHijriAdapter/index.js +1 -0
- package/legacy/tests/describeHijriAdapter/testCalculations.js +94 -0
- package/legacy/tests/describeHijriAdapter/testLocalization.js +12 -0
- package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +25 -0
- package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +1 -0
- package/legacy/tests/describeJalaliAdapter/index.js +1 -0
- package/legacy/tests/describeJalaliAdapter/testCalculations.js +82 -0
- package/legacy/tests/describeJalaliAdapter/testLocalization.js +12 -0
- package/legacy/tests/describePicker/describePicker.js +159 -0
- package/legacy/tests/describePicker/describePicker.types.js +1 -0
- package/legacy/tests/describePicker/index.js +1 -0
- package/legacy/tests/describeValue/describeValue.js +1 -1
- package/legacy/tests/describeValue/testControlledUnControlled.js +8 -9
- package/legacy/tests/describeValue/testPickerActionBar.js +46 -13
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -5
- package/legacy/timeViewRenderers/index.js +1 -1
- package/legacy/timeViewRenderers/timeViewRenderers.js +132 -4
- package/locales/beBY.d.ts +4 -2
- package/locales/beBY.js +3 -3
- package/locales/caES.d.ts +4 -2
- package/locales/caES.js +4 -1
- package/locales/csCZ.d.ts +4 -2
- package/locales/csCZ.js +4 -4
- package/locales/daDK.d.ts +4 -2
- package/locales/daDK.js +4 -2
- package/locales/deDE.d.ts +4 -2
- package/locales/deDE.js +4 -2
- package/locales/enUS.d.ts +3 -2
- package/locales/enUS.js +2 -0
- package/locales/esES.d.ts +4 -2
- package/locales/esES.js +4 -1
- package/locales/faIR.d.ts +4 -2
- package/locales/faIR.js +9 -1
- package/locales/fiFI.d.ts +4 -2
- package/locales/fiFI.js +4 -1
- package/locales/frFR.d.ts +4 -2
- package/locales/frFR.js +4 -1
- package/locales/heIL.d.ts +4 -2
- package/locales/heIL.js +4 -1
- package/locales/huHU.d.ts +4 -2
- package/locales/huHU.js +4 -2
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/isIS.d.ts +4 -2
- package/locales/isIS.js +9 -1
- package/locales/itIT.d.ts +4 -2
- package/locales/itIT.js +4 -1
- package/locales/jaJP.d.ts +4 -2
- package/locales/jaJP.js +4 -2
- package/locales/koKR.d.ts +4 -2
- package/locales/koKR.js +4 -1
- package/locales/kzKZ.d.ts +4 -2
- package/locales/kzKZ.js +4 -2
- package/locales/nbNO.d.ts +4 -2
- package/locales/nbNO.js +9 -1
- package/locales/nlNL.d.ts +8 -7
- package/locales/nlNL.js +9 -1
- package/locales/plPL.d.ts +4 -2
- package/locales/plPL.js +9 -1
- package/locales/ptBR.d.ts +4 -2
- package/locales/ptBR.js +9 -1
- package/locales/ruRU.d.ts +4 -2
- package/locales/ruRU.js +4 -2
- package/locales/svSE.d.ts +4 -2
- package/locales/svSE.js +9 -1
- package/locales/trTR.d.ts +4 -2
- package/locales/trTR.js +14 -7
- package/locales/ukUA.d.ts +4 -2
- package/locales/ukUA.js +9 -1
- package/locales/urPK.d.ts +4 -2
- package/locales/urPK.js +9 -1
- package/locales/utils/getPickersLocalization.d.ts +3 -2
- package/locales/utils/pickersLocaleTextApi.d.ts +5 -3
- package/locales/zhCN.d.ts +4 -2
- package/locales/zhCN.js +22 -23
- package/models/adapters.d.ts +7 -6
- package/models/common.d.ts +5 -0
- package/models/common.js +1 -0
- package/models/fields.d.ts +20 -2
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +597 -0
- package/modern/AdapterDateFns/index.js +1 -149
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +608 -0
- package/modern/AdapterDateFnsJalali/index.js +1 -148
- package/modern/AdapterDayjs/AdapterDayjs.js +146 -111
- package/modern/AdapterLuxon/AdapterLuxon.js +512 -0
- package/modern/AdapterLuxon/index.js +1 -111
- package/modern/AdapterMoment/AdapterMoment.js +416 -0
- package/modern/AdapterMoment/index.js +1 -99
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +269 -0
- package/modern/AdapterMomentHijri/index.js +1 -74
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +276 -0
- package/modern/AdapterMomentJalaali/index.js +1 -87
- package/modern/DateCalendar/DayCalendar.js +1 -1
- package/modern/DateCalendar/useCalendarState.js +1 -1
- package/modern/DateCalendar/useIsDateDisabled.js +27 -0
- package/modern/DateField/DateField.js +20 -3
- package/modern/DateField/useDateField.js +4 -2
- package/modern/DatePicker/DatePickerToolbar.js +1 -1
- package/modern/DateTimeField/DateTimeField.js +21 -3
- package/modern/DateTimeField/useDateTimeField.js +4 -2
- package/modern/DateTimePicker/DateTimePicker.js +1 -0
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +50 -7
- package/modern/DigitalClock/DigitalClock.js +396 -0
- package/modern/DigitalClock/DigitalClock.types.js +1 -0
- package/modern/DigitalClock/digitalClockClasses.js +6 -0
- package/modern/DigitalClock/index.js +2 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +3 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +3 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +479 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.types.js +1 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +65 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +149 -0
- package/modern/MultiSectionDigitalClock/index.js +3 -0
- package/modern/MultiSectionDigitalClock/multiSectionDigitalClockClasses.js +6 -0
- package/modern/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +6 -0
- package/modern/PickersDay/PickersDay.js +4 -1
- package/modern/PickersLayout/PickersLayout.js +2 -2
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -0
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +5 -3
- package/modern/StaticTimePicker/StaticTimePicker.js +5 -3
- package/modern/TimeClock/TimeClock.js +35 -12
- package/modern/TimeField/TimeField.js +21 -3
- package/modern/TimeField/useTimeField.js +4 -2
- package/modern/TimePicker/TimePicker.js +25 -2
- package/modern/TimePicker/TimePickerToolbar.js +2 -2
- package/modern/index.js +4 -1
- package/modern/internals/constants/dimensions.js +2 -1
- package/modern/internals/demo/DemoContainer.js +4 -1
- package/modern/internals/hooks/date-helpers-hooks.js +3 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -15
- package/modern/internals/hooks/useField/useField.js +12 -11
- package/modern/internals/hooks/useField/useField.utils.js +60 -34
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +18 -10
- package/modern/internals/hooks/useField/useFieldState.js +5 -4
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +10 -10
- package/modern/internals/hooks/usePicker/usePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +10 -12
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/modern/internals/hooks/{validation/useValidation.js → useValidation.js} +1 -1
- package/modern/internals/hooks/useViews.js +29 -13
- package/modern/internals/index.js +5 -5
- package/modern/internals/models/index.js +2 -1
- package/modern/internals/models/props/clock.js +1 -0
- package/modern/internals/models/validation.js +1 -0
- package/modern/internals/utils/time-utils.js +2 -1
- package/modern/internals/{hooks/validation/useDateValidation.js → utils/validation/validateDate.js} +1 -27
- package/{internals/hooks/validation/useDateTimeValidation.js → modern/internals/utils/validation/validateDateTime.js} +2 -2
- package/{internals/hooks/validation/useTimeValidation.js → modern/internals/utils/validation/validateTime.js} +1 -1
- package/modern/internals/utils/valueManagers.js +1 -1
- package/modern/locales/beBY.js +3 -3
- package/modern/locales/caES.js +4 -1
- package/modern/locales/csCZ.js +4 -4
- package/modern/locales/daDK.js +4 -2
- package/modern/locales/deDE.js +4 -2
- package/modern/locales/enUS.js +2 -0
- package/modern/locales/esES.js +4 -1
- package/modern/locales/faIR.js +9 -1
- package/modern/locales/fiFI.js +4 -1
- package/modern/locales/frFR.js +4 -1
- package/modern/locales/heIL.js +4 -1
- package/modern/locales/huHU.js +4 -2
- package/modern/locales/index.js +1 -0
- package/modern/locales/isIS.js +9 -1
- package/modern/locales/itIT.js +4 -1
- package/modern/locales/jaJP.js +4 -2
- package/modern/locales/koKR.js +4 -1
- package/modern/locales/kzKZ.js +4 -2
- package/modern/locales/nbNO.js +9 -1
- package/modern/locales/nlNL.js +9 -1
- package/modern/locales/plPL.js +9 -1
- package/modern/locales/ptBR.js +9 -1
- package/modern/locales/ruRU.js +4 -2
- package/modern/locales/svSE.js +9 -1
- package/modern/locales/trTR.js +14 -7
- package/modern/locales/ukUA.js +9 -1
- package/modern/locales/urPK.js +9 -1
- package/modern/locales/zhCN.js +22 -23
- package/modern/models/common.js +1 -0
- package/modern/models/index.js +2 -1
- package/modern/tests/describeAdapters/describeAdapters.js +1 -3
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +29 -26
- package/modern/tests/describeGregorianAdapter/testLocalization.js +2 -2
- package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +23 -0
- package/modern/tests/describeHijriAdapter/describeHijriAdapter.types.js +1 -0
- package/modern/tests/describeHijriAdapter/index.js +1 -0
- package/modern/tests/describeHijriAdapter/testCalculations.js +91 -0
- package/modern/tests/describeHijriAdapter/testLocalization.js +13 -0
- package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +25 -0
- package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +1 -0
- package/modern/tests/describeJalaliAdapter/index.js +1 -0
- package/modern/tests/describeJalaliAdapter/testCalculations.js +83 -0
- package/modern/tests/describeJalaliAdapter/testLocalization.js +13 -0
- package/modern/tests/describePicker/describePicker.js +162 -0
- package/modern/tests/describePicker/describePicker.types.js +1 -0
- package/modern/tests/describePicker/index.js +1 -0
- package/modern/tests/describeValue/describeValue.js +1 -1
- package/modern/tests/describeValue/testControlledUnControlled.js +8 -9
- package/modern/tests/describeValue/testPickerActionBar.js +46 -13
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -5
- package/modern/timeViewRenderers/index.js +1 -1
- package/modern/timeViewRenderers/timeViewRenderers.js +130 -2
- package/node/AdapterDateFns/AdapterDateFns.js +607 -0
- package/node/AdapterDateFns/index.js +6 -152
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +618 -0
- package/node/AdapterDateFnsJalali/index.js +6 -151
- package/node/AdapterDayjs/AdapterDayjs.js +146 -111
- package/node/AdapterLuxon/AdapterLuxon.js +521 -0
- package/node/AdapterLuxon/index.js +6 -114
- package/node/AdapterMoment/AdapterMoment.js +425 -0
- package/node/AdapterMoment/index.js +6 -102
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +278 -0
- package/node/AdapterMomentHijri/index.js +6 -77
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +285 -0
- package/node/AdapterMomentJalaali/index.js +6 -90
- package/node/DateCalendar/DayCalendar.js +2 -2
- package/node/DateCalendar/useCalendarState.js +2 -2
- package/node/{internals/hooks/validation/useDateValidation.js → DateCalendar/useIsDateDisabled.js} +4 -37
- package/node/DateField/DateField.js +20 -3
- package/node/DateField/useDateField.js +5 -3
- package/node/DatePicker/DatePickerToolbar.js +1 -1
- package/node/DateTimeField/DateTimeField.js +21 -3
- package/node/DateTimeField/useDateTimeField.js +5 -3
- package/node/DateTimePicker/DateTimePicker.js +1 -0
- package/node/DesktopDatePicker/DesktopDatePicker.js +3 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -2
- package/node/DesktopTimePicker/DesktopTimePicker.js +51 -8
- package/node/DigitalClock/DigitalClock.js +406 -0
- package/node/DigitalClock/digitalClockClasses.js +15 -0
- package/node/DigitalClock/index.js +25 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MobileDatePicker/MobileDatePicker.js +3 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +4 -2
- package/node/MobileTimePicker/MobileTimePicker.js +4 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +489 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.types.js +5 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +73 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +159 -0
- package/node/MultiSectionDigitalClock/index.js +32 -0
- package/node/MultiSectionDigitalClock/multiSectionDigitalClockClasses.js +15 -0
- package/node/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +15 -0
- package/node/PickersDay/PickersDay.js +4 -1
- package/node/PickersLayout/PickersLayout.js +2 -2
- package/node/StaticDatePicker/StaticDatePicker.js +1 -0
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +5 -3
- package/node/StaticTimePicker/StaticTimePicker.js +5 -3
- package/node/TimeClock/TimeClock.js +35 -12
- package/node/TimeField/TimeField.js +21 -3
- package/node/TimeField/useTimeField.js +5 -3
- package/node/TimePicker/TimePicker.js +25 -2
- package/node/TimePicker/TimePickerToolbar.js +2 -2
- package/node/index.js +25 -1
- package/node/internals/constants/dimensions.js +4 -2
- package/node/internals/demo/DemoContainer.js +4 -1
- package/node/internals/hooks/date-helpers-hooks.js +3 -3
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -15
- package/node/internals/hooks/useField/useField.js +12 -11
- package/node/internals/hooks/useField/useField.utils.js +63 -36
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +17 -9
- package/node/internals/hooks/useField/useFieldState.js +5 -4
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +10 -10
- package/node/internals/hooks/usePicker/usePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +10 -12
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/node/internals/hooks/{validation/useValidation.js → useValidation.js} +1 -1
- package/node/internals/hooks/useViews.js +29 -13
- package/node/internals/index.js +9 -9
- package/node/internals/models/index.js +11 -0
- package/node/internals/models/props/clock.js +5 -0
- package/node/internals/models/validation.js +5 -0
- package/node/internals/utils/time-utils.js +2 -1
- package/node/internals/utils/validation/validateDate.js +40 -0
- package/node/internals/{hooks/validation/useDateTimeValidation.js → utils/validation/validateDateTime.js} +4 -4
- package/node/internals/{hooks/validation/useTimeValidation.js → utils/validation/validateTime.js} +1 -1
- package/node/internals/utils/valueManagers.js +1 -1
- package/node/locales/beBY.js +3 -3
- package/node/locales/caES.js +4 -1
- package/node/locales/csCZ.js +4 -2
- package/node/locales/daDK.js +4 -1
- package/node/locales/deDE.js +4 -1
- package/node/locales/enUS.js +2 -0
- package/node/locales/esES.js +4 -1
- package/node/locales/faIR.js +9 -1
- package/node/locales/fiFI.js +4 -1
- package/node/locales/frFR.js +4 -1
- package/node/locales/heIL.js +4 -1
- package/node/locales/huHU.js +4 -1
- package/node/locales/index.js +11 -0
- package/node/locales/isIS.js +9 -1
- package/node/locales/itIT.js +4 -1
- package/node/locales/jaJP.js +4 -1
- package/node/locales/koKR.js +4 -1
- package/node/locales/kzKZ.js +4 -1
- package/node/locales/nbNO.js +9 -1
- package/node/locales/nlNL.js +9 -1
- package/node/locales/plPL.js +9 -1
- package/node/locales/ptBR.js +9 -1
- package/node/locales/ruRU.js +4 -1
- package/node/locales/svSE.js +9 -1
- package/node/locales/trTR.js +14 -7
- package/node/locales/ukUA.js +9 -1
- package/node/locales/urPK.js +9 -1
- package/node/locales/zhCN.js +22 -23
- package/node/models/common.js +5 -0
- package/node/models/index.js +11 -0
- package/node/tests/describeAdapters/describeAdapters.js +1 -3
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -1
- package/node/tests/describeGregorianAdapter/testCalculations.js +29 -26
- package/node/tests/describeGregorianAdapter/testLocalization.js +2 -2
- package/node/tests/describeHijriAdapter/describeHijriAdapter.js +31 -0
- package/node/tests/describeHijriAdapter/describeHijriAdapter.types.js +5 -0
- package/node/tests/describeHijriAdapter/index.js +12 -0
- package/node/tests/describeHijriAdapter/testCalculations.js +98 -0
- package/node/tests/describeHijriAdapter/testLocalization.js +20 -0
- package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +33 -0
- package/node/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +5 -0
- package/node/tests/describeJalaliAdapter/index.js +12 -0
- package/node/tests/describeJalaliAdapter/testCalculations.js +90 -0
- package/node/tests/describeJalaliAdapter/testLocalization.js +20 -0
- package/node/tests/describePicker/describePicker.js +173 -0
- package/node/tests/describePicker/describePicker.types.js +5 -0
- package/node/tests/describePicker/index.js +12 -0
- package/node/tests/describeValue/describeValue.js +1 -1
- package/node/tests/describeValue/testControlledUnControlled.js +8 -9
- package/node/tests/describeValue/testPickerActionBar.js +46 -13
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -5
- package/node/timeViewRenderers/index.js +12 -0
- package/node/timeViewRenderers/timeViewRenderers.js +134 -4
- package/package.json +3 -10
- package/tests/describeAdapters/describeAdapters.js +1 -3
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -1
- package/tests/describeGregorianAdapter/testCalculations.js +29 -26
- package/tests/describeGregorianAdapter/testLocalization.js +2 -2
- package/tests/describeHijriAdapter/describeHijriAdapter.js +23 -0
- package/tests/describeHijriAdapter/describeHijriAdapter.types.js +1 -0
- package/tests/describeHijriAdapter/index.js +1 -0
- package/tests/describeHijriAdapter/testCalculations.js +91 -0
- package/tests/describeHijriAdapter/testLocalization.js +13 -0
- package/tests/describeJalaliAdapter/describeJalaliAdapter.js +25 -0
- package/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +1 -0
- package/tests/describeJalaliAdapter/index.js +1 -0
- package/tests/describeJalaliAdapter/testCalculations.js +83 -0
- package/tests/describeJalaliAdapter/testLocalization.js +13 -0
- package/tests/describePicker/describePicker.js +162 -0
- package/tests/describePicker/describePicker.types.js +1 -0
- package/tests/describePicker/index.js +1 -0
- package/tests/describeValue/describeValue.js +1 -1
- package/tests/describeValue/testControlledUnControlled.js +8 -9
- package/tests/describeValue/testPickerActionBar.js +46 -13
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -5
- package/themeAugmentation/components.d.ts +12 -0
- package/themeAugmentation/overrides.d.ts +8 -0
- package/themeAugmentation/props.d.ts +8 -0
- package/timeViewRenderers/index.d.ts +1 -1
- package/timeViewRenderers/index.js +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +11 -4
- package/timeViewRenderers/timeViewRenderers.js +130 -2
- /package/{internals/hooks/validation/models.js → DigitalClock/DigitalClock.types.js} +0 -0
- /package/{legacy/internals/hooks/validation/models.js → MultiSectionDigitalClock/MultiSectionDigitalClock.types.js} +0 -0
- /package/{modern/internals/hooks/validation/models.js → internals/models/props/clock.js} +0 -0
- /package/internals/utils/{validation.d.ts → validation/extractValidationProps.d.ts} +0 -0
- /package/internals/utils/{validation.js → validation/extractValidationProps.js} +0 -0
- /package/legacy/internals/utils/{validation.js → validation/extractValidationProps.js} +0 -0
- /package/modern/internals/utils/{validation.js → validation/extractValidationProps.js} +0 -0
- /package/node/{internals/hooks/validation/models.js → DigitalClock/DigitalClock.types.js} +0 -0
- /package/node/internals/utils/{validation.js → validation/extractValidationProps.js} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["
|
|
5
|
-
_excluded2 = ["ownerState"]
|
|
4
|
+
var _excluded = ["props", "getOpenDialogAriaText"],
|
|
5
|
+
_excluded2 = ["ownerState"],
|
|
6
|
+
_excluded3 = ["ownerState"];
|
|
6
7
|
import * as React from 'react';
|
|
7
8
|
import { useSlotProps } from '@mui/base/utils';
|
|
8
9
|
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
@@ -25,9 +26,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
25
26
|
export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
26
27
|
var _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$inputAdornment, _slots$openPickerButt, _slots$layout;
|
|
27
28
|
var props = _ref.props,
|
|
28
|
-
valueManager = _ref.valueManager,
|
|
29
29
|
getOpenDialogAriaText = _ref.getOpenDialogAriaText,
|
|
30
|
-
|
|
30
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
31
31
|
var slots = props.slots,
|
|
32
32
|
innerSlotProps = props.slotProps,
|
|
33
33
|
className = props.className,
|
|
@@ -45,15 +45,13 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
45
45
|
var containerRef = React.useRef(null);
|
|
46
46
|
var labelId = useId();
|
|
47
47
|
var isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
48
|
-
var _usePicker = usePicker({
|
|
48
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
49
49
|
props: props,
|
|
50
50
|
inputRef: internalInputRef,
|
|
51
|
-
valueManager: valueManager,
|
|
52
|
-
validator: validator,
|
|
53
51
|
autoFocusView: true,
|
|
54
52
|
additionalViewProps: {},
|
|
55
53
|
wrapperVariant: 'desktop'
|
|
56
|
-
}),
|
|
54
|
+
})),
|
|
57
55
|
open = _usePicker.open,
|
|
58
56
|
actions = _usePicker.actions,
|
|
59
57
|
hasUIView = _usePicker.hasUIView,
|
|
@@ -71,7 +69,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
71
69
|
ownerState: props
|
|
72
70
|
}),
|
|
73
71
|
inputAdornmentOwnerState = _useSlotProps.ownerState,
|
|
74
|
-
inputAdornmentProps = _objectWithoutProperties(_useSlotProps,
|
|
72
|
+
inputAdornmentProps = _objectWithoutProperties(_useSlotProps, _excluded2);
|
|
75
73
|
var OpenPickerButton = (_slots$openPickerButt = slots.openPickerButton) != null ? _slots$openPickerButt : IconButton;
|
|
76
74
|
var _useSlotProps2 = useSlotProps({
|
|
77
75
|
elementType: OpenPickerButton,
|
|
@@ -85,7 +83,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
85
83
|
ownerState: props
|
|
86
84
|
}),
|
|
87
85
|
openPickerButtonOwnerState = _useSlotProps2.ownerState,
|
|
88
|
-
openPickerButtonProps = _objectWithoutProperties(_useSlotProps2,
|
|
86
|
+
openPickerButtonProps = _objectWithoutProperties(_useSlotProps2, _excluded3);
|
|
89
87
|
var OpenPickerIcon = slots.openPickerIcon;
|
|
90
88
|
var Field = slots.field;
|
|
91
89
|
var fieldProps = useSlotProps({
|
|
@@ -101,7 +99,8 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
101
99
|
format: format,
|
|
102
100
|
formatDensity: formatDensity,
|
|
103
101
|
label: label,
|
|
104
|
-
autoFocus: autoFocus && !props.open
|
|
102
|
+
autoFocus: autoFocus && !props.open,
|
|
103
|
+
focused: open ? true : undefined
|
|
105
104
|
}),
|
|
106
105
|
ownerState: props
|
|
107
106
|
});
|
|
@@ -7,7 +7,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
7
7
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
8
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
9
9
|
import { useTheme } from '@mui/material/styles';
|
|
10
|
-
import { useValidation } from '../
|
|
10
|
+
import { useValidation } from '../useValidation';
|
|
11
11
|
import { useUtils } from '../useUtils';
|
|
12
12
|
import { adjustSectionValue, isAndroid, cleanString, getSectionOrder } from './useField.utils';
|
|
13
13
|
import { useFieldState } from './useFieldState';
|
|
@@ -26,14 +26,6 @@ export var useField = function useField(params) {
|
|
|
26
26
|
setTempAndroidValueStr = _useFieldState.setTempAndroidValueStr,
|
|
27
27
|
sectionsValueBoundaries = _useFieldState.sectionsValueBoundaries,
|
|
28
28
|
placeholder = _useFieldState.placeholder;
|
|
29
|
-
var _useFieldCharacterEdi = useFieldCharacterEditing({
|
|
30
|
-
sections: state.sections,
|
|
31
|
-
updateSectionValue: updateSectionValue,
|
|
32
|
-
sectionsValueBoundaries: sectionsValueBoundaries,
|
|
33
|
-
setTempAndroidValueStr: setTempAndroidValueStr
|
|
34
|
-
}),
|
|
35
|
-
applyCharacterEditing = _useFieldCharacterEdi.applyCharacterEditing,
|
|
36
|
-
resetCharacterQuery = _useFieldCharacterEdi.resetCharacterQuery;
|
|
37
29
|
var inputRefProp = params.inputRef,
|
|
38
30
|
internalProps = params.internalProps,
|
|
39
31
|
_params$internalProps = params.internalProps,
|
|
@@ -52,6 +44,14 @@ export var useField = function useField(params) {
|
|
|
52
44
|
fieldValueManager = params.fieldValueManager,
|
|
53
45
|
valueManager = params.valueManager,
|
|
54
46
|
validator = params.validator;
|
|
47
|
+
var _useFieldCharacterEdi = useFieldCharacterEditing({
|
|
48
|
+
sections: state.sections,
|
|
49
|
+
updateSectionValue: updateSectionValue,
|
|
50
|
+
sectionsValueBoundaries: sectionsValueBoundaries,
|
|
51
|
+
setTempAndroidValueStr: setTempAndroidValueStr
|
|
52
|
+
}),
|
|
53
|
+
applyCharacterEditing = _useFieldCharacterEdi.applyCharacterEditing,
|
|
54
|
+
resetCharacterQuery = _useFieldCharacterEdi.resetCharacterQuery;
|
|
55
55
|
var inputRef = React.useRef(null);
|
|
56
56
|
var handleRef = useForkRef(inputRefProp, inputRef);
|
|
57
57
|
var focusTimeoutRef = React.useRef(undefined);
|
|
@@ -130,7 +130,8 @@ export var useField = function useField(params) {
|
|
|
130
130
|
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
131
131
|
var lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
|
132
132
|
var digitsOnly = /^[0-9]+$/.test(pastedValue);
|
|
133
|
-
var
|
|
133
|
+
var digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
134
|
+
var isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
134
135
|
if (isValidPastedValue) {
|
|
135
136
|
// Early return to let the paste update section, value
|
|
136
137
|
return;
|
|
@@ -8,12 +8,14 @@ export var getDateSectionConfigFromFormatToken = function getDateSectionConfigFr
|
|
|
8
8
|
if (typeof config === 'string') {
|
|
9
9
|
return {
|
|
10
10
|
type: config,
|
|
11
|
-
contentType: config === 'meridiem' ? 'letter' : 'digit'
|
|
11
|
+
contentType: config === 'meridiem' ? 'letter' : 'digit',
|
|
12
|
+
maxLength: undefined
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
16
|
type: config.sectionType,
|
|
16
|
-
contentType: config.contentType
|
|
17
|
+
contentType: config.contentType,
|
|
18
|
+
maxLength: config.maxLength
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
var getDeltaFromKeyCode = function getDeltaFromKeyCode(keyCode) {
|
|
@@ -69,36 +71,33 @@ export var getLetterEditingOptions = function getLetterEditingOptions(utils, sec
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
|
-
export var
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
export var cleanLeadingZeros = function cleanLeadingZeros(utils, valueStr, size) {
|
|
75
|
+
var cleanValueStr = valueStr;
|
|
76
|
+
|
|
77
|
+
// Remove the leading zeros
|
|
78
|
+
cleanValueStr = Number(cleanValueStr).toString();
|
|
79
|
+
|
|
80
|
+
// Add enough leading zeros to fill the section
|
|
81
|
+
while (cleanValueStr.length < size) {
|
|
82
|
+
cleanValueStr = "0".concat(cleanValueStr);
|
|
83
|
+
}
|
|
84
|
+
return cleanValueStr;
|
|
85
|
+
};
|
|
86
|
+
export var cleanDigitSectionValue = function cleanDigitSectionValue(utils, value, sectionBoundaries, section) {
|
|
78
87
|
if (process.env.NODE_ENV !== 'production') {
|
|
79
|
-
if (
|
|
80
|
-
throw new Error(["MUI: The token \"".concat(format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
|
|
88
|
+
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
89
|
+
throw new Error(["MUI: The token \"".concat(section.format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
|
-
if (
|
|
92
|
+
if (section.type === 'day' && section.contentType === 'digit-with-letter') {
|
|
84
93
|
var date = utils.setDate(sectionBoundaries.longestMonth, value);
|
|
85
|
-
return utils.formatByString(date, format);
|
|
94
|
+
return utils.formatByString(date, section.format);
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
// queryValue without leading `0` (`01` => `1`)
|
|
89
98
|
var valueStr = value.toString();
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
var cleanValueStr = valueStr;
|
|
93
|
-
|
|
94
|
-
// Remove the leading zeros
|
|
95
|
-
cleanValueStr = Number(cleanValueStr).toString();
|
|
96
|
-
|
|
97
|
-
// Add enough leading zeros to fill the section
|
|
98
|
-
while (cleanValueStr.length < size) {
|
|
99
|
-
cleanValueStr = "0".concat(cleanValueStr);
|
|
100
|
-
}
|
|
101
|
-
return cleanValueStr;
|
|
99
|
+
if (section.hasLeadingZerosInInput) {
|
|
100
|
+
return cleanLeadingZeros(utils, valueStr, section.maxLength);
|
|
102
101
|
}
|
|
103
102
|
return valueStr;
|
|
104
103
|
};
|
|
@@ -114,7 +113,7 @@ export var adjustSectionValue = function adjustSectionValue(utils, section, keyC
|
|
|
114
113
|
contentType: section.contentType
|
|
115
114
|
});
|
|
116
115
|
var getCleanValue = function getCleanValue(value) {
|
|
117
|
-
return cleanDigitSectionValue(utils, value,
|
|
116
|
+
return cleanDigitSectionValue(utils, value, sectionBoundaries, section);
|
|
118
117
|
};
|
|
119
118
|
if (shouldSetAbsolute) {
|
|
120
119
|
if (section.type === 'year' && !isEnd && !isStart) {
|
|
@@ -150,20 +149,24 @@ export var adjustSectionValue = function adjustSectionValue(utils, section, keyC
|
|
|
150
149
|
var newOptionIndex = (currentOptionIndex + options.length + delta) % options.length;
|
|
151
150
|
return options[newOptionIndex];
|
|
152
151
|
};
|
|
153
|
-
if (section.contentType === 'digit') {
|
|
152
|
+
if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {
|
|
154
153
|
return adjustDigitSection();
|
|
155
154
|
}
|
|
156
155
|
return adjustLetterSection();
|
|
157
156
|
};
|
|
158
157
|
export var getSectionVisibleValue = function getSectionVisibleValue(section, target) {
|
|
159
158
|
var value = section.value || section.placeholder;
|
|
159
|
+
var hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;
|
|
160
|
+
if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {
|
|
161
|
+
value = Number(value).toString();
|
|
162
|
+
}
|
|
160
163
|
|
|
161
164
|
// In the input, we add an empty character at the end of each section without leading zeros.
|
|
162
165
|
// This makes sure that `onChange` will always be fired.
|
|
163
166
|
// Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),
|
|
164
167
|
// If you press `1`, on the first section, the new value is also `1/dd/yyyy`,
|
|
165
168
|
// So the browser will not fire the input `onChange`.
|
|
166
|
-
var shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !
|
|
169
|
+
var shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !hasLeadingZeros && value.length === 1;
|
|
167
170
|
if (shouldAddInvisibleSpace) {
|
|
168
171
|
value = "".concat(value, "\u200E");
|
|
169
172
|
}
|
|
@@ -259,7 +262,7 @@ export var changeSectionValueFormat = function changeSectionValueFormat(utils, v
|
|
|
259
262
|
var isFourDigitYearFormat = function isFourDigitYearFormat(utils, format) {
|
|
260
263
|
return utils.formatByString(utils.date(), format).length === 4;
|
|
261
264
|
};
|
|
262
|
-
export var
|
|
265
|
+
export var doesSectionFormatHaveLeadingZeros = function doesSectionFormatHaveLeadingZeros(utils, contentType, sectionType, format) {
|
|
263
266
|
if (contentType !== 'digit') {
|
|
264
267
|
return false;
|
|
265
268
|
}
|
|
@@ -320,21 +323,41 @@ var getEscapedPartsFromFormat = function getEscapedPartsFromFormat(utils, format
|
|
|
320
323
|
}
|
|
321
324
|
return escapedParts;
|
|
322
325
|
};
|
|
323
|
-
export var splitFormatIntoSections = function splitFormatIntoSections(utils, localeText, format, date, formatDensity) {
|
|
326
|
+
export var splitFormatIntoSections = function splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros) {
|
|
324
327
|
var startSeparator = '';
|
|
325
328
|
var sections = [];
|
|
329
|
+
var now = utils.date();
|
|
326
330
|
var commitToken = function commitToken(token) {
|
|
327
331
|
if (token === '') {
|
|
328
332
|
return null;
|
|
329
333
|
}
|
|
330
334
|
var sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
331
|
-
var
|
|
332
|
-
var
|
|
335
|
+
var hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
336
|
+
var hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
337
|
+
var isValidDate = date != null && utils.isValid(date);
|
|
338
|
+
var sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
339
|
+
var maxLength = null;
|
|
340
|
+
if (hasLeadingZerosInInput) {
|
|
341
|
+
if (hasLeadingZerosInFormat) {
|
|
342
|
+
maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
|
|
343
|
+
} else {
|
|
344
|
+
if (sectionConfig.maxLength == null) {
|
|
345
|
+
throw new Error("MUI: The token ".concat(token, " should have a 'maxDigitNumber' property on it's adapter"));
|
|
346
|
+
}
|
|
347
|
+
maxLength = sectionConfig.maxLength;
|
|
348
|
+
if (isValidDate) {
|
|
349
|
+
sectionValue = cleanLeadingZeros(utils, sectionValue, maxLength);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
333
353
|
sections.push(_extends({}, sectionConfig, {
|
|
334
354
|
format: token,
|
|
355
|
+
maxLength: maxLength,
|
|
335
356
|
value: sectionValue,
|
|
336
357
|
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
|
|
337
|
-
hasLeadingZeros:
|
|
358
|
+
hasLeadingZeros: hasLeadingZerosInFormat,
|
|
359
|
+
hasLeadingZerosInFormat: hasLeadingZerosInFormat,
|
|
360
|
+
hasLeadingZerosInInput: hasLeadingZerosInInput,
|
|
338
361
|
startSeparator: sections.length === 0 ? startSeparator : '',
|
|
339
362
|
endSeparator: '',
|
|
340
363
|
modified: false
|
|
@@ -434,7 +457,8 @@ export var getDateFromDateSections = function getDateFromDateSections(utils, sec
|
|
|
434
457
|
};
|
|
435
458
|
export var createDateStrForInputFromSections = function createDateStrForInputFromSections(sections, isRTL) {
|
|
436
459
|
var formattedSections = sections.map(function (section) {
|
|
437
|
-
|
|
460
|
+
var dateValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr');
|
|
461
|
+
return "".concat(section.startSeparator).concat(dateValue).concat(section.endSeparator);
|
|
438
462
|
});
|
|
439
463
|
var dateStr = formattedSections.join('');
|
|
440
464
|
if (!isRTL) {
|
|
@@ -665,7 +689,7 @@ export var clampDaySectionIfPossible = function clampDaySectionIfPossible(utils,
|
|
|
665
689
|
contentType: section.contentType
|
|
666
690
|
});
|
|
667
691
|
return _extends({}, section, {
|
|
668
|
-
value: cleanDigitSectionValue(utils, dayBoundaries.minimum,
|
|
692
|
+
value: cleanDigitSectionValue(utils, dayBoundaries.minimum, dayBoundaries, section)
|
|
669
693
|
});
|
|
670
694
|
});
|
|
671
695
|
var startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
|
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import { useUtils } from '../useUtils';
|
|
6
|
-
import { changeSectionValueFormat, cleanDigitSectionValue,
|
|
6
|
+
import { changeSectionValueFormat, cleanDigitSectionValue, doesSectionFormatHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions } from './useField.utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The letter editing and the numeric editing each define a `CharacterEditingApplier`.
|
|
@@ -177,12 +177,12 @@ export var useFieldCharacterEditing = function useFieldCharacterEditing(_ref) {
|
|
|
177
177
|
return applyQuery(params, getFirstSectionValueMatchingWithQuery);
|
|
178
178
|
};
|
|
179
179
|
var applyNumericEditing = function applyNumericEditing(params) {
|
|
180
|
-
var getNewSectionValue = function getNewSectionValue(queryValue,
|
|
180
|
+
var getNewSectionValue = function getNewSectionValue(queryValue, section) {
|
|
181
181
|
var queryValueNumber = Number("".concat(queryValue));
|
|
182
|
-
var sectionBoundaries = sectionsValueBoundaries[
|
|
182
|
+
var sectionBoundaries = sectionsValueBoundaries[section.type]({
|
|
183
183
|
currentDate: null,
|
|
184
|
-
format: format,
|
|
185
|
-
contentType: contentType
|
|
184
|
+
format: section.format,
|
|
185
|
+
contentType: section.contentType
|
|
186
186
|
});
|
|
187
187
|
if (queryValueNumber > sectionBoundaries.maximum) {
|
|
188
188
|
return {
|
|
@@ -199,21 +199,29 @@ export var useFieldCharacterEditing = function useFieldCharacterEditing(_ref) {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
var shouldGoToNextSection = Number("".concat(queryValue, "0")) > sectionBoundaries.maximum || queryValue.length === sectionBoundaries.maximum.toString().length;
|
|
202
|
-
var newSectionValue = cleanDigitSectionValue(utils, queryValueNumber,
|
|
202
|
+
var newSectionValue = cleanDigitSectionValue(utils, queryValueNumber, sectionBoundaries, section);
|
|
203
203
|
return {
|
|
204
204
|
sectionValue: newSectionValue,
|
|
205
205
|
shouldGoToNextSection: shouldGoToNextSection
|
|
206
206
|
};
|
|
207
207
|
};
|
|
208
208
|
var getFirstSectionValueMatchingWithQuery = function getFirstSectionValueMatchingWithQuery(queryValue, activeSection) {
|
|
209
|
-
if (activeSection.contentType === 'digit') {
|
|
210
|
-
return getNewSectionValue(queryValue, activeSection
|
|
209
|
+
if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {
|
|
210
|
+
return getNewSectionValue(queryValue, activeSection);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
// When editing a letter-format month and the user presses a digit,
|
|
214
214
|
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
|
215
215
|
if (activeSection.type === 'month') {
|
|
216
|
-
var
|
|
216
|
+
var hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, 'digit', 'month', 'MM');
|
|
217
|
+
var response = getNewSectionValue(queryValue, {
|
|
218
|
+
type: activeSection.type,
|
|
219
|
+
format: 'MM',
|
|
220
|
+
hasLeadingZerosInFormat: hasLeadingZerosInFormat,
|
|
221
|
+
hasLeadingZerosInInput: true,
|
|
222
|
+
contentType: 'digit',
|
|
223
|
+
maxLength: 2
|
|
224
|
+
});
|
|
217
225
|
if (isQueryResponseWithoutValue(response)) {
|
|
218
226
|
return response;
|
|
219
227
|
}
|
|
@@ -226,7 +234,7 @@ export var useFieldCharacterEditing = function useFieldCharacterEditing(_ref) {
|
|
|
226
234
|
// When editing a letter-format weekDay and the user presses a digit,
|
|
227
235
|
// We can support the numeric editing by returning the nth day in the week day array.
|
|
228
236
|
if (activeSection.type === 'weekDay') {
|
|
229
|
-
var _response = getNewSectionValue(queryValue, activeSection
|
|
237
|
+
var _response = getNewSectionValue(queryValue, activeSection);
|
|
230
238
|
if (isQueryResponseWithoutValue(_response)) {
|
|
231
239
|
return _response;
|
|
232
240
|
}
|
|
@@ -26,7 +26,9 @@ export var useFieldState = function useFieldState(params) {
|
|
|
26
26
|
_params$internalProps2 = _params$internalProps.formatDensity,
|
|
27
27
|
formatDensity = _params$internalProps2 === void 0 ? 'dense' : _params$internalProps2,
|
|
28
28
|
selectedSectionsProp = _params$internalProps.selectedSections,
|
|
29
|
-
onSelectedSectionsChange = _params$internalProps.onSelectedSectionsChange
|
|
29
|
+
onSelectedSectionsChange = _params$internalProps.onSelectedSectionsChange,
|
|
30
|
+
_params$internalProps3 = _params$internalProps.shouldRespectLeadingZeros,
|
|
31
|
+
shouldRespectLeadingZeros = _params$internalProps3 === void 0 ? false : _params$internalProps3;
|
|
30
32
|
var firstDefaultValue = React.useRef(defaultValue);
|
|
31
33
|
var valueFromTheOutside = (_ref = valueProp != null ? valueProp : firstDefaultValue.current) != null ? _ref : valueManager.emptyValue;
|
|
32
34
|
var sectionsValueBoundaries = React.useMemo(function () {
|
|
@@ -35,9 +37,9 @@ export var useFieldState = function useFieldState(params) {
|
|
|
35
37
|
var getSectionsFromValue = React.useCallback(function (value) {
|
|
36
38
|
var fallbackSections = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
37
39
|
return fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, function (date) {
|
|
38
|
-
return splitFormatIntoSections(utils, localeText, format, date, formatDensity);
|
|
40
|
+
return splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros);
|
|
39
41
|
});
|
|
40
|
-
}, [fieldValueManager, format, localeText, isRTL, utils, formatDensity]);
|
|
42
|
+
}, [fieldValueManager, format, localeText, isRTL, shouldRespectLeadingZeros, utils, formatDensity]);
|
|
41
43
|
var placeholder = React.useMemo(function () {
|
|
42
44
|
return fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL);
|
|
43
45
|
}, [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
@@ -47,7 +49,7 @@ export var useFieldState = function useFieldState(params) {
|
|
|
47
49
|
return {
|
|
48
50
|
sections: sections,
|
|
49
51
|
value: valueFromTheOutside,
|
|
50
|
-
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, valueManager.getTodayValue(utils)),
|
|
52
|
+
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, valueManager.getTodayValue(utils, valueType)),
|
|
51
53
|
tempValueStrAndroid: null
|
|
52
54
|
};
|
|
53
55
|
}),
|
|
@@ -178,7 +180,7 @@ export var useFieldState = function useFieldState(params) {
|
|
|
178
180
|
if (date == null || !utils.isValid(date)) {
|
|
179
181
|
return null;
|
|
180
182
|
}
|
|
181
|
-
var sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity);
|
|
183
|
+
var sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros);
|
|
182
184
|
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
|
|
183
185
|
};
|
|
184
186
|
var newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["props", "getOpenDialogAriaText"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { useSlotProps } from '@mui/base/utils';
|
|
4
6
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -20,9 +22,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
20
22
|
export var useMobilePicker = function useMobilePicker(_ref) {
|
|
21
23
|
var _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$layout;
|
|
22
24
|
var props = _ref.props,
|
|
23
|
-
valueManager = _ref.valueManager,
|
|
24
25
|
getOpenDialogAriaText = _ref.getOpenDialogAriaText,
|
|
25
|
-
|
|
26
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
26
27
|
var slots = props.slots,
|
|
27
28
|
innerSlotProps = props.slotProps,
|
|
28
29
|
className = props.className,
|
|
@@ -38,15 +39,13 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
38
39
|
var internalInputRef = React.useRef(null);
|
|
39
40
|
var labelId = useId();
|
|
40
41
|
var isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
41
|
-
var _usePicker = usePicker({
|
|
42
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
42
43
|
props: props,
|
|
43
44
|
inputRef: internalInputRef,
|
|
44
|
-
valueManager: valueManager,
|
|
45
|
-
validator: validator,
|
|
46
45
|
autoFocusView: true,
|
|
47
46
|
additionalViewProps: {},
|
|
48
47
|
wrapperVariant: 'mobile'
|
|
49
|
-
}),
|
|
48
|
+
})),
|
|
50
49
|
open = _usePicker.open,
|
|
51
50
|
actions = _usePicker.actions,
|
|
52
51
|
layoutProps = _usePicker.layoutProps,
|
|
@@ -6,6 +6,7 @@ var warnRenderInputIsDefined = buildWarning(['The `renderInput` prop has been re
|
|
|
6
6
|
export var usePicker = function usePicker(_ref) {
|
|
7
7
|
var props = _ref.props,
|
|
8
8
|
valueManager = _ref.valueManager,
|
|
9
|
+
valueType = _ref.valueType,
|
|
9
10
|
wrapperVariant = _ref.wrapperVariant,
|
|
10
11
|
inputRef = _ref.inputRef,
|
|
11
12
|
additionalViewProps = _ref.additionalViewProps,
|
|
@@ -19,6 +20,7 @@ export var usePicker = function usePicker(_ref) {
|
|
|
19
20
|
var pickerValueResponse = usePickerValue({
|
|
20
21
|
props: props,
|
|
21
22
|
valueManager: valueManager,
|
|
23
|
+
valueType: valueType,
|
|
22
24
|
wrapperVariant: wrapperVariant,
|
|
23
25
|
validator: validator
|
|
24
26
|
});
|
|
@@ -5,7 +5,7 @@ import { unstable_useControlled as useControlled } from '@mui/utils';
|
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import { useOpenState } from '../useOpenState';
|
|
7
7
|
import { useLocalizationContext, useUtils } from '../useUtils';
|
|
8
|
-
import { useValidation } from '../
|
|
8
|
+
import { useValidation } from '../useValidation';
|
|
9
9
|
/**
|
|
10
10
|
* Decide if the new value should be published
|
|
11
11
|
* The published value will be passed to `onChange` if defined.
|
|
@@ -92,6 +92,7 @@ var shouldClosePicker = function shouldClosePicker(params) {
|
|
|
92
92
|
export var usePickerValue = function usePickerValue(_ref) {
|
|
93
93
|
var props = _ref.props,
|
|
94
94
|
valueManager = _ref.valueManager,
|
|
95
|
+
valueType = _ref.valueType,
|
|
95
96
|
wrapperVariant = _ref.wrapperVariant,
|
|
96
97
|
validator = _ref.validator;
|
|
97
98
|
var onAccept = props.onAccept,
|
|
@@ -200,21 +201,16 @@ export var usePickerValue = function usePickerValue(_ref) {
|
|
|
200
201
|
setIsOpen(false);
|
|
201
202
|
}
|
|
202
203
|
});
|
|
203
|
-
React.useEffect(function () {
|
|
204
|
-
if (isOpen) {
|
|
205
|
-
setDateState(function (prev) {
|
|
206
|
-
return _extends({}, prev, {
|
|
207
|
-
lastCommittedValue: dateState.draft
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}, [isOpen]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
212
|
-
|
|
213
204
|
if (inValue !== undefined && (dateState.lastControlledValue === undefined || !valueManager.areValuesEqual(utils, dateState.lastControlledValue, inValue))) {
|
|
205
|
+
var isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValue);
|
|
214
206
|
setDateState(function (prev) {
|
|
215
207
|
return _extends({}, prev, {
|
|
216
|
-
lastControlledValue: inValue
|
|
217
|
-
|
|
208
|
+
lastControlledValue: inValue
|
|
209
|
+
}, isUpdateComingFromPicker ? {} : {
|
|
210
|
+
lastCommittedValue: inValue,
|
|
211
|
+
lastPublishedValue: inValue,
|
|
212
|
+
draft: inValue,
|
|
213
|
+
hasBeenModifiedSinceMount: true
|
|
218
214
|
});
|
|
219
215
|
});
|
|
220
216
|
}
|
|
@@ -248,7 +244,7 @@ export var usePickerValue = function usePickerValue(_ref) {
|
|
|
248
244
|
});
|
|
249
245
|
var handleSetToday = useEventCallback(function () {
|
|
250
246
|
updateDate({
|
|
251
|
-
value: valueManager.getTodayValue(utils),
|
|
247
|
+
value: valueManager.getTodayValue(utils, valueType),
|
|
252
248
|
name: 'setValueFromAction',
|
|
253
249
|
pickerAction: 'today'
|
|
254
250
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["props", "ref"];
|
|
3
5
|
import * as React from 'react';
|
|
4
6
|
import clsx from 'clsx';
|
|
5
7
|
import { styled } from '@mui/material/styles';
|
|
@@ -26,9 +28,8 @@ var PickerStaticLayout = styled(PickersLayout)(function (_ref) {
|
|
|
26
28
|
export var useStaticPicker = function useStaticPicker(_ref2) {
|
|
27
29
|
var _slots$layout;
|
|
28
30
|
var props = _ref2.props,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
ref = _ref2.ref;
|
|
31
|
+
ref = _ref2.ref,
|
|
32
|
+
pickerParams = _objectWithoutProperties(_ref2, _excluded);
|
|
32
33
|
var localeText = props.localeText,
|
|
33
34
|
slots = props.slots,
|
|
34
35
|
slotProps = props.slotProps,
|
|
@@ -36,14 +37,12 @@ export var useStaticPicker = function useStaticPicker(_ref2) {
|
|
|
36
37
|
sx = props.sx,
|
|
37
38
|
displayStaticWrapperAs = props.displayStaticWrapperAs,
|
|
38
39
|
autoFocus = props.autoFocus;
|
|
39
|
-
var _usePicker = usePicker({
|
|
40
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
40
41
|
props: props,
|
|
41
|
-
valueManager: valueManager,
|
|
42
|
-
validator: validator,
|
|
43
42
|
autoFocusView: autoFocus != null ? autoFocus : false,
|
|
44
43
|
additionalViewProps: {},
|
|
45
44
|
wrapperVariant: displayStaticWrapperAs
|
|
46
|
-
}),
|
|
45
|
+
})),
|
|
47
46
|
layoutProps = _usePicker.layoutProps,
|
|
48
47
|
renderCurrentView = _usePicker.renderCurrentView;
|
|
49
48
|
var Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickerStaticLayout;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useLocalizationContext } from '
|
|
2
|
+
import { useLocalizationContext } from './useUtils';
|
|
3
3
|
export function useValidation(props, validate, isSameError, defaultErrorState) {
|
|
4
4
|
var value = props.value,
|
|
5
5
|
onError = props.onError;
|
|
@@ -59,24 +59,14 @@ export function useViews(_ref) {
|
|
|
59
59
|
var previousView = (_views = views[viewIndex - 1]) != null ? _views : null;
|
|
60
60
|
var nextView = (_views2 = views[viewIndex + 1]) != null ? _views2 : null;
|
|
61
61
|
var handleChangeView = useEventCallback(function (newView) {
|
|
62
|
+
if (newView === view) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
62
65
|
setView(newView);
|
|
63
66
|
if (onViewChange) {
|
|
64
67
|
onViewChange(newView);
|
|
65
68
|
}
|
|
66
69
|
});
|
|
67
|
-
var goToNextView = useEventCallback(function () {
|
|
68
|
-
if (nextView) {
|
|
69
|
-
handleChangeView(nextView);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
var setValueAndGoToNextView = useEventCallback(function (value, currentViewSelectionState) {
|
|
73
|
-
var isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
74
|
-
var globalSelectionState = isSelectionFinishedOnCurrentView && Boolean(nextView) ? 'partial' : currentViewSelectionState;
|
|
75
|
-
onChange(value, globalSelectionState);
|
|
76
|
-
if (isSelectionFinishedOnCurrentView) {
|
|
77
|
-
goToNextView();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
70
|
var handleFocusedViewChange = useEventCallback(function (viewToFocus, hasFocus) {
|
|
81
71
|
if (hasFocus) {
|
|
82
72
|
// Focus event
|
|
@@ -91,6 +81,31 @@ export function useViews(_ref) {
|
|
|
91
81
|
|
|
92
82
|
onFocusedViewChange == null ? void 0 : onFocusedViewChange(viewToFocus, hasFocus);
|
|
93
83
|
});
|
|
84
|
+
var goToNextView = useEventCallback(function () {
|
|
85
|
+
if (nextView) {
|
|
86
|
+
handleChangeView(nextView);
|
|
87
|
+
}
|
|
88
|
+
handleFocusedViewChange(nextView, true);
|
|
89
|
+
});
|
|
90
|
+
var setValueAndGoToNextView = useEventCallback(function (value, currentViewSelectionState, selectedView) {
|
|
91
|
+
var isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
92
|
+
var hasMoreViews = selectedView ?
|
|
93
|
+
// handles case like `DateTimePicker`, where a view might return a `finish` selection state
|
|
94
|
+
// but we it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
95
|
+
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
96
|
+
var globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
97
|
+
onChange(value, globalSelectionState);
|
|
98
|
+
if (isSelectionFinishedOnCurrentView) {
|
|
99
|
+
goToNextView();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var setValueAndGoToView = useEventCallback(function (value, newView, selectedView) {
|
|
103
|
+
onChange(value, newView ? 'partial' : 'finish', selectedView);
|
|
104
|
+
if (newView) {
|
|
105
|
+
handleChangeView(newView);
|
|
106
|
+
handleFocusedViewChange(newView, true);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
94
109
|
return {
|
|
95
110
|
view: view,
|
|
96
111
|
setView: handleChangeView,
|
|
@@ -100,6 +115,7 @@ export function useViews(_ref) {
|
|
|
100
115
|
previousView: previousView,
|
|
101
116
|
defaultView: defaultView.current,
|
|
102
117
|
goToNextView: goToNextView,
|
|
103
|
-
setValueAndGoToNextView: setValueAndGoToNextView
|
|
118
|
+
setValueAndGoToNextView: setValueAndGoToNextView,
|
|
119
|
+
setValueAndGoToView: setValueAndGoToView
|
|
104
120
|
};
|
|
105
121
|
}
|
|
@@ -13,15 +13,15 @@ export { useField, createDateStrForInputFromSections, addPositionPropertiesToSec
|
|
|
13
13
|
export { usePicker } from './hooks/usePicker';
|
|
14
14
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
15
15
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
16
|
-
export { useValidation } from './hooks/
|
|
17
|
-
export { validateDate } from './hooks/validation/useDateValidation';
|
|
18
|
-
export { validateTime } from './hooks/validation/useTimeValidation';
|
|
19
|
-
export { validateDateTime } from './hooks/validation/useDateTimeValidation';
|
|
16
|
+
export { useValidation } from './hooks/useValidation';
|
|
20
17
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
21
18
|
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
|
|
22
19
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|
|
23
20
|
export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
|
|
24
|
-
export { extractValidationProps } from './utils/validation';
|
|
21
|
+
export { extractValidationProps } from './utils/validation/extractValidationProps';
|
|
22
|
+
export { validateDate } from './utils/validation/validateDate';
|
|
23
|
+
export { validateDateTime } from './utils/validation/validateDateTime';
|
|
24
|
+
export { validateTime } from './utils/validation/validateTime';
|
|
25
25
|
export { buildDeprecatedPropsWarning } from './utils/warning';
|
|
26
26
|
export { uncapitalizeObjectKeys } from './utils/slots-migration';
|
|
27
27
|
export { PickersCalendarHeader } from '../DateCalendar/PickersCalendarHeader';
|