@mui/x-date-pickers 6.11.1 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +2 -2
  2. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -2
  3. package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
  4. package/AdapterLuxon/AdapterLuxon.d.ts +2 -2
  5. package/AdapterMoment/AdapterMoment.d.ts +2 -2
  6. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +2 -2
  7. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +2 -2
  8. package/CHANGELOG.md +154 -31
  9. package/DateCalendar/DateCalendar.js +4 -4
  10. package/DateCalendar/DateCalendar.types.d.ts +2 -2
  11. package/DateCalendar/DayCalendar.js +2 -2
  12. package/DatePicker/DatePicker.js +2 -2
  13. package/DateTimePicker/DateTimePicker.js +2 -2
  14. package/DesktopDatePicker/DesktopDatePicker.js +2 -2
  15. package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  16. package/DesktopTimePicker/DesktopTimePicker.js +5 -0
  17. package/DigitalClock/DigitalClock.js +3 -1
  18. package/MobileDatePicker/MobileDatePicker.js +2 -2
  19. package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  20. package/MobileTimePicker/MobileTimePicker.js +5 -0
  21. package/MonthCalendar/PickersMonth.js +1 -1
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
  23. package/PickersShortcuts/PickersShortcuts.d.ts +2 -1
  24. package/PickersShortcuts/PickersShortcuts.js +9 -4
  25. package/PickersShortcuts/index.d.ts +1 -1
  26. package/StaticDatePicker/StaticDatePicker.js +2 -2
  27. package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  28. package/StaticTimePicker/StaticTimePicker.js +5 -0
  29. package/TimePicker/TimePicker.js +5 -0
  30. package/YearCalendar/YearCalendar.js +5 -2
  31. package/index.js +1 -1
  32. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
  33. package/internals/components/PickersPopper.d.ts +7 -4
  34. package/internals/components/PickersPopper.js +65 -32
  35. package/internals/components/PickersToolbar.js +13 -13
  36. package/internals/hooks/useDefaultReduceAnimations.d.ts +1 -1
  37. package/internals/hooks/useDefaultReduceAnimations.js +7 -2
  38. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
  39. package/internals/hooks/useField/useField.js +6 -6
  40. package/internals/hooks/useField/useField.utils.d.ts +0 -1
  41. package/internals/hooks/useField/useField.utils.js +0 -48
  42. package/internals/hooks/useField/useFieldState.js +5 -25
  43. package/internals/hooks/usePicker/usePickerValue.js +11 -3
  44. package/internals/hooks/usePicker/usePickerValue.types.d.ts +3 -5
  45. package/internals/hooks/usePicker/usePickerViews.d.ts +5 -0
  46. package/internals/hooks/usePicker/usePickerViews.js +1 -1
  47. package/internals/hooks/useValidation.d.ts +2 -4
  48. package/internals/hooks/useValueWithTimezone.js +2 -2
  49. package/internals/hooks/useViews.js +1 -1
  50. package/legacy/DateCalendar/DateCalendar.js +4 -4
  51. package/legacy/DateCalendar/DayCalendar.js +2 -2
  52. package/legacy/DatePicker/DatePicker.js +2 -2
  53. package/legacy/DateTimePicker/DateTimePicker.js +2 -2
  54. package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -2
  55. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  56. package/legacy/DesktopTimePicker/DesktopTimePicker.js +5 -0
  57. package/legacy/DigitalClock/DigitalClock.js +3 -1
  58. package/legacy/MobileDatePicker/MobileDatePicker.js +2 -2
  59. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  60. package/legacy/MobileTimePicker/MobileTimePicker.js +5 -0
  61. package/legacy/MonthCalendar/PickersMonth.js +1 -1
  62. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
  63. package/legacy/PickersShortcuts/PickersShortcuts.js +7 -4
  64. package/legacy/StaticDatePicker/StaticDatePicker.js +2 -2
  65. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  66. package/legacy/StaticTimePicker/StaticTimePicker.js +5 -0
  67. package/legacy/TimePicker/TimePicker.js +5 -0
  68. package/legacy/YearCalendar/YearCalendar.js +5 -2
  69. package/legacy/index.js +1 -1
  70. package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -15
  71. package/legacy/internals/components/PickersPopper.js +61 -32
  72. package/legacy/internals/components/PickersToolbar.js +11 -14
  73. package/legacy/internals/hooks/useDefaultReduceAnimations.js +7 -2
  74. package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
  75. package/legacy/internals/hooks/useField/useField.js +6 -6
  76. package/legacy/internals/hooks/useField/useField.utils.js +0 -52
  77. package/legacy/internals/hooks/useField/useFieldState.js +4 -24
  78. package/legacy/internals/hooks/usePicker/usePickerValue.js +11 -3
  79. package/legacy/internals/hooks/usePicker/usePickerViews.js +1 -1
  80. package/legacy/internals/hooks/useValueWithTimezone.js +2 -2
  81. package/legacy/internals/hooks/useViews.js +1 -1
  82. package/legacy/models/index.js +2 -1
  83. package/legacy/models/pickers.js +1 -0
  84. package/legacy/tests/describeAdapters/describeAdapters.js +1 -1
  85. package/legacy/tests/describeGregorianAdapter/testCalculations.js +1 -1
  86. package/legacy/tests/describeGregorianAdapter/testLocalization.js +1 -1
  87. package/legacy/tests/describeValidation/testDayViewValidation.js +1 -1
  88. package/legacy/tests/describeValidation/testMinutesViewValidation.js +2 -2
  89. package/legacy/tests/describeValidation/testMonthViewValidation.js +1 -1
  90. package/legacy/tests/describeValidation/testTextFieldValidation.js +1 -1
  91. package/legacy/tests/describeValidation/testYearViewValidation.js +1 -1
  92. package/legacy/tests/describeValue/describeValue.js +1 -1
  93. package/legacy/tests/describeValue/testControlledUnControlled.js +2 -2
  94. package/legacy/tests/describeValue/testPickerActionBar.js +1 -2
  95. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
  96. package/legacy/tests/describeValue/testShortcuts.js +1 -1
  97. package/models/adapters.d.ts +2 -1
  98. package/models/index.d.ts +1 -0
  99. package/models/index.js +2 -1
  100. package/models/pickers.d.ts +9 -0
  101. package/models/pickers.js +1 -0
  102. package/modern/DateCalendar/DateCalendar.js +2 -2
  103. package/modern/DatePicker/DatePicker.js +2 -2
  104. package/modern/DateTimePicker/DateTimePicker.js +2 -2
  105. package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -2
  106. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  107. package/modern/DesktopTimePicker/DesktopTimePicker.js +5 -0
  108. package/modern/DigitalClock/DigitalClock.js +3 -1
  109. package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
  110. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  111. package/modern/MobileTimePicker/MobileTimePicker.js +5 -0
  112. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
  113. package/modern/PickersShortcuts/PickersShortcuts.js +9 -4
  114. package/modern/StaticDatePicker/StaticDatePicker.js +2 -2
  115. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  116. package/modern/StaticTimePicker/StaticTimePicker.js +5 -0
  117. package/modern/TimePicker/TimePicker.js +5 -0
  118. package/modern/YearCalendar/YearCalendar.js +4 -1
  119. package/modern/index.js +1 -1
  120. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
  121. package/modern/internals/components/PickersPopper.js +63 -30
  122. package/modern/internals/components/PickersToolbar.js +9 -12
  123. package/modern/internals/hooks/useDefaultReduceAnimations.js +7 -2
  124. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
  125. package/modern/internals/hooks/useField/useField.utils.js +0 -48
  126. package/modern/internals/hooks/useField/useFieldState.js +4 -24
  127. package/modern/internals/hooks/usePicker/usePickerValue.js +10 -2
  128. package/modern/models/index.js +2 -1
  129. package/modern/models/pickers.js +1 -0
  130. package/modern/tests/describeAdapters/describeAdapters.js +1 -1
  131. package/modern/tests/describeGregorianAdapter/testCalculations.js +1 -1
  132. package/modern/tests/describeGregorianAdapter/testLocalization.js +1 -1
  133. package/modern/tests/describeValidation/testDayViewValidation.js +1 -1
  134. package/modern/tests/describeValidation/testMinutesViewValidation.js +2 -2
  135. package/modern/tests/describeValidation/testMonthViewValidation.js +1 -1
  136. package/modern/tests/describeValidation/testTextFieldValidation.js +1 -1
  137. package/modern/tests/describeValidation/testYearViewValidation.js +1 -1
  138. package/modern/tests/describeValue/describeValue.js +1 -1
  139. package/modern/tests/describeValue/testControlledUnControlled.js +1 -1
  140. package/modern/tests/describeValue/testPickerActionBar.js +1 -2
  141. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
  142. package/modern/tests/describeValue/testShortcuts.js +1 -1
  143. package/node/DateCalendar/DateCalendar.js +2 -2
  144. package/node/DatePicker/DatePicker.js +2 -2
  145. package/node/DateTimePicker/DateTimePicker.js +2 -2
  146. package/node/DesktopDatePicker/DesktopDatePicker.js +2 -2
  147. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  148. package/node/DesktopTimePicker/DesktopTimePicker.js +5 -0
  149. package/node/DigitalClock/DigitalClock.js +3 -1
  150. package/node/MobileDatePicker/MobileDatePicker.js +2 -2
  151. package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  152. package/node/MobileTimePicker/MobileTimePicker.js +5 -0
  153. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
  154. package/node/PickersShortcuts/PickersShortcuts.js +9 -4
  155. package/node/StaticDatePicker/StaticDatePicker.js +2 -2
  156. package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  157. package/node/StaticTimePicker/StaticTimePicker.js +5 -0
  158. package/node/TimePicker/TimePicker.js +5 -0
  159. package/node/YearCalendar/YearCalendar.js +4 -1
  160. package/node/index.js +1 -1
  161. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
  162. package/node/internals/components/PickersPopper.js +63 -30
  163. package/node/internals/components/PickersToolbar.js +9 -12
  164. package/node/internals/hooks/useDefaultReduceAnimations.js +9 -4
  165. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
  166. package/node/internals/hooks/useField/useField.utils.js +1 -50
  167. package/node/internals/hooks/useField/useFieldState.js +3 -23
  168. package/node/internals/hooks/usePicker/usePickerValue.js +10 -2
  169. package/node/models/index.js +11 -0
  170. package/node/models/pickers.js +5 -0
  171. package/node/tests/describeAdapters/describeAdapters.js +3 -3
  172. package/node/tests/describeGregorianAdapter/testCalculations.js +2 -2
  173. package/node/tests/describeGregorianAdapter/testLocalization.js +4 -4
  174. package/node/tests/describeValidation/testDayViewValidation.js +33 -33
  175. package/node/tests/describeValidation/testMinutesViewValidation.js +14 -14
  176. package/node/tests/describeValidation/testMonthViewValidation.js +22 -22
  177. package/node/tests/describeValidation/testTextFieldValidation.js +54 -54
  178. package/node/tests/describeValidation/testYearViewValidation.js +18 -18
  179. package/node/tests/describeValue/describeValue.js +2 -2
  180. package/node/tests/describeValue/testControlledUnControlled.js +3 -3
  181. package/node/tests/describeValue/testPickerActionBar.js +10 -11
  182. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -10
  183. package/node/tests/describeValue/testShortcuts.js +6 -6
  184. package/package.json +3 -3
  185. package/tests/describeAdapters/describeAdapters.js +1 -1
  186. package/tests/describeGregorianAdapter/testCalculations.js +1 -1
  187. package/tests/describeGregorianAdapter/testLocalization.js +1 -1
  188. package/tests/describeValidation/testDayViewValidation.js +1 -1
  189. package/tests/describeValidation/testMinutesViewValidation.js +2 -2
  190. package/tests/describeValidation/testMonthViewValidation.js +1 -1
  191. package/tests/describeValidation/testTextFieldValidation.js +1 -1
  192. package/tests/describeValidation/testYearViewValidation.js +1 -1
  193. package/tests/describeValue/describeValue.js +1 -1
  194. package/tests/describeValue/testControlledUnControlled.js +2 -2
  195. package/tests/describeValue/testPickerActionBar.js +1 -2
  196. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
  197. package/tests/describeValue/testShortcuts.js +1 -1
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import useControlled from '@mui/utils/useControlled';
4
4
  import { useTheme } from '@mui/material/styles';
