@material-ui/core
Version:
React components that implement Google's Material Design.
96 lines (88 loc) • 3.12 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import Fade from '../Fade';
export var styles = {
/* Styles applied to the root element. */
root: {
// Improve scrollable dialog support.
zIndex: -1,
position: 'fixed',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
right: 0,
bottom: 0,
top: 0,
left: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
WebkitTapHighlightColor: 'transparent'
},
/* Styles applied to the root element if `invisible={true}`. */
invisible: {
backgroundColor: 'transparent'
}
};
var Backdrop = /*#__PURE__*/React.forwardRef(function Backdrop(props, ref) {
var children = props.children,
classes = props.classes,
className = props.className,
_props$invisible = props.invisible,
invisible = _props$invisible === void 0 ? false : _props$invisible,
open = props.open,
transitionDuration = props.transitionDuration,
_props$TransitionComp = props.TransitionComponent,
TransitionComponent = _props$TransitionComp === void 0 ? Fade : _props$TransitionComp,
other = _objectWithoutProperties(props, ["children", "classes", "className", "invisible", "open", "transitionDuration", "TransitionComponent"]);
return /*#__PURE__*/React.createElement(TransitionComponent, _extends({
in: open,
timeout: transitionDuration
}, other), /*#__PURE__*/React.createElement("div", {
className: clsx(classes.root, className, invisible && classes.invisible),
"aria-hidden": true,
ref: ref
}, children));
});
process.env.NODE_ENV !== "production" ? Backdrop.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* The content of the component.
*/
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,
/**
* If `true`, the backdrop is invisible.
* It can be used when rendering a popover or a custom select component.
*/
invisible: PropTypes.bool,
/**
* If `true`, the backdrop is open.
*/
open: PropTypes.bool.isRequired,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
appear: PropTypes.number,
enter: PropTypes.number,
exit: PropTypes.number
})])
} : void 0;
export default withStyles(styles, {
name: 'MuiBackdrop'
})(Backdrop);