import * as React from 'react'; import { View } from 'react-native'; import type { ZestUIComponentProps } from '../types'; /** * Groups the fields of a form, distributes errors to them, and validates them * all at once. * Renders a ``. * * **Adapted from upstream, not a verbatim port.** React Native has no HTML form * submission, so there is no `
` element, no `action`, and no submit event * to hook. What is left is the part that carries its weight anyway: `errors` * puts messages from a server onto the right fields, and submitting validates * every field and sends the user to the first one that failed. * * Submission is imperative, through `actionsRef` — there is no native event to * ride on: * * ```tsx * const form = React.useRef(null); * * * * * * ``` */ export declare function Form(componentProps: Form.Props): React.JSX.Element; export interface FormState { } export interface FormActions { /** * Validates every field. If one fails, focuses the first that can be focused * and returns `false`; otherwise calls `onSubmit` and returns `true`. */ submit: () => boolean; /** * Validates every field and reports whether the form is valid, without * submitting. */ validate: () => boolean; } export interface FormProps extends ZestUIComponentProps { /** * Errors to show on the fields, keyed by their `name` — a server's response, * typically. A field drops its error as soon as the user changes it, which is * reported through `onClearErrors`. */ errors?: Record | undefined; /** * Called with the remaining errors when a field's error is dropped. Keep your * `errors` state in sync with it. */ onClearErrors?: ((errors: Record) => void) | undefined; /** * Called when `actionsRef.current.submit()` finds every field valid. */ onSubmit?: (() => void) | undefined; /** * A ref to imperative actions. React Native has no submit event, so this is * how a form is submitted. */ actionsRef?: React.RefObject | undefined; } export declare namespace Form { type State = FormState; type Props = FormProps; type Actions = FormActions; } //# sourceMappingURL=Form.d.ts.map