1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | const _excluded = ["className", "color", "component", "disableGutters", "disableSticky", "inset"];
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import clsx from 'clsx';
|
7 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
8 | import styled from '../styles/styled';
|
9 | import useThemeProps from '../styles/useThemeProps';
|
10 | import capitalize from '../utils/capitalize';
|
11 | import { getListSubheaderUtilityClass } from './listSubheaderClasses';
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 |
|
14 | const useUtilityClasses = ownerState => {
|
15 | const {
|
16 | classes,
|
17 | color,
|
18 | disableGutters,
|
19 | inset,
|
20 | disableSticky
|
21 | } = ownerState;
|
22 | const slots = {
|
23 | root: ['root', color !== 'default' && `color${capitalize(color)}`, !disableGutters && 'gutters', inset && 'inset', !disableSticky && 'sticky']
|
24 | };
|
25 | return composeClasses(slots, getListSubheaderUtilityClass, classes);
|
26 | };
|
27 |
|
28 | const ListSubheaderRoot = styled('li', {
|
29 | name: 'MuiListSubheader',
|
30 | slot: 'Root',
|
31 | overridesResolver: (props, styles) => {
|
32 | const {
|
33 | ownerState
|
34 | } = props;
|
35 | return [styles.root, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], !ownerState.disableGutters && styles.gutters, ownerState.inset && styles.inset, !ownerState.disableSticky && styles.sticky];
|
36 | }
|
37 | })(({
|
38 | theme,
|
39 | ownerState
|
40 | }) => _extends({
|
41 | boxSizing: 'border-box',
|
42 | lineHeight: '48px',
|
43 | listStyle: 'none',
|
44 | color: (theme.vars || theme).palette.text.secondary,
|
45 | fontFamily: theme.typography.fontFamily,
|
46 | fontWeight: theme.typography.fontWeightMedium,
|
47 | fontSize: theme.typography.pxToRem(14)
|
48 | }, ownerState.color === 'primary' && {
|
49 | color: (theme.vars || theme).palette.primary.main
|
50 | }, ownerState.color === 'inherit' && {
|
51 | color: 'inherit'
|
52 | }, !ownerState.disableGutters && {
|
53 | paddingLeft: 16,
|
54 | paddingRight: 16
|
55 | }, ownerState.inset && {
|
56 | paddingLeft: 72
|
57 | }, !ownerState.disableSticky && {
|
58 | position: 'sticky',
|
59 | top: 0,
|
60 | zIndex: 1,
|
61 | backgroundColor: (theme.vars || theme).palette.background.paper
|
62 | }));
|
63 | const ListSubheader = React.forwardRef(function ListSubheader(inProps, ref) {
|
64 | const props = useThemeProps({
|
65 | props: inProps,
|
66 | name: 'MuiListSubheader'
|
67 | });
|
68 |
|
69 | const {
|
70 | className,
|
71 | color = 'default',
|
72 | component = 'li',
|
73 | disableGutters = false,
|
74 | disableSticky = false,
|
75 | inset = false
|
76 | } = props,
|
77 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
78 |
|
79 | const ownerState = _extends({}, props, {
|
80 | color,
|
81 | component,
|
82 | disableGutters,
|
83 | disableSticky,
|
84 | inset
|
85 | });
|
86 |
|
87 | const classes = useUtilityClasses(ownerState);
|
88 | return _jsx(ListSubheaderRoot, _extends({
|
89 | as: component,
|
90 | className: clsx(classes.root, className),
|
91 | ref: ref,
|
92 | ownerState: ownerState
|
93 | }, other));
|
94 | });
|
95 | process.env.NODE_ENV !== "production" ? ListSubheader.propTypes
|
96 |
|
97 | = {
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | |
104 |
|
105 |
|
106 | children: PropTypes.node,
|
107 |
|
108 | |
109 |
|
110 |
|
111 | classes: PropTypes.object,
|
112 |
|
113 | |
114 |
|
115 |
|
116 | className: PropTypes.string,
|
117 |
|
118 | |
119 |
|
120 |
|
121 |
|
122 | color: PropTypes.oneOf(['default', 'inherit', 'primary']),
|
123 |
|
124 | |
125 |
|
126 |
|
127 |
|
128 | component: PropTypes.elementType,
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 | disableGutters: PropTypes.bool,
|
135 |
|
136 | |
137 |
|
138 |
|
139 |
|
140 | disableSticky: PropTypes.bool,
|
141 |
|
142 | |
143 |
|
144 |
|
145 |
|
146 | inset: PropTypes.bool,
|
147 |
|
148 | |
149 |
|
150 |
|
151 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
152 | } : void 0;
|
153 | export default ListSubheader; |
\ | No newline at end of file |