@mui/x-date-pickers 6.18.1 → 7.0.0-alpha.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 +4 -15
- package/AdapterDateFns/AdapterDateFns.js +8 -90
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +4 -15
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
- package/AdapterDayjs/AdapterDayjs.d.ts +5 -17
- package/AdapterDayjs/AdapterDayjs.js +11 -60
- package/AdapterLuxon/AdapterLuxon.d.ts +4 -15
- package/AdapterLuxon/AdapterLuxon.js +16 -76
- package/AdapterMoment/AdapterMoment.d.ts +4 -20
- package/AdapterMoment/AdapterMoment.js +9 -66
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +1 -7
- package/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +1 -9
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
- package/CHANGELOG.md +558 -1
- package/DateCalendar/DateCalendar.js +4 -21
- package/DateCalendar/DateCalendar.types.d.ts +12 -3
- package/DateCalendar/DayCalendar.d.ts +13 -5
- package/DateCalendar/DayCalendar.js +12 -21
- package/DateCalendar/index.d.ts +0 -1
- package/DateCalendar/index.js +1 -3
- package/DateCalendar/useCalendarState.js +2 -3
- package/DateField/DateField.js +5 -21
- package/DateField/DateField.types.d.ts +12 -3
- package/DatePicker/DatePicker.js +0 -13
- package/DatePicker/DatePicker.types.d.ts +1 -14
- package/DatePicker/shared.d.ts +4 -16
- package/DatePicker/shared.js +2 -5
- package/DateTimeField/DateTimeField.js +5 -21
- package/DateTimeField/DateTimeField.types.d.ts +2 -15
- package/DateTimePicker/DateTimePicker.js +0 -13
- package/DateTimePicker/DateTimePicker.types.d.ts +1 -14
- package/DateTimePicker/shared.d.ts +4 -17
- package/DateTimePicker/shared.js +4 -7
- package/DesktopDatePicker/DesktopDatePicker.js +0 -13
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +2 -15
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -13
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -15
- package/DesktopTimePicker/DesktopTimePicker.js +0 -12
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -15
- package/DigitalClock/DigitalClock.js +18 -26
- package/DigitalClock/DigitalClock.types.d.ts +2 -15
- package/LocalizationProvider/LocalizationProvider.js +0 -6
- package/MobileDatePicker/MobileDatePicker.js +0 -13
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -15
- package/MobileDateTimePicker/MobileDateTimePicker.js +0 -13
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +2 -15
- package/MobileTimePicker/MobileTimePicker.js +0 -12
- package/MobileTimePicker/MobileTimePicker.types.d.ts +2 -15
- package/MonthCalendar/MonthCalendar.js +3 -7
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +7 -18
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +3 -15
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +2 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +16 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +1 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/PickersCalendarHeader/PickersCalendarHeader.js +14 -20
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -16
- package/PickersLayout/PickersLayout.js +0 -12
- package/PickersLayout/PickersLayout.types.d.ts +6 -19
- package/PickersLayout/usePickerLayout.js +2 -7
- package/StaticDatePicker/StaticDatePicker.js +0 -13
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -14
- package/StaticDateTimePicker/StaticDateTimePicker.js +0 -13
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -14
- package/StaticTimePicker/StaticTimePicker.js +0 -12
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -14
- package/TimeClock/TimeClock.js +3 -20
- package/TimeClock/TimeClock.types.d.ts +1 -14
- package/TimeField/TimeField.js +5 -21
- package/TimeField/TimeField.types.d.ts +2 -15
- package/TimePicker/TimePicker.js +0 -12
- package/TimePicker/TimePicker.types.d.ts +1 -14
- package/TimePicker/shared.d.ts +3 -16
- package/TimePicker/shared.js +4 -7
- package/YearCalendar/YearCalendar.js +4 -8
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +2 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +2 -8
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +0 -4
- package/hooks/useClearableField.d.ts +1 -3
- package/hooks/useClearableField.js +6 -8
- package/index.d.ts +1 -0
- package/index.js +4 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +10 -6
- package/internals/components/PickersModalDialog.d.ts +4 -5
- package/internals/components/PickersPopper.d.ts +5 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -8
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.js +0 -1
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -4
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +1 -14
- package/internals/index.d.ts +0 -2
- package/internals/index.js +0 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +1 -2
- package/internals/utils/getDefaultReferenceDate.js +0 -4
- package/legacy/AdapterDateFns/AdapterDateFns.js +11 -92
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +11 -92
- package/legacy/AdapterDayjs/AdapterDayjs.js +15 -63
- package/legacy/AdapterLuxon/AdapterLuxon.js +19 -78
- package/legacy/AdapterMoment/AdapterMoment.js +12 -70
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -30
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -40
- package/legacy/DateCalendar/DateCalendar.js +4 -21
- package/legacy/DateCalendar/DayCalendar.js +10 -16
- package/legacy/DateCalendar/index.js +1 -3
- package/legacy/DateCalendar/useCalendarState.js +2 -3
- package/legacy/DateField/DateField.js +6 -22
- package/legacy/DatePicker/DatePicker.js +0 -13
- package/legacy/DatePicker/shared.js +2 -5
- package/legacy/DateTimeField/DateTimeField.js +6 -22
- package/legacy/DateTimePicker/DateTimePicker.js +0 -13
- package/legacy/DateTimePicker/shared.js +4 -7
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +0 -13
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -13
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +0 -12
- package/legacy/DigitalClock/DigitalClock.js +20 -26
- package/legacy/LocalizationProvider/LocalizationProvider.js +0 -6
- package/legacy/MobileDatePicker/MobileDatePicker.js +0 -13
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +0 -13
- package/legacy/MobileTimePicker/MobileTimePicker.js +0 -12
- package/legacy/MonthCalendar/MonthCalendar.js +3 -6
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -18
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +16 -6
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +15 -10
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +14 -20
- package/legacy/PickersLayout/PickersLayout.js +0 -12
- package/legacy/PickersLayout/usePickerLayout.js +2 -7
- package/legacy/StaticDatePicker/StaticDatePicker.js +0 -13
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +0 -13
- package/legacy/StaticTimePicker/StaticTimePicker.js +0 -12
- package/legacy/TimeClock/TimeClock.js +3 -20
- package/legacy/TimeField/TimeField.js +5 -21
- package/legacy/TimePicker/TimePicker.js +0 -12
- package/legacy/TimePicker/shared.js +4 -7
- package/legacy/YearCalendar/YearCalendar.js +4 -7
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +2 -8
- package/legacy/dateViewRenderers/dateViewRenderers.js +0 -4
- package/legacy/hooks/useClearableField.js +6 -8
- package/legacy/index.js +4 -1
- package/legacy/internals/hooks/useField/useField.utils.js +0 -1
- package/legacy/internals/hooks/useField/useFieldState.js +1 -1
- package/legacy/internals/index.js +0 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +0 -6
- package/legacy/locales/esES.js +6 -7
- package/legacy/locales/eu.js +94 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/timeViewRenderers/timeViewRenderers.js +0 -12
- package/locales/esES.js +6 -7
- package/locales/eu.d.ts +54 -0
- package/locales/eu.js +58 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/adapters.d.ts +10 -135
- package/models/fields.d.ts +0 -6
- package/modern/AdapterDateFns/AdapterDateFns.js +8 -90
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
- package/modern/AdapterDayjs/AdapterDayjs.js +11 -59
- package/modern/AdapterLuxon/AdapterLuxon.js +16 -76
- package/modern/AdapterMoment/AdapterMoment.js +9 -65
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
- package/modern/DateCalendar/DateCalendar.js +3 -20
- package/modern/DateCalendar/DayCalendar.js +11 -19
- package/modern/DateCalendar/index.js +1 -3
- package/modern/DateCalendar/useCalendarState.js +2 -3
- package/modern/DateField/DateField.js +4 -20
- package/modern/DatePicker/DatePicker.js +0 -13
- package/modern/DatePicker/shared.js +1 -4
- package/modern/DateTimeField/DateTimeField.js +4 -20
- package/modern/DateTimePicker/DateTimePicker.js +0 -13
- package/modern/DateTimePicker/shared.js +3 -6
- package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -13
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -13
- package/modern/DesktopTimePicker/DesktopTimePicker.js +0 -12
- package/modern/DigitalClock/DigitalClock.js +17 -25
- package/modern/LocalizationProvider/LocalizationProvider.js +0 -6
- package/modern/MobileDatePicker/MobileDatePicker.js +0 -13
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -13
- package/modern/MobileTimePicker/MobileTimePicker.js +0 -12
- package/modern/MonthCalendar/MonthCalendar.js +3 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +7 -18
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +16 -6
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +13 -19
- package/modern/PickersLayout/PickersLayout.js +0 -12
- package/modern/PickersLayout/usePickerLayout.js +2 -7
- package/modern/StaticDatePicker/StaticDatePicker.js +0 -13
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +0 -13
- package/modern/StaticTimePicker/StaticTimePicker.js +0 -12
- package/modern/TimeClock/TimeClock.js +3 -20
- package/modern/TimeField/TimeField.js +4 -20
- package/modern/TimePicker/TimePicker.js +0 -12
- package/modern/TimePicker/shared.js +3 -6
- package/modern/YearCalendar/YearCalendar.js +4 -8
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +1 -7
- package/modern/dateViewRenderers/dateViewRenderers.js +0 -4
- package/modern/hooks/useClearableField.js +5 -7
- package/modern/index.js +4 -1
- package/modern/internals/hooks/useField/useField.utils.js +0 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -1
- package/modern/internals/index.js +0 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +0 -1
- package/modern/locales/esES.js +6 -7
- package/modern/locales/eu.js +58 -0
- package/modern/locales/index.js +1 -0
- package/modern/timeViewRenderers/timeViewRenderers.js +0 -12
- package/node/AdapterDateFns/AdapterDateFns.js +8 -90
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
- package/node/AdapterDayjs/AdapterDayjs.js +11 -59
- package/node/AdapterLuxon/AdapterLuxon.js +16 -76
- package/node/AdapterMoment/AdapterMoment.js +9 -65
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
- package/node/DateCalendar/DateCalendar.js +3 -20
- package/node/DateCalendar/DayCalendar.js +11 -19
- package/node/DateCalendar/index.js +1 -21
- package/node/DateCalendar/useCalendarState.js +1 -2
- package/node/DateField/DateField.js +4 -20
- package/node/DatePicker/DatePicker.js +0 -13
- package/node/DatePicker/shared.js +1 -4
- package/node/DateTimeField/DateTimeField.js +4 -20
- package/node/DateTimePicker/DateTimePicker.js +0 -13
- package/node/DateTimePicker/shared.js +3 -6
- package/node/DesktopDatePicker/DesktopDatePicker.js +0 -13
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -13
- package/node/DesktopTimePicker/DesktopTimePicker.js +0 -12
- package/node/DigitalClock/DigitalClock.js +17 -25
- package/node/LocalizationProvider/LocalizationProvider.js +0 -6
- package/node/MobileDatePicker/MobileDatePicker.js +0 -13
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -13
- package/node/MobileTimePicker/MobileTimePicker.js +0 -12
- package/node/MonthCalendar/MonthCalendar.js +3 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +7 -18
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +16 -6
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +13 -19
- package/node/PickersLayout/PickersLayout.js +0 -12
- package/node/PickersLayout/usePickerLayout.js +2 -7
- package/node/StaticDatePicker/StaticDatePicker.js +0 -13
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +0 -13
- package/node/StaticTimePicker/StaticTimePicker.js +0 -12
- package/node/TimeClock/TimeClock.js +3 -20
- package/node/TimeField/TimeField.js +4 -20
- package/node/TimePicker/TimePicker.js +0 -12
- package/node/TimePicker/shared.js +3 -6
- package/node/YearCalendar/YearCalendar.js +4 -8
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +1 -7
- package/node/dateViewRenderers/dateViewRenderers.js +0 -4
- package/node/hooks/useClearableField.js +5 -7
- package/node/index.js +13 -1
- package/node/internals/hooks/useField/useField.utils.js +0 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -1
- package/node/internals/index.js +0 -7
- package/node/internals/utils/getDefaultReferenceDate.js +1 -3
- package/node/locales/esES.js +6 -7
- package/node/locales/eu.js +64 -0
- package/node/locales/index.js +11 -0
- package/node/timeViewRenderers/timeViewRenderers.js +0 -12
- package/package.json +1 -1
- package/themeAugmentation/overrides.d.ts +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.js +0 -12
- package/internals/utils/slots-migration.d.ts +0 -36
- package/internals/utils/slots-migration.js +0 -13
- package/legacy/internals/utils/slots-migration.js +0 -14
- package/modern/internals/utils/slots-migration.js +0 -13
- package/node/internals/utils/slots-migration.js +0 -21
|
@@ -106,19 +106,13 @@ const defaultFormats = {
|
|
|
106
106
|
minutes: 'mm',
|
|
107
107
|
seconds: 'ss',
|
|
108
108
|
fullDate: 'll',
|
|
109
|
-
fullDateWithWeekday: 'dddd, LL',
|
|
110
109
|
keyboardDate: 'L',
|
|
111
110
|
shortDate: 'MMM D',
|
|
112
111
|
normalDate: 'D MMMM',
|
|
113
112
|
normalDateWithWeekday: 'ddd, MMM D',
|
|
114
|
-
monthAndYear: 'MMMM YYYY',
|
|
115
|
-
monthAndDate: 'MMMM D',
|
|
116
113
|
fullTime: 'LT',
|
|
117
114
|
fullTime12h: 'hh:mm A',
|
|
118
115
|
fullTime24h: 'HH:mm',
|
|
119
|
-
fullDateTime: 'lll',
|
|
120
|
-
fullDateTime12h: 'll hh:mm A',
|
|
121
|
-
fullDateTime24h: 'll HH:mm',
|
|
122
116
|
keyboardDateTime: 'L LT',
|
|
123
117
|
keyboardDateTime12h: 'L hh:mm A',
|
|
124
118
|
keyboardDateTime24h: 'L HH:mm'
|
|
@@ -155,13 +149,11 @@ const withLocale = (dayjs, locale) => !locale ? dayjs : (...args) => dayjs(...ar
|
|
|
155
149
|
export class AdapterDayjs {
|
|
156
150
|
constructor({
|
|
157
151
|
locale: _locale,
|
|
158
|
-
formats
|
|
159
|
-
instance
|
|
152
|
+
formats
|
|
160
153
|
} = {}) {
|
|
161
154
|
this.isMUIAdapter = true;
|
|
162
155
|
this.isTimezoneCompatible = true;
|
|
163
156
|
this.lib = 'dayjs';
|
|
164
|
-
this.rawDayJsInstance = void 0;
|
|
165
157
|
this.dayjs = void 0;
|
|
166
158
|
this.locale = void 0;
|
|
167
159
|
this.formats = void 0;
|
|
@@ -203,11 +195,6 @@ export class AdapterDayjs {
|
|
|
203
195
|
}
|
|
204
196
|
};
|
|
205
197
|
this.createSystemDate = value => {
|
|
206
|
-
// TODO v7: Stop using `this.rawDayJsInstance` (drop the `instance` param on the adapters)
|
|
207
|
-
/* istanbul ignore next */
|
|
208
|
-
if (this.rawDayJsInstance) {
|
|
209
|
-
return this.rawDayJsInstance(value);
|
|
210
|
-
}
|
|
211
198
|
if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
|
|
212
199
|
const timezone = defaultDayjs.tz.guess();
|
|
213
200
|
|
|
@@ -338,12 +325,6 @@ export class AdapterDayjs {
|
|
|
338
325
|
this.toJsDate = value => {
|
|
339
326
|
return value.toDate();
|
|
340
327
|
};
|
|
341
|
-
this.parseISO = isoString => {
|
|
342
|
-
return this.dayjs(isoString);
|
|
343
|
-
};
|
|
344
|
-
this.toISO = value => {
|
|
345
|
-
return value.toISOString();
|
|
346
|
-
};
|
|
347
328
|
this.parse = (value, format) => {
|
|
348
329
|
if (value === '') {
|
|
349
330
|
return null;
|
|
@@ -367,14 +348,11 @@ export class AdapterDayjs {
|
|
|
367
348
|
return a || localeFormats[b] || t(localeFormats[B]);
|
|
368
349
|
});
|
|
369
350
|
};
|
|
370
|
-
this.getFormatHelperText = format => {
|
|
371
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
372
|
-
};
|
|
373
|
-
this.isNull = value => {
|
|
374
|
-
return value === null;
|
|
375
|
-
};
|
|
376
351
|
this.isValid = value => {
|
|
377
|
-
|
|
352
|
+
if (value == null) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return value.isValid();
|
|
378
356
|
};
|
|
379
357
|
this.format = (value, formatKey) => {
|
|
380
358
|
return this.formatByString(value, this.formats[formatKey]);
|
|
@@ -385,14 +363,14 @@ export class AdapterDayjs {
|
|
|
385
363
|
this.formatNumber = numberToFormat => {
|
|
386
364
|
return numberToFormat;
|
|
387
365
|
};
|
|
388
|
-
this.getDiff = (value, comparing, unit) => {
|
|
389
|
-
return value.diff(comparing, unit);
|
|
390
|
-
};
|
|
391
366
|
this.isEqual = (value, comparing) => {
|
|
392
367
|
if (value === null && comparing === null) {
|
|
393
368
|
return true;
|
|
394
369
|
}
|
|
395
|
-
|
|
370
|
+
if (value === null || comparing === null) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
return value.toDate().getTime() === comparing.toDate().getTime();
|
|
396
374
|
};
|
|
397
375
|
this.isSameYear = (value, comparing) => {
|
|
398
376
|
return this.isSame(value, comparing, 'YYYY');
|
|
@@ -529,28 +507,6 @@ export class AdapterDayjs {
|
|
|
529
507
|
this.getDaysInMonth = value => {
|
|
530
508
|
return value.daysInMonth();
|
|
531
509
|
};
|
|
532
|
-
this.getNextMonth = value => {
|
|
533
|
-
return this.addMonths(value, 1);
|
|
534
|
-
};
|
|
535
|
-
this.getPreviousMonth = value => {
|
|
536
|
-
return this.addMonths(value, -1);
|
|
537
|
-
};
|
|
538
|
-
this.getMonthArray = value => {
|
|
539
|
-
const firstMonth = value.startOf('year');
|
|
540
|
-
const monthArray = [firstMonth];
|
|
541
|
-
while (monthArray.length < 12) {
|
|
542
|
-
const prevMonth = monthArray[monthArray.length - 1];
|
|
543
|
-
monthArray.push(this.addMonths(prevMonth, 1));
|
|
544
|
-
}
|
|
545
|
-
return monthArray;
|
|
546
|
-
};
|
|
547
|
-
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
548
|
-
return dateParam.hour(timeParam.hour()).minute(timeParam.minute()).second(timeParam.second());
|
|
549
|
-
};
|
|
550
|
-
this.getWeekdays = () => {
|
|
551
|
-
const start = this.dayjs().startOf('week');
|
|
552
|
-
return [0, 1, 2, 3, 4, 5, 6].map(diff => this.formatByString(this.addDays(start, diff), 'dd'));
|
|
553
|
-
};
|
|
554
510
|
this.getWeekArray = value => {
|
|
555
511
|
const cleanValue = this.setLocaleToValue(value);
|
|
556
512
|
const start = cleanValue.startOf('month').startOf('week');
|
|
@@ -570,7 +526,7 @@ export class AdapterDayjs {
|
|
|
570
526
|
this.getWeekNumber = value => {
|
|
571
527
|
return value.week();
|
|
572
528
|
};
|
|
573
|
-
this.getYearRange = (start, end) => {
|
|
529
|
+
this.getYearRange = ([start, end]) => {
|
|
574
530
|
const startDate = start.startOf('year');
|
|
575
531
|
const endDate = end.endOf('year');
|
|
576
532
|
const years = [];
|
|
@@ -581,11 +537,7 @@ export class AdapterDayjs {
|
|
|
581
537
|
}
|
|
582
538
|
return years;
|
|
583
539
|
};
|
|
584
|
-
this.
|
|
585
|
-
return ampm === 'am' ? 'AM' : 'PM';
|
|
586
|
-
};
|
|
587
|
-
this.rawDayJsInstance = instance;
|
|
588
|
-
this.dayjs = withLocale(this.rawDayJsInstance ?? defaultDayjs, _locale);
|
|
540
|
+
this.dayjs = withLocale(defaultDayjs, _locale);
|
|
589
541
|
this.locale = _locale;
|
|
590
542
|
this.formats = _extends({}, defaultFormats, formats);
|
|
591
543
|
defaultDayjs.extend(weekOfYear);
|
|
@@ -120,19 +120,13 @@ const defaultFormats = {
|
|
|
120
120
|
minutes: 'mm',
|
|
121
121
|
seconds: 'ss',
|
|
122
122
|
fullDate: 'DD',
|
|
123
|
-
fullDateWithWeekday: 'DDDD',
|
|
124
123
|
keyboardDate: 'D',
|
|
125
124
|
shortDate: 'MMM d',
|
|
126
125
|
normalDate: 'd MMMM',
|
|
127
126
|
normalDateWithWeekday: 'EEE, MMM d',
|
|
128
|
-
monthAndYear: 'LLLL yyyy',
|
|
129
|
-
monthAndDate: 'MMMM d',
|
|
130
127
|
fullTime: 't',
|
|
131
128
|
fullTime12h: 'hh:mm a',
|
|
132
129
|
fullTime24h: 'HH:mm',
|
|
133
|
-
fullDateTime: 'ff',
|
|
134
|
-
fullDateTime12h: 'DD, hh:mm a',
|
|
135
|
-
fullDateTime24h: 'DD, T',
|
|
136
130
|
keyboardDateTime: 'D t',
|
|
137
131
|
keyboardDateTime12h: 'D hh:mm a',
|
|
138
132
|
keyboardDateTime24h: 'D T'
|
|
@@ -241,14 +235,6 @@ export class AdapterLuxon {
|
|
|
241
235
|
this.toJsDate = value => {
|
|
242
236
|
return value.toJSDate();
|
|
243
237
|
};
|
|
244
|
-
this.parseISO = isoString => {
|
|
245
|
-
return DateTime.fromISO(isoString);
|
|
246
|
-
};
|
|
247
|
-
this.toISO = value => {
|
|
248
|
-
return value.toUTC().toISO({
|
|
249
|
-
format: 'extended'
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
238
|
this.parse = (value, formatString) => {
|
|
253
239
|
if (value === '') {
|
|
254
240
|
return null;
|
|
@@ -272,35 +258,36 @@ export class AdapterLuxon {
|
|
|
272
258
|
};
|
|
273
259
|
this.expandFormat = format => {
|
|
274
260
|
// Extract escaped section to avoid extending them
|
|
275
|
-
const
|
|
276
|
-
|
|
261
|
+
const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
|
|
262
|
+
|
|
263
|
+
// Extract words to test if they are a token or a word to escape.
|
|
264
|
+
const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
|
|
265
|
+
return format.match(catchEscapedSectionsRegexp).map(token => {
|
|
277
266
|
const firstCharacter = token[0];
|
|
278
267
|
if (firstCharacter === "'") {
|
|
279
268
|
return token;
|
|
280
269
|
}
|
|
281
|
-
|
|
270
|
+
const expandedToken = DateTime.expandFormat(token, {
|
|
282
271
|
locale: this.locale
|
|
283
272
|
});
|
|
273
|
+
return expandedToken.replace(catchWordsRegexp, (correspondance, g1, g2) => {
|
|
274
|
+
const word = g1 || g2; // words are either in group 1 or group 2
|
|
275
|
+
if (word === 'yyyyy' || formatTokenMap[word] !== undefined) {
|
|
276
|
+
return correspondance;
|
|
277
|
+
}
|
|
278
|
+
return `'${correspondance}'`;
|
|
279
|
+
});
|
|
284
280
|
}).join('')
|
|
285
281
|
// The returned format can contain `yyyyy` which means year between 4 and 6 digits.
|
|
286
282
|
// This value is supported by luxon parser but not luxon formatter.
|
|
287
283
|
// To avoid conflicts, we replace it by 4 digits which is enough for most use-cases.
|
|
288
284
|
.replace('yyyyy', 'yyyy');
|
|
289
285
|
};
|
|
290
|
-
this.getFormatHelperText = format => {
|
|
291
|
-
return this.expandFormat(format).replace(/(a)/g, '(a|p)m').toLocaleLowerCase();
|
|
292
|
-
};
|
|
293
|
-
this.isNull = value => {
|
|
294
|
-
return value === null;
|
|
295
|
-
};
|
|
296
286
|
this.isValid = value => {
|
|
297
|
-
if (DateTime.isDateTime(value)) {
|
|
298
|
-
return value.isValid;
|
|
299
|
-
}
|
|
300
287
|
if (value === null) {
|
|
301
288
|
return false;
|
|
302
289
|
}
|
|
303
|
-
return
|
|
290
|
+
return value.isValid;
|
|
304
291
|
};
|
|
305
292
|
this.format = (value, formatKey) => {
|
|
306
293
|
return this.formatByString(value, this.formats[formatKey]);
|
|
@@ -311,25 +298,14 @@ export class AdapterLuxon {
|
|
|
311
298
|
this.formatNumber = numberToFormat => {
|
|
312
299
|
return numberToFormat;
|
|
313
300
|
};
|
|
314
|
-
this.getDiff = (value, comparing, unit) => {
|
|
315
|
-
if (typeof comparing === 'string') {
|
|
316
|
-
comparing = DateTime.fromJSDate(new Date(comparing));
|
|
317
|
-
}
|
|
318
|
-
if (unit) {
|
|
319
|
-
return Math.floor(value.diff(comparing).as(unit));
|
|
320
|
-
}
|
|
321
|
-
return value.diff(comparing).as('millisecond');
|
|
322
|
-
};
|
|
323
301
|
this.isEqual = (value, comparing) => {
|
|
324
302
|
if (value === null && comparing === null) {
|
|
325
303
|
return true;
|
|
326
304
|
}
|
|
327
|
-
|
|
328
|
-
// Make sure that null will not be passed to this.date
|
|
329
305
|
if (value === null || comparing === null) {
|
|
330
306
|
return false;
|
|
331
307
|
}
|
|
332
|
-
return +
|
|
308
|
+
return +value === +comparing;
|
|
333
309
|
};
|
|
334
310
|
this.isSameYear = (value, comparing) => {
|
|
335
311
|
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
|
|
@@ -495,37 +471,6 @@ export class AdapterLuxon {
|
|
|
495
471
|
this.getDaysInMonth = value => {
|
|
496
472
|
return value.daysInMonth;
|
|
497
473
|
};
|
|
498
|
-
this.getNextMonth = value => {
|
|
499
|
-
return value.plus({
|
|
500
|
-
months: 1
|
|
501
|
-
});
|
|
502
|
-
};
|
|
503
|
-
this.getPreviousMonth = value => {
|
|
504
|
-
return value.minus({
|
|
505
|
-
months: 1
|
|
506
|
-
});
|
|
507
|
-
};
|
|
508
|
-
this.getMonthArray = value => {
|
|
509
|
-
const firstMonth = value.startOf('year');
|
|
510
|
-
const monthArray = [firstMonth];
|
|
511
|
-
while (monthArray.length < 12) {
|
|
512
|
-
const prevMonth = monthArray[monthArray.length - 1];
|
|
513
|
-
monthArray.push(this.addMonths(prevMonth, 1));
|
|
514
|
-
}
|
|
515
|
-
return monthArray;
|
|
516
|
-
};
|
|
517
|
-
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
518
|
-
return dateParam.set({
|
|
519
|
-
second: timeParam.second,
|
|
520
|
-
hour: timeParam.hour,
|
|
521
|
-
minute: timeParam.minute
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
this.getWeekdays = () => {
|
|
525
|
-
return Info.weekdaysFormat('narrow', {
|
|
526
|
-
locale: this.locale
|
|
527
|
-
});
|
|
528
|
-
};
|
|
529
474
|
this.getWeekArray = value => {
|
|
530
475
|
const cleanValue = this.setLocaleToValue(value);
|
|
531
476
|
const {
|
|
@@ -546,7 +491,7 @@ export class AdapterLuxon {
|
|
|
546
491
|
this.getWeekNumber = value => {
|
|
547
492
|
return value.weekNumber;
|
|
548
493
|
};
|
|
549
|
-
this.getYearRange = (start, end) => {
|
|
494
|
+
this.getYearRange = ([start, end]) => {
|
|
550
495
|
const startDate = start.startOf('year');
|
|
551
496
|
const endDate = end.endOf('year');
|
|
552
497
|
let current = startDate;
|
|
@@ -559,11 +504,6 @@ export class AdapterLuxon {
|
|
|
559
504
|
}
|
|
560
505
|
return years;
|
|
561
506
|
};
|
|
562
|
-
this.getMeridiemText = ampm => {
|
|
563
|
-
return Info.meridiems({
|
|
564
|
-
locale: this.locale
|
|
565
|
-
}).find(v => v.toLowerCase() === ampm.toLowerCase());
|
|
566
|
-
};
|
|
567
507
|
this.locale = locale || 'en-US';
|
|
568
508
|
this.formats = _extends({}, defaultFormats, formats);
|
|
569
509
|
}
|
|
@@ -109,19 +109,13 @@ const defaultFormats = {
|
|
|
109
109
|
minutes: 'mm',
|
|
110
110
|
seconds: 'ss',
|
|
111
111
|
fullDate: 'll',
|
|
112
|
-
fullDateWithWeekday: 'dddd, LL',
|
|
113
112
|
keyboardDate: 'L',
|
|
114
113
|
shortDate: 'MMM D',
|
|
115
114
|
normalDate: 'D MMMM',
|
|
116
115
|
normalDateWithWeekday: 'ddd, MMM D',
|
|
117
|
-
monthAndYear: 'MMMM YYYY',
|
|
118
|
-
monthAndDate: 'MMMM D',
|
|
119
116
|
fullTime: 'LT',
|
|
120
117
|
fullTime12h: 'hh:mm A',
|
|
121
118
|
fullTime24h: 'HH:mm',
|
|
122
|
-
fullDateTime: 'lll',
|
|
123
|
-
fullDateTime12h: 'll hh:mm A',
|
|
124
|
-
fullDateTime24h: 'll HH:mm',
|
|
125
119
|
keyboardDateTime: 'L LT',
|
|
126
120
|
keyboardDateTime12h: 'L hh:mm A',
|
|
127
121
|
keyboardDateTime24h: 'L HH:mm'
|
|
@@ -177,21 +171,6 @@ export class AdapterMoment {
|
|
|
177
171
|
}
|
|
178
172
|
return value.locale(expectedLocale);
|
|
179
173
|
};
|
|
180
|
-
/**
|
|
181
|
-
* Some methods from moment can't take the locale as a parameter and always use the current locale.
|
|
182
|
-
* To respect the adapter locale, we need to set it as the current locale and then reset the previous locale.
|
|
183
|
-
*/
|
|
184
|
-
this.syncMomentLocale = runner => {
|
|
185
|
-
const momentLocale = defaultMoment.locale();
|
|
186
|
-
const adapterLocale = this.locale ?? 'en-us';
|
|
187
|
-
if (momentLocale !== adapterLocale) {
|
|
188
|
-
defaultMoment.locale(adapterLocale);
|
|
189
|
-
const result = runner();
|
|
190
|
-
defaultMoment.locale(momentLocale);
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
return runner();
|
|
194
|
-
};
|
|
195
174
|
this.hasTimezonePlugin = () => typeof this.moment.tz !== 'undefined';
|
|
196
175
|
this.createSystemDate = value => {
|
|
197
176
|
const parsedValue = this.moment(value).local();
|
|
@@ -277,12 +256,6 @@ export class AdapterMoment {
|
|
|
277
256
|
this.toJsDate = value => {
|
|
278
257
|
return value.toDate();
|
|
279
258
|
};
|
|
280
|
-
this.parseISO = isoString => {
|
|
281
|
-
return this.moment(isoString, true);
|
|
282
|
-
};
|
|
283
|
-
this.toISO = value => {
|
|
284
|
-
return value.toISOString();
|
|
285
|
-
};
|
|
286
259
|
this.parse = (value, format) => {
|
|
287
260
|
if (value === '') {
|
|
288
261
|
return null;
|
|
@@ -309,14 +282,11 @@ export class AdapterMoment {
|
|
|
309
282
|
return token;
|
|
310
283
|
}).join('');
|
|
311
284
|
};
|
|
312
|
-
this.getFormatHelperText = format => {
|
|
313
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
314
|
-
};
|
|
315
|
-
this.isNull = value => {
|
|
316
|
-
return value === null;
|
|
317
|
-
};
|
|
318
285
|
this.isValid = value => {
|
|
319
|
-
|
|
286
|
+
if (value == null) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
return value.isValid();
|
|
320
290
|
};
|
|
321
291
|
this.format = (value, formatKey) => {
|
|
322
292
|
return this.formatByString(value, this.formats[formatKey]);
|
|
@@ -329,14 +299,14 @@ export class AdapterMoment {
|
|
|
329
299
|
this.formatNumber = numberToFormat => {
|
|
330
300
|
return numberToFormat;
|
|
331
301
|
};
|
|
332
|
-
this.getDiff = (value, comparing, unit) => {
|
|
333
|
-
return value.diff(comparing, unit);
|
|
334
|
-
};
|
|
335
302
|
this.isEqual = (value, comparing) => {
|
|
336
303
|
if (value === null && comparing === null) {
|
|
337
304
|
return true;
|
|
338
305
|
}
|
|
339
|
-
|
|
306
|
+
if (value === null || comparing === null) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
return value.isSame(comparing);
|
|
340
310
|
};
|
|
341
311
|
this.isSameYear = (value, comparing) => {
|
|
342
312
|
return value.isSame(comparing, 'year');
|
|
@@ -461,25 +431,6 @@ export class AdapterMoment {
|
|
|
461
431
|
this.getDaysInMonth = value => {
|
|
462
432
|
return value.daysInMonth();
|
|
463
433
|
};
|
|
464
|
-
this.getNextMonth = value => {
|
|
465
|
-
return value.clone().add(1, 'month');
|
|
466
|
-
};
|
|
467
|
-
this.getPreviousMonth = value => {
|
|
468
|
-
return value.clone().subtract(1, 'month');
|
|
469
|
-
};
|
|
470
|
-
this.getMonthArray = value => {
|
|
471
|
-
const firstMonth = this.startOfYear(value);
|
|
472
|
-
const monthArray = [firstMonth];
|
|
473
|
-
while (monthArray.length < 12) {
|
|
474
|
-
const prevMonth = monthArray[monthArray.length - 1];
|
|
475
|
-
monthArray.push(this.getNextMonth(prevMonth));
|
|
476
|
-
}
|
|
477
|
-
return monthArray;
|
|
478
|
-
};
|
|
479
|
-
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
480
|
-
return dateParam.clone().hour(timeParam.hour()).minute(timeParam.minute()).second(timeParam.second());
|
|
481
|
-
};
|
|
482
|
-
this.getWeekdays = () => this.syncMomentLocale(() => defaultMoment.weekdaysShort(true));
|
|
483
434
|
this.getWeekArray = value => {
|
|
484
435
|
const cleanValue = this.setLocaleToValue(value);
|
|
485
436
|
const start = cleanValue.clone().startOf('month').startOf('week');
|
|
@@ -499,7 +450,7 @@ export class AdapterMoment {
|
|
|
499
450
|
this.getWeekNumber = value => {
|
|
500
451
|
return value.week();
|
|
501
452
|
};
|
|
502
|
-
this.getYearRange = (start, end) => {
|
|
453
|
+
this.getYearRange = ([start, end]) => {
|
|
503
454
|
const startDate = this.moment(start).startOf('year');
|
|
504
455
|
const endDate = this.moment(end).endOf('year');
|
|
505
456
|
const years = [];
|
|
@@ -510,13 +461,6 @@ export class AdapterMoment {
|
|
|
510
461
|
}
|
|
511
462
|
return years;
|
|
512
463
|
};
|
|
513
|
-
this.getMeridiemText = ampm => {
|
|
514
|
-
if (this.is12HourCycleInCurrentLocale()) {
|
|
515
|
-
// AM/PM translation only possible in those who have 12 hour cycle in locale.
|
|
516
|
-
return defaultMoment.localeData(this.getCurrentLocaleCode()).meridiem(ampm === 'am' ? 0 : 13, 0, false);
|
|
517
|
-
}
|
|
518
|
-
return ampm === 'am' ? 'AM' : 'PM'; // fallback for de, ru, ...etc
|
|
519
|
-
};
|
|
520
464
|
this.moment = instance || defaultMoment;
|
|
521
465
|
this.locale = locale;
|
|
522
466
|
this.formats = _extends({}, defaultFormats, formats);
|
|
@@ -79,19 +79,13 @@ const defaultFormats = {
|
|
|
79
79
|
minutes: 'mm',
|
|
80
80
|
seconds: 'ss',
|
|
81
81
|
fullDate: 'iYYYY, iMMMM Do',
|
|
82
|
-
fullDateWithWeekday: 'iYYYY, iMMMM Do, dddd',
|
|
83
82
|
keyboardDateTime: 'iYYYY/iMM/iDD LT',
|
|
84
83
|
shortDate: 'iD iMMM',
|
|
85
84
|
normalDate: 'dddd, iD iMMM',
|
|
86
85
|
normalDateWithWeekday: 'DD iMMMM',
|
|
87
|
-
monthAndYear: 'iMMMM iYYYY',
|
|
88
|
-
monthAndDate: 'iD iMMMM',
|
|
89
86
|
fullTime: 'LT',
|
|
90
87
|
fullTime12h: 'hh:mm A',
|
|
91
88
|
fullTime24h: 'HH:mm',
|
|
92
|
-
fullDateTime: 'iYYYY, iMMMM Do, hh:mm A',
|
|
93
|
-
fullDateTime12h: 'iD iMMMM hh:mm A',
|
|
94
|
-
fullDateTime24h: 'iD iMMMM HH:mm',
|
|
95
89
|
keyboardDate: 'iYYYY/iMM/iDD',
|
|
96
90
|
keyboardDateTime12h: 'iYYYY/iMM/iDD hh:mm A',
|
|
97
91
|
keyboardDateTime24h: 'iYYYY/iMM/iDD HH:mm'
|
|
@@ -168,18 +162,9 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
168
162
|
}
|
|
169
163
|
return this.moment(value, format, true).locale('ar-SA');
|
|
170
164
|
};
|
|
171
|
-
this.getFormatHelperText = format => {
|
|
172
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('iY', 'Y').replace('iM', 'M').replace('iD', 'D').toLocaleLowerCase();
|
|
173
|
-
};
|
|
174
165
|
this.formatNumber = numberToFormat => {
|
|
175
166
|
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
176
167
|
};
|
|
177
|
-
this.isEqual = (value, comparing) => {
|
|
178
|
-
if (value === null && comparing === null) {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
return this.moment(value).isSame(comparing);
|
|
182
|
-
};
|
|
183
168
|
this.startOfYear = value => {
|
|
184
169
|
return value.clone().startOf('iYear');
|
|
185
170
|
};
|
|
@@ -216,17 +201,6 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
216
201
|
this.setDate = (value, date) => {
|
|
217
202
|
return value.clone().iDate(date);
|
|
218
203
|
};
|
|
219
|
-
this.getNextMonth = value => {
|
|
220
|
-
return value.clone().add(1, 'iMonth');
|
|
221
|
-
};
|
|
222
|
-
this.getPreviousMonth = value => {
|
|
223
|
-
return value.clone().subtract(1, 'iMonth');
|
|
224
|
-
};
|
|
225
|
-
this.getWeekdays = () => {
|
|
226
|
-
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
227
|
-
return this.date().weekday(dayOfWeek).format('dd');
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
204
|
this.getWeekArray = value => {
|
|
231
205
|
const start = value.clone().startOf('iMonth').startOf('week');
|
|
232
206
|
const end = value.clone().endOf('iMonth').endOf('week');
|
|
@@ -245,7 +219,7 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
245
219
|
this.getWeekNumber = value => {
|
|
246
220
|
return value.iWeek();
|
|
247
221
|
};
|
|
248
|
-
this.getYearRange = (start, end) => {
|
|
222
|
+
this.getYearRange = ([start, end]) => {
|
|
249
223
|
// moment-hijri only supports dates between 1356-01-01 H and 1499-12-29 H
|
|
250
224
|
// We need to throw if outside min/max bounds, otherwise the while loop below will be infinite.
|
|
251
225
|
if (start.isBefore('1937-03-14')) {
|
|
@@ -264,9 +238,6 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
264
238
|
}
|
|
265
239
|
return years;
|
|
266
240
|
};
|
|
267
|
-
this.getMeridiemText = ampm => {
|
|
268
|
-
return ampm === 'am' ? this.date().hours(2).format('A') : this.date().hours(14).format('A');
|
|
269
|
-
};
|
|
270
241
|
this.moment = instance || defaultHMoment;
|
|
271
242
|
this.locale = 'ar-SA';
|
|
272
243
|
this.formats = _extends({}, defaultFormats, formats);
|
|
@@ -77,19 +77,13 @@ const defaultFormats = {
|
|
|
77
77
|
minutes: 'mm',
|
|
78
78
|
seconds: 'ss',
|
|
79
79
|
fullDate: 'jYYYY, jMMMM Do',
|
|
80
|
-
fullDateWithWeekday: 'dddd Do jMMMM jYYYY',
|
|
81
80
|
keyboardDate: 'jYYYY/jMM/jDD',
|
|
82
81
|
shortDate: 'jD jMMM',
|
|
83
82
|
normalDate: 'dddd, jD jMMM',
|
|
84
83
|
normalDateWithWeekday: 'DD MMMM',
|
|
85
|
-
monthAndYear: 'jMMMM jYYYY',
|
|
86
|
-
monthAndDate: 'jD jMMMM',
|
|
87
84
|
fullTime: 'LT',
|
|
88
85
|
fullTime12h: 'hh:mm A',
|
|
89
86
|
fullTime24h: 'HH:mm',
|
|
90
|
-
fullDateTime: 'jYYYY, jMMMM Do, hh:mm A',
|
|
91
|
-
fullDateTime12h: 'jD jMMMM hh:mm A',
|
|
92
|
-
fullDateTime24h: 'jD jMMMM HH:mm',
|
|
93
87
|
keyboardDateTime: 'jYYYY/jMM/jDD LT',
|
|
94
88
|
keyboardDateTime12h: 'jYYYY/jMM/jDD hh:mm A',
|
|
95
89
|
keyboardDateTime24h: 'jYYYY/jMM/jDD HH:mm'
|
|
@@ -160,34 +154,15 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
160
154
|
this.setTimezone = value => {
|
|
161
155
|
return value;
|
|
162
156
|
};
|
|
163
|
-
this.parseISO = isoString => {
|
|
164
|
-
return this.moment(isoString).locale('fa');
|
|
165
|
-
};
|
|
166
157
|
this.parse = (value, format) => {
|
|
167
158
|
if (value === '') {
|
|
168
159
|
return null;
|
|
169
160
|
}
|
|
170
161
|
return this.moment(value, format, true).locale('fa');
|
|
171
162
|
};
|
|
172
|
-
this.getFormatHelperText = format => {
|
|
173
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('jY', 'Y').replace('jM', 'M').replace('jD', 'D').toLocaleLowerCase();
|
|
174
|
-
};
|
|
175
|
-
this.isValid = value => {
|
|
176
|
-
// We can't to `this.moment(value)` because moment-jalaali looses the invalidity information when creating a new moment object from an existing one
|
|
177
|
-
if (!this.moment.isMoment(value)) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
return value.isValid();
|
|
181
|
-
};
|
|
182
163
|
this.formatNumber = numberToFormat => {
|
|
183
164
|
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
184
165
|
};
|
|
185
|
-
this.isEqual = (value, comparing) => {
|
|
186
|
-
if (value === null && comparing === null) {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
return this.moment(value).isSame(comparing);
|
|
190
|
-
};
|
|
191
166
|
this.isSameYear = (value, comparing) => {
|
|
192
167
|
// `isSame` seems to mutate the date on `moment-jalaali`
|
|
193
168
|
// @ts-ignore
|
|
@@ -240,17 +215,6 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
240
215
|
this.setDate = (value, date) => {
|
|
241
216
|
return value.clone().jDate(date);
|
|
242
217
|
};
|
|
243
|
-
this.getNextMonth = value => {
|
|
244
|
-
return value.clone().add(1, 'jMonth');
|
|
245
|
-
};
|
|
246
|
-
this.getPreviousMonth = value => {
|
|
247
|
-
return value.clone().subtract(1, 'jMonth');
|
|
248
|
-
};
|
|
249
|
-
this.getWeekdays = () => {
|
|
250
|
-
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
251
|
-
return this.date().weekday(dayOfWeek).format('dd');
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
218
|
this.getWeekArray = value => {
|
|
255
219
|
const start = value.clone().startOf('jMonth').startOf('week');
|
|
256
220
|
const end = value.clone().endOf('jMonth').endOf('week');
|
|
@@ -269,7 +233,7 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
269
233
|
this.getWeekNumber = value => {
|
|
270
234
|
return value.jWeek();
|
|
271
235
|
};
|
|
272
|
-
this.getYearRange = (start, end) => {
|
|
236
|
+
this.getYearRange = ([start, end]) => {
|
|
273
237
|
const startDate = this.moment(start).startOf('jYear');
|
|
274
238
|
const endDate = this.moment(end).endOf('jYear');
|
|
275
239
|
const years = [];
|
|
@@ -280,9 +244,6 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
280
244
|
}
|
|
281
245
|
return years;
|
|
282
246
|
};
|
|
283
|
-
this.getMeridiemText = ampm => {
|
|
284
|
-
return ampm === 'am' ? this.date().hours(2).format('A') : this.date().hours(14).format('A');
|
|
285
|
-
};
|
|
286
247
|
this.moment = instance || defaultJMoment;
|
|
287
248
|
this.locale = 'fa';
|
|
288
249
|
this.formats = _extends({}, defaultFormats, formats);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "referenceDate", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "
|
|
3
|
+
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "referenceDate", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "slots", "slotProps", "loading", "renderLoading", "displayWeekNumber", "yearsPerRow", "monthsPerRow", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -115,8 +115,6 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
115
115
|
showDaysOutsideCurrentMonth,
|
|
116
116
|
fixedWeekNumber,
|
|
117
117
|
dayOfWeekFormatter,
|
|
118
|
-
components,
|
|
119
|
-
componentsProps,
|
|
120
118
|
slots,
|
|
121
119
|
slotProps,
|
|
122
120
|
loading,
|
|
@@ -183,10 +181,10 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
183
181
|
const maxDateWithDisabled = disabled && value || maxDate;
|
|
184
182
|
const gridLabelId = `${id}-grid-label`;
|
|
185
183
|
const hasFocus = focusedView !== null;
|
|
186
|
-
const CalendarHeader = slots?.calendarHeader ??
|
|
184
|
+
const CalendarHeader = slots?.calendarHeader ?? PickersCalendarHeader;
|
|
187
185
|
const calendarHeaderProps = useSlotProps({
|
|
188
186
|
elementType: CalendarHeader,
|
|
189
|
-
externalSlotProps: slotProps?.calendarHeader
|
|
187
|
+
externalSlotProps: slotProps?.calendarHeader,
|
|
190
188
|
additionalProps: {
|
|
191
189
|
views,
|
|
192
190
|
view,
|
|
@@ -337,8 +335,6 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
337
335
|
fixedWeekNumber: fixedWeekNumber,
|
|
338
336
|
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
339
337
|
displayWeekNumber: displayWeekNumber,
|
|
340
|
-
components: components,
|
|
341
|
-
componentsProps: componentsProps,
|
|
342
338
|
slots: slots,
|
|
343
339
|
slotProps: slotProps,
|
|
344
340
|
loading: loading,
|
|
@@ -362,21 +358,8 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
362
358
|
autoFocus: PropTypes.bool,
|
|
363
359
|
classes: PropTypes.object,
|
|
364
360
|
className: PropTypes.string,
|
|
365
|
-
/**
|
|
366
|
-
* Overridable components.
|
|
367
|
-
* @default {}
|
|
368
|
-
* @deprecated Please use `slots`.
|
|
369
|
-
*/
|
|
370
|
-
components: PropTypes.object,
|
|
371
|
-
/**
|
|
372
|
-
* The props used for each component slot.
|
|
373
|
-
* @default {}
|
|
374
|
-
* @deprecated Please use `slotProps`.
|
|
375
|
-
*/
|
|
376
|
-
componentsProps: PropTypes.object,
|
|
377
361
|
/**
|
|
378
362
|
* Formats the day of week displayed in the calendar header.
|
|
379
|
-
* @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
|
|
380
363
|
* @param {TDate} date The date of the day of week provided by the adapter.
|
|
381
364
|
* @returns {string} The name to display.
|
|
382
365
|
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|