@mui/x-date-pickers
Version:
The community edition of the Date and Time Picker components (MUI X).
39 lines • 1.47 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import { useThemeProps } from '@mui/material/styles';
import { useDefaultDates, useUtils } from "../internals/hooks/useUtils.js";
import { applyDefaultViewProps } from "../internals/utils/views.js";
import { applyDefaultDate } from "../internals/utils/date-utils.js";
import { DatePickerToolbar } from "./DatePickerToolbar.js";
export function useDatePickerDefaultizedProps(props, name) {
const utils = useUtils();
const defaultDates = useDefaultDates();
const themeProps = useThemeProps({
props,
name
});
const localeText = React.useMemo(() => {
if (themeProps.localeText?.toolbarTitle == null) {
return themeProps.localeText;
}
return _extends({}, themeProps.localeText, {
datePickerToolbarTitle: themeProps.localeText.toolbarTitle
});
}, [themeProps.localeText]);
return _extends({}, themeProps, {
localeText
}, applyDefaultViewProps({
views: themeProps.views,
openTo: themeProps.openTo,
defaultViews: ['year', 'day'],
defaultOpenTo: 'day'
}), {
disableFuture: themeProps.disableFuture ?? false,
disablePast: themeProps.disablePast ?? false,
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
slots: _extends({
toolbar: DatePickerToolbar
}, themeProps.slots)
});
}