@mui/x-date-pickers
Version:
The community edition of the Date and Time Picker components (MUI X).
51 lines (50 loc) • 1.93 kB
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useTimePickerDefaultizedProps = useTimePickerDefaultizedProps;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
var _styles = require("@mui/material/styles");
var _useUtils = require("../internals/hooks/useUtils");
var _TimePickerToolbar = require("./TimePickerToolbar");
var _views = require("../internals/utils/views");
function useTimePickerDefaultizedProps(props, name) {
const utils = (0, _useUtils.useUtils)();
const themeProps = (0, _styles.useThemeProps)({
props,
name
});
const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
const localeText = React.useMemo(() => {
if (themeProps.localeText?.toolbarTitle == null) {
return themeProps.localeText;
}
return (0, _extends2.default)({}, themeProps.localeText, {
timePickerToolbarTitle: themeProps.localeText.toolbarTitle
});
}, [themeProps.localeText]);
return (0, _extends2.default)({}, themeProps, {
ampm,
localeText
}, (0, _views.applyDefaultViewProps)({
views: themeProps.views,
openTo: themeProps.openTo,
defaultViews: ['hours', 'minutes'],
defaultOpenTo: 'hours'
}), {
disableFuture: themeProps.disableFuture ?? false,
disablePast: themeProps.disablePast ?? false,
slots: (0, _extends2.default)({
toolbar: _TimePickerToolbar.TimePickerToolbar
}, themeProps.slots),
slotProps: (0, _extends2.default)({}, themeProps.slotProps, {
toolbar: (0, _extends2.default)({
ampm,
ampmInClock: themeProps.ampmInClock
}, themeProps.slotProps?.toolbar)
})
});
}
;