@paragrav/rhf-utils 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +12 -0
- package/dist/esm/main.mjs +22 -22
- package/dist/types/form/FormWithProvider.d.ts +13 -0
- package/dist/types/form/context/FormProvider.d.ts +2 -2
- package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +7 -0
- package/dist/types/form/useForm.d.ts +5 -2
- package/dist/types/main.d.ts +1 -1
- package/package.json +4 -4
- package/dist/esm/form/context/group/useAsFormGroupParent.mjs +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import s from "react";
|
|
2
|
+
import t from "../../useFormIsBusy.mjs";
|
|
3
|
+
import { _useFormGroupContext as e } from "./index.mjs";
|
|
4
|
+
const u = () => {
|
|
5
|
+
const r = t(), { setIsBusy: o } = e().parent;
|
|
6
|
+
s.useEffect(() => {
|
|
7
|
+
o(r);
|
|
8
|
+
}, [o, r]);
|
|
9
|
+
}, n = u;
|
|
10
|
+
export {
|
|
11
|
+
n as default
|
|
12
|
+
};
|
package/dist/esm/main.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as e } from "./devtool/LazyDevTool.mjs";
|
|
2
2
|
import { default as s } from "./errors/context/index.mjs";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as u } from "./errors/context/provider.mjs";
|
|
4
4
|
import { default as f } from "./errors/message/FormErrorMessage.mjs";
|
|
5
5
|
import { default as d } from "./errors/message/FormErrorMessageByPath.mjs";
|
|
6
6
|
import { default as F } from "./errors/nonfield/FormNonFieldErrorMarker.mjs";
|
|
@@ -9,18 +9,18 @@ import { default as E } from "./errors/orphan/useFormHasOrphanAndNoFieldErrors.m
|
|
|
9
9
|
import { default as S } from "./errors/orphan/useOrphanFormErrorsMemo.mjs";
|
|
10
10
|
import { default as C } from "./errors/orphan/useOrphanFormErrorsToConsole.mjs";
|
|
11
11
|
import { default as h } from "./errors/root/useRootFormFieldErrorsMemo.mjs";
|
|
12
|
-
import { default as
|
|
12
|
+
import { default as G } from "./errors/useFormErrorConsoleDebug.mjs";
|
|
13
13
|
import { default as I } from "./errors/useFormErrorsEffect.mjs";
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
14
|
+
import { default as k } from "./errors/useFormErrorsIfAny.mjs";
|
|
15
|
+
import { default as O } from "./errors/useFormErrorsMemo.mjs";
|
|
16
|
+
import { default as T } from "./errors/useFormRequestSubmit.mjs";
|
|
17
17
|
import { default as v } from "./form/context/group/FormGroupContextProvider.mjs";
|
|
18
|
-
import { default as N } from "./form/context/group/
|
|
19
|
-
import { default as q } from "./form/context/group/
|
|
20
|
-
import { default as L } from "./form/context/group/
|
|
21
|
-
import { default as w } from "./form/context/group/
|
|
22
|
-
import { default as K } from "./form/context/group/
|
|
23
|
-
import { default as U } from "./form/context/group/
|
|
18
|
+
import { default as N } from "./form/context/group/useFormGroupChildIsMountedTracker.mjs";
|
|
19
|
+
import { default as q } from "./form/context/group/useFormGroupChildIsSubmittingTracker.mjs";
|
|
20
|
+
import { default as L } from "./form/context/group/useFormGroupIsAnyBusy.mjs";
|
|
21
|
+
import { default as w } from "./form/context/group/useFormGroupIsChildBusy.mjs";
|
|
22
|
+
import { default as K } from "./form/context/group/useFormGroupIsParentBusy.mjs";
|
|
23
|
+
import { default as U } from "./form/context/group/useFormGroupParentTracker.mjs";
|
|
24
24
|
import { default as W } from "./form/utils/getSubmitterButtonData.mjs";
|
|
25
25
|
import { default as Y } from "./submit/useFormOnSubmitSuccessful.mjs";
|
|
26
26
|
import { default as _ } from "./submit/useFormOnSubmitSuccessfulAndReset.mjs";
|
|
@@ -28,27 +28,27 @@ import { default as rr } from "./submit/useResetFormOnSubmitSuccessful.mjs";
|
|
|
28
28
|
export {
|
|
29
29
|
f as FormErrorMessage,
|
|
30
30
|
d as FormErrorMessageByPath,
|
|
31
|
-
|
|
31
|
+
u as FormErrorsFlatContextProvider,
|
|
32
32
|
v as FormGroupContextProvider,
|
|
33
33
|
F as FormNonFieldErrorMarker,
|
|
34
34
|
n as FormNonFieldErrorMarkerHtmlAttribute,
|
|
35
35
|
e as LazyDevTool,
|
|
36
36
|
W as getSubmitterButtonData,
|
|
37
|
-
|
|
38
|
-
A as useFormErrorConsoleDebug,
|
|
37
|
+
G as useFormErrorConsoleDebug,
|
|
39
38
|
I as useFormErrorsEffect,
|
|
40
39
|
s as useFormErrorsFlatContext,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
k as useFormErrorsIfAny,
|
|
41
|
+
O as useFormErrorsMemo,
|
|
42
|
+
N as useFormGroupChildIsMountedTracker,
|
|
43
|
+
q as useFormGroupChildIsSubmittingTracker,
|
|
44
|
+
L as useFormGroupIsAnyBusy,
|
|
45
|
+
w as useFormGroupIsChildBusy,
|
|
46
|
+
K as useFormGroupIsParentBusy,
|
|
47
|
+
U as useFormGroupParentTracker,
|
|
48
48
|
E as useFormHasOrphanAndNoFieldErrors,
|
|
49
49
|
Y as useFormOnSubmitSuccessful,
|
|
50
50
|
_ as useFormOnSubmitSuccessfulAndReset,
|
|
51
|
-
|
|
51
|
+
T as useFormRequestSubmit,
|
|
52
52
|
S as useOrphanFormErrorsMemo,
|
|
53
53
|
C as useOrphanFormErrorsToConsole,
|
|
54
54
|
rr as useResetFormAfterSubmitSuccessful,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseFormProps } from './useForm';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
export type FormWithProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<UseFormProps<TFieldValues, TTransformedValues>>;
|
|
5
|
+
/**
|
|
6
|
+
* {@link FormProvider} (and utils) with immediate descendent {@link Form}.
|
|
7
|
+
* (Syntactic sugar for {@link useForm}. Use this for most applications.)
|
|
8
|
+
*
|
|
9
|
+
* Use {@link useForm} if you need to specific nesting hierarchy.
|
|
10
|
+
* (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)
|
|
11
|
+
*/
|
|
12
|
+
declare function FormWithProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ rhf, form, children }: FormWithProvider<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default FormWithProvider;
|
|
@@ -4,10 +4,10 @@ import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
|
4
4
|
|
|
5
5
|
type Props<TFieldValues extends FieldValues, // input values
|
|
6
6
|
TTransformedValues extends FieldValues> = React.PropsWithChildren<{
|
|
7
|
-
|
|
7
|
+
rhf: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
8
8
|
} & {
|
|
9
9
|
form: FormProps<TFieldValues, TTransformedValues>;
|
|
10
10
|
utils?: FormUtilsContextProviderProps;
|
|
11
11
|
}>;
|
|
12
|
-
declare function FormProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({
|
|
12
|
+
declare function FormProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ rhf, form, utils, children }: Props<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default FormProvider;
|
|
@@ -4,8 +4,11 @@ import { FieldValues, UseFormProps as RhfUseFormProps } from 'react-hook-form';
|
|
|
4
4
|
import { default as React } from 'react';
|
|
5
5
|
|
|
6
6
|
export type UseFormProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = {
|
|
7
|
+
/** {@link RhfUseFormProps} props for RHF's {@link useRhfForm}. */
|
|
7
8
|
rhf: RhfUseFormProps<TFieldValues>;
|
|
8
|
-
|
|
9
|
+
/** {@link FormProps} props for Form. */
|
|
10
|
+
form: FormProps<TFieldValues, TTransformedValues>;
|
|
11
|
+
/** {@link FormUtilsContextProviderProps} props for `FormUtilsContextProvider`. */
|
|
9
12
|
utils?: FormUtilsContextProviderProps;
|
|
10
13
|
};
|
|
11
14
|
export type UseFormReturn = ReturnType<typeof useForm>;
|
|
@@ -18,7 +21,7 @@ export type UseFormReturn = ReturnType<typeof useForm>;
|
|
|
18
21
|
* see https://caniuse.com/?search=form%20attribute
|
|
19
22
|
* @returns Form provider and form.
|
|
20
23
|
*/
|
|
21
|
-
export declare const useForm: <TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ rhf,
|
|
24
|
+
export declare const useForm: <TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ rhf, form, utils, }: UseFormProps<TFieldValues, TTransformedValues>) => {
|
|
22
25
|
Provider: React.FC<{
|
|
23
26
|
children?: React.ReactNode;
|
|
24
27
|
}>;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
|
|
|
15
15
|
export { default as useFormErrorsMemo } from './errors/useFormErrorsMemo';
|
|
16
16
|
export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
|
|
17
17
|
export { default as FormGroupContextProvider } from './form/context/group/FormGroupContextProvider';
|
|
18
|
-
export { default as useAsFormGroupParent } from './form/context/group/useAsFormGroupParent';
|
|
19
18
|
export { default as useFormGroupChildIsMountedTracker } from './form/context/group/useFormGroupChildIsMountedTracker';
|
|
20
19
|
export { default as useFormGroupChildIsSubmittingTracker } from './form/context/group/useFormGroupChildIsSubmittingTracker';
|
|
21
20
|
export { default as useFormGroupIsAnyBusy } from './form/context/group/useFormGroupIsAnyBusy';
|
|
22
21
|
export { default as useFormGroupIsChildBusy } from './form/context/group/useFormGroupIsChildBusy';
|
|
23
22
|
export { default as useFormGroupIsParentBusy } from './form/context/group/useFormGroupIsParentBusy';
|
|
23
|
+
export { default as useFormGroupParentTracker } from './form/context/group/useFormGroupParentTracker';
|
|
24
24
|
export { default as getSubmitterButtonData } from './form/utils/getSubmitterButtonData';
|
|
25
25
|
export { default as useFormOnSubmitSuccessful } from './submit/useFormOnSubmitSuccessful';
|
|
26
26
|
export { default as useFormOnSubmitSuccessfulAndReset } from './submit/useFormOnSubmitSuccessfulAndReset';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.37",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"default": "./dist/esm/form/context/group/FormGroupContextProvider.mjs",
|
|
76
76
|
"types": "./dist/types/form/context/group/FormGroupContextProvider.d.ts"
|
|
77
77
|
},
|
|
78
|
-
"./form/context/group/
|
|
79
|
-
"default": "./dist/esm/form/context/group/
|
|
80
|
-
"types": "./dist/types/form/context/group/
|
|
78
|
+
"./form/context/group/useFormGroupParentTracker": {
|
|
79
|
+
"default": "./dist/esm/form/context/group/useFormGroupParentTracker.mjs",
|
|
80
|
+
"types": "./dist/types/form/context/group/useFormGroupParentTracker.d.ts"
|
|
81
81
|
},
|
|
82
82
|
"./form/context/group/useFormGroupChildIsSubmittingTracker": {
|
|
83
83
|
"default": "./dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import r from "react";
|
|
2
|
-
import t from "../../useFormIsBusy.mjs";
|
|
3
|
-
import { _useFormGroupContext as e } from "./index.mjs";
|
|
4
|
-
const u = () => {
|
|
5
|
-
const o = t(), { setIsBusy: s } = e().parent;
|
|
6
|
-
r.useEffect(() => {
|
|
7
|
-
s(o);
|
|
8
|
-
}, [s, o]);
|
|
9
|
-
}, a = u;
|
|
10
|
-
export {
|
|
11
|
-
a as default
|
|
12
|
-
};
|