@mui/x-date-pickers 7.0.0-alpha.0 → 7.0.0-alpha.1

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 (125) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +4 -15
  2. package/AdapterDateFns/AdapterDateFns.js +8 -90
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +4 -15
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
  5. package/AdapterDayjs/AdapterDayjs.d.ts +5 -17
  6. package/AdapterDayjs/AdapterDayjs.js +11 -60
  7. package/AdapterLuxon/AdapterLuxon.d.ts +4 -15
  8. package/AdapterLuxon/AdapterLuxon.js +3 -73
  9. package/AdapterMoment/AdapterMoment.d.ts +4 -20
  10. package/AdapterMoment/AdapterMoment.js +9 -66
  11. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +1 -7
  12. package/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
  13. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +1 -9
  14. package/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
  15. package/CHANGELOG.md +409 -1
  16. package/DateCalendar/DateCalendar.js +0 -1
  17. package/DateCalendar/DayCalendar.d.ts +1 -2
  18. package/DateCalendar/DayCalendar.js +9 -16
  19. package/DateCalendar/index.d.ts +0 -1
  20. package/DateCalendar/index.js +1 -3
  21. package/DatePicker/DatePicker.js +0 -1
  22. package/DatePicker/shared.d.ts +1 -1
  23. package/DateTimePicker/DateTimePicker.js +0 -1
  24. package/DateTimePicker/shared.d.ts +1 -1
  25. package/DesktopDatePicker/DesktopDatePicker.js +0 -1
  26. package/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
  27. package/DigitalClock/DigitalClock.js +3 -2
  28. package/LocalizationProvider/LocalizationProvider.js +0 -6
  29. package/MobileDatePicker/MobileDatePicker.js +0 -1
  30. package/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
  31. package/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
  32. package/StaticDatePicker/StaticDatePicker.js +0 -1
  33. package/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
  34. package/TimePicker/shared.d.ts +1 -1
  35. package/YearCalendar/YearCalendar.js +1 -1
  36. package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
  37. package/index.d.ts +1 -0
  38. package/index.js +4 -1
  39. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +5 -0
  40. package/internals/hooks/useField/useField.utils.js +0 -1
  41. package/internals/hooks/useField/useFieldState.js +1 -1
  42. package/internals/utils/getDefaultReferenceDate.d.ts +1 -2
  43. package/internals/utils/getDefaultReferenceDate.js +0 -4
  44. package/legacy/AdapterDateFns/AdapterDateFns.js +11 -92
  45. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +11 -92
  46. package/legacy/AdapterDayjs/AdapterDayjs.js +15 -63
  47. package/legacy/AdapterLuxon/AdapterLuxon.js +6 -75
  48. package/legacy/AdapterMoment/AdapterMoment.js +12 -70
  49. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -30
  50. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -40
  51. package/legacy/DateCalendar/DateCalendar.js +0 -1
  52. package/legacy/DateCalendar/DayCalendar.js +7 -11
  53. package/legacy/DateCalendar/index.js +1 -3
  54. package/legacy/DatePicker/DatePicker.js +0 -1
  55. package/legacy/DateTimePicker/DateTimePicker.js +0 -1
  56. package/legacy/DesktopDatePicker/DesktopDatePicker.js +0 -1
  57. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
  58. package/legacy/DigitalClock/DigitalClock.js +3 -2
  59. package/legacy/LocalizationProvider/LocalizationProvider.js +0 -6
  60. package/legacy/MobileDatePicker/MobileDatePicker.js +0 -1
  61. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
  62. package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +11 -3
  63. package/legacy/StaticDatePicker/StaticDatePicker.js +0 -1
  64. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
  65. package/legacy/YearCalendar/YearCalendar.js +1 -1
  66. package/legacy/index.js +4 -1
  67. package/legacy/internals/hooks/useField/useField.utils.js +0 -1
  68. package/legacy/internals/hooks/useField/useFieldState.js +1 -1
  69. package/legacy/internals/utils/getDefaultReferenceDate.js +0 -6
  70. package/models/adapters.d.ts +10 -135
  71. package/models/fields.d.ts +0 -6
  72. package/modern/AdapterDateFns/AdapterDateFns.js +8 -90
  73. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
  74. package/modern/AdapterDayjs/AdapterDayjs.js +11 -59
  75. package/modern/AdapterLuxon/AdapterLuxon.js +3 -73
  76. package/modern/AdapterMoment/AdapterMoment.js +9 -65
  77. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
  78. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
  79. package/modern/DateCalendar/DateCalendar.js +0 -1
  80. package/modern/DateCalendar/DayCalendar.js +9 -15
  81. package/modern/DateCalendar/index.js +1 -3
  82. package/modern/DatePicker/DatePicker.js +0 -1
  83. package/modern/DateTimePicker/DateTimePicker.js +0 -1
  84. package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -1
  85. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
  86. package/modern/DigitalClock/DigitalClock.js +3 -2
  87. package/modern/LocalizationProvider/LocalizationProvider.js +0 -6
  88. package/modern/MobileDatePicker/MobileDatePicker.js +0 -1
  89. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
  90. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
  91. package/modern/StaticDatePicker/StaticDatePicker.js +0 -1
  92. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
  93. package/modern/YearCalendar/YearCalendar.js +1 -1
  94. package/modern/index.js +4 -1
  95. package/modern/internals/hooks/useField/useField.utils.js +0 -1
  96. package/modern/internals/hooks/useField/useFieldState.js +1 -1
  97. package/modern/internals/utils/getDefaultReferenceDate.js +0 -1
  98. package/node/AdapterDateFns/AdapterDateFns.js +8 -90
  99. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +8 -90
  100. package/node/AdapterDayjs/AdapterDayjs.js +11 -59
  101. package/node/AdapterLuxon/AdapterLuxon.js +3 -73
  102. package/node/AdapterMoment/AdapterMoment.js +9 -65
  103. package/node/AdapterMomentHijri/AdapterMomentHijri.js +1 -30
  104. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +1 -40
  105. package/node/DateCalendar/DateCalendar.js +0 -1
  106. package/node/DateCalendar/DayCalendar.js +9 -15
  107. package/node/DateCalendar/index.js +1 -21
  108. package/node/DatePicker/DatePicker.js +0 -1
  109. package/node/DateTimePicker/DateTimePicker.js +0 -1
  110. package/node/DesktopDatePicker/DesktopDatePicker.js +0 -1
  111. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -1
  112. package/node/DigitalClock/DigitalClock.js +3 -2
  113. package/node/LocalizationProvider/LocalizationProvider.js +0 -6
  114. package/node/MobileDatePicker/MobileDatePicker.js +0 -1
  115. package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -1
  116. package/node/PickersCalendarHeader/PickersCalendarHeader.js +11 -4
  117. package/node/StaticDatePicker/StaticDatePicker.js +0 -1
  118. package/node/StaticDateTimePicker/StaticDateTimePicker.js +0 -1
  119. package/node/YearCalendar/YearCalendar.js +1 -1
  120. package/node/index.js +13 -1
  121. package/node/internals/hooks/useField/useField.utils.js +0 -1
  122. package/node/internals/hooks/useField/useFieldState.js +1 -1
  123. package/node/internals/utils/getDefaultReferenceDate.js +1 -3
  124. package/package.json +1 -1
  125. package/themeAugmentation/overrides.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,413 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.0.0-alpha.1
