@paragrav/rhf-utils 0.0.118 → 0.0.120

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # README
2
2
 
3
+ ## About
4
+
5
+ Integration and utility library for react-hook-form.
6
+
3
7
  ## Install
4
8
 
5
9
  ```sh
@@ -14,25 +18,32 @@ To configure, create a file `config.tsx` with desired configuration settings. Th
14
18
 
15
19
  ```tsx
16
20
  export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
17
- // defaults -- overridable per form instance
21
+ // overridable per form instance
18
22
  defaults: {
19
- // globally relevant subset of RHF's `UseFormProps` options
23
+ // globally-relevant subset of RHF's `UseFormProps` options
20
24
  rhf: {
21
- mode: 'onBlur',
25
+ mode: 'onSubmit',
22
26
  },
23
27
 
24
28
  // RhfUtilsFormOptions (see further below)
25
29
  utils: {
26
- // enable dev tool on dev env
30
+ stopSubmitPropagation: true,
27
31
  devTool: import.meta.env.DEV,
28
32
  },
33
+
34
+ // default form props
35
+ form: {
36
+ noValidate: true,
37
+ className: 'my-form-class',
38
+ },
29
39
  },
30
40
 
31
41
  // optional (defaults to primitive HTML form)
32
42
  FormComponent: Form.Root,
33
43
 
34
44
  // optional wrapper to inject your own hooks and components
35
- // `children` prop is provided by RhfUtilsZodForm's Children prop
45
+ // around all RhfUtilsZodForm instances
46
+ // (see further below for more info)
36
47
  FormChildren: (
37
48
  // UseRhfUtilsFormChildrenProps
38
49
  {
@@ -42,32 +53,32 @@ export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
42
53
  options, // RhfUtilsFormOptions
43
54
  Controller, // strictly-typed controller
44
55
  FormSubmitError, // strictly-typed error class
45
- children, // RhfUtilsZodForm.Children
56
+ children, // RhfUtilsZodForm's Children instance
46
57
  },
47
58
  ) => {
48
- // navigation blocker (using custom option)
49
- useFormRouterBlocker(!!options?.prompter);
59
+ // your navigation blocker (using custom option prop -- see "Extend RhfUtilsFormOptions" section)
60
+ useMyFormNavigationPrompt(!!options?.enableMyFormNavigationPrompt);
50
61
 
51
62
  return (
52
63
  <>
53
- {/* specific form children -- e.g., fields, etc. */}
64
+ {/* RhfUtilsZodForm Children outlet */}
54
65
  {children}
55
66
 
56
- {/* global error list */}
57
- <RootErrorsListFromFlatFieldErrorsContext />
67
+ {/* root errors list */}
68
+ <RootErrorsList />
58
69
  </>
59
70
  );
60
71
  },
61
72
 
62
- // non-FormSubmitError throw in onSubmit
63
- // example use case: transform backend error
73
+ // non-FormSubmitError thrown in onSubmit
74
+ // use case: catch backend error and transform data for frontend
64
75
  onSubmitUnknownError: (
65
76
  error, // unknown
66
77
  ) => {
67
78
  // if other error, re-throw to handle in ErrorBoundary
68
79
  if (!(error instanceof MyServerError)) throw error;
69
80
 
70
- // return FormSubmitErrors object to be merged into RHF context errors
81
+ // return FormSubmitErrors object to be merged to RHF context errors
71
82
  return transformServerErrorToFormSubmitErrors(error);
72
83
  },
73
84
 
@@ -101,26 +112,26 @@ Currently, only `zod` is supported.
101
112
 
