import { UseFormReturn } from "react-hook-form"; import { AnyZodObject, z } from "zod"; import { FromWizardComponentProps, StepDefinitions } from "./useFormWizard"; export type FormWizardStepFormReturnMap = Partial<{ [TStepKey in keyof z.infer]: UseFormReturn[TStepKey]>; }>; /** * The `` component renders multi-step forms with a sidebar navigation. * Use the `useFormWizard` hook to generate the props for this component. * * The wizard uses Zod schemas for validation, where each schema property represents a step. * Each step receives its own form instance for registering inputs, enabling per-step and * full-form validation. * * **Note:** In production, the schema should be returned from a hook to allow translations * for error messages. * * ### When to use * - Complex forms that benefit from being split into logical steps * - Onboarding flows or setup wizards * - Forms where later steps depend on earlier input * * ### When not to use * - Simple forms with few fields - use regular form components * - Forms that should show all fields at once * * @example Basic usage with useFormWizard hook * ```tsx * import { FormWizard, useFormWizard } from "@trackunit/react-form-wizard"; * import { z } from "zod"; * * const formSchema = z.object({ * basicInfo: z.object({ * name: z.string().min(1, "Name is required"), * email: z.string().email("Invalid email"), * }), * preferences: z.object({ * notifications: z.boolean(), * theme: z.enum(["light", "dark"]), * }), * }); * * const MyWizard = () => { * const wizardProps = useFormWizard({ * fullFormSchema: formSchema, * steps: { * basicInfo: { * title: "Basic Information", * component: BasicInfoStep, * }, * preferences: { * title: "Preferences", * component: PreferencesStep, * }, * }, * onSubmit: (data) => console.log("Form submitted:", data), * }); * * return ; * }; * ``` * @example Step component pattern * ```tsx * import { FormWizardStepProps } from "@trackunit/react-form-wizard"; * import { TextField, EmailField } from "@trackunit/react-form-components"; * * const BasicInfoStep = ({ form }: FormWizardStepProps) => { * const { register, formState: { errors } } = form; * * return ( *
* * *
* ); * }; * ``` * @example With conditional steps * ```tsx * import { FormWizard, useFormWizard } from "@trackunit/react-form-wizard"; * * const wizardProps = useFormWizard({ * fullFormSchema: formSchema, * steps: { * accountType: { * title: "Account Type", * component: AccountTypeStep, * }, * businessDetails: { * title: "Business Details", * component: BusinessDetailsStep, * shouldRender: (formState) => formState.accountType?.type === "business", * }, * confirmation: { * title: "Confirmation", * component: ConfirmationStep, * }, * }, * onSubmit: handleSubmit, * }); * ``` */ export declare const FormWizard: >({ lastStepPrimaryActionLabel, isEdit, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, style, }: FromWizardComponentProps) => import("react/jsx-runtime").JSX.Element;