import { UserInput, ObjectValidator, ValidatorMap } from "../validation/index.js"; /** * An action with a string type and an associated payload. * * @template P The type of the action's payload. * @template T the type used for the action type. */ export interface PayloadAction

{ payload: P; type: T; } export interface FormHelpers { /** * Set the value of the given form field. Curried, so `setValue('someField')` returns a setter function for `someField`. */ setValue: (field: TField) => (value: T[TField]) => void; /** * A function which, given a form field, returns props that are needed for input fields. */ inputProps: (field: TField) => { value: T[TField]; setValue: (value: T[TField]) => void; validity?: { type: "error"; message: string; }; onBlur: () => void; }; } /** * Hook for getting utilities like `inputProps('myFormField')` for handling form logic * @param form The form state * @param setField Setter for updating a field * @param setBlurred Setter for updating a field's blur state * @returns A {@link FormHelpers} object for easily setting up the correct values for each field in the view */ export declare function useFormHelpers(form: UserInput, validators: ValidatorMap, setField: (args: [property: K, value: T[K]]) => void, setBlurred: (property: K) => void): FormHelpers; /** * Function for creating a "property setter", which sets properties in a form object. * Ensures validation state is updated. * * @param formValidator Validation function for the form object * @returns Function for setting individual properties in a form object */ export declare const makePropertySetter: (formValidator: ObjectValidator) => (state: UserInput, [property, value]: [property: K, value: TForm[K]]) => UserInput; /** * Function for creating an "onBlur" function, which sets the blur state for properties in a form object. * Ensures validation is shown, if necessary, when the user leaves a form field. * * @returns Function for usage "onBlur" on individual form fields */ export declare const makeBlurSetter: () => (state: UserInput, property: K) => UserInput; //# sourceMappingURL=formHelpers.d.ts.map