102
113
  ```tsx
103
114
  <RhfUtilsZodForm
104
- schema={authLoginFormSchema}
115
+ schema={loginFormSchema}
105
116
  defaultValues={{
106
117
  email: '',
107
118
  }}
108
119
  // submit handler
109
120
  onSubmit={async (
110
121
  data, // schema output
111
- context, // UseRhfUtilsFormOnSubmitContext (form id, form ref, context (rhf), utils options, strictly-typed FormSubmitError class)
122
+ context, // UseRhfUtilsFormOnSubmitContext (id, ref, rhf context, utils options, strictly-typed FormSubmitError class)
112
123
  event, // SubmitEvent
113
124
  ) => {
114
125
  await authLoginService(data);
115
- onSuccess();
126
+ props.onSuccess();
116
127
  }}
117
128
  // handle error declaratively (i.e., no throw/catch)
118
129
  onSubmitError={({
119
130
  error, // unknown
120
- context, // UseRhfUtilsFormOnSubmitErrorContext (form id, form ref, context (rhf), utils options)
131
+ context, // UseRhfUtilsFormOnSubmitErrorContext (id, ref, rhf context, utils options)
121
132
  event, // SubmitEvent
122
133
  }) => {
123
- onError(error);
134
+ props.onError(error);
124
135
  }}
125
136
  // fields
126
137
  Children={({
@@ -146,6 +157,19 @@ Currently, only `zod` is supported.
146
157
  <button type="submit">Login</button>
147
158
  </>
148
159
  )}
160
+ // options/overrides
161
+ rhf={{
162
+ mode: 'onBlur',
163
+ }}
164
+ utils={{
165
+ submitOnChange: true,
166
+ resetValuesOnSubmitError: true,
167
+ enableMyFormNavigationPrompt: true, // custom option prop (see "Extend RhfUtilsFormOptions" section)
168
+ }}
169
+ form={{
170
+ // class names are merged together with global defaults
171
+ className: 'my-special-form-class',
172
+ }}
149
173
  />
150
174
  ```
151
175
 
@@ -169,7 +193,7 @@ Example:
169
193
 
170
194
  ```tsx
171
195
  <RhfUtilsZodForm
172
- onSubmit={({ FormSubmitError }) => {
196
+ onSubmit={async ({ FormSubmitError }) => {
173
197
  if (isProblem())
174
198
  throw new FormSubmitError({
175
199
  root: { message: 'There was a problem with the form.' },
@@ -183,7 +207,7 @@ Example:
183
207
 
184
208
  Any non-`FormSubmitError`s thrown from submit handler (e.g., fetch/axios error) can be transformed by `RhfUtilsClientConfig`'s `onSubmitUnknownError` callback. This takes an `unknown` error and can return a `FormSubmitErrors` object, which is merged in RHF's context errors.
185
209
 
186
- Most common use case will be transforming backend errors to frontend shape. (You can use `getOnSubmitTrpcClientErrorHandler` HOF for TRPC backends.)
210
+ Most common use case will be transforming backend errors to frontend shape. (You can use `getOnSubmitTrpcClientErrorHandler` HOF provided by this library for TRPC backends.)
187
211
 
188
212
  ## `RhfUtilsFormOptions`
189
213
 
@@ -191,11 +215,6 @@ These options can be set globally and/or per form.
191
215
 
192
216
  ```ts
