@mui/x-date-pickers 7.3.1 → 7.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 (73) hide show
  1. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +3 -0
  2. package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +104 -0
  3. package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +545 -0
  4. package/AdapterDateFnsJalaliV3/index.d.ts +1 -0
  5. package/AdapterDateFnsJalaliV3/index.js +1 -0
  6. package/AdapterDateFnsJalaliV3/package.json +6 -0
  7. package/CHANGELOG.md +141 -5
  8. package/DatePicker/DatePicker.js +1 -1
  9. package/DatePicker/shared.d.ts +1 -1
  10. package/DateTimePicker/DateTimePicker.js +1 -1
  11. package/DateTimePicker/shared.d.ts +1 -1
  12. package/DesktopDatePicker/DesktopDatePicker.js +1 -1
  13. package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
  14. package/DesktopTimePicker/DesktopTimePicker.js +1 -1
  15. package/MobileDatePicker/MobileDatePicker.js +1 -1
  16. package/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
  17. package/MobileTimePicker/MobileTimePicker.js +1 -1
  18. package/PickersShortcuts/PickersShortcuts.d.ts +5 -0
  19. package/PickersShortcuts/PickersShortcuts.js +4 -3
  20. package/StaticDatePicker/StaticDatePicker.js +1 -1
  21. package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  22. package/StaticTimePicker/StaticTimePicker.js +1 -1
  23. package/TimePicker/TimePicker.js +1 -1
  24. package/TimePicker/shared.d.ts +1 -1
  25. package/index.js +1 -1
  26. package/internals/hooks/useField/useField.js +0 -5
  27. package/internals/hooks/useField/useFieldV7TextField.js +5 -0
  28. package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
  29. package/locales/heIL.js +14 -17
  30. package/locales/huHU.js +15 -18
  31. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +3 -0
  32. package/modern/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +545 -0
  33. package/modern/AdapterDateFnsJalaliV3/index.js +1 -0
  34. package/modern/DatePicker/DatePicker.js +1 -1
  35. package/modern/DateTimePicker/DateTimePicker.js +1 -1
  36. package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
  37. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
  38. package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -1
  39. package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
  40. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
  41. package/modern/MobileTimePicker/MobileTimePicker.js +1 -1
  42. package/modern/PickersShortcuts/PickersShortcuts.js +4 -3
  43. package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
  44. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  45. package/modern/StaticTimePicker/StaticTimePicker.js +1 -1
  46. package/modern/TimePicker/TimePicker.js +1 -1
  47. package/modern/index.js +1 -1
  48. package/modern/internals/hooks/useField/useField.js +0 -5
  49. package/modern/internals/hooks/useField/useFieldV7TextField.js +5 -0
  50. package/modern/locales/heIL.js +14 -17
  51. package/modern/locales/huHU.js +15 -18
  52. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +3 -0
  53. package/node/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +554 -0
  54. package/node/AdapterDateFnsJalaliV3/index.js +12 -0
  55. package/node/DatePicker/DatePicker.js +1 -1
  56. package/node/DateTimePicker/DateTimePicker.js +1 -1
  57. package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
  58. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
  59. package/node/DesktopTimePicker/DesktopTimePicker.js +1 -1
  60. package/node/MobileDatePicker/MobileDatePicker.js +1 -1
  61. package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
  62. package/node/MobileTimePicker/MobileTimePicker.js +1 -1
  63. package/node/PickersShortcuts/PickersShortcuts.js +4 -3
  64. package/node/StaticDatePicker/StaticDatePicker.js +1 -1
  65. package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  66. package/node/StaticTimePicker/StaticTimePicker.js +1 -1
  67. package/node/TimePicker/TimePicker.js +1 -1
  68. package/node/index.js +1 -1
  69. package/node/internals/hooks/useField/useField.js +0 -5
  70. package/node/internals/hooks/useField/useFieldV7TextField.js +5 -0
  71. package/node/locales/heIL.js +14 -17
  72. package/node/locales/huHU.js +15 -18
  73. package/package.json +3 -3
