@mui/x-date-pickers-pro 7.0.0-alpha.8 → 7.0.0-beta.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 (187) hide show
  1. package/CHANGELOG.md +508 -30
  2. package/DateRangeCalendar/DateRangeCalendar.js +79 -13
  3. package/DateRangeCalendar/DateRangeCalendar.types.d.ts +15 -14
  4. package/DateRangePicker/DateRangePicker.js +0 -3
  5. package/DateRangePicker/DateRangePickerToolbar.js +0 -3
  6. package/DateTimeRangePicker/DateTimeRangePicker.d.ts +7 -0
  7. package/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
  8. package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +24 -0
  9. package/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
  10. package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +32 -0
  11. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
  12. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +20 -0
  13. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +59 -0
  14. package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +15 -0
  15. package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
  16. package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.d.ts +13 -0
  17. package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
  18. package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.d.ts +11 -0
  19. package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
  20. package/DateTimeRangePicker/index.d.ts +10 -0
  21. package/DateTimeRangePicker/index.js +5 -0
  22. package/DateTimeRangePicker/package.json +6 -0
  23. package/DateTimeRangePicker/shared.d.ts +60 -0
  24. package/DateTimeRangePicker/shared.js +56 -0
  25. package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
  26. package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +1 -1
  27. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +7 -0
  28. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
  29. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +25 -0
  30. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
  31. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +8 -0
  32. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +52 -0
  33. package/DesktopDateTimeRangePicker/index.d.ts +2 -0
  34. package/DesktopDateTimeRangePicker/index.js +1 -0
  35. package/DesktopDateTimeRangePicker/package.json +6 -0
  36. package/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
  37. package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +1 -6
  38. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +7 -0
  39. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +490 -0
  40. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +20 -0
  41. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
  42. package/MobileDateTimeRangePicker/index.d.ts +2 -0
  43. package/MobileDateTimeRangePicker/index.js +1 -0
  44. package/MobileDateTimeRangePicker/package.json +6 -0
  45. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +2 -5
  46. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +2 -5
  47. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +2 -5
  48. package/README.md +3 -3
  49. package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +2 -1
  50. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +2 -1
  51. package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +2 -1
  52. package/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
  53. package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +5 -0
  54. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -4
  55. package/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
  56. package/index.d.ts +3 -0
  57. package/index.js +4 -1
  58. package/internals/constants/dimensions.d.ts +3 -0
  59. package/internals/constants/dimensions.js +5 -0
  60. package/internals/hooks/models/index.d.ts +1 -0
  61. package/internals/hooks/models/index.js +1 -0
  62. package/internals/hooks/models/useRangePicker.d.ts +21 -0
  63. package/internals/hooks/models/useRangePicker.js +1 -0
  64. package/internals/hooks/useDesktopRangePicker/index.d.ts +1 -1
  65. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
  66. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +8 -14
  67. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +5 -2
  68. package/internals/hooks/useEnrichedRangePickerFieldProps.js +41 -11
  69. package/internals/hooks/useMobileRangePicker/index.d.ts +1 -1
  70. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
  71. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +8 -14
  72. package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +2 -6
  73. package/internals/models/dateTimeRange.d.ts +3 -1
  74. package/internals/models/fields.d.ts +7 -2
  75. package/internals/utils/date-range-manager.d.ts +2 -1
  76. package/internals/utils/date-range-manager.js +12 -1
  77. package/internals/utils/releaseInfo.js +1 -1
  78. package/internals/utils/valueManagers.js +4 -4
  79. package/legacy/DateRangeCalendar/DateRangeCalendar.js +77 -12
  80. package/legacy/DateRangePicker/DateRangePicker.js +0 -3
  81. package/legacy/DateRangePicker/DateRangePickerToolbar.js +0 -3
  82. package/legacy/DateTimeRangePicker/DateTimeRangePicker.js +413 -0
  83. package/legacy/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
  84. package/legacy/DateTimeRangePicker/DateTimeRangePickerTabs.js +191 -0
  85. package/legacy/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +57 -0
  86. package/legacy/DateTimeRangePicker/DateTimeRangePickerToolbar.js +184 -0
  87. package/legacy/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
  88. package/legacy/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
  89. package/legacy/DateTimeRangePicker/index.js +5 -0
  90. package/legacy/DateTimeRangePicker/shared.js +54 -0
  91. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
  92. package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
  93. package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
  94. package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +48 -0
  95. package/legacy/DesktopDateTimeRangePicker/index.js +1 -0
  96. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
  97. package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +484 -0
  98. package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
  99. package/legacy/MobileDateTimeRangePicker/index.js +1 -0
  100. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
  101. package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
  102. package/legacy/index.js +4 -1
  103. package/legacy/internals/constants/dimensions.js +5 -0
  104. package/legacy/internals/hooks/models/index.js +1 -0
  105. package/legacy/internals/hooks/models/useRangePicker.js +1 -0
  106. package/legacy/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
  107. package/legacy/internals/hooks/useEnrichedRangePickerFieldProps.js +43 -11
  108. package/legacy/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
  109. package/legacy/internals/utils/date-range-manager.js +13 -1
  110. package/legacy/internals/utils/releaseInfo.js +1 -1
  111. package/legacy/internals/utils/valueManagers.js +4 -4
  112. package/legacy/locales/index.js +1 -0
  113. package/locales/index.d.ts +1 -0
  114. package/locales/index.js +1 -0
  115. package/locales/package.json +6 -0
  116. package/modern/DateRangeCalendar/DateRangeCalendar.js +78 -12
  117. package/modern/DateRangePicker/DateRangePicker.js +0 -3
  118. package/modern/DateRangePicker/DateRangePickerToolbar.js +0 -3
  119. package/modern/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
  120. package/modern/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
  121. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
  122. package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +58 -0
  123. package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
  124. package/modern/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
  125. package/modern/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
  126. package/modern/DateTimeRangePicker/index.js +5 -0
  127. package/modern/DateTimeRangePicker/shared.js +55 -0
  128. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
  129. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +483 -0
  130. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
  131. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +51 -0
  132. package/modern/DesktopDateTimeRangePicker/index.js +1 -0
  133. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
  134. package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +486 -0
  135. package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
  136. package/modern/MobileDateTimeRangePicker/index.js +1 -0
  137. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
  138. package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
  139. package/modern/index.js +4 -1
  140. package/modern/internals/constants/dimensions.js +5 -0
  141. package/modern/internals/hooks/models/index.js +1 -0
  142. package/modern/internals/hooks/models/useRangePicker.js +1 -0
  143. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
  144. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
  145. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
  146. package/modern/internals/utils/date-range-manager.js +12 -1
  147. package/modern/internals/utils/releaseInfo.js +1 -1
  148. package/modern/internals/utils/valueManagers.js +4 -4
  149. package/modern/locales/index.js +1 -0
  150. package/node/DateRangeCalendar/DateRangeCalendar.js +78 -12
  151. package/node/DateRangePicker/DateRangePicker.js +0 -3
  152. package/node/DateRangePicker/DateRangePickerToolbar.js +0 -3
  153. package/node/DateTimeRangePicker/DateTimeRangePicker.js +422 -0
  154. package/node/DateTimeRangePicker/DateTimeRangePicker.types.js +5 -0
  155. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +190 -0
  156. package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +64 -0
  157. package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +183 -0
  158. package/node/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +14 -0
  159. package/node/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +12 -0
  160. package/node/DateTimeRangePicker/index.js +52 -0
  161. package/node/DateTimeRangePicker/shared.js +62 -0
  162. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
  163. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +490 -0
  164. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +5 -0
  165. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +59 -0
  166. package/node/DesktopDateTimeRangePicker/index.js +12 -0
  167. package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
  168. package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +494 -0
  169. package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +5 -0
  170. package/node/MobileDateTimeRangePicker/index.js +12 -0
  171. package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
  172. package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
  173. package/node/index.js +37 -1
  174. package/node/internals/constants/dimensions.js +16 -0
  175. package/node/internals/hooks/models/index.js +5 -0
  176. package/node/internals/hooks/models/useRangePicker.js +5 -0
  177. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
  178. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
  179. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
  180. package/node/internals/utils/date-range-manager.js +12 -1
  181. package/node/internals/utils/releaseInfo.js +1 -1
  182. package/node/internals/utils/valueManagers.js +4 -4
  183. package/node/locales/index.js +16 -0
  184. package/package.json +9 -9
  185. package/themeAugmentation/components.d.ts +22 -3
  186. package/themeAugmentation/overrides.d.ts +7 -0
  187. package/themeAugmentation/props.d.ts +12 -0
