@rachelallyson/hero-hook-form 2.5.1 → 2.6.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 +41 -0
- package/dist/index.d.ts +210 -13
- package/dist/index.js +240 -25
- package/dist/react/index.d.ts +209 -12
- package/dist/react/index.js +240 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.6.0] - 2026-01-13
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Complete Prop Support for All FormFieldHelpers**: All field helpers now accept full component props for complete customization
|
|
10
|
+
- `input()` - Added `inputProps` parameter for full Input component customization
|
|
11
|
+
- `textarea()` - Added `textareaProps` parameter (placeholder still works as shorthand)
|
|
12
|
+
- `select()` - Added `selectProps` parameter
|
|
13
|
+
- `checkbox()` - Added `checkboxProps` parameter
|
|
14
|
+
- `switch()` - Added `switchProps` parameter (description still works as shorthand)
|
|
15
|
+
- `autocomplete()` - Added `autocompleteProps` parameter (placeholder still works as shorthand)
|
|
16
|
+
- `date()` - Improved with proper `DateInput` component typing
|
|
17
|
+
- `slider()` - Improved with proper `Slider` component typing
|
|
18
|
+
- `file()` - Improved with proper `Input` component typing for file inputs
|
|
19
|
+
- `fontPicker()` - Added helper with proper `FontPickerProps` interface typing
|
|
20
|
+
|
|
21
|
+
- **New Field Helpers**: Added missing helpers for complete coverage
|
|
22
|
+
- `radio()` - Radio group field helper with `radioProps` support
|
|
23
|
+
- `slider()` - Slider field helper with `sliderProps` support
|
|
24
|
+
- `file()` - File upload field helper with `fileProps` support
|
|
25
|
+
- `fontPicker()` - Font picker field helper with `fontPickerProps` support
|
|
26
|
+
|
|
27
|
+
### Enhanced
|
|
28
|
+
|
|
29
|
+
- **Improved Type Safety**: Replaced all `Record<string, string | number | boolean>` types with proper component types
|
|
30
|
+
- All helpers now use `Omit<ComponentProps<typeof Component>, ...>` for full type safety
|
|
31
|
+
- Removed all type assertions (`as Record`) - now using proper component types
|
|
32
|
+
- Full IntelliSense support for all component props
|
|
33
|
+
- Type-safe exclusions for form-managed props (value, onChange, label, etc.)
|
|
34
|
+
|
|
35
|
+
- **Consistent API Pattern**: All helpers now follow the same pattern
|
|
36
|
+
- Simple API for basic cases: `FormFieldHelpers.input("email", "Email", "email")`
|
|
37
|
+
- Full customization when needed: `FormFieldHelpers.input("email", "Email", "email", { classNames: {...}, startContent: <Icon /> })`
|
|
38
|
+
- Backward compatible - all existing code continues to work
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- **AdvancedFormBuilder**: Updated to use correct prop names (`maxValue`/`minValue` instead of `max`/`min` for Slider)
|
|
43
|
+
- **TypeInferredBuilder**: Updated slider props to use correct prop names
|
|
44
|
+
- **FontPicker Types**: Improved type safety with proper `FontPickerProps` interface instead of `Record`
|
|
45
|
+
|
|
5
46
|
## [2.5.1] - 2026-01-13
|
|
6
47
|
|
|
7
48
|
### Fixed
|
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ import * as _internationalized_date from '@internationalized/date';
|
|
|
9
9
|
import { CalendarDate } from '@internationalized/date';
|
|
10
10
|
import { Autocomplete } from '@heroui/autocomplete';
|
|
11
11
|
import { Checkbox } from '@heroui/checkbox';
|
|
12
|
+
import { DateInput } from '@heroui/date-input';
|
|
12
13
|
import { Input, Textarea } from '@heroui/input';
|
|
13
14
|
import { RadioGroup } from '@heroui/radio';
|
|
14
15
|
import { Select } from '@heroui/select';
|
|
16
|
+
import { Slider } from '@heroui/slider';
|
|
15
17
|
import { Switch } from '@heroui/switch';
|
|
16
18
|
import { Button as Button$1 } from '@heroui/button';
|
|
17
|
-
import { DateInput } from '@heroui/date-input';
|
|
18
|
-
import { Slider } from '@heroui/slider';
|
|
19
19
|
|
|
20
20
|
interface FieldBaseProps<TFieldValues extends FieldValues, TValue> {
|
|
21
21
|
name: Path<TFieldValues>;
|
|
@@ -76,24 +76,29 @@ interface RadioFieldConfig<TFieldValues extends FieldValues> extends BaseFormFie
|
|
|
76
76
|
interface SliderFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
77
77
|
type: "slider";
|
|
78
78
|
defaultValue?: number;
|
|
79
|
-
sliderProps?:
|
|
79
|
+
sliderProps?: Omit<ComponentProps<typeof Slider>, "value" | "onChange" | "label" | "isDisabled">;
|
|
80
80
|
}
|
|
81
81
|
interface DateFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
82
82
|
type: "date";
|
|
83
83
|
defaultValue?: _internationalized_date.CalendarDate | null;
|
|
84
|
-
dateProps?:
|
|
84
|
+
dateProps?: Omit<ComponentProps<typeof DateInput>, "value" | "onChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">;
|
|
85
85
|
}
|
|
86
86
|
interface FileFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
87
87
|
type: "file";
|
|
88
88
|
defaultValue?: FileList | null;
|
|
89
|
-
fileProps?:
|
|
89
|
+
fileProps?: Omit<ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "type">;
|
|
90
90
|
multiple?: boolean;
|
|
91
91
|
accept?: string;
|
|
92
92
|
}
|
|
93
93
|
interface FontPickerFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
94
94
|
type: "fontPicker";
|
|
95
95
|
defaultValue?: string;
|
|
96
|
-
fontPickerProps?:
|
|
96
|
+
fontPickerProps?: {
|
|
97
|
+
showFontPreview?: boolean;
|
|
98
|
+
loadAllVariants?: boolean;
|
|
99
|
+
onFontsLoaded?: (loaded: boolean) => void;
|
|
100
|
+
fontsLoadedTimeout?: number;
|
|
101
|
+
};
|
|
97
102
|
}
|
|
98
103
|
interface CustomFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
99
104
|
type: "custom";
|
|
@@ -2187,15 +2192,42 @@ declare function createBasicFormBuilder<T extends FieldValues>(): BasicFormBuild
|
|
|
2187
2192
|
declare const FormFieldHelpers: {
|
|
2188
2193
|
/**
|
|
2189
2194
|
* Create an autocomplete field
|
|
2195
|
+
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* ```tsx
|
|
2198
|
+
* // Simple autocomplete
|
|
2199
|
+
* FormFieldHelpers.autocomplete("country", "Country", options)
|
|
2200
|
+
*
|
|
2201
|
+
* // With placeholder
|
|
2202
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries")
|
|
2203
|
+
*
|
|
2204
|
+
* // With full customization
|
|
2205
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries", {
|
|
2206
|
+
* classNames: { base: "custom-autocomplete" },
|
|
2207
|
+
* allowsCustomValue: true
|
|
2208
|
+
* })
|
|
2209
|
+
* ```
|
|
2190
2210
|
*/
|
|
2191
2211
|
autocomplete: <T extends FieldValues>(name: Path<T>, label: string, items: {
|
|
2192
2212
|
label: string;
|
|
2193
2213
|
value: string | number;
|
|
2194
|
-
}[], placeholder?: string) => ZodFormFieldConfig<T>;
|
|
2214
|
+
}[], placeholder?: string, autocompleteProps?: Omit<React$1.ComponentProps<typeof Autocomplete>, "selectedKey" | "onSelectionChange" | "inputValue" | "onInputChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "children" | "items">) => ZodFormFieldConfig<T>;
|
|
2195
2215
|
/**
|
|
2196
2216
|
* Create a checkbox field
|
|
2217
|
+
*
|
|
2218
|
+
* @example
|
|
2219
|
+
* ```tsx
|
|
2220
|
+
* // Simple checkbox
|
|
2221
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter")
|
|
2222
|
+
*
|
|
2223
|
+
* // With full customization
|
|
2224
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter", {
|
|
2225
|
+
* classNames: { base: "custom-checkbox" },
|
|
2226
|
+
* size: "lg"
|
|
2227
|
+
* })
|
|
2228
|
+
* ```
|
|
2197
2229
|
*/
|
|
2198
|
-
checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
|
|
2230
|
+
checkbox: <T extends FieldValues>(name: Path<T>, label: string, checkboxProps?: Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2199
2231
|
/**
|
|
2200
2232
|
* Create a conditional field that shows/hides based on form data
|
|
2201
2233
|
*
|
|
@@ -2245,27 +2277,192 @@ declare const FormFieldHelpers: {
|
|
|
2245
2277
|
}) => ZodFormFieldConfig<T>;
|
|
2246
2278
|
/**
|
|
2247
2279
|
* Create a date field
|
|
2280
|
+
*
|
|
2281
|
+
* @example
|
|
2282
|
+
* ```tsx
|
|
2283
|
+
* // Simple date field
|
|
2284
|
+
* FormFieldHelpers.date("birthDate", "Birth Date")
|
|
2285
|
+
*
|
|
2286
|
+
* // With full customization
|
|
2287
|
+
* FormFieldHelpers.date("birthDate", "Birth Date", {
|
|
2288
|
+
* label: "Select your birth date",
|
|
2289
|
+
* granularity: "day",
|
|
2290
|
+
* minValue: new CalendarDate(1900, 1, 1)
|
|
2291
|
+
* })
|
|
2292
|
+
* ```
|
|
2293
|
+
*/
|
|
2294
|
+
date: <T extends FieldValues>(name: Path<T>, label: string, dateProps?: Omit<React$1.ComponentProps<typeof DateInput>, "value" | "onChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2295
|
+
/**
|
|
2296
|
+
* Create a file upload field
|
|
2297
|
+
*
|
|
2298
|
+
* @example
|
|
2299
|
+
* ```tsx
|
|
2300
|
+
* // Simple file field
|
|
2301
|
+
* FormFieldHelpers.file("avatar", "Profile Picture")
|
|
2302
|
+
*
|
|
2303
|
+
* // With accept and multiple
|
|
2304
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2305
|
+
* accept: "image/*",
|
|
2306
|
+
* multiple: true
|
|
2307
|
+
* })
|
|
2308
|
+
*
|
|
2309
|
+
* // With full customization
|
|
2310
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2311
|
+
* accept: "image/*",
|
|
2312
|
+
* multiple: false,
|
|
2313
|
+
* fileProps: { className: "custom-file-input" }
|
|
2314
|
+
* })
|
|
2315
|
+
* ```
|
|
2248
2316
|
*/
|
|
2249
|
-
|
|
2317
|
+
file: <T extends FieldValues>(name: Path<T>, label: string, options?: {
|
|
2318
|
+
accept?: string;
|
|
2319
|
+
fileProps?: Omit<React$1.ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "type">;
|
|
2320
|
+
multiple?: boolean;
|
|
2321
|
+
}) => ZodFormFieldConfig<T>;
|
|
2322
|
+
/**
|
|
2323
|
+
* Create a font picker field
|
|
2324
|
+
*
|
|
2325
|
+
* @example
|
|
2326
|
+
* ```tsx
|
|
2327
|
+
* // Simple font picker
|
|
2328
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font")
|
|
2329
|
+
*
|
|
2330
|
+
* // With full customization
|
|
2331
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font", {
|
|
2332
|
+
* showFontPreview: true,
|
|
2333
|
+
* loadAllVariants: false,
|
|
2334
|
+
* fontsLoadedTimeout: 5000
|
|
2335
|
+
* })
|
|
2336
|
+
* ```
|
|
2337
|
+
*/
|
|
2338
|
+
fontPicker: <T extends FieldValues>(name: Path<T>, label: string, fontPickerProps?: {
|
|
2339
|
+
showFontPreview?: boolean;
|
|
2340
|
+
loadAllVariants?: boolean;
|
|
2341
|
+
onFontsLoaded?: (loaded: boolean) => void;
|
|
2342
|
+
fontsLoadedTimeout?: number;
|
|
2343
|
+
}) => ZodFormFieldConfig<T>;
|
|
2250
2344
|
/**
|
|
2251
2345
|
* Create an input field
|
|
2346
|
+
*
|
|
2347
|
+
* @example
|
|
2348
|
+
* ```tsx
|
|
2349
|
+
* // Simple input
|
|
2350
|
+
* FormFieldHelpers.input("name", "Name")
|
|
2351
|
+
*
|
|
2352
|
+
* // With type
|
|
2353
|
+
* FormFieldHelpers.input("email", "Email", "email")
|
|
2354
|
+
*
|
|
2355
|
+
* // With full customization
|
|
2356
|
+
* FormFieldHelpers.input("email", "Email", "email", {
|
|
2357
|
+
* placeholder: "Enter your email",
|
|
2358
|
+
* classNames: { input: "custom-input" },
|
|
2359
|
+
* startContent: <MailIcon />,
|
|
2360
|
+
* description: "We'll never share your email"
|
|
2361
|
+
* })
|
|
2362
|
+
* ```
|
|
2252
2363
|
*/
|
|
2253
|
-
input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password") => ZodFormFieldConfig<T>;
|
|
2364
|
+
input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password", inputProps?: Omit<React$1.ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2365
|
+
/**
|
|
2366
|
+
* Create a radio group field
|
|
2367
|
+
*
|
|
2368
|
+
* @example
|
|
2369
|
+
* ```tsx
|
|
2370
|
+
* // Simple radio group
|
|
2371
|
+
* FormFieldHelpers.radio("gender", "Gender", [
|
|
2372
|
+
* { label: "Male", value: "male" },
|
|
2373
|
+
* { label: "Female", value: "female" }
|
|
2374
|
+
* ])
|
|
2375
|
+
*
|
|
2376
|
+
* // With full customization
|
|
2377
|
+
* FormFieldHelpers.radio("gender", "Gender", options, {
|
|
2378
|
+
* orientation: "horizontal",
|
|
2379
|
+
* classNames: { base: "custom-radio" }
|
|
2380
|
+
* })
|
|
2381
|
+
* ```
|
|
2382
|
+
*/
|
|
2383
|
+
radio: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
2384
|
+
label: string;
|
|
2385
|
+
value: string | number;
|
|
2386
|
+
}[], radioProps?: Omit<React$1.ComponentProps<typeof RadioGroup>, "value" | "onValueChange" | "label">) => ZodFormFieldConfig<T>;
|
|
2254
2387
|
/**
|
|
2255
2388
|
* Create a select field
|
|
2389
|
+
*
|
|
2390
|
+
* @example
|
|
2391
|
+
* ```tsx
|
|
2392
|
+
* // Simple select
|
|
2393
|
+
* FormFieldHelpers.select("country", "Country", options)
|
|
2394
|
+
*
|
|
2395
|
+
* // With full customization
|
|
2396
|
+
* FormFieldHelpers.select("country", "Country", options, {
|
|
2397
|
+
* placeholder: "Select a country",
|
|
2398
|
+
* classNames: { trigger: "custom-select" },
|
|
2399
|
+
* selectionMode: "multiple"
|
|
2400
|
+
* })
|
|
2401
|
+
* ```
|
|
2256
2402
|
*/
|
|
2257
2403
|
select: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
2258
2404
|
label: string;
|
|
2259
2405
|
value: string | number;
|
|
2260
|
-
}[]) => ZodFormFieldConfig<T>;
|
|
2406
|
+
}[], selectProps?: Omit<React$1.ComponentProps<typeof Select>, "selectedKeys" | "onSelectionChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2407
|
+
/**
|
|
2408
|
+
* Create a slider field
|
|
2409
|
+
*
|
|
2410
|
+
* @example
|
|
2411
|
+
* ```tsx
|
|
2412
|
+
* // Simple slider
|
|
2413
|
+
* FormFieldHelpers.slider("rating", "Rating")
|
|
2414
|
+
*
|
|
2415
|
+
* // With full customization
|
|
2416
|
+
* FormFieldHelpers.slider("rating", "Rating", {
|
|
2417
|
+
* minValue: 1,
|
|
2418
|
+
* maxValue: 5,
|
|
2419
|
+
* step: 1,
|
|
2420
|
+
* showSteps: true,
|
|
2421
|
+
* classNames: { base: "custom-slider" }
|
|
2422
|
+
* })
|
|
2423
|
+
* ```
|
|
2424
|
+
*/
|
|
2425
|
+
slider: <T extends FieldValues>(name: Path<T>, label: string, sliderProps?: Omit<React$1.ComponentProps<typeof Slider>, "value" | "onChange" | "label" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2261
2426
|
/**
|
|
2262
2427
|
* Create a switch field
|
|
2428
|
+
*
|
|
2429
|
+
* @example
|
|
2430
|
+
* ```tsx
|
|
2431
|
+
* // Simple switch
|
|
2432
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications")
|
|
2433
|
+
*
|
|
2434
|
+
* // With description
|
|
2435
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications")
|
|
2436
|
+
*
|
|
2437
|
+
* // With full customization
|
|
2438
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications", {
|
|
2439
|
+
* classNames: { base: "custom-switch" },
|
|
2440
|
+
* size: "lg",
|
|
2441
|
+
* color: "primary"
|
|
2442
|
+
* })
|
|
2443
|
+
* ```
|
|
2263
2444
|
*/
|
|
2264
|
-
switch: <T extends FieldValues>(name: Path<T>, label: string, description?: string) => ZodFormFieldConfig<T>;
|
|
2445
|
+
switch: <T extends FieldValues>(name: Path<T>, label: string, description?: string, switchProps?: Omit<React$1.ComponentProps<typeof Switch>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2265
2446
|
/**
|
|
2266
2447
|
* Create a textarea field
|
|
2448
|
+
*
|
|
2449
|
+
* @example
|
|
2450
|
+
* ```tsx
|
|
2451
|
+
* // Simple textarea
|
|
2452
|
+
* FormFieldHelpers.textarea("message", "Message")
|
|
2453
|
+
*
|
|
2454
|
+
* // With placeholder
|
|
2455
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message")
|
|
2456
|
+
*
|
|
2457
|
+
* // With full customization
|
|
2458
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message", {
|
|
2459
|
+
* classNames: { input: "custom-textarea" },
|
|
2460
|
+
* minRows: 3,
|
|
2461
|
+
* maxRows: 10
|
|
2462
|
+
* })
|
|
2463
|
+
* ```
|
|
2267
2464
|
*/
|
|
2268
|
-
textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
|
|
2465
|
+
textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string, textareaProps?: Omit<React$1.ComponentProps<typeof Textarea>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2269
2466
|
};
|
|
2270
2467
|
/**
|
|
2271
2468
|
* Common field collections
|
package/dist/index.js
CHANGED
|
@@ -2438,9 +2438,27 @@ function createBasicFormBuilder() {
|
|
|
2438
2438
|
var FormFieldHelpers = {
|
|
2439
2439
|
/**
|
|
2440
2440
|
* Create an autocomplete field
|
|
2441
|
+
*
|
|
2442
|
+
* @example
|
|
2443
|
+
* ```tsx
|
|
2444
|
+
* // Simple autocomplete
|
|
2445
|
+
* FormFieldHelpers.autocomplete("country", "Country", options)
|
|
2446
|
+
*
|
|
2447
|
+
* // With placeholder
|
|
2448
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries")
|
|
2449
|
+
*
|
|
2450
|
+
* // With full customization
|
|
2451
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries", {
|
|
2452
|
+
* classNames: { base: "custom-autocomplete" },
|
|
2453
|
+
* allowsCustomValue: true
|
|
2454
|
+
* })
|
|
2455
|
+
* ```
|
|
2441
2456
|
*/
|
|
2442
|
-
autocomplete: (name, label, items, placeholder) => ({
|
|
2443
|
-
autocompleteProps:
|
|
2457
|
+
autocomplete: (name, label, items, placeholder, autocompleteProps) => ({
|
|
2458
|
+
autocompleteProps: {
|
|
2459
|
+
...placeholder && { placeholder },
|
|
2460
|
+
...autocompleteProps
|
|
2461
|
+
},
|
|
2444
2462
|
label,
|
|
2445
2463
|
name,
|
|
2446
2464
|
options: items,
|
|
@@ -2448,8 +2466,21 @@ var FormFieldHelpers = {
|
|
|
2448
2466
|
}),
|
|
2449
2467
|
/**
|
|
2450
2468
|
* Create a checkbox field
|
|
2469
|
+
*
|
|
2470
|
+
* @example
|
|
2471
|
+
* ```tsx
|
|
2472
|
+
* // Simple checkbox
|
|
2473
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter")
|
|
2474
|
+
*
|
|
2475
|
+
* // With full customization
|
|
2476
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter", {
|
|
2477
|
+
* classNames: { base: "custom-checkbox" },
|
|
2478
|
+
* size: "lg"
|
|
2479
|
+
* })
|
|
2480
|
+
* ```
|
|
2451
2481
|
*/
|
|
2452
|
-
checkbox: (name, label) => ({
|
|
2482
|
+
checkbox: (name, label, checkboxProps) => ({
|
|
2483
|
+
checkboxProps,
|
|
2453
2484
|
label,
|
|
2454
2485
|
name,
|
|
2455
2486
|
type: "checkbox"
|
|
@@ -2511,6 +2542,19 @@ var FormFieldHelpers = {
|
|
|
2511
2542
|
},
|
|
2512
2543
|
/**
|
|
2513
2544
|
* Create a date field
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```tsx
|
|
2548
|
+
* // Simple date field
|
|
2549
|
+
* FormFieldHelpers.date("birthDate", "Birth Date")
|
|
2550
|
+
*
|
|
2551
|
+
* // With full customization
|
|
2552
|
+
* FormFieldHelpers.date("birthDate", "Birth Date", {
|
|
2553
|
+
* label: "Select your birth date",
|
|
2554
|
+
* granularity: "day",
|
|
2555
|
+
* minValue: new CalendarDate(1900, 1, 1)
|
|
2556
|
+
* })
|
|
2557
|
+
* ```
|
|
2514
2558
|
*/
|
|
2515
2559
|
date: (name, label, dateProps) => ({
|
|
2516
2560
|
dateProps,
|
|
@@ -2518,40 +2562,211 @@ var FormFieldHelpers = {
|
|
|
2518
2562
|
name,
|
|
2519
2563
|
type: "date"
|
|
2520
2564
|
}),
|
|
2565
|
+
/**
|
|
2566
|
+
* Create a file upload field
|
|
2567
|
+
*
|
|
2568
|
+
* @example
|
|
2569
|
+
* ```tsx
|
|
2570
|
+
* // Simple file field
|
|
2571
|
+
* FormFieldHelpers.file("avatar", "Profile Picture")
|
|
2572
|
+
*
|
|
2573
|
+
* // With accept and multiple
|
|
2574
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2575
|
+
* accept: "image/*",
|
|
2576
|
+
* multiple: true
|
|
2577
|
+
* })
|
|
2578
|
+
*
|
|
2579
|
+
* // With full customization
|
|
2580
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2581
|
+
* accept: "image/*",
|
|
2582
|
+
* multiple: false,
|
|
2583
|
+
* fileProps: { className: "custom-file-input" }
|
|
2584
|
+
* })
|
|
2585
|
+
* ```
|
|
2586
|
+
*/
|
|
2587
|
+
file: (name, label, options) => ({
|
|
2588
|
+
accept: options?.accept,
|
|
2589
|
+
fileProps: options?.fileProps,
|
|
2590
|
+
label,
|
|
2591
|
+
multiple: options?.multiple,
|
|
2592
|
+
name,
|
|
2593
|
+
type: "file"
|
|
2594
|
+
}),
|
|
2595
|
+
/**
|
|
2596
|
+
* Create a font picker field
|
|
2597
|
+
*
|
|
2598
|
+
* @example
|
|
2599
|
+
* ```tsx
|
|
2600
|
+
* // Simple font picker
|
|
2601
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font")
|
|
2602
|
+
*
|
|
2603
|
+
* // With full customization
|
|
2604
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font", {
|
|
2605
|
+
* showFontPreview: true,
|
|
2606
|
+
* loadAllVariants: false,
|
|
2607
|
+
* fontsLoadedTimeout: 5000
|
|
2608
|
+
* })
|
|
2609
|
+
* ```
|
|
2610
|
+
*/
|
|
2611
|
+
fontPicker: (name, label, fontPickerProps) => ({
|
|
2612
|
+
fontPickerProps,
|
|
2613
|
+
label,
|
|
2614
|
+
name,
|
|
2615
|
+
type: "fontPicker"
|
|
2616
|
+
}),
|
|
2521
2617
|
/**
|
|
2522
2618
|
* Create an input field
|
|
2619
|
+
*
|
|
2620
|
+
* @example
|
|
2621
|
+
* ```tsx
|
|
2622
|
+
* // Simple input
|
|
2623
|
+
* FormFieldHelpers.input("name", "Name")
|
|
2624
|
+
*
|
|
2625
|
+
* // With type
|
|
2626
|
+
* FormFieldHelpers.input("email", "Email", "email")
|
|
2627
|
+
*
|
|
2628
|
+
* // With full customization
|
|
2629
|
+
* FormFieldHelpers.input("email", "Email", "email", {
|
|
2630
|
+
* placeholder: "Enter your email",
|
|
2631
|
+
* classNames: { input: "custom-input" },
|
|
2632
|
+
* startContent: <MailIcon />,
|
|
2633
|
+
* description: "We'll never share your email"
|
|
2634
|
+
* })
|
|
2635
|
+
* ```
|
|
2523
2636
|
*/
|
|
2524
|
-
input: (name, label, type
|
|
2525
|
-
inputProps: {
|
|
2637
|
+
input: (name, label, type, inputProps) => ({
|
|
2638
|
+
inputProps: {
|
|
2639
|
+
type: type || "text",
|
|
2640
|
+
...inputProps
|
|
2641
|
+
},
|
|
2526
2642
|
label,
|
|
2527
2643
|
name,
|
|
2528
2644
|
type: "input"
|
|
2529
2645
|
}),
|
|
2646
|
+
/**
|
|
2647
|
+
* Create a radio group field
|
|
2648
|
+
*
|
|
2649
|
+
* @example
|
|
2650
|
+
* ```tsx
|
|
2651
|
+
* // Simple radio group
|
|
2652
|
+
* FormFieldHelpers.radio("gender", "Gender", [
|
|
2653
|
+
* { label: "Male", value: "male" },
|
|
2654
|
+
* { label: "Female", value: "female" }
|
|
2655
|
+
* ])
|
|
2656
|
+
*
|
|
2657
|
+
* // With full customization
|
|
2658
|
+
* FormFieldHelpers.radio("gender", "Gender", options, {
|
|
2659
|
+
* orientation: "horizontal",
|
|
2660
|
+
* classNames: { base: "custom-radio" }
|
|
2661
|
+
* })
|
|
2662
|
+
* ```
|
|
2663
|
+
*/
|
|
2664
|
+
radio: (name, label, options, radioProps) => ({
|
|
2665
|
+
label,
|
|
2666
|
+
name,
|
|
2667
|
+
radioOptions: options,
|
|
2668
|
+
radioProps,
|
|
2669
|
+
type: "radio"
|
|
2670
|
+
}),
|
|
2530
2671
|
/**
|
|
2531
2672
|
* Create a select field
|
|
2673
|
+
*
|
|
2674
|
+
* @example
|
|
2675
|
+
* ```tsx
|
|
2676
|
+
* // Simple select
|
|
2677
|
+
* FormFieldHelpers.select("country", "Country", options)
|
|
2678
|
+
*
|
|
2679
|
+
* // With full customization
|
|
2680
|
+
* FormFieldHelpers.select("country", "Country", options, {
|
|
2681
|
+
* placeholder: "Select a country",
|
|
2682
|
+
* classNames: { trigger: "custom-select" },
|
|
2683
|
+
* selectionMode: "multiple"
|
|
2684
|
+
* })
|
|
2685
|
+
* ```
|
|
2532
2686
|
*/
|
|
2533
|
-
select: (name, label, options) => ({
|
|
2687
|
+
select: (name, label, options, selectProps) => ({
|
|
2534
2688
|
label,
|
|
2535
2689
|
name,
|
|
2536
2690
|
options,
|
|
2691
|
+
selectProps,
|
|
2537
2692
|
type: "select"
|
|
2538
2693
|
}),
|
|
2694
|
+
/**
|
|
2695
|
+
* Create a slider field
|
|
2696
|
+
*
|
|
2697
|
+
* @example
|
|
2698
|
+
* ```tsx
|
|
2699
|
+
* // Simple slider
|
|
2700
|
+
* FormFieldHelpers.slider("rating", "Rating")
|
|
2701
|
+
*
|
|
2702
|
+
* // With full customization
|
|
2703
|
+
* FormFieldHelpers.slider("rating", "Rating", {
|
|
2704
|
+
* minValue: 1,
|
|
2705
|
+
* maxValue: 5,
|
|
2706
|
+
* step: 1,
|
|
2707
|
+
* showSteps: true,
|
|
2708
|
+
* classNames: { base: "custom-slider" }
|
|
2709
|
+
* })
|
|
2710
|
+
* ```
|
|
2711
|
+
*/
|
|
2712
|
+
slider: (name, label, sliderProps) => ({
|
|
2713
|
+
label,
|
|
2714
|
+
name,
|
|
2715
|
+
sliderProps,
|
|
2716
|
+
type: "slider"
|
|
2717
|
+
}),
|
|
2539
2718
|
/**
|
|
2540
2719
|
* Create a switch field
|
|
2720
|
+
*
|
|
2721
|
+
* @example
|
|
2722
|
+
* ```tsx
|
|
2723
|
+
* // Simple switch
|
|
2724
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications")
|
|
2725
|
+
*
|
|
2726
|
+
* // With description
|
|
2727
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications")
|
|
2728
|
+
*
|
|
2729
|
+
* // With full customization
|
|
2730
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications", {
|
|
2731
|
+
* classNames: { base: "custom-switch" },
|
|
2732
|
+
* size: "lg",
|
|
2733
|
+
* color: "primary"
|
|
2734
|
+
* })
|
|
2735
|
+
* ```
|
|
2541
2736
|
*/
|
|
2542
|
-
switch: (name, label, description) => ({
|
|
2737
|
+
switch: (name, label, description, switchProps) => ({
|
|
2543
2738
|
description,
|
|
2544
2739
|
label,
|
|
2545
2740
|
name,
|
|
2741
|
+
switchProps,
|
|
2546
2742
|
type: "switch"
|
|
2547
2743
|
}),
|
|
2548
2744
|
/**
|
|
2549
2745
|
* Create a textarea field
|
|
2746
|
+
*
|
|
2747
|
+
* @example
|
|
2748
|
+
* ```tsx
|
|
2749
|
+
* // Simple textarea
|
|
2750
|
+
* FormFieldHelpers.textarea("message", "Message")
|
|
2751
|
+
*
|
|
2752
|
+
* // With placeholder
|
|
2753
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message")
|
|
2754
|
+
*
|
|
2755
|
+
* // With full customization
|
|
2756
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message", {
|
|
2757
|
+
* classNames: { input: "custom-textarea" },
|
|
2758
|
+
* minRows: 3,
|
|
2759
|
+
* maxRows: 10
|
|
2760
|
+
* })
|
|
2761
|
+
* ```
|
|
2550
2762
|
*/
|
|
2551
|
-
textarea: (name, label, placeholder) => ({
|
|
2763
|
+
textarea: (name, label, placeholder, textareaProps) => ({
|
|
2552
2764
|
label,
|
|
2553
2765
|
name,
|
|
2554
|
-
textareaProps: {
|
|
2766
|
+
textareaProps: {
|
|
2767
|
+
...placeholder && { placeholder },
|
|
2768
|
+
...textareaProps
|
|
2769
|
+
},
|
|
2555
2770
|
type: "textarea"
|
|
2556
2771
|
})
|
|
2557
2772
|
};
|
|
@@ -2692,11 +2907,10 @@ function sliderField(name, label, props) {
|
|
|
2692
2907
|
type: "slider",
|
|
2693
2908
|
...props && {
|
|
2694
2909
|
sliderProps: {
|
|
2695
|
-
className: props.className
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
step: props.step || 1
|
|
2910
|
+
className: props.className,
|
|
2911
|
+
maxValue: props.max ?? 100,
|
|
2912
|
+
minValue: props.min ?? 0,
|
|
2913
|
+
step: props.step ?? 1
|
|
2700
2914
|
}
|
|
2701
2915
|
}
|
|
2702
2916
|
};
|
|
@@ -2708,9 +2922,8 @@ function dateField(name, label, props) {
|
|
|
2708
2922
|
type: "date",
|
|
2709
2923
|
...props && {
|
|
2710
2924
|
dateProps: {
|
|
2711
|
-
className: props.className
|
|
2712
|
-
|
|
2713
|
-
placeholder: props.placeholder || ""
|
|
2925
|
+
className: props.className,
|
|
2926
|
+
placeholder: props.placeholder
|
|
2714
2927
|
}
|
|
2715
2928
|
}
|
|
2716
2929
|
};
|
|
@@ -2732,15 +2945,12 @@ function fileField(name, label, props) {
|
|
|
2732
2945
|
}
|
|
2733
2946
|
function fontPickerField(name, label, props) {
|
|
2734
2947
|
return {
|
|
2948
|
+
className: props?.className,
|
|
2949
|
+
description: props?.description,
|
|
2950
|
+
fontPickerProps: props?.fontPickerProps,
|
|
2735
2951
|
label,
|
|
2736
2952
|
name,
|
|
2737
|
-
type: "fontPicker"
|
|
2738
|
-
...props && {
|
|
2739
|
-
fontPickerProps: {
|
|
2740
|
-
className: props.className || "",
|
|
2741
|
-
disabled: props.isDisabled || false
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2953
|
+
type: "fontPicker"
|
|
2744
2954
|
};
|
|
2745
2955
|
}
|
|
2746
2956
|
function contentField(title, description, options) {
|
|
@@ -3062,7 +3272,12 @@ var TypeInferredBuilder = class {
|
|
|
3062
3272
|
this.formFields.push({
|
|
3063
3273
|
label,
|
|
3064
3274
|
name,
|
|
3065
|
-
sliderProps: {
|
|
3275
|
+
sliderProps: {
|
|
3276
|
+
maxValue: max,
|
|
3277
|
+
minValue: min,
|
|
3278
|
+
step,
|
|
3279
|
+
...fieldOptions
|
|
3280
|
+
},
|
|
3066
3281
|
type: "slider"
|
|
3067
3282
|
});
|
|
3068
3283
|
return this;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React$1, { ComponentProps } from 'react';
|
|
2
|
-
import { Input, Textarea, Select, Autocomplete, Checkbox, Switch, RadioGroup,
|
|
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
4
|
import { FieldValues, Path, RegisterOptions, Control, UseFormReturn, FieldErrors, UseFormProps, SubmitHandler, UseFormSetError } from 'react-hook-form';
|
|
5
5
|
export { UseFormReturn, useFormContext } from 'react-hook-form';
|
|
@@ -67,24 +67,29 @@ interface RadioFieldConfig<TFieldValues extends FieldValues> extends BaseFormFie
|
|
|
67
67
|
interface SliderFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
68
68
|
type: "slider";
|
|
69
69
|
defaultValue?: number;
|
|
70
|
-
sliderProps?:
|
|
70
|
+
sliderProps?: Omit<ComponentProps<typeof Slider>, "value" | "onChange" | "label" | "isDisabled">;
|
|
71
71
|
}
|
|
72
72
|
interface DateFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
73
73
|
type: "date";
|
|
74
74
|
defaultValue?: _internationalized_date.CalendarDate | null;
|
|
75
|
-
dateProps?:
|
|
75
|
+
dateProps?: Omit<ComponentProps<typeof DateInput>, "value" | "onChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">;
|
|
76
76
|
}
|
|
77
77
|
interface FileFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
78
78
|
type: "file";
|
|
79
79
|
defaultValue?: FileList | null;
|
|
80
|
-
fileProps?:
|
|
80
|
+
fileProps?: Omit<ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "type">;
|
|
81
81
|
multiple?: boolean;
|
|
82
82
|
accept?: string;
|
|
83
83
|
}
|
|
84
84
|
interface FontPickerFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
85
85
|
type: "fontPicker";
|
|
86
86
|
defaultValue?: string;
|
|
87
|
-
fontPickerProps?:
|
|
87
|
+
fontPickerProps?: {
|
|
88
|
+
showFontPreview?: boolean;
|
|
89
|
+
loadAllVariants?: boolean;
|
|
90
|
+
onFontsLoaded?: (loaded: boolean) => void;
|
|
91
|
+
fontsLoadedTimeout?: number;
|
|
92
|
+
};
|
|
88
93
|
}
|
|
89
94
|
interface CustomFieldConfig<TFieldValues extends FieldValues> extends BaseFormFieldConfig<TFieldValues> {
|
|
90
95
|
type: "custom";
|
|
@@ -2178,15 +2183,42 @@ declare function createBasicFormBuilder<T extends FieldValues>(): BasicFormBuild
|
|
|
2178
2183
|
declare const FormFieldHelpers: {
|
|
2179
2184
|
/**
|
|
2180
2185
|
* Create an autocomplete field
|
|
2186
|
+
*
|
|
2187
|
+
* @example
|
|
2188
|
+
* ```tsx
|
|
2189
|
+
* // Simple autocomplete
|
|
2190
|
+
* FormFieldHelpers.autocomplete("country", "Country", options)
|
|
2191
|
+
*
|
|
2192
|
+
* // With placeholder
|
|
2193
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries")
|
|
2194
|
+
*
|
|
2195
|
+
* // With full customization
|
|
2196
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries", {
|
|
2197
|
+
* classNames: { base: "custom-autocomplete" },
|
|
2198
|
+
* allowsCustomValue: true
|
|
2199
|
+
* })
|
|
2200
|
+
* ```
|
|
2181
2201
|
*/
|
|
2182
2202
|
autocomplete: <T extends FieldValues>(name: Path<T>, label: string, items: {
|
|
2183
2203
|
label: string;
|
|
2184
2204
|
value: string | number;
|
|
2185
|
-
}[], placeholder?: string) => ZodFormFieldConfig<T>;
|
|
2205
|
+
}[], placeholder?: string, autocompleteProps?: Omit<React$1.ComponentProps<typeof Autocomplete>, "selectedKey" | "onSelectionChange" | "inputValue" | "onInputChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "children" | "items">) => ZodFormFieldConfig<T>;
|
|
2186
2206
|
/**
|
|
2187
2207
|
* Create a checkbox field
|
|
2208
|
+
*
|
|
2209
|
+
* @example
|
|
2210
|
+
* ```tsx
|
|
2211
|
+
* // Simple checkbox
|
|
2212
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter")
|
|
2213
|
+
*
|
|
2214
|
+
* // With full customization
|
|
2215
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter", {
|
|
2216
|
+
* classNames: { base: "custom-checkbox" },
|
|
2217
|
+
* size: "lg"
|
|
2218
|
+
* })
|
|
2219
|
+
* ```
|
|
2188
2220
|
*/
|
|
2189
|
-
checkbox: <T extends FieldValues>(name: Path<T>, label: string) => ZodFormFieldConfig<T>;
|
|
2221
|
+
checkbox: <T extends FieldValues>(name: Path<T>, label: string, checkboxProps?: Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2190
2222
|
/**
|
|
2191
2223
|
* Create a conditional field that shows/hides based on form data
|
|
2192
2224
|
*
|
|
@@ -2236,27 +2268,192 @@ declare const FormFieldHelpers: {
|
|
|
2236
2268
|
}) => ZodFormFieldConfig<T>;
|
|
2237
2269
|
/**
|
|
2238
2270
|
* Create a date field
|
|
2271
|
+
*
|
|
2272
|
+
* @example
|
|
2273
|
+
* ```tsx
|
|
2274
|
+
* // Simple date field
|
|
2275
|
+
* FormFieldHelpers.date("birthDate", "Birth Date")
|
|
2276
|
+
*
|
|
2277
|
+
* // With full customization
|
|
2278
|
+
* FormFieldHelpers.date("birthDate", "Birth Date", {
|
|
2279
|
+
* label: "Select your birth date",
|
|
2280
|
+
* granularity: "day",
|
|
2281
|
+
* minValue: new CalendarDate(1900, 1, 1)
|
|
2282
|
+
* })
|
|
2283
|
+
* ```
|
|
2284
|
+
*/
|
|
2285
|
+
date: <T extends FieldValues>(name: Path<T>, label: string, dateProps?: Omit<React$1.ComponentProps<typeof DateInput>, "value" | "onChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2286
|
+
/**
|
|
2287
|
+
* Create a file upload field
|
|
2288
|
+
*
|
|
2289
|
+
* @example
|
|
2290
|
+
* ```tsx
|
|
2291
|
+
* // Simple file field
|
|
2292
|
+
* FormFieldHelpers.file("avatar", "Profile Picture")
|
|
2293
|
+
*
|
|
2294
|
+
* // With accept and multiple
|
|
2295
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2296
|
+
* accept: "image/*",
|
|
2297
|
+
* multiple: true
|
|
2298
|
+
* })
|
|
2299
|
+
*
|
|
2300
|
+
* // With full customization
|
|
2301
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2302
|
+
* accept: "image/*",
|
|
2303
|
+
* multiple: false,
|
|
2304
|
+
* fileProps: { className: "custom-file-input" }
|
|
2305
|
+
* })
|
|
2306
|
+
* ```
|
|
2307
|
+
*/
|
|
2308
|
+
file: <T extends FieldValues>(name: Path<T>, label: string, options?: {
|
|
2309
|
+
accept?: string;
|
|
2310
|
+
fileProps?: Omit<React$1.ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled" | "type">;
|
|
2311
|
+
multiple?: boolean;
|
|
2312
|
+
}) => ZodFormFieldConfig<T>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Create a font picker field
|
|
2315
|
+
*
|
|
2316
|
+
* @example
|
|
2317
|
+
* ```tsx
|
|
2318
|
+
* // Simple font picker
|
|
2319
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font")
|
|
2320
|
+
*
|
|
2321
|
+
* // With full customization
|
|
2322
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font", {
|
|
2323
|
+
* showFontPreview: true,
|
|
2324
|
+
* loadAllVariants: false,
|
|
2325
|
+
* fontsLoadedTimeout: 5000
|
|
2326
|
+
* })
|
|
2327
|
+
* ```
|
|
2239
2328
|
*/
|
|
2240
|
-
|
|
2329
|
+
fontPicker: <T extends FieldValues>(name: Path<T>, label: string, fontPickerProps?: {
|
|
2330
|
+
showFontPreview?: boolean;
|
|
2331
|
+
loadAllVariants?: boolean;
|
|
2332
|
+
onFontsLoaded?: (loaded: boolean) => void;
|
|
2333
|
+
fontsLoadedTimeout?: number;
|
|
2334
|
+
}) => ZodFormFieldConfig<T>;
|
|
2241
2335
|
/**
|
|
2242
2336
|
* Create an input field
|
|
2337
|
+
*
|
|
2338
|
+
* @example
|
|
2339
|
+
* ```tsx
|
|
2340
|
+
* // Simple input
|
|
2341
|
+
* FormFieldHelpers.input("name", "Name")
|
|
2342
|
+
*
|
|
2343
|
+
* // With type
|
|
2344
|
+
* FormFieldHelpers.input("email", "Email", "email")
|
|
2345
|
+
*
|
|
2346
|
+
* // With full customization
|
|
2347
|
+
* FormFieldHelpers.input("email", "Email", "email", {
|
|
2348
|
+
* placeholder: "Enter your email",
|
|
2349
|
+
* classNames: { input: "custom-input" },
|
|
2350
|
+
* startContent: <MailIcon />,
|
|
2351
|
+
* description: "We'll never share your email"
|
|
2352
|
+
* })
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
2355
|
+
input: <T extends FieldValues>(name: Path<T>, label: string, type?: "text" | "email" | "tel" | "password", inputProps?: Omit<React$1.ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2356
|
+
/**
|
|
2357
|
+
* Create a radio group field
|
|
2358
|
+
*
|
|
2359
|
+
* @example
|
|
2360
|
+
* ```tsx
|
|
2361
|
+
* // Simple radio group
|
|
2362
|
+
* FormFieldHelpers.radio("gender", "Gender", [
|
|
2363
|
+
* { label: "Male", value: "male" },
|
|
2364
|
+
* { label: "Female", value: "female" }
|
|
2365
|
+
* ])
|
|
2366
|
+
*
|
|
2367
|
+
* // With full customization
|
|
2368
|
+
* FormFieldHelpers.radio("gender", "Gender", options, {
|
|
2369
|
+
* orientation: "horizontal",
|
|
2370
|
+
* classNames: { base: "custom-radio" }
|
|
2371
|
+
* })
|
|
2372
|
+
* ```
|
|
2243
2373
|
*/
|
|
2244
|
-
|
|
2374
|
+
radio: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
2375
|
+
label: string;
|
|
2376
|
+
value: string | number;
|
|
2377
|
+
}[], radioProps?: Omit<React$1.ComponentProps<typeof RadioGroup>, "value" | "onValueChange" | "label">) => ZodFormFieldConfig<T>;
|
|
2245
2378
|
/**
|
|
2246
2379
|
* Create a select field
|
|
2380
|
+
*
|
|
2381
|
+
* @example
|
|
2382
|
+
* ```tsx
|
|
2383
|
+
* // Simple select
|
|
2384
|
+
* FormFieldHelpers.select("country", "Country", options)
|
|
2385
|
+
*
|
|
2386
|
+
* // With full customization
|
|
2387
|
+
* FormFieldHelpers.select("country", "Country", options, {
|
|
2388
|
+
* placeholder: "Select a country",
|
|
2389
|
+
* classNames: { trigger: "custom-select" },
|
|
2390
|
+
* selectionMode: "multiple"
|
|
2391
|
+
* })
|
|
2392
|
+
* ```
|
|
2247
2393
|
*/
|
|
2248
2394
|
select: <T extends FieldValues>(name: Path<T>, label: string, options: {
|
|
2249
2395
|
label: string;
|
|
2250
2396
|
value: string | number;
|
|
2251
|
-
}[]) => ZodFormFieldConfig<T>;
|
|
2397
|
+
}[], selectProps?: Omit<React$1.ComponentProps<typeof Select>, "selectedKeys" | "onSelectionChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2398
|
+
/**
|
|
2399
|
+
* Create a slider field
|
|
2400
|
+
*
|
|
2401
|
+
* @example
|
|
2402
|
+
* ```tsx
|
|
2403
|
+
* // Simple slider
|
|
2404
|
+
* FormFieldHelpers.slider("rating", "Rating")
|
|
2405
|
+
*
|
|
2406
|
+
* // With full customization
|
|
2407
|
+
* FormFieldHelpers.slider("rating", "Rating", {
|
|
2408
|
+
* minValue: 1,
|
|
2409
|
+
* maxValue: 5,
|
|
2410
|
+
* step: 1,
|
|
2411
|
+
* showSteps: true,
|
|
2412
|
+
* classNames: { base: "custom-slider" }
|
|
2413
|
+
* })
|
|
2414
|
+
* ```
|
|
2415
|
+
*/
|
|
2416
|
+
slider: <T extends FieldValues>(name: Path<T>, label: string, sliderProps?: Omit<React$1.ComponentProps<typeof Slider>, "value" | "onChange" | "label" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2252
2417
|
/**
|
|
2253
2418
|
* Create a switch field
|
|
2419
|
+
*
|
|
2420
|
+
* @example
|
|
2421
|
+
* ```tsx
|
|
2422
|
+
* // Simple switch
|
|
2423
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications")
|
|
2424
|
+
*
|
|
2425
|
+
* // With description
|
|
2426
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications")
|
|
2427
|
+
*
|
|
2428
|
+
* // With full customization
|
|
2429
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications", {
|
|
2430
|
+
* classNames: { base: "custom-switch" },
|
|
2431
|
+
* size: "lg",
|
|
2432
|
+
* color: "primary"
|
|
2433
|
+
* })
|
|
2434
|
+
* ```
|
|
2254
2435
|
*/
|
|
2255
|
-
switch: <T extends FieldValues>(name: Path<T>, label: string, description?: string) => ZodFormFieldConfig<T>;
|
|
2436
|
+
switch: <T extends FieldValues>(name: Path<T>, label: string, description?: string, switchProps?: Omit<React$1.ComponentProps<typeof Switch>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2256
2437
|
/**
|
|
2257
2438
|
* Create a textarea field
|
|
2439
|
+
*
|
|
2440
|
+
* @example
|
|
2441
|
+
* ```tsx
|
|
2442
|
+
* // Simple textarea
|
|
2443
|
+
* FormFieldHelpers.textarea("message", "Message")
|
|
2444
|
+
*
|
|
2445
|
+
* // With placeholder
|
|
2446
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message")
|
|
2447
|
+
*
|
|
2448
|
+
* // With full customization
|
|
2449
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message", {
|
|
2450
|
+
* classNames: { input: "custom-textarea" },
|
|
2451
|
+
* minRows: 3,
|
|
2452
|
+
* maxRows: 10
|
|
2453
|
+
* })
|
|
2454
|
+
* ```
|
|
2258
2455
|
*/
|
|
2259
|
-
textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string) => ZodFormFieldConfig<T>;
|
|
2456
|
+
textarea: <T extends FieldValues>(name: Path<T>, label: string, placeholder?: string, textareaProps?: Omit<React$1.ComponentProps<typeof Textarea>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">) => ZodFormFieldConfig<T>;
|
|
2260
2457
|
};
|
|
2261
2458
|
/**
|
|
2262
2459
|
* Common field collections
|
package/dist/react/index.js
CHANGED
|
@@ -2444,9 +2444,27 @@ function createBasicFormBuilder() {
|
|
|
2444
2444
|
var FormFieldHelpers = {
|
|
2445
2445
|
/**
|
|
2446
2446
|
* Create an autocomplete field
|
|
2447
|
+
*
|
|
2448
|
+
* @example
|
|
2449
|
+
* ```tsx
|
|
2450
|
+
* // Simple autocomplete
|
|
2451
|
+
* FormFieldHelpers.autocomplete("country", "Country", options)
|
|
2452
|
+
*
|
|
2453
|
+
* // With placeholder
|
|
2454
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries")
|
|
2455
|
+
*
|
|
2456
|
+
* // With full customization
|
|
2457
|
+
* FormFieldHelpers.autocomplete("country", "Country", options, "Search countries", {
|
|
2458
|
+
* classNames: { base: "custom-autocomplete" },
|
|
2459
|
+
* allowsCustomValue: true
|
|
2460
|
+
* })
|
|
2461
|
+
* ```
|
|
2447
2462
|
*/
|
|
2448
|
-
autocomplete: (name, label, items, placeholder) => ({
|
|
2449
|
-
autocompleteProps:
|
|
2463
|
+
autocomplete: (name, label, items, placeholder, autocompleteProps) => ({
|
|
2464
|
+
autocompleteProps: {
|
|
2465
|
+
...placeholder && { placeholder },
|
|
2466
|
+
...autocompleteProps
|
|
2467
|
+
},
|
|
2450
2468
|
label,
|
|
2451
2469
|
name,
|
|
2452
2470
|
options: items,
|
|
@@ -2454,8 +2472,21 @@ var FormFieldHelpers = {
|
|
|
2454
2472
|
}),
|
|
2455
2473
|
/**
|
|
2456
2474
|
* Create a checkbox field
|
|
2475
|
+
*
|
|
2476
|
+
* @example
|
|
2477
|
+
* ```tsx
|
|
2478
|
+
* // Simple checkbox
|
|
2479
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter")
|
|
2480
|
+
*
|
|
2481
|
+
* // With full customization
|
|
2482
|
+
* FormFieldHelpers.checkbox("newsletter", "Subscribe to newsletter", {
|
|
2483
|
+
* classNames: { base: "custom-checkbox" },
|
|
2484
|
+
* size: "lg"
|
|
2485
|
+
* })
|
|
2486
|
+
* ```
|
|
2457
2487
|
*/
|
|
2458
|
-
checkbox: (name, label) => ({
|
|
2488
|
+
checkbox: (name, label, checkboxProps) => ({
|
|
2489
|
+
checkboxProps,
|
|
2459
2490
|
label,
|
|
2460
2491
|
name,
|
|
2461
2492
|
type: "checkbox"
|
|
@@ -2517,6 +2548,19 @@ var FormFieldHelpers = {
|
|
|
2517
2548
|
},
|
|
2518
2549
|
/**
|
|
2519
2550
|
* Create a date field
|
|
2551
|
+
*
|
|
2552
|
+
* @example
|
|
2553
|
+
* ```tsx
|
|
2554
|
+
* // Simple date field
|
|
2555
|
+
* FormFieldHelpers.date("birthDate", "Birth Date")
|
|
2556
|
+
*
|
|
2557
|
+
* // With full customization
|
|
2558
|
+
* FormFieldHelpers.date("birthDate", "Birth Date", {
|
|
2559
|
+
* label: "Select your birth date",
|
|
2560
|
+
* granularity: "day",
|
|
2561
|
+
* minValue: new CalendarDate(1900, 1, 1)
|
|
2562
|
+
* })
|
|
2563
|
+
* ```
|
|
2520
2564
|
*/
|
|
2521
2565
|
date: (name, label, dateProps) => ({
|
|
2522
2566
|
dateProps,
|
|
@@ -2524,40 +2568,211 @@ var FormFieldHelpers = {
|
|
|
2524
2568
|
name,
|
|
2525
2569
|
type: "date"
|
|
2526
2570
|
}),
|
|
2571
|
+
/**
|
|
2572
|
+
* Create a file upload field
|
|
2573
|
+
*
|
|
2574
|
+
* @example
|
|
2575
|
+
* ```tsx
|
|
2576
|
+
* // Simple file field
|
|
2577
|
+
* FormFieldHelpers.file("avatar", "Profile Picture")
|
|
2578
|
+
*
|
|
2579
|
+
* // With accept and multiple
|
|
2580
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2581
|
+
* accept: "image/*",
|
|
2582
|
+
* multiple: true
|
|
2583
|
+
* })
|
|
2584
|
+
*
|
|
2585
|
+
* // With full customization
|
|
2586
|
+
* FormFieldHelpers.file("avatar", "Profile Picture", {
|
|
2587
|
+
* accept: "image/*",
|
|
2588
|
+
* multiple: false,
|
|
2589
|
+
* fileProps: { className: "custom-file-input" }
|
|
2590
|
+
* })
|
|
2591
|
+
* ```
|
|
2592
|
+
*/
|
|
2593
|
+
file: (name, label, options) => ({
|
|
2594
|
+
accept: options?.accept,
|
|
2595
|
+
fileProps: options?.fileProps,
|
|
2596
|
+
label,
|
|
2597
|
+
multiple: options?.multiple,
|
|
2598
|
+
name,
|
|
2599
|
+
type: "file"
|
|
2600
|
+
}),
|
|
2601
|
+
/**
|
|
2602
|
+
* Create a font picker field
|
|
2603
|
+
*
|
|
2604
|
+
* @example
|
|
2605
|
+
* ```tsx
|
|
2606
|
+
* // Simple font picker
|
|
2607
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font")
|
|
2608
|
+
*
|
|
2609
|
+
* // With full customization
|
|
2610
|
+
* FormFieldHelpers.fontPicker("font", "Choose Font", {
|
|
2611
|
+
* showFontPreview: true,
|
|
2612
|
+
* loadAllVariants: false,
|
|
2613
|
+
* fontsLoadedTimeout: 5000
|
|
2614
|
+
* })
|
|
2615
|
+
* ```
|
|
2616
|
+
*/
|
|
2617
|
+
fontPicker: (name, label, fontPickerProps) => ({
|
|
2618
|
+
fontPickerProps,
|
|
2619
|
+
label,
|
|
2620
|
+
name,
|
|
2621
|
+
type: "fontPicker"
|
|
2622
|
+
}),
|
|
2527
2623
|
/**
|
|
2528
2624
|
* Create an input field
|
|
2625
|
+
*
|
|
2626
|
+
* @example
|
|
2627
|
+
* ```tsx
|
|
2628
|
+
* // Simple input
|
|
2629
|
+
* FormFieldHelpers.input("name", "Name")
|
|
2630
|
+
*
|
|
2631
|
+
* // With type
|
|
2632
|
+
* FormFieldHelpers.input("email", "Email", "email")
|
|
2633
|
+
*
|
|
2634
|
+
* // With full customization
|
|
2635
|
+
* FormFieldHelpers.input("email", "Email", "email", {
|
|
2636
|
+
* placeholder: "Enter your email",
|
|
2637
|
+
* classNames: { input: "custom-input" },
|
|
2638
|
+
* startContent: <MailIcon />,
|
|
2639
|
+
* description: "We'll never share your email"
|
|
2640
|
+
* })
|
|
2641
|
+
* ```
|
|
2529
2642
|
*/
|
|
2530
|
-
input: (name, label, type
|
|
2531
|
-
inputProps: {
|
|
2643
|
+
input: (name, label, type, inputProps) => ({
|
|
2644
|
+
inputProps: {
|
|
2645
|
+
type: type || "text",
|
|
2646
|
+
...inputProps
|
|
2647
|
+
},
|
|
2532
2648
|
label,
|
|
2533
2649
|
name,
|
|
2534
2650
|
type: "input"
|
|
2535
2651
|
}),
|
|
2652
|
+
/**
|
|
2653
|
+
* Create a radio group field
|
|
2654
|
+
*
|
|
2655
|
+
* @example
|
|
2656
|
+
* ```tsx
|
|
2657
|
+
* // Simple radio group
|
|
2658
|
+
* FormFieldHelpers.radio("gender", "Gender", [
|
|
2659
|
+
* { label: "Male", value: "male" },
|
|
2660
|
+
* { label: "Female", value: "female" }
|
|
2661
|
+
* ])
|
|
2662
|
+
*
|
|
2663
|
+
* // With full customization
|
|
2664
|
+
* FormFieldHelpers.radio("gender", "Gender", options, {
|
|
2665
|
+
* orientation: "horizontal",
|
|
2666
|
+
* classNames: { base: "custom-radio" }
|
|
2667
|
+
* })
|
|
2668
|
+
* ```
|
|
2669
|
+
*/
|
|
2670
|
+
radio: (name, label, options, radioProps) => ({
|
|
2671
|
+
label,
|
|
2672
|
+
name,
|
|
2673
|
+
radioOptions: options,
|
|
2674
|
+
radioProps,
|
|
2675
|
+
type: "radio"
|
|
2676
|
+
}),
|
|
2536
2677
|
/**
|
|
2537
2678
|
* Create a select field
|
|
2679
|
+
*
|
|
2680
|
+
* @example
|
|
2681
|
+
* ```tsx
|
|
2682
|
+
* // Simple select
|
|
2683
|
+
* FormFieldHelpers.select("country", "Country", options)
|
|
2684
|
+
*
|
|
2685
|
+
* // With full customization
|
|
2686
|
+
* FormFieldHelpers.select("country", "Country", options, {
|
|
2687
|
+
* placeholder: "Select a country",
|
|
2688
|
+
* classNames: { trigger: "custom-select" },
|
|
2689
|
+
* selectionMode: "multiple"
|
|
2690
|
+
* })
|
|
2691
|
+
* ```
|
|
2538
2692
|
*/
|
|
2539
|
-
select: (name, label, options) => ({
|
|
2693
|
+
select: (name, label, options, selectProps) => ({
|
|
2540
2694
|
label,
|
|
2541
2695
|
name,
|
|
2542
2696
|
options,
|
|
2697
|
+
selectProps,
|
|
2543
2698
|
type: "select"
|
|
2544
2699
|
}),
|
|
2700
|
+
/**
|
|
2701
|
+
* Create a slider field
|
|
2702
|
+
*
|
|
2703
|
+
* @example
|
|
2704
|
+
* ```tsx
|
|
2705
|
+
* // Simple slider
|
|
2706
|
+
* FormFieldHelpers.slider("rating", "Rating")
|
|
2707
|
+
*
|
|
2708
|
+
* // With full customization
|
|
2709
|
+
* FormFieldHelpers.slider("rating", "Rating", {
|
|
2710
|
+
* minValue: 1,
|
|
2711
|
+
* maxValue: 5,
|
|
2712
|
+
* step: 1,
|
|
2713
|
+
* showSteps: true,
|
|
2714
|
+
* classNames: { base: "custom-slider" }
|
|
2715
|
+
* })
|
|
2716
|
+
* ```
|
|
2717
|
+
*/
|
|
2718
|
+
slider: (name, label, sliderProps) => ({
|
|
2719
|
+
label,
|
|
2720
|
+
name,
|
|
2721
|
+
sliderProps,
|
|
2722
|
+
type: "slider"
|
|
2723
|
+
}),
|
|
2545
2724
|
/**
|
|
2546
2725
|
* Create a switch field
|
|
2726
|
+
*
|
|
2727
|
+
* @example
|
|
2728
|
+
* ```tsx
|
|
2729
|
+
* // Simple switch
|
|
2730
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications")
|
|
2731
|
+
*
|
|
2732
|
+
* // With description
|
|
2733
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications")
|
|
2734
|
+
*
|
|
2735
|
+
* // With full customization
|
|
2736
|
+
* FormFieldHelpers.switch("notifications", "Enable notifications", "Receive email notifications", {
|
|
2737
|
+
* classNames: { base: "custom-switch" },
|
|
2738
|
+
* size: "lg",
|
|
2739
|
+
* color: "primary"
|
|
2740
|
+
* })
|
|
2741
|
+
* ```
|
|
2547
2742
|
*/
|
|
2548
|
-
switch: (name, label, description) => ({
|
|
2743
|
+
switch: (name, label, description, switchProps) => ({
|
|
2549
2744
|
description,
|
|
2550
2745
|
label,
|
|
2551
2746
|
name,
|
|
2747
|
+
switchProps,
|
|
2552
2748
|
type: "switch"
|
|
2553
2749
|
}),
|
|
2554
2750
|
/**
|
|
2555
2751
|
* Create a textarea field
|
|
2752
|
+
*
|
|
2753
|
+
* @example
|
|
2754
|
+
* ```tsx
|
|
2755
|
+
* // Simple textarea
|
|
2756
|
+
* FormFieldHelpers.textarea("message", "Message")
|
|
2757
|
+
*
|
|
2758
|
+
* // With placeholder
|
|
2759
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message")
|
|
2760
|
+
*
|
|
2761
|
+
* // With full customization
|
|
2762
|
+
* FormFieldHelpers.textarea("message", "Message", "Enter your message", {
|
|
2763
|
+
* classNames: { input: "custom-textarea" },
|
|
2764
|
+
* minRows: 3,
|
|
2765
|
+
* maxRows: 10
|
|
2766
|
+
* })
|
|
2767
|
+
* ```
|
|
2556
2768
|
*/
|
|
2557
|
-
textarea: (name, label, placeholder) => ({
|
|
2769
|
+
textarea: (name, label, placeholder, textareaProps) => ({
|
|
2558
2770
|
label,
|
|
2559
2771
|
name,
|
|
2560
|
-
textareaProps: {
|
|
2772
|
+
textareaProps: {
|
|
2773
|
+
...placeholder && { placeholder },
|
|
2774
|
+
...textareaProps
|
|
2775
|
+
},
|
|
2561
2776
|
type: "textarea"
|
|
2562
2777
|
})
|
|
2563
2778
|
};
|
|
@@ -2698,11 +2913,10 @@ function sliderField(name, label, props) {
|
|
|
2698
2913
|
type: "slider",
|
|
2699
2914
|
...props && {
|
|
2700
2915
|
sliderProps: {
|
|
2701
|
-
className: props.className
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
step: props.step || 1
|
|
2916
|
+
className: props.className,
|
|
2917
|
+
maxValue: props.max ?? 100,
|
|
2918
|
+
minValue: props.min ?? 0,
|
|
2919
|
+
step: props.step ?? 1
|
|
2706
2920
|
}
|
|
2707
2921
|
}
|
|
2708
2922
|
};
|
|
@@ -2714,9 +2928,8 @@ function dateField(name, label, props) {
|
|
|
2714
2928
|
type: "date",
|
|
2715
2929
|
...props && {
|
|
2716
2930
|
dateProps: {
|
|
2717
|
-
className: props.className
|
|
2718
|
-
|
|
2719
|
-
placeholder: props.placeholder || ""
|
|
2931
|
+
className: props.className,
|
|
2932
|
+
placeholder: props.placeholder
|
|
2720
2933
|
}
|
|
2721
2934
|
}
|
|
2722
2935
|
};
|
|
@@ -2738,15 +2951,12 @@ function fileField(name, label, props) {
|
|
|
2738
2951
|
}
|
|
2739
2952
|
function fontPickerField(name, label, props) {
|
|
2740
2953
|
return {
|
|
2954
|
+
className: props?.className,
|
|
2955
|
+
description: props?.description,
|
|
2956
|
+
fontPickerProps: props?.fontPickerProps,
|
|
2741
2957
|
label,
|
|
2742
2958
|
name,
|
|
2743
|
-
type: "fontPicker"
|
|
2744
|
-
...props && {
|
|
2745
|
-
fontPickerProps: {
|
|
2746
|
-
className: props.className || "",
|
|
2747
|
-
disabled: props.isDisabled || false
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2959
|
+
type: "fontPicker"
|
|
2750
2960
|
};
|
|
2751
2961
|
}
|
|
2752
2962
|
function contentField(title, description, options) {
|
|
@@ -3068,7 +3278,12 @@ var TypeInferredBuilder = class {
|
|
|
3068
3278
|
this.formFields.push({
|
|
3069
3279
|
label,
|
|
3070
3280
|
name,
|
|
3071
|
-
sliderProps: {
|
|
3281
|
+
sliderProps: {
|
|
3282
|
+
maxValue: max,
|
|
3283
|
+
minValue: min,
|
|
3284
|
+
step,
|
|
3285
|
+
...fieldOptions
|
|
3286
|
+
},
|
|
3072
3287
|
type: "slider"
|
|
3073
3288
|
});
|
|
3074
3289
|
return this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rachelallyson/hero-hook-form",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Typed form helpers that combine React Hook Form and HeroUI components.",
|
|
5
5
|
"author": "Rachel Higley",
|
|
6
6
|
"homepage": "https://rachelallyson.github.io/hero-hook-form/",
|