UNPKG

4.8 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 _reactIs = require("react-is");
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var styles = {
25 /* Styles applied to the root element. */
26 root: {},
27
28 /* Styles applied to the root element if `orientation="horizontal"`. */
29 horizontal: {
30 paddingLeft: 8,
31 paddingRight: 8
32 },
33
34 /* Styles applied to the root element if `orientation="vertical"`. */
35 vertical: {},
36
37 /* Styles applied to the root element if `alternativeLabel={true}`. */
38 alternativeLabel: {
39 flex: 1,
40 position: 'relative'
41 },
42
43 /* Pseudo-class applied to the root element if `completed={true}`. */
44 completed: {}
45};
46exports.styles = styles;
47
48var Step = _react.default.forwardRef(function Step(props, ref) {
49 var _props$active = props.active,
50 active = _props$active === void 0 ? false : _props$active,
51 alternativeLabel = props.alternativeLabel,
52 children = props.children,
53 classes = props.classes,
54 className = props.className,
55 _props$completed = props.completed,
56 completed = _props$completed === void 0 ? false : _props$completed,
57 connector = props.connector,
58 _props$disabled = props.disabled,
59 disabled = _props$disabled === void 0 ? false : _props$disabled,
60 index = props.index,
61 last = props.last,
62 orientation = props.orientation,
63 other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "connector", "disabled", "index", "last", "orientation"]);
64 return _react.default.createElement("div", (0, _extends2.default)({
65 className: (0, _clsx.default)(classes.root, classes[orientation], className, alternativeLabel && classes.alternativeLabel, completed && classes.completed),
66 ref: ref
67 }, other), connector && alternativeLabel && index !== 0 && _react.default.cloneElement(connector, {
68 orientation: orientation,
69 alternativeLabel: alternativeLabel,
70 index: index,
71 active: active,
72 completed: completed,
73 disabled: disabled
74 }), _react.default.Children.map(children, function (child) {
75 if (!_react.default.isValidElement(child)) {
76 return null;
77 }
78
79 if (process.env.NODE_ENV !== 'production') {
80 if ((0, _reactIs.isFragment)(child)) {
81 console.error(["Material-UI: the Step component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
82 }
83 }
84
85 return _react.default.cloneElement(child, (0, _extends2.default)({
86 active: active,
87 alternativeLabel: alternativeLabel,
88 completed: completed,
89 disabled: disabled,
90 last: last,
91 icon: index + 1,
92 orientation: orientation
93 }, child.props));
94 }));
95});
96
97process.env.NODE_ENV !== "production" ? Step.propTypes = {
98 /**
99 * Sets the step as active. Is passed to child components.
100 */
101 active: _propTypes.default.bool,
102
103 /**
104 * @ignore
105 * Set internally by Stepper when it's supplied with the alternativeLabel property.
106 */
107 alternativeLabel: _propTypes.default.bool,
108
109 /**
110 * Should be `Step` sub-components such as `StepLabel`, `StepContent`.
111 */
112 children: _propTypes.default.node,
113
114 /**
115 * Override or extend the styles applied to the component.
116 * See [CSS API](#css) below for more details.
117 */
118 classes: _propTypes.default.object.isRequired,
119
120 /**
121 * @ignore
122 */
123 className: _propTypes.default.string,
124
125 /**
126 * Mark the step as completed. Is passed to child components.
127 */
128 completed: _propTypes.default.bool,
129
130 /**
131 * @ignore
132 * Passed down from Stepper if alternativeLabel is also set.
133 */
134 connector: _propTypes.default.element,
135
136 /**
137 * Mark the step as disabled, will also disable the button if
138 * `StepButton` is a child of `Step`. Is passed to child components.
139 */
140 disabled: _propTypes.default.bool,
141
142 /**
143 * @ignore
144 * Used internally for numbering.
145 */
146 index: _propTypes.default.number,
147
148 /**
149 * @ignore
150 */
151 last: _propTypes.default.bool,
152
153 /**
154 * @ignore
155 */
156 orientation: _propTypes.default.oneOf(['horizontal', 'vertical'])
157} : void 0;
158
159var _default = (0, _withStyles.default)(styles, {
160 name: 'MuiStep'
161})(Step);
162
163exports.default = _default;
\No newline at end of file