UNPKG

5.33 kBJavaScriptView Raw
1import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2import _extends from "@babel/runtime/helpers/esm/extends";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import { unstable_composeClasses as composeClasses } from '@mui/base';
7import styled from '../styles/styled';
8import useThemeProps from '../styles/useThemeProps';
9import capitalize from '../utils/capitalize';
10import { getListSubheaderUtilityClass } from './listSubheaderClasses';
11import { jsx as _jsx } from "react/jsx-runtime";
12
13var useUtilityClasses = function useUtilityClasses(ownerState) {
14 var classes = ownerState.classes,
15 color = ownerState.color,
16 disableGutters = ownerState.disableGutters,
17 inset = ownerState.inset,
18 disableSticky = ownerState.disableSticky;
19 var slots = {
20 root: ['root', color !== 'default' && "color".concat(capitalize(color)), !disableGutters && 'gutters', inset && 'inset', !disableSticky && 'sticky']
21 };
22 return composeClasses(slots, getListSubheaderUtilityClass, classes);
23};
24
25var ListSubheaderRoot = styled('li', {
26 name: 'MuiListSubheader',
27 slot: 'Root',
28 overridesResolver: function overridesResolver(props, styles) {
29 var ownerState = props.ownerState;
30 return [styles.root, ownerState.color !== 'default' && styles["color".concat(capitalize(ownerState.color))], !ownerState.disableGutters && styles.gutters, ownerState.inset && styles.inset, !ownerState.disableSticky && styles.sticky];
31 }
32})(function (_ref) {
33 var theme = _ref.theme,
34 ownerState = _ref.ownerState;
35 return _extends({
36 boxSizing: 'border-box',
37 lineHeight: '48px',
38 listStyle: 'none',
39 color: (theme.vars || theme).palette.text.secondary,
40 fontFamily: theme.typography.fontFamily,
41 fontWeight: theme.typography.fontWeightMedium,
42 fontSize: theme.typography.pxToRem(14)
43 }, ownerState.color === 'primary' && {
44 color: (theme.vars || theme).palette.primary.main
45 }, ownerState.color === 'inherit' && {
46 color: 'inherit'
47 }, !ownerState.disableGutters && {
48 paddingLeft: 16,
49 paddingRight: 16
50 }, ownerState.inset && {
51 paddingLeft: 72
52 }, !ownerState.disableSticky && {
53 position: 'sticky',
54 top: 0,
55 zIndex: 1,
56 backgroundColor: (theme.vars || theme).palette.background.paper
57 });
58});
59var ListSubheader = /*#__PURE__*/React.forwardRef(function ListSubheader(inProps, ref) {
60 var props = useThemeProps({
61 props: inProps,
62 name: 'MuiListSubheader'
63 });
64
65 var className = props.className,
66 _props$color = props.color,
67 color = _props$color === void 0 ? 'default' : _props$color,
68 _props$component = props.component,
69 component = _props$component === void 0 ? 'li' : _props$component,
70 _props$disableGutters = props.disableGutters,
71 disableGutters = _props$disableGutters === void 0 ? false : _props$disableGutters,
72 _props$disableSticky = props.disableSticky,
73 disableSticky = _props$disableSticky === void 0 ? false : _props$disableSticky,
74 _props$inset = props.inset,
75 inset = _props$inset === void 0 ? false : _props$inset,
76 other = _objectWithoutProperties(props, ["className", "color", "component", "disableGutters", "disableSticky", "inset"]);
77
78 var ownerState = _extends({}, props, {
79 color: color,
80 component: component,
81 disableGutters: disableGutters,
82 disableSticky: disableSticky,
83 inset: inset
84 });
85
86 var classes = useUtilityClasses(ownerState);
87 return /*#__PURE__*/_jsx(ListSubheaderRoot, _extends({
88 as: component,
89 className: clsx(classes.root, className),
90 ref: ref,
91 ownerState: ownerState
92 }, other));
93});
94process.env.NODE_ENV !== "production" ? ListSubheader.propTypes
95/* remove-proptypes */
96= {
97 // ----------------------------- Warning --------------------------------
98 // | These PropTypes are generated from the TypeScript type definitions |
99 // | To update them edit the d.ts file and run "yarn proptypes" |
100 // ----------------------------------------------------------------------
101
102 /**
103 * The content of the component.
104 */
105 children: PropTypes.node,
106
107 /**
108 * Override or extend the styles applied to the component.
109 */
110 classes: PropTypes.object,
111
112 /**
113 * @ignore
114 */
115 className: PropTypes.string,
116
117 /**
118 * The color of the component. It supports those theme colors that make sense for this component.
119 * @default 'default'
120 */
121 color: PropTypes.oneOf(['default', 'inherit', 'primary']),
122
123 /**
124 * The component used for the root node.
125 * Either a string to use a HTML element or a component.
126 */
127 component: PropTypes.elementType,
128
129 /**
130 * If `true`, the List Subheader will not have gutters.
131 * @default false
132 */
133 disableGutters: PropTypes.bool,
134
135 /**
136 * If `true`, the List Subheader will not stick to the top during scroll.
137 * @default false
138 */
139 disableSticky: PropTypes.bool,
140
141 /**
142 * If `true`, the List Subheader is indented.
143 * @default false
144 */
145 inset: PropTypes.bool,
146
147 /**
148 * The system prop that allows defining system overrides as well as additional CSS styles.
149 */
150 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
151} : void 0;
152export default ListSubheader;
\No newline at end of file