UNPKG

4.3 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = exports.styles = void 0;
9
10var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
12var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
14var _react = _interopRequireDefault(require("react"));
15
16var _propTypes = _interopRequireDefault(require("prop-types"));
17
18var _clsx = _interopRequireDefault(require("clsx"));
19
20var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
21
22var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
23
24var styles = function styles(theme) {
25 return {
26 /* Styles applied to the root element. */
27 root: {
28 boxSizing: 'border-box',
29 lineHeight: '48px',
30 listStyle: 'none',
31 color: theme.palette.text.secondary,
32 fontFamily: theme.typography.fontFamily,
33 fontWeight: theme.typography.fontWeightMedium,
34 fontSize: theme.typography.pxToRem(14)
35 },
36
37 /* Styles applied to the root element if `color="primary"`. */
38 colorPrimary: {
39 color: theme.palette.primary.main
40 },
41
42 /* Styles applied to the root element if `color="inherit"`. */
43 colorInherit: {
44 color: 'inherit'
45 },
46
47 /* Styles applied to the inner `component` element if `disableGutters={false}`. */
48 gutters: {
49 paddingLeft: 16,
50 paddingRight: 16
51 },
52
53 /* Styles applied to the root element if `inset={true}`. */
54 inset: {
55 paddingLeft: 72
56 },
57
58 /* Styles applied to the root element if `disableSticky={false}`. */
59 sticky: {
60 position: 'sticky',
61 top: 0,
62 zIndex: 1,
63 backgroundColor: 'inherit'
64 }
65 };
66};
67
68exports.styles = styles;
69
70var ListSubheader = _react.default.forwardRef(function ListSubheader(props, ref) {
71 var classes = props.classes,
72 className = props.className,
73 _props$color = props.color,
74 color = _props$color === void 0 ? 'default' : _props$color,
75 _props$component = props.component,
76 Component = _props$component === void 0 ? 'li' : _props$component,
77 _props$disableGutters = props.disableGutters,
78 disableGutters = _props$disableGutters === void 0 ? false : _props$disableGutters,
79 _props$disableSticky = props.disableSticky,
80 disableSticky = _props$disableSticky === void 0 ? false : _props$disableSticky,
81 _props$inset = props.inset,
82 inset = _props$inset === void 0 ? false : _props$inset,
83 other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "color", "component", "disableGutters", "disableSticky", "inset"]);
84 return _react.default.createElement(Component, (0, _extends2.default)({
85 className: (0, _clsx.default)(classes.root, className, color !== 'default' && classes["color".concat((0, _capitalize.default)(color))], inset && classes.inset, !disableSticky && classes.sticky, !disableGutters && classes.gutters),
86 ref: ref
87 }, other));
88});
89
90process.env.NODE_ENV !== "production" ? ListSubheader.propTypes = {
91 /**
92 * The content of the component.
93 */
94 children: _propTypes.default.node,
95
96 /**
97 * Override or extend the styles applied to the component.
98 * See [CSS API](#css) below for more details.
99 */
100 classes: _propTypes.default.object.isRequired,
101
102 /**
103 * @ignore
104 */
105 className: _propTypes.default.string,
106
107 /**
108 * The color of the component. It supports those theme colors that make sense for this component.
109 */
110 color: _propTypes.default.oneOf(['default', 'primary', 'inherit']),
111
112 /**
113 * The component used for the root node.
114 * Either a string to use a DOM element or a component.
115 */
116 component: _propTypes.default.elementType,
117
118 /**
119 * If `true`, the List Subheader will not have gutters.
120 */
121 disableGutters: _propTypes.default.bool,
122
123 /**
124 * If `true`, the List Subheader will not stick to the top during scroll.
125 */
126 disableSticky: _propTypes.default.bool,
127
128 /**
129 * If `true`, the List Subheader will be indented.
130 */
131 inset: _propTypes.default.bool
132} : void 0;
133
134var _default = (0, _withStyles.default)(styles, {
135 name: 'MuiListSubheader'
136})(ListSubheader);
137
138exports.default = _default;
\No newline at end of file