@rachelallyson/hero-hook-form 2.0.0 โ†’ 2.1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.1.0] - 2025-01-28
6
+
7
+ ### Added
8
+
9
+ #### Next.js Server Actions Support
10
+
11
+ - **ServerActionForm Component**: New component for seamless integration with Next.js Server Actions
12
+ - **Native Form Submission**: Uses native HTML form submission with `FormData` for Server Actions
13
+ - **Optional Client-Side Validation**: Can combine client-side Zod validation with server-side validation
14
+ - **HeroUI Integration**: Full HeroUI component support with controlled components and hidden inputs
15
+ - **Error Handling**: Comprehensive error display for both client and server validation errors
16
+ - **Success Messages**: Built-in success message display (with redirect handling documentation)
17
+ - **Callbacks**: `onError` and `onSuccess` callbacks for custom handling
18
+ - **Default Values**: Support for pre-filling form fields with default values
19
+ - **Documentation**: Complete guide at `docs/guides/nextjs-server-actions.md`
20
+
5
21
  ## [2.0.0] - 2025-01-27
6
22
 
7
23
  ### ๐ŸŽ‰ Major Release - Enhanced Form Experience
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # Hero Hook Form
2
+
3
+ **Typed form helpers that combine React Hook Form and HeroUI components.**
4
+
5
+ Hero Hook Form provides a comprehensive solution for building accessible, performant forms in React applications. It combines the power of React Hook Form with HeroUI's beautiful design system, offering type-safe form building with minimal boilerplate.
6
+
7
+ ## ๐Ÿ“š Documentation
8
+
9
+ **Full documentation available at: [https://rachelallyson.github.io/hero-hook-form/](https://rachelallyson.github.io/hero-hook-form/)**
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @rachelallyson/hero-hook-form
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```tsx
20
+ import { ZodForm, FormFieldHelpers } from "@rachelallyson/hero-hook-form";
21
+ import { z } from "zod";
22
+
23
+ const schema = z.object({
24
+ email: z.string().email(),
25
+ name: z.string().min(2),
26
+ });
27
+
28
+ export function ContactForm() {
29
+ return (
30
+ <ZodForm
31
+ config={{
32
+ schema,
33
+ fields: [
34
+ FormFieldHelpers.input("name", "Name"),
35
+ FormFieldHelpers.input("email", "Email", "email"),
36
+ ],
37
+ }}
38
+ onSubmit={(data) => console.log(data)}
39
+ />
40
+ );
41
+ }
42
+ ```
43
+
44
+ ## Key Features
45
+
46
+ - **๐ŸŽฏ Type Safety** - Full TypeScript support with automatic type inference
47
+ - **๐ŸŽจ HeroUI Integration** - Beautiful, accessible components out of the box
48
+ - **โšก Performance** - Optimized with React.memo and debounced validation
49
+ - **๐Ÿ”ง Flexible APIs** - Multiple form building patterns to suit your needs
50
+ - **๐Ÿ“ Zod Integration** - Seamless schema validation with Zod
51
+ - **๐Ÿ”„ Dynamic Forms** - Conditional fields, field arrays, and dynamic sections
52
+ - **๐Ÿงช Testing Ready** - Built-in testing utilities for Cypress
53
+ - **๐Ÿš€ Next.js Server Actions** - Compatible with Next.js authentication patterns
54
+
55
+ ## Form Building Patterns
56
+
57
+ ### 1. Helper Functions (Recommended)
58
+
59
+ ```tsx
60
+ const fields = [
61
+ FormFieldHelpers.input("name", "Name"),
62
+ FormFieldHelpers.textarea("message", "Message"),
63
+ FormFieldHelpers.select("country", "Country", options),
64
+ ];
65
+ ```
66
+
67
+ ### 2. Builder Pattern
68
+
69
+ ```tsx
70
+ import { createBasicFormBuilder } from "@rachelallyson/hero-hook-form";
71
+
72
+ const fields = createBasicFormBuilder()
73
+ .input("name", "Name")
74
+ .textarea("message", "Message")
75
+ .select("country", "Country", options)
76
+ .build();
77
+ ```
78
+
79
+ ### 3. Type-Inferred Forms
80
+
81
+ ```tsx
82
+ import { defineInferredForm, field } from "@rachelallyson/hero-hook-form";
83
+
84
+ const form = defineInferredForm({
85
+ name: field.string("Name"),
86
+ email: field.email("Email"),
87
+ age: field.number("Age"),
88
+ });
89
+ ```
90
+
91
+ ### 4. Next.js Server Actions
92
+
93
+ ```tsx
94
+ import { ServerActionForm, FormFieldHelpers } from "@rachelallyson/hero-hook-form";
95
+ import { signup } from "@/app/actions/auth";
96
+
97
+ <ServerActionForm
98
+ action={signup}
99
+ fields={[
100
+ FormFieldHelpers.input("name", "Name"),
101
+ FormFieldHelpers.input("email", "Email", { type: "email" }),
102
+ ]}
103
+ />
104
+ ```
105
+
106
+ ## What's Included
107
+
108
+ - **Components**: `Form`, `FormField`, `ZodForm`, `ServerActionForm`, field components, `FormStatus`
109
+ - **Hooks**: `useFormHelper`, `useHeroForm`, `useEnhancedFormState`, `useDebouncedValidation`, `useInferredForm`
110
+ - **Builders**: `createBasicFormBuilder`, `createAdvancedBuilder`, `createTypeInferredBuilder`
111
+ - **Utils**: `applyServerErrors`, validation helpers, performance utilities, testing utilities
112
+ - **Zod Integration**: `ZodForm` component with automatic schema validation
113
+ - **Next.js Support**: `ServerActionForm` for Next.js Server Actions and authentication
114
+
115
+ ## Setup
116
+
117
+ 1. **Install the package**:
118
+
119
+ ```bash
120
+ npm install @rachelallyson/hero-hook-form
121
+ ```
122
+
123
+ 2. **Set up your provider**:
124
+
125
+ ```tsx
126
+ import { HeroHookFormProvider } from "@rachelallyson/hero-hook-form";
127
+
128
+ function App() {
129
+ return (
130
+ <HeroHookFormProvider>
131
+ <YourForms />
132
+ </HeroHookFormProvider>
133
+ );
134
+ }
135
+ ```
136
+
137
+ 3. **Create your first form**:
138
+
139
+ ```tsx
140
+ import { ZodForm, FormFieldHelpers } from "@rachelallyson/hero-hook-form";
141
+ ```
142
+
143
+ ## Documentation Links
144
+
145
+ - **Quick Start Guide**: [https://rachelallyson.github.io/hero-hook-form/guides/quickstart](https://rachelallyson.github.io/hero-hook-form/guides/quickstart)
146
+ - **API Reference**: [https://rachelallyson.github.io/hero-hook-form/api/README](https://rachelallyson.github.io/hero-hook-form/api/README)
147
+ - **Next.js Server Actions**: [Next.js Authentication Guide](./docs/guides/nextjs-server-actions.md) - Use with Next.js auth forms
148
+ - **Dynamic Forms**: [https://rachelallyson.github.io/hero-hook-form/guides/dynamic-forms](https://rachelallyson.github.io/hero-hook-form/guides/dynamic-forms)
149
+ - **Error Handling**: [https://rachelallyson.github.io/hero-hook-form/guides/error-handling](https://rachelallyson.github.io/hero-hook-form/guides/error-handling)
150
+ - **Testing Guide**: [https://rachelallyson.github.io/hero-hook-form/guides/testing-guide](https://rachelallyson.github.io/hero-hook-form/guides/testing-guide)
151
+ - **Live Demos**: [https://rachelallyson.github.io/hero-hook-form/demo](https://rachelallyson.github.io/hero-hook-form/demo)
152
+
153
+ ## What's New in v2.0
154
+
155
+ - **Dynamic Form Sections** - Conditional fields and field arrays
156
+ - **Enhanced Performance** - Memoized components and debounced validation
157
+ - **Type-Inferred Forms** - Alternative API with automatic schema generation
158
+ - **Form State Management** - Enhanced state tracking and status components
159
+ - **Validation Patterns** - Cross-field validation and common patterns
160
+
161
+ ## Requirements
162
+
163
+ - React >= 18.2.0
164
+ - React Hook Form >= 7
165
+ - Zod >= 4
166
+ - HeroUI components (peer dependencies)
167
+
168
+ ## License
169
+
170
+ ISC License - see [LICENSE](LICENSE) for details.
171
+
172
+ ## Community
173
+
174
+ - **GitHub**: [rachelallyson/hero-hook-form](https://github.com/rachelallyson/hero-hook-form)
175
+ - **Issues**: [Report bugs or request features](https://github.com/rachelallyson/hero-hook-form/issues)
176
+ - **Documentation**: [https://rachelallyson.github.io/hero-hook-form/](https://rachelallyson.github.io/hero-hook-form/)
package/dist/index.d.ts CHANGED
@@ -242,6 +242,75 @@ interface FormFieldProps<TFieldValues extends FieldValues> {
242
242
  }
243
243
  declare const FormField: <TFieldValues extends FieldValues>(props: FormFieldProps<TFieldValues>) => React$1.JSX.Element;
244
244
 
245
+ type ServerAction<TState = unknown, TFormData = FormData> = (state: TState | undefined, formData: TFormData) => Promise<TState>;
246
+ interface ActionState {
247
+ errors?: Record<string, string[]>;
248
+ message?: string;
249
+ success?: boolean;
250
+ }
251
+ interface ServerActionFormProps<T extends FieldValues> {
252
+ /** Server Action function (Next.js pattern) */
253
+ action: ServerAction<ActionState, FormData>;
254
+ /** Optional: Zod schema for client-side validation before submission */
255
+ clientValidationSchema?: z.ZodSchema<T>;
256
+ className?: string;
257
+ columns?: 1 | 2 | 3;
258
+ /** Default values for form fields */
259
+ defaultValues?: Partial<T>;
260
+ fields: FormFieldConfig<T>[];
261
+ /** Initial state for useActionState */
262
+ initialState?: ActionState;
263
+ layout?: "vertical" | "horizontal" | "grid";
264
+ /** Callback when form submission encounters an error */
265
+ onError?: (error: {
266
+ errors?: Record<string, string[]>;
267
+ message?: string;
268
+ }) => void;
269
+ /** Callback when form submission succeeds */
270
+ onSuccess?: (data: FormData) => void;
271
+ resetButtonText?: string;
272
+ showResetButton?: boolean;
273
+ spacing?: "2" | "4" | "6" | "8" | "lg";
274
+ submitButtonProps?: Partial<React$1.ComponentProps<typeof Button>>;
275
+ submitButtonText?: string;
276
+ subtitle?: string;
277
+ title?: string;
278
+ }
279
+ /**
280
+ * ServerActionForm - A form component compatible with Next.js Server Actions
281
+ *
282
+ * This component works with Next.js authentication patterns by using native
283
+ * HTML form submission with Server Actions, while still providing the
284
+ * beautiful HeroUI field components.
285
+ *
286
+ * **Validation Options:**
287
+ * - **Server-side only (default)**: Form submits directly to Server Action
288
+ * - **Client + Server (optional)**: Pass `clientValidationSchema` for client-side
289
+ * validation before submission. Server Action still validates (defense in depth).
290
+ *
291
+ * **Important Notes:**
292
+ * - If your Server Action calls `redirect()`, success messages won't display
293
+ * (the page navigates away). Use URL params or cookies for success messages
294
+ * when redirecting.
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * // Server-side only validation
299
+ * <ServerActionForm
300
+ * action={signup}
301
+ * fields={[...]}
302
+ * />
303
+ *
304
+ * // Client + Server validation
305
+ * <ServerActionForm
306
+ * action={signup}
307
+ * clientValidationSchema={signupSchema}
308
+ * fields={[...]}
309
+ * />
310
+ * ```
311
+ */
312
+ declare function ServerActionForm<T extends FieldValues>({ action, className, clientValidationSchema, columns, defaultValues, fields, initialState, layout, onError, onSuccess, resetButtonText, showResetButton, spacing, submitButtonProps, submitButtonText, subtitle, title, }: ServerActionFormProps<T>): React$1.JSX.Element;
313
+
245
314
  type CheckboxFieldProps<TFieldValues extends FieldValues> = FieldBaseProps<TFieldValues, boolean> & WithControl<TFieldValues> & {
246
315
  checkboxProps?: Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">;
247
316
  };
@@ -562,10 +631,6 @@ declare const createPhoneSchema: () => z.ZodString;
562
631
  * Creates a password validation schema with common requirements
563
632
  */
564
633
  declare const createPasswordSchema: (minLength?: number) => z.ZodString;
565
- /**
566
- * Creates a confirm password validation schema
567
- */
568
- declare const createConfirmPasswordSchema: (passwordField: string) => z.ZodString;
569
634
  /**
570
635
  * Creates a number validation schema with range
571
636
  */
@@ -591,15 +656,35 @@ declare const createFileSchema: (maxSizeInMB?: number, allowedTypes?: string[])
591
656
  */
592
657
  declare const createRequiredCheckboxSchema: (fieldName: string) => z.ZodBoolean;
593
658
  /**
594
- * Creates a conditional validation schema
659
+ * Cross-field validation helpers
595
660
  */
596
- declare const createConditionalSchema: <T>(condition: (data: unknown) => boolean, schema: z.ZodSchema<T>, errorMessage?: string) => z.ZodAny;
661
+ declare const crossFieldValidation: {
662
+ /**
663
+ * Conditional required field validation
664
+ */
665
+ conditionalRequired: (field: string, conditionField: string, conditionValue: any) => z.ZodObject<{
666
+ [x: string]: z.ZodString | z.ZodAny;
667
+ }, z.core.$strip>;
668
+ /**
669
+ * Date range validation
670
+ */
671
+ dateRange: (startField: string, endField: string) => z.ZodObject<{
672
+ [x: string]: z.ZodString;
673
+ }, z.core.$strip>;
674
+ /**
675
+ * Password confirmation validation
676
+ */
677
+ passwordConfirmation: (passwordField: string, confirmField: string) => z.ZodObject<{
678
+ [x: string]: z.ZodString;
679
+ }, z.core.$strip>;
680
+ };
597
681
  /**
598
682
  * Common validation patterns for forms
599
683
  */
600
684
  declare const commonValidations: {
601
- conditional: <T>(condition: (data: unknown) => boolean, schema: z.ZodSchema<T>, errorMessage?: string) => z.ZodAny;
602
- confirmPassword: (passwordField: string) => z.ZodString;
685
+ confirmPassword: (passwordField: string, confirmField: string) => z.ZodObject<{
686
+ [x: string]: z.ZodString;
687
+ }, z.core.$strip>;
603
688
  date: (fieldName: string) => z.ZodDate;
604
689
  email: z.ZodEmail;
605
690
  file: (maxSizeInMB?: number, allowedTypes?: string[]) => z.ZodCustom<File, File>;
@@ -614,29 +699,6 @@ declare const commonValidations: {
614
699
  requiredCheckbox: (fieldName: string) => z.ZodBoolean;
615
700
  url: z.ZodString;
616
701
  };
617
- /**
618
- * Cross-field validation helpers
619
- */
620
- declare const crossFieldValidation: {
621
- /**
622
- * Password confirmation validation
623
- */
624
- passwordConfirmation: (passwordField: string, confirmField: string) => z.ZodObject<{
625
- [x: string]: z.ZodString;
626
- }, z.core.$strip>;
627
- /**
628
- * Date range validation
629
- */
630
- dateRange: (startField: string, endField: string) => z.ZodObject<{
631
- [x: string]: z.ZodString;
632
- }, z.core.$strip>;
633
- /**
634
- * Conditional required field validation
635
- */
636
- conditionalRequired: (field: string, conditionField: string, conditionValue: any) => z.ZodObject<{
637
- [x: string]: z.ZodString | z.ZodAny;
638
- }, z.core.$strip>;
639
- };
640
702
 
641
703
  interface ZodFormProps<T extends FieldValues> {
642
704
  className?: string;
@@ -653,7 +715,6 @@ interface ZodFormProps<T extends FieldValues> {
653
715
  submitButtonText?: string;
654
716
  subtitle?: string;
655
717
  title?: string;
656
- errorDisplay?: "inline" | "toast" | "modal" | "none";
657
718
  render?: (formState: {
658
719
  form: UseFormReturn<T>;
659
720
  isSubmitting: boolean;
@@ -663,7 +724,7 @@ interface ZodFormProps<T extends FieldValues> {
663
724
  values: T;
664
725
  }) => React$1.ReactNode;
665
726
  }
666
- declare function ZodForm<T extends FieldValues>({ className, columns, config, errorDisplay, layout, onError, onSubmit, onSuccess, render, resetButtonText, showResetButton, spacing, submitButtonProps, submitButtonText, subtitle, title, }: ZodFormProps<T>): 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;
727
+ declare function ZodForm<T extends FieldValues>({ className, columns, config, layout, onError, onSubmit, onSuccess, render, resetButtonText, showResetButton, spacing, submitButtonProps, submitButtonText, subtitle, title, }: ZodFormProps<T>): 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;
667
728
 
668
729
  /**
669
730
  * Hook for using Zod validation with React Hook Form
@@ -717,13 +778,13 @@ declare function createBasicFormBuilder<T extends FieldValues>(): BasicFormBuild
717
778
  */
718
779
  declare const FormFieldHelpers: {
719
780
  /**
720
- * Create an input field
781
+ * Create a checkbox field
721
782
  */
722
- input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password") => ZodFormFieldConfig<T>;
783
+ checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
723
784
  /**
724
- * Create a textarea field
785
+ * Create an input field
725
786
  */
726
- textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
787
+ input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password") => ZodFormFieldConfig<T>;
727
788
  /**
728
789
  * Create a select field
729
790
  */
@@ -731,27 +792,27 @@ declare const FormFieldHelpers: {
731
792
  label: string;
732
793
  value: string | number;
733
794
  }[]) => ZodFormFieldConfig<T>;
734
- /**
735
- * Create a checkbox field
736
- */
737
- checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
738
795
  /**
739
796
  * Create a switch field
740
797
  */
741
798
  switch: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
799
+ /**
800
+ * Create a textarea field
801
+ */
802
+ textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
742
803
  };
743
804
  /**
744
805
  * Common field collections
745
806
  */
746
807
  declare const CommonFields: {
747
- /**
748
- * Personal information fields
749
- */
750
- personal: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
751
808
  /**
752
809
  * Address fields
753
810
  */
754
811
  address: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
812
+ /**
813
+ * Personal information fields
814
+ */
815
+ personal: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
755
816
  /**
756
817
  * Terms and conditions fields
757
818
  */
@@ -919,12 +980,7 @@ declare class TypeInferredBuilder<T extends FieldValues> {
919
980
  select(name: Path<T>, label: string, options: {
920
981
  label: string;
921
982
  value: string | number;
922
- }[], fieldOptions?: {
923
- placeholder?: string;
924
- description?: string;
925
- isDisabled?: boolean;
926
- className?: string;
927
- }): this;
983
+ }[]): this;
928
984
  /**
929
985
  * Add a checkbox field
930
986
  */
@@ -1007,23 +1063,23 @@ declare function defineInferredForm<T extends FieldValues>(fieldDefinitions: (bu
1007
1063
  * Field type builders for individual field creation
1008
1064
  */
1009
1065
  declare const field: {
1010
- text: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["text"]>[2]) => TypeInferredBuilder<T>;
1066
+ checkbox: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["checkbox"]>[2]) => TypeInferredBuilder<T>;
1067
+ date: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["date"]>[2]) => TypeInferredBuilder<T>;
1011
1068
  email: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["email"]>[2]) => TypeInferredBuilder<T>;
1069
+ file: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["file"]>[2]) => TypeInferredBuilder<T>;
1012
1070
  number: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["number"]>[2]) => TypeInferredBuilder<T>;
1013
- textarea: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["textarea"]>[2]) => TypeInferredBuilder<T>;
1014
- select: <T extends FieldValues>(name: Path<T>, label: string, options: {
1015
- label: string;
1016
- value: string | number;
1017
- }[], fieldOptions?: Parameters<TypeInferredBuilder<T>["select"]>[3]) => TypeInferredBuilder<T>;
1018
- checkbox: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["checkbox"]>[2]) => TypeInferredBuilder<T>;
1019
- switch: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["switch"]>[2]) => TypeInferredBuilder<T>;
1020
1071
  radio: <T extends FieldValues>(name: Path<T>, label: string, options: {
1021
1072
  label: string;
1022
1073
  value: string | number;
1023
1074
  }[], fieldOptions?: Parameters<TypeInferredBuilder<T>["radio"]>[3]) => TypeInferredBuilder<T>;
1075
+ select: <T extends FieldValues>(name: Path<T>, label: string, options: {
1076
+ label: string;
1077
+ value: string | number;
1078
+ }[]) => TypeInferredBuilder<T>;
1024
1079
  slider: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["slider"]>[2]) => TypeInferredBuilder<T>;
1025
- date: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["date"]>[2]) => TypeInferredBuilder<T>;
1026
- file: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["file"]>[2]) => TypeInferredBuilder<T>;
1080
+ switch: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["switch"]>[2]) => TypeInferredBuilder<T>;
1081
+ text: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["text"]>[2]) => TypeInferredBuilder<T>;
1082
+ textarea: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["textarea"]>[2]) => TypeInferredBuilder<T>;
1027
1083
  };
