UNPKG

@mui/x-date-pickers

Version:

The community edition of the Date and Time Picker components (MUI X).

143 lines (141 loc) 5.42 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.PickersSlideTransition = PickersSlideTransition; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); var React = _interopRequireWildcard(require("react")); var _clsx = _interopRequireDefault(require("clsx")); var _styles = require("@mui/material/styles"); var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses")); var _reactTransitionGroup = require("react-transition-group"); var _pickersSlideTransitionClasses = require("./pickersSlideTransitionClasses"); var _jsxRuntime = require("react/jsx-runtime"); const _excluded = ["children", "className", "reduceAnimations", "slideDirection", "transKey", "classes"]; const useUtilityClasses = ownerState => { const { classes, slideDirection } = ownerState; const slots = { root: ['root'], exit: ['slideExit'], enterActive: ['slideEnterActive'], enter: [`slideEnter-${slideDirection}`], exitActive: [`slideExitActiveLeft-${slideDirection}`] }; return (0, _composeClasses.default)(slots, _pickersSlideTransitionClasses.getPickersSlideTransitionUtilityClass, classes); }; const PickersSlideTransitionRoot = (0, _styles.styled)(_reactTransitionGroup.TransitionGroup, { name: 'MuiPickersSlideTransition', slot: 'Root', overridesResolver: (_, styles) => [styles.root, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideEnter-left']}`]: styles['slideEnter-left'] }, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideEnter-right']}`]: styles['slideEnter-right'] }, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses.slideEnterActive}`]: styles.slideEnterActive }, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses.slideExit}`]: styles.slideExit }, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideExitActiveLeft-left']}`]: styles['slideExitActiveLeft-left'] }, { [`.${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideExitActiveLeft-right']}`]: styles['slideExitActiveLeft-right'] }] })(({ theme }) => { const slideTransition = theme.transitions.create('transform', { duration: theme.transitions.duration.complex, easing: 'cubic-bezier(0.35, 0.8, 0.4, 1)' }); return { display: 'block', position: 'relative', overflowX: 'hidden', '& > *': { position: 'absolute', top: 0, right: 0, left: 0 }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideEnter-left']}`]: { willChange: 'transform', transform: 'translate(100%)', zIndex: 1 }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideEnter-right']}`]: { willChange: 'transform', transform: 'translate(-100%)', zIndex: 1 }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses.slideEnterActive}`]: { transform: 'translate(0%)', transition: slideTransition }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses.slideExit}`]: { transform: 'translate(0%)' }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideExitActiveLeft-left']}`]: { willChange: 'transform', transform: 'translate(-100%)', transition: slideTransition, zIndex: 0 }, [`& .${_pickersSlideTransitionClasses.pickersSlideTransitionClasses['slideExitActiveLeft-right']}`]: { willChange: 'transform', transform: 'translate(100%)', transition: slideTransition, zIndex: 0 } }; }); /** * @ignore - do not document. */ function PickersSlideTransition(inProps) { const props = (0, _styles.useThemeProps)({ props: inProps, name: 'MuiPickersSlideTransition' }); const { children, className, reduceAnimations, transKey // extracting `classes` from `other` } = props, other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded); const classes = useUtilityClasses(props); const theme = (0, _styles.useTheme)(); if (reduceAnimations) { return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: (0, _clsx.default)(classes.root, className), children: children }); } const transitionClasses = { exit: classes.exit, enterActive: classes.enterActive, enter: classes.enter, exitActive: classes.exitActive }; return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersSlideTransitionRoot, { className: (0, _clsx.default)(classes.root, className), childFactory: element => /*#__PURE__*/React.cloneElement(element, { classNames: transitionClasses }), role: "presentation", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.CSSTransition, (0, _extends2.default)({ mountOnEnter: true, unmountOnExit: true, timeout: theme.transitions.duration.complex, classNames: transitionClasses }, other, { children: children }), transKey) }); }