import { DefaultValues } from 'react-hook-form'; import { z, ZodObject } from 'zod'; import { SmartFormFieldsMetadata } from './common.js'; export type SmartFormProps> = { /** * A set of initial values used to pre-fill the form. */ defaultValues?: DefaultValues> | undefined; /** * A callback function invoked when a user clicks the "Save" button. * * The submit button is not displayed by default; you must pass the `onSubmit` props for it to * appear. */ onSubmit?: ((data: z.infer) => Promise | void) | undefined; /** * A zod schema that defines the shape of the form. * * Only ZodObject, ZodString, ZodBoolean, and ZodNumber are supported at this time. */ schema: Schema; /** * A zod schema that defines additional metadata for the form fields. */ fieldsMeta: SmartFormFieldsMetadata; }; /** * A `SmartForm` wraps a `Form` and automatically generates form fields based on a Zod schema. * * @example * ```tsx * import { SmartForm } from "@netlify/sdk/ui/react/components"; * import { z } from "zod"; * * const schema = z.object({ * apiKey: z.string().trim().min(1), * baseUrl: z.string().trim().url(), * stuffEnabled: z.boolean().optional(), * }); * * const fieldsMeta = { * apiKey: { * label: "API Key", * helpText: "Put your API key here", * secret: true, * }, * baseUrl: { * label: "Base URL", * helpText: "The base URL of your API instance", * }, * stuffEnabled: { * label: "Enable Stuff", * helpText: "Should we enable everything?", * }, * }; * * console.log("Form submitted.", { fields })} * /> * ``` */ export declare const SmartForm: >({ defaultValues, onSubmit, schema, fieldsMeta, }: SmartFormProps) => JSX.Element; //# sourceMappingURL=SmartForm.d.ts.map