@mui/x-date-pickers 6.18.6 → 6.19.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 (72) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
  2. package/AdapterDateFns/AdapterDateFns.js +11 -272
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
  4. package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  5. package/AdapterDateFnsBase/index.d.ts +1 -0
  6. package/AdapterDateFnsBase/index.js +1 -0
  7. package/AdapterDateFnsBase/package.json +6 -0
  8. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
  9. package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  10. package/AdapterDateFnsV3/index.d.ts +1 -0
  11. package/AdapterDateFnsV3/index.js +1 -0
  12. package/AdapterDateFnsV3/package.json +6 -0
  13. package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
  14. package/CHANGELOG.md +85 -1
  15. package/DateCalendar/DateCalendar.js +6 -4
  16. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  17. package/DigitalClock/DigitalClock.js +3 -2
  18. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  19. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  20. package/TimeClock/TimeClock.js +3 -2
  21. package/hooks/useClearableField.d.ts +1 -1
  22. package/hooks/useClearableField.js +3 -3
  23. package/index.js +1 -1
  24. package/internals/hooks/useViews.d.ts +4 -4
  25. package/internals/hooks/useViews.js +13 -13
  26. package/internals/models/helpers.d.ts +1 -0
  27. package/internals/models/props/clock.d.ts +0 -9
  28. package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
  29. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  30. package/legacy/AdapterDateFnsBase/index.js +1 -0
  31. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
  32. package/legacy/AdapterDateFnsV3/index.js +1 -0
  33. package/legacy/DateCalendar/DateCalendar.js +6 -4
  34. package/legacy/DigitalClock/DigitalClock.js +3 -2
  35. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  36. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  37. package/legacy/TimeClock/TimeClock.js +3 -2
  38. package/legacy/hooks/useClearableField.js +3 -3
  39. package/legacy/index.js +1 -1
  40. package/legacy/internals/hooks/useViews.js +13 -13
  41. package/legacy/locales/index.js +1 -0
  42. package/locales/index.d.ts +1 -0
  43. package/locales/index.js +1 -0
  44. package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
  45. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
  46. package/modern/AdapterDateFnsBase/index.js +1 -0
  47. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  48. package/modern/AdapterDateFnsV3/index.js +1 -0
  49. package/modern/DateCalendar/DateCalendar.js +6 -4
  50. package/modern/DigitalClock/DigitalClock.js +3 -2
  51. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  52. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  53. package/modern/TimeClock/TimeClock.js +3 -2
  54. package/modern/hooks/useClearableField.js +3 -3
  55. package/modern/index.js +1 -1
  56. package/modern/internals/hooks/useViews.js +13 -13
  57. package/modern/locales/index.js +1 -0
  58. package/node/AdapterDateFns/AdapterDateFns.js +11 -271
  59. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
  60. package/node/AdapterDateFnsBase/index.js +12 -0
  61. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
  62. package/node/AdapterDateFnsV3/index.js +12 -0
  63. package/node/DateCalendar/DateCalendar.js +6 -4
  64. package/node/DigitalClock/DigitalClock.js +3 -2
  65. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  66. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  67. package/node/TimeClock/TimeClock.js +3 -2
  68. package/node/hooks/useClearableField.js +3 -3
  69. package/node/index.js +1 -1
  70. package/node/internals/hooks/useViews.js +13 -13
  71. package/node/locales/index.js +11 -0
  72. package/package.json +2 -2
