UNPKG

@akson/cortex-landing-forms

Version:
165 lines (156 loc) 5.42 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import React, { ReactNode } from 'react'; import { Button } from '@akson/cortex-landing-core'; import { z } from 'zod'; export { z } from 'zod'; interface FormData { [key: string]: any; } interface FormStep$1 { id: string; name: string; fields: string[]; isValid?: boolean; isCompleted?: boolean; } interface FormConfig { id: string; steps: FormStep$1[]; initialData?: FormData; persistKey?: string; onStepChange?: (step: number, data: FormData) => void; onComplete?: (data: FormData) => void; } interface FormContextValue { data: FormData; updateData: (updates: Partial<FormData>) => void; setData: (data: FormData) => void; clearData: () => void; currentStep: number; steps: FormStep$1[]; goToStep: (step: number) => void; nextStep: () => void; previousStep: () => void; canGoNext: boolean; canGoPrevious: boolean; isDirty: boolean; isComplete: boolean; completedSteps: Set<number>; errors: Record<string, string>; setError: (field: string, error: string) => void; clearError: (field: string) => void; clearErrors: () => void; validateStep: (step?: number) => boolean; save: () => void; restore: () => void; config: FormConfig; } declare function useFormContext(): FormContextValue; interface FormProviderProps { children: ReactNode; config: FormConfig; } declare function FormProvider({ children, config }: FormProviderProps): react_jsx_runtime.JSX.Element; interface FormStep { id: string | number; name: string; description?: string; component?: ReactNode; isValid?: () => boolean; } interface MultiStepFormProps { steps: FormStep[]; currentStep: number; onStepChange?: (step: number) => void; children?: ReactNode; showProgress?: boolean; showStepDescription?: boolean; className?: string; stepperClassName?: string; contentClassName?: string; mobileCompact?: boolean; } declare function MultiStepForm({ steps, currentStep, onStepChange, children, showProgress, showStepDescription, className, stepperClassName, contentClassName, mobileCompact, }: MultiStepFormProps): react_jsx_runtime.JSX.Element; interface FormNavigationProps { onNext?: () => void; onPrevious?: () => void; onSubmit?: () => void; canGoNext?: boolean; canGoPrevious?: boolean; isLastStep?: boolean; isFirstStep?: boolean; nextLabel?: string; previousLabel?: string; submitLabel?: string; loading?: boolean; className?: string; nextButtonProps?: React.ComponentProps<typeof Button>; previousButtonProps?: React.ComponentProps<typeof Button>; alignment?: 'left' | 'center' | 'right' | 'between'; } declare function FormNavigation({ onNext, onPrevious, onSubmit, canGoNext, canGoPrevious, isLastStep, isFirstStep, nextLabel, previousLabel, submitLabel, loading, className, nextButtonProps, previousButtonProps, alignment, }: FormNavigationProps): react_jsx_runtime.JSX.Element; interface ValidationRule { field: string; schema: z.ZodSchema; message?: string; } interface ValidationResult { isValid: boolean; errors: Record<string, string>; } declare function useFormValidation(rules: ValidationRule[]): { errors: Record<string, string>; touched: Set<string>; validateField: (field: string, value: any) => boolean; validateAll: (data: Record<string, any>) => ValidationResult; touchField: (field: string) => void; touchAll: () => void; clearErrors: () => void; clearFieldError: (field: string) => void; reset: () => void; getFieldError: (field: string) => string | undefined; }; interface FormPersistenceOptions { key: string; debounceMs?: number; maxAge?: number; excludeFields?: string[]; } declare function useFormPersistence<T extends Record<string, any>>(data: T, options: FormPersistenceOptions): { restore: () => Partial<T> | null; clear: () => void; hasRestored: boolean; isRestoring: boolean; }; interface LeadCaptureModalProps { trigger: 'exit_intent' | 'time_based' | 'scroll_based'; offer: string; downloadUrl?: string; delay?: number; scrollThreshold?: number; whatsappMessage?: string; benefits?: string[]; onSubmit?: (data: LeadData) => Promise<void>; onClose?: () => void; enabled?: boolean; } interface LeadData { email: string; unit?: string; source: string; trigger: string; offer: string; } declare function LeadCaptureModal({ trigger, offer, downloadUrl, delay, // 30 seconds default scrollThreshold, enabled, onSubmit, onClose, }: LeadCaptureModalProps): react_jsx_runtime.JSX.Element | null; declare const validationSchemas: { email: () => z.ZodString; phone: () => z.ZodString; required: () => z.ZodString; minLength: (min: number) => z.ZodString; maxLength: (max: number) => z.ZodString; number: () => z.ZodNumber; positiveNumber: () => z.ZodNumber; url: () => z.ZodString; }; export { type FormConfig, type FormData, FormNavigation, FormProvider, type FormStep$1 as FormStep, LeadCaptureModal, type LeadCaptureModalProps, type LeadData, MultiStepForm, type FormStep as MultiStepFormStep, type ValidationResult, type ValidationRule, useFormContext, useFormPersistence, useFormValidation, validationSchemas };