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

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 (67) hide show
  1. package/CHANGELOG.md +591 -5
  2. package/DateRangeCalendar/DateRangeCalendar.js +72 -68
  3. package/DateRangeCalendar/DateRangeCalendar.types.d.ts +8 -5
  4. package/DateRangeCalendar/useDragRange.js +1 -1
  5. package/DateRangePicker/DateRangePicker.js +1 -6
  6. package/DateRangePicker/shared.d.ts +1 -1
  7. package/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -6
  8. package/MobileDateRangePicker/MobileDateRangePicker.js +1 -6
  9. package/MultiInputDateRangeField/MultiInputDateRangeField.js +1 -1
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -9
  11. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -9
  12. package/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
  13. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -9
  14. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -9
  15. package/StaticDateRangePicker/StaticDateRangePicker.js +1 -6
  16. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +1 -1
  17. package/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -2
  18. package/index.js +1 -1
  19. package/internals/utils/date-fields-utils.d.ts +0 -1
  20. package/internals/utils/releaseInfo.js +1 -1
  21. package/legacy/DateRangeCalendar/DateRangeCalendar.js +42 -41
  22. package/legacy/DateRangeCalendar/useDragRange.js +1 -1
  23. package/legacy/DateRangePicker/DateRangePicker.js +1 -6
  24. package/legacy/DateRangePickerDay/DateRangePickerDay.js +3 -4
  25. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -6
  26. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +1 -6
  27. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +1 -1
  28. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -9
  29. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -9
  30. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
  31. package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -9
  32. package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -9
  33. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +1 -6
  34. package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -2
  35. package/legacy/index.js +1 -1
  36. package/legacy/internals/utils/releaseInfo.js +1 -1
  37. package/modern/DateRangeCalendar/DateRangeCalendar.js +33 -33
  38. package/modern/DateRangeCalendar/useDragRange.js +1 -1
  39. package/modern/DateRangePicker/DateRangePicker.js +1 -6
  40. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -6
  41. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -6
  42. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +1 -1
  43. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -9
  44. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -9
  45. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
  46. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -9
  47. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -9
  48. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -6
  49. package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -2
  50. package/modern/index.js +1 -1
  51. package/modern/internals/utils/releaseInfo.js +1 -1
  52. package/node/DateRangeCalendar/DateRangeCalendar.js +32 -32
  53. package/node/DateRangeCalendar/useDragRange.js +1 -1
  54. package/node/DateRangePicker/DateRangePicker.js +1 -6
  55. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -6
  56. package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -6
  57. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +1 -1
  58. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -9
  59. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -9
  60. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
  61. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -9
  62. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -9
  63. package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -6
  64. package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -2
  65. package/node/index.js +1 -1
  66. package/node/internals/utils/releaseInfo.js +1 -1
  67. package/package.json +7 -6
@@ -2,14 +2,14 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- var _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "defaultCalendarMonth", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
5
+ var _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
6
6
  _excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import useEventCallback from '@mui/utils/useEventCallback';
11
11
  import useMediaQuery from '@mui/material/useMediaQuery';
12
- import { resolveComponentProps } from '@mui/base/utils';
12
+ import { resolveComponentProps, useSlotProps } from '@mui/base/utils';
13
13
  import { styled, useThemeProps } from '@mui/material/styles';
14
14
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
15
15
  import { Watermark } from '@mui/x-license-pro';
@@ -60,23 +60,22 @@ var DAY_RANGE_SIZE = 40;
60
60
  var weeksContainerHeight = (DAY_RANGE_SIZE + DAY_MARGIN * 2) * 6;
61
61
  var warnInvalidCurrentMonthCalendarPosition = buildWarning(['The `currentMonthCalendarPosition` prop must be an integer between `1` and the amount of calendars rendered.', 'For example if you have 2 calendars rendered, it should be equal to either 1 or 2.']);
