@mui/x-date-pickers 5.0.0-beta.7 → 5.0.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 (144) hide show
  1. package/AdapterDateFns/index.d.ts +7 -1
  2. package/AdapterDateFns/index.js +51 -1
  3. package/AdapterDayjs/index.d.ts +12 -1
  4. package/AdapterDayjs/index.js +45 -1
  5. package/CHANGELOG.md +78 -1
  6. package/CalendarPicker/CalendarPicker.d.ts +4 -1
  7. package/CalendarPicker/CalendarPicker.js +40 -10
  8. package/CalendarPicker/DayPicker.d.ts +2 -1
  9. package/CalendarPicker/DayPicker.js +100 -4
  10. package/CalendarPicker/PickersCalendarHeader.d.ts +8 -0
  11. package/CalendarPicker/useCalendarState.d.ts +10 -4
  12. package/CalendarPicker/useCalendarState.js +4 -3
  13. package/ClockPicker/ClockPicker.d.ts +3 -8
  14. package/DateField/DateField.interfaces.d.ts +4 -4
  15. package/DateField/index.d.ts +1 -1
  16. package/DateField/useDateField.d.ts +1 -1
  17. package/DateField/useDateField.js +35 -4
  18. package/DateTimePicker/DateTimePicker.js +2 -1
  19. package/DateTimePicker/DateTimePickerTabs.d.ts +20 -4
  20. package/DateTimePicker/DateTimePickerTabs.js +34 -5
  21. package/DateTimePicker/DateTimePickerToolbar.js +54 -68
  22. package/DateTimePicker/index.d.ts +2 -0
  23. package/DateTimePicker/index.js +2 -1
  24. package/DateTimePicker/shared.d.ts +2 -1
  25. package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -5
  26. package/MobileDateTimePicker/MobileDateTimePicker.js +13 -5
  27. package/MonthPicker/MonthPicker.d.ts +4 -0
  28. package/MonthPicker/MonthPicker.js +87 -10
  29. package/MonthPicker/PickersMonth.d.ts +6 -2
  30. package/MonthPicker/PickersMonth.js +23 -4
  31. package/PickersDay/PickersDay.d.ts +4 -2
  32. package/PickersDay/PickersDay.js +13 -74
  33. package/StaticDateTimePicker/StaticDateTimePicker.js +12 -5
  34. package/YearPicker/PickersYear.d.ts +3 -0
  35. package/YearPicker/PickersYear.js +11 -4
  36. package/YearPicker/YearPicker.d.ts +3 -0
  37. package/YearPicker/YearPicker.js +42 -8
  38. package/index.js +1 -1
  39. package/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.d.ts +8 -0
  40. package/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +26 -4
  41. package/internals/components/CalendarOrClockPicker/useFocusManagement.d.ts +10 -0
  42. package/internals/components/CalendarOrClockPicker/useFocusManagement.js +18 -0
  43. package/internals/components/PickersArrowSwitcher.d.ts +16 -0
  44. package/internals/components/PickersModalDialog.d.ts +2 -2
  45. package/internals/components/PureDateInput.d.ts +4 -0
  46. package/internals/components/PureDateInput.js +1 -1
  47. package/internals/components/wrappers/WrapperProps.d.ts +8 -0
  48. package/internals/hooks/useField/index.d.ts +1 -1
  49. package/internals/hooks/useField/useField.d.ts +2 -2
  50. package/internals/hooks/useField/useField.interfaces.d.ts +24 -20
  51. package/internals/hooks/useField/useField.js +44 -15
  52. package/internals/hooks/useField/useField.utils.d.ts +8 -8
  53. package/internals/hooks/useField/useField.utils.js +14 -52
  54. package/internals/hooks/validation/useDateValidation.d.ts +1 -0
  55. package/internals/hooks/validation/useDateValidation.js +1 -3
  56. package/internals/index.d.ts +0 -2
  57. package/internals/index.js +0 -1
  58. package/internals/models/muiPickersAdapter.d.ts +8 -0
  59. package/internals/models/props/baseToolbarProps.d.ts +0 -1
  60. package/internals-fields/index.d.ts +2 -0
  61. package/internals-fields/index.js +3 -0
  62. package/internals-fields/package.json +6 -0
  63. package/legacy/AdapterDateFns/index.js +76 -1
  64. package/legacy/AdapterDayjs/index.js +74 -1
  65. package/legacy/CalendarPicker/CalendarPicker.js +49 -9
  66. package/legacy/CalendarPicker/DayPicker.js +109 -5
  67. package/legacy/CalendarPicker/useCalendarState.js +4 -3
  68. package/legacy/DateField/useDateField.js +33 -4
  69. package/legacy/DateTimePicker/DateTimePicker.js +2 -1
  70. package/legacy/DateTimePicker/DateTimePickerTabs.js +34 -5
  71. package/legacy/DateTimePicker/DateTimePickerToolbar.js +60 -74
  72. package/legacy/DateTimePicker/index.js +2 -1
  73. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +15 -4
  74. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +15 -4
  75. package/legacy/MonthPicker/MonthPicker.js +100 -8
  76. package/legacy/MonthPicker/PickersMonth.js +28 -3
  77. package/legacy/PickersDay/PickersDay.js +22 -75
  78. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +14 -4
  79. package/legacy/YearPicker/PickersYear.js +16 -3
  80. package/legacy/YearPicker/YearPicker.js +50 -8
  81. package/legacy/index.js +1 -1
  82. package/legacy/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +25 -3
  83. package/legacy/internals/components/CalendarOrClockPicker/useFocusManagement.js +27 -0
  84. package/legacy/internals/components/PureDateInput.js +1 -1
  85. package/legacy/internals/hooks/useField/useField.js +64 -26
  86. package/legacy/internals/hooks/useField/useField.utils.js +14 -52
  87. package/legacy/internals/hooks/validation/useDateValidation.js +1 -3
  88. package/legacy/internals/index.js +0 -1
  89. package/legacy/internals-fields/index.js +3 -0
  90. package/modern/AdapterDateFns/index.js +51 -1
  91. package/modern/AdapterDayjs/index.js +43 -1
  92. package/modern/CalendarPicker/CalendarPicker.js +40 -10
  93. package/modern/CalendarPicker/DayPicker.js +100 -4
  94. package/modern/CalendarPicker/useCalendarState.js +4 -3
  95. package/modern/DateField/useDateField.js +35 -4
  96. package/modern/DateTimePicker/DateTimePicker.js +2 -1
  97. package/modern/DateTimePicker/DateTimePickerTabs.js +34 -5
  98. package/modern/DateTimePicker/DateTimePickerToolbar.js +54 -68
  99. package/modern/DateTimePicker/index.js +2 -1
  100. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -5
  101. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +13 -5
  102. package/modern/MonthPicker/MonthPicker.js +87 -10
  103. package/modern/MonthPicker/PickersMonth.js +21 -4
  104. package/modern/PickersDay/PickersDay.js +13 -74
  105. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +12 -5
  106. package/modern/YearPicker/PickersYear.js +11 -4
  107. package/modern/YearPicker/YearPicker.js +42 -8
  108. package/modern/index.js +1 -1
  109. package/modern/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +24 -4
  110. package/modern/internals/components/CalendarOrClockPicker/useFocusManagement.js +18 -0
  111. package/modern/internals/components/PureDateInput.js +1 -1
  112. package/modern/internals/hooks/useField/useField.js +42 -15
  113. package/modern/internals/hooks/useField/useField.utils.js +14 -52
  114. package/modern/internals/hooks/validation/useDateValidation.js +1 -3
  115. package/modern/internals/index.js +0 -1
  116. package/modern/internals-fields/index.js +3 -0
  117. package/node/AdapterDateFns/index.js +57 -6
  118. package/node/AdapterDayjs/index.js +49 -6
  119. package/node/CalendarPicker/CalendarPicker.js +39 -9
  120. package/node/CalendarPicker/DayPicker.js +100 -3
  121. package/node/CalendarPicker/useCalendarState.js +4 -3
  122. package/node/DateField/useDateField.js +35 -3
  123. package/node/DateTimePicker/DateTimePicker.js +2 -1
  124. package/node/DateTimePicker/DateTimePickerTabs.js +32 -4
  125. package/node/DateTimePicker/DateTimePickerToolbar.js +54 -70
  126. package/node/DateTimePicker/index.js +9 -1
  127. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -5
  128. package/node/MobileDateTimePicker/MobileDateTimePicker.js +13 -5
  129. package/node/MonthPicker/MonthPicker.js +87 -9
  130. package/node/MonthPicker/PickersMonth.js +26 -6
  131. package/node/PickersDay/PickersDay.js +12 -73
  132. package/node/StaticDateTimePicker/StaticDateTimePicker.js +13 -5
  133. package/node/YearPicker/PickersYear.js +11 -4
  134. package/node/YearPicker/YearPicker.js +43 -8
  135. package/node/index.js +1 -1
  136. package/node/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +27 -4
  137. package/node/internals/components/CalendarOrClockPicker/useFocusManagement.js +32 -0
  138. package/node/internals/components/PureDateInput.js +1 -1
  139. package/node/internals/hooks/useField/useField.js +44 -15
  140. package/node/internals/hooks/useField/useField.utils.js +16 -56
  141. package/node/internals/hooks/validation/useDateValidation.js +3 -1
  142. package/node/internals/index.js +0 -26
  143. package/node/internals-fields/index.js +31 -0
  144. package/package.json +1 -1
