@@ -8,6 +8,8 @@ import { useImperativeHandle, useRef } from 'react';
88import { placements } from './placements' ;
99import Popup from './Popup' ;
1010
11+ export type SemanticName = 'root' | 'arrow' | 'body' ;
12+
1113export interface TooltipProps
1214 extends Pick <
1315 TriggerProps ,
@@ -21,47 +23,46 @@ export interface TooltipProps
2123 | 'forceRender'
2224 | 'popupVisible'
2325 > {
26+ // Style
27+ classNames ?: Partial < Record < SemanticName , string > > ;
28+ styles ?: Partial < Record < SemanticName , React . CSSProperties > > ;
29+
30+ /** Config popup motion */
31+ motion ?: TriggerProps [ 'popupMotion' ] ;
32+
33+ /** @deprecated Please use `styles={{ root: {} }}` */
34+ overlayStyle ?: React . CSSProperties ;
35+ /** @deprecated Please use `classNames={{ root: '' }}` */
36+ overlayClassName ?: string ;
37+ /** @deprecated Please use `styles={{ body: {} }}` */
38+ overlayInnerStyle ?: React . CSSProperties ;
39+
40+ // Rest
2441 trigger ?: ActionType | ActionType [ ] ;
2542 defaultVisible ?: boolean ;
2643 visible ?: boolean ;
2744 placement ?: string ;
28- /** Config popup motion */
29- motion ?: TriggerProps [ 'popupMotion' ] ;
45+
3046 onVisibleChange ?: ( visible : boolean ) => void ;
3147 afterVisibleChange ?: ( visible : boolean ) => void ;
3248 overlay : ( ( ) => React . ReactNode ) | React . ReactNode ;
33- /** @deprecated Please use `styles={{ root: {} }}` */
34- overlayStyle ?: React . CSSProperties ;
35- /** @deprecated Please use `classNames={{ root: '' }}` */
36- overlayClassName ?: string ;
49+
3750 getTooltipContainer ?: ( node : HTMLElement ) => HTMLElement ;
3851 destroyOnHidden ?: boolean ;
3952 align ?: AlignType ;
4053 showArrow ?: boolean | ArrowType ;
4154 arrowContent ?: React . ReactNode ;
4255 id ?: string ;
43- /** @deprecated Please use `styles={{ body: {} }}` */
44- overlayInnerStyle ?: React . CSSProperties ;
56+
4557 zIndex ?: number ;
46- styles ?: TooltipStyles ;
47- classNames ?: TooltipClassNames ;
58+
4859 /**
4960 * Configures Tooltip to reuse the background for transition usage.
5061 * This is an experimental API and may not be stable.
5162 */
5263 unique ?: TriggerProps [ 'unique' ] ;
5364}
5465
55- export interface TooltipStyles {
56- root ?: React . CSSProperties ;
57- body ?: React . CSSProperties ;
58- }
59-
60- export interface TooltipClassNames {
61- root ?: string ;
62- body ?: string ;
63- }
64-
6566export interface TooltipRef extends TriggerRef { }
6667
6768const Tooltip = React . forwardRef < TooltipRef , TooltipProps > ( ( props , ref ) => {
@@ -108,7 +109,8 @@ const Tooltip = React.forwardRef<TooltipRef, TooltipProps>((props, ref) => {
108109 prefixCls = { prefixCls }
109110 id = { mergedId }
110111 bodyClassName = { tooltipClassNames ?. body }
111- overlayInnerStyle = { { ...overlayInnerStyle , ...tooltipStyles ?. body } }
112+ overlayInnerStyle = { overlayInnerStyle }
113+ style = { tooltipStyles ?. body }
112114 >
113115 { overlay }
114116 </ Popup >
@@ -124,6 +126,23 @@ const Tooltip = React.forwardRef<TooltipRef, TooltipProps>((props, ref) => {
124126 return React . cloneElement < any > ( children , childProps ) as any ;
125127 } ;
126128
129+ // Process arrow configuration
130+ const getArrowConfig = ( ) => {
131+ if ( ! showArrow ) {
132+ return false ;
133+ }
134+
135+ // Convert true to object for unified processing
136+ const arrowConfig = showArrow === true ? { } : showArrow ;
137+
138+ // Apply semantic styles with unified logic
139+ return {
140+ ...arrowConfig ,
141+ className : classNames ( arrowConfig . className , tooltipClassNames ?. arrow ) ,
142+ content : arrowConfig . content || arrowContent ,
143+ } ;
144+ } ;
145+
127146 return (
128147 < Trigger
129148 popupClassName = { classNames ( overlayClassName , tooltipClassNames ?. root ) }
@@ -143,7 +162,7 @@ const Tooltip = React.forwardRef<TooltipRef, TooltipProps>((props, ref) => {
143162 mouseLeaveDelay = { mouseLeaveDelay }
144163 popupStyle = { { ...overlayStyle , ...tooltipStyles ?. root } }
145164 mouseEnterDelay = { mouseEnterDelay }
146- arrow = { showArrow }
165+ arrow = { getArrowConfig ( ) }
147166 { ...extraProps }
148167 >
149168 { getChildren ( ) }
0 commit comments