@mui/x-date-pickers 6.18.5 → 6.18.7

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 (42) hide show
  1. package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
  2. package/CHANGELOG.md +91 -0
  3. package/DateCalendar/DateCalendar.js +6 -4
  4. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  5. package/DigitalClock/DigitalClock.js +3 -2
  6. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  7. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  8. package/TimeClock/TimeClock.js +3 -2
  9. package/index.js +1 -1
  10. package/internals/hooks/useField/useField.js +8 -1
  11. package/internals/hooks/useViews.d.ts +4 -4
  12. package/internals/hooks/useViews.js +13 -13
  13. package/internals/models/props/clock.d.ts +0 -9
  14. package/legacy/DateCalendar/DateCalendar.js +6 -4
  15. package/legacy/DigitalClock/DigitalClock.js +3 -2
  16. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  17. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  18. package/legacy/TimeClock/TimeClock.js +3 -2
  19. package/legacy/index.js +1 -1
  20. package/legacy/internals/hooks/useField/useField.js +8 -1
  21. package/legacy/internals/hooks/useViews.js +13 -13
  22. package/legacy/locales/ruRU.js +1 -2
  23. package/locales/ruRU.js +1 -2
  24. package/modern/DateCalendar/DateCalendar.js +6 -4
  25. package/modern/DigitalClock/DigitalClock.js +3 -2
  26. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  27. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  28. package/modern/TimeClock/TimeClock.js +3 -2
  29. package/modern/index.js +1 -1
  30. package/modern/internals/hooks/useField/useField.js +8 -1
  31. package/modern/internals/hooks/useViews.js +13 -13
  32. package/modern/locales/ruRU.js +1 -2
  33. package/node/DateCalendar/DateCalendar.js +6 -4
  34. package/node/DigitalClock/DigitalClock.js +3 -2
  35. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  36. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  37. package/node/TimeClock/TimeClock.js +3 -2
  38. package/node/index.js +1 -1
  39. package/node/internals/hooks/useField/useField.js +8 -1
  40. package/node/internals/hooks/useViews.js +13 -13
  41. package/node/locales/ruRU.js +1 -2
  42. package/package.json +1 -1
