Skip to content

Commit 8b78c77

Browse files
authored
Merge pull request mohsinulhaq#8 from brookback/feature/typescript-typings
add TypeScript typings
2 parents 83fff9a + ec1216f commit 8b78c77

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

index.d.ts

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Type definitions for react-popper-tooltip > v2.0.1
2+
// Project: https://github.com/mohsinulhaq/react-popper-tooltip
3+
// Definitions by Johan Brook <https://github.com/brookback>
4+
5+
declare module 'react-popper-tooltip' {
6+
import * as React from 'react';
7+
import Popper from 'popper.js';
8+
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+
}
40+
41+
interface ChildProps {
42+
getTriggerProps: GetTriggerProps;
43+
triggerRef: React.RefObject<any>;
44+
}
45+
46+
interface TooltipProps {
47+
getTooltipProps: (
48+
props?: {
49+
style?: React.CSSProperties;
50+
onMouseLeave?: (evt: React.SyntheticEvent) => void;
51+
onMouseEnter?: (evt: React.SyntheticEvent) => void;
52+
[key: string]: any;
53+
}
54+
) => {
55+
style: React.CSSProperties;
56+
onMouseEnter: (evt: React.SyntheticEvent) => void;
57+
onMouseLeave: (evt: React.SyntheticEvent) => void;
58+
[key: string]: any;
59+
};
60+
tooltipRef: React.RefObject<any>;
61+
getArrowProps: (props: any) => {
62+
style: React.CSSProperties;
63+
[key: string]: any;
64+
};
65+
arrowRef: React.RefObject<any>;
66+
placement: Popper.Placement;
67+
}
68+
69+
export interface Props {
70+
tooltip: (props: TooltipProps) => JSX.Element;
71+
children: (props: ChildProps) => JSX.Element;
72+
defaultTooltipShown?: boolean;
73+
tooltipShown?: boolean;
74+
delayShow?: number;
75+
delayHide?: number;
76+
trigger?: 'click' | 'hover' | 'right-click' | 'none';
77+
closeOnOutOfBoundaries?: boolean;
78+
modifiers?: Popper.Modifiers;
79+
placement?: Popper.Placement;
80+
}
81+
}

0 commit comments

Comments
 (0)