@mui/x-date-pickers 7.0.0-alpha.6 → 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 (128) 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 +357 -49
  15. package/DateCalendar/DateCalendar.js +6 -4
  16. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  17. package/DatePicker/DatePickerToolbar.d.ts +2 -2
  18. package/DatePicker/DatePickerToolbar.js +2 -7
  19. package/DigitalClock/DigitalClock.js +4 -2
  20. package/DigitalClock/DigitalClock.types.d.ts +5 -0
  21. package/LocalizationProvider/LocalizationProvider.js +1 -1
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  23. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
  24. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  25. package/PickersSectionList/PickersSectionList.js +1 -1
  26. package/TimeClock/TimeClock.js +4 -2
  27. package/TimeClock/TimeClock.types.d.ts +5 -0
  28. package/hooks/useClearableField.js +3 -3
  29. package/index.js +1 -1
  30. package/internals/components/PickersInput/PickersFilledInput.js +2 -2
  31. package/internals/components/PickersInput/PickersInput.d.ts +2 -4
  32. package/internals/components/PickersInput/PickersInput.js +2 -3
  33. package/internals/components/PickersInput/PickersStandardInput.js +2 -2
  34. package/internals/hooks/useField/useField.utils.js +5 -5
  35. package/internals/hooks/usePicker/index.d.ts +1 -1
  36. package/internals/hooks/usePicker/usePickerValue.js +2 -2
  37. package/internals/hooks/useUtils.js +2 -2
  38. package/internals/hooks/useViews.d.ts +4 -4
  39. package/internals/hooks/useViews.js +15 -15
  40. package/internals/index.d.ts +9 -3
  41. package/internals/index.js +6 -2
  42. package/internals/models/common.d.ts +1 -1
  43. package/internals/models/helpers.d.ts +1 -0
  44. package/internals/models/props/clock.d.ts +0 -9
  45. package/internals/utils/views.js +1 -1
  46. package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
  47. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
  48. package/legacy/AdapterDateFnsBase/index.js +1 -0
  49. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
  50. package/legacy/AdapterDateFnsV3/index.js +1 -0
  51. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
  52. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
  53. package/legacy/DateCalendar/DateCalendar.js +6 -4
  54. package/legacy/DatePicker/DatePickerToolbar.js +2 -7
  55. package/legacy/DigitalClock/DigitalClock.js +4 -2
  56. package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
  57. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  58. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  59. package/legacy/PickersSectionList/PickersSectionList.js +1 -1
  60. package/legacy/TimeClock/TimeClock.js +4 -2
  61. package/legacy/hooks/useClearableField.js +3 -3
  62. package/legacy/index.js +1 -1
  63. package/legacy/internals/components/PickersInput/PickersFilledInput.js +2 -2
  64. package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
  65. package/legacy/internals/components/PickersInput/PickersStandardInput.js +2 -2
  66. package/legacy/internals/hooks/useField/useField.utils.js +5 -5
  67. package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
  68. package/legacy/internals/hooks/useUtils.js +2 -2
  69. package/legacy/internals/hooks/useViews.js +15 -15
  70. package/legacy/internals/index.js +6 -2
  71. package/legacy/internals/utils/views.js +1 -1
  72. package/legacy/locales/index.js +1 -0
  73. package/locales/enUS.d.ts +1 -1
  74. package/locales/index.d.ts +1 -0
  75. package/locales/index.js +1 -0
  76. package/locales/mk.d.ts +1 -1
  77. package/locales/utils/getPickersLocalization.d.ts +1 -1
  78. package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
  79. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
  80. package/modern/AdapterDateFnsBase/index.js +1 -0
  81. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
  82. package/modern/AdapterDateFnsV3/index.js +1 -0
  83. package/modern/DateCalendar/DateCalendar.js +6 -4
  84. package/modern/DatePicker/DatePickerToolbar.js +2 -7
  85. package/modern/DigitalClock/DigitalClock.js +4 -2
  86. package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
  87. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  88. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  89. package/modern/PickersSectionList/PickersSectionList.js +1 -1
  90. package/modern/TimeClock/TimeClock.js +4 -2
  91. package/modern/hooks/useClearableField.js +3 -3
  92. package/modern/index.js +1 -1
  93. package/modern/internals/components/PickersInput/PickersFilledInput.js +2 -2
  94. package/modern/internals/components/PickersInput/PickersInput.js +2 -3
  95. package/modern/internals/components/PickersInput/PickersStandardInput.js +2 -2
  96. package/modern/internals/hooks/useField/useField.utils.js +5 -5
  97. package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
  98. package/modern/internals/hooks/useUtils.js +2 -2
  99. package/modern/internals/hooks/useViews.js +15 -15
  100. package/modern/internals/index.js +6 -2
  101. package/modern/internals/utils/views.js +1 -1
  102. package/modern/locales/index.js +1 -0
  103. package/node/AdapterDateFns/AdapterDateFns.js +11 -254
  104. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
  105. package/node/AdapterDateFnsBase/index.js +12 -0
  106. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
  107. package/node/AdapterDateFnsV3/index.js +12 -0
  108. package/node/DateCalendar/DateCalendar.js +6 -4
  109. package/node/DatePicker/DatePickerToolbar.js +0 -4
  110. package/node/DigitalClock/DigitalClock.js +4 -2
  111. package/node/LocalizationProvider/LocalizationProvider.js +1 -1
  112. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  113. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  114. package/node/PickersSectionList/PickersSectionList.js +1 -1
  115. package/node/TimeClock/TimeClock.js +4 -2
  116. package/node/hooks/useClearableField.js +3 -3
  117. package/node/index.js +1 -1
  118. package/node/internals/components/PickersInput/PickersFilledInput.js +2 -2
  119. package/node/internals/components/PickersInput/PickersInput.js +2 -3
  120. package/node/internals/components/PickersInput/PickersStandardInput.js +2 -2
  121. package/node/internals/hooks/useField/useField.utils.js +5 -5
  122. package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
  123. package/node/internals/hooks/useUtils.js +2 -2
  124. package/node/internals/hooks/useViews.js +15 -15
  125. package/node/internals/index.js +47 -1
  126. package/node/internals/utils/views.js +1 -1
  127. package/node/locales/index.js +11 -0
  128. package/package.json +6 -6
