UNPKG

5.42 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var _Typography = _interopRequireDefault(require("../Typography"));
25
26var _ListContext = _interopRequireDefault(require("../List/ListContext"));
27
28var styles = {
29 /* Styles applied to the root element. */
30 root: {
31 flex: '1 1 auto',
32 minWidth: 0,
33 marginTop: 4,
34 marginBottom: 4
35 },
36
37 /* Styles applied to the `Typography` components if primary and secondary are set. */
38 multiline: {
39 marginTop: 6,
40 marginBottom: 6
41 },
42
43 /* Styles applied to the `Typography` components if dense. */
44 dense: {},
45
46 /* Styles applied to the root element if `inset={true}`. */
47 inset: {
48 paddingLeft: 56
49 },
50
51 /* Styles applied to the primary `Typography` component. */
52 primary: {},
53
54 /* Styles applied to the secondary `Typography` component. */
55 secondary: {}
56};
57exports.styles = styles;
58var ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(props, ref) {
59 var children = props.children,
60 classes = props.classes,
61 className = props.className,
62 _props$disableTypogra = props.disableTypography,
63 disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra,
64 _props$inset = props.inset,
65 inset = _props$inset === void 0 ? false : _props$inset,
66 primaryProp = props.primary,
67 primaryTypographyProps = props.primaryTypographyProps,
68 secondaryProp = props.secondary,
69 secondaryTypographyProps = props.secondaryTypographyProps,
70 other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"]);
71
72 var _React$useContext = React.useContext(_ListContext.default),
73 dense = _React$useContext.dense;
74
75 var primary = primaryProp != null ? primaryProp : children;
76
77 if (primary != null && primary.type !== _Typography.default && !disableTypography) {
78 primary = /*#__PURE__*/React.createElement(_Typography.default, (0, _extends2.default)({
79 variant: dense ? 'body2' : 'body1',
80 className: classes.primary,
81 component: "span",
82 display: "block"
83 }, primaryTypographyProps), primary);
84 }
85
86 var secondary = secondaryProp;
87
88 if (secondary != null && secondary.type !== _Typography.default && !disableTypography) {
89 secondary = /*#__PURE__*/React.createElement(_Typography.default, (0, _extends2.default)({
90 variant: "body2",
91 className: classes.secondary,
92 color: "textSecondary",
93 display: "block"
94 }, secondaryTypographyProps), secondary);
95 }
96
97 return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
98 className: (0, _clsx.default)(classes.root, className, dense && classes.dense, inset && classes.inset, primary && secondary && classes.multiline),
99 ref: ref
100 }, other), primary, secondary);
101});
102process.env.NODE_ENV !== "production" ? ListItemText.propTypes = {
103 // ----------------------------- Warning --------------------------------
104 // | These PropTypes are generated from the TypeScript type definitions |
105 // | To update them edit the d.ts file and run "yarn proptypes" |
106 // ----------------------------------------------------------------------
107
108 /**
109 * Alias for the `primary` prop.
110 */
111 children: _propTypes.default.node,
112
113 /**
114 * Override or extend the styles applied to the component.
115 * See [CSS API](#css) below for more details.
116 */
117 classes: _propTypes.default.object,
118
119 /**
120 * @ignore
121 */
122 className: _propTypes.default.string,
123
124 /**
125 * If `true`, the children won't be wrapped by a Typography component.
126 * This can be useful to render an alternative Typography variant by wrapping
127 * the `children` (or `primary`) text, and optional `secondary` text
128 * with the Typography component.
129 */
130 disableTypography: _propTypes.default.bool,
131
132 /**
133 * If `true`, the children will be indented.
134 * This should be used if there is no left avatar or left icon.
135 */
136 inset: _propTypes.default.bool,
137
138 /**
139 * The main content element.
140 */
141 primary: _propTypes.default.node,
142
143 /**
144 * These props will be forwarded to the primary typography component
145 * (as long as disableTypography is not `true`).
146 */
147 primaryTypographyProps: _propTypes.default.object,
148
149 /**
150 * The secondary content element.
151 */
152 secondary: _propTypes.default.node,
153
154 /**
155 * These props will be forwarded to the secondary typography component
156 * (as long as disableTypography is not `true`).
157 */
158 secondaryTypographyProps: _propTypes.default.object
159} : void 0;
160
161var _default = (0, _withStyles.default)(styles, {
162 name: 'MuiListItemText'
163})(ListItemText);
164
165exports.default = _default;
\No newline at end of file