UNPKG

4.21 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 _withStyles = _interopRequireDefault(require("../styles/withStyles"));
21
22var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
23
24var _StepLabel = _interopRequireDefault(require("../StepLabel"));
25
26var _isMuiElement = _interopRequireDefault(require("../utils/isMuiElement"));
27
28var styles = {
29 /* Styles applied to the root element. */
30 root: {
31 width: '100%',
32 padding: '24px 16px',
33 margin: '-24px -16px',
34 boxSizing: 'content-box'
35 },
36
37 /* Styles applied to the root element if `orientation="horizontal"`. */
38 horizontal: {},
39
40 /* Styles applied to the root element if `orientation="vertical"`. */
41 vertical: {
42 justifyContent: 'flex-start',
43 padding: '8px',
44 margin: '-8px'
45 },
46
47 /* Styles applied to the `ButtonBase` touch-ripple. */
48 touchRipple: {
49 color: 'rgba(0, 0, 0, 0.3)'
50 }
51};
52exports.styles = styles;
53
54var StepButton = _react.default.forwardRef(function StepButton(props, ref) {
55 var active = props.active,
56 alternativeLabel = props.alternativeLabel,
57 children = props.children,
58 classes = props.classes,
59 className = props.className,
60 completed = props.completed,
61 disabled = props.disabled,
62 icon = props.icon,
63 last = props.last,
64 optional = props.optional,
65 orientation = props.orientation,
66 other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "disabled", "icon", "last", "optional", "orientation"]);
67 var childProps = {
68 active: active,
69 alternativeLabel: alternativeLabel,
70 completed: completed,
71 disabled: disabled,
72 icon: icon,
73 optional: optional,
74 orientation: orientation
75 };
76 var child = (0, _isMuiElement.default)(children, ['StepLabel']) ? _react.default.cloneElement(children, childProps) : _react.default.createElement(_StepLabel.default, childProps, children);
77 return _react.default.createElement(_ButtonBase.default, (0, _extends2.default)({
78 disabled: disabled,
79 TouchRippleProps: {
80 className: classes.touchRipple
81 },
82 className: (0, _clsx.default)(classes.root, classes[orientation], className),
83 ref: ref
84 }, other), child);
85});
86
87process.env.NODE_ENV !== "production" ? StepButton.propTypes = {
88 /**
89 * @ignore
90 * Passed in via `Step` - passed through to `StepLabel`.
91 */
92 active: _propTypes.default.bool,
93
94 /**
95 * @ignore
96 * Set internally by Stepper when it's supplied with the alternativeLabel property.
97 */
98 alternativeLabel: _propTypes.default.bool,
99
100 /**
101 * Can be a `StepLabel` or a node to place inside `StepLabel` as children.
102 */
103 children: _propTypes.default.node,
104
105 /**
106 * Override or extend the styles applied to the component.
107 * See [CSS API](#css) below for more details.
108 */
109 classes: _propTypes.default.object.isRequired,
110
111 /**
112 * @ignore
113 */
114 className: _propTypes.default.string,
115
116 /**
117 * @ignore
118 * Sets completed styling. Is passed to StepLabel.
119 */
120 completed: _propTypes.default.bool,
121
122 /**
123 * @ignore
124 * Disables the button and sets disabled styling. Is passed to StepLabel.
125 */
126 disabled: _propTypes.default.bool,
127
128 /**
129 * The icon displayed by the step label.
130 */
131 icon: _propTypes.default.node,
132
133 /**
134 * @ignore
135 */
136 last: _propTypes.default.bool,
137
138 /**
139 * The optional node to display.
140 */
141 optional: _propTypes.default.node,
142
143 /**
144 * @ignore
145 */
146 orientation: _propTypes.default.oneOf(['horizontal', 'vertical'])
147} : void 0;
148
149var _default = (0, _withStyles.default)(styles, {
150 name: 'MuiStepButton'
151})(StepButton);
152
153exports.default = _default;
\No newline at end of file