@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 +16 -0
- package/README.md +176 -0
- package/dist/index.d.ts +147 -98
- package/dist/index.js +1069 -689
- package/dist/react/index.d.ts +147 -98
- package/dist/react/index.js +1069 -689
- package/package.json +58 -33
package/dist/react/index.d.ts
CHANGED
|
@@ -234,6 +234,75 @@ interface FormFieldProps<TFieldValues extends FieldValues> {
|
|
|
234
234
|
}
|
|
235
235
|
declare const FormField: <TFieldValues extends FieldValues>(props: FormFieldProps<TFieldValues>) => React$1.JSX.Element;
|
|
236
236
|
|
|
237
|
+
type ServerAction<TState = unknown, TFormData = FormData> = (state: TState | undefined, formData: TFormData) => Promise<TState>;
|
|
238
|
+
interface ActionState {
|
|
239
|
+
errors?: Record<string, string[]>;
|
|
240
|
+
message?: string;
|
|
241
|
+
success?: boolean;
|
|
242
|
+
}
|
|
243
|
+
interface ServerActionFormProps<T extends FieldValues> {
|
|
244
|
+
/** Server Action function (Next.js pattern) */
|
|
245
|
+
action: ServerAction<ActionState, FormData>;
|
|
246
|
+
/** Optional: Zod schema for client-side validation before submission */
|
|
247
|
+
clientValidationSchema?: z.ZodSchema<T>;
|
|
248
|
+
className?: string;
|
|
249
|
+
columns?: 1 | 2 | 3;
|
|
250
|
+
/** Default values for form fields */
|
|
251
|
+
defaultValues?: Partial<T>;
|
|
252
|
+
fields: FormFieldConfig<T>[];
|
|
253
|
+
/** Initial state for useActionState */
|
|
254
|
+
initialState?: ActionState;
|
|
255
|
+
layout?: "vertical" | "horizontal" | "grid";
|
|
256
|
+
/** Callback when form submission encounters an error */
|
|
257
|
+
onError?: (error: {
|
|
258
|
+
errors?: Record<string, string[]>;
|
|
259
|
+
message?: string;
|
|
260
|
+
}) => void;
|
|
261
|
+
/** Callback when form submission succeeds */
|
|
262
|
+
onSuccess?: (data: FormData) => void;
|
|
263
|
+
resetButtonText?: string;
|
|
264
|
+
showResetButton?: boolean;
|
|
265
|
+
spacing?: "2" | "4" | "6" | "8" | "lg";
|
|
266
|
+
submitButtonProps?: Partial<React$1.ComponentProps<typeof Button>>;
|
|
267
|
+
submitButtonText?: string;
|
|
268
|
+
subtitle?: string;
|
|
269
|
+
title?: string;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* ServerActionForm - A form component compatible with Next.js Server Actions
|
|
273
|
+
*
|
|
274
|
+
* This component works with Next.js authentication patterns by using native
|
|
275
|
+
* HTML form submission with Server Actions, while still providing the
|
|
276
|
+
* beautiful HeroUI field components.
|
|
277
|
+
*
|
|
278
|
+
* **Validation Options:**
|
|
279
|
+
* - **Server-side only (default)**: Form submits directly to Server Action
|
|
280
|
+
* - **Client + Server (optional)**: Pass `clientValidationSchema` for client-side
|
|
281
|
+
* validation before submission. Server Action still validates (defense in depth).
|
|
282
|
+
*
|
|
283
|
+
* **Important Notes:**
|
|
284
|
+
* - If your Server Action calls `redirect()`, success messages won't display
|
|
285
|
+
* (the page navigates away). Use URL params or cookies for success messages
|
|
286
|
+
* when redirecting.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```tsx
|
|
290
|
+
* // Server-side only validation
|
|
291
|
+
* <ServerActionForm
|
|
292
|
+
* action={signup}
|
|
293
|
+
* fields={[...]}
|
|
294
|
+
* />
|
|
295
|
+
*
|
|
296
|
+
* // Client + Server validation
|
|
297
|
+
* <ServerActionForm
|
|
298
|
+
* action={signup}
|
|
299
|
+
* clientValidationSchema={signupSchema}
|
|
300
|
+
* fields={[...]}
|
|
301
|
+
* />
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
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;
|
|
305
|
+
|
|
237
306
|
type CheckboxFieldProps<TFieldValues extends FieldValues> = FieldBaseProps<TFieldValues, boolean> & WithControl<TFieldValues> & {
|
|
238
307
|
checkboxProps?: Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">;
|
|
239
308
|
};
|
|
@@ -554,10 +623,6 @@ declare const createPhoneSchema: () => z.ZodString;
|
|
|
554
623
|
* Creates a password validation schema with common requirements
|
|
555
624
|
*/
|
|
556
625
|
declare const createPasswordSchema: (minLength?: number) => z.ZodString;
|
|
557
|
-
/**
|
|
558
|
-
* Creates a confirm password validation schema
|
|
559
|
-
*/
|
|
560
|
-
declare const createConfirmPasswordSchema: (passwordField: string) => z.ZodString;
|
|
561
626
|
/**
|
|
562
627
|
* Creates a number validation schema with range
|
|
563
628
|
*/
|
|
@@ -583,15 +648,35 @@ declare const createFileSchema: (maxSizeInMB?: number, allowedTypes?: string[])
|
|
|
583
648
|
*/
|
|
584
649
|
declare const createRequiredCheckboxSchema: (fieldName: string) => z.ZodBoolean;
|
|
585
650
|
/**
|
|
586
|
-
*
|
|
651
|
+
* Cross-field validation helpers
|
|
587
652
|
*/
|
|
588
|
-
declare const
|
|
653
|
+
declare const crossFieldValidation: {
|
|
654
|
+
/**
|
|
655
|
+
* Conditional required field validation
|
|
656
|
+
*/
|
|
657
|
+
conditionalRequired: (field: string, conditionField: string, conditionValue: any) => z.ZodObject<{
|
|
658
|
+
[x: string]: z.ZodString | z.ZodAny;
|
|
659
|
+
}, z.core.$strip>;
|
|
660
|
+
/**
|
|
661
|
+
* Date range validation
|
|
662
|
+
*/
|
|
663
|
+
dateRange: (startField: string, endField: string) => z.ZodObject<{
|
|
664
|
+
[x: string]: z.ZodString;
|
|
665
|
+
}, z.core.$strip>;
|
|
666
|
+
/**
|
|
667
|
+
* Password confirmation validation
|
|
668
|
+
*/
|
|
669
|
+
passwordConfirmation: (passwordField: string, confirmField: string) => z.ZodObject<{
|
|
670
|
+
[x: string]: z.ZodString;
|
|
671
|
+
}, z.core.$strip>;
|
|
672
|
+
};
|
|
589
673
|
/**
|
|
590
674
|
* Common validation patterns for forms
|
|
591
675
|
*/
|
|
592
676
|
declare const commonValidations: {
|
|
593
|
-
|
|
594
|
-
|
|
677
|
+
confirmPassword: (passwordField: string, confirmField: string) => z.ZodObject<{
|
|
678
|
+
[x: string]: z.ZodString;
|
|
679
|
+
}, z.core.$strip>;
|
|
595
680
|
date: (fieldName: string) => z.ZodDate;
|
|
596
681
|
email: z.ZodEmail;
|
|
597
682
|
file: (maxSizeInMB?: number, allowedTypes?: string[]) => z.ZodCustom<File, File>;
|
|
@@ -606,29 +691,6 @@ declare const commonValidations: {
|
|
|
606
691
|
requiredCheckbox: (fieldName: string) => z.ZodBoolean;
|
|
607
692
|
url: z.ZodString;
|
|
608
693
|
};
|
|
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
|
-
};
|
|
632
694
|
|
|
633
695
|
interface ZodFormProps<T extends FieldValues> {
|
|
634
696
|
className?: string;
|
|
@@ -645,7 +707,6 @@ interface ZodFormProps<T extends FieldValues> {
|
|
|
645
707
|
submitButtonText?: string;
|
|
646
708
|
subtitle?: string;
|
|
647
709
|
title?: string;
|
|
648
|
-
errorDisplay?: "inline" | "toast" | "modal" | "none";
|
|
649
710
|
render?: (formState: {
|
|
650
711
|
form: UseFormReturn<T>;
|
|
651
712
|
isSubmitting: boolean;
|
|
@@ -655,7 +716,7 @@ interface ZodFormProps<T extends FieldValues> {
|
|
|
655
716
|
values: T;
|
|
656
717
|
}) => React$1.ReactNode;
|
|
657
718
|
}
|
|
658
|
-
declare function ZodForm<T extends FieldValues>({ className, columns, config,
|
|
719
|
+
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;
|
|
659
720
|
|
|
660
721
|
/**
|
|
661
722
|
* Hook for using Zod validation with React Hook Form
|
|
@@ -709,13 +770,13 @@ declare function createBasicFormBuilder<T extends FieldValues>(): BasicFormBuild
|
|
|
709
770
|
*/
|
|
710
771
|
declare const FormFieldHelpers: {
|
|
711
772
|
/**
|
|
712
|
-
* Create
|
|
773
|
+
* Create a checkbox field
|
|
713
774
|
*/
|
|
714
|
-
|
|
775
|
+
checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
|
|
715
776
|
/**
|
|
716
|
-
* Create
|
|
777
|
+
* Create an input field
|
|
717
778
|
*/
|
|
718
|
-
|
|
779
|
+
input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password") => ZodFormFieldConfig<T>;
|
|
719
780
|
/**
|
|
720
781
|
* Create a select field
|
|
721
782
|
*/
|
|
@@ -723,27 +784,27 @@ declare const FormFieldHelpers: {
|
|
|
723
784
|
label: string;
|
|
724
785
|
value: string | number;
|
|
725
786
|
}[]) => ZodFormFieldConfig<T>;
|
|
726
|
-
/**
|
|
727
|
-
* Create a checkbox field
|
|
728
|
-
*/
|
|
729
|
-
checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
|
|
730
787
|
/**
|
|
731
788
|
* Create a switch field
|
|
732
789
|
*/
|
|
733
790
|
switch: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
|
|
791
|
+
/**
|
|
792
|
+
* Create a textarea field
|
|
793
|
+
*/
|
|
794
|
+
textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
|
|
734
795
|
};
|
|
735
796
|
/**
|
|
736
797
|
* Common field collections
|
|
737
798
|
*/
|
|
738
799
|
declare const CommonFields: {
|
|
739
|
-
/**
|
|
740
|
-
* Personal information fields
|
|
741
|
-
*/
|
|
742
|
-
personal: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
|
|
743
800
|
/**
|
|
744
801
|
* Address fields
|
|
745
802
|
*/
|
|
746
803
|
address: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
|
|
804
|
+
/**
|
|
805
|
+
* Personal information fields
|
|
806
|
+
*/
|
|
807
|
+
personal: <T extends FieldValues>() => ZodFormFieldConfig<T>[];
|
|
747
808
|
/**
|
|
748
809
|
* Terms and conditions fields
|
|
749
810
|
*/
|
|
@@ -911,12 +972,7 @@ declare class TypeInferredBuilder<T extends FieldValues> {
|
|
|
911
972
|
select(name: Path<T>, label: string, options: {
|
|
912
973
|
label: string;
|
|
913
974
|
value: string | number;
|
|
914
|
-
}[]
|
|
915
|
-
placeholder?: string;
|
|
916
|
-
description?: string;
|
|
917
|
-
isDisabled?: boolean;
|
|
918
|
-
className?: string;
|
|
919
|
-
}): this;
|
|
975
|
+
}[]): this;
|
|
920
976
|
/**
|
|
921
977
|
* Add a checkbox field
|
|
922
978
|
*/
|
|
@@ -999,23 +1055,23 @@ declare function defineInferredForm<T extends FieldValues>(fieldDefinitions: (bu
|
|
|
999
1055
|
* Field type builders for individual field creation
|
|
1000
1056
|
*/
|
|
1001
1057
|
declare const field: {
|
|
1002
|
-
|
|
1058
|
+
checkbox: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["checkbox"]>[2]) => TypeInferredBuilder<T>;
|
|
1059
|
+
date: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["date"]>[2]) => TypeInferredBuilder<T>;
|
|
1003
1060
|
email: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["email"]>[2]) => TypeInferredBuilder<T>;
|
|
1061
|
+
file: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["file"]>[2]) => TypeInferredBuilder<T>;
|
|
1004
1062
|
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
1063
|
radio: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
1013
1064
|
label: string;
|
|
1014
1065
|
value: string | number;
|
|
1015
1066
|
}[], fieldOptions?: Parameters<TypeInferredBuilder<T>["radio"]>[3]) => TypeInferredBuilder<T>;
|
|
1067
|
+
select: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
1068
|
+
label: string;
|
|
1069
|
+
value: string | number;
|
|
1070
|
+
}[]) => TypeInferredBuilder<T>;
|
|
1016
1071
|
slider: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["slider"]>[2]) => TypeInferredBuilder<T>;
|
|
1017
|
-
|
|
1018
|
-
|
|
1072
|
+
switch: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["switch"]>[2]) => TypeInferredBuilder<T>;
|
|
1073
|
+
text: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["text"]>[2]) => TypeInferredBuilder<T>;
|
|
1074
|
+
textarea: <T extends FieldValues>(name: Path<T>, label: string, options?: Parameters<TypeInferredBuilder<T>["textarea"]>[2]) => TypeInferredBuilder<T>;
|
|
1019
1075
|
};
|
|
1020
1076
|
|
|
1021
1077
|
/**
|
|
@@ -1048,7 +1104,7 @@ declare class NestedPathBuilder<T extends FieldValues> {
|
|
|
1048
1104
|
* Add a field with template literal path
|
|
1049
1105
|
* Usage: builder.field`user.profile.name`("Full Name")
|
|
1050
1106
|
*/
|
|
1051
|
-
fieldTemplate(path: TemplateStringsArray
|
|
1107
|
+
fieldTemplate(path: TemplateStringsArray): FieldTemplateBuilder<T>;
|
|
1052
1108
|
/**
|
|
1053
1109
|
* Return to the parent builder (no-op for root builder)
|
|
1054
1110
|
*/
|
|
@@ -1089,12 +1145,12 @@ declare class SectionBuilder<T extends FieldValues, TPath extends Path<T>> {
|
|
|
1089
1145
|
/**
|
|
1090
1146
|
* Add multiple fields to the section
|
|
1091
1147
|
*/
|
|
1092
|
-
fields(fieldDefinitions:
|
|
1148
|
+
fields(fieldDefinitions: {
|
|
1093
1149
|
name: string;
|
|
1094
1150
|
label: string;
|
|
1095
1151
|
type?: string;
|
|
1096
1152
|
props?: any;
|
|
1097
|
-
}
|
|
1153
|
+
}[]): SectionBuilder<T, TPath>;
|
|
1098
1154
|
/**
|
|
1099
1155
|
* Nest deeper into the section
|
|
1100
1156
|
*/
|
|
@@ -1160,20 +1216,20 @@ interface ConditionalFieldProps<TFieldValues extends FieldValues> {
|
|
|
1160
1216
|
control: Control<TFieldValues>;
|
|
1161
1217
|
className?: string;
|
|
1162
1218
|
}
|
|
1163
|
-
declare function ConditionalField<TFieldValues extends FieldValues>({ config, control,
|
|
1219
|
+
declare function ConditionalField<TFieldValues extends FieldValues>({ className, config, control, }: ConditionalFieldProps<TFieldValues>): React$1.JSX.Element | null;
|
|
1164
1220
|
|
|
1165
1221
|
interface FieldArrayFieldProps<TFieldValues extends FieldValues> {
|
|
1166
1222
|
config: FieldArrayConfig<TFieldValues>;
|
|
1167
1223
|
className?: string;
|
|
1168
1224
|
}
|
|
1169
|
-
declare function FieldArrayField<TFieldValues extends FieldValues>({
|
|
1225
|
+
declare function FieldArrayField<TFieldValues extends FieldValues>({ className, config, }: FieldArrayFieldProps<TFieldValues>): React$1.JSX.Element | null;
|
|
1170
1226
|
|
|
1171
1227
|
interface DynamicSectionFieldProps<TFieldValues extends FieldValues> {
|
|
1172
1228
|
config: DynamicSectionConfig<TFieldValues>;
|
|
1173
1229
|
control: Control<TFieldValues>;
|
|
1174
1230
|
className?: string;
|
|
1175
1231
|
}
|
|
1176
|
-
declare function DynamicSectionField<TFieldValues extends FieldValues>({ config, control,
|
|
1232
|
+
declare function DynamicSectionField<TFieldValues extends FieldValues>({ className, config, control, }: DynamicSectionFieldProps<TFieldValues>): React$1.JSX.Element | null;
|
|
1177
1233
|
|
|
1178
1234
|
interface FormStatusProps<T extends Record<string, any>> {
|
|
1179
1235
|
state: EnhancedFormState<T>;
|
|
@@ -1181,14 +1237,14 @@ interface FormStatusProps<T extends Record<string, any>> {
|
|
|
1181
1237
|
className?: string;
|
|
1182
1238
|
showDetails?: boolean;
|
|
1183
1239
|
}
|
|
1184
|
-
declare function FormStatus<T extends Record<string, any>>({
|
|
1240
|
+
declare function FormStatus<T extends Record<string, any>>({ className, onDismiss, showDetails, state, }: FormStatusProps<T>): React$1.JSX.Element | null;
|
|
1185
1241
|
interface FormToastProps<T extends Record<string, any>> {
|
|
1186
1242
|
state: EnhancedFormState<T>;
|
|
1187
1243
|
onDismiss?: () => void;
|
|
1188
1244
|
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
1189
1245
|
duration?: number;
|
|
1190
1246
|
}
|
|
1191
|
-
declare function FormToast<T extends Record<string, any>>({
|
|
1247
|
+
declare function FormToast<T extends Record<string, any>>({ duration, onDismiss, position, state, }: FormToastProps<T>): React$1.JSX.Element | null;
|
|
1192
1248
|
|
|
1193
1249
|
/**
|
|
1194
1250
|
* Debounce function for field changes
|
|
@@ -1223,34 +1279,27 @@ declare function usePerformanceMonitor(componentName: string, enabled?: boolean)
|
|
|
1223
1279
|
declare function createOptimizedFieldHandler<T>(onChange: (value: T) => void, options?: {
|
|
1224
1280
|
debounce?: number;
|
|
1225
1281
|
throttle?: number;
|
|
1226
|
-
validate?: boolean;
|
|
1227
1282
|
}): (value: T) => void;
|
|
1228
1283
|
/**
|
|
1229
1284
|
* Memoized field props to prevent unnecessary re-renders
|
|
1230
1285
|
*/
|
|
1231
1286
|
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
1287
|
|
|
1239
1288
|
/**
|
|
1240
1289
|
* Common validation patterns for forms
|
|
1241
1290
|
*/
|
|
1242
1291
|
declare const validationPatterns: {
|
|
1292
|
+
creditCard: z.ZodString;
|
|
1293
|
+
date: z.ZodString;
|
|
1243
1294
|
email: z.ZodString;
|
|
1244
|
-
phoneUS: z.ZodString;
|
|
1245
|
-
phoneInternational: z.ZodString;
|
|
1246
|
-
url: z.ZodString;
|
|
1247
1295
|
password: z.ZodString;
|
|
1248
|
-
|
|
1249
|
-
|
|
1296
|
+
phoneInternational: z.ZodString;
|
|
1297
|
+
phoneUS: z.ZodString;
|
|
1250
1298
|
ssn: z.ZodString;
|
|
1251
|
-
|
|
1252
|
-
date: z.ZodString;
|
|
1299
|
+
strongPassword: z.ZodString;
|
|
1253
1300
|
time: z.ZodString;
|
|
1301
|
+
url: z.ZodString;
|
|
1302
|
+
zipCode: z.ZodString;
|
|
1254
1303
|
};
|
|
1255
1304
|
/**
|
|
1256
1305
|
* Async validation helpers
|
|
@@ -1269,17 +1318,17 @@ declare const asyncValidation: {
|
|
|
1269
1318
|
* Custom error messages
|
|
1270
1319
|
*/
|
|
1271
1320
|
declare const errorMessages: {
|
|
1272
|
-
|
|
1273
|
-
|
|
1321
|
+
date: () => string;
|
|
1322
|
+
email: () => string;
|
|
1323
|
+
max: (fieldName: string, max: number) => string;
|
|
1274
1324
|
maxLength: (fieldName: string, max: number) => string;
|
|
1275
1325
|
min: (fieldName: string, min: number) => string;
|
|
1276
|
-
|
|
1326
|
+
minLength: (fieldName: string, min: number) => string;
|
|
1277
1327
|
pattern: (fieldName: string) => string;
|
|
1278
|
-
email: () => string;
|
|
1279
|
-
url: () => string;
|
|
1280
1328
|
phone: () => string;
|
|
1281
|
-
|
|
1329
|
+
required: (fieldName: string) => string;
|
|
1282
1330
|
time: () => string;
|
|
1331
|
+
url: () => string;
|
|
1283
1332
|
};
|
|
1284
1333
|
/**
|
|
1285
1334
|
* Server-side validation integration
|
|
@@ -1301,14 +1350,7 @@ declare const validationUtils: {
|
|
|
1301
1350
|
/**
|
|
1302
1351
|
* Debounced validation
|
|
1303
1352
|
*/
|
|
1304
|
-
debounceValidation: (fn:
|
|
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
|
-
}>;
|
|
1353
|
+
debounceValidation: (fn: (...args: any[]) => void, delay?: number) => (...args: any[]) => void;
|
|
1312
1354
|
/**
|
|
1313
1355
|
* Get field error message
|
|
1314
1356
|
*/
|
|
@@ -1317,6 +1359,13 @@ declare const validationUtils: {
|
|
|
1317
1359
|
* Check if field has error
|
|
1318
1360
|
*/
|
|
1319
1361
|
hasFieldError: (errors: Record<string, string>, field: string) => boolean;
|
|
1362
|
+
/**
|
|
1363
|
+
* Validate form data against schema
|
|
1364
|
+
*/
|
|
1365
|
+
validateForm: (data: any, schema: z.ZodSchema) => Promise<{
|
|
1366
|
+
errors: Record<string, string>;
|
|
1367
|
+
success: boolean;
|
|
1368
|
+
}>;
|
|
1320
1369
|
};
|
|
1321
1370
|
|
|
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,
|
|
1371
|
+
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 };
|