@thi.ng/rdom
Version:
Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible
42 lines • 1.78 kB
TypeScript
import type { IComponent } from "./api.js";
/**
* Compiles a tree of components given in any supported format incl. reactive
* state values into a single, nested {@link IComponent}.
*
* @remarks
* Supported formats/values:
*
* - hiccup component trees, i.e. `["tag#id.class", attribs, [...]]`
* - {@link IComponent} instances
* - pre-existing DOM elements
* - [`ISubscribable`](https://docs.thi.ng/umbrella/rstream/interfaces/ISubscribable.html)
* instances
* - [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
* instances
* - functions embedded in hiccup, i.e. either:
* - `[fn, ...args]`
* - `["tag", {}, ... noArgFn ...]`
*
* Any other value type will be wrapped in a `<span>` element. Reactive
* `ISubscribable` values can be used as element attributes or element
* body/children. For the former, a subscription will be added to update the
* target attribute. If used as element body, the reactive value will be wrapped
* using a {@link $sub} `<span>` with the value as its reactive body.
*
* If given any of the supported embedded function forms, the function will be
* called with given args (or without) and the result passed back to
* `$compile()`.
*
* **Important:** Use {@link $replace}, {@link $refresh} or {@link $switch} to
* wrap any reactive values/subscriptions which produce actual HTML
* elements/components/subtrees (in hiccup format). See docs for these functions
* for details & examples. Not using any of these wrappers will result in
* unexpected outcomes.
*
* Also see {@link $wrapText}, {@link $wrapHtml} or {@link $wrapEl} for DOM
* element related component wrappers.
*
* @param tree -
*/
export declare const $compile: (tree: any) => IComponent;
//# sourceMappingURL=compile.d.ts.map