@mui/x-date-pickers-pro 6.0.2 → 6.0.4

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 (138) hide show
  1. package/CHANGELOG.md +119 -5
  2. package/DateRangePicker/DateRangePicker.js +12 -0
  3. package/DateRangePicker/DateRangePickerToolbar.d.ts +1 -1
  4. package/DateRangePicker/shared.d.ts +1 -1
  5. package/DateRangePickerDay/DateRangePickerDay.js +3 -6
  6. package/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  7. package/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.js +2 -0
  9. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +8 -10
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +14 -3
  11. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +8 -8
  12. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +14 -3
  13. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +8 -8
  14. package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +1 -0
  15. package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -0
  16. package/SingleInputDateRangeField/useSingleInputDateRangeField.js +5 -3
  17. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +1 -0
  18. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -0
  19. package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +5 -3
  20. package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +1 -0
  21. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  22. package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +5 -3
  23. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +1 -1
  24. package/index.d.ts +1 -1
  25. package/index.js +1 -1
  26. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
  27. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
  28. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +10 -30
  29. package/internal/hooks/useEnrichedRangePickerFieldProps.d.ts +53 -0
  30. package/internal/hooks/useEnrichedRangePickerFieldProps.js +202 -0
  31. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
  32. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
  33. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +10 -29
  34. package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -2
  35. package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +23 -15
  36. package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +1 -2
  37. package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +14 -12
  38. package/internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +14 -2
  39. package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +1 -2
  40. package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +14 -12
  41. package/internal/hooks/useRangePosition.d.ts +4 -0
  42. package/internal/hooks/useRangePosition.js +16 -1
  43. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
  44. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +5 -3
  45. package/internal/hooks/validation/useDateRangeValidation.d.ts +2 -1
  46. package/internal/hooks/validation/useDateTimeRangeValidation.d.ts +2 -1
  47. package/internal/hooks/validation/useTimeRangeValidation.d.ts +2 -1
  48. package/internal/models/dateRange.d.ts +2 -1
  49. package/internal/models/dateTimeRange.d.ts +2 -1
  50. package/internal/models/fields.d.ts +8 -3
  51. package/internal/models/index.d.ts +1 -0
  52. package/internal/models/index.js +2 -1
  53. package/internal/models/rangePickerProps.d.ts +17 -0
  54. package/internal/models/rangePickerProps.js +1 -0
  55. package/internal/models/timeRange.d.ts +2 -1
  56. package/internal/utils/releaseInfo.js +1 -1
  57. package/internal/utils/valueManagers.js +23 -27
  58. package/legacy/DateRangePicker/DateRangePicker.js +12 -0
  59. package/legacy/DateRangePickerDay/DateRangePickerDay.js +4 -7
  60. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  61. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  62. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +2 -0
  63. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +13 -2
  64. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +13 -2
  65. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -0
  66. package/legacy/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
  67. package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -0
  68. package/legacy/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
  69. package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  70. package/legacy/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
  71. package/legacy/index.js +1 -1
  72. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
  73. package/legacy/internal/hooks/useEnrichedRangePickerFieldProps.js +200 -0
  74. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
  75. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +23 -15
  76. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +14 -12
  77. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +14 -12
  78. package/legacy/internal/hooks/useRangePosition.js +16 -1
  79. package/legacy/internal/models/index.js +2 -1
  80. package/legacy/internal/models/rangePickerProps.js +1 -0
  81. package/legacy/internal/utils/releaseInfo.js +1 -1
  82. package/legacy/internal/utils/valueManagers.js +22 -26
  83. package/modern/DateRangePicker/DateRangePicker.js +12 -0
  84. package/modern/DateRangePickerDay/DateRangePickerDay.js +3 -6
  85. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  86. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  87. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +2 -0
  88. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +14 -3
  89. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +14 -3
  90. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -0
  91. package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +5 -3
  92. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -0
  93. package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +5 -3
  94. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  95. package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +5 -3
  96. package/modern/index.js +1 -1
  97. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +30 -38
  98. package/modern/internal/hooks/useEnrichedRangePickerFieldProps.js +195 -0
  99. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +35 -38
  100. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +23 -15
  101. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +14 -12
  102. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +14 -12
  103. package/modern/internal/hooks/useRangePosition.js +16 -1
  104. package/modern/internal/models/index.js +2 -1
  105. package/modern/internal/models/rangePickerProps.js +1 -0
  106. package/modern/internal/utils/releaseInfo.js +1 -1
  107. package/modern/internal/utils/valueManagers.js +23 -27
  108. package/node/DateRangePicker/DateRangePicker.js +12 -0
  109. package/node/DateRangePickerDay/DateRangePickerDay.js +3 -6
  110. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  111. package/node/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  112. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +2 -0
  113. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +14 -3
  114. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +14 -3
  115. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -0
  116. package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +5 -3
  117. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -0
  118. package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +5 -3
  119. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  120. package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +5 -3
  121. package/node/index.js +1 -1
  122. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +29 -37
  123. package/node/internal/hooks/useEnrichedRangePickerFieldProps.js +205 -0
  124. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +34 -37
  125. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +23 -15
  126. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +14 -12
  127. package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +14 -12
  128. package/node/internal/hooks/useRangePosition.js +18 -1
  129. package/node/internal/models/index.js +11 -0
  130. package/node/internal/models/rangePickerProps.js +5 -0
  131. package/node/internal/utils/releaseInfo.js +1 -1
  132. package/node/internal/utils/valueManagers.js +22 -26
  133. package/package.json +4 -4
  134. package/internal/hooks/useRangePickerInputProps.d.ts +0 -19
  135. package/internal/hooks/useRangePickerInputProps.js +0 -89
  136. package/legacy/internal/hooks/useRangePickerInputProps.js +0 -88
  137. package/modern/internal/hooks/useRangePickerInputProps.js +0 -86
  138. package/node/internal/hooks/useRangePickerInputProps.js +0 -96
