@mui/x-date-pickers 6.18.6 → 6.19.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 (72) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
  2. package/AdapterDateFns/AdapterDateFns.js +11 -272
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
  4. package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  5. package/AdapterDateFnsBase/index.d.ts +1 -0
  6. package/AdapterDateFnsBase/index.js +1 -0
  7. package/AdapterDateFnsBase/package.json +6 -0
  8. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
  9. package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  10. package/AdapterDateFnsV3/index.d.ts +1 -0
  11. package/AdapterDateFnsV3/index.js +1 -0
  12. package/AdapterDateFnsV3/package.json +6 -0
  13. package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
  14. package/CHANGELOG.md +85 -1
  15. package/DateCalendar/DateCalendar.js +6 -4
  16. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  17. package/DigitalClock/DigitalClock.js +3 -2
  18. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  19. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  20. package/TimeClock/TimeClock.js +3 -2
  21. package/hooks/useClearableField.d.ts +1 -1
  22. package/hooks/useClearableField.js +3 -3
  23. package/index.js +1 -1
  24. package/internals/hooks/useViews.d.ts +4 -4
  25. package/internals/hooks/useViews.js +13 -13
  26. package/internals/models/helpers.d.ts +1 -0
  27. package/internals/models/props/clock.d.ts +0 -9
  28. package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
  29. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  30. package/legacy/AdapterDateFnsBase/index.js +1 -0
  31. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
  32. package/legacy/AdapterDateFnsV3/index.js +1 -0
  33. package/legacy/DateCalendar/DateCalendar.js +6 -4
  34. package/legacy/DigitalClock/DigitalClock.js +3 -2
  35. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  36. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  37. package/legacy/TimeClock/TimeClock.js +3 -2
  38. package/legacy/hooks/useClearableField.js +3 -3
  39. package/legacy/index.js +1 -1
  40. package/legacy/internals/hooks/useViews.js +13 -13
  41. package/legacy/locales/index.js +1 -0
  42. package/locales/index.d.ts +1 -0
  43. package/locales/index.js +1 -0
  44. package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
  45. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
  46. package/modern/AdapterDateFnsBase/index.js +1 -0
  47. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  48. package/modern/AdapterDateFnsV3/index.js +1 -0
  49. package/modern/DateCalendar/DateCalendar.js +6 -4
  50. package/modern/DigitalClock/DigitalClock.js +3 -2
  51. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  52. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  53. package/modern/TimeClock/TimeClock.js +3 -2
  54. package/modern/hooks/useClearableField.js +3 -3
  55. package/modern/index.js +1 -1
  56. package/modern/internals/hooks/useViews.js +13 -13
  57. package/modern/locales/index.js +1 -0
  58. package/node/AdapterDateFns/AdapterDateFns.js +11 -271
  59. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
  60. package/node/AdapterDateFnsBase/index.js +12 -0
  61. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
  62. package/node/AdapterDateFnsV3/index.js +12 -0
  63. package/node/DateCalendar/DateCalendar.js +6 -4
  64. package/node/DigitalClock/DigitalClock.js +3 -2
  65. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  66. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  67. package/node/TimeClock/TimeClock.js +3 -2
  68. package/node/hooks/useClearableField.js +3 -3
  69. package/node/index.js +1 -1
  70. package/node/internals/hooks/useViews.js +13 -13
  71. package/node/locales/index.js +11 -0
  72. package/package.json +2 -2
@@ -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
  */
@@ -47,8 +47,8 @@ const useClearableField = ({
47
47
  ownerState: {}
48
48
  });
49
49
  const InputProps = (0, _extends2.default)({}, ForwardedInputProps, {
50
- endAdornment: clearable ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
51
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputAdornment.default, {
50
+ endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
51
+ children: [clearable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputAdornment.default, {
52
52
  position: "end",
53
53
  sx: {
54
54
  marginRight: ForwardedInputProps?.endAdornment ? -1 : -1.5
@@ -60,7 +60,7 @@ const useClearableField = ({
60
60
  }, endClearIconProps))
61
61
  }))
62
62
  }), ForwardedInputProps?.endAdornment]
