@@ -6,11 +6,12 @@ import PropTypes from 'prop-types';
6
6
import * as React from 'react' ;
7
7
import styled from '../styles/styled' ;
8
8
import useThemeProps from '../styles/useThemeProps' ;
9
+ import useSlot from '../utils/useSlot' ;
9
10
import { getSvgIconUtilityClass } from './svgIconClasses' ;
10
11
import { SvgIconProps , SvgIconTypeMap , SvgIconOwnerState } from './SvgIconProps' ;
11
12
12
13
const useUtilityClasses = ( ownerState : SvgIconOwnerState ) => {
13
- const { color, fontSize, classes } = ownerState ;
14
+ const { color, fontSize } = ownerState ;
14
15
15
16
const slots = {
16
17
root : [
@@ -20,7 +21,7 @@ const useUtilityClasses = (ownerState: SvgIconOwnerState) => {
20
21
] ,
21
22
} ;
22
23
23
- return composeClasses ( slots , getSvgIconUtilityClass , classes ) ;
24
+ return composeClasses ( slots , getSvgIconUtilityClass , { } ) ;
24
25
} ;
25
26
26
27
const SvgIconRoot = styled ( 'svg' , {
@@ -86,22 +87,26 @@ const SvgIcon = React.forwardRef(function SvgIcon(inProps, ref) {
86
87
87
88
const classes = useUtilityClasses ( ownerState ) ;
88
89
90
+ const [ SlotRoot , rootProps ] = useSlot ( 'root' , {
91
+ ref,
92
+ className : clsx ( classes . root , className ) ,
93
+ elementType : SvgIconRoot ,
94
+ externalForwardedProps : { ...other , component } ,
95
+ ownerState,
96
+ additionalProps : {
97
+ color : htmlColor ,
98
+ focusable : 'false' ,
99
+ ...( titleAccess && { role : 'img' } ) ,
100
+ ...( ! titleAccess && { 'aria-hideen' : true } ) ,
101
+ ...( ! inheritViewBox && { viewBox } ) ,
102
+ } ,
103
+ } ) ;
104
+
89
105
return (
90
- < SvgIconRoot
91
- as = { component }
92
- className = { clsx ( classes . root , className ) }
93
- focusable = "false"
94
- color = { htmlColor }
95
- aria-hidden = { titleAccess ? undefined : true }
96
- role = { titleAccess ? 'img' : undefined }
97
- ref = { ref }
98
- { ...other }
99
- { ...( ! inheritViewBox && { viewBox } ) }
100
- ownerState = { ownerState }
101
- >
106
+ < SlotRoot { ...rootProps } >
102
107
{ children }
103
108
{ titleAccess ? < title > { titleAccess } </ title > : null }
104
- </ SvgIconRoot >
109
+ </ SlotRoot >
105
110
) ;
106
111
} ) as OverridableComponent < SvgIconTypeMap > ;
107
112
0 commit comments