@@ -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, createDateStrForInputFromSections, getSectionOrder as _getSectionOrder } from '@mui/x-date-pickers/internals';
4
+ import { replaceInvalidDateByNull, addPositionPropertiesToSections, createDateStrForInputFromSections, areDatesEqual } 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],
@@ -14,7 +14,7 @@ export var rangeValueManager = {
14
14
  });
15
15
  },
16
16
  areValuesEqual: function areValuesEqual(utils, a, b) {
17
- return utils.isEqual(a[0], b[0]) && utils.isEqual(a[1], b[1]);
17
+ return areDatesEqual(utils, a[0], b[0]) && areDatesEqual(utils, a[1], b[1]);
18
18
  },
19
19
  isSameError: function isSameError(a, b) {
20
20
  return b !== null && a[1] === b[1] && a[0] === b[0];
@@ -36,20 +36,20 @@ export var rangeFieldValueManager = {
36
36
  }
37
37
  return [prevReferenceValue[1], value[1]];
38
38
  },
39
- getSectionsFromValue: function getSectionsFromValue(utils, localeText, prevSections, _ref, format) {
39
+ getSectionsFromValue: function getSectionsFromValue(utils, _ref, fallbackSections, isRTL, getSectionsFromDate) {
40
40
  var _ref2 = _slicedToArray(_ref, 2),
41
41
  start = _ref2[0],
42
42
  end = _ref2[1];
43
- var prevDateRangeSections = prevSections == null ? {
43
+ var separatedFallbackSections = fallbackSections == null ? {
44
44
  startDate: null,
45
45
  endDate: null
46
- } : splitDateRangeSections(prevSections);
47
- var getSections = function getSections(newDate, prevDateSections, position) {
48
- var shouldReUsePrevDateSections = !utils.isValid(newDate) && !!prevDateSections;
46
+ } : splitDateRangeSections(fallbackSections);
47
+ var getSections = function getSections(newDate, fallbackDateSections, position) {
48
+ var shouldReUsePrevDateSections = !utils.isValid(newDate) && !!fallbackDateSections;
49
49
  if (shouldReUsePrevDateSections) {
50
- return prevDateSections;
50
+ return fallbackDateSections;
51
51
  }
52
- var sections = splitFormatIntoSections(utils, localeText, format, newDate);
52
+ var sections = getSectionsFromDate(newDate);
53
53
  return sections.map(function (section, sectionIndex) {
54
54
  if (sectionIndex === sections.length - 1 && position === 'start') {
55
55
  return _extends({}, section, {
@@ -62,16 +62,11 @@ export var rangeFieldValueManager = {
62
62
  });
63
63
  });
64
64
  };
65
- return addPositionPropertiesToSections([].concat(_toConsumableArray(getSections(start, prevDateRangeSections.startDate, 'start')), _toConsumableArray(getSections(end, prevDateRangeSections.endDate, 'end'))));
65
+ return addPositionPropertiesToSections([].concat(_toConsumableArray(getSections(start, separatedFallbackSections.startDate, 'start')), _toConsumableArray(getSections(end, separatedFallbackSections.endDate, 'end'))), isRTL);
66
66
  },
67
- getValueStrFromSections: function getValueStrFromSections(sections) {
67
+ getValueStrFromSections: function getValueStrFromSections(sections, isRTL) {
68
68
  var dateRangeSections = splitDateRangeSections(sections);
69
- return createDateStrForInputFromSections([].concat(_toConsumableArray(dateRangeSections.startDate), _toConsumableArray(dateRangeSections.endDate)));
70
- },
71
- getActiveDateSections: function getActiveDateSections(sections, activeSection) {
72
- var index = activeSection.dateName === 'start' ? 0 : 1;
73
- var dateRangeSections = splitDateRangeSections(sections);
74
- return index === 0 ? removeLastSeparator(dateRangeSections.startDate) : dateRangeSections.endDate;
69
+ return createDateStrForInputFromSections([].concat(_toConsumableArray(dateRangeSections.startDate), _toConsumableArray(dateRangeSections.endDate)), isRTL);
75
70
  },
76
71
  parseValueStr: function parseValueStr(valueStr, referenceValue, parseDate) {
77
72
  // TODO: Improve because it would not work if the date format has `–` as a separator.
@@ -92,9 +87,16 @@ export var rangeFieldValueManager = {
92
87
  return index === 0 ? [newDate, prevDateRange[1]] : [prevDateRange[0], newDate];
93
88
  };
94
89
  return {
95
- activeDate: state.value[index],
96
- referenceActiveDate: state.referenceValue[index],
97
- getNewValueFromNewActiveDate: function getNewValueFromNewActiveDate(newActiveDate) {
90
+ date: state.value[index],
91
+ referenceDate: state.referenceValue[index],
92
+ getSections: function getSections(sections) {
93
+ var dateRangeSections = splitDateRangeSections(sections);
94
+ if (index === 0) {
95
+ return removeLastSeparator(dateRangeSections.startDate);
96
+ }
97
+ return dateRangeSections.endDate;
98
+ },
99
+ getNewValuesFromNewActiveDate: function getNewValuesFromNewActiveDate(newActiveDate) {
98
100
  return {
99
101
  value: updateDateInRange(newActiveDate, state.value),
100
102
  referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : updateDateInRange(newActiveDate, state.referenceValue)
@@ -104,11 +106,5 @@ export var rangeFieldValueManager = {
104
106
  },
105
107
  hasError: function hasError(error) {
106
108
  return error[0] != null || error[1] != null;
107
- },
108
- getSectionOrder: function getSectionOrder(utils, localeText, format, isRTL) {
109
- var splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
110
- return _getSectionOrder([].concat(_toConsumableArray(splitedFormat.slice(0, splitedFormat.length - 1)), [_extends({}, splitedFormat[splitedFormat.length - 1], {
111
- endSeparator: ' – '
112
- })], _toConsumableArray(splitedFormat)), isRTL);
113
109
  }
114
110
  };
@@ -147,6 +147,18 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
147
147
  * Defaults to localized format based on the used `views`.
148
148
  */
149
149
  format: PropTypes.string,
150
+ /**
151
+ * Pass a ref to the `input` element.
152
+ * Ignored if the field has several inputs.
153
+ */
154
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
155
+ current: PropTypes.object
156
+ })]),
157
+ /**
158
+ * The label content.
159
+ * Ignored if the field has several inputs.
160
+ */
161
+ label: PropTypes.node,
150
162
  /**
151
163
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
152
164
  * Can be used to preload information and show it in calendar.
@@ -80,7 +80,7 @@ const DateRangePickerDayRoot = styled('div', {
80
80
  }, ownerState.isHighlighting && {
81
81
  borderRadius: 0,
82
82
  color: (theme.vars || theme).palette.primary.contrastText,
83
- backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.lightChannel} / 0.6)` : alpha(theme.palette.primary.light, 0.6),
83
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity),
84
84
  '&:first-of-type': startBorderStyle,
85
85
  '&:last-of-type': endBorderStyle
86
86
  }, (ownerState.isStartOfHighlighting || ownerState.isFirstVisibleCell) && _extends({}, startBorderStyle, {
@@ -139,7 +139,6 @@ const DateRangePickerDayDay = styled(PickersDay, {
139
139
  [`&.${dateRangePickerDayClasses.notSelectedDate}`]: styles.notSelectedDate
140
140
  }, styles.day]
141
141
  })(({
142
- theme,
143
142
  ownerState
144
143
  }) => _extends({
145
144
  // Required to overlap preview border
@@ -147,12 +146,10 @@ const DateRangePickerDayDay = styled(PickersDay, {
147
146
  '& > *': {
148
147
  transform: 'scale(0.9)'
149
148
  }
150
- }, !ownerState.selected && {
151
- backgroundColor: 'transparent'
152
149
  }, !ownerState.selected && ownerState.isHighlighting && {
153
- color: theme.palette.getContrastText(alpha(theme.palette.primary.light, 0.6)),
150
+ opacity: 0.7,
154
151
  [`&.${pickersDayClasses.dayOutsideMonth}`]: {
155
- color: alpha(theme.palette.getContrastText(theme.palette.primary.light), 0.4)
152
+ opacity: 0.4
156
153
  }
157
154
  }, ownerState.draggable && {
158
155
  cursor: 'grab'
@@ -151,6 +151,18 @@ DesktopDateRangePicker.propTypes = {
151
151
  * Defaults to localized format based on the used `views`.
152
152
  */
153
153
  format: PropTypes.string,
154
+ /**
155
+ * Pass a ref to the `input` element.
156
+ * Ignored if the field has several inputs.
157
+ */
158
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
159
+ current: PropTypes.object
160
+ })]),
161
+ /**
162
+ * The label content.
163
+ * Ignored if the field has several inputs.
164
+ */
165
+ label: PropTypes.node,
154
166
  /**
155
167
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
156
168
  * Can be used to preload information and show it in calendar.
@@ -154,6 +154,18 @@ MobileDateRangePicker.propTypes = {
154
154
  * Defaults to localized format based on the used `views`.
155
155
  */
156
156
  format: PropTypes.string,
157
+ /**
158
+ * Pass a ref to the `input` element.
159
+ * Ignored if the field has several inputs.
160
+ */
161
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
162
+ current: PropTypes.object
163
+ })]),
164
+ /**
165
+ * The label content.
166
+ * Ignored if the field has several inputs.
167
+ */
168
+ label: PropTypes.node,
157
169
  /**
158
170
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
159
171
  * Can be used to preload information and show it in calendar.
@@ -283,6 +283,8 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
283
283
  * The system prop, which allows defining system overrides as well as additional CSS styles.
284
284
  */
