@paragrav/rhf-utils 0.0.95 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useFormContext as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
const
|
|
1
|
+
import { useFormContext as C } from "react-hook-form";
|
|
2
|
+
import F from "../../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
3
|
+
import x from "../../utils/isEmptyObject.mjs";
|
|
4
|
+
import E from "../output/consoleErrors.mjs";
|
|
5
|
+
import d from "./context/useFlatFieldErrorsContext.mjs";
|
|
6
|
+
const v = () => {
|
|
7
|
+
var p, l, t, i, u, a, r, f;
|
|
8
|
+
const h = C(), o = F(), n = d(), m = {
|
|
9
9
|
isDevelopment: o == null ? void 0 : o.isDevelopment,
|
|
10
|
-
hasOrphans: !
|
|
11
|
-
}, t = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
hasOrphans: !x(n.orphans)
|
|
11
|
+
}, e = (i = (t = (l = (p = o == null ? void 0 : o.errors) == null ? void 0 : p.output) == null ? void 0 : l.console) == null ? void 0 : t.getConfig) == null ? void 0 : i.call(t, m);
|
|
12
|
+
e && E(
|
|
13
|
+
e.message ?? c,
|
|
14
|
+
h.getValues(),
|
|
15
|
+
n,
|
|
16
|
+
e.type
|
|
17
17
|
);
|
|
18
|
-
const r = (
|
|
19
|
-
if (
|
|
20
|
-
throw new Error(typeof
|
|
21
|
-
},
|
|
18
|
+
const s = (f = (r = (a = (u = o == null ? void 0 : o.errors) == null ? void 0 : u.output) == null ? void 0 : a.throw) == null ? void 0 : r.getConfig) == null ? void 0 : f.call(r, m);
|
|
19
|
+
if (s)
|
|
20
|
+
throw new Error(typeof s == "string" ? s : c);
|
|
21
|
+
}, c = "Form errors";
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
v as default
|
|
24
24
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, a = i;
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import t from "../flat/context/useFlatFieldErrorsContext.mjs";
|
|
3
|
+
import s from "../flat/FlatFieldErrorsList.mjs";
|
|
4
|
+
const e = () => {
|
|
5
|
+
const r = t().roots;
|
|
6
|
+
return /* @__PURE__ */ o(s, { errors: r });
|
|
7
|
+
}, m = e;
|
|
9
8
|
export {
|
|
10
|
-
|
|
9
|
+
m as default
|
|
11
10
|
};
|
package/dist/esm/form/Form.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import P from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
|
8
8
|
import S from "./_Controller.mjs";
|
|
9
9
|
import T from "./_FormBase.mjs";
|
|
10
10
|
function q({
|
|
11
|
-
formId:
|
|
11
|
+
formId: x,
|
|
12
12
|
formRef: C,
|
|
13
13
|
//
|
|
14
14
|
onSubmit: d,
|
|
@@ -33,29 +33,29 @@ function q({
|
|
|
33
33
|
l,
|
|
34
34
|
a
|
|
35
35
|
), B = (r, a) => {
|
|
36
|
-
var
|
|
36
|
+
var n;
|
|
37
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
|
+
(n = e == null ? void 0 : e.onSubmitError) == null ? void 0 : n.call(e, r)
|
|
43
43
|
);
|
|
44
44
|
m && P(l, m), c == null || c(
|
|
45
45
|
r,
|
|
46
46
|
l,
|
|
47
47
|
a
|
|
48
48
|
);
|
|
49
|
-
},
|
|
50
|
-
formId:
|
|
49
|
+
}, u = {
|
|
50
|
+
formId: x,
|
|
51
51
|
formRef: C,
|
|
52
52
|
ctx: l,
|
|
53
53
|
options: t,
|
|
54
54
|
Controller: S
|
|
55
|
-
},
|
|
55
|
+
}, i = (r) => {
|
|
56
56
|
var m;
|
|
57
57
|
const a = (m = e == null ? void 0 : e.Children) == null ? void 0 : m[r];
|
|
58
|
-
return a && /* @__PURE__ */ o(a, { ...
|
|
58
|
+
return a && /* @__PURE__ */ o(a, { ...u });
|
|
59
59
|
};
|
|
60
60
|
return /* @__PURE__ */ F(
|
|
61
61
|
T,
|
|
@@ -70,7 +70,7 @@ function q({
|
|
|
70
70
|
className: [t == null ? void 0 : t.classNames, s == null ? void 0 : s.className].filter(Boolean).join(" "),
|
|
71
71
|
onSubmit: b,
|
|
72
72
|
children: [
|
|
73
|
-
|
|
73
|
+
i("top"),
|
|
74
74
|
(t == null ? void 0 : t.devTool) !== "disabled" && /* @__PURE__ */ o(
|
|
75
75
|
D,
|
|
76
76
|
{
|
|
@@ -79,9 +79,9 @@ function q({
|
|
|
79
79
|
...t == null ? void 0 : t.devTool
|
|
80
80
|
}
|
|
81
81
|
),
|
|
82
|
-
h && /* @__PURE__ */ o(h, { ...
|
|
82
|
+
h && /* @__PURE__ */ o(h, { ...u }),
|
|
83
83
|
f,
|
|
84
|
-
|
|
84
|
+
i("bottom")
|
|
85
85
|
]
|
|
86
86
|
}
|
|
87
87
|
);
|
|
@@ -40,12 +40,12 @@ export type RhfUtilsClientConfig = {
|
|
|
40
40
|
*/
|
|
41
41
|
onSubmitError?: (error: unknown) => FormSubmitError | undefined;
|
|
42
42
|
FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
|
|
43
|
-
errors
|
|
44
|
-
output
|
|
45
|
-
console
|
|
43
|
+
errors?: {
|
|
44
|
+
output?: {
|
|
45
|
+
console?: {
|
|
46
46
|
getConfig?: (context: RhfUtilsErrorsOutputConfigContext) => RhfUtilsErrorsOutputConsoleConfig | null;
|
|
47
47
|
};
|
|
48
|
-
throw
|
|
48
|
+
throw?: {
|
|
49
49
|
getConfig?: (context: RhfUtilsErrorsOutputConfigContext) => true | string | false;
|
|
50
50
|
};
|
|
51
51
|
};
|