UNPKG

2.34 kBTypeScriptView Raw
1import * as React from 'react';
2import * as PopperJS from '@popperjs/core';
3export declare type TriggerType = 'click' | 'double-click' | 'right-click' | 'hover' | 'focus';
4export declare type Config = {
5 /**
6 * Whether to close the tooltip when its trigger is out of boundary
7 * @default false
8 */
9 closeOnTriggerHidden?: boolean;
10 /**
11 * Event or events that trigger the tooltip
12 * @default hover
13 */
14 trigger?: TriggerType | TriggerType[] | null;
15 /**
16 * Delay in hiding the tooltip (ms)
17 * @default 0
18 */
19 delayHide?: number;
20 /**
21 * Delay in showing the tooltip (ms)
22 * @default 0
23 */
24 delayShow?: number;
25 /**
26 * Whether to make the tooltip spawn at cursor position
27 * @default false
28 */
29 followCursor?: boolean;
30 /**
31 * Options to MutationObserver, used internally for updating
32 * tooltip position based on its DOM changes
33 * @default { attributes: true, childList: true, subtree: true }
34 */
35 mutationObserverOptions?: MutationObserverInit | null;
36 /**
37 * Whether tooltip is shown by default
38 * @default false
39 */
40 defaultVisible?: boolean;
41 /**
42 * Used to create controlled tooltip
43 */
44 visible?: boolean;
45 /**
46 * Called when the visibility of the tooltip changes
47 */
48 onVisibleChange?: (state: boolean) => void;
49 /**
50 * If `true`, a click outside the trigger element closes the tooltip
51 * @default true
52 */
53 closeOnOutsideClick?: boolean;
54 /**
55 * If `true`, hovering the tooltip will keep it open. Normally tooltip closes when the mouse cursor moves out of
56 * the trigger element. If it moves to the tooltip element, the tooltip stays open.
57 * @default false
58 */
59 interactive?: boolean;
60 /**
61 * Alias for popper.js placement, see https://popper.js.org/docs/v2/constructors/#placement
62 */
63 placement?: PopperJS.Placement;
64 /**
65 * Shorthand for popper.js offset modifier, see https://popper.js.org/docs/v2/modifiers/offset/
66 * @default [0, 6]
67 */
68 offset?: [number, number];
69};
70export declare type PopperOptions = Partial<PopperJS.Options> & {
71 createPopper?: typeof PopperJS.createPopper;
72};
73export declare type PropsGetterArgs = {
74 style?: React.CSSProperties;
75 [key: string]: unknown;
76};