@paragrav/rhf-utils 0.0.70 → 0.0.71

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.
@@ -1,32 +1,32 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import u from "../form/FormWithProviders.mjs";
3
- import F from "../form/useForm.mjs";
4
- const p = (t) => (r) => {
5
- const e = l(
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import l from "../form/FormWithProviders.mjs";
3
+ import d from "../form/useForm.mjs";
4
+ const v = (t) => (r) => {
5
+ const e = a(
6
6
  t,
7
7
  r
8
8
  );
9
9
  return {
10
- useForm: (o, s) => F(
10
+ useForm: (o, s) => d(
11
11
  e(o, s)
12
12
  ),
13
- FormWithProviders: P(t, r)
13
+ FormWithProviders: u(t, r)
14
14
  };
15
- }, P = (t, r) => function({
15
+ }, u = (t, r) => function({
16
16
  schema: o,
17
17
  children: s,
18
18
  ...m
19
19
  }) {
20
- const i = l(t, r);
21
- return /* @__PURE__ */ d(
22
- u,
20
+ const i = a(t, r);
21
+ return /* @__PURE__ */ h(
22
+ l,
23
23
  {
24
24
  ...i(o, m),
25
25
  children: s
26
26
  }
27
27
  );
28
- }, l = (t, r) => (e, o) => {
29
- var s, m, i, n, f, a, h;
28
+ }, a = (t, r) => (e, o) => {
29
+ var s, m, i, n, f;
30
30
  return {
31
31
  ...o,
32
32
  config: r,
@@ -35,19 +35,17 @@ const p = (t) => (r) => {
35
35
  ...o.rhf,
36
36
  resolver: t(e)
37
37
  },
38
- form: {
39
- ...o.form,
40
- options: {
41
- ...(m = r.defaultOptions) == null ? void 0 : m.form,
42
- ...(i = o.form) == null ? void 0 : i.options,
43
- classNames: [
44
- ...((f = (n = r.defaultOptions) == null ? void 0 : n.form) == null ? void 0 : f.classNames) ?? [],
45
- ...((h = (a = o.form) == null ? void 0 : a.options) == null ? void 0 : h.classNames) ?? []
46
- ]
47
- }
38
+ form: o.form,
39
+ options: {
40
+ ...(m = r.defaultOptions) == null ? void 0 : m.form,
41
+ ...o.options,
42
+ classNames: [
43
+ ...((n = (i = r.defaultOptions) == null ? void 0 : i.form) == null ? void 0 : n.classNames) ?? [],
44
+ ...((f = o.options) == null ? void 0 : f.classNames) ?? []
45
+ ]
48
46
  }
49
47
  };
50
48
  };
51
49
  export {
52
- p as createRhfUtilsClient
50
+ v as createRhfUtilsClient
53
51
  };
@@ -1,90 +1,83 @@
1
- import { jsxs as B, jsx as p } from "react/jsx-runtime";
1
+ import { jsxs as B, jsx as b } from "react/jsx-runtime";
2
2
  import "react";
3
- import { useFormContext as N } from "react-hook-form";
4
- import P from "../devtool/LazyDevTool.mjs";
5
- import { FormSubmitError as T } from "../submit/error/FormSubmitError.mjs";
6
- import V from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
7
- import _ from "../submit/useResetFormOnSubmitError.mjs";
8
- import O from "./_FormBase.mjs";
9
- function G({
10
- formId: c,
11
- formRef: l,
3
+ import { useFormContext as j } from "react-hook-form";
4
+ import v from "../devtool/LazyDevTool.mjs";
5
+ import { FormSubmitError as N } from "../submit/error/FormSubmitError.mjs";
6
+ import P from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
7
+ import T from "./_FormBase.mjs";
8
+ function L({
9
+ formId: E,
10
+ formRef: r,
12
11
  form: t,
13
- config: n,
14
- children: o
12
+ options: a,
13
+ config: l,
14
+ children: F
15
15
  }) {
16
- var b, S, h, E, F;
17
- const a = N();
18
- _({
19
- disabled: !((b = t == null ? void 0 : t.options) != null && b.resetValuesOnSubmitError)
20
- });
21
- const y = async (s) => {
22
- var e;
23
- (e = t == null ? void 0 : t.options) != null && e.stopSubmitPropagation && s.stopPropagation();
16
+ var h;
17
+ const s = j(), c = async (e) => {
18
+ a != null && a.stopSubmitPropagation && e.stopPropagation();
24
19
  try {
25
- await a.handleSubmit(
26
- j,
20
+ await s.handleSubmit(
21
+ y,
27
22
  t == null ? void 0 : t.onSubmitInvalid
28
- )(s);
29
- } catch (i) {
30
- v(i, s);
23
+ )(e);
24
+ } catch (u) {
25
+ n(u, e);
31
26
  }
32
- }, j = (s, e) => {
33
- var i;
34
- return (i = t == null ? void 0 : t.onSubmit) == null ? void 0 : i.call(
27
+ }, y = (e, u) => {
28
+ var d;
29
+ return (d = t == null ? void 0 : t.onSubmit) == null ? void 0 : d.call(
35
30
  t,
31
+ e,
36
32
  s,
37
- a,
38
- e
33
+ u
39
34
  );
40
- }, v = (s, e) => {
35
+ }, n = (e, u) => {
41
36
  var x, C;
42
- const i = s instanceof T ? (
37
+ const d = e instanceof N ? (
43
38
  // consumer can manually throw FormSubmitError (e.g., manual validation)
44
- s
39
+ e
45
40
  ) : (
46
41
  // if error is not FormSubmitError, consumer can provide global handler
47
- (x = n == null ? void 0 : n.onSubmitError) == null ? void 0 : x.call(n, s)
42
+ (x = l == null ? void 0 : l.onSubmitError) == null ? void 0 : x.call(l, e)
48
43
  );
49
- i && V(a, i), (C = t == null ? void 0 : t.onSubmitError) == null || C.call(
44
+ d && P(s, d), (C = t == null ? void 0 : t.onSubmitError) == null || C.call(
50
45
  t,
46
+ e,
51
47
  s,
52
- a,
53
- e
48
+ u
54
49
  );
55
- }, u = {
56
- formId: c,
57
- formRef: l,
58
- ctx: a,
59
- options: t == null ? void 0 : t.options
60
- }, d = (s) => {
61
- var i;
62
- const e = (i = n == null ? void 0 : n.Children) == null ? void 0 : i[s];
63
- return e && /* @__PURE__ */ p(e, { ...u });
50
+ }, S = {
51
+ formId: E,
52
+ formRef: r,
53
+ ctx: s,
54
+ options: a
55
+ }, i = (e) => {
56
+ var d;
57
+ const u = (d = l == null ? void 0 : l.Children) == null ? void 0 : d[e];
58
+ return u && /* @__PURE__ */ b(u, { ...S });
64
59
  };
65
60
  return /* @__PURE__ */ B(
66
- O,
61
+ T,
67
62
  {
68
63
  noValidate: !0,
69
64
  style: {
70
65
  position: "relative"
71
66
  },
72
67
  ...t == null ? void 0 : t.props,
73
- className: [(S = t == null ? void 0 : t.options) == null ? void 0 : S.classNames, ((h = t == null ? void 0 : t.props) == null ? void 0 : h.className) ?? ""].join(
74
- " "
75
- ),
76
- onSubmit: y,
77
- formRef: l,
68
+ className: [a == null ? void 0 : a.classNames, (h = t == null ? void 0 : t.props) == null ? void 0 : h.className].filter(Boolean).join(" "),
69
+ onSubmit: c,
70
+ formRef: r,
78
71
  children: [
79
- d("top"),
80
- ((E = t == null ? void 0 : t.options) == null ? void 0 : E.devTool) !== "disabled" && /* @__PURE__ */ p(P, { placement: "top-right", ...(F = t == null ? void 0 : t.options) == null ? void 0 : F.devTool }),
81
- (t == null ? void 0 : t.Fields) && /* @__PURE__ */ p(t.Fields, { ...u }),
82
- o,
83
- d("bottom")
72
+ i("top"),
73
+ (a == null ? void 0 : a.devTool) !== "disabled" && /* @__PURE__ */ b(v, { placement: "top-right", ...a == null ? void 0 : a.devTool }),
74
+ (t == null ? void 0 : t.Fields) && /* @__PURE__ */ b(t.Fields, { ...S }),
75
+ F,
76
+ i("bottom")
84
77
  ]
85
78
  }
86
79
  );
87
80
  }
88
81
  export {
89
- G as default
82
+ L as default
90
83
  };
@@ -1,15 +1,24 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { FormProvider as m } from "react-hook-form";
3
- import d from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
4
- import n from "./context/utils/FormUtilsContextProvider.mjs";
5
- function f({
2
+ import { FormProvider as d } from "react-hook-form";
3
+ import n from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
4
+ import l from "./context/utils/FormUtilsContextProvider.mjs";
5
+ function v({
6
+ formId: t,
6
7
  formRef: o,
7
- rhfForm: t,
8
- utils: i,
9
- children: e
8
+ rhfForm: i,
9
+ options: e,
10
+ children: m
10
11
  }) {
11
- return /* @__PURE__ */ r(m, { ...t, children: /* @__PURE__ */ r(d, { formRef: o, children: /* @__PURE__ */ r(n, { formRef: o, ...i, children: e }) }) });
12
+ return /* @__PURE__ */ r(d, { ...i, children: /* @__PURE__ */ r(n, { formRef: o, children: /* @__PURE__ */ r(
13
+ l,
14
+ {
15
+ formId: t,
16
+ formRef: o,
17
+ options: e,
18
+ children: m
19
+ }
20
+ ) }) });
12
21
  }
13
22
  export {
14
- f as default
23
+ v as default
15
24
  };
@@ -1,28 +1,42 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { isDevelopment as s } from "../../../env-conditions/production.mjs";
3
- import F from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
4
- import l from "../../../errors/useFormErrorConsoleDebug.mjs";
5
- import a from "../../../errors/useFormRequestSubmit.mjs";
6
- import u from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
7
- import C from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
8
- import { _FormUtilsContextProvider as f } from "./useFormUtilsContext.mjs";
9
- function P({
10
- // options
11
- disableFormErrorConsoleDebug: n,
12
- disableOrphanFormErrorsToConsole: m,
13
- resetFormAfterSubmitSuccessful: t,
14
- // props
15
- formRef: o,
16
- onSubmitSuccessfulAndReset: r,
17
- children: e
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { isDevelopment as t } from "../../../env-conditions/production.mjs";
3
+ import b from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
4
+ import C from "../../../errors/useFormErrorConsoleDebug.mjs";
5
+ import O from "../../../errors/useFormRequestSubmit.mjs";
6
+ import f from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
7
+ import E from "../../../submit/useResetFormOnSubmitError.mjs";
8
+ import d from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
9
+ import h from "../../../submit/useSubmitFormOnChange.mjs";
10
+ import { _FormUtilsContextProvider as o } from "./useFormUtilsContext.mjs";
11
+ function s({
12
+ formId: u,
13
+ formRef: m,
14
+ onSubmitSuccessfulAndReset: e,
15
+ options: r,
16
+ children: a
18
17
  }) {
19
- const i = a(o);
20
- return l(s), F(o, !m), C({
21
- enabled: t || !!r
22
- }), u(() => {
23
- r == null || r();
24
- }), /* @__PURE__ */ p(f, { value: { formRef: o, requestSubmit: i }, children: e });
18
+ const F = O(m);
19
+ return C(
20
+ t
21
+ ), b(
22
+ m,
23
+ !(r != null && r.disableOrphanFormErrorsToConsole)
24
+ ), h(m, {
25
+ disabled: !(r != null && r.submitOnChange)
26
+ }), E({
27
+ disabled: !(r != null && r.resetValuesOnSubmitError)
28
+ }), d(
29
+ (r == null ? void 0 : r.resetFormAfterSubmitSuccessful) || !!e
30
+ ), f(() => {
31
+ e == null || e();
32
+ }), /* @__PURE__ */ l(
33
+ o,
34
+ {
35
+ value: { formId: u, formRef: m, requestSubmit: F, options: r },
36
+ children: a
37
+ }
38
+ );
25
39
  }
26
40
  export {
27
- P as default
41
+ s as default
28
42
  };
@@ -1,33 +1,30 @@
1
- import n from "react";
2
- import { useForm as i } from "react-hook-form";
3
- import c from "../submit/useSubmitFormOnChange.mjs";
4
- const P = ({
5
- config: m,
6
- rhf: p,
7
- form: o,
8
- utils: u
1
+ import e from "react";
2
+ import { useForm as p } from "react-hook-form";
3
+ const a = ({
4
+ config: t,
5
+ rhf: m,
6
+ form: f,
7
+ options: n
9
8
  }) => {
10
- var t;
11
- const s = n.useId(), e = i(p), r = n.useRef(null);
12
- return c(r, {
13
- disabled: !((t = o == null ? void 0 : o.options) != null && t.submitOnChange)
14
- }), {
15
- id: s,
9
+ const o = e.useId(), s = p(m), r = e.useRef(null);
10
+ return {
11
+ id: o,
16
12
  ref: r,
17
- context: e,
13
+ context: s,
18
14
  providerProps: {
15
+ formId: o,
19
16
  formRef: r,
20
- rhfForm: e,
21
- utils: u
17
+ rhfForm: s,
18
+ options: n
22
19
  },
23
20
  formProps: {
24
- formId: s,
21
+ formId: o,
25
22
  formRef: r,
26
- config: m,
27
- form: o
23
+ config: t,
24
+ form: f
28
25
  }
29
26
  };
30
27
  };
31
28
  export {
32
- P as default
29
+ a as default
33
30
  };
@@ -9,8 +9,8 @@ const c = (t) => {
9
9
  u,
10
10
  s,
11
11
  i,
12
- r,
13
- m
12
+ m,
13
+ r
14
14
  ]);
15
15
  }, a = c;
16
16
  export {
@@ -1,14 +1,20 @@
1
- import { useFormContext as u } from "react-hook-form";
2
- import o from "./useFormOnSubmitSuccessful.mjs";
3
- const r = ({
4
- enabled: e,
5
- ...t
6
- }) => {
7
- const { reset: s } = u();
8
- o(() => {
9
- e && s(void 0, t);
1
+ import { useFormContext as c } from "react-hook-form";
2
+ import m from "./useFormOnSubmitSuccessful.mjs";
3
+ const a = (e) => {
4
+ const { reset: u, getValues: t } = c();
5
+ m(() => {
6
+ if (!e)
7
+ return;
8
+ const s = e === !0 || e.values === void 0 ? void 0 : e.values.resetToCurrentValues ? t() : e.values, r = e === !0 ? (
9
+ // default
10
+ void 0
11
+ ) : (
12
+ // custom settings
13
+ e.state
14
+ );
15
+ u(s, r);
10
16
  });
11
- }, f = r;
17
+ }, o = a;
12
18
  export {
13
- f as default
19
+ o as default
14
20
  };
@@ -1,7 +1,6 @@
1
1
  import { FormSubmitError } from '../submit/error/FormSubmitError';
2
2
  import { UseFormOptions } from '../form/useFormOptions';
3
3
  import { UseFormFieldsProps } from '../form/useForm';
4
- import { FormUtilsOptions } from '../form/context/utils/FormUtilsContextProvider';
5
4
  import { _FormSlots } from '../form/_Form';
6
5
  import { UseFormProps } from 'react-hook-form';
7
6
 
@@ -22,7 +21,6 @@ export type ClientConfig = {
22
21
  * Extend this type to inject custom options/functionality via `Children` component.
23
22
  */
24
23
  form?: UseFormOptions;
25
- utils?: FormUtilsOptions;
26
24
  };
27
25
  /**
28
26
  * Components injected by slot across all forms.
@@ -3,9 +3,9 @@ import { SafeFieldValues } from './SafeFieldValues';
3
3
  import { default as React } from 'react';
4
4
 
5
5
  export type _FormSlots = 'top' | 'bottom';
6
- export type _FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<Pick<UseFormProps<TFieldValues, TTransformedValues>, 'form' | 'config'> & {
6
+ export type _FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<Pick<UseFormProps<TFieldValues, TTransformedValues>, 'form' | 'options' | 'config'> & {
7
7
  formId: string;
8
8
  formRef: React.RefObject<HTMLFormElement>;
9
9
  }>;
10
- declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, form, config, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
10
+ declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, form, options, config, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
11
11
  export default _Form;
@@ -1,11 +1,12 @@
1
+ import { UseFormOptions } from './useFormOptions';
1
2
  import { SafeFieldValues } from './SafeFieldValues';
2
- import { FormUtilsOptions } from './context/utils/FormUtilsContextProvider';
3
3
  import { UseFormReturn } from 'react-hook-form';
4
4
 
5
5
  export type _FormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
6
+ formId: string;
6
7
  formRef: React.RefObject<HTMLFormElement>;
7
8
  rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
8
- utils?: FormUtilsOptions;
9
+ options?: UseFormOptions;
9
10
  }>;
10
- declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formRef, rhfForm, utils, children, }: _FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
11
+ declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, rhfForm, options, children, }: _FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
11
12
  export default _FormProviders;
@@ -1,16 +1,11 @@
1
- /// <reference types="react" />
2
- export type FormUtilsOptions = {
3
- /** Disable `console.debug` of field errors in dev. */
4
- disableFormErrorConsoleDebug?: boolean;
5
- /** Disable `console.error` of orphan field errors. */
6
- disableOrphanFormErrorsToConsole?: boolean;
7
- /** Reset form after successful submit. */
8
- resetFormAfterSubmitSuccessful?: boolean;
9
- };
1
+ import { UseFormOptions } from '../../useFormOptions';
2
+
10
3
  type Props = React.PropsWithChildren<{
4
+ formId: string;
11
5
  formRef: React.RefObject<HTMLFormElement>;
12
6
  /** Callback after successful submit, and form reset. */
13
7
  onSubmitSuccessfulAndReset?: () => void;
14
- } & FormUtilsOptions>;
15
- declare function FormUtilsContextProvider({ disableFormErrorConsoleDebug, disableOrphanFormErrorsToConsole, resetFormAfterSubmitSuccessful, formRef, onSubmitSuccessfulAndReset, children, }: Props): import("react/jsx-runtime").JSX.Element;
8
+ options?: UseFormOptions;
9
+ }>;
10
+ declare function FormUtilsContextProvider({ formId, formRef, onSubmitSuccessfulAndReset, options, children, }: Props): import("react/jsx-runtime").JSX.Element;
16
11
  export default FormUtilsContextProvider;
@@ -1,6 +1,9 @@
1
- /// <reference types="react" />
1
+ import { UseFormOptions } from '../../useFormOptions';
2
+
2
3
  export type FormUtilsContext = {
4
+ formId: string;
3
5
  formRef: React.RefObject<HTMLFormElement>;
6
+ options: UseFormOptions | undefined;
4
7
  /** Callback to trigger submit manually -- e.g., on change. */
5
8
  requestSubmit: HTMLFormElement['requestSubmit'];
6
9
  };
@@ -1,6 +1,5 @@
1
1
  import { UseFormOptions } from './useFormOptions';
2
2
  import { SafeFieldValues } from './SafeFieldValues';
3
- import { FormUtilsOptions } from './context/utils/FormUtilsContextProvider';
4
3
  import { _FormProvidersProps } from './_FormProviders';
5
4
  import { _FormProps } from './_Form';
6
5
  import { ClientConfig } from '../client/config';
@@ -25,10 +24,9 @@ export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValue
25
24
  onSubmitError?: (error: unknown, context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
26
25
  /** Submit handler when form is invalid. */
27
26
  onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
28
- options?: UseFormOptions;
29
27
  props?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
30
28
  };
31
- utils?: FormUtilsOptions;
29
+ options?: UseFormOptions;
32
30
  };
33
31
  /**
34
32
  * Core Rhf Form hook. Use `Form` in `index.ts` for most cases.
@@ -39,7 +37,7 @@ export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValue
39
37
  * see https://caniuse.com/?search=form%20attribute
40
38
  * @returns Form provider and form.
41
39
  */
42
- declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ config, rhf, form, utils, }: UseFormProps<TFieldValues, TTransformedValues>) => {
40
+ declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ config, rhf, form, options, }: UseFormProps<TFieldValues, TTransformedValues>) => {
43
41
  readonly id: string;
44
42
  readonly ref: React.RefObject<HTMLFormElement>;
45
43
  readonly context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>;
@@ -1,7 +1,8 @@
1
+ import { default as useResetFormAfterSubmitSuccessful } from '../submit/useResetFormOnSubmitSuccessful';
1
2
  import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
2
3
 
3
4
  export type UseFormOptions = {
4
- /** Control visibility of certain items via your own classes and styles. */
5
+ /** Control visibility of certain items via your own classes and styles. (Defaults merged with individual class names.) */
5
6
  classNames?: string[];
6
7
  /** Request submit via listener on form change. */
7
8
  submitOnChange?: boolean;
@@ -9,6 +10,12 @@ export type UseFormOptions = {
9
10
  resetValuesOnSubmitError?: boolean;
10
11
  /** Stop propagation of submit event. Useful for portals. */
11
12
  stopSubmitPropagation?: boolean;
13
+ /** Disable `console.debug` of field errors in dev. */
14
+ disableFormErrorConsoleDebug?: boolean;
15
+ /** Disable `console.error` of orphan field errors. */
16
+ disableOrphanFormErrorsToConsole?: boolean;
17
+ /** Reset form after successful submit. */
18
+ resetFormAfterSubmitSuccessful?: Parameters<typeof useResetFormAfterSubmitSuccessful>[0];
12
19
  /** Control dev tool options. */
13
20
  devTool?: DevtoolUIProps | 'disabled';
14
21
  };
@@ -1,12 +1,16 @@
1
+ import { SafeFieldValues } from '../form/SafeFieldValues';
1
2
  import { KeepStateOptions } from 'react-hook-form';
2
3
 
3
- type Options = {
4
- enabled?: boolean;
5
- } & KeepStateOptions;
4
+ type Options = false | undefined | true | {
5
+ values?: undefined | SafeFieldValues | {
6
+ resetToCurrentValues: true;
7
+ };
8
+ state?: KeepStateOptions;
9
+ };
6
10
  /**
7
11
  * Handle resetting after successful submit with no server validation errors.
8
12
  * See `Rules` section: https://react-hook-form.com/api/useform/reset/
9
13
  * Specifically: "- It's recommended to reset inside useEffect after submission."
10
14
  */
11
- declare const useResetFormAfterSubmitSuccessful: ({ enabled, ...options }: Options) => void;
15
+ declare const useResetFormAfterSubmitSuccessful: (options: Options) => void;
12
16
  export default useResetFormAfterSubmitSuccessful;
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.70",
5
+ "version": "0.0.71",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -21,15 +21,15 @@
21
21
  "default": "./dist/esm/exports.mjs",
22
22
  "types": "./dist/types/exports.d.ts"
23
23
  },
24
- "./createZodRhfUtilsClient": {
24
+ "./client/zod/createZodRhfUtilsClient": {
25
25
  "default": "./dist/esm/client/zod/createZodRhfUtilsClient.mjs",
26
26
  "types": "./dist/types/client/zod/createZodRhfUtilsClient.d.ts"
27
27
  },
28
- "./useRhfUtilsZodContext": {
28
+ "./client/zod/useRhfUtilsZodContext": {
29
29
  "default": "./dist/esm/client/zod/useRhfUtilsZodContext.mjs",
30
30
  "types": "./dist/types/client/zod/useRhfUtilsZodContext.d.ts"
31
31
  },
32
- "./RhfUtilsZodContextProvider": {
32
+ "./client/zod/RhfUtilsZodContextProvider": {
33
33
  "default": "./dist/esm/client/zod/RhfUtilsZodContextProvider.mjs",
34
34
  "types": "./dist/types/client/zod/RhfUtilsZodContextProvider.d.ts"
35
35
  },
@@ -202,7 +202,8 @@
202
202
  },
203
203
  "devDependencies": {
204
204
  "@hookform/resolvers": "^3.3.4",
205
- "@playwright/experimental-ct-react": "^1.42.1",
205
+ "@playwright/experimental-ct-react": "^1.43.1",
206
+ "@playwright/test": "^1.43.1",
206
207
  "@rollup/plugin-typescript": "^11.1.6",
207
208
  "@types/node": "^20.12.7",
208
209
  "@types/react": "^18.2.69",
@@ -213,6 +214,7 @@
213
214
  "cross-env": "^7.0.3",
214
215
  "eslint": "^8.57.0",
215
216
  "eslint-config-prettier": "^9.1.0",
217
+ "eslint-import-resolver-typescript": "^3.6.1",
216
218
  "eslint-plugin-import": "^2.29.1",
217
219
  "eslint-plugin-react": "^7.34.1",
218
220
  "eslint-plugin-react-hooks": "^4.6.0",