@@ -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';
@@ -252,9 +252,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
252
252
  const handleSelectedDayChange = useEventCallback(day => {
253
253
  if (day) {
254
254
  // If there is a date already selected, then we want to keep its time
255
- return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish');
255
+ return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish', view);
256
256
  }
257
- return handleValueChange(day, 'finish');
257
+ return handleValueChange(day, 'finish', view);
258
258
  });
259
259
  React.useEffect(() => {
260
260
  if (value != null && utils.isValid(value)) {
@@ -423,9 +423,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
423
423
  monthsPerRow: PropTypes.oneOf([3, 4]),
424
424
  /**
425
425
  * Callback fired when the value changes.
426
- * @template TDate
427
- * @param {TDate | null} value The new value.
426
+ * @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.
427
+ * @template TView The view type. Will be one of date or time views.
428
+ * @param {TValue} value The new value.
428
429
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
430
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
429
431
  */
430
432
  onChange: PropTypes.func,
431
433
  /**
@@ -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;
@@ -327,8 +327,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
327
327
  minutesStep: PropTypes.number,
328
328
  /**
329
329
  * Callback fired when the value changes.
330
- * @template TDate, TView
331
- * @param {TDate | null} value The new value.
330
+ * @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.
331
+ * @template TView The view type. Will be one of date or time views.
332
+ * @param {TValue} value The new value.
332
333
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
333
334
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
334
335
  */
@@ -416,6 +417,7 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
416
417
  view: PropTypes.oneOf(['hours']),
417
418
  /**
418
419
  * Available views.
420
+ * @default ['hours']
419
421
  */
420
422
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours']))
421
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]);
@@ -122,7 +122,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
122
122
  }, [ampm, inViews]);
123
123
  const {
124
124
  view,
125
- setValueAndGoToView,
125
+ setValueAndGoToNextView,
126
126
  focusedView
127
127
  } = useViews({
128
128
  view: inView,
@@ -134,7 +134,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
134
134
  onFocusedViewChange
135
135
  });
136
136
  const handleMeridiemValueChange = useEventCallback(newValue => {
137
- setValueAndGoToView(newValue, null, 'meridiem');
137
+ setValueAndGoToNextView(newValue, 'finish', 'meridiem');
138
138
  });
139
139
  const {
140
140
  meridiemMode,
@@ -215,11 +215,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
215
215
  throw new Error('not supported');
216
216
  }