7
+
8
+ _Nov 17, 2023_
9
+
10
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🐞 Bugfixes
13
+ - 📚 Documentation improvements
14
+
15
+ ### Date Pickers
16
+
17
+ #### `@mui/x-date-pickers@7.0.0-alpha.1` / `@mui/x-date-pickers-pro@7.0.0-alpha.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
18
+
19
+ #### Breaking changes
20
+
21
+ - The string argument of the `dayOfWeekFormatter` prop has been replaced in favor of the date object to allow more flexibility.
22
+
23
+ ```diff
24
+ <DateCalendar
25
+ // If you were still using the day string, you can get it back with your date library.
26
+ - dayOfWeekFormatter={dayStr => `${dayStr}.`}
27
+ + dayOfWeekFormatter={day => `${day.format('dd')}.`}
28
+
29
+ // If you were already using the day object, just remove the first argument.
30
+ - dayOfWeekFormatter={(_dayStr, day) => `${day.format('dd')}.`}
31
+ + dayOfWeekFormatter={day => `${day.format('dd')}.`}
32
+ />
33
+ ```
34
+
35
+ - The imports related to the `calendarHeader` slot have been moved from `@mui/x-date-pickers/DateCalendar` to `@mui/x-date-pickers/PIckersCalendarHeader`:
36
+
37
+ ```diff
38
+ export {
39
+ pickersCalendarHeaderClasses,
40
+ PickersCalendarHeaderClassKey,
41
+ PickersCalendarHeaderClasses,
42
+ PickersCalendarHeader,
43
+ PickersCalendarHeaderProps,
44
+ PickersCalendarHeaderSlotsComponent,
45
+ PickersCalendarHeaderSlotsComponentsProps,
46
+ ExportedPickersCalendarHeaderProps,
47
+ - } from '@mui/x-date-pickers/DateCalendar';
48
+ + } from '@mui/x-date-pickers/PickersCalendarHeader';
49
+
50
+ ```
51
+
52
+ - The `monthAndYear` format has been removed.
53
+ It was used in the header of the calendar views, you can replace it with the new `format` prop of the `calendarHeader` slot:
54
+
55
+ ```diff
56
+ <LocalizationProvider
57
+ adapter={AdapterDayJS}
58
+ - formats={{ monthAndYear: 'MM/YYYY' }}
59
+ />
60
+ <DatePicker
61
+ + slotProps={{ calendarHeader: { format: 'MM/YYYY' }}}
62
+ />
63
+ <DateRangePicker
64
+ + slotProps={{ calendarHeader: { format: 'MM/YYYY' }}}
65
+ />
66
+ <LocalizationProvider />
67
+ ```
68
+
69
+ - The `adapter.getDiff` method have been removed, you can directly use your date library:
70
+
71
+ ```diff
72
+ // For Day.js
73
+ - const diff = adapter.getDiff(value, comparing, unit);
74
+ + const diff = value.diff(comparing, unit);
75
+
76
+ // For Luxon
77
+ - const diff = adapter.getDiff(value, comparing, unit);
78
+ + const getDiff = (value: DateTime, comparing: DateTime | string, unit?: AdapterUnits) => {
79
+ + const parsedComparing = typeof comparing === 'string'
80
+ + ? DateTime.fromJSDate(new Date(comparing))
81
+ + : comparing;
82
+ + if (unit) {
83
+ + return Math.floor(value.diff(comparing).as(unit));
84
+ + }
85
+ + return value.diff(comparing).as('millisecond');
86
+ + };
87
+ +
88
+ + const diff = getDiff(value, comparing, unit);
89
+
90
+ // For DateFns
91
+ - const diff = adapter.getDiff(value, comparing, unit);
92
+ + const getDiff = (value: Date, comparing: Date | string, unit?: AdapterUnits) => {
93
+ + const parsedComparing = typeof comparing === 'string' ? new Date(comparing) : comparing;
94
+ + switch (unit) {
95
+ + case 'years':
96
+ + return dateFns.differenceInYears(value, parsedComparing);
97
+ + case 'quarters':
98
+ + return dateFns.differenceInQuarters(value, parsedComparing);
99
+ + case 'months':
100
+ + return dateFns.differenceInMonths(value, parsedComparing);
101
+ + case 'weeks':
102
+ + return dateFns.differenceInWeeks(value, parsedComparing);
103
+ + case 'days':
104
+ + return dateFns.differenceInDays(value, parsedComparing);
105
+ + case 'hours':
106
+ + return dateFns.differenceInHours(value, parsedComparing);
107
+ + case 'minutes':
108
+ + return dateFns.differenceInMinutes(value, parsedComparing);
109
+ + case 'seconds':
110
+ + return dateFns.differenceInSeconds(value, parsedComparing);
111
+ + default: {
112
+ + return dateFns.differenceInMilliseconds(value, parsedComparing);
113
+ + }
114
+ + }
115
+ + };
116
+ +
117
+ + const diff = getDiff(value, comparing, unit);
118
+
119
+ // For Moment
120
+ - const diff = adapter.getDiff(value, comparing, unit);
121
+ + const diff = value.diff(comparing, unit);
122
+ ```
123
+
124
+ - The `adapter.getFormatHelperText` method have been removed, you can use the `adapter.expandFormat` instead:
125
+
126
+ ```diff
127
+ - const expandedFormat = adapter.getFormatHelperText(format);
128
+ + const expandedFormat = adapter.expandFormat(format);
129
+ ```
130
+
131
+ And if you need the exact same output you can apply the following transformation:
132
+
133
+ ```diff
134
+ // For Day.js
135
+ - const expandedFormat = adapter.getFormatHelperText(format);
136
+ + const expandedFormat = adapter.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
137
+
138
+ // For Luxon
139
+ - const expandedFormat = adapter.getFormatHelperText(format);
140
+ + const expandedFormat = adapter.expandFormat(format).replace(/(a)/g, '(a|p)m').toLocaleLowerCase();
141
+
142
+ // For DateFns
143
+ - const expandedFormat = adapter.getFormatHelperText(format);
144
+ + const expandedFormat = adapter.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
145
+
146
+ // For Moment
147
+ - const expandedFormat = adapter.getFormatHelperText(format);
148
+ + const expandedFormat = adapter.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
149
+ ```
150
+
151
+ - The `adapter.getMeridiemText` method have been removed, you can use the `adapter.setHours`, `adapter.date` and `adapter.format` methods to recreate its behavior:
152
+
153
+ ```diff
154
+ - const meridiem = adapter.getMeridiemText('am');
155
+ + const getMeridiemText = (meridiem: 'am' | 'pm') => {
156
+ + const date = adapter.setHours(adapter.date()!, meridiem === 'am' ? 2 : 14);
157
+ + return utils.format(date, 'meridiem');
158
+ + };
159
+ +
160
+ + const meridiem = getMeridiemText('am');
161
+ ```
162
+
163
+ - The `adapter.getMonthArray` method have been removed, you can use the `adapter.startOfYear` and `adapter.addMonths` methods to recreate its behavior:
164
+
165
+ ```diff
166
+ - const monthArray = adapter.getMonthArray(value);
167
+ + const getMonthArray = (year) => {
168
+ + const firstMonth = utils.startOfYear(year);
169
+ + const months = [firstMonth];
170
+ +
171
+ + while (months.length < 12) {
172
+ + const prevMonth = months[months.length - 1];
173
+ + months.push(utils.addMonths(prevMonth, 1));
174
+ + }
175
+ +
176
+ + return months;
177
+ + }
178
+ +
179
+ + const monthArray = getMonthArray(value);
180
+ ```
181
+
182
+ - The `adapter.getNextMonth` method have been removed, you can use the `adapter.addMonths` method instead:
183
+
184
+ ```diff
185
+ - const nextMonth = adapter.getNextMonth(value);
186
+ + const nextMonth = adapter.addMonths(value, 1);
187
+ ```
188
+
189
+ - The `adapter.getPreviousMonth` method have been removed, you can use the `adapter.addMonths` method instead:
190
+
191
+ ```diff
192
+ - const previousMonth = adapter.getPreviousMonth(value);
193
+ + const previousMonth = adapter.addMonths(value, -1);
194
+ ```
195
+
196
+ - The `adapter.getWeekdays` method have been removed, you can use the `adapter.startOfWeek` and `adapter.addDays` methods instead:
197
+
198
+ ```diff
199
+ - const weekDays = adapter.getWeekdays(value);
200
+ + const getWeekdays = (value) => {
201
+ + const start = adapter.startOfWeek(value);
202
+ + return [0, 1, 2, 3, 4, 5, 6].map((diff) => utils.addDays(start, diff));
203
+ + };
204
+ +
205
+ + const weekDays = getWeekdays(value);
206
+ ```
207
+
208
+ - The `isNull` method have been removed, you can replace it with a very basic check:
209
+
210
+ ```diff
211
+ - const isNull = adapter.isNull(value);
212
+ + const isNull = value === null;
213
+ ```
214
+
215
+ - The `adapter.mergeDateAndTime` method have been removed, you can use the `adapter.setHours`, `adapter.setMinutes`, and `adapter.setSeconds` methods to recreate its behavior:
216
+
217
+ ```diff
218
+ - const result = adapter.mergeDateAndTime(valueWithDate, valueWithTime);
219
+ + const mergeDateAndTime = <TDate>(
220
+ + dateParam,
221
+ + timeParam,
222
+ + ) => {
223
+ + let mergedDate = dateParam;
224
+ + mergedDate = utils.setHours(mergedDate, utils.getHours(timeParam));
225
+ + mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
226
+ + mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
227
+ +
228
+ + return mergedDate;
229
+ + };
230
+ +
231
+ + const result = mergeDateAndTime(valueWithDate, valueWithTime);
232
+ ```
233
+
234
+ - The `adapter.parseISO` method have been removed, you can directly use your date library:
235
+
236
+ ```diff
237
+ // For Day.js
238
+ - const value = adapter.parseISO(isoString);
239
+ + const value = dayjs(isoString);
240
+
241
+ // For Luxon
242
+ - const value = adapter.parseISO(isoString);
243
+ + const value = DateTime.fromISO(isoString);
244
+
245
+ // For DateFns
246
+ - const value = adapter.parseISO(isoString);
247
+ + const value = dateFns.parseISO(isoString);
248
+
249
+ // For Moment
250
+ - const value = adapter.parseISO(isoString);
251
+ + const value = moment(isoString, true);
252
+ ```
253
+
254
+ - The `adapter.toISO` method have been removed, you can directly use your date library:
255
+
256
+ ```diff
257
+ - const isoString = adapter.toISO(value);
258
+ + const isoString = value.toISOString();
259
+ + const isoString = value.toUTC().toISO({ format: 'extended' });
260
+ + const isoString = dateFns.formatISO(value, { format: 'extended' });
261
+ + const isoString = value.toISOString();
262
+ ```
263
+
264
+ - The `adapter.isEqual` method used to accept any type of value for its two input and tried to parse them before checking if they were equal.
265
+ The method has been simplified and now only accepts an already-parsed date or `null` (ie: the same formats used by the `value` prop in the pickers)
266
+
267
+ ```diff
268
+ const adapterDayjs = new AdapterDayjs();
269
+ const adapterLuxon = new AdapterLuxon();
270
+ const adapterDateFns = new AdapterDateFns();
271
+ const adapterMoment = new AdatperMoment();
272
+
273
+ // Supported formats
274
+ const isEqual = adapterDayjs.isEqual(null, null); // Same for the other adapters
275
+ const isEqual = adapterLuxon.isEqual(DateTime.now(), DateTime.fromISO('2022-04-17'));
276
+ const isEqual = adapterMoment.isEqual(moment(), moment('2022-04-17'));
277
+ const isEqual = adapterDateFns.isEqual(new Date(), new Date('2022-04-17'));
278
+
279
+ // Non-supported formats (JS Date)
280
+ - const isEqual = adapterDayjs.isEqual(new Date(), new Date('2022-04-17'));
281
+ + const isEqual = adapterDayjs.isEqual(dayjs(), dayjs('2022-04-17'));
282
+
283
+ - const isEqual = adapterLuxon.isEqual(new Date(), new Date('2022-04-17'));
284
+ + const isEqual = adapterLuxon.isEqual(DateTime.now(), DateTime.fromISO('2022-04-17'));
285
+
286
+ - const isEqual = adapterMoment.isEqual(new Date(), new Date('2022-04-17'));
287
+ + const isEqual = adapterMoment.isEqual(moment(), moment('2022-04-17'));
288
+
289
+ // Non-supported formats (string)
290
+ - const isEqual = adapterDayjs.isEqual('2022-04-16', '2022-04-17');
291
+ + const isEqual = adapterDayjs.isEqual(dayjs('2022-04-17'), dayjs('2022-04-17'));
292
+
293
+ - const isEqual = adapterLuxon.isEqual('2022-04-16', '2022-04-17');
294
+ + const isEqual = adapterLuxon.isEqual(DateTime.fromISO('2022-04-17'), DateTime.fromISO('2022-04-17'));
295
+
296
+ - const isEqual = adapterMoment.isEqual('2022-04-16', '2022-04-17');
297
+ + const isEqual = adapterMoment.isEqual(moment('2022-04-17'), moment('2022-04-17'));
298
+
299
+ - const isEqual = adapterDateFns.isEqual('2022-04-16', '2022-04-17');
300
+ + const isEqual = adapterDateFns.isEqual(new Date('2022-04-17'), new Date('2022-04-17'));
301
+ ```
302
+
303
+ - The `dateLibInstance` prop of `LocalizationProvider` does not work with `AdapterDayjs` anymore (#11023). This prop was used to set the pickers in UTC mode before the implementation of a proper timezone support in the components.
304
+ You can learn more about the new approach on the [dedicated doc page](https://mui.com/x/react-date-pickers/timezone/).
305
+
306
+ ```diff
307
+ // When a `value` or a `defaultValue` is provided
308
+ <LocalizationProvider
309
+ adapter={AdapterDayjs}
310
+ - dateLibInstance={dayjs.utc}
311
+ >
312
+ <DatePicker value={dayjs.utc('2022-04-17')} />
313
+ </LocalizationProvider>
314
+
315
+ // When no `value` or `defaultValue` is provided
316
+ <LocalizationProvider
317
+ adapter={AdapterDayjs}
318
+ - dateLibInstance={dayjs.utc}
319
+ >
320
+ - <DatePicker />
321
+ + <DatePicker timezone="UTC" />
322
+ </LocalizationProvider>
323
+ ```
324
+
325
+ - The property `hasLeadingZeros` has been removed from the sections in favor of the more precise `hasLeadingZerosInFormat` and `hasLeadingZerosInInput` properties (#10994). To keep the same behavior, you can replace it by `hasLeadingZerosInFormat`:
326
+
327
+ ```diff
328
+ const fieldRef = React.useRef<FieldRef<FieldSection>>(null);
329
+
330
+ React.useEffect(() => {
331
+ const firstSection = fieldRef.current!.getSections()[0]
332
+ - console.log(firstSection.hasLeadingZeros)
333
+ + console.log(firstSection.hasLeadingZerosInFormat)
334
+ }, [])
335
+
336
+ return (
337
+ <DateField unstableFieldRef={fieldRef} />
338
+ );
339
+ ```
340
+
341
+ - The `adapter.getYearRange` method used to accept two params and now accepts a tuple to be consistent with the `adapter.isWithinRange` method (#10978):
342
+
343
+ ```diff
344
+ - adapter.getYearRange(start, end);
345
+ + adapter.getYearRange([start, end])
346
+ ```
347
+
348
+ - The `adapter.isValid` method used to accept any type of value and tried to parse them before checking their validity (#10971).
349
+ The method has been simplified and now only accepts an already-parsed date or `null`.
350
+ Which is the same type as the one accepted by the components `value` prop.
351
+
352
+ ```diff
353
+ const adapterDayjs = new AdapterDayjs();
354
+ const adapterLuxon = new AdapterLuxon();
355
+ const adapterDateFns = new AdapterDateFns();
356
+ const adapterMoment = new AdatperMoment();
357
+
358
+ // Supported formats
359
+ const isValid = adapterDayjs.isValid(null); // Same for the other adapters
360
+ const isValid = adapterLuxon.isValid(DateTime.now());
361
+ const isValid = adapterMoment.isValid(moment());
362
+ const isValid = adapterDateFns.isValid(new Date());
363
+
364
+ // Non-supported formats (JS Date)
365
+ - const isValid = adapterDayjs.isValid(new Date('2022-04-17'));
366
+ + const isValid = adapterDayjs.isValid(dayjs('2022-04-17'));
367
+
368
+ - const isValid = adapterLuxon.isValid(new Date('2022-04-17'));
369
+ + const isValid = adapterLuxon.isValid(DateTime.fromISO('2022-04-17'));
370
+
371
+ - const isValid = adapterMoment.isValid(new Date('2022-04-17'));
372
+ + const isValid = adapterMoment.isValid(moment('2022-04-17'));
373
+
374
+ // Non-supported formats (string)
375
+ - const isValid = adapterDayjs.isValid('2022-04-17');
376
+ + const isValid = adapterDayjs.isValid(dayjs('2022-04-17'));
377
+
378
+ - const isValid = adapterLuxon.isValid('2022-04-17');
379
+ + const isValid = adapterLuxon.isValid(DateTime.fromISO('2022-04-17'));
380
+
381
+ - const isValid = adapterMoment.isValid('2022-04-17');
382
+ + const isValid = adapterMoment.isValid(moment('2022-04-17'));
383
+
384
+ - const isValid = adapterDateFns.isValid('2022-04-17');
385
+ + const isValid = adapterDateFns.isValid(new Date('2022-04-17'));
386
+ ```
387
+
388
+ #### Changes
389
+
390
+ - [pickers] Change the input format of `adapter.getYearRange` to be consistent with `adapter.isWithinRange` (#10978) @flaviendelangle
391
+ - [pickers] Clean remaining `components` / `componentsProps` typings (#11040) @flaviendelangle
392
+ - [pickers] Modify `adapter.isEqual` method to accept `TDate | null` instead of `any` (#10976) @flaviendelangle
393
+ - [pickers] Modify `adapter.isValid` method to accept `TDate | null` instead of `any` (#10971) @flaviendelangle
394
+ - [pickers] Remove the `hasLeadingZeros` property from `FieldSection` (#10994) @flaviendelangle
395
+ - [pickers] Remove the deprecated methods and formats from the adapters (#10776) @flaviendelangle
396
+ - [pickers] Remove the legacy UTC implementation for `dayjs` (#11023) @flaviendelangle
397
+ - [pickers] Remove unused code (#11048) @flaviendelangle
398
+ - [pickers] Move the exports of the `calendarHeader` slot to `@mui/x-date-pickers/PickersCalendarHeader` (#11020) @flaviendelangle
399
+ - [DateCalendar] Allow to override the format of the header with a prop (#10990) @flaviendelangle
400
+ - [DateCalendar] Remove the string argument of the `dayOfWeekFormatter` prop (#10992) @flaviendelangle
401
+
402
+ ### Docs
403
+
404
+ - [docs] Fix incorrect component name in the "Custom slots and subcomponents" page (#11024) @flaviendelangle
405
+ - [docs] Fix typos in pickers migration guide (#11057) @flaviendelangle
406
+
407
+ ### Core
408
+
409
+ - [core] Clean the component slots doc generation (#11021) @flaviendelangle
410
+ - [core] Fix script to release with `next` tag (#10996) @LukasTy
411
+ - [test] Wait for images to load (#11004) @cherniavskii
412
+
6
413
  ## 7.0.0-alpha.0
7
414
 
8
415
  _Nov 10, 2023_
@@ -384,7 +791,7 @@ Same changes as in `@mui/x-date-pickers@6.16.3`, plus:
384
791
 
385
792
  - [charts] Add reference links to area + bar chart components (#10652) @michelengelen
386
793
  - [charts] Add reference links to line chart + sparkline components (#10650) @michelengelen
387
- - [charts] Add reference links to pie + scatter chart components (#10653) @michelengelen
794
+ - [charts] Add reference links to pie + scatter chart components (#10653) @michelengelen
388
795
  - [charts] Render only when `width` and `height` are resolved (#10714) @alexfauquette
389
796
  - [charts] Support animation on `BarChart` (#9926) @alexfauquette
390
797
  - [charts] Use new text component to avoid tick label overflow on x-axis (#10648) @alexfauquette
@@ -460,6 +867,7 @@ It adds line break support and avoids overlapping text in the legend.
460
867
  This comes with some breaking changes.
461
868
 
462
869
  - The DOM structure is modified. An intermediary `<tspan />` element has been added. This can impact how your style is applied.
870
+
463
871
  ```diff
464
872
  - <text>The label</text>
465
873
  + <text><tspan>The label</tspan></text>
@@ -362,7 +362,6 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
362
362
  className: PropTypes.string,
363
363
  /**
364
364
  * Formats the day of week displayed in the calendar header.
365
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
366
365
  * @param {TDate} date The date of the day of week provided by the adapter.
367
366
  * @returns {string} The name to display.
368
367
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -36,12 +36,11 @@ export interface ExportedDayCalendarProps<TDate> extends ExportedPickersDayProps
36
36
  renderLoading?: () => React.ReactNode;
37
37
  /**
38
38
  * Formats the day of week displayed in the calendar header.
39
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
40
39
  * @param {TDate} date The date of the day of week provided by the adapter.
41
40
  * @returns {string} The name to display.
42
41
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
43
42
  */
44
- dayOfWeekFormatter?: (day: string, date: TDate) => string;
43
+ dayOfWeekFormatter?: (date: TDate) => string;
45
44
  /**
46
45
  * If `true`, the week number will be display in the calendar.
47
46
  */
@@ -216,6 +216,7 @@ export function DayCalendar(inProps) {
216
216
  props: inProps,
217
217
  name: 'MuiDayCalendar'
218
218
  });
219
+ const utils = useUtils();
219
220
  const {
220
221
  onFocusedDayChange,
221
222
  className,
@@ -239,7 +240,7 @@ export function DayCalendar(inProps) {
239
240
  shouldDisableDate,
240
241
  shouldDisableMonth,
241
242
  shouldDisableYear,
242
- dayOfWeekFormatter: dayOfWeekFormatterFromProps,
243
+ dayOfWeekFormatter = date => utils.format(date, 'weekdayShort').charAt(0).toUpperCase(),
243
244
  hasFocus,
244
245
  onFocusedViewChange,
245
246
  gridLabelId,
@@ -249,13 +250,9 @@ export function DayCalendar(inProps) {
249
250
  timezone
250
251
  } = props;
251
252
  const now = useNow(timezone);
252
- const utils = useUtils();
253
253
  const classes = useUtilityClasses(props);
254
254
  const theme = useTheme();
255
255
  const isRTL = theme.direction === 'rtl';
256
-
257
- // before we could define this outside of the component scope, but now we need utils, which is only defined here
258
- const dayOfWeekFormatter = dayOfWeekFormatterFromProps || ((_day, date) => utils.format(date, 'weekdayShort').charAt(0).toUpperCase());
259
256
  const isDateDisabled = useIsDateDisabled({
260
257
  shouldDisableDate,
261
258
  shouldDisableMonth,
@@ -410,17 +407,13 @@ export function DayCalendar(inProps) {
410
407
  "aria-label": localeText.calendarWeekNumberHeaderLabel,
411
408
  className: classes.weekNumberLabel,
412
409
  children: localeText.calendarWeekNumberHeaderText
413
- }), getWeekdays(utils, now).map((weekday, i) => {
414
- var _dayOfWeekFormatter;
415
- const day = utils.format(weekday, 'weekdayShort');
416
- return /*#__PURE__*/_jsx(PickersCalendarWeekDayLabel, {
417
- variant: "caption",
418
- role: "columnheader",
419
- "aria-label": utils.format(utils.addDays(startOfCurrentWeek, i), 'weekday'),
420
- className: classes.weekDayLabel,
421
- children: (_dayOfWeekFormatter = dayOfWeekFormatter == null ? void 0 : dayOfWeekFormatter(day, weekday)) != null ? _dayOfWeekFormatter : day
422
- }, day + i.toString());
423
- })]
410
+ }), getWeekdays(utils, now).map((weekday, i) => /*#__PURE__*/_jsx(PickersCalendarWeekDayLabel, {
411
+ variant: "caption",
412
+ role: "columnheader",
413
+ "aria-label": utils.format(utils.addDays(startOfCurrentWeek, i), 'weekday'),
414
+ className: classes.weekDayLabel,
415
+ children: dayOfWeekFormatter(weekday)
416
+ }, i.toString()))]
424
417
  }), loading ? /*#__PURE__*/_jsx(PickersCalendarLoadingContainer, {
425
418
  className: classes.loadingContainer,
426
419
  children: renderLoading()
@@ -10,4 +10,3 @@ export type { PickersFadeTransitionGroupClassKey, PickersFadeTransitionGroupClas
10
10
  export { pickersSlideTransitionClasses } from './pickersSlideTransitionClasses';
11
11
  export type { PickersSlideTransitionClassKey, PickersSlideTransitionClasses, } from './pickersSlideTransitionClasses';
12
12
  export type { ExportedSlideTransitionProps } from './PickersSlideTransition';
13
- export * from '../PickersCalendarHeader';
@@ -2,6 +2,4 @@ export { DateCalendar } from './DateCalendar';
2
2
  export { getDateCalendarUtilityClass, dateCalendarClasses } from './dateCalendarClasses';
3
3
  export { dayPickerClasses } from './dayCalendarClasses';
4
4
  export { pickersFadeTransitionGroupClasses } from './pickersFadeTransitionGroupClasses';
5
- export { pickersSlideTransitionClasses } from './pickersSlideTransitionClasses';
6
- // TODO v7: Remove and export the `PickersCalendarHeader` folder from the root instead.
7
- export * from '../PickersCalendarHeader';
5
+ export { pickersSlideTransitionClasses } from './pickersSlideTransitionClasses';
@@ -66,7 +66,6 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
66
66
  closeOnSelect: PropTypes.bool,
67
67
  /**
68
68
  * Formats the day of week displayed in the calendar header.
69
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
70
69
  * @param {TDate} date The date of the day of week provided by the adapter.
71
70
  * @returns {string} The name to display.
72
71
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -36,6 +36,6 @@ export interface BaseDatePickerProps<TDate> extends BasePickerInputProps<TDate |
36
36
  */
37
37
  viewRenderers?: Partial<PickerViewRendererLookup<TDate | null, DateView, DateViewRendererProps<TDate, DateView>, {}>>;
38
38
  }
39
- type UseDatePickerDefaultizedProps<TDate, Props extends BaseDatePickerProps<TDate>> = LocalizedComponent<TDate, Omit<DefaultizedProps<Props, 'views' | 'openTo' | keyof BaseDateValidationProps<TDate>>, 'components' | 'componentsProps'>>;
39
+ type UseDatePickerDefaultizedProps<TDate, Props extends BaseDatePickerProps<TDate>> = LocalizedComponent<TDate, DefaultizedProps<Props, 'views' | 'openTo' | keyof BaseDateValidationProps<TDate>>>;
40
40
  export declare function useDatePickerDefaultizedProps<TDate, Props extends BaseDatePickerProps<TDate>>(props: Props, name: string): UseDatePickerDefaultizedProps<TDate, Props>;
41
41
  export {};
@@ -76,7 +76,6 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
76
76
  closeOnSelect: PropTypes.bool,
77
77
  /**
78
78
  * Formats the day of week displayed in the calendar header.
79
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
80
79
  * @param {TDate} date The date of the day of week provided by the adapter.
81
80
  * @returns {string} The name to display.
82
81
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -59,5 +59,5 @@ export interface BaseDateTimePickerProps<TDate, TView extends DateOrTimeViewWith
59
59
  viewRenderers?: Partial<PickerViewRendererLookup<TDate | null, TView, DateViewRendererProps<TDate, TView> & TimeViewRendererProps<TimeViewWithMeridiem, BaseClockProps<TDate, TimeViewWithMeridiem>>, {}>>;
60
60
  }
61
61
  type UseDateTimePickerDefaultizedProps<TDate, TView extends DateOrTimeViewWithMeridiem, Props extends BaseDateTimePickerProps<TDate, TView>> = LocalizedComponent<TDate, DefaultizedProps<Props, 'views' | 'openTo' | 'orientation' | 'ampm' | keyof BaseDateValidationProps<TDate> | keyof BaseTimeValidationProps>>;
62
- export declare function useDateTimePickerDefaultizedProps<TDate, TView extends DateOrTimeViewWithMeridiem, Props extends BaseDateTimePickerProps<TDate, TView>>(props: Props, name: string): Omit<UseDateTimePickerDefaultizedProps<TDate, TView, Props>, 'components' | 'componentsProps'>;
62
+ export declare function useDateTimePickerDefaultizedProps<TDate, TView extends DateOrTimeViewWithMeridiem, Props extends BaseDateTimePickerProps<TDate, TView>>(props: Props, name: string): UseDateTimePickerDefaultizedProps<TDate, TView, Props>;
63
63
  export {};
@@ -90,7 +90,6 @@ DesktopDatePicker.propTypes = {
90
90
  closeOnSelect: PropTypes.bool,
91
91
  /**
92
92
  * Formats the day of week displayed in the calendar header.
93
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
94
93
  * @param {TDate} date The date of the day of week provided by the adapter.
95
94
  * @returns {string} The name to display.
96
95
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -139,7 +139,6 @@ DesktopDateTimePicker.propTypes = {
139
139
  closeOnSelect: PropTypes.bool,
140
140
  /**
141
141
  * Formats the day of week displayed in the calendar header.
142
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
143
142
  * @param {TDate} date The date of the day of week provided by the adapter.
144
143
  * @returns {string} The name to display.
145
144
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -244,6 +244,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
244
244
  return null;
245
245
  }
246
246
  const isSelected = utils.isEqual(option, value);
247
+ const formattedValue = utils.format(option, ampm ? 'fullTime12h' : 'fullTime24h');
247
248
  const tabIndex = focusedOptionIndex === index || focusedOptionIndex === -1 && index === 0 ? 0 : -1;
248
249
  return /*#__PURE__*/_jsx(ClockItem, _extends({
249
250
  onClick: () => !readOnly && handleItemSelect(option),
@@ -257,8 +258,8 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
257
258
  "aria-selected": isSelected,
258
259
  tabIndex: tabIndex
259
260
  }, clockItemProps, {
260
- children: utils.format(option, ampm ? 'fullTime12h' : 'fullTime24h')
261
- }), utils.toISO(option));
261
+ children: formattedValue
262
+ }), formattedValue);
262
263
  })
263
264
  })
264
265
  }));
@@ -108,10 +108,6 @@ process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
108
108
  dateFormats: PropTypes.shape({
109
109
  dayOfMonth: PropTypes.string,
110
110
  fullDate: PropTypes.string,
111
- fullDateTime: PropTypes.string,
112
- fullDateTime12h: PropTypes.string,
113
- fullDateTime24h: PropTypes.string,
114
- fullDateWithWeekday: PropTypes.string,
115
111
  fullTime: PropTypes.string,
116
112
  fullTime12h: PropTypes.string,
117
113
  fullTime24h: PropTypes.string,
@@ -124,8 +120,6 @@ process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
124
120
  meridiem: PropTypes.string,
125
121
  minutes: PropTypes.string,
126
122
  month: PropTypes.string,
127
- monthAndDate: PropTypes.string,
128
- monthAndYear: PropTypes.string,
129
123
  monthShort: PropTypes.string,
130
124
  normalDate: PropTypes.string,
131
125
  normalDateWithWeekday: PropTypes.string,
@@ -87,7 +87,6 @@ MobileDatePicker.propTypes = {
87
87
  closeOnSelect: PropTypes.bool,
88
88
  /**
89
89
  * Formats the day of week displayed in the calendar header.
90
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
91
90
  * @param {TDate} date The date of the day of week provided by the adapter.
92
91
  * @returns {string} The name to display.
93
92
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
@@ -108,7 +108,6 @@ MobileDateTimePicker.propTypes = {
108
108
  closeOnSelect: PropTypes.bool,
109
109
  /**
110
110
  * Formats the day of week displayed in the calendar header.
111
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
112
111
  * @param {TDate} date The date of the day of week provided by the adapter.
113
112
  * @returns {string} The name to display.
114
113
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()