@mui/x-date-pickers 7.0.0-alpha.7 → 7.0.0-alpha.8

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 (109) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +4 -21
  2. package/AdapterDateFns/AdapterDateFns.js +11 -255
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
  4. package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -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/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
  9. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +80 -0
  10. package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
  11. package/AdapterDateFnsV3/index.d.ts +1 -0
  12. package/AdapterDateFnsV3/index.js +1 -0
  13. package/AdapterDateFnsV3/package.json +6 -0
  14. package/CHANGELOG.md +175 -49
  15. package/DatePicker/DatePickerToolbar.d.ts +2 -2
  16. package/DatePicker/DatePickerToolbar.js +2 -7
  17. package/DigitalClock/DigitalClock.js +1 -0
  18. package/DigitalClock/DigitalClock.types.d.ts +5 -0
  19. package/LocalizationProvider/LocalizationProvider.js +1 -1
  20. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  21. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
  22. package/PickersSectionList/PickersSectionList.js +1 -1
  23. package/TimeClock/TimeClock.js +1 -0
  24. package/TimeClock/TimeClock.types.d.ts +5 -0
  25. package/hooks/useClearableField.js +3 -3
  26. package/index.js +1 -1
  27. package/internals/components/PickersInput/PickersInput.d.ts +2 -4
  28. package/internals/components/PickersInput/PickersInput.js +2 -3
  29. package/internals/hooks/useField/useField.utils.js +5 -5
  30. package/internals/hooks/usePicker/index.d.ts +1 -1
  31. package/internals/hooks/usePicker/usePickerValue.js +2 -2
  32. package/internals/hooks/useUtils.js +2 -2
  33. package/internals/hooks/useViews.js +2 -2
  34. package/internals/index.d.ts +9 -3
  35. package/internals/index.js +6 -2
  36. package/internals/models/common.d.ts +1 -1
  37. package/internals/models/helpers.d.ts +1 -0
  38. package/internals/utils/views.js +1 -1
  39. package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
  40. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
  41. package/legacy/AdapterDateFnsBase/index.js +1 -0
  42. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
  43. package/legacy/AdapterDateFnsV3/index.js +1 -0
  44. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
  45. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
  46. package/legacy/DatePicker/DatePickerToolbar.js +2 -7
  47. package/legacy/DigitalClock/DigitalClock.js +1 -0
  48. package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
  49. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  50. package/legacy/PickersSectionList/PickersSectionList.js +1 -1
  51. package/legacy/TimeClock/TimeClock.js +1 -0
  52. package/legacy/hooks/useClearableField.js +3 -3
  53. package/legacy/index.js +1 -1
  54. package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
  55. package/legacy/internals/hooks/useField/useField.utils.js +5 -5
  56. package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
  57. package/legacy/internals/hooks/useUtils.js +2 -2
  58. package/legacy/internals/hooks/useViews.js +2 -2
  59. package/legacy/internals/index.js +6 -2
  60. package/legacy/internals/utils/views.js +1 -1
  61. package/legacy/locales/index.js +1 -0
  62. package/locales/enUS.d.ts +1 -1
  63. package/locales/index.d.ts +1 -0
  64. package/locales/index.js +1 -0
  65. package/locales/mk.d.ts +1 -1
  66. package/locales/utils/getPickersLocalization.d.ts +1 -1
  67. package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
  68. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
  69. package/modern/AdapterDateFnsBase/index.js +1 -0
  70. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
  71. package/modern/AdapterDateFnsV3/index.js +1 -0
  72. package/modern/DatePicker/DatePickerToolbar.js +2 -7
  73. package/modern/DigitalClock/DigitalClock.js +1 -0
  74. package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
  75. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  76. package/modern/PickersSectionList/PickersSectionList.js +1 -1
  77. package/modern/TimeClock/TimeClock.js +1 -0
  78. package/modern/hooks/useClearableField.js +3 -3
  79. package/modern/index.js +1 -1
  80. package/modern/internals/components/PickersInput/PickersInput.js +2 -3
  81. package/modern/internals/hooks/useField/useField.utils.js +5 -5
  82. package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
  83. package/modern/internals/hooks/useUtils.js +2 -2
  84. package/modern/internals/hooks/useViews.js +2 -2
  85. package/modern/internals/index.js +6 -2
  86. package/modern/internals/utils/views.js +1 -1
  87. package/modern/locales/index.js +1 -0
  88. package/node/AdapterDateFns/AdapterDateFns.js +11 -254
  89. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
  90. package/node/AdapterDateFnsBase/index.js +12 -0
  91. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
  92. package/node/AdapterDateFnsV3/index.js +12 -0
  93. package/node/DatePicker/DatePickerToolbar.js +0 -4
  94. package/node/DigitalClock/DigitalClock.js +1 -0
  95. package/node/LocalizationProvider/LocalizationProvider.js +1 -1
  96. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  97. package/node/PickersSectionList/PickersSectionList.js +1 -1
  98. package/node/TimeClock/TimeClock.js +1 -0
  99. package/node/hooks/useClearableField.js +3 -3
  100. package/node/index.js +1 -1
  101. package/node/internals/components/PickersInput/PickersInput.js +2 -3
  102. package/node/internals/hooks/useField/useField.utils.js +5 -5
  103. package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
  104. package/node/internals/hooks/useUtils.js +2 -2
  105. package/node/internals/hooks/useViews.js +2 -2
  106. package/node/internals/index.js +47 -1
  107. package/node/internals/utils/views.js +1 -1
  108. package/node/locales/index.js +11 -0
  109. package/package.json +2 -2