217
217
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
218
- const handleSectionChange = useEventCallback((sectionView, newValue) => {
219
- const viewIndex = views.indexOf(sectionView);
220
- const nextView = views[viewIndex + 1];
221
- setValueAndGoToView(newValue, nextView, sectionView);
222
- });
223
218
  const buildViewProps = React.useCallback(viewToBuild => {
224
219
  switch (viewToBuild) {
225
220
  case 'hours':
@@ -227,7 +222,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
227
222
  return {
228
223
  onChange: hours => {
229
224
  const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
230
- handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
225
+ setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
231
226
  },
232
227
  items: getHourSectionOptions({
233
228
  now,
@@ -245,7 +240,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
245
240
  {
246
241
  return {
247
242
  onChange: minutes => {
248
- handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
243
+ setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
249
244
  },
250
245
  items: getTimeSectionOptions({
251
246
  value: utils.getMinutes(valueOrReferenceDate),
@@ -262,7 +257,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
262
257
  {
263
258
  return {
264
259
  onChange: seconds => {
265
- handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
260
+ setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
266
261
  },
267
262
  items: getTimeSectionOptions({
268
263
  value: utils.getSeconds(valueOrReferenceDate),
@@ -299,7 +294,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
299
294
  default:
300
295
  throw new Error(`Unknown view: ${viewToBuild} found.`);
301
296
  }
302
- }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
297
+ }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
303
298
  const viewTimeOptions = React.useMemo(() => {
304
299
  return views.reduce((result, currentView) => {
305
300
  return _extends({}, result, {
@@ -397,8 +392,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
397
392
  minutesStep: PropTypes.number,
398
393
  /**
399
394
  * Callback fired when the value changes.
400
- * @template TDate, TView
401
- * @param {TDate | null} value The new value.
395
+ * @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.
396
+ * @template TView The view type. Will be one of date or time views.
397
+ * @param {TValue} value The new value.
402
398
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
403
399
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
404
400
  */
@@ -490,6 +486,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
490
486
  view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
491
487
  /**
492
488
  * Available views.
489
+ * @default ['hours', 'minutes']
493
490
  */
494
491
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
495
492
  } : void 0;
@@ -47,7 +47,7 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
47
47
  '&:not(:first-of-type)': {
48
48
  borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
49
49
  },
50
- '&:after': {
50
+ '&::after': {
51
51
  display: 'block',
52
52
  content: '""',
53
53
  // subtracting the height of one item, extra margin and borders to make sure the max height is correct
@@ -116,17 +116,13 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
116
116
  return;
117
117
  }
118
118
  const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
119
+ if (active && autoFocus && activeItem) {
120
+ activeItem.focus();
121
+ }
119
122
  if (!activeItem || previousActive.current === activeItem) {
120
- // Handle setting the ref to null if the selected item is ever reset via UI
121
- if (previousActive.current !== activeItem) {
122
- previousActive.current = activeItem;
123
- }
124
123
  return;
125
124
  }
126
125
  previousActive.current = activeItem;
127
- if (active && autoFocus) {
128
- activeItem.focus();
129
- }
130
126
  const offsetTop = activeItem.offsetTop;
131
127
 
132
128
  // Subtracting the 4px of extra margin intended for the first visible section item
@@ -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
  };
@@ -383,8 +383,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
383
383
  minutesStep: PropTypes.number,
384
384
  /**
385
385
  * Callback fired when the value changes.
386
- * @template TDate, TView
387
- * @param {TDate | null} value The new value.
386
+ * @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.
387
+ * @template TView The view type. Will be one of date or time views.
388
+ * @param {TValue} value The new value.
388
389
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
389
390
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
390
391
  */
@@ -462,6 +463,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
462
463
  view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
463
464
  /**
464
465
  * Available views.
466
+ * @default ['hours', 'minutes']
465
467
  */
466
468
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
467
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.6
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
@@ -43,7 +43,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
43
43
  backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
44
44
  }
45
45
  }, !ownerState.disableUnderline && {
46
- '&:after': {
46
+ '&::after': {
47
47
  borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color || 'primary']?.main}`,
48
48
  left: 0,
49
49
  bottom: 0,
@@ -68,7 +68,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
68
68
  borderBottomColor: (theme.vars || theme).palette.error.main
69
69
  }
70
70
  },
71
- '&:before': {
71
+ '&::before': {
72
72
  borderBottom: `1px solid ${theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})` : bottomLineColor}`,
73
73
  left: 0,
74
74
  bottom: 0,
@@ -2,7 +2,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "inputProps", "inputRef", "sectionListRef"];
4
4
  import * as React from 'react';
5
- import Box from '@mui/material/Box';
6
5
  import { useFormControl } from '@mui/material/FormControl';
7
6
  import { styled } from '@mui/material/styles';
8
7
  import useForkRef from '@mui/utils/useForkRef';
@@ -14,7 +13,7 @@ import { Unstable_PickersSectionList as PickersSectionList, Unstable_PickersSect
14
13
  import { jsx as _jsx } from "react/jsx-runtime";
15
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
15
  const round = value => Math.round(value * 1e5) / 1e5;
17
- export const PickersInputRoot = styled(Box, {
16
+ export const PickersInputRoot = styled('div', {
18
17
  name: 'MuiPickersInput',
19
18
  slot: 'Root',
20
19
  overridesResolver: (props, styles) => styles.root
@@ -160,7 +159,7 @@ export const PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(
160
159
  const handleInputRef = useForkRef(inputProps?.ref, inputRef);
161
160
  const muiFormControl = useFormControl();
162
161
  if (!muiFormControl) {
163
- throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
162
+ throw new Error('MUI X: PickersInput should always be used inside a PickersTextField component');
164
163
  }
165
164
  const handleInputFocus = event => {
166
165
  // Fix a bug with IE11 where the focus/blur events are triggered
@@ -26,7 +26,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
26
26
  marginTop: 16
27
27
  }
28
28
  }, !ownerState.disableUnderline && {
29
- '&:after': {
29
+ '&::after': {
30
30
  background: 'red',
31
31
  borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
32
32
  left: 0,
@@ -52,7 +52,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
52
52
  borderBottomColor: (theme.vars || theme).palette.error.main
53
53
  }
54
54
  },
55
- '&:before': {
55
+ '&::before': {
56
56
  borderBottom: `1px solid ${bottomLineColor}`,
57
57
  left: 0,
58
58
  bottom: 0,
@@ -3,7 +3,7 @@ import { getMonthsInYear } from '../../utils/date-utils';
3
3
  export const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
4
4
  const config = utils.formatTokenMap[formatToken];
5
5
  if (config == null) {
6
- throw new Error([`MUI: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
6
+ throw new Error([`MUI X: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
7
7
  }
8
8
  if (typeof config === 'string') {
9
9
  return {
@@ -80,7 +80,7 @@ export const cleanLeadingZeros = (utils, valueStr, size) => {
80
80
  export const cleanDigitSectionValue = (utils, timezone, value, sectionBoundaries, section) => {
81
81
  if (process.env.NODE_ENV !== 'production') {
82
82
  if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
83
- throw new Error([`MUI: The token "${section.format}" is a digit format with letter in it.'
83
+ throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
84
84
  This type of format is only supported for 'day' sections`].join('\n'));
85
85
  }
86
86
  }
@@ -356,7 +356,7 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
356
356
  maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
357
357
  } else {
358
358
  if (sectionConfig.maxLength == null) {
359
- throw new Error(`MUI: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
359
+ throw new Error(`MUI X: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
360
360
  }
361
361
  maxLength = sectionConfig.maxLength;
362
362
  if (isValidDate) {
@@ -387,7 +387,7 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
387
387
  nextFormat = utils.expandFormat(prevFormat);
388
388
  formatExpansionOverflow -= 1;
389
389
  if (formatExpansionOverflow < 0) {
390
- throw new Error('MUI: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component');
390
+ throw new Error('MUI X: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component.');
391
391
  }
392
392
  }
393
393
  const expandedFormat = nextFormat;
@@ -601,7 +601,7 @@ export const validateSections = (sections, valueType) => {
601
601
  }
602
602
  const invalidSection = sections.find(section => !supportedSections.includes(section.type));
603
603
  if (invalidSection) {
604
- console.warn(`MUI: The field component you are using is not compatible with the "${invalidSection.type}" date section.`, `The supported date sections are ["${supportedSections.join('", "')}"]\`.`);
604
+ console.warn(`MUI X: The field component you are using is not compatible with the "${invalidSection.type}" date section.`, `The supported date sections are ["${supportedSections.join('", "')}"]\`.`);
605
605
  warnedOnceInvalidSection = true;
606
606
  }
607
607
  }