declare class Expressions { #private; static MODE_EXPRESSION: symbol; static MODE_TEMPLATED: symbol; /** * Parses an expression. * @param {string} expression * @param {(typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED)?} [mode] * @returns the ast */ static parse(expression: string, mode?: (typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED) | null): any; /** * Evaluates an expression. * @param {{[k: string]: any } | null | undefined } modules * @param {any[]} dataStack * @param {any} ast * @param {(typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED)?} [mode] * @returns the result */ static evaluate(modules: { [k: string]: any; } | null | undefined, dataStack: any[], ast: any, mode?: (typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED) | null): any; /** * Parses and evaluates an expression. * @param {{ [x: string]: any; } | null | undefined} modules * @param {any[]} dataStack * @param {string} expression * @param {(typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED)?} [mode] * @returns the result */ static interpret(modules: { [x: string]: any; } | null | undefined, dataStack: any[], expression: string, mode?: (typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED) | null): any; } declare class ExpressionEvaluator { #private; constructor(modules: any, dataStack: any); withModule(name: any, value: any): ExpressionEvaluator; withOverlay(...data: any[]): ExpressionEvaluator; evaluate(expression: any, mode: any): any; evaluateExpression(expression: any): any; evaluateTemplated(expression: any): any; } declare class Fragments { /** * Creates a DocumentFragment from an string. * @param {...string} html * @returns {DocumentFragment} the fragment */ static fromHtml(...html: string[]): DocumentFragment; /** * Creates a string representation (HTML) of a DocumentFragment. * @param {DocumentFragment} fragment * @returns {string} the html */ static toHtml(fragment: DocumentFragment): string; /** * Checks if a fragment contains only blank text nodes * @param {DocumentFragment} fragment * @returns {boolean} true if the fragment is blank */ static isBlank(fragment: DocumentFragment): boolean; /** * Creates a DocumentFragment from nodes. * @param {...Node} nodes * @returns {DocumentFragment} the fragment */ static from(...nodes: Node[]): DocumentFragment; /** * Creates a DocumentFragment from childNodes of an element. * @param {Node} el * @returns {DocumentFragment} the fragment */ static fromChildNodes(el: Node): DocumentFragment; } declare class Attributes { static id: number; /** * Creates a unique id with the given prefix. * @param {string} prefix * @returns */ static uid(prefix: string): string; /** * Sets an attribute if not present. * @param {Element} el * @param {string} k * @param {string} v * @returns */ static defaultValue(el: Element, k: string, v: string): string | null; /** * Forwards prefixed attributes from an element to another (removing the prefix). * @param {string} prefix * @param {Element} from * @param {Element} to */ static forward(prefix: string, from: Element, to: Element): void; /** * Changes the presence of an attribute. * @param {Element} el * @param {string} attr * @param {boolean} value */ static toggle(el: Element, attr: string, value: boolean): void; /** * Changes the presence of an attribute based on its current state. * @param {Element} el * @param {string} attr */ static flip(el: Element, attr: string): void; /** * Sets the value of an attribute. nullish values remove the attribute. * @param {Element} el * @param {string} attr * @param {string | null | undefined} value */ static set(el: Element, attr: string, value: string | null | undefined): void; } declare class LightSlots { /** * Extracts light slots from an element. For non default slots in a template tag, the content is extracted. * @param {Element} el * @returns the slots */ static from(el: Element): { default: DocumentFragment; }; static slotFromNode(el: any): any; } declare class Nodes { /** * Checks if an element is already parsed. * @param {Element} el * @returns */ static isParsed(el: Element): boolean; static waitParsed(el: any): Promise; /** * Returns the first child of the element element (if exists) matching the selector. * @param {Element} el * @param {string} selector * @returns */ static queryChildren(el: Element, selector: string): Element | null; /** * Returns all children of the element matching the selector. * @param {Element} el * @param {string} selector * @returns */ static queryChildrenAll(el: Element, selector: string): Element[]; } declare class Template { #private; /** * Creates a template from a string. * @param {string} html * @param {{ [k: string] : any }?} [modules] * @param {...*} data * @returns the template */ static fromHtml(html: string, modules?: { [k: string]: any; } | null, ...data: any[]): Template; /** * Creates a template from the content of the first template element matching the selector. * @param {string} selector for an HTMLTemplateElement * @param {{ [k: string] : any }?} [modules] * @param {...*} data * @returns the template */ static fromSelector(selector: string, modules?: { [k: string]: any; } | null, ...data: any[]): Template; /** * Creates a template from the content of an HTMLTemplateElement. * @param {HTMLTemplateElement} templateEl * @param {{ [k: string] : any }?} [modules] * @param {...*} data * @returns the template */ static fromTemplate(templateEl: HTMLTemplateElement, modules?: { [k: string]: any; } | null, ...data: any[]): Template; /** * Creates a template from a DocumentFragment. * @param {DocumentFragment} fragment * @param { { [k: string] : any }? } [modules] * @param {...*} data * @returns the template */ static fromFragment(fragment: DocumentFragment, modules?: { [k: string]: any; } | null, ...data: any[]): Template; /** * Creates a template. * @param {DocumentFragment} fragment * @param {{ [x: string]: any; } | null | undefined} modules * @param {any[]} dataStack */ constructor(fragment: DocumentFragment, modules: { [x: string]: any; } | null | undefined, dataStack: any[]); /** * Creates a new Template replacing the modules and dataStack from a context. * @param {{modules: { [x: string]: any; } | null | undefined, data: any[]}} context */ withContext({ modules, data }: { modules: { [x: string]: any; } | null | undefined; data: any[]; }): Template; /** * Creates a new Template replacing the modules and dataStack from a registry. * @param any registry */ withContextFrom(registry: any): Template; /** * Creates a new Template replacing the fragment. * @param {DocumentFragment} fragment */ withFragment(fragment: DocumentFragment): Template; /** * Creates a new Template with a new module added. * @param {string?} name * @param {{[k: string]: any}} value */ withModule(name: string | null, value: { [k: string]: any; }): Template; /** * Creates a new Template replacing the modules. * @param {{ [x: string]: any; }?} modules */ withModules(modules: { [x: string]: any; } | null): Template; /** * Creates a new Template replacing the data stack. * @param {any[]} dataStack the dataStack */ withData(dataStack: any[]): Template; /** * Creates a new Template with new a data overlay added to the stack. * @param {...*} data */ withOverlay(...data: any[]): Template; /** * Evaluates an expression using the configured modules and data. * @param {string} expression * @param {(typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED)?} [mode] * @param {...*} data */ evaluate(expression: string, mode?: (typeof Expressions.MODE_EXPRESSION | typeof Expressions.MODE_TEMPLATED) | null, ...data: any[]): void; /** * Returns an expression evaluator with bound modules and dataStack. */ evaluator(): ExpressionEvaluator; /** * Renders the template. * @returns a DocumentFragment */ render(): DocumentFragment; /** * Renders this template on the Element (replacing children). * @param {Element} el */ renderTo(el: Element): void; /** * Renders this template appending the resulting fragment to the Element. * @param {Element} el */ appendTo(el: Element): void; /** * Renders this template appending the resulting fragment to the first Element maching the selector, if exists. * @param {string} selector */ renderToSelector(selector: string): void; /** * Renders this template appending the resulting fragment to the Element maching the selector, if exists. * @param {string} selector */ appendToSelector(selector: string): void; } declare class RenderError extends Error { #private; node: any; constructor(message: any, nodeOrFragment: any, cause: any); static stringify(nodeOrFragment: any): string; } declare class Registry { #private; defineElement(tag: any, klass: any): this; defineModule(name: any, value: any): this; defineModules(ms: any): this; defineComponent(name: any, value: any): this; defineData(...data: any[]): this; defineOverlay(...data: any[]): this; defineMapper(k: any, v: any): this; plugin(p: any): this; configure(): this; get upgrades(): MapIterator<[any, any]>; context(): { modules: any; data: any[]; }; evaluator(): ExpressionEvaluator; component(name: any): any; } declare const registry: Registry; declare class Templates { static fromHtml(html: any): Template; static fromSelector(selector: any): Template; static fromTemplate(templateEl: any): Template; static fromFragment(fragment: any): Template; } declare class Rendering { static waitFor(el: any): Promise; static waitForChildren(el: any): Promise; } export type Mapper = { unmarshal: (val: string | null | undefined, name: string, el: Element) => any; marshal: (val: any, name: string, el: Element) => string | null; }; /** * An attribute Mapper. * * @typedef {object} Mapper * @property {(val: string|null|undefined, name: string, el: Element) => any} unmarshal * @property {(val: any, name: string, el: Element) => string|null} marshal */ declare class ParsedElement extends HTMLElement { #private; static BITS: { enqueue: (el: any) => void; SLOTS: boolean; OBSERVED: never[]; /** @type {Record} */ ATTR_TO_MAPPER: Record; TEMPLATES: {}; }; static get observedAttributes(): never[]; unmarshal(attr: any, str: any): any; marshal(attr: any, value: any): string | null; /** * @param {string} [name] - The name of the template target, defaults to 'default' */ template(name?: string): any; connectedCallback(): void; attributeChangedCallback(attr: any, oldValue: any, newValue: any): void; formDisabledCallback(disabled: any): void; upgrade(): Promise; render(c: any): void; reflect(fn: any): void; reflectTo(attr: any, value: any): void; } export { Attributes, ExpressionEvaluator, Expressions, Fragments, LightSlots, Nodes, ParsedElement, Registry, RenderError, Rendering, Template, Templates, registry }; export as namespace ftl;