1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | const _excluded = ["children", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"];
|
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 Typography from '../Typography';
|
9 | import ListContext from '../List/ListContext';
|
10 | import useThemeProps from '../styles/useThemeProps';
|
11 | import styled from '../styles/styled';
|
12 | import listItemTextClasses, { getListItemTextUtilityClass } from './listItemTextClasses';
|
13 | import { jsx as _jsx } from "react/jsx-runtime";
|
14 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
15 |
|
16 | const useUtilityClasses = ownerState => {
|
17 | const {
|
18 | classes,
|
19 | inset,
|
20 | primary,
|
21 | secondary,
|
22 | dense
|
23 | } = ownerState;
|
24 | const slots = {
|
25 | root: ['root', inset && 'inset', dense && 'dense', primary && secondary && 'multiline'],
|
26 | primary: ['primary'],
|
27 | secondary: ['secondary']
|
28 | };
|
29 | return composeClasses(slots, getListItemTextUtilityClass, classes);
|
30 | };
|
31 |
|
32 | const ListItemTextRoot = styled('div', {
|
33 | name: 'MuiListItemText',
|
34 | slot: 'Root',
|
35 | overridesResolver: (props, styles) => {
|
36 | const {
|
37 | ownerState
|
38 | } = props;
|
39 | return [{
|
40 | [`& .${listItemTextClasses.primary}`]: styles.primary
|
41 | }, {
|
42 | [`& .${listItemTextClasses.secondary}`]: styles.secondary
|
43 | }, styles.root, ownerState.inset && styles.inset, ownerState.primary && ownerState.secondary && styles.multiline, ownerState.dense && styles.dense];
|
44 | }
|
45 | })(({
|
46 | ownerState
|
47 | }) => _extends({
|
48 | flex: '1 1 auto',
|
49 | minWidth: 0,
|
50 | marginTop: 4,
|
51 | marginBottom: 4
|
52 | }, ownerState.primary && ownerState.secondary && {
|
53 | marginTop: 6,
|
54 | marginBottom: 6
|
55 | }, ownerState.inset && {
|
56 | paddingLeft: 56
|
57 | }));
|
58 | const ListItemText = React.forwardRef(function ListItemText(inProps, ref) {
|
59 | const props = useThemeProps({
|
60 | props: inProps,
|
61 | name: 'MuiListItemText'
|
62 | });
|
63 |
|
64 | const {
|
65 | children,
|
66 | className,
|
67 | disableTypography = false,
|
68 | inset = false,
|
69 | primary: primaryProp,
|
70 | primaryTypographyProps,
|
71 | secondary: secondaryProp,
|
72 | secondaryTypographyProps
|
73 | } = props,
|
74 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
75 |
|
76 | const {
|
77 | dense
|
78 | } = React.useContext(ListContext);
|
79 | let primary = primaryProp != null ? primaryProp : children;
|
80 | let secondary = secondaryProp;
|
81 |
|
82 | const ownerState = _extends({}, props, {
|
83 | disableTypography,
|
84 | inset,
|
85 | primary: !!primary,
|
86 | secondary: !!secondary,
|
87 | dense
|
88 | });
|
89 |
|
90 | const classes = useUtilityClasses(ownerState);
|
91 |
|
92 | if (primary != null && primary.type !== Typography && !disableTypography) {
|
93 | primary = _jsx(Typography, _extends({
|
94 | variant: dense ? 'body2' : 'body1',
|
95 | className: classes.primary,
|
96 | component: "span",
|
97 | display: "block"
|
98 | }, primaryTypographyProps, {
|
99 | children: primary
|
100 | }));
|
101 | }
|
102 |
|
103 | if (secondary != null && secondary.type !== Typography && !disableTypography) {
|
104 | secondary = _jsx(Typography, _extends({
|
105 | variant: "body2",
|
106 | className: classes.secondary,
|
107 | color: "text.secondary",
|
108 | display: "block"
|
109 | }, secondaryTypographyProps, {
|
110 | children: secondary
|
111 | }));
|
112 | }
|
113 |
|
114 | return _jsxs(ListItemTextRoot, _extends({
|
115 | className: clsx(classes.root, className),
|
116 | ownerState: ownerState,
|
117 | ref: ref
|
118 | }, other, {
|
119 | children: [primary, secondary]
|
120 | }));
|
121 | });
|
122 | process.env.NODE_ENV !== "production" ? ListItemText.propTypes
|
123 |
|
124 | = {
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | |
131 |
|
132 |
|
133 | children: PropTypes.node,
|
134 |
|
135 | |
136 |
|
137 |
|
138 | classes: PropTypes.object,
|
139 |
|
140 | |
141 |
|
142 |
|
143 | className: PropTypes.string,
|
144 |
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | disableTypography: PropTypes.bool,
|
153 |
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 | inset: PropTypes.bool,
|
160 |
|
161 | |
162 |
|
163 |
|
164 | primary: PropTypes.node,
|
165 |
|
166 | |
167 |
|
168 |
|
169 |
|
170 | primaryTypographyProps: PropTypes.object,
|
171 |
|
172 | |
173 |
|
174 |
|
175 | secondary: PropTypes.node,
|
176 |
|
177 | |
178 |
|
179 |
|
180 |
|
181 | secondaryTypographyProps: PropTypes.object,
|
182 |
|
183 | |
184 |
|
185 |
|
186 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
187 | } : void 0;
|
188 | export default ListItemText; |
\ | No newline at end of file |