285
285
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
286
+ unstableEndFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
287
+ unstableStartFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
286
288
  /**
287
289
  * The selected value.
288
290
  * Used when the component is controlled.
@@ -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 = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"],
3
+ const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
4
4
  _excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
5
5
  _excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
6
6
  import * as React from 'react';
@@ -61,7 +61,10 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
61
61
  disableFuture,
62
62
  disablePast,
63
63
  selectedSections,
64
- onSelectedSectionsChange
64
+ onSelectedSectionsChange,
65
+ unstableStartFieldRef,
66
+ unstableEndFieldRef,
67
+ autoFocus
65
68
  } = themeProps,
66
69
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
67
70
  const slots = innerSlots ?? uncapitalizeObjectKeys(components);
@@ -81,6 +84,9 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
81
84
  const startTextFieldProps = useSlotProps({
82
85
  elementType: TextField,
83
86
  externalSlotProps: slotProps?.textField,
87
+ additionalProps: {
88
+ autoFocus
89
+ },
84
90
  ownerState: _extends({}, ownerState, {
85
91
  position: 'start'
86
92
  })
@@ -125,7 +131,9 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
125
131
  startTextFieldProps,
126
132
  endTextFieldProps,
127
133
  startInputRef: startTextFieldProps.inputRef,
128
- endInputRef: endTextFieldProps.inputRef
134
+ unstableStartFieldRef,
135
+ endInputRef: endTextFieldProps.inputRef,
136
+ unstableEndFieldRef
129
137
  }),
130
138
  {
131
139
  startDate: {
@@ -175,6 +183,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
175
183
  * @default `utils.is12HourCycleInCurrentLocale()`
176
184
  */
