@rachelallyson/hero-hook-form 2.6.0 → 2.7.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 +35 -0
- package/dist/index.d.ts +374 -25
- package/dist/index.js +313 -67
- package/dist/react/index.d.ts +374 -25
- package/dist/react/index.js +313 -67
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React$1, { ComponentProps } from 'react';
|
|
2
2
|
import { Input, Textarea, Select, Autocomplete, Checkbox, Switch, RadioGroup, Slider, DateInput, Button } from '@heroui/react';
|
|
3
3
|
import * as react_hook_form from 'react-hook-form';
|
|
4
|
-
import { FieldValues, Path, RegisterOptions, Control, UseFormReturn, FieldErrors, UseFormProps, SubmitHandler, UseFormSetError } from 'react-hook-form';
|
|
4
|
+
import { FieldValues, Path, RegisterOptions, Control, UseFormReturn, FieldErrors, UseFormProps, SubmitHandler, UseFormSetError, DefaultValues, ArrayPath, FieldArrayWithId } from 'react-hook-form';
|
|
5
5
|
export { UseFormReturn, useFormContext } from 'react-hook-form';
|
|
6
6
|
import * as zod from 'zod';
|
|
7
|
-
import { z } from 'zod';
|
|
7
|
+
import { z, ZodSchema } from 'zod';
|
|
8
8
|
import * as _internationalized_date from '@internationalized/date';
|
|
9
9
|
import { CalendarDate } from '@internationalized/date';
|
|
10
10
|
|
|
@@ -106,13 +106,74 @@ interface ConditionalFieldConfig<TFieldValues extends FieldValues> extends BaseF
|
|
|
106
106
|
condition: (formData: Partial<TFieldValues>) => boolean;
|
|
107
107
|
field: ZodFormFieldConfig<TFieldValues>;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Field array config for dynamic repeating field groups.
|
|
111
|
+
*
|
|
112
|
+
* @description
|
|
113
|
+
* Configuration for field arrays that support reordering, custom rendering,
|
|
114
|
+
* default values, and conditional fields within array items.
|
|
115
|
+
*
|
|
116
|
+
* @template TFieldValues - The form data type
|
|
117
|
+
*/
|
|
109
118
|
interface FieldArrayConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
110
119
|
type: "fieldArray";
|
|
120
|
+
/** Field configurations for each array item */
|
|
111
121
|
fields: ZodFormFieldConfig<TFieldValues>[];
|
|
122
|
+
/** Minimum number of items (default: 0) */
|
|
112
123
|
min?: number;
|
|
124
|
+
/** Maximum number of items (default: 10) */
|
|
113
125
|
max?: number;
|
|
126
|
+
/** Add button text (default: "Add Item") */
|
|
114
127
|
addButtonText?: string;
|
|
128
|
+
/** Remove button text (default: "Remove") */
|
|
115
129
|
removeButtonText?: string;
|
|
130
|
+
/** Enable reordering of array items with up/down buttons (default: false) */
|
|
131
|
+
enableReordering?: boolean;
|
|
132
|
+
/** Custom text for reorder buttons */
|
|
133
|
+
reorderButtonText?: {
|
|
134
|
+
/** Text for move up button (default: "↑") */
|
|
135
|
+
up?: string;
|
|
136
|
+
/** Text for move down button (default: "↓") */
|
|
137
|
+
down?: string;
|
|
138
|
+
};
|
|
139
|
+
/** Function to create default item when adding new array item */
|
|
140
|
+
defaultItem?: () => any;
|
|
141
|
+
/** Custom render function for array items */
|
|
142
|
+
renderItem?: (props: {
|
|
143
|
+
/** Item index (0-based) */
|
|
144
|
+
index: number;
|
|
145
|
+
/** Field array item with id */
|
|
146
|
+
field: {
|
|
147
|
+
id: string;
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
};
|
|
150
|
+
/** All fields in the array */
|
|
151
|
+
fields: {
|
|
152
|
+
id: string;
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
}[];
|
|
155
|
+
/** Rendered field elements */
|
|
156
|
+
children: React.ReactNode;
|
|
157
|
+
/** Remove this item */
|
|
158
|
+
onRemove: () => void;
|
|
159
|
+
/** Move item up */
|
|
160
|
+
onMoveUp: () => void;
|
|
161
|
+
/** Move item down */
|
|
162
|
+
onMoveDown: () => void;
|
|
163
|
+
/** Whether item can be removed */
|
|
164
|
+
canRemove: boolean;
|
|
165
|
+
/** Whether item can move up */
|
|
166
|
+
canMoveUp: boolean;
|
|
167
|
+
/** Whether item can move down */
|
|
168
|
+
canMoveDown: boolean;
|
|
169
|
+
}) => React.ReactNode;
|
|
170
|
+
/** Custom render function for add button */
|
|
171
|
+
renderAddButton?: (props: {
|
|
172
|
+
/** Add new item */
|
|
173
|
+
onAdd: () => void;
|
|
174
|
+
/** Whether new item can be added */
|
|
175
|
+
canAdd: boolean;
|
|
176
|
+
}) => React.ReactNode;
|
|
116
177
|
}
|
|
117
178
|
interface DynamicSectionConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
118
179
|
type: "dynamicSection";
|
|
@@ -2023,6 +2084,83 @@ interface ZodFormProps<T extends FieldValues> {
|
|
|
2023
2084
|
*/
|
|
2024
2085
|
declare function ZodForm<T extends FieldValues>({ className, columns, config, layout, onError, onSubmit, onSuccess, resetButtonText, showResetButton, spacing, submitButtonProps, submitButtonText, subtitle, title, }: ZodFormProps<T>): React$1.JSX.Element;
|
|
2025
2086
|
|
|
2087
|
+
/**
|
|
2088
|
+
* Props for the SimpleForm component.
|
|
2089
|
+
*
|
|
2090
|
+
* @template TFieldValues - The form data type
|
|
2091
|
+
*/
|
|
2092
|
+
interface SimpleFormProps<TFieldValues extends FieldValues> {
|
|
2093
|
+
/** Zod schema for validation */
|
|
2094
|
+
schema: ZodSchema<TFieldValues>;
|
|
2095
|
+
/** Single field configuration */
|
|
2096
|
+
field: ZodFormFieldConfig<TFieldValues>;
|
|
2097
|
+
/** Submit handler */
|
|
2098
|
+
onSubmit: (data: TFieldValues) => Promise<void> | void;
|
|
2099
|
+
/** Optional custom submit button */
|
|
2100
|
+
submitButton?: React$1.ReactNode;
|
|
2101
|
+
/** Optional form title */
|
|
2102
|
+
title?: string;
|
|
2103
|
+
/** Optional form subtitle */
|
|
2104
|
+
subtitle?: string;
|
|
2105
|
+
/** Optional className */
|
|
2106
|
+
className?: string;
|
|
2107
|
+
/** Optional default values */
|
|
2108
|
+
defaultValues?: DefaultValues<TFieldValues>;
|
|
2109
|
+
/** Optional error callback */
|
|
2110
|
+
onError?: (error: FormValidationError) => void;
|
|
2111
|
+
/** Optional success callback */
|
|
2112
|
+
onSuccess?: (data: TFieldValues) => void;
|
|
2113
|
+
/** Hide default submit button (use custom submitButton instead) */
|
|
2114
|
+
hideSubmitButton?: boolean;
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Simple form component for single-field forms.
|
|
2118
|
+
*
|
|
2119
|
+
* @description
|
|
2120
|
+
* A simplified API for forms with a single field. Provides the same validation
|
|
2121
|
+
* and error handling as ZodForm but with a simpler configuration.
|
|
2122
|
+
* Useful for simple inputs like search bars, message inputs, or single-field forms.
|
|
2123
|
+
*
|
|
2124
|
+
* @template TFieldValues - The form data type
|
|
2125
|
+
*
|
|
2126
|
+
* @param {SimpleFormProps<TFieldValues>} props - Component props
|
|
2127
|
+
* @returns {JSX.Element} The rendered form
|
|
2128
|
+
*
|
|
2129
|
+
* @example
|
|
2130
|
+
* ```tsx
|
|
2131
|
+
* import { SimpleForm, FormFieldHelpers } from "@rachelallyson/hero-hook-form";
|
|
2132
|
+
* import { z } from "zod";
|
|
2133
|
+
*
|
|
2134
|
+
* const messageSchema = z.object({
|
|
2135
|
+
* message: z.string().min(1, "Message cannot be empty"),
|
|
2136
|
+
* });
|
|
2137
|
+
*
|
|
2138
|
+
* function MessageInput() {
|
|
2139
|
+
* return (
|
|
2140
|
+
* <SimpleForm
|
|
2141
|
+
* schema={messageSchema}
|
|
2142
|
+
* field={FormFieldHelpers.input("message", "", {
|
|
2143
|
+
* placeholder: "Add a note...",
|
|
2144
|
+
* endContent: (
|
|
2145
|
+
* <Button type="submit" isIconOnly>
|
|
2146
|
+
* <SendIcon />
|
|
2147
|
+
* </Button>
|
|
2148
|
+
* ),
|
|
2149
|
+
* })}
|
|
2150
|
+
* onSubmit={async (data) => {
|
|
2151
|
+
* await sendMessage(data.message);
|
|
2152
|
+
* }}
|
|
2153
|
+
* hideSubmitButton
|
|
2154
|
+
* />
|
|
2155
|
+
* );
|
|
2156
|
+
* }
|
|
2157
|
+
* ```
|
|
2158
|
+
*
|
|
2159
|
+
* @see {@link ZodForm} for multi-field forms
|
|
2160
|
+
* @category Components
|
|
2161
|
+
*/
|
|
2162
|
+
declare function SimpleForm<TFieldValues extends FieldValues>({ className, defaultValues, field, hideSubmitButton, onError, onSubmit, onSuccess, schema, submitButton, subtitle, title, }: SimpleFormProps<TFieldValues>): React$1.JSX.Element;
|
|
2163
|
+
|
|
2026
2164
|
/**
|
|
2027
2165
|
* Hook for using Zod validation with React Hook Form
|
|
2028
2166
|
*/
|
|
@@ -3153,6 +3291,7 @@ interface FieldArrayFieldProps<TFieldValues extends FieldValues> {
|
|
|
3153
3291
|
* Allows users to add and remove multiple instances of a field group.
|
|
3154
3292
|
* Useful for forms with repeating data like addresses, items, or contacts.
|
|
3155
3293
|
* Automatically manages field array state and provides add/remove buttons.
|
|
3294
|
+
* Supports reordering, custom item rendering, default values, and conditional fields within items.
|
|
3156
3295
|
*
|
|
3157
3296
|
* @template TFieldValues - The form data type
|
|
3158
3297
|
*
|
|
@@ -3163,42 +3302,101 @@ interface FieldArrayFieldProps<TFieldValues extends FieldValues> {
|
|
|
3163
3302
|
* @returns {JSX.Element} The rendered field array with add/remove controls
|
|
3164
3303
|
*
|
|
3165
3304
|
* @example
|
|
3305
|
+
* Basic usage:
|
|
3166
3306
|
* ```tsx
|
|
3167
3307
|
* import { FieldArrayField, FormFieldHelpers } from "@rachelallyson/hero-hook-form";
|
|
3168
3308
|
*
|
|
3169
3309
|
* const fields = [
|
|
3170
3310
|
* FormFieldHelpers.input("name", "Name"),
|
|
3171
|
-
*
|
|
3172
|
-
*
|
|
3173
|
-
*
|
|
3174
|
-
*
|
|
3175
|
-
*
|
|
3176
|
-
*
|
|
3177
|
-
*
|
|
3178
|
-
*
|
|
3179
|
-
*
|
|
3180
|
-
*
|
|
3181
|
-
*
|
|
3182
|
-
*
|
|
3183
|
-
*
|
|
3184
|
-
*
|
|
3185
|
-
* }),
|
|
3311
|
+
* {
|
|
3312
|
+
* type: "fieldArray",
|
|
3313
|
+
* name: "addresses",
|
|
3314
|
+
* label: "Address",
|
|
3315
|
+
* fields: [
|
|
3316
|
+
* FormFieldHelpers.input("street", "Street Address"),
|
|
3317
|
+
* FormFieldHelpers.input("city", "City"),
|
|
3318
|
+
* FormFieldHelpers.input("zipCode", "ZIP Code"),
|
|
3319
|
+
* ],
|
|
3320
|
+
* min: 1,
|
|
3321
|
+
* max: 5,
|
|
3322
|
+
* addButtonText: "Add Address",
|
|
3323
|
+
* removeButtonText: "Remove Address",
|
|
3324
|
+
* },
|
|
3186
3325
|
* ];
|
|
3187
3326
|
* ```
|
|
3188
3327
|
*
|
|
3189
3328
|
* @example
|
|
3190
|
-
* With
|
|
3329
|
+
* With reordering:
|
|
3191
3330
|
* ```tsx
|
|
3192
|
-
*
|
|
3193
|
-
*
|
|
3194
|
-
*
|
|
3195
|
-
*
|
|
3196
|
-
*
|
|
3197
|
-
* }
|
|
3331
|
+
* {
|
|
3332
|
+
* type: "fieldArray",
|
|
3333
|
+
* name: "slots",
|
|
3334
|
+
* label: "Question Slots",
|
|
3335
|
+
* enableReordering: true,
|
|
3336
|
+
* reorderButtonText: { up: "↑", down: "↓" },
|
|
3337
|
+
* fields: [
|
|
3338
|
+
* FormFieldHelpers.select("slotType", "Slot Type", options),
|
|
3339
|
+
* ],
|
|
3340
|
+
* }
|
|
3341
|
+
* ```
|
|
3342
|
+
*
|
|
3343
|
+
* @example
|
|
3344
|
+
* With custom item rendering:
|
|
3345
|
+
* ```tsx
|
|
3346
|
+
* {
|
|
3347
|
+
* type: "fieldArray",
|
|
3348
|
+
* name: "items",
|
|
3349
|
+
* renderItem: ({ index, children, onMoveUp, onMoveDown, onRemove }) => (
|
|
3350
|
+
* <Card className="p-4">
|
|
3351
|
+
* <div className="flex justify-between">
|
|
3352
|
+
* <span>Item {index + 1}</span>
|
|
3353
|
+
* <Button onPress={onRemove}>Remove</Button>
|
|
3354
|
+
* </div>
|
|
3355
|
+
* {children}
|
|
3356
|
+
* </Card>
|
|
3357
|
+
* ),
|
|
3358
|
+
* fields: [...],
|
|
3359
|
+
* }
|
|
3360
|
+
* ```
|
|
3361
|
+
*
|
|
3362
|
+
* @example
|
|
3363
|
+
* With default item:
|
|
3364
|
+
* ```tsx
|
|
3365
|
+
* {
|
|
3366
|
+
* type: "fieldArray",
|
|
3367
|
+
* name: "slots",
|
|
3368
|
+
* defaultItem: () => ({
|
|
3369
|
+
* order: 0,
|
|
3370
|
+
* slotType: "STATIC",
|
|
3371
|
+
* staticQuestionId: "",
|
|
3372
|
+
* }),
|
|
3373
|
+
* fields: [...],
|
|
3374
|
+
* }
|
|
3375
|
+
* ```
|
|
3376
|
+
*
|
|
3377
|
+
* @example
|
|
3378
|
+
* With conditional fields within items:
|
|
3379
|
+
* ```tsx
|
|
3380
|
+
* {
|
|
3381
|
+
* type: "fieldArray",
|
|
3382
|
+
* name: "slots",
|
|
3383
|
+
* fields: [
|
|
3384
|
+
* FormFieldHelpers.select("slotType", "Slot Type", [
|
|
3385
|
+
* { label: "Static", value: "STATIC" },
|
|
3386
|
+
* { label: "Dynamic", value: "DYNAMIC" },
|
|
3387
|
+
* ]),
|
|
3388
|
+
* {
|
|
3389
|
+
* ...FormFieldHelpers.select("staticQuestionId", "Question", questions),
|
|
3390
|
+
* dependsOn: "slotType",
|
|
3391
|
+
* dependsOnValue: "STATIC",
|
|
3392
|
+
* },
|
|
3393
|
+
* ],
|
|
3394
|
+
* }
|
|
3198
3395
|
* ```
|
|
3199
3396
|
*
|
|
3200
3397
|
* @see {@link ConditionalField} for conditional single fields
|
|
3201
3398
|
* @see {@link DynamicSectionField} for conditional field groups
|
|
3399
|
+
* @see {@link createFieldArrayCustomConfig} for advanced custom rendering
|
|
3202
3400
|
* @category Fields
|
|
3203
3401
|
*/
|
|
3204
3402
|
declare function FieldArrayField<TFieldValues extends FieldValues>({ className, config, }: FieldArrayFieldProps<TFieldValues>): React$1.JSX.Element | null;
|
|
@@ -3342,6 +3540,157 @@ declare function createOptimizedFieldHandler<T>(onChange: (value: T) => void, op
|
|
|
3342
3540
|
*/
|
|
3343
3541
|
declare function useMemoizedFieldProps<T extends Record<string, any>>(props: T, deps: React.DependencyList): T;
|
|
3344
3542
|
|
|
3543
|
+
/**
|
|
3544
|
+
* Options for syncing arrays
|
|
3545
|
+
*
|
|
3546
|
+
* @template TItem - The item type in the arrays
|
|
3547
|
+
*/
|
|
3548
|
+
interface ArraySyncOptions<TItem> {
|
|
3549
|
+
/** Existing items (from database/API) */
|
|
3550
|
+
existing: TItem[];
|
|
3551
|
+
/** Current items (from form) */
|
|
3552
|
+
current: TItem[];
|
|
3553
|
+
/** Function to extract ID from an item */
|
|
3554
|
+
getId: (item: TItem) => string | number | undefined;
|
|
3555
|
+
}
|
|
3556
|
+
/**
|
|
3557
|
+
* Result of array sync operation
|
|
3558
|
+
*
|
|
3559
|
+
* @template TItem - The item type in the arrays
|
|
3560
|
+
*/
|
|
3561
|
+
interface ArraySyncResult<TItem> {
|
|
3562
|
+
/** Items that should be deleted (exist in existing but not in current) */
|
|
3563
|
+
toDelete: TItem[];
|
|
3564
|
+
/** Items that should be updated (exist in both, may have changed) */
|
|
3565
|
+
toUpdate: {
|
|
3566
|
+
existing: TItem;
|
|
3567
|
+
current: TItem;
|
|
3568
|
+
}[];
|
|
3569
|
+
/** Items that should be created (exist in current but not in existing) */
|
|
3570
|
+
toCreate: TItem[];
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* Sync arrays to determine what items to delete, update, and create.
|
|
3574
|
+
*
|
|
3575
|
+
* @description
|
|
3576
|
+
* Compares existing items (from database) with current items (from form)
|
|
3577
|
+
* to determine which items need to be deleted, updated, or created.
|
|
3578
|
+
* Useful for edit forms where you need to sync array changes.
|
|
3579
|
+
*
|
|
3580
|
+
* @template TItem - The item type in the arrays
|
|
3581
|
+
*
|
|
3582
|
+
* @param {ArraySyncOptions<TItem>} options - Sync options
|
|
3583
|
+
* @returns {ArraySyncResult<TItem>} Result with items to delete, update, and create
|
|
3584
|
+
*
|
|
3585
|
+
* @example
|
|
3586
|
+
* ```tsx
|
|
3587
|
+
* const { toDelete, toUpdate, toCreate } = syncArrays({
|
|
3588
|
+
* existing: slots,
|
|
3589
|
+
* current: data.slots,
|
|
3590
|
+
* getId: (slot) => slot.id,
|
|
3591
|
+
* });
|
|
3592
|
+
*
|
|
3593
|
+
* // Delete removed slots
|
|
3594
|
+
* await Promise.all(toDelete.map(slot => deleteSlot(slot.id)));
|
|
3595
|
+
*
|
|
3596
|
+
* // Update existing slots
|
|
3597
|
+
* await Promise.all(
|
|
3598
|
+
* toUpdate.map(({ existing, current }) =>
|
|
3599
|
+
* updateSlot(existing.id, current)
|
|
3600
|
+
* )
|
|
3601
|
+
* );
|
|
3602
|
+
*
|
|
3603
|
+
* // Create new slots
|
|
3604
|
+
* await Promise.all(toCreate.map(slot => createSlot(slot)));
|
|
3605
|
+
* ```
|
|
3606
|
+
*
|
|
3607
|
+
* @category Utilities
|
|
3608
|
+
*/
|
|
3609
|
+
declare function syncArrays<TItem>(options: ArraySyncOptions<TItem>): ArraySyncResult<TItem>;
|
|
3610
|
+
|
|
3611
|
+
/**
|
|
3612
|
+
* Options for creating a custom field array config
|
|
3613
|
+
*
|
|
3614
|
+
* @template TFieldValues - The form data type
|
|
3615
|
+
*/
|
|
3616
|
+
interface CreateFieldArrayCustomConfigOptions<TFieldValues extends FieldValues> {
|
|
3617
|
+
/** Field array name */
|
|
3618
|
+
name: ArrayPath<TFieldValues>;
|
|
3619
|
+
/** Optional label for the field array */
|
|
3620
|
+
label?: string;
|
|
3621
|
+
/** Render function for each array item */
|
|
3622
|
+
renderItem: (props: {
|
|
3623
|
+
index: number;
|
|
3624
|
+
field: FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>>;
|
|
3625
|
+
fields: FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>>[];
|
|
3626
|
+
form: UseFormReturn<TFieldValues>;
|
|
3627
|
+
control: Control<TFieldValues>;
|
|
3628
|
+
errors: FieldErrors<TFieldValues>;
|
|
3629
|
+
canMoveUp: boolean;
|
|
3630
|
+
canMoveDown: boolean;
|
|
3631
|
+
onMoveUp: () => void;
|
|
3632
|
+
onMoveDown: () => void;
|
|
3633
|
+
onRemove: () => void;
|
|
3634
|
+
}) => React$1.ReactNode;
|
|
3635
|
+
/** Optional render function for add button */
|
|
3636
|
+
renderAddButton?: (props: {
|
|
3637
|
+
onAdd: () => void;
|
|
3638
|
+
canAdd: boolean;
|
|
3639
|
+
}) => React$1.ReactNode;
|
|
3640
|
+
/** Function to create default item when adding new array item */
|
|
3641
|
+
defaultItem?: () => any;
|
|
3642
|
+
/** Minimum number of items */
|
|
3643
|
+
min?: number;
|
|
3644
|
+
/** Maximum number of items */
|
|
3645
|
+
max?: number;
|
|
3646
|
+
/** Enable reordering of array items */
|
|
3647
|
+
enableReordering?: boolean;
|
|
3648
|
+
/** Optional className */
|
|
3649
|
+
className?: string;
|
|
3650
|
+
}
|
|
3651
|
+
/**
|
|
3652
|
+
* Create a CustomFieldConfig for field arrays with full control over rendering.
|
|
3653
|
+
*
|
|
3654
|
+
* @description
|
|
3655
|
+
* This helper creates a CustomFieldConfig that uses useFieldArray internally,
|
|
3656
|
+
* giving you full control over the UI while still being integrated with the form.
|
|
3657
|
+
* Useful when you need custom layouts, reordering, or complex item rendering
|
|
3658
|
+
* that FieldArrayConfig doesn't support.
|
|
3659
|
+
*
|
|
3660
|
+
* @template TFieldValues - The form data type
|
|
3661
|
+
*
|
|
3662
|
+
* @param {CreateFieldArrayCustomConfigOptions<TFieldValues>} options - Configuration options
|
|
3663
|
+
* @returns {CustomFieldConfig<TFieldValues>} Custom field config for field arrays
|
|
3664
|
+
*
|
|
3665
|
+
* @example
|
|
3666
|
+
* ```tsx
|
|
3667
|
+
* const slotsConfig = createFieldArrayCustomConfig("slots", {
|
|
3668
|
+
* label: "Question Slots",
|
|
3669
|
+
* enableReordering: true,
|
|
3670
|
+
* renderItem: ({ index, field, form, control, onMoveUp, onMoveDown, onRemove }) => (
|
|
3671
|
+
* <div className="border rounded-lg p-4">
|
|
3672
|
+
* <div className="flex justify-between">
|
|
3673
|
+
* <span>Slot {index + 1}</span>
|
|
3674
|
+
* <div className="flex gap-2">
|
|
3675
|
+
* <Button onPress={onMoveUp}>↑</Button>
|
|
3676
|
+
* <Button onPress={onMoveDown}>↓</Button>
|
|
3677
|
+
* <Button onPress={onRemove}>Remove</Button>
|
|
3678
|
+
* </div>
|
|
3679
|
+
* </div>
|
|
3680
|
+
* <SelectField
|
|
3681
|
+
* name={`slots.${index}.slotType`}
|
|
3682
|
+
* control={control}
|
|
3683
|
+
* // ...
|
|
3684
|
+
* />
|
|
3685
|
+
* </div>
|
|
3686
|
+
* ),
|
|
3687
|
+
* });
|
|
3688
|
+
* ```
|
|
3689
|
+
*
|
|
3690
|
+
* @category Utilities
|
|
3691
|
+
*/
|
|
3692
|
+
declare function createFieldArrayCustomConfig<TFieldValues extends FieldValues>(options: CreateFieldArrayCustomConfigOptions<TFieldValues>): CustomFieldConfig<TFieldValues>;
|
|
3693
|
+
|
|
3345
3694
|
/**
|
|
3346
3695
|
* Common validation patterns for forms
|
|
3347
3696
|
*/
|
|
@@ -3425,4 +3774,4 @@ declare const validationUtils: {
|
|
|
3425
3774
|
}>;
|
|
3426
3775
|
};
|
|
3427
3776
|
|
|
3428
|
-
export { AdvancedFieldBuilder, AutocompleteField, type AutocompleteFieldProps, type AutocompleteOption, type BaseFormFieldConfig, BasicFormBuilder, type BooleanFieldConfig, type ButtonDefaults, type CheckboxDefaults, CheckboxField, type CheckboxFieldProps, type CommonFieldDefaults, CommonFields, ConditionalField, type ConditionalFieldConfig, type ConditionalFieldProps, type ConditionalValidation, ConfigurableForm, ContentField, type ContentFieldConfig, 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 };
|
|
3777
|
+
export { AdvancedFieldBuilder, type ArraySyncOptions, type ArraySyncResult, AutocompleteField, type AutocompleteFieldProps, type AutocompleteOption, type BaseFormFieldConfig, BasicFormBuilder, type BooleanFieldConfig, type ButtonDefaults, type CheckboxDefaults, CheckboxField, type CheckboxFieldProps, type CommonFieldDefaults, CommonFields, ConditionalField, type ConditionalFieldConfig, type ConditionalFieldProps, type ConditionalValidation, ConfigurableForm, ContentField, type ContentFieldConfig, type CreateFieldArrayCustomConfigOptions, 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, SimpleForm, type SimpleFormProps, 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, createFieldArrayCustomConfig, 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, syncArrays, throttle, useDebouncedFieldValidation, useDebouncedValidation, useEnhancedFormState, useFormHelper, useHeroForm, useHeroHookFormDefaults, useInferredForm, useMemoizedCallback, useMemoizedFieldProps, usePerformanceMonitor, useTypeInferredForm, useZodForm, validationPatterns, validationUtils, waitForFormState };
|