@paragrav/rhf-utils 0.0.117 → 0.0.119
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 +40 -37
- package/dist/esm/client/index.mjs +33 -34
- package/dist/esm/form/Form.mjs +56 -72
- package/dist/esm/form/FormWithProviders.mjs +7 -10
- package/dist/types/client/config/RhfUtilsClientConfig.d.ts +13 -9
- package/dist/types/form/Form.d.ts +3 -3
- package/dist/types/form/FormWithProviders.d.ts +1 -1
- package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -5
- package/dist/types/form/UseRhfUtilsFormProps.d.ts +3 -3
- package/package.json +1 -1
- package/dist/esm/form/_FormBase.mjs +0 -11
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ To configure, create a file `config.tsx` with desired configuration settings. Th
|
|
|
16
16
|
export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
|
|
17
17
|
// defaults -- overridable per form instance
|
|
18
18
|
defaults: {
|
|
19
|
-
// globally
|
|
19
|
+
// globally-relevant subset of RHF's `UseFormProps` options
|
|
20
20
|
rhf: {
|
|
21
21
|
mode: 'onBlur',
|
|
22
22
|
},
|
|
@@ -26,54 +26,62 @@ export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
|
|
|
26
26
|
// enable dev tool on dev env
|
|
27
27
|
devTool: import.meta.env.DEV,
|
|
28
28
|
},
|
|
29
|
+
|
|
30
|
+
// default form props
|
|
31
|
+
form: {
|
|
32
|
+
noValidate: true,
|
|
33
|
+
className: 'my-form-class',
|
|
34
|
+
},
|
|
29
35
|
},
|
|
30
36
|
|
|
31
37
|
// optional (defaults to primitive HTML form)
|
|
32
38
|
FormComponent: Form.Root,
|
|
33
39
|
|
|
40
|
+
// optional wrapper to inject your own hooks and components
|
|
41
|
+
// `children` prop is provided by RhfUtilsZodForm's Children prop
|
|
42
|
+
FormChildren: (
|
|
43
|
+
// UseRhfUtilsFormChildrenProps
|
|
44
|
+
{
|
|
45
|
+
formId, // unique id string
|
|
46
|
+
formRef, // ref
|
|
47
|
+
context, // rhf UseFormReturn
|
|
48
|
+
options, // RhfUtilsFormOptions
|
|
49
|
+
Controller, // strictly-typed controller
|
|
50
|
+
FormSubmitError, // strictly-typed error class
|
|
51
|
+
children, // RhfUtilsZodForm.Children
|
|
52
|
+
},
|
|
53
|
+
) => {
|
|
54
|
+
// navigation blocker (using custom option)
|
|
55
|
+
useFormRouterBlocker(!!options?.prompter);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
{/* specific form children -- e.g., fields, etc. */}
|
|
60
|
+
{children}
|
|
61
|
+
|
|
62
|
+
{/* global error list */}
|
|
63
|
+
<RootErrorsListFromFlatFieldErrorsContext />
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
|
|
34
68
|
// non-FormSubmitError throw in onSubmit
|
|
35
|
-
// use case: transform backend error
|
|
69
|
+
// example use case: transform backend error
|
|
36
70
|
onSubmitUnknownError: (
|
|
37
71
|
error, // unknown
|
|
38
72
|
) => {
|
|
39
73
|
// if other error, re-throw to handle in ErrorBoundary
|
|
40
74
|
if (!(error instanceof MyServerError)) throw error;
|
|
41
75
|
|
|
42
|
-
// return to be merged into RHF context errors
|
|
76
|
+
// return FormSubmitErrors object to be merged into RHF context errors
|
|
43
77
|
return transformServerErrorToFormSubmitErrors(error);
|
|
44
78
|
},
|
|
45
79
|
|
|
46
|
-
Children: {
|
|
47
|
-
top: (
|
|
48
|
-
// UseRhfUtilsFormChildrenProps
|
|
49
|
-
{
|
|
50
|
-
formId, // unique id string
|
|
51
|
-
formRef, // ref
|
|
52
|
-
context, // rhf UseFormReturn
|
|
53
|
-
options, // RhfUtilsFormOptions
|
|
54
|
-
Controller, // strictly-typed controller
|
|
55
|
-
FormSubmitError, // strictly-typed error class
|
|
56
|
-
},
|
|
57
|
-
) => {
|
|
58
|
-
// navigation blocker (using custom option)
|
|
59
|
-
useFormRouterBlocker(!!options?.prompter);
|
|
60
|
-
|
|
61
|
-
return null;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
bottom: () => (
|
|
65
|
-
<>
|
|
66
|
-
{/* global error list */}
|
|
67
|
-
<RootErrorsListFromFlatFieldErrorsContext />
|
|
68
|
-
</>
|
|
69
|
-
),
|
|
70
|
-
},
|
|
71
|
-
|
|
72
80
|
errors: {
|
|
73
81
|
output: {
|
|
74
82
|
// callback to determine when to output form context errors to console ("debug" or "error")
|
|
75
83
|
console: ({ hasOrphans }) =>
|
|
76
|
-
(hasOrphans && { type: 'error' }) || //
|
|
84
|
+
(hasOrphans && { type: 'error' }) || // console error for reporting on prod
|
|
77
85
|
(import.meta.env.DEV && { type: 'debug' }), // facilitate debugging on dev
|
|
78
86
|
|
|
79
87
|
// callback to determine when to throw an error based on context
|
|
@@ -159,9 +167,9 @@ function Children({...}: RhfUtilsUseFormChildrenZodProps<typeof schema>) { }
|
|
|
159
167
|
|
|
160
168
|
## `FormSubmitError`
|
|
161
169
|
|
|
162
|
-
This is an `Error`-based class you can use to throw a structured error in your submit handler. It is strictly-typed, so it only allows field names
|
|
170
|
+
This is an `Error`-based class you can use to throw a structured error in your submit handler. It is strictly-typed, so it only allows field names from your schema and `root`/`root.{string}` keys.
|
|
163
171
|
|
|
164
|
-
It uses `FormSubmitErrors`
|
|
172
|
+
It uses `FormSubmitErrors` type's structure, which is a flat, simplified version of RHF's `FieldErrors`.
|
|
165
173
|
|
|
166
174
|
Example:
|
|
167
175
|
|
|
@@ -189,11 +197,6 @@ These options can be set globally and/or per form.
|
|
|
189
197
|
|
|
190
198
|
```ts
|
|
191
199
|
type RhfUtilsFormOptions = {
|
|
192
|
-
/**
|
|
193
|
-
* Style via your own classes.
|
|
194
|
-
*/
|
|
195
|
-
classNames?: string[];
|
|
196
|
-
|
|
197
200
|
/** Request submit via listener on form change. */
|
|
198
201
|
submitOnChange?: boolean;
|
|
199
202
|
|
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const m =
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import a from "../form/FormWithProviders.mjs";
|
|
3
|
+
import F from "../form/useRhfUtilsForm.mjs";
|
|
4
|
+
const v = (e) => (r) => {
|
|
5
|
+
const m = d(e, r);
|
|
6
6
|
return {
|
|
7
|
-
useForm: (
|
|
8
|
-
const
|
|
7
|
+
useForm: (s, t) => {
|
|
8
|
+
const o = m(s, t);
|
|
9
9
|
return {
|
|
10
|
-
...
|
|
11
|
-
FormWithProviders: ({
|
|
12
|
-
children: o
|
|
13
|
-
}) => /* @__PURE__ */ h(f, { ...t, children: o })
|
|
10
|
+
...F(o),
|
|
11
|
+
FormWithProviders: () => /* @__PURE__ */ u(a, { ...o })
|
|
14
12
|
};
|
|
15
13
|
},
|
|
16
|
-
FormWithProviders:
|
|
14
|
+
FormWithProviders: P(e, r)
|
|
17
15
|
};
|
|
18
|
-
},
|
|
19
|
-
var
|
|
16
|
+
}, d = (e, r) => function(s, t) {
|
|
17
|
+
var o, i, f, l, n, h;
|
|
20
18
|
return {
|
|
21
|
-
...
|
|
19
|
+
...t,
|
|
22
20
|
rhf: {
|
|
23
|
-
...(
|
|
24
|
-
...
|
|
25
|
-
resolver: e(
|
|
21
|
+
...(o = r.defaults) == null ? void 0 : o.rhf,
|
|
22
|
+
...t.rhf,
|
|
23
|
+
resolver: e(s)
|
|
26
24
|
},
|
|
27
25
|
utils: {
|
|
28
|
-
...(
|
|
29
|
-
...
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
...(i = r.defaults) == null ? void 0 : i.utils,
|
|
27
|
+
...t.utils
|
|
28
|
+
},
|
|
29
|
+
form: {
|
|
30
|
+
...(f = r.defaults) == null ? void 0 : f.form,
|
|
31
|
+
...t.form,
|
|
32
|
+
className: [(n = (l = r.defaults) == null ? void 0 : l.form) == null ? void 0 : n.className, (h = t.form) == null ? void 0 : h.className].filter(Boolean).join(" ")
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
|
-
},
|
|
37
|
-
schema:
|
|
38
|
-
children:
|
|
39
|
-
...
|
|
35
|
+
}, P = (e, r) => function({
|
|
36
|
+
schema: s,
|
|
37
|
+
children: t,
|
|
38
|
+
...o
|
|
40
39
|
}) {
|
|
41
|
-
const
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
|
|
40
|
+
const i = d(e, r);
|
|
41
|
+
return /* @__PURE__ */ u(
|
|
42
|
+
a,
|
|
44
43
|
{
|
|
45
|
-
...
|
|
46
|
-
children:
|
|
44
|
+
...i(s, o),
|
|
45
|
+
children: t
|
|
47
46
|
}
|
|
48
47
|
);
|
|
49
48
|
};
|
|
50
49
|
export {
|
|
51
|
-
|
|
50
|
+
v as createRhfUtilsClient
|
|
52
51
|
};
|
package/dist/esm/form/Form.mjs
CHANGED
|
@@ -1,98 +1,82 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsx as a, jsxs as v, Fragment as E } 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
formRef: m,
|
|
3
|
+
import { useFormContext as P } from "react-hook-form";
|
|
4
|
+
import w from "../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
5
|
+
import S from "../devtool/LazyDevTool.mjs";
|
|
6
|
+
import { FormSubmitError as h } from "../submit/error/FormSubmitError.mjs";
|
|
7
|
+
import U from "../submit/error/setCtxErrorsByFormSubmitErrors.mjs";
|
|
8
|
+
import _ from "./_Controller.mjs";
|
|
9
|
+
function G({
|
|
10
|
+
formId: n,
|
|
11
|
+
formRef: p,
|
|
13
12
|
//
|
|
14
13
|
onSubmit: c,
|
|
15
|
-
onSubmitError:
|
|
16
|
-
onSubmitInvalid:
|
|
17
|
-
Children:
|
|
14
|
+
onSubmitError: d,
|
|
15
|
+
onSubmitInvalid: F,
|
|
16
|
+
Children: i,
|
|
18
17
|
//
|
|
19
|
-
form:
|
|
20
|
-
utils: o
|
|
21
|
-
//
|
|
22
|
-
children: i
|
|
18
|
+
form: l,
|
|
19
|
+
utils: o
|
|
23
20
|
}) {
|
|
24
|
-
const
|
|
21
|
+
const e = P(), r = w(), y = async (t) => {
|
|
25
22
|
o != null && o.stopSubmitPropagation && t.stopPropagation();
|
|
26
23
|
try {
|
|
27
|
-
await
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
24
|
+
await e.handleSubmit(f, F)(t);
|
|
25
|
+
} catch (m) {
|
|
26
|
+
b(m, t);
|
|
30
27
|
}
|
|
31
|
-
},
|
|
28
|
+
}, f = (t, m) => c == null ? void 0 : c(
|
|
32
29
|
t,
|
|
33
30
|
{
|
|
34
|
-
formId:
|
|
35
|
-
formRef:
|
|
36
|
-
context:
|
|
31
|
+
formId: n,
|
|
32
|
+
formRef: p,
|
|
33
|
+
context: e,
|
|
37
34
|
utils: o,
|
|
38
|
-
FormSubmitError:
|
|
35
|
+
FormSubmitError: h
|
|
39
36
|
},
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
var
|
|
43
|
-
const
|
|
37
|
+
m
|
|
38
|
+
), b = (t, m) => {
|
|
39
|
+
var x;
|
|
40
|
+
const C = t instanceof h ? (
|
|
44
41
|
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
45
42
|
t.errors
|
|
46
43
|
) : (
|
|
47
44
|
// if error is not FormSubmitError, consumer can provide global handler
|
|
48
|
-
(
|
|
45
|
+
(x = r == null ? void 0 : r.onSubmitUnknownError) == null ? void 0 : x.call(r, t)
|
|
49
46
|
);
|
|
50
|
-
|
|
47
|
+
C && U(e, C), d == null || d(
|
|
51
48
|
t,
|
|
52
49
|
{
|
|
53
|
-
formId:
|
|
54
|
-
formRef:
|
|
55
|
-
context:
|
|
50
|
+
formId: n,
|
|
51
|
+
formRef: p,
|
|
52
|
+
context: e,
|
|
56
53
|
utils: o
|
|
57
54
|
},
|
|
58
|
-
|
|
55
|
+
m
|
|
59
56
|
);
|
|
60
|
-
},
|
|
61
|
-
formId:
|
|
62
|
-
formRef:
|
|
63
|
-
context:
|
|
57
|
+
}, s = {
|
|
58
|
+
formId: n,
|
|
59
|
+
formRef: p,
|
|
60
|
+
context: e,
|
|
64
61
|
utils: o,
|
|
65
|
-
Controller:
|
|
66
|
-
FormSubmitError:
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
y("top"),
|
|
83
|
-
(o == null ? void 0 : o.devTool) && /* @__PURE__ */ d(
|
|
84
|
-
P,
|
|
85
|
-
{
|
|
86
|
-
props: typeof o.devTool == "object" ? o.devTool : void 0
|
|
87
|
-
}
|
|
88
|
-
),
|
|
89
|
-
h && /* @__PURE__ */ d(h, { ...l }),
|
|
90
|
-
i,
|
|
91
|
-
y("bottom")
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
);
|
|
62
|
+
Controller: _,
|
|
63
|
+
FormSubmitError: h
|
|
64
|
+
}, T = (r == null ? void 0 : r.FormComponent) ?? "form", j = (r == null ? void 0 : r.FormChildren) ?? k;
|
|
65
|
+
return /* @__PURE__ */ a(T, { ...l, ref: p, onSubmit: y, children: /* @__PURE__ */ v(j, { ...s, children: [
|
|
66
|
+
(o == null ? void 0 : o.devTool) && /* @__PURE__ */ a(
|
|
67
|
+
S,
|
|
68
|
+
{
|
|
69
|
+
props: typeof o.devTool == "object" ? o.devTool : void 0
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ a(i, { ...s })
|
|
73
|
+
] }) });
|
|
74
|
+
}
|
|
75
|
+
function k({
|
|
76
|
+
children: n
|
|
77
|
+
}) {
|
|
78
|
+
return /* @__PURE__ */ a(E, { children: n });
|
|
95
79
|
}
|
|
96
80
|
export {
|
|
97
|
-
|
|
81
|
+
G as default
|
|
98
82
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
...i
|
|
8
|
-
}) {
|
|
9
|
-
const r = s(i);
|
|
10
|
-
return /* @__PURE__ */ o(f, { ...r.providerProps, children: /* @__PURE__ */ o(t, { ...r.formProps, children: m }) });
|
|
2
|
+
import i from "./Form.mjs";
|
|
3
|
+
import t from "./RhfUtilsFormProviders.mjs";
|
|
4
|
+
import f from "./useRhfUtilsForm.mjs";
|
|
5
|
+
function n(m) {
|
|
6
|
+
const r = f(m);
|
|
7
|
+
return /* @__PURE__ */ o(t, { ...r.providerProps, children: /* @__PURE__ */ o(i, { ...r.formProps }) });
|
|
11
8
|
}
|
|
12
9
|
export {
|
|
13
|
-
|
|
10
|
+
n as default
|
|
14
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UseFormProps } from 'react-hook-form';
|
|
2
2
|
import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
|
|
3
|
-
import { FormChildrenSlots } from '../../form/Form';
|
|
4
3
|
import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
|
|
4
|
+
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
5
5
|
import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
|
|
6
6
|
import { FormSubmitErrors } from '../../submit/error/FormSubmitErrors';
|
|
7
7
|
|
|
@@ -27,6 +27,10 @@ export type RhfUtilsClientConfig = {
|
|
|
27
27
|
* (Extend this type via `Register` type to inject custom options/functionality via `Children` component.)
|
|
28
28
|
*/
|
|
29
29
|
utils?: RhfUtilsFormOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Default props for form element.
|
|
32
|
+
*/
|
|
33
|
+
form?: Omit<React.PropsWithoutRef<JSX.IntrinsicElements['form']>, 'onSubmit'>;
|
|
30
34
|
};
|
|
31
35
|
/**
|
|
32
36
|
* Supply your own `<form>` component.
|
|
@@ -34,6 +38,14 @@ export type RhfUtilsClientConfig = {
|
|
|
34
38
|
* By default, a primitive `<form>` element is used.
|
|
35
39
|
*/
|
|
36
40
|
FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
|
|
41
|
+
/**
|
|
42
|
+
* Wrap all form bodies with your own hooks, components, etc.
|
|
43
|
+
*
|
|
44
|
+
* Use cases:
|
|
45
|
+
* - custom hooks/behaviors based on `options`
|
|
46
|
+
* - shared header, footer
|
|
47
|
+
*/
|
|
48
|
+
FormChildren?: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>(props: React.PropsWithChildren<UseRhfUtilsFormChildrenProps<TFieldValues, TTransformedValues>>) => React.ReactNode;
|
|
37
49
|
/**
|
|
38
50
|
* Global submit error handler when/if submit handler throws an error other than {@link FormSubmitError}.
|
|
39
51
|
*
|
|
@@ -45,14 +57,6 @@ export type RhfUtilsClientConfig = {
|
|
|
45
57
|
* - if `undefined`: do nothing.
|
|
46
58
|
*/
|
|
47
59
|
onSubmitUnknownError?: (error: unknown) => FormSubmitErrors | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Components injected by slot across all forms.
|
|
50
|
-
* (Per-form injection can be done via `Children` prop.)
|
|
51
|
-
*
|
|
52
|
-
* - `top`: e.g., block navigation on dirty form.
|
|
53
|
-
* - `bottom`: e.g., root errors list.
|
|
54
|
-
*/
|
|
55
|
-
Children?: Partial<Record<FormChildrenSlots, React.FC<UseRhfUtilsFormChildrenProps>>>;
|
|
56
60
|
errors?: {
|
|
57
61
|
/**
|
|
58
62
|
* Configure how/if errors should be outputted.
|
|
@@ -3,9 +3,9 @@ import { SafeFieldValues } from './SafeFieldValues';
|
|
|
3
3
|
import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
|
|
4
4
|
|
|
5
5
|
export type FormChildrenSlots = 'top' | 'bottom';
|
|
6
|
-
export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> =
|
|
6
|
+
export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
|
|
7
7
|
formId: string;
|
|
8
8
|
formRef: React.RefObject<HTMLFormElement>;
|
|
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,
|
|
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, }: FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export default _Form;
|
|
@@ -9,5 +9,5 @@ export type FormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransf
|
|
|
9
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
|
-
declare function FormWithProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>(
|
|
12
|
+
declare function FormWithProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>(props: FormWithProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default FormWithProviders;
|
|
@@ -8,11 +8,6 @@ import { Register } from '../register';
|
|
|
8
8
|
* Can be extended using {@link Register.RhfUtilsFormOptions}.
|
|
9
9
|
*/
|
|
10
10
|
export type RhfUtilsFormOptions = {
|
|
11
|
-
/**
|
|
12
|
-
* Style via your own classes.
|
|
13
|
-
* (Defaults merged with individual class names.)
|
|
14
|
-
*/
|
|
15
|
-
classNames?: string[];
|
|
16
11
|
/** Request submit via listener on form change. */
|
|
17
12
|
submitOnChange?: boolean;
|
|
18
13
|
/** Reset form values if submit throw errors. (Use case: optimistic UI toggle form that submits on each change.) */
|
|
@@ -12,11 +12,11 @@ export type UseRhfUtilsFormProps<TFieldValues extends SafeFieldValues, TTransfor
|
|
|
12
12
|
/** Submit handler when form is invalid. */
|
|
13
13
|
onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
|
|
14
14
|
defaultValues?: UseFormProps<TFieldValues>['defaultValues'];
|
|
15
|
-
Children
|
|
15
|
+
Children: React.FC<UseRhfUtilsFormChildrenProps<TFieldValues, TTransformedValues>>;
|
|
16
16
|
/** {@link RhfUseFormProps} props for RHF's {@link useForm}. */
|
|
17
17
|
rhf?: Omit<UseFormProps<TFieldValues>, 'defaultValues'>;
|
|
18
|
-
/** {@link FormProps} props for Form. */
|
|
19
|
-
form?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
|
|
20
18
|
/** {@link RhfUtilsFormOptions} to enabled utils functionality. */
|
|
21
19
|
utils?: RhfUtilsFormOptions;
|
|
20
|
+
/** {@link FormProps} props for Form. */
|
|
21
|
+
form?: Omit<React.PropsWithoutRef<JSX.IntrinsicElements['form']>, 'onSubmit'>;
|
|
22
22
|
};
|
package/package.json
CHANGED