@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
@@ -255,9 +255,9 @@ export var DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(in
255
255
  var handleSelectedDayChange = useEventCallback(function (day) {
256
256
  if (day) {
257
257
  // If there is a date already selected, then we want to keep its time
258
- return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
258
+ return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish', view);
259
259
  }
260
- return handleValueChange(day, 'finish');
260
+ return handleValueChange(day, 'finish', view);
261
261
  });
262
262
  React.useEffect(function () {
263
263
  if (value != null && utils.isValid(value)) {
@@ -434,9 +434,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
434
434
  monthsPerRow: PropTypes.oneOf([3, 4]),
435
435
  /**
436
436
  * Callback fired when the value changes.
437
- * @template TDate
438
- * @param {TDate | null} value The new value.
437
+ * @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.
438
+ * @template TView The view type. Will be one of date or time views.
439
+ * @param {TValue} value The new value.
439
440
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
441
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
440
442
  */
441
443
  onChange: PropTypes.func,
442
444
  /**
@@ -26,10 +26,6 @@ var DatePickerToolbarRoot = styled(PickersToolbar, {
26
26
  return styles.root;
27
27
  }
28
28
  })({});
29
-
30
- /**
31
- * @ignore - do not document.
32
- */
33
29
  var DatePickerToolbarTitle = styled(Typography, {
34
30
  name: 'MuiDatePickerToolbar',
35
31
  slot: 'Title',
@@ -52,7 +48,7 @@ var DatePickerToolbarTitle = styled(Typography, {
52
48
  *
53
49
  * - [DatePickerToolbar API](https://mui.com/x/api/date-pickers/date-picker-toolbar/)
54
50
  */
55
- var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
51
+ export var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
56
52
  var props = useThemeProps({
57
53
  props: inProps,
58
54
  name: 'MuiDatePickerToolbar'
@@ -136,5 +132,4 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
136
132
  */
137
133
  view: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
138
134
  views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired).isRequired
139
- } : void 0;
140
- export { DatePickerToolbar };
135
+ } : void 0;
@@ -347,8 +347,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
347
347
  minutesStep: PropTypes.number,
348
348
  /**
349
349
  * Callback fired when the value changes.
350
- * @template TDate, TView
351
- * @param {TDate | null} value The new value.
350
+ * @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.
351
+ * @template TView The view type. Will be one of date or time views.
352
+ * @param {TValue} value The new value.
352
353
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
353
354
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
354
355
  */
@@ -436,6 +437,7 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
436
437
  view: PropTypes.oneOf(['hours']),
437
438
  /**
438
439
  * Available views.
440
+ * @default ['hours']
439
441
  */
440
442
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours']))
441
443
  } : void 0;
@@ -59,7 +59,7 @@ export var LocalizationProvider = function LocalizationProvider(inProps) {
59
59
  instance: dateLibInstance
60
60
  });
61
61
  if (!adapter.isMUIAdapter) {
62
- 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"));
62
+ 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"));
63
63
  }
64
64
  return adapter;
65
65
  }, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentUtils]);
@@ -140,10 +140,10 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
140
140
  onFocusedViewChange: onFocusedViewChange
141
141
  }),
142
142
  view = _useViews.view,
143
- setValueAndGoToView = _useViews.setValueAndGoToView,
143
+ setValueAndGoToNextView = _useViews.setValueAndGoToNextView,
144
144
  focusedView = _useViews.focusedView;
145
145
  var handleMeridiemValueChange = useEventCallback(function (newValue) {
146
- setValueAndGoToView(newValue, null, 'meridiem');
146
+ setValueAndGoToNextView(newValue, 'finish', 'meridiem');
147
147
  });
148
148
  var _useMeridiemMode = useMeridiemMode(valueOrReferenceDate, ampm, handleMeridiemValueChange, 'finish'),
149
149
  meridiemMode = _useMeridiemMode.meridiemMode,
@@ -223,11 +223,6 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
223
223
  throw new Error('not supported');
224
224
  }
