@mui/x-date-pickers
Version:
The community edition of the Date and Time Picker components (MUI X).
50 lines (49 loc) • 2.52 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useDefaultizedTimeField = exports.useDefaultizedDateTimeField = exports.useDefaultizedDateField = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _dateUtils = require("../utils/date-utils");
var _useUtils = require("./useUtils");
const useDefaultizedDateField = props => {
const utils = (0, _useUtils.useUtils)();
const defaultDates = (0, _useUtils.useDefaultDates)();
return (0, _extends2.default)({}, props, {
disablePast: props.disablePast ?? false,
disableFuture: props.disableFuture ?? false,
format: props.format ?? utils.formats.keyboardDate,
minDate: (0, _dateUtils.applyDefaultDate)(utils, props.minDate, defaultDates.minDate),
maxDate: (0, _dateUtils.applyDefaultDate)(utils, props.maxDate, defaultDates.maxDate)
});
};
exports.useDefaultizedDateField = useDefaultizedDateField;
const useDefaultizedTimeField = props => {
const utils = (0, _useUtils.useUtils)();
const ampm = props.ampm ?? utils.is12HourCycleInCurrentLocale();
const defaultFormat = ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h;
return (0, _extends2.default)({}, props, {
disablePast: props.disablePast ?? false,
disableFuture: props.disableFuture ?? false,
format: props.format ?? defaultFormat
});
};
exports.useDefaultizedTimeField = useDefaultizedTimeField;
const useDefaultizedDateTimeField = props => {
const utils = (0, _useUtils.useUtils)();
const defaultDates = (0, _useUtils.useDefaultDates)();
const ampm = props.ampm ?? utils.is12HourCycleInCurrentLocale();
const defaultFormat = ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h;
return (0, _extends2.default)({}, props, {
disablePast: props.disablePast ?? false,
disableFuture: props.disableFuture ?? false,
format: props.format ?? defaultFormat,
disableIgnoringDatePartForTimeValidation: Boolean(props.minDateTime || props.maxDateTime),
minDate: (0, _dateUtils.applyDefaultDate)(utils, props.minDateTime ?? props.minDate, defaultDates.minDate),
maxDate: (0, _dateUtils.applyDefaultDate)(utils, props.maxDateTime ?? props.maxDate, defaultDates.maxDate),
minTime: props.minDateTime ?? props.minTime,
maxTime: props.maxDateTime ?? props.maxTime
});
};
exports.useDefaultizedDateTimeField = useDefaultizedDateTimeField;
;