@@ -25,6 +25,8 @@ var _PickersSlideTransition = require("./PickersSlideTransition");
25
25
 
26
26
  var _useDateValidation = require("../internals/hooks/validation/useDateValidation");
27
27
 
28
+ var _dateUtils = require("../internals/utils/date-utils");
29
+
28
30
  var _jsxRuntime = require("react/jsx-runtime");
29
31
 
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -76,7 +78,6 @@ function DayPicker(props) {
76
78
  const now = (0, _useUtils.useNow)();
77
79
  const utils = (0, _useUtils.useUtils)();
78
80
  const {
79
- autoFocus,
80
81
  onFocusedDayChange,
81
82
  className,
82
83
  currentMonth,
@@ -103,6 +104,8 @@ function DayPicker(props) {
103
104
  maxDate,
104
105
  shouldDisableDate,
105
106
  dayOfWeekFormatter = defaultDayOfWeekFormatter,
107
+ hasFocus,
108
+ onFocusedViewChange,
106
109
  gridLabelId
107
110
  } = props;
108
111
  const isDateDisabled = (0, _useDateValidation.useIsDayDisabled)({
@@ -112,6 +115,12 @@ function DayPicker(props) {
112
115
  disablePast,
113
116
  disableFuture
114
117
  });
118
+ const [internalFocusedDay, setInternalFocusedDay] = React.useState(() => focusedDay || now);
119
+ const changeHasFocus = React.useCallback(newHasFocus => {
120
+ if (onFocusedViewChange) {
121
+ onFocusedViewChange(newHasFocus);
122
+ }
123
+ }, [onFocusedViewChange]);
115
124
  const handleDaySelect = React.useCallback((day, isFinish = 'finish') => {
116
125
  if (readOnly) {
117
126
  return;
@@ -119,6 +128,72 @@ function DayPicker(props) {
119
128
 
120
129
  onSelectedDaysChange(day, isFinish);
121
130
  }, [onSelectedDaysChange, readOnly]);
131
+ const focusDay = React.useCallback(day => {
132
+ if (!isDateDisabled(day)) {
133
+ onFocusedDayChange(day);
134
+ setInternalFocusedDay(day);
135
+ changeHasFocus(true);
136
+ }
137
+ }, [isDateDisabled, onFocusedDayChange, changeHasFocus]);
138
+ const theme = (0, _styles.useTheme)();
139
+
140
+ function handleKeyDown(event, day) {
141
+ switch (event.key) {
142
+ case 'ArrowUp':
143
+ focusDay(utils.addDays(day, -7));
144
+ event.preventDefault();
145
+ break;
146
+
147
+ case 'ArrowDown':
148
+ focusDay(utils.addDays(day, 7));
149
+ event.preventDefault();
150
+ break;
151
+
152
+ case 'ArrowLeft':
153
+ focusDay(utils.addDays(day, theme.direction === 'ltr' ? -1 : 1));
154
+ event.preventDefault();
155
+ break;
156
+
157
+ case 'ArrowRight':
158
+ focusDay(utils.addDays(day, theme.direction === 'ltr' ? 1 : -1));
159
+ event.preventDefault();
160
+ break;
161
+
162
+ case 'Home':
163
+ focusDay(utils.startOfWeek(day));
164
+ event.preventDefault();
165
+ break;
166
+
167
+ case 'End':
168
+ focusDay(utils.endOfWeek(day));
169
+ event.preventDefault();
170
+ break;
171
+
172
+ case 'PageUp':
173
+ focusDay(utils.getNextMonth(day));
174
+ event.preventDefault();
175
+ break;
176
+
177
+ case 'PageDown':
178
+ focusDay(utils.getPreviousMonth(day));
179
+ event.preventDefault();
180
+ break;
181
+
182
+ default:
183
+ break;
184
+ }
185
+ }
186
+
187
+ function handleFocus(event, day) {
188
+ focusDay(day);
189
+ }
190
+
191
+ function handleBlur(event, day) {
192
+ if (hasFocus && utils.isSameDay(internalFocusedDay, day)) {
193
+ changeHasFocus(false);
194
+ }
195
+ }
196
+
122
197
  const currentMonthNumber = utils.getMonth(currentMonth);
123
198
  const validSelectedDays = selectedDays.filter(day => !!day).map(day => utils.startOfDay(day)); // need a new ref whenever the `key` of the transition changes: http://reactcommunity.org/react-transition-group/transition/#Transition-prop-nodeRef.
124
199
 
@@ -126,6 +201,24 @@ function DayPicker(props) {
126
201
 
127
202
  const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
128
203
  const startOfCurrentWeek = utils.startOfWeek(now);
204
+ const focusableDay = React.useMemo(() => {
205
+ const startOfMonth = utils.startOfMonth(currentMonth);
206
+ const endOfMonth = utils.endOfMonth(currentMonth);
207
+
208
+ if (isDateDisabled(internalFocusedDay) || utils.isAfterDay(internalFocusedDay, endOfMonth) || utils.isBeforeDay(internalFocusedDay, startOfMonth)) {
209
+ return (0, _dateUtils.findClosestEnabledDate)({
210
+ utils,
211
+ date: internalFocusedDay,
212
+ minDate: startOfMonth,
213
+ maxDate: endOfMonth,
214
+ disablePast,
215
+ disableFuture,
216
+ isDateDisabled
217
+ });
218
+ }
219
+
220
+ return internalFocusedDay;
221
+ }, [currentMonth, disableFuture, disablePast, internalFocusedDay, isDateDisabled, utils]);
129
222
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
130
223
  role: "grid",
131
224
  "aria-labelledby": gridLabelId,
@@ -157,6 +250,7 @@ function DayPicker(props) {
157
250
  children: utils.getWeekArray(currentMonth).map(week => /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersCalendarWeek, {
158
251
  role: "row",
159
252
  children: week.map(day => {
253
+ const isFocusableDay = focusableDay !== null && utils.isSameDay(day, focusableDay);
160
254
  const isSelected = validSelectedDays.some(selectedDay => utils.isSameDay(selectedDay, day));
161
255
  const isToday = utils.isSameDay(day, now);
162
256
  const pickersDayProps = {
@@ -164,14 +258,17 @@ function DayPicker(props) {
164
258
  day,
165
259
  isAnimating: isMonthSwitchingAnimating,
166
260
  disabled: disabled || isDateDisabled(day),
167
- autoFocus: autoFocus && focusedDay !== null && utils.isSameDay(day, focusedDay),
261
+ autoFocus: hasFocus && isFocusableDay,
168
262
  today: isToday,
169
263
  outsideCurrentMonth: utils.getMonth(day) !== currentMonthNumber,
170
264
  selected: isSelected,
171
265
  disableHighlightToday,
172
266
  showDaysOutsideCurrentMonth,
173
- onDayFocus: onFocusedDayChange,
267
+ onKeyDown: handleKeyDown,
268
+ onFocus: handleFocus,
269
+ onBlur: handleBlur,
174
270
  onDaySelect: handleDaySelect,
271
+ tabIndex: isFocusableDay ? 0 : -1,
175
272
  role: 'gridcell',
176
273
  'aria-selected': isSelected
177
274
  };
@@ -42,7 +42,7 @@ const createCalendarStateReducer = (reduceAnimations, disableSwitchToMonthOnDayF
42
42
  const needMonthSwitch = action.focusedDay != null && !disableSwitchToMonthOnDayFocus && !utils.isSameMonth(state.currentMonth, action.focusedDay);
43
43
  return (0, _extends2.default)({}, state, {
44
44
  focusedDay: action.focusedDay,
45
- isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations,
45
+ isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations && !action.withoutMonthSwitchingAnimation,
46
46
  currentMonth: needMonthSwitch ? utils.startOfMonth(action.focusedDay) : state.currentMonth,
47
47
  slideDirection: action.focusedDay != null && utils.isAfterDay(action.focusedDay, state.currentMonth) ? 'left' : 'right'
48
48
  });
@@ -111,11 +111,12 @@ const useCalendarState = ({
111
111
  type: 'finishMonthSwitchingAnimation'
112
112
  });
113
113
  }, []);
114
- const changeFocusedDay = React.useCallback(newFocusedDate => {
114
+ const changeFocusedDay = React.useCallback((newFocusedDate, withoutMonthSwitchingAnimation) => {
115
115
  if (!isDateDisabled(newFocusedDate)) {
116
116
  dispatch({
117
117
  type: 'changeFocusedDay',
118
- focusedDay: newFocusedDate
118
+ focusedDay: newFocusedDate,
119
+ withoutMonthSwitchingAnimation
119
120
  });
120
121
  }
121
122
  }, [isDateDisabled]);
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.useDateField = void 0;
9
9
 
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+
10
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
13
 
12
14
  var _shared = require("../DatePicker/shared");
@@ -19,6 +21,7 @@ var _dateUtils = require("../internals/utils/date-utils");
19
21
 
20
22
  var _useUtils = require("../internals/hooks/useUtils");
21
23
 
24
+ const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast"];
22
25
  const dateRangeFieldValueManager = {
23
26
  getSectionsFromValue: (utils, prevSections, date, format) => (0, _useField.addPositionPropertiesToSections)((0, _useField.splitFormatIntoSections)(utils, format, date)),
24
27
  getValueStrFromSections: sections => (0, _useField.createDateStrFromSections)(sections),
@@ -34,7 +37,8 @@ const dateRangeFieldValueManager = {
34
37
  value,
35
38
  update: newActiveDate => newActiveDate
36
39
  }),
37
- hasError: error => error != null
40
+ hasError: error => error != null,
41
+ isSameError: _useDateValidation.isSameDateError
38
42
  };
39
43
 
40
44
  const useDefaultizedDateField = props => {
@@ -50,9 +54,37 @@ const useDefaultizedDateField = props => {
50
54
  };
51
55
 
52
56
  const useDateField = inProps => {
53
- const props = useDefaultizedDateField(inProps);
57
+ const _useDefaultizedDateFi = useDefaultizedDateField(inProps),
58
+ {
59
+ value,
60
+ defaultValue,
61
+ format,
62
+ onChange,
63
+ readOnly,
64
+ onError,
65
+ shouldDisableDate,
66
+ minDate,
67
+ maxDate,
68
+ disableFuture,
69
+ disablePast
70
+ } = _useDefaultizedDateFi,
71
+ other = (0, _objectWithoutPropertiesLoose2.default)(_useDefaultizedDateFi, _excluded);
72
+
54
73
  return (0, _useField.useField)({
55
- props,
74
+ forwardedProps: other,
75
+ internalProps: {
76
+ value,
77
+ defaultValue,
78
+ format,
79
+ onChange,
80
+ readOnly,
81
+ onError,
82
+ shouldDisableDate,
83
+ minDate,
84
+ maxDate,
85
+ disableFuture,
86
+ disablePast
87
+ },
56
88
  valueManager: _shared.datePickerValueManager,
57
89
  fieldValueManager: dateRangeFieldValueManager,
58
90
  // TODO: Support time validation.
@@ -232,7 +232,8 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
232
232
  getViewSwitchingButtonText: _propTypes.default.func,
233
233
 
234
234
  /**
235
- * To show tabs.
235
+ * Toggles visibility of date time switching tabs
236
+ * @default false for mobile, true for desktop
236
237
  */
237
238
  hideTabs: _propTypes.default.bool,
238
239
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -11,6 +11,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
 
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
14
16
  var _Tab = _interopRequireDefault(require("@mui/material/Tab"));
15
17
 
16
18
  var _Tabs = _interopRequireWildcard(require("@mui/material/Tabs"));
@@ -58,9 +60,6 @@ const DateTimePickerTabsRoot = (0, _styles.styled)(_Tabs.default)(({
58
60
  top: 0
59
61
  }
60
62
  }));
61
- /**
62
- * @ignore - internal component.
63
- */
64
63
 
65
64
  const DateTimePickerTabs = props => {
66
65
  const {
@@ -100,4 +99,33 @@ const DateTimePickerTabs = props => {
100
99
  });
101
100
  };
102
101
 
103
- exports.DateTimePickerTabs = DateTimePickerTabs;
102
+ exports.DateTimePickerTabs = DateTimePickerTabs;
103
+ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
104
+ // ----------------------------- Warning --------------------------------
105
+ // | These PropTypes are generated from the TypeScript type definitions |
106
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
107
+ // ----------------------------------------------------------------------
108
+
109
+ /**
110
+ * Date tab icon.
111
+ * @default DateRange
112
+ */
113
+ dateRangeIcon: _propTypes.default.node,
114
+
115
+ /**
116
+ * Callback called when tab is clicked
117
+ * @param {CalendarOrClockPickerView} view Picker view that was clicked
118
+ */
119
+ onChange: _propTypes.default.func.isRequired,
120
+
121
+ /**
122
+ * Time tab icon.
123
+ * @default Time
124
+ */
125
+ timeIcon: _propTypes.default.node,
126
+
127
+ /**
128
+ * Open picker view
129
+ */
130
+ view: _propTypes.default.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']).isRequired
131
+ } : void 0;
@@ -23,15 +23,11 @@ var _PickersToolbar = require("../internals/components/PickersToolbar");
23
23
 
24
24
  var _PickersToolbarButton = require("../internals/components/PickersToolbarButton");
25
25
 
26
- var _DateTimePickerTabs = require("./DateTimePickerTabs");
27
-
28
26
  var _useUtils = require("../internals/hooks/useUtils");
29
27
 
30
- var _WrapperVariantContext = require("../internals/components/wrappers/WrapperVariantContext");
31
-
32
28
  var _jsxRuntime = require("react/jsx-runtime");
33
29
 
34
- const _excluded = ["ampm", "parsedValue", "dateRangeIcon", "hideTabs", "isMobileKeyboardViewOpen", "onChange", "openView", "setOpenView", "timeIcon", "toggleMobileKeyboardView", "toolbarFormat", "toolbarPlaceholder", "toolbarTitle", "views"];
30
+ const _excluded = ["ampm", "parsedValue", "isMobileKeyboardViewOpen", "onChange", "openView", "setOpenView", "toggleMobileKeyboardView", "toolbarFormat", "toolbarPlaceholder", "toolbarTitle", "views"];
35
31
 
36
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
33
 
@@ -85,12 +81,9 @@ const DateTimePickerToolbar = props => {
85
81
  const {
86
82
  ampm,
87
83
  parsedValue,
88
- dateRangeIcon,
89
- hideTabs,
90
84
  isMobileKeyboardViewOpen,
91
85
  openView,
92
86
  setOpenView,
93
- timeIcon,
94
87
  toggleMobileKeyboardView,
95
88
  toolbarFormat,
96
89
  toolbarPlaceholder = '––',
@@ -101,8 +94,6 @@ const DateTimePickerToolbar = props => {
101
94
  const utils = (0, _useUtils.useUtils)();
102
95
  const localeText = (0, _useUtils.useLocaleText)();
103
96
  const toolbarTitle = toolbarTitleProp != null ? toolbarTitleProp : localeText.dateTimePickerDefaultToolbarTitle;
104
- const wrapperVariant = React.useContext(_WrapperVariantContext.WrapperVariantContext);
105
- const showTabs = wrapperVariant === 'desktop' ? true : !hideTabs && typeof window !== 'undefined' && window.innerHeight > 667;
106
97
 
107
98
  const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
108
99
 
@@ -118,72 +109,65 @@ const DateTimePickerToolbar = props => {
118
109
  return utils.format(parsedValue, 'shortDate');
119
110
  }, [parsedValue, toolbarFormat, toolbarPlaceholder, utils]);
120
111
  const ownerState = props;
121
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
122
- children: [wrapperVariant !== 'desktop' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarRoot, (0, _extends2.default)({
123
- toolbarTitle: toolbarTitle,
124
- isMobileKeyboardViewOpen: isMobileKeyboardViewOpen,
125
- toggleMobileKeyboardView: toggleMobileKeyboardView,
126
- className: dateTimePickerToolbarClasses.root
127
- }, other, {
128
- isLandscape: false,
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarRoot, (0, _extends2.default)({
113
+ toolbarTitle: toolbarTitle,
114
+ isMobileKeyboardViewOpen: isMobileKeyboardViewOpen,
115
+ toggleMobileKeyboardView: toggleMobileKeyboardView,
116
+ className: dateTimePickerToolbarClasses.root
117
+ }, other, {
118
+ isLandscape: false,
119
+ ownerState: ownerState,
120
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarDateContainer, {
121
+ className: dateTimePickerToolbarClasses.dateContainer,
122
+ ownerState: ownerState,
123
+ children: [views.includes('year') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
124
+ tabIndex: -1,
125
+ variant: "subtitle1",
126
+ onClick: () => setOpenView('year'),
127
+ selected: openView === 'year',
128
+ value: parsedValue ? utils.format(parsedValue, 'year') : '–'
129
+ }), views.includes('day') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
130
+ tabIndex: -1,
131
+ variant: "h4",
132
+ onClick: () => setOpenView('day'),
133
+ selected: openView === 'day',
134
+ value: dateText
135
+ })]
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarTimeContainer, {
137
+ className: dateTimePickerToolbarClasses.timeContainer,
129
138
  ownerState: ownerState,
130
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarDateContainer, {
131
- className: dateTimePickerToolbarClasses.dateContainer,
132
- ownerState: ownerState,
133
- children: [views.includes('year') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
134
- tabIndex: -1,
135
- variant: "subtitle1",
136
- onClick: () => setOpenView('year'),
137
- selected: openView === 'year',
138
- value: parsedValue ? utils.format(parsedValue, 'year') : '–'
139
- }), views.includes('day') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
140
- tabIndex: -1,
141
- variant: "h4",
142
- onClick: () => setOpenView('day'),
143
- selected: openView === 'day',
144
- value: dateText
139
+ children: [views.includes('hours') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
140
+ variant: "h3",
141
+ onClick: () => setOpenView('hours'),
142
+ selected: openView === 'hours',
143
+ value: parsedValue ? formatHours(parsedValue) : '--'
144
+ }), views.includes('minutes') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
145
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DateTimePickerToolbarSeparator, {
146
+ variant: "h3",
147
+ value: ":",
148
+ className: dateTimePickerToolbarClasses.separator,
149
+ ownerState: ownerState
150
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
151
+ variant: "h3",
152
+ onClick: () => setOpenView('minutes'),
153
+ selected: openView === 'minutes',
154
+ value: parsedValue ? utils.format(parsedValue, 'minutes') : '--'
145
155
  })]
146
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimePickerToolbarTimeContainer, {
147
- className: dateTimePickerToolbarClasses.timeContainer,
148
- ownerState: ownerState,
149
- children: [views.includes('hours') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
156
+ }), views.includes('seconds') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
157
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DateTimePickerToolbarSeparator, {
158
+ variant: "h3",
159
+ value: ":",
160
+ className: dateTimePickerToolbarClasses.separator,
161
+ ownerState: ownerState
162
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
150
163
  variant: "h3",
151
- onClick: () => setOpenView('hours'),
152
- selected: openView === 'hours',
153
- value: parsedValue ? formatHours(parsedValue) : '--'
154
- }), views.includes('minutes') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
155
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DateTimePickerToolbarSeparator, {
156
- variant: "h3",
157
- value: ":",
158
- className: dateTimePickerToolbarClasses.separator,
159
- ownerState: ownerState
160
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
161
- variant: "h3",
162
- onClick: () => setOpenView('minutes'),
163
- selected: openView === 'minutes',
164
- value: parsedValue ? utils.format(parsedValue, 'minutes') : '--'
165
- })]
166
- }), views.includes('seconds') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
167
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DateTimePickerToolbarSeparator, {
168
- variant: "h3",
169
- value: ":",
170
- className: dateTimePickerToolbarClasses.separator,
171
- ownerState: ownerState
172
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarButton.PickersToolbarButton, {
173
- variant: "h3",
174
- onClick: () => setOpenView('seconds'),
175
- selected: openView === 'seconds',
176
- value: parsedValue ? utils.format(parsedValue, 'seconds') : '--'
177
- })]
164
+ onClick: () => setOpenView('seconds'),
165
+ selected: openView === 'seconds',
166
+ value: parsedValue ? utils.format(parsedValue, 'seconds') : '--'
178
167
  })]
179
168
  })]
180
- })), showTabs && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePickerTabs.DateTimePickerTabs, {
181
- dateRangeIcon: dateRangeIcon,
182
- timeIcon: timeIcon,
183
- view: openView,
184
- onChange: setOpenView
185
169
  })]
