@rachelallyson/hero-hook-form 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,27 @@ interface CustomFieldConfig<TFieldValues extends FieldValues> extends BaseFormFi
95
95
  isSubmitting: boolean;
96
96
  }) => React.ReactNode;
97
97
  }
98
- type FormFieldConfig<TFieldValues extends FieldValues> = StringFieldConfig<TFieldValues> | BooleanFieldConfig<TFieldValues> | RadioFieldConfig<TFieldValues> | SliderFieldConfig<TFieldValues> | DateFieldConfig<TFieldValues> | FileFieldConfig<TFieldValues> | FontPickerFieldConfig<TFieldValues> | CustomFieldConfig<TFieldValues>;
98
+ interface ConditionalFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
99
+ type: "conditional";
100
+ condition: (formData: Partial<TFieldValues>) => boolean;
101
+ field: ZodFormFieldConfig<TFieldValues>;
102
+ }
103
+ interface FieldArrayConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
104
+ type: "fieldArray";
105
+ fields: ZodFormFieldConfig<TFieldValues>[];
106
+ min?: number;
107
+ max?: number;
108
+ addButtonText?: string;
109
+ removeButtonText?: string;
110
+ }
111
+ interface DynamicSectionConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
112
+ type: "dynamicSection";
113
+ title?: string;
114
+ description?: string;
115
+ condition: (formData: Partial<TFieldValues>) => boolean;
116
+ fields: ZodFormFieldConfig<TFieldValues>[];
117
+ }
118
+ type FormFieldConfig<TFieldValues extends FieldValues> = StringFieldConfig<TFieldValues> | BooleanFieldConfig<TFieldValues> | RadioFieldConfig<TFieldValues> | SliderFieldConfig<TFieldValues> | DateFieldConfig<TFieldValues> | FileFieldConfig<TFieldValues> | FontPickerFieldConfig<TFieldValues> | CustomFieldConfig<TFieldValues> | ConditionalFieldConfig<TFieldValues> | FieldArrayConfig<TFieldValues> | DynamicSectionConfig<TFieldValues>;
99
119
  interface FormConfig<TFieldValues extends FieldValues> {
100
120
  fields: FormFieldConfig<TFieldValues>[];
101
121
  layout?: "vertical" | "horizontal" | "grid" | "custom";
@@ -109,7 +129,7 @@ interface FormConfig<TFieldValues extends FieldValues> {
109
129
  className?: string;
110
130
  defaultValues?: Partial<TFieldValues>;
111
131
  }
112
- type ZodFormFieldConfig<TFieldValues extends FieldValues> = Omit<StringFieldConfig<TFieldValues>, "rules"> | Omit<BooleanFieldConfig<TFieldValues>, "rules"> | Omit<RadioFieldConfig<TFieldValues>, "rules"> | Omit<SliderFieldConfig<TFieldValues>, "rules"> | Omit<DateFieldConfig<TFieldValues>, "rules"> | Omit<FileFieldConfig<TFieldValues>, "rules"> | Omit<FontPickerFieldConfig<TFieldValues>, "rules"> | Omit<CustomFieldConfig<TFieldValues>, "rules">;
132
+ type ZodFormFieldConfig<TFieldValues extends FieldValues> = Omit<StringFieldConfig<TFieldValues>, "rules"> | Omit<BooleanFieldConfig<TFieldValues>, "rules"> | Omit<RadioFieldConfig<TFieldValues>, "rules"> | Omit<SliderFieldConfig<TFieldValues>, "rules"> | Omit<DateFieldConfig<TFieldValues>, "rules"> | Omit<FileFieldConfig<TFieldValues>, "rules"> | Omit<FontPickerFieldConfig<TFieldValues>, "rules"> | Omit<CustomFieldConfig<TFieldValues>, "rules"> | Omit<ConditionalFieldConfig<TFieldValues>, "rules"> | Omit<FieldArrayConfig<TFieldValues>, "rules"> | Omit<DynamicSectionConfig<TFieldValues>, "rules">;
113
133
  interface ZodFormConfig<TFieldValues extends FieldValues> extends UseFormProps<TFieldValues> {
114
134
  schema: zod.ZodSchema<TFieldValues>;
115
135
  fields: ZodFormFieldConfig<TFieldValues>[];
@@ -212,7 +232,7 @@ interface FormFieldProps<TFieldValues extends FieldValues> {
212
232
  form: UseFormReturn<TFieldValues>;
213
233
  submissionState: FormSubmissionState;
214
234
  }
215
- declare function FormField<TFieldValues extends FieldValues>({ config, form, submissionState, }: FormFieldProps<TFieldValues>): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | React$1.JSX.Element | null | undefined;
235
+ declare const FormField: <TFieldValues extends FieldValues>(props: FormFieldProps<TFieldValues>) => React$1.JSX.Element;
216
236
 
217
237
  type CheckboxFieldProps<TFieldValues extends FieldValues> = FieldBaseProps<TFieldValues, boolean> & WithControl<TFieldValues> & {
218
238
  checkboxProps?: Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">;
@@ -248,7 +268,7 @@ type InputFieldProps<TFieldValues extends FieldValues> = FieldBaseProps<TFieldVa
248
268
  inputProps?: Omit<React$1.ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">;
249
269
  transform?: (value: string) => string;
250
270
  };
251
- declare function InputField<TFieldValues extends FieldValues>(props: InputFieldProps<TFieldValues>): React$1.JSX.Element;
271
+ declare const InputField: <TFieldValues extends FieldValues>(props: InputFieldProps<TFieldValues>) => React$1.JSX.Element;
252
272
 
253
273
  interface RadioOption<TValue extends string | number> {
254
274
  label: string;
@@ -410,9 +430,38 @@ interface FormProps<TFieldValues extends FieldValues> {
410
430
  }
411
431
  declare function FormProvider<TFieldValues extends FieldValues>(props: FormProps<TFieldValues>): React$1.JSX.Element;
412
432
 
433
+ interface EnhancedFormState<T extends FieldValues> {
434
+ status: "idle" | "submitting" | "success" | "error";
435
+ isSubmitting: boolean;
436
+ isSuccess: boolean;
437
+ isError: boolean;
438
+ error?: string;
439
+ submittedData?: T;
440
+ touchedFields: Set<Path<T>>;
441
+ dirtyFields: Set<Path<T>>;
442
+ hasErrors: boolean;
443
+ errorCount: number;
444
+ handleSuccess: (data: T) => void;
445
+ handleError: (error: string) => void;
446
+ reset: () => void;
447
+ }
448
+ interface UseEnhancedFormStateOptions<T extends FieldValues> {
449
+ onSuccess?: (data: T) => void;
450
+ onError?: (error: string) => void;
451
+ successMessage?: string;
452
+ errorMessage?: string;
453
+ autoReset?: boolean;
454
+ resetDelay?: number;
455
+ }
456
+ declare function useEnhancedFormState<T extends FieldValues>(form: UseFormReturn<T>, options?: UseEnhancedFormStateOptions<T>): EnhancedFormState<T>;
457
+
413
458
  interface SubmitButtonProps {
414
459
  children: React$1.ReactNode;
415
460
  isLoading?: boolean;
461
+ isSuccess?: boolean;
462
+ successText?: string;
463
+ loadingText?: string;
464
+ enhancedState?: EnhancedFormState<any>;
416
465
  buttonProps?: Omit<React$1.ComponentProps<typeof Button>, "type" | "isLoading">;
417
466
  }
418
467
  declare function SubmitButton(props: SubmitButtonProps): React$1.JSX.Element;
@@ -557,6 +606,29 @@ declare const commonValidations: {
557
606
  requiredCheckbox: (fieldName: string) => z.ZodBoolean;
558
607
  url: z.ZodString;
559
608
  };
609
+ /**
610
+ * Cross-field validation helpers
611
+ */
612
+ declare const crossFieldValidation: {
613
+ /**
614
+ * Password confirmation validation
615
+ */
616
+ passwordConfirmation: (passwordField: string, confirmField: string) => z.ZodObject<{
617
+ [x: string]: z.ZodString;
618
+ }, z.core.$strip>;
619
+ /**
620
+ * Date range validation
621
+ */
622
+ dateRange: (startField: string, endField: string) => z.ZodObject<{
623
+ [x: string]: z.ZodString;
624
+ }, z.core.$strip>;
625
+ /**
626
+ * Conditional required field validation
627
+ */
628
+ conditionalRequired: (field: string, conditionField: string, conditionValue: any) => z.ZodObject<{
629
+ [x: string]: z.ZodString | z.ZodAny;
630
+ }, z.core.$strip>;
631
+ };
560
632
 
561
633
  interface ZodFormProps<T extends FieldValues> {
562
634
  className?: string;
@@ -594,4 +666,657 @@ declare function useZodForm<TFieldValues extends FieldValues>(config: ZodFormCon
594
666
  */
595
667
  declare function createZodFormConfig<TFieldValues extends FieldValues>(schema: z.ZodSchema<TFieldValues>, fields: ZodFormFieldConfig<TFieldValues>[], defaultValues?: Partial<TFieldValues>): ZodFormConfig<TFieldValues>;
596
668
 
597
- export { type BaseFormFieldConfig, type BooleanFieldConfig, type ButtonDefaults, type CheckboxDefaults, CheckboxField, type CheckboxFieldProps, type CommonFieldDefaults, type ConditionalValidation, ConfigurableForm, type CustomFieldConfig, DateField, type DateFieldConfig, type DateFieldProps, type DateInputDefaults, type FieldBaseProps, type FieldGroup, FileField, type FileFieldConfig, type FileFieldProps, FontPickerField, type FontPickerFieldConfig, type FontPickerFieldProps, type FormConfig, FormField, type FormFieldConfig, type FormProps, FormProvider, type FormStep, type FormSubmissionState, type FormTestUtils, type FormValidationError, type HeroHookFormDefaultsConfig, HeroHookFormProvider, type HeroHookFormProviderProps, type InputDefaults, InputField, type InputFieldProps, type RadioFieldConfig, type RadioGroupDefaults, RadioGroupField, type RadioGroupFieldProps, type SelectDefaults, SelectField, type SelectFieldProps, type ServerFieldError, type ServerFormError, type SliderDefaults, SliderField, type SliderFieldConfig, type SliderFieldProps, type StringFieldConfig, SubmitButton, type SubmitButtonProps, type SwitchDefaults, SwitchField, type SwitchFieldProps, type TextareaDefaults, TextareaField, type TextareaFieldProps, type ValidationUtils, type WithControl, type WizardFormConfig, ZodForm, type ZodFormConfig, type ZodFormFieldConfig, applyServerErrors, commonValidations, createConditionalSchema, createConfirmPasswordSchema, createDateSchema, createEmailSchema, createFileSchema, createFormTestUtils, createFutureDateSchema, createMaxLengthSchema, createMinLengthSchema, createMockFormData, createMockFormErrors, createNumberRangeSchema, createPasswordSchema, createPastDateSchema, createPhoneSchema, createRequiredCheckboxSchema, createRequiredSchema, createUrlSchema, createZodFormConfig, getFieldError, getFormErrors, hasFieldError, hasFormErrors, simulateFieldInput, simulateFormSubmission, useFormHelper, useHeroForm, useHeroHookFormDefaults, useZodForm, waitForFormState };
669
+ /**
670
+ * Basic form field builder that eliminates "as const" assertions
671
+ * Focuses on the most common use cases
672
+ */
673
+ declare class BasicFormBuilder<T extends FieldValues> {
674
+ private fields;
675
+ /**
676
+ * Add an input field
677
+ */
678
+ input(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password"): this;
679
+ /**
680
+ * Add a textarea field
681
+ */
682
+ textarea(name: Path<T>, label: string, placeholder?: string): this;
683
+ /**
684
+ * Add a select field
685
+ */
686
+ select(name: Path<T>, label: string, options: {
687
+ label: string;
688
+ value: string | number;
689
+ }[]): this;
690
+ /**
691
+ * Add a checkbox field
692
+ */
693
+ checkbox(name: Path<T>, label: string): this;
694
+ /**
695
+ * Add a switch field
696
+ */
697
+ switch(name: Path<T>, label: string): this;
698
+ /**
699
+ * Build the final field configuration array
700
+ */
701
+ build(): ZodFormFieldConfig<T>[];
702
+ }
703
+ /**
704
+ * Create a new simple form field builder
705
+ */
706
+ declare function createBasicFormBuilder<T extends FieldValues>(): BasicFormBuilder<T>;
707
+ /**
708
+ * Simple helper functions for common field types
709
+ */
710
+ declare const FormFieldHelpers: {
711
+ /**
712
+ * Create an input field
713
+ */
714
+ input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password") => ZodFormFieldConfig<T>;
715
+ /**
716
+ * Create a textarea field
717
+ */
718
+ textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
719
+ /**
720
+ * Create a select field
721
+ */
722
+ select: <T extends FieldValues>(name: Path<T>, label: string, options: {
723
+ label: string;
724
+ value: string | number;
725
+ }[]) => ZodFormFieldConfig<T>;
726
+ /**
727
+ * Create a checkbox field
728
+ */
729
+ checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
730
+ /**
731
+ * Create a switch field
732
+ */
733
+ switch: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
734
+ };
735
+ /**
736
+ * Common field collections
737
+ */
738
+ declare const CommonFields: {
739
+ /**
740
+ * Personal information fields
741
+ */
742
+ personal: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
743
+ /**
744
+ * Address fields
745
+ */
746
+ address: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
747
+ /**
748
+ * Terms and conditions fields
749
+ */
750
+ terms: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
751
+ };
752
+
753
+ /**
754
+ * Unified field creation function
755
+ * Takes field type as first argument and delegates to appropriate helper
756
+ */
757
+ declare function createField<T extends FieldValues>(type: string, name: Path<T>, label: string, optionsOrProps?: any, props?: any): ZodFormFieldConfig<T>;
758
+ /**
759
+ * Builder pattern for advanced field creation
760
+ */
761
+ declare class AdvancedFieldBuilder<T extends FieldValues> {
762
+ private fields;
763
+ /**
764
+ * Add any field type using the unified API
765
+ */
766
+ field(type: "input", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
767
+ field(type: "textarea", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
768
+ field(type: "select", name: Path<T>, label: string, options: {
769
+ label: string;
770
+ value: string | number;
771
+ }[], props?: Parameters<typeof createField<T>>[4]): this;
772
+ field(type: "checkbox", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
773
+ field(type: "switch", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
774
+ field(type: "radio", name: Path<T>, label: string, options: {
775
+ label: string;
776
+ value: string | number;
777
+ }[], props?: Parameters<typeof createField<T>>[4]): this;
778
+ field(type: "slider", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
779
+ field(type: "date", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
780
+ field(type: "file", name: Path<T>, label: string, props?: Parameters<typeof createField<T>>[3]): this;
781
+ /**
782
+ * Add a conditional field that shows/hides based on form data
783
+ */
784
+ conditionalField(name: Path<T>, condition: (formData: Partial<T>) => boolean, field: ZodFormFieldConfig<T>): this;
785
+ /**
786
+ * Add a field array for dynamic repeating field groups
787
+ */
788
+ fieldArray(name: Path<T>, label: string, fields: ZodFormFieldConfig<any>[], options?: {
789
+ min?: number;
790
+ max?: number;
791
+ addButtonText?: string;
792
+ removeButtonText?: string;
793
+ }): this;
794
+ /**
795
+ * Add a dynamic section that shows/hides based on form data
796
+ */
797
+ dynamicSection(name: Path<T>, condition: (formData: Partial<T>) => boolean, fields: ZodFormFieldConfig<T>[], options?: {
798
+ title?: string;
799
+ description?: string;
800
+ }): this;
801
+ /**
802
+ * Build the final field configuration array
803
+ */
804
+ build(): ZodFormFieldConfig<T>[];
805
+ }
806
+ /**
807
+ * Field Array Builder for strongly-typed array item fields
808
+ */
809
+ declare class FieldArrayItemBuilder<TItem extends FieldValues> {
810
+ private fields;
811
+ /**
812
+ * Add any field type using the unified API for array items
813
+ */
814
+ field(type: "input", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
815
+ field(type: "textarea", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
816
+ field(type: "select", name: Path<TItem>, label: string, options: {
817
+ label: string;
818
+ value: string | number;
819
+ }[], props?: Parameters<typeof createField<TItem>>[4]): this;
820
+ field(type: "checkbox", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
821
+ field(type: "switch", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
822
+ field(type: "radio", name: Path<TItem>, label: string, options: {
823
+ label: string;
824
+ value: string | number;
825
+ }[], props?: Parameters<typeof createField<TItem>>[4]): this;
826
+ field(type: "slider", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
827
+ field(type: "date", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
828
+ field(type: "file", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
829
+ field(type: "fontPicker", name: Path<TItem>, label: string, props?: Parameters<typeof createField<TItem>>[3]): this;
830
+ /**
831
+ * Build the field array item configuration
832
+ */
833
+ build(): ZodFormFieldConfig<TItem>[];
834
+ }
835
+ /**
836
+ * Create a field array item builder for strongly-typed array fields
837
+ */
838
+ declare function createFieldArrayItemBuilder<TItem extends FieldValues>(): FieldArrayItemBuilder<TItem>;
839
+ /**
840
+ * Field Array Builder for constructing field arrays with proper paths
841
+ */
842
+ declare class FieldArrayBuilder<T extends FieldValues, TArrayName extends Path<T>> {
843
+ private arrayName;
844
+ private fields;
845
+ constructor(arrayName: TArrayName);
846
+ field(type: string, name: string, label: string, optionsOrProps?: any, props?: any): this;
847
+ build(): ZodFormFieldConfig<any>[];
848
+ }
849
+ /**
850
+ * Create a field array builder that constructs proper paths for array items
851
+ */
852
+ declare function createFieldArrayBuilder<T extends FieldValues, TArrayName extends Path<T>>(arrayName: TArrayName): FieldArrayBuilder<T, TArrayName>;
853
+ /**
854
+ * Create a new advanced field builder
855
+ */
856
+ declare function createAdvancedBuilder<T extends FieldValues>(): AdvancedFieldBuilder<T>;
857
+
858
+ /**
859
+ * Type-inferred form builder that auto-generates both schema and field configs
860
+ */
861
+ declare class TypeInferredBuilder<T extends FieldValues> {
862
+ private schemaFields;
863
+ private formFields;
864
+ /**
865
+ * Add a text field
866
+ */
867
+ text(name: Path<T>, label: string, options?: {
868
+ placeholder?: string;
869
+ description?: string;
870
+ isDisabled?: boolean;
871
+ className?: string;
872
+ minLength?: number;
873
+ maxLength?: number;
874
+ pattern?: string;
875
+ }): this;
876
+ /**
877
+ * Add an email field
878
+ */
879
+ email(name: Path<T>, label: string, options?: {
880
+ placeholder?: string;
881
+ description?: string;
882
+ isDisabled?: boolean;
883
+ className?: string;
884
+ }): this;
885
+ /**
886
+ * Add a number field
887
+ */
888
+ number(name: Path<T>, label: string, options?: {
889
+ placeholder?: string;
890
+ description?: string;
891
+ isDisabled?: boolean;
892
+ className?: string;
893
+ min?: number;
894
+ max?: number;
895
+ step?: number;
896
+ }): this;
897
+ /**
898
+ * Add a textarea field
899
+ */
900
+ textarea(name: Path<T>, label: string, options?: {
901
+ placeholder?: string;
902
+ description?: string;
903
+ isDisabled?: boolean;
904
+ className?: string;
905
+ rows?: number;
906
+ minLength?: number;
907
+ }): this;
908
+ /**
909
+ * Add a select field
910
+ */
911
+ select(name: Path<T>, label: string, options: {
912
+ label: string;
913
+ value: string | number;
914
+ }[], fieldOptions?: {
915
+ placeholder?: string;
916
+ description?: string;
917
+ isDisabled?: boolean;
918
+ className?: string;
919
+ }): this;
920
+ /**
921
+ * Add a checkbox field
922
+ */
923
+ checkbox(name: Path<T>, label: string, options?: {
924
+ description?: string;
925
+ isDisabled?: boolean;
926
+ className?: string;
927
+ required?: boolean;
928
+ }): this;
929
+ /**
930
+ * Add a switch field
931
+ */
932
+ switch(name: Path<T>, label: string, options?: {
933
+ description?: string;
934
+ isDisabled?: boolean;
935
+ className?: string;
936
+ }): this;
937
+ /**
938
+ * Add a radio field
939
+ */
940
+ radio(name: Path<T>, label: string, options: {
941
+ label: string;
942
+ value: string | number;
943
+ }[], fieldOptions?: {
944
+ description?: string;
945
+ isDisabled?: boolean;
946
+ className?: string;
947
+ orientation?: "horizontal" | "vertical";
948
+ }): this;
949
+ /**
950
+ * Add a slider field
951
+ */
952
+ slider(name: Path<T>, label: string, options?: {
953
+ min?: number;
954
+ max?: number;
955
+ step?: number;
956
+ description?: string;
957
+ isDisabled?: boolean;
958
+ className?: string;
959
+ }): this;
960
+ /**
961
+ * Add a date field
962
+ */
963
+ date(name: Path<T>, label: string, options?: {
964
+ placeholder?: string;
965
+ description?: string;
966
+ isDisabled?: boolean;
967
+ className?: string;
968
+ }): this;
969
+ /**
970
+ * Add a file field
971
+ */
972
+ file(name: Path<T>, label: string, options?: {
973
+ accept?: string;
974
+ multiple?: boolean;
975
+ description?: string;
976
+ isDisabled?: boolean;
977
+ className?: string;
978
+ }): this;
979
+ /**
980
+ * Build the final schema and fields
981
+ */
982
+ build(): {
983
+ schema: z.ZodSchema<T>;
984
+ fields: ZodFormFieldConfig<T>[];
985
+ };
986
+ }
987
+ /**
988
+ * Create a new type-inferred form builder
989
+ */
990
+ declare function createTypeInferredBuilder<T extends FieldValues>(): TypeInferredBuilder<T>;
991
+ /**
992
+ * Define a form with type inference
993
+ */
994
+ declare function defineInferredForm<T extends FieldValues>(fieldDefinitions: (builder: TypeInferredBuilder<T>) => TypeInferredBuilder<T>): {
995
+ schema: z.ZodSchema<T>;
996
+ fields: ZodFormFieldConfig<T>[];
997
+ };
998
+ /**
999
+ * Field type builders for individual field creation
1000
+ */
1001
+ declare const field: {
1002
+ text: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["text"]>[2]) => TypeInferredBuilder<T>;
1003
+ email: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["email"]>[2]) => TypeInferredBuilder<T>;
1004
+ number: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["number"]>[2]) => TypeInferredBuilder<T>;
1005
+ textarea: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["textarea"]>[2]) => TypeInferredBuilder<T>;
1006
+ select: <T extends FieldValues>(name: Path<T>, label: string, options: {
1007
+ label: string;
1008
+ value: string | number;
1009
+ }[], fieldOptions?: Parameters<TypeInferredBuilder<T>["select"]>[3]) => TypeInferredBuilder<T>;
1010
+ checkbox: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["checkbox"]>[2]) => TypeInferredBuilder<T>;
1011
+ switch: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["switch"]>[2]) => TypeInferredBuilder<T>;
1012
+ radio: <T extends FieldValues>(name: Path<T>, label: string, options: {
1013
+ label: string;
1014
+ value: string | number;
1015
+ }[], fieldOptions?: Parameters<TypeInferredBuilder<T>["radio"]>[3]) => TypeInferredBuilder<T>;
1016
+ slider: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["slider"]>[2]) => TypeInferredBuilder<T>;
1017
+ date: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["date"]>[2]) => TypeInferredBuilder<T>;
1018
+ file: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["file"]>[2]) => TypeInferredBuilder<T>;
1019
+ };
1020
+
1021
+ /**
1022
+ * Enhanced nested path builder with better syntax for complex nested structures
1023
+ * Provides multiple approaches for handling nested field paths
1024
+ */
1025
+ declare class NestedPathBuilder<T extends FieldValues> {
1026
+ private fields;
1027
+ /**
1028
+ * Create a nested object path builder
1029
+ * Usage: builder.nest("address").field("street", "Street Address")
1030
+ */
1031
+ nest<TPath extends Path<T>>(path: TPath): NestedObjectBuilder<T, TPath>;
1032
+ /**
1033
+ * Create a section-based path builder
1034
+ * Usage: builder.section("shipping").field("street", "Street Address")
1035
+ */
1036
+ section<TPath extends Path<T>>(path: TPath): SectionBuilder<T, TPath>;
1037
+ /**
1038
+ * Add a field with single path
1039
+ * Usage: builder.field("firstName", "First Name")
1040
+ */
1041
+ field(name: Path<T>, label: string, type?: string, props?: any): this;
1042
+ /**
1043
+ * Add a field with path segments
1044
+ * Usage: builder.fieldPath(["user", "profile", "name"], "Full Name")
1045
+ */
1046
+ fieldPath(path: string[], label: string, type?: string, props?: any): this;
1047
+ /**
1048
+ * Add a field with template literal path
1049
+ * Usage: builder.field`user.profile.name`("Full Name")
1050
+ */
1051
+ fieldTemplate(path: TemplateStringsArray, ...args: any[]): FieldTemplateBuilder<T>;
1052
+ /**
1053
+ * Return to the parent builder (no-op for root builder)
1054
+ */
1055
+ end(): this;
1056
+ build(): ZodFormFieldConfig<T>[];
1057
+ }
1058
+ /**
1059
+ * Nested object builder for chaining nested paths
1060
+ */
1061
+ declare class NestedObjectBuilder<T extends FieldValues, TPath extends Path<T>> {
1062
+ private parent;
1063
+ private path;
1064
+ constructor(parent: NestedPathBuilder<T>, path: TPath);
1065
+ /**
1066
+ * Add a field to the current nested path
1067
+ */
1068
+ field<FName extends string>(fieldName: FName, label: string, type?: string, props?: any): NestedObjectBuilder<T, TPath>;
1069
+ /**
1070
+ * Nest deeper into the object
1071
+ */
1072
+ nest<SubPath extends string>(subPath: SubPath): NestedObjectBuilder<T, TPath>;
1073
+ /**
1074
+ * Return to the parent builder
1075
+ */
1076
+ end(): NestedPathBuilder<T>;
1077
+ }
1078
+ /**
1079
+ * Section builder for grouping related fields
1080
+ */
1081
+ declare class SectionBuilder<T extends FieldValues, TPath extends Path<T>> {
1082
+ private parent;
1083
+ private path;
1084
+ constructor(parent: NestedPathBuilder<T>, path: TPath);
1085
+ /**
1086
+ * Add a field to the current section
1087
+ */
1088
+ field<FName extends string>(fieldName: FName, label: string, type?: string, props?: any): SectionBuilder<T, TPath>;
1089
+ /**
1090
+ * Add multiple fields to the section
1091
+ */
1092
+ fields(fieldDefinitions: Array<{
1093
+ name: string;
1094
+ label: string;
1095
+ type?: string;
1096
+ props?: any;
1097
+ }>): SectionBuilder<T, TPath>;
1098
+ /**
1099
+ * Nest deeper into the section
1100
+ */
1101
+ nest<SubPath extends string>(subPath: SubPath): NestedObjectBuilder<T, TPath>;
1102
+ /**
1103
+ * Return to the parent builder
1104
+ */
1105
+ end(): NestedPathBuilder<T>;
1106
+ }
1107
+ /**
1108
+ * Template literal field builder
1109
+ */
1110
+ declare class FieldTemplateBuilder<T extends FieldValues> {
1111
+ private parent;
1112
+ private path;
1113
+ constructor(parent: NestedPathBuilder<T>, path: string);
1114
+ /**
1115
+ * Complete the field definition
1116
+ */
1117
+ complete(label: string, type?: string, props?: any): NestedPathBuilder<T>;
1118
+ }
1119
+ /**
1120
+ * Factory function for creating the nested path builder
1121
+ */
1122
+ declare function createNestedPathBuilder<T extends FieldValues>(): NestedPathBuilder<T>;
1123
+
1124
+ interface UseDebouncedValidationOptions {
1125
+ delay?: number;
1126
+ fields?: string[];
1127
+ enabled?: boolean;
1128
+ }
1129
+ declare function useDebouncedValidation<T extends Record<string, any>>(form: UseFormReturn<T>, options?: UseDebouncedValidationOptions): {
1130
+ debouncedTrigger: () => void;
1131
+ isDebouncing: boolean;
1132
+ };
1133
+ declare function useDebouncedFieldValidation<T extends Record<string, any>>(form: UseFormReturn<T>, fieldName: keyof T, options?: {
1134
+ delay?: number;
1135
+ enabled?: boolean;
1136
+ }): {
1137
+ debouncedFieldTrigger: () => void;
1138
+ isDebouncing: boolean;
1139
+ };
1140
+
1141
+ interface UseInferredFormOptions<T extends FieldValues> {
1142
+ defaultValues?: Partial<T>;
1143
+ mode?: "onChange" | "onBlur" | "onSubmit" | "onTouched" | "all";
1144
+ reValidateMode?: "onChange" | "onBlur" | "onSubmit";
1145
+ shouldFocusError?: boolean;
1146
+ shouldUnregister?: boolean;
1147
+ delayError?: number;
1148
+ }
1149
+ declare function useInferredForm<T extends FieldValues>(schema: any, fields: ZodFormFieldConfig<T>[], options?: UseInferredFormOptions<T>): UseFormReturn<T>;
1150
+ /**
1151
+ * Hook that works with type-inferred forms
1152
+ */
1153
+ declare function useTypeInferredForm<T extends FieldValues>(formConfig: {
1154
+ schema: any;
1155
+ fields: ZodFormFieldConfig<T>[];
1156
+ }, options?: UseInferredFormOptions<T>): UseFormReturn<T>;
1157
+
1158
+ interface ConditionalFieldProps<TFieldValues extends FieldValues> {
1159
+ config: ConditionalFieldConfig<TFieldValues>;
1160
+ control: Control<TFieldValues>;
1161
+ className?: string;
1162
+ }
1163
+ declare function ConditionalField<TFieldValues extends FieldValues>({ config, control, className, }: ConditionalFieldProps<TFieldValues>): React$1.JSX.Element | null;
1164
+
1165
+ interface FieldArrayFieldProps<TFieldValues extends FieldValues> {
1166
+ config: FieldArrayConfig<TFieldValues>;
1167
+ className?: string;
1168
+ }
1169
+ declare function FieldArrayField<TFieldValues extends FieldValues>({ config, className, }: FieldArrayFieldProps<TFieldValues>): React$1.JSX.Element | null;
1170
+
1171
+ interface DynamicSectionFieldProps<TFieldValues extends FieldValues> {
1172
+ config: DynamicSectionConfig<TFieldValues>;
1173
+ control: Control<TFieldValues>;
1174
+ className?: string;
1175
+ }
1176
+ declare function DynamicSectionField<TFieldValues extends FieldValues>({ config, control, className, }: DynamicSectionFieldProps<TFieldValues>): React$1.JSX.Element | null;
1177
+
1178
+ interface FormStatusProps<T extends Record<string, any>> {
1179
+ state: EnhancedFormState<T>;
1180
+ onDismiss?: () => void;
1181
+ className?: string;
1182
+ showDetails?: boolean;
1183
+ }
1184
+ declare function FormStatus<T extends Record<string, any>>({ state, onDismiss, className, showDetails, }: FormStatusProps<T>): React$1.JSX.Element | null;
1185
+ interface FormToastProps<T extends Record<string, any>> {
1186
+ state: EnhancedFormState<T>;
1187
+ onDismiss?: () => void;
1188
+ position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
1189
+ duration?: number;
1190
+ }
1191
+ declare function FormToast<T extends Record<string, any>>({ state, onDismiss, position, duration, }: FormToastProps<T>): React$1.JSX.Element | null;
1192
+
1193
+ /**
1194
+ * Debounce function for field changes
1195
+ */
1196
+ declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
1197
+ /**
1198
+ * Throttle function for high-frequency events
1199
+ */
1200
+ declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;
1201
+ /**
1202
+ * Memoization helper for expensive computations
1203
+ */
1204
+ declare function useMemoizedCallback<T extends (...args: any[]) => any>(callback: T, deps: React.DependencyList): T;
1205
+ /**
1206
+ * Shallow comparison for React.memo
1207
+ */
1208
+ declare function shallowEqual<T extends Record<string, any>>(prevProps: T, nextProps: T): boolean;
1209
+ /**
1210
+ * Deep comparison for complex objects
1211
+ */
1212
+ declare function deepEqual<T extends Record<string, any>>(prevProps: T, nextProps: T): boolean;
1213
+ /**
1214
+ * Performance monitoring utilities (dev mode only)
1215
+ */
1216
+ declare function usePerformanceMonitor(componentName: string, enabled?: boolean): {
1217
+ renderCount: number;
1218
+ resetRenderCount: () => void;
1219
+ };
1220
+ /**
1221
+ * Optimized field change handler
1222
+ */
1223
+ declare function createOptimizedFieldHandler<T>(onChange: (value: T) => void, options?: {
1224
+ debounce?: number;
1225
+ throttle?: number;
1226
+ validate?: boolean;
1227
+ }): (value: T) => void;
1228
+ /**
1229
+ * Memoized field props to prevent unnecessary re-renders
1230
+ */
1231
+ declare function useMemoizedFieldProps<T extends Record<string, any>>(props: T, deps: React.DependencyList): T;
1232
+ /**
1233
+ * Batch field updates to reduce re-renders
1234
+ */
1235
+ declare function useBatchedFieldUpdates<T extends Record<string, any>>(form: any, fields: (keyof T)[]): {
1236
+ batchUpdate: (fieldName: keyof T, value: any) => void;
1237
+ };
1238
+
1239
+ /**
1240
+ * Common validation patterns for forms
1241
+ */
1242
+ declare const validationPatterns: {
1243
+ email: z.ZodString;
1244
+ phoneUS: z.ZodString;
1245
+ phoneInternational: z.ZodString;
1246
+ url: z.ZodString;
1247
+ password: z.ZodString;
1248
+ strongPassword: z.ZodString;
1249
+ creditCard: z.ZodString;
1250
+ ssn: z.ZodString;
1251
+ zipCode: z.ZodString;
1252
+ date: z.ZodString;
1253
+ time: z.ZodString;
1254
+ };
1255
+ /**
1256
+ * Async validation helpers
1257
+ */
1258
+ declare const asyncValidation: {
1259
+ /**
1260
+ * Email availability check
1261
+ */
1262
+ emailAvailability: (email: string) => Promise<boolean>;
1263
+ /**
1264
+ * Username availability check
1265
+ */
1266
+ usernameAvailability: (username: string) => Promise<boolean>;
1267
+ };
1268
+ /**
1269
+ * Custom error messages
1270
+ */
1271
+ declare const errorMessages: {
1272
+ required: (fieldName: string) => string;
1273
+ minLength: (fieldName: string, min: number) => string;
1274
+ maxLength: (fieldName: string, max: number) => string;
1275
+ min: (fieldName: string, min: number) => string;
1276
+ max: (fieldName: string, max: number) => string;
1277
+ pattern: (fieldName: string) => string;
1278
+ email: () => string;
1279
+ url: () => string;
1280
+ phone: () => string;
1281
+ date: () => string;
1282
+ time: () => string;
1283
+ };
1284
+ /**
1285
+ * Server-side validation integration
1286
+ */
1287
+ declare const serverValidation: {
1288
+ /**
1289
+ * Apply server errors to form
1290
+ */
1291
+ applyServerErrors: (errors: Record<string, string[]>, setError: any) => void;
1292
+ /**
1293
+ * Clear server errors
1294
+ */
1295
+ clearServerErrors: (fields: string[], clearErrors: any) => void;
1296
+ };
1297
+ /**
1298
+ * Form validation utilities
1299
+ */
1300
+ declare const validationUtils: {
1301
+ /**
1302
+ * Debounced validation
1303
+ */
1304
+ debounceValidation: (fn: Function, delay?: number) => (...args: any[]) => void;
1305
+ /**
1306
+ * Validate form data against schema
1307
+ */
1308
+ validateForm: (data: any, schema: z.ZodSchema) => Promise<{
1309
+ success: boolean;
1310
+ errors: Record<string, string>;
1311
+ }>;
1312
+ /**
1313
+ * Get field error message
1314
+ */
1315
+ getFieldError: (errors: Record<string, string>, field: string) => string | undefined;
1316
+ /**
1317
+ * Check if field has error
1318
+ */
1319
+ hasFieldError: (errors: Record<string, string>, field: string) => boolean;
1320
+ };
1321
+
1322
+ export { AdvancedFieldBuilder, type BaseFormFieldConfig, BasicFormBuilder, type BooleanFieldConfig, type ButtonDefaults, type CheckboxDefaults, CheckboxField, type CheckboxFieldProps, type CommonFieldDefaults, CommonFields, ConditionalField, type ConditionalFieldConfig, type ConditionalFieldProps, type ConditionalValidation, ConfigurableForm, type CustomFieldConfig, DateField, type DateFieldConfig, type DateFieldProps, type DateInputDefaults, type DynamicSectionConfig, DynamicSectionField, type DynamicSectionFieldProps, type EnhancedFormState, FieldArrayBuilder, type FieldArrayConfig, FieldArrayField, type FieldArrayFieldProps, FieldArrayItemBuilder, type FieldBaseProps, type FieldGroup, FileField, type FileFieldConfig, type FileFieldProps, FontPickerField, type FontPickerFieldConfig, type FontPickerFieldProps, type FormConfig, FormField, type FormFieldConfig, FormFieldHelpers, type FormProps, FormProvider, FormStatus, type FormStatusProps, type FormStep, type FormSubmissionState, type FormTestUtils, FormToast, type FormToastProps, type FormValidationError, type HeroHookFormDefaultsConfig, HeroHookFormProvider, type HeroHookFormProviderProps, type InputDefaults, InputField, type InputFieldProps, type RadioFieldConfig, type RadioGroupDefaults, RadioGroupField, type RadioGroupFieldProps, type SelectDefaults, SelectField, type SelectFieldProps, type ServerFieldError, type ServerFormError, type SliderDefaults, SliderField, type SliderFieldConfig, type SliderFieldProps, type StringFieldConfig, SubmitButton, type SubmitButtonProps, type SwitchDefaults, SwitchField, type SwitchFieldProps, type TextareaDefaults, TextareaField, type TextareaFieldProps, TypeInferredBuilder, type UseDebouncedValidationOptions, type UseEnhancedFormStateOptions, type UseInferredFormOptions, type ValidationUtils, type WithControl, type WizardFormConfig, ZodForm, type ZodFormConfig, type ZodFormFieldConfig, applyServerErrors, asyncValidation, commonValidations, createAdvancedBuilder, createBasicFormBuilder, createConditionalSchema, createConfirmPasswordSchema, createDateSchema, createEmailSchema, createField, createFieldArrayBuilder, createFieldArrayItemBuilder, createFileSchema, createFormTestUtils, createFutureDateSchema, createMaxLengthSchema, createMinLengthSchema, createMockFormData, createMockFormErrors, createNestedPathBuilder, createNumberRangeSchema, createOptimizedFieldHandler, createPasswordSchema, createPastDateSchema, createPhoneSchema, createRequiredCheckboxSchema, createRequiredSchema, createTypeInferredBuilder, createUrlSchema, createZodFormConfig, crossFieldValidation, debounce, deepEqual, defineInferredForm, errorMessages, field, getFieldError, getFormErrors, hasFieldError, hasFormErrors, serverValidation, shallowEqual, simulateFieldInput, simulateFormSubmission, throttle, useBatchedFieldUpdates, useDebouncedFieldValidation, useDebouncedValidation, useEnhancedFormState, useFormHelper, useHeroForm, useHeroHookFormDefaults, useInferredForm, useMemoizedCallback, useMemoizedFieldProps, usePerformanceMonitor, useTypeInferredForm, useZodForm, validationPatterns, validationUtils, waitForFormState };