@conform-to/react
Version:
Conform view adapter for react
36 lines • 2.3 kB
TypeScript
import { Serialize } from '@conform-to/dom/future';
import type { ErrorContext, FormRef, InputSnapshot, IntentDispatcher } from './types';
export declare function getFormElement(formRef: FormRef | undefined): HTMLFormElement | null;
export declare function getSubmitEvent(event: React.FormEvent<HTMLFormElement>): SubmitEvent;
export declare function initializeField(element: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, options: {
defaultValue?: string | string[] | File | File[] | null;
defaultChecked?: boolean;
value?: string;
} | undefined): void;
/**
* Makes hidden form inputs focusable with visually hidden styles
*/
export declare function makeInputFocusable(element: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): void;
export declare function getRadioGroupValue(inputs: Array<HTMLInputElement>): string | undefined;
export declare function getCheckboxGroupValue(inputs: Array<HTMLInputElement>): string[] | undefined;
export declare function getInputSnapshot(input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): InputSnapshot;
/**
* Creates an InputSnapshot based on the provided options:
* - checkbox/radio: value / defaultChecked
* - file inputs: defaultValue is File or FileList
* - select multiple: defaultValue is string array
* - others: defaultValue is string
*/
export declare function createDefaultSnapshot(defaultValue: string | string[] | File | File[] | FileList | null | undefined, defaultChecked: boolean | undefined, value: string | undefined): InputSnapshot;
/**
* Focuses the first field with validation errors on default form submission.
* Does nothing if the submission was triggered with a specific intent (e.g. validate / insert)
*/
export declare function focusFirstInvalidField<ErrorShape>(ctx: ErrorContext<ErrorShape>): void;
export declare function updateFormValue(form: HTMLFormElement, intendedValue: Record<string, unknown>, serialize: Serialize): void;
/**
* Creates a proxy that dynamically generates intent dispatch functions.
* Each property access returns a function that submits the intent to the form.
*/
export declare function createIntentDispatcher(formElement: HTMLFormElement | (() => HTMLFormElement | null), intentName: string): IntentDispatcher;
//# sourceMappingURL=dom.d.ts.map