177
185
  ampm: PropTypes.bool,
186
+ autoFocus: PropTypes.bool,
178
187
  className: PropTypes.string,
179
188
  /**
180
189
  * Overridable components.
@@ -340,6 +349,8 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
340
349
  * The system prop, which allows defining system overrides as well as additional CSS styles.
341
350
  */
342
351
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
352
+ unstableEndFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
353
+ unstableStartFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
343
354
  /**
344
355
  * The selected value.
345
356
  * Used when the component is controlled.
@@ -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 = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"],
3
+ const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
4
4
  _excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
5
5
  _excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
6
6
  import * as React from 'react';
@@ -56,7 +56,10 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
56
56
  disableFuture,
57
57
  disablePast,
58
58
  selectedSections,
59
- onSelectedSectionsChange
59
+ onSelectedSectionsChange,
60
+ unstableStartFieldRef,
61
+ unstableEndFieldRef,
62
+ autoFocus
60
63
  } = themeProps,
61
64
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
62
65
  const slots = innerSlots ?? uncapitalizeObjectKeys(components);
@@ -76,6 +79,9 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
76
79
  const startTextFieldProps = useSlotProps({
77
80
  elementType: TextField,
78
81
  externalSlotProps: slotProps?.textField,
82
+ additionalProps: {
83
+ autoFocus
84
+ },
79
85
  ownerState: _extends({}, ownerState, {
80
86
  position: 'start'
81
87
  })
@@ -115,7 +121,9 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
115
121
  startTextFieldProps,
116
122
  endTextFieldProps,
117
123
  startInputRef: startTextFieldProps.inputRef,
118
- endInputRef: endTextFieldProps.inputRef
124
+ unstableStartFieldRef,
125
+ endInputRef: endTextFieldProps.inputRef,
126
+ unstableEndFieldRef
119
127
  }),
120
128
  {
121
129
  startDate: {
@@ -165,6 +173,7 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
165
173
  * @default `utils.is12HourCycleInCurrentLocale()`
166
174
  */
