react-hook-form 7.43.5 → 7.43.7

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.
Files changed (158) hide show
  1. package/README.md +3 -0
  2. package/dist/__tests__/controller.server.test.d.ts +1 -1
  3. package/dist/__tests__/controller.test.d.ts +1 -1
  4. package/dist/__tests__/form.test.d.ts +2 -2
  5. package/dist/__tests__/logic/validateField.test.d.ts +1 -1
  6. package/dist/__tests__/type.test.d.ts +1 -1
  7. package/dist/__tests__/useController.test.d.ts +1 -1
  8. package/dist/__tests__/useFieldArray/append.test.d.ts +1 -1
  9. package/dist/__tests__/useFieldArray/focus.test.d.ts +1 -1
  10. package/dist/__tests__/useFieldArray/insert.test.d.ts +1 -1
  11. package/dist/__tests__/useFieldArray/move.test.d.ts +1 -1
  12. package/dist/__tests__/useFieldArray/prepend.test.d.ts +1 -1
  13. package/dist/__tests__/useFieldArray/remove.test.d.ts +1 -1
  14. package/dist/__tests__/useFieldArray/replace.test.d.ts +1 -1
  15. package/dist/__tests__/useFieldArray/swap.test.d.ts +1 -1
  16. package/dist/__tests__/useFieldArray/update.test.d.ts +1 -1
  17. package/dist/__tests__/useFieldArray.test.d.ts +1 -1
  18. package/dist/__tests__/useForm/clearErrors.test.d.ts +1 -1
  19. package/dist/__tests__/useForm/formState.test.d.ts +1 -1
  20. package/dist/__tests__/useForm/getFieldState.test.d.ts +1 -1
  21. package/dist/__tests__/useForm/getValues.test.d.ts +1 -1
  22. package/dist/__tests__/useForm/handleSubmit.test.d.ts +1 -1
  23. package/dist/__tests__/useForm/register.test.d.ts +1 -1
  24. package/dist/__tests__/useForm/reset.test.d.ts +1 -1
  25. package/dist/__tests__/useForm/resetField.test.d.ts +1 -1
  26. package/dist/__tests__/useForm/resolver.test.d.ts +1 -1
  27. package/dist/__tests__/useForm/setError.test.d.ts +1 -1
  28. package/dist/__tests__/useForm/setValue.test.d.ts +1 -1
  29. package/dist/__tests__/useForm/trigger.test.d.ts +1 -1
  30. package/dist/__tests__/useForm/unregister.test.d.ts +1 -1
  31. package/dist/__tests__/useForm/watch.test.d.ts +1 -1
  32. package/dist/__tests__/useForm.server.test.d.ts +1 -1
  33. package/dist/__tests__/useForm.test.d.ts +1 -1
  34. package/dist/__tests__/useFormContext.server.test.d.ts +1 -1
  35. package/dist/__tests__/useFormContext.test.d.ts +1 -1
  36. package/dist/__tests__/useFormState.test.d.ts +1 -1
  37. package/dist/__tests__/useWatch.test.d.ts +1 -1
  38. package/dist/__typetest__/__fixtures__/index.d.ts +4 -4
  39. package/dist/__typetest__/__fixtures__/pathString.d.ts +3 -3
  40. package/dist/__typetest__/__fixtures__/traversable.d.ts +13 -13
  41. package/dist/__typetest__/__fixtures__/tuple.d.ts +14 -14
  42. package/dist/__typetest__/__fixtures__/type.d.ts +11 -11
  43. package/dist/__typetest__/errors.test-d.d.ts +1 -1
  44. package/dist/__typetest__/form.test-d.d.ts +1 -1
  45. package/dist/__typetest__/path/common.test-d.d.ts +1 -1
  46. package/dist/__typetest__/path/eager.test-d.d.ts +1 -1
  47. package/dist/__typetest__/util.test-d.d.ts +1 -1
  48. package/dist/constants.d.ts +16 -16
  49. package/dist/controller.d.ts +46 -46
  50. package/dist/controller.d.ts.map +1 -1
  51. package/dist/form.d.ts +60 -79
  52. package/dist/index.cjs.js +1 -1
  53. package/dist/index.cjs.js.map +1 -1
  54. package/dist/index.d.ts +10 -10
  55. package/dist/index.esm.mjs +2174 -2164
  56. package/dist/index.esm.mjs.map +1 -1
  57. package/dist/index.umd.js +1 -1
  58. package/dist/index.umd.js.map +1 -1
  59. package/dist/logic/appendErrors.d.ts +3 -3
  60. package/dist/logic/createFormControl.d.ts +25 -25
  61. package/dist/logic/createFormControl.d.ts.map +1 -1
  62. package/dist/logic/focusFieldBy.d.ts +3 -3
  63. package/dist/logic/generateId.d.ts +2 -2
  64. package/dist/logic/generateWatchOutput.d.ts +3 -3
  65. package/dist/logic/getCheckboxValue.d.ts +6 -6
  66. package/dist/logic/getDirtyFields.d.ts +2 -2
  67. package/dist/logic/getEventValue.d.ts +2 -2
  68. package/dist/logic/getFieldValue.d.ts +2 -2
  69. package/dist/logic/getFieldValueAs.d.ts +3 -3
  70. package/dist/logic/getFocusFieldName.d.ts +3 -3
  71. package/dist/logic/getNodeParentName.d.ts +2 -2
  72. package/dist/logic/getProxyFormState.d.ts +3 -3
  73. package/dist/logic/getRadioValue.d.ts +6 -6
  74. package/dist/logic/getResolverOptions.d.ts +13 -13
  75. package/dist/logic/getRuleValue.d.ts +3 -3
  76. package/dist/logic/getValidateError.d.ts +2 -2
  77. package/dist/logic/getValidationModes.d.ts +9 -9
  78. package/dist/logic/getValueAndMessage.d.ts +6 -6
  79. package/dist/logic/hasValidation.d.ts +3 -3
  80. package/dist/logic/index.d.ts +2 -2
  81. package/dist/logic/isNameInFieldArray.d.ts +3 -3
  82. package/dist/logic/isWatched.d.ts +3 -3
  83. package/dist/logic/schemaErrorLookup.d.ts +5 -5
  84. package/dist/logic/shouldRenderFormState.d.ts +5 -5
  85. package/dist/logic/shouldSubscribeByName.d.ts +2 -2
  86. package/dist/logic/skipValidation.d.ts +11 -11
  87. package/dist/logic/unsetEmptyArray.d.ts +2 -2
  88. package/dist/logic/updateFieldArrayRootError.d.ts +3 -3
  89. package/dist/logic/validateField.d.ts +3 -3
  90. package/dist/types/controller.d.ts +56 -56
  91. package/dist/types/errors.d.ts +35 -35
  92. package/dist/types/events.d.ts +1 -1
  93. package/dist/types/fieldArray.d.ts +194 -194
  94. package/dist/types/fields.d.ts +28 -28
  95. package/dist/types/form.d.ts +627 -627
  96. package/dist/types/index.d.ts +10 -10
  97. package/dist/types/path/common.d.ts +315 -315
  98. package/dist/types/path/eager.d.ts +120 -120
  99. package/dist/types/path/index.d.ts +3 -3
  100. package/dist/types/resolvers.d.ts +19 -19
  101. package/dist/types/utils.d.ts +70 -70
  102. package/dist/types/validator.d.ts +38 -38
  103. package/dist/types/validator.d.ts.map +1 -1
  104. package/dist/useController.d.ts +26 -26
  105. package/dist/useController.d.ts.map +1 -1
  106. package/dist/useFieldArray.d.ts +39 -39
  107. package/dist/useForm.d.ts +31 -31
  108. package/dist/useFormContext.d.ts +64 -64
  109. package/dist/useFormContext.d.ts.map +1 -1
  110. package/dist/useFormState.d.ts +33 -33
  111. package/dist/useSubscribe.d.ts +8 -8
  112. package/dist/useWatch.d.ts +99 -99
  113. package/dist/utils/append.d.ts +1 -1
  114. package/dist/utils/cloneObject.d.ts +1 -1
  115. package/dist/utils/compact.d.ts +2 -2
  116. package/dist/utils/convertToArrayPayload.d.ts +2 -2
  117. package/dist/utils/createSubject.d.ts +13 -13
  118. package/dist/utils/deepEqual.d.ts +1 -1
  119. package/dist/utils/deepMerge.d.ts +1 -1
  120. package/dist/utils/fillBooleanArray.d.ts +2 -2
  121. package/dist/utils/fillEmptyArray.d.ts +2 -2
  122. package/dist/utils/get.d.ts +2 -2
  123. package/dist/utils/index.d.ts +3 -3
  124. package/dist/utils/insert.d.ts +2 -2
  125. package/dist/utils/isBoolean.d.ts +2 -2
  126. package/dist/utils/isCheckBoxInput.d.ts +3 -3
  127. package/dist/utils/isDateObject.d.ts +2 -2
  128. package/dist/utils/isEmptyObject.d.ts +3 -3
  129. package/dist/utils/isFileInput.d.ts +3 -3
  130. package/dist/utils/isFunction.d.ts +2 -2
  131. package/dist/utils/isHTMLElement.d.ts +2 -2
  132. package/dist/utils/isKey.d.ts +2 -2
  133. package/dist/utils/isMessage.d.ts +2 -2
  134. package/dist/utils/isMultipleSelect.d.ts +3 -3
  135. package/dist/utils/isNullOrUndefined.d.ts +2 -2
  136. package/dist/utils/isObject.d.ts +3 -3
  137. package/dist/utils/isPlainObject.d.ts +2 -2
  138. package/dist/utils/isPrimitive.d.ts +3 -3
  139. package/dist/utils/isRadioInput.d.ts +3 -3
  140. package/dist/utils/isRadioOrCheckbox.d.ts +3 -3
  141. package/dist/utils/isRegex.d.ts +2 -2
  142. package/dist/utils/isSelectInput.d.ts +3 -3
  143. package/dist/utils/isString.d.ts +2 -2
  144. package/dist/utils/isUndefined.d.ts +2 -2
  145. package/dist/utils/isWeb.d.ts +2 -2
  146. package/dist/utils/live.d.ts +3 -3
  147. package/dist/utils/move.d.ts +2 -2
  148. package/dist/utils/objectHasFunction.d.ts +2 -2
  149. package/dist/utils/omit.d.ts +2 -2
  150. package/dist/utils/prepend.d.ts +1 -1
  151. package/dist/utils/remove.d.ts +2 -2
  152. package/dist/utils/set.d.ts +2 -2
  153. package/dist/utils/sleep.d.ts +1 -1
  154. package/dist/utils/stringToPath.d.ts +2 -2
  155. package/dist/utils/swap.d.ts +2 -2
  156. package/dist/utils/unset.d.ts +1 -1
  157. package/dist/utils/update.d.ts +2 -2
  158. package/package.json +8 -8
