UNPKG

2.9 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 Fade from '../Fade';
8export const styles = {
9 /* Styles applied to the root element. */
10 root: {
11 // Improve scrollable dialog support.
12 zIndex: -1,
13 position: 'fixed',
14 display: 'flex',
15 alignItems: 'center',
16 justifyContent: 'center',
17 right: 0,
18 bottom: 0,
19 top: 0,
20 left: 0,
21 backgroundColor: 'rgba(0, 0, 0, 0.5)',
22 WebkitTapHighlightColor: 'transparent'
23 },
24
25 /* Styles applied to the root element if `invisible={true}`. */
26 invisible: {
27 backgroundColor: 'transparent'
28 }
29};
30const Backdrop = /*#__PURE__*/React.forwardRef(function Backdrop(props, ref) {
31 const {
32 children,
33 classes,
34 className,
35 invisible = false,
36 open,
37 transitionDuration,
38 // eslint-disable-next-line react/prop-types
39 TransitionComponent = Fade
40 } = props,
41 other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "invisible", "open", "transitionDuration", "TransitionComponent"]);
42
43 return /*#__PURE__*/React.createElement(TransitionComponent, _extends({
44 in: open,
45 timeout: transitionDuration
46 }, other), /*#__PURE__*/React.createElement("div", {
47 className: clsx(classes.root, className, invisible && classes.invisible),
48 "aria-hidden": true,
49 ref: ref
50 }, children));
51});
52process.env.NODE_ENV !== "production" ? Backdrop.propTypes = {
53 // ----------------------------- Warning --------------------------------
54 // | These PropTypes are generated from the TypeScript type definitions |
55 // | To update them edit the d.ts file and run "yarn proptypes" |
56 // ----------------------------------------------------------------------
57
58 /**
59 * The content of the component.
60 */
61 children: PropTypes.node,
62
63 /**
64 * Override or extend the styles applied to the component.
65 * See [CSS API](#css) below for more details.
66 */
67 classes: PropTypes.object,
68
69 /**
70 * @ignore
71 */
72 className: PropTypes.string,
73
74 /**
75 * If `true`, the backdrop is invisible.
76 * It can be used when rendering a popover or a custom select component.
77 */
78 invisible: PropTypes.bool,
79
80 /**
81 * If `true`, the backdrop is open.
82 */
83 open: PropTypes.bool.isRequired,
84
85 /**
86 * The duration for the transition, in milliseconds.
87 * You may specify a single timeout for all transitions, or individually with an object.
88 */
89 transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
90 appear: PropTypes.number,
91 enter: PropTypes.number,
92 exit: PropTypes.number
93 })])
94} : void 0;
95export default withStyles(styles, {
96 name: 'MuiBackdrop'
97})(Backdrop);
\No newline at end of file