1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _reactIs = require("react-is");
|
19 |
|
20 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
21 |
|
22 | var _clsx = _interopRequireDefault(require("clsx"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var styles = {
|
27 |
|
28 | root: {},
|
29 |
|
30 |
|
31 | horizontal: {
|
32 | paddingLeft: 8,
|
33 | paddingRight: 8
|
34 | },
|
35 |
|
36 |
|
37 | vertical: {},
|
38 |
|
39 |
|
40 | alternativeLabel: {
|
41 | flex: 1,
|
42 | position: 'relative'
|
43 | },
|
44 |
|
45 |
|
46 | completed: {}
|
47 | };
|
48 | exports.styles = styles;
|
49 | var Step = React.forwardRef(function Step(props, ref) {
|
50 | var _props$active = props.active,
|
51 | active = _props$active === void 0 ? false : _props$active,
|
52 | alternativeLabel = props.alternativeLabel,
|
53 | children = props.children,
|
54 | classes = props.classes,
|
55 | className = props.className,
|
56 | _props$completed = props.completed,
|
57 | completed = _props$completed === void 0 ? false : _props$completed,
|
58 | connectorProp = props.connector,
|
59 | _props$disabled = props.disabled,
|
60 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
61 | _props$expanded = props.expanded,
|
62 | expanded = _props$expanded === void 0 ? false : _props$expanded,
|
63 | index = props.index,
|
64 | last = props.last,
|
65 | orientation = props.orientation,
|
66 | other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "connector", "disabled", "expanded", "index", "last", "orientation"]);
|
67 | var connector = connectorProp ? React.cloneElement(connectorProp, {
|
68 | orientation: orientation,
|
69 | alternativeLabel: alternativeLabel,
|
70 | index: index,
|
71 | active: active,
|
72 | completed: completed,
|
73 | disabled: disabled
|
74 | }) : null;
|
75 | var newChildren = React.createElement("div", (0, _extends2.default)({
|
76 | className: (0, _clsx.default)(classes.root, classes[orientation], className, alternativeLabel && classes.alternativeLabel, completed && classes.completed),
|
77 | ref: ref
|
78 | }, other), connector && alternativeLabel && index !== 0 ? connector : null, React.Children.map(children, function (child) {
|
79 | if (! React.isValidElement(child)) {
|
80 | return null;
|
81 | }
|
82 |
|
83 | if (process.env.NODE_ENV !== 'production') {
|
84 | if ((0, _reactIs.isFragment)(child)) {
|
85 | console.error(["Material-UI: The Step component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
86 | }
|
87 | }
|
88 |
|
89 | return React.cloneElement(child, (0, _extends2.default)({
|
90 | active: active,
|
91 | alternativeLabel: alternativeLabel,
|
92 | completed: completed,
|
93 | disabled: disabled,
|
94 | expanded: expanded,
|
95 | last: last,
|
96 | icon: index + 1,
|
97 | orientation: orientation
|
98 | }, child.props));
|
99 | }));
|
100 |
|
101 | if (connector && !alternativeLabel && index !== 0) {
|
102 | return React.createElement(React.Fragment, null, connector, newChildren);
|
103 | }
|
104 |
|
105 | return newChildren;
|
106 | });
|
107 | process.env.NODE_ENV !== "production" ? Step.propTypes = {
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | |
114 |
|
115 |
|
116 | active: _propTypes.default.bool,
|
117 |
|
118 | |
119 |
|
120 |
|
121 | children: _propTypes.default.node,
|
122 |
|
123 | |
124 |
|
125 |
|
126 |
|
127 | classes: _propTypes.default.object,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | className: _propTypes.default.string,
|
133 |
|
134 | |
135 |
|
136 |
|
137 | completed: _propTypes.default.bool,
|
138 |
|
139 | |
140 |
|
141 |
|
142 |
|
143 | disabled: _propTypes.default.bool,
|
144 |
|
145 | |
146 |
|
147 |
|
148 | expanded: _propTypes.default.bool
|
149 | } : void 0;
|
150 |
|
151 | var _default = (0, _withStyles.default)(styles, {
|
152 | name: 'MuiStep'
|
153 | })(Step);
|
154 |
|
155 | exports.default = _default; |
\ | No newline at end of file |