UNPKG

5.12 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _reactIs = require("react-is");
19
20var _propTypes = _interopRequireDefault(require("prop-types"));
21
22var _clsx = _interopRequireDefault(require("clsx"));
23
24var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
25
26var styles = {
27 /* Styles applied to the root element. */
28 root: {},
29
30 /* Styles applied to the root element if `orientation="horizontal"`. */
31 horizontal: {
32 paddingLeft: 8,
33 paddingRight: 8
34 },
35
36 /* Styles applied to the root element if `orientation="vertical"`. */
37 vertical: {},
38
39 /* Styles applied to the root element if `alternativeLabel={true}`. */
40 alternativeLabel: {
41 flex: 1,
42 position: 'relative'
43 },
44
45 /* Pseudo-class applied to the root element if `completed={true}`. */
46 completed: {}
47};
48exports.styles = styles;
49var Step = /*#__PURE__*/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 ? /*#__PURE__*/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 = /*#__PURE__*/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 (! /*#__PURE__*/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 /*#__PURE__*/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 /*#__PURE__*/React.createElement(React.Fragment, null, connector, newChildren);
103 }
104
105 return newChildren;
106});
107process.env.NODE_ENV !== "production" ? Step.propTypes = {
108 // ----------------------------- Warning --------------------------------
109 // | These PropTypes are generated from the TypeScript type definitions |
110 // | To update them edit the d.ts file and run "yarn proptypes" |
111 // ----------------------------------------------------------------------
112
113 /**
114 * Sets the step as active. Is passed to child components.
115 */
116 active: _propTypes.default.bool,
117
118 /**
119 * Should be `Step` sub-components such as `StepLabel`, `StepContent`.
120 */
121 children: _propTypes.default.node,
122
123 /**
124 * Override or extend the styles applied to the component.
125 * See [CSS API](#css) below for more details.
126 */
127 classes: _propTypes.default.object,
128
129 /**
130 * @ignore
131 */
132 className: _propTypes.default.string,
133
134 /**
135 * Mark the step as completed. Is passed to child components.
136 */
137 completed: _propTypes.default.bool,
138
139 /**
140 * Mark the step as disabled, will also disable the button if
141 * `StepButton` is a child of `Step`. Is passed to child components.
142 */
143 disabled: _propTypes.default.bool,
144
145 /**
146 * Expand the step.
147 */
148 expanded: _propTypes.default.bool
149} : void 0;
150
151var _default = (0, _withStyles.default)(styles, {
152 name: 'MuiStep'
153})(Step);
154
155exports.default = _default;
\No newline at end of file