@paragrav/rhf-utils 0.0.69 → 0.0.70
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/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/_FormProviders.mjs +8 -9
- package/dist/esm/form/context/utils/FormUtilsContextProvider.mjs +20 -13
- package/dist/esm/form/useForm.mjs +0 -1
- package/dist/types/client/config.d.ts +2 -0
- 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/_FormProviders.d.ts +3 -4
- package/dist/types/form/context/utils/FormUtilsContextProvider.d.ts +11 -6
- package/dist/types/form/useForm.d.ts +2 -2
- package/package.json +40 -25
- 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,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
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { FormProvider as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function
|
|
6
|
-
formId: t,
|
|
2
|
+
import { FormProvider as m } from "react-hook-form";
|
|
3
|
+
import d from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
|
|
4
|
+
import n from "./context/utils/FormUtilsContextProvider.mjs";
|
|
5
|
+
function f({
|
|
7
6
|
formRef: o,
|
|
8
|
-
rhfForm:
|
|
9
|
-
utils:
|
|
7
|
+
rhfForm: t,
|
|
8
|
+
utils: i,
|
|
10
9
|
children: e
|
|
11
10
|
}) {
|
|
12
|
-
return /* @__PURE__ */ r(
|
|
11
|
+
return /* @__PURE__ */ r(m, { ...t, children: /* @__PURE__ */ r(d, { formRef: o, children: /* @__PURE__ */ r(n, { formRef: o, ...i, children: e }) }) });
|
|
13
12
|
}
|
|
14
13
|
export {
|
|
15
|
-
|
|
14
|
+
f as default
|
|
16
15
|
};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { isDevelopment as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { isDevelopment as s } from "../../../env-conditions/production.mjs";
|
|
3
|
+
import F from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
4
|
+
import l from "../../../errors/useFormErrorConsoleDebug.mjs";
|
|
5
|
+
import a from "../../../errors/useFormRequestSubmit.mjs";
|
|
6
6
|
import u from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
7
|
-
import
|
|
8
|
-
import { _FormUtilsContextProvider as
|
|
9
|
-
function
|
|
7
|
+
import C from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
|
|
8
|
+
import { _FormUtilsContextProvider as f } from "./useFormUtilsContext.mjs";
|
|
9
|
+
function P({
|
|
10
|
+
// options
|
|
11
|
+
disableFormErrorConsoleDebug: n,
|
|
12
|
+
disableOrphanFormErrorsToConsole: m,
|
|
13
|
+
resetFormAfterSubmitSuccessful: t,
|
|
14
|
+
// props
|
|
10
15
|
formRef: o,
|
|
11
16
|
onSubmitSuccessfulAndReset: r,
|
|
12
|
-
children:
|
|
17
|
+
children: e
|
|
13
18
|
}) {
|
|
14
|
-
const
|
|
15
|
-
return s
|
|
19
|
+
const i = a(o);
|
|
20
|
+
return l(s), F(o, !m), C({
|
|
21
|
+
enabled: t || !!r
|
|
22
|
+
}), u(() => {
|
|
16
23
|
r == null || r();
|
|
17
|
-
}), /* @__PURE__ */
|
|
24
|
+
}), /* @__PURE__ */ p(f, { value: { formRef: o, requestSubmit: i }, children: e });
|
|
18
25
|
}
|
|
19
26
|
export {
|
|
20
|
-
|
|
27
|
+
P as default
|
|
21
28
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
2
2
|
import { UseFormOptions } from '../form/useFormOptions';
|
|
3
3
|
import { UseFormFieldsProps } from '../form/useForm';
|
|
4
|
+
import { FormUtilsOptions } from '../form/context/utils/FormUtilsContextProvider';
|
|
4
5
|
import { _FormSlots } from '../form/_Form';
|
|
5
6
|
import { UseFormProps } from 'react-hook-form';
|
|
6
7
|
|
|
@@ -21,6 +22,7 @@ export type ClientConfig = {
|
|
|
21
22
|
* Extend this type to inject custom options/functionality via `Children` component.
|
|
22
23
|
*/
|
|
23
24
|
form?: UseFormOptions;
|
|
25
|
+
utils?: FormUtilsOptions;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Components injected by slot across all forms.
|
|
@@ -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';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
2
|
-
import {
|
|
2
|
+
import { FormUtilsOptions } from './context/utils/FormUtilsContextProvider';
|
|
3
3
|
import { UseFormReturn } from 'react-hook-form';
|
|
4
4
|
|
|
5
5
|
export type _FormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
6
|
-
formId: string;
|
|
7
6
|
formRef: React.RefObject<HTMLFormElement>;
|
|
8
7
|
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
|
-
utils?:
|
|
8
|
+
utils?: FormUtilsOptions;
|
|
10
9
|
}>;
|
|
11
|
-
declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({
|
|
10
|
+
declare function _FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formRef, rhfForm, utils, children, }: _FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export default _FormProviders;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export type
|
|
3
|
-
/**
|
|
4
|
-
|
|
2
|
+
export type FormUtilsOptions = {
|
|
3
|
+
/** Disable `console.debug` of field errors in dev. */
|
|
4
|
+
disableFormErrorConsoleDebug?: boolean;
|
|
5
|
+
/** Disable `console.error` of orphan field errors. */
|
|
6
|
+
disableOrphanFormErrorsToConsole?: boolean;
|
|
7
|
+
/** Reset form after successful submit. */
|
|
8
|
+
resetFormAfterSubmitSuccessful?: boolean;
|
|
5
9
|
};
|
|
6
10
|
type Props = React.PropsWithChildren<{
|
|
7
|
-
formId: string;
|
|
8
11
|
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
/** Callback after successful submit, and form reset. */
|
|
13
|
+
onSubmitSuccessfulAndReset?: () => void;
|
|
14
|
+
} & FormUtilsOptions>;
|
|
15
|
+
declare function FormUtilsContextProvider({ disableFormErrorConsoleDebug, disableOrphanFormErrorsToConsole, resetFormAfterSubmitSuccessful, formRef, onSubmitSuccessfulAndReset, children, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export default FormUtilsContextProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseFormOptions } from './useFormOptions';
|
|
2
2
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import {
|
|
3
|
+
import { FormUtilsOptions } from './context/utils/FormUtilsContextProvider';
|
|
4
4
|
import { _FormProvidersProps } from './_FormProviders';
|
|
5
5
|
import { _FormProps } from './_Form';
|
|
6
6
|
import { ClientConfig } from '../client/config';
|
|
@@ -28,7 +28,7 @@ export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValue
|
|
|
28
28
|
options?: UseFormOptions;
|
|
29
29
|
props?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
|
|
30
30
|
};
|
|
31
|
-
utils?:
|
|
31
|
+
utils?: FormUtilsOptions;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Core Rhf Form hook. Use `Form` in `index.ts` for most cases.
|
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.70",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -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",
|
|
@@ -207,6 +234,7 @@
|
|
|
207
234
|
"node": ">=20.12",
|
|
208
235
|
"pnpm": ">=9.0.6"
|
|
209
236
|
},
|
|
237
|
+
"packageManager": "pnpm@9.0.6",
|
|
210
238
|
"repository": {
|
|
211
239
|
"type": "git",
|
|
212
240
|
"url": "git+https://github.com/paragrav/rhf-utils.git"
|
|
@@ -224,18 +252,5 @@
|
|
|
224
252
|
"utilities",
|
|
225
253
|
"utils",
|
|
226
254
|
"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
|
-
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
@@ -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
|
-
};
|