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 { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
11 | import { getSvgIconUtilityClass } from "./svgIconClasses.js";
|
12 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | color,
|
16 | fontSize,
|
17 | classes
|
18 | } = ownerState;
|
19 | const slots = {
|
20 | root: ['root', color !== 'inherit' && `color${capitalize(color)}`, `fontSize${capitalize(fontSize)}`]
|
21 | };
|
22 | return composeClasses(slots, getSvgIconUtilityClass, classes);
|
23 | };
|
24 | const SvgIconRoot = styled('svg', {
|
25 | name: 'MuiSvgIcon',
|
26 | slot: 'Root',
|
27 | overridesResolver: (props, styles) => {
|
28 | const {
|
29 | ownerState
|
30 | } = props;
|
31 | return [styles.root, ownerState.color !== 'inherit' && styles[`color${capitalize(ownerState.color)}`], styles[`fontSize${capitalize(ownerState.fontSize)}`]];
|
32 | }
|
33 | })(memoTheme(({
|
34 | theme
|
35 | }) => ({
|
36 | userSelect: 'none',
|
37 | width: '1em',
|
38 | height: '1em',
|
39 | display: 'inline-block',
|
40 | flexShrink: 0,
|
41 | transition: theme.transitions?.create?.('fill', {
|
42 | duration: (theme.vars ?? theme).transitions?.duration?.shorter
|
43 | }),
|
44 | variants: [{
|
45 | props: props => !props.hasSvgAsChild,
|
46 | style: {
|
47 |
|
48 |
|
49 | fill: 'currentColor'
|
50 | }
|
51 | }, {
|
52 | props: {
|
53 | fontSize: 'inherit'
|
54 | },
|
55 | style: {
|
56 | fontSize: 'inherit'
|
57 | }
|
58 | }, {
|
59 | props: {
|
60 | fontSize: 'small'
|
61 | },
|
62 | style: {
|
63 | fontSize: theme.typography?.pxToRem?.(20) || '1.25rem'
|
64 | }
|
65 | }, {
|
66 | props: {
|
67 | fontSize: 'medium'
|
68 | },
|
69 | style: {
|
70 | fontSize: theme.typography?.pxToRem?.(24) || '1.5rem'
|
71 | }
|
72 | }, {
|
73 | props: {
|
74 | fontSize: 'large'
|
75 | },
|
76 | style: {
|
77 | fontSize: theme.typography?.pxToRem?.(35) || '2.1875rem'
|
78 | }
|
79 | },
|
80 |
|
81 | ...Object.entries((theme.vars ?? theme).palette).filter(([, value]) => value && value.main).map(([color]) => ({
|
82 | props: {
|
83 | color
|
84 | },
|
85 | style: {
|
86 | color: (theme.vars ?? theme).palette?.[color]?.main
|
87 | }
|
88 | })), {
|
89 | props: {
|
90 | color: 'action'
|
91 | },
|
92 | style: {
|
93 | color: (theme.vars ?? theme).palette?.action?.active
|
94 | }
|
95 | }, {
|
96 | props: {
|
97 | color: 'disabled'
|
98 | },
|
99 | style: {
|
100 | color: (theme.vars ?? theme).palette?.action?.disabled
|
101 | }
|
102 | }, {
|
103 | props: {
|
104 | color: 'inherit'
|
105 | },
|
106 | style: {
|
107 | color: undefined
|
108 | }
|
109 | }]
|
110 | })));
|
111 | const SvgIcon = React.forwardRef(function SvgIcon(inProps, ref) {
|
112 | const props = useDefaultProps({
|
113 | props: inProps,
|
114 | name: 'MuiSvgIcon'
|
115 | });
|
116 | const {
|
117 | children,
|
118 | className,
|
119 | color = 'inherit',
|
120 | component = 'svg',
|
121 | fontSize = 'medium',
|
122 | htmlColor,
|
123 | inheritViewBox = false,
|
124 | titleAccess,
|
125 | viewBox = '0 0 24 24',
|
126 | ...other
|
127 | } = props;
|
128 | const hasSvgAsChild = React.isValidElement(children) && children.type === 'svg';
|
129 | const ownerState = {
|
130 | ...props,
|
131 | color,
|
132 | component,
|
133 | fontSize,
|
134 | instanceFontSize: inProps.fontSize,
|
135 | inheritViewBox,
|
136 | viewBox,
|
137 | hasSvgAsChild
|
138 | };
|
139 | const more = {};
|
140 | if (!inheritViewBox) {
|
141 | more.viewBox = viewBox;
|
142 | }
|
143 | const classes = useUtilityClasses(ownerState);
|
144 | return _jsxs(SvgIconRoot, {
|
145 | as: component,
|
146 | className: clsx(classes.root, className),
|
147 | focusable: "false",
|
148 | color: htmlColor,
|
149 | "aria-hidden": titleAccess ? undefined : true,
|
150 | role: titleAccess ? 'img' : undefined,
|
151 | ref: ref,
|
152 | ...more,
|
153 | ...other,
|
154 | ...(hasSvgAsChild && children.props),
|
155 | ownerState: ownerState,
|
156 | children: [hasSvgAsChild ? children.props.children : children, titleAccess ? _jsx("title", {
|
157 | children: titleAccess
|
158 | }) : null]
|
159 | });
|
160 | });
|
161 | process.env.NODE_ENV !== "production" ? SvgIcon.propTypes = {
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | |
167 |
|
168 |
|
169 | children: PropTypes.node,
|
170 | |
171 |
|
172 |
|
173 | classes: PropTypes.object,
|
174 | |
175 |
|
176 |
|
177 | className: PropTypes.string,
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 | color: PropTypes .oneOfType([PropTypes.oneOf(['inherit', 'action', 'disabled', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
186 | |
187 |
|
188 |
|
189 |
|
190 | component: PropTypes.elementType,
|
191 | |
192 |
|
193 |
|
194 |
|
195 | fontSize: PropTypes .oneOfType([PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), PropTypes.string]),
|
196 | |
197 |
|
198 |
|
199 | htmlColor: PropTypes.string,
|
200 | |
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | inheritViewBox: PropTypes.bool,
|
208 | |
209 |
|
210 |
|
211 |
|
212 |
|
213 | shapeRendering: PropTypes.string,
|
214 | |
215 |
|
216 |
|
217 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
218 | |
219 |
|
220 |
|
221 |
|
222 | titleAccess: PropTypes.string,
|
223 | |
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | viewBox: PropTypes.string
|
232 | } : void 0;
|
233 | if (SvgIcon) {
|
234 | SvgIcon.muiName = 'SvgIcon';
|
235 | }
|
236 | export default SvgIcon; |
\ | No newline at end of file |