UNPKG

3.41 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import withStyles from '../styles/withStyles';
7import ButtonBase from '../ButtonBase';
8import StepLabel from '../StepLabel';
9import isMuiElement from '../utils/isMuiElement';
10export const styles = {
11 /* Styles applied to the root element. */
12 root: {
13 width: '100%',
14 padding: '24px 16px',
15 margin: '-24px -16px',
16 boxSizing: 'content-box'
17 },
18
19 /* Styles applied to the root element if `orientation="horizontal"`. */
20 horizontal: {},
21
22 /* Styles applied to the root element if `orientation="vertical"`. */
23 vertical: {
24 justifyContent: 'flex-start',
25 padding: '8px',
26 margin: '-8px'
27 },
28
29 /* Styles applied to the `ButtonBase` touch-ripple. */
30 touchRipple: {
31 color: 'rgba(0, 0, 0, 0.3)'
32 }
33};
34const StepButton = /*#__PURE__*/React.forwardRef(function StepButton(props, ref) {
35 const {
36 active,
37 alternativeLabel,
38 children,
39 classes,
40 className,
41 completed,
42 disabled,
43 icon,
44 optional,
45 orientation
46 } = props,
47 other = _objectWithoutPropertiesLoose(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "disabled", "expanded", "icon", "last", "optional", "orientation"]);
48
49 const childProps = {
50 active,
51 alternativeLabel,
52 completed,
53 disabled,
54 icon,
55 optional,
56 orientation
57 };
58 const child = isMuiElement(children, ['StepLabel']) ? /*#__PURE__*/React.cloneElement(children, childProps) : /*#__PURE__*/React.createElement(StepLabel, childProps, children);
59 return /*#__PURE__*/React.createElement(ButtonBase, _extends({
60 focusRipple: true,
61 disabled: disabled,
62 TouchRippleProps: {
63 className: classes.touchRipple
64 },
65 className: clsx(classes.root, classes[orientation], className),
66 ref: ref
67 }, other), child);
68});
69process.env.NODE_ENV !== "production" ? StepButton.propTypes = {
70 /**
71 * @ignore
72 * Passed in via `Step` - passed through to `StepLabel`.
73 */
74 active: PropTypes.bool,
75
76 /**
77 * @ignore
78 * Set internally by Stepper when it's supplied with the alternativeLabel property.
79 */
80 alternativeLabel: PropTypes.bool,
81
82 /**
83 * Can be a `StepLabel` or a node to place inside `StepLabel` as children.
84 */
85 children: PropTypes.node,
86
87 /**
88 * Override or extend the styles applied to the component.
89 * See [CSS API](#css) below for more details.
90 */
91 classes: PropTypes.object.isRequired,
92
93 /**
94 * @ignore
95 */
96 className: PropTypes.string,
97
98 /**
99 * @ignore
100 * Sets completed styling. Is passed to StepLabel.
101 */
102 completed: PropTypes.bool,
103
104 /**
105 * @ignore
106 * Disables the button and sets disabled styling. Is passed to StepLabel.
107 */
108 disabled: PropTypes.bool,
109
110 /**
111 * @ignore
112 * potentially passed from parent `Step`
113 */
114 expanded: PropTypes.bool,
115
116 /**
117 * The icon displayed by the step label.
118 */
119 icon: PropTypes.node,
120
121 /**
122 * @ignore
123 */
124 last: PropTypes.bool,
125
126 /**
127 * The optional node to display.
128 */
129 optional: PropTypes.node,
130
131 /**
132 * @ignore
133 */
134 orientation: PropTypes.oneOf(['horizontal', 'vertical'])
135} : void 0;
136export default withStyles(styles, {
137 name: 'MuiStepButton'
138})(StepButton);
\No newline at end of file