62
62
  var DayCalendarForRange = styled(DayCalendar)(function (_ref2) {
63
- var _$concat, _ref3;
64
63
  var theme = _ref2.theme;
65
- return _ref3 = {
64
+ return _defineProperty(_defineProperty({
66
65
  minWidth: 312,
67
66
  minHeight: weeksContainerHeight
68
- }, _defineProperty(_ref3, "&.".concat(dateRangeCalendarClasses.dayDragging), (_$concat = {}, _defineProperty(_$concat, "& .".concat(dayClasses.day), {
67
+ }, "&.".concat(dateRangeCalendarClasses.dayDragging), _defineProperty(_defineProperty({}, "& .".concat(dayClasses.day), {
69
68
  cursor: 'grabbing'
70
- }), _defineProperty(_$concat, "& .".concat(dayClasses.root, ":not(.").concat(dayClasses.rangeIntervalDayHighlightStart, "):not(.").concat(dayClasses.rangeIntervalDayHighlightEnd, ") .").concat(dayClasses.day, ":not(.").concat(dayClasses.notSelectedDate, ")"), {
69
+ }), "& .".concat(dayClasses.root, ":not(.").concat(dayClasses.rangeIntervalDayHighlightStart, "):not(.").concat(dayClasses.rangeIntervalDayHighlightEnd, ") .").concat(dayClasses.day, ":not(.").concat(dayClasses.notSelectedDate, ")"), {
71
70
  // we can't override `PickersDay` background color here, because it's styles take precedence
72
71
  opacity: 0.6
73
- }), _$concat)), _defineProperty(_ref3, "&:not(.".concat(dateRangeCalendarClasses.dayDragging, ") .").concat(dayClasses.dayOutsideRangeInterval), {
72
+ })), "&:not(.".concat(dateRangeCalendarClasses.dayDragging, ") .").concat(dayClasses.dayOutsideRangeInterval), {
74
73
  '@media (pointer: fine)': {
75
74
  '&:hover': {
76
75
  border: "1px solid ".concat((theme.vars || theme).palette.grey[500])
77
76
  }
78
77
  }
79
- }), _ref3;
78
+ });
80
79
  });