167
175
  ampm: PropTypes.bool,
176
+ autoFocus: PropTypes.bool,
168
177
  className: PropTypes.string,
169
178
  /**
170
179
  * Overridable components.
@@ -306,6 +315,8 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
306
315
  * The system prop, which allows defining system overrides as well as additional CSS styles.
307
316
  */
308
317
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
318
+ unstableEndFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
319
+ unstableStartFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
309
320
  /**
310
321
  * The selected value.
311
322
  * Used when the component is controlled.
@@ -51,6 +51,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
51
51
  })
52
52
  }));
53
53
  });
54
+ SingleInputDateRangeField.fieldType = 'single-input';
54
55
  process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
55
56
  // ----------------------------- Warning --------------------------------
56
57
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -250,6 +251,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
250
251
  * The system prop that allows defining system overrides as well as additional CSS styles.
251
252
  */
252
253
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
254
+ /**
255
+ * The ref object used to imperatively interact with the field.
256
+ */
257
+ unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
253
258
  /**
254
259
  * The selected value.
255
260
  * Used when the component is controlled.
@@ -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 = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"];
3
+ const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
4
4
  import { useUtils, useDefaultDates, applyDefaultDate, useField } from '@mui/x-date-pickers/internals';
5
5
  import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
6
6
  import { validateDateRange } from '../internal/hooks/validation/useDateRangeValidation';
@@ -33,7 +33,8 @@ export const useSingleInputDateRangeField = ({
33
33
  disableFuture,
34
34
  disablePast,
35
35
  selectedSections,
36
- onSelectedSectionsChange
36
+ onSelectedSectionsChange,
37
+ unstableFieldRef
37
38
  } = _useDefaultizedDateRa,
38
39
  other = _objectWithoutPropertiesLoose(_useDefaultizedDateRa, _excluded);
39
40
  return useField({
@@ -52,7 +53,8 @@ export const useSingleInputDateRangeField = ({
52
53
  disableFuture,
53
54
  disablePast,
54
55
  selectedSections,
55
- onSelectedSectionsChange
56
+ onSelectedSectionsChange,
57
+ unstableFieldRef
56
58
  },
57
59
  valueManager: rangeValueManager,
58
60
  fieldValueManager: rangeFieldValueManager,
@@ -51,6 +51,7 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
51
51
  })
52
52
  }));
53
53
  });
54
+ SingleInputDateTimeRangeField.fieldType = 'single-input';
54
55
  process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes = {
55
56
  // ----------------------------- Warning --------------------------------
56
57
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -298,6 +299,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
298
299
  * The system prop that allows defining system overrides as well as additional CSS styles.
299
300
  */
