@mui/x-date-pickers-pro 6.0.0-alpha.11 → 6.0.0-alpha.12

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 (65) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/DateRangeCalendar/DateRangeCalendar.js +23 -2
  3. package/DateRangePicker/DateRangePicker.js +0 -1
  4. package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
  5. package/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
  6. package/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
  7. package/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
  9. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +3 -1
  10. package/index.d.ts +1 -1
  11. package/index.js +1 -1
  12. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
  13. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
  14. package/internal/hooks/useRangePickerInputProps.d.ts +3 -1
  15. package/internal/hooks/useRangePickerInputProps.js +7 -5
  16. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
  17. package/internal/models/fields.d.ts +6 -1
  18. package/internal/models/range.d.ts +0 -4
  19. package/internal/utils/date-fields-utils.d.ts +5 -5
  20. package/internal/utils/releaseInfo.js +1 -1
  21. package/internal/utils/valueManagers.d.ts +3 -2
  22. package/internal/utils/valueManagers.js +11 -6
  23. package/legacy/DateRangeCalendar/DateRangeCalendar.js +29 -2
  24. package/legacy/DateRangePicker/DateRangePicker.js +0 -1
  25. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
  26. package/legacy/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
  27. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
  28. package/legacy/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
  29. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -2
  30. package/legacy/index.js +1 -1
  31. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
  32. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
  33. package/legacy/internal/hooks/useRangePickerInputProps.js +7 -5
  34. package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
  35. package/legacy/internal/utils/releaseInfo.js +1 -1
  36. package/legacy/internal/utils/valueManagers.js +10 -5
  37. package/modern/DateRangeCalendar/DateRangeCalendar.js +22 -2
  38. package/modern/DateRangePicker/DateRangePicker.js +0 -1
  39. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
  40. package/modern/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
  41. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
  42. package/modern/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
  43. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
  44. package/modern/index.js +1 -1
  45. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
  46. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
  47. package/modern/internal/hooks/useRangePickerInputProps.js +6 -5
  48. package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
  49. package/modern/internal/utils/releaseInfo.js +1 -1
  50. package/modern/internal/utils/valueManagers.js +11 -6
  51. package/node/DateRangeCalendar/DateRangeCalendar.js +21 -1
  52. package/node/DateRangePicker/DateRangePicker.js +0 -1
  53. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
  54. package/node/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
  55. package/node/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
  56. package/node/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
  57. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
  58. package/node/index.js +1 -1
  59. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
  60. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
  61. package/node/internal/hooks/useRangePickerInputProps.js +6 -5
  62. package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
  63. package/node/internal/utils/releaseInfo.js +1 -1
  64. package/node/internal/utils/valueManagers.js +10 -5
  65. package/package.json +3 -3
@@ -26,7 +26,6 @@ var MobileNextDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileNex
26
26
  views: ['day'],
27
27
  openTo: 'day',
28
28
  showToolbar: (_defaultizedProps$sho = defaultizedProps.showToolbar) != null ? _defaultizedProps$sho : true,
29
- autoFocus: true,
30
29
  components: _extends({
31
30
  Field: MultiInputDateRangeField
32
31
  }, defaultizedProps.components),
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"],
3
+ var _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
4
4
  _excluded2 = ["onKeyDown", "ref"],
5
5
  _excluded3 = ["onKeyDown", "ref"];
6
6
  import * as React from 'react';
