/** * adowire client — adowire:dirty directive * * Manages visibility and class changes on elements when the local (client-side) * state of a component has been modified but not yet confirmed by the server. * * A component is considered "dirty" when any `adowire:model` input's current * value differs from the value stored in the component's last server-confirmed * snapshot. Once a successful server round-trip completes and the snapshot is * updated, the dirty state is cleared. * * Supported attribute forms: * * adowire:dirty — hidden by default; shown when dirty * adowire:dirty.remove — shown by default; hidden when dirty * adowire:dirty.class="x" — class "x" added when dirty * adowire:dirty.class.remove="x" — class "x" removed when dirty * * All of the above can be combined with adowire:target to scope dirty detection * to a single model property instead of the entire component: * * adowire:dirty adowire:target="title" — shown only when "title" is dirty * adowire:dirty.class="x" adowire:target="email" * * Additionally, when adowire:dirty.class (or .class.remove) is placed directly * on the same element as adowire:model, that model property is used as the * implicit target automatically — no adowire:target needed: * * * * Public API * ────────── * initDirty() — call once at boot; hides all plain adowire:dirty elements * and registers the delegated input listener * applyDirtyState() — manually trigger a dirty-state re-evaluation for all components * clearDirtyState() — reset all dirty indicators to their idle state * checkDirty(root, prop?) — returns true if the component (or a specific property) * is dirty; used by the Alpine $wire.$dirty() bridge */ /** * Initialise the dirty directive. * * 1. Hides all plain `adowire:dirty` elements (they should only appear when * state has diverged from the server snapshot). * 2. Registers delegated `input` and `change` listeners on the document so * that dirty state is re-evaluated on every user interaction with a model * input. * * Safe to call multiple times — event listeners are only registered once. */ export declare function initDirty(): void; /** * Manually trigger a dirty-state re-evaluation for every mounted component * on the page. * * Called automatically after each successful server round-trip so that * indicators update to reflect the newly confirmed snapshot state. */ export declare function applyDirtyState(): void; /** * Force-reset dirty state for all components — clear every dirty indicator * back to its idle (clean) appearance without re-evaluating input values. * * Useful for programmatic resets (e.g. after a navigation or when you know * all changes have been discarded on the server side). */ export declare function clearDirtyState(): void; /** * Imperatively check whether a component (or a specific model property within * it) currently has unsaved changes. * * This computes the result fresh from the current DOM values and the live * component snapshot — it does not rely on the internally cached `dirtyProps` * map so it is always accurate even before the first input event fires. * * Used by the Alpine `$wire.$dirty()` bridge so that Alpine expressions can * react to dirty state without requiring adowire:dirty attributes in the HTML. * * @param root The component's root `[adowire:id]` element. * @param prop Optional property scope: * - `undefined` — returns true if ANY property is dirty * - `string` — returns true if that specific property is dirty * - `string[]` — returns true if ANY of the listed properties is dirty * * @example * // In Alpine: *
Any unsaved change
*
Email changed
*
Title or body changed
*/ export declare function checkDirty(root: HTMLElement, prop?: string | string[]): boolean;