/** * Declarative DOM rendering with reactive bindings. * * Parses tag selectors, creates elements (including SVG/MathML), and syncs * the virtual tree to the real DOM. Property accesses inside callbacks are * tracked by signal so that updates flow automatically on change. * * @module render */ /** * A value that is either the desired type directly, or a function that returns it. * * When a function is provided, it will be called inside a reactive * {@link effect} so that its return value updates automatically when * tracked properties change. * * @category Render * * @typeParam T The type of the value. */ export type ReactiveProperty = T | ((this: Node) => T); /** * A child node config value that can be passed to render or used as children. * If `null` or `undefined`, the child is skipped. * * @category Render */ export type NodeConfig = ElementConfig | Node | string | null | undefined; /** * Configuration object passed to {@link render} or used as a child config. * * Known keys (`tagName`, `className`, `attributes`, `dataset`, `style`, `children`, * `shadowRootMode`, `adoptedStyleSheets`, `namespaceURI`, `on`, `use`) are handled * by the renderer. All other keys are treated as element properties and bound reactively. * * @category Render */ export type ElementConfig = { /** Tag name. */ tagName?: string; /** CSS class name(s) applied to the element. Array falsy entries are filtered automatically. */ className?: ReactiveProperty; /** Map of HTML attributes to set on the element. */ attributes?: ReactiveProperty> & ThisType>; /** Map of `data-*` attributes to set on the element. */ dataset?: ReactiveProperty> & ThisType>; /** Map of inline CSS styles to apply. */ style?: ReactiveProperty> & ThisType>; /** Child nodes or config objects rendered inside the element. Falsy entries are skipped automatically. */ children?: ReactiveProperty; /** Shadow DOM mode for attaching a shadow root to the element. */ shadowRootMode?: "open" | "closed"; /** Style sheets adopted by the shadow root. */ adoptedStyleSheets?: CSSStyleSheet[]; /** Explicit namespace URI; auto-detected for SVG and MathML when omitted. */ namespaceURI?: string; /** Map of event names to handler functions. Includes native DOM events and * lifecycle events: `mounted`, `removed`, `updated`. */ on?: Partial & Record void>; /** A tag string, optionally with id and class selectors * (e.g., `"div#id1.cls1.cls2"`), an HTML markup, or existing element. */ use?: string | Element; } & Record> & ThisType; /** * Lifecycle event handlers for elements, triggered by {@link render}. * * @category Events */ export interface ElementLifecycle { /** Fired top-down when an element is appended to a parent. */ mounted: (this: Node, event: CustomEvent) => void; /** Fired top-down before cleanup when an element is removed from a parent. */ removed: (this: Node, event: CustomEvent) => void; /** Fired on the bound element after its property value changes. */ updated: (this: Node, event: CustomEvent<{ /** The name of the changed property. */ property: string; /** The property value before the change. */ oldValue: unknown; /** The property value after the change. */ newValue: unknown; }>) => void; } export declare function render(this: object | void, config: NodeConfig[], target?: Element | DocumentFragment | string): T; export declare function render(this: object | void, config: NodeConfig, target?: Element | DocumentFragment | string): T; //# sourceMappingURL=render.d.ts.map