/** * Prop declarations for `defineElement`. Each key is a camelCase prop name * observed as its kebab-case attribute; the constructor picks the attribute * conversion (DESIGN §4.1). */ export type PropSpec = Record; /** The prop type a constructor declares (DESIGN §8). */ type PropType = C extends NumberConstructor ? number : C extends BooleanConstructor ? boolean : C extends StringConstructor ? string : unknown; /** * Props a declaration produces. Every prop can be absent (no attribute, no * property yet) except Boolean ones, which start as `false` (DESIGN §4.1). */ export type PropsOf = { [K in keyof S as S[K] extends BooleanConstructor ? K : never]: boolean; } & { [K in keyof S as S[K] extends BooleanConstructor ? never : K]?: PropType; }; /** What the inner component receives: the declared props and `host`. */ export type ElementProps = PropsOf & { host: HTMLElement; }; /** The element `defineElement` registers, with a property per prop. */ export type LithentElementOf = HTMLElement & PropsOf; export type DefineElementOptions = { props?: S; shadow?: boolean | 'open' | 'closed'; styles?: string[]; }; /** * Dispatch a DOM event from the element (DC-5). It is dispatched on the * element itself, so it bubbles to the host page; `composed` lets it also * leave an outer shadow root when the element is nested in another * component. It is cancelable: returns `false` when a listener called * `preventDefault()`. Pass `init` to change `bubbles`, `composed` or * `cancelable`. * * ```ts * const PayButton = mount<{ amount: number; host: HTMLElement }>( * (_renew, props) => () => * h('button', { onClick: () => emit(props.host, 'pay', props.amount) }, 'Pay') * ); * ``` */ export declare const emit: (host: Element, name: string, detail?: unknown, init?: EventInit) => boolean; /** * Register a lithent component as a Custom Element. * * The element owns the props and renders a small Host component that holds * `renew`; the user's component sits under it unchanged (DESIGN §2). * Returns `undefined` where Custom Elements do not exist (SSR, Node), and the * existing constructor when the name is already taken (DC-7). */ export declare const defineElement: >(name: `${string}-${string}`, component: (props: ElementProps, children?: never) => unknown, options?: DefineElementOptions) => (new () => LithentElementOf) | undefined; export {};