UNPKG

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