@rachelallyson/hero-hook-form 1.0.0 โ 1.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 +54 -42
- package/README.md +161 -189
- package/dist/index.d.ts +304 -61
- package/dist/index.js +503 -16862
- package/dist/react/index.d.ts +304 -61
- package/dist/react/index.js +441 -209
- package/package.json +60 -42
- package/dist/dist-ICUU7SXF.js +0 -8
- package/dist/index.cjs +0 -17915
- package/dist/index.d.cts +0 -362
- package/dist/react/index.cjs +0 -1297
- package/dist/react/index.d.cts +0 -354
package/CHANGELOG.md
CHANGED
|
@@ -2,49 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
## [1.0.2] - 2025-01-27
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
### Enhanced
|
|
8
|
+
|
|
9
|
+
- **Font Picker Refactored**: Now uses native [HeroUI Autocomplete component](https://www.heroui.com/docs/components/autocomplete)
|
|
10
|
+
- **Better Integration**: Perfect HeroUI design system integration with Autocomplete
|
|
11
|
+
- **Enhanced Features**: Built-in search, filtering, keyboard navigation, and accessibility
|
|
12
|
+
- **Sections Support**: Organized font categories with `AutocompleteSection`
|
|
13
|
+
- **Improved Performance**: Leverages HeroUI's optimized Autocomplete implementation
|
|
14
|
+
- **Better UX**: Native HeroUI animations, transitions, and responsive design
|
|
9
15
|
|
|
10
16
|
### Added
|
|
11
17
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
###
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
- **Google Fonts Integration**: Access to 1000+ Google Fonts with API key
|
|
19
|
+
- **Automatic Font Loading**: Selected fonts are automatically loaded from Google Fonts
|
|
20
|
+
- **Fallback Support**: Graceful fallback to local fonts if Google Fonts unavailable
|
|
21
|
+
- **Font Previews**: Live font previews in the picker
|
|
22
|
+
- **Accessibility Features**: Full ARIA support and keyboard navigation
|
|
23
|
+
|
|
24
|
+
## [1.0.1] - 2024-12-19
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **`createZodFormConfig` function**: Missing utility function for creating Zod form configurations
|
|
29
|
+
- **Font picker field**: Optional font picker field with `react-fontpicker-ts` integration
|
|
30
|
+
- **Comprehensive documentation**: Complete guides for radio buttons, nested fields, and font picker
|
|
31
|
+
- **Working examples**: Practical examples demonstrating proper usage
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **Default values handling**: Fixed type casting issues in `createZodFormConfig`
|
|
36
|
+
- **Radio button configuration**: Clarified proper usage with `radioOptions` instead of `inputProps.options`
|
|
37
|
+
- **Nested field names**: Documented proper schema structure for nested fields like "fonts.scale"
|
|
38
|
+
- **Type safety**: Updated `ZodFormConfig` interface to make `schema` required
|
|
39
|
+
|
|
40
|
+
### Documentation
|
|
41
|
+
|
|
42
|
+
- [Quick Start Guide](./docs/quick-start.md) - Get started quickly with examples
|
|
43
|
+
- [Radio Buttons Guide](./docs/radio-buttons-guide.md) - Complete guide for radio button configuration
|
|
44
|
+
- [Nested Fields Guide](./docs/nested-fields-guide.md) - Working with nested field names
|
|
45
|
+
- [Input Types Guide](./docs/input-types-guide.md) - Complete reference for all input types
|
|
46
|
+
- [Font Picker Guide](./docs/font-picker-guide.md) - Optional font picker field
|
|
47
|
+
- [Font Picker Styling](./docs/font-picker-styling.md) - HeroUI integration and styling
|
|
48
|
+
- [Fixes Summary](./docs/fixes-summary.md) - Summary of all fixes implemented
|
|
49
|
+
|
|
50
|
+
### Examples
|
|
51
|
+
|
|
52
|
+
- `example-settings-form.tsx` - Complete settings form with nested fields and radio buttons
|
|
53
|
+
- `example-nested-fields.tsx` - Demonstration of nested field names
|
|
54
|
+
|
|
55
|
+
## [1.0.0] - 2024-12-18
|
|
56
|
+
|
|
57
|
+
### Initial Release
|
|
58
|
+
|
|
59
|
+
- Basic form components with HeroUI integration
|
|
60
|
+
- Zod integration support
|
|
61
|
+
- TypeScript support
|
|
62
|
+
- Form validation and error handling
|
package/README.md
CHANGED
|
@@ -6,45 +6,76 @@
|
|
|
6
6
|
[](https://reactjs.org/)
|
|
7
7
|
[](https://heroui.com/)
|
|
8
8
|
|
|
9
|
-
> **
|
|
9
|
+
> **Type-safe form components that combine React Hook Form with HeroUI's design system.**
|
|
10
10
|
|
|
11
|
-
Build beautiful, accessible forms with full TypeScript support, validation, and HeroUI's design system.
|
|
11
|
+
Build beautiful, accessible forms with full TypeScript support, comprehensive validation, and HeroUI's modern design system. Perfect for React applications that need robust form handling with excellent developer experience.
|
|
12
12
|
|
|
13
13
|
## โจ Features
|
|
14
14
|
|
|
15
|
-
- ๐ฏ **Strongly-typed** field components
|
|
16
|
-
- ๐๏ธ **
|
|
17
|
-
- Default entrypoint for individual HeroUI packages
|
|
18
|
-
- `/react` entrypoint for the aggregate `@heroui/react`
|
|
19
|
-
- ๐ฆ **Optional
|
|
20
|
-
- ๐ง **Global configuration** system for consistent styling
|
|
21
|
-
- โ
**Zod integration** for schema-based validation
|
|
22
|
-
- ๐จ **Multiple layouts** (vertical, horizontal, grid)
|
|
23
|
-
- โฟ **Accessibility-first** with HeroUI's built-in
|
|
15
|
+
- ๐ฏ **Strongly-typed** field components with automatic TypeScript inference
|
|
16
|
+
- ๐๏ธ **Dual entrypoints** for maximum flexibility:
|
|
17
|
+
- Default entrypoint for individual HeroUI packages (better tree-shaking)
|
|
18
|
+
- `/react` entrypoint for the aggregate `@heroui/react` (convenient single dependency)
|
|
19
|
+
- ๐ฆ **Optional dependencies** - install only what you need
|
|
20
|
+
- ๐ง **Global configuration** system for consistent styling across your app
|
|
21
|
+
- โ
**Zod integration** for schema-based validation with type safety
|
|
22
|
+
- ๐จ **Multiple layouts** (vertical, horizontal, grid) with responsive design
|
|
23
|
+
- โฟ **Accessibility-first** with HeroUI's built-in ARIA support
|
|
24
24
|
- ๐ณ **Tree-shakeable** for optimal bundle sizes
|
|
25
|
+
- ๐ **Rapid prototyping** with ConfigurableForm component
|
|
26
|
+
- ๐จ **Optional font picker** with Google Fonts integration
|
|
25
27
|
|
|
26
28
|
## ๐ Quick Start
|
|
27
29
|
|
|
30
|
+
### Option 1: All-in-One HeroUI Package (Recommended for Development)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @rachelallyson/hero-hook-form @heroui/react react-hook-form zod
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Option 2: Individual HeroUI Packages (Recommended for Production)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @rachelallyson/hero-hook-form react-hook-form zod
|
|
40
|
+
npm install @heroui/button @heroui/input @heroui/select # Only what you need
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Option 3: With Optional Font Picker
|
|
44
|
+
|
|
45
|
+
For advanced font selection with Google Fonts integration:
|
|
46
|
+
|
|
28
47
|
```bash
|
|
29
|
-
npm install @rachelallyson/hero-hook-form
|
|
48
|
+
npm install @rachelallyson/hero-hook-form @rachelallyson/heroui-font-picker
|
|
30
49
|
```
|
|
31
50
|
|
|
51
|
+
The `FontPickerField` will automatically use the font picker package if available, with a helpful fallback message if not installed.
|
|
52
|
+
|
|
53
|
+
### Basic Usage
|
|
54
|
+
|
|
32
55
|
```tsx
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
56
|
+
import { ZodForm } from "@rachelallyson/hero-hook-form";
|
|
57
|
+
import { z } from "zod";
|
|
58
|
+
|
|
59
|
+
const schema = z.object({
|
|
60
|
+
email: z.string().email("Invalid email"),
|
|
61
|
+
name: z.string().min(1, "Name is required"),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const config = {
|
|
65
|
+
schema,
|
|
66
|
+
fields: [
|
|
67
|
+
{ name: "name", type: "input", label: "Name" },
|
|
68
|
+
{ name: "email", type: "input", label: "Email", inputProps: { type: "email" } },
|
|
69
|
+
],
|
|
70
|
+
};
|
|
35
71
|
|
|
36
72
|
export function ContactForm() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Form methods={methods} onSubmit={console.log}>
|
|
41
|
-
<InputField control={methods.control} label="Email" name="email" />
|
|
42
|
-
<SubmitButton>Send</SubmitButton>
|
|
43
|
-
</Form>
|
|
44
|
-
);
|
|
73
|
+
return <ZodForm config={config} onSubmit={console.log} />;
|
|
45
74
|
}
|
|
46
75
|
```
|
|
47
76
|
|
|
77
|
+
> ๐ **See [Installation Guide](./docs/installation.md) for detailed setup instructions and bundle optimization tips.**
|
|
78
|
+
|
|
48
79
|
## ๐ Why Hero Hook Form?
|
|
49
80
|
|
|
50
81
|
| Feature | Manual Setup | Hero Hook Form |
|
|
@@ -58,39 +89,39 @@ export function ContactForm() {
|
|
|
58
89
|
|
|
59
90
|
## Requirements
|
|
60
91
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
- HeroUI
|
|
92
|
+
- **React**: >=18.2 <20
|
|
93
|
+
- **React DOM**: >=18.2 <20
|
|
94
|
+
- **React Hook Form**: >=7 <8
|
|
95
|
+
- **HeroUI**: >=2 <3 (either individual packages or `@heroui/react`)
|
|
65
96
|
|
|
66
|
-
## Installation
|
|
97
|
+
## Installation Options
|
|
67
98
|
|
|
68
|
-
### Option A:
|
|
99
|
+
### Option A: Individual HeroUI Packages (Recommended for Production)
|
|
69
100
|
|
|
70
|
-
Install
|
|
101
|
+
Install only the HeroUI components you actually use for optimal bundle size:
|
|
71
102
|
|
|
72
103
|
```bash
|
|
73
|
-
#
|
|
104
|
+
# Minimal set that covers all included fields
|
|
74
105
|
npm i @rachelallyson/hero-hook-form react-hook-form \
|
|
75
106
|
@heroui/input @heroui/checkbox @heroui/radio @heroui/select \
|
|
76
107
|
@heroui/switch @heroui/button @heroui/spinner
|
|
77
108
|
```
|
|
78
109
|
|
|
79
|
-
|
|
110
|
+
Import from the package root:
|
|
80
111
|
|
|
81
112
|
```tsx
|
|
82
113
|
import { InputField, SelectField, CheckboxField, RadioGroupField, SwitchField, TextareaField, SubmitButton } from "@rachelallyson/hero-hook-form";
|
|
83
114
|
```
|
|
84
115
|
|
|
85
|
-
### Option B:
|
|
116
|
+
### Option B: Aggregate HeroUI Package (Recommended for Development)
|
|
86
117
|
|
|
87
|
-
Install the
|
|
118
|
+
Install the all-in-one HeroUI package for convenience:
|
|
88
119
|
|
|
89
120
|
```bash
|
|
90
121
|
npm i @rachelallyson/hero-hook-form react-hook-form @heroui/react
|
|
91
122
|
```
|
|
92
123
|
|
|
93
|
-
|
|
124
|
+
Import from the `/react` subpath:
|
|
94
125
|
|
|
95
126
|
```tsx
|
|
96
127
|
import { InputField, SelectField, CheckboxField, RadioGroupField, SwitchField, TextareaField, SubmitButton } from "@rachelallyson/hero-hook-form/react";
|
|
@@ -210,185 +241,126 @@ const config = createZodFormConfig(contactSchema, [
|
|
|
210
241
|
/>
|
|
211
242
|
```
|
|
212
243
|
|
|
213
|
-
###
|
|
214
|
-
|
|
215
|
-
- **Type Safety**: Full TypeScript support with automatic type inference
|
|
216
|
-
- **Runtime Validation**: Comprehensive validation with custom error messages
|
|
217
|
-
- **Schema Reusability**: Define schemas once and reuse across your app
|
|
218
|
-
- **Complex Validation**: Support for enums, numbers, custom refinements, and more
|
|
219
|
-
- **Optional Integration**: Only install Zod if you need it
|
|
220
|
-
|
|
221
|
-
### Zod vs Standard Validation
|
|
244
|
+
### Nested Fields and Radio Buttons
|
|
222
245
|
|
|
223
|
-
|
|
224
|
-
|---------|---------------|----------|
|
|
225
|
-
| Validation Rules | In field config | In schema |
|
|
226
|
-
| Type Safety | Manual types | Automatic inference |
|
|
227
|
-
| Error Messages | Inline | In schema |
|
|
228
|
-
| Reusability | Per field | Schema-wide |
|
|
229
|
-
| Runtime Safety | Basic | Comprehensive |
|
|
230
|
-
|
|
231
|
-
## Quick start
|
|
232
|
-
|
|
233
|
-
A small form wired with React Hook Form using our typed field components.
|
|
246
|
+
For nested field names and radio buttons:
|
|
234
247
|
|
|
235
248
|
```tsx
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export function ExampleForm() {
|
|
250
|
-
const methods = useForm<Values>({
|
|
251
|
-
defaultValues: {
|
|
252
|
-
name: "",
|
|
253
|
-
email: "",
|
|
254
|
-
bio: "",
|
|
255
|
-
plan: "free",
|
|
256
|
-
agree: false,
|
|
257
|
-
enabled: false,
|
|
258
|
-
},
|
|
259
|
-
mode: "onBlur",
|
|
260
|
-
});
|
|
249
|
+
const settingsSchema = z.object({
|
|
250
|
+
fonts: z.object({
|
|
251
|
+
scale: z.enum(["small", "medium", "large"]).default("medium"),
|
|
252
|
+
}),
|
|
253
|
+
layout: z.object({
|
|
254
|
+
sidebarPosition: z.enum(["left", "right", "hidden"]).default("left"),
|
|
255
|
+
}),
|
|
256
|
+
style: z.object({
|
|
257
|
+
theme: z.enum(["light", "dark", "auto"]).default("auto"),
|
|
258
|
+
}),
|
|
259
|
+
});
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
<SwitchField control={methods.control} label="Enable feature" name="enabled" />
|
|
301
|
-
|
|
302
|
-
<div className="flex justify-end">
|
|
303
|
-
<SubmitButton buttonProps={{ color: "primary" }}>Submit</SubmitButton>
|
|
304
|
-
</div>
|
|
305
|
-
</Form>
|
|
306
|
-
);
|
|
307
|
-
}
|
|
261
|
+
const config = createZodFormConfig(settingsSchema, [
|
|
262
|
+
{
|
|
263
|
+
name: "fonts.scale",
|
|
264
|
+
type: "radio",
|
|
265
|
+
label: "Font Scale",
|
|
266
|
+
radioOptions: [
|
|
267
|
+
{ label: "Small", value: "small" },
|
|
268
|
+
{ label: "Medium", value: "medium" },
|
|
269
|
+
{ label: "Large", value: "large" },
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "layout.sidebarPosition",
|
|
274
|
+
type: "radio",
|
|
275
|
+
label: "Sidebar Position",
|
|
276
|
+
radioOptions: [
|
|
277
|
+
{ label: "Left", value: "left" },
|
|
278
|
+
{ label: "Right", value: "right" },
|
|
279
|
+
{ label: "Hidden", value: "hidden" },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "style.theme",
|
|
284
|
+
type: "radio",
|
|
285
|
+
label: "Theme",
|
|
286
|
+
radioOptions: [
|
|
287
|
+
{ label: "Light", value: "light" },
|
|
288
|
+
{ label: "Dark", value: "dark" },
|
|
289
|
+
{ label: "Auto", value: "auto" },
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
], {
|
|
293
|
+
defaultValues: {
|
|
294
|
+
fonts: { scale: "large" },
|
|
295
|
+
layout: { sidebarPosition: "right" },
|
|
296
|
+
style: { theme: "auto" },
|
|
297
|
+
},
|
|
298
|
+
});
|
|
308
299
|
```
|
|
309
300
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
### Field components
|
|
313
|
-
|
|
314
|
-
All field components are strongly typed over your form values and expose a `...Props` prop for passing through component props in a type-safe way. We derive prop types via `React.ComponentProps<typeof Component>` to avoid tight coupling to HeroUIโs internal type names.
|
|
315
|
-
|
|
316
|
-
- `InputField<TFieldValues>`
|
|
317
|
-
- `inputProps?: Omit<ComponentProps<typeof Input>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">`
|
|
318
|
-
- `transform?: (value: string) => string` โ modify the value before writing to the form state
|
|
319
|
-
- `TextareaField<TFieldValues>`
|
|
320
|
-
- `textareaProps?: Omit<ComponentProps<typeof Textarea>, ...>`
|
|
321
|
-
- `SelectField<TFieldValues, TValue extends string | number = string>`
|
|
322
|
-
- `options: readonly { label: string; value: TValue; description?: string; disabled?: boolean }[]`
|
|
323
|
-
- `selectProps?: Omit<ComponentProps<typeof Select>, "selectedKeys" | "onSelectionChange" | ...>`
|
|
324
|
-
- `RadioGroupField<TFieldValues, TValue extends string | number = string>`
|
|
325
|
-
- `options: readonly { label: string; value: TValue; description?: string; disabled?: boolean }[]`
|
|
326
|
-
- `radioGroupProps?: Omit<ComponentProps<typeof RadioGroup>, "value" | "onValueChange" | "label">`
|
|
327
|
-
- `CheckboxField<TFieldValues>`
|
|
328
|
-
- `checkboxProps?: Omit<ComponentProps<typeof Checkbox>, ...>`
|
|
329
|
-
- `SwitchField<TFieldValues>`
|
|
330
|
-
- `switchProps?: Omit<ComponentProps<typeof Switch>, ...>`
|
|
331
|
-
- `SubmitButton`
|
|
332
|
-
- `isLoading?: boolean` โ if omitted, reflects RHFโs `formState.isSubmitting`
|
|
333
|
-
- `buttonProps?: Omit<ComponentProps<typeof Button>, "type" | "isLoading">`
|
|
334
|
-
|
|
335
|
-
### Form provider
|
|
301
|
+
### Zod Features
|
|
336
302
|
|
|
337
|
-
-
|
|
303
|
+
- **Type Safety**: Full TypeScript support with automatic type inference
|
|
304
|
+
- **Nested Fields**: Support for nested field names like "fonts.scale"
|
|
305
|
+
- **Default Values**: Proper handling of default values with nested structure
|
|
306
|
+
- **Radio Buttons**: Easy configuration with `radioOptions`
|
|
338
307
|
|
|
339
|
-
|
|
340
|
-
import { Form } from "@rachelallyson/hero-hook-form"; // or "/react"
|
|
308
|
+
## ๐ฏ Examples
|
|
341
309
|
|
|
342
|
-
|
|
343
|
-
{/* fields */}
|
|
344
|
-
</Form>
|
|
345
|
-
```
|
|
310
|
+
Check out our [comprehensive demo](../example/app/comprehensive-demo/page.tsx) to see Hero Hook Form in action with all field types and layouts!
|
|
346
311
|
|
|
347
|
-
|
|
312
|
+
## ๐ Documentation
|
|
348
313
|
|
|
349
|
-
|
|
314
|
+
For comprehensive guides and examples, visit our [documentation](./docs/README.md):
|
|
350
315
|
|
|
351
|
-
|
|
352
|
-
|
|
316
|
+
- [๐ Getting Started](./docs/getting-started.md) - Installation, setup, and first form
|
|
317
|
+
- [๐งฉ Components](./docs/components.md) - All available field components
|
|
318
|
+
- [โ๏ธ Configuration](./docs/configuration.md) - Global configuration and providers
|
|
319
|
+
- [๐ Form Builder](./docs/form-builder.md) - ConfigurableForm component
|
|
320
|
+
- [โ
Validation](./docs/validation.md) - Form validation patterns
|
|
321
|
+
- [๐ฎ Zod Integration](./docs/zod-integration.md) - Schema-based validation with Zod
|
|
322
|
+
- [๐จ Layouts](./docs/layouts.md) - Form layout options
|
|
323
|
+
- [๐ API Reference](./docs/api-reference.md) - Complete API documentation
|
|
353
324
|
|
|
354
|
-
|
|
355
|
-
await api.save(values);
|
|
356
|
-
} catch (e) {
|
|
357
|
-
applyServerErrors(methods, e.errors);
|
|
358
|
-
}
|
|
359
|
-
```
|
|
325
|
+
## ๐ง API Overview
|
|
360
326
|
|
|
361
|
-
|
|
327
|
+
### Field Components
|
|
362
328
|
|
|
363
|
-
|
|
364
|
-
- Use `/react` if your app installs the aggregate `@heroui/react` and you prefer a single HeroUI dep.
|
|
329
|
+
All field components are strongly typed and expose component-specific props:
|
|
365
330
|
|
|
366
|
-
|
|
331
|
+
- **`InputField`** - Text inputs with validation
|
|
332
|
+
- **`TextareaField`** - Multi-line text inputs
|
|
333
|
+
- **`SelectField`** - Dropdown selections
|
|
334
|
+
- **`RadioGroupField`** - Radio button groups
|
|
335
|
+
- **`CheckboxField`** - Single checkboxes
|
|
336
|
+
- **`SwitchField`** - Toggle switches
|
|
337
|
+
- **`SliderField`** - Range slider inputs
|
|
338
|
+
- **`DateField`** - Date picker inputs
|
|
339
|
+
- **`FileField`** - File upload inputs
|
|
340
|
+
- **`FontPickerField`** - Optional font selection (requires `@rachelallyson/heroui-font-picker`)
|
|
367
341
|
|
|
368
|
-
|
|
342
|
+
### Form Components
|
|
369
343
|
|
|
370
|
-
-
|
|
371
|
-
-
|
|
372
|
-
-
|
|
344
|
+
- **`Form`** - Light wrapper around React Hook Form's FormProvider
|
|
345
|
+
- **`FormField`** - Generic field wrapper component
|
|
346
|
+
- **`ZodForm`** - Schema-based forms with Zod validation
|
|
347
|
+
- **`ConfigurableForm`** - Rapid form development with declarative config
|
|
373
348
|
|
|
374
|
-
|
|
349
|
+
### Utilities & Hooks
|
|
375
350
|
|
|
376
|
-
|
|
351
|
+
- **`applyServerErrors`** - Map API validation errors to form fields
|
|
352
|
+
- **`HeroHookFormProvider`** - Global configuration for consistent styling
|
|
353
|
+
- **`useHeroForm`** - Enhanced form hook with additional utilities
|
|
354
|
+
- **`useFormHelper`** - Form helper utilities
|
|
377
355
|
|
|
378
|
-
|
|
356
|
+
For complete API documentation, see [API Reference](./docs/api-reference.md).
|
|
379
357
|
|
|
380
|
-
|
|
381
|
-
- [๐งฉ Components](./docs/components.md) - All available field components
|
|
382
|
-
- [๐๏ธ Form Builder](./docs/form-builder.md) - ConfigurableForm component guide
|
|
383
|
-
- [โ๏ธ Configuration](./docs/configuration.md) - Global configuration and providers
|
|
384
|
-
- [โ
Validation](./docs/validation.md) - Form validation patterns
|
|
385
|
-
- [๐ Zod Integration](./docs/zod-integration.md) - Schema-based validation with Zod
|
|
386
|
-
- [๐จ Layouts](./docs/layouts.md) - Form layout options
|
|
387
|
-
- [๐ API Reference](./docs/api-reference.md) - Complete API documentation
|
|
358
|
+
## ๐ฏ Entrypoint Selection
|
|
388
359
|
|
|
389
|
-
|
|
360
|
+
- **Default entrypoint**: For apps using individual HeroUI packages (better tree-shaking)
|
|
361
|
+
- **`/react` entrypoint**: For apps using `@heroui/react` (convenient single dependency)
|
|
390
362
|
|
|
391
|
-
|
|
363
|
+
Both entrypoints are fully tree-shakeable and support all features.
|
|
392
364
|
|
|
393
365
|
## โ FAQ
|
|
394
366
|
|