import * as React from "react";
import { FormHTMLAttributes } from "react";
import { LocalFormState } from "./useLocalFormState.js";
interface FormContext {
id: string;
form: LocalFormState;
}
export interface FormProviderProps extends Omit, "onSubmit"> {
/**
* An id for the form. Must be unique for the current page.
*/
id: string;
/**
* Form state, validation data and helper functions. Create this with `useLocalFormState` hook. See {@link LocalFormState}
*/
form: LocalFormState;
/**
* Will be run when the form submit event is triggered, but only if the form data is valid. Receives the validated, sanitized data according to the validation setup.
*/
onSubmit?: (state: T) => void;
/**
* Use this to hide the auto-generated text explaining which fields are necessary/optional.
*
* Note that the text itself, or an equivalent, is **required** for good usability.
* The auto-generated text is accessible on {@link LocalFormState}.necessityText if you want
* to include it a different place in the layout.
*/
hideNecessityText?: boolean;
/**
* Use this to trigger submit when enter is pressed.
*/
submitOnEnter?: boolean;
}
/**
Provides an easy way to create a form with consistent validation logic. Input fields inside this component will automatically be connected to the form, as long as their `field` prop refers to one of the form's fields.
The following input component properties will be set automatically:
- `value`
- `onChange`
- `onBlur`
- `validity`
- `id`
A text explaining the necessity (required/optional) of fields will be inserted at the top unless `hideNecessityText` is set to true.
Additionally, `helperText` will be prefixed with the correct necessity indicator if the form contains a mix of required and optional fields.
*/
export declare function FormProvider({ id, form, onSubmit, hideNecessityText, submitOnEnter, children, ...rest }: React.PropsWithChildren>): import("react/jsx-runtime").JSX.Element;
export declare function useForm(): FormContext | undefined;
export {};
//# sourceMappingURL=formContext.d.ts.map