81
80
  function useDateRangeCalendarDefaultizedProps(props, name) {
82
81
  var _themeProps$renderLoa, _themeProps$reduceAni, _props$loading, _props$disablePast, _props$disableFuture, _themeProps$calendars, _themeProps$disableDr;
@@ -124,6 +123,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
124
123
  * - [DateRangeCalendar API](https://mui.com/x/api/date-pickers/date-range-calendar/)
125
124
  */
126
125
  var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar(inProps, ref) {
126
+ var _slots$calendarHeader;
127
127
  var props = useDateRangeCalendarDefaultizedProps(inProps, 'MuiDateRangeCalendar');
128
128
  var shouldHavePreview = useMediaQuery(DEFAULT_DESKTOP_MODE_MEDIA_QUERY, {
129
129
  defaultMatches: false
@@ -140,7 +140,6 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
140
140
  shouldDisableDate = props.shouldDisableDate,
141
141
  reduceAnimations = props.reduceAnimations,
142
142
  onMonthChange = props.onMonthChange,
143
- defaultCalendarMonth = props.defaultCalendarMonth,
144
143
  rangePositionProp = props.rangePosition,
145
144
  inDefaultRangePosition = props.defaultRangePosition,
146
145
  inOnRangePositionChange = props.onRangePositionChange,
@@ -254,7 +253,6 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
254
253
  var _useCalendarState = useCalendarState({
255
254
  value: value[0] || value[1],
256
255
  referenceDate: referenceDate,
257
- defaultCalendarMonth: defaultCalendarMonth,
258
256
  disableFuture: disableFuture,
259
257
  disablePast: disablePast,
260
258
  disableSwitchToMonthOnDayFocus: true,
@@ -270,6 +268,36 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
270
268
  changeMonth = _useCalendarState.changeMonth,
271
269
  handleChangeMonth = _useCalendarState.handleChangeMonth,
272
270
  onMonthSwitchingAnimationEnd = _useCalendarState.onMonthSwitchingAnimationEnd;
271
+
272
+ // When disabled, limit the view to the selected date
273
+ var minDateWithDisabled = disabled && value[0] || minDate;
274
+ var maxDateWithDisabled = disabled && value[1] || maxDate;
275
+ var CalendarHeader = (_slots$calendarHeader = slots == null ? void 0 : slots.calendarHeader) != null ? _slots$calendarHeader : PickersCalendarHeader;
276
+ var calendarHeaderProps = useSlotProps({
277
+ elementType: CalendarHeader,
278
+ externalSlotProps: slotProps == null ? void 0 : slotProps.calendarHeader,
279
+ additionalProps: {
280
+ views: ['day'],
281
+ view: 'day',
282
+ currentMonth: calendarState.currentMonth,
283
+ onMonthChange: function onMonthChange(newMonth, direction) {
284
+ return handleChangeMonth({
285
+ newMonth: newMonth,
286
+ direction: direction
287
+ });
288
+ },
289
+ minDate: minDateWithDisabled,
290
+ maxDate: maxDateWithDisabled,
291
+ disabled: disabled,
292
+ disablePast: disablePast,
293
+ disableFuture: disableFuture,
294
+ reduceAnimations: reduceAnimations,
295
+ slots: slots,
296
+ slotProps: slotProps,
297
+ timezone: timezone
298
+ },
299
+ ownerState: props
300
+ });
273
301
  var prevValue = React.useRef(null);
274
302
  React.useEffect(function () {
275
303
  var _prevValue$current, _prevValue$current2;
@@ -323,10 +351,6 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
323
351
  readOnly: readOnly,
324
352
  disabled: disabled
325
353
  };
326
-
327
- // When disabled, limit the view to the selected date
328
- var minDateWithDisabled = disabled && value[0] || minDate;
329
- var maxDateWithDisabled = disabled && value[1] || maxDate;
330
354
  var _React$useState = React.useState(null),
331
355
  _React$useState2 = _slicedToArray(_React$useState, 2),
332
356
  rangePreviewDay = _React$useState2[0],
@@ -441,28 +465,10 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
441
465
  packageName: "x-date-pickers-pro",
442
466
  releaseInfo: releaseInfo
443
467
  }), calendarMonths.map(function (month, index) {
468
+ var _calendarHeaderProps$;
444
469
  return /*#__PURE__*/_jsxs(DateRangeCalendarMonthContainer, {
445
470
  className: classes.monthContainer,
446
- children: [calendars === 1 ? /*#__PURE__*/_jsx(PickersCalendarHeader, {
447
- views: ['day'],
448
- view: 'day',
449
- currentMonth: calendarState.currentMonth,
450
- onMonthChange: function onMonthChange(newMonth, direction) {
451
- return handleChangeMonth({
452
- newMonth: newMonth,
453
- direction: direction
454
- });
455
- },
456
- minDate: minDateWithDisabled,
457
- maxDate: maxDateWithDisabled,
458
- disabled: disabled,
459
- disablePast: disablePast,
460
- disableFuture: disableFuture,
461
- reduceAnimations: reduceAnimations,
462
- slots: slots,
463
- slotProps: slotProps,
464
- timezone: timezone
465
- }) : /*#__PURE__*/_jsx(DateRangeCalendarArrowSwitcher, {
471
+ children: [calendars === 1 ? /*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps)) : /*#__PURE__*/_jsx(DateRangeCalendarArrowSwitcher, {
466
472
  onGoToPrevious: selectPreviousMonth,
467
473
  onGoToNext: selectNextMonth,
468
474
  isPreviousHidden: index !== 0,
@@ -473,7 +479,7 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
473
479
  nextLabel: localeText.nextMonth,
474
480
  slots: slots,
475
481
  slotProps: slotProps,
476
- children: utils.format(visibleMonths[month], 'monthAndYear')
482
+ children: utils.formatByString(visibleMonths[month], (_calendarHeaderProps$ = calendarHeaderProps.format) != null ? _calendarHeaderProps$ : "".concat(utils.formats.month, " ").concat(utils.formats.year))
477
483
  }), /*#__PURE__*/_jsx(DayCalendarForRange, _extends({
478
484
  className: classes.dayCalendar
479
485
  }, calendarState, baseDateValidationProps, commonViewProps, {
@@ -526,16 +532,11 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
526
532
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
527
533
  /**
528
534
  * Formats the day of week displayed in the calendar header.
529
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
530
535
  * @param {TDate} date The date of the day of week provided by the adapter.
531
536
  * @returns {string} The name to display.
532
537
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
533
538
  */
534
539
  dayOfWeekFormatter: PropTypes.func,
535
- /**
536
- * Default calendar month displayed when `value={[null, null]}`.
537
- */
538
- defaultCalendarMonth: PropTypes.any,
539
540
  /**
540
541
  * The initial position in the edited date range.
541
542
  * Used when the component is not controlled.
@@ -685,7 +686,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
685
686
  * Choose which timezone to use for the value.
686
687
  * Example: "default", "system", "UTC", "America/New_York".
687
688
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
688
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
689
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
689
690
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
690
691
  */
691
692
  timezone: PropTypes.string,
@@ -9,7 +9,7 @@ var resolveDateFromTarget = function resolveDateFromTarget(target, utils, timezo
9
9
  return null;
10
10
  }
11
11
  var timestamp = +timestampString;
12
- return utils.dateWithTimezone(new Date(timestamp).toISOString(), timezone);
12
+ return utils.date(new Date(timestamp).toISOString(), timezone);
13
13
  };
14
14
  var isSameAsDraggingDate = function isSameAsDraggingDate(event) {
15
15
  var timestampString = event.target.dataset.timestamp;
@@ -74,16 +74,11 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
74
74
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
75
75
  /**
76
76
  * Formats the day of week displayed in the calendar header.
77
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
78
77
  * @param {TDate} date The date of the day of week provided by the adapter.
79
78
  * @returns {string} The name to display.
80
79
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
81
80
  */
82
81
  dayOfWeekFormatter: PropTypes.func,
83
- /**
84
- * Default calendar month displayed when `value={[null, null]}`.
85
- */
86
- defaultCalendarMonth: PropTypes.any,
87
82
  /**
88
83
  * The initial position in the edited date range.
89
84
  * Used when the component is not controlled.
@@ -316,7 +311,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
316
311
  * Choose which timezone to use for the value.
317
312
  * Example: "default", "system", "UTC", "America/New_York".
318
313
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
319
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
314
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
320
315
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
321
316
  */
322
317
  timezone: PropTypes.string,
@@ -51,14 +51,13 @@ var DateRangePickerDayRoot = styled('div', {
51
51
  return [_defineProperty({}, "&.".concat(dateRangePickerDayClasses.rangeIntervalDayHighlight), styles.rangeIntervalDayHighlight), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.rangeIntervalDayHighlightStart), styles.rangeIntervalDayHighlightStart), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.rangeIntervalDayHighlightEnd), styles.rangeIntervalDayHighlightEnd), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.firstVisibleCell), styles.firstVisibleCell), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.lastVisibleCell), styles.lastVisibleCell), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.startOfMonth), styles.startOfMonth), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.endOfMonth), styles.endOfMonth), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.outsideCurrentMonth), styles.outsideCurrentMonth), _defineProperty({}, "&.".concat(dateRangePickerDayClasses.hiddenDayFiller), styles.hiddenDayFiller), styles.root];
52
52
  }
53
53
  })(function (_ref10) {
54
- var _extends2;
55
54
  var theme = _ref10.theme,
56
55
  ownerState = _ref10.ownerState;
57
- return ownerState.isHiddenDayFiller ? {} : _extends((_extends2 = {}, _defineProperty(_extends2, "&:first-of-type .".concat(dateRangePickerDayClasses.rangeIntervalDayPreview), _extends({}, startBorderStyle, {
56
+ return ownerState.isHiddenDayFiller ? {} : _extends(_defineProperty(_defineProperty({}, "&:first-of-type .".concat(dateRangePickerDayClasses.rangeIntervalDayPreview), _extends({}, startBorderStyle, {
58
57
  borderLeftColor: (theme.vars || theme).palette.divider
59
- })), _defineProperty(_extends2, "&:last-of-type .".concat(dateRangePickerDayClasses.rangeIntervalDayPreview), _extends({}, endBorderStyle, {
58
+ })), "&:last-of-type .".concat(dateRangePickerDayClasses.rangeIntervalDayPreview), _extends({}, endBorderStyle, {
60
59
  borderRightColor: (theme.vars || theme).palette.divider
61
- })), _extends2), ownerState.isHighlighting && {
60
+ })), ownerState.isHighlighting && {
62
61
  borderRadius: 0,
63
62
  color: (theme.vars || theme).palette.primary.contrastText,
64
63
  backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / ").concat(theme.vars.palette.action.focusOpacity, ")") : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity),
@@ -89,16 +89,11 @@ DesktopDateRangePicker.propTypes = {
89
89
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
90
90
  /**
91
91
  * Formats the day of week displayed in the calendar header.
92
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
93
92
  * @param {TDate} date The date of the day of week provided by the adapter.
94
93
  * @returns {string} The name to display.
95
94
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
96
95
  */
97
96
  dayOfWeekFormatter: PropTypes.func,
98
- /**
99
- * Default calendar month displayed when `value={[null, null]}`.
100
- */
101
- defaultCalendarMonth: PropTypes.any,
102
97
  /**
103
98
  * The initial position in the edited date range.
104
99
  * Used when the component is not controlled.
@@ -325,7 +320,7 @@ DesktopDateRangePicker.propTypes = {
325
320
  * Choose which timezone to use for the value.
326
321
  * Example: "default", "system", "UTC", "America/New_York".
327
322
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
328
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
323
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
329
324
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
330
325
  */
331
326
  timezone: PropTypes.string,
@@ -89,16 +89,11 @@ MobileDateRangePicker.propTypes = {
89
89
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
90
90
  /**
91
91
  * Formats the day of week displayed in the calendar header.
92
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
93
92
  * @param {TDate} date The date of the day of week provided by the adapter.
94
93
  * @returns {string} The name to display.
95
94
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
96
95
  */
97
96
  dayOfWeekFormatter: PropTypes.func,
98
- /**
99
- * Default calendar month displayed when `value={[null, null]}`.
100
- */
101
- defaultCalendarMonth: PropTypes.any,
102
97
  /**
103
98
  * The initial position in the edited date range.
104
99
  * Used when the component is not controlled.
@@ -325,7 +320,7 @@ MobileDateRangePicker.propTypes = {
325
320
  * Choose which timezone to use for the value.
326
321
  * Example: "default", "system", "UTC", "America/New_York".
327
322
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
328
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
323
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
329
324
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
330
325
  */
331
326
  timezone: PropTypes.string,
@@ -324,7 +324,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
324
324
  * Choose which timezone to use for the value.
325
325
  * Example: "default", "system", "UTC", "America/New_York".
326
326
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
327
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
327
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
328
328
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
329
329
  */
330
330
  timezone: PropTypes.string,
@@ -307,14 +307,6 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
307
307
  endIndex: PropTypes.number.isRequired,
308
308
  startIndex: PropTypes.number.isRequired
309
309
  })]),
310
- /**
311
- * Disable specific clock time.
312
- * @param {number} clockValue The value to check.
313
- * @param {TimeView} view The clock type of the timeValue.
314
- * @returns {boolean} If `true` the time will be disabled.
315
- * @deprecated Consider using `shouldDisableTime`.
316
- */
317
- shouldDisableClock: PropTypes.func,
318
310
  /**
319
311
  * Disable specific date.
320
312
  *
@@ -373,7 +365,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
373
365
  * Choose which timezone to use for the value.
374
366
  * Example: "default", "system", "UTC", "America/New_York".
375
367
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
376
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
368
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
377
369
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
378
370
  */
379
371
  timezone: PropTypes.string,
@@ -291,14 +291,6 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
291
291
  endIndex: PropTypes.number.isRequired,
292
292
  startIndex: PropTypes.number.isRequired
293
293
  })]),
294
- /**
295
- * Disable specific clock time.
296
- * @param {number} clockValue The value to check.
297
- * @param {TimeView} view The clock type of the timeValue.
298
- * @returns {boolean} If `true` the time will be disabled.
299
- * @deprecated Consider using `shouldDisableTime`.
300
- */
301
- shouldDisableClock: PropTypes.func,
302
294
  /**
303
295
  * Disable specific time.
304
296
  * @template TDate
@@ -346,7 +338,7 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
346
338
  * Choose which timezone to use for the value.
347
339
  * Example: "default", "system", "UTC", "America/New_York".
348
340
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
349
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
341
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
350
342
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
351
343
  */
352
344
  timezone: PropTypes.string,
@@ -313,7 +313,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
313
313
  * Choose which timezone to use for the value.
314
314
  * Example: "default", "system", "UTC", "America/New_York".
315
315
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
316
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
316
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
317
317
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
318
318
  */
319
319
  timezone: PropTypes.string,
@@ -297,14 +297,6 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
297
297
  endIndex: PropTypes.number.isRequired,
298
298
  startIndex: PropTypes.number.isRequired
299
299
  })]),
