@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
28 lines (27 loc) • 1.17 kB
TypeScript
import { type AnyKitForm } from '../runtime/formRuntime.js';
export interface FormStatusState {
/** `!isDefaultValue` — differs from the baseline (never TanStack's persistent `isDirty`). */
isDirty: boolean;
isSubmitting: boolean;
isSubmitted: boolean;
isSubmitSuccessful: boolean;
/** Not submitting/validating, and valid (or never submitted). Ignores `canSubmitWhenInvalid`. */
canSubmit: boolean;
submitCount: number;
isValidating: boolean;
hasErrors: boolean;
}
/**
* The form's state at a glance (dirty, submitting, submitted, valid), re-rendering only when a
* part of it changes.
*
* @remarks
* `useFormStatus` reads the form-wide state you build interface around: whether it's dirty,
* submitting or submitted, whether it can submit, and how many times it's been submitted. Each
* part is its own selector and the result is memoised, so a component using it re-renders only
* when something it reads actually changes.
*
* @privateRemarks
* Form-wide status; each slice is its own primitive selector, the object is memoised (§6.5).
*/
export declare function useFormStatus(form?: AnyKitForm): FormStatusState;