300
301
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
302
+ /**
303
+ * The ref object used to imperatively interact with the field.
304
+ */
305
+ unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
301
306
  /**
302
307
  * The selected value.
303
308
  * Used when the component is controlled.
@@ -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 = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange"];
3
+ const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
4
4
  import { useUtils, useField, applyDefaultDate, useDefaultDates } from '@mui/x-date-pickers/internals';
5
5
  import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
6
6
  import { validateDateTimeRange } from '../internal/hooks/validation/useDateTimeRangeValidation';
@@ -43,7 +43,8 @@ export const useSingleInputDateTimeRangeField = ({
43
43
  shouldDisableTime,
44
44
  disableIgnoringDatePartForTimeValidation,
45
45
  selectedSections,
46
- onSelectedSectionsChange
46
+ onSelectedSectionsChange,
47
+ unstableFieldRef
47
48
  } = _useDefaultizedTimeRa,
48
49
  other = _objectWithoutPropertiesLoose(_useDefaultizedTimeRa, _excluded);
49
50
  return useField({
@@ -67,7 +68,8 @@ export const useSingleInputDateTimeRangeField = ({
67
68
  shouldDisableTime,
68
69
  disableIgnoringDatePartForTimeValidation,
69
70
  selectedSections,
70
- onSelectedSectionsChange
71
+ onSelectedSectionsChange,
72
+ unstableFieldRef
71
73
  },
72
74
  valueManager: rangeValueManager,
73
75
  fieldValueManager: rangeFieldValueManager,
@@ -51,6 +51,7 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
51
51
  })
52
52
  }));
53
53
  });
54
+ SingleInputTimeRangeField.fieldType = 'single-input';
54
55
  process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
55
56
  // ----------------------------- Warning --------------------------------
56
57
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -274,6 +275,10 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
274
275
  * The system prop that allows defining system overrides as well as additional CSS styles.
275
276
  */
