import { EventPriority } from "../../../reconciler/event-phase"; import type { ElementLifecycle } from "../../element-extender"; import type { GjsElement } from "../../gjs-element"; export type BindableProps> = keyof { [K in keyof R as R[K] extends Function | undefined ? K : never]: K; }; type EventConnect = (signal: K, callback: (target: any, ...args: A) => boolean) => number; type Widget = { connect: EventConnect; disconnect: (id: number) => void; }; type SyntheticEventPropsGenerator = (...args: A) => Record; export type SyntheticEvent = {}, T extends GjsElement = GjsElement> = A & { stopPropagation(): void; preventDefault(): void; originalEvent: any; target: T; targetWidget: ReturnType; }; /** A helper class to bind props callbacks to the widget's `connect`. */ export declare class EventHandlers, P extends Record> { private element; private bindEvents; private internalBinds; private listeners; constructor(element: { getWidget: () => W; lifecycle: ElementLifecycle; }); private update; private unbindAll; bindInternal(signal: K, handler: W["connect"] extends EventConnect ? (event: SyntheticEvent) => void : never, eventPhase?: EventPriority): void; /** * Binds the function that this elements receives in the specified * "prop" to the signal type of the widget of this Element. * * @example * handler.bind("clicked", "onClick"); * // This makes it so that all "clicked" signals from the * // widget are forwarded to the "onClick" function that * // exists of this element properties, if such prop is defined. */ bind(signal: K, propName: W["connect"] extends EventConnect ? BindableProps

: never, getArgs?: SyntheticEventPropsGenerator, eventPhase?: EventPriority): void; addListener(signal: string, callback: (widget: W, event?: unknown) => boolean | void): void; removeListener(signal: string, callback: (widget: W, event?: unknown) => boolean | void): void; notifyWidgetDestroyedOutsideLifecycle(): void; } export declare class EventNoop extends Error { constructor(); } export {};