@paragrav/rhf-utils 0.0.83 → 0.0.85
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 +36 -27
- package/dist/esm/exports.mjs +54 -50
- package/dist/esm/form/Form.mjs +81 -0
- package/dist/esm/form/FormWithProviders.mjs +2 -2
- package/dist/esm/form/useForm.mjs +33 -18
- package/dist/types/client/config.d.ts +2 -2
- package/dist/types/client/index.d.ts +5 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/form/Form.d.ts +11 -0
- package/dist/types/form/FormProviders.d.ts +12 -0
- package/dist/types/form/_Form.d.ts +3 -3
- package/dist/types/form/useForm.d.ts +31 -15
- package/package.json +7 -259
- package/dist/esm/form/_Form.mjs +0 -83
- /package/dist/esm/form/{_FormProviders.mjs → FormProviders.mjs} +0 -0
|
@@ -1,51 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import f from "../form/FormWithProviders.mjs";
|
|
3
|
+
import l from "../form/useForm.mjs";
|
|
4
|
+
const p = (s) => (r) => {
|
|
5
|
+
const n = a(
|
|
6
|
+
s,
|
|
7
7
|
r
|
|
8
8
|
);
|
|
9
9
|
return {
|
|
10
|
-
useForm: (o,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
useForm: (o, t, e, i, u) => {
|
|
11
|
+
const m = Array.isArray(t) ? t : [t, void 0, void 0];
|
|
12
|
+
return l(
|
|
13
|
+
n(o, {
|
|
14
|
+
onSubmit: m[0],
|
|
15
|
+
onSubmitError: m[1],
|
|
16
|
+
onSubmitInvalid: m[2],
|
|
17
|
+
defaultValues: e,
|
|
18
|
+
Fields: i,
|
|
19
|
+
...u
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
FormWithProviders: h(s, r)
|
|
14
24
|
};
|
|
15
|
-
},
|
|
25
|
+
}, h = (s, r) => function({
|
|
16
26
|
schema: o,
|
|
17
|
-
children:
|
|
18
|
-
...
|
|
27
|
+
children: t,
|
|
28
|
+
...e
|
|
19
29
|
}) {
|
|
20
|
-
const i = a(
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
30
|
+
const i = a(s, r);
|
|
31
|
+
return /* @__PURE__ */ d(
|
|
32
|
+
f,
|
|
23
33
|
{
|
|
24
|
-
...i(o,
|
|
25
|
-
children:
|
|
34
|
+
...i(o, e),
|
|
35
|
+
children: t
|
|
26
36
|
}
|
|
27
37
|
);
|
|
28
|
-
}, a = (
|
|
29
|
-
var
|
|
38
|
+
}, a = (s, r) => (n, o) => {
|
|
39
|
+
var t, e, i, u, m;
|
|
30
40
|
return {
|
|
31
41
|
...o,
|
|
32
42
|
config: r,
|
|
33
43
|
rhf: {
|
|
34
|
-
...(
|
|
44
|
+
...(t = r.defaultOptions) == null ? void 0 : t.rhf,
|
|
35
45
|
...o.rhf,
|
|
36
|
-
resolver:
|
|
46
|
+
resolver: s(n)
|
|
37
47
|
},
|
|
38
|
-
form: o.form,
|
|
39
48
|
options: {
|
|
40
|
-
...(
|
|
49
|
+
...(e = r.defaultOptions) == null ? void 0 : e.form,
|
|
41
50
|
...o.options,
|
|
42
51
|
classNames: [
|
|
43
|
-
...((
|
|
44
|
-
...((
|
|
52
|
+
...((u = (i = r.defaultOptions) == null ? void 0 : i.form) == null ? void 0 : u.classNames) ?? [],
|
|
53
|
+
...((m = o.options) == null ? void 0 : m.classNames) ?? []
|
|
45
54
|
]
|
|
46
55
|
}
|
|
47
56
|
};
|
|
48
57
|
};
|
|
49
58
|
export {
|
|
50
|
-
|
|
59
|
+
p as createRhfUtilsClient
|
|
51
60
|
};
|
package/dist/esm/exports.mjs
CHANGED
|
@@ -8,77 +8,81 @@ import { default as i } from "./errors/flat/FlatFieldErrorsList.mjs";
|
|
|
8
8
|
import { default as E } from "./errors/message/FormErrorMessage.mjs";
|
|
9
9
|
import { default as h } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
10
10
|
import { default as S } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
11
|
+
import { default as P } from "./errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
12
|
+
import { default as M } from "./errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.mjs";
|
|
13
13
|
import { default as R } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
14
|
+
import { default as v } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
15
|
+
import { default as T } from "./errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs";
|
|
16
|
+
import { default as k } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
17
17
|
import { default as A } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
18
18
|
import { default as D } from "./errors/useFormErrorsEffect.mjs";
|
|
19
19
|
import { default as Z } from "./errors/useFormErrorsIfAny.mjs";
|
|
20
20
|
import { default as N } from "./errors/useFormErrorsTransformMemo.mjs";
|
|
21
21
|
import { default as z } from "./errors/useFormRequestSubmit.mjs";
|
|
22
|
-
import { default as j } from "./form/
|
|
23
|
-
import { default as J } from "./form/
|
|
24
|
-
import { default as Q } from "./form/
|
|
25
|
-
import { default as X } from "./form/
|
|
26
|
-
import { default as _ } from "./form/context/
|
|
27
|
-
import { default as rr } from "./form/context/
|
|
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 mr } from "./form/context/group/
|
|
32
|
-
import { default as dr } from "./form/context/group/
|
|
33
|
-
import { default as xr } from "./form/context/group/
|
|
34
|
-
import { default as ir } from "./form/context/group/
|
|
35
|
-
import { default as Er } from "./form/
|
|
36
|
-
import {
|
|
37
|
-
import { default as Sr } from "./
|
|
38
|
-
import {
|
|
39
|
-
import { default as
|
|
40
|
-
import { default as Rr } from "./submit/
|
|
41
|
-
import { default as
|
|
22
|
+
import { default as j } from "./form/Form.mjs";
|
|
23
|
+
import { default as J } from "./form/FormProviders.mjs";
|
|
24
|
+
import { default as Q } from "./form/FormWithProviders.mjs";
|
|
25
|
+
import { default as X } from "./form/useForm.mjs";
|
|
26
|
+
import { default as _ } from "./form/context/utils/FormUtilsContextProvider.mjs";
|
|
27
|
+
import { default as rr } from "./form/context/utils/useFormUtilsContext.mjs";
|
|
28
|
+
import { default as er } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
29
|
+
import { default as sr } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
30
|
+
import { default as ur } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
31
|
+
import { default as mr } from "./form/context/group/useFormGroupChildTracker.mjs";
|
|
32
|
+
import { default as dr } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
33
|
+
import { default as xr } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
34
|
+
import { default as ir } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
35
|
+
import { default as Er } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
36
|
+
import { default as hr } from "./form/context/group/useFormOrParentIsBusy.mjs";
|
|
37
|
+
import { default as Sr } from "./form/utils/getSubmitterButtonData.mjs";
|
|
38
|
+
import { FormSubmitError as Pr } from "./submit/error/FormSubmitError.mjs";
|
|
39
|
+
import { default as Mr } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
40
|
+
import { default as Rr } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
41
|
+
import { default as vr } from "./submit/useResetFormOnSubmitError.mjs";
|
|
42
|
+
import { default as Tr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
43
|
+
import { default as kr } from "./submit/useSubmitFormOnChange.mjs";
|
|
42
44
|
export {
|
|
43
45
|
d as FlatFieldErrorsContextProvider,
|
|
44
46
|
i as FlatFieldErrorsList,
|
|
47
|
+
j as Form,
|
|
45
48
|
E as FormErrorMessage,
|
|
46
49
|
h as FormErrorMessageByPath,
|
|
47
|
-
|
|
50
|
+
er as FormGroupContextProvider,
|
|
48
51
|
S as FormNonFieldErrorMarker,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
P as FormNonFieldErrorMarkerHtmlAttribute,
|
|
53
|
+
J as FormProviders,
|
|
54
|
+
Pr as FormSubmitError,
|
|
55
|
+
_ as FormUtilsContextProvider,
|
|
56
|
+
Q as FormWithProviders,
|
|
53
57
|
m as LazyDevTool,
|
|
54
58
|
e as RhfUtilsClientForZodContextProvider,
|
|
55
|
-
|
|
59
|
+
T as RootErrorsListFromFlatFieldErrorsContext,
|
|
56
60
|
u as createRhfUtilsClientForZod,
|
|
57
|
-
|
|
61
|
+
Sr as getSubmitterButtonData,
|
|
58
62
|
x as useFlatFieldErrorsContext,
|
|
59
|
-
|
|
63
|
+
X as useForm,
|
|
60
64
|
A as useFormErrorConsoleDebug,
|
|
61
65
|
D as useFormErrorsEffect,
|
|
62
66
|
Z as useFormErrorsIfAny,
|
|
63
67
|
N as useFormErrorsTransformMemo,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
sr as useFormGroupChildIsMountedTracker,
|
|
69
|
+
ur as useFormGroupChildIsSubmittingTracker,
|
|
70
|
+
mr as useFormGroupChildTracker,
|
|
71
|
+
dr as useFormGroupIsAnyBusy,
|
|
72
|
+
xr as useFormGroupIsChildBusy,
|
|
73
|
+
ir as useFormGroupIsParentBusy,
|
|
74
|
+
Er as useFormGroupParentTracker,
|
|
75
|
+
M as useFormHasOnlyOrphanFieldErrorsMemo,
|
|
76
|
+
Mr as useFormOnSubmitSuccessful,
|
|
77
|
+
Rr as useFormOnSubmitSuccessfulAndReset,
|
|
78
|
+
hr as useFormOrParentIsBusy,
|
|
75
79
|
z as useFormRequestSubmit,
|
|
76
|
-
|
|
80
|
+
rr as useFormUtilsContext,
|
|
77
81
|
R as useOrphanFormErrorsMemo,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
v as useOrphanFormErrorsToConsole,
|
|
83
|
+
Tr as useResetFormAfterSubmitSuccessful,
|
|
84
|
+
vr as useResetFormOnSubmitError,
|
|
81
85
|
s as useRhfUtilsClientForZodContext,
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
k as useRootFormFieldErrorsMemo,
|
|
87
|
+
kr as useSubmitFormOnChange
|
|
84
88
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxs as T, jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useFormContext as _ } from "react-hook-form";
|
|
4
|
+
import v from "../devtool/LazyDevTool.mjs";
|
|
5
|
+
import { FormSubmitError as E } from "../submit/error/FormSubmitError.mjs";
|
|
6
|
+
import V from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
7
|
+
import w from "./_FormBase.mjs";
|
|
8
|
+
function H({
|
|
9
|
+
formId: B,
|
|
10
|
+
formRef: x,
|
|
11
|
+
//
|
|
12
|
+
onSubmit: s,
|
|
13
|
+
onSubmitError: h,
|
|
14
|
+
onSubmitInvalid: F,
|
|
15
|
+
Fields: C,
|
|
16
|
+
//
|
|
17
|
+
form: d,
|
|
18
|
+
options: a,
|
|
19
|
+
config: t,
|
|
20
|
+
//
|
|
21
|
+
children: j
|
|
22
|
+
}) {
|
|
23
|
+
const l = _(), N = async (r) => {
|
|
24
|
+
a != null && a.stopSubmitPropagation && r.stopPropagation();
|
|
25
|
+
try {
|
|
26
|
+
await l.handleSubmit(P, F)(r);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
S(e, r);
|
|
29
|
+
}
|
|
30
|
+
}, P = (r, e) => s == null ? void 0 : s(
|
|
31
|
+
r,
|
|
32
|
+
l,
|
|
33
|
+
e
|
|
34
|
+
), S = (r, e) => {
|
|
35
|
+
var b;
|
|
36
|
+
const m = r instanceof E ? (
|
|
37
|
+
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
38
|
+
r
|
|
39
|
+
) : (
|
|
40
|
+
// if error is not FormSubmitError, consumer can provide global handler
|
|
41
|
+
(b = t == null ? void 0 : t.onSubmitError) == null ? void 0 : b.call(t, r)
|
|
42
|
+
);
|
|
43
|
+
m && V(l, m), h == null || h(
|
|
44
|
+
r,
|
|
45
|
+
l,
|
|
46
|
+
e
|
|
47
|
+
);
|
|
48
|
+
}, c = {
|
|
49
|
+
formId: B,
|
|
50
|
+
formRef: x,
|
|
51
|
+
ctx: l,
|
|
52
|
+
options: a
|
|
53
|
+
}, y = (r) => {
|
|
54
|
+
var m;
|
|
55
|
+
const e = (m = t == null ? void 0 : t.Children) == null ? void 0 : m[r];
|
|
56
|
+
return e && /* @__PURE__ */ u(e, { ...c });
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ T(
|
|
59
|
+
w,
|
|
60
|
+
{
|
|
61
|
+
noValidate: !0,
|
|
62
|
+
style: {
|
|
63
|
+
position: "relative"
|
|
64
|
+
},
|
|
65
|
+
...d,
|
|
66
|
+
className: [a == null ? void 0 : a.classNames, d == null ? void 0 : d.className].filter(Boolean).join(" "),
|
|
67
|
+
onSubmit: N,
|
|
68
|
+
formRef: x,
|
|
69
|
+
children: [
|
|
70
|
+
y("top"),
|
|
71
|
+
(a == null ? void 0 : a.devTool) !== "disabled" && /* @__PURE__ */ u(v, { placement: "top-right", ...a == null ? void 0 : a.devTool }),
|
|
72
|
+
C && /* @__PURE__ */ u(C, { ...c }),
|
|
73
|
+
j,
|
|
74
|
+
y("bottom")
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
H as default
|
|
81
|
+
};
|
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useForm as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import t from "react";
|
|
2
|
+
import { useForm as a } from "react-hook-form";
|
|
3
|
+
import { FormSubmitError as l } from "../submit/error/FormSubmitError.mjs";
|
|
4
|
+
const E = ({
|
|
5
|
+
onSubmit: e,
|
|
6
|
+
onSubmitError: m,
|
|
7
|
+
onSubmitInvalid: f,
|
|
8
|
+
defaultValues: n,
|
|
9
|
+
Fields: p,
|
|
10
|
+
config: u,
|
|
11
|
+
rhf: c,
|
|
12
|
+
form: i,
|
|
13
|
+
options: d
|
|
8
14
|
}) => {
|
|
9
|
-
const
|
|
15
|
+
const r = t.useId(), s = a({
|
|
16
|
+
...c,
|
|
17
|
+
defaultValues: n
|
|
18
|
+
}), o = t.useRef(null);
|
|
10
19
|
return {
|
|
11
|
-
id:
|
|
12
|
-
ref:
|
|
20
|
+
id: r,
|
|
21
|
+
ref: o,
|
|
13
22
|
context: s,
|
|
14
23
|
providerProps: {
|
|
15
|
-
formId:
|
|
16
|
-
formRef:
|
|
24
|
+
formId: r,
|
|
25
|
+
formRef: o,
|
|
17
26
|
rhfForm: s,
|
|
18
|
-
options:
|
|
27
|
+
options: d
|
|
19
28
|
},
|
|
20
29
|
formProps: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
Fields: p,
|
|
31
|
+
onSubmit: e,
|
|
32
|
+
onSubmitError: m,
|
|
33
|
+
onSubmitInvalid: f,
|
|
34
|
+
formId: r,
|
|
35
|
+
formRef: o,
|
|
36
|
+
config: u,
|
|
37
|
+
form: i
|
|
38
|
+
},
|
|
39
|
+
SubmitError: class extends l {
|
|
25
40
|
}
|
|
26
41
|
};
|
|
27
42
|
};
|
|
28
43
|
export {
|
|
29
|
-
|
|
44
|
+
E as default
|
|
30
45
|
};
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { FormChildrenSlots } from '../form/Form';
|
|
5
5
|
import { UseFormProps } from 'react-hook-form';
|
|
6
6
|
|
|
7
7
|
export type ClientConfig = {
|
|
@@ -29,7 +29,7 @@ export type ClientConfig = {
|
|
|
29
29
|
* top: e.g., block navigation on dirty form.
|
|
30
30
|
* bottom: e.g., root errors list.
|
|
31
31
|
*/
|
|
32
|
-
Children?: Partial<Record<
|
|
32
|
+
Children?: Partial<Record<FormChildrenSlots, React.FC<UseFormFieldsProps>>>;
|
|
33
33
|
/**
|
|
34
34
|
* Handle non-{@link FormSubmitError} errors. Optionally, return {@link FormSubmitError} to merge into context errors.
|
|
35
35
|
*/
|
|
@@ -13,7 +13,11 @@ export type ObjectSchema<TInputKey extends string, TOutputKey extends string> =
|
|
|
13
13
|
[key in TOutputKey]: SafeFieldValues;
|
|
14
14
|
};
|
|
15
15
|
export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
|
|
16
|
-
useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]
|
|
16
|
+
useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseFormPropsForm extends UseFormProps<TSchemaInput, TSchemaOutput> = UseFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, handlers: NonNullable<UseFormPropsForm['onSubmit']> | [
|
|
17
|
+
NonNullable<UseFormPropsForm['onSubmit']>,
|
|
18
|
+
UseFormPropsForm['onSubmitError'],
|
|
19
|
+
UseFormPropsForm['onSubmitInvalid']
|
|
20
|
+
], defaultValues: UseFormPropsForm['defaultValues'], Fields: UseFormPropsForm['Fields'], props: UseFormProps<TSchemaInput, TSchemaOutput>) => UseFormReturn<TSchemaInput, TSchemaOutput>;
|
|
17
21
|
FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
|
|
18
22
|
schema: TSchema;
|
|
19
23
|
} & FormWithProvidersProps<TSchemaInput, TSchemaOutput>) => JSX.Element;
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
|
|
|
21
21
|
export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
22
22
|
export { default as useFormErrorsTransformMemo } from './errors/useFormErrorsTransformMemo';
|
|
23
23
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
|
24
|
+
export { default as Form } from './form/Form';
|
|
25
|
+
export { default as FormProviders } from './form/FormProviders';
|
|
24
26
|
export { default as FormWithProviders } from './form/FormWithProviders';
|
|
25
27
|
export type { SafeFieldValues } from './form/SafeFieldValues';
|
|
26
28
|
export type { UseFormFieldsProps } from './form/useForm';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseFormProps } from './useForm';
|
|
2
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
|
|
5
|
+
export type FormChildrenSlots = 'top' | 'bottom';
|
|
6
|
+
export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
7
|
+
formId: string;
|
|
8
|
+
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
+
} & Pick<UseFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Fields' | 'form' | 'options' | 'config'>>;
|
|
10
|
+
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Fields, form, options, config, children, }: FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default _Form;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UseFormOptions } from './useFormOptions';
|
|
2
|
+
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
export type FormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
6
|
+
formId: string;
|
|
7
|
+
formRef: React.RefObject<HTMLFormElement>;
|
|
8
|
+
rhfForm: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
9
|
+
options?: UseFormOptions;
|
|
10
|
+
}>;
|
|
11
|
+
declare function FormProviders<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, rhfForm, options, children, }: FormProvidersProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default FormProviders;
|
|
@@ -3,9 +3,9 @@ import { SafeFieldValues } from './SafeFieldValues';
|
|
|
3
3
|
import { default as React } from 'react';
|
|
4
4
|
|
|
5
5
|
export type _FormSlots = 'top' | 'bottom';
|
|
6
|
-
export type _FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<
|
|
6
|
+
export type _FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
|
|
7
7
|
formId: string;
|
|
8
8
|
formRef: React.RefObject<HTMLFormElement>;
|
|
9
|
-
}
|
|
10
|
-
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, form, options, config, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
} & Pick<UseFormProps<TFieldValues, TTransformedValues>, 'onSubmit' | 'onSubmitError' | 'onSubmitInvalid' | 'Fields' | 'form' | 'options' | 'config'>>;
|
|
10
|
+
declare function _Form<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ formId, formRef, onSubmit, onSubmitError, onSubmitInvalid, Fields, form, options, config, children, }: _FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export default _Form;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UseFormOptions } from './useFormOptions';
|
|
2
2
|
import { SafeFieldValues } from './SafeFieldValues';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormProvidersProps } from './FormProviders';
|
|
4
|
+
import { FormProps } from './Form';
|
|
5
5
|
import { ClientConfig } from '../client/config';
|
|
6
6
|
import { SubmitErrorHandler, UseFormProps as RhfUseFormProps, UseFormReturn as RhfUseFormReturn } from 'react-hook-form';
|
|
7
7
|
import { default as React } from 'react';
|
|
@@ -13,19 +13,18 @@ export type UseFormFieldsProps<TFieldValues extends SafeFieldValues = SafeFieldV
|
|
|
13
13
|
options?: UseFormOptions;
|
|
14
14
|
};
|
|
15
15
|
export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
|
|
16
|
+
onSubmit?: (values: TTransformedValues, context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => unknown | Promise<unknown>;
|
|
17
|
+
/** Submit error handler. (Only for errors not of instance `FormError`, which are handled internally.) */
|
|
18
|
+
onSubmitError?: (error: unknown, context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
|
|
19
|
+
/** Submit handler when form is invalid. */
|
|
20
|
+
onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
|
|
21
|
+
defaultValues?: RhfUseFormProps<TFieldValues>['defaultValues'];
|
|
22
|
+
Fields?: React.FC<UseFormFieldsProps<TFieldValues, TTransformedValues>>;
|
|
16
23
|
config?: ClientConfig;
|
|
17
24
|
/** {@link RhfUseFormProps} props for RHF's {@link useRhfForm}. */
|
|
18
|
-
rhf?: RhfUseFormProps<TFieldValues>;
|
|
25
|
+
rhf?: Omit<RhfUseFormProps<TFieldValues>, 'defaultValues'>;
|
|
19
26
|
/** {@link FormProps} props for Form. */
|
|
20
|
-
form?:
|
|
21
|
-
Fields?: React.FC<UseFormFieldsProps<TFieldValues, TTransformedValues>>;
|
|
22
|
-
onSubmit?: (values: TTransformedValues, context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => unknown | Promise<unknown>;
|
|
23
|
-
/** Submit error handler. (Only for errors not of instance `FormError`, which are handled internally.) */
|
|
24
|
-
onSubmitError?: (error: unknown, context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
|
|
25
|
-
/** Submit handler when form is invalid. */
|
|
26
|
-
onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
|
|
27
|
-
props?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
|
|
28
|
-
};
|
|
27
|
+
form?: React.PropsWithoutRef<JSX.IntrinsicElements['form']>;
|
|
29
28
|
options?: UseFormOptions;
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
@@ -37,12 +36,29 @@ export type UseFormProps<TFieldValues extends SafeFieldValues, TTransformedValue
|
|
|
37
36
|
* see https://caniuse.com/?search=form%20attribute
|
|
38
37
|
* @returns Form provider and form.
|
|
39
38
|
*/
|
|
40
|
-
declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ config, rhf, form, options, }: UseFormProps<TFieldValues, TTransformedValues>) => {
|
|
39
|
+
declare const useForm: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>({ onSubmit, onSubmitError, onSubmitInvalid, defaultValues, Fields, config, rhf, form, options, }: UseFormProps<TFieldValues, TTransformedValues>) => {
|
|
41
40
|
readonly id: string;
|
|
42
41
|
readonly ref: React.RefObject<HTMLFormElement>;
|
|
43
42
|
readonly context: RhfUseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
44
|
-
readonly providerProps:
|
|
45
|
-
readonly formProps:
|
|
43
|
+
readonly providerProps: FormProvidersProps<TFieldValues, TTransformedValues>;
|
|
44
|
+
readonly formProps: FormProps<TFieldValues, TTransformedValues>;
|
|
45
|
+
readonly SubmitError: {
|
|
46
|
+
new (errors: Record<`root.${string}` | import('react-hook-form').Path<TFieldValues>, {
|
|
47
|
+
type?: string | undefined;
|
|
48
|
+
message: string;
|
|
49
|
+
}>, message?: string | undefined): {
|
|
50
|
+
errors: Record<`root.${string}` | import('react-hook-form').Path<TFieldValues>, {
|
|
51
|
+
type?: string | undefined;
|
|
52
|
+
message: string;
|
|
53
|
+
}>;
|
|
54
|
+
name: string;
|
|
55
|
+
message: string;
|
|
56
|
+
stack?: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
59
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
60
|
+
stackTraceLimit: number;
|
|
61
|
+
};
|
|
46
62
|
};
|
|
47
63
|
export default useForm;
|
|
48
64
|
export type UseForm<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = typeof useForm<TFieldValues, TTransformedValues>;
|
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.85",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -11,270 +11,18 @@
|
|
|
11
11
|
"dist/types/*"
|
|
12
12
|
],
|
|
13
13
|
"module": "./dist/esm/exports.mjs",
|
|
14
|
-
"imports": {
|
|
15
|
-
"#is-development": {
|
|
16
|
-
"development": "./src/env-conditions/development.ts",
|
|
17
|
-
"default": "./src/env-conditions/production.ts"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
14
|
"exports": {
|
|
21
15
|
".": {
|
|
22
16
|
"import": {
|
|
23
17
|
"default": "./dist/esm/exports.mjs",
|
|
24
18
|
"types": "./dist/types/exports.d.ts"
|
|
25
19
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
"./client/zod/*": {
|
|
34
|
-
"import": {
|
|
35
|
-
"default": "./dist/esm/client/zod/*",
|
|
36
|
-
"types": "./dist/types/client/zod/*"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"./client/zod/createRhfUtilsClientForZod": {
|
|
40
|
-
"import": {
|
|
41
|
-
"default": "./dist/esm/client/zod/createRhfUtilsClientForZod.mjs",
|
|
42
|
-
"types": "./dist/types/client/zod/createRhfUtilsClientForZod.d.ts"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"./client/zod/useRhfUtilsClientForZodContext": {
|
|
46
|
-
"import": {
|
|
47
|
-
"default": "./dist/esm/client/zod/useRhfUtilsClientForZodContext.mjs",
|
|
48
|
-
"types": "./dist/types/client/zod/useRhfUtilsClientForZodContext.d.ts"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"./client/zod/RhfUtilsClientForZodContextProvider": {
|
|
52
|
-
"import": {
|
|
53
|
-
"default": "./dist/esm/client/zod/RhfUtilsClientForZodContextProvider.mjs",
|
|
54
|
-
"types": "./dist/types/client/zod/RhfUtilsClientForZodContextProvider.d.ts"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"./devtool/LazyDevTool": {
|
|
58
|
-
"import": {
|
|
59
|
-
"default": "./dist/esm/devtool/LazyDevTool.mjs",
|
|
60
|
-
"types": "./dist/types/devtool/LazyDevTool.d.ts"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"./errors/flat/context/FlatFieldErrorsContextProvider": {
|
|
64
|
-
"import": {
|
|
65
|
-
"default": "./dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs",
|
|
66
|
-
"types": "./dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts"
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"./errors/flat/context/useFlatFieldErrorsContext": {
|
|
70
|
-
"import": {
|
|
71
|
-
"default": "./dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs",
|
|
72
|
-
"types": "./dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"./errors/flat/FlatFieldErrorsList": {
|
|
76
|
-
"import": {
|
|
77
|
-
"default": "./dist/esm/errors/flat/FlatFieldErrorsList.mjs",
|
|
78
|
-
"types": "./dist/types/errors/flat/FlatFieldErrorsList.d.ts"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"./errors/FormErrorMessage": {
|
|
82
|
-
"import": {
|
|
83
|
-
"default": "./dist/esm/errors/message/FormErrorMessage.mjs",
|
|
84
|
-
"types": "./dist/types/errors/message/FormErrorMessage.d.ts"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"./errors/FormErrorMessageByPath": {
|
|
88
|
-
"import": {
|
|
89
|
-
"default": "./dist/esm/errors/message/FormErrorMessageByPath.mjs",
|
|
90
|
-
"types": "./dist/types/errors/message/FormErrorMessageByPath.d.ts"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"./errors/useFormErrorConsoleDebug": {
|
|
94
|
-
"import": {
|
|
95
|
-
"default": "./dist/esm/errors/useFormErrorConsoleDebug.mjs",
|
|
96
|
-
"types": "./dist/types/errors/useFormErrorConsoleDebug.d.ts"
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
"./errors/useFormErrorsEffect": {
|
|
100
|
-
"import": {
|
|
101
|
-
"default": "./dist/esm/errors/useFormErrorsEffect.mjs",
|
|
102
|
-
"types": "./dist/types/errors/useFormErrorsEffect.d.ts"
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
"./errors/useFormErrorsIfAny": {
|
|
106
|
-
"import": {
|
|
107
|
-
"default": "./dist/esm/errors/useFormErrorsIfAny.mjs",
|
|
108
|
-
"types": "./dist/types/errors/useFormErrorsIfAny.d.ts"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"./errors/useFormErrorsTransformMemo": {
|
|
112
|
-
"import": {
|
|
113
|
-
"default": "./dist/esm/errors/useFormErrorsTransformMemo.mjs",
|
|
114
|
-
"types": "./dist/types/errors/useFormErrorsTransformMemo.d.ts"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"./errors/useFormRequestSubmit": {
|
|
118
|
-
"import": {
|
|
119
|
-
"default": "./dist/esm/errors/useFormRequestSubmit.mjs",
|
|
120
|
-
"types": "./dist/types/errors/useFormRequestSubmit.d.ts"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"./errors/FormNonFieldErrorMarker": {
|
|
124
|
-
"import": {
|
|
125
|
-
"default": "./dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs",
|
|
126
|
-
"types": "./dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts"
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
"./errors/FormNonFieldErrorMarkerHtmlAttribute": {
|
|
130
|
-
"import": {
|
|
131
|
-
"default": "./dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs",
|
|
132
|
-
"types": "./dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts"
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
"./errors/useFormHasOnlyOrphanFieldErrorsMemo": {
|
|
136
|
-
"import": {
|
|
137
|
-
"default": "./dist/esm/errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.mjs",
|
|
138
|
-
"types": "./dist/types/errors/orphan/useFormHasOnlyOrphanFieldErrorsMemo.d.ts"
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"./errors/useOrphanFormErrorsToConsoleError": {
|
|
142
|
-
"import": {
|
|
143
|
-
"default": "./dist/esm/errors/orphan/useOrphanFormErrorsToConsoleError.mjs",
|
|
144
|
-
"types": "./dist/types/errors/orphan/useOrphanFormErrorsToConsoleError.d.ts"
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
"./errors/useOrphanFormErrors": {
|
|
148
|
-
"import": {
|
|
149
|
-
"default": "./dist/esm/errors/orphan/useOrphanFormErrors.mjs",
|
|
150
|
-
"types": "./dist/types/errors/orphan/useOrphanFormErrors.d.ts"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"./errors/useRootFormFieldErrors": {
|
|
154
|
-
"import": {
|
|
155
|
-
"default": "./dist/esm/errors/root/useRootFormFieldErrors.mjs",
|
|
156
|
-
"types": "./dist/types/errors/root/useRootFormFieldErrors.d.ts"
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
"./errors/RootErrorsListFromFlatFieldErrorsContext": {
|
|
160
|
-
"import": {
|
|
161
|
-
"default": "./dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs",
|
|
162
|
-
"types": "./dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts"
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
"./form/useForm": {
|
|
166
|
-
"import": {
|
|
167
|
-
"default": "./dist/esm/form/useForm.mjs",
|
|
168
|
-
"types": "./dist/types/form/useForm.d.ts"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"./form/context/group/FormGroupContextProvider": {
|
|
172
|
-
"import": {
|
|
173
|
-
"default": "./dist/esm/form/context/group/FormGroupContextProvider.mjs",
|
|
174
|
-
"types": "./dist/types/form/context/group/FormGroupContextProvider.d.ts"
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
"./form/context/group/useFormGroupParentTracker": {
|
|
178
|
-
"import": {
|
|
179
|
-
"default": "./dist/esm/form/context/group/useFormGroupParentTracker.mjs",
|
|
180
|
-
"types": "./dist/types/form/context/group/useFormGroupParentTracker.d.ts"
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
"./form/context/group/useFormOrParentIsBusy": {
|
|
184
|
-
"import": {
|
|
185
|
-
"default": "./dist/esm/form/context/group/useFormOrParentIsBusy.mjs",
|
|
186
|
-
"types": "./dist/types/form/context/group/useFormOrParentIsBusy.d.ts"
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
"./form/context/group/useFormGroupChildIsSubmittingTracker": {
|
|
190
|
-
"import": {
|
|
191
|
-
"default": "./dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs",
|
|
192
|
-
"types": "./dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts"
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
"./form/context/group/useFormGroupChildTracker": {
|
|
196
|
-
"import": {
|
|
197
|
-
"default": "./dist/esm/form/context/group/useFormGroupChildTracker.mjs",
|
|
198
|
-
"types": "./dist/types/form/context/group/useFormGroupChildTracker.d.ts"
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
"./form/context/group/useFormGroupChildIsMountedTracker": {
|
|
202
|
-
"import": {
|
|
203
|
-
"default": "./dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs",
|
|
204
|
-
"types": "./dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts"
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
"./form/context/group/useFormGroupIsAnyBusy": {
|
|
208
|
-
"import": {
|
|
209
|
-
"default": "./dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs",
|
|
210
|
-
"types": "./dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts"
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
"./form/context/group/useFormGroupIsChildBusy": {
|
|
214
|
-
"import": {
|
|
215
|
-
"default": "./dist/esm/form/context/group/useFormGroupIsChildBusy.mjs",
|
|
216
|
-
"types": "./dist/types/form/context/group/useFormGroupIsChildBusy.d.ts"
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
"./form/context/group/useFormGroupIsParentBusy": {
|
|
220
|
-
"import": {
|
|
221
|
-
"default": "./dist/esm/form/context/group/useFormGroupIsParentBusy.mjs",
|
|
222
|
-
"types": "./dist/types/form/context/group/useFormGroupIsParentBusy.d.ts"
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
"./form/context/utils/FormUtilsContextProvider": {
|
|
226
|
-
"import": {
|
|
227
|
-
"default": "./dist/esm/form/context/utils/FormUtilsContextProvider.mjs",
|
|
228
|
-
"types": "./dist/types/form/context/utils/FormUtilsContextProvider.d.ts"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
"./form/context/utils/useFormUtilsContext": {
|
|
232
|
-
"import": {
|
|
233
|
-
"default": "./dist/esm/form/context/utils/useFormUtilsContext.mjs",
|
|
234
|
-
"types": "./dist/types/form/context/utils/useFormUtilsContext.d.ts"
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
"./form/utils/getSubmitterButtonData": {
|
|
238
|
-
"import": {
|
|
239
|
-
"default": "./dist/esm/form/utils/getSubmitterButtonData.mjs",
|
|
240
|
-
"types": "./dist/types/form/utils/getSubmitterButtonData.d.ts"
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
"./submit/useFormOnSubmitSuccessful": {
|
|
244
|
-
"import": {
|
|
245
|
-
"default": "./dist/esm/submit/useFormOnSubmitSuccessful.mjs",
|
|
246
|
-
"types": "./dist/types/submit/useFormOnSubmitSuccessful.d.ts"
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
"./submit/error/FormSubmitError": {
|
|
250
|
-
"import": {
|
|
251
|
-
"default": "./dist/esm/submit/error/FormSubmitError.mjs",
|
|
252
|
-
"types": "./dist/types/submit/error/FormSubmitError.d.ts"
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
"./submit/useFormOnSubmitSuccessfulAndReset": {
|
|
256
|
-
"import": {
|
|
257
|
-
"default": "./dist/esm/submit/useFormOnSubmitSuccessfulAndReset.mjs",
|
|
258
|
-
"types": "./dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts"
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
"./submit/useResetFormOnSubmitError": {
|
|
262
|
-
"import": {
|
|
263
|
-
"default": "./dist/esm/submit/useResetFormOnSubmitError.mjs",
|
|
264
|
-
"types": "./dist/types/submit/useResetFormOnSubmitError.d.ts"
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
"./submit/useResetFormAfterSubmitSuccessful": {
|
|
268
|
-
"import": {
|
|
269
|
-
"default": "./dist/esm/submit/useResetFormAfterSubmitSuccessful.mjs",
|
|
270
|
-
"types": "./dist/types/submit/useResetFormAfterSubmitSuccessful.d.ts"
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
"./submit/useSubmitFormOnChange": {
|
|
274
|
-
"import": {
|
|
275
|
-
"default": "./dist/esm/submit/useSubmitFormOnChange.mjs",
|
|
276
|
-
"types": "./dist/types/submit/useSubmitFormOnChange.d.ts"
|
|
277
|
-
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"imports": {
|
|
23
|
+
"#is-development": {
|
|
24
|
+
"development": "./src/env-conditions/development.ts",
|
|
25
|
+
"default": "./src/env-conditions/production.ts"
|
|
278
26
|
}
|
|
279
27
|
},
|
|
280
28
|
"peerDependencies": {
|
package/dist/esm/form/_Form.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { jsxs as B, jsx as b } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import { useFormContext as j } from "react-hook-form";
|
|
4
|
-
import v from "../devtool/LazyDevTool.mjs";
|
|
5
|
-
import { FormSubmitError as N } from "../submit/error/FormSubmitError.mjs";
|
|
6
|
-
import P from "../submit/error/setCtxErrorsByFormSubmitError.mjs";
|
|
7
|
-
import T from "./_FormBase.mjs";
|
|
8
|
-
function L({
|
|
9
|
-
formId: E,
|
|
10
|
-
formRef: r,
|
|
11
|
-
form: t,
|
|
12
|
-
options: a,
|
|
13
|
-
config: l,
|
|
14
|
-
children: F
|
|
15
|
-
}) {
|
|
16
|
-
var h;
|
|
17
|
-
const s = j(), c = async (e) => {
|
|
18
|
-
a != null && a.stopSubmitPropagation && e.stopPropagation();
|
|
19
|
-
try {
|
|
20
|
-
await s.handleSubmit(
|
|
21
|
-
y,
|
|
22
|
-
t == null ? void 0 : t.onSubmitInvalid
|
|
23
|
-
)(e);
|
|
24
|
-
} catch (u) {
|
|
25
|
-
n(u, e);
|
|
26
|
-
}
|
|
27
|
-
}, y = (e, u) => {
|
|
28
|
-
var d;
|
|
29
|
-
return (d = t == null ? void 0 : t.onSubmit) == null ? void 0 : d.call(
|
|
30
|
-
t,
|
|
31
|
-
e,
|
|
32
|
-
s,
|
|
33
|
-
u
|
|
34
|
-
);
|
|
35
|
-
}, n = (e, u) => {
|
|
36
|
-
var x, C;
|
|
37
|
-
const d = e instanceof N ? (
|
|
38
|
-
// consumer can manually throw FormSubmitError (e.g., manual validation)
|
|
39
|
-
e
|
|
40
|
-
) : (
|
|
41
|
-
// if error is not FormSubmitError, consumer can provide global handler
|
|
42
|
-
(x = l == null ? void 0 : l.onSubmitError) == null ? void 0 : x.call(l, e)
|
|
43
|
-
);
|
|
44
|
-
d && P(s, d), (C = t == null ? void 0 : t.onSubmitError) == null || C.call(
|
|
45
|
-
t,
|
|
46
|
-
e,
|
|
47
|
-
s,
|
|
48
|
-
u
|
|
49
|
-
);
|
|
50
|
-
}, S = {
|
|
51
|
-
formId: E,
|
|
52
|
-
formRef: r,
|
|
53
|
-
ctx: s,
|
|
54
|
-
options: a
|
|
55
|
-
}, i = (e) => {
|
|
56
|
-
var d;
|
|
57
|
-
const u = (d = l == null ? void 0 : l.Children) == null ? void 0 : d[e];
|
|
58
|
-
return u && /* @__PURE__ */ b(u, { ...S });
|
|
59
|
-
};
|
|
60
|
-
return /* @__PURE__ */ B(
|
|
61
|
-
T,
|
|
62
|
-
{
|
|
63
|
-
noValidate: !0,
|
|
64
|
-
style: {
|
|
65
|
-
position: "relative"
|
|
66
|
-
},
|
|
67
|
-
...t == null ? void 0 : t.props,
|
|
68
|
-
className: [a == null ? void 0 : a.classNames, (h = t == null ? void 0 : t.props) == null ? void 0 : h.className].filter(Boolean).join(" "),
|
|
69
|
-
onSubmit: c,
|
|
70
|
-
formRef: r,
|
|
71
|
-
children: [
|
|
72
|
-
i("top"),
|
|
73
|
-
(a == null ? void 0 : a.devTool) !== "disabled" && /* @__PURE__ */ b(v, { placement: "top-right", ...a == null ? void 0 : a.devTool }),
|
|
74
|
-
(t == null ? void 0 : t.Fields) && /* @__PURE__ */ b(t.Fields, { ...S }),
|
|
75
|
-
F,
|
|
76
|
-
i("bottom")
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
export {
|
|
82
|
-
L as default
|
|
83
|
-
};
|
|
File without changes
|