@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.
- package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
- package/AdapterDateFns/AdapterDateFns.js +11 -272
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
- package/CHANGELOG.md +85 -1
- package/DateCalendar/DateCalendar.js +6 -4
- package/DateCalendar/DateCalendar.types.d.ts +0 -8
- package/DigitalClock/DigitalClock.js +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/TimeClock/TimeClock.js +3 -2
- package/hooks/useClearableField.d.ts +1 -1
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +13 -13
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/clock.d.ts +0 -9
- package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/DateCalendar/DateCalendar.js +6 -4
- package/legacy/DigitalClock/DigitalClock.js +3 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/legacy/TimeClock/TimeClock.js +3 -2
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useViews.js +13 -13
- package/legacy/locales/index.js +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +6 -4
- package/modern/DigitalClock/DigitalClock.js +3 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/modern/TimeClock/TimeClock.js +3 -2
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useViews.js +13 -13
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -271
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DateCalendar/DateCalendar.js +6 -4
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/node/TimeClock/TimeClock.js +3 -2
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/hooks/useViews.js +13 -13
- package/node/locales/index.js +11 -0
- 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
|
|
459
|
-
* @
|
|
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
|
|
352
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
425
|
-
* @
|
|
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
|
|
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
|
|
128
|
-
if (
|
|
129
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
selectedItem.focus();
|
|
131
|
+
if (!activeItem || previousActive.current === activeItem) {
|
|
132
|
+
return;
|
|
138
133
|
}
|
|
139
|
-
|
|
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
|
|
416
|
-
* @
|
|
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:
|
|
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
|
-
})
|
|
63
|
+
})
|
|
64
64
|
});
|
|
65
65
|
const fieldProps = (0, _extends2.default)({}, forwardedFieldProps, {
|
|
66
66
|
sx: [{
|
package/node/index.js
CHANGED
|
@@ -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
|
|
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
|
}
|
package/node/locales/index.js
CHANGED
|
@@ -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.
|
|
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",
|