type EventHandlerMap = { [key in keyof HTMLElementEventMap]: (event: HTMLElementEventMap[key]) => unknown; }; type StyleMap = { [key in keyof CSSStyleDeclaration]: string; }; export interface CreateElementOptions { /** * FIXME: can we lock this down a bit? * * actually that might not be wise since we sometimes use "scope" type * attributes that are not standard (maybe we should fix that, instead?) */ attrs?: Record; /** * optionally style as a map */ style?: Partial; /** dataset or data-* attributes */ data?: Record; /** innerText */ text?: string; /** innerHTML */ html?: string; /** event handlers */ events?: Partial; } /** * we still need a good way to represent the 'no-DOM' context, * ideally without throwing exceptions. * */ export declare class DOMContext { protected static instances: DOMContext[]; /** * FIXME: how about we default to document, so it won't break? * that will make it harder to debug though. */ static GetInstance(doc?: Document): DOMContext; /** ugh sloppy */ doc?: Document; /** ugh sloppy */ view?: (Window & typeof globalThis) | null; /** class for `instanceof` comparison */ get HTMLElement(): { new (): HTMLElement; prototype: HTMLElement; } | undefined; protected constructor(doc?: Document); /** wrapper for window.getSelection */ GetSelection(): Selection | null | undefined; /** creates a div and assigns class name/names */ Div(classes?: string | string[], parent?: HTMLElement, options?: CreateElementOptions): HTMLDivElement; ClassNames(element: HTMLElement | SVGElement, classes: string | string[]): void; SVG(tag: K, classes?: string | string[], parent?: HTMLElement | SVGElement | DocumentFragment): SVGElementTagNameMap[K]; /** * this is a wrapper for createTextNode. but if we want to expose * the element/node classes (@see HTMLElement, above) then this * should properly be the Text class and not a method. So we should * rename it. * * @param data * @returns */ Text(data: string): Text; Fragment(): DocumentFragment; /** better typing */ Create(tag: K, classes?: string | string[], parent?: HTMLElement | DocumentFragment, options?: CreateElementOptions): HTMLElementTagNameMap[K]; } export {};