@@ -20,21 +20,37 @@ const useMultiInputFieldSlotProps = ({
20
20
  pickerSlotProps,
21
21
  pickerSlots,
22
22
  fieldProps,
23
- anchorRef
23
+ anchorRef,
24
+ currentView,
25
+ initialView,
26
+ onViewChange
24
27
  }) => {
25
28
  const localeText = useLocaleText();
26
29
  const startRef = React.useRef(null);
27
30
  const endRef = React.useRef(null);
31
+ const startFieldRef = React.useRef(null);
32
+ const endFieldRef = React.useRef(null);
33
+ const handleStartFieldRef = useForkRef(fieldProps.unstableStartFieldRef, startFieldRef);
34
+ const handleEndFieldRef = useForkRef(fieldProps.unstableFieldRef, endFieldRef);
35
+ const previousRangePosition = React.useRef(rangePosition);
28
36
  React.useEffect(() => {
29
37
  if (!open) {
30
38
  return;
31
39
  }
32
- if (rangePosition === 'start') {
33
- startRef.current?.focus();
34
- } else if (rangePosition === 'end') {
35
- endRef.current?.focus();
40
+ const currentRef = rangePosition === 'start' ? startRef : endRef;
41
+ currentRef.current?.focus();
42
+ const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
43
+ if (!currentFieldRef.current || !currentView) {
44
+ // could happen when the user is switching between the inputs
45
+ previousRangePosition.current = rangePosition;
46
+ return;
36
47
  }
37
- }, [rangePosition, open]);
48
+ // bring back focus to the field
49
+ currentFieldRef.current.setSelectedSections(
50
+ // use the current view or `0` when the range position has just been swapped
51
+ previousRangePosition.current === rangePosition ? currentView : 0);
52
+ previousRangePosition.current = rangePosition;
53
+ }, [rangePosition, open, currentView]);
38
54
  const openRangeStartSelection = event => {
39
55
  event.stopPropagation();
40
56
  onRangePositionChange('start');
@@ -52,11 +68,17 @@ const useMultiInputFieldSlotProps = ({
52
68
  const handleFocusStart = () => {
53
69
  if (open) {
54
70
  onRangePositionChange('start');
71
+ if (previousRangePosition.current !== 'start' && initialView) {
72
+ onViewChange?.(initialView);
73
+ }
55
74
  }
56
75
  };
57
76
  const handleFocusEnd = () => {
58
77
  if (open) {
59
78
  onRangePositionChange('end');
79
+ if (previousRangePosition.current !== 'end' && initialView) {
80
+ onViewChange?.(initialView);
81
+ }
60
82
  }
61
83
  };
62
84
  const slots = _extends({
@@ -119,7 +141,9 @@ const useMultiInputFieldSlotProps = ({
119
141
  const restFieldProps = _objectWithoutPropertiesLoose(fieldProps, _excluded);
120
142
  const enrichedFieldProps = _extends({}, restFieldProps, {
121
143
  slots,
122
- slotProps
144
+ slotProps,
145
+ unstableStartFieldRef: handleStartFieldRef,
146
+ unstableEndFieldRef: handleEndFieldRef
123
147
  });
124
148
  return enrichedFieldProps;
125
149
  };
@@ -139,7 +163,8 @@ const useSingleInputFieldSlotProps = ({
139
163
  pickerSlots,
140
164
  pickerSlotProps,
141
165
  fieldProps,
142
- anchorRef
166
+ anchorRef,
167
+ currentView
143
168
  }) => {
144
169
  const inputRef = React.useRef(null);
145
170
  const handleInputRef = useForkRef(inInputRef, inputRef);
@@ -149,7 +174,13 @@ const useSingleInputFieldSlotProps = ({
149
174
  return;
150
175
  }
151
176
  inputRef.current?.focus();
152
- }, [rangePosition, open]);
177
+ if (!singleInputFieldRef.current || !currentView) {
178
+ return;
179
+ }
180
+ const sections = singleInputFieldRef.current.getSections().map(section => section.type);
181
+ // bring back focus to the field with the current view section selected
182
+ singleInputFieldRef.current.setSelectedSections(rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView));
183
+ }, [rangePosition, open, currentView, singleInputFieldRef]);
153
184
  const updateRangePosition = () => {
154
185
  if (!singleInputFieldRef.current || inputRef.current !== getActiveElement(document)) {
155
186
  return;
@@ -96,6 +96,10 @@ export const useMobileRangePicker = _ref => {
96
96
  fieldProps
97
97
  });
98
98
  const slotPropsForLayout = _extends({}, innerSlotProps, {
99
+ tabs: _extends({}, innerSlotProps?.tabs, {
100
+ rangePosition,
101
+ onRangePositionChange
102
+ }),
99
103
  toolbar: _extends({}, innerSlotProps?.toolbar, {
100
104
  titleId: labelId,
101
105
  rangePosition,
@@ -1,11 +1,22 @@
1
+ import { mergeDateAndTime } from '@mui/x-date-pickers/internals';
1
2
  export function calculateRangeChange({
2
3
  utils,
3
4
  range,
4
5
  newDate: selectedDate,
5
6
  rangePosition,
6
- allowRangeFlip = false
7
+ allowRangeFlip = false,
8
+ shouldMergeDateAndTime = false
7
9
  }) {
8
10
  const [start, end] = range;
11
+ if (shouldMergeDateAndTime && selectedDate) {
12
+ // If there is a date already selected, then we want to keep its time
13
+ if (start && rangePosition === 'start') {
14
+ selectedDate = mergeDateAndTime(utils, selectedDate, start);
15
+ }
16
+ if (end && rangePosition === 'end') {
17
+ selectedDate = mergeDateAndTime(utils, selectedDate, end);
18
+ }
19
+ }
9
20
  if (rangePosition === 'start') {
10
21
  const truthyResult = allowRangeFlip ? {
11
22
  nextSelection: 'start',
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcwNDkyNzYwMDAwMA==";
3
+ const releaseInfo = "MTcwNjIyMDAwMDAwMA==";
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
@@ -50,7 +50,7 @@ export const rangeFieldValueManager = {
50
50
  }
51
51
  return [prevReferenceValue[1], value[1]];
52
52
  },
53
- getSectionsFromValue: (utils, [start, end], fallbackSections, isRTL, getSectionsFromDate) => {
53
+ getSectionsFromValue: (utils, [start, end], fallbackSections, localizedDigits, isRTL, getSectionsFromDate) => {
54
54
  const separatedFallbackSections = fallbackSections == null ? {
55
55
  startDate: null,
56
56
  endDate: null
@@ -73,11 +73,11 @@ export const rangeFieldValueManager = {
73
73
  });
74
74
  });
75
75
  };
76
- return addPositionPropertiesToSections([...getSections(start, separatedFallbackSections.startDate, 'start'), ...getSections(end, separatedFallbackSections.endDate, 'end')], isRTL);
76
+ return addPositionPropertiesToSections([...getSections(start, separatedFallbackSections.startDate, 'start'), ...getSections(end, separatedFallbackSections.endDate, 'end')], localizedDigits, isRTL);
77
77
  },
78
- getValueStrFromSections: (sections, isRTL) => {
78
+ getValueStrFromSections: (sections, localizedDigits, isRTL) => {
79
79
  const dateRangeSections = splitDateRangeSections(sections);
80
- return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], isRTL);
80
+ return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], localizedDigits, isRTL);
81
81
  },
82
82
  parseValueStr: (valueStr, referenceValue, parseDate) => {
83
83
  // TODO: Improve because it would not work if the date format has `–` as a separator.
@@ -0,0 +1 @@
1
+ export * from '@mui/x-date-pickers/locales';
@@ -26,8 +26,9 @@ var _DateRangePickerDay = require("../DateRangePickerDay");
26
26
  var _valueManagers = require("../internals/utils/valueManagers");
27
27
  var _useDragRange2 = require("./useDragRange");
28
28
  var _useRangePosition = require("../internals/hooks/useRangePosition");
29
+ var _dimensions = require("../internals/constants/dimensions");
29
30
  var _jsxRuntime = require("react/jsx-runtime");
30
- const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
31
+ const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
31
32
  _excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
32
33
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
33
34
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -57,8 +58,7 @@ const DateRangeCalendarArrowSwitcher = (0, _styles.styled)(_internals.PickersArr
57
58
  alignItems: 'center',
58
59
  justifyContent: 'space-between'
59
60
  });
60
- const DAY_RANGE_SIZE = 40;
61
- const weeksContainerHeight = (DAY_RANGE_SIZE + _internals.DAY_MARGIN * 2) * 6;
61
+ const weeksContainerHeight = (_dimensions.DAY_RANGE_SIZE + _dimensions.DAY_MARGIN * 2) * 6;
62
62
  const warnInvalidCurrentMonthCalendarPosition = (0, _internals.buildWarning)(['The `currentMonthCalendarPosition` prop must be an integer between `1` and the amount of calendars rendered.', 'For example if you have 2 calendars rendered, it should be equal to either 1 or 2.']);
63
63
  const DayCalendarForRange = (0, _styles.styled)(_internals.DayCalendar)(({
64
64
  theme
@@ -98,10 +98,13 @@ function useDateRangeCalendarDefaultizedProps(props, name) {
98
98
  loading: props.loading ?? false,
99
99
  disablePast: props.disablePast ?? false,
100
100
  disableFuture: props.disableFuture ?? false,
101
+ openTo: themeProps.openTo ?? 'day',
102
+ views: themeProps.views ?? ['day'],
101
103
  minDate: (0, _internals.applyDefaultDate)(utils, themeProps.minDate, defaultDates.minDate),
102
104
  maxDate: (0, _internals.applyDefaultDate)(utils, themeProps.maxDate, defaultDates.maxDate),
103
105
  calendars: themeProps.calendars ?? 2,
104
- disableDragEditing: themeProps.disableDragEditing ?? false
106
+ disableDragEditing: themeProps.disableDragEditing ?? false,
107
+ availableRangePositions: themeProps.availableRangePositions ?? ['start', 'end']
105
108
  });
106
109
  }
107
110
  const useUtilityClasses = ownerState => {
@@ -163,7 +166,12 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
163
166
  fixedWeekNumber,
164
167
  disableDragEditing,
165
168
  displayWeekNumber,
166
- timezone: timezoneProp
169
+ timezone: timezoneProp,
170
+ availableRangePositions,
171
+ views,
172
+ view: inView,
173
+ openTo,
174
+ onViewChange
167
175
  } = props,
168
176
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
169
177
  const {
@@ -178,6 +186,17 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
178
186
  onChange,
179
187
  valueManager: _valueManagers.rangeValueManager
180
188
  });
189
+ const {
190
+ setValueAndGoToNextView,
191
+ view
192
+ } = (0, _internals.useViews)({
193
+ view: inView,
194
+ views,
195
+ openTo,
196
+ onChange: handleValueChange,
197
+ onViewChange,
198
+ autoFocus
199
+ });
181
200
  const utils = (0, _internals.useUtils)();
182
201
  const localeText = (0, _internals.useLocaleText)();
183
202
  const now = (0, _internals.useNow)(timezone);
@@ -203,11 +222,15 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
203
222
  utils,
204
223
  range: value,
205
224
  rangePosition,
206
- allowRangeFlip
225
+ allowRangeFlip,
226
+ shouldMergeDateAndTime: true
207
227
  });
208
- onRangePositionChange(nextSelection);
228
+ const isNextSectionAvailable = availableRangePositions.includes(nextSelection);
229
+ if (isNextSectionAvailable) {
230
+ onRangePositionChange(nextSelection);
231
+ }
209
232
  const isFullRangeSelected = rangePosition === 'end' && (0, _dateUtils.isRangeValid)(utils, newRange);
210
- handleValueChange(newRange, isFullRangeSelected ? 'finish' : 'partial');
233
+ setValueAndGoToNextView(newRange, isFullRangeSelected || !isNextSectionAvailable ? 'finish' : 'partial', view);
211
234
  });
212
235
  const handleDrop = (0, _useEventCallback.default)(newDate => {
213
236
  handleSelectedDayChange(newDate, undefined, true);
@@ -498,6 +521,14 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
498
521
  * - the `input` element if there is a field rendered.
499
522
  */
500
523
  autoFocus: _propTypes.default.bool,
524
+ /**
525
+ * Range positions available for selection.
526
+ * This list is checked against when checking if a next range position can be selected.
527
+ *
528
+ * Used on Date Time Range pickers with current `rangePosition` to force a `finish` selection after just one range position selection.
529
+ * @default ['start', 'end']
530
+ */
531
+ availableRangePositions: _propTypes.default.arrayOf(_propTypes.default.oneOf(['end', 'start']).isRequired),
501
532
  /**
502
533
  * The number of calendars to render.
503
534
  * @default 2
@@ -568,6 +599,10 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
568
599
  * @default undefined
569
600
  */
570
601
  fixedWeekNumber: _propTypes.default.number,
602
+ /**
603
+ * Controlled focused view.
604
+ */
605
+ focusedView: _propTypes.default.oneOf(['day']),
571
606
  /**
572
607
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
573
608
  * Can be used to preload information and show it in calendar.
@@ -584,11 +619,20 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
584
619
  minDate: _propTypes.default.any,
585
620
  /**
586
621
  * Callback fired when the value changes.
587
- * @template TDate
588
- * @param {DateRange<TDate>} value The new value.
589
- * @param {PickerSelectionState | undefined} selectionState Indicates if the date range selection is complete.
622
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
623
+ * @template TView The view type. Will be one of date or time views.
624
+ * @param {TValue} value The new value.
625
+ * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
626
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
590
627
  */
591
628
  onChange: _propTypes.default.func,
629
+ /**
630
+ * Callback fired on focused view change.
631
+ * @template TView
632
+ * @param {TView} view The new view to focus or not.
633
+ * @param {boolean} hasFocus `true` if the view should be focused.
634
+ */
635
+ onFocusedViewChange: _propTypes.default.func,
592
636
  /**
593
637
  * Callback fired on month change.
594
638
  * @template TDate
@@ -600,6 +644,18 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
600
644
  * @param {RangePosition} rangePosition The new range position.
601
645
  */
602
646
  onRangePositionChange: _propTypes.default.func,
647
+ /**
648
+ * Callback fired on view change.
649
+ * @template TView
650
+ * @param {TView} view The new view.
651
+ */
652
+ onViewChange: _propTypes.default.func,
653
+ /**
654
+ * The default visible view.
655
+ * Used when the component view is not controlled.
656
+ * Must be a valid option from `views` list.
657
+ */
658
+ openTo: _propTypes.default.oneOf(['day']),
603
659
  /**
604
660
  * The position in the currently edited date range.
605
661
  * Used when the component position is controlled.
@@ -674,5 +730,15 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
674
730
  * The selected value.
675
731
  * Used when the component is controlled.
676
732
  */
677
- value: _propTypes.default.arrayOf(_propTypes.default.any)
733
+ value: _propTypes.default.arrayOf(_propTypes.default.any),
734
+ /**
735
+ * The visible view.
736
+ * Used when the component view is controlled.
737
+ * Must be a valid option from `views` list.
738
+ */
739
+ view: _propTypes.default.oneOf(['day']),
740
+ /**
741
+ * Available views.
742
+ */
743
+ views: _propTypes.default.arrayOf(_propTypes.default.oneOf(['day']))
678
744
  } : void 0;
@@ -68,9 +68,6 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
68
68
  * @default 2
69
69
  */
70
70
  calendars: _propTypes.default.oneOf([1, 2, 3]),
71
- /**
72
- * Class name applied to the root element.
73
- */
74
71
  className: _propTypes.default.string,
75
72
  /**
76
73
  * If `true`, the popover or modal will close after submitting the full date.
@@ -102,9 +102,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
102
102
  // | To update them edit the TypeScript types and run "yarn proptypes" |
103
103
  // ----------------------------------------------------------------------
104
104
  classes: _propTypes.default.object,
105
- /**
106
- * className applied to the root component.
107
- */
108
105
  className: _propTypes.default.string,
109
106
  disabled: _propTypes.default.bool,
110
107
  /**