186
- });
170
+ }));
187
171
  };
188
172
 
189
173
  exports.DateTimePickerToolbar = DateTimePickerToolbar;
@@ -9,5 +9,13 @@ Object.defineProperty(exports, "DateTimePicker", {
9
9
  return _DateTimePicker.DateTimePicker;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "DateTimePickerTabs", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _DateTimePickerTabs.DateTimePickerTabs;
16
+ }
17
+ });
18
+
19
+ var _DateTimePicker = require("./DateTimePicker");
12
20
 
13
- var _DateTimePicker = require("./DateTimePicker");
21
+ var _DateTimePickerTabs = require("./DateTimePickerTabs");
@@ -29,9 +29,11 @@ var _KeyboardDateInput = require("../internals/components/KeyboardDateInput");
29
29
 
30
30
  var _usePickerState = require("../internals/hooks/usePickerState");
31
31
 
32
+ var _DateTimePicker = require("../DateTimePicker");
33
+
32
34
  var _jsxRuntime = require("react/jsx-runtime");
33
35
 
34
- const _excluded = ["onChange", "PaperProps", "PopperProps", "ToolbarComponent", "TransitionComponent", "value", "components", "componentsProps"];
36
+ const _excluded = ["onChange", "PaperProps", "PopperProps", "ToolbarComponent", "TransitionComponent", "value", "components", "componentsProps", "hideTabs"];
35
37
 