@@ -0,0 +1,545 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ /* eslint-disable class-methods-use-this */
3
+ // TODO remove when date-fns-jalali-v3 is the default
4
+ // @ts-nocheck
5
+ import { addSeconds } from 'date-fns-jalali/addSeconds';
6
+ import { addMinutes } from 'date-fns-jalali/addMinutes';
7
+ import { addHours } from 'date-fns-jalali/addHours';
8
+ import { addDays } from 'date-fns-jalali/addDays';
9
+ import { addWeeks } from 'date-fns-jalali/addWeeks';
10
+ import { addMonths } from 'date-fns-jalali/addMonths';
11
+ import { addYears } from 'date-fns-jalali/addYears';
12
+ import { endOfDay } from 'date-fns-jalali/endOfDay';
13
+ import { endOfWeek } from 'date-fns-jalali/endOfWeek';
14
+ import { endOfYear } from 'date-fns-jalali/endOfYear';
15
+ import { format as dateFnsFormat, longFormatters } from 'date-fns-jalali/format';
16
+ import { getHours } from 'date-fns-jalali/getHours';
17
+ import { getSeconds } from 'date-fns-jalali/getSeconds';
18
+ import { getMilliseconds } from 'date-fns-jalali/getMilliseconds';
19
+ import { getWeek } from 'date-fns-jalali/getWeek';
20
+ import { getYear } from 'date-fns-jalali/getYear';
21
+ import { getMonth } from 'date-fns-jalali/getMonth';
22
+ import { getDate } from 'date-fns-jalali/getDate';
23
+ import { getDaysInMonth } from 'date-fns-jalali/getDaysInMonth';
24
+ import { getMinutes } from 'date-fns-jalali/getMinutes';
25
+ import { isAfter } from 'date-fns-jalali/isAfter';
26
+ import { isBefore } from 'date-fns-jalali/isBefore';
27
+ import { isEqual } from 'date-fns-jalali/isEqual';
28
+ import { isSameDay } from 'date-fns-jalali/isSameDay';
29
+ import { isSameYear } from 'date-fns-jalali/isSameYear';
30
+ import { isSameMonth } from 'date-fns-jalali/isSameMonth';
31
+ import { isSameHour } from 'date-fns-jalali/isSameHour';
32
+ import { isValid } from 'date-fns-jalali/isValid';
33
+ import { parse as dateFnsParse } from 'date-fns-jalali/parse';
34
+ import { setDate } from 'date-fns-jalali/setDate';
35
+ import { setHours } from 'date-fns-jalali/setHours';
36
+ import { setMinutes } from 'date-fns-jalali/setMinutes';
37
+ import { setMonth } from 'date-fns-jalali/setMonth';
38
+ import { setSeconds } from 'date-fns-jalali/setSeconds';
39
+ import { setMilliseconds } from 'date-fns-jalali/setMilliseconds';
40
+ import { setYear } from 'date-fns-jalali/setYear';
41
+ import { startOfDay } from 'date-fns-jalali/startOfDay';
42
+ import { startOfMonth } from 'date-fns-jalali/startOfMonth';
43
+ import { endOfMonth } from 'date-fns-jalali/endOfMonth';
44
+ import { startOfWeek } from 'date-fns-jalali/startOfWeek';
45
+ import { startOfYear } from 'date-fns-jalali/startOfYear';
46
+ import { isWithinInterval } from 'date-fns-jalali/isWithinInterval';
47
+ import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR';
48
+ // date-fns-jalali v2 does not export types
49
+ // @ts-ignore TODO remove when date-fns-jalali-v3 is the default
50
+
51
+ const formatTokenMap = {
52
+ // Year
53
+ y: {
54
+ sectionType: 'year',
55
+ contentType: 'digit',
56
+ maxLength: 4
57
+ },
58
+ yy: 'year',
59
+ yyy: {
60
+ sectionType: 'year',
61
+ contentType: 'digit',
62
+ maxLength: 4
63
+ },
64
+ yyyy: 'year',
65
+ // Month
66
+ M: {
67
+ sectionType: 'month',
68
+ contentType: 'digit',
69
+ maxLength: 2
70
+ },
71
+ MM: 'month',
72
+ MMMM: {
73
+ sectionType: 'month',
74
+ contentType: 'letter'
75
+ },
76
+ MMM: {
77
+ sectionType: 'month',
78
+ contentType: 'letter'
79
+ },
80
+ L: {
81
+ sectionType: 'month',
82
+ contentType: 'digit',
83
+ maxLength: 2
84
+ },
85
+ LL: 'month',
86
+ LLL: {
87
+ sectionType: 'month',
88
+ contentType: 'letter'
89
+ },
90
+ LLLL: {
91
+ sectionType: 'month',
92
+ contentType: 'letter'
93
+ },
94
+ // Day of the month
95
+ d: {
96
+ sectionType: 'day',
97
+ contentType: 'digit',
98
+ maxLength: 2
99
+ },
100
+ dd: 'day',
101
+ do: {
102
+ sectionType: 'day',
103
+ contentType: 'digit-with-letter'
104
+ },
105
+ // Day of the week
106
+ E: {
107
+ sectionType: 'weekDay',
108
+ contentType: 'letter'
109
+ },
110
+ EE: {
111
+ sectionType: 'weekDay',
112
+ contentType: 'letter'
113
+ },
114
+ EEE: {
115
+ sectionType: 'weekDay',
116
+ contentType: 'letter'
117
+ },
118
+ EEEE: {
119
+ sectionType: 'weekDay',
120
+ contentType: 'letter'
121
+ },
122
+ EEEEE: {
123
+ sectionType: 'weekDay',
124
+ contentType: 'letter'
125
+ },
126
+ i: {
127
+ sectionType: 'weekDay',
128
+ contentType: 'digit',
129
+ maxLength: 1
130
+ },
131
+ ii: 'weekDay',
132
+ iii: {
133
+ sectionType: 'weekDay',
134
+ contentType: 'letter'
135
+ },
136
+ iiii: {
137
+ sectionType: 'weekDay',
138
+ contentType: 'letter'
139
+ },
140
+ e: {
141
+ sectionType: 'weekDay',
142
+ contentType: 'digit',
143
+ maxLength: 1
144
+ },
145
+ ee: 'weekDay',
146
+ eee: {
147
+ sectionType: 'weekDay',
148
+ contentType: 'letter'
149
+ },
150
+ eeee: {
151
+ sectionType: 'weekDay',
152
+ contentType: 'letter'
153
+ },
154
+ eeeee: {
155
+ sectionType: 'weekDay',
156
+ contentType: 'letter'
157
+ },
158
+ eeeeee: {
159
+ sectionType: 'weekDay',
160
+ contentType: 'letter'
161
+ },
162
+ c: {
163
+ sectionType: 'weekDay',
164
+ contentType: 'digit',
165
+ maxLength: 1
166
+ },
167
+ cc: 'weekDay',
168
+ ccc: {
169
+ sectionType: 'weekDay',
170
+ contentType: 'letter'
171
+ },
172
+ cccc: {
173
+ sectionType: 'weekDay',
174
+ contentType: 'letter'
175
+ },
176
+ ccccc: {
177
+ sectionType: 'weekDay',
178
+ contentType: 'letter'
179
+ },
180
+ cccccc: {
181
+ sectionType: 'weekDay',
182
+ contentType: 'letter'
183
+ },
184
+ // Meridiem
185
+ a: 'meridiem',
186
+ aa: 'meridiem',
187
+ aaa: 'meridiem',
188
+ // Hours
189
+ H: {
190
+ sectionType: 'hours',
191
+ contentType: 'digit',
192
+ maxLength: 2
193
+ },
194
+ HH: 'hours',
195
+ h: {
196
+ sectionType: 'hours',
197
+ contentType: 'digit',
198
+ maxLength: 2
199
+ },
200
+ hh: 'hours',
201
+ // Minutes
202
+ m: {
203
+ sectionType: 'minutes',
204
+ contentType: 'digit',
205
+ maxLength: 2
206
+ },
207
+ mm: 'minutes',
208
+ // Seconds
209
+ s: {
210
+ sectionType: 'seconds',
211
+ contentType: 'digit',
212
+ maxLength: 2
213
+ },
214
+ ss: 'seconds'
215
+ };
216
+ const defaultFormats = {
217
+ year: 'yyyy',
218
+ month: 'LLLL',
219
+ monthShort: 'MMM',
220
+ dayOfMonth: 'd',
221
+ dayOfMonthFull: 'do',
222
+ weekday: 'EEEE',
223
+ weekdayShort: 'EEEEEE',
224
+ hours24h: 'HH',
225
+ hours12h: 'hh',
226
+ meridiem: 'aa',
227
+ minutes: 'mm',
228
+ seconds: 'ss',
229
+ fullDate: 'PPP',
230
+ keyboardDate: 'P',
231
+ shortDate: 'd MMM',
232
+ normalDate: 'd MMMM',
233
+ normalDateWithWeekday: 'EEE, d MMMM',
234
+ fullTime: 'p',
235
+ fullTime12h: 'hh:mm aaa',
236
+ fullTime24h: 'HH:mm',
237
+ keyboardDateTime: 'P p',
238
+ keyboardDateTime12h: 'P hh:mm aa',
239
+ keyboardDateTime24h: 'P HH:mm'
240
+ };
241
+ const NUMBER_SYMBOL_MAP = {
242
+ '1': '۱',
243
+ '2': '۲',
244
+ '3': '۳',
245
+ '4': '۴',
246
+ '5': '۵',
247
+ '6': '۶',
248
+ '7': '۷',
249
+ '8': '۸',
250
+ '9': '۹',
251
+ '0': '۰'
252
+ };
253
+ /**
254
+ * Based on `@date-io/date-fns-jalali`
255
+ *
256
+ * MIT License
257
+ *
258
+ * Copyright (c) 2017 Dmitriy Kovalenko
259
+ *
260
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
261
+ * of this software and associated documentation files (the "Software"), to deal
262
+ * in the Software without restriction, including without limitation the rights
263
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
264
+ * copies of the Software, and to permit persons to whom the Software is
265
+ * furnished to do so, subject to the following conditions:
266
+ *
267
+ * The above copyright notice and this permission notice shall be included in all
268
+ * copies or substantial portions of the Software.
269
+ *
270
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
271
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
272
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
273
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
274
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
275
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
276
+ * SOFTWARE.
277
+ */
278
+ export class AdapterDateFnsJalali {
279
+ constructor({
280
+ locale: _locale,
281
+ formats
282
+ } = {}) {
283
+ this.isMUIAdapter = true;
284
+ this.isTimezoneCompatible = false;
285
+ this.lib = 'date-fns-jalali';
286
+ this.locale = void 0;
287
+ this.formats = void 0;
288
+ this.formatTokenMap = formatTokenMap;
289
+ this.escapedCharacters = {
290
+ start: "'",
291
+ end: "'"
292
+ };
293
+ this.date = value => {
294
+ if (typeof value === 'undefined') {
295
+ return new Date();
296
+ }
297
+ if (value === null) {
298
+ return null;
299
+ }
300
+ return new Date(value);
301
+ };
302
+ this.getInvalidDate = () => new Date('Invalid Date');
303
+ this.getTimezone = () => {
304
+ return 'default';
305
+ };
306
+ this.setTimezone = value => {
307
+ return value;
308
+ };
309
+ this.toJsDate = value => {
310
+ return value;
311
+ };
312
+ this.parse = (value, format) => {
313
+ if (value === '') {
314
+ return null;
315
+ }
316
+ return dateFnsParse(value, format, new Date(), {
317
+ locale: this.locale
318
+ });
319
+ };
320
+ this.getCurrentLocaleCode = () => {
321
+ return this.locale?.code || 'fa-IR';
322
+ };
323
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
324
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
325
+ this.is12HourCycleInCurrentLocale = () => {
326
+ if (this.locale) {
327
+ return /a/.test(this.locale.formatLong.time());
328
+ }
329
+
330
+ // By default, date-fns-jalali is using fa-IR locale with am/pm enabled
331
+ return true;
332
+ };
333
+ this.expandFormat = format => {
334
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
335
+ const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
336
+ const locale = this.locale ?? defaultLocale;
337
+ return format.match(longFormatRegexp).map(token => {
338
+ const firstCharacter = token[0];
339
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
340
+ const longFormatter = longFormatters[firstCharacter];
341
+ return longFormatter(token, locale.formatLong, {});
342
+ }
343
+ return token;
344
+ }).join('');
345
+ };
346
+ this.isValid = value => {
347
+ if (value == null) {
348
+ return false;
349
+ }
350
+ return isValid(value);
351
+ };
352
+ this.format = (value, formatKey) => {
353
+ return this.formatByString(value, this.formats[formatKey]);
354
+ };
355
+ this.formatByString = (value, formatString) => {
356
+ return dateFnsFormat(value, formatString, {
357
+ locale: this.locale
358
+ });
359
+ };
360
+ this.formatNumber = numberToFormat => {
361
+ return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
362
+ };
363
+ this.isEqual = (value, comparing) => {
364
+ if (value === null && comparing === null) {
365
+ return true;
366
+ }
367
+ if (value === null || comparing === null) {
368
+ return false;
369
+ }
370
+ return isEqual(value, comparing);
371
+ };
372
+ this.isSameYear = (value, comparing) => {
373
+ return isSameYear(value, comparing);
374
+ };
375
+ this.isSameMonth = (value, comparing) => {
376
+ return isSameMonth(value, comparing);
377
+ };
378
+ this.isSameDay = (value, comparing) => {
379
+ return isSameDay(value, comparing);
380
+ };
381
+ this.isSameHour = (value, comparing) => {
382
+ return isSameHour(value, comparing);
383
+ };
384
+ this.isAfter = (value, comparing) => {
385
+ return isAfter(value, comparing);
386
+ };
387
+ this.isAfterYear = (value, comparing) => {
388
+ return isAfter(value, this.endOfYear(comparing));
389
+ };
390
+ this.isAfterDay = (value, comparing) => {
391
+ return isAfter(value, this.endOfDay(comparing));
392
+ };
393
+ this.isBefore = (value, comparing) => {
394
+ return isBefore(value, comparing);
395
+ };
396
+ this.isBeforeYear = (value, comparing) => {
397
+ return isBefore(value, this.startOfYear(comparing));
398
+ };
399
+ this.isBeforeDay = (value, comparing) => {
400
+ return isBefore(value, this.startOfDay(comparing));
401
+ };
402
+ this.isWithinRange = (value, [start, end]) => {
403
+ return isWithinInterval(value, {
404
+ start,
405
+ end
406
+ });
407
+ };
408
+ this.startOfYear = value => {
409
+ return startOfYear(value);
410
+ };
411
+ this.startOfMonth = value => {
412
+ return startOfMonth(value);
413
+ };
414
+ this.startOfWeek = value => {
415
+ return startOfWeek(value, {
416
+ locale: this.locale
417
+ });
418
+ };
419
+ this.startOfDay = value => {
420
+ return startOfDay(value);
421
+ };
422
+ this.endOfYear = value => {
423
+ return endOfYear(value);
424
+ };
425
+ this.endOfMonth = value => {
426
+ return endOfMonth(value);
427
+ };
428
+ this.endOfWeek = value => {
429
+ return endOfWeek(value, {
430
+ locale: this.locale
431
+ });
432
+ };
433
+ this.endOfDay = value => {
434
+ return endOfDay(value);
435
+ };
436
+ this.addYears = (value, amount) => {
437
+ return addYears(value, amount);
438
+ };
439
+ this.addMonths = (value, amount) => {
440
+ return addMonths(value, amount);
441
+ };
442
+ this.addWeeks = (value, amount) => {
443
+ return addWeeks(value, amount);
444
+ };
445
+ this.addDays = (value, amount) => {
446
+ return addDays(value, amount);
447
+ };
448
+ this.addHours = (value, amount) => {
449
+ return addHours(value, amount);
450
+ };
451
+ this.addMinutes = (value, amount) => {
452
+ return addMinutes(value, amount);
453
+ };
454
+ this.addSeconds = (value, amount) => {
455
+ return addSeconds(value, amount);
456
+ };
457
+ this.getYear = value => {
458
+ return getYear(value);
459
+ };
460
+ this.getMonth = value => {
461
+ return getMonth(value);
462
+ };
463
+ this.getDate = value => {
464
+ return getDate(value);
465
+ };
466
+ this.getHours = value => {
467
+ return getHours(value);
468
+ };
469
+ this.getMinutes = value => {
470
+ return getMinutes(value);
471
+ };
472
+ this.getSeconds = value => {
473
+ return getSeconds(value);
474
+ };
475
+ this.getMilliseconds = value => {
476
+ return getMilliseconds(value);
477
+ };
478
+ this.setYear = (value, year) => {
479
+ return setYear(value, year);
480
+ };
481
+ this.setMonth = (value, month) => {
482
+ return setMonth(value, month);
483
+ };
484
+ this.setDate = (value, date) => {
485
+ return setDate(value, date);
486
+ };
487
+ this.setHours = (value, hours) => {
488
+ return setHours(value, hours);
489
+ };
490
+ this.setMinutes = (value, minutes) => {
491
+ return setMinutes(value, minutes);
492
+ };
493
+ this.setSeconds = (value, seconds) => {
494
+ return setSeconds(value, seconds);
495
+ };
496
+ this.setMilliseconds = (value, milliseconds) => {
497
+ return setMilliseconds(value, milliseconds);
498
+ };
499
+ this.getDaysInMonth = value => {
500
+ return getDaysInMonth(value);
501
+ };
502
+ this.getWeekArray = value => {
503
+ const start = this.startOfWeek(this.startOfMonth(value));
504
+ const end = this.endOfWeek(this.endOfMonth(value));
505
+ let count = 0;
506
+ let current = start;
507
+ const nestedWeeks = [];
508
+ while (this.isBefore(current, end)) {
509
+ const weekNumber = Math.floor(count / 7);
510
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
511
+ nestedWeeks[weekNumber].push(current);
512
+ current = this.addDays(current, 1);
513
+ count += 1;
514
+ }
515
+ return nestedWeeks;
516
+ };
517
+ this.getWeekNumber = date => {
518
+ return getWeek(date, {
519
+ locale: this.locale
520
+ });
521
+ };
522
+ this.getYearRange = ([start, end]) => {
523
+ const startDate = this.startOfYear(start);
524
+ const endDate = this.endOfYear(end);
525
+ const years = [];
526
+ let current = startDate;
527
+ while (this.isBefore(current, endDate)) {
528
+ years.push(current);
529
+ current = this.addYears(current, 1);
530
+ }
531
+ return years;
532
+ };
533
+ if (typeof addDays !== 'function') {
534
+ throw new Error([`MUI: The \`date-fns-jalali\` package v2.x is not compatible with this adapter.`, 'Please, install v3.x of the package or use the `AdapterDateFnsJalali` instead.'].join('\n'));
535
+ }
536
+ if (!longFormatters) {
537
+ throw new Error('MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.');
538
+ }
539
+ this.locale = _locale;
540
+ this.formats = _extends({}, defaultFormats, formats);
541
+ }
542
+ getDayOfWeek(value) {
543
+ return value.getDay() + 1;
544
+ }
545
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFnsJalali } from './AdapterDateFnsJalaliV3';
@@ -334,7 +334,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
334
334
  /**
335
335
  * Define custom view renderers for each section.
336
336
  * If `null`, the section will only have field editing.
337
- * If `undefined`, internally defined view will be the used.
337
+ * If `undefined`, internally defined view will be used.
338
338
  */
