@mui/x-date-pickers-pro 7.0.0-beta.7 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +266 -12
  2. package/DateRangeCalendar/DateRangeCalendar.js +17 -22
  3. package/DateRangeCalendar/useDragRange.js +1 -2
  4. package/DateRangePicker/DateRangePicker.js +1 -1
  5. package/DateRangePicker/shared.js +3 -5
  6. package/DateRangePickerDay/DateRangePickerDay.d.ts +5 -0
  7. package/DateRangePickerDay/DateRangePickerDay.js +107 -43
  8. package/DateTimeRangePicker/DateTimeRangePicker.d.ts +10 -0
  9. package/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  10. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +4 -5
  11. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -3
  12. package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
  13. package/DateTimeRangePicker/shared.d.ts +5 -4
  14. package/DateTimeRangePicker/shared.js +9 -10
  15. package/DesktopDateRangePicker/DesktopDateRangePicker.js +6 -10
  16. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +10 -0
  17. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +31 -28
  18. package/MobileDateRangePicker/MobileDateRangePicker.js +5 -9
  19. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +10 -0
  20. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +20 -14
  21. package/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -15
  22. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -15
  23. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +16 -14
  24. package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +1 -1
  25. package/README.md +1 -1
  26. package/SingleInputDateRangeField/SingleInputDateRangeField.js +8 -4
  27. package/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
  28. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +8 -4
  29. package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
  30. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +7 -3
  31. package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
  32. package/StaticDateRangePicker/StaticDateRangePicker.js +4 -5
  33. package/index.js +1 -1
  34. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -11
  35. package/internals/hooks/useEnrichedRangePickerFieldProps.js +26 -32
  36. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -10
  37. package/internals/hooks/useMultiInputFieldSelectedSections.js +3 -6
  38. package/internals/hooks/useRangePosition.js +3 -5
  39. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -18
  40. package/internals/models/dateRange.d.ts +3 -3
  41. package/internals/models/dateTimeRange.d.ts +2 -2
  42. package/internals/models/timeRange.d.ts +2 -2
  43. package/internals/utils/releaseInfo.js +1 -1
  44. package/internals/utils/validation/validateDateRange.js +2 -2
  45. package/internals/utils/validation/validateDateTimeRange.js +2 -2
  46. package/internals/utils/valueManagers.d.ts +3 -1
  47. package/internals/utils/valueManagers.js +9 -7
  48. package/models/fields.d.ts +8 -1
  49. package/modern/DateRangeCalendar/DateRangeCalendar.js +1 -1
  50. package/modern/DateRangePicker/DateRangePicker.js +1 -1
  51. package/modern/DateRangePickerDay/DateRangePickerDay.js +107 -43
  52. package/modern/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  53. package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
  54. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
  55. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
  56. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
  57. package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
  58. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
  59. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
  60. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
  61. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
  62. package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
  63. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
  64. package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
  65. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  66. package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
  67. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
  68. package/modern/index.js +1 -1
  69. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +1 -1
  70. package/modern/internals/utils/releaseInfo.js +1 -1
  71. package/modern/internals/utils/valueManagers.js +7 -5
  72. package/node/DateRangeCalendar/DateRangeCalendar.js +1 -1
  73. package/node/DateRangePicker/DateRangePicker.js +1 -1
  74. package/node/DateRangePickerDay/DateRangePickerDay.js +107 -43
  75. package/node/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  76. package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
  77. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
  78. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
  79. package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
  80. package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
  81. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
  82. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
  83. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
  84. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
  85. package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +7 -1
  86. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
  87. package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +7 -1
  88. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  89. package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +7 -1
  90. package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
  91. package/node/index.js +1 -1
  92. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +1 -1
  93. package/node/internals/utils/releaseInfo.js +1 -1
  94. package/node/internals/utils/valueManagers.js +9 -6
  95. package/package.json +7 -7
  96. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +0 -9
  97. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -52
  98. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -51
  99. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -59
