@paragrav/rhf-utils 0.0.93 → 0.0.94
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/client/config/useRhfUtilsClientConfigContext.mjs +10 -0
- package/dist/esm/client/index.mjs +3 -4
- package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +12 -11
- package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +2 -2
- package/dist/esm/devtool/LazyDevTool.mjs +14 -7
- package/dist/esm/exports.mjs +80 -82
- package/dist/esm/form/Form.mjs +62 -55
- package/dist/esm/form/context/utils/FormUtilsContextProvider.mjs +28 -28
- package/dist/esm/form/useForm.mjs +13 -15
- package/dist/types/client/{config.d.ts → config/RhfUtilsClientConfig.d.ts} +9 -5
- package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +5 -0
- package/dist/types/client/index.d.ts +2 -2
- package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +2 -2
- package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +1 -1
- package/dist/types/devtool/LazyDevTool.d.ts +3 -1
- package/dist/types/exports.d.ts +1 -2
- package/dist/types/form/Form.d.ts +2 -2
- package/dist/types/form/_FormBase.d.ts +2 -2
- package/dist/types/form/useForm.d.ts +1 -3
- package/package.json +1 -7
- package/dist/esm/env-conditions/production.mjs +0 -4
- package/dist/types/env-conditions/development.d.ts +0 -7
- package/dist/types/env-conditions/production.d.ts +0 -1
- package/dist/types/form/_Form.d.ts +0 -11
- package/dist/types/form/_FormProviders.d.ts +0 -12
|
@@ -19,10 +19,9 @@ const v = (s) => (r) => {
|
|
|
19
19
|
FormWithProviders: l(s, r)
|
|
20
20
|
};
|
|
21
21
|
}, d = (s, r) => function(n, o) {
|
|
22
|
-
var t, e, m,
|
|
22
|
+
var t, e, m, f, u;
|
|
23
23
|
return {
|
|
24
24
|
...o,
|
|
25
|
-
config: r,
|
|
26
25
|
rhf: {
|
|
27
26
|
...(t = r.defaultOptions) == null ? void 0 : t.rhf,
|
|
28
27
|
...o.rhf,
|
|
@@ -32,8 +31,8 @@ const v = (s) => (r) => {
|
|
|
32
31
|
...(e = r.defaultOptions) == null ? void 0 : e.form,
|
|
33
32
|
...o.options,
|
|
34
33
|
classNames: [
|
|
35
|
-
...((
|
|
36
|
-
...((
|
|
34
|
+
...((f = (m = r.defaultOptions) == null ? void 0 : m.form) == null ? void 0 : f.classNames) ?? [],
|
|
35
|
+
...((u = o.options) == null ? void 0 : u.classNames) ?? []
|
|
37
36
|
]
|
|
38
37
|
}
|
|
39
38
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import e from "react";
|
|
3
|
+
import { _RhfUtilsClientConfigContextProvider as l } from "../../config/useRhfUtilsClientConfigContext.mjs";
|
|
4
|
+
import f from "../createRhfUtilsClientForZod.mjs";
|
|
5
|
+
import { _RhfUtilsClientForZodContextProvider as s } from "./useRhfUtilsClientForZodContext.mjs";
|
|
6
|
+
const d = ({
|
|
7
|
+
config: r,
|
|
8
|
+
children: i
|
|
8
9
|
}) => {
|
|
9
|
-
const [r] =
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
},
|
|
10
|
+
const [t] = e.useState(r), [n] = e.useState(() => f(t));
|
|
11
|
+
return /* @__PURE__ */ o(l, { value: t, children: /* @__PURE__ */ o(s, { value: n, children: i }) });
|
|
12
|
+
}, p = d;
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
+
p as default
|
|
14
15
|
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import "react-hook-form";
|
|
4
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import e from "react";
|
|
3
|
+
import { useFormContext as n } from "react-hook-form";
|
|
4
|
+
const a = e.lazy(
|
|
5
5
|
() => import("@hookform/devtools").then((o) => ({
|
|
6
6
|
default: o.DevTool
|
|
7
7
|
}))
|
|
8
|
-
)
|
|
9
|
-
|
|
8
|
+
), s = ({
|
|
9
|
+
isDevelopment: o,
|
|
10
|
+
...l
|
|
11
|
+
}) => {
|
|
12
|
+
if (!o)
|
|
13
|
+
return null;
|
|
14
|
+
const { control: r } = n();
|
|
15
|
+
return /* @__PURE__ */ t(e.Suspense, { fallback: null, children: /* @__PURE__ */ t(a, { control: r, ...l }) });
|
|
16
|
+
}, u = s;
|
|
10
17
|
export {
|
|
11
|
-
|
|
18
|
+
u as default
|
|
12
19
|
};
|
package/dist/esm/exports.mjs
CHANGED
|
@@ -2,91 +2,89 @@ import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextPr
|
|
|
2
2
|
import { default as s } from "./client/zod/context/RhfUtilsZodFormWithProviders.mjs";
|
|
3
3
|
import { default as u } from "./client/zod/context/useRhfUtilsClientForZodContext.mjs";
|
|
4
4
|
import { default as m } from "./client/zod/context/useRhfUtilsZodForm.mjs";
|
|
5
|
-
import { default as d } from "./
|
|
6
|
-
import { default as x } from "./
|
|
7
|
-
import { default as i } from "./errors/flat/context/
|
|
8
|
-
import { default as E } from "./errors/flat/
|
|
9
|
-
import { default as h } from "./errors/
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as P } from "./errors/
|
|
12
|
-
import { default as y } from "./errors/nonfield/
|
|
13
|
-
import { default as O } from "./errors/
|
|
14
|
-
import { default as G } from "./errors/orphan/
|
|
15
|
-
import { default as T } from "./errors/orphan/
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as Z } from "./errors/
|
|
19
|
-
import { default as L } from "./errors/
|
|
20
|
-
import { default as N } from "./errors/
|
|
21
|
-
import { default as q } from "./errors/
|
|
22
|
-
import { default as j } from "./errors/
|
|
23
|
-
import { default as J } from "./
|
|
24
|
-
import { default as Q } from "./form/
|
|
25
|
-
import { default as X } from "./form/
|
|
26
|
-
import { default as _ } from "./form/
|
|
27
|
-
import { default as rr } from "./form/
|
|
28
|
-
import { default as er } from "./form/context/utils/
|
|
29
|
-
import { default as sr } from "./form/context/
|
|
30
|
-
import { default as ur } from "./form/context/group/
|
|
31
|
-
import { default as mr } from "./form/context/group/
|
|
32
|
-
import { default as dr } from "./form/context/group/
|
|
33
|
-
import { default as xr } from "./form/context/group/
|
|
34
|
-
import { default as ir } from "./form/context/group/
|
|
35
|
-
import { default as Er } from "./form/context/group/
|
|
36
|
-
import { default as hr } from "./form/context/group/
|
|
37
|
-
import { default as
|
|
38
|
-
import { default as Pr } from "./form/
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import { default as Gr } from "./submit/
|
|
42
|
-
import { default as Tr } from "./submit/
|
|
43
|
-
import { default as
|
|
44
|
-
import { default as
|
|
45
|
-
import { default as Zr } from "./submit/useSubmitFormOnChange.mjs";
|
|
5
|
+
import { default as d } from "./devtool/LazyDevTool.mjs";
|
|
6
|
+
import { default as x } from "./errors/flat/context/FlatFieldErrorsContextProvider.mjs";
|
|
7
|
+
import { default as i } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
|
|
8
|
+
import { default as E } from "./errors/flat/FlatFieldErrorsList.mjs";
|
|
9
|
+
import { default as h } from "./errors/message/FormErrorMessage.mjs";
|
|
10
|
+
import { default as b } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
11
|
+
import { default as P } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
12
|
+
import { default as y } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
13
|
+
import { default as O } from "./errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.mjs";
|
|
14
|
+
import { default as G } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
15
|
+
import { default as T } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
16
|
+
import { default as k } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
|
|
17
|
+
import { default as U } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
18
|
+
import { default as Z } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
19
|
+
import { default as L } from "./errors/useFormErrorsEffect.mjs";
|
|
20
|
+
import { default as N } from "./errors/useFormErrorsIfAny.mjs";
|
|
21
|
+
import { default as q } from "./errors/useFormErrorsTransformMemo.mjs";
|
|
22
|
+
import { default as j } from "./errors/useFormRequestSubmit.mjs";
|
|
23
|
+
import { default as J } from "./form/Form.mjs";
|
|
24
|
+
import { default as Q } from "./form/FormProviders.mjs";
|
|
25
|
+
import { default as X } from "./form/FormWithProviders.mjs";
|
|
26
|
+
import { default as _ } from "./form/useForm.mjs";
|
|
27
|
+
import { default as rr } from "./form/context/utils/FormUtilsContextProvider.mjs";
|
|
28
|
+
import { default as er } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
29
|
+
import { default as sr } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
30
|
+
import { default as ur } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
31
|
+
import { default as mr } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
32
|
+
import { default as dr } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
33
|
+
import { default as xr } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
34
|
+
import { default as ir } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
35
|
+
import { default as Er } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
36
|
+
import { default as hr } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
37
|
+
import { default as br } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
38
|
+
import { default as Pr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
39
|
+
import { FormSubmitError as yr } from "./submit/error/FormSubmitError.mjs";
|
|
40
|
+
import { default as Or } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
41
|
+
import { default as Gr } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
42
|
+
import { default as Tr } from "./submit/useResetFormOnSubmitError.mjs";
|
|
43
|
+
import { default as kr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
44
|
+
import { default as Ur } from "./submit/useSubmitFormOnChange.mjs";
|
|
46
45
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
x as FlatFieldErrorsContextProvider,
|
|
47
|
+
E as FlatFieldErrorsList,
|
|
48
|
+
J as Form,
|
|
49
|
+
h as FormErrorMessage,
|
|
50
|
+
b as FormErrorMessageByPath,
|
|
51
|
+
sr as FormGroupContextProvider,
|
|
52
|
+
P as FormNonFieldErrorMarker,
|
|
53
|
+
y as FormNonFieldErrorMarkerHtmlAttribute,
|
|
54
|
+
Q as FormProviders,
|
|
55
|
+
yr as FormSubmitError,
|
|
56
|
+
rr as FormUtilsContextProvider,
|
|
57
|
+
X as FormWithProviders,
|
|
58
|
+
d as LazyDevTool,
|
|
60
59
|
e as RhfUtilsClientForZodContextProvider,
|
|
61
60
|
s as RhfUtilsZodFormWithProviders,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
L as
|
|
68
|
-
N as
|
|
69
|
-
q as
|
|
70
|
-
|
|
71
|
-
mr as
|
|
72
|
-
dr as
|
|
73
|
-
xr as
|
|
74
|
-
ir as
|
|
75
|
-
Er as
|
|
76
|
-
hr as
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Gr as
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
T as
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
gr as useResetFormOnSubmitError,
|
|
61
|
+
k as RootErrorsListFromFlatFieldErrorsContext,
|
|
62
|
+
Pr as getSubmitterButtonData,
|
|
63
|
+
i as useFlatFieldErrorsContext,
|
|
64
|
+
_ as useForm,
|
|
65
|
+
Z as useFormErrorConsoleDebug,
|
|
66
|
+
L as useFormErrorsEffect,
|
|
67
|
+
N as useFormErrorsIfAny,
|
|
68
|
+
q as useFormErrorsTransformMemo,
|
|
69
|
+
ur as useFormGroupChildIsMountedTracker,
|
|
70
|
+
mr as useFormGroupChildIsSubmittingTracker,
|
|
71
|
+
dr as useFormGroupChildTracker,
|
|
72
|
+
xr as useFormGroupIsAnyBusy,
|
|
73
|
+
ir as useFormGroupIsChildBusy,
|
|
74
|
+
Er as useFormGroupIsParentBusy,
|
|
75
|
+
hr as useFormGroupParentTracker,
|
|
76
|
+
O as useFormHasOnlyOrphanFieldErrorsMemo,
|
|
77
|
+
Or as useFormOnSubmitSuccessful,
|
|
78
|
+
Gr as useFormOnSubmitSuccessfulAndReset,
|
|
79
|
+
br as useFormOrParentIsBusy,
|
|
80
|
+
j as useFormRequestSubmit,
|
|
81
|
+
er as useFormUtilsContext,
|
|
82
|
+
G as useOrphanFormErrorsMemo,
|
|
83
|
+
T as useOrphanFormErrorsToConsole,
|
|
84
|
+
kr as useResetFormAfterSubmitSuccessful,
|
|
85
|
+
Tr as useResetFormOnSubmitError,
|
|
88
86
|
u as useRhfUtilsClientForZodContext,
|
|
89
87
|
m as useRhfUtilsZodForm,
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
U as useRootFormFieldErrorsMemo,
|
|
89
|
+
Ur as useSubmitFormOnChange
|
|
92
90
|
};
|
package/dist/esm/form/Form.mjs
CHANGED
|
@@ -1,84 +1,91 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as F, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { useFormContext as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { useFormContext as _ } from "react-hook-form";
|
|
4
|
+
import j from "../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
5
|
+
import D from "../devtool/LazyDevTool.mjs";
|
|
6
|
+
import { FormSubmitError as N } from "../submit/error/FormSubmitError.mjs";
|
|
7
|
+
import P from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
8
|
+
import S from "./_Controller.mjs";
|
|
9
|
+
import T from "./_FormBase.mjs";
|
|
10
|
+
function q({
|
|
11
|
+
formId: n,
|
|
12
|
+
formRef: C,
|
|
12
13
|
//
|
|
13
|
-
onSubmit:
|
|
14
|
-
onSubmitError:
|
|
15
|
-
onSubmitInvalid:
|
|
16
|
-
Fields:
|
|
14
|
+
onSubmit: d,
|
|
15
|
+
onSubmitError: c,
|
|
16
|
+
onSubmitInvalid: y,
|
|
17
|
+
Fields: h,
|
|
17
18
|
//
|
|
18
|
-
form:
|
|
19
|
-
options:
|
|
20
|
-
config: a,
|
|
19
|
+
form: s,
|
|
20
|
+
options: t,
|
|
21
21
|
//
|
|
22
|
-
children:
|
|
22
|
+
children: f
|
|
23
23
|
}) {
|
|
24
|
-
const l =
|
|
25
|
-
|
|
24
|
+
const l = _(), e = j(), b = async (r) => {
|
|
25
|
+
t != null && t.stopSubmitPropagation && r.stopPropagation();
|
|
26
26
|
try {
|
|
27
|
-
await l.handleSubmit(
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
27
|
+
await l.handleSubmit(v, y)(r);
|
|
28
|
+
} catch (a) {
|
|
29
|
+
B(a, r);
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
31
|
+
}, v = (r, a) => d == null ? void 0 : d(
|
|
32
|
+
r,
|
|
33
33
|
l,
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
var
|
|
37
|
-
const m =
|
|
34
|
+
a
|
|
35
|
+
), B = (r, a) => {
|
|
36
|
+
var x;
|
|
37
|
+
const m = r instanceof N ? (
|
|
38
38
|
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
39
|
-
|
|
39
|
+
r
|
|
40
40
|
) : (
|
|
41
41
|
// if error is not FormSubmitError, consumer can provide global handler
|
|
42
|
-
(
|
|
42
|
+
(x = e == null ? void 0 : e.onSubmitError) == null ? void 0 : x.call(e, r)
|
|
43
43
|
);
|
|
44
|
-
m &&
|
|
45
|
-
|
|
44
|
+
m && P(l, m), c == null || c(
|
|
45
|
+
r,
|
|
46
46
|
l,
|
|
47
|
-
|
|
47
|
+
a
|
|
48
48
|
);
|
|
49
|
-
},
|
|
50
|
-
formId:
|
|
51
|
-
formRef:
|
|
49
|
+
}, i = {
|
|
50
|
+
formId: n,
|
|
51
|
+
formRef: C,
|
|
52
52
|
ctx: l,
|
|
53
|
-
options:
|
|
54
|
-
Controller:
|
|
55
|
-
},
|
|
53
|
+
options: t,
|
|
54
|
+
Controller: S
|
|
55
|
+
}, u = (r) => {
|
|
56
56
|
var m;
|
|
57
|
-
const
|
|
58
|
-
return
|
|
57
|
+
const a = (m = e == null ? void 0 : e.Children) == null ? void 0 : m[r];
|
|
58
|
+
return a && /* @__PURE__ */ o(a, { ...i });
|
|
59
59
|
};
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
60
|
+
return /* @__PURE__ */ F(
|
|
61
|
+
T,
|
|
62
62
|
{
|
|
63
63
|
noValidate: !0,
|
|
64
64
|
style: {
|
|
65
65
|
position: "relative"
|
|
66
66
|
},
|
|
67
|
-
config:
|
|
68
|
-
formRef:
|
|
69
|
-
...
|
|
70
|
-
className: [
|
|
71
|
-
onSubmit:
|
|
67
|
+
config: e,
|
|
68
|
+
formRef: C,
|
|
69
|
+
...s,
|
|
70
|
+
className: [t == null ? void 0 : t.classNames, s == null ? void 0 : s.className].filter(Boolean).join(" "),
|
|
71
|
+
onSubmit: b,
|
|
72
72
|
children: [
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
u("top"),
|
|
74
|
+
(t == null ? void 0 : t.devTool) !== "disabled" && /* @__PURE__ */ o(
|
|
75
|
+
D,
|
|
76
|
+
{
|
|
77
|
+
placement: "top-right",
|
|
78
|
+
isDevelopment: e == null ? void 0 : e.isDevelopment,
|
|
79
|
+
...t == null ? void 0 : t.devTool
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
h && /* @__PURE__ */ o(h, { ...i }),
|
|
83
|
+
f,
|
|
84
|
+
u("bottom")
|
|
78
85
|
]
|
|
79
86
|
}
|
|
80
87
|
);
|
|
81
88
|
}
|
|
82
89
|
export {
|
|
83
|
-
|
|
90
|
+
q as default
|
|
84
91
|
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
+
import C from "../../../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
3
|
+
import t from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
4
|
+
import f from "../../../errors/useFormErrorConsoleDebug.mjs";
|
|
5
5
|
import O from "../../../errors/useFormRequestSubmit.mjs";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { _FormUtilsContextProvider as
|
|
11
|
-
function
|
|
12
|
-
formId:
|
|
13
|
-
formRef:
|
|
14
|
-
onSubmitSuccessfulAndReset:
|
|
6
|
+
import E from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
7
|
+
import d from "../../../submit/useResetFormOnSubmitError.mjs";
|
|
8
|
+
import h from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
|
|
9
|
+
import x from "../../../submit/useSubmitFormOnChange.mjs";
|
|
10
|
+
import { _FormUtilsContextProvider as g } from "./useFormUtilsContext.mjs";
|
|
11
|
+
function M({
|
|
12
|
+
formId: l,
|
|
13
|
+
formRef: e,
|
|
14
|
+
onSubmitSuccessfulAndReset: m,
|
|
15
15
|
options: r,
|
|
16
16
|
children: a
|
|
17
17
|
}) {
|
|
18
|
-
const F = O(
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
),
|
|
22
|
-
|
|
18
|
+
const u = C(), F = O(e);
|
|
19
|
+
return f(
|
|
20
|
+
(u == null ? void 0 : u.isDevelopment) && !(r != null && r.disableFormErrorConsoleDebug)
|
|
21
|
+
), t(
|
|
22
|
+
e,
|
|
23
23
|
!(r != null && r.disableOrphanFormErrorsToConsole)
|
|
24
|
-
),
|
|
24
|
+
), x(e, {
|
|
25
25
|
disabled: !(r != null && r.submitOnChange)
|
|
26
|
-
}),
|
|
26
|
+
}), d({
|
|
27
27
|
disabled: !(r != null && r.resetValuesOnSubmitError)
|
|
28
|
-
}),
|
|
29
|
-
(r == null ? void 0 : r.resetFormAfterSubmitSuccessful) || !!
|
|
30
|
-
),
|
|
31
|
-
|
|
32
|
-
}), /* @__PURE__ */
|
|
33
|
-
|
|
28
|
+
}), h(
|
|
29
|
+
(r == null ? void 0 : r.resetFormAfterSubmitSuccessful) || !!m
|
|
30
|
+
), E(() => {
|
|
31
|
+
m == null || m();
|
|
32
|
+
}), /* @__PURE__ */ b(
|
|
33
|
+
g,
|
|
34
34
|
{
|
|
35
|
-
value: { formId:
|
|
35
|
+
value: { formId: l, formRef: e, requestSubmit: F, options: r },
|
|
36
36
|
children: a
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
export {
|
|
41
|
-
|
|
41
|
+
M as default
|
|
42
42
|
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import m from "react";
|
|
2
|
-
import { useForm as
|
|
3
|
-
import { FormSubmitError as
|
|
4
|
-
const
|
|
2
|
+
import { useForm as d } from "react-hook-form";
|
|
3
|
+
import { FormSubmitError as F } from "../submit/error/FormSubmitError.mjs";
|
|
4
|
+
const a = ({
|
|
5
5
|
onSubmit: t,
|
|
6
6
|
onSubmitError: e,
|
|
7
7
|
onSubmitInvalid: f,
|
|
8
8
|
defaultValues: n,
|
|
9
9
|
Fields: p,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
options: d
|
|
10
|
+
rhf: u,
|
|
11
|
+
form: c,
|
|
12
|
+
options: i
|
|
14
13
|
}) => {
|
|
15
|
-
const o = m.useId(), s =
|
|
16
|
-
...
|
|
14
|
+
const o = m.useId(), s = d({
|
|
15
|
+
...u,
|
|
17
16
|
defaultValues: n
|
|
18
17
|
}), r = m.useRef(null);
|
|
19
18
|
return {
|
|
@@ -24,7 +23,7 @@ const P = ({
|
|
|
24
23
|
formId: o,
|
|
25
24
|
formRef: r,
|
|
26
25
|
rhfForm: s,
|
|
27
|
-
options:
|
|
26
|
+
options: i
|
|
28
27
|
},
|
|
29
28
|
formProps: {
|
|
30
29
|
Fields: p,
|
|
@@ -33,12 +32,11 @@ const P = ({
|
|
|
33
32
|
onSubmitInvalid: f,
|
|
34
33
|
formId: o,
|
|
35
34
|
formRef: r,
|
|
36
|
-
|
|
37
|
-
form: i
|
|
35
|
+
form: c
|
|
38
36
|
},
|
|
39
|
-
FormSubmitError:
|
|
37
|
+
FormSubmitError: F
|
|
40
38
|
};
|
|
41
|
-
},
|
|
39
|
+
}, I = a;
|
|
42
40
|
export {
|
|
43
|
-
|
|
41
|
+
I as default
|
|
44
42
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { UseFormProps } from 'react-hook-form';
|
|
2
|
-
import { FormChildrenSlots } from '
|
|
3
|
-
import { UseFormFieldsProps } from '
|
|
4
|
-
import { UseFormOptions } from '
|
|
5
|
-
import { FormSubmitError } from '
|
|
2
|
+
import { FormChildrenSlots } from '../../form/Form';
|
|
3
|
+
import { UseFormFieldsProps } from '../../form/useForm';
|
|
4
|
+
import { UseFormOptions } from '../../form/useFormOptions';
|
|
5
|
+
import { FormSubmitError } from '../../submit/error/FormSubmitError';
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type RhfUtilsClientConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* Some behavior is dependent on environment. (e.g., console logging errors in dev)
|
|
10
|
+
*/
|
|
11
|
+
isDevelopment?: boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Default options for all forms. (Are overridden by form-specific options.)
|
|
10
14
|
*/
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RhfUtilsClientConfig } from './RhfUtilsClientConfig';
|
|
2
|
+
|
|
3
|
+
declare const useRhfUtilsClientConfigMaybeContext: () => RhfUtilsClientConfig | undefined, _RhfUtilsClientConfigContextProvider: import('react').Provider<RhfUtilsClientConfig | undefined>;
|
|
4
|
+
export default useRhfUtilsClientConfigMaybeContext;
|
|
5
|
+
export { _RhfUtilsClientConfigContextProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Resolver } from 'react-hook-form';
|
|
2
|
-
import {
|
|
2
|
+
import { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';
|
|
3
3
|
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
4
|
import { SafeFieldValues } from '../form/SafeFieldValues';
|
|
5
5
|
import { UseFormProps, UseFormReturn } from '../form/useForm';
|
|
@@ -25,4 +25,4 @@ export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchem
|
|
|
25
25
|
*
|
|
26
26
|
* (We need to use generics to generate types for schema resolver.)
|
|
27
27
|
*/
|
|
28
|
-
export declare const createRhfUtilsClient: <TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string>(resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>) => (config:
|
|
28
|
+
export declare const createRhfUtilsClient: <TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string>(resolver: (schema: TObjectSchema) => Resolver<SafeFieldValues, unknown>) => (config: RhfUtilsClientConfig) => CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RhfUtilsClientConfig } from '../../config/RhfUtilsClientConfig';
|
|
3
3
|
|
|
4
4
|
type Props = React.PropsWithChildren<{
|
|
5
|
-
config:
|
|
5
|
+
config: RhfUtilsClientConfig;
|
|
6
6
|
}>;
|
|
7
7
|
declare const RhfUtilsClientForZodContextProvider: React.FC<Props>;
|
|
8
8
|
export default RhfUtilsClientForZodContextProvider;
|
|
@@ -2,5 +2,5 @@ import { z } from 'zod';
|
|
|
2
2
|
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
3
3
|
|
|
4
4
|
export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
|
|
5
|
-
declare const createRhfUtilsClientForZod: (config: import('../config').
|
|
5
|
+
declare const createRhfUtilsClientForZod: (config: import('../config/RhfUtilsClientConfig').RhfUtilsClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
|
|
6
6
|
export default createRhfUtilsClientForZod;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
|
|
4
|
-
export type LazyDevToolProps = Omit<DevtoolUIProps, 'control'
|
|
4
|
+
export type LazyDevToolProps = Omit<DevtoolUIProps, 'control'> & {
|
|
5
|
+
isDevelopment?: boolean;
|
|
6
|
+
};
|
|
5
7
|
/**
|
|
6
8
|
* Lazy-loaded RHF DevTool.
|
|
7
9
|
*/
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export type { Register } from './register';
|
|
2
|
-
export type {
|
|
2
|
+
export type { RhfUtilsClientConfig } from './client/config/RhfUtilsClientConfig';
|
|
3
3
|
export { default as RhfUtilsClientForZodContextProvider } from './client/zod/context/RhfUtilsClientForZodContextProvider';
|
|
4
4
|
export { default as RhfUtilsZodFormWithProviders } from './client/zod/context/RhfUtilsZodFormWithProviders';
|
|
5
5
|
export { default as useRhfUtilsClientForZodContext } from './client/zod/context/useRhfUtilsClientForZodContext';
|
|
6
6
|
export { default as useRhfUtilsZodForm } from './client/zod/context/useRhfUtilsZodForm';
|
|
7
|
-
export { default as createRhfUtilsClientForZod } from './client/zod/createRhfUtilsClientForZod';
|
|
8
7
|
export { default as LazyDevTool } from './devtool/LazyDevTool';
|
|
9
8
|
export { default as FlatFieldErrorsContextProvider } from './errors/flat/context/FlatFieldErrorsContextProvider';
|
|
10
9
|
export { default as useFlatFieldErrorsContext } from './errors/flat/context/useFlatFieldErrorsContext';
|
|
@@ -6,6 +6,6 @@ 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<UseFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Fields' | 'form' | 'options'
|
|
10
|
-
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Fields, form, options,
|
|
9
|
+
} & Pick<UseFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Fields' | 'form' | 'options'>>;
|
|
10
|
+
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Fields, form, options, children, }: FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export default _Form;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RhfUtilsClientConfig } from '../client/config/RhfUtilsClientConfig';
|
|
3
3
|
|
|
4
4
|
export type FormBaseProps = React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>> & {
|
|
5
|
-
config?: ClientConfig;
|
|
6
5
|
formRef: React.RefObject<HTMLFormElement>;
|
|
6
|
+
config?: RhfUtilsClientConfig;
|
|
7
7
|
antiCsrfToken?: string;
|
|
8
8
|
};
|
|
9
9
|
declare const _FormBase: ({ config, formRef, antiCsrfToken, children, ...props }: FormBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SubmitErrorHandler, UseFormProps as RhfUseFormProps, UseFormReturn as RhfUseFormReturn } from 'react-hook-form';
|
|
3
|
-
import { ClientConfig } from '../client/config';
|
|
4
3
|
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
5
4
|
import { default as _Controller } from './_Controller';
|
|
6
5
|
import { FormProps } from './Form';
|
|
@@ -23,7 +22,6 @@ export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValue
|
|
|
23
22
|
onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
|
|
24
23
|
defaultValues?: RhfUseFormProps<TFieldValues>['defaultValues'];
|
|
25
24
|
Fields?: React.FC<UseFormFieldsProps<TFieldValues, TTransformedValues>>;
|
|
26
|
-
config?: ClientConfig;
|
|
27
25
|
/** {@link RhfUseFormProps} props for RHF's {@link useRhfForm}. */
|
|
28
26
|
rhf?: Omit<RhfUseFormProps<TFieldValues>, 'defaultValues'>;
|
|
29
27
|
/** {@link FormProps} props for Form. */
|
|
@@ -47,6 +45,6 @@ export type UseFormReturn<TFieldValues extends SafeFieldValues, TTransformedValu
|
|
|
47
45
|
* see https://caniuse.com/?search=form%20attribute
|
|
48
46
|
* @returns Form provider and form.
|
|
49
47
|
*/
|
|
50
|
-
declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ onSubmit, onSubmitError, onSubmitInvalid, defaultValues, Fields,
|
|
48
|
+
declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ onSubmit, onSubmitError, onSubmitInvalid, defaultValues, Fields, rhf, form, options, }: UseFormProps<TFieldValues, TTransformedValues>) => UseFormReturn<TFieldValues, TTransformedValues>;
|
|
51
49
|
export default useForm;
|
|
52
50
|
export type UseForm<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = typeof useForm<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.
|
|
5
|
+
"version": "0.0.94",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -19,12 +19,6 @@
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"imports": {
|
|
23
|
-
"#is-development": {
|
|
24
|
-
"development": "./src/env-conditions/development.ts",
|
|
25
|
-
"default": "./src/env-conditions/production.ts"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
22
|
"peerDependencies": {
|
|
29
23
|
"@hookform/devtools": "4",
|
|
30
24
|
"@hookform/resolvers": "3",
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDevelopment: boolean;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { UseFormProps } from './useForm';
|
|
2
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import { default as React } from 'react';
|
|
4
|
-
|
|
5
|
-
export type _FormSlots = 'top' | 'bottom';
|
|
6
|
-
export type _FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
7
|
-
formId: string;
|
|
8
|
-
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
-
} & Pick<UseFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Fields' | 'form' | 'options' | 'config'>>;
|
|
10
|
-
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Fields, form, options, config, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export default _Form;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { UseFormOptions } from './useFormOptions';
|
|
2
|
-
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import { UseFormReturn } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
export type _FormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
6
|
-
formId: string;
|
|
7
|
-
formRef: React.RefObject<HTMLFormElement>;
|
|
8
|
-
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
|
-
options?: UseFormOptions;
|
|
10
|
-
}>;
|
|
11
|
-
declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, rhfForm, options, children, }: _FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export default _FormProviders;
|