UNPKG

3.93 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import Collapse from '../Collapse';
7import withStyles from '../styles/withStyles';
8export const styles = theme => ({
9 /* Styles applied to the root element. */
10 root: {
11 marginTop: 8,
12 marginLeft: 12,
13 // half icon
14 paddingLeft: 8 + 12,
15 // margin + half icon
16 paddingRight: 8,
17 borderLeft: `1px solid ${theme.palette.type === 'light' ? theme.palette.grey[400] : theme.palette.grey[600]}`
18 },
19
20 /* Styles applied to the root element if `last={true}` (controlled by `Step`). */
21 last: {
22 borderLeft: 'none'
23 },
24
25 /* Styles applied to the Transition component. */
26 transition: {}
27});
28const StepContent = /*#__PURE__*/React.forwardRef(function StepContent(props, ref) {
29 const {
30 // eslint-disable-next-line react/prop-types
31 active,
32 children,
33 classes,
34 className,
35 // eslint-disable-next-line react/prop-types
36 expanded,
37 // eslint-disable-next-line react/prop-types
38 last,
39 // eslint-disable-next-line react/prop-types
40 orientation,
41 TransitionComponent = Collapse,
42 transitionDuration: transitionDurationProp = 'auto',
43 TransitionProps
44 } = props,
45 other = _objectWithoutPropertiesLoose(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "expanded", "last", "optional", "orientation", "TransitionComponent", "transitionDuration", "TransitionProps"]);
46
47 if (process.env.NODE_ENV !== 'production') {
48 if (orientation !== 'vertical') {
49 console.error('Material-UI: <StepContent /> is only designed for use with the vertical stepper.');
50 }
51 }
52
53 let transitionDuration = transitionDurationProp;
54
55 if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
56 transitionDuration = undefined;
57 }
58
59 return /*#__PURE__*/React.createElement("div", _extends({
60 className: clsx(classes.root, className, last && classes.last),
61 ref: ref
62 }, other), /*#__PURE__*/React.createElement(TransitionComponent, _extends({
63 in: active || expanded,
64 className: classes.transition,
65 timeout: transitionDuration,
66 unmountOnExit: true
67 }, TransitionProps), children));
68});
69process.env.NODE_ENV !== "production" ? StepContent.propTypes = {
70 // ----------------------------- Warning --------------------------------
71 // | These PropTypes are generated from the TypeScript type definitions |
72 // | To update them edit the d.ts file and run "yarn proptypes" |
73 // ----------------------------------------------------------------------
74
75 /**
76 * Step content.
77 */
78 children: PropTypes.node,
79
80 /**
81 * Override or extend the styles applied to the component.
82 * See [CSS API](#css) below for more details.
83 */
84 classes: PropTypes.object,
85
86 /**
87 * @ignore
88 */
89 className: PropTypes.string,
90
91 /**
92 * The component used for the transition.
93 * [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
94 */
95 TransitionComponent: PropTypes.elementType,
96
97 /**
98 * Adjust the duration of the content expand transition.
99 * Passed as a prop to the transition component.
100 *
101 * Set to 'auto' to automatically calculate transition time based on height.
102 */
103 transitionDuration: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({
104 appear: PropTypes.number,
105 enter: PropTypes.number,
106 exit: PropTypes.number
107 })]),
108
109 /**
110 * Props applied to the [`Transition`](http://reactcommunity.org/react-transition-group/transition#Transition-props) element.
111 */
112 TransitionProps: PropTypes.object
113} : void 0;
114export default withStyles(styles, {
115 name: 'MuiStepContent'
116})(StepContent);
\No newline at end of file