@paragrav/rhf-utils 0.0.50 → 0.0.53
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/dist/esm/devtool/LazyDevTool.mjs +7 -11
- package/dist/esm/env-conditions/production.mjs +4 -0
- package/dist/esm/errors/isFieldError.mjs +2 -2
- package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +5 -12
- package/dist/esm/errors/orphan/isOrphanFormError.mjs +12 -0
- package/dist/esm/errors/orphan/useOrphanFormErrorsToConsole.mjs +8 -9
- package/dist/esm/errors/outputErrors.mjs +5 -6
- package/dist/esm/exports.mjs +38 -34
- package/dist/esm/form/Form.mjs +32 -40
- package/dist/esm/form/context/FormProvider.mjs +17 -19
- package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +5 -14
- package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +6 -11
- package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +13 -0
- package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +10 -0
- package/dist/esm/form/context/utils/FormUtilsContextProvider.mjs +10 -10
- package/dist/esm/form/useForm.mjs +14 -16
- package/dist/esm/form/useFormWithProviders.mjs +15 -17
- package/dist/types/src/devtool/LazyDevTool.d.ts +9 -0
- package/dist/types/src/env-conditions/development.d.ts +7 -0
- package/dist/types/src/env-conditions/production.d.ts +1 -0
- package/dist/types/src/errors/consoleErrors.d.ts +13 -0
- package/dist/types/src/errors/context/index.d.ts +10 -0
- package/dist/types/src/errors/context/provider.d.ts +11 -0
- package/dist/types/src/errors/flat/flattenFieldErrors.d.ts +15 -0
- package/dist/types/src/errors/flat/getFlatFieldErrors.d.ts +25 -0
- package/dist/types/src/errors/flat/types.d.ts +13 -0
- package/dist/types/src/errors/flat/useFormFlatFieldErrorsMemo.d.ts +5 -0
- package/dist/types/src/errors/flat/useRefdFieldErrorsMemo.d.ts +9 -0
- package/dist/types/src/errors/isFieldError.d.ts +7 -0
- package/dist/types/src/errors/message/FormErrorMessage.d.ts +8 -0
- package/dist/types/src/errors/message/FormErrorMessageByPath.d.ts +9 -0
- package/dist/types/src/errors/nonfield/FormNonFieldErrorMarker.d.ts +10 -0
- package/dist/types/src/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +1 -0
- package/dist/types/src/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +2 -0
- package/dist/types/src/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +5 -0
- package/dist/types/src/errors/nonfield/isNonFieldError.d.ts +19 -0
- package/dist/types/src/errors/orphan/getOrphansFromFieldErrors.d.ts +5 -0
- package/dist/types/src/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +4 -0
- package/dist/types/src/errors/orphan/isOrphanFormError.d.ts +4 -0
- package/dist/types/src/errors/orphan/useFormHasOrphanAndNoFieldErrors.d.ts +9 -0
- package/dist/types/src/errors/orphan/useOrphanFormErrorsMemo.d.ts +4 -0
- package/dist/types/src/errors/orphan/useOrphanFormErrorsToConsole.d.ts +9 -0
- package/dist/types/src/errors/outputErrors.d.ts +13 -0
- package/dist/types/src/errors/root/FormRootErrors.d.ts +7 -0
- package/dist/types/src/errors/root/FormRootErrorsFromContext.d.ts +3 -0
- package/dist/types/src/errors/root/consts.d.ts +1 -0
- package/dist/types/src/errors/root/getRootsFromFieldErrors.d.ts +5 -0
- package/dist/types/src/errors/root/getRootsFromFlatFieldErrors.d.ts +4 -0
- package/dist/types/src/errors/root/isFormErrorPathRoot.d.ts +6 -0
- package/dist/types/src/errors/root/useRootFormFieldErrorsMemo.d.ts +6 -0
- package/dist/types/src/errors/useFormErrorConsoleDebug.d.ts +8 -0
- package/dist/types/src/errors/useFormErrorsEffect.d.ts +4 -0
- package/dist/types/src/errors/useFormErrorsIfAny.d.ts +6 -0
- package/dist/types/src/errors/useFormErrorsMemo.d.ts +7 -0
- package/dist/types/src/errors/useFormErrorsToConsole.d.ts +13 -0
- package/dist/types/src/errors/useFormRequestSubmit.d.ts +6 -0
- package/dist/types/src/exports.d.ts +39 -0
- package/dist/types/src/form/ErrorBoundary.d.ts +15 -0
- package/dist/types/src/form/Form.d.ts +29 -0
- package/dist/types/src/form/FormBase.d.ts +9 -0
- package/dist/types/src/form/FormWithProviders.d.ts +13 -0
- package/dist/types/src/form/context/FormProvider.d.ts +15 -0
- package/dist/types/src/form/context/group/FormGroupContextProvider.d.ts +5 -0
- package/dist/types/src/form/context/group/index.d.ts +15 -0
- package/dist/types/src/form/context/group/useFormGroupChildIsMountedTracker.d.ts +5 -0
- package/dist/types/src/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +5 -0
- package/dist/types/src/form/context/group/useFormGroupChildTracker.d.ts +6 -0
- package/dist/types/src/form/context/group/useFormGroupIsAnyBusy.d.ts +2 -0
- package/dist/types/src/form/context/group/useFormGroupIsChildBusy.d.ts +2 -0
- package/dist/types/src/form/context/group/useFormGroupIsParentBusy.d.ts +2 -0
- package/dist/types/src/form/context/group/useFormGroupParentTracker.d.ts +7 -0
- package/dist/types/src/form/context/group/useFormOrParentIsBusy.d.ts +2 -0
- package/dist/types/src/form/context/utils/FormUtilsContextProvider.d.ts +14 -0
- package/dist/types/src/form/context/utils/useFormUtilsContext.d.ts +9 -0
- package/dist/types/src/form/search/FormSearch.d.ts +32 -0
- package/dist/types/src/form/search/FormSearchHiddenInputs.d.ts +13 -0
- package/dist/types/src/form/search/getNewSearchParams.d.ts +2 -0
- package/dist/types/src/form/useForm.d.ts +29 -0
- package/dist/types/src/form/useFormIsBusy.d.ts +2 -0
- package/dist/types/src/form/useFormOrParentIsBusy.d.ts +2 -0
- package/dist/types/src/form/useFormWithProviders.d.ts +31 -0
- package/dist/types/src/form/utils/getSubmitterButtonData.d.ts +11 -0
- package/dist/types/src/isEmptyObject.d.ts +2 -0
- package/dist/types/src/main.d.ts +1 -0
- package/dist/types/src/submit/error/FormSubmitError.d.ts +6 -0
- package/dist/types/src/submit/error/handleFormSubmitError.d.ts +7 -0
- package/dist/types/src/submit/useFormOnSubmitSuccessful.d.ts +2 -0
- package/dist/types/src/submit/useFormOnSubmitSuccessfulAndReset.d.ts +13 -0
- package/dist/types/src/submit/useResetFormOnSubmitError.d.ts +7 -0
- package/dist/types/src/submit/useResetFormOnSubmitSuccessful.d.ts +12 -0
- package/dist/types/src/submit/useSubmitFormOnChange.d.ts +4 -0
- package/dist/types/src/utils/createContext.d.ts +8 -0
- package/dist/types/src/utils/fixedForwardRef.d.ts +7 -0
- package/dist/types/src/utils/useImperativeForwardedRef.d.ts +11 -0
- package/dist/types/src/utils/useThrowAsyncError.d.ts +5 -0
- package/dist/types/src/utils/useToggle.d.ts +4 -0
- package/package.json +17 -3
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import "react-hook-form";
|
|
4
|
+
t.lazy(
|
|
5
5
|
() => import("@hookform/devtools").then((o) => ({
|
|
6
6
|
default: o.DevTool
|
|
7
7
|
}))
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
return null;
|
|
11
|
-
const { control: r } = n();
|
|
12
|
-
return /* @__PURE__ */ t(e.Suspense, { fallback: null, children: /* @__PURE__ */ t(a, { control: r, ...l }) });
|
|
13
|
-
}, u = s;
|
|
8
|
+
);
|
|
9
|
+
const e = (o) => null, p = e;
|
|
14
10
|
export {
|
|
15
|
-
|
|
11
|
+
p as default
|
|
16
12
|
};
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.entries(o).filter(
|
|
6
|
-
([r, e]) => (
|
|
7
|
-
// not root path
|
|
8
|
-
!s(r) && // non-field
|
|
9
|
-
!i(e) && // does not have marker
|
|
10
|
-
!m(r, t)
|
|
11
|
-
)
|
|
1
|
+
import s from "./isOrphanFormError.mjs";
|
|
2
|
+
const a = (r, t) => Object.fromEntries(
|
|
3
|
+
Object.entries(r).filter(
|
|
4
|
+
([e, o]) => s(e, o, t)
|
|
12
5
|
)
|
|
13
6
|
);
|
|
14
7
|
export {
|
|
15
|
-
|
|
8
|
+
a as default
|
|
16
9
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import m from "../isFieldError.mjs";
|
|
2
|
+
import { hasNonFieldErrorMarkerInDOM as t } from "../nonfield/FormNonFieldErrorMarker.utils.mjs";
|
|
3
|
+
import s from "../root/isFormErrorPathRoot.mjs";
|
|
4
|
+
const n = (r, o, i) => (
|
|
5
|
+
// not root path
|
|
6
|
+
!s(r) && // non-field
|
|
7
|
+
!m(o) && // does not have marker
|
|
8
|
+
!t(r, i)
|
|
9
|
+
);
|
|
10
|
+
export {
|
|
11
|
+
n as default
|
|
12
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const o =
|
|
6
|
-
|
|
7
|
-
disabled: !
|
|
8
|
-
isDev: s,
|
|
2
|
+
import e from "../useFormErrorsToConsole.mjs";
|
|
3
|
+
import n from "./useOrphanFormErrorsMemo.mjs";
|
|
4
|
+
const t = (r, s) => {
|
|
5
|
+
const o = n(r);
|
|
6
|
+
e("Orphan errors detected!", o, {
|
|
7
|
+
disabled: !s,
|
|
9
8
|
isError: !0,
|
|
10
9
|
data: {
|
|
11
10
|
location: window.location,
|
|
12
11
|
orphans: o
|
|
13
12
|
}
|
|
14
13
|
});
|
|
15
|
-
},
|
|
14
|
+
}, i = t;
|
|
16
15
|
export {
|
|
17
|
-
|
|
16
|
+
i as default
|
|
18
17
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}, f = c;
|
|
1
|
+
import s from "./consoleErrors.mjs";
|
|
2
|
+
const u = (o, r, t) => {
|
|
3
|
+
s(o, r, t);
|
|
4
|
+
}, c = u;
|
|
6
5
|
export {
|
|
7
|
-
|
|
6
|
+
c as default
|
|
8
7
|
};
|
package/dist/esm/exports.mjs
CHANGED
|
@@ -6,15 +6,15 @@ import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
|
6
6
|
import { default as x } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
7
7
|
import { default as i } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
8
8
|
import { default as E } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs";
|
|
9
|
-
import { default as
|
|
9
|
+
import { default as S } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
10
10
|
import { default as c } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
11
11
|
import { default as P } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
12
|
+
import { default as G } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
13
|
+
import { default as O } from "./errors/useFormErrorsEffect.mjs";
|
|
14
|
+
import { default as I } from "./errors/useFormErrorsIfAny.mjs";
|
|
15
|
+
import { default as k } from "./errors/useFormErrorsMemo.mjs";
|
|
16
16
|
import { default as B } from "./errors/useFormRequestSubmit.mjs";
|
|
17
|
-
import { default as
|
|
17
|
+
import { default as R } from "./form/Form.mjs";
|
|
18
18
|
import { default as N } from "./form/FormWithProviders.mjs";
|
|
19
19
|
import { default as U } from "./form/useForm.mjs";
|
|
20
20
|
import { default as q } from "./form/useFormWithProviders.mjs";
|
|
@@ -24,19 +24,21 @@ import { default as K } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
|
24
24
|
import { default as V } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
25
25
|
import { default as Y } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
26
26
|
import { default as _ } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
27
|
-
import { default as rr } from "./form/context/group/
|
|
28
|
-
import { default as er } from "./form/context/group/
|
|
29
|
-
import { default as sr } from "./form/context/group/
|
|
30
|
-
import { default as ur } from "./form/context/group/
|
|
31
|
-
import { default as fr } from "./form/
|
|
32
|
-
import {
|
|
33
|
-
import { default as xr } from "./
|
|
34
|
-
import {
|
|
35
|
-
import { default as Er } from "./submit/
|
|
36
|
-
import { default as
|
|
37
|
-
import { default as cr } from "./submit/
|
|
27
|
+
import { default as rr } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
28
|
+
import { default as er } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
29
|
+
import { default as sr } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
30
|
+
import { default as ur } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
31
|
+
import { default as fr } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
32
|
+
import { default as dr } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
33
|
+
import { default as xr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
34
|
+
import { FormSubmitError as ir } from "./submit/error/FormSubmitError.mjs";
|
|
35
|
+
import { default as Er } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
36
|
+
import { default as Sr } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
37
|
+
import { default as cr } from "./submit/useResetFormOnSubmitError.mjs";
|
|
38
|
+
import { default as Pr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
39
|
+
import { default as Gr } from "./submit/useSubmitFormOnChange.mjs";
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
R as Form,
|
|
40
42
|
f as FormErrorMessage,
|
|
41
43
|
d as FormErrorMessageByPath,
|
|
42
44
|
u as FormErrorsFlatContextProvider,
|
|
@@ -44,33 +46,35 @@ export {
|
|
|
44
46
|
x as FormNonFieldErrorMarker,
|
|
45
47
|
i as FormNonFieldErrorMarkerHtmlAttribute,
|
|
46
48
|
L as FormProvider,
|
|
47
|
-
|
|
49
|
+
ir as FormSubmitError,
|
|
48
50
|
w as FormUtilsContextProvider,
|
|
49
51
|
N as FormWithProviders,
|
|
50
52
|
e as LazyDevTool,
|
|
51
|
-
|
|
53
|
+
xr as getSubmitterButtonData,
|
|
52
54
|
U as useForm,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
G as useFormErrorConsoleDebug,
|
|
56
|
+
O as useFormErrorsEffect,
|
|
55
57
|
s as useFormErrorsFlatContext,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
I as useFormErrorsIfAny,
|
|
59
|
+
k as useFormErrorsMemo,
|
|
58
60
|
Y as useFormGroupChildIsMountedTracker,
|
|
59
61
|
_ as useFormGroupChildIsSubmittingTracker,
|
|
60
|
-
rr as
|
|
61
|
-
er as
|
|
62
|
-
sr as
|
|
63
|
-
ur as
|
|
62
|
+
rr as useFormGroupChildTracker,
|
|
63
|
+
er as useFormGroupIsAnyBusy,
|
|
64
|
+
sr as useFormGroupIsChildBusy,
|
|
65
|
+
ur as useFormGroupIsParentBusy,
|
|
66
|
+
fr as useFormGroupParentTracker,
|
|
64
67
|
E as useFormHasOrphanAndNoFieldErrors,
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
Er as useFormOnSubmitSuccessful,
|
|
69
|
+
Sr as useFormOnSubmitSuccessfulAndReset,
|
|
70
|
+
dr as useFormOrParentIsBusy,
|
|
67
71
|
B as useFormRequestSubmit,
|
|
68
72
|
K as useFormUtilsContext,
|
|
69
73
|
q as useFormWithProviders,
|
|
70
|
-
|
|
74
|
+
S as useOrphanFormErrorsMemo,
|
|
71
75
|
c as useOrphanFormErrorsToConsole,
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
Pr as useResetFormAfterSubmitSuccessful,
|
|
77
|
+
cr as useResetFormOnSubmitError,
|
|
74
78
|
P as useRootFormFieldErrorsMemo,
|
|
75
|
-
|
|
79
|
+
Gr as useSubmitFormOnChange
|
|
76
80
|
};
|
package/dist/esm/form/Form.mjs
CHANGED
|
@@ -1,71 +1,63 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as C, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { useFormContext as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
formRef: F,
|
|
3
|
+
import { useFormContext as O } from "react-hook-form";
|
|
4
|
+
import v from "../devtool/LazyDevTool.mjs";
|
|
5
|
+
import T from "../errors/root/FormRootErrorsFromContext.mjs";
|
|
6
|
+
import V from "../submit/error/handleFormSubmitError.mjs";
|
|
7
|
+
import j from "../submit/useResetFormOnSubmitError.mjs";
|
|
8
|
+
import w from "../submit/useSubmitFormOnChange.mjs";
|
|
9
|
+
import E from "../utils/useImperativeForwardedRef.mjs";
|
|
10
|
+
import P from "./FormBase.mjs";
|
|
11
|
+
function G({
|
|
12
|
+
formId: u,
|
|
13
|
+
formRef: h,
|
|
15
14
|
Fields: f,
|
|
16
15
|
//
|
|
17
16
|
onSubmit: d,
|
|
18
17
|
onSubmitError: l,
|
|
19
|
-
onSubmitInvalid:
|
|
18
|
+
onSubmitInvalid: F,
|
|
20
19
|
//
|
|
21
20
|
options: r,
|
|
22
21
|
//
|
|
23
|
-
children:
|
|
24
|
-
...
|
|
22
|
+
children: x,
|
|
23
|
+
...g
|
|
25
24
|
}) {
|
|
26
|
-
const m =
|
|
27
|
-
|
|
28
|
-
const
|
|
25
|
+
const m = O(), c = E(h);
|
|
26
|
+
w(c, !(r != null && r.submitOnChange)), j(!(r != null && r.resetValuesOnSubmitError));
|
|
27
|
+
const R = async (e) => {
|
|
29
28
|
r != null && r.stopSubmitPropagation && e.stopPropagation();
|
|
30
29
|
try {
|
|
31
|
-
await m.handleSubmit(
|
|
30
|
+
await m.handleSubmit(b, F)(e);
|
|
32
31
|
} catch (a) {
|
|
33
|
-
|
|
32
|
+
y(a, e);
|
|
34
33
|
}
|
|
35
|
-
},
|
|
34
|
+
}, b = (e, a) => d == null ? void 0 : d(
|
|
36
35
|
e,
|
|
37
36
|
m,
|
|
38
37
|
a
|
|
39
|
-
),
|
|
40
|
-
|
|
38
|
+
), y = (e, a) => {
|
|
39
|
+
V(e, m), l == null || l(e, m, a);
|
|
41
40
|
};
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
|
|
41
|
+
return /* @__PURE__ */ C(
|
|
42
|
+
P,
|
|
44
43
|
{
|
|
45
|
-
id:
|
|
46
|
-
onSubmit:
|
|
44
|
+
id: u,
|
|
45
|
+
onSubmit: R,
|
|
47
46
|
noValidate: !0,
|
|
48
47
|
style: {
|
|
49
48
|
position: "relative"
|
|
50
49
|
},
|
|
51
|
-
...
|
|
50
|
+
...g,
|
|
52
51
|
ref: c,
|
|
53
52
|
children: [
|
|
54
|
-
(r == null ? void 0 : r.devTool) !== "disabled" && /* @__PURE__ */ t(
|
|
55
|
-
T,
|
|
56
|
-
{
|
|
57
|
-
isDev: u,
|
|
58
|
-
placement: "top-right",
|
|
59
|
-
...r == null ? void 0 : r.devTool
|
|
60
|
-
}
|
|
61
|
-
),
|
|
53
|
+
(r == null ? void 0 : r.devTool) !== "disabled" && /* @__PURE__ */ t(v, { placement: "top-right", ...r == null ? void 0 : r.devTool }),
|
|
62
54
|
f && /* @__PURE__ */ t(f, { ctx: m }),
|
|
63
|
-
|
|
64
|
-
!(r != null && r.hideRootErrors) && /* @__PURE__ */ t(
|
|
55
|
+
x,
|
|
56
|
+
!(r != null && r.hideRootErrors) && /* @__PURE__ */ t(T, {})
|
|
65
57
|
]
|
|
66
58
|
}
|
|
67
59
|
);
|
|
68
60
|
}
|
|
69
61
|
export {
|
|
70
|
-
|
|
62
|
+
G as default
|
|
71
63
|
};
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { FormProvider as
|
|
3
|
-
import
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
children: f
|
|
2
|
+
import { FormProvider as f } from "react-hook-form";
|
|
3
|
+
import n from "./utils/FormUtilsContextProvider.mjs";
|
|
4
|
+
function v({
|
|
5
|
+
formId: o,
|
|
6
|
+
formRef: m,
|
|
7
|
+
rhf: i,
|
|
8
|
+
form: t,
|
|
9
|
+
utils: e,
|
|
10
|
+
children: d
|
|
12
11
|
}) {
|
|
13
|
-
return /* @__PURE__ */ r(
|
|
14
|
-
|
|
12
|
+
return /* @__PURE__ */ r(f, { ...i, children: /* @__PURE__ */ r(
|
|
13
|
+
n,
|
|
15
14
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children: f
|
|
15
|
+
formId: o,
|
|
16
|
+
formRef: m,
|
|
17
|
+
formProps: t,
|
|
18
|
+
...e,
|
|
19
|
+
children: d
|
|
22
20
|
}
|
|
23
21
|
) });
|
|
24
22
|
}
|
|
25
23
|
export {
|
|
26
|
-
|
|
24
|
+
v as default
|
|
27
25
|
};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
o.useEffect(() => {
|
|
6
|
-
const e = (t) => {
|
|
7
|
-
r(s, t);
|
|
8
|
-
};
|
|
9
|
-
return e(!0), () => {
|
|
10
|
-
e(!1);
|
|
11
|
-
};
|
|
12
|
-
}, []);
|
|
13
|
-
}, m = c;
|
|
1
|
+
import r from "./useFormGroupChildTracker.mjs";
|
|
2
|
+
const o = () => {
|
|
3
|
+
r(!0);
|
|
4
|
+
}, u = o;
|
|
14
5
|
export {
|
|
15
|
-
|
|
6
|
+
u as default
|
|
16
7
|
};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { _useFormGroupContext as u } from "./index.mjs";
|
|
1
|
+
import { useFormState as o } from "react-hook-form";
|
|
2
|
+
import t from "./useFormGroupChildTracker.mjs";
|
|
4
3
|
const i = () => {
|
|
5
|
-
const { isSubmitting:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, [o, r, t]), e.useEffect(() => () => {
|
|
9
|
-
t(r, !1);
|
|
10
|
-
}, []);
|
|
11
|
-
}, f = i;
|
|
4
|
+
const { isSubmitting: r } = o();
|
|
5
|
+
t(r);
|
|
6
|
+
}, u = i;
|
|
12
7
|
export {
|
|
13
|
-
|
|
8
|
+
u as default
|
|
14
9
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import o from "react";
|
|
2
|
+
import { _useFormGroupContext as t } from "./index.mjs";
|
|
3
|
+
const u = (s) => {
|
|
4
|
+
const { setBusyId: e } = t().children, r = o.useId();
|
|
5
|
+
o.useEffect(() => {
|
|
6
|
+
e(r, s);
|
|
7
|
+
}, [s, r, e]), o.useEffect(() => () => {
|
|
8
|
+
e(r, !1);
|
|
9
|
+
}, []);
|
|
10
|
+
}, d = u;
|
|
11
|
+
export {
|
|
12
|
+
d as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import t from "../../useFormIsBusy.mjs";
|
|
2
|
+
import { _useFormGroupContextMaybe as e } from "./index.mjs";
|
|
3
|
+
const u = () => {
|
|
4
|
+
var s;
|
|
5
|
+
const r = t(), o = (s = e()) == null ? void 0 : s.parent.isBusy;
|
|
6
|
+
return !!(r || o);
|
|
7
|
+
}, a = u;
|
|
8
|
+
export {
|
|
9
|
+
a as default
|
|
10
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { isDevelopment as i } from "../../../env-conditions/production.mjs";
|
|
2
3
|
import p from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import s from "../../../errors/useFormErrorConsoleDebug.mjs";
|
|
5
|
+
import F from "../../../errors/useFormRequestSubmit.mjs";
|
|
6
|
+
import u from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
7
|
+
import a from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
|
|
7
8
|
import { _FormUtilsContextProvider as l } from "./useFormUtilsContext.mjs";
|
|
8
9
|
function O({
|
|
9
|
-
isDev: m,
|
|
10
10
|
formRef: o,
|
|
11
11
|
onSubmitSuccessfulAndReset: r,
|
|
12
|
-
children:
|
|
12
|
+
children: m
|
|
13
13
|
}) {
|
|
14
|
-
const
|
|
15
|
-
return
|
|
14
|
+
const t = F(o);
|
|
15
|
+
return s(i), p(o, !0), a({ enabled: !!r }), u(() => {
|
|
16
16
|
r == null || r();
|
|
17
|
-
}), /* @__PURE__ */
|
|
17
|
+
}), /* @__PURE__ */ e(l, { value: { formRef: o, requestSubmit: t }, children: m });
|
|
18
18
|
}
|
|
19
19
|
export {
|
|
20
20
|
O as default
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useForm as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
rhf: m,
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import i from "react";
|
|
3
|
+
import { useForm as u } from "react-hook-form";
|
|
4
|
+
import F from "../utils/useImperativeForwardedRef.mjs";
|
|
5
|
+
import c from "./Form.mjs";
|
|
6
|
+
const f = ({
|
|
7
|
+
rhf: e,
|
|
9
8
|
form: o
|
|
10
9
|
}) => {
|
|
11
|
-
const r =
|
|
10
|
+
const r = i.useId(), m = u(e), t = F();
|
|
12
11
|
return {
|
|
13
12
|
id: r,
|
|
14
13
|
ref: t,
|
|
15
|
-
context:
|
|
16
|
-
Form: ({ children:
|
|
17
|
-
|
|
14
|
+
context: m,
|
|
15
|
+
Form: ({ children: s }) => /* @__PURE__ */ n(
|
|
16
|
+
c,
|
|
18
17
|
{
|
|
19
|
-
isDev: e,
|
|
20
18
|
formId: r,
|
|
21
19
|
formRef: t,
|
|
22
20
|
onSubmit: o == null ? void 0 : o.onSubmit,
|
|
23
21
|
...o,
|
|
24
|
-
children:
|
|
22
|
+
children: s
|
|
25
23
|
}
|
|
26
24
|
)
|
|
27
25
|
};
|
|
28
|
-
},
|
|
26
|
+
}, b = f;
|
|
29
27
|
export {
|
|
30
|
-
|
|
28
|
+
b as default
|
|
31
29
|
};
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
utils: m
|
|
3
|
+
import s from "./context/FormProvider.mjs";
|
|
4
|
+
import f from "./useForm.mjs";
|
|
5
|
+
const d = ({
|
|
6
|
+
rhf: t,
|
|
7
|
+
form: o,
|
|
8
|
+
utils: e
|
|
10
9
|
}) => {
|
|
11
|
-
const r =
|
|
10
|
+
const r = f({ rhf: t, form: o });
|
|
12
11
|
return {
|
|
13
12
|
...r,
|
|
14
|
-
Provider: ({ children:
|
|
15
|
-
|
|
13
|
+
Provider: ({ children: m }) => /* @__PURE__ */ i(
|
|
14
|
+
s,
|
|
16
15
|
{
|
|
17
|
-
isDev: o,
|
|
18
16
|
formRef: r.ref,
|
|
19
17
|
rhf: r.context,
|
|
20
18
|
formId: r.id,
|
|
21
|
-
form:
|
|
22
|
-
utils:
|
|
23
|
-
children:
|
|
19
|
+
form: o,
|
|
20
|
+
utils: e,
|
|
21
|
+
children: m
|
|
24
22
|
}
|
|
25
23
|
)
|
|
26
24
|
};
|
|
27
|
-
},
|
|
25
|
+
}, P = d;
|
|
28
26
|
export {
|
|
29
|
-
|
|
27
|
+
P as default
|
|
30
28
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
|
|
3
|
+
|
|
4
|
+
export type LazyDevToolProps = Omit<DevtoolUIProps, 'control'>;
|
|
5
|
+
/**
|
|
6
|
+
* Lazy-loaded RHF DevTool.
|
|
7
|
+
*/
|
|
8
|
+
declare const LazyDevTool: React.FC<LazyDevToolProps>;
|
|
9
|
+
export default LazyDevTool;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determined whether env is dev via `imports`.
|
|
3
|
+
*
|
|
4
|
+
* Technique borrowed from react-error-boundary {@link https://github.com/bvaughn/react-error-boundary/blob/master/package.json}.
|
|
5
|
+
* Assign `boolean` type to avoid `@typescript-eslint/no-unnecessary-condition`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDevelopment: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isDevelopment: boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FieldErrors, FieldValues } from 'react-hook-form';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Output form values and errors to console.
|
|
5
|
+
*/
|
|
6
|
+
declare const consoleErrors: (message: string, form: {
|
|
7
|
+
values: FieldValues;
|
|
8
|
+
errors: FieldErrors;
|
|
9
|
+
}, options?: {
|
|
10
|
+
other?: Record<string, unknown>;
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
}) => void;
|
|
13
|
+
export default consoleErrors;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FlatFieldErrors } from '../flat/types';
|
|
2
|
+
|
|
3
|
+
export type FormErrorsFlatContext = {
|
|
4
|
+
all: FlatFieldErrors;
|
|
5
|
+
roots: FlatFieldErrors;
|
|
6
|
+
orphans: FlatFieldErrors;
|
|
7
|
+
};
|
|
8
|
+
declare const useFormErrorsFlatContextMaybe: () => FormErrorsFlatContext | undefined, useFormErrorsFlatContext: () => FormErrorsFlatContext, _FormErrorsFlatContextProvider: import('react').Provider<FormErrorsFlatContext | undefined>;
|
|
9
|
+
export default useFormErrorsFlatContext;
|
|
10
|
+
export { _FormErrorsFlatContextProvider, useFormErrorsFlatContextMaybe };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = React.PropsWithChildren<{
|
|
3
|
+
formRef: React.RefObject<HTMLFormElement>;
|
|
4
|
+
outputErrors?: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Provides a flattened version of the form errors.
|
|
8
|
+
* Allows flattening and filtering to happen once per errors change.
|
|
9
|
+
*/
|
|
10
|
+
declare const FormErrorsFlatContextProvider: React.FC<Props>;
|
|
11
|
+
export default FormErrorsFlatContextProvider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FieldErrors } from 'react-hook-form';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Only flattens a {@link FieldErrors} object.
|
|
5
|
+
* @returns e.g.,
|
|
6
|
+
* ```
|
|
7
|
+
* {
|
|
8
|
+
* "address.street.type": "too_short",
|
|
9
|
+
* "address.street.ref.value": "123",
|
|
10
|
+
* "address.street.message": "Required."
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare const flattenFieldErrors: (errors: FieldErrors) => Record<string, unknown>;
|
|
15
|
+
export default flattenFieldErrors;
|