@@ -0,0 +1,290 @@
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
+ keyboardDate: 'P',
183
+ shortDate: 'MMM d',
184
+ normalDate: 'd MMMM',
185
+ normalDateWithWeekday: 'EEE, MMM d',
186
+ fullTime: 'p',
187
+ fullTime12h: 'hh:mm aa',
188
+ fullTime24h: 'HH:mm',
189
+ keyboardDateTime: 'P p',
190
+ keyboardDateTime12h: 'P hh:mm aa',
191
+ keyboardDateTime24h: 'P HH:mm'
192
+ };
193
+ /**
194
+ * Based on `@date-io/date-fns`
195
+ *
196
+ * MIT License
197
+ *
198
+ * Copyright (c) 2017 Dmitriy Kovalenko
199
+ *
200
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
201
+ * of this software and associated documentation files (the "Software"), to deal
202
+ * in the Software without restriction, including without limitation the rights
203
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
204
+ * copies of the Software, and to permit persons to whom the Software is
205
+ * furnished to do so, subject to the following conditions:
206
+ *
207
+ * The above copyright notice and this permission notice shall be included in all
208
+ * copies or substantial portions of the Software.
209
+ *
210
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
211
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
212
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
213
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
214
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
215
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
216
+ * SOFTWARE.
217
+ */
218
+ export class AdapterDateFnsBase {
219
+ constructor(props) {
220
+ this.isMUIAdapter = true;
221
+ this.isTimezoneCompatible = false;
222
+ this.lib = 'date-fns';
223
+ this.locale = void 0;
224
+ this.formats = void 0;
225
+ this.formatTokenMap = formatTokenMap;
226
+ this.escapedCharacters = {
227
+ start: "'",
228
+ end: "'"
229
+ };
230
+ this.longFormatters = void 0;
231
+ this.date = value => {
232
+ if (typeof value === 'undefined') {
233
+ return new Date();
234
+ }
235
+ if (value === null) {
236
+ return null;
237
+ }
238
+ return new Date(value);
239
+ };
240
+ this.getInvalidDate = () => new Date('Invalid Date');
241
+ this.getTimezone = () => {
242
+ return 'default';
243
+ };
244
+ this.setTimezone = value => {
245
+ return value;
246
+ };
247
+ this.toJsDate = value => {
248
+ return value;
249
+ };
250
+ this.getCurrentLocaleCode = () => {
251
+ return this.locale?.code || 'en-US';
252
+ };
253
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
254
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
255
+ this.is12HourCycleInCurrentLocale = () => {
256
+ if (this.locale) {
257
+ return /a/.test(this.locale.formatLong.time({
258
+ width: 'short'
259
+ }));
260
+ }
261
+
262
+ // By default, date-fns is using en-US locale with am/pm enabled
263
+ return true;
264
+ };
265
+ this.expandFormat = format => {
266
+ const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
267
+
268
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
269
+ return format.match(longFormatRegexp).map(token => {
270
+ const firstCharacter = token[0];
271
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
272
+ const longFormatter = this.longFormatters[firstCharacter];
273
+ return longFormatter(token, this.locale.formatLong);
274
+ }
275
+ return token;
276
+ }).join('');
277
+ };
278
+ this.formatNumber = numberToFormat => {
279
+ return numberToFormat;
280
+ };
281
+ const {
282
+ locale,
283
+ formats,
284
+ longFormatters
285
+ } = props;
286
+ this.locale = locale;
287
+ this.formats = _extends({}, defaultFormats, formats);
288
+ this.longFormatters = longFormatters;
289
+ }
290
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFnsBase } from './AdapterDateFnsBase';
@@ -0,0 +1,287 @@
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 { endOfDay } from 'date-fns/endOfDay';
12
+ import { endOfWeek } from 'date-fns/endOfWeek';
13
+ import { endOfYear } from 'date-fns/endOfYear';
14
+ // @ts-ignore TODO remove when date-fns-v3 is the default
15
+ import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
16
+ import { getDate } from 'date-fns/getDate';
17
+ import { getDaysInMonth } from 'date-fns/getDaysInMonth';
18
+ import { getHours } from 'date-fns/getHours';
19
+ import { getMinutes } from 'date-fns/getMinutes';
20
+ import { getMonth } from 'date-fns/getMonth';
21
+ import { getSeconds } from 'date-fns/getSeconds';
22
+ import { getMilliseconds } from 'date-fns/getMilliseconds';
23
+ import { getWeek } from 'date-fns/getWeek';
24
+ import { getYear } from 'date-fns/getYear';
25
+ import { isAfter } from 'date-fns/isAfter';
26
+ import { isBefore } from 'date-fns/isBefore';
27
+ import { isEqual } from 'date-fns/isEqual';
28
+ import { isSameDay } from 'date-fns/isSameDay';
29
+ import { isSameYear } from 'date-fns/isSameYear';
30
+ import { isSameMonth } from 'date-fns/isSameMonth';
31
+ import { isSameHour } from 'date-fns/isSameHour';
32
+ import { isValid } from 'date-fns/isValid';
33
+ import { parse as dateFnsParse } from 'date-fns/parse';
34
+ import { setDate } from 'date-fns/setDate';
35
+ import { setHours } from 'date-fns/setHours';
36
+ import { setMinutes } from 'date-fns/setMinutes';
37
+ import { setMonth } from 'date-fns/setMonth';
38
+ import { setSeconds } from 'date-fns/setSeconds';
39
+ import { setMilliseconds } from 'date-fns/setMilliseconds';
40
+ import { setYear } from 'date-fns/setYear';
41
+ import { startOfDay } from 'date-fns/startOfDay';
42
+ import { startOfMonth } from 'date-fns/startOfMonth';
43
+ import { endOfMonth } from 'date-fns/endOfMonth';
44
+ import { startOfWeek } from 'date-fns/startOfWeek';
45
+ import { startOfYear } from 'date-fns/startOfYear';
46
+ import { isWithinInterval } from 'date-fns/isWithinInterval';
47
+ import { enUS } from 'date-fns/locale/en-US';
48
+ // date-fns v2 does not export types
49
+ // @ts-ignore TODO remove when date-fns-v3 is the default
50
+
51
+ import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
52
+
53
+ /**
54
+ * Based on `@date-io/date-fns`
55
+ *
56
+ * MIT License
57
+ *
58
+ * Copyright (c) 2017 Dmitriy Kovalenko
59
+ *
60
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
61
+ * of this software and associated documentation files (the "Software"), to deal
62
+ * in the Software without restriction, including without limitation the rights
63
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
64
+ * copies of the Software, and to permit persons to whom the Software is
65
+ * furnished to do so, subject to the following conditions:
66
+ *
67
+ * The above copyright notice and this permission notice shall be included in all
68
+ * copies or substantial portions of the Software.
69
+ *
70
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
76
+ * SOFTWARE.
77
+ */
78
+ export class AdapterDateFns extends AdapterDateFnsBase {
79
+ constructor({
80
+ locale,
81
+ formats
82
+ } = {}) {
83
+ if (typeof addDays !== 'function') {
84
+ 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'));
85
+ }
86
+ if (!longFormatters) {
87
+ throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
88
+ }
89
+ super({
90
+ locale: locale ?? enUS,
91
+ formats,
92
+ longFormatters
93
+ });
94
+ this.parse = (value, format) => {
95
+ if (value === '') {
96
+ return null;
97
+ }
98
+ return dateFnsParse(value, format, new Date(), {
99
+ locale: this.locale
100
+ });
101
+ };
102
+ this.isValid = value => {
103
+ if (value == null) {
104
+ return false;
105
+ }
106
+ return isValid(value);
107
+ };
108
+ this.format = (value, formatKey) => {
109
+ return this.formatByString(value, this.formats[formatKey]);
110
+ };
111
+ this.formatByString = (value, formatString) => {
112
+ return dateFnsFormat(value, formatString, {
113
+ locale: this.locale
114
+ });
115
+ };
116
+ this.isEqual = (value, comparing) => {
117
+ if (value === null && comparing === null) {
118
+ return true;
119
+ }
120
+ if (value === null || comparing === null) {
121
+ return false;
122
+ }
123
+ return isEqual(value, comparing);
124
+ };
125
+ this.isSameYear = (value, comparing) => {
126
+ return isSameYear(value, comparing);
127
+ };
128
+ this.isSameMonth = (value, comparing) => {
129
+ return isSameMonth(value, comparing);
130
+ };
131
+ this.isSameDay = (value, comparing) => {
132
+ return isSameDay(value, comparing);
133
+ };
134
+ this.isSameHour = (value, comparing) => {
135
+ return isSameHour(value, comparing);
136
+ };
137
+ this.isAfter = (value, comparing) => {
138
+ return isAfter(value, comparing);
139
+ };
140
+ this.isAfterYear = (value, comparing) => {
141
+ return isAfter(value, endOfYear(comparing));
142
+ };
143
+ this.isAfterDay = (value, comparing) => {
144
+ return isAfter(value, endOfDay(comparing));
145
+ };
146
+ this.isBefore = (value, comparing) => {
147
+ return isBefore(value, comparing);
148
+ };
149
+ this.isBeforeYear = (value, comparing) => {
150
+ return isBefore(value, this.startOfYear(comparing));
151
+ };
152
+ this.isBeforeDay = (value, comparing) => {
153
+ return isBefore(value, this.startOfDay(comparing));
154
+ };
155
+ this.isWithinRange = (value, [start, end]) => {
156
+ return isWithinInterval(value, {
157
+ start,
158
+ end
159
+ });
160
+ };
161
+ this.startOfYear = value => {
162
+ return startOfYear(value);
163
+ };
164
+ this.startOfMonth = value => {
165
+ return startOfMonth(value);
166
+ };
167
+ this.startOfWeek = value => {
168
+ return startOfWeek(value, {
169
+ locale: this.locale
170
+ });
171
+ };
172
+ this.startOfDay = value => {
173
+ return startOfDay(value);
174
+ };
175
+ this.endOfYear = value => {
176
+ return endOfYear(value);
177
+ };
178
+ this.endOfMonth = value => {
179
+ return endOfMonth(value);
180
+ };
181
+ this.endOfWeek = value => {
182
+ return endOfWeek(value, {
183
+ locale: this.locale
184
+ });
185
+ };
186
+ this.endOfDay = value => {
187
+ return endOfDay(value);
188
+ };
189
+ this.addYears = (value, amount) => {
190
+ return addYears(value, amount);
191
+ };
192
+ this.addMonths = (value, amount) => {
193
+ return addMonths(value, amount);
194
+ };
195
+ this.addWeeks = (value, amount) => {
196
+ return addWeeks(value, amount);
197
+ };
198
+ this.addDays = (value, amount) => {
199
+ return addDays(value, amount);
200
+ };
201
+ this.addHours = (value, amount) => {
202
+ return addHours(value, amount);
203
+ };
204
+ this.addMinutes = (value, amount) => {
205
+ return addMinutes(value, amount);
206
+ };
207
+ this.addSeconds = (value, amount) => {
208
+ return addSeconds(value, amount);
209
+ };
210
+ this.getYear = value => {
211
+ return getYear(value);
212
+ };
213
+ this.getMonth = value => {
214
+ return getMonth(value);
215
+ };
216
+ this.getDate = value => {
217
+ return getDate(value);
218
+ };
219
+ this.getHours = value => {
220
+ return getHours(value);
221
+ };
222
+ this.getMinutes = value => {
223
+ return getMinutes(value);
224
+ };
225
+ this.getSeconds = value => {
226
+ return getSeconds(value);
227
+ };
228
+ this.getMilliseconds = value => {
229
+ return getMilliseconds(value);
230
+ };
231
+ this.setYear = (value, year) => {
232
+ return setYear(value, year);
233
+ };
234
+ this.setMonth = (value, month) => {
235
+ return setMonth(value, month);
236
+ };
237
+ this.setDate = (value, date) => {
238
+ return setDate(value, date);
239
+ };
240
+ this.setHours = (value, hours) => {
241
+ return setHours(value, hours);
242
+ };
243
+ this.setMinutes = (value, minutes) => {
244
+ return setMinutes(value, minutes);
245
+ };
246
+ this.setSeconds = (value, seconds) => {
247
+ return setSeconds(value, seconds);
248
+ };
249
+ this.setMilliseconds = (value, milliseconds) => {
250
+ return setMilliseconds(value, milliseconds);
251
+ };
252
+ this.getDaysInMonth = value => {
253
+ return getDaysInMonth(value);
254
+ };
255
+ this.getWeekArray = value => {
256
+ const start = this.startOfWeek(this.startOfMonth(value));
257
+ const end = this.endOfWeek(this.endOfMonth(value));
258
+ let count = 0;
259
+ let current = start;
260
+ const nestedWeeks = [];
261
+ while (this.isBefore(current, end)) {
262
+ const weekNumber = Math.floor(count / 7);
263
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
264
+ nestedWeeks[weekNumber].push(current);
265
+ current = this.addDays(current, 1);
266
+ count += 1;
267
+ }
268
+ return nestedWeeks;
269
+ };
270
+ this.getWeekNumber = value => {
271
+ return getWeek(value, {
272
+ locale: this.locale
273
+ });
274
+ };
275
+ this.getYearRange = ([start, end]) => {
276
+ const startDate = this.startOfYear(start);
277
+ const endDate = this.endOfYear(end);
278
+ const years = [];
279
+ let current = startDate;
280
+ while (this.isBefore(current, endDate)) {
281
+ years.push(current);
282
+ current = this.addYears(current, 1);
283
+ }
284
+ return years;
285
+ };
286
+ }
287
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFns } from './AdapterDateFnsV3';
@@ -26,10 +26,6 @@ const DatePickerToolbarRoot = styled(PickersToolbar, {
26
26
  slot: 'Root',
27
27
  overridesResolver: (_, styles) => styles.root
28
28
  })({});
