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