@paragrav/rhf-utils 0.0.138 → 0.0.140
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/README.md +29 -18
- package/dist/esm/{utils/createContext.mjs → createContext.mjs} +1 -1
- package/dist/esm/group.mjs +74 -0
- package/dist/esm/main.mjs +483 -0
- package/dist/esm/trpc.mjs +41 -0
- package/dist/esm/useFlatFieldErrorsContext.mjs +10 -0
- package/dist/esm/utils.mjs +20 -0
- package/dist/types/group.d.ts +9 -0
- package/dist/types/main.d.ts +15 -1
- package/dist/types/trpc.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -0
- package/package.json +22 -4
- package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs +0 -9
- package/dist/esm/client/index.mjs +0 -49
- package/dist/esm/client/utils.mjs +0 -38
- package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +0 -17
- package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs +0 -12
- package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs +0 -9
- package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs +0 -5
- package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +0 -6
- package/dist/esm/devtool/LazyDevTool.mjs +0 -15
- package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +0 -17
- package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +0 -27
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +0 -9
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs +0 -9
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs +0 -24
- package/dist/esm/errors/flat/filterFlatFieldErrors.mjs +0 -10
- package/dist/esm/errors/flat/flattenFieldErrors.mjs +0 -5
- package/dist/esm/errors/flat/getFlatFieldErrors.mjs +0 -24
- package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/isFieldErrorRefd.mjs +0 -4
- package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs +0 -5
- package/dist/esm/errors/message/FormErrorMessage.mjs +0 -14
- package/dist/esm/errors/message/RhfUtilsFieldErrorMessage.mjs +0 -14
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +0 -19
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +0 -23
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs +0 -4
- package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs +0 -5
- package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs +0 -5
- package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/orphan/isOrphanFormError.mjs +0 -12
- package/dist/esm/errors/output/consoleErrors.mjs +0 -6
- package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs +0 -10
- package/dist/esm/errors/root/consts.mjs +0 -4
- package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs +0 -5
- package/dist/esm/errors/root/isFormErrorPathRoot.mjs +0 -5
- package/dist/esm/exports.mjs +0 -46
- package/dist/esm/form/Form.mjs +0 -86
- package/dist/esm/form/FormWithProviders.mjs +0 -11
- package/dist/esm/form/RhfUtilsFormProviders.mjs +0 -24
- package/dist/esm/form/_Controller.mjs +0 -8
- package/dist/esm/form/context/group/FormGroupContextProvider.mjs +0 -30
- package/dist/esm/form/context/group/index.mjs +0 -11
- package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +0 -6
- package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +0 -10
- package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +0 -13
- package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +0 -13
- package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +0 -10
- package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs +0 -23
- package/dist/esm/form/context/utils/useRhfUtilsContext.mjs +0 -6
- package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs +0 -9
- package/dist/esm/form/useFormIsBusy.mjs +0 -8
- package/dist/esm/form/useRhfUtilsForm.mjs +0 -43
- package/dist/esm/form/utils/getSubmitterButtonData.mjs +0 -12
- package/dist/esm/form/utils/useFormRequestSubmit.mjs +0 -13
- package/dist/esm/submit/error/FormSubmitError.mjs +0 -8
- package/dist/esm/submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs +0 -12
- package/dist/esm/submit/useFormOnSubmitted.mjs +0 -12
- package/dist/esm/submit/useResetFormOnSubmitted.mjs +0 -36
- package/dist/esm/submit/useSubmitFormOnChange.mjs +0 -26
- package/dist/esm/utils/PassthroughChildren.mjs +0 -7
- package/dist/esm/utils/isEmptyObject.mjs +0 -4
- package/dist/esm/utils/useDebouncedOnChangeValue.mjs +0 -26
- package/dist/esm/utils/useRefIfValueWasTrue.mjs +0 -14
- package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -71
- package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -5
- package/dist/types/client/context.d.ts +0 -3
- package/dist/types/client/index.d.ts +0 -30
- package/dist/types/client/utils.d.ts +0 -13
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -13
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -5
- package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -4
- package/dist/types/client/zod/consts.d.ts +0 -4
- package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -8
- package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -9
- package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -6
- package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -8
- package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -4
- package/dist/types/devtool/LazyDevTool.d.ts +0 -12
- package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -7
- package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -11
- package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -20
- package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -13
- package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
- package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -7
- package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -9
- package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -16
- package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -32
- package/dist/types/errors/flat/types.d.ts +0 -17
- package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
- package/dist/types/errors/isFieldErrorRefd.d.ts +0 -7
- package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -7
- package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
- package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts +0 -13
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -1
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +0 -18
- package/dist/types/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
- package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
- package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
- package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -7
- package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
- package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -4
- package/dist/types/errors/output/consoleErrors.d.ts +0 -7
- package/dist/types/errors/output/types.d.ts +0 -7
- package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
- package/dist/types/errors/root/consts.d.ts +0 -1
- package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
- package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -7
- package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -7
- package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +0 -11
- package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -24
- package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -28
- package/dist/types/exports.d.ts +0 -29
- package/dist/types/form/Form.d.ts +0 -11
- package/dist/types/form/FormWithProviders.d.ts +0 -13
- package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -29
- package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -12
- package/dist/types/form/SafeFieldValues.d.ts +0 -4
- package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -20
- package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -27
- package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -23
- package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -20
- package/dist/types/form/_Controller.d.ts +0 -6
- package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
- package/dist/types/form/context/group/index.d.ts +0 -14
- package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
- package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
- package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
- 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/group/useFormOrParentIsBusy.d.ts +0 -2
- package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
- package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -14
- package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
- package/dist/types/form/useFormIsBusy.d.ts +0 -2
- package/dist/types/form/useRhfUtilsForm.d.ts +0 -16
- package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -8
- package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -11
- package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -26
- package/dist/types/register.d.ts +0 -7
- package/dist/types/submit/error/FormSubmitError.d.ts +0 -7
- package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -15
- package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -10
- package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -15
- package/dist/types/submit/useFormOnSubmitted.d.ts +0 -6
- package/dist/types/submit/useResetFormOnSubmitted.d.ts +0 -36
- package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -9
- package/dist/types/utils/PassthroughChildren.d.ts +0 -7
- package/dist/types/utils/createContext.d.ts +0 -12
- package/dist/types/utils/fixedForwardRef.d.ts +0 -7
- package/dist/types/utils/isEmptyObject.d.ts +0 -2
- package/dist/types/utils/timeoutAsync.d.ts +0 -6
- package/dist/types/utils/types.d.ts +0 -1
- package/dist/types/utils/useDebouncedOnChangeValue.d.ts +0 -14
- package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
- package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
- package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
- package/dist/types/utils/useToggle.d.ts +0 -4
package/dist/esm/exports.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { default as e } from "./client/zod/context/RhfUtilsClientForZodContextProvider.mjs";
|
|
2
|
-
import { default as s } from "./client/zod/context/RhfUtilsZodForm.mjs";
|
|
3
|
-
import { default as u } from "./client/zod/context/useRhfUtilsZodForm.mjs";
|
|
4
|
-
import { default as m } from "./errors/flat/context/useFlatFieldErrorsContext.mjs";
|
|
5
|
-
import { default as d } from "./errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs";
|
|
6
|
-
import { default as x } from "./errors/message/RhfUtilsFieldErrorMessage.mjs";
|
|
7
|
-
import { default as F } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
8
|
-
import { default as C } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
|
|
9
|
-
import { default as R } from "./form/context/utils/useRhfUtilsContext.mjs";
|
|
10
|
-
import { default as E } from "./form/context/utils/useRhfUtilsContextRequestSubmit.mjs";
|
|
11
|
-
import { default as I } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
12
|
-
import { default as b } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
13
|
-
import { default as B } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
14
|
-
import { default as S } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
15
|
-
import { default as T } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
16
|
-
import { default as M } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
17
|
-
import { default as Z } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
18
|
-
import { default as v } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
19
|
-
import { default as D } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
20
|
-
import { default as L } from "./form/utils/getSubmitterButtonData.mjs";
|
|
21
|
-
import { default as j } from "./form/utils/useFormRequestSubmit.mjs";
|
|
22
|
-
import { FormSubmitError as z } from "./submit/error/FormSubmitError.mjs";
|
|
23
|
-
export {
|
|
24
|
-
I as FormGroupContextProvider,
|
|
25
|
-
F as FormNonFieldErrorMarker,
|
|
26
|
-
z as FormSubmitError,
|
|
27
|
-
e as RhfUtilsClientForZodContextProvider,
|
|
28
|
-
x as RhfUtilsFieldErrorMessage,
|
|
29
|
-
s as RhfUtilsZodForm,
|
|
30
|
-
C as RootErrorsListFromFlatFieldErrorsContext,
|
|
31
|
-
L as getSubmitterButtonData,
|
|
32
|
-
m as useFlatFieldErrorsContext,
|
|
33
|
-
d as useFlatFieldErrorsContextHasOnlyOrphans,
|
|
34
|
-
b as useFormGroupChildIsMountedTracker,
|
|
35
|
-
B as useFormGroupChildIsSubmittingTracker,
|
|
36
|
-
S as useFormGroupChildTracker,
|
|
37
|
-
T as useFormGroupIsAnyBusy,
|
|
38
|
-
M as useFormGroupIsChildBusy,
|
|
39
|
-
Z as useFormGroupIsParentBusy,
|
|
40
|
-
v as useFormGroupParentTracker,
|
|
41
|
-
D as useFormOrParentIsBusy,
|
|
42
|
-
j as useFormRequestSubmit,
|
|
43
|
-
R as useRhfUtilsContext,
|
|
44
|
-
E as useRhfUtilsContextRequestSubmit,
|
|
45
|
-
u as useRhfUtilsZodForm
|
|
46
|
-
};
|
package/dist/esm/form/Form.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { jsx as s, jsxs as j } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import { useFormContext as W } from "react-hook-form";
|
|
4
|
-
import w from "../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
5
|
-
import E from "../devtool/LazyDevTool.mjs";
|
|
6
|
-
import { FormSubmitError as c } from "../submit/error/FormSubmitError.mjs";
|
|
7
|
-
import S from "../submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs";
|
|
8
|
-
import U from "../utils/PassthroughChildren.mjs";
|
|
9
|
-
import _ from "./_Controller.mjs";
|
|
10
|
-
function G({
|
|
11
|
-
formId: m,
|
|
12
|
-
formRef: p,
|
|
13
|
-
//
|
|
14
|
-
onSubmit: a,
|
|
15
|
-
onSubmitError: d,
|
|
16
|
-
onSubmitInvalid: l,
|
|
17
|
-
Children: x,
|
|
18
|
-
//
|
|
19
|
-
form: F,
|
|
20
|
-
utils: r
|
|
21
|
-
}) {
|
|
22
|
-
const e = W(), t = w(), y = async (o) => {
|
|
23
|
-
r != null && r.stopSubmitPropagation && o.stopPropagation();
|
|
24
|
-
try {
|
|
25
|
-
await e.handleSubmit(f, l)(o);
|
|
26
|
-
} catch (n) {
|
|
27
|
-
P(n, o);
|
|
28
|
-
}
|
|
29
|
-
}, f = (o, n) => a == null ? void 0 : a(
|
|
30
|
-
o,
|
|
31
|
-
{
|
|
32
|
-
formId: m,
|
|
33
|
-
formRef: p,
|
|
34
|
-
context: e,
|
|
35
|
-
utils: r,
|
|
36
|
-
FormSubmitError: c
|
|
37
|
-
},
|
|
38
|
-
n
|
|
39
|
-
), P = (o, n) => {
|
|
40
|
-
var i;
|
|
41
|
-
const C = o instanceof c ? (
|
|
42
|
-
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
43
|
-
o.errors
|
|
44
|
-
) : (
|
|
45
|
-
// if error is not FormSubmitError, consumer can provide global handler
|
|
46
|
-
(i = t == null ? void 0 : t.onSubmitErrorUnknown) == null ? void 0 : i.call(t, o)
|
|
47
|
-
);
|
|
48
|
-
C && S(e, C), d == null || d(
|
|
49
|
-
o,
|
|
50
|
-
{
|
|
51
|
-
formId: m,
|
|
52
|
-
formRef: p,
|
|
53
|
-
context: e,
|
|
54
|
-
utils: r
|
|
55
|
-
},
|
|
56
|
-
n
|
|
57
|
-
);
|
|
58
|
-
}, h = {
|
|
59
|
-
formId: m,
|
|
60
|
-
formRef: p,
|
|
61
|
-
context: e,
|
|
62
|
-
utils: r,
|
|
63
|
-
Controller: _,
|
|
64
|
-
FormSubmitError: c
|
|
65
|
-
}, b = h, v = (t == null ? void 0 : t.FormComponent) ?? "form", T = (t == null ? void 0 : t.FormChildrenWrapper) ?? U;
|
|
66
|
-
return /* @__PURE__ */ s(
|
|
67
|
-
v,
|
|
68
|
-
{
|
|
69
|
-
...F,
|
|
70
|
-
ref: p,
|
|
71
|
-
onSubmit: (o) => void y(o),
|
|
72
|
-
children: /* @__PURE__ */ j(T, { ...b, children: [
|
|
73
|
-
(r == null ? void 0 : r.devTool) && /* @__PURE__ */ s(
|
|
74
|
-
E,
|
|
75
|
-
{
|
|
76
|
-
props: typeof r.devTool == "object" ? r.devTool : void 0
|
|
77
|
-
}
|
|
78
|
-
),
|
|
79
|
-
/* @__PURE__ */ s(x, { ...h })
|
|
80
|
-
] })
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
export {
|
|
85
|
-
G as default
|
|
86
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import i from "./Form.mjs";
|
|
3
|
-
import t from "./RhfUtilsFormProviders.mjs";
|
|
4
|
-
import f from "./useRhfUtilsForm.mjs";
|
|
5
|
-
function n(m) {
|
|
6
|
-
const r = f(m);
|
|
7
|
-
return /* @__PURE__ */ o(t, { ...r.providerProps, children: /* @__PURE__ */ o(i, { ...r.formProps }) });
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
n as default
|
|
11
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { FormProvider as d } from "react-hook-form";
|
|
3
|
-
import n from "../errors/flat/context/FlatFieldErrorsContextProvider.mjs";
|
|
4
|
-
import l from "./context/utils/RhfUtilsContextProvider.mjs";
|
|
5
|
-
function v({
|
|
6
|
-
formId: t,
|
|
7
|
-
formRef: o,
|
|
8
|
-
rhfForm: i,
|
|
9
|
-
utils: e,
|
|
10
|
-
children: m
|
|
11
|
-
}) {
|
|
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
|
-
) }) });
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
v as default
|
|
24
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import s from "react";
|
|
3
|
-
import { _FormGroupContextProvider as m } from "./index.mjs";
|
|
4
|
-
const B = ({ children: o }) => {
|
|
5
|
-
const [t, u] = s.useState([]), n = t.length, a = s.useCallback((e, l) => {
|
|
6
|
-
u(
|
|
7
|
-
(r) => l ? (
|
|
8
|
-
// add to array
|
|
9
|
-
[...r, e]
|
|
10
|
-
) : (
|
|
11
|
-
// remove from array
|
|
12
|
-
r.filter((c) => c !== e)
|
|
13
|
-
)
|
|
14
|
-
);
|
|
15
|
-
}, []), [d, i] = s.useState(!1);
|
|
16
|
-
return /* @__PURE__ */ y(m, { value: {
|
|
17
|
-
children: {
|
|
18
|
-
busyCount: n,
|
|
19
|
-
busyIds: t,
|
|
20
|
-
setBusyId: a
|
|
21
|
-
},
|
|
22
|
-
parent: {
|
|
23
|
-
isBusy: d,
|
|
24
|
-
setIsBusy: i
|
|
25
|
-
}
|
|
26
|
-
}, children: o });
|
|
27
|
-
}, h = B;
|
|
28
|
-
export {
|
|
29
|
-
h as default
|
|
30
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useFormState as o } from "react-hook-form";
|
|
2
|
-
import t from "./useFormGroupChildTracker.mjs";
|
|
3
|
-
import u from "./useFormGroupIsParentBusy.mjs";
|
|
4
|
-
const m = () => {
|
|
5
|
-
const { isSubmitting: r } = o();
|
|
6
|
-
return t(r), u();
|
|
7
|
-
}, n = m;
|
|
8
|
-
export {
|
|
9
|
-
n as default
|
|
10
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import o from "react";
|
|
2
|
-
import { _useFormGroupContext as t } from "./index.mjs";
|
|
3
|
-
const u = (s) => {
|
|
4
|
-
const { setBusyId: e } = t().children, r = o.useId();
|
|
5
|
-
o.useEffect(() => {
|
|
6
|
-
e(r, s);
|
|
7
|
-
}, [s, r, e]), o.useEffect(() => () => {
|
|
8
|
-
e(r, !1);
|
|
9
|
-
}, []);
|
|
10
|
-
}, d = u;
|
|
11
|
-
export {
|
|
12
|
-
d as default
|
|
13
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import s from "react";
|
|
2
|
-
import t from "../../useFormIsBusy.mjs";
|
|
3
|
-
import { _useFormGroupContext as e } from "./index.mjs";
|
|
4
|
-
import u from "./useFormGroupIsChildBusy.mjs";
|
|
5
|
-
const m = () => {
|
|
6
|
-
const r = t(), { setIsBusy: o } = e().parent;
|
|
7
|
-
return s.useEffect(() => {
|
|
8
|
-
o(r);
|
|
9
|
-
}, [o, r]), u();
|
|
10
|
-
}, f = m;
|
|
11
|
-
export {
|
|
12
|
-
f as default
|
|
13
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import t from "../../useFormIsBusy.mjs";
|
|
2
|
-
import { _useFormGroupContextMaybe as e } from "./index.mjs";
|
|
3
|
-
const u = () => {
|
|
4
|
-
var s;
|
|
5
|
-
const r = t(), o = (s = e()) == null ? void 0 : s.parent.isBusy;
|
|
6
|
-
return !!(r || o);
|
|
7
|
-
}, a = u;
|
|
8
|
-
export {
|
|
9
|
-
a as default
|
|
10
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import l from "../../../client/config/useRhfUtilsClientConfigContext.mjs";
|
|
3
|
-
import d from "../../../errors/flat/context/useFlatFieldErrorsContextOutput.mjs";
|
|
4
|
-
import b from "../../../submit/useResetFormOnSubmitted.mjs";
|
|
5
|
-
import C from "../../../submit/useSubmitFormOnChange.mjs";
|
|
6
|
-
import { _RhfUtilsContextProvider as h } from "./useRhfUtilsContext.mjs";
|
|
7
|
-
const v = ({
|
|
8
|
-
formId: u,
|
|
9
|
-
formRef: t,
|
|
10
|
-
options: e,
|
|
11
|
-
children: a
|
|
12
|
-
}) => {
|
|
13
|
-
var m;
|
|
14
|
-
const r = l();
|
|
15
|
-
return d((m = r == null ? void 0 : r.fieldErrors) == null ? void 0 : m.output), C(t, {
|
|
16
|
-
// check for false/undefined
|
|
17
|
-
disabled: ((e == null ? void 0 : e.submitOnChange) ?? !1) === !1,
|
|
18
|
-
debounce: typeof (e == null ? void 0 : e.submitOnChange) == "number" ? e.submitOnChange : void 0
|
|
19
|
-
}), b(e == null ? void 0 : e.resetOnSubmitted), /* @__PURE__ */ f(h, { value: { formId: u, formRef: t, options: e }, children: a });
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
v as default
|
|
23
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import s from "react";
|
|
2
|
-
import { useForm as d } from "react-hook-form";
|
|
3
|
-
import { FormSubmitError as F } from "../submit/error/FormSubmitError.mjs";
|
|
4
|
-
const v = ({
|
|
5
|
-
defaultValues: e,
|
|
6
|
-
onSubmit: f,
|
|
7
|
-
onSubmitError: p,
|
|
8
|
-
onSubmitInvalid: n,
|
|
9
|
-
Children: c,
|
|
10
|
-
rhf: i,
|
|
11
|
-
form: u,
|
|
12
|
-
utils: t
|
|
13
|
-
}) => {
|
|
14
|
-
const r = s.useId(), m = d({
|
|
15
|
-
...i,
|
|
16
|
-
defaultValues: e
|
|
17
|
-
}), o = s.useRef(null);
|
|
18
|
-
return {
|
|
19
|
-
id: r,
|
|
20
|
-
ref: o,
|
|
21
|
-
context: m,
|
|
22
|
-
providerProps: {
|
|
23
|
-
formId: r,
|
|
24
|
-
formRef: o,
|
|
25
|
-
rhfForm: m,
|
|
26
|
-
utils: t
|
|
27
|
-
},
|
|
28
|
-
formProps: {
|
|
29
|
-
Children: c,
|
|
30
|
-
onSubmit: f,
|
|
31
|
-
onSubmitError: p,
|
|
32
|
-
onSubmitInvalid: n,
|
|
33
|
-
formId: r,
|
|
34
|
-
formRef: o,
|
|
35
|
-
form: u,
|
|
36
|
-
utils: t
|
|
37
|
-
},
|
|
38
|
-
FormSubmitError: F
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
v as default
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
const e = (t) => {
|
|
3
|
-
if (t.nativeEvent instanceof SubmitEvent && !(!(t.nativeEvent.submitter instanceof HTMLButtonElement) && // not button
|
|
4
|
-
!(t.nativeEvent.submitter instanceof HTMLInputElement)) && t.nativeEvent.submitter.name)
|
|
5
|
-
return [
|
|
6
|
-
t.nativeEvent.submitter.name,
|
|
7
|
-
t.nativeEvent.submitter.value
|
|
8
|
-
];
|
|
9
|
-
}, i = e;
|
|
10
|
-
export {
|
|
11
|
-
i as default
|
|
12
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import u from "react";
|
|
2
|
-
import { useFormState as o } from "react-hook-form";
|
|
3
|
-
import m from "../utils/useRefIfValueWasTrue.mjs";
|
|
4
|
-
const c = (e, f) => {
|
|
5
|
-
const { isSubmitSuccessful: i, isSubmitting: t } = o(), [r, s] = m(t);
|
|
6
|
-
u.useEffect(() => {
|
|
7
|
-
e && (t || r && (s(), e(i)));
|
|
8
|
-
}, [t]);
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
c as default
|
|
12
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useFormContext as n } from "react-hook-form";
|
|
2
|
-
import i from "./useFormOnSubmitted.mjs";
|
|
3
|
-
const p = (e) => {
|
|
4
|
-
const { getValues: s, reset: o } = n();
|
|
5
|
-
i((m) => {
|
|
6
|
-
var u;
|
|
7
|
-
if (!e) return;
|
|
8
|
-
const t = (u = e[m ? "success" : "error"]) == null ? void 0 : u.values;
|
|
9
|
-
if (!t) return;
|
|
10
|
-
const r = t === "current", c = r ? s() : void 0;
|
|
11
|
-
o(c, {
|
|
12
|
-
// keep submit stuff for tracking relevant state (e.g., `useFormOnSubmitSuccessful`)
|
|
13
|
-
keepIsSubmitSuccessful: !0,
|
|
14
|
-
keepIsSubmitted: !0,
|
|
15
|
-
keepSubmitCount: !0,
|
|
16
|
-
/**
|
|
17
|
-
* This is necessary when setting default values to current values (lest form stop updating).
|
|
18
|
-
*
|
|
19
|
-
* Technically, we are keeping values and resetting default values to same values.
|
|
20
|
-
*
|
|
21
|
-
* Steps to repro:
|
|
22
|
-
* - RhfUtilsClientConfig with resetOnSubmitted set to success values to current
|
|
23
|
-
* - remove `keepValues` prop from reset
|
|
24
|
-
* - create valid form, submit
|
|
25
|
-
* - form values should be unchanged
|
|
26
|
-
* - unexpectedly: can no longer type into input
|
|
27
|
-
*/
|
|
28
|
-
keepValues: r,
|
|
29
|
-
// keep errors in the case of unsuccessful submit
|
|
30
|
-
keepErrors: !0
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
p as default
|
|
36
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import d from "react";
|
|
2
|
-
import b from "../form/utils/useFormRequestSubmit.mjs";
|
|
3
|
-
import { useDebouncedOnChangeValue as h } from "../utils/useDebouncedOnChangeValue.mjs";
|
|
4
|
-
const l = (n, e) => {
|
|
5
|
-
const u = !(e != null && e.disabled), a = b(n), [c] = h({
|
|
6
|
-
// on change value after debounce
|
|
7
|
-
onChange: () => {
|
|
8
|
-
a();
|
|
9
|
-
},
|
|
10
|
-
delay: (e == null ? void 0 : e.debounce) ?? 0
|
|
11
|
-
});
|
|
12
|
-
d.useEffect(() => {
|
|
13
|
-
if (!u) return;
|
|
14
|
-
const r = n.current;
|
|
15
|
-
if (!r) throw new Error();
|
|
16
|
-
const t = (m) => {
|
|
17
|
-
c(m);
|
|
18
|
-
};
|
|
19
|
-
return r.addEventListener("change", t), () => {
|
|
20
|
-
r.removeEventListener("change", t);
|
|
21
|
-
};
|
|
22
|
-
}, []);
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
l as default
|
|
26
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import r from "react";
|
|
2
|
-
const a = ({
|
|
3
|
-
onChange: u,
|
|
4
|
-
delay: n
|
|
5
|
-
}) => {
|
|
6
|
-
const e = r.useRef(), c = () => {
|
|
7
|
-
e.current && (u(e.current.value), e.current = void 0);
|
|
8
|
-
}, t = () => {
|
|
9
|
-
e.current && clearTimeout(e.current.timer);
|
|
10
|
-
};
|
|
11
|
-
return r.useEffect(
|
|
12
|
-
// return timeout clearer
|
|
13
|
-
() => t,
|
|
14
|
-
[]
|
|
15
|
-
), [(o) => {
|
|
16
|
-
t(), e.current = {
|
|
17
|
-
// value being tracked
|
|
18
|
-
value: o,
|
|
19
|
-
// new timer
|
|
20
|
-
timer: setTimeout(c, n)
|
|
21
|
-
};
|
|
22
|
-
}];
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
a as useDebouncedOnChangeValue
|
|
26
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { UseFormProps } from 'react-hook-form';
|
|
2
|
-
import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
|
|
3
|
-
import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
|
|
4
|
-
import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
|
|
5
|
-
import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Client configuration object.
|
|
9
|
-
*
|
|
10
|
-
* Options under `defaults` can be overridden at form level.
|
|
11
|
-
*/
|
|
12
|
-
export type RhfUtilsClientConfig = {
|
|
13
|
-
/**
|
|
14
|
-
* Default options for all forms. (Are overridden by form-specific options.)
|
|
15
|
-
*/
|
|
16
|
-
defaults?: {
|
|
17
|
-
/**
|
|
18
|
-
* Default RHF `useForm` settings.
|
|
19
|
-
*
|
|
20
|
-
* (Exposes only non-local props.)
|
|
21
|
-
*/
|
|
22
|
-
rhf?: Pick<UseFormProps, 'mode' | 'reValidateMode' | 'resetOptions' | 'context' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'progressive' | 'criteriaMode' | 'delayError'>;
|
|
23
|
-
/**
|
|
24
|
-
* Global settings and defaults.
|
|
25
|
-
*
|
|
26
|
-
* (Extend this type via `Register` type to inject custom options/functionality via `Children` component.)
|
|
27
|
-
*/
|
|
28
|
-
utils?: RhfUtilsFormOptions;
|
|
29
|
-
/**
|
|
30
|
-
* Default props for form element.
|
|
31
|
-
*/
|
|
32
|
-
form?: Omit<React.PropsWithoutRef<JSX.IntrinsicElements['form']>, 'onSubmit'>;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Supply your own `<form>` component.
|
|
36
|
-
*
|
|
37
|
-
* By default, a primitive `<form>` element is used.
|
|
38
|
-
*/
|
|
39
|
-
FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
|
|
40
|
-
/**
|
|
41
|
-
* Wrap all form bodies with your own hooks, components, etc.
|
|
42
|
-
*
|
|
43
|
-
* (NOTE: not schema-typed as not possible at this level)
|
|
44
|
-
*
|
|
45
|
-
* Use cases:
|
|
46
|
-
* - custom hooks/behaviors based on `options`
|
|
47
|
-
* - shared header, footer
|
|
48
|
-
*/
|
|
49
|
-
FormChildrenWrapper?: (props: RhfUtilsFormChildrenWrapperProps) => React.ReactNode;
|
|
50
|
-
/**
|
|
51
|
-
* Global submit error handler when/if submit handler throws an error other than {@link FormSubmitError}.
|
|
52
|
-
*
|
|
53
|
-
* Example use case:
|
|
54
|
-
* - transform API errors to {@link FormSubmitFieldErrors}.
|
|
55
|
-
*
|
|
56
|
-
* @returns
|
|
57
|
-
* - if {@link FormSubmitFieldErrors}: merge into context errors.
|
|
58
|
-
* - if `undefined`: do nothing.
|
|
59
|
-
*/
|
|
60
|
-
onSubmitErrorUnknown?: (error: unknown) => FormSubmitFieldErrors | undefined;
|
|
61
|
-
fieldErrors?: {
|
|
62
|
-
/**
|
|
63
|
-
* Configure how/if errors should be outputted.
|
|
64
|
-
*/
|
|
65
|
-
output?: FlatFieldErrorsOutputConfig;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Non-schema-typed version of `UseRhfUtilsFormChildrenProps` for global config.
|
|
70
|
-
*/
|
|
71
|
-
export type RhfUtilsFormChildrenWrapperProps = React.PropsWithChildren<UseRhfUtilsFormChildrenProps>;
|