@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 @@ var _excluded = ["componentFamily", "render", "renderWithProps", "values", "empt
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 var testShortcuts = function testShortcuts(ElementToTest, options) {
@@ -171,6 +171,7 @@ export type AdapterOptions<TLocale, TInstance> = {
171
171
  formats?: Partial<AdapterFormats>;
172
172
  locale?: TLocale;
173
173
  } & PropertyIfNotNever<'instance', TInstance>;
174
+ export type DateBuilderReturnType<T extends string | null | undefined, TDate> = T extends null ? null : TDate;
174
175
  export interface MuiPickersAdapter<TDate, TLocale = any> {
175
176
  /**
176
177
  * A boolean confirming that the adapter used is an MUI adapter.
@@ -212,7 +213,7 @@ export interface MuiPickersAdapter<TDate, TLocale = any> {
212
213
  * @param {PickersTimezone} timezone The timezone of the date.
213
214
  * @returns {TDate | null} The parsed date.
214
215
  */
215
- dateWithTimezone(value: string | null | undefined, timezone: PickersTimezone): TDate | null;
216
+ dateWithTimezone<T extends string | null | undefined>(value: T, timezone: PickersTimezone): DateBuilderReturnType<T, TDate>;
216
217
  /**
217
218
  * Extracts the timezone from a date.
218
219
  * @template TDate
package/models/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './validation';
4
4
  export * from './views';
5
5
  export * from './adapters';
6
6
  export * from './common';
7
+ export * from './pickers';
package/models/index.js CHANGED
@@ -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,9 @@
1
+ import type { PickersShortcutsItemContext } from '../PickersShortcuts';
2
+ export interface PickerChangeHandlerContext<TError> {
3
+ validationError: TError;
4
+ /**
5
+ * Shortcut causing this `onChange` call.
6
+ * If the call has not been caused by a shortcut selection, this property will be `undefined`.
7
+ */
8
+ shortcut?: PickersShortcutsItemContext;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -484,8 +484,8 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
484
484
  */
485
485
  readOnly: PropTypes.bool,
486
486
  /**
487
- * Disable heavy animations.
488
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
487
+ * If `true`, disable heavy animations.
488
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
489
489
  */
490
490
  reduceAnimations: PropTypes.bool,
491
491
  /**
@@ -241,8 +241,8 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
241
241
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
242
242
  readOnly: PropTypes.bool,
243
243
  /**
244
- * Disable heavy animations.
245
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
244
+ * If `true`, disable heavy animations.
245
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
246
246
  */
247
247
  reduceAnimations: PropTypes.bool,
248
248
  /**
@@ -279,8 +279,8 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
279
279
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
280
280
  readOnly: PropTypes.bool,
281
281
  /**
282
- * Disable heavy animations.
283
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
282
+ * If `true`, disable heavy animations.
283
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
284
284
  */
285
285
  reduceAnimations: PropTypes.bool,
286
286
  /**
@@ -255,8 +255,8 @@ DesktopDatePicker.propTypes = {
255
255
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
256
256
  readOnly: PropTypes.bool,
257
257
  /**
258
- * Disable heavy animations.
259
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
258
+ * If `true`, disable heavy animations.
259
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
260
260
  */
261
261
  reduceAnimations: PropTypes.bool,
262
262
  /**
@@ -329,8 +329,8 @@ DesktopDateTimePicker.propTypes = {
329
329
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
330
330
  readOnly: PropTypes.bool,
331
331
  /**
332
- * Disable heavy animations.
333
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
332
+ * If `true`, disable heavy animations.
333
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
334
334
  */
335
335
  reduceAnimations: PropTypes.bool,
336
336
  /**
@@ -250,6 +250,11 @@ DesktopTimePicker.propTypes = {
250
250
  */
251
251
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
252
252
  readOnly: PropTypes.bool,
253
+ /**
254
+ * If `true`, disable heavy animations.
255
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
256
+ */
257
+ reduceAnimations: PropTypes.bool,
253
258
  /**
254
259
  * The currently selected sections.
255
260
  * This prop accept four formats:
@@ -41,7 +41,9 @@ const DigitalClockRoot = styled(PickerViewRoot, {
41
41
  }) => ({
42
42
  overflowY: 'auto',
43
43
  width: '100%',
44
- scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto',
44
+ '@media (prefers-reduced-motion: no-preference)': {
45
+ scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
46
+ },
45
47
  maxHeight: DIGITAL_CLOCK_VIEW_HEIGHT
46
48
  }));
47
49
  const DigitalClockList = styled(MenuList, {
@@ -252,8 +252,8 @@ MobileDatePicker.propTypes = {
252
252
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
253
253
  readOnly: PropTypes.bool,
254
254
  /**
255
- * Disable heavy animations.
256
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
255
+ * If `true`, disable heavy animations.
256
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
257
257
  */
258
258
  reduceAnimations: PropTypes.bool,
259
259
  /**
@@ -301,8 +301,8 @@ MobileDateTimePicker.propTypes = {
301
301
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
302
302
  readOnly: PropTypes.bool,
303
303
  /**
304
- * Disable heavy animations.
305
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
304
+ * If `true`, disable heavy animations.
305
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
306
306
  */
307
307
  reduceAnimations: PropTypes.bool,
308
308
  /**
@@ -228,6 +228,11 @@ MobileTimePicker.propTypes = {
228
228
  */
229
229
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
230
230
  readOnly: PropTypes.bool,
231
+ /**
232
+ * If `true`, disable heavy animations.
233
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
234
+ */
235
+ reduceAnimations: PropTypes.bool,
231
236
  /**
232
237
  * The currently selected sections.
233
238
  * This prop accept four formats:
@@ -33,7 +33,9 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
33
33
  width: 56,
34
34
  padding: 0,
35
35
  overflow: 'hidden',
36
- scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto',
36
+ '@media (prefers-reduced-motion: no-preference)': {
37
+ scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
38
+ },
37
39
  '&:hover': {
38
40
  overflowY: 'auto'
39
41
  },
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"];
3
+ const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"],
4
+ _excluded2 = ["getValue"];
4
5
  import * as React from 'react';
5
6
  import PropTypes from 'prop-types';
6
7
  import List from '@mui/material/List';
@@ -19,14 +20,18 @@ function PickersShortcuts(props) {
19
20
  if (items == null || items.length === 0) {
20
21
  return null;
21
22
  }
22
- const resolvedItems = items.map(item => {
23
- const newValue = item.getValue({
23
+ const resolvedItems = items.map(_ref => {
24
+ let {
25
+ getValue
26
+ } = _ref,
27
+ item = _objectWithoutPropertiesLoose(_ref, _excluded2);
28
+ const newValue = getValue({
24
29
  isValid
25
30
  });
26
31
  return {
27
32
  label: item.label,
28
33
  onClick: () => {
29
- onChange(newValue, changeImportance);
34
+ onChange(newValue, changeImportance, item);
30
35
  },
31
36
  disabled: !isValid(newValue)
32
37
  };
@@ -200,8 +200,8 @@ StaticDatePicker.propTypes = {
200
200
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
201
201
  readOnly: PropTypes.bool,
202
202
  /**
203
- * Disable heavy animations.
204
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
203
+ * If `true`, disable heavy animations.
204
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
205
205
  */
206
206
  reduceAnimations: PropTypes.bool,
207
207
  /**
@@ -248,8 +248,8 @@ StaticDateTimePicker.propTypes = {
248
248
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
249
249
  readOnly: PropTypes.bool,
250
250
  /**
251
- * Disable heavy animations.
252
- * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
251
+ * If `true`, disable heavy animations.
252
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
253
253
  */
254
254
  reduceAnimations: PropTypes.bool,
255
255
  /**
@@ -174,6 +174,11 @@ StaticTimePicker.propTypes = {
174
174
  */
175
175
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
176
176
  readOnly: PropTypes.bool,
177
+ /**
178
+ * If `true`, disable heavy animations.
179
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
180
+ */
181
+ reduceAnimations: PropTypes.bool,
177
182
  /**
178
183
  * Disable specific clock time.
179
184
  * @param {number} clockValue The value to check.
@@ -213,6 +213,11 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
213
213
  */
214
214
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
215
215
  readOnly: PropTypes.bool,
216
+ /**
217
+ * If `true`, disable heavy animations.
218
+ * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
219
+ */
220
+ reduceAnimations: PropTypes.bool,
216
221
  /**
217
222
  * The currently selected sections.
218
223
  * This prop accept four formats:
@@ -51,7 +51,10 @@ const YearCalendarRoot = styled('div', {
51
51
  height: '100%',
52
52
  padding: '0 4px',
53
53
  width: 320,
54
- maxHeight: 304
54
+ maxHeight: 304,
55
+ // avoid padding increasing width over defined
56
+ boxSizing: 'border-box',
57
+ position: 'relative'
55
58
  });
56
59
  export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
57
60
  const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
package/modern/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
@@ -86,21 +86,20 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
86
86
  goTo: onGoToPrevious,
87
87
  label: previousLabel
88
88
  };
89
- const [leftProps, rightProps] = isRTL ? [nextProps, previousProps] : [previousProps, nextProps];
90
89
  const PreviousIconButton = slots?.previousIconButton ?? PickersArrowSwitcherButton;
91
90
  const previousIconButtonProps = useSlotProps({
92
91
  elementType: PreviousIconButton,
93
92
  externalSlotProps: slotProps?.previousIconButton,
94
93
  additionalProps: {
95
94
  size: 'medium',
96
- title: leftProps.label,
97
- 'aria-label': leftProps.label,
98
- disabled: leftProps.isDisabled,
95
+ title: previousProps.label,
96
+ 'aria-label': previousProps.label,
97
+ disabled: previousProps.isDisabled,
99
98
  edge: 'end',
100
- onClick: leftProps.goTo
99
+ onClick: previousProps.goTo
101
100
  },
102
101
  ownerState: _extends({}, ownerState, {
103
- hidden: leftProps.isHidden
102
+ hidden: previousProps.isHidden
104
103
  }),
105
104
  className: classes.button
106
105
  });
@@ -110,14 +109,14 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
110
109
  externalSlotProps: slotProps?.nextIconButton,
111
110
  additionalProps: {
112
111
  size: 'medium',
113
- title: rightProps.label,
114
- 'aria-label': rightProps.label,
115
- disabled: rightProps.isDisabled,
112
+ title: nextProps.label,
113
+ 'aria-label': nextProps.label,
114
+ disabled: nextProps.isDisabled,
116
115
  edge: 'start',
117
- onClick: rightProps.goTo
116
+ onClick: nextProps.goTo
118
117
  },
119
118
  ownerState: _extends({}, ownerState, {
120
- hidden: rightProps.isHidden
119
+ hidden: nextProps.isHidden
121
120
  }),
122
121
  className: classes.button
123
122
  });
@@ -1,7 +1,10 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
1
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["PaperComponent", "popperPlacement", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
2
4
  import * as React from 'react';
3
5
  import { useSlotProps } from '@mui/base/utils';
4
6
  import Grow from '@mui/material/Grow';
7
+ import Fade from '@mui/material/Fade';
5
8
  import MuiPaper from '@mui/material/Paper';
6
9
  import MuiPopper from '@mui/material/Popper';
7
10
  import MuiTrapFocus from '@mui/material/Unstable_TrapFocus';
@@ -9,6 +12,7 @@ import { unstable_useForkRef as useForkRef, unstable_useEventCallback as useEven
9
12
  import { styled, useThemeProps } from '@mui/material/styles';
10
13
  import { getPickersPopperUtilityClass } from './pickersPopperClasses';
11
14
  import { getActiveElement } from '../utils/utils';
15
+ import { useDefaultReduceAnimations } from '../hooks/useDefaultReduceAnimations';
12
16
  import { jsx as _jsx } from "react/jsx-runtime";
13
17
  const useUtilityClasses = ownerState => {
14
18
  const {
@@ -36,9 +40,9 @@ const PickersPopperPaper = styled(MuiPaper, {
36
40
  })(({
37
41
  ownerState
38
42
  }) => _extends({
39
- transformOrigin: 'top center',
40
- outline: 0
41
- }, ownerState.placement === 'top' && {
43
+ outline: 0,
44
+ transformOrigin: 'top center'
45
+ }, ownerState.placement.includes('top') && {
42
46
  transformOrigin: 'bottom center'
43
47
  }));
44
48
  function clickedRootScrollbar(event, doc) {
@@ -156,6 +160,47 @@ function useClickAwayListener(active, onClickAway) {
156
160
  }, [active, handleClickAway]);
157
161
  return [nodeRef, handleSynthetic, handleSynthetic];
158
162
  }
163
+ const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
164
+ const {
165
+ PaperComponent,
166
+ popperPlacement,
167
+ ownerState: inOwnerState,
168
+ children,
169
+ paperSlotProps,
170
+ paperClasses,
171
+ onPaperClick,
172
+ onPaperTouchStart
173
+ // picks up the style props provided by `Transition`
174
+ // https://mui.com/material-ui/transitions/#child-requirement
175
+ } = props,
176
+ other = _objectWithoutPropertiesLoose(props, _excluded);
177
+ const ownerState = _extends({}, inOwnerState, {
178
+ placement: popperPlacement
179
+ });
180
+ const paperProps = useSlotProps({
181
+ elementType: PaperComponent,
182
+ externalSlotProps: paperSlotProps,
183
+ additionalProps: {
184
+ tabIndex: -1,
185
+ elevation: 8,
186
+ ref
187
+ },
188
+ className: paperClasses,
189
+ ownerState
190
+ });
191
+ return /*#__PURE__*/_jsx(PaperComponent, _extends({}, other, paperProps, {
192
+ onClick: event => {
193
+ onPaperClick(event);
194
+ paperProps.onClick?.(event);
195
+ },
196
+ onTouchStart: event => {
197
+ onPaperTouchStart(event);
198
+ paperProps.onTouchStart?.(event);
199
+ },
200
+ ownerState: ownerState,
201
+ children: children
202
+ }));
203
+ });
159
204
  export function PickersPopper(inProps) {
160
205
  const props = useThemeProps({
161
206
  props: inProps,
@@ -172,7 +217,8 @@ export function PickersPopper(inProps) {
172
217
  role,
173
218
  placement,
174
219
  slots,
175
- slotProps
220
+ slotProps,
221
+ reduceAnimations: inReduceAnimations
176
222
  } = props;
177
223
  React.useEffect(() => {
178
224
  function handleKeyDown(nativeEvent) {
@@ -209,6 +255,8 @@ export function PickersPopper(inProps) {
209
255
  const handlePaperRef = useForkRef(handleRef, clickAwayRef);
210
256
  const ownerState = props;
211
257
  const classes = useUtilityClasses(ownerState);
258
+ const defaultReduceAnimations = useDefaultReduceAnimations();
259
+ const reduceAnimations = inReduceAnimations ?? defaultReduceAnimations;
212
260
  const handleKeyDown = event => {
213
261
  if (event.key === 'Escape') {
214
262
  // stop the propagation to avoid closing parent modal
@@ -216,21 +264,9 @@ export function PickersPopper(inProps) {
216
264
  onDismiss();
217
265
  }
218
266
  };
219
- const Transition = slots?.desktopTransition ?? Grow;
267
+ const Transition = slots?.desktopTransition ?? reduceAnimations ? Fade : Grow;
220
268
  const TrapFocus = slots?.desktopTrapFocus ?? MuiTrapFocus;
221
269
  const Paper = slots?.desktopPaper ?? PickersPopperPaper;
222
- const paperProps = useSlotProps({
223
- elementType: Paper,
224
- externalSlotProps: slotProps?.desktopPaper,
225
- additionalProps: {
226
- tabIndex: -1,
227
- elevation: 8,
228
- ref: handlePaperRef
229
- },
230
- className: classes.paper,
231
- ownerState: {} // Is overridden below to use `placement
232
- });
233
-
234
270
  const Popper = slots?.popper ?? PickersPopperRoot;
235
271
  const popperProps = useSlotProps({
236
272
  elementType: Popper,
@@ -262,20 +298,17 @@ export function PickersPopper(inProps) {
262
298
  isEnabled: () => true
263
299
  }, slotProps?.desktopTrapFocus, {
264
300
  children: /*#__PURE__*/_jsx(Transition, _extends({}, TransitionProps, slotProps?.desktopTransition, {
265
- children: /*#__PURE__*/_jsx(Paper, _extends({}, paperProps, {
266
- onClick: event => {
267
- onPaperClick(event);
268
- paperProps.onClick?.(event);
269
- },
270
- onTouchStart: event => {
271
- onPaperTouchStart(event);
272
- paperProps.onTouchStart?.(event);
273
- },
274
- ownerState: _extends({}, ownerState, {
275
- placement: popperPlacement
276
- }),
301
+ children: /*#__PURE__*/_jsx(PickersPopperPaperWrapper, {
302
+ PaperComponent: Paper,
303
+ ownerState: ownerState,
304
+ popperPlacement: popperPlacement,
305
+ ref: handlePaperRef,
306
+ onPaperClick: onPaperClick,
307
+ onPaperTouchStart: onPaperTouchStart,
308
+ paperClasses: classes.paper,
309
+ paperSlotProps: slotProps?.desktopPaper,
277
310
  children: children
278
- }))
311
+ })
279
312
  }))
280
313
  }))
281
314
  }));
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import clsx from 'clsx';
4
- import Grid from '@mui/material/Grid';
5
4
  import Typography from '@mui/material/Typography';
6
5
  import { styled, useThemeProps } from '@mui/material/styles';
7
6
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
@@ -40,16 +39,20 @@ const PickersToolbarRoot = styled('div', {
40
39
  justifyContent: 'flex-start',
41
40
  flexWrap: 'wrap'
42
41
  }));
43
- const PickersToolbarContent = styled(Grid, {
42
+ const PickersToolbarContent = styled('div', {
44
43
  name: 'MuiPickersToolbar',
45
44
  slot: 'Content',
46
45
  overridesResolver: (props, styles) => styles.content
47
46
  })(({
48
47
  ownerState
49
- }) => _extends({
50
- flex: 1
51
- }, !ownerState.isLandscape && {
52
- alignItems: 'center'
48
+ }) => ({
49
+ display: 'flex',
50
+ flexWrap: 'wrap',
51
+ width: '100%',
52
+ justifyContent: ownerState.isLandscape ? 'flex-start' : 'space-between',
53
+ flexDirection: ownerState.isLandscape ? ownerState.landscapeDirection ?? 'column' : 'row',
54
+ flex: 1,
55
+ alignItems: ownerState.isLandscape ? 'flex-start' : 'center'
53
56
  }));
54
57
  export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersToolbar(inProps, ref) {
55
58
  const props = useThemeProps({
@@ -59,8 +62,6 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
59
62
  const {
60
63
  children,
61
64
  className,
62
- isLandscape,
63
- landscapeDirection = 'column',
64
65
  toolbarTitle,
65
66
  hidden,
66
67
  titleId
@@ -80,12 +81,8 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
80
81
  id: titleId,
81
82
  children: toolbarTitle
82
83
  }), /*#__PURE__*/_jsx(PickersToolbarContent, {
83
- container: true,
84
- justifyContent: isLandscape ? 'flex-start' : 'space-between',
85
84
  className: classes.content,
86
85
  ownerState: ownerState,
87
- direction: isLandscape ? landscapeDirection : 'row',
88
- alignItems: isLandscape ? 'flex-start' : 'flex-end',
89
86
  children: children
90
87
  })]
91
88
  });
@@ -1,9 +1,14 @@
1
1
  import useMediaQuery from '@mui/material/useMediaQuery';
2
2
  const PREFERS_REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
3
- export const defaultReduceAnimations = typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent);
3
+
4
+ // detect if user agent has Android version < 10 or iOS version < 13
5
+ const mobileVersionMatches = typeof navigator !== 'undefined' && navigator.userAgent.match(/android\s(\d+)|OS\s(\d+)/i);
6
+ const androidVersion = mobileVersionMatches && mobileVersionMatches[1] ? parseInt(mobileVersionMatches[1], 10) : null;
7
+ const iOSVersion = mobileVersionMatches && mobileVersionMatches[2] ? parseInt(mobileVersionMatches[2], 10) : null;
8
+ export const slowAnimationDevices = androidVersion && androidVersion < 10 || iOSVersion && iOSVersion < 13 || false;
4
9
  export const useDefaultReduceAnimations = () => {
5
10
  const prefersReduced = useMediaQuery(PREFERS_REDUCED_MOTION, {
6
11
  defaultMatches: false
7
12
  });
8
- return prefersReduced || defaultReduceAnimations;
13
+ return prefersReduced || slowAnimationDevices;
9
14
  };
@@ -41,7 +41,8 @@ export const useDesktopPicker = _ref => {
41
41
  readOnly,
42
42
  disabled,
43
43
  autoFocus,
44
- localeText
44
+ localeText,
45
+ reduceAnimations
45
46
  } = props;
46
47
  const utils = useUtils();
47
48
  const internalInputRef = React.useRef(null);
@@ -79,7 +80,7 @@ export const useDesktopPicker = _ref => {
79
80
  externalSlotProps: innerSlotProps?.openPickerButton,
80
81
  additionalProps: {
81
82
  disabled: disabled || readOnly,
82
- onClick: actions.onOpen,
83
+ onClick: open ? actions.onClose : actions.onOpen,
83
84
  'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils),
84
85
  edge: inputAdornmentProps.position
85
86
  },
@@ -155,6 +156,7 @@ export const useDesktopPicker = _ref => {
155
156
  slots: slots,
156
157
  slotProps: slotProps,
157
158
  shouldRestoreFocus: shouldRestoreFocus,
159
+ reduceAnimations: reduceAnimations,
158
160
  children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
159
161
  slots: slots,
160
162
  slotProps: slotProps,
@@ -645,54 +645,6 @@ export const mergeDateIntoReferenceDate = (utils, timezone, dateToTransferFrom,
645
645
  return mergedDate;
646
646
  }, referenceDate);
647
647
  export const isAndroid = () => navigator.userAgent.toLowerCase().indexOf('android') > -1;
648
- export const clampDaySectionIfPossible = (utils, timezone, sections, sectionsValueBoundaries) => {
649
- // We can only clamp the day value if:
650
- // 1. if all the sections are filled (except the week day section which can be empty)
651
- // 2. there is a day section
652
- const canClamp = sections.every(section => section.type === 'weekDay' || section.value !== '') && sections.some(section => section.type === 'day');
653
- if (!canClamp) {
654
- return null;
655
- }
656
-
657
- // We try to generate a valid date representing the start of the month of the invalid date typed by the user.
658
- const sectionsForStartOfMonth = sections.map(section => {
659
- if (section.type !== 'day') {
660
- return section;
661
- }
662
- const dayBoundaries = sectionsValueBoundaries.day({
663
- currentDate: null,
664
- format: section.format,
665
- contentType: section.contentType
666
- });
667
- return _extends({}, section, {
668
- value: cleanDigitSectionValue(utils, timezone, dayBoundaries.minimum, dayBoundaries, section)
669
- });
670
- });
671
- const startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
672
-
673
- // Even the start of the month is invalid, we probably have other invalid sections, the clamping failed.
674
- if (startOfMonth == null || !utils.isValid(startOfMonth)) {
675
- return null;
676
- }
677
-
678
- // The only invalid section was the day of the month, we replace its value with the maximum boundary for the correct month.
679
- return sections.map(section => {
680
- if (section.type !== 'day') {
681
- return section;
682
- }
683
- const dayBoundaries = sectionsValueBoundaries.day({
684
- currentDate: startOfMonth,
685
- format: section.format,
686
- contentType: section.contentType
687
- });
688
- if (Number(section.value) <= dayBoundaries.maximum) {
689
- return section;
690
- }
691
- return _extends({}, section, {
692
- value: dayBoundaries.maximum.toString()
693
- });
694
- });
695
- };
696
648
  export const getSectionOrder = (sections, isRTL) => {
697
649
  const neighbors = {};
698
650
  if (!isRTL) {