@@ -27,7 +27,9 @@ var MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef(functio
27
27
  overridesResolver: function overridesResolver(props, styles) {
28
28
  return styles.root;
29
29
  }
30
- })({});
30
+ })({
31
+ alignItems: 'baseline'
32
+ });
31
33
  var MultiInputDateRangeFieldSeparator = styled(function (props) {
32
34
  var _props$children;
33
35
  return /*#__PURE__*/_jsx(Typography, _extends({}, props, {
@@ -61,6 +63,7 @@ var MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
61
63
  disablePast = themeProps.disablePast,
62
64
  selectedSections = themeProps.selectedSections,
63
65
  onSelectedSectionsChange = themeProps.onSelectedSectionsChange,
66
+ autoFocus = themeProps.autoFocus,
64
67
  other = _objectWithoutProperties(themeProps, _excluded);
65
68
  var ownerState = themeProps;
66
69
  var Root = (_components$Root = components == null ? void 0 : components.Root) != null ? _components$Root : MultiInputDateRangeFieldRoot;
@@ -77,6 +80,9 @@ var MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
77
80
  var startInputProps = useSlotProps({
78
81
  elementType: Input,
79
82
  externalSlotProps: componentsProps == null ? void 0 : componentsProps.input,
83
+ additionalProps: {
84
+ autoFocus: autoFocus
85
+ },
80
86
  ownerState: _extends({}, ownerState, {
81
87
  position: 'start'
82
88
  })
@@ -142,6 +148,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
142
148
  // | These PropTypes are generated from the TypeScript type definitions |
143
149
  // | To update them edit the TypeScript types and run "yarn proptypes" |
144
150
  // ----------------------------------------------------------------------
151
+ autoFocus: PropTypes.bool,
145
152
  /**
146
153
  * Overrideable components.
147
154
  * @default {}
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v6.0.0-alpha.11
1
+ /** @license MUI v6.0.0-alpha.12
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -23,6 +23,7 @@ export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
23
23
  format = props.format,
24
24
  readOnly = props.readOnly,
25
25
  disabled = props.disabled,
26
+ autoFocus = props.autoFocus,
26
27
  disableOpenPicker = props.disableOpenPicker,
27
28
  localeText = props.localeText;
28
29
  var fieldRef = React.useRef(null);
@@ -37,6 +38,7 @@ export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
37
38
  wrapperVariant: 'desktop',
38
39
  viewLookup: viewLookup,
39
40
  validator: validator,
41
+ autoFocusView: true,
40
42
  additionalViewProps: {
41
43
  rangePosition: rangePosition,
42
44
  onRangePositionChange: setRangePosition
@@ -64,6 +66,7 @@ export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
64
66
  readOnly: readOnly,
65
67
  disabled: disabled,
66
68
  disableOpenPicker: disableOpenPicker,
69
+ localeText: localeText,
67
70
  onBlur: handleBlur,
68
71
  rangePosition: rangePosition,
69
72
  onRangePositionChange: setRangePosition
@@ -77,6 +80,7 @@ export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
77
80
  disabled: disabled,
78
81
  className: className,
79
82
  format: format,
83
+ autoFocus: autoFocus && !props.open,
80
84
  ref: fieldRef
81
85
  }),
82
86
  ownerState: props
@@ -36,6 +36,7 @@ export var useMobileRangePicker = function useMobileRangePicker(_ref) {
36
36
  wrapperVariant: 'mobile',
37
37
  viewLookup: viewLookup,
38
38
  validator: validator,
39
+ autoFocusView: true,
39
40
  additionalViewProps: {
40
41
  rangePosition: rangePosition,
41
42
  onRangePositionChange: setRangePosition
@@ -53,6 +54,7 @@ export var useMobileRangePicker = function useMobileRangePicker(_ref) {
53
54
  readOnly: readOnly,
54
55
  disabled: disabled,
55
56
  disableOpenPicker: disableOpenPicker,
57
+ localeText: localeText,
56
58
  rangePosition: rangePosition,
57
59
  onRangePositionChange: setRangePosition
58
60
  });
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { onSpaceOrEnter, useLocaleText } from '@mui/x-date-pickers/internals';
4
4
  export var useRangePickerInputProps = function useRangePickerInputProps(_ref) {
5
+ var _inLocaleText$start, _inLocaleText$end;
5
6
  var wrapperVariant = _ref.wrapperVariant,
6
7
  open = _ref.open,
7
8
  actions = _ref.actions,
@@ -10,7 +11,8 @@ export var useRangePickerInputProps = function useRangePickerInputProps(_ref) {
10
11
  disableOpenPicker = _ref.disableOpenPicker,
11
12
  onBlur = _ref.onBlur,
12
13
  rangePosition = _ref.rangePosition,
13
- onRangePositionChange = _ref.onRangePositionChange;
14
+ onRangePositionChange = _ref.onRangePositionChange,
15
+ inLocaleText = _ref.localeText;
14
16
  var localeText = useLocaleText();
15
17
  var startRef = React.useRef(null);
16
18
  var endRef = React.useRef(null);
@@ -27,14 +29,14 @@ export var useRangePickerInputProps = function useRangePickerInputProps(_ref) {
27
29
  }
28
30
  }, [rangePosition, open]);
29
31
  var openRangeStartSelection = function openRangeStartSelection(event) {
30
- event == null ? void 0 : event.stopPropagation();
32
+ event.stopPropagation();
31
33
  onRangePositionChange('start');
32
34
  if (!readOnly && !disableOpenPicker) {
33
35
  actions.onOpen();
34
36
  }
35
37
  };
36
38
  var openRangeEndSelection = function openRangeEndSelection(event) {
37
- event == null ? void 0 : event.stopPropagation();
39
+ event.stopPropagation();
38
40
  onRangePositionChange('end');
39
41
  if (!readOnly && !disableOpenPicker) {
40
42
  actions.onOpen();
@@ -52,7 +54,7 @@ export var useRangePickerInputProps = function useRangePickerInputProps(_ref) {
52
54
  };
53
55
  var startInputProps = _extends({
54
56
  inputRef: startRef,
55
- label: localeText.start,
57
+ label: (_inLocaleText$start = inLocaleText == null ? void 0 : inLocaleText.start) != null ? _inLocaleText$start : localeText.start,
56
58
  onKeyDown: onSpaceOrEnter(openRangeStartSelection),
57
59
  onFocus: focusOnRangeStart,
58
60
  focused: open ? rangePosition === 'start' : undefined
@@ -65,7 +67,7 @@ export var useRangePickerInputProps = function useRangePickerInputProps(_ref) {
65
67
  });
66
68
  var endInputProps = _extends({
67
69
  inputRef: endRef,
68
- label: localeText.end,
70
+ label: (_inLocaleText$end = inLocaleText == null ? void 0 : inLocaleText.end) != null ? _inLocaleText$end : localeText.end,
69
71
  onKeyDown: onSpaceOrEnter(openRangeEndSelection),
70
72
  onFocus: focusOnRangeEnd,
71
73
  focused: open ? rangePosition === 'end' : undefined
@@ -27,7 +27,8 @@ export var useStaticRangePicker = function useStaticRangePicker(_ref2) {
27
27
  var localeText = props.localeText,
28
28
  components = props.components,
29
29
  componentsProps = props.componentsProps,
30
- displayStaticWrapperAs = props.displayStaticWrapperAs;
30
+ displayStaticWrapperAs = props.displayStaticWrapperAs,
31
+ autoFocus = props.autoFocus;
31
32
  var _React$useState = React.useState('start'),
32
33
  _React$useState2 = _slicedToArray(_React$useState, 2),
33
34
  rangePosition = _React$useState2[0],
@@ -37,6 +38,7 @@ export var useStaticRangePicker = function useStaticRangePicker(_ref2) {
37
38
  viewLookup: viewLookup,
38
39
  valueManager: valueManager,
39
40
  validator: validator,
41
+ autoFocusView: autoFocus != null ? autoFocus : false,
40
42
  additionalViewProps: {},
41
43
  wrapperVariant: displayStaticWrapperAs
42
44
  }),
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTY3MDQ1NDAwMDAwMA==";
3
+ var releaseInfo = "MTY3MTE0NTIwMDAwMA==";
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,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections } from '@mui/x-date-pickers/internals';
4
+ import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections, getSectionOrder as _getSectionOrder } from '@mui/x-date-pickers/internals';
5
5
  import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
6
6
  export var rangeValueManager = {
7
7
  emptyValue: [null, null],
@@ -57,7 +57,8 @@ export var rangeFieldValueManager = {
57
57
  if (sectionIndex === rawSectionsOfStartDate.length - 1) {
58
58
  return _extends({}, section, {
59
59
  dateName: 'start',
60
- separator: ' '
60
+ separator: "\u2069 \u2013 \u2066",
61
+ parsingSeparator: ' – '
61
62
  });
62
63
  }
63
64
  return _extends({}, section, {
@@ -73,9 +74,7 @@ export var rangeFieldValueManager = {
73
74
  },
74
75
  getValueStrFromSections: function getValueStrFromSections(sections) {
75
76
  var dateRangeSections = splitDateRangeSections(sections);
76
- var startDateStr = createDateStrFromSections(dateRangeSections.startDate, true);
77
- var endDateStr = createDateStrFromSections(dateRangeSections.endDate, true);
78
- return "".concat(startDateStr).concat(endDateStr);
77
+ return createDateStrFromSections([].concat(_toConsumableArray(dateRangeSections.startDate), _toConsumableArray(dateRangeSections.endDate)), true);
79
78
  },
80
79
  getActiveDateSections: function getActiveDateSections(sections, activeSection) {
81
80
  var index = activeSection.dateName === 'start' ? 0 : 1;
@@ -113,5 +112,11 @@ export var rangeFieldValueManager = {
113
112
  },
114
113
  hasError: function hasError(error) {
115
114
  return error[0] != null || error[1] != null;
115
+ },
116
+ getSectionOrder: function getSectionOrder(utils, localeText, format, isRTL) {
117
+ var splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
118
+ return _getSectionOrder([].concat(_toConsumableArray(splitedFormat.slice(0, splitedFormat.length - 1)), [_extends({}, splitedFormat[splitedFormat.length - 1], {
119
+ separator: ' – '
120
+ })], _toConsumableArray(splitedFormat)), isRTL);
116
121
  }
117
122
  };
@@ -11,7 +11,7 @@ import { resolveComponentProps } 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';
14
- import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext } from '@mui/x-date-pickers/internals';
14
+ import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext, useNow } from '@mui/x-date-pickers/internals';
15
15
  import { getReleaseInfo } from '../internal/utils/releaseInfo';
16
16
  import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from './dateRangeCalendarClasses';
17
17
  import { isEndOfRange, isRangeValid, isStartOfRange, isWithinRange } from '../internal/utils/date-utils';
@@ -107,6 +107,7 @@ const useUtilityClasses = ownerState => {
107
107
  const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar(inProps, ref) {
108
108
  const utils = useUtils();
109
109
  const localeText = useLocaleText();
110
+ const now = useNow();
110
111
  const props = useDateRangeCalendarDefaultizedProps(inProps, 'MuiDateRangeCalendar');
111
112
  const isMobile = React.useContext(WrapperVariantContext) === 'mobile';
112
113
  const {
@@ -347,6 +348,25 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
347
348
  const visibleMonths = React.useMemo(() => Array.from({
348
349
  length: calendars
349
350
  }).map((_, index) => utils.setMonth(calendarState.currentMonth, utils.getMonth(calendarState.currentMonth) + index)), [utils, calendarState.currentMonth, calendars]);
351
+ const focusedMonth = React.useMemo(() => {
352
+ if (!autoFocus) {
353
+ return null;
354
+ }
355
+
356
+ // The focus priority of the "day" view is as follows:
357
+ // 1. Month of the `start` date
358
+ // 2. Month of the `end` date
359
+ // 3. Month of the current date
360
+ // 4. First visible month
361
+
362
+ if (value[0] != null) {
363
+ return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
364
+ }
365
+ if (value[1] != null) {
366
+ return visibleMonths.find(month => utils.isSameMonth(month, value[1]));
367
+ }
368
+ return visibleMonths.find(month => utils.isSameMonth(month, now)) ?? visibleMonths[0];
369
+ }, [utils, value, visibleMonths, autoFocus, now]);
350
370
  return /*#__PURE__*/_jsxs(DateRangeCalendarRoot, _extends({
351
371
  ref: ref,
352
372
  className: clsx(className, classes.root),
@@ -402,7 +422,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
402
422
  renderLoading: renderLoading,
403
423
  components: componentsForDayCalendar,
404
424
  componentsProps: componentsPropsForDayCalendar,
405
- autoFocus: autoFocus,
425
+ autoFocus: month === focusedMonth,
406
426
  fixedWeekNumber: fixedWeekNumber,
407
427
  displayWeekNumber: displayWeekNumber
408
428
  }), index)]
@@ -55,7 +55,6 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
55
55
  * @default /\dap/gi
56
56
  */
57
57
  acceptRegex: PropTypes.instanceOf(RegExp),
58
- autoFocus: PropTypes.bool,
59
58
  /**
60
59
  * The number of calendars that render on **desktop**.
61
60
  * @default 2
@@ -75,7 +75,6 @@ process.env.NODE_ENV !== "production" ? DesktopDateRangePicker.propTypes = {
75
75
  * @default /\dap/gi
76
76
  */
77
77
  acceptRegex: PropTypes.instanceOf(RegExp),
78
- autoFocus: PropTypes.bool,
79
78
  /**
80
79
  * The number of calendars that render on **desktop**.
81
80
  * @default 2
@@ -27,7 +27,6 @@ const DesktopNextDateRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
27
27
  views: ['day'],
28
28
  openTo: 'day',
29
29
  showToolbar: defaultizedProps.showToolbar ?? false,
30
- autoFocus: true,
31
30
  components: _extends({
32
31
  Field: MultiInputDateRangeField
33
32
  }, defaultizedProps.components),
@@ -82,7 +82,6 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes = {
82
82
  * @default /\dap/gi
83
83
  */
84
84
  acceptRegex: PropTypes.instanceOf(RegExp),
85
- autoFocus: PropTypes.bool,
86
85
  /**
87
86
  * The number of calendars that render on **desktop**.
88
87
  * @default 2
@@ -27,7 +27,6 @@ const MobileNextDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileN
27
27
  views: ['day'],
28
28
  openTo: 'day',
29
29
  showToolbar: defaultizedProps.showToolbar ?? true,
30
- autoFocus: true,
31
30
  components: _extends({
32
31
  Field: MultiInputDateRangeField
33
32
  }, defaultizedProps.components),
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"],
3
+ const _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
4
4
  _excluded2 = ["onKeyDown", "ref"],
5
5
  _excluded3 = ["onKeyDown", "ref"];
6
6
  import * as React from 'react';
@@ -23,7 +23,9 @@ const MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
23
23
  name: 'MuiMultiInputDateRangeField',
24
24
  slot: 'Root',
25
25
  overridesResolver: (props, styles) => styles.root
26
- })({});
26
+ })({
27
+ alignItems: 'baseline'
28
+ });
27
29
  const MultiInputDateRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
28
30
  children: props.children ?? ' — '
29
31
  })), {
@@ -51,7 +53,8 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
51
53
  disableFuture,
52
54
  disablePast,
53
55
  selectedSections,
54
- onSelectedSectionsChange
56
+ onSelectedSectionsChange,
57
+ autoFocus
55
58
  } = themeProps,
56
59
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
57
60
  const ownerState = themeProps;
@@ -69,6 +72,9 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
69
72
  const startInputProps = useSlotProps({
70
73
  elementType: Input,
71
74
  externalSlotProps: componentsProps?.input,
75
+ additionalProps: {
76
+ autoFocus
77
+ },
72
78
  ownerState: _extends({}, ownerState, {
73
79
  position: 'start'
74
80
  })
@@ -138,6 +144,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
138
144
  // | These PropTypes are generated from the TypeScript type definitions |
139
145
  // | To update them edit the TypeScript types and run "yarn proptypes" |
140
146
  // ----------------------------------------------------------------------
147
+ autoFocus: PropTypes.bool,
141
148
  /**
142
149
  * Overrideable components.
143
150
  * @default {}
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v6.0.0-alpha.11
1
+ /** @license MUI v6.0.0-alpha.12
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -23,6 +23,7 @@ export const useDesktopRangePicker = ({
23
23
  format,
24
24
  readOnly,
25
25
  disabled,
26
+ autoFocus,
26
27
  disableOpenPicker,
27
28
  localeText
28
29
  } = props;
@@ -42,6 +43,7 @@ export const useDesktopRangePicker = ({
42
43
  wrapperVariant: 'desktop',
43
44
  viewLookup,
44
45
  validator,
46
+ autoFocusView: true,
45
47
  additionalViewProps: {
46
48
  rangePosition,
47
49
  onRangePositionChange: setRangePosition
@@ -62,6 +64,7 @@ export const useDesktopRangePicker = ({
62
64
  readOnly,
63
65
  disabled,
64
66
  disableOpenPicker,
67
+ localeText,
65
68
  onBlur: handleBlur,
66
69
  rangePosition,
67
70
  onRangePositionChange: setRangePosition
@@ -75,6 +78,7 @@ export const useDesktopRangePicker = ({
75
78
  disabled,
76
79
  className,
77
80
  format,
81
+ autoFocus: autoFocus && !props.open,
78
82
  ref: fieldRef
79
83
  }),
80
84
  ownerState: props
@@ -40,6 +40,7 @@ export const useMobileRangePicker = ({
40
40
  wrapperVariant: 'mobile',
41
41
  viewLookup,
42
42
  validator,
43
+ autoFocusView: true,
43
44
  additionalViewProps: {
44
45
  rangePosition,
45
46
  onRangePositionChange: setRangePosition
@@ -52,6 +53,7 @@ export const useMobileRangePicker = ({
52
53
  readOnly,
53
54
  disabled,
54
55
  disableOpenPicker,
56
+ localeText,
55
57
  rangePosition,
56
58
  onRangePositionChange: setRangePosition
57
59
  });
@@ -10,7 +10,8 @@ export const useRangePickerInputProps = ({
10
10
  disableOpenPicker,
11
11
  onBlur,
12
12
  rangePosition,
13
- onRangePositionChange
13
+ onRangePositionChange,
14
+ localeText: inLocaleText
14
15
  }) => {
15
16
  const localeText = useLocaleText();
16
17
  const startRef = React.useRef(null);
@@ -26,14 +27,14 @@ export const useRangePickerInputProps = ({
26
27
  }
27
28
  }, [rangePosition, open]);
28
29
  const openRangeStartSelection = event => {
29
- event?.stopPropagation();
30
+ event.stopPropagation();
30
31
  onRangePositionChange('start');
31
32
  if (!readOnly && !disableOpenPicker) {
32
33
  actions.onOpen();
33
34
  }
34
35
  };
35
36
  const openRangeEndSelection = event => {
36
- event?.stopPropagation();
37
+ event.stopPropagation();
37
38
  onRangePositionChange('end');
38
39
  if (!readOnly && !disableOpenPicker) {
39
40
  actions.onOpen();
@@ -51,7 +52,7 @@ export const useRangePickerInputProps = ({
51
52
  };
52
53
  const startInputProps = _extends({
53
54
  inputRef: startRef,
54
- label: localeText.start,
55
+ label: inLocaleText?.start ?? localeText.start,
55
56
  onKeyDown: onSpaceOrEnter(openRangeStartSelection),
56
57
  onFocus: focusOnRangeStart,
57
58
  focused: open ? rangePosition === 'start' : undefined
@@ -64,7 +65,7 @@ export const useRangePickerInputProps = ({
64
65
  });
65
66
  const endInputProps = _extends({
66
67
  inputRef: endRef,
67
- label: localeText.end,
68
+ label: inLocaleText?.end ?? localeText.end,
68
69
  onKeyDown: onSpaceOrEnter(openRangeEndSelection),
69
70
  onFocus: focusOnRangeEnd,
70
71
  focused: open ? rangePosition === 'end' : undefined
@@ -27,7 +27,8 @@ export const useStaticRangePicker = ({
27
27
  localeText,
28
28
  components,
29
29
  componentsProps,
30
- displayStaticWrapperAs
30
+ displayStaticWrapperAs,
31
+ autoFocus
31
32
  } = props;
32
33
  const [rangePosition, setRangePosition] = React.useState('start');
33
34
  const {
@@ -38,6 +39,7 @@ export const useStaticRangePicker = ({
38
39
  viewLookup,
39
40
  valueManager,
40
41
  validator,
42
+ autoFocusView: autoFocus ?? false,
41
43
  additionalViewProps: {},
42
44
  wrapperVariant: displayStaticWrapperAs
43
45
  });
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY3MDQ1NDAwMDAwMA==";
3
+ const releaseInfo = "MTY3MTE0NTIwMDAwMA==";
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,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections } from '@mui/x-date-pickers/internals';
2
+ import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections, getSectionOrder } from '@mui/x-date-pickers/internals';
3
3
  import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
4
4
  export const rangeValueManager = {
5
5
  emptyValue: [null, null],
@@ -42,7 +42,8 @@ export const rangeFieldValueManager = {
42
42
  if (sectionIndex === rawSectionsOfStartDate.length - 1) {
43
43
  return _extends({}, section, {
44
44
  dateName: 'start',
45
- separator: ''
45
+ separator: `\u2069\u2066`,
46
+ parsingSeparator: ' – '
46
47
  });
47
48
  }
48
49
  return _extends({}, section, {
@@ -56,9 +57,7 @@ export const rangeFieldValueManager = {
56
57
  },
57
58
  getValueStrFromSections: sections => {
58
59
  const dateRangeSections = splitDateRangeSections(sections);
59
- const startDateStr = createDateStrFromSections(dateRangeSections.startDate, true);
60
- const endDateStr = createDateStrFromSections(dateRangeSections.endDate, true);
61
- return `${startDateStr}${endDateStr}`;
60
+ return createDateStrFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], true);
62
61
  },
63
62
  getActiveDateSections: (sections, activeSection) => {
64
63
  const index = activeSection.dateName === 'start' ? 0 : 1;
@@ -87,5 +86,11 @@ export const rangeFieldValueManager = {
87
86
  })
88
87
  };
89
88
  },
90
- hasError: error => error[0] != null || error[1] != null
89
+ hasError: error => error[0] != null || error[1] != null,
90
+ getSectionOrder: (utils, localeText, format, isRTL) => {
91
+ const splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
92
+ return getSectionOrder([...splitedFormat.slice(0, splitedFormat.length - 1), _extends({}, splitedFormat[splitedFormat.length - 1], {
93
+ separator: ' – '
94
+ }), ...splitedFormat], isRTL);
95
+ }
91
96
  };
@@ -115,6 +115,7 @@ const useUtilityClasses = ownerState => {
115
115
  const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar(inProps, ref) {
116
116
  const utils = (0, _internals.useUtils)();
117
117
  const localeText = (0, _internals.useLocaleText)();
118
+ const now = (0, _internals.useNow)();
118
119
  const props = useDateRangeCalendarDefaultizedProps(inProps, 'MuiDateRangeCalendar');
119
120
  const isMobile = React.useContext(_internals.WrapperVariantContext) === 'mobile';
120
121
  const {
@@ -355,6 +356,25 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
355
356
  const visibleMonths = React.useMemo(() => Array.from({
356
357
  length: calendars
357
358
  }).map((_, index) => utils.setMonth(calendarState.currentMonth, utils.getMonth(calendarState.currentMonth) + index)), [utils, calendarState.currentMonth, calendars]);
359
+ const focusedMonth = React.useMemo(() => {
360
+ if (!autoFocus) {
361
+ return null;
362
+ }
363
+
364
+ // The focus priority of the "day" view is as follows:
365
+ // 1. Month of the `start` date
366
+ // 2. Month of the `end` date
367
+ // 3. Month of the current date
368
+ // 4. First visible month
369
+
370
+ if (value[0] != null) {
371
+ return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
372
+ }
373
+ if (value[1] != null) {
374
+ return visibleMonths.find(month => utils.isSameMonth(month, value[1]));
375
+ }
376
+ return visibleMonths.find(month => utils.isSameMonth(month, now)) ?? visibleMonths[0];
377
+ }, [utils, value, visibleMonths, autoFocus, now]);
358
378
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateRangeCalendarRoot, (0, _extends2.default)({
359
379
  ref: ref,
360
380
  className: (0, _clsx.default)(className, classes.root),
@@ -410,7 +430,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
410
430
  renderLoading: renderLoading,
411
431
  components: componentsForDayCalendar,
412
432
  componentsProps: componentsPropsForDayCalendar,
413
- autoFocus: autoFocus,
433
+ autoFocus: month === focusedMonth,
414
434
  fixedWeekNumber: fixedWeekNumber,
415
435
  displayWeekNumber: displayWeekNumber
416
436
  }), index)]
@@ -65,7 +65,6 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
65
65
  * @default /\dap/gi
66
66
  */
67
67
  acceptRegex: _propTypes.default.instanceOf(RegExp),
68
- autoFocus: _propTypes.default.bool,
69
68
  /**
70
69
  * The number of calendars that render on **desktop**.
71
70
  * @default 2
@@ -85,7 +85,6 @@ process.env.NODE_ENV !== "production" ? DesktopDateRangePicker.propTypes = {
85
85
  * @default /\dap/gi
86
86
  */
87
87
  acceptRegex: _propTypes.default.instanceOf(RegExp),
88
- autoFocus: _propTypes.default.bool,
89
88
  /**
90
89
  * The number of calendars that render on **desktop**.
91
90
  * @default 2
@@ -36,7 +36,6 @@ const DesktopNextDateRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
36
36
  views: ['day'],
37
37
  openTo: 'day',
38
38
  showToolbar: defaultizedProps.showToolbar ?? false,
39
- autoFocus: true,
40
39
  components: (0, _extends2.default)({
41
40
  Field: _MultiInputDateRangeField.Unstable_MultiInputDateRangeField
42
41
  }, defaultizedProps.components),
@@ -92,7 +92,6 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes = {
92
92
  * @default /\dap/gi
93
93
  */
94
94
  acceptRegex: _propTypes.default.instanceOf(RegExp),
95
- autoFocus: _propTypes.default.bool,
96
95
  /**
97
96
  * The number of calendars that render on **desktop**.
98
97
  * @default 2
@@ -36,7 +36,6 @@ const MobileNextDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileN
36
36
  views: ['day'],
37
37
  openTo: 'day',
38
38
  showToolbar: defaultizedProps.showToolbar ?? true,
39
- autoFocus: true,
40
39
  components: (0, _extends2.default)({
41
40
  Field: _MultiInputDateRangeField.Unstable_MultiInputDateRangeField
42
41
  }, defaultizedProps.components),