@@ -93,7 +93,7 @@ export var MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(funct
93
93
  var _slots$digitalClockSe;
94
94
  var containerRef = React.useRef(null);
95
95
  var handleRef = useForkRef(ref, containerRef);
96
- var previousSelected = React.useRef(null);
96
+ var previousActive = React.useRef(null);
97
97
  var props = useThemeProps({
98
98
  props: inProps,
99
99
  name: 'MuiMultiSectionDigitalClockSection'
@@ -120,19 +120,15 @@ export var MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(funct
120
120
  if (containerRef.current === null) {
121
121
  return;
122
122
  }
123
- var selectedItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
124
- if (!selectedItem || previousSelected.current === selectedItem) {
125
- // Handle setting the ref to null if the selected item is ever reset via UI
126
- if (previousSelected.current !== selectedItem) {
127
- previousSelected.current = selectedItem;
128
- }
129
- return;
123
+ var activeItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
124
+ if (active && autoFocus && activeItem) {
125
+ activeItem.focus();
130
126
  }
131
- previousSelected.current = selectedItem;
132
- if (active && autoFocus) {
133
- selectedItem.focus();
127
+ if (!activeItem || previousActive.current === activeItem) {
128
+ return;
134
129
  }
135
- var offsetTop = selectedItem.offsetTop;
130
+ previousActive.current = activeItem;
131
+ var offsetTop = activeItem.offsetTop;
136
132
 
137
133
  // Subtracting the 4px of extra margin intended for the first visible section item
138
134
  containerRef.current.scrollTop = offsetTop - 4;
@@ -416,8 +416,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
416
416
  minutesStep: PropTypes.number,
417
417
  /**
418
418
  * Callback fired when the value changes.
419
- * @template TDate, TView
420
- * @param {TDate | null} value The new value.
419
+ * @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.
420
+ * @template TView The view type. Will be one of date or time views.
421
+ * @param {TValue} value The new value.
421
422
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
422
423
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
423
424
  */
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.18.5
2
+ * @mui/x-date-pickers v6.18.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -152,7 +152,14 @@ export var useField = function useField(params) {
152
152
  var digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
153
153
  var isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
154
154
  if (isValidPastedValue) {
155
- // Early return to let the paste update section, value
155
+ resetCharacterQuery();
156
+ updateSectionValue({
157
+ activeSection: activeSection,
158
+ newSectionValue: pastedValue,
159
+ shouldGoToNextSection: true
160
+ });
161
+ // prevent default to avoid the input change handler being called
162
+ event.preventDefault();
156
163
  return;
157
164
  }
158
165
  if (lettersOnly || digitsOnly) {
@@ -75,11 +75,12 @@ export function useViews(_ref) {
75
75
  onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
76
76
  });
77
77
  var handleChangeView = useEventCallback(function (newView) {
78
+ // always keep the focused view in sync
79
+ handleFocusedViewChange(newView, true);
78
80
  if (newView === view) {
79
81
  return;
80
82
  }
81
83
  setView(newView);
82
- handleFocusedViewChange(newView, true);
83
84
  if (onViewChange) {
84
85
  onViewChange(newView);
85
86
  }
@@ -88,7 +89,6 @@ export function useViews(_ref) {
88
89
  if (nextView) {
89
90
  handleChangeView(nextView);
90
91
  }
91
- handleFocusedViewChange(nextView, true);
92
92
  });
93
93
  var setValueAndGoToNextView = useEventCallback(function (value, currentViewSelectionState, selectedView) {
94
94
  var isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
@@ -97,18 +97,19 @@ export function useViews(_ref) {
97
97
  // but we it's not the final view given all `views` -> overall selection state should be `partial`.
98
98
  views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
99
99
  var globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
100
- onChange(value, globalSelectionState);
101
- if (isSelectionFinishedOnCurrentView) {
100
+ onChange(value, globalSelectionState, selectedView);
101
+ // Detects if the selected view is not the active one.
102
+ // Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
103
+ if (selectedView && selectedView !== view) {
104
+ var nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
105
+ if (nextViewAfterSelected) {
106
+ // move to next view after the selected one
107
+ handleChangeView(nextViewAfterSelected);
108
+ }
109
+ } else if (isSelectionFinishedOnCurrentView) {
102
110
  goToNextView();
103
111
  }
104
112
  });
105
- var setValueAndGoToView = useEventCallback(function (value, newView, selectedView) {
106
- onChange(value, newView ? 'partial' : 'finish', selectedView);
107
- if (newView) {
108
- handleChangeView(newView);
109
- handleFocusedViewChange(newView, true);
110
- }
111
- });
112
113
  return {
113
114
  view: view,
114
115
  setView: handleChangeView,
@@ -119,7 +120,6 @@ export function useViews(_ref) {
119
120
  // Always return up to date default view instead of the initial one (i.e. defaultView.current)
120
121
  defaultView: views.includes(openTo) ? openTo : views[0],
121
122
  goToNextView: goToNextView,
122
- setValueAndGoToNextView: setValueAndGoToNextView,
123
- setValueAndGoToView: setValueAndGoToView
123
+ setValueAndGoToNextView: setValueAndGoToNextView
124
124
  };
125
125
  }
@@ -62,8 +62,7 @@ var ruRUPickers = {
62
62
  openTimePickerDialogue: function openTimePickerDialogue(value, utils) {
63
63
  return value !== null && utils.isValid(value) ? "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0440\u0435\u043C\u044F, \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0432\u0440\u0435\u043C\u044F ".concat(utils.format(value, 'fullTime')) : 'Выберите время';
64
64
  },
65
- // fieldClearLabel: 'Clear value',
66
-
65
+ fieldClearLabel: 'Очистить значение',
67
66
  // Table labels
68
67
  timeTableLabel: 'выбрать время',
69
68
  dateTableLabel: 'выбрать дату',
package/locales/ruRU.js CHANGED
@@ -42,8 +42,7 @@ const ruRUPickers = {
42
42
  // Open picker labels
43
43
  openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите дату, выбрана дата ${utils.format(value, 'fullDate')}` : 'Выберите дату',
44
44
  openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите время, выбрано время ${utils.format(value, 'fullTime')}` : 'Выберите время',
45
- // fieldClearLabel: 'Clear value',
46
-
45
+ fieldClearLabel: 'Очистить значение',
47
46
  // Table labels
48
47
  timeTableLabel: 'выбрать время',
49
48
  dateTableLabel: 'выбрать дату',
@@ -256,9 +256,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
256
256
  const handleSelectedDayChange = useEventCallback(day => {
257
257
  if (day) {
258
258
  // If there is a date already selected, then we want to keep its time
259
- return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish');
259
+ return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish', view);
260
260
  }
261
- return handleValueChange(day, 'finish');
261
+ return handleValueChange(day, 'finish', view);
262
262
  });
263
263
  React.useEffect(() => {
264
264
  if (value != null && utils.isValid(value)) {
@@ -447,9 +447,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
447
447
  monthsPerRow: PropTypes.oneOf([3, 4]),
448
448
  /**
449
449
  * Callback fired when the value changes.
450
- * @template TDate
451
- * @param {TDate | null} value The new value.
450
+ * @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.
451
+ * @template TView The view type. Will be one of date or time views.
452
+ * @param {TValue} value The new value.
452
453
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
454
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
453
455
  */
454
456
  onChange: PropTypes.func,
455
457
  /**
@@ -339,8 +339,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
339
339
  minutesStep: PropTypes.number,
340
340
  /**
341
341
  * Callback fired when the value changes.
342
- * @template TDate, TView
343
- * @param {TDate | null} value The new value.
342
+ * @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.
343
+ * @template TView The view type. Will be one of date or time views.
344
+ * @param {TValue} value The new value.
344
345
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
345
346
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
346
347
  */
@@ -125,7 +125,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
125
125
  }, [ampm, inViews]);
126
126
  const {
127
127
  view,
128
- setValueAndGoToView,
128
+ setValueAndGoToNextView,
129
129
  focusedView
130
130
  } = useViews({
131
131
  view: inView,
@@ -137,7 +137,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
137
137
  onFocusedViewChange
138
138
  });
139
139
  const handleMeridiemValueChange = useEventCallback(newValue => {
140
- setValueAndGoToView(newValue, null, 'meridiem');
140
+ setValueAndGoToNextView(newValue, 'finish', 'meridiem');
141
141
  });
142
142
  const {
143
143
  meridiemMode,
@@ -221,11 +221,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
221
221
  throw new Error('not supported');
222
222
  }
223
223
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableClock, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
224
- const handleSectionChange = useEventCallback((sectionView, newValue) => {
225
- const viewIndex = views.indexOf(sectionView);
226
- const nextView = views[viewIndex + 1];
227
- setValueAndGoToView(newValue, nextView, sectionView);
228
- });
229
224
  const buildViewProps = React.useCallback(viewToBuild => {
230
225
  switch (viewToBuild) {
231
226
  case 'hours':
@@ -233,7 +228,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
233
228
  return {
234
229
  onChange: hours => {
235
230
  const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
236
- handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
231
+ setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
237
232
  },
238
233
  items: getHourSectionOptions({
239
234
  now,
@@ -250,7 +245,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
250
245
  {
251
246
  return {
252
247
  onChange: minutes => {
253
- handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
248
+ setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
254
249
  },
255
250
  items: getTimeSectionOptions({
256
251
  value: utils.getMinutes(valueOrReferenceDate),
@@ -267,7 +262,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
267
262
  {
268
263
  return {
269
264
  onChange: seconds => {
270
- handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
265
+ setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
271
266
  },
272
267
  items: getTimeSectionOptions({
273
268
  value: utils.getSeconds(valueOrReferenceDate),
@@ -302,7 +297,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
302
297
  default:
303
298
  throw new Error(`Unknown view: ${viewToBuild} found.`);
304
299
  }
305
- }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
300
+ }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
306
301
  const viewTimeOptions = React.useMemo(() => {
307
302
  return views.reduce((result, currentView) => {
308
303
  return _extends({}, result, {
@@ -412,8 +407,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
412
407
  minutesStep: PropTypes.number,
413
408
  /**
414
409
  * Callback fired when the value changes.
415
- * @template TDate, TView
416
- * @param {TDate | null} value The new value.
410
+ * @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.
411
+ * @template TView The view type. Will be one of date or time views.
412
+ * @param {TValue} value The new value.
417
413
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
418
414
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
419
415
  */
@@ -88,7 +88,7 @@ const MultiSectionDigitalClockSectionItem = styled(MenuItem, {
88
88
  export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(function MultiSectionDigitalClockSection(inProps, ref) {
89
89
  const containerRef = React.useRef(null);
90
90
  const handleRef = useForkRef(ref, containerRef);
91
- const previousSelected = React.useRef(null);
91
+ const previousActive = React.useRef(null);
92
92
  const props = useThemeProps({
93
93
  props: inProps,
94
94
  name: 'MuiMultiSectionDigitalClockSection'
@@ -115,19 +115,15 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
115
115
  if (containerRef.current === null) {
116
116
  return;
117
117
  }
118
- const selectedItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
119
- if (!selectedItem || previousSelected.current === selectedItem) {
120
- // Handle setting the ref to null if the selected item is ever reset via UI
121
- if (previousSelected.current !== selectedItem) {
122
- previousSelected.current = selectedItem;
123
- }
124
- return;
118
+ const activeItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
119
+ if (active && autoFocus && activeItem) {
120
+ activeItem.focus();
125
121
  }
126
- previousSelected.current = selectedItem;
127
- if (active && autoFocus) {
128
- selectedItem.focus();
122
+ if (!activeItem || previousActive.current === activeItem) {
123
+ return;
129
124
  }
130
- const offsetTop = selectedItem.offsetTop;
125
+ previousActive.current = activeItem;
126
+ const offsetTop = activeItem.offsetTop;
131
127
 
132
128
  // Subtracting the 4px of extra margin intended for the first visible section item
133
129
  containerRef.current.scrollTop = offsetTop - 4;
@@ -404,8 +404,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
404
404
  minutesStep: PropTypes.number,
405
405
  /**
406
406
  * Callback fired when the value changes.
407
- * @template TDate, TView
408
- * @param {TDate | null} value The new value.
407
+ * @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.
408
+ * @template TView The view type. Will be one of date or time views.
409
+ * @param {TValue} value The new value.
409
410
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
410
411
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
411
412
  */
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.18.5
2
+ * @mui/x-date-pickers v6.18.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -142,7 +142,14 @@ export const useField = params => {
142
142
  const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
143
143
  const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
144
144
  if (isValidPastedValue) {
145
- // Early return to let the paste update section, value
145
+ resetCharacterQuery();
146
+ updateSectionValue({
147
+ activeSection,
148
+ newSectionValue: pastedValue,
149
+ shouldGoToNextSection: true
150
+ });
151
+ // prevent default to avoid the input change handler being called
152
+ event.preventDefault();
146
153
  return;
147
154
  }
148
155
  if (lettersOnly || digitsOnly) {
@@ -64,11 +64,12 @@ export function useViews({
64
64
  onFocusedViewChange?.(viewToFocus, hasFocus);
65
65
  });
66
66
  const handleChangeView = useEventCallback(newView => {
67
+ // always keep the focused view in sync
68
+ handleFocusedViewChange(newView, true);
67
69
  if (newView === view) {
68
70
  return;
69
71
  }
70
72
  setView(newView);
71
- handleFocusedViewChange(newView, true);
72
73
  if (onViewChange) {
73
74
  onViewChange(newView);
74
75
  }
@@ -77,7 +78,6 @@ export function useViews({
77
78
  if (nextView) {
78
79
  handleChangeView(nextView);
79
80
  }
80
- handleFocusedViewChange(nextView, true);
81
81
  });
82
82
  const setValueAndGoToNextView = useEventCallback((value, currentViewSelectionState, selectedView) => {
83
83
  const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
@@ -86,18 +86,19 @@ export function useViews({
86
86
  // but we it's not the final view given all `views` -> overall selection state should be `partial`.
87
87
  views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
88
88
  const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
89
- onChange(value, globalSelectionState);
90
- if (isSelectionFinishedOnCurrentView) {
89
+ onChange(value, globalSelectionState, selectedView);
90
+ // Detects if the selected view is not the active one.
91
+ // Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
92
+ if (selectedView && selectedView !== view) {
93
+ const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
94
+ if (nextViewAfterSelected) {
95
+ // move to next view after the selected one
96
+ handleChangeView(nextViewAfterSelected);
97
+ }
98
+ } else if (isSelectionFinishedOnCurrentView) {
91
99
  goToNextView();
92
100
  }
93
101
  });
94
- const setValueAndGoToView = useEventCallback((value, newView, selectedView) => {
95
- onChange(value, newView ? 'partial' : 'finish', selectedView);
96
- if (newView) {
97
- handleChangeView(newView);
98
- handleFocusedViewChange(newView, true);
99
- }
100
- });
101
102
  return {
102
103
  view,
103
104
  setView: handleChangeView,
@@ -108,7 +109,6 @@ export function useViews({
108
109
  // Always return up to date default view instead of the initial one (i.e. defaultView.current)
109
110
  defaultView: views.includes(openTo) ? openTo : views[0],
110
111
  goToNextView,
111
- setValueAndGoToNextView,
112
- setValueAndGoToView
112
+ setValueAndGoToNextView
113
113
  };
114
114
  }
@@ -42,8 +42,7 @@ const ruRUPickers = {
42
42
  // Open picker labels
43
43
  openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите дату, выбрана дата ${utils.format(value, 'fullDate')}` : 'Выберите дату',
44
44
  openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите время, выбрано время ${utils.format(value, 'fullTime')}` : 'Выберите время',
45
- // fieldClearLabel: 'Clear value',
46
-
45
+ fieldClearLabel: 'Очистить значение',
47
46
  // Table labels
48
47
  timeTableLabel: 'выбрать время',
49
48
  dateTableLabel: 'выбрать дату',
@@ -264,9 +264,9 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
264
264
  const handleSelectedDayChange = (0, _utils2.unstable_useEventCallback)(day => {
265
265
  if (day) {
266
266
  // If there is a date already selected, then we want to keep its time
267
- return handleValueChange((0, _dateUtils.mergeDateAndTime)(utils, day, value ?? referenceDate), 'finish');
267
+ return handleValueChange((0, _dateUtils.mergeDateAndTime)(utils, day, value ?? referenceDate), 'finish', view);
268
268
  }
269
- return handleValueChange(day, 'finish');
269
+ return handleValueChange(day, 'finish', view);
270
270
  });
271
271
  React.useEffect(() => {
272
272
  if (value != null && utils.isValid(value)) {
@@ -455,9 +455,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
455
455
  monthsPerRow: _propTypes.default.oneOf([3, 4]),
456
456
  /**
457
457
  * Callback fired when the value changes.
458
- * @template TDate
459
- * @param {TDate | null} value The new value.
458
+ * @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.
459
+ * @template TView The view type. Will be one of date or time views.
460
+ * @param {TValue} value The new value.
460
461
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
462
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
461
463
  */
462
464
  onChange: _propTypes.default.func,
463
465
  /**
@@ -348,8 +348,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
348
348
  minutesStep: _propTypes.default.number,
349
349
  /**
350
350
  * Callback fired when the value changes.
351
- * @template TDate, TView
352
- * @param {TDate | null} value The new value.
351
+ * @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.
352
+ * @template TView The view type. Will be one of date or time views.
353
+ * @param {TValue} value The new value.
353
354
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
354
355
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
355
356
  */
@@ -134,7 +134,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
134
134
  }, [ampm, inViews]);
135
135
  const {
136
136
  view,
137
- setValueAndGoToView,
137
+ setValueAndGoToNextView,
138
138
  focusedView
139
139
  } = (0, _useViews.useViews)({
140
140
  view: inView,
@@ -146,7 +146,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
146
146
  onFocusedViewChange
147
147
  });
148
148
  const handleMeridiemValueChange = (0, _useEventCallback.default)(newValue => {
149
- setValueAndGoToView(newValue, null, 'meridiem');
149
+ setValueAndGoToNextView(newValue, 'finish', 'meridiem');
150
150
  });
151
151
  const {
152
152
  meridiemMode,
@@ -230,11 +230,6 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
230
230
  throw new Error('not supported');
231
231
  }
232
232
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableClock, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
233
- const handleSectionChange = (0, _useEventCallback.default)((sectionView, newValue) => {
234
- const viewIndex = views.indexOf(sectionView);
235
- const nextView = views[viewIndex + 1];
236
- setValueAndGoToView(newValue, nextView, sectionView);
237
- });
238
233
  const buildViewProps = React.useCallback(viewToBuild => {
239
234
  switch (viewToBuild) {
240
235
  case 'hours':
@@ -242,7 +237,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
242
237
  return {
243
238
  onChange: hours => {
244
239
  const valueWithMeridiem = (0, _timeUtils.convertValueToMeridiem)(hours, meridiemMode, ampm);
245
- handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
240
+ setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
246
241
  },
247
242
  items: (0, _MultiSectionDigitalClock.getHourSectionOptions)({
248
243
  now,
@@ -259,7 +254,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
259
254
  {
260
255
  return {
261
256
  onChange: minutes => {
262
- handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
257
+ setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
263
258
  },
264
259
  items: (0, _MultiSectionDigitalClock.getTimeSectionOptions)({
265
260
  value: utils.getMinutes(valueOrReferenceDate),
@@ -276,7 +271,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
276
271
  {
277
272
  return {
278
273
  onChange: seconds => {
279
- handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
274
+ setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
280
275
  },
281
276
  items: (0, _MultiSectionDigitalClock.getTimeSectionOptions)({
282
277
  value: utils.getSeconds(valueOrReferenceDate),
@@ -311,7 +306,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
311
306
  default:
312
307
  throw new Error(`Unknown view: ${viewToBuild} found.`);
313
308
  }
314
- }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
309
+ }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
315
310
  const viewTimeOptions = React.useMemo(() => {
316
311
  return views.reduce((result, currentView) => {
317
312
  return (0, _extends2.default)({}, result, {
@@ -421,8 +416,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
421
416
  minutesStep: _propTypes.default.number,
422
417
  /**
423
418
  * Callback fired when the value changes.
424
- * @template TDate, TView
425
- * @param {TDate | null} value The new value.
419
+ * @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.
420
+ * @template TView The view type. Will be one of date or time views.
421
+ * @param {TValue} value The new value.
426
422
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
427
423
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
428
424
  */
@@ -97,7 +97,7 @@ const MultiSectionDigitalClockSectionItem = (0, _styles.styled)(_MenuItem.defaul
97
97
  const MultiSectionDigitalClockSection = exports.MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(function MultiSectionDigitalClockSection(inProps, ref) {
98
98
  const containerRef = React.useRef(null);
99
99
  const handleRef = (0, _useForkRef.default)(ref, containerRef);
100
- const previousSelected = React.useRef(null);
100
+ const previousActive = React.useRef(null);
101
101
  const props = (0, _styles.useThemeProps)({
102
102
  props: inProps,
103
103
  name: 'MuiMultiSectionDigitalClockSection'
@@ -124,19 +124,15 @@ const MultiSectionDigitalClockSection = exports.MultiSectionDigitalClockSection
124
124
  if (containerRef.current === null) {
125
125
  return;
126
126
  }
127
- const selectedItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
128
- if (!selectedItem || previousSelected.current === selectedItem) {
129
- // Handle setting the ref to null if the selected item is ever reset via UI
130
- if (previousSelected.current !== selectedItem) {
131
- previousSelected.current = selectedItem;
132
- }
133
- return;
127
+ const activeItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
128
+ if (active && autoFocus && activeItem) {
129
+ activeItem.focus();
134
130
  }
135
- previousSelected.current = selectedItem;
136
- if (active && autoFocus) {
137
- selectedItem.focus();
131
+ if (!activeItem || previousActive.current === activeItem) {
132
+ return;
138
133
  }
139
- const offsetTop = selectedItem.offsetTop;
134
+ previousActive.current = activeItem;
135
+ const offsetTop = activeItem.offsetTop;
140
136
 
141
137
  // Subtracting the 4px of extra margin intended for the first visible section item
142
138
  containerRef.current.scrollTop = offsetTop - 4;
@@ -412,8 +412,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
412
412
  minutesStep: _propTypes.default.number,
413
413
  /**
414
414
  * Callback fired when the value changes.
415
- * @template TDate, TView
416
- * @param {TDate | null} value The new value.
415
+ * @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.
416
+ * @template TView The view type. Will be one of date or time views.
417
+ * @param {TValue} value The new value.
417
418
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
418
419
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
419
420
  */
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.18.5
2
+ * @mui/x-date-pickers v6.18.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -151,7 +151,14 @@ const useField = params => {
151
151
  const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
152
152
  const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
153
153
  if (isValidPastedValue) {
154
- // Early return to let the paste update section, value
154
+ resetCharacterQuery();
155
+ updateSectionValue({
156
+ activeSection,
157
+ newSectionValue: pastedValue,
158
+ shouldGoToNextSection: true
159
+ });
160
+ // prevent default to avoid the input change handler being called
161
+ event.preventDefault();
155
162
  return;
156
163
  }
157
164
  if (lettersOnly || digitsOnly) {