@paragrav/rhf-utils 0.0.60 → 0.0.62
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 +53 -0
- package/dist/esm/client/zod/context/index.mjs +6 -0
- package/dist/esm/client/zod/context/provider.mjs +11 -0
- package/dist/esm/client/zod/index.mjs +6 -0
- package/dist/esm/exports.mjs +76 -72
- package/dist/esm/form/FormWithProviders.mjs +14 -0
- package/dist/esm/form/_Form.mjs +89 -0
- package/dist/esm/form/_FormBase.mjs +14 -0
- package/dist/esm/form/_FormProviders.mjs +16 -0
- package/dist/esm/form/useForm.mjs +12 -16
- package/dist/esm/submit/error/setCtxErrorsByFormSubmitError.mjs +12 -0
- package/dist/types/src/client/config.d.ts +19 -0
- package/dist/types/src/client/context.d.ts +3 -0
- package/dist/types/src/client/index.d.ts +26 -0
- package/dist/types/src/client/zod/context/index.d.ts +8 -0
- package/dist/types/src/client/zod/context/provider.d.ts +12 -0
- package/dist/types/src/client/zod/index.d.ts +8 -0
- package/dist/types/src/exports.d.ts +6 -2
- package/dist/types/src/form/FormWithProviders.d.ts +2 -2
- package/dist/types/src/form/_Form.d.ts +2 -3
- package/dist/types/src/form/_FormProviders.d.ts +2 -3
- package/dist/types/src/form/useForm.d.ts +12 -28
- package/dist/types/src/form/useFormOptions.d.ts +28 -0
- package/dist/types/src/main.d.ts +1 -7
- package/package.json +12 -4
- package/README.md +0 -1
- package/dist/assets/index-BgBykTYQ.js +0 -40
- package/dist/esm/config/index.mjs +0 -21
- package/dist/index.html +0 -12
- package/dist/types/devtool/LazyDevTool.d.ts +0 -11
- package/dist/types/errors/consoleErrors.d.ts +0 -13
- package/dist/types/errors/context/index.d.ts +0 -10
- package/dist/types/errors/context/provider.d.ts +0 -12
- package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -15
- package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -25
- package/dist/types/errors/flat/types.d.ts +0 -13
- package/dist/types/errors/flat/useFormFlatFieldErrorsMemo.d.ts +0 -5
- package/dist/types/errors/flat/useRefdFieldErrorsMemo.d.ts +0 -9
- package/dist/types/errors/isFieldError.d.ts +0 -7
- package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
- package/dist/types/errors/message/FormErrorMessageByPath.d.ts +0 -9
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts +0 -10
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -1
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +0 -2
- package/dist/types/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
- package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
- package/dist/types/errors/orphan/getOrphansFromFieldErrors.d.ts +0 -5
- package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
- package/dist/types/errors/orphan/useFormHasOrphanAndNoFieldErrors.d.ts +0 -9
- package/dist/types/errors/orphan/useOrphanFormErrorsMemo.d.ts +0 -4
- package/dist/types/errors/orphan/useOrphanFormErrorsToConsole.d.ts +0 -9
- package/dist/types/errors/outputErrors.d.ts +0 -14
- package/dist/types/errors/root/FormRootErrors.d.ts +0 -7
- package/dist/types/errors/root/FormRootErrorsFromContext.d.ts +0 -3
- package/dist/types/errors/root/consts.d.ts +0 -1
- package/dist/types/errors/root/getRootsFromFieldErrors.d.ts +0 -5
- package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -4
- package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -6
- package/dist/types/errors/root/useRootFormFieldErrorsMemo.d.ts +0 -6
- package/dist/types/errors/useFormErrorConsoleDebug.d.ts +0 -8
- package/dist/types/errors/useFormErrorsEffect.d.ts +0 -4
- package/dist/types/errors/useFormErrorsIfAny.d.ts +0 -6
- package/dist/types/errors/useFormErrorsMemo.d.ts +0 -7
- package/dist/types/errors/useFormErrorsToConsole.d.ts +0 -14
- package/dist/types/errors/useFormRequestSubmit.d.ts +0 -6
- package/dist/types/exports.d.ts +0 -37
- package/dist/types/form/ErrorBoundary.d.ts +0 -15
- package/dist/types/form/Form.d.ts +0 -30
- package/dist/types/form/FormBase.d.ts +0 -9
- package/dist/types/form/FormWithProviders.d.ts +0 -13
- package/dist/types/form/context/FormProvider.d.ts +0 -16
- package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
- package/dist/types/form/context/group/index.d.ts +0 -15
- package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
- package/dist/types/form/context/utils/FormUtilsContextProvider.d.ts +0 -15
- package/dist/types/form/context/utils/useFormUtilsContext.d.ts +0 -9
- package/dist/types/form/search/FormSearch.d.ts +0 -32
- package/dist/types/form/search/FormSearchHiddenInputs.d.ts +0 -13
- package/dist/types/form/search/getNewSearchParams.d.ts +0 -2
- package/dist/types/form/useForm.d.ts +0 -30
- package/dist/types/form/useFormIsBusy.d.ts +0 -2
- package/dist/types/form/useFormOrParentIsBusy.d.ts +0 -2
- package/dist/types/form/useFormWithProviders.d.ts +0 -31
- package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -11
- package/dist/types/isEmptyObject.d.ts +0 -2
- package/dist/types/main.d.ts +0 -1
- package/dist/types/src/config/index.d.ts +0 -69
- package/dist/types/src/form/ErrorBoundary.d.ts +0 -15
- package/dist/types/src/form/Form.d.ts +0 -29
- package/dist/types/src/form/FormBase.d.ts +0 -9
- package/dist/types/src/form/context/FormProvider.d.ts +0 -15
- package/dist/types/src/form/search/FormSearch.d.ts +0 -32
- package/dist/types/src/form/search/FormSearchHiddenInputs.d.ts +0 -13
- package/dist/types/src/form/search/getNewSearchParams.d.ts +0 -2
- package/dist/types/src/form/useFormOrParentIsBusy.d.ts +0 -2
- package/dist/types/src/form/useFormWithProviders.d.ts +0 -31
- package/dist/types/src/isEmptyObject.d.ts +0 -2
- package/dist/types/src/submit/error/handleFormSubmitError.d.ts +0 -7
- package/dist/types/submit/error/FormSubmitError.d.ts +0 -6
- package/dist/types/submit/error/handleFormSubmitError.d.ts +0 -7
- package/dist/types/submit/useFormOnSubmitSuccessful.d.ts +0 -2
- package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -13
- package/dist/types/submit/useResetFormOnSubmitError.d.ts +0 -7
- package/dist/types/submit/useResetFormOnSubmitSuccessful.d.ts +0 -12
- package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -4
- package/dist/types/utils/createContext.d.ts +0 -8
- package/dist/types/utils/fixedForwardRef.d.ts +0 -7
- package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
- package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
- package/dist/types/utils/useToggle.d.ts +0 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import u from "../form/FormWithProviders.mjs";
|
|
3
|
+
import F from "../form/useForm.mjs";
|
|
4
|
+
const p = (t) => (r) => {
|
|
5
|
+
const e = l(
|
|
6
|
+
t,
|
|
7
|
+
r
|
|
8
|
+
);
|
|
9
|
+
return {
|
|
10
|
+
config: r,
|
|
11
|
+
useForm: (o, s) => F(
|
|
12
|
+
e(o, s)
|
|
13
|
+
),
|
|
14
|
+
FormWithProviders: P(t, r)
|
|
15
|
+
};
|
|
16
|
+
}, P = (t, r) => function({
|
|
17
|
+
schema: o,
|
|
18
|
+
children: s,
|
|
19
|
+
...m
|
|
20
|
+
}) {
|
|
21
|
+
const i = l(t, r);
|
|
22
|
+
return /* @__PURE__ */ d(
|
|
23
|
+
u,
|
|
24
|
+
{
|
|
25
|
+
...i(o, m),
|
|
26
|
+
children: s
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}, l = (t, r) => (e, o) => {
|
|
30
|
+
var s, m, i, n, f, a, h;
|
|
31
|
+
return {
|
|
32
|
+
...o,
|
|
33
|
+
rhf: {
|
|
34
|
+
...(s = r.defaultOptions) == null ? void 0 : s.rhf,
|
|
35
|
+
...o.rhf,
|
|
36
|
+
resolver: t(e)
|
|
37
|
+
},
|
|
38
|
+
form: {
|
|
39
|
+
...o.form,
|
|
40
|
+
options: {
|
|
41
|
+
...(m = r.defaultOptions) == null ? void 0 : m.form,
|
|
42
|
+
...(i = o.form) == null ? void 0 : i.options,
|
|
43
|
+
classNames: [
|
|
44
|
+
...((f = (n = r.defaultOptions) == null ? void 0 : n.form) == null ? void 0 : f.classNames) ?? [],
|
|
45
|
+
...((h = (a = o.form) == null ? void 0 : a.options) == null ? void 0 : h.classNames) ?? []
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
p as createRhfUtilsClient
|
|
53
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import i from "react";
|
|
3
|
+
import { createZodRhfUtilsClient as s } from "../index.mjs";
|
|
4
|
+
import { _RhfUtilsContextProvider as f } from "./index.mjs";
|
|
5
|
+
const n = ({ config: t, children: o }) => {
|
|
6
|
+
const [r] = i.useState(() => s(t));
|
|
7
|
+
return /* @__PURE__ */ e(f, { value: r, children: o });
|
|
8
|
+
}, c = n;
|
|
9
|
+
export {
|
|
10
|
+
c as default
|
|
11
|
+
};
|
package/dist/esm/exports.mjs
CHANGED
|
@@ -1,74 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { default as s } from "./
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as d } from "./errors/
|
|
6
|
-
import { default as x } from "./errors/
|
|
7
|
-
import { default as n } from "./errors/
|
|
8
|
-
import { default as E } from "./errors/
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as y } from "./errors/orphan/
|
|
12
|
-
import { default as M } from "./errors/
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as v } from "./errors/
|
|
18
|
-
import { default as
|
|
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
|
|
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
|
|
31
|
-
import {
|
|
32
|
-
import { default as dr } from "./
|
|
33
|
-
import {
|
|
34
|
-
import { default as nr } from "./submit/
|
|
35
|
-
import { default as Er } from "./submit/
|
|
36
|
-
import { default as
|
|
1
|
+
import { createZodRhfUtilsClient as e } from "./client/zod/index.mjs";
|
|
2
|
+
import { default as s } from "./client/zod/context/index.mjs";
|
|
3
|
+
import { default as u } from "./client/zod/context/provider.mjs";
|
|
4
|
+
import { default as m } from "./devtool/LazyDevTool.mjs";
|
|
5
|
+
import { default as d } from "./errors/context/index.mjs";
|
|
6
|
+
import { default as x } from "./errors/context/provider.mjs";
|
|
7
|
+
import { default as n } from "./errors/message/FormErrorMessage.mjs";
|
|
8
|
+
import { default as E } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
9
|
+
import { default as c } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
10
|
+
import { default as S } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
11
|
+
import { default as y } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.mjs";
|
|
12
|
+
import { default as M } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
13
|
+
import { default as P } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
14
|
+
import { default as I } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
15
|
+
import { default as k } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
16
|
+
import { default as B } from "./errors/useFormErrorsEffect.mjs";
|
|
17
|
+
import { default as v } from "./errors/useFormErrorsIfAny.mjs";
|
|
18
|
+
import { default as D } from "./errors/useFormErrorsMemo.mjs";
|
|
19
|
+
import { default as Z } from "./errors/useFormRequestSubmit.mjs";
|
|
20
|
+
import { default as q } from "./form/useForm.mjs";
|
|
21
|
+
import { default as L } from "./form/context/utils/FormUtilsContextProvider.mjs";
|
|
22
|
+
import { default as w } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
23
|
+
import { default as K } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
24
|
+
import { default as V } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
25
|
+
import { default as X } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
26
|
+
import { default as _ } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
27
|
+
import { default as rr } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
28
|
+
import { default as er } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
29
|
+
import { default as sr } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
30
|
+
import { default as ur } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
31
|
+
import { default as mr } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
32
|
+
import { default as dr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
33
|
+
import { FormSubmitError as xr } from "./submit/error/FormSubmitError.mjs";
|
|
34
|
+
import { default as nr } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
35
|
+
import { default as Er } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
36
|
+
import { default as cr } from "./submit/useResetFormOnSubmitError.mjs";
|
|
37
|
+
import { default as Sr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
38
|
+
import { default as yr } from "./submit/useSubmitFormOnChange.mjs";
|
|
37
39
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
e as
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
n as FormErrorMessage,
|
|
41
|
+
E as FormErrorMessageByPath,
|
|
42
|
+
x as FormErrorsFlatContextProvider,
|
|
43
|
+
K as FormGroupContextProvider,
|
|
44
|
+
c as FormNonFieldErrorMarker,
|
|
45
|
+
S as FormNonFieldErrorMarkerHtmlAttribute,
|
|
46
|
+
xr as FormSubmitError,
|
|
47
|
+
L as FormUtilsContextProvider,
|
|
48
|
+
m as LazyDevTool,
|
|
49
|
+
u as RhfUtilsZodContextProvider,
|
|
50
|
+
e as createZodRhfUtilsClient,
|
|
51
|
+
dr as getSubmitterButtonData,
|
|
52
|
+
q as useForm,
|
|
53
|
+
k as useFormErrorConsoleDebug,
|
|
54
|
+
B as useFormErrorsEffect,
|
|
55
|
+
d as useFormErrorsFlatContext,
|
|
56
|
+
v as useFormErrorsIfAny,
|
|
57
|
+
D as useFormErrorsMemo,
|
|
58
|
+
V as useFormGroupChildIsMountedTracker,
|
|
59
|
+
X as useFormGroupChildIsSubmittingTracker,
|
|
60
|
+
_ as useFormGroupChildTracker,
|
|
61
|
+
rr as useFormGroupIsAnyBusy,
|
|
62
|
+
er as useFormGroupIsChildBusy,
|
|
63
|
+
sr as useFormGroupIsParentBusy,
|
|
64
|
+
ur as useFormGroupParentTracker,
|
|
65
|
+
y as useFormHasOrphanAndNoFieldErrors,
|
|
66
|
+
nr as useFormOnSubmitSuccessful,
|
|
67
|
+
Er as useFormOnSubmitSuccessfulAndReset,
|
|
68
|
+
mr as useFormOrParentIsBusy,
|
|
69
|
+
Z as useFormRequestSubmit,
|
|
70
|
+
w as useFormUtilsContext,
|
|
71
|
+
M as useOrphanFormErrorsMemo,
|
|
72
|
+
P as useOrphanFormErrorsToConsole,
|
|
73
|
+
Sr as useResetFormAfterSubmitSuccessful,
|
|
74
|
+
cr as useResetFormOnSubmitError,
|
|
75
|
+
s as useRhfUtilsZodContext,
|
|
76
|
+
I as useRootFormFieldErrorsMemo,
|
|
77
|
+
yr as useSubmitFormOnChange
|
|
74
78
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import t from "./_Form.mjs";
|
|
3
|
+
import e from "./_FormProviders.mjs";
|
|
4
|
+
import f from "./useForm.mjs";
|
|
5
|
+
function u({
|
|
6
|
+
children: m,
|
|
7
|
+
...i
|
|
8
|
+
}) {
|
|
9
|
+
const r = f(i);
|
|
10
|
+
return /* @__PURE__ */ o(e, { ...r.providerProps, children: /* @__PURE__ */ o(t, { ...r.formProps, children: m }) });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
u as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsxs as v, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useFormContext as B } from "react-hook-form";
|
|
4
|
+
import N from "../devtool/LazyDevTool.mjs";
|
|
5
|
+
import { FormSubmitError as P } from "../submit/error/FormSubmitError.mjs";
|
|
6
|
+
import T from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
7
|
+
import V from "../submit/useResetFormOnSubmitError.mjs";
|
|
8
|
+
import _ from "./_FormBase.mjs";
|
|
9
|
+
function A({
|
|
10
|
+
formId: x,
|
|
11
|
+
formRef: l,
|
|
12
|
+
form: t,
|
|
13
|
+
children: y
|
|
14
|
+
}) {
|
|
15
|
+
var c, b, S, o, h;
|
|
16
|
+
const a = B();
|
|
17
|
+
V({
|
|
18
|
+
disabled: !((c = t == null ? void 0 : t.options) != null && c.resetValuesOnSubmitError)
|
|
19
|
+
});
|
|
20
|
+
const C = async (i) => {
|
|
21
|
+
var n;
|
|
22
|
+
(n = t == null ? void 0 : t.options) != null && n.stopSubmitPropagation && i.stopPropagation();
|
|
23
|
+
try {
|
|
24
|
+
await a.handleSubmit(
|
|
25
|
+
g,
|
|
26
|
+
t == null ? void 0 : t.onSubmitInvalid
|
|
27
|
+
)(i);
|
|
28
|
+
} catch (s) {
|
|
29
|
+
j(s, i);
|
|
30
|
+
}
|
|
31
|
+
}, g = (i, n) => {
|
|
32
|
+
var s;
|
|
33
|
+
return (s = t == null ? void 0 : t.onSubmit) == null ? void 0 : s.call(
|
|
34
|
+
t,
|
|
35
|
+
i,
|
|
36
|
+
a,
|
|
37
|
+
n
|
|
38
|
+
);
|
|
39
|
+
}, j = (i, n) => {
|
|
40
|
+
var e, E, F;
|
|
41
|
+
const s = i instanceof P ? (
|
|
42
|
+
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
43
|
+
i
|
|
44
|
+
) : (
|
|
45
|
+
// if error is not FormSubmitError, consumer can provide global handler
|
|
46
|
+
(E = (e = t == null ? void 0 : t.options) == null ? void 0 : e.onSubmitError) == null ? void 0 : E.call(e, i)
|
|
47
|
+
);
|
|
48
|
+
s && T(a, s), (F = t == null ? void 0 : t.onSubmitError) == null || F.call(
|
|
49
|
+
t,
|
|
50
|
+
i,
|
|
51
|
+
a,
|
|
52
|
+
n
|
|
53
|
+
);
|
|
54
|
+
}, u = {
|
|
55
|
+
formId: x,
|
|
56
|
+
formRef: l,
|
|
57
|
+
ctx: a,
|
|
58
|
+
options: t == null ? void 0 : t.options
|
|
59
|
+
}, d = (i) => {
|
|
60
|
+
var s, e;
|
|
61
|
+
const n = (e = (s = t == null ? void 0 : t.options) == null ? void 0 : s.Children) == null ? void 0 : e[i];
|
|
62
|
+
return n && /* @__PURE__ */ p(n, { ...u });
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ v(
|
|
65
|
+
_,
|
|
66
|
+
{
|
|
67
|
+
noValidate: !0,
|
|
68
|
+
style: {
|
|
69
|
+
position: "relative"
|
|
70
|
+
},
|
|
71
|
+
...t == null ? void 0 : t.props,
|
|
72
|
+
className: [(b = t == null ? void 0 : t.options) == null ? void 0 : b.classNames, ((S = t == null ? void 0 : t.props) == null ? void 0 : S.className) ?? ""].join(
|
|
73
|
+
" "
|
|
74
|
+
),
|
|
75
|
+
onSubmit: C,
|
|
76
|
+
formRef: l,
|
|
77
|
+
children: [
|
|
78
|
+
d("top"),
|
|
79
|
+
((o = t == null ? void 0 : t.options) == null ? void 0 : o.devTool) !== "disabled" && /* @__PURE__ */ p(N, { placement: "top-right", ...(h = t == null ? void 0 : t.options) == null ? void 0 : h.devTool }),
|
|
80
|
+
(t == null ? void 0 : t.Fields) && /* @__PURE__ */ p(t.Fields, { ...u }),
|
|
81
|
+
y,
|
|
82
|
+
d("bottom")
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
A as default
|
|
89
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs as m, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const n = ({
|
|
4
|
+
formRef: e,
|
|
5
|
+
antiCsrfToken: r,
|
|
6
|
+
children: o,
|
|
7
|
+
...t
|
|
8
|
+
}) => /* @__PURE__ */ m("form", { role: "form", ...t, ref: e, children: [
|
|
9
|
+
r && /* @__PURE__ */ s("input", { type: "hidden", name: "anticsrftoken", value: r }),
|
|
10
|
+
o
|
|
11
|
+
] }), i = n;
|
|
12
|
+
export {
|
|
13
|
+
i as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { FormProvider as d } from "react-hook-form";
|
|
3
|
+
import n from "../errors/context/provider.mjs";
|
|
4
|
+
import l from "./context/utils/FormUtilsContextProvider.mjs";
|
|
5
|
+
function v({
|
|
6
|
+
formId: t,
|
|
7
|
+
formRef: o,
|
|
8
|
+
rhfForm: i,
|
|
9
|
+
utils: m,
|
|
10
|
+
children: e
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ r(d, { ...i, children: /* @__PURE__ */ r(n, { formRef: o, children: /* @__PURE__ */ r(l, { formId: t, formRef: o, ...m, children: e }) }) });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
v as default
|
|
16
|
+
};
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import i from "react";
|
|
1
|
+
import n from "react";
|
|
3
2
|
import { useForm as u } from "react-hook-form";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const a = ({
|
|
7
|
-
schema: t,
|
|
3
|
+
import i from "../submit/useSubmitFormOnChange.mjs";
|
|
4
|
+
const l = ({
|
|
8
5
|
rhf: m,
|
|
9
6
|
form: o,
|
|
10
7
|
utils: p
|
|
11
8
|
}) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}),
|
|
17
|
-
return c(r, { disabled: !e.options.submitOnChange }), {
|
|
9
|
+
var t;
|
|
10
|
+
const s = n.useId(), e = u(m), r = n.useRef(null);
|
|
11
|
+
return i(r, {
|
|
12
|
+
disabled: !((t = o == null ? void 0 : o.options) != null && t.submitOnChange)
|
|
13
|
+
}), {
|
|
18
14
|
id: s,
|
|
19
15
|
ref: r,
|
|
20
|
-
context:
|
|
16
|
+
context: e,
|
|
21
17
|
providerProps: {
|
|
22
18
|
formId: s,
|
|
23
19
|
formRef: r,
|
|
24
|
-
rhfForm:
|
|
20
|
+
rhfForm: e,
|
|
25
21
|
utils: p
|
|
26
22
|
},
|
|
27
23
|
formProps: {
|
|
@@ -30,7 +26,7 @@ const a = ({
|
|
|
30
26
|
form: o
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
|
-
}
|
|
29
|
+
};
|
|
34
30
|
export {
|
|
35
|
-
|
|
31
|
+
l as default
|
|
36
32
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseFormOptions } from '../form/useFormOptions';
|
|
2
|
+
import { UseFormProps } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
export type ClientConfig = {
|
|
5
|
+
defaultOptions?: {
|
|
6
|
+
/**
|
|
7
|
+
* Default RHF `useForm` settings.
|
|
8
|
+
*
|
|
9
|
+
* (Exposes only non-local props.)
|
|
10
|
+
*/
|
|
11
|
+
rhf?: Pick<UseFormProps, 'mode' | 'reValidateMode' | 'resetOptions' | 'context' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'progressive' | 'criteriaMode' | 'delayError'>;
|
|
12
|
+
/**
|
|
13
|
+
* Default global options settings.
|
|
14
|
+
*
|
|
15
|
+
* Extend this type to inject custom options/functionality via `Children` component.
|
|
16
|
+
*/
|
|
17
|
+
form?: UseFormOptions;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CreateRhfUtilsClient, ObjectSchema } from '.';
|
|
2
|
+
|
|
3
|
+
export type RhfUtilsClientContext<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClientConfig } from './config';
|
|
2
|
+
import { UseFormProps, UseFormReturn } from '../form/useForm';
|
|
3
|
+
import { FormWithProvidersProps } from '../form/FormWithProviders';
|
|
4
|
+
import { FieldValues, Resolver } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generic object schema type.
|
|
8
|
+
*/
|
|
9
|
+
export type ObjectSchema<TInputKey extends string, TOutputKey extends string> = {
|
|
10
|
+
[key in TInputKey]: FieldValues;
|
|
11
|
+
} & {
|
|
12
|
+
[key in TOutputKey]: FieldValues;
|
|
13
|
+
};
|
|
14
|
+
export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
|
|
15
|
+
config: ClientConfig;
|
|
16
|
+
useForm: <TSchema extends TObjectSchema, TSchemaInput extends FieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends FieldValues = TSchema[TObjectSchemaOutputKey]>(schema: TSchema, props: UseFormProps<TSchemaInput, TSchemaOutput>) => UseFormReturn<TSchemaInput, TSchemaOutput>;
|
|
17
|
+
FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends FieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends FieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
|
|
18
|
+
schema: TSchema;
|
|
19
|
+
} & FormWithProvidersProps<TSchemaInput, TSchemaOutput>) => JSX.Element;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* ...
|
|
23
|
+
*
|
|
24
|
+
* (We need to use generics to generate types for schema resolver.)
|
|
25
|
+
*/
|
|
26
|
+
export declare const createRhfUtilsClient: <TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string>(resolver: (schema: TObjectSchema) => Resolver<FieldValues, unknown>) => (config: ClientConfig) => CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RhfUtilsClientContext } from '../../context';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
export type RhfUtilsZodClientContext = RhfUtilsClientContext<z.ZodObject<FieldValues>, '_input', '_output'>;
|
|
6
|
+
declare const useRhfUtilsZodContext: () => RhfUtilsZodClientContext, _RhfUtilsZodContextProvider: import('react').Provider<RhfUtilsZodClientContext | undefined>;
|
|
7
|
+
export default useRhfUtilsZodContext;
|
|
8
|
+
export { _RhfUtilsZodContextProvider as _RhfUtilsContextProvider };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClientConfig } from '../../config';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = React.PropsWithChildren<{
|
|
5
|
+
config: ClientConfig;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Provides a flattened version of the form errors.
|
|
9
|
+
* Allows flattening and filtering to happen once per errors change.
|
|
10
|
+
*/
|
|
11
|
+
declare const RhfUtilsZodContextProvider: React.FC<Props>;
|
|
12
|
+
export default RhfUtilsZodContextProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
export declare const createZodRhfUtilsClient: (config: import('../config').ClientConfig) => import('..').CreateRhfUtilsClient<z.ZodObject<FieldValues, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
}, {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}>, "_input", "_output">;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { ClientConfig } from './client/config';
|
|
2
|
+
export { createZodRhfUtilsClient } from './client/zod';
|
|
3
|
+
export { default as useRhfUtilsZodContext } from './client/zod/context';
|
|
4
|
+
export { default as RhfUtilsZodContextProvider } from './client/zod/context/provider';
|
|
2
5
|
export { default as LazyDevTool } from './devtool/LazyDevTool';
|
|
3
6
|
export { default as useFormErrorsFlatContext } from './errors/context';
|
|
4
7
|
export { default as FormErrorsFlatContextProvider } from './errors/context/provider';
|
|
@@ -15,8 +18,9 @@ export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
|
|
|
15
18
|
export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
16
19
|
export { default as useFormErrorsMemo } from './errors/useFormErrorsMemo';
|
|
17
20
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
|
18
|
-
export type { UseFormFieldsProps
|
|
21
|
+
export type { UseFormFieldsProps } from './form/useForm';
|
|
19
22
|
export { default as useForm } from './form/useForm';
|
|
23
|
+
export type { UseFormOptions } from './form/useFormOptions';
|
|
20
24
|
export { default as FormUtilsContextProvider } from './form/context/utils/FormUtilsContextProvider';
|
|
21
25
|
export { default as useFormUtilsContext } from './form/context/utils/useFormUtilsContext';
|
|
22
26
|
export { default as FormGroupContextProvider } from './form/context/group/FormGroupContextProvider';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UseFormProps } from './useForm';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import { FieldValues } from 'react-hook-form';
|
|
4
3
|
|
|
4
|
+
export type FormWithProvidersProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<UseFormProps<TFieldValues, TTransformedValues>>;
|
|
5
5
|
/**
|
|
6
6
|
* Form providers (with utils) with immediate descendent {@link Form}.
|
|
7
7
|
* (Syntactic sugar for {@link useForm}. Use this for most applications.)
|
|
@@ -9,5 +9,5 @@ import { FieldValues } from 'react-hook-form';
|
|
|
9
9
|
* Use {@link useForm} if you need to specific nesting hierarchy.
|
|
10
10
|
* (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)
|
|
11
11
|
*/
|
|
12
|
-
declare function FormWithProviders<
|
|
12
|
+
declare function FormWithProviders<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ children, ...props }: FormWithProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default FormWithProviders;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { UseFormProps } from './useForm';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import { FieldValues } from 'react-hook-form';
|
|
4
3
|
import { default as React } from 'react';
|
|
5
4
|
|
|
6
5
|
export type _FormSlots = 'top' | 'bottom';
|
|
7
|
-
export type _FormProps<
|
|
6
|
+
export type _FormProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<Pick<UseFormProps<TFieldValues, TTransformedValues>, 'form'> & {
|
|
8
7
|
formId: string;
|
|
9
8
|
formRef: React.RefObject<HTMLFormElement>;
|
|
10
9
|
}>;
|
|
11
|
-
declare function _Form<
|
|
10
|
+
declare function _Form<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ formId, formRef, form, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export default _Form;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { FormUtilsContextProviderProps } from './context/utils/FormUtilsContextProvider';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
4
3
|
|
|
5
|
-
export type _FormProvidersProps<
|
|
4
|
+
export type _FormProvidersProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<{
|
|
6
5
|
formId: string;
|
|
7
6
|
formRef: React.RefObject<HTMLFormElement>;
|
|
8
7
|
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
8
|
utils?: FormUtilsContextProviderProps;
|
|
10
9
|
}>;
|
|
11
|
-
declare function _FormProviders<
|
|
10
|
+
declare function _FormProviders<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ formId, formRef, rhfForm, utils, children, }: _FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export default _FormProviders;
|