|
1 | | -import * as React from 'react' |
2 | | -declare function useEvent< |
3 | | - T extends Window = Window, |
4 | | - K extends keyof WindowEventMap = keyof WindowEventMap |
5 | | ->( |
6 | | - target: Window | null, |
7 | | - type: K, |
8 | | - listener: WindowEventListener<K>, |
9 | | - cleanup?: (...args: any[]) => void |
10 | | -): void |
11 | | -declare function useEvent< |
12 | | - T extends Document = Document, |
13 | | - K extends keyof DocumentEventMap = keyof DocumentEventMap |
14 | | ->( |
15 | | - target: Document | null, |
16 | | - type: K, |
17 | | - listener: DocumentEventListener<K>, |
18 | | - cleanup?: (...args: any[]) => void |
19 | | -): void |
20 | | -declare function useEvent< |
21 | | - T extends HTMLElement = HTMLElement, |
22 | | - K extends keyof HTMLElementEventMap = keyof HTMLElementEventMap |
23 | | ->( |
24 | | - target: React.RefObject<T> | T | null, |
25 | | - type: K, |
26 | | - listener: ElementEventListener<K>, |
27 | | - cleanup?: (...args: any[]) => void |
28 | | -): void |
29 | | -export declare type ElementEventListener< |
30 | | - K extends keyof HTMLElementEventMap = keyof HTMLElementEventMap |
31 | | -> = (this: HTMLElement, ev: HTMLElementEventMap[K]) => any |
32 | | -export declare type DocumentEventListener< |
33 | | - K extends keyof DocumentEventMap = keyof DocumentEventMap |
34 | | -> = (this: Document, ev: DocumentEventMap[K]) => any |
35 | | -export declare type WindowEventListener< |
36 | | - K extends keyof WindowEventMap = keyof WindowEventMap |
37 | | -> = (this: Document, ev: WindowEventMap[K]) => any |
38 | | -export default useEvent |
| 1 | +import * as React from 'react'; |
| 2 | +declare function useEvent<T extends Window = Window, K extends keyof WindowEventMap = keyof WindowEventMap>(target: Window | null, type: K, listener: WindowEventListener<K>, cleanup?: (...args: any[]) => void): void; |
| 3 | +declare function useEvent<T extends Document = Document, K extends keyof DocumentEventMap = keyof DocumentEventMap>(target: Document | null, type: K, listener: DocumentEventListener<K>, cleanup?: (...args: any[]) => void): void; |
| 4 | +declare function useEvent<T extends HTMLElement = HTMLElement, K extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(target: React.RefObject<T> | T | null, type: K, listener: ElementEventListener<K>, cleanup?: (...args: any[]) => void): void; |
| 5 | +export declare type ElementEventListener<K extends keyof HTMLElementEventMap = keyof HTMLElementEventMap> = (this: HTMLElement, ev: HTMLElementEventMap[K]) => any; |
| 6 | +export declare type DocumentEventListener<K extends keyof DocumentEventMap = keyof DocumentEventMap> = (this: Document, ev: DocumentEventMap[K]) => any; |
| 7 | +export declare type WindowEventListener<K extends keyof WindowEventMap = keyof WindowEventMap> = (this: Document, ev: WindowEventMap[K]) => any; |
| 8 | +export default useEvent; |
0 commit comments