@paragrav/rhf-utils 0.0.144 → 0.0.145
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/README.md +10 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## About
|
|
4
4
|
|
|
5
|
-
Integration and utility library for [react-hook-form](https://www.react-hook-form.com/) and [zod](https://www.npmjs.com/package/zod). Declaratively configure your forms via global and form-level options.
|
|
5
|
+
Integration and utility library for [react-hook-form](https://www.react-hook-form.com/) (and [zod](https://www.npmjs.com/package/zod)). Declaratively configure your forms via global and form-level options.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -227,12 +227,14 @@ function Children({...}: RhfUtilsUseFormChildrenZodProps<typeof schema>) { }
|
|
|
227
227
|
|
|
228
228
|
## Form Component Hierarchy
|
|
229
229
|
|
|
230
|
+
`RhfUtilsZodForm` renders as:
|
|
231
|
+
|
|
230
232
|
```tsx
|
|
231
|
-
<ReactHookForm.FormProvider>
|
|
232
|
-
<RhfUtilsProviders>
|
|
233
|
-
<RhfUtilsClientConfig.FormComponent>
|
|
234
|
-
<RhfUtilsClientConfig.FormChildrenWrapper>
|
|
235
|
-
<RhfUtilsZodForm.Children />
|
|
233
|
+
<ReactHookForm.FormProvider> // standard rhf provider
|
|
234
|
+
<RhfUtilsProviders> // rhf utils internal providers
|
|
235
|
+
<RhfUtilsClientConfig.FormComponent> // from global config (or default)
|
|
236
|
+
<RhfUtilsClientConfig.FormChildrenWrapper> // from global config (if provided)
|
|
237
|
+
<RhfUtilsZodForm.Children /> // form instance component prop
|
|
236
238
|
</RhfUtilsClientConfig.FormChildrenWrapper>
|
|
237
239
|
</RhfUtilsClientConfig.FormComponent>
|
|
238
240
|
<RhfUtilsProviders>
|
|
@@ -266,7 +268,7 @@ Most common use case will be transforming backend errors to frontend shape.
|
|
|
266
268
|
|
|
267
269
|
## `RhfUtilsFormOptions`
|
|
268
270
|
|
|
269
|
-
These options can be set globally and/or per form.
|
|
271
|
+
These built-in options can be set globally and/or per form.
|
|
270
272
|
|
|
271
273
|
```ts
|
|
272
274
|
type RhfUtilsFormOptions = {
|
|
@@ -301,7 +303,7 @@ Use `useRhfUtilsContextRequestSubmit` hook to get `requestSubmit` function for c
|
|
|
301
303
|
|
|
302
304
|
## Extend `RhfUtilsFormOptions`
|
|
303
305
|
|
|
304
|
-
Extend `RhfUtilsFormOptions` with custom options, which get passed to `Children`
|
|
306
|
+
Extend `RhfUtilsFormOptions` with custom options, which get passed to `RhfUtilsClientConfig`'s `ChildrenWrapper` and `RhfUtilsZodForm`'s `Children` components via `options` prop. These can take any shape, and allow you to override your own functionality at form-level.
|
|
305
307
|
|
|
306
308
|
```tsx
|
|
307
309
|
import '@paragrav/rhf-utils';
|