@material-ui/core
Version:
React components that implement Google's Material Design.
101 lines (92 loc) • 2.95 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import StepLabel from '../StepLabel';
import isMuiElement from '../utils/isMuiElement';
import StepperContext from '../Stepper/StepperContext';
import StepContext from '../Step/StepContext';
export const styles = {
/* Styles applied to the root element. */
root: {
width: '100%',
padding: '24px 16px',
margin: '-24px -16px',
boxSizing: 'content-box'
},
/* Styles applied to the root element if `orientation="horizontal"`. */
horizontal: {},
/* Styles applied to the root element if `orientation="vertical"`. */
vertical: {
justifyContent: 'flex-start',
padding: '8px',
margin: '-8px'
},
/* Styles applied to the `ButtonBase` touch-ripple. */
touchRipple: {
color: 'rgba(0, 0, 0, 0.3)'
}
};
const StepButton = /*#__PURE__*/React.forwardRef(function StepButton(props, ref) {
const {
children,
classes,
className,
icon,
optional
} = props,
other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "icon", "optional"]);
const {
disabled
} = React.useContext(StepContext);
const {
orientation
} = React.useContext(StepperContext);
const childProps = {
icon,
optional
};
const child = isMuiElement(children, ['StepLabel']) ? /*#__PURE__*/React.cloneElement(children, childProps) : /*#__PURE__*/React.createElement(StepLabel, childProps, children);
return /*#__PURE__*/React.createElement(ButtonBase, _extends({
focusRipple: true,
disabled: disabled,
TouchRippleProps: {
className: classes.touchRipple
},
className: clsx(classes.root, classes[orientation], className),
ref: ref
}, other), child);
});
process.env.NODE_ENV !== "production" ? StepButton.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* Can be a `StepLabel` or a node to place inside `StepLabel` as children.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The icon displayed by the step label.
*/
icon: PropTypes.node,
/**
* The optional node to display.
*/
optional: PropTypes.node
} : void 0;
export default withStyles(styles, {
name: 'MuiStepButton'
})(StepButton);