UNPKG

1.95 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import withStyles from '../styles/withStyles';
7import ListContext from '../List/ListContext';
8export const styles = {
9 /* Styles applied to the root element. */
10 root: {
11 minWidth: 56,
12 flexShrink: 0
13 },
14
15 /* Styles applied to the root element when the parent `ListItem` uses `alignItems="flex-start"`. */
16 alignItemsFlexStart: {
17 marginTop: 8
18 }
19};
20/**
21 * A simple wrapper to apply `List` styles to an `Avatar`.
22 */
23
24const ListItemAvatar = /*#__PURE__*/React.forwardRef(function ListItemAvatar(props, ref) {
25 const {
26 classes,
27 className
28 } = props,
29 other = _objectWithoutPropertiesLoose(props, ["classes", "className"]);
30
31 const context = React.useContext(ListContext);
32 return /*#__PURE__*/React.createElement("div", _extends({
33 className: clsx(classes.root, className, context.alignItems === 'flex-start' && classes.alignItemsFlexStart),
34 ref: ref
35 }, other));
36});
37process.env.NODE_ENV !== "production" ? ListItemAvatar.propTypes = {
38 // ----------------------------- Warning --------------------------------
39 // | These PropTypes are generated from the TypeScript type definitions |
40 // | To update them edit the d.ts file and run "yarn proptypes" |
41 // ----------------------------------------------------------------------
42
43 /**
44 * The content of the component – normally `Avatar`.
45 */
46 children: PropTypes.element.isRequired,
47
48 /**
49 * Override or extend the styles applied to the component.
50 * See [CSS API](#css) below for more details.
51 */
52 classes: PropTypes.object,
53
54 /**
55 * @ignore
56 */
57 className: PropTypes.string
58} : void 0;
59export default withStyles(styles, {
60 name: 'MuiListItemAvatar'
61})(ListItemAvatar);
\No newline at end of file