UNPKG

3.43 kBTypeScriptView Raw
1import * as React from 'react';
2import type { placements as Placements } from 'rc-tooltip/lib/placements';
3import type { TooltipProps as RcTooltipProps } from 'rc-tooltip/lib/Tooltip';
4import type { PresetColorType } from '../_util/colors';
5import type { RenderFunction } from '../_util/getRenderPropValue';
6import type { AdjustOverflow, PlacementsConfig } from '../_util/placements';
7import type { LiteralUnion } from '../_util/type';
8import PurePanel from './PurePanel';
9export type { AdjustOverflow, PlacementsConfig };
10export interface TooltipRef {
11 /** @deprecated Please use `forceAlign` instead */
12 forcePopupAlign: VoidFunction;
13 forceAlign: VoidFunction;
14}
15export type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
16export interface TooltipAlignConfig {
17 points?: [string, string];
18 offset?: [number | string, number | string];
19 targetOffset?: [number | string, number | string];
20 overflow?: {
21 adjustX: boolean;
22 adjustY: boolean;
23 };
24 useCssRight?: boolean;
25 useCssBottom?: boolean;
26 useCssTransform?: boolean;
27}
28interface LegacyTooltipProps extends Partial<Omit<RcTooltipProps, 'children' | 'visible' | 'defaultVisible' | 'onVisibleChange' | 'afterVisibleChange' | 'destroyTooltipOnHide'>> {
29 open?: RcTooltipProps['visible'];
30 defaultOpen?: RcTooltipProps['defaultVisible'];
31 onOpenChange?: RcTooltipProps['onVisibleChange'];
32 afterOpenChange?: RcTooltipProps['afterVisibleChange'];
33 /** @deprecated Please use `open` instead. */
34 visible?: RcTooltipProps['visible'];
35 /** @deprecated Please use `defaultOpen` instead. */
36 defaultVisible?: RcTooltipProps['defaultVisible'];
37 /** @deprecated Please use `onOpenChange` instead. */
38 onVisibleChange?: RcTooltipProps['onVisibleChange'];
39 /** @deprecated Please use `afterOpenChange` instead. */
40 afterVisibleChange?: RcTooltipProps['afterVisibleChange'];
41}
42export interface AbstractTooltipProps extends LegacyTooltipProps {
43 style?: React.CSSProperties;
44 className?: string;
45 rootClassName?: string;
46 color?: LiteralUnion<PresetColorType>;
47 placement?: TooltipPlacement;
48 builtinPlacements?: typeof Placements;
49 openClassName?: string;
50 /** @deprecated Please use `arrow={{ pointAtCenter: true }}` instead. */
51 arrowPointAtCenter?: boolean;
52 arrow?: boolean | {
53 /** @deprecated Please use `pointAtCenter` instead. */
54 arrowPointAtCenter?: boolean;
55 pointAtCenter?: boolean;
56 };
57 autoAdjustOverflow?: boolean | AdjustOverflow;
58 getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
59 children?: React.ReactNode;
60 destroyTooltipOnHide?: boolean | {
61 keepParent?: boolean;
62 };
63}
64export interface TooltipPropsWithOverlay extends AbstractTooltipProps {
65 title?: React.ReactNode | RenderFunction;
66 overlay?: React.ReactNode | RenderFunction;
67}
68export interface TooltipPropsWithTitle extends AbstractTooltipProps {
69 title: React.ReactNode | RenderFunction;
70 overlay?: React.ReactNode | RenderFunction;
71}
72export declare type TooltipProps = TooltipPropsWithTitle | TooltipPropsWithOverlay;
73declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<unknown>> & {
74 _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
75};
76export default Tooltip;