1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _reactIs = require("react-is");
|
19 |
|
20 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
21 |
|
22 | var _clsx = _interopRequireDefault(require("clsx"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var styles = {
|
27 |
|
28 | root: {
|
29 | display: 'flex',
|
30 | flexWrap: 'wrap',
|
31 | overflowY: 'auto',
|
32 | listStyle: 'none',
|
33 | padding: 0,
|
34 | WebkitOverflowScrolling: 'touch'
|
35 |
|
36 | }
|
37 | };
|
38 | exports.styles = styles;
|
39 | var GridList = React.forwardRef(function GridList(props, ref) {
|
40 | var _props$cellHeight = props.cellHeight,
|
41 | cellHeight = _props$cellHeight === void 0 ? 180 : _props$cellHeight,
|
42 | children = props.children,
|
43 | classes = props.classes,
|
44 | className = props.className,
|
45 | _props$cols = props.cols,
|
46 | cols = _props$cols === void 0 ? 2 : _props$cols,
|
47 | _props$component = props.component,
|
48 | Component = _props$component === void 0 ? 'ul' : _props$component,
|
49 | _props$spacing = props.spacing,
|
50 | spacing = _props$spacing === void 0 ? 4 : _props$spacing,
|
51 | style = props.style,
|
52 | other = (0, _objectWithoutProperties2.default)(props, ["cellHeight", "children", "classes", "className", "cols", "component", "spacing", "style"]);
|
53 | return React.createElement(Component, (0, _extends2.default)({
|
54 | className: (0, _clsx.default)(classes.root, className),
|
55 | ref: ref,
|
56 | style: (0, _extends2.default)({
|
57 | margin: -spacing / 2
|
58 | }, style)
|
59 | }, other), React.Children.map(children, function (child) {
|
60 | if (! React.isValidElement(child)) {
|
61 | return null;
|
62 | }
|
63 |
|
64 | if (process.env.NODE_ENV !== 'production') {
|
65 | if ((0, _reactIs.isFragment)(child)) {
|
66 | console.error(["Material-UI: The GridList component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
67 | }
|
68 | }
|
69 |
|
70 | var childCols = child.props.cols || 1;
|
71 | var childRows = child.props.rows || 1;
|
72 | return React.cloneElement(child, {
|
73 | style: (0, _extends2.default)({
|
74 | width: "".concat(100 / cols * childCols, "%"),
|
75 | height: cellHeight === 'auto' ? 'auto' : cellHeight * childRows + spacing,
|
76 | padding: spacing / 2
|
77 | }, child.props.style)
|
78 | });
|
79 | }));
|
80 | });
|
81 | process.env.NODE_ENV !== "production" ? GridList.propTypes = {
|
82 | |
83 |
|
84 |
|
85 |
|
86 | cellHeight: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.oneOf(['auto'])]),
|
87 |
|
88 | |
89 |
|
90 |
|
91 | children: _propTypes.default.node.isRequired,
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 | classes: _propTypes.default.object.isRequired,
|
98 |
|
99 | |
100 |
|
101 |
|
102 | className: _propTypes.default.string,
|
103 |
|
104 | |
105 |
|
106 |
|
107 | cols: _propTypes.default.number,
|
108 |
|
109 | |
110 |
|
111 |
|
112 |
|
113 | component: _propTypes.default
|
114 |
|
115 | .elementType,
|
116 |
|
117 | |
118 |
|
119 |
|
120 | spacing: _propTypes.default.number,
|
121 |
|
122 | |
123 |
|
124 |
|
125 | style: _propTypes.default.object
|
126 | } : void 0;
|
127 |
|
128 | var _default = (0, _withStyles.default)(styles, {
|
129 | name: 'MuiGridList'
|
130 | })(GridList);
|
131 |
|
132 | exports.default = _default; |
\ | No newline at end of file |