1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import { chainPropTypes } from '@material-ui/utils';
|
7 | import withStyles from '../styles/withStyles';
|
8 | export const styles = theme => {
|
9 | const elevations = {};
|
10 | theme.shadows.forEach((shadow, index) => {
|
11 | elevations[`elevation${index}`] = {
|
12 | boxShadow: shadow
|
13 | };
|
14 | });
|
15 | return _extends({
|
16 |
|
17 | root: {
|
18 | backgroundColor: theme.palette.background.paper,
|
19 | color: theme.palette.text.primary,
|
20 | transition: theme.transitions.create('box-shadow')
|
21 | },
|
22 |
|
23 |
|
24 | rounded: {
|
25 | borderRadius: theme.shape.borderRadius
|
26 | },
|
27 |
|
28 |
|
29 | outlined: {
|
30 | border: `1px solid ${theme.palette.divider}`
|
31 | }
|
32 | }, elevations);
|
33 | };
|
34 | const Paper = React.forwardRef(function Paper(props, ref) {
|
35 | const {
|
36 | classes,
|
37 | className,
|
38 | component: Component = 'div',
|
39 | square = false,
|
40 | elevation = 1,
|
41 | variant = 'elevation'
|
42 | } = props,
|
43 | other = _objectWithoutPropertiesLoose(props, ["classes", "className", "component", "square", "elevation", "variant"]);
|
44 |
|
45 | return React.createElement(Component, _extends({
|
46 | className: clsx(classes.root, className, variant === 'outlined' ? classes.outlined : classes[`elevation${elevation}`], !square && classes.rounded),
|
47 | ref: ref
|
48 | }, other));
|
49 | });
|
50 | process.env.NODE_ENV !== "production" ? Paper.propTypes = {
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | |
57 |
|
58 |
|
59 | children: PropTypes.node,
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 | classes: PropTypes.object,
|
66 |
|
67 | |
68 |
|
69 |
|
70 | className: PropTypes.string,
|
71 |
|
72 | |
73 |
|
74 |
|
75 |
|
76 | component: PropTypes
|
77 |
|
78 | .elementType,
|
79 |
|
80 | |
81 |
|
82 |
|
83 |
|
84 | elevation: chainPropTypes(PropTypes.number, props => {
|
85 | const {
|
86 | classes,
|
87 | elevation
|
88 | } = props;
|
89 |
|
90 | if (classes === undefined) {
|
91 | return null;
|
92 | }
|
93 |
|
94 | if (elevation != null && classes[`elevation${elevation}`] === undefined) {
|
95 | return new Error(`Material-UI: This elevation \`${elevation}\` is not implemented.`);
|
96 | }
|
97 |
|
98 | return null;
|
99 | }),
|
100 |
|
101 | |
102 |
|
103 |
|
104 | square: PropTypes.bool,
|
105 |
|
106 | |
107 |
|
108 |
|
109 | variant: PropTypes.oneOf(['elevation', 'outlined'])
|
110 | } : void 0;
|
111 | export default withStyles(styles, {
|
112 | name: 'MuiPaper'
|
113 | })(Paper); |
\ | No newline at end of file |