import { t as ATTRIBUTES } from "./attributes-DILeh3-s.mjs"; //#region src/custom-elements.d.ts type RegisteredElementInstances = { [K in keyof ElementsKit.CustomElementRegistry]: ElementsKit.CustomElementRegistry[K] extends (abstract new (...args: any[]) => infer I) ? I : never }; declare global { namespace ElementsKit { interface CustomElementRegistry {} } interface HTMLElementTagNameMap extends RegisteredElementInstances {} } type CustomElementRegistry = ElementsKit.CustomElementRegistry; type AnyCtor = CustomElementConstructor; /** * @internal Public instance keys of `I`: for `HTMLElement` subclasses the * inherited DOM surface is dropped; for plain classes `render` is dropped. * Shared by the raw extractors here and the JSX helpers in jsx-runtime. */ type PublicPropKeys = I extends HTMLElement ? Exclude : Exclude; type InstanceOfCtor = C extends (abstract new (...args: any[]) => infer I) ? I : C; /** * Settable property surface of a custom-element class (or instance) — the * user's public fields, all optional, without the inherited `HTMLElement` * surface. Slot-backed props (`@slot()` accessors) appear here as their * `Node | null` read type — assignment fills the slot. * * @example * ```ts * class XCounter extends HTMLElement { count = 0; } * type P = PropertiesOf; // { count?: number } * ``` */ type PropertiesOf = InstanceOfCtor extends infer I ? { [K in PublicPropKeys & string]?: I[K] } : never; /** * Observed attributes of a custom-element class — every key of * `static [ATTRIBUTES]`, valued `string | null` (the raw HTML surface). * * @example * ```ts * type A = AttributesOf; // { min?: string | null; ... } * ``` */ type AttributesOf = C extends { [ATTRIBUTES]: infer M; } ? M extends Record ? string extends keyof M ? {} : { [K in keyof M & string]?: string | null } : {} : {}; /** * Raw event map of a custom-element class — `static events` verbatim. * Shape it however your host needs: `addEventListener` typing, framework * event bindings, or an `HTMLElementEventMap` augmentation. * * @example * ```ts * type E = EventsOf; // { commit: CustomEvent } * declare global { * interface HTMLElementEventMap extends EventsOf {} * } * ``` */ type EventsOf = C extends { events: infer E; } ? E extends Record ? E : {} : {}; /** * Register a custom element with the browser and return its class. * Pair with an augmentation of `ElementsKit.CustomElementRegistry` to get typed JSX. * * @example * ```tsx * import { defineElement } from "elements-kit/custom-elements"; * * class XCounter extends HTMLElement {} * * defineElement("x-counter", XCounter); * * declare global { * namespace ElementsKit { * interface CustomElementRegistry { * "x-counter": typeof XCounter; * } * } * } * * // JSX now gets typed props + typed ref * // * ``` */ declare function defineElement(tag: Tag, cls: C, options?: ElementDefinitionOptions): C; //#endregion export { PublicPropKeys as a, PropertiesOf as i, CustomElementRegistry as n, defineElement as o, EventsOf as r, AttributesOf as t };