@mui/x-date-pickers 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDateFns/AdapterDateFns.d.ts +3 -7
- package/AdapterDateFns/AdapterDateFns.js +2 -8
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +3 -7
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
- package/AdapterDayjs/AdapterDayjs.d.ts +3 -9
- package/AdapterDayjs/AdapterDayjs.js +2 -3
- package/AdapterLuxon/AdapterLuxon.d.ts +3 -8
- package/AdapterLuxon/AdapterLuxon.js +6 -5
- package/AdapterMoment/AdapterMoment.d.ts +3 -9
- package/AdapterMoment/AdapterMoment.js +2 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +5 -14
- package/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +6 -16
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
- package/CHANGELOG.md +105 -2
- package/DateCalendar/DateCalendar.js +2 -2
- package/DateCalendar/DayCalendar.js +11 -10
- package/DateCalendar/PickersCalendarHeader.js +2 -2
- package/DateCalendar/useCalendarState.d.ts +1 -1
- package/DateField/DateField.js +4 -0
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimeField/DateTimeField.js +4 -0
- package/DateTimeField/DateTimeField.types.d.ts +2 -10
- package/DateTimePicker/shared.d.ts +5 -12
- package/DesktopTimePicker/DesktopTimePicker.js +4 -2
- package/LocalizationProvider/LocalizationProvider.d.ts +10 -8
- package/LocalizationProvider/LocalizationProvider.js +3 -3
- package/MonthCalendar/MonthCalendar.js +2 -2
- package/TimeClock/TimeClock.types.d.ts +2 -1
- package/TimeField/TimeField.js +4 -0
- package/index.js +1 -1
- package/internals/hooks/useField/useField.utils.d.ts +13 -13
- package/internals/hooks/useField/useField.utils.js +5 -4
- package/internals/hooks/useField/useFieldState.js +2 -2
- package/internals/hooks/usePicker/usePickerViews.d.ts +2 -2
- package/internals/hooks/useUtils.d.ts +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/models/props/clock.d.ts +1 -1
- package/internals/models/validation.d.ts +13 -0
- package/internals/utils/date-utils.d.ts +6 -4
- package/internals/utils/date-utils.js +16 -0
- package/internals/utils/time-utils.d.ts +4 -4
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/internals/utils/validation/extractValidationProps.js +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +2 -8
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
- package/legacy/AdapterDayjs/AdapterDayjs.js +2 -3
- package/legacy/AdapterLuxon/AdapterLuxon.js +6 -5
- package/legacy/AdapterMoment/AdapterMoment.js +2 -2
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
- package/legacy/DateCalendar/DateCalendar.js +2 -2
- package/legacy/DateCalendar/DayCalendar.js +11 -10
- package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
- package/legacy/DateField/DateField.js +4 -0
- package/legacy/DateTimeField/DateTimeField.js +4 -0
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +4 -2
- package/legacy/LocalizationProvider/LocalizationProvider.js +3 -3
- package/legacy/MonthCalendar/MonthCalendar.js +2 -2
- package/legacy/TimeField/TimeField.js +4 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.utils.js +7 -6
- package/legacy/internals/hooks/useField/useFieldState.js +2 -2
- package/legacy/internals/utils/date-utils.js +16 -0
- package/legacy/internals/utils/validation/extractValidationProps.js +1 -1
- package/legacy/locales/csCZ.js +3 -3
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/skSK.js +93 -0
- package/legacy/locales/ukUA.js +3 -1
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
- package/legacy/tests/describeGregorianAdapter/index.js +2 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +272 -200
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +34 -0
- package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
- package/legacy/tests/describeHijriAdapter/testCalculations.js +101 -28
- package/legacy/tests/describeHijriAdapter/testLocalization.js +8 -0
- package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
- package/legacy/tests/describeJalaliAdapter/testCalculations.js +157 -24
- package/legacy/tests/describeJalaliAdapter/testLocalization.js +8 -0
- package/legacy/tests/describeValidation/testTextFieldValidation.js +26 -0
- package/locales/beBY.d.ts +3 -3
- package/locales/caES.d.ts +3 -3
- package/locales/csCZ.d.ts +3 -3
- package/locales/csCZ.js +3 -3
- package/locales/daDK.d.ts +3 -3
- package/locales/deDE.d.ts +3 -3
- package/locales/enUS.d.ts +3 -3
- package/locales/esES.d.ts +3 -3
- package/locales/faIR.d.ts +3 -3
- package/locales/fiFI.d.ts +3 -3
- package/locales/frFR.d.ts +3 -3
- package/locales/heIL.d.ts +3 -3
- package/locales/huHU.d.ts +3 -3
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/isIS.d.ts +3 -3
- package/locales/itIT.d.ts +3 -3
- package/locales/jaJP.d.ts +3 -3
- package/locales/koKR.d.ts +3 -3
- package/locales/kzKZ.d.ts +3 -3
- package/locales/nbNO.d.ts +3 -3
- package/locales/nlNL.d.ts +3 -3
- package/locales/plPL.d.ts +3 -3
- package/locales/ptBR.d.ts +3 -3
- package/locales/ruRU.d.ts +3 -3
- package/locales/skSK.d.ts +53 -0
- package/locales/skSK.js +61 -0
- package/locales/svSE.d.ts +3 -3
- package/locales/trTR.d.ts +3 -3
- package/locales/ukUA.d.ts +3 -3
- package/locales/ukUA.js +1 -1
- package/locales/urPK.d.ts +3 -3
- package/locales/utils/getPickersLocalization.d.ts +3 -3
- package/locales/zhCN.d.ts +3 -3
- package/models/adapters.d.ts +43 -35
- package/modern/AdapterDateFns/AdapterDateFns.js +2 -8
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
- package/modern/AdapterDayjs/AdapterDayjs.js +2 -2
- package/modern/AdapterLuxon/AdapterLuxon.js +6 -5
- package/modern/AdapterMoment/AdapterMoment.js +2 -2
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DateCalendar/DayCalendar.js +11 -10
- package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
- package/modern/DateField/DateField.js +4 -0
- package/modern/DateTimeField/DateTimeField.js +4 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -1
- package/modern/LocalizationProvider/LocalizationProvider.js +3 -3
- package/modern/MonthCalendar/MonthCalendar.js +2 -2
- package/modern/TimeField/TimeField.js +4 -0
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useField/useField.utils.js +5 -4
- package/modern/internals/hooks/useField/useFieldState.js +2 -2
- package/modern/internals/utils/date-utils.js +16 -0
- package/modern/internals/utils/validation/extractValidationProps.js +1 -1
- package/modern/locales/csCZ.js +3 -3
- package/modern/locales/index.js +1 -0
- package/modern/locales/skSK.js +58 -0
- package/modern/locales/ukUA.js +1 -1
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
- package/modern/tests/describeGregorianAdapter/index.js +2 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -198
- package/modern/tests/describeGregorianAdapter/testLocalization.js +34 -0
- package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
- package/modern/tests/describeHijriAdapter/testCalculations.js +101 -28
- package/modern/tests/describeHijriAdapter/testLocalization.js +8 -0
- package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
- package/modern/tests/describeJalaliAdapter/testCalculations.js +157 -24
- package/modern/tests/describeJalaliAdapter/testLocalization.js +8 -0
- package/modern/tests/describeValidation/testTextFieldValidation.js +27 -0
- package/node/AdapterDateFns/AdapterDateFns.js +2 -8
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
- package/node/AdapterDayjs/AdapterDayjs.js +2 -2
- package/node/AdapterLuxon/AdapterLuxon.js +6 -5
- package/node/AdapterMoment/AdapterMoment.js +2 -2
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateCalendar/DayCalendar.js +11 -10
- package/node/DateCalendar/PickersCalendarHeader.js +2 -2
- package/node/DateField/DateField.js +4 -0
- package/node/DateTimeField/DateTimeField.js +4 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +3 -1
- package/node/LocalizationProvider/LocalizationProvider.js +5 -5
- package/node/MonthCalendar/MonthCalendar.js +1 -1
- package/node/TimeField/TimeField.js +4 -0
- package/node/index.js +1 -1
- package/node/internals/hooks/useField/useField.utils.js +5 -4
- package/node/internals/hooks/useField/useFieldState.js +2 -2
- package/node/internals/utils/date-utils.js +20 -2
- package/node/internals/utils/validation/extractValidationProps.js +1 -1
- package/node/locales/csCZ.js +3 -3
- package/node/locales/index.js +11 -0
- package/node/locales/skSK.js +65 -0
- package/node/locales/ukUA.js +1 -1
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -9
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +10 -0
- package/node/tests/describeGregorianAdapter/index.js +4 -3
- package/node/tests/describeGregorianAdapter/testCalculations.js +272 -198
- package/node/tests/describeGregorianAdapter/testLocalization.js +35 -0
- package/node/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
- package/node/tests/describeHijriAdapter/testCalculations.js +100 -27
- package/node/tests/describeHijriAdapter/testLocalization.js +8 -0
- package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
- package/node/tests/describeJalaliAdapter/testCalculations.js +156 -23
- package/node/tests/describeJalaliAdapter/testLocalization.js +8 -0
- package/node/tests/describeValidation/testTextFieldValidation.js +27 -0
- package/package.json +2 -2
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
- package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
- package/tests/describeGregorianAdapter/index.js +2 -1
- package/tests/describeGregorianAdapter/testCalculations.js +272 -198
- package/tests/describeGregorianAdapter/testLocalization.js +34 -0
- package/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
- package/tests/describeHijriAdapter/testCalculations.js +101 -28
- package/tests/describeHijriAdapter/testLocalization.js +8 -0
- package/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
- package/tests/describeJalaliAdapter/testCalculations.js +157 -24
- package/tests/describeJalaliAdapter/testLocalization.js +8 -0
- package/tests/describeValidation/testTextFieldValidation.js +27 -0
- package/themeAugmentation/props.d.ts +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +2 -2
package/models/adapters.d.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { FieldSectionContentType, FieldSectionType } from './fields';
|
|
2
|
-
export interface AdapterFormats
|
|
2
|
+
export interface AdapterFormats {
|
|
3
3
|
/** Localized full date @example "Jan 1, 2019" */
|
|
4
|
-
fullDate:
|
|
4
|
+
fullDate: string;
|
|
5
5
|
/** Partially localized full date with weekday, useful for text-to-speech accessibility @example "Tuesday, January 1, 2019" */
|
|
6
|
-
fullDateWithWeekday:
|
|
6
|
+
fullDateWithWeekday: string;
|
|
7
7
|
/** Date format string with month and day of month @example "1 January" */
|
|
8
|
-
normalDate:
|
|
8
|
+
normalDate: string;
|
|
9
9
|
/** Date format string with weekday, month and day of month @example "Wed, Jan 1" */
|
|
10
|
-
normalDateWithWeekday:
|
|
10
|
+
normalDateWithWeekday: string;
|
|
11
11
|
/** Shorter day format @example "Jan 1" */
|
|
12
|
-
shortDate:
|
|
12
|
+
shortDate: string;
|
|
13
13
|
/** Year format string @example "2019" */
|
|
14
|
-
year:
|
|
14
|
+
year: string;
|
|
15
15
|
/** Month format string @example "January" */
|
|
16
|
-
month:
|
|
16
|
+
month: string;
|
|
17
17
|
/** Short month format string @example "Jan" */
|
|
18
|
-
monthShort:
|
|
18
|
+
monthShort: string;
|
|
19
19
|
/** Month with year format string @example "January 2018" */
|
|
20
|
-
monthAndYear:
|
|
20
|
+
monthAndYear: string;
|
|
21
21
|
/** Month with date format string @example "January 1" */
|
|
22
|
-
monthAndDate:
|
|
22
|
+
monthAndDate: string;
|
|
23
23
|
/** Weekday format string @example "Wednesday" */
|
|
24
|
-
weekday:
|
|
24
|
+
weekday: string;
|
|
25
25
|
/** Short weekday format string @example "Wed" */
|
|
26
|
-
weekdayShort:
|
|
26
|
+
weekdayShort: string;
|
|
27
27
|
/** Day format string @example "1" */
|
|
28
|
-
dayOfMonth:
|
|
28
|
+
dayOfMonth: string;
|
|
29
29
|
/** Hours format string @example "11" */
|
|
30
|
-
hours12h:
|
|
30
|
+
hours12h: string;
|
|
31
31
|
/** Hours format string @example "23" */
|
|
32
|
-
hours24h:
|
|
32
|
+
hours24h: string;
|
|
33
33
|
/** Minutes format string @example "44" */
|
|
34
|
-
minutes:
|
|
34
|
+
minutes: string;
|
|
35
35
|
/** Seconds format string @example "00" */
|
|
36
|
-
seconds:
|
|
36
|
+
seconds: string;
|
|
37
37
|
/** Full time localized format string @example "11:44 PM" for US, "23:44" for Europe */
|
|
38
|
-
fullTime:
|
|
38
|
+
fullTime: string;
|
|
39
39
|
/** Not localized full time format string @example "11:44 PM" */
|
|
40
|
-
fullTime12h:
|
|
40
|
+
fullTime12h: string;
|
|
41
41
|
/** Not localized full time format string @example "23:44" */
|
|
42
|
-
fullTime24h:
|
|
42
|
+
fullTime24h: string;
|
|
43
43
|
/** Date & time format string with localized time @example "Jan 1, 2018 11:44 PM" */
|
|
44
|
-
fullDateTime:
|
|
44
|
+
fullDateTime: string;
|
|
45
45
|
/** Not localized date & Time format 12h @example "Jan 1, 2018 11:44 PM" */
|
|
46
|
-
fullDateTime12h:
|
|
46
|
+
fullDateTime12h: string;
|
|
47
47
|
/** Not localized date & Time format 24h @example "Jan 1, 2018 23:44" */
|
|
48
|
-
fullDateTime24h:
|
|
48
|
+
fullDateTime24h: string;
|
|
49
49
|
/** Localized keyboard input friendly date format @example "02/13/2020 */
|
|
50
|
-
keyboardDate:
|
|
50
|
+
keyboardDate: string;
|
|
51
51
|
/** Localized keyboard input friendly date/time format @example "02/13/2020 23:44" */
|
|
52
|
-
keyboardDateTime:
|
|
52
|
+
keyboardDateTime: string;
|
|
53
53
|
/** Partially localized keyboard input friendly date/time 12h format @example "02/13/2020 11:44 PM" */
|
|
54
|
-
keyboardDateTime12h:
|
|
54
|
+
keyboardDateTime12h: string;
|
|
55
55
|
/** Partially localized keyboard input friendly date/time 24h format @example "02/13/2020 23:44" */
|
|
56
|
-
keyboardDateTime24h:
|
|
56
|
+
keyboardDateTime24h: string;
|
|
57
57
|
}
|
|
58
58
|
export type AdapterUnits = 'years' | 'quarters' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds';
|
|
59
59
|
export type FieldFormatTokenMap = {
|
|
@@ -63,16 +63,23 @@ export type FieldFormatTokenMap = {
|
|
|
63
63
|
maxLength?: number;
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
type PropertyIfNotNever<PName extends string, PType> = [PType] extends [never] ? {} : {
|
|
67
|
+
[P in PName]?: PType;
|
|
68
|
+
};
|
|
69
|
+
export type AdapterOptions<TLocale, TInstance> = {
|
|
70
|
+
formats?: Partial<AdapterFormats>;
|
|
71
|
+
locale?: TLocale;
|
|
72
|
+
} & PropertyIfNotNever<'instance', TInstance>;
|
|
73
|
+
export interface MuiPickersAdapter<TDate, TLocale = any> {
|
|
67
74
|
/**
|
|
68
75
|
* A boolean confirming that the adapter used is an MUI adapter.
|
|
69
76
|
*/
|
|
70
77
|
isMUIAdapter: boolean;
|
|
71
|
-
formats: AdapterFormats
|
|
72
|
-
locale?:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
formats: AdapterFormats;
|
|
79
|
+
locale?: TLocale;
|
|
80
|
+
/**
|
|
81
|
+
* Name of the library that is used right now
|
|
82
|
+
*/
|
|
76
83
|
lib: string;
|
|
77
84
|
/**
|
|
78
85
|
* The characters used to escape a string inside a format.
|
|
@@ -96,7 +103,6 @@ export interface MuiPickersAdapter<TDate> {
|
|
|
96
103
|
date(value?: any): TDate | null;
|
|
97
104
|
/**
|
|
98
105
|
* Convert a date in the library format into a JavaScript `Date` object.
|
|
99
|
-
* @deprecate Will be removed in v7.
|
|
100
106
|
* @template TDate
|
|
101
107
|
* @param {TDate} value The value to convert.
|
|
102
108
|
* @returns {Date} the JavaScript date.
|
|
@@ -527,6 +533,7 @@ export interface MuiPickersAdapter<TDate> {
|
|
|
527
533
|
getMonthArray(value: TDate): TDate[];
|
|
528
534
|
/**
|
|
529
535
|
* Create a date with the date of the first param and the time of the second param.
|
|
536
|
+
* @deprecated Use `adapter.setHours`, `adapter.setMinutes` and `adapter.setSeconds`.
|
|
530
537
|
* @template TDate
|
|
531
538
|
* @param {TDate} dateParam Param from which we want to get the date.
|
|
532
539
|
* @param {TDate} timeParam Param from which we want to get the time.
|
|
@@ -567,3 +574,4 @@ export interface MuiPickersAdapter<TDate> {
|
|
|
567
574
|
*/
|
|
568
575
|
getMeridiemText(meridiem: 'am' | 'pm'): string;
|
|
569
576
|
}
|
|
577
|
+
export {};
|
|
@@ -22,7 +22,6 @@ import endOfWeek from 'date-fns/endOfWeek';
|
|
|
22
22
|
import endOfYear from 'date-fns/endOfYear';
|
|
23
23
|
import dateFnsFormat from 'date-fns/format';
|
|
24
24
|
import getDate from 'date-fns/getDate';
|
|
25
|
-
import getDay from 'date-fns/getDay';
|
|
26
25
|
import getDaysInMonth from 'date-fns/getDaysInMonth';
|
|
27
26
|
import getHours from 'date-fns/getHours';
|
|
28
27
|
import getMinutes from 'date-fns/getMinutes';
|
|
@@ -558,17 +557,12 @@ export class AdapterDateFns {
|
|
|
558
557
|
let count = 0;
|
|
559
558
|
let current = start;
|
|
560
559
|
const nestedWeeks = [];
|
|
561
|
-
let lastDay = null;
|
|
562
560
|
while (isBefore(current, end)) {
|
|
563
561
|
const weekNumber = Math.floor(count / 7);
|
|
564
562
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
565
|
-
|
|
566
|
-
if (lastDay !== day) {
|
|
567
|
-
lastDay = day;
|
|
568
|
-
nestedWeeks[weekNumber].push(current);
|
|
569
|
-
count += 1;
|
|
570
|
-
}
|
|
563
|
+
nestedWeeks[weekNumber].push(current);
|
|
571
564
|
current = addDays(current, 1);
|
|
565
|
+
count += 1;
|
|
572
566
|
}
|
|
573
567
|
return nestedWeeks;
|
|
574
568
|
};
|
|
@@ -28,7 +28,6 @@ import getWeek from 'date-fns-jalali/getWeek';
|
|
|
28
28
|
import getYear from 'date-fns-jalali/getYear';
|
|
29
29
|
import getMonth from 'date-fns-jalali/getMonth';
|
|
30
30
|
import getDate from 'date-fns-jalali/getDate';
|
|
31
|
-
import getDay from 'date-fns-jalali/getDay';
|
|
32
31
|
import getDaysInMonth from 'date-fns-jalali/getDaysInMonth';
|
|
33
32
|
import getMinutes from 'date-fns-jalali/getMinutes';
|
|
34
33
|
import isAfter from 'date-fns-jalali/isAfter';
|
|
@@ -569,17 +568,12 @@ export class AdapterDateFnsJalali {
|
|
|
569
568
|
let count = 0;
|
|
570
569
|
let current = start;
|
|
571
570
|
const nestedWeeks = [];
|
|
572
|
-
let lastDay = null;
|
|
573
571
|
while (isBefore(current, end)) {
|
|
574
572
|
const weekNumber = Math.floor(count / 7);
|
|
575
573
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
576
|
-
|
|
577
|
-
if (lastDay !== day) {
|
|
578
|
-
lastDay = day;
|
|
579
|
-
nestedWeeks[weekNumber].push(current);
|
|
580
|
-
count += 1;
|
|
581
|
-
}
|
|
574
|
+
nestedWeeks[weekNumber].push(current);
|
|
582
575
|
current = addDays(current, 1);
|
|
576
|
+
count += 1;
|
|
583
577
|
}
|
|
584
578
|
return nestedWeeks;
|
|
585
579
|
};
|
|
@@ -167,7 +167,7 @@ export class AdapterDayjs {
|
|
|
167
167
|
};
|
|
168
168
|
this.formatTokenMap = formatTokenMap;
|
|
169
169
|
this.getLocaleFormats = () => {
|
|
170
|
-
const locales =
|
|
170
|
+
const locales = defaultDayjs.Ls;
|
|
171
171
|
const locale = this.locale || 'en';
|
|
172
172
|
let localeObject = locales[locale];
|
|
173
173
|
if (localeObject === undefined) {
|
|
@@ -369,7 +369,7 @@ export class AdapterDayjs {
|
|
|
369
369
|
const monthArray = [firstMonth];
|
|
370
370
|
while (monthArray.length < 12) {
|
|
371
371
|
const prevMonth = monthArray[monthArray.length - 1];
|
|
372
|
-
monthArray.push(this.
|
|
372
|
+
monthArray.push(this.addMonths(prevMonth, 1));
|
|
373
373
|
}
|
|
374
374
|
return monthArray;
|
|
375
375
|
};
|
|
@@ -9,7 +9,11 @@ const formatTokenMap = {
|
|
|
9
9
|
maxLength: 4
|
|
10
10
|
},
|
|
11
11
|
yy: 'year',
|
|
12
|
-
yyyy:
|
|
12
|
+
yyyy: {
|
|
13
|
+
sectionType: 'year',
|
|
14
|
+
contentType: 'digit',
|
|
15
|
+
maxLength: 4
|
|
16
|
+
},
|
|
13
17
|
// Month
|
|
14
18
|
L: {
|
|
15
19
|
sectionType: 'month',
|
|
@@ -227,9 +231,6 @@ export class AdapterLuxon {
|
|
|
227
231
|
})?.resolvedOptions()?.hour12);
|
|
228
232
|
};
|
|
229
233
|
this.expandFormat = format => {
|
|
230
|
-
if (!DateTime.expandFormat) {
|
|
231
|
-
throw Error('Your luxon version does not support `expandFormat`. Consider upgrading it to v3.0.2');
|
|
232
|
-
}
|
|
233
234
|
// Extract escaped section to avoid extending them
|
|
234
235
|
const longFormatRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
|
|
235
236
|
return format.match(longFormatRegexp).map(token => {
|
|
@@ -453,7 +454,7 @@ export class AdapterLuxon {
|
|
|
453
454
|
const monthArray = [firstMonth];
|
|
454
455
|
while (monthArray.length < 12) {
|
|
455
456
|
const prevMonth = monthArray[monthArray.length - 1];
|
|
456
|
-
monthArray.push(this.
|
|
457
|
+
monthArray.push(this.addMonths(prevMonth, 1));
|
|
457
458
|
}
|
|
458
459
|
return monthArray;
|
|
459
460
|
};
|
|
@@ -359,7 +359,7 @@ export class AdapterMoment {
|
|
|
359
359
|
return value.clone().subtract(1, 'month');
|
|
360
360
|
};
|
|
361
361
|
this.getMonthArray = value => {
|
|
362
|
-
const firstMonth =
|
|
362
|
+
const firstMonth = this.startOfYear(value);
|
|
363
363
|
const monthArray = [firstMonth];
|
|
364
364
|
while (monthArray.length < 12) {
|
|
365
365
|
const prevMonth = monthArray[monthArray.length - 1];
|
|
@@ -405,7 +405,7 @@ export class AdapterMoment {
|
|
|
405
405
|
this.getMeridiemText = ampm => {
|
|
406
406
|
if (this.is12HourCycleInCurrentLocale()) {
|
|
407
407
|
// AM/PM translation only possible in those who have 12 hour cycle in locale.
|
|
408
|
-
return
|
|
408
|
+
return defaultMoment.localeData(this.getCurrentLocaleCode()).meridiem(ampm === 'am' ? 0 : 13, 0, false);
|
|
409
409
|
}
|
|
410
410
|
return ampm === 'am' ? 'AM' : 'PM'; // fallback for de, ru, ...etc
|
|
411
411
|
};
|
|
@@ -142,15 +142,9 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
142
142
|
locale: 'ar-SA',
|
|
143
143
|
instance
|
|
144
144
|
});
|
|
145
|
-
this.
|
|
145
|
+
this.lib = 'moment-hijri';
|
|
146
|
+
this.moment = void 0;
|
|
146
147
|
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
148
|
this.date = value => {
|
|
155
149
|
if (value === null) {
|
|
156
150
|
return null;
|
|
@@ -219,7 +213,7 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
219
213
|
};
|
|
220
214
|
this.getWeekdays = () => {
|
|
221
215
|
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
222
|
-
return this.
|
|
216
|
+
return this.date().weekday(dayOfWeek).format('dd');
|
|
223
217
|
});
|
|
224
218
|
};
|
|
225
219
|
this.getWeekArray = value => {
|
|
@@ -260,7 +254,7 @@ export class AdapterMomentHijri extends AdapterMoment {
|
|
|
260
254
|
return years;
|
|
261
255
|
};
|
|
262
256
|
this.getMeridiemText = ampm => {
|
|
263
|
-
return ampm === 'am' ? this.
|
|
257
|
+
return ampm === 'am' ? this.date().hours(2).format('A') : this.date().hours(14).format('A');
|
|
264
258
|
};
|
|
265
259
|
this.moment = instance || defaultHMoment;
|
|
266
260
|
this.locale = 'ar-SA';
|
|
@@ -140,25 +140,18 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
140
140
|
locale: 'fa',
|
|
141
141
|
instance
|
|
142
142
|
});
|
|
143
|
-
this.isMUIAdapter = true;
|
|
144
143
|
this.lib = 'moment-jalaali';
|
|
145
144
|
this.moment = void 0;
|
|
146
|
-
this.locale = void 0;
|
|
147
|
-
this.formats = void 0;
|
|
148
145
|
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
146
|
this.date = value => {
|
|
157
147
|
if (value === null) {
|
|
158
148
|
return null;
|
|
159
149
|
}
|
|
160
150
|
return this.moment(value).locale('fa');
|
|
161
151
|
};
|
|
152
|
+
this.parseISO = isoString => {
|
|
153
|
+
return this.moment(isoString).locale('fa');
|
|
154
|
+
};
|
|
162
155
|
this.parse = (value, format) => {
|
|
163
156
|
if (value === '') {
|
|
164
157
|
return null;
|
|
@@ -184,6 +177,16 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
184
177
|
}
|
|
185
178
|
return this.moment(value).isSame(comparing);
|
|
186
179
|
};
|
|
180
|
+
this.isSameYear = (value, comparing) => {
|
|
181
|
+
// `isSame` seems to mutate the date on `moment-jalaali`
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
return value.clone().isSame(comparing, 'jYear');
|
|
184
|
+
};
|
|
185
|
+
this.isSameMonth = (value, comparing) => {
|
|
186
|
+
// `isSame` seems to mutate the date on `moment-jalaali`
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
return value.clone().isSame(comparing, 'jMonth');
|
|
189
|
+
};
|
|
187
190
|
this.isAfterYear = (value, comparing) => {
|
|
188
191
|
return value.jYear() > comparing.jYear();
|
|
189
192
|
};
|
|
@@ -234,7 +237,7 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
234
237
|
};
|
|
235
238
|
this.getWeekdays = () => {
|
|
236
239
|
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek => {
|
|
237
|
-
return this.
|
|
240
|
+
return this.date().weekday(dayOfWeek).format('dd');
|
|
238
241
|
});
|
|
239
242
|
};
|
|
240
243
|
this.getWeekArray = value => {
|
|
@@ -267,7 +270,7 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
267
270
|
return years;
|
|
268
271
|
};
|
|
269
272
|
this.getMeridiemText = ampm => {
|
|
270
|
-
return ampm === 'am' ? this.
|
|
273
|
+
return ampm === 'am' ? this.date().hours(2).format('A') : this.date().hours(14).format('A');
|
|
271
274
|
};
|
|
272
275
|
this.moment = instance || defaultJMoment;
|
|
273
276
|
this.locale = 'fa';
|
|
@@ -14,7 +14,7 @@ import { MonthCalendar } from '../MonthCalendar';
|
|
|
14
14
|
import { YearCalendar } from '../YearCalendar';
|
|
15
15
|
import { useViews } from '../internals/hooks/useViews';
|
|
16
16
|
import { PickersCalendarHeader } from './PickersCalendarHeader';
|
|
17
|
-
import { findClosestEnabledDate, applyDefaultDate } from '../internals/utils/date-utils';
|
|
17
|
+
import { findClosestEnabledDate, applyDefaultDate, mergeDateAndTime } from '../internals/utils/date-utils';
|
|
18
18
|
import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
19
19
|
import { defaultReduceAnimations } from '../internals/utils/defaultReduceAnimations';
|
|
20
20
|
import { getDateCalendarUtilityClass } from './dateCalendarClasses';
|
|
@@ -209,7 +209,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
209
209
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
210
210
|
if (value && day) {
|
|
211
211
|
// If there is a date already selected, then we want to keep its time
|
|
212
|
-
return setValueAndGoToNextView(
|
|
212
|
+
return setValueAndGoToNextView(mergeDateAndTime(utils, day, value), 'finish');
|
|
213
213
|
}
|
|
214
214
|
return setValueAndGoToNextView(day, 'finish');
|
|
215
215
|
});
|
|
@@ -215,6 +215,7 @@ export function DayCalendar(inProps) {
|
|
|
215
215
|
});
|
|
216
216
|
const classes = useUtilityClasses(props);
|
|
217
217
|
const theme = useTheme();
|
|
218
|
+
const isRTL = theme.direction === 'rtl';
|
|
218
219
|
const {
|
|
219
220
|
onFocusedDayChange,
|
|
220
221
|
className,
|
|
@@ -289,13 +290,13 @@ export function DayCalendar(inProps) {
|
|
|
289
290
|
break;
|
|
290
291
|
case 'ArrowLeft':
|
|
291
292
|
{
|
|
292
|
-
const newFocusedDayDefault = utils.addDays(day,
|
|
293
|
-
const nextAvailableMonth =
|
|
293
|
+
const newFocusedDayDefault = utils.addDays(day, isRTL ? 1 : -1);
|
|
294
|
+
const nextAvailableMonth = utils.addMonths(day, isRTL ? 1 : -1);
|
|
294
295
|
const closestDayToFocus = findClosestEnabledDate({
|
|
295
296
|
utils,
|
|
296
297
|
date: newFocusedDayDefault,
|
|
297
|
-
minDate:
|
|
298
|
-
maxDate:
|
|
298
|
+
minDate: isRTL ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
|
|
299
|
+
maxDate: isRTL ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
299
300
|
isDateDisabled
|
|
300
301
|
});
|
|
301
302
|
focusDay(closestDayToFocus || newFocusedDayDefault);
|
|
@@ -304,13 +305,13 @@ export function DayCalendar(inProps) {
|
|
|
304
305
|
}
|
|
305
306
|
case 'ArrowRight':
|
|
306
307
|
{
|
|
307
|
-
const newFocusedDayDefault = utils.addDays(day,
|
|
308
|
-
const nextAvailableMonth =
|
|
308
|
+
const newFocusedDayDefault = utils.addDays(day, isRTL ? -1 : 1);
|
|
309
|
+
const nextAvailableMonth = utils.addMonths(day, isRTL ? -1 : 1);
|
|
309
310
|
const closestDayToFocus = findClosestEnabledDate({
|
|
310
311
|
utils,
|
|
311
312
|
date: newFocusedDayDefault,
|
|
312
|
-
minDate:
|
|
313
|
-
maxDate:
|
|
313
|
+
minDate: isRTL ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
314
|
+
maxDate: isRTL ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
|
|
314
315
|
isDateDisabled
|
|
315
316
|
});
|
|
316
317
|
focusDay(closestDayToFocus || newFocusedDayDefault);
|
|
@@ -326,11 +327,11 @@ export function DayCalendar(inProps) {
|
|
|
326
327
|
event.preventDefault();
|
|
327
328
|
break;
|
|
328
329
|
case 'PageUp':
|
|
329
|
-
focusDay(utils.
|
|
330
|
+
focusDay(utils.addMonths(day, 1));
|
|
330
331
|
event.preventDefault();
|
|
331
332
|
break;
|
|
332
333
|
case 'PageDown':
|
|
333
|
-
focusDay(utils.
|
|
334
|
+
focusDay(utils.addMonths(day, -1));
|
|
334
335
|
event.preventDefault();
|
|
335
336
|
break;
|
|
336
337
|
default:
|
|
@@ -140,8 +140,8 @@ export function PickersCalendarHeader(inProps) {
|
|
|
140
140
|
className: classes.switchViewIcon
|
|
141
141
|
}),
|
|
142
142
|
switchViewIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded);
|
|
143
|
-
const selectNextMonth = () => onMonthChange(utils.
|
|
144
|
-
const selectPreviousMonth = () => onMonthChange(utils.
|
|
143
|
+
const selectNextMonth = () => onMonthChange(utils.addMonths(month, 1), 'left');
|
|
144
|
+
const selectPreviousMonth = () => onMonthChange(utils.addMonths(month, -1), 'right');
|
|
145
145
|
const isNextMonthDisabled = useNextMonthDisabled(month, {
|
|
146
146
|
disableFuture,
|
|
147
147
|
maxDate
|
|
@@ -204,6 +204,10 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
204
204
|
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
205
205
|
*/
|
|
206
206
|
onChange: PropTypes.func,
|
|
207
|
+
/**
|
|
208
|
+
* @ignore
|
|
209
|
+
*/
|
|
210
|
+
onClick: PropTypes.func,
|
|
207
211
|
/**
|
|
208
212
|
* Callback fired when the error associated to the current value changes.
|
|
209
213
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -237,6 +237,10 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
237
237
|
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
238
238
|
*/
|
|
239
239
|
onChange: PropTypes.func,
|
|
240
|
+
/**
|
|
241
|
+
* @ignore
|
|
242
|
+
*/
|
|
243
|
+
onClick: PropTypes.func,
|
|
240
244
|
/**
|
|
241
245
|
* Callback fired when the error associated to the current value changes.
|
|
242
246
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -31,7 +31,9 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
31
31
|
}, defaultizedProps.viewRenderers);
|
|
32
32
|
const ampmInClock = defaultizedProps.ampmInClock ?? true;
|
|
33
33
|
const actionBarActions = shouldRenderTimeInASingleColumn ? [] : ['accept'];
|
|
34
|
-
|
|
34
|
+
// Need to avoid adding the `meridiem` view when unexpected renderer is specified
|
|
35
|
+
const shouldHoursRendererContainMeridiemView = viewRenderers.hours?.name === renderMultiSectionDigitalClockTimeView.name;
|
|
36
|
+
const views = defaultizedProps.ampm && shouldHoursRendererContainMeridiemView ? [...defaultizedProps.views, 'meridiem'] : defaultizedProps.views;
|
|
35
37
|
|
|
36
38
|
// Props with the default values specific to the desktop variant
|
|
37
39
|
const props = _extends({}, defaultizedProps, {
|
|
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
12
12
|
/**
|
|
13
13
|
* @ignore - do not document.
|
|
14
14
|
*/
|
|
15
|
-
export function LocalizationProvider(inProps) {
|
|
15
|
+
export const LocalizationProvider = function LocalizationProvider(inProps) {
|
|
16
16
|
const {
|
|
17
17
|
localeText: inLocaleText
|
|
18
18
|
} = inProps,
|
|
@@ -76,7 +76,7 @@ export function LocalizationProvider(inProps) {
|
|
|
76
76
|
value: contextValue,
|
|
77
77
|
children: children
|
|
78
78
|
});
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
|
|
81
81
|
// ----------------------------- Warning --------------------------------
|
|
82
82
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -85,7 +85,7 @@ process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
|
|
|
85
85
|
/**
|
|
86
86
|
* Locale for the date library you are using
|
|
87
87
|
*/
|
|
88
|
-
adapterLocale: PropTypes.
|
|
88
|
+
adapterLocale: PropTypes.any,
|
|
89
89
|
children: PropTypes.node,
|
|
90
90
|
/**
|
|
91
91
|
* Date library adapter class function.
|
|
@@ -10,7 +10,7 @@ import { unstable_useControlled as useControlled, unstable_composeClasses as com
|
|
|
10
10
|
import { PickersMonth } from './PickersMonth';
|
|
11
11
|
import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
|
|
12
12
|
import { getMonthCalendarUtilityClass } from './monthCalendarClasses';
|
|
13
|
-
import { applyDefaultDate } from '../internals/utils/date-utils';
|
|
13
|
+
import { applyDefaultDate, getMonthsInYear } from '../internals/utils/date-utils';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const useUtilityClasses = ownerState => {
|
|
16
16
|
const {
|
|
@@ -175,7 +175,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
175
175
|
className: clsx(classes.root, className),
|
|
176
176
|
ownerState: ownerState
|
|
177
177
|
}, other, {
|
|
178
|
-
children: utils
|
|
178
|
+
children: getMonthsInYear(utils, selectedDateOrStartOfMonth).map(month => {
|
|
179
179
|
const monthNumber = utils.getMonth(month);
|
|
180
180
|
const monthText = utils.format(month, 'monthShort');
|
|
181
181
|
const isSelected = monthNumber === selectedMonth;
|
|
@@ -221,6 +221,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
221
221
|
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
222
222
|
*/
|
|
223
223
|
onChange: PropTypes.func,
|
|
224
|
+
/**
|
|
225
|
+
* @ignore
|
|
226
|
+
*/
|
|
227
|
+
onClick: PropTypes.func,
|
|
224
228
|
/**
|
|
225
229
|
* Callback fired when the error associated to the current value changes.
|
|
226
230
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { getMonthsInYear } from '../../utils/date-utils';
|
|
2
3
|
export const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
3
4
|
const config = utils.formatTokenMap[formatToken];
|
|
4
5
|
if (config == null) {
|
|
@@ -47,7 +48,7 @@ export const getLetterEditingOptions = (utils, sectionType, format) => {
|
|
|
47
48
|
switch (sectionType) {
|
|
48
49
|
case 'month':
|
|
49
50
|
{
|
|
50
|
-
return
|
|
51
|
+
return getMonthsInYear(utils, utils.date()).map(month => utils.formatByString(month, format));
|
|
51
52
|
}
|
|
52
53
|
case 'weekDay':
|
|
53
54
|
{
|
|
@@ -312,7 +313,7 @@ const getEscapedPartsFromFormat = (utils, format) => {
|
|
|
312
313
|
}
|
|
313
314
|
return escapedParts;
|
|
314
315
|
};
|
|
315
|
-
export const splitFormatIntoSections = (utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros) => {
|
|
316
|
+
export const splitFormatIntoSections = (utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
316
317
|
let startSeparator = '';
|
|
317
318
|
const sections = [];
|
|
318
319
|
const now = utils.date();
|
|
@@ -400,7 +401,7 @@ export const splitFormatIntoSections = (utils, localeText, format, date, formatD
|
|
|
400
401
|
return sections.map(section => {
|
|
401
402
|
const cleanSeparator = separator => {
|
|
402
403
|
let cleanedSeparator = separator;
|
|
403
|
-
if (cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
404
|
+
if (isRTL && cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
404
405
|
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
|
|
405
406
|
}
|
|
406
407
|
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
|
@@ -460,7 +461,7 @@ export const getSectionsBoundaries = utils => {
|
|
|
460
461
|
const {
|
|
461
462
|
maxDaysInMonth,
|
|
462
463
|
longestMonth
|
|
463
|
-
} = utils
|
|
464
|
+
} = getMonthsInYear(utils, today).reduce((acc, month) => {
|
|
464
465
|
const daysInMonth = utils.getDaysInMonth(month);
|
|
465
466
|
if (daysInMonth > acc.maxDaysInMonth) {
|
|
466
467
|
return {
|
|
@@ -30,7 +30,7 @@ export const useFieldState = params => {
|
|
|
30
30
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
31
31
|
const valueFromTheOutside = valueProp ?? firstDefaultValue.current ?? valueManager.emptyValue;
|
|
32
32
|
const sectionsValueBoundaries = React.useMemo(() => getSectionsBoundaries(utils), [utils]);
|
|
33
|
-
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros)), [fieldValueManager, format, localeText, isRTL, shouldRespectLeadingZeros, utils, formatDensity]);
|
|
33
|
+
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL)), [fieldValueManager, format, localeText, isRTL, shouldRespectLeadingZeros, utils, formatDensity]);
|
|
34
34
|
const placeholder = React.useMemo(() => fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL), [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
35
35
|
const [state, setState] = React.useState(() => {
|
|
36
36
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
@@ -154,7 +154,7 @@ export const useFieldState = params => {
|
|
|
154
154
|
if (date == null || !utils.isValid(date)) {
|
|
155
155
|
return null;
|
|
156
156
|
}
|
|
157
|
-
const sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros);
|
|
157
|
+
const sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL);
|
|
158
158
|
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
|
|
159
159
|
};
|
|
160
160
|
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -69,4 +69,20 @@ export const areDatesEqual = (utils, a, b) => {
|
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
71
|
return utils.isEqual(a, b);
|
|
72
|
+
};
|
|
73
|
+
export const getMonthsInYear = (utils, year) => {
|
|
74
|
+
const firstMonth = utils.startOfYear(year);
|
|
75
|
+
const months = [firstMonth];
|
|
76
|
+
while (months.length < 12) {
|
|
77
|
+
const prevMonth = months[months.length - 1];
|
|
78
|
+
months.push(utils.addMonths(prevMonth, 1));
|
|
79
|
+
}
|
|
80
|
+
return months;
|
|
81
|
+
};
|
|
82
|
+
export const mergeDateAndTime = (utils, dateParam, timeParam) => {
|
|
83
|
+
let mergedDate = dateParam;
|
|
84
|
+
mergedDate = utils.setHours(mergedDate, utils.getHours(timeParam));
|
|
85
|
+
mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
|
|
86
|
+
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
|
|
87
|
+
return mergedDate;
|
|
72
88
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minDate', 'maxDate', 'minTime', 'maxTime', 'minDateTime', 'maxDateTime', 'shouldDisableDate', 'shouldDisableMonth', 'shouldDisableYear', 'shouldDisableClock', 'shouldDisableTime', '
|
|
1
|
+
const VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minDate', 'maxDate', 'minTime', 'maxTime', 'minDateTime', 'maxDateTime', 'shouldDisableDate', 'shouldDisableMonth', 'shouldDisableYear', 'shouldDisableClock', 'shouldDisableTime', 'minutesStep'];
|
|
2
2
|
/**
|
|
3
3
|
* Extract the validation props for the props received by a component.
|
|
4
4
|
* Limit the risk of forgetting some of them and reduce the bundle size.
|