UNPKG

4.98 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import { styled } from "../zero-styled/index.js";
8import memoTheme from "../utils/memoTheme.js";
9import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10import capitalize from "../utils/capitalize.js";
11import { getListSubheaderUtilityClass } from "./listSubheaderClasses.js";
12import { jsx as _jsx } from "react/jsx-runtime";
13const 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};
26const 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})));
86const ListSubheader = /*#__PURE__*/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 /*#__PURE__*/_jsx(ListSubheaderRoot, {
110 as: component,
111 className: clsx(classes.root, className),
112 ref: ref,
113 ownerState: ownerState,
114 ...other
115 });
116});
117if (ListSubheader) {
118 ListSubheader.muiSkipListHighlight = true;
119}
120process.env.NODE_ENV !== "production" ? ListSubheader.propTypes /* remove-proptypes */ = {
121 // ┌────────────────────────────── Warning ──────────────────────────────┐
122 // │ These PropTypes are generated from the TypeScript type definitions. │
123 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
124 // └─────────────────────────────────────────────────────────────────────┘
125 /**
126 * The content of the component.
127 */
128 children: PropTypes.node,
129 /**
130 * Override or extend the styles applied to the component.
131 */
132 classes: PropTypes.object,
133 /**
134 * @ignore
135 */
136 className: PropTypes.string,
137 /**
138 * The color of the component. It supports those theme colors that make sense for this component.
139 * @default 'default'
140 */
141 color: PropTypes.oneOf(['default', 'inherit', 'primary']),
142 /**
143 * The component used for the root node.
144 * Either a string to use a HTML element or a component.
145 */
146 component: PropTypes.elementType,
147 /**
148 * If `true`, the List Subheader will not have gutters.
149 * @default false
150 */
151 disableGutters: PropTypes.bool,
152 /**
153 * If `true`, the List Subheader will not stick to the top during scroll.
154 * @default false
155 */
156 disableSticky: PropTypes.bool,
157 /**
158 * If `true`, the List Subheader is indented.
159 * @default false
160 */
161 inset: PropTypes.bool,
162 /**
163 * The system prop that allows defining system overrides as well as additional CSS styles.
164 */
165 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
166} : void 0;
167export default ListSubheader;
\No newline at end of file