@mui/x-date-pickers 8.0.0-alpha.13 → 8.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -0
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/DateTimePicker/shared.d.ts +18 -10
- package/DateTimePicker/shared.js +23 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +61 -6
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/PickersTextField/PickersTextField.js +3 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +60 -6
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/TimePicker/shared.d.ts +1 -1
- package/esm/DatePicker/shared.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/esm/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/esm/DateTimePicker/shared.d.ts +18 -10
- package/esm/DateTimePicker/shared.js +23 -2
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/esm/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/esm/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/esm/PickersTextField/PickersTextField.js +3 -1
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/esm/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/esm/TimePicker/shared.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.js +6 -2
- package/esm/internals/components/PickerPopper/PickerPopper.js +3 -3
- package/esm/internals/components/PickerProvider.d.ts +137 -6
- package/esm/internals/components/PickerProvider.js +1 -1
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -7
- package/esm/internals/hooks/useField/useField.js +7 -8
- package/esm/internals/hooks/useField/useField.types.d.ts +46 -43
- package/esm/internals/hooks/useField/useField.utils.js +4 -1
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/esm/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/esm/internals/hooks/useField/useFieldState.js +136 -83
- package/esm/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/esm/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/esm/internals/hooks/useNullableFieldPrivateContext.d.ts +5 -2
- package/esm/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/esm/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/esm/internals/hooks/usePicker/index.d.ts +1 -3
- package/esm/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/esm/internals/hooks/usePicker/usePicker.js +276 -34
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/esm/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/esm/internals/index.d.ts +3 -6
- package/esm/internals/models/manager.d.ts +108 -4
- package/esm/internals/models/props/basePickerProps.d.ts +2 -2
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +2 -2
- package/esm/internals/utils/valueManagers.d.ts +1 -1
- package/esm/internals/utils/valueManagers.js +10 -18
- package/esm/managers/useDateManager.d.ts +3 -4
- package/esm/managers/useDateTimeManager.d.ts +3 -4
- package/esm/managers/useTimeManager.d.ts +3 -4
- package/esm/models/adapters.d.ts +2 -1
- package/esm/models/manager.d.ts +4 -5
- package/esm/validation/useValidation.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.js +6 -2
- package/internals/components/PickerPopper/PickerPopper.js +3 -3
- package/internals/components/PickerProvider.d.ts +137 -6
- package/internals/components/PickerProvider.js +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -7
- package/internals/hooks/useField/useField.js +7 -8
- package/internals/hooks/useField/useField.types.d.ts +46 -43
- package/internals/hooks/useField/useField.utils.js +4 -1
- package/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/internals/hooks/useField/useFieldState.js +135 -82
- package/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/internals/hooks/useNullableFieldPrivateContext.d.ts +5 -2
- package/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/internals/hooks/usePicker/hooks/useOrientation.js +42 -0
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/internals/hooks/usePicker/{usePickerValue.js → hooks/useValueAndOpenStates.js} +97 -114
- package/internals/hooks/usePicker/index.d.ts +1 -3
- package/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +278 -34
- package/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/internals/index.d.ts +3 -6
- package/internals/models/manager.d.ts +108 -4
- package/internals/models/props/basePickerProps.d.ts +2 -2
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +2 -2
- package/internals/utils/valueManagers.d.ts +1 -1
- package/internals/utils/valueManagers.js +10 -18
- package/managers/useDateManager.d.ts +3 -4
- package/managers/useDateTimeManager.d.ts +3 -4
- package/managers/useTimeManager.d.ts +3 -4
- package/models/adapters.d.ts +2 -1
- package/models/manager.d.ts +4 -5
- package/modern/DatePicker/shared.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/modern/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/modern/DateTimePicker/shared.d.ts +18 -10
- package/modern/DateTimePicker/shared.js +23 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/modern/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/modern/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/modern/PickersTextField/PickersTextField.js +3 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/modern/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/modern/TimePicker/shared.d.ts +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.js +6 -2
- package/modern/internals/components/PickerPopper/PickerPopper.js +3 -3
- package/modern/internals/components/PickerProvider.d.ts +137 -6
- package/modern/internals/components/PickerProvider.js +1 -1
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -7
- package/modern/internals/hooks/useField/useField.js +7 -8
- package/modern/internals/hooks/useField/useField.types.d.ts +46 -43
- package/modern/internals/hooks/useField/useField.utils.js +4 -1
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/modern/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/modern/internals/hooks/useField/useFieldState.js +136 -83
- package/modern/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/modern/internals/hooks/useNullableFieldPrivateContext.d.ts +5 -2
- package/modern/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/modern/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/modern/internals/hooks/usePicker/index.d.ts +1 -3
- package/modern/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/modern/internals/hooks/usePicker/usePicker.js +276 -34
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/modern/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/modern/internals/index.d.ts +3 -6
- package/modern/internals/models/manager.d.ts +108 -4
- package/modern/internals/models/props/basePickerProps.d.ts +2 -2
- package/modern/internals/models/props/time.d.ts +1 -1
- package/modern/internals/utils/date-time-utils.d.ts +2 -2
- package/modern/internals/utils/valueManagers.d.ts +1 -1
- package/modern/internals/utils/valueManagers.js +10 -18
- package/modern/managers/useDateManager.d.ts +3 -4
- package/modern/managers/useDateTimeManager.d.ts +3 -4
- package/modern/managers/useTimeManager.d.ts +3 -4
- package/modern/models/adapters.d.ts +2 -1
- package/modern/models/manager.d.ts +4 -5
- package/modern/validation/useValidation.d.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/useValidation.d.ts +1 -1
- package/esm/internals/hooks/useOpenState.d.ts +0 -14
- package/esm/internals/hooks/useOpenState.js +0 -37
- package/esm/internals/hooks/usePicker/usePickerProvider.d.ts +0 -65
- package/esm/internals/hooks/usePicker/usePickerProvider.js +0 -125
- package/esm/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/esm/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/esm/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/esm/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/esm/internals/hooks/usePicker/usePickerViews.d.ts +0 -137
- package/esm/internals/hooks/usePicker/usePickerViews.js +0 -188
- package/internals/hooks/useOpenState.d.ts +0 -14
- package/internals/hooks/useOpenState.js +0 -46
- package/internals/hooks/usePicker/usePickerProvider.d.ts +0 -65
- package/internals/hooks/usePicker/usePickerProvider.js +0 -135
- package/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/internals/hooks/usePicker/usePickerValue.types.js +0 -5
- package/internals/hooks/usePicker/usePickerViews.d.ts +0 -137
- package/internals/hooks/usePicker/usePickerViews.js +0 -195
- package/modern/internals/hooks/useOpenState.d.ts +0 -14
- package/modern/internals/hooks/useOpenState.js +0 -37
- package/modern/internals/hooks/usePicker/usePickerProvider.d.ts +0 -65
- package/modern/internals/hooks/usePicker/usePickerProvider.js +0 -125
- package/modern/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/modern/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/modern/internals/hooks/usePicker/usePickerViews.d.ts +0 -137
- package/modern/internals/hooks/usePicker/usePickerViews.js +0 -188
|
@@ -5,108 +5,126 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.useValueAndOpenStates = useValueAndOpenStates;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _warning = require("@mui/x-internals/warning");
|
|
11
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
12
|
-
var
|
|
13
|
-
var _useUtils = require("
|
|
14
|
-
var _validation = require("
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Manage the value lifecycle of all the pickers.
|
|
18
|
-
*/
|
|
19
|
-
const usePickerValue = ({
|
|
20
|
-
props,
|
|
21
|
-
valueManager,
|
|
22
|
-
valueType,
|
|
23
|
-
validator
|
|
24
|
-
}) => {
|
|
13
|
+
var _useValueWithTimezone = require("../../useValueWithTimezone");
|
|
14
|
+
var _useUtils = require("../../useUtils");
|
|
15
|
+
var _validation = require("../../../../validation");
|
|
16
|
+
function useValueAndOpenStates(parameters) {
|
|
25
17
|
const {
|
|
26
|
-
|
|
18
|
+
props,
|
|
19
|
+
valueManager,
|
|
20
|
+
validator
|
|
21
|
+
} = parameters;
|
|
22
|
+
const {
|
|
23
|
+
value: valueProp,
|
|
24
|
+
defaultValue: defaultValueProp,
|
|
27
25
|
onChange,
|
|
28
|
-
|
|
29
|
-
defaultValue: inDefaultValue,
|
|
30
|
-
closeOnSelect = false,
|
|
26
|
+
referenceDate,
|
|
31
27
|
timezone: timezoneProp,
|
|
32
|
-
|
|
28
|
+
onAccept,
|
|
29
|
+
closeOnSelect,
|
|
30
|
+
open: openProp,
|
|
31
|
+
onOpen,
|
|
32
|
+
onClose
|
|
33
33
|
} = props;
|
|
34
34
|
const {
|
|
35
35
|
current: defaultValue
|
|
36
|
-
} = React.useRef(
|
|
36
|
+
} = React.useRef(defaultValueProp);
|
|
37
|
+
const {
|
|
38
|
+
current: isValueControlled
|
|
39
|
+
} = React.useRef(valueProp !== undefined);
|
|
37
40
|
const {
|
|
38
|
-
current:
|
|
39
|
-
} = React.useRef(
|
|
41
|
+
current: isOpenControlled
|
|
42
|
+
} = React.useRef(openProp !== undefined);
|
|
40
43
|
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
44
|
+
const utils = (0, _useUtils.useUtils)();
|
|
45
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
46
|
+
if (props.renderInput != null) {
|
|
47
|
+
(0, _warning.warnOnce)(['MUI X: The `renderInput` prop has been removed in version 6.0 of the Date and Time Pickers.', 'You can replace it with the `textField` component slot in most cases.', 'For more information, please have a look at the migration guide (https://mui.com/x/migration/migration-pickers-v5/#input-renderer-required-in-v5).']);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
41
50
|
|
|
42
51
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
43
52
|
if (process.env.NODE_ENV !== 'production') {
|
|
44
53
|
React.useEffect(() => {
|
|
45
|
-
if (
|
|
46
|
-
console.error([`MUI X: A component is changing the ${
|
|
54
|
+
if (isValueControlled !== (valueProp !== undefined)) {
|
|
55
|
+
console.error([`MUI X: A component is changing the ${isValueControlled ? '' : 'un'}controlled value of a picker to be ${isValueControlled ? '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'));
|
|
47
56
|
}
|
|
48
|
-
}, [
|
|
57
|
+
}, [valueProp]);
|
|
49
58
|
React.useEffect(() => {
|
|
50
|
-
if (!
|
|
59
|
+
if (!isValueControlled && defaultValue !== defaultValueProp) {
|
|
51
60
|
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'));
|
|
52
61
|
}
|
|
53
62
|
}, [JSON.stringify(defaultValue)]);
|
|
54
63
|
}
|
|
55
64
|
/* eslint-enable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
56
65
|
|
|
57
|
-
const utils = (0, _useUtils.useUtils)();
|
|
58
|
-
const adapter = (0, _useUtils.useLocalizationContext)();
|
|
59
|
-
const {
|
|
60
|
-
open,
|
|
61
|
-
setOpen
|
|
62
|
-
} = (0, _useOpenState.useOpenState)(props);
|
|
63
66
|
const {
|
|
64
67
|
timezone,
|
|
65
|
-
value:
|
|
68
|
+
value: valuePropWithTimezoneToRender,
|
|
66
69
|
handleValueChange
|
|
67
70
|
} = (0, _useValueWithTimezone.useValueWithTimezone)({
|
|
68
71
|
timezone: timezoneProp,
|
|
69
|
-
value:
|
|
72
|
+
value: valueProp,
|
|
70
73
|
defaultValue,
|
|
71
74
|
referenceDate,
|
|
72
75
|
onChange,
|
|
73
76
|
valueManager
|
|
74
77
|
});
|
|
75
|
-
const [
|
|
78
|
+
const [state, setState] = React.useState(() => {
|
|
76
79
|
let initialValue;
|
|
77
|
-
if (
|
|
78
|
-
initialValue =
|
|
80
|
+
if (valuePropWithTimezoneToRender !== undefined) {
|
|
81
|
+
initialValue = valuePropWithTimezoneToRender;
|
|
79
82
|
} else if (defaultValue !== undefined) {
|
|
80
83
|
initialValue = defaultValue;
|
|
81
84
|
} else {
|
|
82
85
|
initialValue = valueManager.emptyValue;
|
|
83
86
|
}
|
|
84
87
|
return {
|
|
88
|
+
open: false,
|
|
85
89
|
draft: initialValue,
|
|
86
90
|
lastPublishedValue: initialValue,
|
|
87
91
|
lastCommittedValue: initialValue,
|
|
88
|
-
lastControlledValue:
|
|
92
|
+
lastControlledValue: valueProp,
|
|
89
93
|
hasBeenModifiedSinceMount: false
|
|
90
94
|
};
|
|
91
95
|
});
|
|
92
|
-
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
93
|
-
if (previousTimezoneProp !== timezoneProp) {
|
|
94
|
-
setPreviousTimezoneProp(timezoneProp);
|
|
95
|
-
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
96
|
-
setDateState(prev => (0, _extends2.default)({}, prev, {
|
|
97
|
-
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
96
|
const {
|
|
102
97
|
getValidationErrorForNewValue
|
|
103
98
|
} = (0, _validation.useValidation)({
|
|
104
99
|
props,
|
|
105
100
|
validator,
|
|
106
101
|
timezone,
|
|
107
|
-
value:
|
|
102
|
+
value: state.draft,
|
|
108
103
|
onError: props.onError
|
|
109
104
|
});
|
|
105
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, state.draft);
|
|
106
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
107
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
108
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
109
|
+
setState(prev => (0, _extends2.default)({}, prev, {
|
|
110
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const setOpen = (0, _useEventCallback.default)(action => {
|
|
115
|
+
const newOpen = typeof action === 'function' ? action(state.open) : action;
|
|
116
|
+
if (!isOpenControlled) {
|
|
117
|
+
setState(prevState => (0, _extends2.default)({}, prevState, {
|
|
118
|
+
open: newOpen
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
if (newOpen && onOpen) {
|
|
122
|
+
onOpen();
|
|
123
|
+
}
|
|
124
|
+
if (!newOpen && onClose) {
|
|
125
|
+
onClose();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
110
128
|
const setValue = (0, _useEventCallback.default)((newValue, options) => {
|
|
111
129
|
const {
|
|
112
130
|
changeImportance = 'accept',
|
|
@@ -117,16 +135,16 @@ const usePickerValue = ({
|
|
|
117
135
|
} = options ?? {};
|
|
118
136
|
let shouldPublish;
|
|
119
137
|
let shouldCommit;
|
|
120
|
-
if (!skipPublicationIfPristine && !
|
|
138
|
+
if (!skipPublicationIfPristine && !isValueControlled && !state.hasBeenModifiedSinceMount) {
|
|
121
139
|
// If the value is not controlled and the value has never been modified before,
|
|
122
140
|
// Then clicking on any value (including the one equal to `defaultValue`) should call `onChange` and `onAccept`
|
|
123
141
|
shouldPublish = true;
|
|
124
142
|
shouldCommit = changeImportance === 'accept';
|
|
125
143
|
} else {
|
|
126
|
-
shouldPublish = !valueManager.areValuesEqual(utils, newValue,
|
|
127
|
-
shouldCommit = changeImportance === 'accept' && !valueManager.areValuesEqual(utils, newValue,
|
|
144
|
+
shouldPublish = !valueManager.areValuesEqual(utils, newValue, state.lastPublishedValue);
|
|
145
|
+
shouldCommit = changeImportance === 'accept' && !valueManager.areValuesEqual(utils, newValue, state.lastCommittedValue);
|
|
128
146
|
}
|
|
129
|
-
|
|
147
|
+
setState(prev => (0, _extends2.default)({}, prev, {
|
|
130
148
|
draft: newValue,
|
|
131
149
|
lastPublishedValue: shouldPublish ? newValue : prev.lastPublishedValue,
|
|
132
150
|
lastCommittedValue: shouldCommit ? newValue : prev.lastCommittedValue,
|
|
@@ -154,41 +172,21 @@ const usePickerValue = ({
|
|
|
154
172
|
setOpen(false);
|
|
155
173
|
}
|
|
156
174
|
});
|
|
157
|
-
if (
|
|
158
|
-
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils,
|
|
159
|
-
|
|
160
|
-
lastControlledValue:
|
|
175
|
+
if (state.lastControlledValue !== valueProp) {
|
|
176
|
+
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, state.draft, valuePropWithTimezoneToRender);
|
|
177
|
+
setState(prev => (0, _extends2.default)({}, prev, {
|
|
178
|
+
lastControlledValue: valueProp
|
|
161
179
|
}, isUpdateComingFromPicker ? {} : {
|
|
162
|
-
lastCommittedValue:
|
|
163
|
-
lastPublishedValue:
|
|
164
|
-
draft:
|
|
180
|
+
lastCommittedValue: valuePropWithTimezoneToRender,
|
|
181
|
+
lastPublishedValue: valuePropWithTimezoneToRender,
|
|
182
|
+
draft: valuePropWithTimezoneToRender,
|
|
165
183
|
hasBeenModifiedSinceMount: true
|
|
166
184
|
}));
|
|
167
185
|
}
|
|
168
|
-
const isValid = testedValue => {
|
|
169
|
-
const error = validator({
|
|
170
|
-
adapter,
|
|
171
|
-
value: testedValue,
|
|
172
|
-
timezone,
|
|
173
|
-
props
|
|
174
|
-
});
|
|
175
|
-
return !valueManager.hasError(error);
|
|
176
|
-
};
|
|
177
|
-
const clearValue = (0, _useEventCallback.default)(() => setValue(valueManager.emptyValue));
|
|
178
|
-
const setValueToToday = (0, _useEventCallback.default)(() => setValue(valueManager.getTodayValue(utils, timezone, valueType)));
|
|
179
|
-
const acceptValueChanges = (0, _useEventCallback.default)(() => setValue(dateState.lastPublishedValue));
|
|
180
|
-
const cancelValueChanges = (0, _useEventCallback.default)(() => setValue(dateState.lastCommittedValue, {
|
|
181
|
-
skipPublicationIfPristine: true
|
|
182
|
-
}));
|
|
183
|
-
const dismissViews = (0, _useEventCallback.default)(() => {
|
|
184
|
-
setValue(dateState.lastPublishedValue, {
|
|
185
|
-
skipPublicationIfPristine: true
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
186
|
const setValueFromView = (0, _useEventCallback.default)((newValue, selectionState = 'partial') => {
|
|
189
187
|
// TODO: Expose a new method (private?) like `setView` that only updates the draft value.
|
|
190
188
|
if (selectionState === 'shallow') {
|
|
191
|
-
|
|
189
|
+
setState(prev => (0, _extends2.default)({}, prev, {
|
|
192
190
|
draft: newValue,
|
|
193
191
|
hasBeenModifiedSinceMount: true
|
|
194
192
|
}));
|
|
@@ -197,39 +195,24 @@ const usePickerValue = ({
|
|
|
197
195
|
changeImportance: selectionState === 'finish' && closeOnSelect ? 'accept' : 'set'
|
|
198
196
|
});
|
|
199
197
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
cancelValueChanges
|
|
214
|
-
}), [setValue, setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges]);
|
|
215
|
-
const contextValue = React.useMemo(() => (0, _extends2.default)({}, actionsContextValue, {
|
|
216
|
-
value: dateState.draft,
|
|
217
|
-
timezone,
|
|
218
|
-
open
|
|
219
|
-
}), [actionsContextValue, timezone, open, dateState.draft]);
|
|
220
|
-
const privateContextValue = React.useMemo(() => ({
|
|
221
|
-
dismissViews
|
|
222
|
-
}), [dismissViews]);
|
|
223
|
-
const providerParams = {
|
|
224
|
-
value: dateState.draft,
|
|
225
|
-
contextValue,
|
|
226
|
-
actionsContextValue,
|
|
227
|
-
privateContextValue,
|
|
228
|
-
isValidContextValue: isValid
|
|
229
|
-
};
|
|
198
|
+
|
|
199
|
+
// It is required to update inner state in useEffect in order to avoid situation when
|
|
200
|
+
// Our component is not mounted yet, but `open` state is set to `true` (for example initially opened)
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
if (isOpenControlled) {
|
|
203
|
+
if (openProp === undefined) {
|
|
204
|
+
throw new Error('You must not mix controlling and uncontrolled mode for `open` prop');
|
|
205
|
+
}
|
|
206
|
+
setState(prevState => (0, _extends2.default)({}, prevState, {
|
|
207
|
+
open: openProp
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
}, [isOpenControlled, openProp]);
|
|
230
211
|
return {
|
|
231
|
-
|
|
232
|
-
|
|
212
|
+
timezone,
|
|
213
|
+
state,
|
|
214
|
+
setValue,
|
|
215
|
+
setValueFromView,
|
|
216
|
+
setOpen
|
|
233
217
|
};
|
|
234
|
-
}
|
|
235
|
-
exports.usePickerValue = usePickerValue;
|
|
218
|
+
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export { usePicker } from "./usePicker.js";
|
|
2
|
-
export type { UsePickerProps, UsePickerBaseProps,
|
|
3
|
-
export type { PickerValueManager, PickerSelectionState, UsePickerValueFieldResponse } from './usePickerValue.types';
|
|
4
|
-
export type { PickerViewsRendererProps } from './usePickerViews';
|
|
2
|
+
export type { UsePickerProps, UsePickerBaseProps, UsePickerParameters, PickerSelectionState, PickerViewsRendererProps, PickerViewRendererLookup, PickerRendererInterceptorProps, PickerViewRenderer, UsePickerNonStaticProps } from './usePicker.types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UsePickerParameters, UsePickerProps, UsePickerReturnValue } from "./usePicker.types.js";
|
|
2
2
|
import { DateOrTimeViewWithMeridiem, PickerValidValue } from "../../models/index.js";
|
|
3
3
|
export declare const usePicker: <TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any>>({
|
|
4
4
|
ref,
|
|
@@ -8,7 +8,7 @@ export declare const usePicker: <TValue extends PickerValidValue, TView extends
|
|
|
8
8
|
variant,
|
|
9
9
|
validator,
|
|
10
10
|
autoFocusView,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}:
|
|
11
|
+
rendererInterceptor: RendererInterceptor,
|
|
12
|
+
localeText,
|
|
13
|
+
viewContainerRole
|
|
14
|
+
}: UsePickerParameters<TValue, TView, TExternalProps>) => UsePickerReturnValue<TValue>;
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.usePicker = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
14
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
15
|
+
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
16
|
+
var _useUtils = require("../useUtils");
|
|
17
|
+
var _useReduceAnimations = require("../useReduceAnimations");
|
|
18
|
+
var _timeUtils = require("../../utils/time-utils");
|
|
19
|
+
var _useViews = require("../useViews");
|
|
20
|
+
var _useOrientation = require("./hooks/useOrientation");
|
|
21
|
+
var _useValueAndOpenStates = require("./hooks/useValueAndOpenStates");
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
const _excluded = ["className", "sx"];
|
|
11
24
|
const usePicker = ({
|
|
12
25
|
ref,
|
|
13
26
|
props,
|
|
@@ -16,44 +29,275 @@ const usePicker = ({
|
|
|
16
29
|
variant,
|
|
17
30
|
validator,
|
|
18
31
|
autoFocusView,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
rendererInterceptor: RendererInterceptor,
|
|
33
|
+
localeText,
|
|
34
|
+
viewContainerRole
|
|
22
35
|
}) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const {
|
|
37
|
+
// View props
|
|
38
|
+
views,
|
|
39
|
+
view: viewProp,
|
|
40
|
+
openTo,
|
|
41
|
+
onViewChange,
|
|
42
|
+
viewRenderers,
|
|
43
|
+
reduceAnimations: reduceAnimationsProp,
|
|
44
|
+
orientation: orientationProp,
|
|
45
|
+
disableOpenPicker,
|
|
46
|
+
// Form props
|
|
47
|
+
disabled,
|
|
48
|
+
readOnly,
|
|
49
|
+
// Field props
|
|
50
|
+
formatDensity,
|
|
51
|
+
enableAccessibleFieldDOMStructure,
|
|
52
|
+
selectedSections,
|
|
53
|
+
onSelectedSectionsChange,
|
|
54
|
+
format,
|
|
55
|
+
label,
|
|
56
|
+
// Other props
|
|
57
|
+
autoFocus,
|
|
58
|
+
name
|
|
59
|
+
} = props;
|
|
60
|
+
const {
|
|
61
|
+
className,
|
|
62
|
+
sx
|
|
63
|
+
} = props,
|
|
64
|
+
propsToForwardToView = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* TODO: Improve how we generate the aria-label and aria-labelledby attributes.
|
|
68
|
+
*/
|
|
69
|
+
const labelId = (0, _useId.default)();
|
|
70
|
+
const utils = (0, _useUtils.useUtils)();
|
|
71
|
+
const adapter = (0, _useUtils.useLocalizationContext)();
|
|
72
|
+
const reduceAnimations = (0, _useReduceAnimations.useReduceAnimations)(reduceAnimationsProp);
|
|
73
|
+
const orientation = (0, _useOrientation.useOrientation)(views, orientationProp);
|
|
74
|
+
const {
|
|
75
|
+
current: initialView
|
|
76
|
+
} = React.useRef(openTo ?? null);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Refs
|
|
80
|
+
*/
|
|
81
|
+
const triggerRef = React.useRef(null);
|
|
82
|
+
const popupRef = React.useRef(null);
|
|
83
|
+
const fieldRef = React.useRef(null);
|
|
84
|
+
const rootRefObject = React.useRef(null);
|
|
85
|
+
const rootRef = (0, _useForkRef.default)(ref, rootRefObject);
|
|
86
|
+
const {
|
|
87
|
+
timezone,
|
|
88
|
+
state,
|
|
89
|
+
setOpen,
|
|
90
|
+
setValue,
|
|
91
|
+
setValueFromView
|
|
92
|
+
} = (0, _useValueAndOpenStates.useValueAndOpenStates)({
|
|
29
93
|
props,
|
|
30
94
|
valueManager,
|
|
31
|
-
valueType,
|
|
32
95
|
validator
|
|
33
96
|
});
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
97
|
+
const {
|
|
98
|
+
view,
|
|
99
|
+
setView,
|
|
100
|
+
defaultView,
|
|
101
|
+
focusedView,
|
|
102
|
+
setFocusedView,
|
|
103
|
+
setValueAndGoToNextView
|
|
104
|
+
} = (0, _useViews.useViews)({
|
|
105
|
+
view: viewProp,
|
|
106
|
+
views,
|
|
107
|
+
openTo,
|
|
108
|
+
onChange: setValueFromView,
|
|
109
|
+
onViewChange,
|
|
110
|
+
autoFocus: autoFocusView
|
|
40
111
|
});
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
112
|
+
const clearValue = (0, _useEventCallback.default)(() => setValue(valueManager.emptyValue));
|
|
113
|
+
const setValueToToday = (0, _useEventCallback.default)(() => setValue(valueManager.getTodayValue(utils, timezone, valueType)));
|
|
114
|
+
const acceptValueChanges = (0, _useEventCallback.default)(() => setValue(state.lastPublishedValue));
|
|
115
|
+
const cancelValueChanges = (0, _useEventCallback.default)(() => setValue(state.lastCommittedValue, {
|
|
116
|
+
skipPublicationIfPristine: true
|
|
117
|
+
}));
|
|
118
|
+
const dismissViews = (0, _useEventCallback.default)(() => {
|
|
119
|
+
setValue(state.lastPublishedValue, {
|
|
120
|
+
skipPublicationIfPristine: true
|
|
121
|
+
});
|
|
49
122
|
});
|
|
123
|
+
const valueWithoutError = React.useMemo(() => valueManager.cleanValue(utils, state.draft), [utils, valueManager, state.draft]);
|
|
124
|
+
const {
|
|
125
|
+
hasUIView,
|
|
126
|
+
viewModeLookup,
|
|
127
|
+
timeViewsCount
|
|
128
|
+
} = React.useMemo(() => views.reduce((acc, viewForReduce) => {
|
|
129
|
+
const viewMode = viewRenderers[viewForReduce] == null ? 'field' : 'UI';
|
|
130
|
+
acc.viewModeLookup[viewForReduce] = viewMode;
|
|
131
|
+
if (viewMode === 'UI') {
|
|
132
|
+
acc.hasUIView = true;
|
|
133
|
+
if ((0, _timeUtils.isTimeView)(viewForReduce)) {
|
|
134
|
+
acc.timeViewsCount += 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return acc;
|
|
138
|
+
}, {
|
|
139
|
+
hasUIView: false,
|
|
140
|
+
viewModeLookup: {},
|
|
141
|
+
timeViewsCount: 0
|
|
142
|
+
}), [viewRenderers, views]);
|
|
143
|
+
const currentViewMode = viewModeLookup[view];
|
|
144
|
+
const getCurrentViewMode = (0, _useEventCallback.default)(() => currentViewMode);
|
|
145
|
+
const [popperView, setPopperView] = React.useState(currentViewMode === 'UI' ? view : null);
|
|
146
|
+
if (popperView !== view && viewModeLookup[view] === 'UI') {
|
|
147
|
+
setPopperView(view);
|
|
148
|
+
}
|
|
149
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
150
|
+
// Handle case of Date Time Picker without time renderers
|
|
151
|
+
if (currentViewMode === 'field' && state.open) {
|
|
152
|
+
setOpen(false);
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
fieldRef?.current?.setSelectedSections(view);
|
|
155
|
+
// focusing the input before the range selection is done
|
|
156
|
+
// calling it outside of timeout results in an inconsistent behavior between Safari And Chrome
|
|
157
|
+
fieldRef?.current?.focusField(view);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, [view]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
161
|
+
|
|
162
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
163
|
+
if (!state.open) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
let newView = view;
|
|
167
|
+
|
|
168
|
+
// If the current view is a field view, go to the last popper view
|
|
169
|
+
if (currentViewMode === 'field' && popperView != null) {
|
|
170
|
+
newView = popperView;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// If the current view is not the default view and both are UI views
|
|
174
|
+
if (newView !== defaultView && viewModeLookup[newView] === 'UI' && viewModeLookup[defaultView] === 'UI') {
|
|
175
|
+
newView = defaultView;
|
|
176
|
+
}
|
|
177
|
+
if (newView !== view) {
|
|
178
|
+
setView(newView);
|
|
179
|
+
}
|
|
180
|
+
setFocusedView(newView, true);
|
|
181
|
+
}, [state.open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
182
|
+
|
|
183
|
+
const ownerState = React.useMemo(() => ({
|
|
184
|
+
isPickerValueEmpty: valueManager.areValuesEqual(utils, state.draft, valueManager.emptyValue),
|
|
185
|
+
isPickerOpen: state.open,
|
|
186
|
+
isPickerDisabled: props.disabled ?? false,
|
|
187
|
+
isPickerReadOnly: props.readOnly ?? false,
|
|
188
|
+
pickerOrientation: orientation,
|
|
189
|
+
pickerVariant: variant
|
|
190
|
+
}), [utils, valueManager, state.draft, state.open, orientation, variant, props.disabled, props.readOnly]);
|
|
191
|
+
const triggerStatus = React.useMemo(() => {
|
|
192
|
+
if (disableOpenPicker || !hasUIView) {
|
|
193
|
+
return 'hidden';
|
|
194
|
+
}
|
|
195
|
+
if (disabled || readOnly) {
|
|
196
|
+
return 'disabled';
|
|
197
|
+
}
|
|
198
|
+
return 'enabled';
|
|
199
|
+
}, [disableOpenPicker, hasUIView, disabled, readOnly]);
|
|
200
|
+
const actionsContextValue = React.useMemo(() => ({
|
|
201
|
+
setValue,
|
|
202
|
+
setOpen,
|
|
203
|
+
clearValue,
|
|
204
|
+
setValueToToday,
|
|
205
|
+
acceptValueChanges,
|
|
206
|
+
cancelValueChanges,
|
|
207
|
+
setView
|
|
208
|
+
}), [setValue, setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges, setView]);
|
|
209
|
+
const contextValue = React.useMemo(() => (0, _extends2.default)({}, actionsContextValue, {
|
|
210
|
+
value: state.draft,
|
|
211
|
+
timezone,
|
|
212
|
+
open: state.open,
|
|
213
|
+
views,
|
|
214
|
+
view: popperView,
|
|
215
|
+
initialView,
|
|
216
|
+
disabled: disabled ?? false,
|
|
217
|
+
readOnly: readOnly ?? false,
|
|
218
|
+
autoFocus: autoFocus ?? false,
|
|
219
|
+
variant,
|
|
220
|
+
orientation,
|
|
221
|
+
popupRef,
|
|
222
|
+
reduceAnimations,
|
|
223
|
+
triggerRef,
|
|
224
|
+
triggerStatus,
|
|
225
|
+
fieldFormat: format ?? '',
|
|
226
|
+
name,
|
|
227
|
+
label,
|
|
228
|
+
rootSx: sx,
|
|
229
|
+
rootRef,
|
|
230
|
+
rootClassName: className
|
|
231
|
+
}), [actionsContextValue, state.draft, rootRef, variant, orientation, reduceAnimations, disabled, readOnly, format, className, name, label, sx, triggerRef, triggerStatus, timezone, state.open, popperView, views, initialView, autoFocus]);
|
|
232
|
+
const privateContextValue = React.useMemo(() => ({
|
|
233
|
+
dismissViews,
|
|
234
|
+
hasUIView,
|
|
235
|
+
getCurrentViewMode,
|
|
236
|
+
ownerState,
|
|
237
|
+
rootRefObject,
|
|
238
|
+
labelId,
|
|
239
|
+
viewContainerRole
|
|
240
|
+
}), [dismissViews, hasUIView, getCurrentViewMode, ownerState, rootRefObject, labelId, viewContainerRole]);
|
|
241
|
+
const fieldPrivateContextValue = React.useMemo(() => ({
|
|
242
|
+
formatDensity,
|
|
243
|
+
enableAccessibleFieldDOMStructure,
|
|
244
|
+
selectedSections,
|
|
245
|
+
onSelectedSectionsChange,
|
|
246
|
+
fieldRef
|
|
247
|
+
}), [formatDensity, enableAccessibleFieldDOMStructure, selectedSections, onSelectedSectionsChange, fieldRef]);
|
|
248
|
+
const isValidContextValue = testedValue => {
|
|
249
|
+
const error = validator({
|
|
250
|
+
adapter,
|
|
251
|
+
value: testedValue,
|
|
252
|
+
timezone,
|
|
253
|
+
props
|
|
254
|
+
});
|
|
255
|
+
return !valueManager.hasError(error);
|
|
256
|
+
};
|
|
257
|
+
const renderCurrentView = () => {
|
|
258
|
+
if (popperView == null) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const renderer = viewRenderers[popperView];
|
|
262
|
+
if (renderer == null) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
const rendererProps = (0, _extends2.default)({}, propsToForwardToView, {
|
|
266
|
+
views,
|
|
267
|
+
timezone,
|
|
268
|
+
value: valueWithoutError,
|
|
269
|
+
onChange: setValueAndGoToNextView,
|
|
270
|
+
view: popperView,
|
|
271
|
+
onViewChange: setView,
|
|
272
|
+
showViewSwitcher: timeViewsCount > 1,
|
|
273
|
+
timeViewsCount
|
|
274
|
+
}, viewContainerRole === 'tooltip' ? {
|
|
275
|
+
focusedView: null,
|
|
276
|
+
onFocusedViewChange: () => {}
|
|
277
|
+
} : {
|
|
278
|
+
focusedView,
|
|
279
|
+
onFocusedViewChange: setFocusedView
|
|
280
|
+
});
|
|
281
|
+
if (RendererInterceptor) {
|
|
282
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(RendererInterceptor, {
|
|
283
|
+
viewRenderers: viewRenderers,
|
|
284
|
+
popperView: popperView,
|
|
285
|
+
rendererProps: rendererProps
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
return renderer(rendererProps);
|
|
289
|
+
};
|
|
50
290
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
291
|
+
providerProps: {
|
|
292
|
+
localeText,
|
|
293
|
+
contextValue,
|
|
294
|
+
privateContextValue,
|
|
295
|
+
actionsContextValue,
|
|
296
|
+
fieldPrivateContextValue,
|
|
297
|
+
isValidContextValue
|
|
298
|
+
},
|
|
299
|
+
renderCurrentView,
|
|
300
|
+
ownerState
|
|
57
301
|
};
|
|
58
302
|
};
|
|
59
303
|
exports.usePicker = usePicker;
|