@mui/x-date-pickers 7.0.0-alpha.5 → 7.0.0-alpha.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/CHANGELOG.md +408 -6
- 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 +4 -8
- package/PickersSectionList/PickersSectionList.d.ts +11 -0
- package/PickersSectionList/PickersSectionList.js +223 -0
- package/PickersSectionList/PickersSectionList.types.d.ts +56 -0
- package/PickersSectionList/index.d.ts +4 -0
- package/PickersSectionList/index.js +2 -0
- package/PickersSectionList/package.json +6 -0
- package/PickersSectionList/pickersSectionListClasses.d.ts +11 -0
- package/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/TimeClock/TimeClock.js +3 -2
- package/index.d.ts +1 -0
- package/index.js +4 -1
- package/internals/components/{PickersTextField → PickersInput}/Outline.d.ts +1 -0
- package/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/internals/components/PickersInput/PickersFilledInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersFilledInput.js +166 -0
- package/internals/components/PickersInput/PickersInput.d.ts +15 -0
- package/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/internals/components/PickersInput/PickersInput.types.d.ts +60 -0
- package/internals/components/PickersInput/PickersOutlinedInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/internals/components/PickersInput/PickersStandardInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/internals/components/PickersInput/index.d.ts +4 -0
- package/internals/components/PickersInput/index.js +3 -0
- package/internals/components/PickersInput/pickersInputClasses.d.ts +84 -0
- package/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/internals/components/PickersTextField/PickersTextField.d.ts +1 -2
- package/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +46 -3
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +0 -31
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- 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 +4 -8
- package/legacy/PickersSectionList/PickersSectionList.js +230 -0
- package/legacy/PickersSectionList/index.js +2 -0
- package/legacy/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/legacy/TimeClock/TimeClock.js +3 -2
- package/legacy/index.js +4 -1
- package/legacy/internals/components/{PickersTextField → PickersInput}/Outline.js +40 -22
- package/legacy/internals/components/PickersInput/PickersFilledInput.js +161 -0
- package/legacy/internals/components/{PickersTextField → PickersInput}/PickersInput.js +75 -90
- package/legacy/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/legacy/internals/components/PickersInput/PickersOutlinedInput.js +110 -0
- package/legacy/internals/components/PickersInput/PickersStandardInput.js +117 -0
- package/legacy/internals/components/PickersInput/index.js +3 -0
- package/legacy/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.js +16 -7
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- 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 +4 -8
- package/modern/PickersSectionList/PickersSectionList.js +221 -0
- package/modern/PickersSectionList/PickersSectionList.types.js +1 -0
- package/modern/PickersSectionList/index.js +2 -0
- package/modern/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/modern/TimeClock/TimeClock.js +3 -2
- package/modern/index.js +4 -1
- package/modern/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/modern/internals/components/PickersInput/PickersFilledInput.js +165 -0
- package/modern/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/modern/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/modern/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/modern/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/modern/internals/components/PickersInput/index.js +3 -0
- package/modern/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/modern/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- 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 +4 -8
- package/node/PickersSectionList/PickersSectionList.js +228 -0
- package/node/PickersSectionList/index.js +49 -0
- package/node/PickersSectionList/pickersSectionListClasses.js +14 -0
- package/node/TimeClock/TimeClock.js +3 -2
- package/node/index.js +13 -1
- package/node/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/node/internals/components/PickersInput/PickersFilledInput.js +174 -0
- package/node/internals/components/{PickersTextField → PickersInput}/PickersInput.js +80 -108
- package/node/internals/components/PickersInput/PickersInput.types.js +5 -0
- package/node/internals/components/PickersInput/PickersOutlinedInput.js +125 -0
- package/node/internals/components/PickersInput/PickersStandardInput.js +132 -0
- package/node/internals/components/PickersInput/index.js +32 -0
- package/node/internals/components/PickersInput/pickersInputClasses.js +29 -0
- package/node/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +6 -9
- 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 +5 -5
- package/internals/components/PickersTextField/PickersInput.d.ts +0 -3
- package/internals/components/PickersTextField/PickersInput.types.d.ts +0 -45
- /package/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/{legacy/internals/components/PickersTextField → internals/components/PickersInput}/PickersInput.types.js +0 -0
- /package/{modern/internals/components/PickersTextField/PickersInput.types.js → legacy/PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/node/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
|
@@ -74,11 +74,12 @@ export function useViews(_ref) {
|
|
|
74
74
|
onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
|
|
75
75
|
});
|
|
76
76
|
var handleChangeView = useEventCallback(function (newView) {
|
|
77
|
+
// always keep the focused view in sync
|
|
78
|
+
handleFocusedViewChange(newView, true);
|
|
77
79
|
if (newView === view) {
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
setView(newView);
|
|
81
|
-
handleFocusedViewChange(newView, true);
|
|
82
83
|
if (onViewChange) {
|
|
83
84
|
onViewChange(newView);
|
|
84
85
|
}
|
|
@@ -87,7 +88,6 @@ export function useViews(_ref) {
|
|
|
87
88
|
if (nextView) {
|
|
88
89
|
handleChangeView(nextView);
|
|
89
90
|
}
|
|
90
|
-
handleFocusedViewChange(nextView, true);
|
|
91
91
|
});
|
|
92
92
|
var setValueAndGoToNextView = useEventCallback(function (value, currentViewSelectionState, selectedView) {
|
|
93
93
|
var isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
@@ -96,18 +96,19 @@ export function useViews(_ref) {
|
|
|
96
96
|
// but when it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
97
97
|
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
98
98
|
var globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
99
|
-
onChange(value, globalSelectionState);
|
|
100
|
-
if
|
|
99
|
+
onChange(value, globalSelectionState, selectedView);
|
|
100
|
+
// Detects if the selected view is not the active one.
|
|
101
|
+
// Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
|
|
102
|
+
if (selectedView && selectedView !== view) {
|
|
103
|
+
var nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
|
|
104
|
+
if (nextViewAfterSelected) {
|
|
105
|
+
// move to next view after the selected one
|
|
106
|
+
handleChangeView(nextViewAfterSelected);
|
|
107
|
+
}
|
|
108
|
+
} else if (isSelectionFinishedOnCurrentView) {
|
|
101
109
|
goToNextView();
|
|
102
110
|
}
|
|
103
111
|
});
|
|
104
|
-
var setValueAndGoToView = useEventCallback(function (value, newView, selectedView) {
|
|
105
|
-
onChange(value, newView ? 'partial' : 'finish', selectedView);
|
|
106
|
-
if (newView) {
|
|
107
|
-
handleChangeView(newView);
|
|
108
|
-
handleFocusedViewChange(newView, true);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
112
|
return {
|
|
112
113
|
view: view,
|
|
113
114
|
setView: handleChangeView,
|
|
@@ -118,7 +119,6 @@ export function useViews(_ref) {
|
|
|
118
119
|
// Always return up-to-date default view instead of the initial one (i.e. defaultView.current)
|
|
119
120
|
defaultView: views.includes(openTo) ? openTo : views[0],
|
|
120
121
|
goToNextView: goToNextView,
|
|
121
|
-
setValueAndGoToNextView: setValueAndGoToNextView
|
|
122
|
-
setValueAndGoToView: setValueAndGoToView
|
|
122
|
+
setValueAndGoToNextView: setValueAndGoToNextView
|
|
123
123
|
};
|
|
124
124
|
}
|
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: 'выбрать дату',
|
|
@@ -252,9 +252,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
252
252
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
253
253
|
if (day) {
|
|
254
254
|
// If there is a date already selected, then we want to keep its time
|
|
255
|
-
return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish');
|
|
255
|
+
return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), 'finish', view);
|
|
256
256
|
}
|
|
257
|
-
return handleValueChange(day, 'finish');
|
|
257
|
+
return handleValueChange(day, 'finish', view);
|
|
258
258
|
});
|
|
259
259
|
React.useEffect(() => {
|
|
260
260
|
if (value != null && utils.isValid(value)) {
|
|
@@ -423,9 +423,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
423
423
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
424
424
|
/**
|
|
425
425
|
* Callback fired when the value changes.
|
|
426
|
-
* @template
|
|
427
|
-
* @
|
|
426
|
+
* @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.
|
|
427
|
+
* @template TView The view type. Will be one of date or time views.
|
|
428
|
+
* @param {TValue} value The new value.
|
|
428
429
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
430
|
+
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
429
431
|
*/
|
|
430
432
|
onChange: PropTypes.func,
|
|
431
433
|
/**
|
|
@@ -327,8 +327,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
327
327
|
minutesStep: PropTypes.number,
|
|
328
328
|
/**
|
|
329
329
|
* Callback fired when the value changes.
|
|
330
|
-
* @template
|
|
331
|
-
* @
|
|
330
|
+
* @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.
|
|
331
|
+
* @template TView The view type. Will be one of date or time views.
|
|
332
|
+
* @param {TValue} value The new value.
|
|
332
333
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
333
334
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
334
335
|
*/
|
|
@@ -122,7 +122,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
122
122
|
}, [ampm, inViews]);
|
|
123
123
|
const {
|
|
124
124
|
view,
|
|
125
|
-
|
|
125
|
+
setValueAndGoToNextView,
|
|
126
126
|
focusedView
|
|
127
127
|
} = useViews({
|
|
128
128
|
view: inView,
|
|
@@ -134,7 +134,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
134
134
|
onFocusedViewChange
|
|
135
135
|
});
|
|
136
136
|
const handleMeridiemValueChange = useEventCallback(newValue => {
|
|
137
|
-
|
|
137
|
+
setValueAndGoToNextView(newValue, 'finish', 'meridiem');
|
|
138
138
|
});
|
|
139
139
|
const {
|
|
140
140
|
meridiemMode,
|
|
@@ -215,11 +215,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
215
215
|
throw new Error('not supported');
|
|
216
216
|
}
|
|
217
217
|
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
218
|
-
const handleSectionChange = useEventCallback((sectionView, newValue) => {
|
|
219
|
-
const viewIndex = views.indexOf(sectionView);
|
|
220
|
-
const nextView = views[viewIndex + 1];
|
|
221
|
-
setValueAndGoToView(newValue, nextView, sectionView);
|
|
222
|
-
});
|
|
223
218
|
const buildViewProps = React.useCallback(viewToBuild => {
|
|
224
219
|
switch (viewToBuild) {
|
|
225
220
|
case 'hours':
|
|
@@ -227,7 +222,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
227
222
|
return {
|
|
228
223
|
onChange: hours => {
|
|
229
224
|
const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
|
|
230
|
-
|
|
225
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
|
|
231
226
|
},
|
|
232
227
|
items: getHourSectionOptions({
|
|
233
228
|
now,
|
|
@@ -245,7 +240,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
245
240
|
{
|
|
246
241
|
return {
|
|
247
242
|
onChange: minutes => {
|
|
248
|
-
|
|
243
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
|
|
249
244
|
},
|
|
250
245
|
items: getTimeSectionOptions({
|
|
251
246
|
value: utils.getMinutes(valueOrReferenceDate),
|
|
@@ -262,7 +257,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
262
257
|
{
|
|
263
258
|
return {
|
|
264
259
|
onChange: seconds => {
|
|
265
|
-
|
|
260
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
|
|
266
261
|
},
|
|
267
262
|
items: getTimeSectionOptions({
|
|
268
263
|
value: utils.getSeconds(valueOrReferenceDate),
|
|
@@ -299,7 +294,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
299
294
|
default:
|
|
300
295
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
301
296
|
}
|
|
302
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode,
|
|
297
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
|
|
303
298
|
const viewTimeOptions = React.useMemo(() => {
|
|
304
299
|
return views.reduce((result, currentView) => {
|
|
305
300
|
return _extends({}, result, {
|
|
@@ -397,8 +392,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
397
392
|
minutesStep: PropTypes.number,
|
|
398
393
|
/**
|
|
399
394
|
* Callback fired when the value changes.
|
|
400
|
-
* @template
|
|
401
|
-
* @
|
|
395
|
+
* @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.
|
|
396
|
+
* @template TView The view type. Will be one of date or time views.
|
|
397
|
+
* @param {TValue} value The new value.
|
|
402
398
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
403
399
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
404
400
|
*/
|
|
@@ -47,7 +47,7 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
|
|
|
47
47
|
'&:not(:first-of-type)': {
|
|
48
48
|
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
|
|
49
49
|
},
|
|
50
|
-
'
|
|
50
|
+
'&::after': {
|
|
51
51
|
display: 'block',
|
|
52
52
|
content: '""',
|
|
53
53
|
// subtracting the height of one item, extra margin and borders to make sure the max height is correct
|
|
@@ -116,17 +116,13 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
|
|
119
|
+
if (active && autoFocus && activeItem) {
|
|
120
|
+
activeItem.focus();
|
|
121
|
+
}
|
|
119
122
|
if (!activeItem || previousActive.current === activeItem) {
|
|
120
|
-
// Handle setting the ref to null if the selected item is ever reset via UI
|
|
121
|
-
if (previousActive.current !== activeItem) {
|
|
122
|
-
previousActive.current = activeItem;
|
|
123
|
-
}
|
|
124
123
|
return;
|
|
125
124
|
}
|
|
126
125
|
previousActive.current = activeItem;
|
|
127
|
-
if (active && autoFocus) {
|
|
128
|
-
activeItem.focus();
|
|
129
|
-
}
|
|
130
126
|
const offsetTop = activeItem.offsetTop;
|
|
131
127
|
|
|
132
128
|
// Subtracting the 4px of extra margin intended for the first visible section item
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["slots", "slotProps", "elements", "sectionListRef"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import styled from '@mui/system/styled';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
10
|
+
import { getPickersSectionListUtilityClass, pickersSectionListClasses } from './pickersSectionListClasses';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export const PickersSectionListRoot = styled('div', {
|
|
14
|
+
name: 'MuiPickersSectionList',
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})({
|
|
18
|
+
direction: 'ltr /*! @noflip */',
|
|
19
|
+
outline: 'none'
|
|
20
|
+
});
|
|
21
|
+
export const PickersSectionListSection = styled('span', {
|
|
22
|
+
name: 'MuiPickersSectionList',
|
|
23
|
+
slot: 'Section',
|
|
24
|
+
overridesResolver: (props, styles) => styles.section
|
|
25
|
+
})({});
|
|
26
|
+
export const PickersSectionListSectionSeparator = styled('span', {
|
|
27
|
+
name: 'MuiPickersSectionList',
|
|
28
|
+
slot: 'SectionSeparator',
|
|
29
|
+
overridesResolver: (props, styles) => styles.sectionSeparator
|
|
30
|
+
})({
|
|
31
|
+
whiteSpace: 'pre'
|
|
32
|
+
});
|
|
33
|
+
export const PickersSectionListSectionContent = styled('span', {
|
|
34
|
+
name: 'MuiPickersSectionList',
|
|
35
|
+
slot: 'SectionContent',
|
|
36
|
+
overridesResolver: (props, styles) => styles.sectionContent
|
|
37
|
+
})({
|
|
38
|
+
outline: 'none'
|
|
39
|
+
});
|
|
40
|
+
const useUtilityClasses = ownerState => {
|
|
41
|
+
const {
|
|
42
|
+
classes
|
|
43
|
+
} = ownerState;
|
|
44
|
+
const slots = {
|
|
45
|
+
root: ['root'],
|
|
46
|
+
section: ['section'],
|
|
47
|
+
sectionContent: ['sectionContent']
|
|
48
|
+
};
|
|
49
|
+
return composeClasses(slots, getPickersSectionListUtilityClass, classes);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Demos:
|
|
53
|
+
*
|
|
54
|
+
* - [Custom field](https://mui.com/x/react-date-pickers/custom-field/)
|
|
55
|
+
*
|
|
56
|
+
* API:
|
|
57
|
+
*
|
|
58
|
+
* - [PickersSectionList API](https://mui.com/x/api/date-pickers/pickers-section-list/)
|
|
59
|
+
*/
|
|
60
|
+
function PickersSection(props) {
|
|
61
|
+
const {
|
|
62
|
+
slots,
|
|
63
|
+
slotProps,
|
|
64
|
+
element,
|
|
65
|
+
classes
|
|
66
|
+
} = props;
|
|
67
|
+
const Section = slots?.section ?? PickersSectionListSection;
|
|
68
|
+
const sectionProps = useSlotProps({
|
|
69
|
+
elementType: Section,
|
|
70
|
+
externalSlotProps: slotProps?.section,
|
|
71
|
+
externalForwardedProps: element.container,
|
|
72
|
+
className: classes.section,
|
|
73
|
+
ownerState: {}
|
|
74
|
+
});
|
|
75
|
+
const SectionContent = slots?.sectionContent ?? PickersSectionListSectionContent;
|
|
76
|
+
const sectionContentProps = useSlotProps({
|
|
77
|
+
elementType: SectionContent,
|
|
78
|
+
externalSlotProps: slotProps?.sectionContent,
|
|
79
|
+
externalForwardedProps: element.content,
|
|
80
|
+
additionalProps: {
|
|
81
|
+
suppressContentEditableWarning: true
|
|
82
|
+
},
|
|
83
|
+
className: classes.sectionContent,
|
|
84
|
+
ownerState: {}
|
|
85
|
+
});
|
|
86
|
+
const SectionSeparator = slots?.sectionSeparator ?? PickersSectionListSectionSeparator;
|
|
87
|
+
const sectionSeparatorBeforeProps = useSlotProps({
|
|
88
|
+
elementType: SectionSeparator,
|
|
89
|
+
externalSlotProps: slotProps?.sectionSeparator,
|
|
90
|
+
externalForwardedProps: element.before,
|
|
91
|
+
ownerState: {
|
|
92
|
+
position: 'before'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const sectionSeparatorAfterProps = useSlotProps({
|
|
96
|
+
elementType: SectionSeparator,
|
|
97
|
+
externalSlotProps: slotProps?.sectionSeparator,
|
|
98
|
+
externalForwardedProps: element.after,
|
|
99
|
+
ownerState: {
|
|
100
|
+
position: 'after'
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return /*#__PURE__*/_jsxs(Section, _extends({}, sectionProps, {
|
|
104
|
+
children: [/*#__PURE__*/_jsx(SectionSeparator, _extends({}, sectionSeparatorBeforeProps)), /*#__PURE__*/_jsx(SectionContent, _extends({}, sectionContentProps)), /*#__PURE__*/_jsx(SectionSeparator, _extends({}, sectionSeparatorAfterProps))]
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
const PickersSectionList = /*#__PURE__*/React.forwardRef(function PickersSectionList(props, ref) {
|
|
108
|
+
const {
|
|
109
|
+
slots,
|
|
110
|
+
slotProps,
|
|
111
|
+
elements,
|
|
112
|
+
sectionListRef
|
|
113
|
+
} = props,
|
|
114
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
115
|
+
const classes = useUtilityClasses(props);
|
|
116
|
+
const rootRef = React.useRef(null);
|
|
117
|
+
const handleRootRef = useForkRef(ref, rootRef);
|
|
118
|
+
const getRoot = methodName => {
|
|
119
|
+
if (!rootRef.current) {
|
|
120
|
+
throw new Error(`MUI: Cannot call sectionListRef.${methodName} before the mount of the component`);
|
|
121
|
+
}
|
|
122
|
+
return rootRef.current;
|
|
123
|
+
};
|
|
124
|
+
React.useImperativeHandle(sectionListRef, () => ({
|
|
125
|
+
getRoot() {
|
|
126
|
+
return getRoot('getRoot');
|
|
127
|
+
},
|
|
128
|
+
getSectionContainer(index) {
|
|
129
|
+
const root = getRoot('getSectionContainer');
|
|
130
|
+
return root.querySelector(`.${pickersSectionListClasses.section}[data-sectionindex="${index}"]`);
|
|
131
|
+
},
|
|
132
|
+
getSectionContent(index) {
|
|
133
|
+
const root = getRoot('getSectionContent');
|
|
134
|
+
return root.querySelector(`.${pickersSectionListClasses.section}[data-sectionindex="${index}"] .${pickersSectionListClasses.sectionContent}`);
|
|
135
|
+
},
|
|
136
|
+
getSectionIndexFromDOMElement(element) {
|
|
137
|
+
const root = getRoot('getSectionIndexFromDOMElement');
|
|
138
|
+
if (element == null || !root.contains(element)) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
let sectionContainer = null;
|
|
142
|
+
if (element.classList.contains(pickersSectionListClasses.section)) {
|
|
143
|
+
sectionContainer = element;
|
|
144
|
+
} else if (element.classList.contains(pickersSectionListClasses.sectionContent)) {
|
|
145
|
+
sectionContainer = element.parentElement;
|
|
146
|
+
}
|
|
147
|
+
if (sectionContainer == null) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return Number(sectionContainer.dataset.sectionindex);
|
|
151
|
+
}
|
|
152
|
+
}));
|
|
153
|
+
const Root = slots?.root ?? PickersSectionListRoot;
|
|
154
|
+
const rootProps = useSlotProps({
|
|
155
|
+
elementType: Root,
|
|
156
|
+
externalSlotProps: slotProps?.root,
|
|
157
|
+
externalForwardedProps: other,
|
|
158
|
+
additionalProps: {
|
|
159
|
+
ref: handleRootRef,
|
|
160
|
+
suppressContentEditableWarning: true
|
|
161
|
+
},
|
|
162
|
+
className: classes.root,
|
|
163
|
+
ownerState: {}
|
|
164
|
+
});
|
|
165
|
+
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
|
166
|
+
children: rootProps.contentEditable ? elements.map(({
|
|
167
|
+
content,
|
|
168
|
+
before,
|
|
169
|
+
after
|
|
170
|
+
}) => `${before.children}${content.children}${after.children}`).join('') : /*#__PURE__*/_jsx(React.Fragment, {
|
|
171
|
+
children: elements.map((element, elementIndex) => /*#__PURE__*/_jsx(PickersSection, {
|
|
172
|
+
slots: slots,
|
|
173
|
+
slotProps: slotProps,
|
|
174
|
+
element: element,
|
|
175
|
+
classes: classes
|
|
176
|
+
}, elementIndex))
|
|
177
|
+
})
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
process.env.NODE_ENV !== "production" ? PickersSectionList.propTypes = {
|
|
181
|
+
// ----------------------------- Warning --------------------------------
|
|
182
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
183
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
184
|
+
// ----------------------------------------------------------------------
|
|
185
|
+
/**
|
|
186
|
+
* Override or extend the styles applied to the component.
|
|
187
|
+
*/
|
|
188
|
+
classes: PropTypes.object,
|
|
189
|
+
/**
|
|
190
|
+
* If true, the whole element is editable.
|
|
191
|
+
* Useful when all the sections are selected.
|
|
192
|
+
*/
|
|
193
|
+
contentEditable: PropTypes.bool.isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* The elements to render.
|
|
196
|
+
* Each element contains the prop to edit a section of the value.
|
|
197
|
+
*/
|
|
198
|
+
elements: PropTypes.arrayOf(PropTypes.shape({
|
|
199
|
+
after: PropTypes.object.isRequired,
|
|
200
|
+
before: PropTypes.object.isRequired,
|
|
201
|
+
container: PropTypes.object.isRequired,
|
|
202
|
+
content: PropTypes.object.isRequired
|
|
203
|
+
})).isRequired,
|
|
204
|
+
sectionListRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
205
|
+
current: PropTypes.shape({
|
|
206
|
+
getRoot: PropTypes.func.isRequired,
|
|
207
|
+
getSectionContainer: PropTypes.func.isRequired,
|
|
208
|
+
getSectionContent: PropTypes.func.isRequired,
|
|
209
|
+
getSectionIndexFromDOMElement: PropTypes.func.isRequired
|
|
210
|
+
})
|
|
211
|
+
})]),
|
|
212
|
+
/**
|
|
213
|
+
* The props used for each component slot.
|
|
214
|
+
*/
|
|
215
|
+
slotProps: PropTypes.object,
|
|
216
|
+
/**
|
|
217
|
+
* Overridable component slots.
|
|
218
|
+
*/
|
|
219
|
+
slots: PropTypes.object
|
|
220
|
+
} : void 0;
|
|
221
|
+
export { PickersSectionList };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PickersSectionList as Unstable_PickersSectionList, PickersSectionListRoot as Unstable_PickersSectionListRoot, PickersSectionListSection as Unstable_PickersSectionListSection, PickersSectionListSectionSeparator as Unstable_PickersSectionListSectionSeparator, PickersSectionListSectionContent as Unstable_PickersSectionListSectionContent } from './PickersSectionList';
|
|
2
|
+
export { getPickersSectionListUtilityClass, pickersSectionListClasses } from './pickersSectionListClasses';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
export function getPickersSectionListUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiPickersSectionList', slot);
|
|
5
|
+
}
|
|
6
|
+
export const pickersSectionListClasses = generateUtilityClasses('MuiPickersSectionList', ['root', 'section', 'sectionContent']);
|
|
@@ -383,8 +383,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
383
383
|
minutesStep: PropTypes.number,
|
|
384
384
|
/**
|
|
385
385
|
* Callback fired when the value changes.
|
|
386
|
-
* @template
|
|
387
|
-
* @
|
|
386
|
+
* @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.
|
|
387
|
+
* @template TView The view type. Will be one of date or time views.
|
|
388
|
+
* @param {TValue} value The new value.
|
|
388
389
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
389
390
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
390
391
|
*/
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v7.0.0-alpha.
|
|
2
|
+
* @mui/x-date-pickers v7.0.0-alpha.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -49,6 +49,9 @@ export * from './PickersShortcuts';
|
|
|
49
49
|
|
|
50
50
|
// Other slots
|
|
51
51
|
export * from './PickersCalendarHeader';
|
|
52
|
+
|
|
53
|
+
// Field utilities
|
|
54
|
+
export * from './PickersSectionList';
|
|
52
55
|
export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
|
|
53
56
|
export * from './models';
|
|
54
57
|
export * from './icons';
|
|
@@ -4,22 +4,38 @@ const _excluded = ["children", "className", "label"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const OutlineRoot = styled('fieldset'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const OutlineRoot = styled('fieldset', {
|
|
8
|
+
name: 'MuiPickersOutlinedInput',
|
|
9
|
+
slot: 'NotchedOutline',
|
|
10
|
+
overridesResolver: (props, styles) => styles.notchedOutline
|
|
11
|
+
})(({
|
|
12
|
+
theme
|
|
13
|
+
}) => {
|
|
14
|
+
const borderColor = theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)';
|
|
15
|
+
return {
|
|
16
|
+
textAlign: 'left',
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
bottom: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
top: -5,
|
|
21
|
+
left: 0,
|
|
22
|
+
margin: 0,
|
|
23
|
+
padding: '0 8px',
|
|
24
|
+
pointerEvents: 'none',
|
|
25
|
+
borderRadius: 'inherit',
|
|
26
|
+
borderStyle: 'solid',
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
minWidth: '0%',
|
|
30
|
+
borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
|
|
31
|
+
};
|
|
22
32
|
});
|
|
33
|
+
const OutlineLabel = styled('span')(({
|
|
34
|
+
theme
|
|
35
|
+
}) => ({
|
|
36
|
+
fontFamily: theme.typography.fontFamily,
|
|
37
|
+
fontSize: 'inherit'
|
|
38
|
+
}));
|
|
23
39
|
const OutlineLegend = styled('legend')(({
|
|
24
40
|
ownerState,
|
|
25
41
|
theme
|
|
@@ -78,17 +94,17 @@ export default function Outline(props) {
|
|
|
78
94
|
});
|
|
79
95
|
return /*#__PURE__*/_jsx(OutlineRoot, _extends({
|
|
80
96
|
"aria-hidden": true,
|
|
81
|
-
className: className
|
|
82
|
-
ownerState: ownerState
|
|
97
|
+
className: className
|
|
83
98
|
}, other, {
|
|
99
|
+
ownerState: ownerState,
|
|
84
100
|
children: /*#__PURE__*/_jsx(OutlineLegend, {
|
|
85
101
|
ownerState: ownerState,
|
|
86
|
-
children: withLabel ? /*#__PURE__*/_jsx(
|
|
102
|
+
children: withLabel ? /*#__PURE__*/_jsx(OutlineLabel, {
|
|
87
103
|
children: label
|
|
88
104
|
}) :
|
|
89
105
|
/*#__PURE__*/
|
|
90
106
|
// notranslate needed while Google Translate will not fix zero-width space issue
|
|
91
|
-
_jsx(
|
|
107
|
+
_jsx(OutlineLabel, {
|
|
92
108
|
className: "notranslate",
|
|
93
109
|
children: "\u200B"
|
|
94
110
|
})
|