@@ -1,40 +1,40 @@
1
- import { FieldArrayPath, FieldValues, UseFieldArrayProps, UseFieldArrayReturn } from './types';
2
- /**
3
- * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)
4
- *
5
- * @remarks
6
- * [API](https://react-hook-form.com/api/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)
7
- *
8
- * @param props - useFieldArray props
9
- *
10
- * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}
11
- *
12
- * @example
13
- * ```tsx
14
- * function App() {
15
- * const { register, control, handleSubmit, reset, trigger, setError } = useForm({
16
- * defaultValues: {
17
- * test: []
18
- * }
19
- * });
20
- * const { fields, append } = useFieldArray({
21
- * control,
22
- * name: "test"
23
- * });
24
- *
25
- * return (
26
- * <form onSubmit={handleSubmit(data => console.log(data))}>
27
- * {fields.map((item, index) => (
28
- * <input key={item.id} {...register(`test.${index}.firstName`)} />
29
- * ))}
30
- * <button type="button" onClick={() => append({ firstName: "bill" })}>
31
- * append
32
- * </button>
33
- * <input type="submit" />
34
- * </form>
35
- * );
36
- * }
37
- * ```
38
- */
39
- export declare function useFieldArray<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>, TKeyName extends string = 'id'>(props: UseFieldArrayProps<TFieldValues, TFieldArrayName, TKeyName>): UseFieldArrayReturn<TFieldValues, TFieldArrayName, TKeyName>;
1
+ import { FieldArrayPath, FieldValues, UseFieldArrayProps, UseFieldArrayReturn } from './types';
2
+ /**
3
+ * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)
4
+ *
5
+ * @remarks
6
+ * [API](https://react-hook-form.com/api/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)
7
+ *
8
+ * @param props - useFieldArray props
9
+ *
10
+ * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function App() {
15
+ * const { register, control, handleSubmit, reset, trigger, setError } = useForm({
16
+ * defaultValues: {
17
+ * test: []
18
+ * }
19
+ * });
20
+ * const { fields, append } = useFieldArray({
21
+ * control,
22
+ * name: "test"
23
+ * });
24
+ *
25
+ * return (
26
+ * <form onSubmit={handleSubmit(data => console.log(data))}>
27
+ * {fields.map((item, index) => (
28
+ * <input key={item.id} {...register(`test.${index}.firstName`)} />
29
+ * ))}
30
+ * <button type="button" onClick={() => append({ firstName: "bill" })}>
31
+ * append
32
+ * </button>
33
+ * <input type="submit" />
34
+ * </form>
35
+ * );
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function useFieldArray<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>, TKeyName extends string = 'id'>(props: UseFieldArrayProps<TFieldValues, TFieldArrayName, TKeyName>): UseFieldArrayReturn<TFieldValues, TFieldArrayName, TKeyName>;
40
40
  //# sourceMappingURL=useFieldArray.d.ts.map
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
@@ -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, any>;
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,0EAGkD,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,YAAY,qHASxB,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"}
@@ -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,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
@@ -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
@@ -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
@@ -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