1
1
'use client' ;
2
2
import * as React from 'react' ;
3
3
import PropTypes from 'prop-types' ;
4
+ import clsx from 'clsx' ;
4
5
import composeClasses from '@mui/utils/composeClasses' ;
5
6
import generateUtilityClass from '@mui/utils/generateUtilityClass' ;
6
- import { styled } from '@mui/material/styles' ;
7
+ import { styled , useTheme } from '@mui/material/styles' ;
7
8
import generateUtilityClasses from '@mui/utils/generateUtilityClasses' ;
8
9
import { useAnimatePieArc } from '../hooks' ;
9
10
import { ANIMATION_DURATION_MS , ANIMATION_TIMING_FUNCTION } from '../internals/animation/animation' ;
@@ -22,6 +23,8 @@ export interface PieArcClasses {
22
23
* Needs to be suffixed with the series ID: `.${pieArcClasses.series}-${seriesId}`.
23
24
*/
24
25
series : string ;
26
+ /** Styles applied to the focus indicator element. */
27
+ focusIndicator : string ;
25
28
}
26
29
27
30
export type PieArcClassKey = keyof PieArcClasses ;
@@ -33,6 +36,7 @@ interface PieArcOwnerState {
33
36
isFaded : boolean ;
34
37
isHighlighted : boolean ;
35
38
isFocused : boolean ;
39
+ stroke ?: string ;
36
40
classes ?: Partial < PieArcClasses > ;
37
41
}
38
42
@@ -45,6 +49,7 @@ export const pieArcClasses: PieArcClasses = generateUtilityClasses('MuiPieArc',
45
49
'highlighted' ,
46
50
'faded' ,
47
51
'series' ,
52
+ 'focusIndicator' ,
48
53
] ) ;
49
54
50
55
const useUtilityClasses = ( ownerState : PieArcOwnerState ) => {
@@ -66,13 +71,11 @@ const PieArcRoot = styled('path', {
66
71
name : 'MuiPieArc' ,
67
72
slot : 'Root' ,
68
73
overridesResolver : ( _ , styles ) => styles . arc , // FIXME: Inconsistent naming with slot
69
- } ) < { ownerState : PieArcOwnerState } > ( ( { theme } ) => ( {
70
- // Got to move stroke to an element prop instead of style.
71
- stroke : ( theme . vars || theme ) . palette . background . paper ,
74
+ } ) < { ownerState : PieArcOwnerState } > ( {
72
75
transitionProperty : 'opacity, fill, filter' ,
73
76
transitionDuration : `${ ANIMATION_DURATION_MS } ms` ,
74
77
transitionTimingFunction : ANIMATION_TIMING_FUNCTION ,
75
- } ) ) ;
78
+ } ) ;
76
79
77
80
export type PieArcProps = Omit < React . SVGProps < SVGPathElement > , 'ref' | 'id' > &
78
81
PieArcOwnerState & {
@@ -89,6 +92,7 @@ export type PieArcProps = Omit<React.SVGProps<SVGPathElement>, 'ref' | 'id'> &
89
92
90
93
const PieArc = React . forwardRef < SVGPathElement , PieArcProps > ( function PieArc ( props , ref ) {
91
94
const {
95
+ className,
92
96
classes : innerClasses ,
93
97
color,
94
98
dataIndex,
@@ -104,9 +108,13 @@ const PieArc = React.forwardRef<SVGPathElement, PieArcProps>(function PieArc(pro
104
108
outerRadius,
105
109
paddingAngle,
106
110
skipAnimation,
111
+ stroke : strokeProp ,
107
112
...other
108
113
} = props ;
109
114
115
+ const theme = useTheme ( ) ;
116
+ const stroke = strokeProp ?? ( theme . vars || theme ) . palette . background . paper ;
117
+
110
118
const ownerState = {
111
119
id,
112
120
dataIndex,
@@ -135,15 +143,15 @@ const PieArc = React.forwardRef<SVGPathElement, PieArcProps>(function PieArc(pro
135
143
onClick = { onClick }
136
144
cursor = { onClick ? 'pointer' : 'unset' }
137
145
ownerState = { ownerState }
138
- className = { classes . root }
146
+ className = { clsx ( classes . root , className ) }
139
147
fill = { ownerState . color }
140
148
opacity = { ownerState . isFaded ? 0.3 : 1 }
141
149
filter = { ownerState . isHighlighted ? 'brightness(120%)' : 'none' }
150
+ stroke = { stroke }
142
151
strokeWidth = { 1 }
143
152
strokeLinejoin = "round"
144
153
data-highlighted = { ownerState . isHighlighted || undefined }
145
154
data-faded = { ownerState . isFaded || undefined }
146
- data-focused = { isFocused || undefined }
147
155
{ ...other }
148
156
{ ...interactionProps }
149
157
{ ...animatedProps }
0 commit comments