UNPKG

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