@mui/x-date-pickers 6.2.1 → 6.3.1
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 -3
- 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 +24 -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 +25 -3
- package/DateTimeField/DateTimeField.types.d.ts +4 -11
- package/DateTimeField/useDateTimeField.js +4 -2
- package/DateTimePicker/DateTimePicker.js +1 -0
- package/DateTimePicker/shared.d.ts +6 -12
- package/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -1
- package/DesktopTimePicker/DesktopTimePicker.js +52 -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 +5 -67
- package/TimeField/TimeField.js +25 -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 +61 -35
- 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 +12 -12
- 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} +13 -3
- 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/utils/{validation.d.ts → validation/extractValidationProps.d.ts} +1 -1
- package/internals/utils/{validation.js → validation/extractValidationProps.js} +1 -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 +24 -3
- package/legacy/DateField/useDateField.js +4 -2
- package/legacy/DatePicker/DatePickerToolbar.js +1 -1
- package/legacy/DateTimeField/DateTimeField.js +25 -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 +53 -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 +25 -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 +59 -35
- 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/utils/{validation.js → validation/extractValidationProps.js} +1 -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/describeValidation/testTextFieldValidation.js +26 -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 +24 -3
- package/modern/DateField/useDateField.js +4 -2
- package/modern/DatePicker/DatePickerToolbar.js +1 -1
- package/modern/DateTimeField/DateTimeField.js +25 -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 +51 -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 +25 -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 +61 -35
- 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/utils/{validation.js → validation/extractValidationProps.js} +1 -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/describeValidation/testTextFieldValidation.js +27 -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 +24 -3
- package/node/DateField/useDateField.js +5 -3
- package/node/DatePicker/DatePickerToolbar.js +1 -1
- package/node/DateTimeField/DateTimeField.js +25 -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 +52 -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 +25 -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 +64 -37
- 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.js → validation/extractValidationProps.js} +1 -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/describeValidation/testTextFieldValidation.js +27 -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/describeValidation/testTextFieldValidation.js +27 -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/node/{internals/hooks/validation/models.js → DigitalClock/DigitalClock.types.js} +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
import defaultHMoment from 'moment-hijri';
|
|
4
|
+
import { AdapterMoment } from '../AdapterMoment';
|
|
5
|
+
// From https://momentjs.com/docs/#/displaying/format/
|
|
6
|
+
const formatTokenMap = {
|
|
7
|
+
// Year
|
|
8
|
+
iY: {
|
|
9
|
+
sectionType: 'year',
|
|
10
|
+
contentType: 'letter'
|
|
11
|
+
},
|
|
12
|
+
iYY: {
|
|
13
|
+
sectionType: 'year',
|
|
14
|
+
contentType: 'letter'
|
|
15
|
+
},
|
|
16
|
+
iYYYY: {
|
|
17
|
+
sectionType: 'year',
|
|
18
|
+
contentType: 'letter'
|
|
19
|
+
},
|
|
20
|
+
// Month
|
|
21
|
+
iM: 'month',
|
|
22
|
+
iMM: 'month',
|
|
23
|
+
iMMM: {
|
|
24
|
+
sectionType: 'month',
|
|
25
|
+
contentType: 'letter'
|
|
26
|
+
},
|
|
27
|
+
iMMMM: {
|
|
28
|
+
sectionType: 'month',
|
|
29
|
+
contentType: 'letter'
|
|
30
|
+
},
|
|
31
|
+
// Day of the month
|
|
32
|
+
iD: {
|
|
33
|
+
sectionType: 'day',
|
|
34
|
+
contentType: 'digit',
|
|
35
|
+
maxLength: 2
|
|
36
|
+
},
|
|
37
|
+
iDD: 'day',
|
|
38
|
+
// Meridiem
|
|
39
|
+
A: 'meridiem',
|
|
40
|
+
a: 'meridiem',
|
|
41
|
+
// Hours
|
|
42
|
+
H: {
|
|
43
|
+
sectionType: 'hours',
|
|
44
|
+
contentType: 'digit',
|
|
45
|
+
maxLength: 2
|
|
46
|
+
},
|
|
47
|
+
HH: 'hours',
|
|
48
|
+
h: {
|
|
49
|
+
sectionType: 'hours',
|
|
50
|
+
contentType: 'digit',
|
|
51
|
+
maxLength: 2
|
|
52
|
+
},
|
|
53
|
+
hh: 'hours',
|
|
54
|
+
// Minutes
|
|
55
|
+
m: {
|
|
56
|
+
sectionType: 'minutes',
|
|
57
|
+
contentType: 'digit',
|
|
58
|
+
maxLength: 2
|
|
59
|
+
},
|
|
60
|
+
mm: 'minutes',
|
|
61
|
+
// Seconds
|
|
62
|
+
s: {
|
|
63
|
+
sectionType: 'seconds',
|
|
64
|
+
contentType: 'digit',
|
|
65
|
+
maxLength: 2
|
|
66
|
+
},
|
|
67
|
+
ss: 'seconds'
|
|
68
|
+
};
|
|
69
|
+
const defaultFormats = {
|
|
70
|
+
dayOfMonth: 'iD',
|
|
71
|
+
fullDate: 'iYYYY, iMMMM Do',
|
|
72
|
+
fullDateWithWeekday: 'iYYYY, iMMMM Do, dddd',
|
|
73
|
+
fullDateTime: 'iYYYY, iMMMM Do, hh:mm A',
|
|
74
|
+
fullDateTime12h: 'iD iMMMM hh:mm A',
|
|
75
|
+
fullDateTime24h: 'iD iMMMM HH:mm',
|
|
76
|
+
fullTime: 'LT',
|
|
77
|
+
fullTime12h: 'hh:mm A',
|
|
78
|
+
fullTime24h: 'HH:mm',
|
|
79
|
+
hours12h: 'hh',
|
|
80
|
+
hours24h: 'HH',
|
|
81
|
+
keyboardDate: 'iYYYY/iMM/iDD',
|
|
82
|
+
keyboardDateTime: 'iYYYY/iMM/iDD LT',
|
|
83
|
+
keyboardDateTime12h: 'iYYYY/iMM/iDD hh:mm A',
|
|
84
|
+
keyboardDateTime24h: 'iYYYY/iMM/iDD HH:mm',
|
|
85
|
+
minutes: 'mm',
|
|
86
|
+
month: 'iMMMM',
|
|
87
|
+
monthAndDate: 'iD iMMMM',
|
|
88
|
+
monthAndYear: 'iMMMM iYYYY',
|
|
89
|
+
monthShort: 'iMMM',
|
|
90
|
+
weekday: 'dddd',
|
|
91
|
+
weekdayShort: 'ddd',
|
|
92
|
+
normalDate: 'dddd, iD iMMM',
|
|
93
|
+
normalDateWithWeekday: 'DD iMMMM',
|
|
94
|
+
seconds: 'ss',
|
|
95
|
+
shortDate: 'iD iMMM',
|
|
96
|
+
year: 'iYYYY'
|
|
97
|
+
};
|
|
98
|
+
const NUMBER_SYMBOL_MAP = {
|
|
99
|
+
'1': '١',
|
|
100
|
+
'2': '٢',
|
|
101
|
+
'3': '٣',
|
|
102
|
+
'4': '٤',
|
|
103
|
+
'5': '٥',
|
|
104
|
+
'6': '٦',
|
|
105
|
+
'7': '٧',
|
|
106
|
+
'8': '٨',
|
|
107
|
+
'9': '٩',
|
|
108
|
+
'0': '٠'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Based on `@date-io/hijri`
|
|
113
|
+
*
|
|
114
|
+
* MIT License
|
|
115
|
+
*
|
|
116
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
117
|
+
*
|
|
118
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
119
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
120
|
+
* in the Software without restriction, including without limitation the rights
|
|
121
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
122
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
123
|
+
* furnished to do so, subject to the following conditions:
|
|
124
|
+
*
|
|
125
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
126
|
+
* copies or substantial portions of the Software.
|
|
127
|
+
*
|
|
128
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
129
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
130
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
131
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
132
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
133
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
134
|
+
* SOFTWARE.
|
|
135
|
+
*/
|
|
136
|
+
export class AdapterMomentHijri extends AdapterMoment {
|
|
137
|
+
constructor({
|
|
138
|
+
formats,
|
|
139
|
+
instance
|
|
140
|
+
} = {}) {
|
|
141
|
+
super({
|
|
142
|
+
locale: 'ar-SA',
|
|
143
|
+
instance
|
|
144
|
+
});
|
|
145
|
+
this.isMUIAdapter = true;
|
|
146
|
+
this.formatTokenMap = formatTokenMap;
|
|
147
|
+
this.escapedCharacters = {
|
|
148
|
+
start: '[',
|
|
149
|
+
end: ']'
|
|
150
|
+
};
|
|
151
|
+
this.toIMoment = value => {
|
|
152
|
+
return this.moment(value ? value.clone() : undefined).locale('ar-SA');
|
|
153
|
+
};
|
|
154
|
+
this.date = value => {
|
|
155
|
+
if (value === null) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
return this.moment(value).locale('ar-SA');
|
|
159
|
+
};
|
|
160
|
+
this.parse = (value, format) => {
|
|
161
|
+
if (value === '') {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return this.moment(value, format, true).locale('ar-SA');
|
|
165
|
+
};
|
|
166
|
+
this.getFormatHelperText = format => {
|
|
167
|
+
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('iY', 'Y').replace('iM', 'M').replace('iD', 'D').toLocaleLowerCase();
|
|
168
|
+
};
|
|
169
|
+
this.formatNumber = numberToFormat => {
|
|
170
|
+
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
171
|
+
};
|
|
172
|
+
this.isEqual = (value, comparing) => {
|
|
173
|
+
if (value === null && comparing === null) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return this.moment(value).isSame(comparing);
|
|
177
|
+
};
|
|
178
|
+
this.startOfYear = value => {
|
|
179
|
+
return value.clone().startOf('iYear');
|
|
180
|
+
};
|
|
181
|
+
this.startOfMonth = value => {
|
|
182
|
+
return value.clone().startOf('iMonth');
|
|
183
|
+
};
|
|
184
|
+
this.endOfYear = value => {
|
|
185
|
+
return value.clone().endOf('iYear');
|
|
186
|
+
};
|
|
187
|
+
this.endOfMonth = value => {
|
|
188
|
+
return value.clone().endOf('iMonth');
|
|
189
|
+
};
|
|
190
|
+
this.addYears = (value, amount) => {
|
|
191
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iYear') : value.clone().add(amount, 'iYear');
|
|
192
|
+
};
|
|
193
|
+
this.addMonths = (value, amount) => {
|
|
194
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iMonth') : value.clone().add(amount, 'iMonth');
|
|
195
|
+
};
|
|
196
|
+
this.getYear = value => {
|
|
197
|
+
return value.iYear();
|
|
198
|
+
};
|
|
199
|
+
this.getMonth = value => {
|
|
200
|
+
return value.iMonth();
|
|
201
|
+
};
|
|
202
|
+
this.getDate = value => {
|
|
203
|
+
return value.iDate();
|
|
204
|
+
};
|
|
205
|
+
this.setYear = (value, year) => {
|
|
206
|
+
return value.clone().iYear(year);
|
|
207
|
+
};
|
|
208
|
+
this.setMonth = (value, month) => {
|
|
209
|
+
return value.clone().iMonth(month);
|
|
210
|
+
};
|
|
211
|
+
this.setDate = (value, date) => {
|
|
212
|
+
return value.clone().iDate(date);
|
|
213
|
+
};
|
|
214
|
+
this.getNextMonth = value => {
|
|
215
|
+
return value.clone().add(1, 'iMonth');
|
|
216
|
+
};
|
|
217
|
+
this.getPreviousMonth = value => {
|
|
218
|
+
return value.clone().subtract(1, 'iMonth');
|
|
219
|
+
};
|
|
220
|
+
this.getWeekdays = () => {
|
|
221
|
+
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
222
|
+
return this.toIMoment().weekday(dayOfWeek).format('dd');
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
this.getWeekArray = value => {
|
|
226
|
+
const start = value.clone().startOf('iMonth').startOf('week');
|
|
227
|
+
const end = value.clone().endOf('iMonth').endOf('week');
|
|
228
|
+
let count = 0;
|
|
229
|
+
let current = start;
|
|
230
|
+
const nestedWeeks = [];
|
|
231
|
+
while (current.isBefore(end)) {
|
|
232
|
+
const weekNumber = Math.floor(count / 7);
|
|
233
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
234
|
+
nestedWeeks[weekNumber].push(current);
|
|
235
|
+
current = current.clone().add(1, 'day');
|
|
236
|
+
count += 1;
|
|
237
|
+
}
|
|
238
|
+
return nestedWeeks;
|
|
239
|
+
};
|
|
240
|
+
this.getWeekNumber = value => {
|
|
241
|
+
return value.iWeek();
|
|
242
|
+
};
|
|
243
|
+
this.getYearRange = (start, end) => {
|
|
244
|
+
// moment-hijri only supports dates between 1356-01-01 H and 1499-12-29 H
|
|
245
|
+
// We need to throw if outside min/max bounds, otherwise the while loop below will be infinite.
|
|
246
|
+
if (start.isBefore('1937-03-14')) {
|
|
247
|
+
throw new Error('min date must be on or after 1356-01-01 H (1937-03-14)');
|
|
248
|
+
}
|
|
249
|
+
if (end.isAfter('2076-11-26')) {
|
|
250
|
+
throw new Error('max date must be on or before 1499-12-29 H (2076-11-26)');
|
|
251
|
+
}
|
|
252
|
+
const startDate = this.moment(start).startOf('iYear');
|
|
253
|
+
const endDate = this.moment(end).endOf('iYear');
|
|
254
|
+
const years = [];
|
|
255
|
+
let current = startDate;
|
|
256
|
+
while (current.isBefore(endDate)) {
|
|
257
|
+
years.push(current);
|
|
258
|
+
current = current.clone().add(1, 'iYear');
|
|
259
|
+
}
|
|
260
|
+
return years;
|
|
261
|
+
};
|
|
262
|
+
this.getMeridiemText = ampm => {
|
|
263
|
+
return ampm === 'am' ? this.toIMoment().hours(2).format('A') : this.toIMoment().hours(14).format('A');
|
|
264
|
+
};
|
|
265
|
+
this.moment = instance || defaultHMoment;
|
|
266
|
+
this.locale = 'ar-SA';
|
|
267
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import BaseAdapterMomentHijri from '@date-io/hijri';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
|
|
5
|
-
// From https://momentjs.com/docs/#/displaying/format/
|
|
6
|
-
const formatTokenMap = {
|
|
7
|
-
// Year
|
|
8
|
-
iY: 'year',
|
|
9
|
-
iYY: 'year',
|
|
10
|
-
iYYYY: 'year',
|
|
11
|
-
// Month
|
|
12
|
-
iM: 'month',
|
|
13
|
-
iMM: 'month',
|
|
14
|
-
iMMM: {
|
|
15
|
-
sectionType: 'month',
|
|
16
|
-
contentType: 'letter'
|
|
17
|
-
},
|
|
18
|
-
iMMMM: {
|
|
19
|
-
sectionType: 'month',
|
|
20
|
-
contentType: 'letter'
|
|
21
|
-
},
|
|
22
|
-
// Day of the month
|
|
23
|
-
iD: 'day',
|
|
24
|
-
iDD: 'day',
|
|
25
|
-
// Meridiem
|
|
26
|
-
A: 'meridiem',
|
|
27
|
-
a: 'meridiem',
|
|
28
|
-
// Hours
|
|
29
|
-
H: 'hours',
|
|
30
|
-
HH: 'hours',
|
|
31
|
-
h: 'hours',
|
|
32
|
-
hh: 'hours',
|
|
33
|
-
k: 'hours',
|
|
34
|
-
kk: 'hours',
|
|
35
|
-
// Minutes
|
|
36
|
-
m: 'minutes',
|
|
37
|
-
mm: 'minutes',
|
|
38
|
-
// Seconds
|
|
39
|
-
s: 'seconds',
|
|
40
|
-
ss: 'seconds'
|
|
41
|
-
};
|
|
42
|
-
export class AdapterMomentHijri extends BaseAdapterMomentHijri {
|
|
43
|
-
constructor(...args) {
|
|
44
|
-
super(...args);
|
|
45
|
-
this.isMUIAdapter = true;
|
|
46
|
-
this.formatTokenMap = formatTokenMap;
|
|
47
|
-
this.escapedCharacters = {
|
|
48
|
-
start: '[',
|
|
49
|
-
end: ']'
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
53
|
-
* We should use this one in the future to support all localized formats.
|
|
54
|
-
*/
|
|
55
|
-
this.expandFormat = format => {
|
|
56
|
-
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
57
|
-
const localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
58
|
-
return format.match(localFormattingTokens).map(token => {
|
|
59
|
-
const firstCharacter = token[0];
|
|
60
|
-
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
61
|
-
return this.moment.localeData(this.getCurrentLocaleCode()).longDateFormat(token);
|
|
62
|
-
}
|
|
63
|
-
return token;
|
|
64
|
-
}).join('').replace('dd', 'iDD'); // Fix for https://github.com/dmtrKovalenko/date-io/pull/632
|
|
65
|
-
};
|
|
66
|
-
// Redefined here just to show how it can be written using expandFormat
|
|
67
|
-
this.getFormatHelperText = format => {
|
|
68
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('iY', 'Y').replace('iM', 'M').replace('iD', 'D').toLocaleLowerCase();
|
|
69
|
-
};
|
|
70
|
-
this.getWeekNumber = date => {
|
|
71
|
-
return date.iWeek();
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
export { AdapterMomentHijri } from './AdapterMomentHijri';
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
import defaultJMoment from 'moment-jalaali';
|
|
4
|
+
import { AdapterMoment } from '../AdapterMoment';
|
|
5
|
+
// From https://momentjs.com/docs/#/displaying/format/
|
|
6
|
+
const formatTokenMap = {
|
|
7
|
+
// Year
|
|
8
|
+
jYY: 'year',
|
|
9
|
+
jYYYY: {
|
|
10
|
+
sectionType: 'year',
|
|
11
|
+
contentType: 'digit',
|
|
12
|
+
maxLength: 4
|
|
13
|
+
},
|
|
14
|
+
// Month
|
|
15
|
+
jM: {
|
|
16
|
+
sectionType: 'month',
|
|
17
|
+
contentType: 'digit',
|
|
18
|
+
maxLength: 2
|
|
19
|
+
},
|
|
20
|
+
jMM: 'month',
|
|
21
|
+
jMMM: {
|
|
22
|
+
sectionType: 'month',
|
|
23
|
+
contentType: 'letter'
|
|
24
|
+
},
|
|
25
|
+
jMMMM: {
|
|
26
|
+
sectionType: 'month',
|
|
27
|
+
contentType: 'letter'
|
|
28
|
+
},
|
|
29
|
+
// Day of the month
|
|
30
|
+
jD: {
|
|
31
|
+
sectionType: 'day',
|
|
32
|
+
contentType: 'digit',
|
|
33
|
+
maxLength: 2
|
|
34
|
+
},
|
|
35
|
+
jDD: 'day',
|
|
36
|
+
// Meridiem
|
|
37
|
+
A: 'meridiem',
|
|
38
|
+
a: 'meridiem',
|
|
39
|
+
// Hours
|
|
40
|
+
H: {
|
|
41
|
+
sectionType: 'hours',
|
|
42
|
+
contentType: 'digit',
|
|
43
|
+
maxLength: 2
|
|
44
|
+
},
|
|
45
|
+
HH: 'hours',
|
|
46
|
+
h: {
|
|
47
|
+
sectionType: 'hours',
|
|
48
|
+
contentType: 'digit',
|
|
49
|
+
maxLength: 2
|
|
50
|
+
},
|
|
51
|
+
hh: 'hours',
|
|
52
|
+
// Minutes
|
|
53
|
+
m: {
|
|
54
|
+
sectionType: 'minutes',
|
|
55
|
+
contentType: 'digit',
|
|
56
|
+
maxLength: 2
|
|
57
|
+
},
|
|
58
|
+
mm: 'minutes',
|
|
59
|
+
// Seconds
|
|
60
|
+
s: {
|
|
61
|
+
sectionType: 'seconds',
|
|
62
|
+
contentType: 'digit',
|
|
63
|
+
maxLength: 2
|
|
64
|
+
},
|
|
65
|
+
ss: 'seconds'
|
|
66
|
+
};
|
|
67
|
+
const defaultFormats = {
|
|
68
|
+
dayOfMonth: 'jD',
|
|
69
|
+
fullDate: 'jYYYY, jMMMM Do',
|
|
70
|
+
fullDateWithWeekday: 'dddd Do jMMMM jYYYY',
|
|
71
|
+
fullDateTime: 'jYYYY, jMMMM Do, hh:mm A',
|
|
72
|
+
fullDateTime12h: 'jD jMMMM hh:mm A',
|
|
73
|
+
fullDateTime24h: 'jD jMMMM HH:mm',
|
|
74
|
+
fullTime: 'LT',
|
|
75
|
+
fullTime12h: 'hh:mm A',
|
|
76
|
+
fullTime24h: 'HH:mm',
|
|
77
|
+
hours12h: 'hh',
|
|
78
|
+
hours24h: 'HH',
|
|
79
|
+
keyboardDate: 'jYYYY/jMM/jDD',
|
|
80
|
+
keyboardDateTime: 'jYYYY/jMM/jDD LT',
|
|
81
|
+
keyboardDateTime12h: 'jYYYY/jMM/jDD hh:mm A',
|
|
82
|
+
keyboardDateTime24h: 'jYYYY/jMM/jDD HH:mm',
|
|
83
|
+
minutes: 'mm',
|
|
84
|
+
month: 'jMMMM',
|
|
85
|
+
monthAndDate: 'jD jMMMM',
|
|
86
|
+
monthAndYear: 'jMMMM jYYYY',
|
|
87
|
+
monthShort: 'jMMM',
|
|
88
|
+
weekday: 'dddd',
|
|
89
|
+
weekdayShort: 'ddd',
|
|
90
|
+
normalDate: 'dddd, jD jMMM',
|
|
91
|
+
normalDateWithWeekday: 'DD MMMM',
|
|
92
|
+
seconds: 'ss',
|
|
93
|
+
shortDate: 'jD jMMM',
|
|
94
|
+
year: 'jYYYY'
|
|
95
|
+
};
|
|
96
|
+
const NUMBER_SYMBOL_MAP = {
|
|
97
|
+
'1': '۱',
|
|
98
|
+
'2': '۲',
|
|
99
|
+
'3': '۳',
|
|
100
|
+
'4': '۴',
|
|
101
|
+
'5': '۵',
|
|
102
|
+
'6': '۶',
|
|
103
|
+
'7': '۷',
|
|
104
|
+
'8': '۸',
|
|
105
|
+
'9': '۹',
|
|
106
|
+
'0': '۰'
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Based on `@date-io/jalaali`
|
|
111
|
+
*
|
|
112
|
+
* MIT License
|
|
113
|
+
*
|
|
114
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
115
|
+
*
|
|
116
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
117
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
118
|
+
* in the Software without restriction, including without limitation the rights
|
|
119
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
120
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
121
|
+
* furnished to do so, subject to the following conditions:
|
|
122
|
+
*
|
|
123
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
124
|
+
* copies or substantial portions of the Software.
|
|
125
|
+
*
|
|
126
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
127
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
128
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
129
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
130
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
131
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
132
|
+
* SOFTWARE.
|
|
133
|
+
*/
|
|
134
|
+
export class AdapterMomentJalaali extends AdapterMoment {
|
|
135
|
+
constructor({
|
|
136
|
+
formats,
|
|
137
|
+
instance
|
|
138
|
+
} = {}) {
|
|
139
|
+
super({
|
|
140
|
+
locale: 'fa',
|
|
141
|
+
instance
|
|
142
|
+
});
|
|
143
|
+
this.isMUIAdapter = true;
|
|
144
|
+
this.lib = 'moment-jalaali';
|
|
145
|
+
this.moment = void 0;
|
|
146
|
+
this.locale = void 0;
|
|
147
|
+
this.formats = void 0;
|
|
148
|
+
this.formatTokenMap = formatTokenMap;
|
|
149
|
+
this.escapedCharacters = {
|
|
150
|
+
start: '[',
|
|
151
|
+
end: ']'
|
|
152
|
+
};
|
|
153
|
+
this.toJMoment = value => {
|
|
154
|
+
return this.moment(value ? value.clone() : undefined).locale('fa');
|
|
155
|
+
};
|
|
156
|
+
this.date = value => {
|
|
157
|
+
if (value === null) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return this.moment(value).locale('fa');
|
|
161
|
+
};
|
|
162
|
+
this.parse = (value, format) => {
|
|
163
|
+
if (value === '') {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return this.moment(value, format, true).locale('fa');
|
|
167
|
+
};
|
|
168
|
+
this.getFormatHelperText = format => {
|
|
169
|
+
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('jY', 'Y').replace('jM', 'M').replace('jD', 'D').toLocaleLowerCase();
|
|
170
|
+
};
|
|
171
|
+
this.isValid = value => {
|
|
172
|
+
// We can't to `this.moment(value)` because moment-jalaali looses the invalidity information when creating a new moment object from an existing one
|
|
173
|
+
if (!this.moment.isMoment(value)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return value.isValid();
|
|
177
|
+
};
|
|
178
|
+
this.formatNumber = numberToFormat => {
|
|
179
|
+
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
180
|
+
};
|
|
181
|
+
this.isEqual = (value, comparing) => {
|
|
182
|
+
if (value === null && comparing === null) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return this.moment(value).isSame(comparing);
|
|
186
|
+
};
|
|
187
|
+
this.isAfterYear = (value, comparing) => {
|
|
188
|
+
return value.jYear() > comparing.jYear();
|
|
189
|
+
};
|
|
190
|
+
this.isBeforeYear = (value, comparing) => {
|
|
191
|
+
return value.jYear() < comparing.jYear();
|
|
192
|
+
};
|
|
193
|
+
this.startOfYear = value => {
|
|
194
|
+
return value.clone().startOf('jYear');
|
|
195
|
+
};
|
|
196
|
+
this.startOfMonth = value => {
|
|
197
|
+
return value.clone().startOf('jMonth');
|
|
198
|
+
};
|
|
199
|
+
this.endOfYear = value => {
|
|
200
|
+
return value.clone().endOf('jYear');
|
|
201
|
+
};
|
|
202
|
+
this.endOfMonth = value => {
|
|
203
|
+
return value.clone().endOf('jMonth');
|
|
204
|
+
};
|
|
205
|
+
this.addYears = (value, amount) => {
|
|
206
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jYear') : value.clone().add(amount, 'jYear');
|
|
207
|
+
};
|
|
208
|
+
this.addMonths = (value, amount) => {
|
|
209
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jMonth') : value.clone().add(amount, 'jMonth');
|
|
210
|
+
};
|
|
211
|
+
this.getYear = value => {
|
|
212
|
+
return value.jYear();
|
|
213
|
+
};
|
|
214
|
+
this.getMonth = value => {
|
|
215
|
+
return value.jMonth();
|
|
216
|
+
};
|
|
217
|
+
this.getDate = value => {
|
|
218
|
+
return value.jDate();
|
|
219
|
+
};
|
|
220
|
+
this.setYear = (value, year) => {
|
|
221
|
+
return value.clone().jYear(year);
|
|
222
|
+
};
|
|
223
|
+
this.setMonth = (value, month) => {
|
|
224
|
+
return value.clone().jMonth(month);
|
|
225
|
+
};
|
|
226
|
+
this.setDate = (value, date) => {
|
|
227
|
+
return value.clone().jDate(date);
|
|
228
|
+
};
|
|
229
|
+
this.getNextMonth = value => {
|
|
230
|
+
return value.clone().add(1, 'jMonth');
|
|
231
|
+
};
|
|
232
|
+
this.getPreviousMonth = value => {
|
|
233
|
+
return value.clone().subtract(1, 'jMonth');
|
|
234
|
+
};
|
|
235
|
+
this.getWeekdays = () => {
|
|
236
|
+
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
237
|
+
return this.toJMoment().weekday(dayOfWeek).format('dd');
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
this.getWeekArray = value => {
|
|
241
|
+
const start = value.clone().startOf('jMonth').startOf('week');
|
|
242
|
+
const end = value.clone().endOf('jMonth').endOf('week');
|
|
243
|
+
let count = 0;
|
|
244
|
+
let current = start;
|
|
245
|
+
const nestedWeeks = [];
|
|
246
|
+
while (current.isBefore(end)) {
|
|
247
|
+
const weekNumber = Math.floor(count / 7);
|
|
248
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
249
|
+
nestedWeeks[weekNumber].push(current);
|
|
250
|
+
current = current.clone().add(1, 'day');
|
|
251
|
+
count += 1;
|
|
252
|
+
}
|
|
253
|
+
return nestedWeeks;
|
|
254
|
+
};
|
|
255
|
+
this.getWeekNumber = value => {
|
|
256
|
+
return value.jWeek();
|
|
257
|
+
};
|
|
258
|
+
this.getYearRange = (start, end) => {
|
|
259
|
+
const startDate = this.moment(start).startOf('jYear');
|
|
260
|
+
const endDate = this.moment(end).endOf('jYear');
|
|
261
|
+
const years = [];
|
|
262
|
+
let current = startDate;
|
|
263
|
+
while (current.isBefore(endDate)) {
|
|
264
|
+
years.push(current);
|
|
265
|
+
current = current.clone().add(1, 'jYear');
|
|
266
|
+
}
|
|
267
|
+
return years;
|
|
268
|
+
};
|
|
269
|
+
this.getMeridiemText = ampm => {
|
|
270
|
+
return ampm === 'am' ? this.toJMoment().hours(2).format('A') : this.toJMoment().hours(14).format('A');
|
|
271
|
+
};
|
|
272
|
+
this.moment = instance || defaultJMoment;
|
|
273
|
+
this.locale = 'fa';
|
|
274
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -1,87 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import BaseAdapterMomentJalaali from '@date-io/jalaali';
|
|
3
|
-
// From https://momentjs.com/docs/#/displaying/format/
|
|
4
|
-
const formatTokenMap = {
|
|
5
|
-
// Year
|
|
6
|
-
jYY: 'year',
|
|
7
|
-
jYYYY: 'year',
|
|
8
|
-
// Month
|
|
9
|
-
jM: 'month',
|
|
10
|
-
jMM: 'month',
|
|
11
|
-
jMMM: {
|
|
12
|
-
sectionType: 'month',
|
|
13
|
-
contentType: 'letter'
|
|
14
|
-
},
|
|
15
|
-
jMMMM: {
|
|
16
|
-
sectionType: 'month',
|
|
17
|
-
contentType: 'letter'
|
|
18
|
-
},
|
|
19
|
-
// Day of the month
|
|
20
|
-
jD: 'day',
|
|
21
|
-
jDD: 'day',
|
|
22
|
-
// Meridiem
|
|
23
|
-
A: 'meridiem',
|
|
24
|
-
a: 'meridiem',
|
|
25
|
-
// Hours
|
|
26
|
-
H: 'hours',
|
|
27
|
-
HH: 'hours',
|
|
28
|
-
h: 'hours',
|
|
29
|
-
hh: 'hours',
|
|
30
|
-
k: 'hours',
|
|
31
|
-
kk: 'hours',
|
|
32
|
-
// Minutes
|
|
33
|
-
m: 'minutes',
|
|
34
|
-
mm: 'minutes',
|
|
35
|
-
// Seconds
|
|
36
|
-
s: 'seconds',
|
|
37
|
-
ss: 'seconds'
|
|
38
|
-
};
|
|
39
|
-
export class AdapterMomentJalaali extends BaseAdapterMomentJalaali {
|
|
40
|
-
constructor(...args) {
|
|
41
|
-
super(...args);
|
|
42
|
-
this.isMUIAdapter = true;
|
|
43
|
-
this.formatTokenMap = formatTokenMap;
|
|
44
|
-
this.escapedCharacters = {
|
|
45
|
-
start: '[',
|
|
46
|
-
end: ']'
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
50
|
-
* We should use this one in the future to support all localized formats.
|
|
51
|
-
*/
|
|
52
|
-
this.expandFormat = format => {
|
|
53
|
-
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
54
|
-
const localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
55
|
-
return format.match(localFormattingTokens).map(token => {
|
|
56
|
-
const firstCharacter = token[0];
|
|
57
|
-
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
58
|
-
return this.moment.localeData(this.getCurrentLocaleCode()).longDateFormat(token);
|
|
59
|
-
}
|
|
60
|
-
return token;
|
|
61
|
-
}).join('').replace('dd', 'jDD'); // Fix for https://github.com/dmtrKovalenko/date-io/pull/632;
|
|
62
|
-
};
|
|
63
|
-
// Redefined here just to show how it can be written using expandFormat
|
|
64
|
-
this.getFormatHelperText = format => {
|
|
65
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('jY', 'Y').replace('jM', 'M').replace('jD', 'D').toLocaleLowerCase();
|
|
66
|
-
};
|
|
67
|
-
this.getWeekNumber = date => {
|
|
68
|
-
return date.jWeek();
|
|
69
|
-
};
|
|
70
|
-
this.addYears = (date, count) => {
|
|
71
|
-
return count < 0 ? date.clone().subtract(Math.abs(count), 'jYear') : date.clone().add(count, 'jYear');
|
|
72
|
-
};
|
|
73
|
-
this.addMonths = (date, count) => {
|
|
74
|
-
return count < 0 ? date.clone().subtract(Math.abs(count), 'jMonth') : date.clone().add(count, 'jMonth');
|
|
75
|
-
};
|
|
76
|
-
this.setMonth = (date, month) => {
|
|
77
|
-
return date.clone().jMonth(month);
|
|
78
|
-
};
|
|
79
|
-
this.isValid = value => {
|
|
80
|
-
// We can't to `this.moment(value)` because moment-jalaali looses the invalidity information when creating a new moment object from an existing one
|
|
81
|
-
if (!this.moment.isMoment(value)) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
return value.isValid(value);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
export { AdapterMomentJalaali } from './AdapterMomentJalaali';
|