@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.
- package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
- package/CHANGELOG.md +91 -0
- 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/index.js +1 -1
- package/internals/hooks/useField/useField.js +8 -1
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +13 -13
- package/internals/models/props/clock.d.ts +0 -9
- 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/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +8 -1
- package/legacy/internals/hooks/useViews.js +13 -13
- package/legacy/locales/ruRU.js +1 -2
- package/locales/ruRU.js +1 -2
- 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/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +8 -1
- package/modern/internals/hooks/useViews.js +13 -13
- package/modern/locales/ruRU.js +1 -2
- 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/index.js +1 -1
- package/node/internals/hooks/useField/useField.js +8 -1
- package/node/internals/hooks/useViews.js +13 -13
- package/node/locales/ruRU.js +1 -2
- 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
|
|
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
|
|
124
|
-
if (
|
|
125
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
selectedItem.focus();
|
|
127
|
+
if (!activeItem || previousActive.current === activeItem) {
|
|
128
|
+
return;
|
|
134
129
|
}
|
|
135
|
-
|
|
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
|
|
420
|
-
* @
|
|
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
|
@@ -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
|
-
|
|
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
|
|
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
|
}
|
package/legacy/locales/ruRU.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
451
|
-
* @
|
|
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
|
|
343
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
416
|
-
* @
|
|
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
|
|
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
|
|
119
|
-
if (
|
|
120
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
selectedItem.focus();
|
|
122
|
+
if (!activeItem || previousActive.current === activeItem) {
|
|
123
|
+
return;
|
|
129
124
|
}
|
|
130
|
-
|
|
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
|
|
408
|
-
* @
|
|
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
|
@@ -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
|
-
|
|
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
|
|
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
|
}
|
package/modern/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
|
-
|
|
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
|
|
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
|
*/
|
package/node/index.js
CHANGED
|
@@ -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
|
-
|
|
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) {
|