UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

158 lines (124 loc) 4.98 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.styles = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _clsx = _interopRequireDefault(require("clsx")); var _withStyles = _interopRequireDefault(require("../styles/withStyles")); var _Typography = _interopRequireDefault(require("../Typography")); var _ListContext = _interopRequireDefault(require("../List/ListContext")); var styles = { /* Styles applied to the root element. */ root: { flex: '1 1 auto', minWidth: 0, marginTop: 4, marginBottom: 4 }, /* Styles applied to the `Typography` components if primary and secondary are set. */ multiline: { marginTop: 6, marginBottom: 6 }, /* Styles applied to the `Typography` components if dense. */ dense: {}, /* Styles applied to the root element if `inset={true}`. */ inset: { paddingLeft: 56 }, /* Styles applied to the primary `Typography` component. */ primary: {}, /* Styles applied to the secondary `Typography` component. */ secondary: {} }; exports.styles = styles; var ListItemText = _react.default.forwardRef(function ListItemText(props, ref) { var children = props.children, classes = props.classes, className = props.className, _props$disableTypogra = props.disableTypography, disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra, _props$inset = props.inset, inset = _props$inset === void 0 ? false : _props$inset, primaryProp = props.primary, primaryTypographyProps = props.primaryTypographyProps, secondaryProp = props.secondary, secondaryTypographyProps = props.secondaryTypographyProps, other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"]); var _React$useContext = _react.default.useContext(_ListContext.default), dense = _React$useContext.dense; var primary = primaryProp != null ? primaryProp : children; if (primary != null && primary.type !== _Typography.default && !disableTypography) { primary = _react.default.createElement(_Typography.default, (0, _extends2.default)({ variant: dense ? 'body2' : 'body1', className: classes.primary, component: "span" }, primaryTypographyProps), primary); } var secondary = secondaryProp; if (secondary != null && secondary.type !== _Typography.default && !disableTypography) { secondary = _react.default.createElement(_Typography.default, (0, _extends2.default)({ variant: "body2", className: classes.secondary, color: "textSecondary" }, secondaryTypographyProps), secondary); } return _react.default.createElement("div", (0, _extends2.default)({ className: (0, _clsx.default)(classes.root, className, dense && classes.dense, inset && classes.inset, primary && secondary && classes.multiline), ref: ref }, other), primary, secondary); }); process.env.NODE_ENV !== "production" ? ListItemText.propTypes = { /** * Alias for the `primary` property. */ children: _propTypes.default.node, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ classes: _propTypes.default.object.isRequired, /** * @ignore */ className: _propTypes.default.string, /** * If `true`, the children won't be wrapped by a Typography component. * This can be useful to render an alternative Typography variant by wrapping * the `children` (or `primary`) text, and optional `secondary` text * with the Typography component. */ disableTypography: _propTypes.default.bool, /** * If `true`, the children will be indented. * This should be used if there is no left avatar or left icon. */ inset: _propTypes.default.bool, /** * The main content element. */ primary: _propTypes.default.node, /** * These props will be forwarded to the primary typography component * (as long as disableTypography is not `true`). */ primaryTypographyProps: _propTypes.default.object, /** * The secondary content element. */ secondary: _propTypes.default.node, /** * These props will be forwarded to the secondary typography component * (as long as disableTypography is not `true`). */ secondaryTypographyProps: _propTypes.default.object } : void 0; var _default = (0, _withStyles.default)(styles, { name: 'MuiListItemText' })(ListItemText); exports.default = _default;