@@ -14,7 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const releaseInfo = getReleaseInfo();
16
16
  export const useDesktopRangePicker = _ref => {
17
- var _props$openTo, _fieldType, _initialView$current, _slots$layout;
18
17
  let {
19
18
  props
20
19
  } = _ref,
@@ -46,8 +45,8 @@ export const useDesktopRangePicker = _ref => {
46
45
  const popperRef = React.useRef(null);
47
46
  const startFieldRef = React.useRef(null);
48
47
  const endFieldRef = React.useRef(null);
49
- const initialView = React.useRef((_props$openTo = props.openTo) != null ? _props$openTo : null);
50
- const fieldType = (_fieldType = slots.field.fieldType) != null ? _fieldType : 'multi-input';
48
+ const initialView = React.useRef(props.openTo ?? null);
49
+ const fieldType = slots.field.fieldType ?? 'multi-input';
51
50
  const {
52
51
  rangePosition,
53
52
  onRangePositionChange
@@ -77,8 +76,7 @@ export const useDesktopRangePicker = _ref => {
77
76
  }, []);
78
77
  const handleBlur = () => {
79
78
  executeInTheNextEventLoopTick(() => {
80
- var _fieldContainerRef$cu, _popperRef$current;
81
- if ((_fieldContainerRef$cu = fieldContainerRef.current) != null && _fieldContainerRef$cu.contains(getActiveElement(document)) || (_popperRef$current = popperRef.current) != null && _popperRef$current.contains(getActiveElement(document))) {
79
+ if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
82
80
  return;
83
81
  }
84
82
  actions.onDismiss();
@@ -87,7 +85,7 @@ export const useDesktopRangePicker = _ref => {
87
85
  const Field = slots.field;
88
86
  const fieldProps = useSlotProps({
89
87
  elementType: Field,
90
- externalSlotProps: slotProps == null ? void 0 : slotProps.field,
88
+ externalSlotProps: slotProps?.field,
91
89
  additionalProps: _extends({}, pickerFieldProps, {
92
90
  readOnly,
93
91
  disabled,
@@ -126,20 +124,20 @@ export const useDesktopRangePicker = _ref => {
126
124
  startFieldRef,
127
125
  endFieldRef,
128
126
  currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
129
- initialView: (_initialView$current = initialView.current) != null ? _initialView$current : undefined,
127
+ initialView: initialView.current ?? undefined,
130
128
  onViewChange: layoutProps.onViewChange
131
129
  });
132
130
  const slotPropsForLayout = _extends({}, slotProps, {
133
- tabs: _extends({}, slotProps == null ? void 0 : slotProps.tabs, {
131
+ tabs: _extends({}, slotProps?.tabs, {
134
132
  rangePosition,
135
133
  onRangePositionChange
136
134
  }),
137
- toolbar: _extends({}, slotProps == null ? void 0 : slotProps.toolbar, {
135
+ toolbar: _extends({}, slotProps?.toolbar, {
138
136
  rangePosition,
139
137
  onRangePositionChange
140
138
  })
141
139
  });
142
- const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickersLayout;
140
+ const Layout = slots?.layout ?? PickersLayout;
143
141
  const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
144
142
  localeText: localeText,
145
143
  children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, _extends({
@@ -154,7 +152,7 @@ export const useDesktopRangePicker = _ref => {
154
152
  slotProps: slotProps,
155
153
  shouldRestoreFocus: shouldRestoreFocus,
156
154
  reduceAnimations: reduceAnimations,
157
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
155
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
158
156
  slots: slots,
159
157
  slotProps: slotPropsForLayout,
160
158
  children: renderCurrentView()
@@ -32,12 +32,11 @@ const useMultiInputFieldSlotProps = ({
32
32
  const handleEndFieldRef = useForkRef(fieldProps.unstableEndFieldRef, endFieldRef);
33
33
  const previousRangePosition = React.useRef(rangePosition);
34
34
  React.useEffect(() => {
35
- var _currentFieldRef$curr;
36
35
  if (!open) {
37
36
  return;
38
37
  }
39
38
  const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
40
- (_currentFieldRef$curr = currentFieldRef.current) == null || _currentFieldRef$curr.focusField();
39
+ currentFieldRef.current?.focusField();
41
40
  if (!currentFieldRef.current || !currentView) {
42
41
  // could happen when the user is switching between the inputs
43
42
  previousRangePosition.current = rangePosition;
@@ -68,7 +67,7 @@ const useMultiInputFieldSlotProps = ({
68
67
  if (open) {
69
68
  onRangePositionChange('start');
70
69
  if (previousRangePosition.current !== 'start' && initialView) {
71
- onViewChange == null || onViewChange(initialView);
70
+ onViewChange?.(initialView);
72
71
  }
73
72
  }
74
73
  };
@@ -76,24 +75,23 @@ const useMultiInputFieldSlotProps = ({
76
75
  if (open) {
77
76
  onRangePositionChange('end');
78
77
  if (previousRangePosition.current !== 'end' && initialView) {
79
- onViewChange == null || onViewChange(initialView);
78
+ onViewChange?.(initialView);
80
79
  }
81
80
  }
82
81
  };
83
82
  const slots = _extends({
84
- textField: pickerSlots == null ? void 0 : pickerSlots.textField,
85
- root: pickerSlots == null ? void 0 : pickerSlots.fieldRoot,
86
- separator: pickerSlots == null ? void 0 : pickerSlots.fieldSeparator
83
+ textField: pickerSlots?.textField,
84
+ root: pickerSlots?.fieldRoot,
85
+ separator: pickerSlots?.fieldSeparator
87
86
  }, fieldProps.slots);
88
87
  const slotProps = _extends({}, fieldProps.slotProps, {
89
88
  textField: ownerState => {
90
- const resolvedComponentProps = resolveComponentProps(pickerSlotProps == null ? void 0 : pickerSlotProps.textField, ownerState);
89
+ const resolvedComponentProps = resolveComponentProps(pickerSlotProps?.textField, ownerState);
91
90
  let textFieldProps;
92
91
  let InputProps;
93
92
  if (ownerState.position === 'start') {
94
- var _inLocaleText$start;
95
93
  textFieldProps = _extends({
96
- label: (_inLocaleText$start = inLocaleText == null ? void 0 : inLocaleText.start) != null ? _inLocaleText$start : localeText.start,
94
+ label: inLocaleText?.start ?? localeText.start,
97
95
  onKeyDown: onSpaceOrEnter(openRangeStartSelection),
98
96
  onFocus: handleFocusStart,
99
97
  focused: open ? rangePosition === 'start' : undefined
@@ -103,14 +101,13 @@ const useMultiInputFieldSlotProps = ({
103
101
  readOnly: true
104
102
  });
105
103
  if (anchorRef) {
106
- InputProps = _extends({}, resolvedComponentProps == null ? void 0 : resolvedComponentProps.InputProps, {
104
+ InputProps = _extends({}, resolvedComponentProps?.InputProps, {
107
105
  ref: anchorRef
108
106
  });
109
107
  }
110
108
  } else {
111
- var _inLocaleText$end;
112
109
  textFieldProps = _extends({
113
- label: (_inLocaleText$end = inLocaleText == null ? void 0 : inLocaleText.end) != null ? _inLocaleText$end : localeText.end,
110
+ label: inLocaleText?.end ?? localeText.end,
114
111
  onKeyDown: onSpaceOrEnter(openRangeEndSelection),
115
112
  onFocus: handleFocusEnd,
116
113
  focused: open ? rangePosition === 'end' : undefined
@@ -119,11 +116,11 @@ const useMultiInputFieldSlotProps = ({
119
116
  }, wrapperVariant === 'mobile' && {
120
117
  readOnly: true
121
118
  });
122
- InputProps = resolvedComponentProps == null ? void 0 : resolvedComponentProps.InputProps;
119
+ InputProps = resolvedComponentProps?.InputProps;
123
120
  }
124
121
  return _extends({}, labelId != null && {
125
122
  id: `${labelId}-${ownerState.position}`
126
- }, textFieldProps, resolveComponentProps(pickerSlotProps == null ? void 0 : pickerSlotProps.textField, ownerState), {
123
+ }, textFieldProps, resolveComponentProps(pickerSlotProps?.textField, ownerState), {
127
124
  InputProps
128
125
  });
129
126
  },
@@ -131,9 +128,9 @@ const useMultiInputFieldSlotProps = ({
131
128
  const rootProps = {
132
129
  onBlur
133
130
  };
134
- return _extends({}, rootProps, resolveComponentProps(pickerSlotProps == null ? void 0 : pickerSlotProps.fieldRoot, ownerState));
131
+ return _extends({}, rootProps, resolveComponentProps(pickerSlotProps?.fieldRoot, ownerState));
135
132
  },
136
- separator: pickerSlotProps == null ? void 0 : pickerSlotProps.fieldSeparator
133
+ separator: pickerSlotProps?.fieldSeparator
137
134
  });
138
135
 
139
136
  /* TODO: remove this when a clearable behavior for multiple input range fields is implemented */
@@ -177,28 +174,25 @@ const useSingleInputFieldSlotProps = ({
177
174
 
178
175
  // bring back focus to the field with the current view section selected
179
176
  if (currentView) {
180
- var _startFieldRef$curren;
181
177
  const sections = startFieldRef.current.getSections().map(section => section.type);
182
178
  const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
183
- (_startFieldRef$curren = startFieldRef.current) == null || _startFieldRef$curren.focusField(newSelectedSection);
179
+ startFieldRef.current?.focusField(newSelectedSection);
184
180
  }
185
181
  }, [rangePosition, open, currentView, startFieldRef]);
186
182
  const updateRangePosition = () => {
187
- var _startFieldRef$curren2, _startFieldRef$curren3;
188
- if (!((_startFieldRef$curren2 = startFieldRef.current) != null && _startFieldRef$curren2.isFieldFocused())) {
183
+ if (!startFieldRef.current?.isFieldFocused()) {
189
184
  return;
190
185
  }
191
186
  const sections = startFieldRef.current.getSections();
192
- const activeSectionIndex = (_startFieldRef$curren3 = startFieldRef.current) == null ? void 0 : _startFieldRef$curren3.getActiveSectionIndex();
187
+ const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
193
188
  const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
194
189
  if (domRangePosition != null && domRangePosition !== rangePosition) {
195
190
  onRangePositionChange(domRangePosition);
196
191
  }
197
192
  };
198
193
  const handleSelectedSectionsChange = useEventCallback(selectedSection => {
199
- var _fieldProps$onSelecte;
200
194
  setTimeout(updateRangePosition);
201
- (_fieldProps$onSelecte = fieldProps.onSelectedSectionsChange) == null || _fieldProps$onSelecte.call(fieldProps, selectedSection);
195
+ fieldProps.onSelectedSectionsChange?.(selectedSection);
202
196
  });
203
197
  const openPicker = event => {
204
198
  event.stopPropagation();
@@ -207,14 +201,14 @@ const useSingleInputFieldSlotProps = ({
207
201
  }
208
202
  };
209
203
  const slots = _extends({}, fieldProps.slots, {
210
- textField: pickerSlots == null ? void 0 : pickerSlots.textField,
211
- clearButton: pickerSlots == null ? void 0 : pickerSlots.clearButton,
212
- clearIcon: pickerSlots == null ? void 0 : pickerSlots.clearIcon
204
+ textField: pickerSlots?.textField,
205
+ clearButton: pickerSlots?.clearButton,
206
+ clearIcon: pickerSlots?.clearIcon
213
207
  });
214
208
  const slotProps = _extends({}, fieldProps.slotProps, {
215
- textField: pickerSlotProps == null ? void 0 : pickerSlotProps.textField,
216
- clearButton: pickerSlots == null ? void 0 : pickerSlots.clearButton,
217
- clearIcon: pickerSlots == null ? void 0 : pickerSlots.clearIcon
209
+ textField: pickerSlotProps?.textField,
210
+ clearButton: pickerSlots?.clearButton,
211
+ clearIcon: pickerSlots?.clearIcon
218
212
  });
219
213
  const enrichedFieldProps = _extends({}, fieldProps, {
220
214
  slots,
@@ -226,8 +220,8 @@ const useSingleInputFieldSlotProps = ({
226
220
  onBlur,
227
221
  InputProps: _extends({
228
222
  ref: anchorRef
229
- }, fieldProps == null ? void 0 : fieldProps.InputProps),
230
- focused: open
223
+ }, fieldProps?.InputProps),
224
+ focused: open ? true : undefined
231
225
  }, labelId != null && {
232
226
  id: labelId
233
227
  }, wrapperVariant === 'mobile' && {
@@ -15,7 +15,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
16
  const releaseInfo = getReleaseInfo();
17
17
  export const useMobileRangePicker = _ref => {
18
- var _fieldType, _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$layout;
19
18
  let {
20
19
  props
21
20
  } = _ref,
@@ -42,7 +41,7 @@ export const useMobileRangePicker = _ref => {
42
41
  } = props;
43
42
  const startFieldRef = React.useRef(null);
44
43
  const endFieldRef = React.useRef(null);
45
- const fieldType = (_fieldType = slots.field.fieldType) != null ? _fieldType : 'multi-input';
44
+ const fieldType = slots.field.fieldType ?? 'multi-input';
46
45
  const {
47
46
  rangePosition,
48
47
  onRangePositionChange
@@ -68,9 +67,9 @@ export const useMobileRangePicker = _ref => {
68
67
  const Field = slots.field;
69
68
  const fieldProps = useSlotProps({
70
69
  elementType: Field,
71
- externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
70
+ externalSlotProps: innerSlotProps?.field,
72
71
  additionalProps: _extends({}, pickerFieldProps, {
73
- readOnly: readOnly != null ? readOnly : true,
72
+ readOnly: readOnly ?? true,
74
73
  disabled,
75
74
  className,
76
75
  sx,
@@ -86,7 +85,7 @@ export const useMobileRangePicker = _ref => {
86
85
  } : {}),
87
86
  ownerState: props
88
87
  });
89
- const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null || (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
88
+ const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
90
89
  const enrichedFieldProps = useEnrichedRangePickerFieldProps({
91
90
  wrapperVariant: 'mobile',
92
91
  fieldType,
@@ -106,17 +105,17 @@ export const useMobileRangePicker = _ref => {
106
105
  endFieldRef
107
106
  });
108
107
  const slotPropsForLayout = _extends({}, innerSlotProps, {
109
- tabs: _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.tabs, {
108
+ tabs: _extends({}, innerSlotProps?.tabs, {
110
109
  rangePosition,
111
110
  onRangePositionChange
112
111
  }),
113
- toolbar: _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.toolbar, {
112
+ toolbar: _extends({}, innerSlotProps?.toolbar, {
114
113
  titleId: labelId,
115
114
  rangePosition,
116
115
  onRangePositionChange
117
116
  })
118
117
  });
119
- const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickersLayout;
118
+ const Layout = slots?.layout ?? PickersLayout;
120
119
  const finalLocaleText = _extends({}, contextLocaleText, localeText);
121
120
  let labelledById = pickerParams.valueType === 'date-time' ? `${labelId}-start-toolbar ${labelId}-end-toolbar` : labelId;
122
121
  if (isToolbarHidden) {
@@ -136,7 +135,7 @@ export const useMobileRangePicker = _ref => {
136
135
  const slotProps = _extends({}, innerSlotProps, {
137
136
  mobilePaper: _extends({
138
137
  'aria-labelledby': labelledById
139
- }, innerSlotProps == null ? void 0 : innerSlotProps.mobilePaper)
138
+ }, innerSlotProps?.mobilePaper)
140
139
  });
141
140
  const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
142
141
  localeText: localeText,
@@ -144,7 +143,7 @@ export const useMobileRangePicker = _ref => {
144
143
  open: open,
145
144
  slots: slots,
146
145
  slotProps: slotProps,
147
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
146
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
148
147
  slots: slots,
149
148
  slotProps: slotPropsForLayout,
150
149
  children: renderCurrentView()
@@ -2,10 +2,9 @@ import * as React from 'react';
2
2
  import useForkRef from '@mui/utils/useForkRef';
3
3
  import useEventCallback from '@mui/utils/useEventCallback';
4
4
  export const useMultiInputFieldSelectedSections = params => {
5
- var _params$selectedSecti;
6
5
  const unstableEndFieldRef = React.useRef(null);
7
6
  const handleUnstableEndFieldRef = useForkRef(params.unstableEndFieldRef, unstableEndFieldRef);
8
- const [startSelectedSection, setStartSelectedSection] = React.useState((_params$selectedSecti = params.selectedSections) != null ? _params$selectedSecti : null);
7
+ const [startSelectedSection, setStartSelectedSection] = React.useState(params.selectedSections ?? null);
9
8
  const [endSelectedSection, setEndSelectedSection] = React.useState(null);
10
9
  const getActiveField = () => {
11
10
  if (unstableEndFieldRef.current && unstableEndFieldRef.current.isFieldFocused()) {
@@ -16,15 +15,13 @@ export const useMultiInputFieldSelectedSections = params => {
16
15
  const handleStartSelectedSectionChange = useEventCallback(newSelectedSections => {
17
16
  setStartSelectedSection(newSelectedSections);
18
17
  if (getActiveField() === 'start') {
19
- var _params$onSelectedSec;
20
- (_params$onSelectedSec = params.onSelectedSectionsChange) == null || _params$onSelectedSec.call(params, newSelectedSections);
18
+ params.onSelectedSectionsChange?.(newSelectedSections);
21
19
  }
22
20
  });
23
21
  const handleEndSelectedSectionChange = useEventCallback(newSelectedSections => {
24
22
  setEndSelectedSection(newSelectedSections);
25
23
  if (getActiveField() === 'end') {
26
- var _params$onSelectedSec2;
27
- (_params$onSelectedSec2 = params.onSelectedSectionsChange) == null || _params$onSelectedSec2.call(params, newSelectedSections);
24
+ params.onSelectedSectionsChange?.(newSelectedSections);
28
25
  }
29
26
  });
30
27
  const activeField = getActiveField();
@@ -1,18 +1,17 @@
1
1
  import useControlled from '@mui/utils/useControlled';
2
2
  import useEventCallback from '@mui/utils/useEventCallback';
3
3
  export const useRangePosition = (props, singleInputFieldRef) => {
4
- var _props$defaultRangePo;
5
4
  const [rangePosition, setRangePosition] = useControlled({
6
5
  name: 'useRangePosition',
7
6
  state: 'rangePosition',
8
7
  controlled: props.rangePosition,
9
- default: (_props$defaultRangePo = props.defaultRangePosition) != null ? _props$defaultRangePo : 'start'
8
+ default: props.defaultRangePosition ?? 'start'
10
9
  });
11
10
 
12
11
  // When using a single input field,
13
12
  // we want to select the 1st section of the edited date when updating the range position.
14
13
  const syncRangePositionWithSingleInputField = newRangePosition => {
15
- if ((singleInputFieldRef == null ? void 0 : singleInputFieldRef.current) == null) {
14
+ if (singleInputFieldRef?.current == null) {
16
15
  return;
17
16
  }
18
17
  const sections = singleInputFieldRef.current.getSections();
@@ -20,9 +19,8 @@ export const useRangePosition = (props, singleInputFieldRef) => {
20
19
  singleInputFieldRef.current.setSelectedSections(targetActiveSectionIndex);
21
20
  };
22
21
  const handleRangePositionChange = useEventCallback(newRangePosition => {
23
- var _props$onRangePositio;
24
22
  setRangePosition(newRangePosition);
25
- (_props$onRangePositio = props.onRangePositionChange) == null || _props$onRangePositio.call(props, newRangePosition);
23
+ props.onRangePositionChange?.(newRangePosition);
26
24
  syncRangePositionWithSingleInputField(newRangePosition);
27
25
  });
28
26
  return {
@@ -22,7 +22,6 @@ const PickerStaticLayout = styled(PickersLayout)(({
22
22
  * - StaticDateRangePicker
23
23
  */
24
24
  export const useStaticRangePicker = _ref => {
25
- var _slots$layout;
26
25
  let {
27
26
  props,
28
27
  ref
@@ -46,7 +45,7 @@ export const useStaticRangePicker = _ref => {
46
45
  renderCurrentView
47
46
  } = usePicker(_extends({}, pickerParams, {
48
47
  props,
49
- autoFocusView: autoFocus != null ? autoFocus : false,
48
+ autoFocusView: autoFocus ?? false,
50
49
  fieldRef: undefined,
51
50
  additionalViewProps: {
52
51
  rangePosition,
@@ -54,27 +53,24 @@ export const useStaticRangePicker = _ref => {
54
53
  },
55
54
  wrapperVariant: displayStaticWrapperAs
56
55
  }));
57
- const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickerStaticLayout;
56
+ const Layout = slots?.layout ?? PickerStaticLayout;
58
57
  const slotPropsForLayout = _extends({}, slotProps, {
59
- toolbar: _extends({}, slotProps == null ? void 0 : slotProps.toolbar, {
58
+ toolbar: _extends({}, slotProps?.toolbar, {
60
59
  rangePosition,
61
60
  onRangePositionChange
62
61
  })
63
62
  });
64
- const renderPicker = () => {
65
- var _slotProps$layout, _slotProps$layout2, _slotProps$layout3;
66
- return /*#__PURE__*/_jsx(LocalizationProvider, {
67
- localeText: localeText,
68
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
69
- slots: slots,
70
- slotProps: slotPropsForLayout,
71
- sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps == null || (_slotProps$layout = slotProps.layout) == null ? void 0 : _slotProps$layout.sx) ? slotProps.layout.sx : [slotProps == null || (_slotProps$layout2 = slotProps.layout) == null ? void 0 : _slotProps$layout2.sx])],
72
- className: clsx(className, slotProps == null || (_slotProps$layout3 = slotProps.layout) == null ? void 0 : _slotProps$layout3.className),
73
- ref: ref,
74
- children: renderCurrentView()
75
- }))
76
- });
77
- };
63
+ const renderPicker = () => /*#__PURE__*/_jsx(LocalizationProvider, {
64
+ localeText: localeText,
65
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
66
+ slots: slots,
67
+ slotProps: slotPropsForLayout,
68
+ sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps?.layout?.sx])],
69
+ className: clsx(className, slotProps?.layout?.className),
70
+ ref: ref,
71
+ children: renderCurrentView()
72
+ }))
73
+ });
78
74
  return {
79
75
  renderPicker
80
76
  };
@@ -1,6 +1,6 @@
1
1
  import { BaseDateValidationProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
- import type { DateRangeValidationError, RangeFieldSection, DateRange } from '../../models';
3
+ import { DateRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
4
4
  /**
5
5
  * Props used to validate a day value in range pickers.
6
6
  */
@@ -8,7 +8,7 @@ export interface DayRangeValidationProps<TDate extends PickerValidDate> {
8
8
  /**
9
9
  * Disable specific date.
10
10
  *
11
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
11
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
12
12
  *
13
13
  * @template TDate
14
14
  * @param {TDate} day The date to test.
@@ -17,5 +17,5 @@ export interface DayRangeValidationProps<TDate extends PickerValidDate> {
17
17
  */
18
18
  shouldDisableDate?: (day: TDate, position: 'start' | 'end') => boolean;
19
19
  }
20
- export interface UseDateRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, DayRangeValidationProps<TDate>, BaseDateValidationProps<TDate> {
20
+ export interface UseDateRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, DayRangeValidationProps<TDate>, BaseDateValidationProps<TDate> {
21
21
  }
@@ -1,8 +1,8 @@
1
1
  import { BaseDateValidationProps, TimeValidationProps, MakeOptional, UseFieldInternalProps, DateTimeValidationProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
3
  import { DayRangeValidationProps } from './dateRange';
4
- import { DateTimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
5
- export interface UseDateTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate>, DateTimeValidationProps<TDate> {
4
+ import { DateTimeRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
5
+ export interface UseDateTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate>, DateTimeValidationProps<TDate> {
6
6
  /**
7
7
  * 12h/24h view for hour selection clock.
8
8
  * @default `utils.is12HourCycleInCurrentLocale()`
@@ -1,7 +1,7 @@
1
1
  import { BaseTimeValidationProps, TimeValidationProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
- import { TimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
4
- export interface UseTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, TimeValidationProps<TDate>, BaseTimeValidationProps {
3
+ import { TimeRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
4
+ export interface UseTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, TimeValidationProps<TDate>, BaseTimeValidationProps {
5
5
  /**
6
6
  * 12h/24h view for hour selection clock.
7
7
  * @default `utils.is12HourCycleInCurrentLocale()`
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxMDM3MDgwMDAwMA==";
3
+ const releaseInfo = "MTcxMTU4MDQwMDAwMA==";
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
@@ -17,13 +17,13 @@ export const validateDateRange = ({
17
17
  adapter,
18
18
  value: start,
19
19
  props: _extends({}, otherProps, {
20
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'start'))
20
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'start')
21
21
  })
22
22
  }), validateDate({
23
23
  adapter,
24
24
  value: end,
25
25
  props: _extends({}, otherProps, {
26
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'end'))
26
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'end')
27
27
  })
28
28
  })];
29
29
  if (dateValidations[0] || dateValidations[1]) {
@@ -17,13 +17,13 @@ export const validateDateTimeRange = ({
17
17
  adapter,
18
18
  value: start,
19
19
  props: _extends({}, otherProps, {
20
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'start'))
20
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'start')
21
21
  })
22
22
  }), validateDateTime({
23
23
  adapter,
24
24
  value: end,
25
25
  props: _extends({}, otherProps, {
26
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'end'))
26
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'end')
27
27
  })
28
28
  })];
29
29
  if (dateTimeValidations[0] || dateTimeValidations[1]) {
@@ -3,4 +3,6 @@ import { PickerValidDate } from '@mui/x-date-pickers/models';
3
3
  import type { DateRangeValidationError, DateTimeRangeValidationError, TimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
4
4
  export type RangePickerValueManager<TValue = [any, any], TDate extends PickerValidDate = any, TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
5
5
  export declare const rangeValueManager: RangePickerValueManager;
6
- export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any, RangeFieldSection>;
6
+ export declare const getRangeFieldValueManager: <TDate extends PickerValidDate>({ dateSeparator, }: {
7
+ dateSeparator: string | undefined;
8
+ }) => FieldValueManager<DateRange<TDate>, TDate, RangeFieldSection>;
@@ -17,7 +17,7 @@ export const rangeValueManager = {
17
17
  if (shouldKeepStartDate && shouldKeepEndDate) {
18
18
  return value;
19
19
  }
20
- const referenceDate = referenceDateProp != null ? referenceDateProp : getDefaultReferenceDate(params);
20
+ const referenceDate = referenceDateProp ?? getDefaultReferenceDate(params);
21
21
  return [shouldKeepStartDate ? value[0] : referenceDate, shouldKeepEndDate ? value[1] : referenceDate];
22
22
  },
23
23
  cleanValue: (utils, value) => value.map(date => replaceInvalidDateByNull(utils, date)),
@@ -31,11 +31,13 @@ export const rangeValueManager = {
31
31
  if (timezoneStart != null && timezoneEnd != null && timezoneStart !== timezoneEnd) {
32
32
  throw new Error('MUI X: The timezone of the start and the end date should be the same.');
33
33
  }
34
- return timezoneStart != null ? timezoneStart : timezoneEnd;
34
+ return timezoneStart ?? timezoneEnd;
35
35
  },
36
36
  setTimezone: (utils, timezone, value) => [value[0] == null ? null : utils.setTimezone(value[0], timezone), value[1] == null ? null : utils.setTimezone(value[1], timezone)]
37
37
  };
38
- export const rangeFieldValueManager = {
38
+ export const getRangeFieldValueManager = ({
39
+ dateSeparator = '–'
40
+ }) => ({
39
41
  updateReferenceValue: (utils, value, prevReferenceValue) => {
40
42
  const shouldKeepStartDate = value[0] != null && utils.isValid(value[0]);
41
43
  const shouldKeepEndDate = value[1] != null && utils.isValid(value[1]);
@@ -66,7 +68,7 @@ export const rangeFieldValueManager = {
66
68
  return _extends({}, section, {
67
69
  dateName: position,
68
70
  // TODO: Check if RTL still works
69
- endSeparator: `${section.endSeparator} `
71
+ endSeparator: `${section.endSeparator} ${dateSeparator} `
70
72
  });
71
73
  }
72
74
  return _extends({}, section, {
@@ -85,8 +87,8 @@ export const rangeFieldValueManager = {
85
87
  return createDateStrForV6InputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], localizedDigits, isRTL);
86
88
  },
87
89
  parseValueStr: (valueStr, referenceValue, parseDate) => {
88
- // TODO: Improve because it would not work if the date format has `–` as a separator.
89
- const [startStr, endStr] = valueStr.split('–');
90
+ // TODO: Improve because it would not work if some section have the same separator as the dateSeparator.
91
+ const [startStr, endStr] = valueStr.split(dateSeparator);
90
92
  return [startStr, endStr].map((dateStr, index) => {
91
93
  if (dateStr == null) {
92
94
  return null;
@@ -113,4 +115,4 @@ export const rangeFieldValueManager = {
113
115
  })
114
116
  };
115
117
  }
116
- };
118
+ });
@@ -36,12 +36,19 @@ export interface MultiInputFieldRefs {
36
36
  unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
37
37
  unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
38
38
  }
39
+ export interface RangeFieldSeparatorProps {
40
+ /**
41
+ * String displayed between the start and the end dates.
42
+ * @default "–"
43
+ */
44
+ dateSeparator?: string;
45
+ }
39
46
  /**
40
47
  * Props the multi input field can receive when used inside a picker.
41
48
  * Only contains what the MUI components are passing to the field,
42
49
  * not what users can pass using the `props.slotProps.field`.
43
50
  */
44
- export interface BaseMultiInputFieldProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Omit<BaseFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'unstableFieldRef'> {
51
+ export interface BaseMultiInputFieldProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Omit<BaseFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'unstableFieldRef'>, RangeFieldSeparatorProps {
45
52
  sx?: SxProps<any>;
46
53
  unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
47
54
  unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
@@ -647,7 +647,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
647
647
  /**
648
648
  * Disable specific date.
649
649
  *
650
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
650
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
651
651
  *
652
652
  * @template TDate
653
653
  * @param {TDate} day The date to test.
@@ -277,7 +277,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
277
277
  /**
278
278
  * Disable specific date.
279
279
  *
280
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
280
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
281
281
  *
282
282
  * @template TDate
283
283
  * @param {TDate} day The date to test.