1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import ListContext from './ListContext';
|
8 | export const styles = {
|
9 |
|
10 | root: {
|
11 | listStyle: 'none',
|
12 | margin: 0,
|
13 | padding: 0,
|
14 | position: 'relative'
|
15 | },
|
16 |
|
17 |
|
18 | padding: {
|
19 | paddingTop: 8,
|
20 | paddingBottom: 8
|
21 | },
|
22 |
|
23 |
|
24 | dense: {},
|
25 |
|
26 |
|
27 | subheader: {
|
28 | paddingTop: 0
|
29 | }
|
30 | };
|
31 | const List = React.forwardRef(function List(props, ref) {
|
32 | const {
|
33 | children,
|
34 | classes,
|
35 | className,
|
36 | component: Component = 'ul',
|
37 | dense = false,
|
38 | disablePadding = false,
|
39 | subheader
|
40 | } = props,
|
41 | other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "component", "dense", "disablePadding", "subheader"]);
|
42 |
|
43 | const context = React.useMemo(() => ({
|
44 | dense
|
45 | }), [dense]);
|
46 | return React.createElement(ListContext.Provider, {
|
47 | value: context
|
48 | }, React.createElement(Component, _extends({
|
49 | className: clsx(classes.root, className, dense && classes.dense, !disablePadding && classes.padding, subheader && classes.subheader),
|
50 | ref: ref
|
51 | }, other), subheader, children));
|
52 | });
|
53 | process.env.NODE_ENV !== "production" ? List.propTypes = {
|
54 | |
55 |
|
56 |
|
57 | children: PropTypes.node,
|
58 |
|
59 | |
60 |
|
61 |
|
62 |
|
63 | classes: PropTypes.object.isRequired,
|
64 |
|
65 | |
66 |
|
67 |
|
68 | className: PropTypes.string,
|
69 |
|
70 | |
71 |
|
72 |
|
73 |
|
74 | component: PropTypes
|
75 |
|
76 | .elementType,
|
77 |
|
78 | |
79 |
|
80 |
|
81 |
|
82 |
|
83 | dense: PropTypes.bool,
|
84 |
|
85 | |
86 |
|
87 |
|
88 | disablePadding: PropTypes.bool,
|
89 |
|
90 | |
91 |
|
92 |
|
93 | subheader: PropTypes.node
|
94 | } : void 0;
|
95 | export default withStyles(styles, {
|
96 | name: 'MuiList'
|
97 | })(List); |
\ | No newline at end of file |