@mui/x-date-pickers 6.3.1 → 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.
Files changed (169) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +3 -7
  2. package/AdapterDateFns/AdapterDateFns.js +2 -8
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +3 -7
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  5. package/AdapterDayjs/AdapterDayjs.d.ts +3 -9
  6. package/AdapterDayjs/AdapterDayjs.js +2 -3
  7. package/AdapterLuxon/AdapterLuxon.d.ts +3 -8
  8. package/AdapterLuxon/AdapterLuxon.js +6 -5
  9. package/AdapterMoment/AdapterMoment.d.ts +3 -9
  10. package/AdapterMoment/AdapterMoment.js +2 -2
  11. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +5 -14
  12. package/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  13. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +6 -16
  14. package/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  15. package/CHANGELOG.md +57 -0
  16. package/DateCalendar/DateCalendar.js +2 -2
  17. package/DateCalendar/DayCalendar.js +11 -10
  18. package/DateCalendar/PickersCalendarHeader.js +2 -2
  19. package/DateCalendar/useCalendarState.d.ts +1 -1
  20. package/DatePicker/shared.d.ts +1 -1
  21. package/LocalizationProvider/LocalizationProvider.d.ts +10 -8
  22. package/LocalizationProvider/LocalizationProvider.js +3 -3
  23. package/MonthCalendar/MonthCalendar.js +2 -2
  24. package/index.js +1 -1
  25. package/internals/hooks/useField/useField.utils.d.ts +13 -13
  26. package/internals/hooks/useField/useField.utils.js +3 -2
  27. package/internals/hooks/useUtils.d.ts +1 -1
  28. package/internals/utils/date-utils.d.ts +6 -4
  29. package/internals/utils/date-utils.js +16 -0
  30. package/internals/utils/time-utils.d.ts +4 -4
  31. package/internals/utils/validation/extractValidationProps.d.ts +1 -1
  32. package/legacy/AdapterDateFns/AdapterDateFns.js +2 -8
  33. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  34. package/legacy/AdapterDayjs/AdapterDayjs.js +2 -3
  35. package/legacy/AdapterLuxon/AdapterLuxon.js +6 -5
  36. package/legacy/AdapterMoment/AdapterMoment.js +2 -2
  37. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  38. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  39. package/legacy/DateCalendar/DateCalendar.js +2 -2
  40. package/legacy/DateCalendar/DayCalendar.js +11 -10
  41. package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
  42. package/legacy/LocalizationProvider/LocalizationProvider.js +3 -3
  43. package/legacy/MonthCalendar/MonthCalendar.js +2 -2
  44. package/legacy/index.js +1 -1
  45. package/legacy/internals/hooks/useField/useField.utils.js +5 -4
  46. package/legacy/internals/utils/date-utils.js +16 -0
  47. package/legacy/locales/csCZ.js +3 -3
  48. package/legacy/locales/index.js +1 -0
  49. package/legacy/locales/skSK.js +93 -0
  50. package/legacy/locales/ukUA.js +3 -1
  51. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  52. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  53. package/legacy/tests/describeGregorianAdapter/index.js +2 -1
  54. package/legacy/tests/describeGregorianAdapter/testCalculations.js +272 -200
  55. package/legacy/tests/describeGregorianAdapter/testLocalization.js +34 -0
  56. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  57. package/legacy/tests/describeHijriAdapter/testCalculations.js +101 -28
  58. package/legacy/tests/describeHijriAdapter/testLocalization.js +8 -0
  59. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  60. package/legacy/tests/describeJalaliAdapter/testCalculations.js +157 -24
  61. package/legacy/tests/describeJalaliAdapter/testLocalization.js +8 -0
  62. package/locales/beBY.d.ts +3 -3
  63. package/locales/caES.d.ts +3 -3
  64. package/locales/csCZ.d.ts +3 -3
  65. package/locales/csCZ.js +3 -3
  66. package/locales/daDK.d.ts +3 -3
  67. package/locales/deDE.d.ts +3 -3
  68. package/locales/enUS.d.ts +3 -3
  69. package/locales/esES.d.ts +3 -3
  70. package/locales/faIR.d.ts +3 -3
  71. package/locales/fiFI.d.ts +3 -3
  72. package/locales/frFR.d.ts +3 -3
  73. package/locales/heIL.d.ts +3 -3
  74. package/locales/huHU.d.ts +3 -3
  75. package/locales/index.d.ts +1 -0
  76. package/locales/index.js +1 -0
  77. package/locales/isIS.d.ts +3 -3
  78. package/locales/itIT.d.ts +3 -3
  79. package/locales/jaJP.d.ts +3 -3
  80. package/locales/koKR.d.ts +3 -3
  81. package/locales/kzKZ.d.ts +3 -3
  82. package/locales/nbNO.d.ts +3 -3
  83. package/locales/nlNL.d.ts +3 -3
  84. package/locales/plPL.d.ts +3 -3
  85. package/locales/ptBR.d.ts +3 -3
  86. package/locales/ruRU.d.ts +3 -3
  87. package/locales/skSK.d.ts +53 -0
  88. package/locales/skSK.js +61 -0
  89. package/locales/svSE.d.ts +3 -3
  90. package/locales/trTR.d.ts +3 -3
  91. package/locales/ukUA.d.ts +3 -3
  92. package/locales/ukUA.js +1 -1
  93. package/locales/urPK.d.ts +3 -3
  94. package/locales/utils/getPickersLocalization.d.ts +3 -3
  95. package/locales/zhCN.d.ts +3 -3
  96. package/models/adapters.d.ts +43 -35
  97. package/modern/AdapterDateFns/AdapterDateFns.js +2 -8
  98. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  99. package/modern/AdapterDayjs/AdapterDayjs.js +2 -2
  100. package/modern/AdapterLuxon/AdapterLuxon.js +6 -5
  101. package/modern/AdapterMoment/AdapterMoment.js +2 -2
  102. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  103. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  104. package/modern/DateCalendar/DateCalendar.js +2 -2
  105. package/modern/DateCalendar/DayCalendar.js +11 -10
  106. package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
  107. package/modern/LocalizationProvider/LocalizationProvider.js +3 -3
  108. package/modern/MonthCalendar/MonthCalendar.js +2 -2
  109. package/modern/index.js +1 -1
  110. package/modern/internals/hooks/useField/useField.utils.js +3 -2
  111. package/modern/internals/utils/date-utils.js +16 -0
  112. package/modern/locales/csCZ.js +3 -3
  113. package/modern/locales/index.js +1 -0
  114. package/modern/locales/skSK.js +58 -0
  115. package/modern/locales/ukUA.js +1 -1
  116. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  117. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  118. package/modern/tests/describeGregorianAdapter/index.js +2 -1
  119. package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -198
  120. package/modern/tests/describeGregorianAdapter/testLocalization.js +34 -0
  121. package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  122. package/modern/tests/describeHijriAdapter/testCalculations.js +101 -28
  123. package/modern/tests/describeHijriAdapter/testLocalization.js +8 -0
  124. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  125. package/modern/tests/describeJalaliAdapter/testCalculations.js +157 -24
  126. package/modern/tests/describeJalaliAdapter/testLocalization.js +8 -0
  127. package/node/AdapterDateFns/AdapterDateFns.js +2 -8
  128. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  129. package/node/AdapterDayjs/AdapterDayjs.js +2 -2
  130. package/node/AdapterLuxon/AdapterLuxon.js +6 -5
  131. package/node/AdapterMoment/AdapterMoment.js +2 -2
  132. package/node/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  133. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  134. package/node/DateCalendar/DateCalendar.js +1 -1
  135. package/node/DateCalendar/DayCalendar.js +11 -10
  136. package/node/DateCalendar/PickersCalendarHeader.js +2 -2
  137. package/node/LocalizationProvider/LocalizationProvider.js +5 -5
  138. package/node/MonthCalendar/MonthCalendar.js +1 -1
  139. package/node/index.js +1 -1
  140. package/node/internals/hooks/useField/useField.utils.js +3 -2
  141. package/node/internals/utils/date-utils.js +20 -2
  142. package/node/locales/csCZ.js +3 -3
  143. package/node/locales/index.js +11 -0
  144. package/node/locales/skSK.js +65 -0
  145. package/node/locales/ukUA.js +1 -1
  146. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -9
  147. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +10 -0
  148. package/node/tests/describeGregorianAdapter/index.js +4 -3
  149. package/node/tests/describeGregorianAdapter/testCalculations.js +272 -198
  150. package/node/tests/describeGregorianAdapter/testLocalization.js +35 -0
  151. package/node/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  152. package/node/tests/describeHijriAdapter/testCalculations.js +100 -27
  153. package/node/tests/describeHijriAdapter/testLocalization.js +8 -0
  154. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  155. package/node/tests/describeJalaliAdapter/testCalculations.js +156 -23
  156. package/node/tests/describeJalaliAdapter/testLocalization.js +8 -0
  157. package/package.json +1 -1
  158. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  159. package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  160. package/tests/describeGregorianAdapter/index.js +2 -1
  161. package/tests/describeGregorianAdapter/testCalculations.js +272 -198
  162. package/tests/describeGregorianAdapter/testLocalization.js +34 -0
  163. package/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  164. package/tests/describeHijriAdapter/testCalculations.js +101 -28
  165. package/tests/describeHijriAdapter/testLocalization.js +8 -0
  166. package/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  167. package/tests/describeJalaliAdapter/testCalculations.js +157 -24
  168. package/tests/describeJalaliAdapter/testLocalization.js +8 -0
  169. package/themeAugmentation/props.d.ts +1 -1