29
-
30
- /**
31
- * @ignore - do not document.
32
- */
33
29
  const DatePickerToolbarTitle = styled(Typography, {
34
30
  name: 'MuiDatePickerToolbar',
35
31
  slot: 'Title',
@@ -49,7 +45,7 @@ const DatePickerToolbarTitle = styled(Typography, {
49
45
  *
50
46
  * - [DatePickerToolbar API](https://mui.com/x/api/date-pickers/date-picker-toolbar/)
51
47
  */
52
- const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
48
+ export const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
53
49
  const props = useThemeProps({
54
50
  props: inProps,
55
51
  name: 'MuiDatePickerToolbar'
@@ -133,5 +129,4 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
133
129
  */
134
130
  view: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
135
131
  views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired).isRequired
136
- } : void 0;
137
- export { DatePickerToolbar };
132
+ } : void 0;
@@ -417,6 +417,7 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
417
417
  view: PropTypes.oneOf(['hours']),
418
418
  /**
419
419
  * Available views.
420
+ * @default ['hours']
420
421
  */
421
422
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours']))
422
423
  } : void 0;
@@ -61,7 +61,7 @@ export const LocalizationProvider = function LocalizationProvider(inProps) {
61
61
  instance: dateLibInstance
62
62
  });
63
63
  if (!adapter.isMUIAdapter) {
64
- throw new Error(['MUI: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation'].join(`\n`));
64
+ throw new Error(['MUI X: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation'].join(`\n`));
65
65
  }
66
66
  return adapter;
67
67
  }, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentUtils]);
