export declare type VdsEventInit = CustomEventInit & { readonly originalEvent?: Event; }; export declare class VdsEvent extends CustomEvent { readonly originalEvent?: Event; /** * Walks up the event chain (following each `originalEvent`) and returns the origin event * that started the chain. */ get originEvent(): Event; /** * Walks up the event chain (following each `originalEvent`) and determines whether the initial * event was triggered by the end user (ie: check whether `isTrusted` on the `originEvent` `true`). */ get isOriginTrusted(): boolean; constructor(type: string, eventInit?: VdsEventInit); } /** * Walks up the event chain (following each `originalEvent`) and returns the origin event * that started the chain. * * @param event */ export declare function getOriginEvent(event: VdsEvent): Event | undefined; export declare function redispatchEvent(target: EventTarget, event: Event | CustomEvent | VdsEvent): void; export declare type ExtractEventDetail = Event extends VdsEvent ? I : never; export declare type ExtractEventInit = VdsEventInit>; /** * Helps build a `VdsEvent` with type safety. * * @param type * @param eventInit */ export declare function vdsEvent(type: EventType, eventInit?: ExtractEventInit): GlobalEventHandlersEventMap[EventType]; export declare type GlobalEventHandlerMap = { [EventType in keyof GlobalEventHandlersEventMap]?: (event: GlobalEventHandlersEventMap[EventType]) => void | Promise; }; /** * Listens to an event on the given `target` and returns a cleanup function to stop listening. * * @param target - The target to listen for the events on. * @param type - The name of the event to listen to. * @param listener - The function to be called when the event is fired. * @param options - Configures the event listener. * @returns Stop listening cleanup function. * @example * ```ts * const disposeListener = listen(window, 'resize', () => {}); * * // Stop listening. * disposeListener(); * ``` */ export declare function listen(target: EventTarget, type: EventType, listener: GlobalEventHandlerMap[EventType], options?: boolean | EventListenerOptions | AddEventListenerOptions): () => void; export declare function isPointerEvent(event: Event | undefined): event is PointerEvent; export declare function isVdsEvent(event: Event | undefined): event is VdsEvent;