@@ -1,59 +1,59 @@
1
1
  import { FieldSectionContentType, FieldSectionType } from './fields';
2
- export interface AdapterFormats<TLibFormatToken = string> {
2
+ export interface AdapterFormats {
3
3
  /** Localized full date @example "Jan 1, 2019" */
4
- fullDate: TLibFormatToken;
4
+ fullDate: string;
5
5
  /** Partially localized full date with weekday, useful for text-to-speech accessibility @example "Tuesday, January 1, 2019" */
6
- fullDateWithWeekday: TLibFormatToken;
6
+ fullDateWithWeekday: string;
7
7
  /** Date format string with month and day of month @example "1 January" */
8
- normalDate: TLibFormatToken;
8
+ normalDate: string;
9
9
  /** Date format string with weekday, month and day of month @example "Wed, Jan 1" */
10
- normalDateWithWeekday: TLibFormatToken;
10
+ normalDateWithWeekday: string;
11
11
  /** Shorter day format @example "Jan 1" */
12
- shortDate: TLibFormatToken;
12
+ shortDate: string;
13
13
  /** Year format string @example "2019" */
14
- year: TLibFormatToken;
14
+ year: string;
15
15
  /** Month format string @example "January" */
16
- month: TLibFormatToken;
16
+ month: string;
17
17
  /** Short month format string @example "Jan" */
18
- monthShort: TLibFormatToken;
18
+ monthShort: string;
19
19
  /** Month with year format string @example "January 2018" */
20
- monthAndYear: TLibFormatToken;
20
+ monthAndYear: string;
21
21
  /** Month with date format string @example "January 1" */
22
- monthAndDate: TLibFormatToken;
22
+ monthAndDate: string;
23
23
  /** Weekday format string @example "Wednesday" */
24
- weekday: TLibFormatToken;
24
+ weekday: string;
25
25
  /** Short weekday format string @example "Wed" */
26
- weekdayShort: TLibFormatToken;
26
+ weekdayShort: string;
27
27
  /** Day format string @example "1" */
28
- dayOfMonth: TLibFormatToken;
28
+ dayOfMonth: string;
29
29
  /** Hours format string @example "11" */
30
- hours12h: TLibFormatToken;
30
+ hours12h: string;
31
31
  /** Hours format string @example "23" */
32
- hours24h: TLibFormatToken;
32
+ hours24h: string;
33
33
  /** Minutes format string @example "44" */
34
- minutes: TLibFormatToken;
34
+ minutes: string;
35
35
  /** Seconds format string @example "00" */
36
- seconds: TLibFormatToken;
36
+ seconds: string;
37
37
  /** Full time localized format string @example "11:44 PM" for US, "23:44" for Europe */
38
- fullTime: TLibFormatToken;
38
+ fullTime: string;
39
39
  /** Not localized full time format string @example "11:44 PM" */
40
- fullTime12h: TLibFormatToken;
40
+ fullTime12h: string;
41
41
  /** Not localized full time format string @example "23:44" */
42
- fullTime24h: TLibFormatToken;
42
+ fullTime24h: string;
43
43
  /** Date & time format string with localized time @example "Jan 1, 2018 11:44 PM" */
44
- fullDateTime: TLibFormatToken;
44
+ fullDateTime: string;
45
45
  /** Not localized date & Time format 12h @example "Jan 1, 2018 11:44 PM" */
46
- fullDateTime12h: TLibFormatToken;
46
+ fullDateTime12h: string;
47
47
  /** Not localized date & Time format 24h @example "Jan 1, 2018 23:44" */
48
- fullDateTime24h: TLibFormatToken;
48
+ fullDateTime24h: string;
49
49
  /** Localized keyboard input friendly date format @example "02/13/2020 */
50
- keyboardDate: TLibFormatToken;
50
+ keyboardDate: string;
51
51
  /** Localized keyboard input friendly date/time format @example "02/13/2020 23:44" */
52
- keyboardDateTime: TLibFormatToken;
52
+ keyboardDateTime: string;
53
53
  /** Partially localized keyboard input friendly date/time 12h format @example "02/13/2020 11:44 PM" */
54
- keyboardDateTime12h: TLibFormatToken;
54
+ keyboardDateTime12h: string;
55
55
  /** Partially localized keyboard input friendly date/time 24h format @example "02/13/2020 23:44" */
56
- keyboardDateTime24h: TLibFormatToken;
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
- export interface MuiPickersAdapter<TDate> {
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<any>;
72
- locale?: any;
73
- moment?: any;
74
- dayjs?: any;
75
- /** Name of the library that is used right now */
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
- const day = getDay(current);
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
- const day = getDay(current);
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 = this.rawDayJsInstance.Ls ?? defaultDayjs.Ls;
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.getNextMonth(prevMonth));
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: 'year',
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.getNextMonth(prevMonth));
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 = value.clone().startOf('year');
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 this.moment.localeData(this.getCurrentLocaleCode()).meridiem(ampm === 'am' ? 0 : 13, 0, false);
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.isMUIAdapter = true;
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.toIMoment().weekday(dayOfWeek).format('dd');
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.toIMoment().hours(2).format('A') : this.toIMoment().hours(14).format('A');
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.toJMoment().weekday(dayOfWeek).format('dd');
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.toJMoment().hours(2).format('A') : this.toJMoment().hours(14).format('A');
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(utils.mergeDateAndTime(day, value), 'finish');
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, theme.direction === 'ltr' ? -1 : 1);
293
- const nextAvailableMonth = theme.direction === 'ltr' ? utils.getPreviousMonth(day) : utils.getNextMonth(day);
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: theme.direction === 'ltr' ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
298
- maxDate: theme.direction === 'ltr' ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
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, theme.direction === 'ltr' ? 1 : -1);
308
- const nextAvailableMonth = theme.direction === 'ltr' ? utils.getNextMonth(day) : utils.getPreviousMonth(day);
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: theme.direction === 'ltr' ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
313
- maxDate: theme.direction === 'ltr' ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
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.getNextMonth(day));
330
+ focusDay(utils.addMonths(day, 1));
330
331
  event.preventDefault();
