import type { Signal } from '../reactivity/types.ts'; interface BooleanPropConfig { type: 'boolean'; attribute?: string; } interface NumberPropConfig { type: 'number'; attribute?: string; initial?: number; } interface StringPropConfig { type: 'string'; attribute?: string; initial?: string; } /** * A reactive property backed by a signal, with attribute parsing and reflection. * * Eliminates the 4-part signal/getter/setter/attributeChangedCallback pattern: * * ```ts * // Before: ~10 lines per property * #disabled = signal(false); * get disabled() { return this.#disabled.value; } * set disabled(val) { this.#disabled.value = val; this.toggleAttribute('disabled', val); } * // + attributeChangedCallback case * * // After: 1 line declaration + auto-handled attribute sync * #disabled = prop(this, 'disabled', { type: 'boolean' }); * get disabled() { return this.#disabled.value; } * set disabled(val) { this.#disabled.set(val); } * ``` */ export interface ReactiveProp { /** The underlying signal. */ readonly signal: Signal; /** Read the current value (tracks in effects). */ readonly value: T; /** Update value and reflect to attribute. */ set(val: T): void; /** Parse an attribute value and update the signal (for attributeChangedCallback). */ fromAttribute(val: string | null): void; } export declare function prop(el: HTMLElement, attribute: string, config: BooleanPropConfig): ReactiveProp; export declare function prop(el: HTMLElement, attribute: string, config: NumberPropConfig): ReactiveProp; export declare function prop(el: HTMLElement, attribute: string, config: StringPropConfig): ReactiveProp; /** * Dispatches an attribute change to the matching reactive prop. * Returns true if handled, false if no matching prop was found. * * ```ts * attributeChangedCallback(name, old, val) { * if (old === val) return; * if (syncProp(this.#props, name, val)) return; * // handle non-prop attributes... * super.attributeChangedCallback?.(name, old, val); * } * ``` */ export declare function syncProp(props: Record>, name: string, val: string | null): boolean; export {}; //# sourceMappingURL=reactive-prop.d.ts.map