import { ref as litRef } from "lit-html/directives/ref.js"; export interface MatesRef { readonly value: T | undefined; __subscribe: (fn: (el: T | undefined) => void) => () => void; readonly __isMatesRef__: true; } /** * Creates a `MatesRef` — a reactive reference that holds a DOM element, * or `undefined` when no element is currently attached. * * The actual value is managed exclusively by the `setRef` directive; you * should never call `__set` directly. * * @typeParam T - The element type held by this ref (defaults to `Element`). * * ### Members * - **`value`** — the current element, or `undefined` before the element is * attached (pre-render) or after it is detached (unmount / conditional render). * - **`__subscribe(fn)`** — registers a subscriber that fires synchronously * whenever `value` changes (element attached *or* detached). Returns an * unsubscribe function. * - **`__isMatesRef__`** — type discriminator; always `true`. Used by * `setRef` to distinguish a `MatesRef` from a plain lit-html `Ref`. * * @example * ```ts * const inputRef = ref(); * * inputRef.__subscribe((el) => { * if (el) el.focus(); // focus on mount * }); * * // In a template: * html``; * * // After render: * inputRef.value; // HTMLInputElement * ``` */ export declare function ref(): MatesRef; /** * A lit-html directive that attaches a DOM element to a `MatesRef` created by * `ref()`, or forwards to a plain lit-html `Ref` / callback for backwards * compatibility. * * ### Lifecycle behaviour * - **Element added to the DOM** — `ref.value` is set to the element and all * subscribers fire synchronously. * - **Element removed from the DOM** — `ref.value` is set to `undefined` and * all subscribers fire synchronously. * * @param r - A `MatesRef` (created by `ref()`), a lit-html `Ref` object, * or a lit-html ref callback. When `r.__isMatesRef__` is `true` the * `MatesRef` path is used; otherwise the value is passed straight through * to lit-html's own `ref` directive. * * @example * ```ts * const inputRef = ref(); * * inputRef.__subscribe((el) => { * if (el) el.focus(); // focus on mount * }); * * // In a template: * html``; * * // After render: * inputRef.value; // HTMLInputElement * ``` */ export declare function setRef(r: MatesRef | Parameters[0]): import("lit-html/directive").DirectiveResult; export type { MatesRef as Ref }; //# sourceMappingURL=ref.d.ts.map