1- // Type definitions for react-popper-tooltip > v2.2.1
1+ // Type definitions for react-popper-tooltip > v2.4.0
22// Project: https://github.com/mohsinulhaq/react-popper-tooltip
33// Definitions by Johan Brook <https://github.com/brookback>
44
55declare module 'react-popper-tooltip' {
66 import * as React from 'react' ;
77 import Popper from 'popper.js' ;
88
9- type GetTriggerProps = (
10- props ?: {
11- onClick ?: ( evt : React . SyntheticEvent ) => void ;
12- onContextMenu ?: ( evt : React . SyntheticEvent ) => void ;
13- onMouseEnter ?: ( evt : React . SyntheticEvent ) => void ;
14- onMouseLeave ?: ( evt : React . SyntheticEvent ) => void ;
15- [ key : string ] : any ;
16- }
17- ) => {
18- onClick : ( evt : React . SyntheticEvent ) => void ;
19- onContextMenu : ( evt : React . SyntheticEvent ) => void ;
20- onMouseEnter : ( evt : React . SyntheticEvent ) => void ;
21- onMouseLeave : ( evt : React . SyntheticEvent ) => void ;
22- [ key : string ] : any ;
23- } ;
24-
25- export default class TooltipTrigger extends React . PureComponent < Props , { } > {
26- showTooltip ( ) : void ;
27-
28- hideTooltip ( ) : void ;
29-
30- toggleTooltip ( ) : void ;
31-
32- scheduleShow ( ) : void ;
33-
34- scheduleHide ( ) : void ;
35-
36- scheduleToggle ( ) : void ;
37-
38- getTriggerProps : GetTriggerProps ;
39- }
9+ /**
10+ * TooltipTrigger is the only component exposed by the package. It's just a positioning
11+ * engine. What to render is left completely to the user, which can be provided using
12+ * render props. Your props should be passed through getTriggerProps, getTooltipProps
13+ * and getArrowProps.
14+ */
15+ export default class TooltipTrigger extends React . PureComponent < Props , { } > { }
4016
4117 interface ChildProps {
42- getTriggerProps : GetTriggerProps ;
18+ /** Returns the props you should apply to the trigger element you render. */
19+ getTriggerProps : (
20+ props ?: {
21+ onClick ?: ( evt : React . SyntheticEvent ) => void ;
22+ onContextMenu ?: ( evt : React . SyntheticEvent ) => void ;
23+ onMouseEnter ?: ( evt : React . SyntheticEvent ) => void ;
24+ onMouseLeave ?: ( evt : React . SyntheticEvent ) => void ;
25+ [ key : string ] : any ;
26+ }
27+ ) => {
28+ onClick : ( evt : React . SyntheticEvent ) => void ;
29+ onContextMenu : ( evt : React . SyntheticEvent ) => void ;
30+ onMouseEnter : ( evt : React . SyntheticEvent ) => void ;
31+ onMouseLeave : ( evt : React . SyntheticEvent ) => void ;
32+ [ key : string ] : any ;
33+ } ;
34+ /** Returns the react ref you should apply to the trigger element. */
4335 triggerRef : React . RefObject < any > ;
4436 }
4537
4638 interface TooltipProps {
39+ /** Returns the props you should apply to the tooltip element you render. */
4740 getTooltipProps : (
4841 props ?: {
4942 style ?: React . CSSProperties ;
@@ -57,25 +50,75 @@ declare module 'react-popper-tooltip' {
5750 onMouseLeave : ( evt : React . SyntheticEvent ) => void ;
5851 [ key : string ] : any ;
5952 } ;
53+ /** Returns the react ref you should apply to the tooltip element. */
6054 tooltipRef : React . RefObject < any > ;
55+ /** Returns the props you should apply to the tooltip arrow element. */
6156 getArrowProps : ( props ?: any ) => {
6257 style : React . CSSProperties ;
6358 [ key : string ] : any ;
6459 } ;
60+ /** Returns the react ref you should apply to the tooltip arrow element. */
6561 arrowRef : React . RefObject < any > ;
62+ /**
63+ * Returns the placement of the tooltip.
64+ *
65+ * @see https://popper.js.org/popper-documentation.html#Popper.placements
66+ */
6667 placement : Popper . Placement ;
6768 }
6869
6970 export interface Props {
71+ /** The tooltip child. */
7072 tooltip : ( props : TooltipProps ) => JSX . Element ;
73+ /** The trigger child. */
7174 children : ( props : ChildProps ) => JSX . Element ;
75+ /** The initial visibility state of the tooltip. */
7276 defaultTooltipShown ?: boolean ;
77+ /**
78+ * Use this prop if you want to control the visibility state of the tooltip.
79+ *
80+ * React-popper-tooltip manages its own state internally. You can use this prop to
81+ * pass the visibility state of the tooltip from the outside. You will be required to
82+ * keep this state up to date (this is where onVisibilityChange becomes useful), but
83+ * you can also control the state from anywhere, be that state from other components,
84+ * redux, react-router, or anywhere else. */
7385 tooltipShown ?: boolean ;
86+ /** Called when the visibility of the tooltip changes.
87+ * `tooltipShown` is a new state. */
88+ onVisibilityChange : ( tooltipShown : boolean ) => void ;
89+ /** Delay in showing the tooltip (ms). Defaults to 0. */
7490 delayShow ?: number ;
91+ /** Delay in hiding the tooltip (ms). Defaults to 0. */
7592 delayHide ?: number ;
93+ /**
94+ * The event that triggers the tooltip. One of click, hover, right-click, none.
95+ * Defaults to hover.
96+ */
7697 trigger ?: 'click' | 'hover' | 'right-click' | 'none' ;
98+ /** Whether to close the tooltip when it's trigger is out of the boundary.
99+ * Defaults to true.
100+ */
77101 closeOnOutOfBoundaries ?: boolean ;
102+ /**
103+ * Modifiers passed directly to the underlying popper.js instance. For more
104+ * information, refer to Popper.js’ [modifier docs](https://popper.js.org/popper-documentation.html#modifiers).
105+ *
106+ * Default modifiers:
107+ ```
108+ {
109+ preventOverflow: {
110+ boundariesElement: 'viewport',
111+ padding: 0
112+ }
113+ }
114+ ```
115+ */
78116 modifiers ?: Popper . Modifiers ;
117+ /**
118+ * The tooltip placement.
119+ *
120+ * @see https://popper.js.org/popper-documentation.html#Popper.placements
121+ */
79122 placement ?: Popper . Placement ;
80123 }
81124}
0 commit comments