UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

17 lines (16 loc) • 723 B
import { type AnyKitForm } from '../runtime/formRuntime.js'; /** * Ask before the reader leaves a form with unsaved changes, and tell your router the same. * * @remarks * `useUnsavedChanges(form)` adds a `beforeunload` prompt while the form differs from its baseline, * so closing or reloading the tab asks first. It returns whether the form is dirty, so your * router's own navigation blocker can use the same answer. * * @privateRemarks * Guards against leaving with unsaved changes: a `beforeunload` prompt while the form differs * from its baseline. Returns `isDirty` so router blockers can use it too. */ export declare function useUnsavedChanges(form: AnyKitForm, opts?: { when?: boolean; }): boolean;