@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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import defaultLocale from 'date-fns/locale/en-US';
|
|
2
|
+
import { AdapterFormats, AdapterUnits, FieldFormatTokenMap, MuiPickersAdapter } from '../models';
|
|
3
|
+
type DateFnsLocale = typeof defaultLocale;
|
|
4
|
+
interface AdapterDateFnsOptions {
|
|
5
|
+
locale?: DateFnsLocale;
|
|
6
|
+
formats?: Partial<AdapterFormats>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Based on `@date-io/date-fns`
|
|
10
|
+
*
|
|
11
|
+
* MIT License
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
export declare class AdapterDateFns implements MuiPickersAdapter<Date> {
|
|
34
|
+
isMUIAdapter: boolean;
|
|
35
|
+
lib: string;
|
|
36
|
+
locale?: DateFnsLocale;
|
|
37
|
+
formats: AdapterFormats;
|
|
38
|
+
formatTokenMap: FieldFormatTokenMap;
|
|
39
|
+
escapedCharacters: {
|
|
40
|
+
start: string;
|
|
41
|
+
end: string;
|
|
42
|
+
};
|
|
43
|
+
constructor({ locale, formats }?: AdapterDateFnsOptions);
|
|
44
|
+
date: (value?: any) => Date | null;
|
|
45
|
+
toJsDate: (value: Date) => Date;
|
|
46
|
+
parseISO: (isoString: string) => Date;
|
|
47
|
+
toISO: (value: Date) => string;
|
|
48
|
+
parse: (value: string, format: string) => Date | null;
|
|
49
|
+
getCurrentLocaleCode: () => string;
|
|
50
|
+
is12HourCycleInCurrentLocale: () => boolean;
|
|
51
|
+
expandFormat: (format: string) => string;
|
|
52
|
+
getFormatHelperText: (format: string) => string;
|
|
53
|
+
isNull: (value: Date | null) => boolean;
|
|
54
|
+
isValid: (value: any) => boolean;
|
|
55
|
+
format: (value: Date, formatKey: keyof AdapterFormats) => string;
|
|
56
|
+
formatByString: (value: Date, formatString: string) => string;
|
|
57
|
+
formatNumber: (numberToFormat: string) => string;
|
|
58
|
+
getDiff: (value: Date, comparing: Date | string, unit?: AdapterUnits) => number;
|
|
59
|
+
isEqual: (value: any, comparing: any) => boolean;
|
|
60
|
+
isSameYear: (value: Date, comparing: Date) => boolean;
|
|
61
|
+
isSameMonth: (value: Date, comparing: Date) => boolean;
|
|
62
|
+
isSameDay: (value: Date, comparing: Date) => boolean;
|
|
63
|
+
isSameHour: (value: Date, comparing: Date) => boolean;
|
|
64
|
+
isAfter: (value: Date, comparing: Date) => boolean;
|
|
65
|
+
isAfterYear: (value: Date, comparing: Date) => boolean;
|
|
66
|
+
isAfterDay: (value: Date, comparing: Date) => boolean;
|
|
67
|
+
isBefore: (value: Date, comparing: Date) => boolean;
|
|
68
|
+
isBeforeYear: (value: Date, comparing: Date) => boolean;
|
|
69
|
+
isBeforeDay: (value: Date, comparing: Date) => boolean;
|
|
70
|
+
isWithinRange: (value: Date, [start, end]: [Date, Date]) => boolean;
|
|
71
|
+
startOfYear: (value: Date) => Date;
|
|
72
|
+
startOfMonth: (value: Date) => Date;
|
|
73
|
+
startOfWeek: (value: Date) => Date;
|
|
74
|
+
startOfDay: (value: Date) => Date;
|
|
75
|
+
endOfYear: (value: Date) => Date;
|
|
76
|
+
endOfMonth: (value: Date) => Date;
|
|
77
|
+
endOfWeek: (value: Date) => Date;
|
|
78
|
+
endOfDay: (value: Date) => Date;
|
|
79
|
+
addYears: (value: Date, amount: number) => Date;
|
|
80
|
+
addMonths: (value: Date, amount: number) => Date;
|
|
81
|
+
addWeeks: (value: Date, amount: number) => Date;
|
|
82
|
+
addDays: (value: Date, amount: number) => Date;
|
|
83
|
+
addHours: (value: Date, amount: number) => Date;
|
|
84
|
+
addMinutes: (value: Date, amount: number) => Date;
|
|
85
|
+
addSeconds: (value: Date, amount: number) => Date;
|
|
86
|
+
getYear: (value: Date) => number;
|
|
87
|
+
getMonth: (value: Date) => number;
|
|
88
|
+
getDate: (value: Date) => number;
|
|
89
|
+
getHours: (value: Date) => number;
|
|
90
|
+
getMinutes: (value: Date) => number;
|
|
91
|
+
getSeconds: (value: Date) => number;
|
|
92
|
+
setYear: (value: Date, year: number) => Date;
|
|
93
|
+
setMonth: (value: Date, month: number) => Date;
|
|
94
|
+
setDate: (value: Date, date: number) => Date;
|
|
95
|
+
setHours: (value: Date, hours: number) => Date;
|
|
96
|
+
setMinutes: (value: Date, minutes: number) => Date;
|
|
97
|
+
setSeconds: (value: Date, seconds: number) => Date;
|
|
98
|
+
getDaysInMonth: (value: Date) => number;
|
|
99
|
+
getNextMonth: (value: Date) => Date;
|
|
100
|
+
getPreviousMonth: (value: Date) => Date;
|
|
101
|
+
getMonthArray: (value: Date) => Date[];
|
|
102
|
+
mergeDateAndTime: (dateParam: Date, timeParam: Date) => Date;
|
|
103
|
+
getWeekdays: () => string[];
|
|
104
|
+
getWeekArray: (value: Date) => Date[][];
|
|
105
|
+
getWeekNumber: (value: Date) => number;
|
|
106
|
+
getYearRange: (start: Date, end: Date) => Date[];
|
|
107
|
+
getMeridiemText: (ampm: 'am' | 'pm') => "AM" | "PM";
|
|
108
|
+
}
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
import addDays from 'date-fns/addDays';
|
|
4
|
+
import addSeconds from 'date-fns/addSeconds';
|
|
5
|
+
import addMinutes from 'date-fns/addMinutes';
|
|
6
|
+
import addHours from 'date-fns/addHours';
|
|
7
|
+
import addWeeks from 'date-fns/addWeeks';
|
|
8
|
+
import addMonths from 'date-fns/addMonths';
|
|
9
|
+
import addYears from 'date-fns/addYears';
|
|
10
|
+
import differenceInYears from 'date-fns/differenceInYears';
|
|
11
|
+
import differenceInQuarters from 'date-fns/differenceInQuarters';
|
|
12
|
+
import differenceInMonths from 'date-fns/differenceInMonths';
|
|
13
|
+
import differenceInWeeks from 'date-fns/differenceInWeeks';
|
|
14
|
+
import differenceInDays from 'date-fns/differenceInDays';
|
|
15
|
+
import differenceInHours from 'date-fns/differenceInHours';
|
|
16
|
+
import differenceInMinutes from 'date-fns/differenceInMinutes';
|
|
17
|
+
import differenceInSeconds from 'date-fns/differenceInSeconds';
|
|
18
|
+
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds';
|
|
19
|
+
import eachDayOfInterval from 'date-fns/eachDayOfInterval';
|
|
20
|
+
import endOfDay from 'date-fns/endOfDay';
|
|
21
|
+
import endOfWeek from 'date-fns/endOfWeek';
|
|
22
|
+
import endOfYear from 'date-fns/endOfYear';
|
|
23
|
+
import dateFnsFormat from 'date-fns/format';
|
|
24
|
+
import getDate from 'date-fns/getDate';
|
|
25
|
+
import getDay from 'date-fns/getDay';
|
|
26
|
+
import getDaysInMonth from 'date-fns/getDaysInMonth';
|
|
27
|
+
import getHours from 'date-fns/getHours';
|
|
28
|
+
import getMinutes from 'date-fns/getMinutes';
|
|
29
|
+
import getMonth from 'date-fns/getMonth';
|
|
30
|
+
import getSeconds from 'date-fns/getSeconds';
|
|
31
|
+
import getWeek from 'date-fns/getWeek';
|
|
32
|
+
import getYear from 'date-fns/getYear';
|
|
33
|
+
import isAfter from 'date-fns/isAfter';
|
|
34
|
+
import isBefore from 'date-fns/isBefore';
|
|
35
|
+
import isEqual from 'date-fns/isEqual';
|
|
36
|
+
import isSameDay from 'date-fns/isSameDay';
|
|
37
|
+
import isSameYear from 'date-fns/isSameYear';
|
|
38
|
+
import isSameMonth from 'date-fns/isSameMonth';
|
|
39
|
+
import isSameHour from 'date-fns/isSameHour';
|
|
40
|
+
import isValid from 'date-fns/isValid';
|
|
41
|
+
import dateFnsParse from 'date-fns/parse';
|
|
42
|
+
import setDate from 'date-fns/setDate';
|
|
43
|
+
import setHours from 'date-fns/setHours';
|
|
44
|
+
import setMinutes from 'date-fns/setMinutes';
|
|
45
|
+
import setMonth from 'date-fns/setMonth';
|
|
46
|
+
import setSeconds from 'date-fns/setSeconds';
|
|
47
|
+
import setYear from 'date-fns/setYear';
|
|
48
|
+
import startOfDay from 'date-fns/startOfDay';
|
|
49
|
+
import startOfMonth from 'date-fns/startOfMonth';
|
|
50
|
+
import endOfMonth from 'date-fns/endOfMonth';
|
|
51
|
+
import startOfWeek from 'date-fns/startOfWeek';
|
|
52
|
+
import startOfYear from 'date-fns/startOfYear';
|
|
53
|
+
import parseISO from 'date-fns/parseISO';
|
|
54
|
+
import formatISO from 'date-fns/formatISO';
|
|
55
|
+
import isWithinInterval from 'date-fns/isWithinInterval';
|
|
56
|
+
import defaultLocale from 'date-fns/locale/en-US';
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
import longFormatters from 'date-fns/_lib/format/longFormatters';
|
|
59
|
+
const formatTokenMap = {
|
|
60
|
+
// Year
|
|
61
|
+
y: {
|
|
62
|
+
sectionType: 'year',
|
|
63
|
+
contentType: 'digit',
|
|
64
|
+
maxLength: 4
|
|
65
|
+
},
|
|
66
|
+
yy: 'year',
|
|
67
|
+
yyy: {
|
|
68
|
+
sectionType: 'year',
|
|
69
|
+
contentType: 'digit',
|
|
70
|
+
maxLength: 4
|
|
71
|
+
},
|
|
72
|
+
yyyy: 'year',
|
|
73
|
+
// Month
|
|
74
|
+
M: {
|
|
75
|
+
sectionType: 'month',
|
|
76
|
+
contentType: 'digit',
|
|
77
|
+
maxLength: 2
|
|
78
|
+
},
|
|
79
|
+
MM: 'month',
|
|
80
|
+
MMMM: {
|
|
81
|
+
sectionType: 'month',
|
|
82
|
+
contentType: 'letter'
|
|
83
|
+
},
|
|
84
|
+
MMM: {
|
|
85
|
+
sectionType: 'month',
|
|
86
|
+
contentType: 'letter'
|
|
87
|
+
},
|
|
88
|
+
L: {
|
|
89
|
+
sectionType: 'month',
|
|
90
|
+
contentType: 'digit',
|
|
91
|
+
maxLength: 2
|
|
92
|
+
},
|
|
93
|
+
LL: 'month',
|
|
94
|
+
LLL: {
|
|
95
|
+
sectionType: 'month',
|
|
96
|
+
contentType: 'letter'
|
|
97
|
+
},
|
|
98
|
+
LLLL: {
|
|
99
|
+
sectionType: 'month',
|
|
100
|
+
contentType: 'letter'
|
|
101
|
+
},
|
|
102
|
+
// Day of the month
|
|
103
|
+
d: {
|
|
104
|
+
sectionType: 'day',
|
|
105
|
+
contentType: 'digit',
|
|
106
|
+
maxLength: 2
|
|
107
|
+
},
|
|
108
|
+
dd: 'day',
|
|
109
|
+
do: {
|
|
110
|
+
sectionType: 'day',
|
|
111
|
+
contentType: 'digit-with-letter'
|
|
112
|
+
},
|
|
113
|
+
// Day of the week
|
|
114
|
+
E: {
|
|
115
|
+
sectionType: 'weekDay',
|
|
116
|
+
contentType: 'letter'
|
|
117
|
+
},
|
|
118
|
+
EE: {
|
|
119
|
+
sectionType: 'weekDay',
|
|
120
|
+
contentType: 'letter'
|
|
121
|
+
},
|
|
122
|
+
EEE: {
|
|
123
|
+
sectionType: 'weekDay',
|
|
124
|
+
contentType: 'letter'
|
|
125
|
+
},
|
|
126
|
+
EEEE: {
|
|
127
|
+
sectionType: 'weekDay',
|
|
128
|
+
contentType: 'letter'
|
|
129
|
+
},
|
|
130
|
+
EEEEE: {
|
|
131
|
+
sectionType: 'weekDay',
|
|
132
|
+
contentType: 'letter'
|
|
133
|
+
},
|
|
134
|
+
i: {
|
|
135
|
+
sectionType: 'weekDay',
|
|
136
|
+
contentType: 'digit',
|
|
137
|
+
maxLength: 1
|
|
138
|
+
},
|
|
139
|
+
ii: 'weekDay',
|
|
140
|
+
iii: {
|
|
141
|
+
sectionType: 'weekDay',
|
|
142
|
+
contentType: 'letter'
|
|
143
|
+
},
|
|
144
|
+
iiii: {
|
|
145
|
+
sectionType: 'weekDay',
|
|
146
|
+
contentType: 'letter'
|
|
147
|
+
},
|
|
148
|
+
e: {
|
|
149
|
+
sectionType: 'weekDay',
|
|
150
|
+
contentType: 'digit',
|
|
151
|
+
maxLength: 1
|
|
152
|
+
},
|
|
153
|
+
ee: 'weekDay',
|
|
154
|
+
eee: {
|
|
155
|
+
sectionType: 'weekDay',
|
|
156
|
+
contentType: 'letter'
|
|
157
|
+
},
|
|
158
|
+
eeee: {
|
|
159
|
+
sectionType: 'weekDay',
|
|
160
|
+
contentType: 'letter'
|
|
161
|
+
},
|
|
162
|
+
eeeee: {
|
|
163
|
+
sectionType: 'weekDay',
|
|
164
|
+
contentType: 'letter'
|
|
165
|
+
},
|
|
166
|
+
eeeeee: {
|
|
167
|
+
sectionType: 'weekDay',
|
|
168
|
+
contentType: 'letter'
|
|
169
|
+
},
|
|
170
|
+
c: {
|
|
171
|
+
sectionType: 'weekDay',
|
|
172
|
+
contentType: 'digit',
|
|
173
|
+
maxLength: 1
|
|
174
|
+
},
|
|
175
|
+
cc: 'weekDay',
|
|
176
|
+
ccc: {
|
|
177
|
+
sectionType: 'weekDay',
|
|
178
|
+
contentType: 'letter'
|
|
179
|
+
},
|
|
180
|
+
cccc: {
|
|
181
|
+
sectionType: 'weekDay',
|
|
182
|
+
contentType: 'letter'
|
|
183
|
+
},
|
|
184
|
+
ccccc: {
|
|
185
|
+
sectionType: 'weekDay',
|
|
186
|
+
contentType: 'letter'
|
|
187
|
+
},
|
|
188
|
+
cccccc: {
|
|
189
|
+
sectionType: 'weekDay',
|
|
190
|
+
contentType: 'letter'
|
|
191
|
+
},
|
|
192
|
+
// Meridiem
|
|
193
|
+
a: 'meridiem',
|
|
194
|
+
aa: 'meridiem',
|
|
195
|
+
aaa: 'meridiem',
|
|
196
|
+
// Hours
|
|
197
|
+
H: {
|
|
198
|
+
sectionType: 'hours',
|
|
199
|
+
contentType: 'digit',
|
|
200
|
+
maxLength: 2
|
|
201
|
+
},
|
|
202
|
+
HH: 'hours',
|
|
203
|
+
h: {
|
|
204
|
+
sectionType: 'hours',
|
|
205
|
+
contentType: 'digit',
|
|
206
|
+
maxLength: 2
|
|
207
|
+
},
|
|
208
|
+
hh: 'hours',
|
|
209
|
+
// Minutes
|
|
210
|
+
m: {
|
|
211
|
+
sectionType: 'minutes',
|
|
212
|
+
contentType: 'digit',
|
|
213
|
+
maxLength: 2
|
|
214
|
+
},
|
|
215
|
+
mm: 'minutes',
|
|
216
|
+
// Seconds
|
|
217
|
+
s: {
|
|
218
|
+
sectionType: 'seconds',
|
|
219
|
+
contentType: 'digit',
|
|
220
|
+
maxLength: 2
|
|
221
|
+
},
|
|
222
|
+
ss: 'seconds'
|
|
223
|
+
};
|
|
224
|
+
const defaultFormats = {
|
|
225
|
+
dayOfMonth: 'd',
|
|
226
|
+
fullDate: 'PP',
|
|
227
|
+
fullDateWithWeekday: 'PPPP',
|
|
228
|
+
fullDateTime: 'PP p',
|
|
229
|
+
fullDateTime12h: 'PP hh:mm aa',
|
|
230
|
+
fullDateTime24h: 'PP HH:mm',
|
|
231
|
+
fullTime: 'p',
|
|
232
|
+
fullTime12h: 'hh:mm aa',
|
|
233
|
+
fullTime24h: 'HH:mm',
|
|
234
|
+
hours12h: 'hh',
|
|
235
|
+
hours24h: 'HH',
|
|
236
|
+
keyboardDate: 'P',
|
|
237
|
+
keyboardDateTime: 'P p',
|
|
238
|
+
keyboardDateTime12h: 'P hh:mm aa',
|
|
239
|
+
keyboardDateTime24h: 'P HH:mm',
|
|
240
|
+
minutes: 'mm',
|
|
241
|
+
month: 'LLLL',
|
|
242
|
+
monthAndDate: 'MMMM d',
|
|
243
|
+
monthAndYear: 'LLLL yyyy',
|
|
244
|
+
monthShort: 'MMM',
|
|
245
|
+
weekday: 'EEEE',
|
|
246
|
+
weekdayShort: 'EEE',
|
|
247
|
+
normalDate: 'd MMMM',
|
|
248
|
+
normalDateWithWeekday: 'EEE, MMM d',
|
|
249
|
+
seconds: 'ss',
|
|
250
|
+
shortDate: 'MMM d',
|
|
251
|
+
year: 'yyyy'
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Based on `@date-io/date-fns`
|
|
256
|
+
*
|
|
257
|
+
* MIT License
|
|
258
|
+
*
|
|
259
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
260
|
+
*
|
|
261
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
262
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
263
|
+
* in the Software without restriction, including without limitation the rights
|
|
264
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
265
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
266
|
+
* furnished to do so, subject to the following conditions:
|
|
267
|
+
*
|
|
268
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
269
|
+
* copies or substantial portions of the Software.
|
|
270
|
+
*
|
|
271
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
272
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
273
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
274
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
275
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
276
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
277
|
+
* SOFTWARE.
|
|
278
|
+
*/
|
|
279
|
+
export class AdapterDateFns {
|
|
280
|
+
constructor({
|
|
281
|
+
locale: _locale,
|
|
282
|
+
formats
|
|
283
|
+
} = {}) {
|
|
284
|
+
this.isMUIAdapter = true;
|
|
285
|
+
this.lib = 'date-fns';
|
|
286
|
+
this.locale = void 0;
|
|
287
|
+
this.formats = void 0;
|
|
288
|
+
this.formatTokenMap = formatTokenMap;
|
|
289
|
+
this.escapedCharacters = {
|
|
290
|
+
start: "'",
|
|
291
|
+
end: "'"
|
|
292
|
+
};
|
|
293
|
+
this.date = value => {
|
|
294
|
+
if (typeof value === 'undefined') {
|
|
295
|
+
return new Date();
|
|
296
|
+
}
|
|
297
|
+
if (value === null) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
return new Date(value);
|
|
301
|
+
};
|
|
302
|
+
this.toJsDate = value => {
|
|
303
|
+
return value;
|
|
304
|
+
};
|
|
305
|
+
this.parseISO = isoString => {
|
|
306
|
+
return parseISO(isoString);
|
|
307
|
+
};
|
|
308
|
+
this.toISO = value => {
|
|
309
|
+
return formatISO(value, {
|
|
310
|
+
format: 'extended'
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
this.parse = (value, format) => {
|
|
314
|
+
if (value === '') {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return dateFnsParse(value, format, new Date(), {
|
|
318
|
+
locale: this.locale
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
this.getCurrentLocaleCode = () => {
|
|
322
|
+
var _this$locale;
|
|
323
|
+
return ((_this$locale = this.locale) == null ? void 0 : _this$locale.code) || 'en-US';
|
|
324
|
+
};
|
|
325
|
+
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
326
|
+
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
327
|
+
this.is12HourCycleInCurrentLocale = () => {
|
|
328
|
+
if (this.locale) {
|
|
329
|
+
return /a/.test(this.locale.formatLong.time());
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// By default, date-fns is using en-US locale with am/pm enabled
|
|
333
|
+
return true;
|
|
334
|
+
};
|
|
335
|
+
this.expandFormat = format => {
|
|
336
|
+
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
337
|
+
|
|
338
|
+
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
339
|
+
return format.match(longFormatRegexp).map(token => {
|
|
340
|
+
const firstCharacter = token[0];
|
|
341
|
+
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
342
|
+
const longFormatter = longFormatters[firstCharacter];
|
|
343
|
+
const locale = this.locale || defaultLocale;
|
|
344
|
+
return longFormatter(token, locale.formatLong, {});
|
|
345
|
+
}
|
|
346
|
+
return token;
|
|
347
|
+
}).join('');
|
|
348
|
+
};
|
|
349
|
+
this.getFormatHelperText = format => {
|
|
350
|
+
return this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
351
|
+
};
|
|
352
|
+
this.isNull = value => {
|
|
353
|
+
return value === null;
|
|
354
|
+
};
|
|
355
|
+
this.isValid = value => {
|
|
356
|
+
return isValid(this.date(value));
|
|
357
|
+
};
|
|
358
|
+
this.format = (value, formatKey) => {
|
|
359
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
360
|
+
};
|
|
361
|
+
this.formatByString = (value, formatString) => {
|
|
362
|
+
return dateFnsFormat(value, formatString, {
|
|
363
|
+
locale: this.locale
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
this.formatNumber = numberToFormat => {
|
|
367
|
+
return numberToFormat;
|
|
368
|
+
};
|
|
369
|
+
this.getDiff = (value, comparing, unit) => {
|
|
370
|
+
switch (unit) {
|
|
371
|
+
case 'years':
|
|
372
|
+
return differenceInYears(value, this.date(comparing));
|
|
373
|
+
case 'quarters':
|
|
374
|
+
return differenceInQuarters(value, this.date(comparing));
|
|
375
|
+
case 'months':
|
|
376
|
+
return differenceInMonths(value, this.date(comparing));
|
|
377
|
+
case 'weeks':
|
|
378
|
+
return differenceInWeeks(value, this.date(comparing));
|
|
379
|
+
case 'days':
|
|
380
|
+
return differenceInDays(value, this.date(comparing));
|
|
381
|
+
case 'hours':
|
|
382
|
+
return differenceInHours(value, this.date(comparing));
|
|
383
|
+
case 'minutes':
|
|
384
|
+
return differenceInMinutes(value, this.date(comparing));
|
|
385
|
+
case 'seconds':
|
|
386
|
+
return differenceInSeconds(value, this.date(comparing));
|
|
387
|
+
default:
|
|
388
|
+
{
|
|
389
|
+
return differenceInMilliseconds(value, this.date(comparing));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
this.isEqual = (value, comparing) => {
|
|
394
|
+
if (value === null && comparing === null) {
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
return isEqual(value, comparing);
|
|
398
|
+
};
|
|
399
|
+
this.isSameYear = (value, comparing) => {
|
|
400
|
+
return isSameYear(value, comparing);
|
|
401
|
+
};
|
|
402
|
+
this.isSameMonth = (value, comparing) => {
|
|
403
|
+
return isSameMonth(value, comparing);
|
|
404
|
+
};
|
|
405
|
+
this.isSameDay = (value, comparing) => {
|
|
406
|
+
return isSameDay(value, comparing);
|
|
407
|
+
};
|
|
408
|
+
this.isSameHour = (value, comparing) => {
|
|
409
|
+
return isSameHour(value, comparing);
|
|
410
|
+
};
|
|
411
|
+
this.isAfter = (value, comparing) => {
|
|
412
|
+
return isAfter(value, comparing);
|
|
413
|
+
};
|
|
414
|
+
this.isAfterYear = (value, comparing) => {
|
|
415
|
+
return isAfter(value, endOfYear(comparing));
|
|
416
|
+
};
|
|
417
|
+
this.isAfterDay = (value, comparing) => {
|
|
418
|
+
return isAfter(value, endOfDay(comparing));
|
|
419
|
+
};
|
|
420
|
+
this.isBefore = (value, comparing) => {
|
|
421
|
+
return isBefore(value, comparing);
|
|
422
|
+
};
|
|
423
|
+
this.isBeforeYear = (value, comparing) => {
|
|
424
|
+
return isBefore(value, startOfYear(comparing));
|
|
425
|
+
};
|
|
426
|
+
this.isBeforeDay = (value, comparing) => {
|
|
427
|
+
return isBefore(value, startOfDay(comparing));
|
|
428
|
+
};
|
|
429
|
+
this.isWithinRange = (value, [start, end]) => {
|
|
430
|
+
return isWithinInterval(value, {
|
|
431
|
+
start,
|
|
432
|
+
end
|
|
433
|
+
});
|
|
434
|
+
};
|
|
435
|
+
this.startOfYear = value => {
|
|
436
|
+
return startOfYear(value);
|
|
437
|
+
};
|
|
438
|
+
this.startOfMonth = value => {
|
|
439
|
+
return startOfMonth(value);
|
|
440
|
+
};
|
|
441
|
+
this.startOfWeek = value => {
|
|
442
|
+
return startOfWeek(value, {
|
|
443
|
+
locale: this.locale
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
this.startOfDay = value => {
|
|
447
|
+
return startOfDay(value);
|
|
448
|
+
};
|
|
449
|
+
this.endOfYear = value => {
|
|
450
|
+
return endOfYear(value);
|
|
451
|
+
};
|
|
452
|
+
this.endOfMonth = value => {
|
|
453
|
+
return endOfMonth(value);
|
|
454
|
+
};
|
|
455
|
+
this.endOfWeek = value => {
|
|
456
|
+
return endOfWeek(value, {
|
|
457
|
+
locale: this.locale
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
this.endOfDay = value => {
|
|
461
|
+
return endOfDay(value);
|
|
462
|
+
};
|
|
463
|
+
this.addYears = (value, amount) => {
|
|
464
|
+
return addYears(value, amount);
|
|
465
|
+
};
|
|
466
|
+
this.addMonths = (value, amount) => {
|
|
467
|
+
return addMonths(value, amount);
|
|
468
|
+
};
|
|
469
|
+
this.addWeeks = (value, amount) => {
|
|
470
|
+
return addWeeks(value, amount);
|
|
471
|
+
};
|
|
472
|
+
this.addDays = (value, amount) => {
|
|
473
|
+
return addDays(value, amount);
|
|
474
|
+
};
|
|
475
|
+
this.addHours = (value, amount) => {
|
|
476
|
+
return addHours(value, amount);
|
|
477
|
+
};
|
|
478
|
+
this.addMinutes = (value, amount) => {
|
|
479
|
+
return addMinutes(value, amount);
|
|
480
|
+
};
|
|
481
|
+
this.addSeconds = (value, amount) => {
|
|
482
|
+
return addSeconds(value, amount);
|
|
483
|
+
};
|
|
484
|
+
this.getYear = value => {
|
|
485
|
+
return getYear(value);
|
|
486
|
+
};
|
|
487
|
+
this.getMonth = value => {
|
|
488
|
+
return getMonth(value);
|
|
489
|
+
};
|
|
490
|
+
this.getDate = value => {
|
|
491
|
+
return getDate(value);
|
|
492
|
+
};
|
|
493
|
+
this.getHours = value => {
|
|
494
|
+
return getHours(value);
|
|
495
|
+
};
|
|
496
|
+
this.getMinutes = value => {
|
|
497
|
+
return getMinutes(value);
|
|
498
|
+
};
|
|
499
|
+
this.getSeconds = value => {
|
|
500
|
+
return getSeconds(value);
|
|
501
|
+
};
|
|
502
|
+
this.setYear = (value, year) => {
|
|
503
|
+
return setYear(value, year);
|
|
504
|
+
};
|
|
505
|
+
this.setMonth = (value, month) => {
|
|
506
|
+
return setMonth(value, month);
|
|
507
|
+
};
|
|
508
|
+
this.setDate = (value, date) => {
|
|
509
|
+
return setDate(value, date);
|
|
510
|
+
};
|
|
511
|
+
this.setHours = (value, hours) => {
|
|
512
|
+
return setHours(value, hours);
|
|
513
|
+
};
|
|
514
|
+
this.setMinutes = (value, minutes) => {
|
|
515
|
+
return setMinutes(value, minutes);
|
|
516
|
+
};
|
|
517
|
+
this.setSeconds = (value, seconds) => {
|
|
518
|
+
return setSeconds(value, seconds);
|
|
519
|
+
};
|
|
520
|
+
this.getDaysInMonth = value => {
|
|
521
|
+
return getDaysInMonth(value);
|
|
522
|
+
};
|
|
523
|
+
this.getNextMonth = value => {
|
|
524
|
+
return addMonths(value, 1);
|
|
525
|
+
};
|
|
526
|
+
this.getPreviousMonth = value => {
|
|
527
|
+
return addMonths(value, -1);
|
|
528
|
+
};
|
|
529
|
+
this.getMonthArray = value => {
|
|
530
|
+
const firstMonth = startOfYear(value);
|
|
531
|
+
const monthArray = [firstMonth];
|
|
532
|
+
while (monthArray.length < 12) {
|
|
533
|
+
const prevMonth = monthArray[monthArray.length - 1];
|
|
534
|
+
monthArray.push(this.getNextMonth(prevMonth));
|
|
535
|
+
}
|
|
536
|
+
return monthArray;
|
|
537
|
+
};
|
|
538
|
+
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
539
|
+
return this.setSeconds(this.setMinutes(this.setHours(dateParam, this.getHours(timeParam)), this.getMinutes(timeParam)), this.getSeconds(timeParam));
|
|
540
|
+
};
|
|
541
|
+
this.getWeekdays = () => {
|
|
542
|
+
const now = new Date();
|
|
543
|
+
return eachDayOfInterval({
|
|
544
|
+
start: startOfWeek(now, {
|
|
545
|
+
locale: this.locale
|
|
546
|
+
}),
|
|
547
|
+
end: endOfWeek(now, {
|
|
548
|
+
locale: this.locale
|
|
549
|
+
})
|
|
550
|
+
}).map(day => this.formatByString(day, 'EEEEEE'));
|
|
551
|
+
};
|
|
552
|
+
this.getWeekArray = value => {
|
|
553
|
+
const start = startOfWeek(startOfMonth(value), {
|
|
554
|
+
locale: this.locale
|
|
555
|
+
});
|
|
556
|
+
const end = endOfWeek(endOfMonth(value), {
|
|
557
|
+
locale: this.locale
|
|
558
|
+
});
|
|
559
|
+
let count = 0;
|
|
560
|
+
let current = start;
|
|
561
|
+
const nestedWeeks = [];
|
|
562
|
+
let lastDay = null;
|
|
563
|
+
while (isBefore(current, end)) {
|
|
564
|
+
const weekNumber = Math.floor(count / 7);
|
|
565
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
566
|
+
const day = getDay(current);
|
|
567
|
+
if (lastDay !== day) {
|
|
568
|
+
lastDay = day;
|
|
569
|
+
nestedWeeks[weekNumber].push(current);
|
|
570
|
+
count += 1;
|
|
571
|
+
}
|
|
572
|
+
current = addDays(current, 1);
|
|
573
|
+
}
|
|
574
|
+
return nestedWeeks;
|
|
575
|
+
};
|
|
576
|
+
this.getWeekNumber = value => {
|
|
577
|
+
return getWeek(value, {
|
|
578
|
+
locale: this.locale
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
this.getYearRange = (start, end) => {
|
|
582
|
+
const startDate = startOfYear(start);
|
|
583
|
+
const endDate = endOfYear(end);
|
|
584
|
+
const years = [];
|
|
585
|
+
let current = startDate;
|
|
586
|
+
while (isBefore(current, endDate)) {
|
|
587
|
+
years.push(current);
|
|
588
|
+
current = addYears(current, 1);
|
|
589
|
+
}
|
|
590
|
+
return years;
|
|
591
|
+
};
|
|
592
|
+
this.getMeridiemText = ampm => {
|
|
593
|
+
return ampm === 'am' ? 'AM' : 'PM';
|
|
594
|
+
};
|
|
595
|
+
this.locale = _locale;
|
|
596
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
597
|
+
}
|
|
598
|
+
}
|