UNPKG

2.07 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 = theme => ({
9 /* Styles applied to the root element. */
10 root: {
11 minWidth: 56,
12 color: theme.palette.action.active,
13 flexShrink: 0,
14 display: 'inline-flex'
15 },
16
17 /* Styles applied to the root element when the parent `ListItem` uses `alignItems="flex-start"`. */
18 alignItemsFlexStart: {
19 marginTop: 8
20 }
21});
22/**
23 * A simple wrapper to apply `List` styles to an `Icon` or `SvgIcon`.
24 */
25
26const ListItemIcon = /*#__PURE__*/React.forwardRef(function ListItemIcon(props, ref) {
27 const {
28 classes,
29 className
30 } = props,
31 other = _objectWithoutPropertiesLoose(props, ["classes", "className"]);
32
33 const context = React.useContext(ListContext);
34 return /*#__PURE__*/React.createElement("div", _extends({
35 className: clsx(classes.root, className, context.alignItems === 'flex-start' && classes.alignItemsFlexStart),
36 ref: ref
37 }, other));
38});
39process.env.NODE_ENV !== "production" ? ListItemIcon.propTypes = {
40 // ----------------------------- Warning --------------------------------
41 // | These PropTypes are generated from the TypeScript type definitions |
42 // | To update them edit the d.ts file and run "yarn proptypes" |
43 // ----------------------------------------------------------------------
44
45 /**
46 * The content of the component, normally `Icon`, `SvgIcon`,
47 * or a `@material-ui/icons` SVG icon element.
48 */
49 children: PropTypes.node,
50
51 /**
52 * Override or extend the styles applied to the component.
53 * See [CSS API](#css) below for more details.
54 */
55 classes: PropTypes.object,
56
57 /**
58 * @ignore
59 */
60 className: PropTypes.string
61} : void 0;
62export default withStyles(styles, {
63 name: 'MuiListItemIcon'
64})(ListItemIcon);
\No newline at end of file