@@ -0,0 +1,307 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ /* eslint-disable class-methods-use-this */
3
+
4
+ const formatTokenMap = {
5
+ // Year
6
+ y: {
7
+ sectionType: 'year',
8
+ contentType: 'digit',
9
+ maxLength: 4
10
+ },
11
+ yy: 'year',
12
+ yyy: {
13
+ sectionType: 'year',
14
+ contentType: 'digit',
15
+ maxLength: 4
16
+ },
17
+ yyyy: 'year',
18
+ // Month
19
+ M: {
20
+ sectionType: 'month',
21
+ contentType: 'digit',
22
+ maxLength: 2
23
+ },
24
+ MM: 'month',
25
+ MMMM: {
26
+ sectionType: 'month',
27
+ contentType: 'letter'
28
+ },
29
+ MMM: {
30
+ sectionType: 'month',
31
+ contentType: 'letter'
32
+ },
33
+ L: {
34
+ sectionType: 'month',
35
+ contentType: 'digit',
36
+ maxLength: 2
37
+ },
38
+ LL: 'month',
39
+ LLL: {
40
+ sectionType: 'month',
41
+ contentType: 'letter'
42
+ },
43
+ LLLL: {
44
+ sectionType: 'month',
45
+ contentType: 'letter'
46
+ },
47
+ // Day of the month
48
+ d: {
49
+ sectionType: 'day',
50
+ contentType: 'digit',
51
+ maxLength: 2
52
+ },
53
+ dd: 'day',
54
+ do: {
55
+ sectionType: 'day',
56
+ contentType: 'digit-with-letter'
57
+ },
58
+ // Day of the week
59
+ E: {
60
+ sectionType: 'weekDay',
61
+ contentType: 'letter'
62
+ },
63
+ EE: {
64
+ sectionType: 'weekDay',
65
+ contentType: 'letter'
66
+ },
67
+ EEE: {
68
+ sectionType: 'weekDay',
69
+ contentType: 'letter'
70
+ },
71
+ EEEE: {
72
+ sectionType: 'weekDay',
73
+ contentType: 'letter'
74
+ },
75
+ EEEEE: {
76
+ sectionType: 'weekDay',
77
+ contentType: 'letter'
78
+ },
79
+ i: {
80
+ sectionType: 'weekDay',
81
+ contentType: 'digit',
82
+ maxLength: 1
83
+ },
84
+ ii: 'weekDay',
85
+ iii: {
86
+ sectionType: 'weekDay',
87
+ contentType: 'letter'
88
+ },
89
+ iiii: {
90
+ sectionType: 'weekDay',
91
+ contentType: 'letter'
92
+ },
93
+ e: {
94
+ sectionType: 'weekDay',
95
+ contentType: 'digit',
96
+ maxLength: 1
97
+ },
98
+ ee: 'weekDay',
99
+ eee: {
100
+ sectionType: 'weekDay',
101
+ contentType: 'letter'
102
+ },
103
+ eeee: {
104
+ sectionType: 'weekDay',
105
+ contentType: 'letter'
106
+ },
107
+ eeeee: {
108
+ sectionType: 'weekDay',
109
+ contentType: 'letter'
110
+ },
111
+ eeeeee: {
112
+ sectionType: 'weekDay',
113
+ contentType: 'letter'
114
+ },
115
+ c: {
116
+ sectionType: 'weekDay',
117
+ contentType: 'digit',
118
+ maxLength: 1
119
+ },
120
+ cc: 'weekDay',
121
+ ccc: {
122
+ sectionType: 'weekDay',
123
+ contentType: 'letter'
124
+ },
125
+ cccc: {
126
+ sectionType: 'weekDay',
127
+ contentType: 'letter'
128
+ },
129
+ ccccc: {
130
+ sectionType: 'weekDay',
131
+ contentType: 'letter'
132
+ },
133
+ cccccc: {
134
+ sectionType: 'weekDay',
135
+ contentType: 'letter'
136
+ },
137
+ // Meridiem
138
+ a: 'meridiem',
139
+ aa: 'meridiem',
140
+ aaa: 'meridiem',
141
+ // Hours
142
+ H: {
143
+ sectionType: 'hours',
144
+ contentType: 'digit',
145
+ maxLength: 2
146
+ },
147
+ HH: 'hours',
148
+ h: {
149
+ sectionType: 'hours',
150
+ contentType: 'digit',
151
+ maxLength: 2
152
+ },
153
+ hh: 'hours',
154
+ // Minutes
155
+ m: {
156
+ sectionType: 'minutes',
157
+ contentType: 'digit',
158
+ maxLength: 2
159
+ },
160
+ mm: 'minutes',
161
+ // Seconds
162
+ s: {
163
+ sectionType: 'seconds',
164
+ contentType: 'digit',
165
+ maxLength: 2
166
+ },
167
+ ss: 'seconds'
168
+ };
169
+ const defaultFormats = {
170
+ year: 'yyyy',
171
+ month: 'LLLL',
172
+ monthShort: 'MMM',
173
+ dayOfMonth: 'd',
174
+ weekday: 'EEEE',
175
+ weekdayShort: 'EEEEEE',
176
+ hours24h: 'HH',
177
+ hours12h: 'hh',
178
+ meridiem: 'aa',
179
+ minutes: 'mm',
180
+ seconds: 'ss',
181
+ fullDate: 'PP',
182
+ fullDateWithWeekday: 'PPPP',
183
+ keyboardDate: 'P',
184
+ shortDate: 'MMM d',
185
+ normalDate: 'd MMMM',
186
+ normalDateWithWeekday: 'EEE, MMM d',
187
+ monthAndYear: 'LLLL yyyy',
188
+ monthAndDate: 'MMMM d',
189
+ fullTime: 'p',
190
+ fullTime12h: 'hh:mm aa',
191
+ fullTime24h: 'HH:mm',
192
+ fullDateTime: 'PP p',
193
+ fullDateTime12h: 'PP hh:mm aa',
194
+ fullDateTime24h: 'PP HH:mm',
195
+ keyboardDateTime: 'P p',
196
+ keyboardDateTime12h: 'P hh:mm aa',
197
+ keyboardDateTime24h: 'P HH:mm'
198
+ };
199
+ /**
200
+ * Based on `@date-io/date-fns`
201
+ *
202
+ * MIT License
203
+ *
204
+ * Copyright (c) 2017 Dmitriy Kovalenko
205
+ *
206
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
207
+ * of this software and associated documentation files (the "Software"), to deal
208
+ * in the Software without restriction, including without limitation the rights
209
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
210
+ * copies of the Software, and to permit persons to whom the Software is
211
+ * furnished to do so, subject to the following conditions:
212
+ *
213
+ * The above copyright notice and this permission notice shall be included in all
214
+ * copies or substantial portions of the Software.
215
+ *
216
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
217
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
218
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
219
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
220
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
222
+ * SOFTWARE.
223
+ */
224
+ export class AdapterDateFnsBase {
225
+ constructor(props) {
226
+ this.isMUIAdapter = true;
227
+ this.isTimezoneCompatible = false;
228
+ this.lib = 'date-fns';
229
+ this.locale = void 0;
230
+ this.formats = void 0;
231
+ this.formatTokenMap = formatTokenMap;
232
+ this.escapedCharacters = {
233
+ start: "'",
234
+ end: "'"
235
+ };
236
+ this.longFormatters = void 0;
237
+ this.date = value => {
238
+ if (typeof value === 'undefined') {
239
+ return new Date();
240
+ }
241
+ if (value === null) {
242
+ return null;
243
+ }
244
+ return new Date(value);
245
+ };
246
+ this.dateWithTimezone = value => {
247
+ return this.date(value);
248
+ };
249
+ this.getTimezone = () => {
250
+ return 'default';
251
+ };
252
+ this.setTimezone = value => {
253
+ return value;
254
+ };
255
+ this.toJsDate = value => {
256
+ return value;
257
+ };
258
+ this.getCurrentLocaleCode = () => {
259
+ return this.locale?.code || 'en-US';
260
+ };
261
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
262
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
263
+ this.is12HourCycleInCurrentLocale = () => {
264
+ if (this.locale) {
265
+ return /a/.test(this.locale.formatLong.time({
266
+ width: 'short'
267
+ }));
268
+ }
269
+
270
+ // By default, date-fns is using en-US locale with am/pm enabled
271
+ return true;
272
+ };
273
+ this.expandFormat = format => {
274
+ const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
275
+
276
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
277
+ return format.match(longFormatRegexp).map(token => {
278
+ const firstCharacter = token[0];
279
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
280
+ const longFormatter = this.longFormatters[firstCharacter];
281
+ return longFormatter(token, this.locale.formatLong);
282
+ }
283
+ return token;
284
+ }).join('');
285
+ };
286
+ this.getFormatHelperText = format => {
287
+ return this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
288
+ };
289
+ this.isNull = value => {
290
+ return value === null;
291
+ };
292
+ this.formatNumber = numberToFormat => {
293
+ return numberToFormat;
294
+ };
295
+ this.getMeridiemText = ampm => {
296
+ return ampm === 'am' ? 'AM' : 'PM';
297
+ };
298
+ const {
299
+ locale,
300
+ formats,
301
+ longFormatters
302
+ } = props;
303
+ this.locale = locale;
304
+ this.formats = _extends({}, defaultFormats, formats);
305
+ this.longFormatters = longFormatters;
306
+ }
307
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFnsBase } from './AdapterDateFnsBase';
@@ -0,0 +1,357 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ // TODO remove when date-fns-v3 is the default
3
+ // @ts-nocheck
4
+ import { addDays } from 'date-fns/addDays';
5
+ import { addSeconds } from 'date-fns/addSeconds';
6
+ import { addMinutes } from 'date-fns/addMinutes';
7
+ import { addHours } from 'date-fns/addHours';
8
+ import { addWeeks } from 'date-fns/addWeeks';
9
+ import { addMonths } from 'date-fns/addMonths';
10
+ import { addYears } from 'date-fns/addYears';
11
+ import { differenceInYears } from 'date-fns/differenceInYears';
12
+ import { differenceInQuarters } from 'date-fns/differenceInQuarters';
13
+ import { differenceInMonths } from 'date-fns/differenceInMonths';
14
+ import { differenceInWeeks } from 'date-fns/differenceInWeeks';
15
+ import { differenceInDays } from 'date-fns/differenceInDays';
16
+ import { differenceInHours } from 'date-fns/differenceInHours';
17
+ import { differenceInMinutes } from 'date-fns/differenceInMinutes';
18
+ import { differenceInSeconds } from 'date-fns/differenceInSeconds';
19
+ import { differenceInMilliseconds } from 'date-fns/differenceInMilliseconds';
20
+ import { eachDayOfInterval } from 'date-fns/eachDayOfInterval';
21
+ import { endOfDay } from 'date-fns/endOfDay';
22
+ import { endOfWeek } from 'date-fns/endOfWeek';
23
+ import { endOfYear } from 'date-fns/endOfYear';
24
+ // @ts-ignore TODO remove when date-fns-v3 is the default
25
+ import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
26
+ import { getDate } from 'date-fns/getDate';
27
+ import { getDaysInMonth } from 'date-fns/getDaysInMonth';
28
+ import { getHours } from 'date-fns/getHours';
29
+ import { getMinutes } from 'date-fns/getMinutes';
30
+ import { getMonth } from 'date-fns/getMonth';
31
+ import { getSeconds } from 'date-fns/getSeconds';
32
+ import { getMilliseconds } from 'date-fns/getMilliseconds';
33
+ import { getWeek } from 'date-fns/getWeek';
34
+ import { getYear } from 'date-fns/getYear';
35
+ import { isAfter } from 'date-fns/isAfter';
36
+ import { isBefore } from 'date-fns/isBefore';
37
+ import { isEqual } from 'date-fns/isEqual';
38
+ import { isSameDay } from 'date-fns/isSameDay';
39
+ import { isSameYear } from 'date-fns/isSameYear';
40
+ import { isSameMonth } from 'date-fns/isSameMonth';
41
+ import { isSameHour } from 'date-fns/isSameHour';
42
+ import { isValid } from 'date-fns/isValid';
43
+ import { parse as dateFnsParse } from 'date-fns/parse';
44
+ import { setDate } from 'date-fns/setDate';
45
+ import { setHours } from 'date-fns/setHours';
46
+ import { setMinutes } from 'date-fns/setMinutes';
47
+ import { setMonth } from 'date-fns/setMonth';
48
+ import { setSeconds } from 'date-fns/setSeconds';
49
+ import { setMilliseconds } from 'date-fns/setMilliseconds';
50
+ import { setYear } from 'date-fns/setYear';
51
+ import { startOfDay } from 'date-fns/startOfDay';
52
+ import { startOfMonth } from 'date-fns/startOfMonth';
53
+ import { endOfMonth } from 'date-fns/endOfMonth';
54
+ import { startOfWeek } from 'date-fns/startOfWeek';
55
+ import { startOfYear } from 'date-fns/startOfYear';
56
+ import { formatISO } from 'date-fns/formatISO';
57
+ import { parseISO } from 'date-fns/parseISO';
58
+ import { isWithinInterval } from 'date-fns/isWithinInterval';
59
+ import { enUS } from 'date-fns/locale/en-US';
60
+ // date-fns v2 does not export types
61
+ // @ts-ignore TODO remove when date-fns-v3 is the default
62
+ import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
63
+
64
+ /**
65
+ * Based on `@date-io/date-fns`
66
+ *
67
+ * MIT License
68
+ *
69
+ * Copyright (c) 2017 Dmitriy Kovalenko
70
+ *
71
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
72
+ * of this software and associated documentation files (the "Software"), to deal
73
+ * in the Software without restriction, including without limitation the rights
74
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75
+ * copies of the Software, and to permit persons to whom the Software is
76
+ * furnished to do so, subject to the following conditions:
77
+ *
78
+ * The above copyright notice and this permission notice shall be included in all
79
+ * copies or substantial portions of the Software.
80
+ *
81
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
87
+ * SOFTWARE.
88
+ */
89
+ export class AdapterDateFns extends AdapterDateFnsBase {
90
+ constructor({
91
+ locale,
92
+ formats
93
+ } = {}) {
94
+ if (typeof addDays !== 'function') {
95
+ throw new Error([`MUI: The \`date-fns\` package v2.x is not compatible with this adapter.`, 'Please, install v3.x of the package or use the `AdapterDateFns` instead.'].join('\n'));
96
+ }
97
+ if (!longFormatters) {
98
+ throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
99
+ }
100
+ super({
101
+ locale: locale ?? enUS,
102
+ formats,
103
+ longFormatters
104
+ });
105
+ this.parseISO = isoString => {
106
+ return parseISO(isoString);
107
+ };
108
+ this.toISO = value => {
109
+ return formatISO(value, {
110
+ format: 'extended'
111
+ });
112
+ };
113
+ this.parse = (value, format) => {
114
+ if (value === '') {
115
+ return null;
116
+ }
117
+ return dateFnsParse(value, format, new Date(), {
118
+ locale: this.locale
119
+ });
120
+ };
121
+ this.isValid = value => {
122
+ return isValid(this.date(value));
123
+ };
124
+ this.format = (value, formatKey) => {
125
+ return this.formatByString(value, this.formats[formatKey]);
126
+ };
127
+ this.formatByString = (value, formatString) => {
128
+ return dateFnsFormat(value, formatString, {
129
+ locale: this.locale
130
+ });
131
+ };
132
+ this.getDiff = (value, comparing, unit) => {
133
+ switch (unit) {
134
+ case 'years':
135
+ return differenceInYears(value, this.date(comparing));
136
+ case 'quarters':
137
+ return differenceInQuarters(value, this.date(comparing));
138
+ case 'months':
139
+ return differenceInMonths(value, this.date(comparing));
140
+ case 'weeks':
141
+ return differenceInWeeks(value, this.date(comparing));
142
+ case 'days':
143
+ return differenceInDays(value, this.date(comparing));
144
+ case 'hours':
145
+ return differenceInHours(value, this.date(comparing));
146
+ case 'minutes':
147
+ return differenceInMinutes(value, this.date(comparing));
148
+ case 'seconds':
149
+ return differenceInSeconds(value, this.date(comparing));
150
+ default:
151
+ {
152
+ return differenceInMilliseconds(value, this.date(comparing));
153
+ }
154
+ }
155
+ };
156
+ this.isEqual = (value, comparing) => {
157
+ if (value === null && comparing === null) {
158
+ return true;
159
+ }
160
+ return isEqual(value, comparing);
161
+ };
162
+ this.isSameYear = (value, comparing) => {
163
+ return isSameYear(value, comparing);
164
+ };
165
+ this.isSameMonth = (value, comparing) => {
166
+ return isSameMonth(value, comparing);
167
+ };
168
+ this.isSameDay = (value, comparing) => {
169
+ return isSameDay(value, comparing);
170
+ };
171
+ this.isSameHour = (value, comparing) => {
172
+ return isSameHour(value, comparing);
173
+ };
174
+ this.isAfter = (value, comparing) => {
175
+ return isAfter(value, comparing);
176
+ };
177
+ this.isAfterYear = (value, comparing) => {
178
+ return isAfter(value, endOfYear(comparing));
179
+ };
180
+ this.isAfterDay = (value, comparing) => {
181
+ return isAfter(value, endOfDay(comparing));
182
+ };
183
+ this.isBefore = (value, comparing) => {
184
+ return isBefore(value, comparing);
185
+ };
186
+ this.isBeforeYear = (value, comparing) => {
187
+ return isBefore(value, this.startOfYear(comparing));
188
+ };
189
+ this.isBeforeDay = (value, comparing) => {
190
+ return isBefore(value, this.startOfDay(comparing));
191
+ };
192
+ this.isWithinRange = (value, [start, end]) => {
193
+ return isWithinInterval(value, {
194
+ start,
195
+ end
196
+ });
197
+ };
198
+ this.startOfYear = value => {
199
+ return startOfYear(value);
200
+ };
201
+ this.startOfMonth = value => {
202
+ return startOfMonth(value);
203
+ };
204
+ this.startOfWeek = value => {
205
+ return startOfWeek(value, {
206
+ locale: this.locale
207
+ });
208
+ };
209
+ this.startOfDay = value => {
210
+ return startOfDay(value);
211
+ };
212
+ this.endOfYear = value => {
213
+ return endOfYear(value);
214
+ };
215
+ this.endOfMonth = value => {
216
+ return endOfMonth(value);
217
+ };
218
+ this.endOfWeek = value => {
219
+ return endOfWeek(value, {
220
+ locale: this.locale
221
+ });
222
+ };
223
+ this.endOfDay = value => {
224
+ return endOfDay(value);
225
+ };
226
+ this.addYears = (value, amount) => {
227
+ return addYears(value, amount);
228
+ };
229
+ this.addMonths = (value, amount) => {
230
+ return addMonths(value, amount);
231
+ };
232
+ this.addWeeks = (value, amount) => {
233
+ return addWeeks(value, amount);
234
+ };
235
+ this.addDays = (value, amount) => {
236
+ return addDays(value, amount);
237
+ };
238
+ this.addHours = (value, amount) => {
239
+ return addHours(value, amount);
240
+ };
241
+ this.addMinutes = (value, amount) => {
242
+ return addMinutes(value, amount);
243
+ };
244
+ this.addSeconds = (value, amount) => {
245
+ return addSeconds(value, amount);
246
+ };
247
+ this.getYear = value => {
248
+ return getYear(value);
249
+ };
250
+ this.getMonth = value => {
251
+ return getMonth(value);
252
+ };
253
+ this.getDate = value => {
254
+ return getDate(value);
255
+ };
256
+ this.getHours = value => {
257
+ return getHours(value);
258
+ };
259
+ this.getMinutes = value => {
260
+ return getMinutes(value);
261
+ };
262
+ this.getSeconds = value => {
263
+ return getSeconds(value);
264
+ };
265
+ this.getMilliseconds = value => {
266
+ return getMilliseconds(value);
267
+ };
268
+ this.setYear = (value, year) => {
269
+ return setYear(value, year);
270
+ };
271
+ this.setMonth = (value, month) => {
272
+ return setMonth(value, month);
273
+ };
274
+ this.setDate = (value, date) => {
275
+ return setDate(value, date);
276
+ };
277
+ this.setHours = (value, hours) => {
278
+ return setHours(value, hours);
279
+ };
280
+ this.setMinutes = (value, minutes) => {
281
+ return setMinutes(value, minutes);
282
+ };
283
+ this.setSeconds = (value, seconds) => {
284
+ return setSeconds(value, seconds);
285
+ };
286
+ this.setMilliseconds = (value, milliseconds) => {
287
+ return setMilliseconds(value, milliseconds);
288
+ };
289
+ this.getDaysInMonth = value => {
290
+ return getDaysInMonth(value);
291
+ };
292
+ this.getNextMonth = value => {
293
+ return addMonths(value, 1);
294
+ };
295
+ this.getPreviousMonth = value => {
296
+ return addMonths(value, -1);
297
+ };
298
+ this.getMonthArray = value => {
299
+ const firstMonth = startOfYear(value);
300
+ const monthArray = [firstMonth];
301
+ while (monthArray.length < 12) {
302
+ const prevMonth = monthArray[monthArray.length - 1];
303
+ monthArray.push(this.getNextMonth(prevMonth));
304
+ }
305
+ return monthArray;
306
+ };
307
+ this.mergeDateAndTime = (dateParam, timeParam) => {
308
+ return this.setSeconds(this.setMinutes(this.setHours(dateParam, this.getHours(timeParam)), this.getMinutes(timeParam)), this.getSeconds(timeParam));
309
+ };
310
+ this.getWeekdays = () => {
311
+ const now = new Date();
312
+ return eachDayOfInterval({
313
+ start: startOfWeek(now, {
314
+ locale: this.locale
315
+ }),
316
+ end: endOfWeek(now, {
317
+ locale: this.locale
318
+ })
319
+ }).map(day => this.formatByString(day, 'EEEEEE'));
320
+ };
321
+ this.getWeekArray = value => {
322
+ const start = startOfWeek(startOfMonth(value), {
323
+ locale: this.locale
324
+ });
325
+ const end = endOfWeek(endOfMonth(value), {
326
+ locale: this.locale
327
+ });
328
+ let count = 0;
329
+ let current = start;
330
+ const nestedWeeks = [];
331
+ while (isBefore(current, end)) {
332
+ const weekNumber = Math.floor(count / 7);
333
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
334
+ nestedWeeks[weekNumber].push(current);
335
+ current = addDays(current, 1);
336
+ count += 1;
337
+ }
338
+ return nestedWeeks;
339
+ };
340
+ this.getWeekNumber = value => {
341
+ return getWeek(value, {
342
+ locale: this.locale
343
+ });
344
+ };
345
+ this.getYearRange = (start, end) => {
346
+ const startDate = startOfYear(start);
347
+ const endDate = endOfYear(end);
348
+ const years = [];
349
+ let current = startDate;
350
+ while (isBefore(current, endDate)) {
351
+ years.push(current);
352
+ current = addYears(current, 1);
353
+ }
354
+ return years;
355
+ };
356
+ }
357
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFns } from './AdapterDateFnsV3';
@@ -256,9 +256,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
256
256
  const handleSelectedDayChange = useEventCallback(day => {
257
257
  if (day) {
258
258
  // If there is a date already selected, then we want to keep its time
259
- return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish');
259
+ return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish', view);
260
260
  }
261
- return handleValueChange(day, 'finish');
261
+ return handleValueChange(day, 'finish', view);
262
262
  });
263
263
  React.useEffect(() => {
264
264
  if (value != null && utils.isValid(value)) {
@@ -447,9 +447,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
447
447
  monthsPerRow: PropTypes.oneOf([3, 4]),
448
448
  /**
449
449
  * Callback fired when the value changes.
450
- * @template TDate
451
- * @param {TDate | null} value The new value.
450
+ * @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.
451
+ * @template TView The view type. Will be one of date or time views.
452
+ * @param {TValue} value The new value.
452
453
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
454
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
453
455
  */
454
456
  onChange: PropTypes.func,
455
457
  /**
@@ -339,8 +339,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
339
339
  minutesStep: PropTypes.number,
340
340
  /**
341
341
  * Callback fired when the value changes.
342
- * @template TDate, TView
343
- * @param {TDate | null} value The new value.
342
+ * @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.
343
+ * @template TView The view type. Will be one of date or time views.
344
+ * @param {TValue} value The new value.
344
345
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
345
346
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
346
347
  */