UNPKG

3.02 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import ListContext from "../List/ListContext.js";
8import { styled } from "../zero-styled/index.js";
9import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10import { getListItemAvatarUtilityClass } from "./listItemAvatarClasses.js";
11import { jsx as _jsx } from "react/jsx-runtime";
12const useUtilityClasses = ownerState => {
13 const {
14 alignItems,
15 classes
16 } = ownerState;
17 const slots = {
18 root: ['root', alignItems === 'flex-start' && 'alignItemsFlexStart']
19 };
20 return composeClasses(slots, getListItemAvatarUtilityClass, classes);
21};
22const ListItemAvatarRoot = styled('div', {
23 name: 'MuiListItemAvatar',
24 slot: 'Root',
25 overridesResolver: (props, styles) => {
26 const {
27 ownerState
28 } = props;
29 return [styles.root, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart];
30 }
31})({
32 minWidth: 56,
33 flexShrink: 0,
34 variants: [{
35 props: {
36 alignItems: 'flex-start'
37 },
38 style: {
39 marginTop: 8
40 }
41 }]
42});
43
44/**
45 * A simple wrapper to apply `List` styles to an `Avatar`.
46 */
47const ListItemAvatar = /*#__PURE__*/React.forwardRef(function ListItemAvatar(inProps, ref) {
48 const props = useDefaultProps({
49 props: inProps,
50 name: 'MuiListItemAvatar'
51 });
52 const {
53 className,
54 ...other
55 } = props;
56 const context = React.useContext(ListContext);
57 const ownerState = {
58 ...props,
59 alignItems: context.alignItems
60 };
61 const classes = useUtilityClasses(ownerState);
62 return /*#__PURE__*/_jsx(ListItemAvatarRoot, {
63 className: clsx(classes.root, className),
64 ownerState: ownerState,
65 ref: ref,
66 ...other
67 });
68});
69process.env.NODE_ENV !== "production" ? ListItemAvatar.propTypes /* remove-proptypes */ = {
70 // ┌────────────────────────────── Warning ──────────────────────────────┐
71 // │ These PropTypes are generated from the TypeScript type definitions. │
72 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
73 // └─────────────────────────────────────────────────────────────────────┘
74 /**
75 * The content of the component, normally an `Avatar`.
76 */
77 children: PropTypes.node,
78 /**
79 * Override or extend the styles applied to the component.
80 */
81 classes: PropTypes.object,
82 /**
83 * @ignore
84 */
85 className: PropTypes.string,
86 /**
87 * The system prop that allows defining system overrides as well as additional CSS styles.
88 */
89 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
90} : void 0;
91export default ListItemAvatar;
\No newline at end of file