import { ClassValue, EventListener, NODE, NodeTarget, StyleValue, TagNameMap } from "./element-common.js"; import { Expression } from "./signals.js"; import { Content } from "./types.js"; export declare class ElementBuilder implements NodeTarget { #private; /** * The target element this builder is modifying. */ elem: E; get [NODE](): E; /** * Create a new element builder for the specified element. * * For also creating an element, use the {@link e} shorthand. * * @param elem The element to modify. */ constructor(elem: E); /** * Append an event listener. * * @param type The event type to listen for. * @param listener The event listener function. The current context is available within this listener. * @param options Optional add event listener options. * * @example * ```tsx * e("button").on("click", event => { ... }) * * e("div").on("scroll", event => { ... }, { capture: true }) * ``` */ on(type: K, listener: EventListener, options?: AddEventListenerOptions): this; on(type: string, listener: EventListener, options?: AddEventListenerOptions): this; /** * Set element styles. * * @param value Any combination of arrays, objects and expressions. * + Properties use the same casing as in css. E.g. `font-family`, not `fontFamily`. * + Properties specified later take precedence over earlier properties. * * @example * ```tsx * e("div").style({ color: "red" }) * * e("div").style([ * { * "color": "red", * "font-size": "1rem", * }, * () => ({ "color": () => "blue" }), * { "color": someSignal }, * [ * { "width": "42px" }, * ], * ]) * ``` */ style(value: StyleValue): Omit; /** * Set element classes. * * @param value Any combination of class tokens, arrays and objects with boolean expressions to determine which classes are added. `undefined`, `null` and `false` is ignored. * * @example * ```tsx * e("div").class("example") * * e("div").class([ * "foo", * () => "bar", * { * baz: true, * boo: () => false, * }, * ]) * ``` */ class(value: ClassValue): Omit; /** * Set an attribute. * * @param name The name. * @param value An expression for the value. * * @example * ```tsx * e("img").set("src", someSignal).set("alt", "Example") * ``` */ set(name: string, value: Expression): this; /** * Set a property. * * @param name The name. * @param value An expression for the value. * * @example * ```tsx * e("input").prop("value", someValue) * ``` */ prop(name: K, value: Expression): this; /** * Append content. * * + Any expression will be rendered as text. * + DOM nodes. * + Views. * + Arrays, jsx fragments & any combination of the above. * * @example * ```tsx * e("h1").append("Hello World!") * * e("div").append([ * ["Hello World!"], * e("div"), * ... * ]) * ``` */ append(...content: Content[]): this; } /** * Create a new element builder. * * This uses the current {@link XMLNS} value to determine the namespace. * * @param tagName The tag name. * @returns The builder. * * @example * ```tsx * e("h1").append("Hello World!") * * XMLNS.provide(SVG, () => { * return e("svg").set("viewbox", "0 0 ...") * }) * ``` */ export declare function e(tagName: K): ElementBuilder; export declare function e(tagName: string): ElementBuilder; //# sourceMappingURL=element-builder.d.ts.map