UNPKG

@6thquake/react-material

Version:

React components that implement Google's Material Design.

119 lines (101 loc) 2.74 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import withStyles from '../styles/withStyles'; import Slide from '../transitions/Slide'; const styles = theme => ({ root: { width: '100%' }, show: { position: 'relative' }, hide: { position: 'absolute', top: '0px', left: '0px' } }); const negative = direction => { if (direction === 'left') { return 'right'; } return 'left'; }; function StepPane(props) { const { active, children, classes, className: classNameProp, direction, theme, unmountAfterBack } = props, other = _objectWithoutPropertiesLoose(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "disabled", "direction", "theme", "unmountAfterBack"]); const mount = _extends({}, { mountOnEnter: true, unmountOnExit: unmountAfterBack }); const className = classNames(classes.root, classNameProp, active ? classes.show : classes.hide); let _direction; if (direction === 'prev') { _direction = theme.direction === 'rtl' ? 'left' : 'right'; } else { _direction = theme.direction === 'rtl' ? 'right' : 'left'; } return React.createElement(Slide, _extends({ direction: active ? _direction : negative(_direction), in: active }, mount), React.createElement("div", _extends({ className: className }, other), children)); } // process.env.NODE_ENV !== "production" ? StepPane.propTypes = { /** * Sets the step as active. Is passed to child components. */ active: PropTypes.bool, /** * @ignore * Set internally by Stepper when it's supplied with the alternativeLabel property. */ alternativeLabel: PropTypes.bool, /** * Override or extend the styles applied to the component. * See [CSS API](#css-api) below for more details. */ classes: PropTypes.object.isRequired, /** * @ignore */ className: PropTypes.string, /** * Mark the step as completed. Is passed to child components. */ completed: PropTypes.bool, /** * direction */ direction: PropTypes.oneOf(['next', 'prev']), /** * Mark the step as disabled, will also disable the button if * `StepButton` is a child of `Step`. Is passed to child components. */ disabled: PropTypes.bool, /** * @ignore */ unmountAfterBack: PropTypes.bool } : void 0; StepPane.defaultProps = { active: false, completed: false, disabled: false }; export default withStyles(styles, { withTheme: true, name: 'RMStepPane' })(StepPane);