339
339
  viewRenderers: PropTypes.shape({
340
340
  day: PropTypes.func,
@@ -401,7 +401,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
401
401
  /**
402
402
  * Define custom view renderers for each section.
403
403
  * If `null`, the section will only have field editing.
404
- * If `undefined`, internally defined view will be the used.
404
+ * If `undefined`, internally defined view will be used.
405
405
  */
406
406
  viewRenderers: PropTypes.shape({
407
407
  day: PropTypes.func,
@@ -349,7 +349,7 @@ DesktopDatePicker.propTypes = {
349
349
  /**
350
350
  * Define custom view renderers for each section.
351
351
  * If `null`, the section will only have field editing.
352
- * If `undefined`, internally defined view will be the used.
352
+ * If `undefined`, internally defined view will be used.
353
353
  */
354
354
  viewRenderers: PropTypes.shape({
355
355
  day: PropTypes.func,
@@ -501,7 +501,7 @@ DesktopDateTimePicker.propTypes = {
501
501
  /**
502
502
  * Define custom view renderers for each section.
503
503
  * If `null`, the section will only have field editing.
504
- * If `undefined`, internally defined view will be the used.
504
+ * If `undefined`, internally defined view will be used.
505
505
  */
506
506
  viewRenderers: PropTypes.shape({
507
507
  day: PropTypes.func,
@@ -336,7 +336,7 @@ DesktopTimePicker.propTypes = {
336
336
  /**
337
337
  * Define custom view renderers for each section.
338
338
  * If `null`, the section will only have field editing.
339
- * If `undefined`, internally defined view will be the used.
339
+ * If `undefined`, internally defined view will be used.
340
340
  */
341
341
  viewRenderers: PropTypes.shape({
342
342
  hours: PropTypes.func,
@@ -346,7 +346,7 @@ MobileDatePicker.propTypes = {
346
346
  /**
347
347
  * Define custom view renderers for each section.
348
348
  * If `null`, the section will only have field editing.
349
- * If `undefined`, internally defined view will be the used.
349
+ * If `undefined`, internally defined view will be used.
350
350
  */
351
351
  viewRenderers: PropTypes.shape({
352
352
  day: PropTypes.func,
@@ -402,7 +402,7 @@ MobileDateTimePicker.propTypes = {
402
402
  /**
403
403
  * Define custom view renderers for each section.
404
404
  * If `null`, the section will only have field editing.
405
- * If `undefined`, internally defined view will be the used.
405
+ * If `undefined`, internally defined view will be used.
406
406
  */
407
407
  viewRenderers: PropTypes.shape({
408
408
  day: PropTypes.func,
@@ -294,7 +294,7 @@ MobileTimePicker.propTypes = {
294
294
  /**
295
295
  * Define custom view renderers for each section.
296
296
  * If `null`, the section will only have field editing.
297
- * If `undefined`, internally defined view will be the used.
297
+ * If `undefined`, internally defined view will be used.
298
298
  */
299
299
  viewRenderers: PropTypes.shape({
300
300
  hours: PropTypes.func,
@@ -37,13 +37,13 @@ function PickersShortcuts(props) {
37
37
  const newValue = getValue({
38
38
  isValid
39
39
  });
40
- return {
40
+ return _extends({}, item, {
41
41
  label: item.label,
42
42
  onClick: () => {
43
43
  onChange(newValue, changeImportance, item);
44
44
  },
45
45
  disabled: !isValid(newValue)
46
- };
46
+ });
47
47
  });
48
48
  return /*#__PURE__*/_jsx(List, _extends({
49
49
  dense: true,
@@ -56,7 +56,7 @@ function PickersShortcuts(props) {
56
56
  children: resolvedItems.map(item => {
57
57
  return /*#__PURE__*/_jsx(ListItem, {
58
58
  children: /*#__PURE__*/_jsx(Chip, _extends({}, item))
59
- }, item.label);
59
+ }, item.id ?? item.label);
60
60
  })
61
61
  }));
62
62
  }
@@ -95,6 +95,7 @@ process.env.NODE_ENV !== "production" ? PickersShortcuts.propTypes = {
95
95
  */
96
96
  items: PropTypes.arrayOf(PropTypes.shape({
97
97
  getValue: PropTypes.func.isRequired,
98
+ id: PropTypes.string,
98
99
  label: PropTypes.string.isRequired
99
100
  })),
100
101
  onChange: PropTypes.func.isRequired,
@@ -276,7 +276,7 @@ StaticDatePicker.propTypes = {
276
276
  /**
277
277
  * Define custom view renderers for each section.
278
278
  * If `null`, the section will only have field editing.
279
- * If `undefined`, internally defined view will be the used.
279
+ * If `undefined`, internally defined view will be used.
280
280
  */
281
281
  viewRenderers: PropTypes.shape({
282
282
  day: PropTypes.func,
@@ -332,7 +332,7 @@ StaticDateTimePicker.propTypes = {
332
332
  /**
333
333
  * Define custom view renderers for each section.
334
334
  * If `null`, the section will only have field editing.
335
- * If `undefined`, internally defined view will be the used.
335
+ * If `undefined`, internally defined view will be used.
336
336
  */
337
337
  viewRenderers: PropTypes.shape({
338
338
  day: PropTypes.func,
@@ -223,7 +223,7 @@ StaticTimePicker.propTypes = {
223
223
  /**
224
224
  * Define custom view renderers for each section.
225
225
  * If `null`, the section will only have field editing.
226
- * If `undefined`, internally defined view will be the used.
226
+ * If `undefined`, internally defined view will be used.
227
227
  */
228
228
  viewRenderers: PropTypes.shape({
229
229
  hours: PropTypes.func,