@paragrav/rhf-utils 0.0.109 → 0.0.110
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 +29 -21
- package/dist/esm/src/client/index.mjs +13 -16
- package/dist/esm/src/client/zod/createRhfUtilsClientForZod.mjs +3 -4
- package/dist/esm/src/devtool/LazyDevTool.mjs +1 -4
- package/dist/esm/src/exports.mjs +14 -14
- package/dist/esm/src/form/Form.mjs +41 -42
- package/dist/esm/src/form/FormWithProviders.mjs +6 -6
- package/dist/esm/src/form/{useForm.mjs → useRhfUtilsForm.mjs} +17 -17
- package/dist/types/client/config/RhfUtilsClientConfig.d.ts +3 -3
- package/dist/types/client/index.d.ts +3 -2
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +13 -0
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +4 -0
- package/dist/types/client/zod/RhfUtilsZodForm.d.ts +3 -3
- package/dist/types/client/zod/ZodTypeFieldValues.d.ts +4 -0
- package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +1 -1
- package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +3 -3
- package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +1 -3
- package/dist/types/devtool/LazyDevTool.d.ts +2 -1
- package/dist/types/exports.d.ts +4 -3
- package/dist/types/form/Form.d.ts +3 -3
- package/dist/types/form/FormWithProviders.d.ts +4 -4
- package/dist/types/form/RhfUtilsFormOptions.d.ts +2 -2
- package/dist/types/form/RhfUtilsFormProviders.d.ts +12 -0
- package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +13 -0
- package/dist/types/form/UseRhfUtilsFormProps.d.ts +21 -0
- package/dist/types/form/UseRhfUtilsFormReturn.d.ts +15 -0
- package/dist/types/form/useRhfUtilsForm.d.ts +16 -0
- package/package.json +1 -1
- /package/dist/esm/src/form/{FormProviders.mjs → RhfUtilsFormProviders.mjs} +0 -0
package/README.md
CHANGED
|
@@ -10,12 +10,13 @@ yarn add @paragrav/rhf-utils # yarn
|
|
|
10
10
|
|
|
11
11
|
## Config
|
|
12
12
|
|
|
13
|
-
To configure, create a file
|
|
13
|
+
To configure, create a file `config.tsx` with desired configuration settings. This is global configuration across all forms.
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
export const
|
|
16
|
+
export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
|
|
17
17
|
isDevelopment: import.meta.env.DEV,
|
|
18
18
|
|
|
19
|
+
// defaults -- overridable per form instance
|
|
19
20
|
defaults: {
|
|
20
21
|
// globally relevant subset of RHF's `UseFormProps` options
|
|
21
22
|
rhf: {
|
|
@@ -24,9 +25,8 @@ export const config: RhfUtilsClientConfig = {
|
|
|
24
25
|
|
|
25
26
|
// RhfUtilsFormOptions (see further below)
|
|
26
27
|
utils: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
28
|
+
// enable dev tool
|
|
29
|
+
devTool: true,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
|
|
@@ -47,13 +47,14 @@ export const config: RhfUtilsClientConfig = {
|
|
|
47
47
|
|
|
48
48
|
Children: {
|
|
49
49
|
top: (
|
|
50
|
+
// UseRhfUtilsFormChildrenProps
|
|
50
51
|
{
|
|
51
52
|
formId, // unique id string
|
|
52
53
|
formRef, // ref
|
|
53
54
|
context, // rhf UseFormReturn
|
|
54
55
|
options, // RhfUtilsFormOptions
|
|
55
56
|
Controller, // strongly-typed controller
|
|
56
|
-
},
|
|
57
|
+
},
|
|
57
58
|
) => {
|
|
58
59
|
// navigation blocker (using custom option)
|
|
59
60
|
useFormRouterBlocker(!!options?.prompter);
|
|
@@ -88,11 +89,13 @@ export const config: RhfUtilsClientConfig = {
|
|
|
88
89
|
And add the context provider to your stack:
|
|
89
90
|
|
|
90
91
|
```tsx
|
|
91
|
-
<RhfUtilsClientForZodContextProvider config={
|
|
92
|
+
<RhfUtilsClientForZodContextProvider config={rhfUtilsClientConfig}>
|
|
92
93
|
{children}
|
|
93
94
|
</RhfUtilsClientForZodContextProvider>
|
|
94
95
|
```
|
|
95
96
|
|
|
97
|
+
Currently, only `zod` is supported.
|
|
98
|
+
|
|
96
99
|
## Usage
|
|
97
100
|
|
|
98
101
|
```tsx
|
|
@@ -114,16 +117,15 @@ And add the context provider to your stack:
|
|
|
114
117
|
}) => {
|
|
115
118
|
onError(error);
|
|
116
119
|
}}
|
|
117
|
-
// fields
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
) => (
|
|
120
|
+
// children/fields
|
|
121
|
+
Children={({
|
|
122
|
+
// UseRhfUtilsFormChildrenProps
|
|
123
|
+
formId, // unique id string
|
|
124
|
+
formRef, // ref
|
|
125
|
+
context, // rhf UseFormReturn
|
|
126
|
+
options, // RhfUtilsFormOptions
|
|
127
|
+
Controller, // strongly-typed controller
|
|
128
|
+
}) => (
|
|
127
129
|
<>
|
|
128
130
|
<Controller
|
|
129
131
|
name="email" // strongly-typed field name
|
|
@@ -144,7 +146,13 @@ And add the context provider to your stack:
|
|
|
144
146
|
/>
|
|
145
147
|
```
|
|
146
148
|
|
|
147
|
-
`
|
|
149
|
+
`Children` is a component which is rendered as a child of the form. It receives `UseRhfUtilsFormChildrenProps` as props, including type-safe `Controller`.
|
|
150
|
+
|
|
151
|
+
If you prefer to define your `Children` component as standalone:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
const Children: RhfUtilsUseFormChildrenZodFC<typeof schema> = () => {};
|
|
155
|
+
```
|
|
148
156
|
|
|
149
157
|
## `RhfUtilsFormOptions`
|
|
150
158
|
|
|
@@ -172,14 +180,14 @@ type RhfUtilsFormOptions = {
|
|
|
172
180
|
typeof useResetFormAfterSubmitSuccessful
|
|
173
181
|
>[0];
|
|
174
182
|
|
|
175
|
-
/** Control dev tool options. */
|
|
176
|
-
devTool?: Pick<DevtoolUIProps, 'placement' | 'styles'
|
|
183
|
+
/** Control dev tool options. (Lazy-loaded when `isDevelopment` is `true` and truthy value supplied. Zero bundle size in prod.) */
|
|
184
|
+
devTool?: true | Pick<DevtoolUIProps, 'placement' | 'styles'>;
|
|
177
185
|
};
|
|
178
186
|
```
|
|
179
187
|
|
|
180
188
|
## Extend `RhfUtilsFormOptions`
|
|
181
189
|
|
|
182
|
-
Extend `RhfUtilsFormOptions` with custom options, which get passed to `
|
|
190
|
+
Extend `RhfUtilsFormOptions` with custom options, which get passed to `Children` component in `options` prop.
|
|
183
191
|
|
|
184
192
|
```tsx
|
|
185
193
|
import '@paragrav/rhf-utils';
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const m =
|
|
6
|
-
e,
|
|
7
|
-
r
|
|
8
|
-
);
|
|
2
|
+
import f from "../form/FormWithProviders.mjs";
|
|
3
|
+
import d from "../form/useRhfUtilsForm.mjs";
|
|
4
|
+
const R = (e) => (r) => {
|
|
5
|
+
const m = F(e, r);
|
|
9
6
|
return {
|
|
10
7
|
useForm: (i, s) => {
|
|
11
8
|
const t = m(i, s);
|
|
12
9
|
return {
|
|
13
|
-
...
|
|
10
|
+
...d(t),
|
|
14
11
|
FormWithProviders: ({
|
|
15
12
|
children: o
|
|
16
|
-
}) => /* @__PURE__ */ h(
|
|
13
|
+
}) => /* @__PURE__ */ h(f, { ...t, children: o })
|
|
17
14
|
};
|
|
18
15
|
},
|
|
19
16
|
FormWithProviders: a(e, r)
|
|
20
17
|
};
|
|
21
|
-
},
|
|
22
|
-
var t, o, n, u
|
|
18
|
+
}, F = (e, r) => function(i, s) {
|
|
19
|
+
var t, o, l, n, u;
|
|
23
20
|
return {
|
|
24
21
|
...s,
|
|
25
22
|
rhf: {
|
|
@@ -31,8 +28,8 @@ const W = (e) => (r) => {
|
|
|
31
28
|
...(o = r.defaults) == null ? void 0 : o.utils,
|
|
32
29
|
...s.utils,
|
|
33
30
|
classNames: [
|
|
34
|
-
...((
|
|
35
|
-
...((
|
|
31
|
+
...((n = (l = r.defaults) == null ? void 0 : l.utils) == null ? void 0 : n.classNames) ?? [],
|
|
32
|
+
...((u = s.utils) == null ? void 0 : u.classNames) ?? []
|
|
36
33
|
]
|
|
37
34
|
}
|
|
38
35
|
};
|
|
@@ -41,9 +38,9 @@ const W = (e) => (r) => {
|
|
|
41
38
|
children: s,
|
|
42
39
|
...t
|
|
43
40
|
}) {
|
|
44
|
-
const o =
|
|
41
|
+
const o = F(e, r);
|
|
45
42
|
return /* @__PURE__ */ h(
|
|
46
|
-
|
|
43
|
+
f,
|
|
47
44
|
{
|
|
48
45
|
...o(i, t),
|
|
49
46
|
children: s
|
|
@@ -51,5 +48,5 @@ const W = (e) => (r) => {
|
|
|
51
48
|
);
|
|
52
49
|
};
|
|
53
50
|
export {
|
|
54
|
-
|
|
51
|
+
R as createRhfUtilsClient
|
|
55
52
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { zodResolver as t } from "@hookform/resolvers/zod";
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
const l = o(t);
|
|
2
|
+
import { createRhfUtilsClient as e } from "../index.mjs";
|
|
3
|
+
const i = e(t);
|
|
5
4
|
export {
|
|
6
|
-
|
|
5
|
+
i as default
|
|
7
6
|
};
|
package/dist/esm/src/exports.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextProvider.mjs";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as s } from "./client/zod/context/useRhfUtilsClientForZodContext.mjs";
|
|
3
3
|
import { default as f } from "./client/zod/context/useRhfUtilsZodForm.mjs";
|
|
4
4
|
import { default as u } from "./client/zod/RhfUtilsZodForm.mjs";
|
|
5
5
|
import { default as d } from "./devtool/LazyDevTool.mjs";
|
|
6
6
|
import { default as x } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
|
|
7
7
|
import { default as i } from "./errors/flat/FlatFieldErrorsList.mjs";
|
|
8
8
|
import { default as E } from "./errors/message/FormErrorMessage.mjs";
|
|
9
|
-
import { default as
|
|
9
|
+
import { default as C } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
10
10
|
import { default as y } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
11
11
|
import { default as M } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
12
12
|
import { default as T } from "./errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.mjs";
|
|
13
13
|
import { default as I } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { getOnSubmitTrpcClientErrorHandler as
|
|
14
|
+
import { default as R } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
|
|
15
|
+
import { default as B } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
16
|
+
import { getOnSubmitTrpcClientErrorHandler as U } from "./errors/trpc/getOnSubmitTrpcClientErrorHandler.mjs";
|
|
17
17
|
import { trpcClientErrorToFormSubmitErrorsSchemaTransformer as v } from "./errors/trpc/trpcClientErrorToFormSubmitErrorsSchemaTransformer.mjs";
|
|
18
18
|
import { default as A } from "./errors/useFormErrorsEffect.mjs";
|
|
19
19
|
import { default as L } from "./errors/useFormErrorsIfAny.mjs";
|
|
20
20
|
import { default as N } from "./form/FormWithProviders.mjs";
|
|
21
|
-
import { default as W } from "./form/
|
|
21
|
+
import { default as W } from "./form/useRhfUtilsForm.mjs";
|
|
22
22
|
import { default as q } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
23
23
|
import { default as J } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
24
24
|
import { default as Q } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
@@ -26,7 +26,7 @@ import { default as X } from "./form/context/group/useFormGroupChildIsSubmitting
|
|
|
26
26
|
import { default as _ } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
27
27
|
import { default as rr } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
28
28
|
import { default as er } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
29
|
-
import { default as
|
|
29
|
+
import { default as sr } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
30
30
|
import { default as fr } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
31
31
|
import { default as ur } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
32
32
|
import { default as dr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
@@ -35,7 +35,7 @@ import { default as ir } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
|
35
35
|
export {
|
|
36
36
|
i as FlatFieldErrorsList,
|
|
37
37
|
E as FormErrorMessage,
|
|
38
|
-
|
|
38
|
+
C as FormErrorMessageByPath,
|
|
39
39
|
J as FormGroupContextProvider,
|
|
40
40
|
y as FormNonFieldErrorMarker,
|
|
41
41
|
M as FormNonFieldErrorMarkerHtmlAttribute,
|
|
@@ -44,12 +44,11 @@ export {
|
|
|
44
44
|
d as LazyDevTool,
|
|
45
45
|
e as RhfUtilsClientForZodContextProvider,
|
|
46
46
|
u as RhfUtilsZodForm,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
R as RootErrorsListFromFlatFieldErrorsContext,
|
|
48
|
+
U as getOnSubmitTrpcClientErrorHandler,
|
|
49
49
|
dr as getSubmitterButtonData,
|
|
50
50
|
v as trpcClientErrorToFormSubmitErrorsSchemaTransformer,
|
|
51
51
|
x as useFlatFieldErrorsContext,
|
|
52
|
-
W as useForm,
|
|
53
52
|
A as useFormErrorsEffect,
|
|
54
53
|
L as useFormErrorsIfAny,
|
|
55
54
|
Q as useFormGroupChildIsMountedTracker,
|
|
@@ -57,14 +56,15 @@ export {
|
|
|
57
56
|
_ as useFormGroupChildTracker,
|
|
58
57
|
rr as useFormGroupIsAnyBusy,
|
|
59
58
|
er as useFormGroupIsChildBusy,
|
|
60
|
-
|
|
59
|
+
sr as useFormGroupIsParentBusy,
|
|
61
60
|
fr as useFormGroupParentTracker,
|
|
62
61
|
T as useFormHasOnlyOrphanFieldErrorsMemo,
|
|
63
62
|
ir as useFormOnSubmitSuccessful,
|
|
64
63
|
ur as useFormOrParentIsBusy,
|
|
65
64
|
q as useFormUtilsContext,
|
|
66
65
|
I as useOrphanFormErrorsMemo,
|
|
67
|
-
|
|
66
|
+
s as useRhfUtilsClientForZodContext,
|
|
67
|
+
W as useRhfUtilsForm,
|
|
68
68
|
f as useRhfUtilsZodForm,
|
|
69
|
-
|
|
69
|
+
B as useRootFormFieldErrorsMemo
|
|
70
70
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as j, jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { useFormContext as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { FormSubmitError as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
3
|
+
import { useFormContext as B } from "react-hook-form";
|
|
4
|
+
import T from "../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
5
|
+
import _ from "../devtool/LazyDevTool.mjs";
|
|
6
|
+
import { FormSubmitError as D } from "../submit/error/FormSubmitError.mjs";
|
|
7
|
+
import N from "../submit/error/setCtxErrorsByFormSubmitErrors.mjs";
|
|
8
|
+
import P from "./_Controller.mjs";
|
|
9
|
+
import S from "./_FormBase.mjs";
|
|
10
10
|
function A({
|
|
11
11
|
formId: x,
|
|
12
12
|
formRef: c,
|
|
@@ -14,74 +14,73 @@ function A({
|
|
|
14
14
|
onSubmit: p,
|
|
15
15
|
onSubmitError: s,
|
|
16
16
|
onSubmitInvalid: y,
|
|
17
|
-
|
|
17
|
+
Children: l,
|
|
18
18
|
//
|
|
19
19
|
form: m,
|
|
20
20
|
utils: o,
|
|
21
21
|
//
|
|
22
22
|
children: f
|
|
23
23
|
}) {
|
|
24
|
-
const a =
|
|
25
|
-
o != null && o.stopSubmitPropagation &&
|
|
24
|
+
const a = B(), t = T(), v = async (e) => {
|
|
25
|
+
o != null && o.stopSubmitPropagation && e.stopPropagation();
|
|
26
26
|
try {
|
|
27
|
-
await a.handleSubmit(
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
27
|
+
await a.handleSubmit(b, y)(e);
|
|
28
|
+
} catch (r) {
|
|
29
|
+
F(r, e);
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
31
|
+
}, b = (e, r) => p == null ? void 0 : p(
|
|
32
|
+
e,
|
|
33
33
|
a,
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
var
|
|
37
|
-
const n =
|
|
34
|
+
r
|
|
35
|
+
), F = (e, r) => {
|
|
36
|
+
var h;
|
|
37
|
+
const n = e instanceof D ? (
|
|
38
38
|
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
39
|
-
|
|
39
|
+
e.errors
|
|
40
40
|
) : (
|
|
41
41
|
// if error is not FormSubmitError, consumer can provide global handler
|
|
42
|
-
(
|
|
42
|
+
(h = t == null ? void 0 : t.onSubmitError) == null ? void 0 : h.call(t, e)
|
|
43
43
|
);
|
|
44
|
-
n &&
|
|
45
|
-
|
|
44
|
+
n && N(a, n), s == null || s(
|
|
45
|
+
e,
|
|
46
46
|
a,
|
|
47
|
-
|
|
47
|
+
r
|
|
48
48
|
);
|
|
49
|
-
},
|
|
49
|
+
}, i = {
|
|
50
50
|
formId: x,
|
|
51
51
|
formRef: c,
|
|
52
52
|
context: a,
|
|
53
53
|
utils: o,
|
|
54
|
-
Controller:
|
|
55
|
-
},
|
|
54
|
+
Controller: P
|
|
55
|
+
}, C = (e) => {
|
|
56
56
|
var n;
|
|
57
|
-
const
|
|
58
|
-
return
|
|
57
|
+
const r = (n = t == null ? void 0 : t.Children) == null ? void 0 : n[e];
|
|
58
|
+
return r && /* @__PURE__ */ d(r, { ...i });
|
|
59
59
|
};
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
60
|
+
return /* @__PURE__ */ j(
|
|
61
|
+
S,
|
|
62
62
|
{
|
|
63
63
|
noValidate: !0,
|
|
64
64
|
style: {
|
|
65
65
|
position: "relative"
|
|
66
66
|
},
|
|
67
|
-
config:
|
|
67
|
+
config: t,
|
|
68
68
|
formRef: c,
|
|
69
69
|
...m,
|
|
70
70
|
className: [o == null ? void 0 : o.classNames, m == null ? void 0 : m.className].filter(Boolean).join(" "),
|
|
71
|
-
onSubmit:
|
|
71
|
+
onSubmit: v,
|
|
72
72
|
children: [
|
|
73
|
-
|
|
74
|
-
(o == null ? void 0 : o.devTool)
|
|
75
|
-
|
|
73
|
+
C("top"),
|
|
74
|
+
(o == null ? void 0 : o.devTool) && /* @__PURE__ */ d(
|
|
75
|
+
_,
|
|
76
76
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...o == null ? void 0 : o.devTool
|
|
77
|
+
isDevelopment: t == null ? void 0 : t.isDevelopment,
|
|
78
|
+
props: typeof o.devTool == "object" ? o.devTool : void 0
|
|
80
79
|
}
|
|
81
80
|
),
|
|
82
|
-
|
|
81
|
+
l && /* @__PURE__ */ d(l, { ...i }),
|
|
83
82
|
f,
|
|
84
|
-
|
|
83
|
+
C("bottom")
|
|
85
84
|
]
|
|
86
85
|
}
|
|
87
86
|
);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import t from "./Form.mjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function
|
|
3
|
+
import f from "./RhfUtilsFormProviders.mjs";
|
|
4
|
+
import s from "./useRhfUtilsForm.mjs";
|
|
5
|
+
function h({
|
|
6
6
|
children: m,
|
|
7
7
|
...i
|
|
8
8
|
}) {
|
|
9
|
-
const r =
|
|
10
|
-
return /* @__PURE__ */ o(
|
|
9
|
+
const r = s(i);
|
|
10
|
+
return /* @__PURE__ */ o(f, { ...r.providerProps, children: /* @__PURE__ */ o(t, { ...r.formProps, children: m }) });
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
h as default
|
|
14
14
|
};
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useForm as
|
|
1
|
+
import m from "react";
|
|
2
|
+
import { useForm as d } from "react-hook-form";
|
|
3
3
|
import { FormSubmitError as F } from "../submit/error/FormSubmitError.mjs";
|
|
4
|
-
const
|
|
5
|
-
onSubmit:
|
|
4
|
+
const R = ({
|
|
5
|
+
onSubmit: e,
|
|
6
6
|
onSubmitError: f,
|
|
7
7
|
onSubmitInvalid: n,
|
|
8
8
|
defaultValues: p,
|
|
9
|
-
|
|
10
|
-
rhf:
|
|
11
|
-
form:
|
|
9
|
+
Children: c,
|
|
10
|
+
rhf: i,
|
|
11
|
+
form: u,
|
|
12
12
|
utils: s
|
|
13
13
|
}) => {
|
|
14
|
-
const o =
|
|
15
|
-
...
|
|
14
|
+
const o = m.useId(), t = d({
|
|
15
|
+
...i,
|
|
16
16
|
defaultValues: p
|
|
17
|
-
}), r =
|
|
17
|
+
}), r = m.useRef(null);
|
|
18
18
|
return {
|
|
19
19
|
id: o,
|
|
20
20
|
ref: r,
|
|
21
|
-
context:
|
|
21
|
+
context: t,
|
|
22
22
|
providerProps: {
|
|
23
23
|
formId: o,
|
|
24
24
|
formRef: r,
|
|
25
|
-
rhfForm:
|
|
25
|
+
rhfForm: t,
|
|
26
26
|
utils: s
|
|
27
27
|
},
|
|
28
28
|
formProps: {
|
|
29
|
-
|
|
30
|
-
onSubmit:
|
|
29
|
+
Children: c,
|
|
30
|
+
onSubmit: e,
|
|
31
31
|
onSubmitError: f,
|
|
32
32
|
onSubmitInvalid: n,
|
|
33
33
|
formId: o,
|
|
34
34
|
formRef: r,
|
|
35
|
-
form:
|
|
35
|
+
form: u,
|
|
36
36
|
utils: s
|
|
37
37
|
},
|
|
38
38
|
FormSubmitError: F
|
|
39
39
|
};
|
|
40
|
-
},
|
|
40
|
+
}, x = R;
|
|
41
41
|
export {
|
|
42
|
-
|
|
42
|
+
x as default
|
|
43
43
|
};
|
|
@@ -2,7 +2,7 @@ import { UseFormProps } from 'react-hook-form';
|
|
|
2
2
|
import { RhfUtilsErrorsOutputConfigContext, RhfUtilsErrorsOutputConsoleConfig } from '../../errors/output/types';
|
|
3
3
|
import { FormChildrenSlots } from '../../form/Form';
|
|
4
4
|
import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
|
|
5
|
-
import {
|
|
5
|
+
import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
|
|
6
6
|
import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -53,12 +53,12 @@ export type RhfUtilsClientConfig = {
|
|
|
53
53
|
onSubmitError?: (error: unknown) => FormSubmitErrors | undefined;
|
|
54
54
|
/**
|
|
55
55
|
* Components injected by slot across all forms.
|
|
56
|
-
* (Per-form injection can be done via
|
|
56
|
+
* (Per-form injection can be done via `Children` prop.)
|
|
57
57
|
*
|
|
58
58
|
* - `top`: e.g., block navigation on dirty form.
|
|
59
59
|
* - `bottom`: e.g., root errors list.
|
|
60
60
|
*/
|
|
61
|
-
Children?: Partial<Record<FormChildrenSlots, React.FC<
|
|
61
|
+
Children?: Partial<Record<FormChildrenSlots, React.FC<UseRhfUtilsFormChildrenProps>>>;
|
|
62
62
|
errors?: {
|
|
63
63
|
/**
|
|
64
64
|
* Configure how/if errors should be outputted.
|
|
@@ -2,7 +2,8 @@ import { Resolver } from 'react-hook-form';
|
|
|
2
2
|
import { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';
|
|
3
3
|
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
4
|
import { SafeFieldValues } from '../form/SafeFieldValues';
|
|
5
|
-
import {
|
|
5
|
+
import { UseRhfUtilsFormProps } from '../form/UseRhfUtilsFormProps';
|
|
6
|
+
import { UseRhfUtilsFormReturn } from '../form/UseRhfUtilsFormReturn';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Generic object schema type.
|
|
@@ -13,7 +14,7 @@ export type ObjectSchema<TInputKey extends string, TOutputKey extends string> =
|
|
|
13
14
|
[key in TOutputKey]: SafeFieldValues;
|
|
14
15
|
};
|
|
15
16
|
export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
|
|
16
|
-
useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey],
|
|
17
|
+
useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseRhfUtilsFormPropsForm extends UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput> = UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: Omit<UseRhfUtilsFormPropsForm, 'config'>) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {
|
|
17
18
|
FormWithProviders: React.FC<React.PropsWithChildren>;
|
|
18
19
|
};
|
|
19
20
|
FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RhfUtilsUseFormChildrenZodProps } from './RhfUtilsUseFormChildrenZodProps';
|
|
3
|
+
import { ZodTypeFieldValues } from './ZodTypeFieldValues';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link React.FC} for {@link RhfUtilsUseFormChildrenZodProps}.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const Children: RhfUtilsUseFormChildrenZodFC<typeof schema> = () => {};
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type RhfUtilsUseFormChildrenZodFC<TSchema extends ZodTypeFieldValues> = React.FC<RhfUtilsUseFormChildrenZodProps<TSchema>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
|
|
2
|
+
import { ZodTypeFieldValues } from './ZodTypeFieldValues';
|
|
3
|
+
|
|
4
|
+
export type RhfUtilsUseFormChildrenZodProps<TSchema extends ZodTypeFieldValues> = UseRhfUtilsFormChildrenProps<TSchema['_input'], TSchema['_output']>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ZodTypeFieldValues } from './
|
|
1
|
+
import { UseRhfUtilsFormProps } from '../../form/UseRhfUtilsFormProps';
|
|
2
|
+
import { ZodTypeFieldValues } from './ZodTypeFieldValues';
|
|
3
3
|
|
|
4
4
|
type Props<TSchema extends ZodTypeFieldValues> = {
|
|
5
5
|
schema: TSchema;
|
|
6
|
-
} & Omit<
|
|
6
|
+
} & Omit<UseRhfUtilsFormProps<TSchema['_input'], TSchema['_output']>, 'config'>;
|
|
7
7
|
declare function RhfUtilsZodForm<TSchema extends ZodTypeFieldValues>({ schema, ...props }: Props<TSchema>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default RhfUtilsZodForm;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as createRhfUtilsClientForZod } from '../createRhfUtilsClientForZod';
|
|
2
2
|
|
|
3
3
|
export type RhfUtilsClientForZodContext = ReturnType<typeof createRhfUtilsClientForZod>;
|
|
4
|
-
declare const useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<import('../
|
|
4
|
+
declare const useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output">, _RhfUtilsClientForZodContextProvider: import('react').Provider<import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output"> | undefined>;
|
|
5
5
|
export default useRhfUtilsClientForZodContext;
|
|
6
6
|
export { _RhfUtilsClientForZodContextProvider };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ZodTypeFieldValues } from '../
|
|
1
|
+
import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
|
|
2
|
+
import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
|
|
3
3
|
|
|
4
|
-
declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: Omit<
|
|
4
|
+
declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: Omit<UseRhfUtilsFormProps<TSchema['_input'], TSchema['_output']>, 'config'>) => import('../../../form/UseRhfUtilsFormReturn').UseRhfUtilsFormReturn<TSchema["_input"], TSchema["_output"]> & {
|
|
5
5
|
FormWithProviders: import('react').FC<{
|
|
6
6
|
children?: import('react').ReactNode;
|
|
7
7
|
}>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
1
|
+
import { ZodTypeFieldValues } from './ZodTypeFieldValues';
|
|
3
2
|
|
|
4
|
-
export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
|
|
5
3
|
declare const createRhfUtilsClientForZod: (config: import('../config/RhfUtilsClientConfig').RhfUtilsClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
|
|
6
4
|
export default createRhfUtilsClientForZod;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type LazyDevToolProps = {
|
|
5
5
|
isDevelopment?: boolean;
|
|
6
|
+
props?: Omit<DevtoolUIProps, 'control'>;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* Lazy-loaded RHF DevTool.
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export type { RhfUtilsClientConfig } from './client/config/RhfUtilsClientConfig'
|
|
|
3
3
|
export { default as RhfUtilsClientForZodContextProvider } from './client/zod/context/RhfUtilsClientForZodContextProvider';
|
|
4
4
|
export { default as useRhfUtilsClientForZodContext } from './client/zod/context/useRhfUtilsClientForZodContext';
|
|
5
5
|
export { default as useRhfUtilsZodForm } from './client/zod/context/useRhfUtilsZodForm';
|
|
6
|
+
export type { RhfUtilsUseFormChildrenZodFC } from './client/zod/RhfUtilsUseFormChildrenZodFC';
|
|
7
|
+
export type { RhfUtilsUseFormChildrenZodProps } from './client/zod/RhfUtilsUseFormChildrenZodProps';
|
|
6
8
|
export { default as RhfUtilsZodForm } from './client/zod/RhfUtilsZodForm';
|
|
7
|
-
export type { UseFormFieldsZodProps } from './client/zod/UseFormFieldsZodProps';
|
|
8
9
|
export { default as LazyDevTool } from './devtool/LazyDevTool';
|
|
9
10
|
export { default as useFlatFieldErrorsContext } from './errors/flat/context/useFlatFieldErrorsContext';
|
|
10
11
|
export { default as FlatFieldErrorsList } from './errors/flat/FlatFieldErrorsList';
|
|
@@ -23,8 +24,8 @@ export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
|
23
24
|
export { default as FormWithProviders } from './form/FormWithProviders';
|
|
24
25
|
export type { RhfUtilsFormOptions } from './form/RhfUtilsFormOptions';
|
|
25
26
|
export type { SafeFieldValues } from './form/SafeFieldValues';
|
|
26
|
-
export
|
|
27
|
-
export {
|
|
27
|
+
export { default as useRhfUtilsForm } from './form/useRhfUtilsForm';
|
|
28
|
+
export type { UseRhfUtilsFormChildrenProps } from './form/UseRhfUtilsFormChildrenProps';
|
|
28
29
|
export { default as useFormUtilsContext } from './form/context/utils/useFormUtilsContext';
|
|
29
30
|
export { default as FormGroupContextProvider } from './form/context/group/FormGroupContextProvider';
|
|
30
31
|
export { default as useFormGroupChildIsMountedTracker } from './form/context/group/useFormGroupChildIsMountedTracker';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import {
|
|
3
|
+
import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
|
|
4
4
|
|
|
5
5
|
export type FormChildrenSlots = 'top' | 'bottom';
|
|
6
6
|
export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
7
7
|
formId: string;
|
|
8
8
|
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
-
} & Pick<
|
|
10
|
-
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid,
|
|
9
|
+
} & Pick<UseRhfUtilsFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Children' | 'form' | 'utils'>>;
|
|
10
|
+
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Children, form, utils, children, }: FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export default _Form;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
|
-
import {
|
|
2
|
+
import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
|
|
3
3
|
|
|
4
|
-
export type FormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<
|
|
4
|
+
export type FormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<UseRhfUtilsFormProps<TFieldValues, TTransformedValues>>;
|
|
5
5
|
/**
|
|
6
6
|
* Form providers (with utils) with immediate descendent {@link Form}.
|
|
7
|
-
* (Syntactic sugar for {@link
|
|
7
|
+
* (Syntactic sugar for {@link useRhfUtilsForm}. Use this for most applications.)
|
|
8
8
|
*
|
|
9
|
-
* Use {@link
|
|
9
|
+
* Use {@link useRhfUtilsForm} if you need to specific nesting hierarchy.
|
|
10
10
|
* (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)
|
|
11
11
|
*/
|
|
12
12
|
declare function FormWithProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ children, ...props }: FormWithProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,8 +21,8 @@ export type RhfUtilsFormOptions = {
|
|
|
21
21
|
stopSubmitPropagation?: boolean;
|
|
22
22
|
/** Reset form after successful submit. */
|
|
23
23
|
resetFormAfterSubmitSuccessful?: Parameters<typeof useResetFormAfterSubmitSuccessful>[0];
|
|
24
|
-
/** Control dev tool options. */
|
|
25
|
-
devTool?: Pick<DevtoolUIProps, 'placement' | 'styles'
|
|
24
|
+
/** Control dev tool options. (Lazy-loaded when `isDevelopment` is `true` and truthy value supplied. Zero bundle size in prod.) */
|
|
25
|
+
devTool?: true | Pick<DevtoolUIProps, 'placement' | 'styles'>;
|
|
26
26
|
} & (Register extends {
|
|
27
27
|
RhfUtilsFormOptions: infer _RhfUtilsFormOptions;
|
|
28
28
|
} ? _RhfUtilsFormOptions : {});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
|
|
3
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
4
|
+
|
|
5
|
+
export type RhfUtilsFormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
6
|
+
formId: string;
|
|
7
|
+
formRef: React.RefObject<HTMLFormElement>;
|
|
8
|
+
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
|
+
utils?: RhfUtilsFormOptions;
|
|
10
|
+
}>;
|
|
11
|
+
declare function RhfUtilsFormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, rhfForm, utils, children, }: RhfUtilsFormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default RhfUtilsFormProviders;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { default as _Controller } from './_Controller';
|
|
4
|
+
import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
|
|
5
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
6
|
+
|
|
7
|
+
export type UseRhfUtilsFormChildrenProps<TFieldValues extends SafeFieldValues = SafeFieldValues, TTransformedValues extends SafeFieldValues = SafeFieldValues> = {
|
|
8
|
+
formId: string;
|
|
9
|
+
formRef: React.RefObject<HTMLFormElement>;
|
|
10
|
+
context: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
11
|
+
utils?: RhfUtilsFormOptions;
|
|
12
|
+
Controller: typeof _Controller<TFieldValues>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SubmitErrorHandler, UseFormProps, UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
|
|
4
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
5
|
+
import { UseRhfUtilsFormChildrenProps } from './UseRhfUtilsFormChildrenProps';
|
|
6
|
+
|
|
7
|
+
export type UseRhfUtilsFormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
|
|
8
|
+
onSubmit?: (values: TTransformedValues, context: UseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => unknown | Promise<unknown>;
|
|
9
|
+
/** Submit error handler. (Only for errors not of instance `FormError`, which are handled internally.) */
|
|
10
|
+
onSubmitError?: (error: unknown, context: UseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
|
|
11
|
+
/** Submit handler when form is invalid. */
|
|
12
|
+
onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
|
|
13
|
+
defaultValues?: UseFormProps<TFieldValues>['defaultValues'];
|
|
14
|
+
Children?: React.FC<UseRhfUtilsFormChildrenProps<TFieldValues, TTransformedValues>>;
|
|
15
|
+
/** {@link RhfUseFormProps} props for RHF's {@link useForm}. */
|
|
16
|
+
rhf?: Omit<UseFormProps<TFieldValues>, 'defaultValues'>;
|
|
17
|
+
/** {@link FormProps} props for Form. */
|
|
18
|
+
form?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
|
|
19
|
+
/** {@link RhfUtilsFormOptions} to enabled utils functionality. */
|
|
20
|
+
utils?: RhfUtilsFormOptions;
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
4
|
+
import { FormProps } from './Form';
|
|
5
|
+
import { RhfUtilsFormProvidersProps } from './RhfUtilsFormProviders';
|
|
6
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
7
|
+
|
|
8
|
+
export type UseRhfUtilsFormReturn<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
|
|
9
|
+
id: string;
|
|
10
|
+
ref: React.RefObject<HTMLFormElement>;
|
|
11
|
+
context: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
12
|
+
providerProps: RhfUtilsFormProvidersProps<TFieldValues, TTransformedValues>;
|
|
13
|
+
formProps: FormProps<TFieldValues, TTransformedValues>;
|
|
14
|
+
FormSubmitError: typeof FormSubmitError<TFieldValues>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
|
+
import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
|
|
3
|
+
import { UseRhfUtilsFormReturn } from './UseRhfUtilsFormReturn';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Core Rhf Form hook. Use `Form` in `index.ts` for most cases.
|
|
7
|
+
* Use this if you need to separate form components.
|
|
8
|
+
* e.g., a form for table row due to `form` being considered invalid HTML around `tr` tags.
|
|
9
|
+
* With this hook, you can wrap the `tr` tag with `form.Provider` and use `form.Form` inside
|
|
10
|
+
* one of the cells. Other components can be outside form while referring to form by its id via `form` attribute.
|
|
11
|
+
* see https://caniuse.com/?search=form%20attribute
|
|
12
|
+
* @returns Form provider and form.
|
|
13
|
+
*/
|
|
14
|
+
declare const useRhfUtilsForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ onSubmit, onSubmitError, onSubmitInvalid, defaultValues, Children, rhf, form, utils, }: UseRhfUtilsFormProps<TFieldValues, TTransformedValues>) => UseRhfUtilsFormReturn<TFieldValues, TTransformedValues>;
|
|
15
|
+
export default useRhfUtilsForm;
|
|
16
|
+
export type UseRhfUtilsForm<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = typeof useRhfUtilsForm<TFieldValues, TTransformedValues>;
|
package/package.json
CHANGED
|
File without changes
|