331
332
  break;
332
333
  case 'PageDown':
333
- focusDay(utils.getPreviousMonth(day));
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.getNextMonth(month), 'left');
144
- const selectPreviousMonth = () => onMonthChange(utils.getPreviousMonth(month), 'right');
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
@@ -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.oneOfType([PropTypes.object, PropTypes.string]),
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.getMonthArray(selectedDateOrStartOfMonth).map(month => {
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;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.3.1
2
+ * @mui/x-date-pickers v6.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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 utils.getMonthArray(utils.date()).map(month => utils.formatByString(month, format));
51
+ return getMonthsInYear(utils, utils.date()).map(month => utils.formatByString(month, format));
51
52
  }
52
53
  case 'weekDay':
53
54
  {
@@ -460,7 +461,7 @@ export const getSectionsBoundaries = utils => {
460
461
  const {
461
462
  maxDaysInMonth,
462
463
  longestMonth
463
- } = utils.getMonthArray(today).reduce((acc, month) => {
464
+ } = getMonthsInYear(utils, today).reduce((acc, month) => {
464
465
  const daysInMonth = utils.getDaysInMonth(month);
465
466
  if (daysInMonth > acc.maxDaysInMonth) {
466
467
  return {
@@ -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
  };
@@ -9,7 +9,7 @@ const timeViews = {
9
9
  const csCZPickers = {
10
10
  // Calendar navigation
11
11
  previousMonth: 'Další měsíc',
12
- nextMonth: 'Předchozí month',
12
+ nextMonth: 'Předchozí měsíc',
13
13
  // View navigation
14
14
  openPreviousView: 'otevřít předchozí zobrazení',
15
15
  openNextView: 'otevřít další zobrazení',
@@ -40,8 +40,8 @@ const csCZPickers = {
40
40
  calendarWeekNumberAriaLabelText: weekNumber => `${weekNumber} týden v roce`,
41
41
  calendarWeekNumberText: weekNumber => `${weekNumber}`,
42
42
  // Open picker labels
43
- openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vybrané datum, vybrané datum je ${utils.format(value, 'fullDate')}` : 'Vyberte datum',
44
- openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vybrané čas, vybraný čas je ${utils.format(value, 'fullTime')}` : 'Vyberte čas',
43
+ openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vyberte datum, vybrané datum je ${utils.format(value, 'fullDate')}` : 'Vyberte datum',
44
+ openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vyberte čas, vybraný čas je ${utils.format(value, 'fullTime')}` : 'Vyberte čas',
45
45
  // Table labels
46
46
  timeTableLabel: 'vyberte čas',
47
47
  dateTableLabel: 'vyberte datum',
@@ -24,4 +24,5 @@ export * from './urPK';
24
24
  export * from './beBY';
25
25
  export * from './ruRU';
26
26
  export * from './heIL';
27
+ export * from './skSK';
27
28
  export * from './utils/pickersLocaleTextApi';
@@ -0,0 +1,58 @@
1
+ import { getPickersLocalization } from './utils/getPickersLocalization';
2
+ // maps TimeView to its translation
3
+ const timeViews = {
4
+ hours: 'Hodiny',
5
+ minutes: 'Minúty',
6
+ seconds: 'Sekundy',
7
+ meridiem: 'Popoludnie'
8
+ };
9
+ const skSKPickers = {
10
+ // Calendar navigation
11
+ previousMonth: 'Ďalší mesiac',
12
+ nextMonth: 'Predchádzajúci mesiac',
13
+ // View navigation
14
+ openPreviousView: 'otvoriť predchádzajúce zobrazenie',
15
+ openNextView: 'otvoriť ďalšie zobrazenie',
16
+ calendarViewSwitchingButtonAriaLabel: view => view === 'year' ? 'ročné zobrazenie otvorené, prepnite do zobrazenia kalendára' : 'zobrazenie kalendára otvorené, prepnite do zobrazenia roka',
17
+ // DateRange placeholders
18
+ start: 'Začiatok',
19
+ end: 'Koniec',
20
+ // Action bar
21
+ cancelButtonLabel: 'Zrušiť',
22
+ clearButtonLabel: 'Vymazať',
23
+ okButtonLabel: 'Potvrdiť',
24
+ todayButtonLabel: 'Dnes',
25
+ // Toolbar titles
26
+ datePickerToolbarTitle: 'Vyberte dátum',
27
+ dateTimePickerToolbarTitle: 'Vyberte dátum a čas',
28
+ timePickerToolbarTitle: 'Vyberte čas',
29
+ dateRangePickerToolbarTitle: 'Vyberete rozmedzie dátumov',
30
+ // Clock labels
31
+ clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} vybraný. ${time === null ? 'Nie je vybraný čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`,
32
+ hoursClockNumberText: hours => `${hours} hodín`,
33
+ minutesClockNumberText: minutes => `${minutes} minút`,
34
+ secondsClockNumberText: seconds => `${seconds} sekúnd`,
35
+ // Digital clock labels
36
+ selectViewText: view => `Vyberte ${timeViews[view]}`,
37
+ // Calendar labels
38
+ calendarWeekNumberHeaderLabel: 'Týždeň v roku',
39
+ calendarWeekNumberHeaderText: '#',
40
+ calendarWeekNumberAriaLabelText: weekNumber => `${weekNumber} týždeň v roku`,
41
+ calendarWeekNumberText: weekNumber => `${weekNumber}`,
42
+ // Open picker labels
43
+ openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vyberte dátum, vybraný dátum je ${utils.format(value, 'fullDate')}` : 'Vyberte dátum',
44
+ openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Vyberte čas, vybraný čas je ${utils.format(value, 'fullTime')}` : 'Vyberte čas',
45
+ // Table labels
46
+ timeTableLabel: 'vyberte čas',
47
+ dateTableLabel: 'vyberte dátum',
48
+ // Field section placeholders
49
+ fieldYearPlaceholder: params => 'Y'.repeat(params.digitAmount),
50
+ fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
51
+ fieldDayPlaceholder: () => 'DD',
52
+ // fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
53
+ fieldHoursPlaceholder: () => 'hh',
54
+ fieldMinutesPlaceholder: () => 'mm',
55
+ fieldSecondsPlaceholder: () => 'ss',
56
+ fieldMeridiemPlaceholder: () => 'aa'
57
+ };
58
+ export const skSK = getPickersLocalization(skSKPickers);
@@ -48,7 +48,7 @@ const ukUAPickers = {
48
48
  fieldYearPlaceholder: params => 'Y'.repeat(params.digitAmount),
49
49
  fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
50
50
  fieldDayPlaceholder: () => 'DD',
51
- // fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
51
+ fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
52
52
  fieldHoursPlaceholder: () => 'hh',
53
53
  fieldMinutesPlaceholder: () => 'mm',
54
54
  fieldSecondsPlaceholder: () => 'ss',