@paragrav/rhf-utils 0.0.69 → 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.
- package/dist/esm/client/index.mjs +22 -24
- package/dist/esm/client/zod/context/provider.mjs +1 -1
- package/dist/esm/client/zod/createZodRhfUtilsClient.mjs +7 -0
- package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +17 -0
- package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +21 -0
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +11 -0
- package/dist/esm/errors/message/FormErrorMessageByPath.mjs +8 -11
- package/dist/esm/exports.mjs +78 -76
- package/dist/esm/form/_Form.mjs +51 -58
- package/dist/esm/form/_FormProviders.mjs +12 -4
- package/dist/esm/form/context/utils/FormUtilsContextProvider.mjs +38 -17
- package/dist/esm/form/useForm.mjs +18 -22
- package/dist/esm/submit/useResetFormOnSubmitError.mjs +2 -2
- package/dist/esm/submit/useResetFormOnSubmitSuccessful.mjs +17 -11
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/zod/context/index.d.ts +1 -1
- package/dist/types/client/zod/createZodRhfUtilsClient.d.ts +6 -0
- package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +7 -0
- package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +11 -0
- package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +10 -0
- package/dist/types/errors/isFieldError.d.ts +7 -0
- package/dist/types/errors/message/FormErrorMessageByPath.d.ts +3 -1
- package/dist/types/errors/orphan/useFormHasOrphanAndNoFieldErrors.d.ts +9 -0
- package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +3 -0
- package/dist/types/errors/useFormErrorsMemo.d.ts +7 -0
- package/dist/types/exports.d.ts +4 -3
- package/dist/types/form/_Form.d.ts +2 -2
- package/dist/types/form/_FormProviders.d.ts +3 -3
- package/dist/types/form/context/utils/FormUtilsContextProvider.d.ts +7 -7
- package/dist/types/form/context/utils/useFormUtilsContext.d.ts +4 -1
- package/dist/types/form/useForm.d.ts +2 -4
- package/dist/types/form/useFormOptions.d.ts +8 -1
- package/dist/types/submit/useResetFormOnSubmitSuccessful.d.ts +8 -4
- package/package.json +46 -29
- package/dist/esm/client/zod/index.mjs +0 -7
- package/dist/esm/errors/context/index.mjs +0 -11
- package/dist/esm/errors/context/provider.mjs +0 -21
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const e =
|
|
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) =>
|
|
10
|
+
useForm: (o, s) => d(
|
|
11
11
|
e(o, s)
|
|
12
12
|
),
|
|
13
|
-
FormWithProviders:
|
|
13
|
+
FormWithProviders: u(t, r)
|
|
14
14
|
};
|
|
15
|
-
},
|
|
15
|
+
}, u = (t, r) => function({
|
|
16
16
|
schema: o,
|
|
17
17
|
children: s,
|
|
18
18
|
...m
|
|
19
19
|
}) {
|
|
20
|
-
const i =
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
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
|
-
},
|
|
29
|
-
var s, m, i, n, f
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
50
|
+
v as createRhfUtilsClient
|
|
53
51
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import i from "react";
|
|
3
|
-
import
|
|
3
|
+
import s from "../createZodRhfUtilsClient.mjs";
|
|
4
4
|
import { _RhfUtilsContextProvider as f } from "./index.mjs";
|
|
5
5
|
const n = ({ config: t, children: o }) => {
|
|
6
6
|
const [r] = i.useState(() => s(t));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import l from "../../utils/isEmptyObject.mjs";
|
|
3
|
+
const a = ({ errors: t }) => {
|
|
4
|
+
if (t && !l(t))
|
|
5
|
+
return /* @__PURE__ */ e("ul", { children: Object.values(t).map((r, i) => /* @__PURE__ */ e(
|
|
6
|
+
"li",
|
|
7
|
+
{
|
|
8
|
+
role: "alert",
|
|
9
|
+
"aria-live": "polite",
|
|
10
|
+
children: r.message
|
|
11
|
+
},
|
|
12
|
+
i
|
|
13
|
+
)) });
|
|
14
|
+
}, m = a;
|
|
15
|
+
export {
|
|
16
|
+
m as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import l from "../../orphan/getOrphansFromFlatFieldErrors.mjs";
|
|
3
|
+
import F from "../../root/getRootsFromFlatFieldErrors.mjs";
|
|
4
|
+
import a from "../../useFormErrorsTransformMemo.mjs";
|
|
5
|
+
import d from "../getFlatFieldErrors.mjs";
|
|
6
|
+
import { _FormErrorsFlatContextProvider as p } from "./useFlatFieldErrorsContext.mjs";
|
|
7
|
+
const c = ({
|
|
8
|
+
formRef: o,
|
|
9
|
+
children: t
|
|
10
|
+
}) => {
|
|
11
|
+
const e = a((s) => {
|
|
12
|
+
if (!o.current)
|
|
13
|
+
return;
|
|
14
|
+
const r = d(s), m = F(r), n = l(r, o.current);
|
|
15
|
+
return { all: r, roots: m, orphans: n };
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ i(p, { value: e, children: t });
|
|
18
|
+
}, C = c;
|
|
19
|
+
export {
|
|
20
|
+
C as default
|
|
21
|
+
};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { jsxs as n, Fragment as a, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useFormState as g, get as i } from "react-hook-form";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const { errors:
|
|
7
|
-
if (!(r != null && r.message))
|
|
8
|
-
return null;
|
|
9
|
-
const m = s.Component ?? F;
|
|
3
|
+
import F from "../nonfield/FormNonFieldErrorMarker.mjs";
|
|
4
|
+
import c from "./FormErrorMessage.mjs";
|
|
5
|
+
const p = ({ path: o, ...s }) => {
|
|
6
|
+
const { errors: m } = g(), r = i(m, o, void 0), t = s.Component ?? c;
|
|
10
7
|
return /* @__PURE__ */ n(a, { children: [
|
|
11
|
-
/* @__PURE__ */ e(
|
|
12
|
-
/* @__PURE__ */ e(
|
|
8
|
+
/* @__PURE__ */ e(F, { path: o }),
|
|
9
|
+
(r == null ? void 0 : r.message) && /* @__PURE__ */ e(t, { message: r.message })
|
|
13
10
|
] });
|
|
14
|
-
},
|
|
11
|
+
}, l = p;
|
|
15
12
|
export {
|
|
16
|
-
|
|
13
|
+
l as default
|
|
17
14
|
};
|
package/dist/esm/exports.mjs
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { default as s } from "./client/zod/context/
|
|
3
|
-
import { default as u } from "./client/zod/
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as d } from "./errors/context/
|
|
6
|
-
import { default as x } from "./errors/context/
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as E } from "./errors/message/
|
|
9
|
-
import { default as c } from "./errors/
|
|
10
|
-
import { default as S } from "./errors/nonfield/
|
|
11
|
-
import { default as y } from "./errors/
|
|
12
|
-
import { default as O } from "./errors/orphan/
|
|
13
|
-
import { default as P } from "./errors/orphan/
|
|
14
|
-
import { default as I } from "./errors/
|
|
15
|
-
import { default as g } from "./errors/
|
|
16
|
-
import { default as B } from "./errors/
|
|
17
|
-
import { default as A } from "./errors/
|
|
18
|
-
import { default as D } from "./errors/
|
|
19
|
-
import { default as H } from "./errors/
|
|
20
|
-
import { default as
|
|
21
|
-
import { default as
|
|
22
|
-
import { default as w } from "./form/context/utils/
|
|
23
|
-
import { default as K } from "./form/context/
|
|
24
|
-
import { default as V } from "./form/context/group/
|
|
25
|
-
import { default as X } from "./form/context/group/
|
|
26
|
-
import { default as _ } from "./form/context/group/
|
|
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
|
|
32
|
-
import { default as dr } from "./form/
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { default as Er } from "./submit/
|
|
36
|
-
import { default as cr } from "./submit/
|
|
37
|
-
import { default as Sr } from "./submit/
|
|
38
|
-
import { default as yr } from "./submit/
|
|
1
|
+
import { default as e } from "./client/zod/context/index.mjs";
|
|
2
|
+
import { default as s } from "./client/zod/context/provider.mjs";
|
|
3
|
+
import { default as u } from "./client/zod/createZodRhfUtilsClient.mjs";
|
|
4
|
+
import { default as m } from "./devtool/LazyDevTool.mjs";
|
|
5
|
+
import { default as d } from "./errors/flat/context/FlatFieldErrorsContextProvider.mjs";
|
|
6
|
+
import { default as x } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
|
|
7
|
+
import { default as i } from "./errors/flat/FlatFieldErrorsList.mjs";
|
|
8
|
+
import { default as E } from "./errors/message/FormErrorMessage.mjs";
|
|
9
|
+
import { default as c } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
10
|
+
import { default as S } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
11
|
+
import { default as y } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
12
|
+
import { default as O } from "./errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.mjs";
|
|
13
|
+
import { default as P } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
14
|
+
import { default as I } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
15
|
+
import { default as g } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
16
|
+
import { default as B } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
17
|
+
import { default as A } from "./errors/useFormErrorsEffect.mjs";
|
|
18
|
+
import { default as D } from "./errors/useFormErrorsIfAny.mjs";
|
|
19
|
+
import { default as H } from "./errors/useFormErrorsTransformMemo.mjs";
|
|
20
|
+
import { default as N } from "./errors/useFormRequestSubmit.mjs";
|
|
21
|
+
import { default as z } from "./form/useForm.mjs";
|
|
22
|
+
import { default as w } from "./form/context/utils/FormUtilsContextProvider.mjs";
|
|
23
|
+
import { default as K } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
24
|
+
import { default as V } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
25
|
+
import { default as X } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
26
|
+
import { default as _ } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
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 mr } 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 cr } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
37
|
+
import { default as Sr } from "./submit/useResetFormOnSubmitError.mjs";
|
|
38
|
+
import { default as yr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
39
|
+
import { default as Or } from "./submit/useSubmitFormOnChange.mjs";
|
|
39
40
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
S as
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
A as
|
|
57
|
-
D as
|
|
58
|
-
|
|
59
|
-
X as
|
|
60
|
-
_ as
|
|
61
|
-
rr as
|
|
62
|
-
er as
|
|
63
|
-
sr as
|
|
64
|
-
ur as
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Er as
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
P as
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
41
|
+
d as FlatFieldErrorsContextProvider,
|
|
42
|
+
i as FlatFieldErrorsList,
|
|
43
|
+
E as FormErrorMessage,
|
|
44
|
+
c as FormErrorMessageByPath,
|
|
45
|
+
V as FormGroupContextProvider,
|
|
46
|
+
S as FormNonFieldErrorMarker,
|
|
47
|
+
y as FormNonFieldErrorMarkerHtmlAttribute,
|
|
48
|
+
ir as FormSubmitError,
|
|
49
|
+
w as FormUtilsContextProvider,
|
|
50
|
+
m as LazyDevTool,
|
|
51
|
+
s as RhfUtilsZodContextProvider,
|
|
52
|
+
u as createZodRhfUtilsClient,
|
|
53
|
+
xr as getSubmitterButtonData,
|
|
54
|
+
x as useFlatFieldErrorsContext,
|
|
55
|
+
z as useForm,
|
|
56
|
+
B as useFormErrorConsoleDebug,
|
|
57
|
+
A as useFormErrorsEffect,
|
|
58
|
+
D as useFormErrorsIfAny,
|
|
59
|
+
H as useFormErrorsTransformMemo,
|
|
60
|
+
X as useFormGroupChildIsMountedTracker,
|
|
61
|
+
_ as useFormGroupChildIsSubmittingTracker,
|
|
62
|
+
rr as useFormGroupChildTracker,
|
|
63
|
+
er as useFormGroupIsAnyBusy,
|
|
64
|
+
sr as useFormGroupIsChildBusy,
|
|
65
|
+
ur as useFormGroupIsParentBusy,
|
|
66
|
+
mr as useFormGroupParentTracker,
|
|
67
|
+
O as useFormHasOnlyOrphanFieldErrorsMemo,
|
|
68
|
+
Er as useFormOnSubmitSuccessful,
|
|
69
|
+
cr as useFormOnSubmitSuccessfulAndReset,
|
|
70
|
+
dr as useFormOrParentIsBusy,
|
|
71
|
+
N as useFormRequestSubmit,
|
|
72
|
+
K as useFormUtilsContext,
|
|
73
|
+
P as useOrphanFormErrorsMemo,
|
|
74
|
+
I as useOrphanFormErrorsToConsole,
|
|
75
|
+
yr as useResetFormAfterSubmitSuccessful,
|
|
76
|
+
Sr as useResetFormOnSubmitError,
|
|
77
|
+
e as useRhfUtilsZodContext,
|
|
78
|
+
g as useRootFormFieldErrorsMemo,
|
|
79
|
+
Or as useSubmitFormOnChange
|
|
78
80
|
};
|
package/dist/esm/form/_Form.mjs
CHANGED
|
@@ -1,90 +1,83 @@
|
|
|
1
|
-
import { jsxs as B, jsx as
|
|
1
|
+
import { jsxs as B, jsx as b } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { useFormContext as
|
|
4
|
-
import
|
|
5
|
-
import { FormSubmitError as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
|
|
12
|
+
options: a,
|
|
13
|
+
config: l,
|
|
14
|
+
children: F
|
|
15
15
|
}) {
|
|
16
|
-
var
|
|
17
|
-
const
|
|
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
|
|
26
|
-
|
|
20
|
+
await s.handleSubmit(
|
|
21
|
+
y,
|
|
27
22
|
t == null ? void 0 : t.onSubmitInvalid
|
|
28
|
-
)(
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
23
|
+
)(e);
|
|
24
|
+
} catch (u) {
|
|
25
|
+
n(u, e);
|
|
31
26
|
}
|
|
32
|
-
},
|
|
33
|
-
var
|
|
34
|
-
return (
|
|
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
|
-
|
|
38
|
-
e
|
|
33
|
+
u
|
|
39
34
|
);
|
|
40
|
-
},
|
|
35
|
+
}, n = (e, u) => {
|
|
41
36
|
var x, C;
|
|
42
|
-
const
|
|
37
|
+
const d = e instanceof N ? (
|
|
43
38
|
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
44
|
-
|
|
39
|
+
e
|
|
45
40
|
) : (
|
|
46
41
|
// if error is not FormSubmitError, consumer can provide global handler
|
|
47
|
-
(x =
|
|
42
|
+
(x = l == null ? void 0 : l.onSubmitError) == null ? void 0 : x.call(l, e)
|
|
48
43
|
);
|
|
49
|
-
|
|
44
|
+
d && P(s, d), (C = t == null ? void 0 : t.onSubmitError) == null || C.call(
|
|
50
45
|
t,
|
|
46
|
+
e,
|
|
51
47
|
s,
|
|
52
|
-
|
|
53
|
-
e
|
|
48
|
+
u
|
|
54
49
|
);
|
|
55
|
-
},
|
|
56
|
-
formId:
|
|
57
|
-
formRef:
|
|
58
|
-
ctx:
|
|
59
|
-
options:
|
|
60
|
-
},
|
|
61
|
-
var
|
|
62
|
-
const
|
|
63
|
-
return
|
|
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
|
-
|
|
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: [
|
|
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
|
-
|
|
80
|
-
(
|
|
81
|
-
(t == null ? void 0 : t.Fields) && /* @__PURE__ */
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
82
|
+
L as default
|
|
90
83
|
};
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { FormProvider as d } from "react-hook-form";
|
|
3
|
-
import n from "../errors/context/
|
|
3
|
+
import n from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
|
|
4
4
|
import l from "./context/utils/FormUtilsContextProvider.mjs";
|
|
5
5
|
function v({
|
|
6
6
|
formId: t,
|
|
7
7
|
formRef: o,
|
|
8
8
|
rhfForm: i,
|
|
9
|
-
|
|
10
|
-
children:
|
|
9
|
+
options: e,
|
|
10
|
+
children: m
|
|
11
11
|
}) {
|
|
12
|
-
return /* @__PURE__ */ r(d, { ...i, children: /* @__PURE__ */ r(n, { formRef: o, children: /* @__PURE__ */ r(
|
|
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
|
+
) }) });
|
|
13
21
|
}
|
|
14
22
|
export {
|
|
15
23
|
v as default
|
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { isDevelopment as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
13
17
|
}) {
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
);
|
|
18
39
|
}
|
|
19
40
|
export {
|
|
20
|
-
|
|
41
|
+
s as default
|
|
21
42
|
};
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useForm as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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:
|
|
13
|
+
context: s,
|
|
18
14
|
providerProps: {
|
|
19
|
-
formId:
|
|
15
|
+
formId: o,
|
|
20
16
|
formRef: r,
|
|
21
|
-
rhfForm:
|
|
22
|
-
|
|
17
|
+
rhfForm: s,
|
|
18
|
+
options: n
|
|
23
19
|
},
|
|
24
20
|
formProps: {
|
|
25
|
-
formId:
|
|
21
|
+
formId: o,
|
|
26
22
|
formRef: r,
|
|
27
|
-
config:
|
|
28
|
-
form:
|
|
23
|
+
config: t,
|
|
24
|
+
form: f
|
|
29
25
|
}
|
|
30
26
|
};
|
|
31
27
|
};
|
|
32
28
|
export {
|
|
33
|
-
|
|
29
|
+
a as default
|
|
34
30
|
};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { useFormContext as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
},
|
|
17
|
+
}, o = a;
|
|
12
18
|
export {
|
|
13
|
-
|
|
19
|
+
o as default
|
|
14
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClientConfig } from './config';
|
|
2
1
|
import { UseFormProps, UseFormReturn } from '../form/useForm';
|
|
3
2
|
import { SafeFieldValues } from '../form/SafeFieldValues';
|
|
4
3
|
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
|
+
import { ClientConfig } from './config';
|
|
5
5
|
import { Resolver } from 'react-hook-form';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SafeFieldValues } from '../../form/SafeFieldValues';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
|
|
5
|
+
declare const createZodRhfUtilsClient: (config: import('../config').ClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
|
|
6
|
+
export default createZodRhfUtilsClient;
|
|
@@ -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 FlatFieldErrorsContextProvider: React.FC<Props>;
|
|
11
|
+
export default FlatFieldErrorsContextProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FlatFieldErrors } from '../types';
|
|
2
|
+
|
|
3
|
+
export type FlatFieldErrorsContext = {
|
|
4
|
+
all: FlatFieldErrors;
|
|
5
|
+
roots: FlatFieldErrors;
|
|
6
|
+
orphans: FlatFieldErrors;
|
|
7
|
+
};
|
|
8
|
+
declare const useFlatFieldErrorsContextMaybe: () => FlatFieldErrorsContext | undefined, useFlatFieldErrorsContext: () => FlatFieldErrorsContext, _FormErrorsFlatContextProvider: import('react').Provider<FlatFieldErrorsContext | undefined>;
|
|
9
|
+
export default useFlatFieldErrorsContext;
|
|
10
|
+
export { _FormErrorsFlatContextProvider, useFlatFieldErrorsContextMaybe };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
type Props = {
|
|
3
|
-
name
|
|
3
|
+
/** Field name as flat path. (e.g., "address.street") */
|
|
4
|
+
path: string;
|
|
5
|
+
/** Optional component to use to display message. (Defaults to {@link FormErrorMessage}) */
|
|
4
6
|
Component?: React.FC<{
|
|
5
7
|
message: string;
|
|
6
8
|
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determined if there are orphan errors and no field errors.
|
|
3
|
+
* (May be useful when reporting or displaying a specific message to user.)
|
|
4
|
+
* RHF doesn't seem to have any other mechanism to indicate a failed submit but to `setErrors()`.
|
|
5
|
+
* Therefore, we have no way of distinguishing between "placeholder" root error and actual error.
|
|
6
|
+
* (e.g., "Please fix form errors above." vs "Start date must be less than end date.")
|
|
7
|
+
*/
|
|
8
|
+
declare const useFormHasOrphanAndNoFieldErrors: (formRef: React.RefObject<HTMLFormElement>) => boolean;
|
|
9
|
+
export default useFormHasOrphanAndNoFieldErrors;
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export type { ClientConfig } from './client/config';
|
|
2
|
-
export { createZodRhfUtilsClient } from './client/zod';
|
|
3
2
|
export { default as useRhfUtilsZodContext } from './client/zod/context';
|
|
4
3
|
export { default as RhfUtilsZodContextProvider } from './client/zod/context/provider';
|
|
4
|
+
export { default as createZodRhfUtilsClient } from './client/zod/createZodRhfUtilsClient';
|
|
5
5
|
export { default as LazyDevTool } from './devtool/LazyDevTool';
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
6
|
+
export { default as FlatFieldErrorsContextProvider } from './errors/flat/context/FlatFieldErrorsContextProvider';
|
|
7
|
+
export { default as useFlatFieldErrorsContext } from './errors/flat/context/useFlatFieldErrorsContext';
|
|
8
|
+
export { default as FlatFieldErrorsList } from './errors/flat/FlatFieldErrorsList';
|
|
8
9
|
export { default as FormErrorMessage } from './errors/message/FormErrorMessage';
|
|
9
10
|
export { default as FormErrorMessageByPath } from './errors/message/FormErrorMessageByPath';
|
|
10
11
|
export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
|
|
@@ -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,12 +1,12 @@
|
|
|
1
|
+
import { UseFormOptions } from './useFormOptions';
|
|
1
2
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
|
-
import { FormUtilsContextProviderProps } 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
6
|
formId: string;
|
|
7
7
|
formRef: React.RefObject<HTMLFormElement>;
|
|
8
8
|
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
|
-
|
|
9
|
+
options?: UseFormOptions;
|
|
10
10
|
}>;
|
|
11
|
-
declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, rhfForm,
|
|
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
12
|
export default _FormProviders;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Callback after successful submit, and form reset. */
|
|
4
|
-
onSubmitSuccessfulAndReset?: () => void;
|
|
5
|
-
};
|
|
1
|
+
import { UseFormOptions } from '../../useFormOptions';
|
|
2
|
+
|
|
6
3
|
type Props = React.PropsWithChildren<{
|
|
7
4
|
formId: string;
|
|
8
5
|
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/** Callback after successful submit, and form reset. */
|
|
7
|
+
onSubmitSuccessfulAndReset?: () => void;
|
|
8
|
+
options?: UseFormOptions;
|
|
9
|
+
}>;
|
|
10
|
+
declare function FormUtilsContextProvider({ formId, formRef, onSubmitSuccessfulAndReset, options, children, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export default FormUtilsContextProvider;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
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 { FormUtilsContextProviderProps } 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
|
-
|
|
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,
|
|
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
|
-
|
|
5
|
-
|
|
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: (
|
|
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.
|
|
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
|
},
|
|
@@ -37,6 +37,18 @@
|
|
|
37
37
|
"default": "./dist/esm/devtool/LazyDevTool.mjs",
|
|
38
38
|
"types": "./dist/types/devtool/LazyDevTool.d.ts"
|
|
39
39
|
},
|
|
40
|
+
"./errors/flat/context/FlatFieldErrorsContextProvider": {
|
|
41
|
+
"default": "./dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs",
|
|
42
|
+
"types": "./dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./errors/flat/context/useFlatFieldErrorsContext": {
|
|
45
|
+
"default": "./dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs",
|
|
46
|
+
"types": "./dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./errors/flat/FlatFieldErrorsList": {
|
|
49
|
+
"default": "./dist/esm/errors/flat/FlatFieldErrorsList.mjs",
|
|
50
|
+
"types": "./dist/types/errors/flat/FlatFieldErrorsList.d.ts"
|
|
51
|
+
},
|
|
40
52
|
"./errors/FormErrorMessage": {
|
|
41
53
|
"default": "./dist/esm/errors/message/FormErrorMessage.mjs",
|
|
42
54
|
"types": "./dist/types/errors/message/FormErrorMessage.d.ts"
|
|
@@ -93,14 +105,6 @@
|
|
|
93
105
|
"default": "./dist/esm/form/useForm.mjs",
|
|
94
106
|
"types": "./dist/types/form/useForm.d.ts"
|
|
95
107
|
},
|
|
96
|
-
"./form/context/FormUtilsContextProvider": {
|
|
97
|
-
"default": "./dist/esm/form/context/FormUtilsContextProvider.mjs",
|
|
98
|
-
"types": "./dist/types/form/context/FormUtilsContextProvider.d.ts"
|
|
99
|
-
},
|
|
100
|
-
"./form/context/useFormUtilsContext": {
|
|
101
|
-
"default": "./dist/esm/form/context/useFormUtilsContext.mjs",
|
|
102
|
-
"types": "./dist/types/form/context/useFormUtilsContext.d.ts"
|
|
103
|
-
},
|
|
104
108
|
"./form/context/group/FormGroupContextProvider": {
|
|
105
109
|
"default": "./dist/esm/form/context/group/FormGroupContextProvider.mjs",
|
|
106
110
|
"types": "./dist/types/form/context/group/FormGroupContextProvider.d.ts"
|
|
@@ -137,7 +141,15 @@
|
|
|
137
141
|
"default": "./dist/esm/form/context/group/useFormGroupIsParentBusy.mjs",
|
|
138
142
|
"types": "./dist/types/form/context/group/useFormGroupIsParentBusy.d.ts"
|
|
139
143
|
},
|
|
140
|
-
"./form/context/utils/
|
|
144
|
+
"./form/context/utils/FormUtilsContextProvider": {
|
|
145
|
+
"default": "./dist/esm/form/context/utils/FormUtilsContextProvider.mjs",
|
|
146
|
+
"types": "./dist/types/form/context/utils/FormUtilsContextProvider.d.ts"
|
|
147
|
+
},
|
|
148
|
+
"./form/context/utils/useFormUtilsContext": {
|
|
149
|
+
"default": "./dist/esm/form/context/utils/useFormUtilsContext.mjs",
|
|
150
|
+
"types": "./dist/types/form/context/utils/useFormUtilsContext.d.ts"
|
|
151
|
+
},
|
|
152
|
+
"./form/utils/getSubmitterButtonData": {
|
|
141
153
|
"default": "./dist/esm/form/utils/getSubmitterButtonData.mjs",
|
|
142
154
|
"types": "./dist/types/form/utils/getSubmitterButtonData.d.ts"
|
|
143
155
|
},
|
|
@@ -166,6 +178,21 @@
|
|
|
166
178
|
"types": "./dist/types/submit/useSubmitFormOnChange.d.ts"
|
|
167
179
|
}
|
|
168
180
|
},
|
|
181
|
+
"scripts": {
|
|
182
|
+
"build": "vite build",
|
|
183
|
+
"build:dev": "vite build --config vite.config.dev.ts",
|
|
184
|
+
"dev": "vite --config vite.config.dev.ts",
|
|
185
|
+
"lint": "eslint --ignore-path ./.gitignore --ext ts,tsx --report-unused-disable-directives --max-warnings 0 .",
|
|
186
|
+
"preinstall": "npx only-allow pnpm",
|
|
187
|
+
"prepare": "husky",
|
|
188
|
+
"prepublishOnly": "pnpm build",
|
|
189
|
+
"preview": "vite preview --config vite.config.dev.ts",
|
|
190
|
+
"test": "vitest",
|
|
191
|
+
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
192
|
+
"test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
193
|
+
"tsc": "tsc",
|
|
194
|
+
"validate": "cross-env CI=1 pnpm install && pnpm tsc & pnpm lint & pnpm test && pnpm test:ct"
|
|
195
|
+
},
|
|
169
196
|
"peerDependencies": {
|
|
170
197
|
"@hookform/devtools": "^4",
|
|
171
198
|
"flat": "^6",
|
|
@@ -175,7 +202,8 @@
|
|
|
175
202
|
},
|
|
176
203
|
"devDependencies": {
|
|
177
204
|
"@hookform/resolvers": "^3.3.4",
|
|
178
|
-
"@playwright/experimental-ct-react": "^1.
|
|
205
|
+
"@playwright/experimental-ct-react": "^1.43.1",
|
|
206
|
+
"@playwright/test": "^1.43.1",
|
|
179
207
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
180
208
|
"@types/node": "^20.12.7",
|
|
181
209
|
"@types/react": "^18.2.69",
|
|
@@ -186,6 +214,7 @@
|
|
|
186
214
|
"cross-env": "^7.0.3",
|
|
187
215
|
"eslint": "^8.57.0",
|
|
188
216
|
"eslint-config-prettier": "^9.1.0",
|
|
217
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
189
218
|
"eslint-plugin-import": "^2.29.1",
|
|
190
219
|
"eslint-plugin-react": "^7.34.1",
|
|
191
220
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
@@ -207,6 +236,7 @@
|
|
|
207
236
|
"node": ">=20.12",
|
|
208
237
|
"pnpm": ">=9.0.6"
|
|
209
238
|
},
|
|
239
|
+
"packageManager": "pnpm@9.0.6",
|
|
210
240
|
"repository": {
|
|
211
241
|
"type": "git",
|
|
212
242
|
"url": "git+https://github.com/paragrav/rhf-utils.git"
|
|
@@ -224,18 +254,5 @@
|
|
|
224
254
|
"utilities",
|
|
225
255
|
"utils",
|
|
226
256
|
"zod"
|
|
227
|
-
]
|
|
228
|
-
|
|
229
|
-
"build": "vite build",
|
|
230
|
-
"build:dev": "vite build --config vite.config.dev.ts",
|
|
231
|
-
"dev": "vite --config vite.config.dev.ts",
|
|
232
|
-
"lint": "eslint --ignore-path ./.gitignore --ext ts,tsx --report-unused-disable-directives --max-warnings 0 .",
|
|
233
|
-
"preinstall": "npx only-allow pnpm",
|
|
234
|
-
"preview": "vite preview --config vite.config.dev.ts",
|
|
235
|
-
"test": "vitest",
|
|
236
|
-
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
237
|
-
"test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
238
|
-
"tsc": "tsc",
|
|
239
|
-
"validate": "cross-env CI=1 pnpm install && pnpm tsc & pnpm lint & pnpm test && pnpm test:ct"
|
|
240
|
-
}
|
|
241
|
-
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
-
import a from "../flat/getFlatFieldErrors.mjs";
|
|
3
|
-
import i from "../orphan/getOrphansFromFlatFieldErrors.mjs";
|
|
4
|
-
import l from "../root/getRootsFromFlatFieldErrors.mjs";
|
|
5
|
-
import p from "../useFormErrorsTransformMemo.mjs";
|
|
6
|
-
import { _FormErrorsFlatContextProvider as c } from "./index.mjs";
|
|
7
|
-
const u = ({
|
|
8
|
-
formRef: o,
|
|
9
|
-
children: t
|
|
10
|
-
}) => {
|
|
11
|
-
const e = p((s) => {
|
|
12
|
-
if (!o.current)
|
|
13
|
-
return;
|
|
14
|
-
const r = a(s), m = l(r), n = i(r, o.current);
|
|
15
|
-
return { all: r, roots: m, orphans: n };
|
|
16
|
-
});
|
|
17
|
-
return /* @__PURE__ */ F(c, { value: e, children: t });
|
|
18
|
-
}, C = u;
|
|
19
|
-
export {
|
|
20
|
-
C as default
|
|
21
|
-
};
|