import * as z from "zod"; import type { FieldEvent } from "./stepper.utils"; export type CompletionStatus = "idle" | "loading" | "completed" | "error"; /** Props that OnboardingStepper passes to every step component */ export interface StepComponentProps { formState: Record; validationErrors: ValidationErrors; onChange: (e: FieldEvent) => void; /** Direct field setter — preferred over synthetic events for programmatic changes */ setFieldValue: (name: string, value: unknown) => void; } export interface StepConfig { id: string; label: string; component: React.ComponentType; validationSchema?: z.ZodSchema; fields?: string[]; /** Custom title displayed above the step content */ title?: string; /** Subtitle displayed below the step title */ description?: string; /** Additional props forwarded to the step component beyond base StepComponentProps */ extraProps?: Record; } export interface OnboardingStepperProps { steps: StepConfig[]; initialData: Record; onComplete: (data: Record) => void | Promise; onCancel?: () => void; onStepChange?: (step: number) => void; onFinishAutoRedirect?: (data: Record) => void | Promise; isLoading?: boolean; error?: string | { message: string; } | null; getStepValidation?: (stepId: string) => z.ZodSchema; completionMessages?: readonly string[]; showProgress?: boolean; showStepLabels?: boolean; } export interface OnboardingFormState { [key: string]: unknown; } export interface ValidationErrors { [key: string]: string; } export interface UseOnboardingStepperReturn { currentStep: number; formState: OnboardingFormState; validationErrors: ValidationErrors; progress: number; canProceedToNextStep: boolean; completionStatus: CompletionStatus; currentCompletionMessage: string; handleChange: (e: FieldEvent) => void; setFieldValue: (name: string, value: unknown) => void; handleNextStep: () => void; handlePreviousStep: () => void; handleComplete: () => void; resetCompletionState: () => void; }