UNPKG

3.2 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 capitalize from '../utils/capitalize';
8export const styles = theme => ({
9 /* Styles applied to the root element. */
10 root: {
11 boxSizing: 'border-box',
12 lineHeight: '48px',
13 listStyle: 'none',
14 color: theme.palette.text.secondary,
15 fontFamily: theme.typography.fontFamily,
16 fontWeight: theme.typography.fontWeightMedium,
17 fontSize: theme.typography.pxToRem(14)
18 },
19
20 /* Styles applied to the root element if `color="primary"`. */
21 colorPrimary: {
22 color: theme.palette.primary.main
23 },
24
25 /* Styles applied to the root element if `color="inherit"`. */
26 colorInherit: {
27 color: 'inherit'
28 },
29
30 /* Styles applied to the inner `component` element if `disableGutters={false}`. */
31 gutters: {
32 paddingLeft: 16,
33 paddingRight: 16
34 },
35
36 /* Styles applied to the root element if `inset={true}`. */
37 inset: {
38 paddingLeft: 72
39 },
40
41 /* Styles applied to the root element if `disableSticky={false}`. */
42 sticky: {
43 position: 'sticky',
44 top: 0,
45 zIndex: 1,
46 backgroundColor: 'inherit'
47 }
48});
49const ListSubheader = /*#__PURE__*/React.forwardRef(function ListSubheader(props, ref) {
50 const {
51 classes,
52 className,
53 color = 'default',
54 component: Component = 'li',
55 disableGutters = false,
56 disableSticky = false,
57 inset = false
58 } = props,
59 other = _objectWithoutPropertiesLoose(props, ["classes", "className", "color", "component", "disableGutters", "disableSticky", "inset"]);
60
61 return /*#__PURE__*/React.createElement(Component, _extends({
62 className: clsx(classes.root, className, color !== 'default' && classes[`color${capitalize(color)}`], inset && classes.inset, !disableSticky && classes.sticky, !disableGutters && classes.gutters),
63 ref: ref
64 }, other));
65});
66process.env.NODE_ENV !== "production" ? ListSubheader.propTypes = {
67 /**
68 * The content of the component.
69 */
70 children: PropTypes.node,
71
72 /**
73 * Override or extend the styles applied to the component.
74 * See [CSS API](#css) below for more details.
75 */
76 classes: PropTypes.object.isRequired,
77
78 /**
79 * @ignore
80 */
81 className: PropTypes.string,
82
83 /**
84 * The color of the component. It supports those theme colors that make sense for this component.
85 */
86 color: PropTypes.oneOf(['default', 'primary', 'inherit']),
87
88 /**
89 * The component used for the root node.
90 * Either a string to use a HTML element or a component.
91 */
92 component: PropTypes
93 /* @typescript-to-proptypes-ignore */
94 .elementType,
95
96 /**
97 * If `true`, the List Subheader will not have gutters.
98 */
99 disableGutters: PropTypes.bool,
100
101 /**
102 * If `true`, the List Subheader will not stick to the top during scroll.
103 */
104 disableSticky: PropTypes.bool,
105
106 /**
107 * If `true`, the List Subheader will be indented.
108 */
109 inset: PropTypes.bool
110} : void 0;
111export default withStyles(styles, {
112 name: 'MuiListSubheader'
113})(ListSubheader);
\No newline at end of file