UNPKG

react-server-actions

Version:

A package for working with actions in React and Next.js

42 lines 1.48 kB
import React from 'react'; import { z } from 'zod'; import type { ActionResult } from '../index.js'; export declare const useForm: <Schema extends z.AnyZodObject>() => { state: undefined; schema: undefined; debug: boolean; } | { state: ActionResult<Schema>; schema: Schema; debug: boolean | undefined; }; type UseFieldReturn = { invalid: string[] | undefined; value: any; input: { id: string; name: string; 'aria-invalid': boolean; autoComplete: 'on' | 'off' | undefined; defaultValue?: string; defaultChecked?: boolean; }; }; export declare const useField: <Schema extends z.AnyZodObject>() => UseFieldReturn; export declare function Form<Schema extends z.AnyZodObject>({ children, action, state, schema, className, reset, onSuccess, onError, debug, ...props }: React.ComponentProps<'form'> & { children: React.ReactNode; action: (payload: FormData) => void; state: ActionResult<Schema>; schema: Schema; className?: string; reset?: boolean; onSuccess?: (successData: any, formData: z.TypeOf<Schema> | undefined) => void; onError?: (error: string) => void; debug?: boolean; }): React.JSX.Element; export declare function FormField<Schema extends z.AnyZodObject>({ render, name, }: { render: (field: ReturnType<typeof useField>) => React.ReactNode; name: keyof z.TypeOf<Schema>; }): React.JSX.Element; export {}; //# sourceMappingURL=index.d.ts.map