5
5
  import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
6
- import { addPositionPropertiesToSections, splitFormatIntoSections, clampDaySectionIfPossible, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
6
+ import { addPositionPropertiesToSections, splitFormatIntoSections, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
7
7
  import { useValueWithTimezone } from '../useValueWithTimezone';
8
8
  import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
9
9
  export const useFieldState = params => {
@@ -209,21 +209,7 @@ export const useFieldState = params => {
209
209
  const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
210
210
  const newSections = setSectionValue(selectedSectionIndexes.startIndex, newSectionValue);
211
211
  const newActiveDateSections = activeDateManager.getSections(newSections);
212
- let newActiveDate = getDateFromDateSections(utils, newActiveDateSections);
213
- let shouldRegenSections = false;
214
-
215
- /**
216
- * If the date is invalid,
217
- * Then we can try to clamp the day section to see if that produces a valid date.
218
- * This can be useful if the month has fewer days than the day value currently provided.
219
- */
220
- if (!utils.isValid(newActiveDate)) {
221
- const clampedSections = clampDaySectionIfPossible(utils, timezone, newActiveDateSections, sectionsValueBoundaries);
222
- if (clampedSections != null) {
223
- shouldRegenSections = true;
224
- newActiveDate = getDateFromDateSections(utils, clampedSections);
225
- }
226
- }
212
+ const newActiveDate = getDateFromDateSections(utils, newActiveDateSections);
227
213
  let values;
228
214
  let shouldPublish;
229
215
 
@@ -241,22 +227,16 @@ export const useFieldState = params => {
241
227
  shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));
242
228
  }
243
229
 
244
- /**
245
- * If the value has been modified (to clamp the day).
246
- * Then we need to re-generate the sections to make sure they also have this change.
247
- */
248
- const sections = shouldRegenSections ? getSectionsFromValue(values.value, state.sections) : newSections;
249
-
250
230
  /**
251
231
  * Publish or update the internal state with the new value and sections.
252
232
  */
253
233
  if (shouldPublish) {
254
234
  return publishValue(_extends({}, values, {
255
- sections
235
+ sections: newSections
256
236
  }));
257
237
  }
258
238
  return setState(prevState => _extends({}, prevState, values, {
259
- sections,
239
+ sections: newSections,
260
240
  tempValueStrAndroid: null
261
241
  }));
262
242
  };
@@ -221,6 +221,11 @@ export const usePickerValue = ({
221
221
  const context = {
222
222
  validationError
223
223
  };
224
+
225
+ // TODO v7: Remove 2nd condition
226
+ if (action.name === 'setValueFromShortcut' && action.shortcut != null) {
227
+ context.shortcut = action.shortcut;
228
+ }
224
229
  handleValueChange(action.value, context);
225
230
  }
226
231
  if (shouldCommit && onAccept) {
@@ -283,10 +288,13 @@ export const usePickerValue = ({
283
288
  value: newValue,
284
289
  selectionState
285
290
  }));
286
- const handleSelectShortcut = useEventCallback((newValue, changeImportance) => updateDate({
291
+
292
+ // TODO v7: Make changeImportance and label mandatory.
293
+ const handleSelectShortcut = useEventCallback((newValue, changeImportance, shortcut) => updateDate({
287
294
  name: 'setValueFromShortcut',
288
295
  value: newValue,
289
- changeImportance: changeImportance ?? 'accept'
296
+ changeImportance: changeImportance ?? 'accept',
297
+ shortcut
290
298
  }));
291
299
  const handleChangeFromField = useEventCallback((newValue, context) => updateDate({
292
300
  name: 'setValueFromField',
@@ -3,4 +3,5 @@ export * from './timezone';
3
3
  export * from './validation';
4
4
  export * from './views';
5
5
  export * from './adapters';
6
- export * from './common';
6
+ export * from './common';
7
+ export * from './pickers';
@@ -0,0 +1 @@
1
+ export {};
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import moment from 'moment';
3
3
  import momentTZ from 'moment-timezone';
4
4
  import createDescribe from '@mui/monorepo/test/utils/createDescribe';
5
- import { buildFieldInteractions, createPickerRenderer } from 'test/utils/pickers-utils';
5
+ import { buildFieldInteractions, createPickerRenderer } from 'test/utils/pickers';
6
6
  const ADAPTERS = ['dayjs', 'date-fns', 'luxon', 'moment'];
7
7
  function innerDescribeAdapters(title, FieldComponent, testRunner) {
8
8
  ADAPTERS.forEach(adapterName => {
@@ -1,5 +1,5 @@
1
1
  import { expect } from 'chai';
2
- import { getDateOffset } from 'test/utils/pickers-utils';
2
+ import { getDateOffset } from 'test/utils/pickers';
3
3
  import { TEST_DATE_ISO_STRING, TEST_DATE_LOCALE_STRING } from './describeGregorianAdapter.utils';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai';
2
2
  import { stub } from 'sinon';
3
- import { cleanText } from 'test/utils/pickers-utils';
3
+ import { cleanText } from 'test/utils/pickers';
4
4
  import { TEST_DATE_ISO_STRING } from './describeGregorianAdapter.utils';
5
5
  export const testLocalization = ({
6
6
  adapter
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { expect } from 'chai';
3
3
  import * as React from 'react';
4
4
  import { screen } from '@mui/monorepo/test/utils';
5
- import { adapterToUse } from 'test/utils/pickers-utils';
5
+ import { adapterToUse } from 'test/utils/pickers';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const testDayViewValidation = (ElementToTest, getOptions) => {
8
8
  const {
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { expect } from 'chai';
3
2
  import * as React from 'react';
3
+ import { expect } from 'chai';
4
4
  import { screen } from '@mui/monorepo/test/utils';
5
- import { adapterToUse } from 'test/utils/pickers-utils';
5
+ import { adapterToUse } from 'test/utils/pickers';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const toMinutesLabel = minutes => `${Number(minutes) < 10 ? `0${minutes}` : minutes} minutes`;
8
8
  export const testMinutesViewValidation = (ElementToTest, getOption) => {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { expect } from 'chai';
3
3
  import * as React from 'react';
4
4
  import { screen } from '@mui/monorepo/test/utils';
5
- import { adapterToUse } from 'test/utils/pickers-utils';
5
+ import { adapterToUse } from 'test/utils/pickers';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const testMonthViewValidation = (ElementToTest, getOptions) => {
8
8
  const {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { expect } from 'chai';
4
4
  import { spy } from 'sinon';
5
5
  import { screen } from '@mui/monorepo/test/utils';
6
- import { adapterToUse } from 'test/utils/pickers-utils';
6
+ import { adapterToUse } from 'test/utils/pickers';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export const testTextFieldValidation = (ElementToTest, getOptions) => {
9
9
  const {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { expect } from 'chai';
4
4
  import { screen } from '@mui/monorepo/test/utils';
5
- import { adapterToUse } from 'test/utils/pickers-utils';
5
+ import { adapterToUse } from 'test/utils/pickers';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const testYearViewValidation = (ElementToTest, getOptions) => {
8
8
  const {
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["hook"];
4
4
  import * as React from 'react';
5
5
  import createDescribe from '@mui/monorepo/test/utils/createDescribe';
6
- import { buildFieldInteractions } from 'test/utils/pickers-utils';
6
+ import { buildFieldInteractions } from 'test/utils/pickers';
7
7
  import { testControlledUnControlled } from './testControlledUnControlled';
8
8
  import { testPickerOpenCloseLifeCycle } from './testPickerOpenCloseLifeCycle';
9
9
  import { testPickerActionBar } from './testPickerActionBar';
@@ -6,7 +6,7 @@ import { expect } from 'chai';
6
6
  import { spy } from 'sinon';
7
7
  import { screen, act, userEvent } from '@mui/monorepo/test/utils';
8
8
  import { inputBaseClasses } from '@mui/material/InputBase';
9
- import { getExpectedOnChangeCount } from 'test/utils/pickers-utils';
9
+ import { getExpectedOnChangeCount } from 'test/utils/pickers';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  export const testControlledUnControlled = (ElementToTest, options) => {
@@ -4,8 +4,7 @@ import * as React from 'react';
4
4
  import { expect } from 'chai';
5
5
  import { spy } from 'sinon';
6
6
  import { screen, userEvent } from '@mui/monorepo/test/utils';
7
- import { adapterToUse, getExpectedOnChangeCount } from 'test/utils/pickers-utils';
8
- import { expectPickerChangeHandlerValue } from 'test/utils/pickers/assertions';
7
+ import { adapterToUse, getExpectedOnChangeCount, expectPickerChangeHandlerValue } from 'test/utils/pickers';
9
8
  import { jsx as _jsx } from "react/jsx-runtime";
10
9
  export const testPickerActionBar = (ElementToTest, options) => {
11
10
  const {
@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
  import { expect } from 'chai';
5
5
  import { spy } from 'sinon';
6
6
  import { screen, userEvent } from '@mui/monorepo/test/utils';
7
- import { getExpectedOnChangeCount, getTextbox, openPicker } from 'test/utils/pickers-utils';
7
+ import { getExpectedOnChangeCount, getTextbox, openPicker } from 'test/utils/pickers';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export const testPickerOpenCloseLifeCycle = (ElementToTest, options) => {
10
10
  const {
@@ -3,7 +3,7 @@ const _excluded = ["componentFamily", "render", "renderWithProps", "values", "em
3
3
  import * as React from 'react';
4
4
  import { expect } from 'chai';
5
5
  import { spy } from 'sinon';
6
- import { expectPickerChangeHandlerValue } from 'test/utils/pickers/assertions';
6
+ import { expectPickerChangeHandlerValue } from 'test/utils/pickers';
7
7
  import { userEvent, screen } from '@mui/monorepo/test/utils';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export const testShortcuts = (ElementToTest, options) => {
@@ -493,8 +493,8 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
493
493
  */
494
494
  readOnly: _propTypes.default.bool,
495
495
  /**
496
- * Disable heavy animations.
497
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
496
+ * If `true`, disable heavy animations.
497
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
498
498
  */
499
499
  reduceAnimations: _propTypes.default.bool,
500
500
  /**
@@ -251,8 +251,8 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
251
251
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
252
252
  readOnly: _propTypes.default.bool,
253
253
  /**
254
- * Disable heavy animations.
255
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
254
+ * If `true`, disable heavy animations.
255
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
256
256
  */
257
257
  reduceAnimations: _propTypes.default.bool,
258
258
  /**
@@ -289,8 +289,8 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
289
289
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
290
290
  readOnly: _propTypes.default.bool,
291
291
  /**
292
- * Disable heavy animations.
293
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
292
+ * If `true`, disable heavy animations.
293
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
294
294
  */
295
295
  reduceAnimations: _propTypes.default.bool,
296
296
  /**
@@ -265,8 +265,8 @@ DesktopDatePicker.propTypes = {
265
265
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
266
266
  readOnly: _propTypes.default.bool,
267
267
  /**
268
- * Disable heavy animations.
269
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
268
+ * If `true`, disable heavy animations.
269
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
270
270
  */
271
271
  reduceAnimations: _propTypes.default.bool,
272
272
  /**
@@ -339,8 +339,8 @@ DesktopDateTimePicker.propTypes = {
339
339
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
340
340
  readOnly: _propTypes.default.bool,
341
341
  /**
342
- * Disable heavy animations.
343
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
342
+ * If `true`, disable heavy animations.
343
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
344
344
  */
345
345
  reduceAnimations: _propTypes.default.bool,
346
346
  /**
@@ -260,6 +260,11 @@ DesktopTimePicker.propTypes = {
260
260
  */
261
261
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
262
262
  readOnly: _propTypes.default.bool,
263
+ /**
264
+ * If `true`, disable heavy animations.
265
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
266
+ */
267
+ reduceAnimations: _propTypes.default.bool,
263
268
  /**
264
269
  * The currently selected sections.
265
270
  * This prop accept four formats:
@@ -50,7 +50,9 @@ const DigitalClockRoot = (0, _styles.styled)(_PickerViewRoot.PickerViewRoot, {
50
50
  }) => ({
51
51
  overflowY: 'auto',
52
52
  width: '100%',
53
- scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto',
53
+ '@media (prefers-reduced-motion: no-preference)': {
54
+ scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
55
+ },
54
56
  maxHeight: _dimensions.DIGITAL_CLOCK_VIEW_HEIGHT
55
57
  }));
56
58
  const DigitalClockList = (0, _styles.styled)(_MenuList.default, {
@@ -262,8 +262,8 @@ MobileDatePicker.propTypes = {
262
262
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
263
263
  readOnly: _propTypes.default.bool,
264
264
  /**
265
- * Disable heavy animations.
266
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
265
+ * If `true`, disable heavy animations.
266
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
267
267
  */
268
268
  reduceAnimations: _propTypes.default.bool,
269
269
  /**
@@ -311,8 +311,8 @@ MobileDateTimePicker.propTypes = {
311
311
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
312
312
  readOnly: _propTypes.default.bool,
313
313
  /**
314
- * Disable heavy animations.
315
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
314
+ * If `true`, disable heavy animations.
315
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
316
316
  */
317
317
  reduceAnimations: _propTypes.default.bool,
318
318
  /**
@@ -238,6 +238,11 @@ MobileTimePicker.propTypes = {
238
238
  */
239
239
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
240
240
  readOnly: _propTypes.default.bool,
241
+ /**
242
+ * If `true`, disable heavy animations.
243
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
244
+ */
245
+ reduceAnimations: _propTypes.default.bool,
241
246
  /**
242
247
  * The currently selected sections.
243
248
  * This prop accept four formats:
@@ -42,7 +42,9 @@ const MultiSectionDigitalClockSectionRoot = (0, _styles.styled)(_MenuList.defaul
42
42
  width: 56,
43
43
  padding: 0,
44
44
  overflow: 'hidden',
45
- scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto',
45
+ '@media (prefers-reduced-motion: no-preference)': {
46
+ scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
47
+ },
46
48
  '&:hover': {
47
49
  overflowY: 'auto'
48
50
  },
@@ -14,7 +14,8 @@ var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
14
14
  var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
15
15
  var _dimensions = require("../internals/constants/dimensions");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"];
17
+ const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"],
18
+ _excluded2 = ["getValue"];
18
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
21
  function PickersShortcuts(props) {
@@ -28,14 +29,18 @@ function PickersShortcuts(props) {
28
29
  if (items == null || items.length === 0) {
29
30
  return null;
30
31
  }
31
- const resolvedItems = items.map(item => {
32
- const newValue = item.getValue({
32
+ const resolvedItems = items.map(_ref => {
33
+ let {
34
+ getValue
35
+ } = _ref,
36
+ item = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
37
+ const newValue = getValue({
33
38
  isValid
34
39
  });
35
40
  return {
36
41
  label: item.label,
37
42
  onClick: () => {
38
- onChange(newValue, changeImportance);
43
+ onChange(newValue, changeImportance, item);
39
44
  },
40
45
  disabled: !isValid(newValue)
41
46
  };
@@ -210,8 +210,8 @@ StaticDatePicker.propTypes = {
210
210
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
211
211
  readOnly: _propTypes.default.bool,
212
212
  /**
213
- * Disable heavy animations.
214
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
213
+ * If `true`, disable heavy animations.
214
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
215
215
  */
216
216
  reduceAnimations: _propTypes.default.bool,
217
217
  /**
@@ -258,8 +258,8 @@ StaticDateTimePicker.propTypes = {
258
258
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
259
259
  readOnly: _propTypes.default.bool,
260
260
  /**
261
- * Disable heavy animations.
262
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
261
+ * If `true`, disable heavy animations.
262
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
263
263
  */
264
264
  reduceAnimations: _propTypes.default.bool,
265
265
  /**
@@ -184,6 +184,11 @@ StaticTimePicker.propTypes = {
184
184
  */
185
185
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
186
186
  readOnly: _propTypes.default.bool,
187
+ /**
188
+ * If `true`, disable heavy animations.
189
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
190
+ */
191
+ reduceAnimations: _propTypes.default.bool,
187
192
  /**
188
193
  * Disable specific clock time.
189
194
  * @param {number} clockValue The value to check.
@@ -223,6 +223,11 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
223
223
  */
224
224
  orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
225
225
  readOnly: _propTypes.default.bool,
226
+ /**
227
+ * If `true`, disable heavy animations.
228
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
229
+ */
230
+ reduceAnimations: _propTypes.default.bool,
226
231
  /**
227
232
  * The currently selected sections.
228
233
  * This prop accept four formats:
@@ -60,7 +60,10 @@ const YearCalendarRoot = (0, _styles.styled)('div', {
60
60
  height: '100%',
61
61
  padding: '0 4px',
62
62
  width: 320,
63
- maxHeight: 304
63
+ maxHeight: 304,
64
+ // avoid padding increasing width over defined
65
+ boxSizing: 'border-box',
66
+ position: 'relative'
64
67
  });
65
68
  const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
66
69
  const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.11.1
2
+ * @mui/x-date-pickers v6.12.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -94,21 +94,20 @@ const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrow
94
94
  goTo: onGoToPrevious,
95
95
  label: previousLabel
96
96
  };
97
- const [leftProps, rightProps] = isRTL ? [nextProps, previousProps] : [previousProps, nextProps];
98
97
  const PreviousIconButton = slots?.previousIconButton ?? PickersArrowSwitcherButton;
99
98
  const previousIconButtonProps = (0, _utils2.useSlotProps)({
100
99
  elementType: PreviousIconButton,
101
100
  externalSlotProps: slotProps?.previousIconButton,
102
101
  additionalProps: {
103
102
  size: 'medium',
104
- title: leftProps.label,
105
- 'aria-label': leftProps.label,
106
- disabled: leftProps.isDisabled,
103
+ title: previousProps.label,
104
+ 'aria-label': previousProps.label,
105
+ disabled: previousProps.isDisabled,
107
106
  edge: 'end',
108
- onClick: leftProps.goTo
107
+ onClick: previousProps.goTo
109
108
  },
110
109
  ownerState: (0, _extends2.default)({}, ownerState, {
111
- hidden: leftProps.isHidden
110
+ hidden: previousProps.isHidden
112
111
  }),
113
112
  className: classes.button
114
113
  });
@@ -118,14 +117,14 @@ const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrow
118
117
  externalSlotProps: slotProps?.nextIconButton,
119
118
  additionalProps: {
120
119
  size: 'medium',
121
- title: rightProps.label,
122
- 'aria-label': rightProps.label,
123
- disabled: rightProps.isDisabled,
120
+ title: nextProps.label,
121
+ 'aria-label': nextProps.label,
122
+ disabled: nextProps.isDisabled,
124
123
  edge: 'start',
125
- onClick: rightProps.goTo
124
+ onClick: nextProps.goTo
126
125
  },
127
126
  ownerState: (0, _extends2.default)({}, ownerState, {
128
- hidden: rightProps.isHidden
127
+ hidden: nextProps.isHidden
129
128
  }),
130
129
  className: classes.button
131
130
  });