react-hook-form 7.43.6 → 7.43.8
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/__tests__/controller.server.test.d.ts +1 -1
- package/dist/__tests__/controller.test.d.ts +1 -1
- package/dist/__tests__/logic/validateField.test.d.ts +1 -1
- package/dist/__tests__/type.test.d.ts +1 -1
- package/dist/__tests__/useController.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/append.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/focus.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/insert.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/move.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/prepend.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/remove.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/replace.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/swap.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray/update.test.d.ts +1 -1
- package/dist/__tests__/useFieldArray.test.d.ts +1 -1
- package/dist/__tests__/useForm/clearErrors.test.d.ts +1 -1
- package/dist/__tests__/useForm/formState.test.d.ts +1 -1
- package/dist/__tests__/useForm/getFieldState.test.d.ts +1 -1
- package/dist/__tests__/useForm/getValues.test.d.ts +1 -1
- package/dist/__tests__/useForm/handleSubmit.test.d.ts +1 -1
- package/dist/__tests__/useForm/register.test.d.ts +1 -1
- package/dist/__tests__/useForm/reset.test.d.ts +1 -1
- package/dist/__tests__/useForm/resetField.test.d.ts +1 -1
- package/dist/__tests__/useForm/resolver.test.d.ts +1 -1
- package/dist/__tests__/useForm/setError.test.d.ts +1 -1
- package/dist/__tests__/useForm/setValue.test.d.ts +1 -1
- package/dist/__tests__/useForm/trigger.test.d.ts +1 -1
- package/dist/__tests__/useForm/unregister.test.d.ts +1 -1
- package/dist/__tests__/useForm/watch.test.d.ts +1 -1
- package/dist/__tests__/useForm.server.test.d.ts +1 -1
- package/dist/__tests__/useForm.test.d.ts +1 -1
- package/dist/__tests__/useFormContext.server.test.d.ts +1 -1
- package/dist/__tests__/useFormContext.test.d.ts +1 -1
- package/dist/__tests__/useFormState.test.d.ts +1 -1
- package/dist/__tests__/useWatch.test.d.ts +1 -1
- package/dist/__typetest__/__fixtures__/index.d.ts +4 -4
- package/dist/__typetest__/__fixtures__/pathString.d.ts +3 -3
- package/dist/__typetest__/__fixtures__/traversable.d.ts +13 -13
- package/dist/__typetest__/__fixtures__/tuple.d.ts +14 -14
- package/dist/__typetest__/__fixtures__/type.d.ts +11 -11
- package/dist/__typetest__/errors.test-d.d.ts +1 -1
- package/dist/__typetest__/form.test-d.d.ts +1 -1
- package/dist/__typetest__/path/common.test-d.d.ts +1 -1
- package/dist/__typetest__/path/eager.test-d.d.ts +1 -1
- package/dist/__typetest__/util.test-d.d.ts +1 -1
- package/dist/constants.d.ts +16 -16
- package/dist/controller.d.ts +46 -46
- package/dist/controller.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.esm.mjs +2165 -2174
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/appendErrors.d.ts +3 -3
- package/dist/logic/createFormControl.d.ts +25 -25
- package/dist/logic/focusFieldBy.d.ts +3 -3
- package/dist/logic/generateId.d.ts +2 -2
- package/dist/logic/generateWatchOutput.d.ts +3 -3
- package/dist/logic/getCheckboxValue.d.ts +6 -6
- package/dist/logic/getDirtyFields.d.ts +2 -2
- package/dist/logic/getEventValue.d.ts +2 -2
- package/dist/logic/getFieldValue.d.ts +2 -2
- package/dist/logic/getFieldValueAs.d.ts +3 -3
- package/dist/logic/getFocusFieldName.d.ts +3 -3
- package/dist/logic/getNodeParentName.d.ts +2 -2
- package/dist/logic/getProxyFormState.d.ts +3 -3
- package/dist/logic/getRadioValue.d.ts +6 -6
- package/dist/logic/getResolverOptions.d.ts +13 -13
- package/dist/logic/getRuleValue.d.ts +3 -3
- package/dist/logic/getValidateError.d.ts +2 -2
- package/dist/logic/getValidationModes.d.ts +9 -9
- package/dist/logic/getValueAndMessage.d.ts +6 -6
- package/dist/logic/hasValidation.d.ts +3 -3
- package/dist/logic/index.d.ts +2 -2
- package/dist/logic/isNameInFieldArray.d.ts +3 -3
- package/dist/logic/isWatched.d.ts +3 -3
- package/dist/logic/schemaErrorLookup.d.ts +5 -5
- package/dist/logic/shouldRenderFormState.d.ts +5 -5
- package/dist/logic/shouldSubscribeByName.d.ts +2 -2
- package/dist/logic/skipValidation.d.ts +11 -11
- package/dist/logic/unsetEmptyArray.d.ts +2 -2
- package/dist/logic/updateFieldArrayRootError.d.ts +3 -3
- package/dist/logic/validateField.d.ts +3 -3
- package/dist/types/controller.d.ts +56 -56
- package/dist/types/errors.d.ts +35 -35
- package/dist/types/events.d.ts +1 -1
- package/dist/types/fieldArray.d.ts +194 -194
- package/dist/types/fields.d.ts +28 -28
- package/dist/types/form.d.ts +627 -627
- package/dist/types/index.d.ts +10 -10
- package/dist/types/path/common.d.ts +315 -315
- package/dist/types/path/eager.d.ts +120 -120
- package/dist/types/path/index.d.ts +3 -3
- package/dist/types/resolvers.d.ts +19 -19
- package/dist/types/utils.d.ts +70 -70
- package/dist/types/validator.d.ts +38 -38
- package/dist/useController.d.ts +26 -26
- package/dist/useFieldArray.d.ts +39 -39
- package/dist/useFieldArray.d.ts.map +1 -1
- package/dist/useForm.d.ts +31 -31
- package/dist/useFormContext.d.ts +64 -64
- package/dist/useFormContext.d.ts.map +1 -1
- package/dist/useFormState.d.ts +33 -33
- package/dist/useFormState.d.ts.map +1 -1
- package/dist/useSubscribe.d.ts +8 -8
- package/dist/useWatch.d.ts +99 -99
- package/dist/utils/append.d.ts +1 -1
- package/dist/utils/cloneObject.d.ts +1 -1
- package/dist/utils/compact.d.ts +2 -2
- package/dist/utils/convertToArrayPayload.d.ts +2 -2
- package/dist/utils/createSubject.d.ts +13 -13
- package/dist/utils/deepEqual.d.ts +1 -1
- package/dist/utils/deepMerge.d.ts +1 -1
- package/dist/utils/fillBooleanArray.d.ts +2 -2
- package/dist/utils/fillEmptyArray.d.ts +2 -2
- package/dist/utils/get.d.ts +2 -2
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/insert.d.ts +2 -2
- package/dist/utils/isBoolean.d.ts +2 -2
- package/dist/utils/isCheckBoxInput.d.ts +3 -3
- package/dist/utils/isDateObject.d.ts +2 -2
- package/dist/utils/isEmptyObject.d.ts +3 -3
- package/dist/utils/isFileInput.d.ts +3 -3
- package/dist/utils/isFunction.d.ts +2 -2
- package/dist/utils/isHTMLElement.d.ts +2 -2
- package/dist/utils/isKey.d.ts +2 -2
- package/dist/utils/isMessage.d.ts +2 -2
- package/dist/utils/isMultipleSelect.d.ts +3 -3
- package/dist/utils/isNullOrUndefined.d.ts +2 -2
- package/dist/utils/isObject.d.ts +3 -3
- package/dist/utils/isPlainObject.d.ts +2 -2
- package/dist/utils/isPrimitive.d.ts +3 -3
- package/dist/utils/isRadioInput.d.ts +3 -3
- package/dist/utils/isRadioOrCheckbox.d.ts +3 -3
- package/dist/utils/isRegex.d.ts +2 -2
- package/dist/utils/isSelectInput.d.ts +3 -3
- package/dist/utils/isString.d.ts +2 -2
- package/dist/utils/isUndefined.d.ts +2 -2
- package/dist/utils/isWeb.d.ts +2 -2
- package/dist/utils/live.d.ts +3 -3
- package/dist/utils/move.d.ts +2 -2
- package/dist/utils/objectHasFunction.d.ts +2 -2
- package/dist/utils/omit.d.ts +2 -2
- package/dist/utils/prepend.d.ts +1 -1
- package/dist/utils/remove.d.ts +2 -2
- package/dist/utils/set.d.ts +2 -2
- package/dist/utils/sleep.d.ts +1 -1
- package/dist/utils/stringToPath.d.ts +2 -2
- package/dist/utils/swap.d.ts +2 -2
- package/dist/utils/unset.d.ts +1 -1
- package/dist/utils/update.d.ts +2 -2
- package/package.json +8 -8
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldArray.d.ts","sourceRoot":"","sources":["../src/useFieldArray.ts"],"names":[],"mappings":"AAwBA,OAAO,EAKL,cAAc,EAId,WAAW,EAIX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SAAS,cAAc,CAAC,YAAY,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,EACnF,QAAQ,SAAS,MAAM,GAAG,IAAI,EAE9B,KAAK,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,GACjE,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"useFieldArray.d.ts","sourceRoot":"","sources":["../src/useFieldArray.ts"],"names":[],"mappings":"AAwBA,OAAO,EAKL,cAAc,EAId,WAAW,EAIX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SAAS,cAAc,CAAC,YAAY,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,EACnF,QAAQ,SAAS,MAAM,GAAG,IAAI,EAE9B,KAAK,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,GACjE,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,CAyT9D"}
|
package/dist/useForm.d.ts
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
import { FieldValues, UseFormProps, UseFormReturn } from './types';
|
2
|
-
/**
|
3
|
-
* Custom hook to manage the entire form.
|
4
|
-
*
|
5
|
-
* @remarks
|
6
|
-
* [API](https://react-hook-form.com/api/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
|
7
|
-
*
|
8
|
-
* @param props - form configuration and validation parameters.
|
9
|
-
*
|
10
|
-
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
11
|
-
*
|
12
|
-
* @example
|
13
|
-
* ```tsx
|
14
|
-
* function App() {
|
15
|
-
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
16
|
-
* const onSubmit = data => console.log(data);
|
17
|
-
*
|
18
|
-
* console.log(watch("example"));
|
19
|
-
*
|
20
|
-
* return (
|
21
|
-
* <form onSubmit={handleSubmit(onSubmit)}>
|
22
|
-
* <input defaultValue="test" {...register("example")} />
|
23
|
-
* <input {...register("exampleRequired", { required: true })} />
|
24
|
-
* {errors.exampleRequired && <span>This field is required</span>}
|
25
|
-
* <input type="submit" />
|
26
|
-
* </form>
|
27
|
-
* );
|
28
|
-
* }
|
29
|
-
* ```
|
30
|
-
*/
|
31
|
-
export declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any>(props?: UseFormProps<TFieldValues, TContext>): UseFormReturn<TFieldValues, TContext>;
|
1
|
+
import { FieldValues, UseFormProps, UseFormReturn } from './types';
|
2
|
+
/**
|
3
|
+
* Custom hook to manage the entire form.
|
4
|
+
*
|
5
|
+
* @remarks
|
6
|
+
* [API](https://react-hook-form.com/api/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
|
7
|
+
*
|
8
|
+
* @param props - form configuration and validation parameters.
|
9
|
+
*
|
10
|
+
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* ```tsx
|
14
|
+
* function App() {
|
15
|
+
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
16
|
+
* const onSubmit = data => console.log(data);
|
17
|
+
*
|
18
|
+
* console.log(watch("example"));
|
19
|
+
*
|
20
|
+
* return (
|
21
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
22
|
+
* <input defaultValue="test" {...register("example")} />
|
23
|
+
* <input {...register("exampleRequired", { required: true })} />
|
24
|
+
* {errors.exampleRequired && <span>This field is required</span>}
|
25
|
+
* <input type="submit" />
|
26
|
+
* </form>
|
27
|
+
* );
|
28
|
+
* }
|
29
|
+
* ```
|
30
|
+
*/
|
31
|
+
export declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any>(props?: UseFormProps<TFieldValues, TContext>): UseFormReturn<TFieldValues, TContext>;
|
32
32
|
//# sourceMappingURL=useForm.d.ts.map
|
package/dist/useFormContext.d.ts
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { FieldValues, FormProviderProps, UseFormReturn } from './types';
|
3
|
-
/**
|
4
|
-
* This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
|
5
|
-
*
|
6
|
-
* @remarks
|
7
|
-
* [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
8
|
-
*
|
9
|
-
* @returns return all useForm methods
|
10
|
-
*
|
11
|
-
* @example
|
12
|
-
* ```tsx
|
13
|
-
* function App() {
|
14
|
-
* const methods = useForm();
|
15
|
-
* const onSubmit = data => console.log(data);
|
16
|
-
*
|
17
|
-
* return (
|
18
|
-
* <FormProvider {...methods} >
|
19
|
-
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
20
|
-
* <NestedInput />
|
21
|
-
* <input type="submit" />
|
22
|
-
* </form>
|
23
|
-
* </FormProvider>
|
24
|
-
* );
|
25
|
-
* }
|
26
|
-
*
|
27
|
-
* function NestedInput() {
|
28
|
-
* const { register } = useFormContext(); // retrieve all hook methods
|
29
|
-
* return <input {...register("test")} />;
|
30
|
-
* }
|
31
|
-
* ```
|
32
|
-
*/
|
33
|
-
export declare const useFormContext: <TFieldValues extends FieldValues>() => UseFormReturn<TFieldValues
|
34
|
-
/**
|
35
|
-
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
|
36
|
-
*
|
37
|
-
* @remarks
|
38
|
-
* [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
39
|
-
*
|
40
|
-
* @param props - all useFrom methods
|
41
|
-
*
|
42
|
-
* @example
|
43
|
-
* ```tsx
|
44
|
-
* function App() {
|
45
|
-
* const methods = useForm();
|
46
|
-
* const onSubmit = data => console.log(data);
|
47
|
-
*
|
48
|
-
* return (
|
49
|
-
* <FormProvider {...methods} >
|
50
|
-
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
51
|
-
* <NestedInput />
|
52
|
-
* <input type="submit" />
|
53
|
-
* </form>
|
54
|
-
* </FormProvider>
|
55
|
-
* );
|
56
|
-
* }
|
57
|
-
*
|
58
|
-
* function NestedInput() {
|
59
|
-
* const { register } = useFormContext(); // retrieve all hook methods
|
60
|
-
* return <input {...register("test")} />;
|
61
|
-
* }
|
62
|
-
* ```
|
63
|
-
*/
|
64
|
-
export declare const FormProvider: <TFieldValues extends FieldValues, TContext = any>(props: FormProviderProps<TFieldValues, TContext>) => JSX.Element;
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { FieldValues, FormProviderProps, UseFormReturn } from './types';
|
3
|
+
/**
|
4
|
+
* This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
|
5
|
+
*
|
6
|
+
* @remarks
|
7
|
+
* [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
8
|
+
*
|
9
|
+
* @returns return all useForm methods
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* ```tsx
|
13
|
+
* function App() {
|
14
|
+
* const methods = useForm();
|
15
|
+
* const onSubmit = data => console.log(data);
|
16
|
+
*
|
17
|
+
* return (
|
18
|
+
* <FormProvider {...methods} >
|
19
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
20
|
+
* <NestedInput />
|
21
|
+
* <input type="submit" />
|
22
|
+
* </form>
|
23
|
+
* </FormProvider>
|
24
|
+
* );
|
25
|
+
* }
|
26
|
+
*
|
27
|
+
* function NestedInput() {
|
28
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
29
|
+
* return <input {...register("test")} />;
|
30
|
+
* }
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare const useFormContext: <TFieldValues extends FieldValues>() => UseFormReturn<TFieldValues>;
|
34
|
+
/**
|
35
|
+
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
|
36
|
+
*
|
37
|
+
* @remarks
|
38
|
+
* [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
39
|
+
*
|
40
|
+
* @param props - all useFrom methods
|
41
|
+
*
|
42
|
+
* @example
|
43
|
+
* ```tsx
|
44
|
+
* function App() {
|
45
|
+
* const methods = useForm();
|
46
|
+
* const onSubmit = data => console.log(data);
|
47
|
+
*
|
48
|
+
* return (
|
49
|
+
* <FormProvider {...methods} >
|
50
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
51
|
+
* <NestedInput />
|
52
|
+
* <input type="submit" />
|
53
|
+
* </form>
|
54
|
+
* </FormProvider>
|
55
|
+
* );
|
56
|
+
* }
|
57
|
+
*
|
58
|
+
* function NestedInput() {
|
59
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
60
|
+
* return <input {...register("test")} />;
|
61
|
+
* }
|
62
|
+
* ```
|
63
|
+
*/
|
64
|
+
export declare const FormProvider: <TFieldValues extends FieldValues, TContext = any>(props: FormProviderProps<TFieldValues, TContext>) => JSX.Element;
|
65
65
|
//# sourceMappingURL=useFormContext.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../src/useFormContext.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,cAAc,
|
1
|
+
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../src/useFormContext.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,cAAc,qEAGkD,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,YAAY,qHASxB,CAAC"}
|
package/dist/useFormState.d.ts
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
import { FieldValues, UseFormStateProps, UseFormStateReturn } from './types';
|
2
|
-
/**
|
3
|
-
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
4
|
-
*
|
5
|
-
* @remarks
|
6
|
-
* [API](https://react-hook-form.com/api/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
7
|
-
*
|
8
|
-
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
9
|
-
*
|
10
|
-
* @example
|
11
|
-
* ```tsx
|
12
|
-
* function App() {
|
13
|
-
* const { register, handleSubmit, control } = useForm({
|
14
|
-
* defaultValues: {
|
15
|
-
* firstName: "firstName"
|
16
|
-
* }});
|
17
|
-
* const { dirtyFields } = useFormState({
|
18
|
-
* control
|
19
|
-
* });
|
20
|
-
* const onSubmit = (data) => console.log(data);
|
21
|
-
*
|
22
|
-
* return (
|
23
|
-
* <form onSubmit={handleSubmit(onSubmit)}>
|
24
|
-
* <input {...register("firstName")} placeholder="First Name" />
|
25
|
-
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
26
|
-
* <input type="submit" />
|
27
|
-
* </form>
|
28
|
-
* );
|
29
|
-
* }
|
30
|
-
* ```
|
31
|
-
*/
|
32
|
-
declare function useFormState<TFieldValues extends FieldValues = FieldValues>(props?: UseFormStateProps<TFieldValues>): UseFormStateReturn<TFieldValues>;
|
33
|
-
export { useFormState };
|
1
|
+
import { FieldValues, UseFormStateProps, UseFormStateReturn } from './types';
|
2
|
+
/**
|
3
|
+
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
4
|
+
*
|
5
|
+
* @remarks
|
6
|
+
* [API](https://react-hook-form.com/api/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
7
|
+
*
|
8
|
+
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* ```tsx
|
12
|
+
* function App() {
|
13
|
+
* const { register, handleSubmit, control } = useForm({
|
14
|
+
* defaultValues: {
|
15
|
+
* firstName: "firstName"
|
16
|
+
* }});
|
17
|
+
* const { dirtyFields } = useFormState({
|
18
|
+
* control
|
19
|
+
* });
|
20
|
+
* const onSubmit = (data) => console.log(data);
|
21
|
+
*
|
22
|
+
* return (
|
23
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
24
|
+
* <input {...register("firstName")} placeholder="First Name" />
|
25
|
+
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
26
|
+
* <input type="submit" />
|
27
|
+
* </form>
|
28
|
+
* );
|
29
|
+
* }
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
declare function useFormState<TFieldValues extends FieldValues = FieldValues>(props?: UseFormStateProps<TFieldValues>): UseFormStateReturn<TFieldValues>;
|
33
|
+
export { useFormState };
|
34
34
|
//# sourceMappingURL=useFormState.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../src/useFormState.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAGX,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,YAAY,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,EAClE,KAAK,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACtC,kBAAkB,CAAC,YAAY,CAAC,
|
1
|
+
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../src/useFormState.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAGX,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,YAAY,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,EAClE,KAAK,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACtC,kBAAkB,CAAC,YAAY,CAAC,CAwDlC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/useSubscribe.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Subject } from './utils/createSubject';
|
2
|
-
type Props<T> = {
|
3
|
-
disabled?: boolean;
|
4
|
-
subject: Subject<T>;
|
5
|
-
next: (value: T) => void;
|
6
|
-
};
|
7
|
-
export declare function useSubscribe<T>(props: Props<T>): void;
|
8
|
-
export {};
|
1
|
+
import { Subject } from './utils/createSubject';
|
2
|
+
type Props<T> = {
|
3
|
+
disabled?: boolean;
|
4
|
+
subject: Subject<T>;
|
5
|
+
next: (value: T) => void;
|
6
|
+
};
|
7
|
+
export declare function useSubscribe<T>(props: Props<T>): void;
|
8
|
+
export {};
|
9
9
|
//# sourceMappingURL=useSubscribe.d.ts.map
|
package/dist/useWatch.d.ts
CHANGED
@@ -1,100 +1,100 @@
|
|
1
|
-
import { Control, DeepPartialSkipArrayKey, FieldPath, FieldPathValue, FieldPathValues, FieldValues } from './types';
|
2
|
-
/**
|
3
|
-
* Subscribe to the entire form values change and re-render at the hook level.
|
4
|
-
*
|
5
|
-
* @remarks
|
6
|
-
*
|
7
|
-
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
8
|
-
*
|
9
|
-
* @param props - defaultValue, disable subscription and match exact name.
|
10
|
-
*
|
11
|
-
* @example
|
12
|
-
* ```tsx
|
13
|
-
* const { watch } = useForm();
|
14
|
-
* const values = useWatch({
|
15
|
-
* control,
|
16
|
-
* defaultValue: {
|
17
|
-
* name: "data"
|
18
|
-
* },
|
19
|
-
* exact: false,
|
20
|
-
* })
|
21
|
-
* ```
|
22
|
-
*/
|
23
|
-
export declare function useWatch<TFieldValues extends FieldValues = FieldValues>(props: {
|
24
|
-
defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;
|
25
|
-
control?: Control<TFieldValues>;
|
26
|
-
disabled?: boolean;
|
27
|
-
exact?: boolean;
|
28
|
-
}): DeepPartialSkipArrayKey<TFieldValues>;
|
29
|
-
/**
|
30
|
-
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
31
|
-
*
|
32
|
-
* @remarks
|
33
|
-
*
|
34
|
-
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
35
|
-
*
|
36
|
-
* @param props - defaultValue, disable subscription and match exact name.
|
37
|
-
*
|
38
|
-
* @example
|
39
|
-
* ```tsx
|
40
|
-
* const { watch } = useForm();
|
41
|
-
* const values = useWatch({
|
42
|
-
* control,
|
43
|
-
* name: "fieldA",
|
44
|
-
* defaultValue: "default value",
|
45
|
-
* exact: false,
|
46
|
-
* })
|
47
|
-
* ```
|
48
|
-
*/
|
49
|
-
export declare function useWatch<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: {
|
50
|
-
name: TFieldName;
|
51
|
-
defaultValue?: FieldPathValue<TFieldValues, TFieldName>;
|
52
|
-
control?: Control<TFieldValues>;
|
53
|
-
disabled?: boolean;
|
54
|
-
exact?: boolean;
|
55
|
-
}): FieldPathValue<TFieldValues, TFieldName>;
|
56
|
-
/**
|
57
|
-
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
58
|
-
*
|
59
|
-
* @remarks
|
60
|
-
*
|
61
|
-
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
62
|
-
*
|
63
|
-
* @param props - defaultValue, disable subscription and match exact name.
|
64
|
-
*
|
65
|
-
* @example
|
66
|
-
* ```tsx
|
67
|
-
* const { watch } = useForm();
|
68
|
-
* const values = useWatch({
|
69
|
-
* control,
|
70
|
-
* name: ["fieldA", "fieldB"],
|
71
|
-
* defaultValue: {
|
72
|
-
* fieldA: "data",
|
73
|
-
* fieldB: "data"
|
74
|
-
* },
|
75
|
-
* exact: false,
|
76
|
-
* })
|
77
|
-
* ```
|
78
|
-
*/
|
79
|
-
export declare function useWatch<TFieldValues extends FieldValues = FieldValues, TFieldNames extends readonly FieldPath<TFieldValues>[] = readonly FieldPath<TFieldValues>[]>(props: {
|
80
|
-
name: readonly [...TFieldNames];
|
81
|
-
defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;
|
82
|
-
control?: Control<TFieldValues>;
|
83
|
-
disabled?: boolean;
|
84
|
-
exact?: boolean;
|
85
|
-
}): FieldPathValues<TFieldValues, TFieldNames>;
|
86
|
-
/**
|
87
|
-
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
88
|
-
*
|
89
|
-
* @remarks
|
90
|
-
*
|
91
|
-
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
92
|
-
*
|
93
|
-
* @example
|
94
|
-
* ```tsx
|
95
|
-
* // can skip passing down the control into useWatch if the form is wrapped with the FormProvider
|
96
|
-
* const values = useWatch()
|
97
|
-
* ```
|
98
|
-
*/
|
99
|
-
export declare function useWatch<TFieldValues extends FieldValues = FieldValues>(): DeepPartialSkipArrayKey<TFieldValues>;
|
1
|
+
import { Control, DeepPartialSkipArrayKey, FieldPath, FieldPathValue, FieldPathValues, FieldValues } from './types';
|
2
|
+
/**
|
3
|
+
* Subscribe to the entire form values change and re-render at the hook level.
|
4
|
+
*
|
5
|
+
* @remarks
|
6
|
+
*
|
7
|
+
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
8
|
+
*
|
9
|
+
* @param props - defaultValue, disable subscription and match exact name.
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* ```tsx
|
13
|
+
* const { watch } = useForm();
|
14
|
+
* const values = useWatch({
|
15
|
+
* control,
|
16
|
+
* defaultValue: {
|
17
|
+
* name: "data"
|
18
|
+
* },
|
19
|
+
* exact: false,
|
20
|
+
* })
|
21
|
+
* ```
|
22
|
+
*/
|
23
|
+
export declare function useWatch<TFieldValues extends FieldValues = FieldValues>(props: {
|
24
|
+
defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;
|
25
|
+
control?: Control<TFieldValues>;
|
26
|
+
disabled?: boolean;
|
27
|
+
exact?: boolean;
|
28
|
+
}): DeepPartialSkipArrayKey<TFieldValues>;
|
29
|
+
/**
|
30
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
31
|
+
*
|
32
|
+
* @remarks
|
33
|
+
*
|
34
|
+
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
35
|
+
*
|
36
|
+
* @param props - defaultValue, disable subscription and match exact name.
|
37
|
+
*
|
38
|
+
* @example
|
39
|
+
* ```tsx
|
40
|
+
* const { watch } = useForm();
|
41
|
+
* const values = useWatch({
|
42
|
+
* control,
|
43
|
+
* name: "fieldA",
|
44
|
+
* defaultValue: "default value",
|
45
|
+
* exact: false,
|
46
|
+
* })
|
47
|
+
* ```
|
48
|
+
*/
|
49
|
+
export declare function useWatch<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: {
|
50
|
+
name: TFieldName;
|
51
|
+
defaultValue?: FieldPathValue<TFieldValues, TFieldName>;
|
52
|
+
control?: Control<TFieldValues>;
|
53
|
+
disabled?: boolean;
|
54
|
+
exact?: boolean;
|
55
|
+
}): FieldPathValue<TFieldValues, TFieldName>;
|
56
|
+
/**
|
57
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
58
|
+
*
|
59
|
+
* @remarks
|
60
|
+
*
|
61
|
+
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
62
|
+
*
|
63
|
+
* @param props - defaultValue, disable subscription and match exact name.
|
64
|
+
*
|
65
|
+
* @example
|
66
|
+
* ```tsx
|
67
|
+
* const { watch } = useForm();
|
68
|
+
* const values = useWatch({
|
69
|
+
* control,
|
70
|
+
* name: ["fieldA", "fieldB"],
|
71
|
+
* defaultValue: {
|
72
|
+
* fieldA: "data",
|
73
|
+
* fieldB: "data"
|
74
|
+
* },
|
75
|
+
* exact: false,
|
76
|
+
* })
|
77
|
+
* ```
|
78
|
+
*/
|
79
|
+
export declare function useWatch<TFieldValues extends FieldValues = FieldValues, TFieldNames extends readonly FieldPath<TFieldValues>[] = readonly FieldPath<TFieldValues>[]>(props: {
|
80
|
+
name: readonly [...TFieldNames];
|
81
|
+
defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;
|
82
|
+
control?: Control<TFieldValues>;
|
83
|
+
disabled?: boolean;
|
84
|
+
exact?: boolean;
|
85
|
+
}): FieldPathValues<TFieldValues, TFieldNames>;
|
86
|
+
/**
|
87
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
88
|
+
*
|
89
|
+
* @remarks
|
90
|
+
*
|
91
|
+
* [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
92
|
+
*
|
93
|
+
* @example
|
94
|
+
* ```tsx
|
95
|
+
* // can skip passing down the control into useWatch if the form is wrapped with the FormProvider
|
96
|
+
* const values = useWatch()
|
97
|
+
* ```
|
98
|
+
*/
|
99
|
+
export declare function useWatch<TFieldValues extends FieldValues = FieldValues>(): DeepPartialSkipArrayKey<TFieldValues>;
|
100
100
|
//# sourceMappingURL=useWatch.d.ts.map
|
package/dist/utils/append.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export default function append<T>(data: T[], value: T | T[]): T[];
|
1
|
+
export default function append<T>(data: T[], value: T | T[]): T[];
|
2
2
|
//# sourceMappingURL=append.d.ts.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export default function cloneObject<T>(data: T): T;
|
1
|
+
export default function cloneObject<T>(data: T): T;
|
2
2
|
//# sourceMappingURL=cloneObject.d.ts.map
|
package/dist/utils/compact.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: <TValue>(value: TValue[]) => TValue[];
|
2
|
-
export default _default;
|
1
|
+
declare const _default: <TValue>(value: TValue[]) => TValue[];
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=compact.d.ts.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: <T>(value: T) => (T & any[]) | T[];
|
2
|
-
export default _default;
|
1
|
+
declare const _default: <T>(value: T) => (T & any[]) | T[];
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=convertToArrayPayload.d.ts.map
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { Noop } from '../types';
|
2
|
-
export type Observer<T> = {
|
3
|
-
next: (value: T) => void;
|
4
|
-
};
|
5
|
-
export type Subscription = {
|
6
|
-
unsubscribe: Noop;
|
7
|
-
};
|
8
|
-
export type Subject<T> = {
|
9
|
-
readonly observers: Observer<T>[];
|
10
|
-
subscribe: (value: Observer<T>) => Subscription;
|
11
|
-
unsubscribe: Noop;
|
12
|
-
} & Observer<T>;
|
13
|
-
export default function createSubject<T>(): Subject<T>;
|
1
|
+
import { Noop } from '../types';
|
2
|
+
export type Observer<T> = {
|
3
|
+
next: (value: T) => void;
|
4
|
+
};
|
5
|
+
export type Subscription = {
|
6
|
+
unsubscribe: Noop;
|
7
|
+
};
|
8
|
+
export type Subject<T> = {
|
9
|
+
readonly observers: Observer<T>[];
|
10
|
+
subscribe: (value: Observer<T>) => Subscription;
|
11
|
+
unsubscribe: Noop;
|
12
|
+
} & Observer<T>;
|
13
|
+
export default function createSubject<T>(): Subject<T>;
|
14
14
|
//# sourceMappingURL=createSubject.d.ts.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export default function deepEqual(object1: any, object2: any): boolean;
|
1
|
+
export default function deepEqual(object1: any, object2: any): boolean;
|
2
2
|
//# sourceMappingURL=deepEqual.d.ts.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare function deepMerge<T extends Record<keyof T, any>, U extends Record<keyof U, any>>(target: T, source: U): T & U;
|
1
|
+
export declare function deepMerge<T extends Record<keyof T, any>, U extends Record<keyof U, any>>(target: T, source: U): T & U;
|
2
2
|
//# sourceMappingURL=deepMerge.d.ts.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: <T>(value: T) => (true | Record<string, boolean>)[];
|
2
|
-
export default _default;
|
1
|
+
declare const _default: <T>(value: T) => (true | Record<string, boolean>)[];
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=fillBooleanArray.d.ts.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: <T>(value: T | T[]) => undefined[] | undefined;
|
2
|
-
export default _default;
|
1
|
+
declare const _default: <T>(value: T | T[]) => undefined[] | undefined;
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=fillEmptyArray.d.ts.map
|
package/dist/utils/get.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: <T>(obj: T, path?: string, defaultValue?: unknown) => any;
|
2
|
-
export default _default;
|
1
|
+
declare const _default: <T>(obj: T, path?: string, defaultValue?: unknown) => any;
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=get.d.ts.map
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import get from './get';
|
2
|
-
import set from './set';
|
3
|
-
export { get, set };
|
1
|
+
import get from './get';
|
2
|
+
import set from './set';
|
3
|
+
export { get, set };
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/utils/insert.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export default function insert<T>(data: T[], index: number): (T | undefined)[];
|
2
|
-
export default function insert<T>(data: T[], index: number, value: T | T[]): T[];
|
1
|
+
export default function insert<T>(data: T[], index: number): (T | undefined)[];
|
2
|
+
export default function insert<T>(data: T[], index: number, value: T | T[]): T[];
|
3
3
|
//# sourceMappingURL=insert.d.ts.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: (value: unknown) => value is boolean;
|
2
|
-
export default _default;
|
1
|
+
declare const _default: (value: unknown) => value is boolean;
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=isBoolean.d.ts.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldElement } from '../types';
|
2
|
-
declare const _default: (element: FieldElement) => element is HTMLInputElement;
|
3
|
-
export default _default;
|
1
|
+
import { FieldElement } from '../types';
|
2
|
+
declare const _default: (element: FieldElement) => element is HTMLInputElement;
|
3
|
+
export default _default;
|
4
4
|
//# sourceMappingURL=isCheckBoxInput.d.ts.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
declare const _default: (value: unknown) => value is Date;
|
2
|
-
export default _default;
|
1
|
+
declare const _default: (value: unknown) => value is Date;
|
2
|
+
export default _default;
|
3
3
|
//# sourceMappingURL=isDateObject.d.ts.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { EmptyObject } from '../types';
|
2
|
-
declare const _default: (value: unknown) => value is EmptyObject;
|
3
|
-
export default _default;
|
1
|
+
import { EmptyObject } from '../types';
|
2
|
+
declare const _default: (value: unknown) => value is EmptyObject;
|
3
|
+
export default _default;
|
4
4
|
//# sourceMappingURL=isEmptyObject.d.ts.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldElement } from '../types';
|
2
|
-
declare const _default: (element: FieldElement) => element is HTMLInputElement;
|
3
|
-
export default _default;
|
1
|
+
import { FieldElement } from '../types';
|
2
|
+
declare const _default: (element: FieldElement) => element is HTMLInputElement;
|
3
|
+
export default _default;
|
4
4
|
//# sourceMappingURL=isFileInput.d.ts.map
|