@mui/x-date-pickers
Version:
The community edition of the Date and Time Picker components (MUI X).
63 lines • 2.09 kB
JavaScript
import { warnOnce } from '@mui/x-internals/warning';
import { usePickerValue } from "./usePickerValue.js";
import { usePickerViews } from "./usePickerViews.js";
import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
import { usePickerOwnerState } from "./usePickerOwnerState.js";
export const usePicker = ({
props,
valueManager,
valueType,
wrapperVariant,
additionalViewProps,
validator,
autoFocusView,
rendererInterceptor,
fieldRef
}) => {
if (process.env.NODE_ENV !== 'production') {
if (props.renderInput != null) {
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).']);
}
}
const pickerValueResponse = usePickerValue({
props,
valueManager,
valueType,
wrapperVariant,
validator
});
const pickerViewsResponse = usePickerViews({
props,
additionalViewProps,
autoFocusView,
fieldRef,
propsFromPickerValue: pickerValueResponse.viewProps,
rendererInterceptor
});
const pickerLayoutResponse = usePickerLayoutProps({
props,
wrapperVariant,
propsFromPickerValue: pickerValueResponse.layoutProps,
propsFromPickerViews: pickerViewsResponse.layoutProps
});
const pickerOwnerState = usePickerOwnerState({
props,
pickerValueResponse
});
return {
// Picker value
open: pickerValueResponse.open,
actions: pickerValueResponse.actions,
fieldProps: pickerValueResponse.fieldProps,
// Picker views
renderCurrentView: pickerViewsResponse.renderCurrentView,
hasUIView: pickerViewsResponse.hasUIView,
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
// Picker layout
layoutProps: pickerLayoutResponse.layoutProps,
// Picker context
contextValue: pickerValueResponse.contextValue,
// Picker owner state
ownerState: pickerOwnerState
};
};