UNPKG

@liberquack/utils

Version:
28 lines (27 loc) 1.23 kB
import { Assign } from "utility-types"; import { Narrow } from "../utils.js"; declare type TypedCustomEvent<N extends string, T> = Narrow<CustomEvent, { type: N; detail?: T; }>; export declare function CreateCustomEvent<N extends string, T>(type: N, eventInit?: CustomEventInit<T>): TypedCustomEvent<N, T>; export declare type CustomEvents = { [x: string]: any; }; declare type EventDispatcher<E extends CustomEvents = {}> = { dispatchEvent<K extends Extract<keyof E, string>>(event: TypedCustomEvent<K, E[K]>): boolean; }; export declare type EventListener<E extends CustomEvents = {}> = { addEventListener<K extends Extract<keyof E, string>>(type: K, listener: (e: Narrow<CustomEvent, { detail: E[K]; }>) => void, options?: boolean | AddEventListenerOptions): void; }; export declare type CustomElement<P extends object = {}, E extends CustomEvents = {}> = Assign<HTMLElement, P & EventDispatcher<E>>; export declare type CustomElementDefinition<P extends object = {}, E extends CustomEvents = {}> = (this: CustomElement<P, E>, props: P) => any; export declare type ControlProps<P extends object = {}> = Assign<{ name: string; label: any; value?: any; errMsg?: any; }, P>; export {};