36
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
39
 
@@ -60,10 +62,14 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
60
62
  PopperProps,
61
63
  ToolbarComponent = _DateTimePickerToolbar.DateTimePickerToolbar,
62
64
  TransitionComponent,
63
- components,
64
- componentsProps
65
+ components: providedComponents,
66
+ componentsProps,
67
+ hideTabs = true
65
68
  } = props,
66
69
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
70
+ const components = React.useMemo(() => (0, _extends2.default)({
71
+ Tabs: _DateTimePicker.DateTimePickerTabs
72
+ }, providedComponents), [providedComponents]);
67
73
  const AllDateInputProps = (0, _extends2.default)({}, inputProps, other, {
68
74
  components,
69
75
  componentsProps,
@@ -84,7 +90,8 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
84
90
  ToolbarComponent: ToolbarComponent,
85
91
  DateInputProps: AllDateInputProps,
86
92
  components: components,
87
- componentsProps: componentsProps
93
+ componentsProps: componentsProps,
94
+ hideTabs: hideTabs
88
95
  }, other))
89
96
  }));
90
97
  });
@@ -236,7 +243,8 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
236
243
  getViewSwitchingButtonText: _propTypes.default.func,
237
244
 
238
245
  /**
239
- * To show tabs.
246
+ * Toggles visibility of date time switching tabs
247
+ * @default false for mobile, true for desktop
240
248
  */
