1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | const _excluded = ["className"];
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import clsx from 'clsx';
|
7 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
8 | import ListContext from '../List/ListContext';
|
9 | import styled from '../styles/styled';
|
10 | import useThemeProps from '../styles/useThemeProps';
|
11 | import { getListItemAvatarUtilityClass } from './listItemAvatarClasses';
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 |
|
14 | const useUtilityClasses = ownerState => {
|
15 | const {
|
16 | alignItems,
|
17 | classes
|
18 | } = ownerState;
|
19 | const slots = {
|
20 | root: ['root', alignItems === 'flex-start' && 'alignItemsFlexStart']
|
21 | };
|
22 | return composeClasses(slots, getListItemAvatarUtilityClass, classes);
|
23 | };
|
24 |
|
25 | const ListItemAvatarRoot = styled('div', {
|
26 | name: 'MuiListItemAvatar',
|
27 | slot: 'Root',
|
28 | overridesResolver: (props, styles) => {
|
29 | const {
|
30 | ownerState
|
31 | } = props;
|
32 | return [styles.root, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart];
|
33 | }
|
34 | })(({
|
35 | ownerState
|
36 | }) => _extends({
|
37 | minWidth: 56,
|
38 | flexShrink: 0
|
39 | }, ownerState.alignItems === 'flex-start' && {
|
40 | marginTop: 8
|
41 | }));
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | const ListItemAvatar = React.forwardRef(function ListItemAvatar(inProps, ref) {
|
47 | const props = useThemeProps({
|
48 | props: inProps,
|
49 | name: 'MuiListItemAvatar'
|
50 | });
|
51 |
|
52 | const {
|
53 | className
|
54 | } = props,
|
55 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
56 |
|
57 | const context = React.useContext(ListContext);
|
58 |
|
59 | const ownerState = _extends({}, props, {
|
60 | alignItems: context.alignItems
|
61 | });
|
62 |
|
63 | const classes = useUtilityClasses(ownerState);
|
64 | return _jsx(ListItemAvatarRoot, _extends({
|
65 | className: clsx(classes.root, className),
|
66 | ownerState: ownerState,
|
67 | ref: ref
|
68 | }, other));
|
69 | });
|
70 | process.env.NODE_ENV !== "production" ? ListItemAvatar.propTypes
|
71 |
|
72 | = {
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | |
79 |
|
80 |
|
81 | children: PropTypes.node,
|
82 |
|
83 | |
84 |
|
85 |
|
86 | classes: PropTypes.object,
|
87 |
|
88 | |
89 |
|
90 |
|
91 | className: PropTypes.string,
|
92 |
|
93 | |
94 |
|
95 |
|
96 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
97 | } : void 0;
|
98 | export default ListItemAvatar; |
\ | No newline at end of file |