import classNames from "classnames" ; import * as React from "react" ; import { Classes as CoreClasses , DISPLAYNAME_PREFIX , IntentProps } from "@blueprintjs/core" ; import * as Classes from "./classes" ; import { Popover2 , Popover2InteractionKind } from "./popover2" ; import { TOOLTIP_ARROW_SVG_SIZE } from "./popover2Arrow" ; import { Popover2SharedProps } from "./popover2SharedProps" ; import { Tooltip2Context , Tooltip2ContextState , Tooltip2Provider } from "./tooltip2Context" ; export type Tooltip2Props < TProps = React . HTMLProps < HTMLElement > > = ITooltip2Props < TProps > ; deprecated export interface ITooltip2Props < TProps = React . HTMLProps < HTMLElement > > extends Omit < Popover2SharedProps < TProps > , "shouldReturnFocusOnClose" > , IntentProps { /**
     * The content that will be displayed inside of the tooltip.
     */ content : JSX . Element | string ; default hoverCloseDelay ? : number ; default hoverOpenDelay ? : number ; default interactionKind ? : typeof Popover2InteractionKind . HOVER | typeof Popover2InteractionKind . HOVER_TARGET_ONLY ; default transitionDuration ? : number ; } export class Tooltip2 < T > extends React . PureComponent < Tooltip2Props < T > > { public static displayName = `${ DISPLAYNAME_PREFIX }.Tooltip2` ; public static defaultProps : Partial < Tooltip2Props > = { hoverCloseDelay : 0 , hoverOpenDelay : 100 , minimal : false , transitionDuration : 100 , } ; private popover : Popover2 < T > | null = null ; public render ( ) { return ( < Tooltip2Context . Consumer > { ( [ state ] ) => < Tooltip2Provider { ... state } > { this . renderPopover } < /Tooltip2Provider>} < /Tooltip2Context.Consumer>); } public reposition ( ) { if ( this . popover != null ) { this . popover . reposition ( ) ; } } private renderPopover = ( ctxState ) => { const { children , disabled , intent , popoverClassName , ... restProps } = this . props ; const classes = classNames ( Classes . TOOLTIP2 , { [ CoreClasses . MINIMAL ] : this . props . minimal } , CoreClasses . intentClass ( intent ) , popoverClassName ) ; return ( < Popover2 interactionKind = { Popover2InteractionKind . HOVER_TARGET_ONLY } modifiers = { { arrow : { enabled : ! this . props . minimal , } , offset : { options : { offset : [ 0 , TOOLTIP_ARROW_SVG_SIZE / 2 ] , } , } , } } { ... restProps } autoFocus = { false } canEscapeKeyClose = { false } disabled = { ctxState . forceDisabled ?? disabled } enforceFocus = { false } lazy = { true } popoverClassName = { classes } portalContainer = { this . props . portalContainer } ref = { ref => ( this . popover = ref ) } > { children } < /Popover2>); } ; }