UNPKG

4.86 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = exports.styles = void 0;
9
10var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
12var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
14var _react = _interopRequireDefault(require("react"));
15
16var _propTypes = _interopRequireDefault(require("prop-types"));
17
18var _clsx = _interopRequireDefault(require("clsx"));
19
20var _Collapse = _interopRequireDefault(require("../Collapse"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var styles = function styles(theme) {
25 return {
26 /* Styles applied to the root element. */
27 root: {
28 marginTop: 8,
29 marginLeft: 12,
30 // half icon
31 paddingLeft: 8 + 12,
32 // margin + half icon
33 paddingRight: 8,
34 borderLeft: "1px solid ".concat(theme.palette.type === 'light' ? theme.palette.grey[400] : theme.palette.grey[600])
35 },
36
37 /* Styles applied to the root element if `last={true}` (controlled by `Step`). */
38 last: {
39 borderLeft: 'none'
40 },
41
42 /* Styles applied to the Transition component. */
43 transition: {}
44 };
45};
46
47exports.styles = styles;
48
49var StepContent = _react.default.forwardRef(function StepContent(props, ref) {
50 var active = props.active,
51 alternativeLabel = props.alternativeLabel,
52 children = props.children,
53 classes = props.classes,
54 className = props.className,
55 completed = props.completed,
56 last = props.last,
57 optional = props.optional,
58 orientation = props.orientation,
59 _props$TransitionComp = props.TransitionComponent,
60 TransitionComponent = _props$TransitionComp === void 0 ? _Collapse.default : _props$TransitionComp,
61 _props$transitionDura = props.transitionDuration,
62 transitionDurationProp = _props$transitionDura === void 0 ? 'auto' : _props$transitionDura,
63 TransitionProps = props.TransitionProps,
64 other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "last", "optional", "orientation", "TransitionComponent", "transitionDuration", "TransitionProps"]);
65
66 if (process.env.NODE_ENV !== 'production') {
67 if (orientation !== 'vertical') {
68 console.error('Material-UI: <StepContent /> is only designed for use with the vertical stepper.');
69 }
70 }
71
72 var transitionDuration = transitionDurationProp;
73
74 if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
75 transitionDuration = undefined;
76 }
77
78 return _react.default.createElement("div", (0, _extends2.default)({
79 className: (0, _clsx.default)(classes.root, className, last && classes.last),
80 ref: ref
81 }, other), _react.default.createElement(TransitionComponent, (0, _extends2.default)({
82 in: active,
83 className: classes.transition,
84 timeout: transitionDuration,
85 unmountOnExit: true
86 }, TransitionProps), children));
87});
88
89process.env.NODE_ENV !== "production" ? StepContent.propTypes = {
90 /**
91 * @ignore
92 * Expands the content.
93 */
94 active: _propTypes.default.bool,
95
96 /**
97 * @ignore
98 * Set internally by Step when it's supplied with the alternativeLabel prop.
99 */
100 alternativeLabel: _propTypes.default.bool,
101
102 /**
103 * Step content.
104 */
105 children: _propTypes.default.node,
106
107 /**
108 * Override or extend the styles applied to the component.
109 * See [CSS API](#css) below for more details.
110 */
111 classes: _propTypes.default.object.isRequired,
112
113 /**
114 * @ignore
115 */
116 className: _propTypes.default.string,
117
118 /**
119 * @ignore
120 */
121 completed: _propTypes.default.bool,
122
123 /**
124 * @ignore
125 */
126 last: _propTypes.default.bool,
127
128 /**
129 * @ignore
130 * Set internally by Step when it's supplied with the optional prop.
131 */
132 optional: _propTypes.default.bool,
133
134 /**
135 * @ignore
136 */
137 orientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
138
139 /**
140 * The component used for the transition.
141 */
142 TransitionComponent: _propTypes.default.elementType,
143
144 /**
145 * Adjust the duration of the content expand transition.
146 * Passed as a prop to the transition component.
147 *
148 * Set to 'auto' to automatically calculate transition time based on height.
149 */
150 transitionDuration: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
151 enter: _propTypes.default.number,
152 exit: _propTypes.default.number
153 }), _propTypes.default.oneOf(['auto'])]),
154
155 /**
156 * Props applied to the `Transition` element.
157 */
158 TransitionProps: _propTypes.default.object
159} : void 0;
160
161var _default = (0, _withStyles.default)(styles, {
162 name: 'MuiStepContent'
163})(StepContent);
164
165exports.default = _default;
\No newline at end of file