@mui/x-date-pickers 6.2.1 → 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 +70 -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 +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/DesktopTimePicker/DesktopTimePicker.js +50 -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/MobileDatePicker/MobileDatePicker.js +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -1
- package/MobileTimePicker/MobileTimePicker.js +2 -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/StaticDateTimePicker/StaticDateTimePicker.js +2 -1
- package/StaticTimePicker/StaticTimePicker.js +2 -1
- 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 +2 -1
- 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 -4
- package/internals/hooks/useField/useField.utils.d.ts +8 -5
- package/internals/hooks/useField/useField.utils.js +60 -34
- package/internals/hooks/useField/useFieldCharacterEditing.js +18 -10
- package/internals/hooks/useField/useFieldState.js +4 -3
- package/internals/hooks/useIsLandscape.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -6
- package/internals/hooks/usePicker/usePicker.d.ts +4 -3
- 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 +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +1 -1
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -11
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
- 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/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 +1 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +51 -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/MobileDatePicker/MobileDatePicker.js +1 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +2 -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/StaticDateTimePicker/StaticDateTimePicker.js +2 -1
- package/legacy/StaticTimePicker/StaticTimePicker.js +2 -1
- 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 +2 -1
- 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 +6 -4
- package/legacy/internals/hooks/usePicker/usePickerValue.js +1 -1
- 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/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 +19 -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 +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +49 -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/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -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/StaticDateTimePicker/StaticDateTimePicker.js +2 -1
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -1
- 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 +2 -1
- 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 +4 -3
- package/modern/internals/hooks/usePicker/usePickerValue.js +1 -1
- 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/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 +2 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -2
- package/node/DesktopTimePicker/DesktopTimePicker.js +50 -8
- package/node/DigitalClock/DigitalClock.js +406 -0
- package/node/DigitalClock/digitalClockClasses.js +15 -0
- package/node/DigitalClock/index.js +25 -0
- package/node/MobileDatePicker/MobileDatePicker.js +2 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +3 -2
- package/node/MobileTimePicker/MobileTimePicker.js +3 -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/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/node/StaticTimePicker/StaticTimePicker.js +3 -2
- 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 +2 -1
- 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 +4 -3
- package/node/internals/hooks/usePicker/usePickerValue.js +1 -1
- 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/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
|
@@ -18,6 +18,9 @@ const getChildTypeFromChildName = childName => {
|
|
|
18
18
|
if (childName.match(/^([A-Za-z]+)Range(Calendar|Clock)$/)) {
|
|
19
19
|
return 'multi-panel-UI-view';
|
|
20
20
|
}
|
|
21
|
+
if (childName.match(/^([A-Za-z]*)(DigitalClock)$/)) {
|
|
22
|
+
return 'Tall-UI-view';
|
|
23
|
+
}
|
|
21
24
|
if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
|
|
22
25
|
return 'UI-view';
|
|
23
26
|
}
|
|
@@ -82,7 +85,7 @@ function DemoContainer(props) {
|
|
|
82
85
|
});
|
|
83
86
|
const getSpacing = direction => {
|
|
84
87
|
if (direction === 'row') {
|
|
85
|
-
return childrenTypes.has('UI-view') ? 3 : 2;
|
|
88
|
+
return childrenTypes.has('UI-view') || childrenTypes.has('Tall-UI-view') ? 3 : 2;
|
|
86
89
|
}
|
|
87
90
|
return childrenTypes.has('UI-view') ? 4 : 3;
|
|
88
91
|
};
|
|
@@ -33,13 +33,13 @@ function usePreviousMonthDisabled(month, {
|
|
|
33
33
|
return !utils.isBefore(firstEnabledMonth, month);
|
|
34
34
|
}, [disablePast, minDate, month, utils]);
|
|
35
35
|
}
|
|
36
|
-
function useMeridiemMode(date, ampm, onChange) {
|
|
36
|
+
function useMeridiemMode(date, ampm, onChange, selectionState) {
|
|
37
37
|
const utils = (0, _useUtils.useUtils)();
|
|
38
38
|
const meridiemMode = (0, _timeUtils.getMeridiem)(date, utils);
|
|
39
39
|
const handleMeridiemChange = React.useCallback(mode => {
|
|
40
40
|
const timeWithMeridiem = date == null ? null : (0, _timeUtils.convertToMeridiem)(date, mode, Boolean(ampm), utils);
|
|
41
|
-
onChange(timeWithMeridiem, 'partial');
|
|
42
|
-
}, [ampm, date, onChange, utils]);
|
|
41
|
+
onChange(timeWithMeridiem, selectionState ?? 'partial');
|
|
42
|
+
}, [ampm, date, onChange, selectionState, utils]);
|
|
43
43
|
return {
|
|
44
44
|
meridiemMode,
|
|
45
45
|
handleMeridiemChange
|
|
@@ -12,7 +12,7 @@ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedE
|
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
-
var _useValidation = require("../
|
|
15
|
+
var _useValidation = require("../useValidation");
|
|
16
16
|
var _useUtils = require("../useUtils");
|
|
17
17
|
var _useField = require("./useField.utils");
|
|
18
18
|
var _useFieldState = require("./useFieldState");
|
|
@@ -35,15 +35,6 @@ const useField = params => {
|
|
|
35
35
|
sectionsValueBoundaries,
|
|
36
36
|
placeholder
|
|
37
37
|
} = (0, _useFieldState.useFieldState)(params);
|
|
38
|
-
const {
|
|
39
|
-
applyCharacterEditing,
|
|
40
|
-
resetCharacterQuery
|
|
41
|
-
} = (0, _useFieldCharacterEditing.useFieldCharacterEditing)({
|
|
42
|
-
sections: state.sections,
|
|
43
|
-
updateSectionValue,
|
|
44
|
-
sectionsValueBoundaries,
|
|
45
|
-
setTempAndroidValueStr
|
|
46
|
-
});
|
|
47
38
|
const {
|
|
48
39
|
inputRef: inputRefProp,
|
|
49
40
|
internalProps,
|
|
@@ -65,6 +56,15 @@ const useField = params => {
|
|
|
65
56
|
validator
|
|
66
57
|
} = params,
|
|
67
58
|
otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(params.forwardedProps, _excluded);
|
|
59
|
+
const {
|
|
60
|
+
applyCharacterEditing,
|
|
61
|
+
resetCharacterQuery
|
|
62
|
+
} = (0, _useFieldCharacterEditing.useFieldCharacterEditing)({
|
|
63
|
+
sections: state.sections,
|
|
64
|
+
updateSectionValue,
|
|
65
|
+
sectionsValueBoundaries,
|
|
66
|
+
setTempAndroidValueStr
|
|
67
|
+
});
|
|
68
68
|
const inputRef = React.useRef(null);
|
|
69
69
|
const handleRef = (0, _useForkRef.default)(inputRefProp, inputRef);
|
|
70
70
|
const focusTimeoutRef = React.useRef(undefined);
|
|
@@ -129,7 +129,8 @@ const useField = params => {
|
|
|
129
129
|
const activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
130
130
|
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
|
131
131
|
const digitsOnly = /^[0-9]+$/.test(pastedValue);
|
|
132
|
-
const
|
|
132
|
+
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
133
|
+
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
133
134
|
if (isValidPastedValue) {
|
|
134
135
|
// Early return to let the paste update section, value
|
|
135
136
|
return;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.validateSections = exports.splitFormatIntoSections = exports.mergeDateIntoReferenceDate = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.
|
|
7
|
+
exports.validateSections = exports.splitFormatIntoSections = exports.mergeDateIntoReferenceDate = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForInputFromSections = exports.cleanString = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.clampDaySectionIfPossible = exports.changeSectionValueFormat = exports.adjustSectionValue = exports.addPositionPropertiesToSections = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
10
10
|
const config = utils.formatTokenMap[formatToken];
|
|
@@ -14,12 +14,14 @@ const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
|
14
14
|
if (typeof config === 'string') {
|
|
15
15
|
return {
|
|
16
16
|
type: config,
|
|
17
|
-
contentType: config === 'meridiem' ? 'letter' : 'digit'
|
|
17
|
+
contentType: config === 'meridiem' ? 'letter' : 'digit',
|
|
18
|
+
maxLength: undefined
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
return {
|
|
21
22
|
type: config.sectionType,
|
|
22
|
-
contentType: config.contentType
|
|
23
|
+
contentType: config.contentType,
|
|
24
|
+
maxLength: config.maxLength
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
exports.getDateSectionConfigFromFormatToken = getDateSectionConfigFromFormatToken;
|
|
@@ -72,37 +74,35 @@ const getLetterEditingOptions = (utils, sectionType, format) => {
|
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
76
|
exports.getLetterEditingOptions = getLetterEditingOptions;
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const cleanLeadingZeros = (utils, valueStr, size) => {
|
|
78
|
+
let cleanValueStr = valueStr;
|
|
79
|
+
|
|
80
|
+
// Remove the leading zeros
|
|
81
|
+
cleanValueStr = Number(cleanValueStr).toString();
|
|
82
|
+
|
|
83
|
+
// Add enough leading zeros to fill the section
|
|
84
|
+
while (cleanValueStr.length < size) {
|
|
85
|
+
cleanValueStr = `0${cleanValueStr}`;
|
|
86
|
+
}
|
|
87
|
+
return cleanValueStr;
|
|
88
|
+
};
|
|
89
|
+
exports.cleanLeadingZeros = cleanLeadingZeros;
|
|
90
|
+
const cleanDigitSectionValue = (utils, value, sectionBoundaries, section) => {
|
|
81
91
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
|
-
if (
|
|
83
|
-
throw new Error([`MUI: The token "${format}" is a digit format with letter in it.'
|
|
92
|
+
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
93
|
+
throw new Error([`MUI: The token "${section.format}" is a digit format with letter in it.'
|
|
84
94
|
This type of format is only supported for 'day' sections`].join('\n'));
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
|
-
if (
|
|
97
|
+
if (section.type === 'day' && section.contentType === 'digit-with-letter') {
|
|
88
98
|
const date = utils.setDate(sectionBoundaries.longestMonth, value);
|
|
89
|
-
return utils.formatByString(date, format);
|
|
99
|
+
return utils.formatByString(date, section.format);
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
// queryValue without leading `0` (`01` => `1`)
|
|
93
103
|
const valueStr = value.toString();
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
let cleanValueStr = valueStr;
|
|
97
|
-
|
|
98
|
-
// Remove the leading zeros
|
|
99
|
-
cleanValueStr = Number(cleanValueStr).toString();
|
|
100
|
-
|
|
101
|
-
// Add enough leading zeros to fill the section
|
|
102
|
-
while (cleanValueStr.length < size) {
|
|
103
|
-
cleanValueStr = `0${cleanValueStr}`;
|
|
104
|
-
}
|
|
105
|
-
return cleanValueStr;
|
|
104
|
+
if (section.hasLeadingZerosInInput) {
|
|
105
|
+
return cleanLeadingZeros(utils, valueStr, section.maxLength);
|
|
106
106
|
}
|
|
107
107
|
return valueStr;
|
|
108
108
|
};
|
|
@@ -118,7 +118,7 @@ const adjustSectionValue = (utils, section, keyCode, sectionsValueBoundaries, ac
|
|
|
118
118
|
format: section.format,
|
|
119
119
|
contentType: section.contentType
|
|
120
120
|
});
|
|
121
|
-
const getCleanValue = value => cleanDigitSectionValue(utils, value,
|
|
121
|
+
const getCleanValue = value => cleanDigitSectionValue(utils, value, sectionBoundaries, section);
|
|
122
122
|
if (shouldSetAbsolute) {
|
|
123
123
|
if (section.type === 'year' && !isEnd && !isStart) {
|
|
124
124
|
return utils.formatByString(utils.date(), section.format);
|
|
@@ -153,7 +153,7 @@ const adjustSectionValue = (utils, section, keyCode, sectionsValueBoundaries, ac
|
|
|
153
153
|
const newOptionIndex = (currentOptionIndex + options.length + delta) % options.length;
|
|
154
154
|
return options[newOptionIndex];
|
|
155
155
|
};
|
|
156
|
-
if (section.contentType === 'digit') {
|
|
156
|
+
if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {
|
|
157
157
|
return adjustDigitSection();
|
|
158
158
|
}
|
|
159
159
|
return adjustLetterSection();
|
|
@@ -161,13 +161,17 @@ const adjustSectionValue = (utils, section, keyCode, sectionsValueBoundaries, ac
|
|
|
161
161
|
exports.adjustSectionValue = adjustSectionValue;
|
|
162
162
|
const getSectionVisibleValue = (section, target) => {
|
|
163
163
|
let value = section.value || section.placeholder;
|
|
164
|
+
const hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;
|
|
165
|
+
if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {
|
|
166
|
+
value = Number(value).toString();
|
|
167
|
+
}
|
|
164
168
|
|
|
165
169
|
// In the input, we add an empty character at the end of each section without leading zeros.
|
|
166
170
|
// This makes sure that `onChange` will always be fired.
|
|
167
171
|
// Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),
|
|
168
172
|
// If you press `1`, on the first section, the new value is also `1/dd/yyyy`,
|
|
169
173
|
// So the browser will not fire the input `onChange`.
|
|
170
|
-
const shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !
|
|
174
|
+
const shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !hasLeadingZeros && value.length === 1;
|
|
171
175
|
if (shouldAddInvisibleSpace) {
|
|
172
176
|
value = `${value}\u200e`;
|
|
173
177
|
}
|
|
@@ -263,7 +267,7 @@ const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) =>
|
|
|
263
267
|
};
|
|
264
268
|
exports.changeSectionValueFormat = changeSectionValueFormat;
|
|
265
269
|
const isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.date(), format).length === 4;
|
|
266
|
-
const
|
|
270
|
+
const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {
|
|
267
271
|
if (contentType !== 'digit') {
|
|
268
272
|
return false;
|
|
269
273
|
}
|
|
@@ -308,7 +312,7 @@ const doesSectionHaveLeadingZeros = (utils, contentType, sectionType, format) =>
|
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
314
|
};
|
|
311
|
-
exports.
|
|
315
|
+
exports.doesSectionFormatHaveLeadingZeros = doesSectionFormatHaveLeadingZeros;
|
|
312
316
|
const getEscapedPartsFromFormat = (utils, format) => {
|
|
313
317
|
const escapedParts = [];
|
|
314
318
|
const {
|
|
@@ -326,21 +330,41 @@ const getEscapedPartsFromFormat = (utils, format) => {
|
|
|
326
330
|
}
|
|
327
331
|
return escapedParts;
|
|
328
332
|
};
|
|
329
|
-
const splitFormatIntoSections = (utils, localeText, format, date, formatDensity) => {
|
|
333
|
+
const splitFormatIntoSections = (utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros) => {
|
|
330
334
|
let startSeparator = '';
|
|
331
335
|
const sections = [];
|
|
336
|
+
const now = utils.date();
|
|
332
337
|
const commitToken = token => {
|
|
333
338
|
if (token === '') {
|
|
334
339
|
return null;
|
|
335
340
|
}
|
|
336
341
|
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
337
|
-
const
|
|
338
|
-
const
|
|
342
|
+
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
343
|
+
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
344
|
+
const isValidDate = date != null && utils.isValid(date);
|
|
345
|
+
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
346
|
+
let maxLength = null;
|
|
347
|
+
if (hasLeadingZerosInInput) {
|
|
348
|
+
if (hasLeadingZerosInFormat) {
|
|
349
|
+
maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
|
|
350
|
+
} else {
|
|
351
|
+
if (sectionConfig.maxLength == null) {
|
|
352
|
+
throw new Error(`MUI: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
|
|
353
|
+
}
|
|
354
|
+
maxLength = sectionConfig.maxLength;
|
|
355
|
+
if (isValidDate) {
|
|
356
|
+
sectionValue = cleanLeadingZeros(utils, sectionValue, maxLength);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
339
360
|
sections.push((0, _extends2.default)({}, sectionConfig, {
|
|
340
361
|
format: token,
|
|
362
|
+
maxLength,
|
|
341
363
|
value: sectionValue,
|
|
342
364
|
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
|
|
343
|
-
hasLeadingZeros,
|
|
365
|
+
hasLeadingZeros: hasLeadingZerosInFormat,
|
|
366
|
+
hasLeadingZerosInFormat,
|
|
367
|
+
hasLeadingZerosInInput,
|
|
344
368
|
startSeparator: sections.length === 0 ? startSeparator : '',
|
|
345
369
|
endSeparator: '',
|
|
346
370
|
modified: false
|
|
@@ -434,7 +458,10 @@ const getDateFromDateSections = (utils, sections) => {
|
|
|
434
458
|
};
|
|
435
459
|
exports.getDateFromDateSections = getDateFromDateSections;
|
|
436
460
|
const createDateStrForInputFromSections = (sections, isRTL) => {
|
|
437
|
-
const formattedSections = sections.map(section =>
|
|
461
|
+
const formattedSections = sections.map(section => {
|
|
462
|
+
const dateValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr');
|
|
463
|
+
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
|
|
464
|
+
});
|
|
438
465
|
const dateStr = formattedSections.join('');
|
|
439
466
|
if (!isRTL) {
|
|
440
467
|
return dateStr;
|
|
@@ -649,7 +676,7 @@ const clampDaySectionIfPossible = (utils, sections, sectionsValueBoundaries) =>
|
|
|
649
676
|
contentType: section.contentType
|
|
650
677
|
});
|
|
651
678
|
return (0, _extends2.default)({}, section, {
|
|
652
|
-
value: cleanDigitSectionValue(utils, dayBoundaries.minimum,
|
|
679
|
+
value: cleanDigitSectionValue(utils, dayBoundaries.minimum, dayBoundaries, section)
|
|
653
680
|
});
|
|
654
681
|
});
|
|
655
682
|
const startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
|
|
@@ -168,12 +168,12 @@ const useFieldCharacterEditing = ({
|
|
|
168
168
|
return applyQuery(params, getFirstSectionValueMatchingWithQuery);
|
|
169
169
|
};
|
|
170
170
|
const applyNumericEditing = params => {
|
|
171
|
-
const getNewSectionValue = (queryValue,
|
|
171
|
+
const getNewSectionValue = (queryValue, section) => {
|
|
172
172
|
const queryValueNumber = Number(`${queryValue}`);
|
|
173
|
-
const sectionBoundaries = sectionsValueBoundaries[
|
|
173
|
+
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
|
174
174
|
currentDate: null,
|
|
175
|
-
format,
|
|
176
|
-
contentType
|
|
175
|
+
format: section.format,
|
|
176
|
+
contentType: section.contentType
|
|
177
177
|
});
|
|
178
178
|
if (queryValueNumber > sectionBoundaries.maximum) {
|
|
179
179
|
return {
|
|
@@ -190,21 +190,29 @@ const useFieldCharacterEditing = ({
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
const shouldGoToNextSection = Number(`${queryValue}0`) > sectionBoundaries.maximum || queryValue.length === sectionBoundaries.maximum.toString().length;
|
|
193
|
-
const newSectionValue = (0, _useField.cleanDigitSectionValue)(utils, queryValueNumber,
|
|
193
|
+
const newSectionValue = (0, _useField.cleanDigitSectionValue)(utils, queryValueNumber, sectionBoundaries, section);
|
|
194
194
|
return {
|
|
195
195
|
sectionValue: newSectionValue,
|
|
196
196
|
shouldGoToNextSection
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
199
|
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
|
|
200
|
-
if (activeSection.contentType === 'digit') {
|
|
201
|
-
return getNewSectionValue(queryValue, activeSection
|
|
200
|
+
if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {
|
|
201
|
+
return getNewSectionValue(queryValue, activeSection);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// When editing a letter-format month and the user presses a digit,
|
|
205
205
|
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
|
206
206
|
if (activeSection.type === 'month') {
|
|
207
|
-
const
|
|
207
|
+
const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(utils, 'digit', 'month', 'MM');
|
|
208
|
+
const response = getNewSectionValue(queryValue, {
|
|
209
|
+
type: activeSection.type,
|
|
210
|
+
format: 'MM',
|
|
211
|
+
hasLeadingZerosInFormat,
|
|
212
|
+
hasLeadingZerosInInput: true,
|
|
213
|
+
contentType: 'digit',
|
|
214
|
+
maxLength: 2
|
|
215
|
+
});
|
|
208
216
|
if (isQueryResponseWithoutValue(response)) {
|
|
209
217
|
return response;
|
|
210
218
|
}
|
|
@@ -217,7 +225,7 @@ const useFieldCharacterEditing = ({
|
|
|
217
225
|
// When editing a letter-format weekDay and the user presses a digit,
|
|
218
226
|
// We can support the numeric editing by returning the nth day in the week day array.
|
|
219
227
|
if (activeSection.type === 'weekDay') {
|
|
220
|
-
const response = getNewSectionValue(queryValue, activeSection
|
|
228
|
+
const response = getNewSectionValue(queryValue, activeSection);
|
|
221
229
|
if (isQueryResponseWithoutValue(response)) {
|
|
222
230
|
return response;
|
|
223
231
|
}
|
|
@@ -32,13 +32,14 @@ const useFieldState = params => {
|
|
|
32
32
|
format,
|
|
33
33
|
formatDensity = 'dense',
|
|
34
34
|
selectedSections: selectedSectionsProp,
|
|
35
|
-
onSelectedSectionsChange
|
|
35
|
+
onSelectedSectionsChange,
|
|
36
|
+
shouldRespectLeadingZeros = false
|
|
36
37
|
}
|
|
37
38
|
} = params;
|
|
38
39
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
39
40
|
const valueFromTheOutside = valueProp ?? firstDefaultValue.current ?? valueManager.emptyValue;
|
|
40
41
|
const sectionsValueBoundaries = React.useMemo(() => (0, _useField.getSectionsBoundaries)(utils), [utils]);
|
|
41
|
-
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => (0, _useField.splitFormatIntoSections)(utils, localeText, format, date, formatDensity)), [fieldValueManager, format, localeText, isRTL, utils, formatDensity]);
|
|
42
|
+
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => (0, _useField.splitFormatIntoSections)(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros)), [fieldValueManager, format, localeText, isRTL, shouldRespectLeadingZeros, utils, formatDensity]);
|
|
42
43
|
const placeholder = React.useMemo(() => fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL), [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
43
44
|
const [state, setState] = React.useState(() => {
|
|
44
45
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
@@ -162,7 +163,7 @@ const useFieldState = params => {
|
|
|
162
163
|
if (date == null || !utils.isValid(date)) {
|
|
163
164
|
return null;
|
|
164
165
|
}
|
|
165
|
-
const sections = (0, _useField.splitFormatIntoSections)(utils, localeText, format, date, formatDensity);
|
|
166
|
+
const sections = (0, _useField.splitFormatIntoSections)(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros);
|
|
166
167
|
return (0, _useField.mergeDateIntoReferenceDate)(utils, date, sections, referenceDate, false);
|
|
167
168
|
};
|
|
168
169
|
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -11,7 +11,7 @@ var _utils = require("@mui/utils");
|
|
|
11
11
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
12
12
|
var _useOpenState = require("../useOpenState");
|
|
13
13
|
var _useUtils = require("../useUtils");
|
|
14
|
-
var _useValidation = require("../
|
|
14
|
+
var _useValidation = require("../useValidation");
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
/**
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useValidation = useValidation;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _useUtils = require("
|
|
8
|
+
var _useUtils = require("./useUtils");
|
|
9
9
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
11
|
function useValidation(props, validate, isSameError, defaultErrorState) {
|
|
@@ -59,35 +59,50 @@ function useViews({
|
|
|
59
59
|
const previousView = views[viewIndex - 1] ?? null;
|
|
60
60
|
const nextView = views[viewIndex + 1] ?? null;
|
|
61
61
|
const handleChangeView = (0, _useEventCallback.default)(newView => {
|
|
62
|
+
if (newView === view) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
62
65
|
setView(newView);
|
|
63
66
|
if (onViewChange) {
|
|
64
67
|
onViewChange(newView);
|
|
65
68
|
}
|
|
66
69
|
});
|
|
70
|
+
const handleFocusedViewChange = (0, _useEventCallback.default)((viewToFocus, hasFocus) => {
|
|
71
|
+
if (hasFocus) {
|
|
72
|
+
// Focus event
|
|
73
|
+
setFocusedView(viewToFocus);
|
|
74
|
+
} else {
|
|
75
|
+
// Blur event
|
|
76
|
+
setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
81
|
+
});
|
|
67
82
|
const goToNextView = (0, _useEventCallback.default)(() => {
|
|
68
83
|
if (nextView) {
|
|
69
84
|
handleChangeView(nextView);
|
|
70
85
|
}
|
|
86
|
+
handleFocusedViewChange(nextView, true);
|
|
71
87
|
});
|
|
72
|
-
const setValueAndGoToNextView = (0, _useEventCallback.default)((value, currentViewSelectionState) => {
|
|
88
|
+
const setValueAndGoToNextView = (0, _useEventCallback.default)((value, currentViewSelectionState, selectedView) => {
|
|
73
89
|
const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
74
|
-
const
|
|
90
|
+
const hasMoreViews = selectedView ?
|
|
91
|
+
// handles case like `DateTimePicker`, where a view might return a `finish` selection state
|
|
92
|
+
// but we it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
93
|
+
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
94
|
+
const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
75
95
|
onChange(value, globalSelectionState);
|
|
76
96
|
if (isSelectionFinishedOnCurrentView) {
|
|
77
97
|
goToNextView();
|
|
78
98
|
}
|
|
79
99
|
});
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// Blur event
|
|
86
|
-
setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
|
|
87
|
-
);
|
|
100
|
+
const setValueAndGoToView = (0, _useEventCallback.default)((value, newView, selectedView) => {
|
|
101
|
+
onChange(value, newView ? 'partial' : 'finish', selectedView);
|
|
102
|
+
if (newView) {
|
|
103
|
+
handleChangeView(newView);
|
|
104
|
+
handleFocusedViewChange(newView, true);
|
|
88
105
|
}
|
|
89
|
-
|
|
90
|
-
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
91
106
|
});
|
|
92
107
|
return {
|
|
93
108
|
view,
|
|
@@ -98,6 +113,7 @@ function useViews({
|
|
|
98
113
|
previousView,
|
|
99
114
|
defaultView: defaultView.current,
|
|
100
115
|
goToNextView,
|
|
101
|
-
setValueAndGoToNextView
|
|
116
|
+
setValueAndGoToNextView,
|
|
117
|
+
setValueAndGoToView
|
|
102
118
|
};
|
|
103
119
|
}
|
package/node/internals/index.js
CHANGED
|
@@ -108,7 +108,7 @@ Object.defineProperty(exports, "executeInTheNextEventLoopTick", {
|
|
|
108
108
|
Object.defineProperty(exports, "extractValidationProps", {
|
|
109
109
|
enumerable: true,
|
|
110
110
|
get: function () {
|
|
111
|
-
return
|
|
111
|
+
return _extractValidationProps.extractValidationProps;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
Object.defineProperty(exports, "getActiveElement", {
|
|
@@ -240,19 +240,19 @@ Object.defineProperty(exports, "useValidation", {
|
|
|
240
240
|
Object.defineProperty(exports, "validateDate", {
|
|
241
241
|
enumerable: true,
|
|
242
242
|
get: function () {
|
|
243
|
-
return
|
|
243
|
+
return _validateDate.validateDate;
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
246
|
Object.defineProperty(exports, "validateDateTime", {
|
|
247
247
|
enumerable: true,
|
|
248
248
|
get: function () {
|
|
249
|
-
return
|
|
249
|
+
return _validateDateTime.validateDateTime;
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
Object.defineProperty(exports, "validateTime", {
|
|
253
253
|
enumerable: true,
|
|
254
254
|
get: function () {
|
|
255
|
-
return
|
|
255
|
+
return _validateTime.validateTime;
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
var _PickersArrowSwitcher = require("./components/PickersArrowSwitcher/PickersArrowSwitcher");
|
|
@@ -270,15 +270,15 @@ var _useField = require("./hooks/useField");
|
|
|
270
270
|
var _usePicker = require("./hooks/usePicker");
|
|
271
271
|
var _useStaticPicker = require("./hooks/useStaticPicker");
|
|
272
272
|
var _useUtils = require("./hooks/useUtils");
|
|
273
|
-
var _useValidation = require("./hooks/
|
|
274
|
-
var _useDateValidation = require("./hooks/validation/useDateValidation");
|
|
275
|
-
var _useTimeValidation = require("./hooks/validation/useTimeValidation");
|
|
276
|
-
var _useDateTimeValidation = require("./hooks/validation/useDateTimeValidation");
|
|
273
|
+
var _useValidation = require("./hooks/useValidation");
|
|
277
274
|
var _dateHelpersHooks = require("./hooks/date-helpers-hooks");
|
|
278
275
|
var _dateUtils = require("./utils/date-utils");
|
|
279
276
|
var _utils = require("./utils/utils");
|
|
280
277
|
var _defaultReduceAnimations = require("./utils/defaultReduceAnimations");
|
|
281
|
-
var
|
|
278
|
+
var _extractValidationProps = require("./utils/validation/extractValidationProps");
|
|
279
|
+
var _validateDate = require("./utils/validation/validateDate");
|
|
280
|
+
var _validateDateTime = require("./utils/validation/validateDateTime");
|
|
281
|
+
var _validateTime = require("./utils/validation/validateTime");
|
|
282
282
|
var _warning = require("./utils/warning");
|
|
283
283
|
var _slotsMigration = require("./utils/slots-migration");
|
|
284
284
|
var _PickersCalendarHeader = require("../DateCalendar/PickersCalendarHeader");
|
|
@@ -13,4 +13,15 @@ Object.keys(_fields).forEach(function (key) {
|
|
|
13
13
|
return _fields[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
+
});
|
|
17
|
+
var _common = require("./common");
|
|
18
|
+
Object.keys(_common).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _common[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _common[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
16
27
|
});
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isTimeView = exports.getSecondsInDay = exports.getMeridiem = exports.createIsAfterIgnoreDatePart = exports.convertValueToMeridiem = exports.convertToMeridiem = void 0;
|
|
7
|
-
const
|
|
7
|
+
const timeViews = ['hours', 'minutes', 'seconds'];
|
|
8
|
+
const isTimeView = view => timeViews.includes(view);
|
|
8
9
|
exports.isTimeView = isTimeView;
|
|
9
10
|
const getMeridiem = (date, utils) => {
|
|
10
11
|
if (!date) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateDate = void 0;
|
|
7
|
+
var _dateUtils = require("../date-utils");
|
|
8
|
+
const validateDate = ({
|
|
9
|
+
props,
|
|
10
|
+
value,
|
|
11
|
+
adapter
|
|
12
|
+
}) => {
|
|
13
|
+
if (value === null) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const now = adapter.utils.date();
|
|
17
|
+
const minDate = (0, _dateUtils.applyDefaultDate)(adapter.utils, props.minDate, adapter.defaultDates.minDate);
|
|
18
|
+
const maxDate = (0, _dateUtils.applyDefaultDate)(adapter.utils, props.maxDate, adapter.defaultDates.maxDate);
|
|
19
|
+
switch (true) {
|
|
20
|
+
case !adapter.utils.isValid(value):
|
|
21
|
+
return 'invalidDate';
|
|
22
|
+
case Boolean(props.shouldDisableDate && props.shouldDisableDate(value)):
|
|
23
|
+
return 'shouldDisableDate';
|
|
24
|
+
case Boolean(props.shouldDisableMonth && props.shouldDisableMonth(value)):
|
|
25
|
+
return 'shouldDisableMonth';
|
|
26
|
+
case Boolean(props.shouldDisableYear && props.shouldDisableYear(value)):
|
|
27
|
+
return 'shouldDisableYear';
|
|
28
|
+
case Boolean(props.disableFuture && adapter.utils.isAfterDay(value, now)):
|
|
29
|
+
return 'disableFuture';
|
|
30
|
+
case Boolean(props.disablePast && adapter.utils.isBeforeDay(value, now)):
|
|
31
|
+
return 'disablePast';
|
|
32
|
+
case Boolean(minDate && adapter.utils.isBeforeDay(value, minDate)):
|
|
33
|
+
return 'minDate';
|
|
34
|
+
case Boolean(maxDate && adapter.utils.isAfterDay(value, maxDate)):
|
|
35
|
+
return 'maxDate';
|
|
36
|
+
default:
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.validateDate = validateDate;
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.validateDateTime = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _validateDate = require("./validateDate");
|
|
8
|
+
var _validateTime = require("./validateTime");
|
|
9
9
|
const validateDateTime = ({
|
|
10
10
|
props,
|
|
11
11
|
value,
|
|
12
12
|
adapter
|
|
13
13
|
}) => {
|
|
14
|
-
const dateValidationResult = (0,
|
|
14
|
+
const dateValidationResult = (0, _validateDate.validateDate)({
|
|
15
15
|
adapter,
|
|
16
16
|
value,
|
|
17
17
|
props
|
|
@@ -19,7 +19,7 @@ const validateDateTime = ({
|
|
|
19
19
|
if (dateValidationResult !== null) {
|
|
20
20
|
return dateValidationResult;
|
|
21
21
|
}
|
|
22
|
-
return (0,
|
|
22
|
+
return (0, _validateTime.validateTime)({
|
|
23
23
|
adapter,
|
|
24
24
|
value,
|
|
25
25
|
props
|