1
1
import React from "react" ;
2
- import PropTypes from "prop-types " ;
2
+ import { evaluateProp } from "../victory-util/helpers " ;
3
3
import { VictoryCommonPrimitiveProps } from "../victory-util/common-props" ;
4
4
5
5
export interface TextProps extends VictoryCommonPrimitiveProps {
@@ -9,19 +9,22 @@ export interface TextProps extends VictoryCommonPrimitiveProps {
9
9
}
10
10
11
11
export const Text = ( props : TextProps ) => {
12
- const { children, title, desc, ...rest } = props ;
12
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars --
13
+ * origin conflicts with the SVG element's origin attribute
14
+ */
15
+ const { children, desc, id, origin, tabIndex, title, ...rest } = props ;
16
+
17
+ const svgProps : React . SVGProps < SVGTextElement > = {
18
+ id : evaluateProp ( id , props ) ?. toString ( ) ,
19
+ tabIndex : evaluateProp ( tabIndex , props ) ,
20
+ ...rest ,
21
+ } ;
22
+
13
23
return (
14
- // @ts -expect-error FIXME: "id cannot be a number"
15
- < text { ...rest } >
24
+ < text { ...svgProps } >
16
25
{ title && < title > { title } </ title > }
17
26
{ desc && < desc > { desc } </ desc > }
18
27
{ children }
19
28
</ text >
20
29
) ;
21
30
} ;
22
-
23
- Text . propTypes = {
24
- children : PropTypes . node ,
25
- desc : PropTypes . string ,
26
- title : PropTypes . string ,
27
- } ;
0 commit comments