@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.2
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/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +651 -6
- package/DateCalendar/DateCalendar.js +1 -0
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/DateCalendar/PickersSlideTransition.js +12 -5
- package/DateCalendar/useCalendarState.d.ts +6 -4
- package/DateField/DateField.js +5 -4
- package/DateField/DateField.types.d.ts +10 -9
- package/DatePicker/DatePicker.types.d.ts +3 -3
- package/DatePicker/DatePickerToolbar.d.ts +3 -2
- package/DatePicker/DatePickerToolbar.js +0 -12
- package/DatePicker/shared.d.ts +6 -5
- package/DateTimeField/DateTimeField.js +5 -4
- package/DateTimeField/DateTimeField.types.d.ts +10 -10
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/DateTimePicker/DateTimePickerToolbar.d.ts +3 -4
- package/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/DateTimePicker/shared.d.ts +6 -6
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
- package/DigitalClock/DigitalClock.js +1 -0
- package/MonthCalendar/MonthCalendar.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
- package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +22 -39
- package/PickersLayout/PickersLayout.types.d.ts +14 -15
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +20 -17
- package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/PickersTextField/PickersTextField.js +2 -2
- package/README.md +9 -6
- package/TimeClock/Clock.js +1 -0
- package/TimeClock/TimeClock.js +1 -0
- package/TimeField/TimeField.js +5 -4
- package/TimeField/TimeField.types.d.ts +10 -10
- package/TimePicker/TimePicker.types.d.ts +3 -3
- package/TimePicker/TimePickerToolbar.d.ts +2 -3
- package/TimePicker/TimePickerToolbar.js +6 -15
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +1 -0
- package/hooks/useParsedFormat.d.ts +2 -2
- package/hooks/useParsedFormat.js +1 -1
- package/hooks/useSplitFieldProps.d.ts +3 -3
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +26 -0
- package/internals/components/PickerProvider.js +3 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/components/PickersToolbar.js +2 -4
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.types.d.ts +46 -46
- package/internals/hooks/useField/useField.utils.d.ts +4 -3
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
- package/internals/hooks/useField/useFieldState.d.ts +9 -8
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +12 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
- package/internals/hooks/usePicker/usePicker.d.ts +3 -3
- package/internals/hooks/usePicker/usePicker.js +10 -19
- package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
- package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
- package/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
- package/internals/hooks/useValueWithTimezone.d.ts +20 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +5 -3
- package/internals/index.js +1 -0
- package/internals/models/common.d.ts +2 -1
- package/internals/models/fields.d.ts +6 -1
- package/internals/models/pickers.d.ts +1 -0
- package/internals/models/pickers.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +4 -3
- package/internals/models/props/time.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +2 -2
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +3 -3
- package/internals/utils/valueManagers.d.ts +4 -3
- package/locales/nlNL.js +7 -7
- package/models/adapters.d.ts +4 -4
- package/models/common.d.ts +1 -0
- package/models/fields.d.ts +19 -6
- package/models/pickers.d.ts +18 -0
- package/models/validation.d.ts +2 -1
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +1 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateField/DateField.js +5 -4
- package/modern/DatePicker/DatePickerToolbar.js +0 -12
- package/modern/DateTimeField/DateTimeField.js +5 -4
- package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +1 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/modern/PickersLayout/PickersLayout.js +22 -39
- package/modern/PickersLayout/usePickerLayout.js +20 -17
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/modern/PickersTextField/PickersTextField.js +2 -2
- package/modern/TimeClock/Clock.js +1 -0
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/TimeField/TimeField.js +5 -4
- package/modern/TimePicker/TimePickerToolbar.js +6 -15
- package/modern/YearCalendar/YearCalendar.js +1 -0
- package/modern/hooks/useParsedFormat.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +3 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/modern/internals/components/PickersToolbar.js +2 -4
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/modern/internals/hooks/useFieldOwnerState.js +12 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +10 -19
- package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/modern/internals/hooks/useValueWithTimezone.js +13 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/models/pickers.js +1 -0
- package/modern/locales/nlNL.js +7 -7
- package/modern/validation/useValidation.js +1 -1
- package/modern/validation/validateDate.js +8 -0
- package/modern/validation/validateDateTime.js +8 -0
- package/modern/validation/validateTime.js +8 -0
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/DateCalendar.js +1 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateField/DateField.js +5 -4
- package/node/DatePicker/DatePickerToolbar.js +0 -12
- package/node/DateTimeField/DateTimeField.js +5 -4
- package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +1 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/node/PickersLayout/PickersLayout.js +22 -39
- package/node/PickersLayout/usePickerLayout.js +20 -17
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/node/PickersTextField/PickersTextField.js +2 -2
- package/node/TimeClock/Clock.js +1 -0
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/TimeField/TimeField.js +5 -4
- package/node/TimePicker/TimePickerToolbar.js +6 -15
- package/node/YearCalendar/YearCalendar.js +1 -0
- package/node/hooks/useParsedFormat.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +3 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/node/internals/components/PickersToolbar.js +2 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -1
- package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/node/internals/hooks/useFieldOwnerState.js +20 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/node/internals/hooks/usePicker/usePicker.js +11 -19
- package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- package/node/internals/index.js +7 -0
- package/node/internals/models/pickers.js +5 -0
- package/node/locales/nlNL.js +7 -7
- package/node/validation/useValidation.js +1 -1
- package/node/validation/validateDate.js +8 -0
- package/node/validation/validateDateTime.js +8 -0
- package/node/validation/validateTime.js +8 -0
- package/package.json +4 -4
- package/themeAugmentation/overrides.d.ts +1 -1
- package/themeAugmentation/props.d.ts +3 -2
- package/validation/useValidation.d.ts +7 -6
- package/validation/useValidation.js +1 -1
- package/validation/validateDate.d.ts +12 -3
- package/validation/validateDate.js +8 -0
- package/validation/validateDateTime.d.ts +12 -4
- package/validation/validateDateTime.js +8 -0
- package/validation/validateTime.d.ts +12 -3
- package/validation/validateTime.js +8 -0
- package/internals/hooks/useIsLandscape.d.ts +0 -4
- package/internals/hooks/useIsLandscape.js +0 -35
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -33
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.usePicker = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
9
|
var _warning = require("@mui/x-internals/warning");
|
|
8
10
|
var _usePickerValue = require("./usePickerValue");
|
|
9
11
|
var _usePickerViews = require("./usePickerViews");
|
|
10
|
-
var _usePickerLayoutProps = require("./usePickerLayoutProps");
|
|
11
|
-
var _usePickerOwnerState = require("./usePickerOwnerState");
|
|
12
12
|
var _usePickerProvider = require("./usePickerProvider");
|
|
13
13
|
const usePicker = ({
|
|
14
14
|
props,
|
|
15
15
|
valueManager,
|
|
16
16
|
valueType,
|
|
17
|
-
|
|
17
|
+
variant,
|
|
18
18
|
additionalViewProps,
|
|
19
19
|
validator,
|
|
20
20
|
autoFocusView,
|
|
@@ -31,7 +31,7 @@ const usePicker = ({
|
|
|
31
31
|
props,
|
|
32
32
|
valueManager,
|
|
33
33
|
valueType,
|
|
34
|
-
|
|
34
|
+
variant,
|
|
35
35
|
validator
|
|
36
36
|
});
|
|
37
37
|
const pickerViewsResponse = (0, _usePickerViews.usePickerViews)({
|
|
@@ -42,21 +42,13 @@ const usePicker = ({
|
|
|
42
42
|
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
43
43
|
rendererInterceptor
|
|
44
44
|
});
|
|
45
|
-
const pickerLayoutResponse = (0, _usePickerLayoutProps.usePickerLayoutProps)({
|
|
46
|
-
props,
|
|
47
|
-
wrapperVariant,
|
|
48
|
-
propsFromPickerValue: pickerValueResponse.layoutProps,
|
|
49
|
-
propsFromPickerViews: pickerViewsResponse.layoutProps
|
|
50
|
-
});
|
|
51
|
-
const pickerOwnerState = (0, _usePickerOwnerState.usePickerOwnerState)({
|
|
52
|
-
props,
|
|
53
|
-
pickerValueResponse,
|
|
54
|
-
valueManager
|
|
55
|
-
});
|
|
56
45
|
const providerProps = (0, _usePickerProvider.usePickerProvider)({
|
|
46
|
+
props,
|
|
57
47
|
pickerValueResponse,
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
localeText,
|
|
49
|
+
valueManager,
|
|
50
|
+
variant,
|
|
51
|
+
views: pickerViewsResponse.views
|
|
60
52
|
});
|
|
61
53
|
return {
|
|
62
54
|
// Picker value
|
|
@@ -68,11 +60,11 @@ const usePicker = ({
|
|
|
68
60
|
hasUIView: pickerViewsResponse.hasUIView,
|
|
69
61
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
70
62
|
// Picker layout
|
|
71
|
-
layoutProps:
|
|
63
|
+
layoutProps: (0, _extends2.default)({}, pickerViewsResponse.layoutProps, pickerValueResponse.layoutProps),
|
|
72
64
|
// Picker provider
|
|
73
65
|
providerProps,
|
|
74
66
|
// Picker owner state
|
|
75
|
-
ownerState:
|
|
67
|
+
ownerState: providerProps.privateContextValue.ownerState
|
|
76
68
|
};
|
|
77
69
|
};
|
|
78
70
|
exports.usePicker = usePicker;
|
|
@@ -1,22 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
8
|
+
exports.usePickerOrientation = void 0;
|
|
7
9
|
exports.usePickerProvider = usePickerProvider;
|
|
8
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
12
|
+
var _useUtils = require("../useUtils");
|
|
13
|
+
var _utils = require("../../utils/utils");
|
|
14
|
+
function getOrientation() {
|
|
15
|
+
if (typeof window === 'undefined') {
|
|
16
|
+
return 'portrait';
|
|
17
|
+
}
|
|
18
|
+
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
|
19
|
+
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Support IOS safari
|
|
23
|
+
if (window.orientation) {
|
|
24
|
+
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
|
25
|
+
}
|
|
26
|
+
return 'portrait';
|
|
27
|
+
}
|
|
28
|
+
const usePickerOrientation = (views, customOrientation) => {
|
|
29
|
+
const [orientation, setOrientation] = React.useState(getOrientation);
|
|
30
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
31
|
+
const eventHandler = () => {
|
|
32
|
+
setOrientation(getOrientation());
|
|
33
|
+
};
|
|
34
|
+
window.addEventListener('orientationchange', eventHandler);
|
|
35
|
+
return () => {
|
|
36
|
+
window.removeEventListener('orientationchange', eventHandler);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
if ((0, _utils.arrayIncludes)(views, ['hours', 'minutes', 'seconds'])) {
|
|
40
|
+
// could not display 13:34:44 in landscape mode
|
|
41
|
+
return 'portrait';
|
|
42
|
+
}
|
|
43
|
+
return customOrientation ?? orientation;
|
|
44
|
+
};
|
|
45
|
+
exports.usePickerOrientation = usePickerOrientation;
|
|
9
46
|
function usePickerProvider(parameters) {
|
|
10
47
|
const {
|
|
48
|
+
props,
|
|
11
49
|
pickerValueResponse,
|
|
12
|
-
|
|
13
|
-
localeText
|
|
50
|
+
valueManager,
|
|
51
|
+
localeText,
|
|
52
|
+
variant,
|
|
53
|
+
views
|
|
14
54
|
} = parameters;
|
|
55
|
+
const utils = (0, _useUtils.useUtils)();
|
|
56
|
+
const orientation = usePickerOrientation(views, props.orientation);
|
|
57
|
+
const ownerState = React.useMemo(() => ({
|
|
58
|
+
isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
|
|
59
|
+
isPickerOpen: pickerValueResponse.open,
|
|
60
|
+
isPickerDisabled: props.disabled ?? false,
|
|
61
|
+
isPickerReadOnly: props.readOnly ?? false,
|
|
62
|
+
pickerOrientation: orientation,
|
|
63
|
+
pickerVariant: variant
|
|
64
|
+
}), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, orientation, variant, props.disabled, props.readOnly]);
|
|
15
65
|
const contextValue = React.useMemo(() => ({
|
|
16
66
|
onOpen: pickerValueResponse.actions.onOpen,
|
|
17
67
|
onClose: pickerValueResponse.actions.onClose,
|
|
18
|
-
open: pickerValueResponse.open
|
|
19
|
-
|
|
68
|
+
open: pickerValueResponse.open,
|
|
69
|
+
disabled: props.disabled ?? false,
|
|
70
|
+
readOnly: props.readOnly ?? false,
|
|
71
|
+
variant,
|
|
72
|
+
orientation
|
|
73
|
+
}), [pickerValueResponse.actions.onOpen, pickerValueResponse.actions.onClose, pickerValueResponse.open, variant, orientation, props.disabled, props.readOnly]);
|
|
20
74
|
const privateContextValue = React.useMemo(() => ({
|
|
21
75
|
ownerState
|
|
22
76
|
}), [ownerState]);
|
|
@@ -25,4 +79,9 @@ function usePickerProvider(parameters) {
|
|
|
25
79
|
contextValue,
|
|
26
80
|
privateContextValue
|
|
27
81
|
};
|
|
28
|
-
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Props used to create the private context.
|
|
86
|
+
* Those props are exposed on all the pickers.
|
|
87
|
+
*/
|
|
@@ -120,7 +120,7 @@ const usePickerValue = ({
|
|
|
120
120
|
props,
|
|
121
121
|
valueManager,
|
|
122
122
|
valueType,
|
|
123
|
-
|
|
123
|
+
variant,
|
|
124
124
|
validator
|
|
125
125
|
}) => {
|
|
126
126
|
const {
|
|
@@ -128,8 +128,9 @@ const usePickerValue = ({
|
|
|
128
128
|
onChange,
|
|
129
129
|
value: inValueWithoutRenderTimezone,
|
|
130
130
|
defaultValue: inDefaultValue,
|
|
131
|
-
closeOnSelect =
|
|
132
|
-
timezone: timezoneProp
|
|
131
|
+
closeOnSelect = variant === 'desktop',
|
|
132
|
+
timezone: timezoneProp,
|
|
133
|
+
referenceDate
|
|
133
134
|
} = props;
|
|
134
135
|
const {
|
|
135
136
|
current: defaultValue
|
|
@@ -137,6 +138,7 @@ const usePickerValue = ({
|
|
|
137
138
|
const {
|
|
138
139
|
current: isControlled
|
|
139
140
|
} = React.useRef(inValueWithoutRenderTimezone !== undefined);
|
|
141
|
+
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
140
142
|
|
|
141
143
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
142
144
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -167,6 +169,7 @@ const usePickerValue = ({
|
|
|
167
169
|
timezone: timezoneProp,
|
|
168
170
|
value: inValueWithoutRenderTimezone,
|
|
169
171
|
defaultValue,
|
|
172
|
+
referenceDate,
|
|
170
173
|
onChange,
|
|
171
174
|
valueManager
|
|
172
175
|
});
|
|
@@ -183,10 +186,19 @@ const usePickerValue = ({
|
|
|
183
186
|
draft: initialValue,
|
|
184
187
|
lastPublishedValue: initialValue,
|
|
185
188
|
lastCommittedValue: initialValue,
|
|
186
|
-
lastControlledValue:
|
|
189
|
+
lastControlledValue: inValueWithoutRenderTimezone,
|
|
187
190
|
hasBeenModifiedSinceMount: false
|
|
188
191
|
};
|
|
189
192
|
});
|
|
193
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
194
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
195
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
196
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
197
|
+
setDateState(prev => (0, _extends2.default)({}, prev, {
|
|
198
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
190
202
|
const {
|
|
191
203
|
getValidationErrorForNewValue
|
|
192
204
|
} = (0, _validation.useValidation)({
|
|
@@ -236,10 +248,10 @@ const usePickerValue = ({
|
|
|
236
248
|
setIsOpen(false);
|
|
237
249
|
}
|
|
238
250
|
});
|
|
239
|
-
if (
|
|
251
|
+
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
240
252
|
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
|
|
241
253
|
setDateState(prev => (0, _extends2.default)({}, prev, {
|
|
242
|
-
lastControlledValue:
|
|
254
|
+
lastControlledValue: inValueWithoutRenderTimezone
|
|
243
255
|
}, isUpdateComingFromPicker ? {} : {
|
|
244
256
|
lastCommittedValue: inValueWithTimezoneToRender,
|
|
245
257
|
lastPublishedValue: inValueWithTimezoneToRender,
|
|
@@ -56,7 +56,7 @@ const useStaticPicker = _ref => {
|
|
|
56
56
|
fieldRef: undefined,
|
|
57
57
|
localeText,
|
|
58
58
|
additionalViewProps: {},
|
|
59
|
-
|
|
59
|
+
variant: displayStaticWrapperAs
|
|
60
60
|
}));
|
|
61
61
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
62
62
|
const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerProvider.PickerProvider, (0, _extends2.default)({}, providerProps, {
|
|
@@ -19,6 +19,7 @@ const useValueWithTimezone = ({
|
|
|
19
19
|
timezone: timezoneProp,
|
|
20
20
|
value: valueProp,
|
|
21
21
|
defaultValue,
|
|
22
|
+
referenceDate,
|
|
22
23
|
onChange,
|
|
23
24
|
valueManager
|
|
24
25
|
}) => {
|
|
@@ -32,7 +33,16 @@ const useValueWithTimezone = ({
|
|
|
32
33
|
}
|
|
33
34
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
+
let timezoneToRender;
|
|
37
|
+
if (timezoneProp) {
|
|
38
|
+
timezoneToRender = timezoneProp;
|
|
39
|
+
} else if (inputTimezone) {
|
|
40
|
+
timezoneToRender = inputTimezone;
|
|
41
|
+
} else if (referenceDate) {
|
|
42
|
+
timezoneToRender = utils.getTimezone(referenceDate);
|
|
43
|
+
} else {
|
|
44
|
+
timezoneToRender = 'default';
|
|
45
|
+
}
|
|
36
46
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
37
47
|
const handleValueChange = (0, _useEventCallback.default)((newValue, ...otherParams) => {
|
|
38
48
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
@@ -54,6 +64,7 @@ const useControlledValueWithTimezone = ({
|
|
|
54
64
|
timezone: timezoneProp,
|
|
55
65
|
value: valueProp,
|
|
56
66
|
defaultValue,
|
|
67
|
+
referenceDate,
|
|
57
68
|
onChange: onChangeProp,
|
|
58
69
|
valueManager
|
|
59
70
|
}) => {
|
|
@@ -71,6 +82,7 @@ const useControlledValueWithTimezone = ({
|
|
|
71
82
|
timezone: timezoneProp,
|
|
72
83
|
value: valueWithInputTimezone,
|
|
73
84
|
defaultValue: undefined,
|
|
85
|
+
referenceDate,
|
|
74
86
|
onChange,
|
|
75
87
|
valueManager
|
|
76
88
|
});
|
package/node/internals/index.js
CHANGED
|
@@ -261,6 +261,12 @@ Object.defineProperty(exports, "useField", {
|
|
|
261
261
|
return _useField.useField;
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
|
+
Object.defineProperty(exports, "useFieldOwnerState", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function () {
|
|
267
|
+
return _useFieldOwnerState.useFieldOwnerState;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
264
270
|
Object.defineProperty(exports, "useLocalizationContext", {
|
|
265
271
|
enumerable: true,
|
|
266
272
|
get: function () {
|
|
@@ -329,6 +335,7 @@ var _PickersToolbarButton = require("./components/PickersToolbarButton");
|
|
|
329
335
|
var _dimensions = require("./constants/dimensions");
|
|
330
336
|
var _useValueWithTimezone = require("./hooks/useValueWithTimezone");
|
|
331
337
|
var _useField = require("./hooks/useField");
|
|
338
|
+
var _useFieldOwnerState = require("./hooks/useFieldOwnerState");
|
|
332
339
|
var _usePicker = require("./hooks/usePicker");
|
|
333
340
|
var _usePickerPrivateContext = require("./hooks/usePickerPrivateContext");
|
|
334
341
|
var _useStaticPicker = require("./hooks/useStaticPicker");
|
package/node/locales/nlNL.js
CHANGED
|
@@ -22,10 +22,10 @@ const nlNLPickers = {
|
|
|
22
22
|
// DateRange labels
|
|
23
23
|
start: 'Start',
|
|
24
24
|
end: 'Einde',
|
|
25
|
-
startDate: '
|
|
26
|
-
startTime: '
|
|
27
|
-
endDate: '
|
|
28
|
-
endTime: '
|
|
25
|
+
startDate: 'Startdatum',
|
|
26
|
+
startTime: 'Starttijd',
|
|
27
|
+
endDate: 'Einddatum',
|
|
28
|
+
endTime: 'Eindtijd',
|
|
29
29
|
// Action bar
|
|
30
30
|
cancelButtonLabel: 'Annuleren',
|
|
31
31
|
clearButtonLabel: 'Resetten',
|
|
@@ -56,11 +56,11 @@ const nlNLPickers = {
|
|
|
56
56
|
timeTableLabel: 'kies tijd',
|
|
57
57
|
dateTableLabel: 'kies datum',
|
|
58
58
|
// Field section placeholders
|
|
59
|
-
fieldYearPlaceholder: params => '
|
|
59
|
+
fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
|
|
60
60
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
61
61
|
fieldDayPlaceholder: () => 'DD',
|
|
62
62
|
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
|
|
63
|
-
fieldHoursPlaceholder: () => '
|
|
63
|
+
fieldHoursPlaceholder: () => 'uu',
|
|
64
64
|
fieldMinutesPlaceholder: () => 'mm',
|
|
65
65
|
fieldSecondsPlaceholder: () => 'ss',
|
|
66
66
|
fieldMeridiemPlaceholder: () => 'aa',
|
|
@@ -74,6 +74,6 @@ const nlNLPickers = {
|
|
|
74
74
|
seconds: 'Seconden',
|
|
75
75
|
meridiem: 'Middag',
|
|
76
76
|
// Common
|
|
77
|
-
empty: '
|
|
77
|
+
empty: 'Leeg'
|
|
78
78
|
};
|
|
79
79
|
const nlNL = exports.nlNL = (0, _getPickersLocalization.getPickersLocalization)(nlNLPickers);
|
|
@@ -12,7 +12,7 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
|
|
|
12
12
|
var _useUtils = require("../internals/hooks/useUtils");
|
|
13
13
|
/**
|
|
14
14
|
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
15
|
-
* @template TValue The value type. It will be
|
|
15
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
16
16
|
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
17
17
|
* @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
|
|
18
18
|
* @param {TValue} options.value The value to validate.
|
|
@@ -10,6 +10,14 @@ var _valueManagers = require("../internals/utils/valueManagers");
|
|
|
10
10
|
* Validation props used by the Date Picker, Date Field and Date Calendar components.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Validation props as received by the validateDate method.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Name of the props that should be defaulted before being passed to the validateDate method.
|
|
19
|
+
*/
|
|
20
|
+
|
|
13
21
|
const validateDate = ({
|
|
14
22
|
props,
|
|
15
23
|
value,
|
|
@@ -11,6 +11,14 @@ var _valueManagers = require("../internals/utils/valueManagers");
|
|
|
11
11
|
* Validation props used by the Date Time Picker and Date Time Field components.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validation props as received by the validateDateTime method.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Name of the props that should be defaulted before being passed to the validateDateTime method.
|
|
20
|
+
*/
|
|
21
|
+
|
|
14
22
|
const validateDateTime = ({
|
|
15
23
|
adapter,
|
|
16
24
|
value,
|
|
@@ -10,6 +10,14 @@ var _valueManagers = require("../internals/utils/valueManagers");
|
|
|
10
10
|
* Validation props used by the Time Picker, Time Field and Clock components.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Validation props as received by the validateTime method.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Name of the props that should be defaulted before being passed to the validateTime method.
|
|
19
|
+
*/
|
|
20
|
+
|
|
13
21
|
const validateTime = ({
|
|
14
22
|
adapter,
|
|
15
23
|
value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"description": "The community edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"prop-types": "^15.8.1",
|
|
43
43
|
"react-transition-group": "^4.4.5",
|
|
44
|
-
"@mui/x-internals": "8.0.0-alpha.
|
|
44
|
+
"@mui/x-internals": "8.0.0-alpha.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"moment": "^2.29.4",
|
|
56
56
|
"moment-hijri": "^2.1.2 || ^3.0.0",
|
|
57
57
|
"moment-jalaali": "^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0",
|
|
58
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
59
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
58
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
59
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"@emotion/react": {
|
|
@@ -57,13 +57,13 @@ export interface PickersComponentNameToClassKey {
|
|
|
57
57
|
MuiPickersCalendarHeader: PickersCalendarHeaderClassKey;
|
|
58
58
|
MuiPickersDay: PickersDayClassKey;
|
|
59
59
|
MuiPickersFadeTransitionGroup: PickersFadeTransitionGroupClassKey;
|
|
60
|
+
MuiPickersLayout: PickersLayoutClassKey;
|
|
60
61
|
MuiPickersMonth: PickersMonthClassKey;
|
|
61
62
|
MuiPickersPopper: PickersPopperClassKey;
|
|
62
63
|
MuiPickersSlideTransition: PickersSlideTransitionClassKey;
|
|
63
64
|
MuiPickersToolbar: PickersToolbarClassKey;
|
|
64
65
|
MuiPickersToolbarButton: PickersToolbarButtonClassKey;
|
|
65
66
|
MuiPickersToolbarText: PickersToolbarTextClassKey;
|
|
66
|
-
MuiPickersLayout: PickersLayoutClassKey;
|
|
67
67
|
MuiPickersYear: PickersYearClassKey;
|
|
68
68
|
MuiTimeClock: TimeClockClassKey;
|
|
69
69
|
MuiTimePickerToolbar: TimePickerToolbarClassKey;
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
PickersFilledInputProps,
|
|
53
53
|
} from '../PickersTextField';
|
|
54
54
|
import { PickersSectionListProps } from '../PickersSectionList';
|
|
55
|
+
import { PickerValidValue } from '../internals/models';
|
|
55
56
|
|
|
56
57
|
export interface PickersComponentsPropsList {
|
|
57
58
|
MuiClock: ClockProps;
|
|
@@ -77,10 +78,10 @@ export interface PickersComponentsPropsList {
|
|
|
77
78
|
MuiPickersMonth: ExportedPickersMonthProps;
|
|
78
79
|
MuiPickersPopper: PickerPopperProps;
|
|
79
80
|
MuiPickersSlideTransition: ExportedSlideTransitionProps;
|
|
80
|
-
MuiPickersToolbar: PickersToolbarProps<
|
|
81
|
+
MuiPickersToolbar: PickersToolbarProps<PickerValidValue, DateOrTimeView>;
|
|
81
82
|
MuiPickersToolbarButton: PickersToolbarButtonProps;
|
|
82
83
|
MuiPickersToolbarText: ExportedPickersToolbarTextProps;
|
|
83
|
-
MuiPickersLayout: PickersLayoutProps<
|
|
84
|
+
MuiPickersLayout: PickersLayoutProps<PickerValidValue, DateOrTimeView>;
|
|
84
85
|
MuiPickersYear: ExportedPickersYearProps;
|
|
85
86
|
MuiTimeClock: TimeClockProps;
|
|
86
87
|
MuiTimeField: TimeFieldProps<any>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
|
|
2
2
|
import { OnErrorProps, PickersTimezone } from '../models';
|
|
3
3
|
import type { PickerValueManager } from '../internals/hooks/usePicker';
|
|
4
|
-
|
|
4
|
+
import { PickerValidValue } from '../internals/models';
|
|
5
|
+
export type Validator<TValue extends PickerValidValue, TError, TValidationProps> = {
|
|
5
6
|
(params: {
|
|
6
7
|
adapter: MuiPickersAdapterContextValue;
|
|
7
8
|
value: TValue;
|
|
@@ -10,7 +11,7 @@ export type Validator<TValue, TError, TValidationProps> = {
|
|
|
10
11
|
}): TError;
|
|
11
12
|
valueManager: PickerValueManager<TValue, any>;
|
|
12
13
|
};
|
|
13
|
-
interface UseValidationOptions<TValue, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
|
|
14
|
+
interface UseValidationOptions<TValue extends PickerValidValue, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
|
|
14
15
|
/**
|
|
15
16
|
* The value to validate.
|
|
16
17
|
*/
|
|
@@ -32,7 +33,7 @@ interface UseValidationOptions<TValue, TError, TValidationProps extends {}> exte
|
|
|
32
33
|
*/
|
|
33
34
|
props: TValidationProps;
|
|
34
35
|
}
|
|
35
|
-
interface UseValidationReturnValue<TValue, TError> {
|
|
36
|
+
interface UseValidationReturnValue<TValue extends PickerValidValue, TError> {
|
|
36
37
|
/**
|
|
37
38
|
* The validation error associated to the value passed to the `useValidation` hook.
|
|
38
39
|
*/
|
|
@@ -46,7 +47,7 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
46
47
|
/**
|
|
47
48
|
* Get the validation error for a new value.
|
|
48
49
|
* This can be used to validate the value in a change handler before updating the state.
|
|
49
|
-
* @template TValue The value type.
|
|
50
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
50
51
|
* @param {TValue} newValue The value to validate.
|
|
51
52
|
* @returns {TError} The validation error associated to the new value.
|
|
52
53
|
*/
|
|
@@ -54,7 +55,7 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
57
|
-
* @template TValue The value type. It will be
|
|
58
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
58
59
|
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
59
60
|
* @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
|
|
60
61
|
* @param {TValue} options.value The value to validate.
|
|
@@ -63,5 +64,5 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
63
64
|
* @param {TValidationProps} options.props The validation props, they differ depending on the component.
|
|
64
65
|
* @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
|
|
65
66
|
*/
|
|
66
|
-
export declare function useValidation<TValue, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
|
|
67
|
+
export declare function useValidation<TValue extends PickerValidValue, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
|
|
67
68
|
export {};
|
|
@@ -5,7 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import { useLocalizationContext } from "../internals/hooks/useUtils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
8
|
-
* @template TValue The value type. It will be
|
|
8
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
9
9
|
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
10
10
|
* @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
|
|
11
11
|
* @param {TValue} options.value The value to validate.
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import type { MakeRequired } from '@mui/x-internals/types';
|
|
1
2
|
import { Validator } from './useValidation';
|
|
2
3
|
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
3
|
-
import { DateValidationError
|
|
4
|
+
import { DateValidationError } from '../models';
|
|
5
|
+
import { PickerValue } from '../internals/models';
|
|
4
6
|
/**
|
|
5
7
|
* Validation props used by the Date Picker, Date Field and Date Calendar components.
|
|
6
8
|
*/
|
|
7
9
|
export interface ExportedValidateDateProps extends DayValidationProps, MonthValidationProps, YearValidationProps, BaseDateValidationProps {
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateDate method.
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateDateProps extends MakeRequired<ExportedValidateDateProps, ValidateDatePropsToDefault> {
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateDate method.
|
|
18
|
+
*/
|
|
19
|
+
export type ValidateDatePropsToDefault = keyof BaseDateValidationProps;
|
|
20
|
+
export declare const validateDate: Validator<PickerValue, DateValidationError, ValidateDateProps>;
|
|
@@ -5,6 +5,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
5
5
|
* Validation props used by the Date Picker, Date Field and Date Calendar components.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Validation props as received by the validateDate method.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Name of the props that should be defaulted before being passed to the validateDate method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
8
16
|
export const validateDate = ({
|
|
9
17
|
props,
|
|
10
18
|
value,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { Validator } from './useValidation';
|
|
2
|
-
import { ExportedValidateDateProps, ValidateDateProps } from './validateDate';
|
|
3
|
-
import { ExportedValidateTimeProps, ValidateTimeProps } from './validateTime';
|
|
4
|
-
import { DateTimeValidationError
|
|
2
|
+
import { ExportedValidateDateProps, ValidateDateProps, ValidateDatePropsToDefault } from './validateDate';
|
|
3
|
+
import { ExportedValidateTimeProps, ValidateTimeProps, ValidateTimePropsToDefault } from './validateTime';
|
|
4
|
+
import { DateTimeValidationError } from '../models';
|
|
5
5
|
import { DateTimeValidationProps } from '../internals/models/validation';
|
|
6
|
+
import { PickerValue } from '../internals/models';
|
|
6
7
|
/**
|
|
7
8
|
* Validation props used by the Date Time Picker and Date Time Field components.
|
|
8
9
|
*/
|
|
9
10
|
export interface ExportedValidateDateTimeProps extends ExportedValidateDateProps, ExportedValidateTimeProps, DateTimeValidationProps {
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateTime method.
|
|
14
|
+
*/
|
|
11
15
|
export interface ValidateDateTimeProps extends ValidateDateProps, ValidateTimeProps {
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Name of the props that should be defaulted before being passed to the validateDateTime method.
|
|
19
|
+
*/
|
|
20
|
+
export type ValidateDateTimePropsToDefault = ValidateDatePropsToDefault | ValidateTimePropsToDefault;
|
|
21
|
+
export declare const validateDateTime: Validator<PickerValue, DateTimeValidationError, ValidateDateTimeProps>;
|
|
@@ -6,6 +6,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
6
6
|
* Validation props used by the Date Time Picker and Date Time Field components.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Validation props as received by the validateDateTime method.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Name of the props that should be defaulted before being passed to the validateDateTime method.
|
|
15
|
+
*/
|
|
16
|
+
|
|
9
17
|
export const validateDateTime = ({
|
|
10
18
|
adapter,
|
|
11
19
|
value,
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import type { MakeRequired } from '@mui/x-internals/types';
|
|
1
2
|
import { Validator } from './useValidation';
|
|
2
3
|
import { BaseTimeValidationProps, TimeValidationProps } from '../internals/models/validation';
|
|
3
|
-
import {
|
|
4
|
+
import { TimeValidationError } from '../models';
|
|
5
|
+
import { PickerValue } from '../internals/models';
|
|
4
6
|
/**
|
|
5
7
|
* Validation props used by the Time Picker, Time Field and Clock components.
|
|
6
8
|
*/
|
|
7
9
|
export interface ExportedValidateTimeProps extends BaseTimeValidationProps, TimeValidationProps {
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateTime method.
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateTimeProps extends MakeRequired<ExportedValidateTimeProps, ValidateTimePropsToDefault> {
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateTime method.
|
|
18
|
+
*/
|
|
19
|
+
export type ValidateTimePropsToDefault = keyof BaseTimeValidationProps;
|
|
20
|
+
export declare const validateTime: Validator<PickerValue, TimeValidationError, ValidateTimeProps>;
|