@@ -486,6 +486,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
486
486
  view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
487
487
  /**
488
488
  * Available views.
489
+ * @default ['hours', 'minutes']
489
490
  */
490
491
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
491
492
  } : void 0;
@@ -117,7 +117,7 @@ const PickersSectionList = /*#__PURE__*/React.forwardRef(function PickersSection
117
117
  const handleRootRef = useForkRef(ref, rootRef);
118
118
  const getRoot = methodName => {
119
119
  if (!rootRef.current) {
120
- throw new Error(`MUI: Cannot call sectionListRef.${methodName} before the mount of the component`);
120
+ throw new Error(`MUI X: Cannot call sectionListRef.${methodName} before the mount of the component.`);
121
121
  }
122
122
  return rootRef.current;
123
123
  };
@@ -463,6 +463,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
463
463
  view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
464
464
  /**
465
465
  * Available views.
466
+ * @default ['hours', 'minutes']
466
467
  */
467
468
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
468
469
  } : void 0;
@@ -41,8 +41,8 @@ export const useClearableField = props => {
41
41
  });
42
42
  return _extends({}, other, {
43
43
  InputProps: _extends({}, InputProps, {
44
- endAdornment: clearable ? /*#__PURE__*/_jsxs(React.Fragment, {
45
- children: [/*#__PURE__*/_jsx(InputAdornment, {
44
+ endAdornment: /*#__PURE__*/_jsxs(React.Fragment, {
45
+ children: [clearable && /*#__PURE__*/_jsx(InputAdornment, {
46
46
  position: "end",
47
47
  sx: {
48
48
  marginRight: InputProps?.endAdornment ? -1 : -1.5
@@ -54,7 +54,7 @@ export const useClearableField = props => {
54
54
  }, endClearIconProps))
55
55
  }))
56
56
  }), InputProps?.endAdornment]
57
- }) : InputProps?.endAdornment
57
+ })
58
58
  }),
59
59
  sx: [{
60
60
  '& .clearButton': {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.0.0-alpha.7
2
+ * @mui/x-date-pickers v7.0.0-alpha.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the