1 | import type { BasicTarget } from '../utils/domTarget';
|
2 | type noop = (...p: any) => void;
|
3 | export type Target = BasicTarget<HTMLElement | Element | Window | Document>;
|
4 | type Options<T extends Target = Target> = {
|
5 | target?: T;
|
6 | capture?: boolean;
|
7 | once?: boolean;
|
8 | passive?: boolean;
|
9 | };
|
10 | declare function useEventListener<K extends keyof HTMLElementEventMap>(eventName: K, handler: (ev: HTMLElementEventMap[K]) => void, options?: Options<HTMLElement>): void;
|
11 | declare function useEventListener<K extends keyof ElementEventMap>(eventName: K, handler: (ev: ElementEventMap[K]) => void, options?: Options<Element>): void;
|
12 | declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (ev: DocumentEventMap[K]) => void, options?: Options<Document>): void;
|
13 | declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (ev: WindowEventMap[K]) => void, options?: Options<Window>): void;
|
14 | declare function useEventListener(eventName: string, handler: noop, options: Options): void;
|
15 | export default useEventListener;
|