225
225
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
226
- var handleSectionChange = useEventCallback(function (sectionView, newValue) {
227
- var viewIndex = views.indexOf(sectionView);
228
- var nextView = views[viewIndex + 1];
229
- setValueAndGoToView(newValue, nextView, sectionView);
230
- });
231
226
  var buildViewProps = React.useCallback(function (viewToBuild) {
232
227
  switch (viewToBuild) {
233
228
  case 'hours':
@@ -235,7 +230,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
235
230
  return {
236
231
  onChange: function onChange(hours) {
237
232
  var valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
238
- handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
233
+ setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
239
234
  },
240
235
  items: getHourSectionOptions({
241
236
  now: now,
@@ -255,7 +250,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
255
250
  {
256
251
  return {
257
252
  onChange: function onChange(minutes) {
258
- handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
253
+ setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
259
254
  },
260
255
  items: getTimeSectionOptions({
261
256
  value: utils.getMinutes(valueOrReferenceDate),
@@ -276,7 +271,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
276
271
  {
277
272
  return {
278
273
  onChange: function onChange(seconds) {
279
- handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
274
+ setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
280
275
  },
281
276
  items: getTimeSectionOptions({
282
277
  value: utils.getSeconds(valueOrReferenceDate),
@@ -325,7 +320,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
325
320
  default:
326
321
  throw new Error("Unknown view: ".concat(viewToBuild, " found."));
327
322
  }
328
- }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
323
+ }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
329
324
  var viewTimeOptions = React.useMemo(function () {
330
325
  return views.reduce(function (result, currentView) {
331
326
  return _extends({}, result, _defineProperty({}, currentView, buildViewProps(currentView)));
@@ -426,8 +421,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
426
421
  minutesStep: PropTypes.number,
427
422
  /**
428
423
  * Callback fired when the value changes.
429
- * @template TDate, TView
430
- * @param {TDate | null} value The new value.
424
+ * @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.
425
+ * @template TView The view type. Will be one of date or time views.
426
+ * @param {TValue} value The new value.
431
427
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
432
428
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
433
429
  */
@@ -519,6 +515,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
519
515
  view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
520
516
  /**
521
517
  * Available views.
518
+ * @default ['hours', 'minutes']
522
519
  */
523
520
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
524
521
  } : void 0;
@@ -47,7 +47,7 @@ var MultiSectionDigitalClockSectionRoot = styled(MenuList, {
47
47
  '&:not(:first-of-type)': {
48
48
  borderLeft: "1px solid ".concat((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
@@ -121,17 +121,13 @@ export var MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(funct
121
121
  return;
122
122
  }
123
123
  var activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
124
+ if (active && autoFocus && activeItem) {
125
+ activeItem.focus();
126
+ }
124
127
  if (!activeItem || previousActive.current === activeItem) {
125
- // Handle setting the ref to null if the selected item is ever reset via UI
126
- if (previousActive.current !== activeItem) {
127
- previousActive.current = activeItem;
128
- }
129
128
  return;
130
129
  }
131
130
  previousActive.current = activeItem;
132
- if (active && autoFocus) {
133
- activeItem.focus();
134
- }
135
131
  var offsetTop = activeItem.offsetTop;
136
132
 
137
133
  // Subtracting the 4px of extra margin intended for the first visible section item
@@ -121,7 +121,7 @@ var PickersSectionList = /*#__PURE__*/React.forwardRef(function PickersSectionLi
121
121
  var handleRootRef = useForkRef(ref, rootRef);
122
122
  var _getRoot = function getRoot(methodName) {
123
123
  if (!rootRef.current) {
124
- throw new Error("MUI: Cannot call sectionListRef.".concat(methodName, " before the mount of the component"));
124
+ throw new Error("MUI X: Cannot call sectionListRef.".concat(methodName, " before the mount of the component."));
125
125
  }
126
126
  return rootRef.current;
127
127
  };
@@ -395,8 +395,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
395
395
  minutesStep: PropTypes.number,
396
396
  /**
397
397
  * Callback fired when the value changes.
398
- * @template TDate, TView
399
- * @param {TDate | null} value The new value.
398
+ * @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.
399
+ * @template TView The view type. Will be one of date or time views.
400
+ * @param {TValue} value The new value.
400
401
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
401
402
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
402
403
  */
@@ -474,6 +475,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
474
475
  view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
475
476
  /**
476
477
  * Available views.
478
+ * @default ['hours', 'minutes']
477
479
  */
478
480
  views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
479
481
  } : void 0;
@@ -42,8 +42,8 @@ export var useClearableField = function useClearableField(props) {
42
42
  });
43
43
  return _extends({}, other, {
44
44
  InputProps: _extends({}, InputProps, {
45
- endAdornment: clearable ? /*#__PURE__*/_jsxs(React.Fragment, {
46
- children: [/*#__PURE__*/_jsx(InputAdornment, {
45
+ endAdornment: /*#__PURE__*/_jsxs(React.Fragment, {
46
+ children: [clearable && /*#__PURE__*/_jsx(InputAdornment, {
47
47
  position: "end",
48
48
  sx: {
49
49
  marginRight: InputProps != null && InputProps.endAdornment ? -1 : -1.5
@@ -55,7 +55,7 @@ export var useClearableField = function useClearableField(props) {
55
55
  }, endClearIconProps))
56
56
  }))
57
57
  }), InputProps == null ? void 0 : InputProps.endAdornment]
58
- }) : InputProps == null ? void 0 : InputProps.endAdornment
58
+ })
59
59
  }),
60
60
  sx: [{
61
61
  '& .clearButton': {
package/legacy/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
@@ -44,7 +44,7 @@ var FilledInputRoot = styled(PickersInputRoot, {
44
44
  }), "&.".concat(pickersFilledInputClasses.disabled), {
45
45
  backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
46
46
  }), !ownerState.disableUnderline && _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
47
- '&:after': {
47
+ '&::after': {
48
48
  borderBottom: "2px solid ".concat((_palette = (theme.vars || theme).palette[ownerState.color || 'primary']) == null ? void 0 : _palette.main),
49
49
  left: 0,
50
50
  bottom: 0,
@@ -67,7 +67,7 @@ var FilledInputRoot = styled(PickersInputRoot, {
67
67
  '&:before, &:after': {
68
68
  borderBottomColor: (theme.vars || theme).palette.error.main
69
69
  }
70
- }), '&:before', {
70
+ }), '&::before', {
71
71
  borderBottom: "1px solid ".concat(theme.vars ? "rgba(".concat(theme.vars.palette.common.onBackgroundChannel, " / ").concat(theme.vars.opacity.inputUnderline, ")") : bottomLineColor),
72
72
  left: 0,
73
73
  bottom: 0,
@@ -2,7 +2,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  var _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';
@@ -16,7 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
16
15
  var round = function round(value) {
17
16
  return Math.round(value * 1e5) / 1e5;
18
17
  };
19
- export var PickersInputRoot = styled(Box, {
18
+ export var PickersInputRoot = styled('div', {
20
19
  name: 'MuiPickersInput',
21
20
  slot: 'Root',
22
21
  overridesResolver: function overridesResolver(props, styles) {
@@ -180,7 +179,7 @@ export var PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(pr
180
179
  var handleInputRef = useForkRef(inputProps == null ? void 0 : inputProps.ref, inputRef);
181
180
  var muiFormControl = useFormControl();
182
181
  if (!muiFormControl) {
183
- throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
182
+ throw new Error('MUI X: PickersInput should always be used inside a PickersTextField component');
184
183
  }
185
184
  var handleInputFocus = function handleInputFocus(event) {
186
185
  var _muiFormControl$onFoc;
@@ -28,7 +28,7 @@ var StandardInputRoot = styled(PickersInputRoot, {
28
28
  marginTop: 16
29
29
  }
30
30
  }, !ownerState.disableUnderline && _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
31
- '&:after': {
31
+ '&::after': {
32
32
  background: 'red',
33
33
  borderBottom: "2px solid ".concat((theme.vars || theme).palette[ownerState.color].main),
34
34
  left: 0,
@@ -52,7 +52,7 @@ var StandardInputRoot = styled(PickersInputRoot, {
52
52
  '&:before, &:after': {
53
53
  borderBottomColor: (theme.vars || theme).palette.error.main
54
54
  }
55
- }), '&:before', {
55
+ }), '&::before', {
56
56
  borderBottom: "1px solid ".concat(bottomLineColor),
57
57
  left: 0,
58
58
  bottom: 0,
@@ -4,7 +4,7 @@ import { getMonthsInYear } from '../../utils/date-utils';
4
4
  export var getDateSectionConfigFromFormatToken = function getDateSectionConfigFromFormatToken(utils, formatToken) {
5
5
  var config = utils.formatTokenMap[formatToken];
6
6
  if (config == null) {
7
- throw new Error(["MUI: The token \"".concat(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
+ throw new Error(["MUI X: The token \"".concat(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'));
8
8
  }
9
9
  if (typeof config === 'string') {
10
10
  return {
@@ -87,7 +87,7 @@ export var cleanLeadingZeros = function cleanLeadingZeros(utils, valueStr, size)
87
87
  export var cleanDigitSectionValue = function cleanDigitSectionValue(utils, timezone, value, sectionBoundaries, section) {
88
88
  if (process.env.NODE_ENV !== 'production') {
89
89
  if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
90
- throw new Error(["MUI: The token \"".concat(section.format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
90
+ throw new Error(["MUI X: The token \"".concat(section.format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
91
91
  }
92
92
  }
93
93
  if (section.type === 'day' && section.contentType === 'digit-with-letter') {
@@ -367,7 +367,7 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, tim
367
367
  maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
368
368
  } else {
369
369
  if (sectionConfig.maxLength == null) {
370
- throw new Error("MUI: The token ".concat(token, " should have a 'maxDigitNumber' property on it's adapter"));
370
+ throw new Error("MUI X: The token ".concat(token, " should have a 'maxDigitNumber' property on it's adapter"));
371
371
  }
372
372
  maxLength = sectionConfig.maxLength;
373
373
  if (isValidDate) {
@@ -398,7 +398,7 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, tim
398
398
  nextFormat = utils.expandFormat(prevFormat);
399
399
  formatExpansionOverflow -= 1;
400
400
  if (formatExpansionOverflow < 0) {
401
- 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');
401
+ 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.');
402
402
  }
403
403
  }
404
404
  var expandedFormat = nextFormat;
@@ -633,7 +633,7 @@ export var validateSections = function validateSections(sections, valueType) {
633
633
  return !supportedSections.includes(section.type);
634
634
  });
635
635
  if (invalidSection) {
636
- console.warn("MUI: The field component you are using is not compatible with the \"".concat(invalidSection.type, "\" date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
636
+ console.warn("MUI X: The field component you are using is not compatible with the \"".concat(invalidSection.type, "\" date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
637
637
  warnedOnceInvalidSection = true;
638
638
  }
639
639
  }
@@ -129,12 +129,12 @@ export var usePickerValue = function usePickerValue(_ref) {
129
129
  if (process.env.NODE_ENV !== 'production') {
130
130
  React.useEffect(function () {
131
131
  if (isControlled !== (inValue !== undefined)) {
132
- console.error(["MUI: A component is changing the ".concat(isControlled ? '' : 'un', "controlled value of a picker to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled value" + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
132
+ console.error(["MUI X: A component is changing the ".concat(isControlled ? '' : 'un', "controlled value of a picker to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled value" + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
133
133
  }
134
134
  }, [inValue]);
135
135
  React.useEffect(function () {
136
136
  if (!isControlled && defaultValue !== inDefaultValue) {
137
- console.error(["MUI: A component is changing the defaultValue of an uncontrolled picker after being initialized. " + "To suppress this warning opt to use a controlled value."].join('\n'));
137
+ console.error(["MUI X: A component is changing the defaultValue of an uncontrolled picker after being initialized. " + "To suppress this warning opt to use a controlled value."].join('\n'));
138
138
  }
139
139
  }, [JSON.stringify(defaultValue)]);
140
140
  }
@@ -5,10 +5,10 @@ import { DEFAULT_LOCALE } from '../../locales/enUS';
5
5
  export var useLocalizationContext = function useLocalizationContext() {
6
6
  var localization = React.useContext(MuiPickersAdapterContext);
7
7
  if (localization === null) {
8
- throw new Error(['MUI: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
8
+ throw new Error(['MUI X: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
9
9
  }
10
10
  if (localization.utils === null) {
11
- throw new Error(['MUI: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
11
+ throw new Error(['MUI X: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
12
12
  }
13
13
  var localeText = React.useMemo(function () {
14
14
  return _extends({}, DEFAULT_LOCALE, localization.localeText);
@@ -16,11 +16,11 @@ export function useViews(_ref) {
16
16
  if (process.env.NODE_ENV !== 'production') {
17
17
  if (!warnedOnceNotValidView) {
18
18
  if (inView != null && !views.includes(inView)) {
19
- console.warn("MUI: `view=\"".concat(inView, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
19
+ console.warn("MUI X: `view=\"".concat(inView, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
20
20
  warnedOnceNotValidView = true;
21
21
  }
22
22
  if (inView == null && openTo != null && !views.includes(openTo)) {
23
- console.warn("MUI: `openTo=\"".concat(openTo, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
23
+ console.warn("MUI X: `openTo=\"".concat(openTo, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
24
24
  warnedOnceNotValidView = true;
25
25
  }
26
26
  }
@@ -74,11 +74,12 @@ export function useViews(_ref) {
74
74
  onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
75
75
  });
76
76
  var handleChangeView = useEventCallback(function (newView) {
77
+ // always keep the focused view in sync
78
+ handleFocusedViewChange(newView, true);
77
79
  if (newView === view) {
78
80
  return;
79
81
  }
80
82
  setView(newView);
81
- handleFocusedViewChange(newView, true);
82
83
  if (onViewChange) {
83
84
  onViewChange(newView);
84
85
  }
@@ -87,7 +88,6 @@ export function useViews(_ref) {
87
88
  if (nextView) {
88
89
  handleChangeView(nextView);
89
90
  }
90
- handleFocusedViewChange(nextView, true);
91
91
  });
92
92
  var setValueAndGoToNextView = useEventCallback(function (value, currentViewSelectionState, selectedView) {
93
93
  var isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
@@ -96,18 +96,19 @@ export function useViews(_ref) {
96
96
  // but when it's not the final view given all `views` -> overall selection state should be `partial`.
97
97
  views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
98
98
  var globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
99
- onChange(value, globalSelectionState);
100
- if (isSelectionFinishedOnCurrentView) {
99
+ onChange(value, globalSelectionState, selectedView);
100
+ // Detects if the selected view is not the active one.
101
+ // Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
102
+ if (selectedView && selectedView !== view) {
103
+ var nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
104
+ if (nextViewAfterSelected) {
105
+ // move to next view after the selected one
106
+ handleChangeView(nextViewAfterSelected);
107
+ }
108
+ } else if (isSelectionFinishedOnCurrentView) {
101
109
  goToNextView();
102
110
  }
103
111
  });
104
- var setValueAndGoToView = useEventCallback(function (value, newView, selectedView) {
105
- onChange(value, newView ? 'partial' : 'finish', selectedView);
106
- if (newView) {
107
- handleChangeView(newView);
108
- handleFocusedViewChange(newView, true);
109
- }
110
- });
111
112
  return {
112
113
  view: view,
113
114
  setView: handleChangeView,
@@ -118,7 +119,6 @@ export function useViews(_ref) {
118
119
  // Always return up-to-date default view instead of the initial one (i.e. defaultView.current)
119
120
  defaultView: views.includes(openTo) ? openTo : views[0],
120
121
  goToNextView: goToNextView,
121
- setValueAndGoToNextView: setValueAndGoToNextView,
122
- setValueAndGoToView: setValueAndGoToView
122
+ setValueAndGoToNextView: setValueAndGoToNextView
123
123
  };
124
124
  }
@@ -14,10 +14,12 @@ export { useField, createDateStrForInputFromSections, addPositionPropertiesToSec
14
14
  export { usePicker } from './hooks/usePicker';
15
15
  export { useStaticPicker } from './hooks/useStaticPicker';
16
16
  export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
17
+ export { useViews } from './hooks/useViews';
17
18
  export { useValidation } from './hooks/useValidation';
18
19
  export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
19
20
  export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
20
- export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
21
+ export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem } from './utils/date-utils';
22
+ export { resolveTimeViewsResponse } from './utils/date-time-utils';
21
23
  export { splitFieldInternalAndForwardedProps } from './utils/fields';
22
24
  export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
23
25
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
@@ -26,6 +28,8 @@ export { extractValidationProps } from './utils/validation/extractValidationProp
26
28
  export { validateDate } from './utils/validation/validateDate';
27
29
  export { validateDateTime } from './utils/validation/validateDateTime';
28
30
  export { validateTime } from './utils/validation/validateTime';
31
+ export { applyDefaultViewProps } from './utils/views';
29
32
  export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
30
33
  export { DayCalendar } from '../DateCalendar/DayCalendar';
31
- export { useCalendarState } from '../DateCalendar/useCalendarState';
34
+ export { useCalendarState } from '../DateCalendar/useCalendarState';
35
+ export { isTimeView } from './utils/time-utils';
@@ -20,7 +20,7 @@ export var applyDefaultViewProps = function applyDefaultViewProps(_ref) {
20
20
  } else if (viewsWithDefault.length > 0) {
21
21
  openToWithDefault = viewsWithDefault[0];
22
22
  } else {
23
- throw new Error('MUI: The `views` prop must contain at least one view');
23
+ throw new Error('MUI X: The `views` prop must contain at least one view.');
24
24
  }
25
25
  return {
26
26
  views: viewsWithDefault,
@@ -1,6 +1,7 @@
1
1
  export * from './beBY';
2
2
  export * from './caES';
3
3
  export * from './csCZ';
4
+ export * from './daDK';
4
5
  export * from './deDE';
5
6
  export * from './elGR';
6
7
  export * from './enUS';
package/locales/enUS.d.ts CHANGED
@@ -24,7 +24,7 @@ export declare const enUS: {
24
24
  hoursClockNumberText?: ((hours: string) => string) | undefined;
25
25
  minutesClockNumberText?: ((minutes: string) => string) | undefined;
26
26
  secondsClockNumberText?: ((seconds: string) => string) | undefined;
27
- selectViewText?: ((view: import("../internals/models").TimeViewWithMeridiem) => string) | undefined;
27
+ selectViewText?: ((view: import("../internals").TimeViewWithMeridiem) => string) | undefined;
28
28
  openDatePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
29
29
  openTimePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
30
30
  fieldClearLabel?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  export * from './beBY';
2
2
  export * from './caES';
3
3
  export * from './csCZ';
4
+ export * from './daDK';
4
5
  export * from './deDE';
5
6
  export * from './elGR';
6
7
  export * from './enUS';
package/locales/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './beBY';
2
2
  export * from './caES';
3
3
  export * from './csCZ';
4
+ export * from './daDK';
4
5
  export * from './deDE';
5
6
  export * from './elGR';
6
7
  export * from './enUS';
package/locales/mk.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare const mk: {
22
22
  hoursClockNumberText?: ((hours: string) => string) | undefined;
23
23
  minutesClockNumberText?: ((minutes: string) => string) | undefined;
24
24
  secondsClockNumberText?: ((seconds: string) => string) | undefined;
25
- selectViewText?: ((view: import("../internals/models").TimeViewWithMeridiem) => string) | undefined;
25
+ selectViewText?: ((view: import("../internals").TimeViewWithMeridiem) => string) | undefined;
26
26
  openDatePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
27
27
  openTimePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
28
28
  fieldClearLabel?: string | undefined;
@@ -23,7 +23,7 @@ export declare const getPickersLocalization: (pickersTranslations: Partial<Picke
23
23
  hoursClockNumberText?: ((hours: string) => string) | undefined;
24
24
  minutesClockNumberText?: ((minutes: string) => string) | undefined;
25
25
  secondsClockNumberText?: ((seconds: string) => string) | undefined;
26
- selectViewText?: ((view: import("../../internals/models").TimeViewWithMeridiem) => string) | undefined;
26
+ selectViewText?: ((view: import("../../internals").TimeViewWithMeridiem) => string) | undefined;
27
27
  openDatePickerDialogue?: ((date: any, utils: import("../..").MuiPickersAdapter<any, any>) => string) | undefined;
28
28
  openTimePickerDialogue?: ((date: any, utils: import("../..").MuiPickersAdapter<any, any>) => string) | undefined;
29
29
  fieldClearLabel?: string | undefined;