@mui/x-date-pickers 7.0.0-alpha.6 → 7.0.0-alpha.8
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 +4 -21
- package/AdapterDateFns/AdapterDateFns.js +11 -255
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +80 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/CHANGELOG.md +357 -49
- package/DateCalendar/DateCalendar.js +6 -4
- package/DateCalendar/DateCalendar.types.d.ts +0 -8
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -7
- package/DigitalClock/DigitalClock.js +4 -2
- package/DigitalClock/DigitalClock.types.d.ts +5 -0
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/PickersSectionList/PickersSectionList.js +1 -1
- package/TimeClock/TimeClock.js +4 -2
- package/TimeClock/TimeClock.types.d.ts +5 -0
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/components/PickersInput/PickersFilledInput.js +2 -2
- package/internals/components/PickersInput/PickersInput.d.ts +2 -4
- package/internals/components/PickersInput/PickersInput.js +2 -3
- package/internals/components/PickersInput/PickersStandardInput.js +2 -2
- package/internals/hooks/useField/useField.utils.js +5 -5
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/internals/hooks/useUtils.js +2 -2
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +15 -15
- package/internals/index.d.ts +9 -3
- package/internals/index.js +6 -2
- package/internals/models/common.d.ts +1 -1
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/clock.d.ts +0 -9
- package/internals/utils/views.js +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
- package/legacy/DateCalendar/DateCalendar.js +6 -4
- package/legacy/DatePicker/DatePickerToolbar.js +2 -7
- package/legacy/DigitalClock/DigitalClock.js +4 -2
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/legacy/PickersSectionList/PickersSectionList.js +1 -1
- package/legacy/TimeClock/TimeClock.js +4 -2
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersInput/PickersFilledInput.js +2 -2
- package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
- package/legacy/internals/components/PickersInput/PickersStandardInput.js +2 -2
- package/legacy/internals/hooks/useField/useField.utils.js +5 -5
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/legacy/internals/hooks/useUtils.js +2 -2
- package/legacy/internals/hooks/useViews.js +15 -15
- package/legacy/internals/index.js +6 -2
- package/legacy/internals/utils/views.js +1 -1
- package/legacy/locales/index.js +1 -0
- package/locales/enUS.d.ts +1 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/mk.d.ts +1 -1
- package/locales/utils/getPickersLocalization.d.ts +1 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +6 -4
- package/modern/DatePicker/DatePickerToolbar.js +2 -7
- package/modern/DigitalClock/DigitalClock.js +4 -2
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/modern/PickersSectionList/PickersSectionList.js +1 -1
- package/modern/TimeClock/TimeClock.js +4 -2
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersInput/PickersFilledInput.js +2 -2
- package/modern/internals/components/PickersInput/PickersInput.js +2 -3
- package/modern/internals/components/PickersInput/PickersStandardInput.js +2 -2
- package/modern/internals/hooks/useField/useField.utils.js +5 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/modern/internals/hooks/useUtils.js +2 -2
- package/modern/internals/hooks/useViews.js +15 -15
- package/modern/internals/index.js +6 -2
- package/modern/internals/utils/views.js +1 -1
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -254
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DateCalendar/DateCalendar.js +6 -4
- package/node/DatePicker/DatePickerToolbar.js +0 -4
- package/node/DigitalClock/DigitalClock.js +4 -2
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/node/PickersSectionList/PickersSectionList.js +1 -1
- package/node/TimeClock/TimeClock.js +4 -2
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersInput/PickersFilledInput.js +2 -2
- package/node/internals/components/PickersInput/PickersInput.js +2 -3
- package/node/internals/components/PickersInput/PickersStandardInput.js +2 -2
- package/node/internals/hooks/useField/useField.utils.js +5 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/node/internals/hooks/useUtils.js +2 -2
- package/node/internals/hooks/useViews.js +15 -15
- package/node/internals/index.js +47 -1
- package/node/internals/utils/views.js +1 -1
- package/node/locales/index.js +11 -0
- package/package.json +6 -6
|
@@ -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
|
*/
|
|
@@ -490,6 +486,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
490
486
|
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
|
|
491
487
|
/**
|
|
492
488
|
* Available views.
|
|
489
|
+
* @default ['hours', 'minutes']
|
|
493
490
|
*/
|
|
494
491
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
|
|
495
492
|
} : void 0;
|
|
@@ -28,6 +28,11 @@ export interface MultiSectionDigitalClockSlotProps {
|
|
|
28
28
|
digitalClockSectionItem?: SlotComponentProps<typeof MenuItem, {}, Record<string, any>>;
|
|
29
29
|
}
|
|
30
30
|
export interface MultiSectionDigitalClockProps<TDate> extends ExportedMultiSectionDigitalClockProps<TDate>, BaseClockProps<TDate, TimeViewWithMeridiem> {
|
|
31
|
+
/**
|
|
32
|
+
* Available views.
|
|
33
|
+
* @default ['hours', 'minutes']
|
|
34
|
+
*/
|
|
35
|
+
views?: readonly TimeViewWithMeridiem[];
|
|
31
36
|
/**
|
|
32
37
|
* Override or extend the styles applied to the component.
|
|
33
38
|
*/
|
|
@@ -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
|
|
@@ -117,17 +117,13 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
|
|
120
|
+
if (active && autoFocus && activeItem) {
|
|
121
|
+
activeItem.focus();
|
|
122
|
+
}
|
|
120
123
|
if (!activeItem || previousActive.current === activeItem) {
|
|
121
|
-
// Handle setting the ref to null if the selected item is ever reset via UI
|
|
122
|
-
if (previousActive.current !== activeItem) {
|
|
123
|
-
previousActive.current = activeItem;
|
|
124
|
-
}
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
previousActive.current = activeItem;
|
|
128
|
-
if (active && autoFocus) {
|
|
129
|
-
activeItem.focus();
|
|
130
|
-
}
|
|
131
127
|
const offsetTop = activeItem.offsetTop;
|
|
132
128
|
|
|
133
129
|
// Subtracting the 4px of extra margin intended for the first visible section item
|
|
@@ -119,7 +119,7 @@ const PickersSectionList = /*#__PURE__*/React.forwardRef(function PickersSection
|
|
|
119
119
|
const handleRootRef = useForkRef(ref, rootRef);
|
|
120
120
|
const getRoot = methodName => {
|
|
121
121
|
if (!rootRef.current) {
|
|
122
|
-
throw new Error(`MUI: Cannot call sectionListRef.${methodName} before the mount of the component
|
|
122
|
+
throw new Error(`MUI X: Cannot call sectionListRef.${methodName} before the mount of the component.`);
|
|
123
123
|
}
|
|
124
124
|
return rootRef.current;
|
|
125
125
|
};
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -462,6 +463,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
462
463
|
view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
|
|
463
464
|
/**
|
|
464
465
|
* Available views.
|
|
466
|
+
* @default ['hours', 'minutes']
|
|
465
467
|
*/
|
|
466
468
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
|
|
467
469
|
} : void 0;
|
|
@@ -15,6 +15,11 @@ export interface TimeClockSlots extends PickersArrowSwitcherSlots {
|
|
|
15
15
|
export interface TimeClockSlotProps extends PickersArrowSwitcherSlotProps {
|
|
16
16
|
}
|
|
17
17
|
export interface TimeClockProps<TDate, TView extends TimeViewWithMeridiem = TimeView> extends ExportedTimeClockProps<TDate>, BaseClockProps<TDate, TView> {
|
|
18
|
+
/**
|
|
19
|
+
* Available views.
|
|
20
|
+
* @default ['hours', 'minutes']
|
|
21
|
+
*/
|
|
22
|
+
views?: readonly TView[];
|
|
18
23
|
/**
|
|
19
24
|
* Override or extend the styles applied to the component.
|
|
20
25
|
*/
|
|
@@ -42,8 +42,8 @@ export const useClearableField = props => {
|
|
|
42
42
|
});
|
|
43
43
|
return _extends({}, other, {
|
|
44
44
|
InputProps: _extends({}, InputProps, {
|
|
45
|
-
endAdornment:
|
|
46
|
-
children: [/*#__PURE__*/_jsx(InputAdornment, {
|
|
45
|
+
endAdornment: /*#__PURE__*/_jsxs(React.Fragment, {
|
|
46
|
+
children: [clearable && /*#__PURE__*/_jsx(InputAdornment, {
|
|
47
47
|
position: "end",
|
|
48
48
|
sx: {
|
|
49
49
|
marginRight: InputProps != null && InputProps.endAdornment ? -1 : -1.5
|
|
@@ -55,7 +55,7 @@ export const useClearableField = props => {
|
|
|
55
55
|
}, endClearIconProps))
|
|
56
56
|
}))
|
|
57
57
|
}), InputProps == null ? void 0 : InputProps.endAdornment]
|
|
58
|
-
})
|
|
58
|
+
})
|
|
59
59
|
}),
|
|
60
60
|
sx: [{
|
|
61
61
|
'& .clearButton': {
|
package/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
|
|
|
44
44
|
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
|
|
45
45
|
}
|
|
46
46
|
}, !ownerState.disableUnderline && {
|
|
47
|
-
'
|
|
47
|
+
'&::after': {
|
|
48
48
|
borderBottom: `2px solid ${(_palette = (theme.vars || theme).palette[ownerState.color || 'primary']) == null ? void 0 : _palette.main}`,
|
|
49
49
|
left: 0,
|
|
50
50
|
bottom: 0,
|
|
@@ -69,7 +69,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
|
|
|
69
69
|
borderBottomColor: (theme.vars || theme).palette.error.main
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
'
|
|
72
|
+
'&::before': {
|
|
73
73
|
borderBottom: `1px solid ${theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})` : bottomLineColor}`,
|
|
74
74
|
left: 0,
|
|
75
75
|
bottom: 0,
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FormControlState } from '@mui/material/FormControl';
|
|
3
3
|
import { PickersInputProps } from './PickersInput.types';
|
|
4
|
-
export declare const PickersInputRoot: import("@emotion/styled").StyledComponent<
|
|
5
|
-
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
6
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>>, "hidden" | "content" | "style" | "translate" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
4
|
+
export declare const PickersInputRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
7
5
|
ownerState: OwnerStateType;
|
|
8
|
-
},
|
|
6
|
+
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
9
7
|
export declare const PickersInputSectionsContainer: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme> & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
10
8
|
ownerState: OwnerStateType;
|
|
11
9
|
}, {}, {}>;
|
|
@@ -2,7 +2,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "inputProps", "inputRef", "sectionListRef"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import Box from '@mui/material/Box';
|
|
6
5
|
import { useFormControl } from '@mui/material/FormControl';
|
|
7
6
|
import { styled } from '@mui/material/styles';
|
|
8
7
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -14,7 +13,7 @@ import { Unstable_PickersSectionList as PickersSectionList, Unstable_PickersSect
|
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
const round = value => Math.round(value * 1e5) / 1e5;
|
|
17
|
-
export const PickersInputRoot = styled(
|
|
16
|
+
export const PickersInputRoot = styled('div', {
|
|
18
17
|
name: 'MuiPickersInput',
|
|
19
18
|
slot: 'Root',
|
|
20
19
|
overridesResolver: (props, styles) => styles.root
|
|
@@ -160,7 +159,7 @@ export const PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(
|
|
|
160
159
|
const handleInputRef = useForkRef(inputProps == null ? void 0 : inputProps.ref, inputRef);
|
|
161
160
|
const muiFormControl = useFormControl();
|
|
162
161
|
if (!muiFormControl) {
|
|
163
|
-
throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
|
|
162
|
+
throw new Error('MUI X: PickersInput should always be used inside a PickersTextField component');
|
|
164
163
|
}
|
|
165
164
|
const handleInputFocus = event => {
|
|
166
165
|
var _muiFormControl$onFoc;
|
|
@@ -26,7 +26,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
|
|
|
26
26
|
marginTop: 16
|
|
27
27
|
}
|
|
28
28
|
}, !ownerState.disableUnderline && {
|
|
29
|
-
'
|
|
29
|
+
'&::after': {
|
|
30
30
|
background: 'red',
|
|
31
31
|
borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
|
|
32
32
|
left: 0,
|
|
@@ -52,7 +52,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
|
|
|
52
52
|
borderBottomColor: (theme.vars || theme).palette.error.main
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
'
|
|
55
|
+
'&::before': {
|
|
56
56
|
borderBottom: `1px solid ${bottomLineColor}`,
|
|
57
57
|
left: 0,
|
|
58
58
|
bottom: 0,
|
|
@@ -3,7 +3,7 @@ import { getMonthsInYear } from '../../utils/date-utils';
|
|
|
3
3
|
export const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
4
4
|
const config = utils.formatTokenMap[formatToken];
|
|
5
5
|
if (config == null) {
|
|
6
|
-
throw new Error([`MUI: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
|
|
6
|
+
throw new Error([`MUI X: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
|
|
7
7
|
}
|
|
8
8
|
if (typeof config === 'string') {
|
|
9
9
|
return {
|
|
@@ -80,7 +80,7 @@ export const cleanLeadingZeros = (utils, valueStr, size) => {
|
|
|
80
80
|
export const cleanDigitSectionValue = (utils, timezone, value, sectionBoundaries, section) => {
|
|
81
81
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
82
|
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
83
|
-
throw new Error([`MUI: The token "${section.format}" is a digit format with letter in it.'
|
|
83
|
+
throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
|
|
84
84
|
This type of format is only supported for 'day' sections`].join('\n'));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -356,7 +356,7 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
|
|
|
356
356
|
maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
|
|
357
357
|
} else {
|
|
358
358
|
if (sectionConfig.maxLength == null) {
|
|
359
|
-
throw new Error(`MUI: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
|
|
359
|
+
throw new Error(`MUI X: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
|
|
360
360
|
}
|
|
361
361
|
maxLength = sectionConfig.maxLength;
|
|
362
362
|
if (isValidDate) {
|
|
@@ -387,7 +387,7 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
|
|
|
387
387
|
nextFormat = utils.expandFormat(prevFormat);
|
|
388
388
|
formatExpansionOverflow -= 1;
|
|
389
389
|
if (formatExpansionOverflow < 0) {
|
|
390
|
-
throw new Error('MUI: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component');
|
|
390
|
+
throw new Error('MUI X: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component.');
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
const expandedFormat = nextFormat;
|
|
@@ -601,7 +601,7 @@ export const validateSections = (sections, valueType) => {
|
|
|
601
601
|
}
|
|
602
602
|
const invalidSection = sections.find(section => !supportedSections.includes(section.type));
|
|
603
603
|
if (invalidSection) {
|
|
604
|
-
console.warn(`MUI: The field component you are using is not compatible with the "${invalidSection.type}" date section.`, `The supported date sections are ["${supportedSections.join('", "')}"]\`.`);
|
|
604
|
+
console.warn(`MUI X: The field component you are using is not compatible with the "${invalidSection.type}" date section.`, `The supported date sections are ["${supportedSections.join('", "')}"]\`.`);
|
|
605
605
|
warnedOnceInvalidSection = true;
|
|
606
606
|
}
|
|
607
607
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { usePicker } from './usePicker';
|
|
2
2
|
export type { UsePickerProps, UsePickerBaseProps, UsePickerParams, UsePickerResponse, } from './usePicker.types';
|
|
3
|
-
export type { PickerValueManager, PickerSelectionState } from './usePickerValue.types';
|
|
3
|
+
export type { PickerValueManager, PickerSelectionState, UsePickerValueFieldResponse, } from './usePickerValue.types';
|
|
@@ -138,12 +138,12 @@ export const usePickerValue = ({
|
|
|
138
138
|
if (process.env.NODE_ENV !== 'production') {
|
|
139
139
|
React.useEffect(() => {
|
|
140
140
|
if (isControlled !== (inValue !== undefined)) {
|
|
141
|
-
console.error([`MUI: A component is changing the ${isControlled ? '' : 'un'}controlled value of a picker to be ${isControlled ? 'un' : ''}controlled.`, 'Elements should not switch from uncontrolled to controlled (or vice versa).', `Decide between using a controlled or uncontrolled value` + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
141
|
+
console.error([`MUI X: A component is changing the ${isControlled ? '' : 'un'}controlled value of a picker to be ${isControlled ? 'un' : ''}controlled.`, 'Elements should not switch from uncontrolled to controlled (or vice versa).', `Decide between using a controlled or uncontrolled value` + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
142
142
|
}
|
|
143
143
|
}, [inValue]);
|
|
144
144
|
React.useEffect(() => {
|
|
145
145
|
if (!isControlled && defaultValue !== inDefaultValue) {
|
|
146
|
-
console.error([`MUI: A component is changing the defaultValue of an uncontrolled picker after being initialized. ` + `To suppress this warning opt to use a controlled value.`].join('\n'));
|
|
146
|
+
console.error([`MUI X: A component is changing the defaultValue of an uncontrolled picker after being initialized. ` + `To suppress this warning opt to use a controlled value.`].join('\n'));
|
|
147
147
|
}
|
|
148
148
|
}, [JSON.stringify(defaultValue)]);
|
|
149
149
|
}
|
|
@@ -5,10 +5,10 @@ import { DEFAULT_LOCALE } from '../../locales/enUS';
|
|
|
5
5
|
export const useLocalizationContext = () => {
|
|
6
6
|
const localization = React.useContext(MuiPickersAdapterContext);
|
|
7
7
|
if (localization === null) {
|
|
8
|
-
throw new Error(['MUI: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
|
|
8
|
+
throw new Error(['MUI X: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
|
|
9
9
|
}
|
|
10
10
|
if (localization.utils === null) {
|
|
11
|
-
throw new Error(['MUI: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
|
|
11
|
+
throw new Error(['MUI X: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
|
|
12
12
|
}
|
|
13
13
|
const localeText = React.useMemo(() => _extends({}, DEFAULT_LOCALE, localization.localeText), [localization.localeText]);
|
|
14
14
|
return React.useMemo(() => _extends({}, localization, {
|
|
@@ -5,7 +5,8 @@ export type PickerOnChangeFn<TDate> = (date: TDate | null, selectionState?: Pick
|
|
|
5
5
|
export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
6
6
|
/**
|
|
7
7
|
* Callback fired when the value changes.
|
|
8
|
-
* @template TValue
|
|
8
|
+
* @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.
|
|
9
|
+
* @template TView The view type. Will be one of date or time views.
|
|
9
10
|
* @param {TValue} value The new value.
|
|
10
11
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
11
12
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
@@ -52,7 +53,7 @@ export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridie
|
|
|
52
53
|
*/
|
|
53
54
|
onFocusedViewChange?: (view: TView, hasFocus: boolean) => void;
|
|
54
55
|
}
|
|
55
|
-
export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<
|
|
56
|
+
export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<UseViewsOptions<any, TView>, 'onChange' | 'openTo' | 'views'> {
|
|
56
57
|
}
|
|
57
58
|
interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
58
59
|
view: TView;
|
|
@@ -63,8 +64,7 @@ interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
|
63
64
|
previousView: TView | null;
|
|
64
65
|
defaultView: TView;
|
|
65
66
|
goToNextView: () => void;
|
|
66
|
-
setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState) => void;
|
|
67
|
-
setValueAndGoToView: (value: TValue, newView: TView | null, selectedView: TView) => void;
|
|
67
|
+
setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState, selectedView?: TView) => void;
|
|
68
68
|
}
|
|
69
69
|
export declare function useViews<TValue, TView extends DateOrTimeViewWithMeridiem>({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange, }: UseViewsOptions<TValue, TView>): UseViewsResponse<TValue, TView>;
|
|
70
70
|
export {};
|
|
@@ -16,11 +16,11 @@ export function useViews({
|
|
|
16
16
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
17
|
if (!warnedOnceNotValidView) {
|
|
18
18
|
if (inView != null && !views.includes(inView)) {
|
|
19
|
-
console.warn(`MUI: \`view="${inView}"\` is not a valid prop.`, `It must be an element of \`views=["${views.join('", "')}"]\`.`);
|
|
19
|
+
console.warn(`MUI X: \`view="${inView}"\` is not a valid prop.`, `It must be an element of \`views=["${views.join('", "')}"]\`.`);
|
|
20
20
|
warnedOnceNotValidView = true;
|
|
21
21
|
}
|
|
22
22
|
if (inView == null && openTo != null && !views.includes(openTo)) {
|
|
23
|
-
console.warn(`MUI: \`openTo="${openTo}"\` is not a valid prop.`, `It must be an element of \`views=["${views.join('", "')}"]\`.`);
|
|
23
|
+
console.warn(`MUI X: \`openTo="${openTo}"\` is not a valid prop.`, `It must be an element of \`views=["${views.join('", "')}"]\`.`);
|
|
24
24
|
warnedOnceNotValidView = true;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -64,11 +64,12 @@ export function useViews({
|
|
|
64
64
|
onFocusedViewChange == null || 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 when 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/internals/index.d.ts
CHANGED
|
@@ -33,18 +33,22 @@ export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, UsePickerV
|
|
|
33
33
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
34
34
|
export type { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotProps, } from './hooks/useStaticPicker';
|
|
35
35
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow, } from './hooks/useUtils';
|
|
36
|
-
export type { ExportedUseViewsOptions } from './hooks/useViews';
|
|
36
|
+
export type { ExportedUseViewsOptions, UseViewsOptions } from './hooks/useViews';
|
|
37
|
+
export { useViews } from './hooks/useViews';
|
|
37
38
|
export { useValidation } from './hooks/useValidation';
|
|
38
39
|
export type { ValidationProps, Validator, InferError } from './hooks/useValidation';
|
|
39
40
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
40
41
|
export type { BaseFieldProps, FieldsTextFieldProps } from './models/fields';
|
|
41
42
|
export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
|
|
43
|
+
export type { BaseClockProps, DesktopOnlyTimePickerProps } from './models/props/clock';
|
|
44
|
+
export type { BaseTabsProps, ExportedBaseTabsProps } from './models/props/tabs';
|
|
42
45
|
export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
|
|
43
46
|
export type { DefaultizedProps, MakeOptional } from './models/helpers';
|
|
44
|
-
export type { WrapperVariant } from './models/common';
|
|
47
|
+
export type { WrapperVariant, TimeViewWithMeridiem, DateOrTimeViewWithMeridiem, } from './models/common';
|
|
45
48
|
export type { BaseDateValidationProps, BaseTimeValidationProps, TimeValidationProps, MonthValidationProps, YearValidationProps, DayValidationProps, DateTimeValidationProps, } from './models/validation';
|
|
46
49
|
export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
47
|
-
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, } from './utils/date-utils';
|
|
50
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem, } from './utils/date-utils';
|
|
51
|
+
export { resolveTimeViewsResponse } from './utils/date-time-utils';
|
|
48
52
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
49
53
|
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
50
54
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, } from './utils/utils';
|
|
@@ -53,8 +57,10 @@ export { extractValidationProps } from './utils/validation/extractValidationProp
|
|
|
53
57
|
export { validateDate } from './utils/validation/validateDate';
|
|
54
58
|
export { validateDateTime } from './utils/validation/validateDateTime';
|
|
55
59
|
export { validateTime } from './utils/validation/validateTime';
|
|
60
|
+
export { applyDefaultViewProps } from './utils/views';
|
|
56
61
|
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
|
|
57
62
|
export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
58
63
|
export type { DayCalendarProps, DayCalendarSlots, DayCalendarSlotProps, ExportedDayCalendarProps, } from '../DateCalendar/DayCalendar';
|
|
59
64
|
export type { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar.types';
|
|
60
65
|
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
66
|
+
export { isTimeView } from './utils/time-utils';
|
package/internals/index.js
CHANGED
|
@@ -14,10 +14,12 @@ export { useField, createDateStrForInputFromSections, addPositionPropertiesToSec
|
|
|
14
14
|
export { usePicker } from './hooks/usePicker';
|
|
15
15
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
16
16
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
17
|
+
export { useViews } from './hooks/useViews';
|
|
17
18
|
export { useValidation } from './hooks/useValidation';
|
|
18
19
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
19
20
|
export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
20
|
-
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
|
|
21
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem } from './utils/date-utils';
|
|
22
|
+
export { resolveTimeViewsResponse } from './utils/date-time-utils';
|
|
21
23
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
22
24
|
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
23
25
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|
|
@@ -26,6 +28,8 @@ export { extractValidationProps } from './utils/validation/extractValidationProp
|
|
|
26
28
|
export { validateDate } from './utils/validation/validateDate';
|
|
27
29
|
export { validateDateTime } from './utils/validation/validateDateTime';
|
|
28
30
|
export { validateTime } from './utils/validation/validateTime';
|
|
31
|
+
export { applyDefaultViewProps } from './utils/views';
|
|
29
32
|
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
|
|
30
33
|
export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
31
|
-
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
34
|
+
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
35
|
+
export { isTimeView } from './utils/time-utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateView, TimeView } from '
|
|
1
|
+
import { DateView, TimeView } from '../../models/views';
|
|
2
2
|
export type WrapperVariant = 'mobile' | 'desktop' | null;
|
|
3
3
|
export type TimeViewWithMeridiem = TimeView | 'meridiem';
|
|
4
4
|
export type DateOrTimeViewWithMeridiem = DateView | TimeViewWithMeridiem;
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type ExtendMui<C, Removals extends keyof C = never> = Omit<C, 'classes' | 'theme' | Removals>;
|
|
7
7
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
|
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
8
9
|
export type DefaultizedProps<P extends {}, RequiredProps extends keyof P, AdditionalProps extends {} = {}> = Omit<P, RequiredProps | keyof AdditionalProps> & Required<Pick<P, RequiredProps>> & AdditionalProps;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
2
|
import { BaseTimeValidationProps, TimeValidationProps } from '../validation';
|
|
3
|
-
import { PickerSelectionState } from '../../hooks/usePicker/usePickerValue.types';
|
|
4
3
|
import { TimeStepOptions, TimezoneProps } from '../../../models';
|
|
5
4
|
import type { ExportedDigitalClockProps } from '../../../DigitalClock/DigitalClock.types';
|
|
6
5
|
import type { ExportedMultiSectionDigitalClockProps } from '../../../MultiSectionDigitalClock/MultiSectionDigitalClock.types';
|
|
@@ -29,14 +28,6 @@ export interface BaseClockProps<TDate, TView extends TimeViewWithMeridiem> exten
|
|
|
29
28
|
* Used when the component is not controlled.
|
|
30
29
|
*/
|
|
31
30
|
defaultValue?: TDate | null;
|
|
32
|
-
/**
|
|
33
|
-
* Callback fired when the value changes.
|
|
34
|
-
* @template TDate, TView
|
|
35
|
-
* @param {TDate | null} value The new value.
|
|
36
|
-
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
37
|
-
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
38
|
-
*/
|
|
39
|
-
onChange?: (value: TDate | null, selectionState?: PickerSelectionState, selectedView?: TView) => void;
|
|
40
31
|
/**
|
|
41
32
|
* If `true`, the picker views and text field are disabled.
|
|
42
33
|
* @default false
|
package/internals/utils/views.js
CHANGED
|
@@ -19,7 +19,7 @@ export const applyDefaultViewProps = ({
|
|
|
19
19
|
} else if (viewsWithDefault.length > 0) {
|
|
20
20
|
openToWithDefault = viewsWithDefault[0];
|
|
21
21
|
} else {
|
|
22
|
-
throw new Error('MUI: The `views` prop must contain at least one view');
|
|
22
|
+
throw new Error('MUI X: The `views` prop must contain at least one view.');
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
25
|
views: viewsWithDefault,
|