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