193
217
  type RhfUtilsFormOptions = {
194
- /**
195
- * Style via your own classes.
196
- */
197
- classNames?: string[];
198
-
199
218
  /** Request submit via listener on form change. */
200
219
  submitOnChange?: boolean;
201
220
 
@@ -208,10 +227,7 @@ type RhfUtilsFormOptions = {
208
227
  /** Reset form after successful submit. */
209
228
  resetFormAfterSubmitSuccessful?: UseResetFormAfterSubmitSuccessfulOptions;
210
229
 
211
- /**
212
- * Control dev tool options.
213
- * (Lazy-loaded when truthy value supplied.)
214
- */
230
+ /** Control dev tool options. (Lazy-loaded when truthy value supplied.) */
215
231
  devTool?: true | Pick<DevtoolUIProps, 'placement' | 'styles'>;
216
232
  };
217
233
  ```
@@ -231,7 +247,7 @@ declare module '@paragrav/rhf-utils' {
231
247
  export interface Register {
232
248
  RhfUtilsFormOptions: {
233
249
  /** Enable user prompt to confirm navigating away from dirty form. */
234
- prompter?: boolean;
250
+ enableMyFormNavigationPrompt?: boolean;
235
251
  };
236
252
  }
237
253
  }
@@ -241,6 +257,8 @@ declare module '@paragrav/rhf-utils' {
241
257
 
242
258
  You can configure via `RhfUtilsClientConfig` (example at the top) when form context errors are outputted -- i.e., via console and/or thrown error.
243
259
 
260
+ Use `useFlatFieldErrorsContext()` hook, which returns an object with errors grouped by `all`, `fields`, `root`, and `orphans`.
261
+
244
262
  ### Orphans
245
263
 
246
264
  The concept of orphan errors is any error that is not being shown to user. An example would be a stray field in a schema that is prohibiting users from successfully submitting a form.
@@ -1,50 +1,52 @@
1
- import { jsx as h } from "react/jsx-runtime";
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);
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: (o, s) => {
8
- const t = m(o, s);
7
+ useForm: (s, t) => {
8
+ const o = m(s, t);
9
9
  return {
10
- ...d(t),
11
- FormWithProviders: () => /* @__PURE__ */ h(f, { ...t })
10
+ ...F(o),
11
+ FormWithProviders: () => /* @__PURE__ */ u(a, { ...o })
12
12
  };
13
13
  },
14
- FormWithProviders: a(e, r)
14
+ FormWithProviders: P(e, r)
15
15
  };
16
- }, F = (e, r) => function(o, s) {
17
- var t, i, l, n, u;
16
+ }, d = (e, r) => function(s, t) {
17
+ var o, i, f, l, n, h;
18
18
  return {
19
- ...s,
19
+ ...t,
20
+ // merge global config with instance options...
20
21
  rhf: {
21
- ...(t = r.defaults) == null ? void 0 : t.rhf,
22
- ...s.rhf,
23
- resolver: e(o)
22
+ resolver: e(s),
23
+ ...(o = r.defaults) == null ? void 0 : o.rhf,
24
+ ...t.rhf
24
25
  },
25
26
  utils: {
26
27
  ...(i = r.defaults) == null ? void 0 : i.utils,
27
- ...s.utils,
28
- classNames: [
29
- ...((n = (l = r.defaults) == null ? void 0 : l.utils) == null ? void 0 : n.classNames) ?? [],
30
- ...((u = s.utils) == null ? void 0 : u.classNames) ?? []
31
- ]
28
+ ...t.utils
29
+ },
30
+ form: {
31
+ ...(f = r.defaults) == null ? void 0 : f.form,
32
+ ...t.form,
33
+ 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(" ")
32
34
  }
33
35
  };
34
- }, a = (e, r) => function({
35
- schema: o,
36
- children: s,
37
- ...t
36
+ }, P = (e, r) => function({
37
+ schema: s,
38
+ children: t,
39
+ ...o
38
40
  }) {
39
- const i = F(e, r);
40
- return /* @__PURE__ */ h(
41
- f,
41
+ const i = d(e, r);
42
+ return /* @__PURE__ */ u(
43
+ a,
42
44
  {
43
- ...i(o, t),
44
- children: s
45
+ ...i(s, o),
46
+ children: t
45
47
  }
46
48
  );
47
49
  };
48
50
  export {
49
- R as createRhfUtilsClient
51
+ v as createRhfUtilsClient
50
52
  };
@@ -1,92 +1,82 @@
1
- import { jsx as c, jsxs as E, Fragment as N } from "react/jsx-runtime";
1
+ import { jsx as a, jsxs as v, Fragment as E } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { useFormContext as P } from "react-hook-form";
4
- import f from "../client/config/useRhfUtilsClientConfigContext.mjs";
5
- import w from "../devtool/LazyDevTool.mjs";
6
- import { FormSubmitError as C } from "../submit/error/FormSubmitError.mjs";
7
- import B from "../submit/error/setCtxErrorsByFormSubmitErrors.mjs";
8
- import S from "./_Controller.mjs";
9
- function A({
10
- formId: e,
11
- formRef: m,
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,
12
12
  //
13
- onSubmit: s,
13
+ onSubmit: c,
14
14
  onSubmitError: d,
15
- onSubmitInvalid: y,
16
- Children: h,
15
+ onSubmitInvalid: F,
16
+ Children: i,
17
17
  //
18
- form: p,
18
+ form: l,
19
19
  utils: o
20
20
  }) {
21
- const n = P(), r = f(), i = async (t) => {
21
+ const e = P(), r = w(), y = async (t) => {
22
22
  o != null && o.stopSubmitPropagation && t.stopPropagation();
23
23
  try {
24
- await n.handleSubmit(b, y)(t);
25
- } catch (a) {
26
- j(a, t);
24
+ await e.handleSubmit(f, F)(t);
25
+ } catch (m) {
26
+ b(m, t);
27
27
  }
28
- }, b = (t, a) => s == null ? void 0 : s(
28
+ }, f = (t, m) => c == null ? void 0 : c(
29
29
  t,
30
30
  {
31
- formId: e,
32
- formRef: m,
33
- context: n,
31
+ formId: n,
32
+ formRef: p,
33
+ context: e,
34
34
  utils: o,
35
- FormSubmitError: C
35
+ FormSubmitError: h
36
36
  },
37
- a
38
- ), j = (t, a) => {
39
- var l;
40
- const F = t instanceof C ? (
37
+ m
38
+ ), b = (t, m) => {
39
+ var x;
40
+ const C = t instanceof h ? (
41
41
  // consumer can manually throw FormSubmitError (e.g., manual validation)
42
42
  t.errors
43
43
  ) : (
44
44
  // if error is not FormSubmitError, consumer can provide global handler
45
- (l = r == null ? void 0 : r.onSubmitUnknownError) == null ? void 0 : l.call(r, t)
45
+ (x = r == null ? void 0 : r.onSubmitUnknownError) == null ? void 0 : x.call(r, t)
46
46
  );
47
- F && B(n, F), d == null || d(
47
+ C && U(e, C), d == null || d(
48
48
  t,
49
49
  {
50
- formId: e,
51
- formRef: m,
52
- context: n,
50
+ formId: n,
51
+ formRef: p,
52
+ context: e,
53
53
  utils: o
54
54
  },
55
- a
55
+ m
56
56
  );
57
- }, x = {
58
- formId: e,
59
- formRef: m,
60
- context: n,
57
+ }, s = {
58
+ formId: n,
59
+ formRef: p,
60
+ context: e,
61
61
  utils: o,
62
- Controller: S,
63
- FormSubmitError: C
64
- }, T = (r == null ? void 0 : r.FormComponent) ?? "form", v = (r == null ? void 0 : r.FormChildren) ?? U;
65
- return /* @__PURE__ */ c(
66
- T,
67
- {
68
- noValidate: !0,
69
- ref: m,
70
- ...p,
71
- className: [o == null ? void 0 : o.classNames, p == null ? void 0 : p.className].filter(Boolean).join(" "),
72
- onSubmit: i,
73
- children: /* @__PURE__ */ E(v, { ...x, children: [
74
- (o == null ? void 0 : o.devTool) && /* @__PURE__ */ c(
75
- w,
76
- {
77
- props: typeof o.devTool == "object" ? o.devTool : void 0
78
- }
79
- ),
80
- h && /* @__PURE__ */ c(h, { ...x })
81
- ] })
82
- }
83
- );
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
+ ] }) });
84
74
  }
85
- function U({
86
- children: e
75
+ function k({
76
+ children: n
87
77
  }) {
88
- return /* @__PURE__ */ c(N, { children: e });
78
+ return /* @__PURE__ */ a(E, { children: n });
89
79
  }
90
80
  export {
91
- A as default
81
+ G as default
92
82
  };
@@ -2,10 +2,10 @@ import s from "react";
2
2
  import { useForm as d } from "react-hook-form";
3
3
  import { FormSubmitError as F } from "../submit/error/FormSubmitError.mjs";
4
4
  const v = ({
5
- onSubmit: e,
6
- onSubmitError: f,
7
- onSubmitInvalid: p,
8
- defaultValues: n,
5
+ defaultValues: e,
6
+ onSubmit: f,
7
+ onSubmitError: p,
8
+ onSubmitInvalid: n,
9
9
  Children: c,
10
10
  rhf: i,
11
11
  form: u,
@@ -13,7 +13,7 @@ const v = ({
13
13
  }) => {
14
14
  const r = s.useId(), m = d({
15
15
  ...i,
16
- defaultValues: n
16
+ defaultValues: e
17
17
  }), o = s.useRef(null);
18
18
  return {
19
19
  id: r,
@@ -27,9 +27,9 @@ const v = ({
27
27
  },
28
28
  formProps: {
29
29
  Children: c,
30
- onSubmit: e,
31
- onSubmitError: f,
32
- onSubmitInvalid: p,
30
+ onSubmit: f,
31
+ onSubmitError: p,
32
+ onSubmitInvalid: n,
33
33
  formId: r,
34
34
  formRef: o,
35
35
  form: u,
@@ -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.
@@ -14,7 +14,7 @@ export type ObjectSchema<TInputKey extends string, TOutputKey extends string> =
14
14
  [key in TOutputKey]: SafeFieldValues;
15
15
  };
16
16
  export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
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
+ 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: UseRhfUtilsFormPropsForm) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {
18
18
  FormWithProviders: React.FC<React.PropsWithChildren>;
19
19
  };
20
20
  FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
@@ -4,6 +4,6 @@ import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
4
 
5
5
  type Props<TSchema extends ZodTypeFieldValues> = {
6
6
  schema: TSchema;
7
- } & Omit<UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>, 'config'>;
7
+ } & UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>;
8
8
  declare function RhfUtilsZodForm<TSchema extends ZodTypeFieldValues>({ schema, ...props }: Props<TSchema>): import("react/jsx-runtime").JSX.Element;
9
9
  export default RhfUtilsZodForm;
@@ -2,7 +2,7 @@ import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
2
2
  import { zodTypeInput, zodTypeOutput } from '../consts';
3
3
  import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
4
 
5
- declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: Omit<UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>, 'config'>) => import('../../../form/UseRhfUtilsFormReturn').UseRhfUtilsFormReturn<TSchema["_input"], TSchema["_output"]> & {
5
+ declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>) => import('../../../form/UseRhfUtilsFormReturn').UseRhfUtilsFormReturn<TSchema["_input"], TSchema["_output"]> & {
6
6
  FormWithProviders: import('react').FC<{
7
7
  children?: import('react').ReactNode;
8
8
  }>;
@@ -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.) */
@@ -6,17 +6,17 @@ import { UseRhfUtilsFormChildrenProps } from './UseRhfUtilsFormChildrenProps';
6
6
  import { UseRhfUtilsFormOnSubmitContext, UseRhfUtilsFormOnSubmitErrorContext } from './UseRhfUtilsFormOnSubmitContext';
7
7
 
8
8
  export type UseRhfUtilsFormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
9
+ defaultValues?: UseFormProps<TFieldValues>['defaultValues'];
9
10
  onSubmit?: (values: TTransformedValues, context: UseRhfUtilsFormOnSubmitContext<TFieldValues, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => unknown | Promise<unknown>;
10
11
  /** Submit error handler. (Only for errors not of instance `FormError`, which are handled internally.) */
11
12
  onSubmitError?: (error: unknown, context: UseRhfUtilsFormOnSubmitErrorContext<TFieldValues, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
12
13
  /** Submit handler when form is invalid. */
13
14
  onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
14
- defaultValues?: UseFormProps<TFieldValues>['defaultValues'];
15
- Children?: React.FC<UseRhfUtilsFormChildrenProps<TFieldValues, TTransformedValues>>;
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
  };
@@ -11,6 +11,6 @@ import { UseRhfUtilsFormReturn } from './UseRhfUtilsFormReturn';
11
11
  * see https://caniuse.com/?search=form%20attribute
12
12
  * @returns Form provider and form.
13
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>;
14
+ declare const useRhfUtilsForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ defaultValues, onSubmit, onSubmitError, onSubmitInvalid, Children, rhf, form, utils, }: UseRhfUtilsFormProps<TFieldValues, TTransformedValues>) => UseRhfUtilsFormReturn<TFieldValues, TTransformedValues>;
15
15
  export default useRhfUtilsForm;
16
16
  export type UseRhfUtilsForm<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = typeof useRhfUtilsForm<TFieldValues, TTransformedValues>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.118",
5
+ "version": "0.0.120",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,