@paragrav/rhf-utils 0.0.38 → 0.0.45
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/form/FormWithProvider.mjs +9 -0
- package/dist/esm/form/context/FormProvider.mjs +27 -0
- package/dist/esm/form/context/utils/FormUtilsContextProvider.mjs +21 -0
- package/dist/esm/form/context/utils/useFormUtilsContext.mjs +6 -0
- package/dist/esm/form/useFormWithProvider.mjs +30 -0
- package/dist/esm/main.mjs +58 -44
- package/dist/esm/utils/useImperativeForwardedRef.mjs +3 -3
- package/dist/types/form/useFormWithProvider.d.ts +2 -1
- package/dist/types/main.d.ts +8 -1
- package/package.json +29 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import e from "./useFormWithProvider.mjs";
|
|
3
|
+
function f({ children: i, ...t }) {
|
|
4
|
+
const r = e(t);
|
|
5
|
+
return /* @__PURE__ */ o(r.Provider, { children: /* @__PURE__ */ o(r.Form, { children: i }) });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
f as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { FormProvider as n } from "react-hook-form";
|
|
3
|
+
import p from "./utils/FormUtilsContextProvider.mjs";
|
|
4
|
+
function F({
|
|
5
|
+
isDev: o,
|
|
6
|
+
formId: m,
|
|
7
|
+
formRef: i,
|
|
8
|
+
rhf: t,
|
|
9
|
+
form: e,
|
|
10
|
+
utils: d,
|
|
11
|
+
children: f
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ r(n, { ...t, children: /* @__PURE__ */ r(
|
|
14
|
+
p,
|
|
15
|
+
{
|
|
16
|
+
isDev: o,
|
|
17
|
+
formId: m,
|
|
18
|
+
formRef: i,
|
|
19
|
+
formProps: e,
|
|
20
|
+
...d,
|
|
21
|
+
children: f
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
F as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import p from "../../../errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
3
|
+
import F from "../../../errors/useFormErrorConsoleDebug.mjs";
|
|
4
|
+
import u from "../../../errors/useFormRequestSubmit.mjs";
|
|
5
|
+
import a from "../../../submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
6
|
+
import s from "../../../submit/useResetFormOnSubmitSuccessful.mjs";
|
|
7
|
+
import { _FormUtilsContextProvider as l } from "./useFormUtilsContext.mjs";
|
|
8
|
+
function O({
|
|
9
|
+
isDev: m,
|
|
10
|
+
formRef: o,
|
|
11
|
+
onSubmitSuccessfulAndReset: r,
|
|
12
|
+
children: t
|
|
13
|
+
}) {
|
|
14
|
+
const e = u(o);
|
|
15
|
+
return F(m), p(o, m, !0), s({ enabled: !!r }), a(() => {
|
|
16
|
+
r == null || r();
|
|
17
|
+
}), /* @__PURE__ */ i(l, { value: { formRef: o, requestSubmit: e }, children: t });
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
O as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import d from "./context/FormProvider.mjs";
|
|
4
|
+
import s from "./useForm.mjs";
|
|
5
|
+
const n = ({
|
|
6
|
+
isDev: o,
|
|
7
|
+
rhf: e,
|
|
8
|
+
form: t,
|
|
9
|
+
utils: m
|
|
10
|
+
}) => {
|
|
11
|
+
const r = s({ isDev: o, rhf: e, form: t });
|
|
12
|
+
return {
|
|
13
|
+
...r,
|
|
14
|
+
Provider: ({ children: i }) => /* @__PURE__ */ f(
|
|
15
|
+
d,
|
|
16
|
+
{
|
|
17
|
+
isDev: o,
|
|
18
|
+
formRef: r.ref,
|
|
19
|
+
rhf: r.context,
|
|
20
|
+
formId: r.id,
|
|
21
|
+
form: t,
|
|
22
|
+
utils: m,
|
|
23
|
+
children: i
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
};
|
|
27
|
+
}, F = n;
|
|
28
|
+
export {
|
|
29
|
+
F as default
|
|
30
|
+
};
|
package/dist/esm/main.mjs
CHANGED
|
@@ -3,56 +3,70 @@ import { default as s } from "./errors/context/index.mjs";
|
|
|
3
3
|
import { default as u } from "./errors/context/provider.mjs";
|
|
4
4
|
import { default as f } from "./errors/message/FormErrorMessage.mjs";
|
|
5
5
|
import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
6
|
+
import { default as x } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
7
|
+
import { default as i } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
8
8
|
import { default as E } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import {
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import { default as
|
|
22
|
-
import { default as
|
|
23
|
-
import { default as
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as Y } from "./form/
|
|
26
|
-
import { default as _ } from "./
|
|
27
|
-
import { default as rr } from "./
|
|
28
|
-
import { default as er } from "./
|
|
9
|
+
import { default as C } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
10
|
+
import { default as P } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
11
|
+
import { default as b } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
12
|
+
import { default as v } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
13
|
+
import { default as G } from "./errors/useFormErrorsEffect.mjs";
|
|
14
|
+
import { default as I } from "./errors/useFormErrorsIfAny.mjs";
|
|
15
|
+
import { default as k } from "./errors/useFormErrorsMemo.mjs";
|
|
16
|
+
import { default as O } from "./errors/useFormRequestSubmit.mjs";
|
|
17
|
+
import { default as R } from "./form/Form.mjs";
|
|
18
|
+
import { FormError as N } from "./form/FormError.mjs";
|
|
19
|
+
import { default as U } from "./form/FormWithProvider.mjs";
|
|
20
|
+
import { default as q } from "./form/useForm.mjs";
|
|
21
|
+
import { default as L } from "./form/useFormWithProvider.mjs";
|
|
22
|
+
import { default as w } from "./form/context/FormProvider.mjs";
|
|
23
|
+
import { default as K } from "./form/context/utils/FormUtilsContextProvider.mjs";
|
|
24
|
+
import { default as V } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
25
|
+
import { default as Y } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
26
|
+
import { default as _ } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
27
|
+
import { default as rr } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
28
|
+
import { default as er } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
29
|
+
import { default as sr } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
30
|
+
import { default as ur } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
31
|
+
import { default as fr } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
32
|
+
import { default as dr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
33
|
+
import { default as xr } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
34
|
+
import { default as ir } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
35
|
+
import { default as Er } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
29
36
|
export {
|
|
37
|
+
R as Form,
|
|
38
|
+
N as FormError,
|
|
30
39
|
f as FormErrorMessage,
|
|
31
40
|
d as FormErrorMessageByPath,
|
|
32
41
|
u as FormErrorsFlatContextProvider,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
Y as FormGroupContextProvider,
|
|
43
|
+
x as FormNonFieldErrorMarker,
|
|
44
|
+
i as FormNonFieldErrorMarkerHtmlAttribute,
|
|
45
|
+
w as FormProvider,
|
|
46
|
+
K as FormUtilsContextProvider,
|
|
47
|
+
U as FormWithProvider,
|
|
36
48
|
e as LazyDevTool,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
dr as getSubmitterButtonData,
|
|
50
|
+
q as useForm,
|
|
51
|
+
v as useFormErrorConsoleDebug,
|
|
52
|
+
G as useFormErrorsEffect,
|
|
41
53
|
s as useFormErrorsFlatContext,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
I as useFormErrorsIfAny,
|
|
55
|
+
k as useFormErrorsMemo,
|
|
56
|
+
_ as useFormGroupChildIsMountedTracker,
|
|
57
|
+
rr as useFormGroupChildIsSubmittingTracker,
|
|
58
|
+
er as useFormGroupIsAnyBusy,
|
|
59
|
+
sr as useFormGroupIsChildBusy,
|
|
60
|
+
ur as useFormGroupIsParentBusy,
|
|
61
|
+
fr as useFormGroupParentTracker,
|
|
50
62
|
E as useFormHasOrphanAndNoFieldErrors,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
xr as useFormOnSubmitSuccessful,
|
|
64
|
+
ir as useFormOnSubmitSuccessfulAndReset,
|
|
65
|
+
O as useFormRequestSubmit,
|
|
66
|
+
V as useFormUtilsContext,
|
|
67
|
+
L as useFormWithProvider,
|
|
68
|
+
C as useOrphanFormErrorsMemo,
|
|
69
|
+
P as useOrphanFormErrorsToConsole,
|
|
70
|
+
Er as useResetFormAfterSubmitSuccessful,
|
|
71
|
+
b as useRootFormFieldErrorsMemo
|
|
58
72
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "react";
|
|
2
|
-
const
|
|
2
|
+
const a = (t) => {
|
|
3
3
|
const e = r.useRef(null);
|
|
4
4
|
return r.useImperativeHandle(
|
|
5
5
|
t,
|
|
@@ -10,7 +10,7 @@ const u = (t) => {
|
|
|
10
10
|
},
|
|
11
11
|
[]
|
|
12
12
|
), e;
|
|
13
|
-
};
|
|
13
|
+
}, o = a;
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
o as default
|
|
16
16
|
};
|
|
@@ -17,7 +17,7 @@ export type UseFormWithProviderReturn = ReturnType<typeof useFormWithProvider>;
|
|
|
17
17
|
* see https://caniuse.com/?search=form%20attribute
|
|
18
18
|
* @returns Form provider and form.
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
declare const useFormWithProvider: <TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, rhf, form, utils, }: UseFormWithProviderProps<TFieldValues, TTransformedValues>) => {
|
|
21
21
|
readonly Provider: React.FC<{
|
|
22
22
|
children?: React.ReactNode;
|
|
23
23
|
}>;
|
|
@@ -28,3 +28,4 @@ export declare const useFormWithProvider: <TFieldValues extends FieldValues, TTr
|
|
|
28
28
|
children?: React.ReactNode;
|
|
29
29
|
}>;
|
|
30
30
|
};
|
|
31
|
+
export default useFormWithProvider;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
|
|
|
14
14
|
export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
15
15
|
export { default as useFormErrorsMemo } from './errors/useFormErrorsMemo';
|
|
16
16
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
|
17
|
+
export { default as Form } from './form/Form';
|
|
18
|
+
export { FormError } from './form/FormError';
|
|
19
|
+
export { default as FormWithProvider } from './form/FormWithProvider';
|
|
20
|
+
export { default as useForm } from './form/useForm';
|
|
21
|
+
export { default as useFormWithProvider } from './form/useFormWithProvider';
|
|
22
|
+
export { default as FormProvider } from './form/context/FormProvider';
|
|
23
|
+
export { default as FormUtilsContextProvider } from './form/context/utils/FormUtilsContextProvider';
|
|
24
|
+
export { default as useFormUtilsContext } from './form/context/utils/useFormUtilsContext';
|
|
17
25
|
export { default as FormGroupContextProvider } from './form/context/group/FormGroupContextProvider';
|
|
18
26
|
export { default as useFormGroupChildIsMountedTracker } from './form/context/group/useFormGroupChildIsMountedTracker';
|
|
19
27
|
export { default as useFormGroupChildIsSubmittingTracker } from './form/context/group/useFormGroupChildIsSubmittingTracker';
|
|
@@ -21,7 +29,6 @@ export { default as useFormGroupIsAnyBusy } from './form/context/group/useFormGr
|
|
|
21
29
|
export { default as useFormGroupIsChildBusy } from './form/context/group/useFormGroupIsChildBusy';
|
|
22
30
|
export { default as useFormGroupIsParentBusy } from './form/context/group/useFormGroupIsParentBusy';
|
|
23
31
|
export { default as useFormGroupParentTracker } from './form/context/group/useFormGroupParentTracker';
|
|
24
|
-
export { default as useForm } from './form/useForm';
|
|
25
32
|
export { default as getSubmitterButtonData } from './form/utils/getSubmitterButtonData';
|
|
26
33
|
export { default as useFormOnSubmitSuccessful } from './submit/useFormOnSubmitSuccessful';
|
|
27
34
|
export { default as useFormOnSubmitSuccessfulAndReset } from './submit/useFormOnSubmitSuccessfulAndReset';
|
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.45",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -71,10 +71,38 @@
|
|
|
71
71
|
"default": "./dist/esm/errors/root/useRootFormFieldErrors.mjs",
|
|
72
72
|
"types": "./dist/types/errors/root/useRootFormFieldErrors.d.ts"
|
|
73
73
|
},
|
|
74
|
+
"./form/Form": {
|
|
75
|
+
"default": "./dist/esm/form/Form.mjs",
|
|
76
|
+
"types": "./dist/types/form/Form.d.ts"
|
|
77
|
+
},
|
|
78
|
+
"./form/FormError": {
|
|
79
|
+
"default": "./dist/esm/form/FormError.mjs",
|
|
80
|
+
"types": "./dist/types/form/FormError.d.ts"
|
|
81
|
+
},
|
|
82
|
+
"./form/context/FormWithProvider": {
|
|
83
|
+
"default": "./dist/esm/form/context/FormWithProvider.mjs",
|
|
84
|
+
"types": "./dist/types/form/context/FormWithProvider.d.ts"
|
|
85
|
+
},
|
|
74
86
|
"./form/useForm": {
|
|
75
87
|
"default": "./dist/esm/form/useForm.mjs",
|
|
76
88
|
"types": "./dist/types/form/useForm.d.ts"
|
|
77
89
|
},
|
|
90
|
+
"./form/useFormWithProvider": {
|
|
91
|
+
"default": "./dist/esm/form/useFormWithProvider.mjs",
|
|
92
|
+
"types": "./dist/types/form/useFormWithProvider.d.ts"
|
|
93
|
+
},
|
|
94
|
+
"./form/context/FormProvider": {
|
|
95
|
+
"default": "./dist/esm/form/context/FormProvider.mjs",
|
|
96
|
+
"types": "./dist/types/form/context/FormProvider.d.ts"
|
|
97
|
+
},
|
|
98
|
+
"./form/context/FormUtilsContextProvider": {
|
|
99
|
+
"default": "./dist/esm/form/context/FormUtilsContextProvider.mjs",
|
|
100
|
+
"types": "./dist/types/form/context/FormUtilsContextProvider.d.ts"
|
|
101
|
+
},
|
|
102
|
+
"./form/context/useFormUtilsContext": {
|
|
103
|
+
"default": "./dist/esm/form/context/useFormUtilsContext.mjs",
|
|
104
|
+
"types": "./dist/types/form/context/useFormUtilsContext.d.ts"
|
|
105
|
+
},
|
|
78
106
|
"./form/context/group/FormGroupContextProvider": {
|
|
79
107
|
"default": "./dist/esm/form/context/group/FormGroupContextProvider.mjs",
|
|
80
108
|
"types": "./dist/types/form/context/group/FormGroupContextProvider.d.ts"
|