1
1
import * as React from 'react' ;
2
- import type { AlignType } from '../interface' ;
2
+ import classNames from 'classnames' ;
3
+ import type { AlignType , ArrowType } from '../interface' ;
3
4
4
5
export interface ArrowProps {
5
6
prefixCls : string ;
6
7
align : AlignType ;
7
- arrowX ?: number ;
8
- arrowY ?: number ;
8
+ arrow : ArrowType ;
9
9
}
10
10
11
11
export default function Arrow ( props : ArrowProps ) {
12
- const { prefixCls, align, arrowX = 0 , arrowY = 0 } = props ;
12
+ const { prefixCls, align, arrow } = props ;
13
+
14
+ const { x = 0 , y = 0 , className } = arrow || { } ;
13
15
14
16
const arrowRef = React . useRef < HTMLDivElement > ( ) ;
15
17
@@ -33,7 +35,7 @@ export default function Arrow(props: ArrowProps) {
33
35
34
36
// Top & Bottom
35
37
if ( popupTB === targetTB || ! [ 't' , 'b' ] . includes ( popupTB ) ) {
36
- alignStyle . top = arrowY ;
38
+ alignStyle . top = y ;
37
39
} else if ( popupTB === 't' ) {
38
40
alignStyle . top = 0 ;
39
41
} else {
@@ -42,7 +44,7 @@ export default function Arrow(props: ArrowProps) {
42
44
43
45
// Left & Right
44
46
if ( popupLR === targetLR || ! [ 'l' , 'r' ] . includes ( popupLR ) ) {
45
- alignStyle . left = arrowX ;
47
+ alignStyle . left = x ;
46
48
} else if ( popupLR === 'l' ) {
47
49
alignStyle . left = 0 ;
48
50
} else {
@@ -51,6 +53,6 @@ export default function Arrow(props: ArrowProps) {
51
53
}
52
54
53
55
return (
54
- < div ref = { arrowRef } className = { `${ prefixCls } -arrow` } style = { alignStyle } />
56
+ < div ref = { arrowRef } className = { classNames ( `${ prefixCls } -arrow` , className ) } style = { alignStyle } />
55
57
) ;
56
58
}
0 commit comments