@mui/x-date-pickers 7.0.0-alpha.0 → 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 +3 -73
- 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 +409 -1
- package/DateCalendar/DateCalendar.js +0 -1
- package/DateCalendar/DayCalendar.d.ts +1 -2
- package/DateCalendar/DayCalendar.js +9 -16
- package/DateCalendar/index.d.ts +0 -1
- package/DateCalendar/index.js +1 -3
- package/DatePicker/DatePicker.js +0 -1
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +0 -1
- package/DateTimePicker/shared.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +0 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
- package/DigitalClock/DigitalClock.js +3 -2
- package/LocalizationProvider/LocalizationProvider.js +0 -6
- package/MobileDatePicker/MobileDatePicker.js +0 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
- package/StaticDatePicker/StaticDatePicker.js +0 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/TimePicker/shared.d.ts +1 -1
- package/YearCalendar/YearCalendar.js +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
- package/index.d.ts +1 -0
- package/index.js +4 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +5 -0
- package/internals/hooks/useField/useField.utils.js +0 -1
- package/internals/hooks/useField/useFieldState.js +1 -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 +6 -75
- 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 +0 -1
- package/legacy/DateCalendar/DayCalendar.js +7 -11
- package/legacy/DateCalendar/index.js +1 -3
- package/legacy/DatePicker/DatePicker.js +0 -1
- package/legacy/DateTimePicker/DateTimePicker.js +0 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +0 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
- package/legacy/DigitalClock/DigitalClock.js +3 -2
- package/legacy/LocalizationProvider/LocalizationProvider.js +0 -6
- package/legacy/MobileDatePicker/MobileDatePicker.js +0 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +11 -3
- package/legacy/StaticDatePicker/StaticDatePicker.js +0 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/legacy/YearCalendar/YearCalendar.js +1 -1
- 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/utils/getDefaultReferenceDate.js +0 -6
- 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 +3 -73
- 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 +0 -1
- package/modern/DateCalendar/DayCalendar.js +9 -15
- package/modern/DateCalendar/index.js +1 -3
- package/modern/DatePicker/DatePicker.js +0 -1
- package/modern/DateTimePicker/DateTimePicker.js +0 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
- package/modern/DigitalClock/DigitalClock.js +3 -2
- package/modern/LocalizationProvider/LocalizationProvider.js +0 -6
- package/modern/MobileDatePicker/MobileDatePicker.js +0 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
- package/modern/StaticDatePicker/StaticDatePicker.js +0 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/modern/YearCalendar/YearCalendar.js +1 -1
- 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/utils/getDefaultReferenceDate.js +0 -1
- 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 +3 -73
- 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 +0 -1
- package/node/DateCalendar/DayCalendar.js +9 -15
- package/node/DateCalendar/index.js +1 -21
- package/node/DatePicker/DatePicker.js +0 -1
- package/node/DateTimePicker/DateTimePicker.js +0 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +0 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/LocalizationProvider/LocalizationProvider.js +0 -6
- package/node/MobileDatePicker/MobileDatePicker.js +0 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
- package/node/StaticDatePicker/StaticDatePicker.js +0 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
- package/node/YearCalendar/YearCalendar.js +1 -1
- 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/utils/getDefaultReferenceDate.js +1 -3
- package/package.json +1 -1
- package/themeAugmentation/overrides.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
|
-
import { AdapterFormats, AdapterOptions,
|
|
2
|
+
import { AdapterFormats, AdapterOptions, DateBuilderReturnType, FieldFormatTokenMap, MuiPickersAdapter, PickersTimezone } from '../models';
|
|
3
3
|
/**
|
|
4
4
|
* Based on `@date-io/luxon`
|
|
5
5
|
*
|
|
@@ -43,20 +43,15 @@ export declare class AdapterLuxon implements MuiPickersAdapter<DateTime, string>
|
|
|
43
43
|
getTimezone: (value: DateTime) => string;
|
|
44
44
|
setTimezone: (value: DateTime, timezone: PickersTimezone) => DateTime;
|
|
45
45
|
toJsDate: (value: DateTime) => Date;
|
|
46
|
-
parseISO: (isoString: string) => DateTime;
|
|
47
|
-
toISO: (value: DateTime) => string;
|
|
48
46
|
parse: (value: string, formatString: string) => DateTime | null;
|
|
49
47
|
getCurrentLocaleCode: () => string;
|
|
50
48
|
is12HourCycleInCurrentLocale: () => boolean;
|
|
51
49
|
expandFormat: (format: string) => string;
|
|
52
|
-
|
|
53
|
-
isNull: (value: DateTime | null) => boolean;
|
|
54
|
-
isValid: (value: any) => boolean;
|
|
50
|
+
isValid: (value: DateTime | null) => boolean;
|
|
55
51
|
format: (value: DateTime, formatKey: keyof AdapterFormats) => string;
|
|
56
52
|
formatByString: (value: DateTime, format: string) => string;
|
|
57
53
|
formatNumber: (numberToFormat: string) => string;
|
|
58
|
-
|
|
59
|
-
isEqual: (value: any, comparing: any) => boolean;
|
|
54
|
+
isEqual: (value: DateTime | null, comparing: DateTime | null) => boolean;
|
|
60
55
|
isSameYear: (value: DateTime, comparing: DateTime) => boolean;
|
|
61
56
|
isSameMonth: (value: DateTime, comparing: DateTime) => boolean;
|
|
62
57
|
isSameDay: (value: DateTime, comparing: DateTime) => boolean;
|
|
@@ -98,13 +93,7 @@ export declare class AdapterLuxon implements MuiPickersAdapter<DateTime, string>
|
|
|
98
93
|
setSeconds: (value: DateTime, seconds: number) => DateTime;
|
|
99
94
|
setMilliseconds: (value: DateTime, milliseconds: number) => DateTime;
|
|
100
95
|
getDaysInMonth: (value: DateTime) => import("luxon").PossibleDaysInMonth;
|
|
101
|
-
getNextMonth: (value: DateTime) => DateTime;
|
|
102
|
-
getPreviousMonth: (value: DateTime) => DateTime;
|
|
103
|
-
getMonthArray: (value: DateTime) => DateTime[];
|
|
104
|
-
mergeDateAndTime: (dateParam: DateTime, timeParam: DateTime) => DateTime;
|
|
105
|
-
getWeekdays: () => string[];
|
|
106
96
|
getWeekArray: (value: DateTime) => DateTime[][];
|
|
107
97
|
getWeekNumber: (value: DateTime) => number;
|
|
108
|
-
getYearRange: (start
|
|
109
|
-
getMeridiemText: (ampm: 'am' | 'pm') => string;
|
|
98
|
+
getYearRange: ([start, end]: [DateTime, DateTime]) => DateTime[];
|
|
110
99
|
}
|
|
@@ -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;
|
|
@@ -298,20 +284,11 @@ export class AdapterLuxon {
|
|
|
298
284
|
// To avoid conflicts, we replace it by 4 digits which is enough for most use-cases.
|
|
299
285
|
.replace('yyyyy', 'yyyy');
|
|
300
286
|
};
|
|
301
|
-
this.getFormatHelperText = format => {
|
|
302
|
-
return this.expandFormat(format).replace(/(a)/g, '(a|p)m').toLocaleLowerCase();
|
|
303
|
-
};
|
|
304
|
-
this.isNull = value => {
|
|
305
|
-
return value === null;
|
|
306
|
-
};
|
|
307
287
|
this.isValid = value => {
|
|
308
|
-
if (DateTime.isDateTime(value)) {
|
|
309
|
-
return value.isValid;
|
|
310
|
-
}
|
|
311
288
|
if (value === null) {
|
|
312
289
|
return false;
|
|
313
290
|
}
|
|
314
|
-
return
|
|
291
|
+
return value.isValid;
|
|
315
292
|
};
|
|
316
293
|
this.format = (value, formatKey) => {
|
|
317
294
|
return this.formatByString(value, this.formats[formatKey]);
|
|
@@ -322,25 +299,14 @@ export class AdapterLuxon {
|
|
|
322
299
|
this.formatNumber = numberToFormat => {
|
|
323
300
|
return numberToFormat;
|
|
324
301
|
};
|
|
325
|
-
this.getDiff = (value, comparing, unit) => {
|
|
326
|
-
if (typeof comparing === 'string') {
|
|
327
|
-
comparing = DateTime.fromJSDate(new Date(comparing));
|
|
328
|
-
}
|
|
329
|
-
if (unit) {
|
|
330
|
-
return Math.floor(value.diff(comparing).as(unit));
|
|
331
|
-
}
|
|
332
|
-
return value.diff(comparing).as('millisecond');
|
|
333
|
-
};
|
|
334
302
|
this.isEqual = (value, comparing) => {
|
|
335
303
|
if (value === null && comparing === null) {
|
|
336
304
|
return true;
|
|
337
305
|
}
|
|
338
|
-
|
|
339
|
-
// Make sure that null will not be passed to this.date
|
|
340
306
|
if (value === null || comparing === null) {
|
|
341
307
|
return false;
|
|
342
308
|
}
|
|
343
|
-
return +
|
|
309
|
+
return +value === +comparing;
|
|
344
310
|
};
|
|
345
311
|
this.isSameYear = (value, comparing) => {
|
|
346
312
|
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
|
|
@@ -506,37 +472,6 @@ export class AdapterLuxon {
|
|
|
506
472
|
this.getDaysInMonth = value => {
|
|
507
473
|
return value.daysInMonth;
|
|
508
474
|
};
|
|
509
|
-
this.getNextMonth = value => {
|
|
510
|
-
return value.plus({
|
|
511
|
-
months: 1
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
this.getPreviousMonth = value => {
|
|
515
|
-
return value.minus({
|
|
516
|
-
months: 1
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
this.getMonthArray = value => {
|
|
520
|
-
const firstMonth = value.startOf('year');
|
|
521
|
-
const monthArray = [firstMonth];
|
|
522
|
-
while (monthArray.length < 12) {
|
|
523
|
-
const prevMonth = monthArray[monthArray.length - 1];
|
|
524
|
-
monthArray.push(this.addMonths(prevMonth, 1));
|
|
525
|
-
}
|
|
526
|
-
return monthArray;
|
|
527
|
-
};
|
|
528
|
-
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
529
|
-
return dateParam.set({
|
|
530
|
-
second: timeParam.second,
|
|
531
|
-
hour: timeParam.hour,
|
|
532
|
-
minute: timeParam.minute
|
|
533
|
-
});
|
|
534
|
-
};
|
|
535
|
-
this.getWeekdays = () => {
|
|
536
|
-
return Info.weekdaysFormat('narrow', {
|
|
537
|
-
locale: this.locale
|
|
538
|
-
});
|
|
539
|
-
};
|
|
540
475
|
this.getWeekArray = value => {
|
|
541
476
|
const cleanValue = this.setLocaleToValue(value);
|
|
542
477
|
const {
|
|
@@ -557,7 +492,7 @@ export class AdapterLuxon {
|
|
|
557
492
|
this.getWeekNumber = value => {
|
|
558
493
|
return value.weekNumber;
|
|
559
494
|
};
|
|
560
|
-
this.getYearRange = (start, end) => {
|
|
495
|
+
this.getYearRange = ([start, end]) => {
|
|
561
496
|
const startDate = start.startOf('year');
|
|
562
497
|
const endDate = end.endOf('year');
|
|
563
498
|
let current = startDate;
|
|
@@ -570,11 +505,6 @@ export class AdapterLuxon {
|
|
|
570
505
|
}
|
|
571
506
|
return years;
|
|
572
507
|
};
|
|
573
|
-
this.getMeridiemText = ampm => {
|
|
574
|
-
return Info.meridiems({
|
|
575
|
-
locale: this.locale
|
|
576
|
-
}).find(v => v.toLowerCase() === ampm.toLowerCase());
|
|
577
|
-
};
|
|
578
508
|
this.locale = locale || 'en-US';
|
|
579
509
|
this.formats = _extends({}, defaultFormats, formats);
|
|
580
510
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import defaultMoment, { Moment } from 'moment';
|
|
2
|
-
import { AdapterFormats, AdapterOptions,
|
|
2
|
+
import { AdapterFormats, AdapterOptions, DateBuilderReturnType, FieldFormatTokenMap, MuiPickersAdapter, PickersTimezone } from '../models';
|
|
3
3
|
/**
|
|
4
4
|
* Based on `@date-io/moment`
|
|
5
5
|
*
|
|
@@ -39,11 +39,6 @@ export declare class AdapterMoment implements MuiPickersAdapter<Moment, string>
|
|
|
39
39
|
formatTokenMap: FieldFormatTokenMap;
|
|
40
40
|
constructor({ locale, formats, instance }?: AdapterOptions<string, typeof defaultMoment>);
|
|
41
41
|
private setLocaleToValue;
|
|
42
|
-
/**
|
|
43
|
-
* Some methods from moment can't take the locale as a parameter and always use the current locale.
|
|
44
|
-
* To respect the adapter locale, we need to set it as the current locale and then reset the previous locale.
|
|
45
|
-
*/
|
|
46
|
-
private syncMomentLocale;
|
|
47
42
|
private hasTimezonePlugin;
|
|
48
43
|
private createSystemDate;
|
|
49
44
|
private createUTCDate;
|
|
@@ -53,20 +48,15 @@ export declare class AdapterMoment implements MuiPickersAdapter<Moment, string>
|
|
|
53
48
|
getTimezone: (value: Moment) => string;
|
|
54
49
|
setTimezone: (value: Moment, timezone: PickersTimezone) => Moment;
|
|
55
50
|
toJsDate: (value: Moment) => Date;
|
|
56
|
-
parseISO: (isoString: string) => defaultMoment.Moment;
|
|
57
|
-
toISO: (value: Moment) => string;
|
|
58
51
|
parse: (value: string, format: string) => defaultMoment.Moment | null;
|
|
59
52
|
getCurrentLocaleCode: () => string;
|
|
60
53
|
is12HourCycleInCurrentLocale: () => boolean;
|
|
61
54
|
expandFormat: (format: string) => string;
|
|
62
|
-
|
|
63
|
-
isNull: (value: Moment | null) => boolean;
|
|
64
|
-
isValid: (value: any) => boolean;
|
|
55
|
+
isValid: (value: Moment | null) => boolean;
|
|
65
56
|
format: (value: Moment, formatKey: keyof AdapterFormats) => string;
|
|
66
57
|
formatByString: (value: Moment, formatString: string) => string;
|
|
67
58
|
formatNumber: (numberToFormat: string) => string;
|
|
68
|
-
|
|
69
|
-
isEqual: (value: any, comparing: any) => boolean;
|
|
59
|
+
isEqual: (value: Moment | null, comparing: Moment | null) => boolean;
|
|
70
60
|
isSameYear: (value: Moment, comparing: Moment) => boolean;
|
|
71
61
|
isSameMonth: (value: Moment, comparing: Moment) => boolean;
|
|
72
62
|
isSameDay: (value: Moment, comparing: Moment) => boolean;
|
|
@@ -108,13 +98,7 @@ export declare class AdapterMoment implements MuiPickersAdapter<Moment, string>
|
|
|
108
98
|
setSeconds: (value: Moment, seconds: number) => defaultMoment.Moment;
|
|
109
99
|
setMilliseconds: (value: Moment, milliseconds: number) => defaultMoment.Moment;
|
|
110
100
|
getDaysInMonth: (value: Moment) => number;
|
|
111
|
-
getNextMonth: (value: Moment) => defaultMoment.Moment;
|
|
112
|
-
getPreviousMonth: (value: Moment) => defaultMoment.Moment;
|
|
113
|
-
getMonthArray: (value: Moment) => defaultMoment.Moment[];
|
|
114
|
-
mergeDateAndTime: (dateParam: Moment, timeParam: Moment) => defaultMoment.Moment;
|
|
115
|
-
getWeekdays: () => string[];
|
|
116
101
|
getWeekArray: (value: Moment) => defaultMoment.Moment[][];
|
|
117
102
|
getWeekNumber: (value: Moment) => number;
|
|
118
|
-
getYearRange: (start
|
|
119
|
-
getMeridiemText: (ampm: 'am' | 'pm') => string;
|
|
103
|
+
getYearRange: ([start, end]: [Moment, Moment]) => defaultMoment.Moment[];
|
|
120
104
|
}
|
|
@@ -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,22 +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
|
-
var _this$locale;
|
|
186
|
-
const momentLocale = defaultMoment.locale();
|
|
187
|
-
const adapterLocale = (_this$locale = this.locale) != null ? _this$locale : 'en-us';
|
|
188
|
-
if (momentLocale !== adapterLocale) {
|
|
189
|
-
defaultMoment.locale(adapterLocale);
|
|
190
|
-
const result = runner();
|
|
191
|
-
defaultMoment.locale(momentLocale);
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
return runner();
|
|
195
|
-
};
|
|
196
174
|
this.hasTimezonePlugin = () => typeof this.moment.tz !== 'undefined';
|
|
197
175
|
this.createSystemDate = value => {
|
|
198
176
|
const parsedValue = this.moment(value).local();
|
|
@@ -279,12 +257,6 @@ export class AdapterMoment {
|
|
|
279
257
|
this.toJsDate = value => {
|
|
280
258
|
return value.toDate();
|
|
281
259
|
};
|
|
282
|
-
this.parseISO = isoString => {
|
|
283
|
-
return this.moment(isoString, true);
|
|
284
|
-
};
|
|
285
|
-
this.toISO = value => {
|
|
286
|
-
return value.toISOString();
|
|
287
|
-
};
|
|
288
260
|
this.parse = (value, format) => {
|
|
289
261
|
if (value === '') {
|
|
290
262
|
return null;
|
|
@@ -311,14 +283,11 @@ export class AdapterMoment {
|
|
|
311
283
|
return token;
|
|
312
284
|
}).join('');
|
|
313
285
|
};
|
|
314
|
-
this.getFormatHelperText = format => {
|
|
315
|
-
return this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
316
|
-
};
|
|
317
|
-
this.isNull = value => {
|
|
318
|
-
return value === null;
|
|
319
|
-
};
|
|
320
286
|
this.isValid = value => {
|
|
321
|
-
|
|
287
|
+
if (value == null) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return value.isValid();
|
|
322
291
|
};
|
|
323
292
|
this.format = (value, formatKey) => {
|
|
324
293
|
return this.formatByString(value, this.formats[formatKey]);
|
|
@@ -331,14 +300,14 @@ export class AdapterMoment {
|
|
|
331
300
|
this.formatNumber = numberToFormat => {
|
|
332
301
|
return numberToFormat;
|
|
333
302
|
};
|
|
334
|
-
this.getDiff = (value, comparing, unit) => {
|
|
335
|
-
return value.diff(comparing, unit);
|
|
336
|
-
};
|
|
337
303
|
this.isEqual = (value, comparing) => {
|
|
338
304
|
if (value === null && comparing === null) {
|
|
339
305
|
return true;
|
|
340
306
|
}
|
|
341
|
-
|
|
307
|
+
if (value === null || comparing === null) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
return value.isSame(comparing);
|
|
342
311
|
};
|
|
343
312
|
this.isSameYear = (value, comparing) => {
|
|
344
313
|
return value.isSame(comparing, 'year');
|
|
@@ -463,25 +432,6 @@ export class AdapterMoment {
|
|
|
463
432
|
this.getDaysInMonth = value => {
|
|
464
433
|
return value.daysInMonth();
|
|
465
434
|
};
|
|
466
|
-
this.getNextMonth = value => {
|
|
467
|
-
return value.clone().add(1, 'month');
|
|
468
|
-
};
|
|
469
|
-
this.getPreviousMonth = value => {
|
|
470
|
-
return value.clone().subtract(1, 'month');
|
|
471
|
-
};
|
|
472
|
-
this.getMonthArray = value => {
|
|
473
|
-
const firstMonth = this.startOfYear(value);
|
|
474
|
-
const monthArray = [firstMonth];
|
|
475
|
-
while (monthArray.length < 12) {
|
|
476
|
-
const prevMonth = monthArray[monthArray.length - 1];
|
|
477
|
-
monthArray.push(this.getNextMonth(prevMonth));
|
|
478
|
-
}
|
|
479
|
-
return monthArray;
|
|
480
|
-
};
|
|
481
|
-
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
482
|
-
return dateParam.clone().hour(timeParam.hour()).minute(timeParam.minute()).second(timeParam.second());
|
|
483
|
-
};
|
|
484
|
-
this.getWeekdays = () => this.syncMomentLocale(() => defaultMoment.weekdaysShort(true));
|
|
485
435
|
this.getWeekArray = value => {
|
|
486
436
|
const cleanValue = this.setLocaleToValue(value);
|
|
487
437
|
const start = cleanValue.clone().startOf('month').startOf('week');
|
|
@@ -501,7 +451,7 @@ export class AdapterMoment {
|
|
|
501
451
|
this.getWeekNumber = value => {
|
|
502
452
|
return value.week();
|
|
503
453
|
};
|
|
504
|
-
this.getYearRange = (start, end) => {
|
|
454
|
+
this.getYearRange = ([start, end]) => {
|
|
505
455
|
const startDate = this.moment(start).startOf('year');
|
|
506
456
|
const endDate = this.moment(end).endOf('year');
|
|
507
457
|
const years = [];
|
|
@@ -512,13 +462,6 @@ export class AdapterMoment {
|
|
|
512
462
|
}
|
|
513
463
|
return years;
|
|
514
464
|
};
|
|
515
|
-
this.getMeridiemText = ampm => {
|
|
516
|
-
if (this.is12HourCycleInCurrentLocale()) {
|
|
517
|
-
// AM/PM translation only possible in those who have 12 hour cycle in locale.
|
|
518
|
-
return defaultMoment.localeData(this.getCurrentLocaleCode()).meridiem(ampm === 'am' ? 0 : 13, 0, false);
|
|
519
|
-
}
|
|
520
|
-
return ampm === 'am' ? 'AM' : 'PM'; // fallback for de, ru, ...etc
|
|
521
|
-
};
|
|
522
465
|
this.moment = instance || defaultMoment;
|
|
523
466
|
this.locale = locale;
|
|
524
467
|
this.formats = _extends({}, defaultFormats, formats);
|
|
@@ -37,9 +37,7 @@ export declare class AdapterMomentHijri extends AdapterMoment implements MuiPick
|
|
|
37
37
|
getTimezone: () => string;
|
|
38
38
|
setTimezone: (value: Moment) => Moment;
|
|
39
39
|
parse: (value: string, format: string) => defaultHMoment.Moment | null;
|
|
40
|
-
getFormatHelperText: (format: string) => string;
|
|
41
40
|
formatNumber: (numberToFormat: string) => string;
|
|
42
|
-
isEqual: (value: any, comparing: any) => boolean;
|
|
43
41
|
startOfYear: (value: Moment) => defaultHMoment.Moment;
|
|
44
42
|
startOfMonth: (value: Moment) => defaultHMoment.Moment;
|
|
45
43
|
endOfYear: (value: Moment) => defaultHMoment.Moment;
|
|
@@ -52,11 +50,7 @@ export declare class AdapterMomentHijri extends AdapterMoment implements MuiPick
|
|
|
52
50
|
setYear: (value: Moment, year: number) => defaultHMoment.Moment;
|
|
53
51
|
setMonth: (value: Moment, month: number) => defaultHMoment.Moment;
|
|
54
52
|
setDate: (value: Moment, date: number) => defaultHMoment.Moment;
|
|
55
|
-
getNextMonth: (value: Moment) => defaultHMoment.Moment;
|
|
56
|
-
getPreviousMonth: (value: Moment) => defaultHMoment.Moment;
|
|
57
|
-
getWeekdays: () => string[];
|
|
58
53
|
getWeekArray: (value: Moment) => defaultHMoment.Moment[][];
|
|
59
54
|
getWeekNumber: (value: Moment) => number;
|
|
60
|
-
getYearRange: (start
|
|
61
|
-
getMeridiemText: (ampm: 'am' | 'pm') => string;
|
|
55
|
+
getYearRange: ([start, end]: [Moment, Moment]) => defaultHMoment.Moment[];
|
|
62
56
|
}
|
|
@@ -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);
|
|
@@ -36,12 +36,8 @@ export declare class AdapterMomentJalaali extends AdapterMoment implements MuiPi
|
|
|
36
36
|
dateWithTimezone: <T extends string | null | undefined>(value: T) => DateBuilderReturnType<T, defaultJMoment.Moment>;
|
|
37
37
|
getTimezone: () => string;
|
|
38
38
|
setTimezone: (value: Moment) => Moment;
|
|
39
|
-
parseISO: (isoString: string) => defaultJMoment.Moment;
|
|
40
39
|
parse: (value: string, format: string) => defaultJMoment.Moment | null;
|
|
41
|
-
getFormatHelperText: (format: string) => string;
|
|
42
|
-
isValid: (value: any) => boolean;
|
|
43
40
|
formatNumber: (numberToFormat: string) => string;
|
|
44
|
-
isEqual: (value: any, comparing: any) => boolean;
|
|
45
41
|
isSameYear: (value: Moment, comparing: Moment) => boolean;
|
|
46
42
|
isSameMonth: (value: Moment, comparing: Moment) => boolean;
|
|
47
43
|
isAfterYear: (value: Moment, comparing: Moment) => boolean;
|
|
@@ -58,11 +54,7 @@ export declare class AdapterMomentJalaali extends AdapterMoment implements MuiPi
|
|
|
58
54
|
setYear: (value: Moment, year: number) => defaultJMoment.Moment;
|
|
59
55
|
setMonth: (value: Moment, month: number) => defaultJMoment.Moment;
|
|
60
56
|
setDate: (value: Moment, date: number) => defaultJMoment.Moment;
|
|
61
|
-
getNextMonth: (value: Moment) => defaultJMoment.Moment;
|
|
62
|
-
getPreviousMonth: (value: Moment) => defaultJMoment.Moment;
|
|
63
|
-
getWeekdays: () => string[];
|
|
64
57
|
getWeekArray: (value: Moment) => defaultJMoment.Moment[][];
|
|
65
58
|
getWeekNumber: (value: Moment) => number;
|
|
66
|
-
getYearRange: (start
|
|
67
|
-
getMeridiemText: (ampm: 'am' | 'pm') => string;
|
|
59
|
+
getYearRange: ([start, end]: [Moment, Moment]) => defaultJMoment.Moment[];
|
|
68
60
|
}
|
|
@@ -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);
|