63
- }) : ForwardedInputProps?.endAdornment
63
+ })
64
64
  });
65
65
  const fieldProps = (0, _extends2.default)({}, forwardedFieldProps, {
66
66
  sx: [{
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.18.6
2
+ * @mui/x-date-pickers v6.19.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -73,11 +73,12 @@ function useViews({
73
73
  onFocusedViewChange?.(viewToFocus, hasFocus);
74
74
  });
75
75
  const handleChangeView = (0, _useEventCallback.default)(newView => {
76
+ // always keep the focused view in sync
77
+ handleFocusedViewChange(newView, true);
76
78
  if (newView === view) {
77
79
  return;
78
80
  }
79
81
  setView(newView);
80
- handleFocusedViewChange(newView, true);
81
82
  if (onViewChange) {
82
83
  onViewChange(newView);
83
84
  }
@@ -86,7 +87,6 @@ function useViews({
86
87
  if (nextView) {
87
88
  handleChangeView(nextView);
88
89
  }
89
- handleFocusedViewChange(nextView, true);
90
90
  });
91
91
  const setValueAndGoToNextView = (0, _useEventCallback.default)((value, currentViewSelectionState, selectedView) => {
92
92
  const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
@@ -95,18 +95,19 @@ function useViews({
95
95
  // but we it's not the final view given all `views` -> overall selection state should be `partial`.
96
96
  views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
97
97
  const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
98
- onChange(value, globalSelectionState);
99
- if (isSelectionFinishedOnCurrentView) {
98
+ onChange(value, globalSelectionState, selectedView);
99
+ // Detects if the selected view is not the active one.
100
+ // Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
101
+ if (selectedView && selectedView !== view) {
102
+ const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
103
+ if (nextViewAfterSelected) {
104
+ // move to next view after the selected one
105
+ handleChangeView(nextViewAfterSelected);
106
+ }
107
+ } else if (isSelectionFinishedOnCurrentView) {
100
108
  goToNextView();
101
109
  }
102
110
  });
103
- const setValueAndGoToView = (0, _useEventCallback.default)((value, newView, selectedView) => {
104
- onChange(value, newView ? 'partial' : 'finish', selectedView);
105
- if (newView) {
106
- handleChangeView(newView);
107
- handleFocusedViewChange(newView, true);
108
- }
109
- });
110
111
  return {
111
112
  view,
112
113
  setView: handleChangeView,
@@ -117,7 +118,6 @@ function useViews({
117
118
  // Always return up to date default view instead of the initial one (i.e. defaultView.current)
118
119
  defaultView: views.includes(openTo) ? openTo : views[0],
119
120
  goToNextView,
120
- setValueAndGoToNextView,
121
- setValueAndGoToView
121
+ setValueAndGoToNextView
122
122
  };
123
123
  }
@@ -36,6 +36,17 @@ Object.keys(_csCZ).forEach(function (key) {
36
36
  }
37
37
  });
38
38
  });
39
+ var _daDK = require("./daDK");
40
+ Object.keys(_daDK).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _daDK[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _daDK[key];
47
+ }
48
+ });
49
+ });
39
50
  var _deDE = require("./deDE");
40
51
  Object.keys(_deDE).forEach(function (key) {
41
52
  if (key === "default" || key === "__esModule") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers",
3
- "version": "6.18.6",
3
+ "version": "6.19.0",
4
4
  "description": "The community edition of the date picker components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -46,7 +46,7 @@
46
46
  "@emotion/styled": "^11.8.1",
47
47
  "@mui/material": "^5.8.6",
48
48
  "@mui/system": "^5.8.0",
49
- "date-fns": "^2.25.0",
49
+ "date-fns": "^2.25.0 || ^3.2.0",
50
50
  "date-fns-jalali": "^2.13.0-0",
51
51
  "dayjs": "^1.10.7",
52
52
  "luxon": "^3.0.2",