300
- /**
301
- * Disable specific clock time.
302
- * @param {number} clockValue The value to check.
303
- * @param {TimeView} view The clock type of the timeValue.
304
- * @returns {boolean} If `true` the time will be disabled.
305
- * @deprecated Consider using `shouldDisableTime`.
306
- */
307
- shouldDisableClock: PropTypes.func,
308
300
  /**
309
301
  * Disable specific date.
310
302
  *
@@ -362,7 +354,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
362
354
  * Choose which timezone to use for the value.
363
355
  * Example: "default", "system", "UTC", "America/New_York".
364
356
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
365
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
357
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
366
358
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
367
359
  */
368
360
  timezone: PropTypes.string,
@@ -281,14 +281,6 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
281
281
  endIndex: PropTypes.number.isRequired,
282
282
  startIndex: PropTypes.number.isRequired
283
283
  })]),
284
- /**
285
- * Disable specific clock time.
286
- * @param {number} clockValue The value to check.
287
- * @param {TimeView} view The clock type of the timeValue.
288
- * @returns {boolean} If `true` the time will be disabled.
289
- * @deprecated Consider using `shouldDisableTime`.
290
- */
291
- shouldDisableClock: PropTypes.func,
292
284
  /**
293
285
  * Disable specific time.
294
286
  * @template TDate
@@ -335,7 +327,7 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
335
327
  * Choose which timezone to use for the value.
336
328
  * Example: "default", "system", "UTC", "America/New_York".
337
329
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
338
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
330
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
339
331
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
340
332
  */