1028
1084
 
1029
1085
  /**
@@ -1056,7 +1112,7 @@ declare class NestedPathBuilder<T extends FieldValues> {
1056
1112
  * Add a field with template literal path
1057
1113
  * Usage: builder.field`user.profile.name`("Full Name")
1058
1114
  */
1059
- fieldTemplate(path: TemplateStringsArray, ...args: any[]): FieldTemplateBuilder<T>;
1115
+ fieldTemplate(path: TemplateStringsArray): FieldTemplateBuilder<T>;
1060
1116
  /**
1061
1117
  * Return to the parent builder (no-op for root builder)
1062
1118
  */
@@ -1097,12 +1153,12 @@ declare class SectionBuilder<T extends FieldValues, TPath extends Path<T>> {
1097
1153
  /**
1098
1154
  * Add multiple fields to the section
1099
1155
  */
1100
- fields(fieldDefinitions: Array<{
1156
+ fields(fieldDefinitions: {
1101
1157
  name: string;
1102
1158
  label: string;
1103
1159
  type?: string;
1104
1160
  props?: any;
1105
- }>): SectionBuilder<T, TPath>;
1161
+ }[]): SectionBuilder<T, TPath>;
1106
1162
  /**
1107
1163
  * Nest deeper into the section
1108
1164
  */
@@ -1168,20 +1224,20 @@ interface ConditionalFieldProps<TFieldValues extends FieldValues> {
1168
1224
  control: Control<TFieldValues>;
1169
1225
  className?: string;
1170
1226
  }
1171
- declare function ConditionalField<TFieldValues extends FieldValues>({ config, control, className, }: ConditionalFieldProps<TFieldValues>): React$1.JSX.Element | null;
1227
+ declare function ConditionalField<TFieldValues extends FieldValues>({ className, config, control, }: ConditionalFieldProps<TFieldValues>): React$1.JSX.Element | null;
1172
1228
 
1173
1229
  interface FieldArrayFieldProps<TFieldValues extends FieldValues> {
1174
1230
  config: FieldArrayConfig<TFieldValues>;
1175
1231
  className?: string;
1176
1232
  }
1177
- declare function FieldArrayField<TFieldValues extends FieldValues>({ config, className, }: FieldArrayFieldProps<TFieldValues>): React$1.JSX.Element | null;
1233
+ declare function FieldArrayField<TFieldValues extends FieldValues>({ className, config, }: FieldArrayFieldProps<TFieldValues>): React$1.JSX.Element | null;
1178
1234
 
1179
1235
  interface DynamicSectionFieldProps<TFieldValues extends FieldValues> {
1180
1236
  config: DynamicSectionConfig<TFieldValues>;
1181
1237
  control: Control<TFieldValues>;
1182
1238
  className?: string;
1183
1239
  }
1184
- declare function DynamicSectionField<TFieldValues extends FieldValues>({ config, control, className, }: DynamicSectionFieldProps<TFieldValues>): React$1.JSX.Element | null;
1240
+ declare function DynamicSectionField<TFieldValues extends FieldValues>({ className, config, control, }: DynamicSectionFieldProps<TFieldValues>): React$1.JSX.Element | null;
1185
1241
 
1186
1242
  interface FormStatusProps<T extends Record<string, any>> {
1187
1243
  state: EnhancedFormState<T>;
@@ -1189,14 +1245,14 @@ interface FormStatusProps<T extends Record<string, any>> {
1189
1245
  className?: string;
1190
1246
  showDetails?: boolean;
1191
1247
  }
1192
- declare function FormStatus<T extends Record<string, any>>({ state, onDismiss, className, showDetails, }: FormStatusProps<T>): React$1.JSX.Element | null;
1248
+ declare function FormStatus<T extends Record<string, any>>({ className, onDismiss, showDetails, state, }: FormStatusProps<T>): React$1.JSX.Element | null;
1193
1249
  interface FormToastProps<T extends Record<string, any>> {
1194
1250
  state: EnhancedFormState<T>;
1195
1251
  onDismiss?: () => void;
1196
1252
  position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
1197
1253
  duration?: number;
1198
1254
  }
1199
- declare function FormToast<T extends Record<string, any>>({ state, onDismiss, position, duration, }: FormToastProps<T>): React$1.JSX.Element | null;
1255
+ declare function FormToast<T extends Record<string, any>>({ duration, onDismiss, position, state, }: FormToastProps<T>): React$1.JSX.Element | null;
1200
1256
 
1201
1257
  /**
1202
1258
  * Debounce function for field changes
@@ -1231,34 +1287,27 @@ declare function usePerformanceMonitor(componentName: string, enabled?: boolean)
1231
1287
  declare function createOptimizedFieldHandler<T>(onChange: (value: T) => void, options?: {
1232
1288
  debounce?: number;
1233
1289
  throttle?: number;
1234
- validate?: boolean;
1235
1290
  }): (value: T) => void;
1236
1291
  /**
1237
1292
  * Memoized field props to prevent unnecessary re-renders
1238
1293
  */
1239
1294
  declare function useMemoizedFieldProps<T extends Record<string, any>>(props: T, deps: React.DependencyList): T;
1240
- /**
1241
- * Batch field updates to reduce re-renders
1242
- */
1243
- declare function useBatchedFieldUpdates<T extends Record<string, any>>(form: any, fields: (keyof T)[]): {
1244
- batchUpdate: (fieldName: keyof T, value: any) => void;
1245
- };
1246
1295
 
1247
1296
  /**
1248
1297
  * Common validation patterns for forms
1249
1298
  */
1250
1299
  declare const validationPatterns: {
1300
+ creditCard: z.ZodString;
1301
+ date: z.ZodString;
1251
1302
  email: z.ZodString;
1252
- phoneUS: z.ZodString;
1253
- phoneInternational: z.ZodString;
1254
- url: z.ZodString;
1255
1303
  password: z.ZodString;
1256
- strongPassword: z.ZodString;
1257
- creditCard: z.ZodString;
1304
+ phoneInternational: z.ZodString;
1305
+ phoneUS: z.ZodString;
1258
1306
  ssn: z.ZodString;
1259
- zipCode: z.ZodString;
1260
- date: z.ZodString;
1307
+ strongPassword: z.ZodString;
1261
1308
  time: z.ZodString;
1309
+ url: z.ZodString;
1310
+ zipCode: z.ZodString;
1262
1311
  };
1263
1312
  /**
1264
1313
  * Async validation helpers
@@ -1277,17 +1326,17 @@ declare const asyncValidation: {
1277
1326
  * Custom error messages
1278
1327
  */
1279
1328
  declare const errorMessages: {
1280
- required: (fieldName: string) => string;
1281
- minLength: (fieldName: string, min: number) => string;
1329
+ date: () => string;
1330
+ email: () => string;
1331
+ max: (fieldName: string, max: number) => string;
1282
1332
  maxLength: (fieldName: string, max: number) => string;
1283
1333
  min: (fieldName: string, min: number) => string;
1284
- max: (fieldName: string, max: number) => string;
1334
+ minLength: (fieldName: string, min: number) => string;
1285
1335
  pattern: (fieldName: string) => string;
1286
- email: () => string;
1287
- url: () => string;
1288
1336
  phone: () => string;
1289
- date: () => string;
1337
+ required: (fieldName: string) => string;
1290
1338
  time: () => string;
1339
+ url: () => string;
1291
1340
  };
1292
1341
  /**
1293
1342
  * Server-side validation integration
@@ -1309,14 +1358,7 @@ declare const validationUtils: {
1309
1358
  /**
1310
1359
  * Debounced validation
1311
1360
  */
1312
- debounceValidation: (fn: Function, delay?: number) => (...args: any[]) => void;
1313
- /**
1314
- * Validate form data against schema
1315
- */
1316
- validateForm: (data: any, schema: z.ZodSchema) => Promise<{
1317
- success: boolean;
1318
- errors: Record<string, string>;
1319
- }>;
1361
+ debounceValidation: (fn: (...args: any[]) => void, delay?: number) => (...args: any[]) => void;
1320
1362
  /**
1321
1363
  * Get field error message
1322
1364
  */
@@ -1325,6 +1367,13 @@ declare const validationUtils: {
1325
1367
  * Check if field has error
1326
1368
  */
1327
1369
  hasFieldError: (errors: Record<string, string>, field: string) => boolean;
1370
+ /**
1371
+ * Validate form data against schema
1372
+ */
1373
+ validateForm: (data: any, schema: z.ZodSchema) => Promise<{
1374
+ errors: Record<string, string>;
1375
+ success: boolean;
1376
+ }>;
1328
1377
  };
1329
1378
 
1330
- 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 };
1379
+ 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, ServerActionForm, 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, 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, useDebouncedFieldValidation, useDebouncedValidation, useEnhancedFormState, useFormHelper, useHeroForm, useHeroHookFormDefaults, useInferredForm, useMemoizedCallback, useMemoizedFieldProps, usePerformanceMonitor, useTypeInferredForm, useZodForm, validationPatterns, validationUtils, waitForFormState };