1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import Typography from '../Typography';
|
8 | import ListContext from '../List/ListContext';
|
9 | export const styles = {
|
10 |
|
11 | root: {
|
12 | flex: '1 1 auto',
|
13 | minWidth: 0,
|
14 | marginTop: 4,
|
15 | marginBottom: 4
|
16 | },
|
17 |
|
18 |
|
19 | multiline: {
|
20 | marginTop: 6,
|
21 | marginBottom: 6
|
22 | },
|
23 |
|
24 |
|
25 | dense: {},
|
26 |
|
27 |
|
28 | inset: {
|
29 | paddingLeft: 56
|
30 | },
|
31 |
|
32 |
|
33 | primary: {},
|
34 |
|
35 |
|
36 | secondary: {}
|
37 | };
|
38 | const ListItemText = React.forwardRef(function ListItemText(props, ref) {
|
39 | const {
|
40 | children,
|
41 | classes,
|
42 | className,
|
43 | disableTypography = false,
|
44 | inset = false,
|
45 | primary: primaryProp,
|
46 | primaryTypographyProps,
|
47 | secondary: secondaryProp,
|
48 | secondaryTypographyProps
|
49 | } = props,
|
50 | other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"]);
|
51 |
|
52 | const {
|
53 | dense
|
54 | } = React.useContext(ListContext);
|
55 | let primary = primaryProp != null ? primaryProp : children;
|
56 |
|
57 | if (primary != null && primary.type !== Typography && !disableTypography) {
|
58 | primary = React.createElement(Typography, _extends({
|
59 | variant: dense ? 'body2' : 'body1',
|
60 | className: classes.primary,
|
61 | component: "span",
|
62 | display: "block"
|
63 | }, primaryTypographyProps), primary);
|
64 | }
|
65 |
|
66 | let secondary = secondaryProp;
|
67 |
|
68 | if (secondary != null && secondary.type !== Typography && !disableTypography) {
|
69 | secondary = React.createElement(Typography, _extends({
|
70 | variant: "body2",
|
71 | className: classes.secondary,
|
72 | color: "textSecondary",
|
73 | display: "block"
|
74 | }, secondaryTypographyProps), secondary);
|
75 | }
|
76 |
|
77 | return React.createElement("div", _extends({
|
78 | className: clsx(classes.root, className, dense && classes.dense, inset && classes.inset, primary && secondary && classes.multiline),
|
79 | ref: ref
|
80 | }, other), primary, secondary);
|
81 | });
|
82 | process.env.NODE_ENV !== "production" ? ListItemText.propTypes = {
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | |
89 |
|
90 |
|
91 | children: PropTypes.node,
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 | classes: PropTypes.object,
|
98 |
|
99 | |
100 |
|
101 |
|
102 | className: PropTypes.string,
|
103 |
|
104 | |
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | disableTypography: PropTypes.bool,
|
111 |
|
112 | |
113 |
|
114 |
|
115 |
|
116 | inset: PropTypes.bool,
|
117 |
|
118 | |
119 |
|
120 |
|
121 | primary: PropTypes.node,
|
122 |
|
123 | |
124 |
|
125 |
|
126 |
|
127 | primaryTypographyProps: PropTypes.object,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | secondary: PropTypes.node,
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 | secondaryTypographyProps: PropTypes.object
|
139 | } : void 0;
|
140 | export default withStyles(styles, {
|
141 | name: 'MuiListItemText'
|
142 | })(ListItemText); |
\ | No newline at end of file |