UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

142 lines (122 loc) 4.64 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import withStyles from '../styles/withStyles'; import Typography from '../Typography'; import ListContext from '../List/ListContext'; export 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: {} }; var ListItemText = /*#__PURE__*/React.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 = _objectWithoutProperties(props, ["children", "classes", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"]); var _React$useContext = React.useContext(ListContext), dense = _React$useContext.dense; var primary = primaryProp != null ? primaryProp : children; if (primary != null && primary.type !== Typography && !disableTypography) { primary = /*#__PURE__*/React.createElement(Typography, _extends({ variant: dense ? 'body2' : 'body1', className: classes.primary, component: "span", display: "block" }, primaryTypographyProps), primary); } var secondary = secondaryProp; if (secondary != null && secondary.type !== Typography && !disableTypography) { secondary = /*#__PURE__*/React.createElement(Typography, _extends({ variant: "body2", className: classes.secondary, color: "textSecondary", display: "block" }, secondaryTypographyProps), secondary); } return /*#__PURE__*/React.createElement("div", _extends({ className: clsx(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 = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the d.ts file and run "yarn proptypes" | // ---------------------------------------------------------------------- /** * Alias for the `primary` prop. */ children: PropTypes.node, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ classes: PropTypes.object, /** * @ignore */ className: PropTypes.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.bool, /** * If `true`, the children will be indented. * This should be used if there is no left avatar or left icon. */ inset: PropTypes.bool, /** * The main content element. */ primary: PropTypes.node, /** * These props will be forwarded to the primary typography component * (as long as disableTypography is not `true`). */ primaryTypographyProps: PropTypes.object, /** * The secondary content element. */ secondary: PropTypes.node, /** * These props will be forwarded to the secondary typography component * (as long as disableTypography is not `true`). */ secondaryTypographyProps: PropTypes.object } : void 0; export default withStyles(styles, { name: 'MuiListItemText' })(ListItemText);