1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import capitalize from "../utils/capitalize.js";
|
8 | import { styled } from "../zero-styled/index.js";
|
9 | import memoTheme from "../utils/memoTheme.js";
|
10 | import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
|
11 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
12 | import { getIconUtilityClass } from "./iconClasses.js";
|
13 | import { jsx as _jsx } from "react/jsx-runtime";
|
14 | const useUtilityClasses = ownerState => {
|
15 | const {
|
16 | color,
|
17 | fontSize,
|
18 | classes
|
19 | } = ownerState;
|
20 | const slots = {
|
21 | root: ['root', color !== 'inherit' && `color${capitalize(color)}`, `fontSize${capitalize(fontSize)}`]
|
22 | };
|
23 | return composeClasses(slots, getIconUtilityClass, classes);
|
24 | };
|
25 | const IconRoot = styled('span', {
|
26 | name: 'MuiIcon',
|
27 | slot: 'Root',
|
28 | overridesResolver: (props, styles) => {
|
29 | const {
|
30 | ownerState
|
31 | } = props;
|
32 | return [styles.root, ownerState.color !== 'inherit' && styles[`color${capitalize(ownerState.color)}`], styles[`fontSize${capitalize(ownerState.fontSize)}`]];
|
33 | }
|
34 | })(memoTheme(({
|
35 | theme
|
36 | }) => ({
|
37 | userSelect: 'none',
|
38 | width: '1em',
|
39 | height: '1em',
|
40 |
|
41 |
|
42 | overflow: 'hidden',
|
43 | display: 'inline-block',
|
44 |
|
45 | textAlign: 'center',
|
46 |
|
47 | flexShrink: 0,
|
48 | variants: [{
|
49 | props: {
|
50 | fontSize: 'inherit'
|
51 | },
|
52 | style: {
|
53 | fontSize: 'inherit'
|
54 | }
|
55 | }, {
|
56 | props: {
|
57 | fontSize: 'small'
|
58 | },
|
59 | style: {
|
60 | fontSize: theme.typography.pxToRem(20)
|
61 | }
|
62 | }, {
|
63 | props: {
|
64 | fontSize: 'medium'
|
65 | },
|
66 | style: {
|
67 | fontSize: theme.typography.pxToRem(24)
|
68 | }
|
69 | }, {
|
70 | props: {
|
71 | fontSize: 'large'
|
72 | },
|
73 | style: {
|
74 | fontSize: theme.typography.pxToRem(36)
|
75 | }
|
76 | }, {
|
77 | props: {
|
78 | color: 'action'
|
79 | },
|
80 | style: {
|
81 | color: (theme.vars || theme).palette.action.active
|
82 | }
|
83 | }, {
|
84 | props: {
|
85 | color: 'disabled'
|
86 | },
|
87 | style: {
|
88 | color: (theme.vars || theme).palette.action.disabled
|
89 | }
|
90 | }, {
|
91 | props: {
|
92 | color: 'inherit'
|
93 | },
|
94 | style: {
|
95 | color: undefined
|
96 | }
|
97 | }, ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
|
98 | props: {
|
99 | color
|
100 | },
|
101 | style: {
|
102 | color: (theme.vars || theme).palette[color].main
|
103 | }
|
104 | }))]
|
105 | })));
|
106 | const Icon = React.forwardRef(function Icon(inProps, ref) {
|
107 | const props = useDefaultProps({
|
108 | props: inProps,
|
109 | name: 'MuiIcon'
|
110 | });
|
111 | const {
|
112 | baseClassName = 'material-icons',
|
113 | className,
|
114 | color = 'inherit',
|
115 | component: Component = 'span',
|
116 | fontSize = 'medium',
|
117 | ...other
|
118 | } = props;
|
119 | const ownerState = {
|
120 | ...props,
|
121 | baseClassName,
|
122 | color,
|
123 | component: Component,
|
124 | fontSize
|
125 | };
|
126 | const classes = useUtilityClasses(ownerState);
|
127 | return _jsx(IconRoot, {
|
128 | as: Component,
|
129 | className: clsx(baseClassName,
|
130 |
|
131 |
|
132 | 'notranslate', classes.root, className),
|
133 | ownerState: ownerState,
|
134 | "aria-hidden": true,
|
135 | ref: ref,
|
136 | ...other
|
137 | });
|
138 | });
|
139 | process.env.NODE_ENV !== "production" ? Icon.propTypes = {
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 | baseClassName: PropTypes.string,
|
150 | |
151 |
|
152 |
|
153 | children: PropTypes.node,
|
154 | |
155 |
|
156 |
|
157 | classes: PropTypes.object,
|
158 | |
159 |
|
160 |
|
161 | className: PropTypes.string,
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | color: PropTypes .oneOfType([PropTypes.oneOf(['inherit', 'action', 'disabled', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
169 | |
170 |
|
171 |
|
172 |
|
173 | component: PropTypes.elementType,
|
174 | |
175 |
|
176 |
|
177 |
|
178 | fontSize: PropTypes .oneOfType([PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), PropTypes.string]),
|
179 | |
180 |
|
181 |
|
182 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
183 | } : void 0;
|
184 | if (Icon) {
|
185 | Icon.muiName = 'Icon';
|
186 | }
|
187 | export default Icon; |
\ | No newline at end of file |