forked from ReactTooltip/react-tooltip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTooltipTypes.d.ts
162 lines (148 loc) · 3.52 KB
/
TooltipTypes.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import type { ElementType, ReactNode, CSSProperties, RefObject } from 'react'
export type PlacesType =
| 'top'
| 'top-start'
| 'top-end'
| 'right'
| 'right-start'
| 'right-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end'
export type VariantType = 'dark' | 'light' | 'success' | 'warning' | 'error' | 'info'
export type WrapperType = ElementType | 'div' | 'span'
export type ChildrenType = Element | ElementType | ReactNode
export type EventsType = 'hover' | 'click'
export type PositionStrategy = 'absolute' | 'fixed'
export type DataAttribute =
| 'place'
| 'content'
| 'html'
| 'variant'
| 'offset'
| 'wrapper'
| 'events'
| 'position-strategy'
| 'delay-show'
| 'delay-hide'
| 'float'
| 'hidden'
| 'class-name'
/**
* @description floating-ui middleware
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Middleware = any
export interface IPosition {
x: number
y: number
}
export interface TooltipImperativeOpenOptions {
anchorSelect?: string
position?: IPosition
place?: PlacesType
content?: ChildrenType
/**
* @description Delay (in ms) before opening the tooltip.
*/
delay?: number
}
export interface TooltipImperativeCloseOptions {
/**
* @description Delay (in ms) before closing the tooltip.
*/
delay?: number
}
export interface TooltipRefProps {
open: (options?: TooltipImperativeOpenOptions) => void
close: (options?: TooltipImperativeCloseOptions) => void
/**
* @readonly
*/
activeAnchor: HTMLElement | null
/**
* @readonly
*/
place: PlacesType
/**
* @readonly
*/
isOpen: boolean
}
export type AnchorOpenEvents = {
mouseenter?: boolean
focus?: boolean
mouseover?: boolean
click?: boolean
dblclick?: boolean
mousedown?: boolean
}
export type AnchorCloseEvents = {
mouseleave?: boolean
blur?: boolean
mouseout?: boolean
click?: boolean
dblclick?: boolean
mouseup?: boolean
}
export type GlobalCloseEvents = {
escape?: boolean
scroll?: boolean
resize?: boolean
clickOutsideAnchor?: boolean
}
export interface ITooltip {
forwardRef?: React.ForwardedRef<TooltipRefProps>
className?: string
classNameArrow?: string
content?: ChildrenType
contentWrapperRef?: RefObject<HTMLDivElement>
place?: PlacesType
offset?: number
id?: string
variant?: VariantType
/**
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
* See https://react-tooltip.com/docs/getting-started
*/
anchorId?: string
anchorSelect?: string
wrapper: WrapperType
/**
* @deprecated Use `openOnClick` instead.
*/
events?: EventsType[]
openOnClick?: boolean
positionStrategy?: PositionStrategy
middlewares?: Middleware[]
delayShow?: number
delayHide?: number
float?: boolean
hidden?: boolean
noArrow?: boolean
clickable?: boolean
closeOnEsc?: boolean
closeOnScroll?: boolean
closeOnResize?: boolean
openEvents?: AnchorOpenEvents
closeEvents?: AnchorCloseEvents
globalCloseEvents?: GlobalCloseEvents
imperativeModeOnly?: boolean
style?: CSSProperties
position?: IPosition
isOpen?: boolean
defaultIsOpen?: boolean
setIsOpen?: (value: boolean) => void
afterShow?: () => void
afterHide?: () => void
disableTooltip?: (anchorRef: HTMLElement | null) => boolean
activeAnchor: HTMLElement | null
setActiveAnchor: (anchor: HTMLElement | null) => void
border?: CSSProperties['border']
opacity?: CSSProperties['opacity']
arrowColor?: CSSProperties['backgroundColor']
role?: React.AriaRole
}