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