241
249
  hideTabs: _propTypes.default.bool,
242
250
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -29,9 +29,11 @@ var _PureDateInput = require("../internals/components/PureDateInput");
29
29
 
30
30
  var _usePickerState = require("../internals/hooks/usePickerState");
31
31
 
32
+ var _DateTimePicker = require("../DateTimePicker");
33
+
32
34
  var _jsxRuntime = require("react/jsx-runtime");
33
35
 
34
- const _excluded = ["ToolbarComponent", "value", "onChange", "components", "componentsProps"];
36
+ const _excluded = ["ToolbarComponent", "value", "onChange", "components", "componentsProps", "hideTabs"];
35
37
 
36
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
39
 
@@ -59,10 +61,14 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
59
61
 
60
62
  const {
61
63
  ToolbarComponent = _DateTimePickerToolbar.DateTimePickerToolbar,
62
- components,
63
- componentsProps
64
+ components: providedComponents,
65
+ componentsProps,
66
+ hideTabs = false
64
67
  } = props,
65
68
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
69
+ const components = React.useMemo(() => (0, _extends2.default)({
70
+ Tabs: _DateTimePicker.DateTimePickerTabs
71
+ }, providedComponents), [providedComponents]);
66
72
  const DateInputProps = (0, _extends2.default)({}, inputProps, other, {
67
73
  components,
68
74
  componentsProps,
@@ -80,7 +86,8 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
80
86
  ToolbarComponent: ToolbarComponent,
81
87
  DateInputProps: DateInputProps,
82
88
  components: components,
83
- componentsProps: componentsProps
89
+ componentsProps: componentsProps,
90
+ hideTabs: hideTabs
84
91
  }, other))
85
92
  }));
86
93
  });
@@ -237,7 +244,8 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes = {
237
244
  getViewSwitchingButtonText: _propTypes.default.func,
238
245
 
239
246
  /**
240
- * To show tabs.
247
+ * Toggles visibility of date time switching tabs
248
+ * @default false for mobile, true for desktop
241
249
  */
242
250
  hideTabs: _propTypes.default.bool,
243
251
  ignoreInvalidInputs: _propTypes.default.bool,