341
333
  timezone: PropTypes.string,
@@ -75,16 +75,11 @@ StaticDateRangePicker.propTypes = {
75
75
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
76
76
  /**
77
77
  * Formats the day of week displayed in the calendar header.
78
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
79
78
  * @param {TDate} date The date of the day of week provided by the adapter.
80
79
  * @returns {string} The name to display.
81
80
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
82
81
  */
83
82
  dayOfWeekFormatter: PropTypes.func,
84
- /**
85
- * Default calendar month displayed when `value={[null, null]}`.
86
- */
87
- defaultCalendarMonth: PropTypes.any,
88
83
  /**
89
84
  * The initial position in the edited date range.
90
85
  * Used when the component is not controlled.
@@ -263,7 +258,7 @@ StaticDateRangePicker.propTypes = {
263
258
  * Choose which timezone to use for the value.
264
259
  * Example: "default", "system", "UTC", "America/New_York".
265
260
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
266
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
261
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
267
262
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
268
263
  */
269
264
  timezone: PropTypes.string,
@@ -19,7 +19,6 @@ export var renderDateRangeViewCalendar = function renderDateRangeViewCalendar(_r
19
19
  shouldDisableDate = _ref.shouldDisableDate,
20
20
  reduceAnimations = _ref.reduceAnimations,
21
21
  onMonthChange = _ref.onMonthChange,
22
- defaultCalendarMonth = _ref.defaultCalendarMonth,
23
22
  rangePosition = _ref.rangePosition,
24
23
  defaultRangePosition = _ref.defaultRangePosition,
25
24
  onRangePositionChange = _ref.onRangePositionChange,
@@ -55,7 +54,6 @@ export var renderDateRangeViewCalendar = function renderDateRangeViewCalendar(_r
55
54
  shouldDisableDate: shouldDisableDate,
56
55
  reduceAnimations: reduceAnimations,
57
56
  onMonthChange: onMonthChange,
58
- defaultCalendarMonth: defaultCalendarMonth,
59
57
  rangePosition: rangePosition,
60
58
  defaultRangePosition: defaultRangePosition,
61
59
  onRangePositionChange: onRangePositionChange,
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v7.0.0-alpha.0
2
+ * @mui/x-date-pickers-pro v7.0.0-alpha.2
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTY5OTU3MDgwMDAwMA==";
3
+ var releaseInfo = "MTcwMDY5MDQwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -1,13 +1,13 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "defaultCalendarMonth", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
3
+ const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
4
4
  _excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import clsx from 'clsx';
8
8
  import useEventCallback from '@mui/utils/useEventCallback';
9
9
  import useMediaQuery from '@mui/material/useMediaQuery';
10
- import { resolveComponentProps } from '@mui/base/utils';
10
+ import { resolveComponentProps, useSlotProps } from '@mui/base/utils';
11
11
  import { styled, useThemeProps } from '@mui/material/styles';
12
12
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
13
13
  import { Watermark } from '@mui/x-license-pro';
@@ -136,7 +136,6 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
136
136
  shouldDisableDate,
137
137
  reduceAnimations,
138
138
  onMonthChange,
139
- defaultCalendarMonth,
140
139
  rangePosition: rangePositionProp,
141
140
  defaultRangePosition: inDefaultRangePosition,
142
141
  onRangePositionChange: inOnRangePositionChange,
@@ -256,7 +255,6 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
256
255
  } = useCalendarState({
257
256
  value: value[0] || value[1],
258
257
  referenceDate,
259
- defaultCalendarMonth,
260
258
  disableFuture,
261
259
  disablePast,
262
260
  disableSwitchToMonthOnDayFocus: true,
@@ -267,6 +265,34 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
267
265
  shouldDisableDate: wrappedShouldDisableDate,
268
266
  timezone
269
267
  });
268
+
269
+ // When disabled, limit the view to the selected date
270
+ const minDateWithDisabled = disabled && value[0] || minDate;
271
+ const maxDateWithDisabled = disabled && value[1] || maxDate;
272
+ const CalendarHeader = slots?.calendarHeader ?? PickersCalendarHeader;
273
+ const calendarHeaderProps = useSlotProps({
274
+ elementType: CalendarHeader,
275
+ externalSlotProps: slotProps?.calendarHeader,
276
+ additionalProps: {
277
+ views: ['day'],
278
+ view: 'day',
279
+ currentMonth: calendarState.currentMonth,
280
+ onMonthChange: (newMonth, direction) => handleChangeMonth({
281
+ newMonth,
282
+ direction
283
+ }),
284
+ minDate: minDateWithDisabled,
285
+ maxDate: maxDateWithDisabled,
286
+ disabled,
287
+ disablePast,
288
+ disableFuture,
289
+ reduceAnimations,
290
+ slots,
291
+ slotProps,
292
+ timezone
293
+ },
294
+ ownerState: props
295
+ });
270
296
  const prevValue = React.useRef(null);
271
297
  React.useEffect(() => {
272
298
  const date = rangePosition === 'start' ? value[0] : value[1];
@@ -319,10 +345,6 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
319
345
  readOnly,
320
346
  disabled
321
347
  };
322
-
323
- // When disabled, limit the view to the selected date
324
- const minDateWithDisabled = disabled && value[0] || minDate;
325
- const maxDateWithDisabled = disabled && value[1] || maxDate;
326
348
  const [rangePreviewDay, setRangePreviewDay] = React.useState(null);
327
349
  const CalendarTransitionProps = React.useMemo(() => ({
328
350
  onMouseLeave: () => setRangePreviewDay(null)
@@ -419,24 +441,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
419
441
  releaseInfo: releaseInfo
420
442
  }), calendarMonths.map((month, index) => /*#__PURE__*/_jsxs(DateRangeCalendarMonthContainer, {
421
443
  className: classes.monthContainer,
422
- children: [calendars === 1 ? /*#__PURE__*/_jsx(PickersCalendarHeader, {
423
- views: ['day'],
424
- view: 'day',
425
- currentMonth: calendarState.currentMonth,
426
- onMonthChange: (newMonth, direction) => handleChangeMonth({
427
- newMonth,
428
- direction
429
- }),
430
- minDate: minDateWithDisabled,
431
- maxDate: maxDateWithDisabled,
432
- disabled: disabled,
433
- disablePast: disablePast,
434
- disableFuture: disableFuture,
435
- reduceAnimations: reduceAnimations,
436
- slots: slots,
437
- slotProps: slotProps,
438
- timezone: timezone
439
- }) : /*#__PURE__*/_jsx(DateRangeCalendarArrowSwitcher, {
444
+ children: [calendars === 1 ? /*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps)) : /*#__PURE__*/_jsx(DateRangeCalendarArrowSwitcher, {
440
445
  onGoToPrevious: selectPreviousMonth,
441
446
  onGoToNext: selectNextMonth,
442
447
  isPreviousHidden: index !== 0,
@@ -447,7 +452,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
447
452
  nextLabel: localeText.nextMonth,
448
453
  slots: slots,
449
454
  slotProps: slotProps,
450
- children: utils.format(visibleMonths[month], 'monthAndYear')
455
+ children: utils.formatByString(visibleMonths[month], calendarHeaderProps.format ?? `${utils.formats.month} ${utils.formats.year}`)
451
456
  }), /*#__PURE__*/_jsx(DayCalendarForRange, _extends({
452
457
  className: classes.dayCalendar
453
458
  }, calendarState, baseDateValidationProps, commonViewProps, {
@@ -499,16 +504,11 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
499
504
  currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
500
505
  /**
501
506
  * Formats the day of week displayed in the calendar header.
502
- * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
503
507
  * @param {TDate} date The date of the day of week provided by the adapter.
504
508
  * @returns {string} The name to display.
505
509
  * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
506
510
  */
507
511
  dayOfWeekFormatter: PropTypes.func,
508
- /**
509
- * Default calendar month displayed when `value={[null, null]}`.
510
- */
511
- defaultCalendarMonth: PropTypes.any,
512
512
  /**
513
513
  * The initial position in the edited date range.
514
514
  * Used when the component is not controlled.
@@ -658,7 +658,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
658
658
  * Choose which timezone to use for the value.
659
659
  * Example: "default", "system", "UTC", "America/New_York".
660
660
  * If you pass values from other timezones to some props, they will be converted to this timezone before being used.
661
- * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
661
+ * @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
662
662
  * @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
663
663
  */
664
664
  timezone: PropTypes.string,
@@ -8,7 +8,7 @@ const resolveDateFromTarget = (target, utils, timezone) => {
8
8
  return null;
9
9
  }
10
10
  const timestamp = +timestampString;
11
- return utils.dateWithTimezone(new Date(timestamp).toISOString(), timezone);
11
+ return utils.date(new Date(timestamp).toISOString(), timezone);
12
12
  };
13
13
  const isSameAsDraggingDate = event => {
14
14
  const timestampString = event.target.dataset.timestamp;