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