276
277
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
278
+ /**
279
+ * The ref object used to imperatively interact with the field.
280
+ */
281
+ unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
277
282
  /**
278
283
  * The selected value.
279
284
  * Used when the component is controlled.
@@ -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 = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"];
3
+ const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
4
4
  import { useUtils, useField } from '@mui/x-date-pickers/internals';
5
5
  import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
6
6
  import { validateTimeRange } from '../internal/hooks/validation/useTimeRangeValidation';
@@ -33,7 +33,8 @@ export const useSingleInputTimeRangeField = ({
33
33
  disableFuture,
34
34
  disablePast,
35
35
  selectedSections,
36
- onSelectedSectionsChange
36
+ onSelectedSectionsChange,
37
+ unstableFieldRef
37
38
  } = _useDefaultizedTimeRa,
38
39
  other = _objectWithoutPropertiesLoose(_useDefaultizedTimeRa, _excluded);
39
40
  return useField({
@@ -53,7 +54,8 @@ export const useSingleInputTimeRangeField = ({
53
54
  disableFuture,
54
55
  disablePast,
55
56
  selectedSections,
56
- onSelectedSectionsChange
57
+ onSelectedSectionsChange,
58
+ unstableFieldRef
57
59
  },
58
60
  valueManager: rangeValueManager,
59
61
  fieldValueManager: rangeFieldValueManager,
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v6.0.2
2
+ * @mui/x-date-pickers-pro v6.0.4
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,11 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { resolveComponentProps, useSlotProps } from '@mui/base/utils';
3
+ import { useSlotProps } from '@mui/base/utils';
4
4
  import { useLicenseVerifier } from '@mui/x-license-pro';
5
5
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
6
6
  import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
7
7
  import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickersPopper } from '@mui/x-date-pickers/internals';
8
- import { useRangePickerInputProps } from '../useRangePickerInputProps';
8
+ import { useEnrichedRangePickerFieldProps } from '../useEnrichedRangePickerFieldProps';
9
9
  import { getReleaseInfo } from '../../utils/releaseInfo';
10
10
  import { useRangePosition } from '../useRangePosition';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -23,17 +23,20 @@ export const useDesktopRangePicker = ({
23
23
  className,
24
24
  sx,
25
25
  format,
26
+ label,
27
+ inputRef,
26
28
  readOnly,
27
29
  disabled,
28
30
  autoFocus,
29
31
  disableOpenPicker,
30
32
  localeText
31
33
  } = props;
32
- const fieldRef = React.useRef(null);
34
+ const fieldContainerRef = React.useRef(null);
33
35
  const popperRef = React.useRef(null);
34
36
  const {
35
37
  rangePosition,
36
- onRangePositionChange
38
+ onRangePositionChange,
39
+ singleInputFieldRef
37
40
  } = useRangePosition(props);
38
41
  const {
39
42
  open,
@@ -55,25 +58,14 @@ export const useDesktopRangePicker = ({
55
58
  });
56
59
  const handleBlur = () => {
57
60
  executeInTheNextEventLoopTick(() => {
58
- if (fieldRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
61
+ if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
59
62
  return;
60
63
  }
61
64
  actions.onDismiss();
62
65
  });
63
66
  };
64
- const fieldSlotProps = useRangePickerInputProps({
65
- wrapperVariant: 'desktop',
66
- open,
67
- actions,
68
- readOnly,
69
- disabled,
70
- disableOpenPicker,
71
- localeText,
72
- onBlur: handleBlur,
73
- rangePosition,
74
- onRangePositionChange
75
- });
76
67
  const Field = slots.field;
68
+ const fieldType = Field.fieldType ?? 'multi-input';
77
69
  const fieldProps = useSlotProps({
78
70
  elementType: Field,
79
71
  externalSlotProps: slotProps?.field,
@@ -84,25 +76,28 @@ export const useDesktopRangePicker = ({
84
76
  sx,
85
77
  format,
86
78
  autoFocus: autoFocus && !props.open,
87
- ref: fieldRef
79
+ ref: fieldContainerRef
80
+ }, fieldType === 'single-input' && {
81
+ inputRef
88
82
  }),
89
83
  ownerState: props
90
84
  });
91
- const slotsForField = _extends({
92
- textField: slots.textField,
93
- root: slots.fieldRoot,
94
- separator: slots.fieldSeparator
95
- }, fieldProps.slots);
96
- const slotPropsForField = _extends({}, fieldProps.slotProps, {
97
- textField: ownerState => {
98
- const externalInputProps = resolveComponentProps(slotProps?.textField, ownerState);
99
- return _extends({}, ownerState.position === 'start' ? fieldSlotProps.startInput : fieldSlotProps.endInput, externalInputProps);
100
- },
101
- root: ownerState => {
102
- const externalRootProps = resolveComponentProps(slotProps?.fieldRoot, ownerState);
103
- return _extends({}, externalRootProps, fieldSlotProps.root);
104
- },
105
- separator: slotProps?.fieldSeparator
85
+ const enrichedFieldProps = useEnrichedRangePickerFieldProps({
86
+ wrapperVariant: 'desktop',
87
+ fieldType,
88
+ open,
89
+ actions,
90
+ readOnly,
91
+ disableOpenPicker,
92
+ label,
93
+ localeText,
94
+ onBlur: handleBlur,
95
+ rangePosition,
96
+ onRangePositionChange,
97
+ singleInputFieldRef,
98
+ pickerSlotProps: slotProps,
99
+ pickerSlots: slots,
100
+ fieldProps
106
101
  });
107
102
  const slotPropsForLayout = _extends({}, slotProps, {
108
103
  toolbar: _extends({}, slotProps?.toolbar, {
@@ -113,13 +108,10 @@ export const useDesktopRangePicker = ({
113
108
  const Layout = slots?.layout ?? PickersLayout;
114
109
  const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
115
110
  localeText: localeText,
116
- children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
117
- slots: slotsForField,
118
- slotProps: slotPropsForField
119
- })), /*#__PURE__*/_jsx(PickersPopper, _extends({
111
+ children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, _extends({
120
112
  role: "tooltip",
121
113
  containerRef: popperRef,
122
- anchorEl: fieldRef.current,
114
+ anchorEl: fieldContainerRef.current,
123
115
  onBlur: handleBlur
124
116
  }, actions, {
125
117
  open: open,