@graphcommerce/react-hook-form 8.0.6-canary.4 → 8.0.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.
- package/CHANGELOG.md +10 -41
- package/README.md +14 -6
- package/package.json +4 -4
- package/src/useFormAutoSubmit.tsx +1 -3
- package/src/useFormGqlMutation.tsx +5 -12
- package/src/useFormGqlQuery.tsx +3 -1
- package/src/useFormMuiRegister.tsx +0 -3
- package/src/useFormPersist.tsx +5 -25
- package/src/useFormValidFields.tsx +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 8.0.
|
|
3
|
+
## 8.0.7
|
|
4
4
|
|
|
5
|
-
## 8.0.6
|
|
6
|
-
|
|
7
|
-
## 8.0.6-canary.2
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Add deprecation warnings for useFormMuiRegister. Refactor useFormPersist to useWatch and add a separate `<FormPersist/>` component to prevent rerenders.
|
|
12
|
-
([@FrankHarland](https://github.com/FrankHarland))
|
|
13
|
-
|
|
14
|
-
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
|
|
15
|
-
([@FrankHarland](https://github.com/FrankHarland))
|
|
16
|
-
|
|
17
|
-
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`02da217`](https://github.com/graphcommerce-org/graphcommerce/commit/02da2172ef702133510f6923190efae2801032c5) - Migrate most usages of useFormAutoSubmit to <FormAutoSubmit/> and deprecated useFormAutoSubmit
|
|
18
|
-
([@FrankHarland](https://github.com/FrankHarland))
|
|
19
|
-
|
|
20
|
-
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders.
|
|
21
|
-
([@FrankHarland](https://github.com/FrankHarland))
|
|
22
|
-
|
|
23
|
-
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`1a6d0c4`](https://github.com/graphcommerce-org/graphcommerce/commit/1a6d0c4a3584b1e404b444f1ca44c68eaad56cb7) - Mark useFormValidFields as deprecated: Please use TextInputElement, SelectElement, etc. with the showValid prop
|
|
24
|
-
([@FrankHarland](https://github.com/FrankHarland))
|
|
25
|
-
|
|
26
|
-
## 8.0.6-canary.1
|
|
27
|
-
|
|
28
|
-
## 8.0.6-canary.0
|
|
5
|
+
## 8.0.6
|
|
29
6
|
|
|
30
7
|
## 8.0.5
|
|
31
8
|
|
|
32
9
|
### Patch Changes
|
|
33
10
|
|
|
34
|
-
- [#2237](https://github.com/graphcommerce-org/graphcommerce/pull/2237) [`60f387d`](https://github.com/graphcommerce-org/graphcommerce/commit/60f387d4a037736aa8105fa45728ee481bdaf887) - Solve an issue where the checkout address form wouldn't be automatically submitted on change.
|
|
35
|
-
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
11
|
+
- [#2237](https://github.com/graphcommerce-org/graphcommerce/pull/2237) [`60f387d`](https://github.com/graphcommerce-org/graphcommerce/commit/60f387d4a037736aa8105fa45728ee481bdaf887) - Solve an issue where the checkout address form wouldn't be automatically submitted on change. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
36
12
|
|
|
37
13
|
## 8.0.5-canary.10
|
|
38
14
|
|
|
@@ -50,8 +26,7 @@
|
|
|
50
26
|
|
|
51
27
|
### Patch Changes
|
|
52
28
|
|
|
53
|
-
- [#2237](https://github.com/graphcommerce-org/graphcommerce/pull/2237) [`60f387d`](https://github.com/graphcommerce-org/graphcommerce/commit/60f387d4a037736aa8105fa45728ee481bdaf887) - Solve an issue where the checkout address form wouldn't be automatically submitted on change.
|
|
54
|
-
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
29
|
+
- [#2237](https://github.com/graphcommerce-org/graphcommerce/pull/2237) [`60f387d`](https://github.com/graphcommerce-org/graphcommerce/commit/60f387d4a037736aa8105fa45728ee481bdaf887) - Solve an issue where the checkout address form wouldn't be automatically submitted on change. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
55
30
|
|
|
56
31
|
## 8.0.5-canary.3
|
|
57
32
|
|
|
@@ -71,11 +46,9 @@
|
|
|
71
46
|
|
|
72
47
|
### Patch Changes
|
|
73
48
|
|
|
74
|
-
- [#2206](https://github.com/graphcommerce-org/graphcommerce/pull/2206) [`855ab09`](https://github.com/graphcommerce-org/graphcommerce/commit/855ab097b9ea204a7c73c6550b7a5e9e2290f378) - Cleanup `<FormAutoSubmit/>` and remove internal hook.
|
|
75
|
-
([@paales](https://github.com/paales))
|
|
49
|
+
- [#2206](https://github.com/graphcommerce-org/graphcommerce/pull/2206) [`855ab09`](https://github.com/graphcommerce-org/graphcommerce/commit/855ab097b9ea204a7c73c6550b7a5e9e2290f378) - Cleanup `<FormAutoSubmit/>` and remove internal hook. ([@paales](https://github.com/paales))
|
|
76
50
|
|
|
77
|
-
- [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`7c9f5da`](https://github.com/graphcommerce-org/graphcommerce/commit/7c9f5da1d458a19b0316c556c75415ff28bc5b2d) - Added noValidate prop so we can use the FormAutoSubmit component to submit partial forms
|
|
78
|
-
([@paales](https://github.com/paales))
|
|
51
|
+
- [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`7c9f5da`](https://github.com/graphcommerce-org/graphcommerce/commit/7c9f5da1d458a19b0316c556c75415ff28bc5b2d) - Added noValidate prop so we can use the FormAutoSubmit component to submit partial forms ([@paales](https://github.com/paales))
|
|
79
52
|
|
|
80
53
|
## 8.0.3-canary.6
|
|
81
54
|
|
|
@@ -83,8 +56,7 @@
|
|
|
83
56
|
|
|
84
57
|
### Patch Changes
|
|
85
58
|
|
|
86
|
-
- [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`7c9f5da`](https://github.com/graphcommerce-org/graphcommerce/commit/7c9f5da1d458a19b0316c556c75415ff28bc5b2d) - Added noValidate prop so we can use the FormAutoSubmit component to submit partial forms
|
|
87
|
-
([@paales](https://github.com/paales))
|
|
59
|
+
- [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`7c9f5da`](https://github.com/graphcommerce-org/graphcommerce/commit/7c9f5da1d458a19b0316c556c75415ff28bc5b2d) - Added noValidate prop so we can use the FormAutoSubmit component to submit partial forms ([@paales](https://github.com/paales))
|
|
88
60
|
|
|
89
61
|
## 8.0.3-canary.4
|
|
90
62
|
|
|
@@ -92,8 +64,7 @@
|
|
|
92
64
|
|
|
93
65
|
### Patch Changes
|
|
94
66
|
|
|
95
|
-
- [#2206](https://github.com/graphcommerce-org/graphcommerce/pull/2206) [`855ab09`](https://github.com/graphcommerce-org/graphcommerce/commit/855ab097b9ea204a7c73c6550b7a5e9e2290f378) - Cleanup `<FormAutoSubmit/>` and remove internal hook.
|
|
96
|
-
([@paales](https://github.com/paales))
|
|
67
|
+
- [#2206](https://github.com/graphcommerce-org/graphcommerce/pull/2206) [`855ab09`](https://github.com/graphcommerce-org/graphcommerce/commit/855ab097b9ea204a7c73c6550b7a5e9e2290f378) - Cleanup `<FormAutoSubmit/>` and remove internal hook. ([@paales](https://github.com/paales))
|
|
97
68
|
|
|
98
69
|
## 8.0.3-canary.2
|
|
99
70
|
|
|
@@ -127,11 +98,9 @@
|
|
|
127
98
|
|
|
128
99
|
### Patch Changes
|
|
129
100
|
|
|
130
|
-
- [#2093](https://github.com/graphcommerce-org/graphcommerce/pull/2093) [`112b041`](https://github.com/graphcommerce-org/graphcommerce/commit/112b041f01a33fbd521ce3eb3955844f96b29917) - Created a new experimental mutation abort feature inside `useFormGql`. This will allow redundant mutations to be canceled. This is enabled when the `experimental_useV2` prop on the `useFormGql` hook is used.
|
|
131
|
-
([@mikekeehnen](https://github.com/mikekeehnen))
|
|
101
|
+
- [#2093](https://github.com/graphcommerce-org/graphcommerce/pull/2093) [`112b041`](https://github.com/graphcommerce-org/graphcommerce/commit/112b041f01a33fbd521ce3eb3955844f96b29917) - Created a new experimental mutation abort feature inside `useFormGql`. This will allow redundant mutations to be canceled. This is enabled when the `experimental_useV2` prop on the `useFormGql` hook is used. ([@mikekeehnen](https://github.com/mikekeehnen))
|
|
132
102
|
|
|
133
|
-
- [#2007](https://github.com/graphcommerce-org/graphcommerce/pull/2007) [`f59c276`](https://github.com/graphcommerce-org/graphcommerce/commit/f59c276605f9ed649d1197a9ba0e3f12d7c6d026) - Crosssell behavior now properly shows for the latest added product. Added latest submitted variables to be retrieved when using the useFormGql hook.
|
|
134
|
-
([@JoshuaS98](https://github.com/JoshuaS98))
|
|
103
|
+
- [#2007](https://github.com/graphcommerce-org/graphcommerce/pull/2007) [`f59c276`](https://github.com/graphcommerce-org/graphcommerce/commit/f59c276605f9ed649d1197a9ba0e3f12d7c6d026) - Crosssell behavior now properly shows for the latest added product. Added latest submitted variables to be retrieved when using the useFormGql hook. ([@JoshuaS98](https://github.com/JoshuaS98))
|
|
135
104
|
|
|
136
105
|
## 8.0.0-canary.100
|
|
137
106
|
|
package/README.md
CHANGED
|
@@ -77,10 +77,10 @@ export default function MyComponent() {
|
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
## `
|
|
80
|
+
## `useFormAutoSubmit`
|
|
81
81
|
|
|
82
82
|
```tsx
|
|
83
|
-
import {
|
|
83
|
+
import { useFormAutoSubmit } from '@graphcommerce/react-hook-form'
|
|
84
84
|
|
|
85
85
|
export default function MyAutoSubmitForm() {
|
|
86
86
|
// Regular useForm hook, but you can also use useFormGqlMutation
|
|
@@ -90,13 +90,20 @@ export default function MyAutoSubmitForm() {
|
|
|
90
90
|
const submit = handleSubmit(() => {
|
|
91
91
|
console.log('submitted')
|
|
92
92
|
})
|
|
93
|
+
const autoSubmitting = useFormAutoSubmit({
|
|
94
|
+
form,
|
|
95
|
+
submit,
|
|
96
|
+
fields: ['couponCode'], //optional, default: all fields
|
|
97
|
+
wait: 1200, // optional, default: 500ms
|
|
98
|
+
})
|
|
99
|
+
const disableFields = formState.isSubmitting && !autoSubmitting
|
|
93
100
|
|
|
94
101
|
return (
|
|
95
102
|
<form onSubmit={submit} noValidate>
|
|
96
|
-
<FormAutoSubmit control={control} submit={submit} name={['couponCode']} wait={1200}>
|
|
97
103
|
<input
|
|
98
104
|
type='text'
|
|
99
105
|
{...register('couponCode', { required: required.couponCode })}
|
|
106
|
+
disabled={formState.isSubmitting}
|
|
100
107
|
/>
|
|
101
108
|
{errors.couponCode?.message}
|
|
102
109
|
</form>
|
|
@@ -104,10 +111,10 @@ export default function MyAutoSubmitForm() {
|
|
|
104
111
|
}
|
|
105
112
|
```
|
|
106
113
|
|
|
107
|
-
### `
|
|
114
|
+
### `useFormPersist`
|
|
108
115
|
|
|
109
116
|
```tsx
|
|
110
|
-
import {
|
|
117
|
+
import { useFormAutoSubmit } from '@graphcommerce/react-hook-form'
|
|
111
118
|
|
|
112
119
|
export default function MyAutoSubmitForm() {
|
|
113
120
|
// Regular useForm hook, but you can also use useFormGqlMutation
|
|
@@ -117,10 +124,11 @@ export default function MyAutoSubmitForm() {
|
|
|
117
124
|
const submit = handleSubmit(() => {
|
|
118
125
|
console.log('submitted')
|
|
119
126
|
})
|
|
127
|
+
const autoSubmitting = useFormPersist({ form, name: 'MyForm' })
|
|
128
|
+
const disableFields = formState.isSubmitting && !autoSubmitting
|
|
120
129
|
|
|
121
130
|
return (
|
|
122
131
|
<form onSubmit={submit} noValidate>
|
|
123
|
-
<FormPersist form={form} name='MyForm'>
|
|
124
132
|
<input
|
|
125
133
|
type='text'
|
|
126
134
|
{...register('couponCode', { required: required.couponCode })}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/react-hook-form",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.0.
|
|
5
|
+
"version": "8.0.7",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@apollo/client": "^3",
|
|
19
|
-
"@graphcommerce/eslint-config-pwa": "^8.0.
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^8.0.
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^8.0.
|
|
19
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.7",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.7",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.7",
|
|
22
22
|
"graphql": "^16.6.0",
|
|
23
23
|
"react": "^18.2.0",
|
|
24
24
|
"react-dom": "^18.2.0",
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from 'react-hook-form'
|
|
16
16
|
import { DebounceOptions } from './utils/debounce'
|
|
17
17
|
import { useDebouncedCallback } from './utils/useDebounceCallback'
|
|
18
|
+
import { useFormValidFields } from './useFormValidFields'
|
|
18
19
|
|
|
19
20
|
export type UseFormAutoSubmitOptions<TForm extends UseFormReturn<V>, V extends FieldValues> = {
|
|
20
21
|
/** Instance of current form */
|
|
@@ -53,9 +54,6 @@ export type UseFormAutoSubmitOptions<TForm extends UseFormReturn<V>, V extends F
|
|
|
53
54
|
* Q: How to I resubmit if the form is modified during the request?
|
|
54
55
|
* formState.isDirty should be true after the submission
|
|
55
56
|
* @see useFormGqlMutation.tsx for an example implementation
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @deprecated Please use the <FormAutoSubmit /> component instead. This method causes excessive rerenders.
|
|
59
57
|
*/
|
|
60
58
|
export function useFormAutoSubmit<
|
|
61
59
|
Form extends UseFormReturn<V>,
|
|
@@ -2,7 +2,7 @@ import { MutationHookOptions, TypedDocumentNode, useMutation } from '@apollo/cli
|
|
|
2
2
|
import { FieldValues, useForm, UseFormReturn } from 'react-hook-form'
|
|
3
3
|
import { useFormGql, UseFormGqlMethods, UseFormGraphQlOptions } from './useFormGql'
|
|
4
4
|
import { useFormMuiRegister, UseMuiFormRegister } from './useFormMuiRegister'
|
|
5
|
-
import { UseFormValidReturn } from './useFormValidFields'
|
|
5
|
+
import { useFormValidFields, UseFormValidReturn } from './useFormValidFields'
|
|
6
6
|
|
|
7
7
|
export type UseFormGqlMutationReturn<
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -10,16 +10,7 @@ export type UseFormGqlMutationReturn<
|
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
V extends FieldValues = FieldValues,
|
|
12
12
|
> = UseFormGqlMethods<Q, V> &
|
|
13
|
-
UseFormReturn<V> & {
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Please use TextFieldElement
|
|
16
|
-
*/
|
|
17
|
-
muiRegister: UseMuiFormRegister<V>
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated Please use TextFieldElement showValid
|
|
20
|
-
*/
|
|
21
|
-
valid: UseFormValidReturn<V>
|
|
22
|
-
}
|
|
13
|
+
UseFormReturn<V> & { muiRegister: UseMuiFormRegister<V>; valid: UseFormValidReturn<V> }
|
|
23
14
|
|
|
24
15
|
export function isFormGqlOperation<
|
|
25
16
|
V extends FieldValues,
|
|
@@ -47,5 +38,7 @@ export function useFormGqlMutation<Q extends Record<string, unknown>, V extends
|
|
|
47
38
|
const tuple = useMutation(document, operationOptions)
|
|
48
39
|
const operation = useFormGql({ document, form, tuple, ...options })
|
|
49
40
|
const muiRegister = useFormMuiRegister(form)
|
|
50
|
-
|
|
41
|
+
const valid = useFormValidFields(form, operation.required)
|
|
42
|
+
|
|
43
|
+
return { ...form, ...operation, valid, muiRegister }
|
|
51
44
|
}
|
package/src/useFormGqlQuery.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { FieldValues, useForm } from 'react-hook-form'
|
|
|
3
3
|
import { useFormGql, UseFormGraphQlOptions } from './useFormGql'
|
|
4
4
|
import { UseFormGqlMutationReturn } from './useFormGqlMutation'
|
|
5
5
|
import { useFormMuiRegister } from './useFormMuiRegister'
|
|
6
|
+
import { useFormValidFields } from './useFormValidFields'
|
|
6
7
|
|
|
7
8
|
export type UseFormGqlQueryReturn<
|
|
8
9
|
Q extends Record<string, unknown>,
|
|
@@ -18,6 +19,7 @@ export function useFormGqlQuery<Q extends Record<string, unknown>, V extends Fie
|
|
|
18
19
|
const tuple = useLazyQuery(document, operationOptions)
|
|
19
20
|
const operation = useFormGql({ document, form, tuple, ...options })
|
|
20
21
|
const muiRegister = useFormMuiRegister(form)
|
|
22
|
+
const valid = useFormValidFields(form, operation.required)
|
|
21
23
|
|
|
22
|
-
return { ...form, ...operation, valid
|
|
24
|
+
return { ...form, ...operation, valid, muiRegister }
|
|
23
25
|
}
|
|
@@ -13,9 +13,6 @@ export type UseMuiFormRegister<TFieldValues extends FieldValues> = <
|
|
|
13
13
|
options?: RegisterOptions<TFieldValues, TFieldName>,
|
|
14
14
|
) => Omit<UseFormRegisterReturn, 'ref'> & { inputRef: UseFormRegisterReturn['ref'] }
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Please use use TextFieldElement, etc.
|
|
18
|
-
*/
|
|
19
16
|
export function useFormMuiRegister<V extends FieldValues>({
|
|
20
17
|
register,
|
|
21
18
|
}: Pick<UseFormReturn<V>, 'register'>) {
|
package/src/useFormPersist.tsx
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { useMemoObject } from '@graphcommerce/next-ui/hooks/useMemoObject'
|
|
2
1
|
import { useEffect } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
FieldValues,
|
|
5
|
-
UseFormReturn,
|
|
6
|
-
Path,
|
|
7
|
-
FieldPath,
|
|
8
|
-
PathValue,
|
|
9
|
-
useWatch,
|
|
10
|
-
useFormState,
|
|
11
|
-
} from 'react-hook-form'
|
|
2
|
+
import { FieldValues, UseFormReturn, Path, FieldPath, PathValue } from 'react-hook-form'
|
|
12
3
|
|
|
13
4
|
export type UseFormPersistOptions<
|
|
14
5
|
TFieldValues extends FieldValues = FieldValues,
|
|
@@ -38,30 +29,24 @@ export type UseFormPersistOptions<
|
|
|
38
29
|
* dirty fields when the form is initialized
|
|
39
30
|
*
|
|
40
31
|
* Todo: Use wath callback so it won't trigger a rerender
|
|
41
|
-
*
|
|
42
|
-
* @deprecated Please use <FormPersist /> instead. This method causes INP problems.
|
|
43
32
|
*/
|
|
44
33
|
export function useFormPersist<V extends FieldValues>(options: UseFormPersistOptions<V>) {
|
|
45
34
|
const { form, name, storage = 'sessionStorage', exclude = [], persist = [] } = options
|
|
46
|
-
const { setValue,
|
|
47
|
-
|
|
48
|
-
const formState = useFormState({ control })
|
|
49
|
-
const allFields = useWatch({ control })
|
|
35
|
+
const { setValue, watch, formState } = form
|
|
50
36
|
|
|
51
37
|
const dirtyFieldKeys = Object.keys(formState.dirtyFields) as Path<V>[]
|
|
52
38
|
|
|
53
|
-
//
|
|
39
|
+
// Get all dirty field values and exclude sensitive data
|
|
54
40
|
const newValues = Object.fromEntries(
|
|
55
|
-
dirtyFieldKeys.filter((f) => !exclude.includes(f)).map((field) => [field,
|
|
41
|
+
dirtyFieldKeys.filter((f) => !exclude.includes(f)).map((field) => [field, watch(field)]),
|
|
56
42
|
)
|
|
57
43
|
|
|
58
44
|
// Amend the values with the values that should always be persisted
|
|
59
45
|
persist.forEach((persistKey) => {
|
|
60
|
-
const value =
|
|
46
|
+
const value = watch(persistKey)
|
|
61
47
|
if (value) newValues[persistKey] = value
|
|
62
48
|
})
|
|
63
49
|
|
|
64
|
-
// const valuesJson = useMemoObject(newValues)
|
|
65
50
|
const valuesJson = JSON.stringify(newValues)
|
|
66
51
|
|
|
67
52
|
// Restore changes
|
|
@@ -97,8 +82,3 @@ export function useFormPersist<V extends FieldValues>(options: UseFormPersistOpt
|
|
|
97
82
|
}
|
|
98
83
|
}, [name, storage, valuesJson])
|
|
99
84
|
}
|
|
100
|
-
|
|
101
|
-
export function FormPersist<V extends FieldValues>(props: UseFormPersistOptions<V>) {
|
|
102
|
-
useFormPersist(props)
|
|
103
|
-
return null
|
|
104
|
-
}
|
|
@@ -7,8 +7,6 @@ export type UseFormValidReturn<TFieldValues> = Partial<Record<Path<TFieldValues>
|
|
|
7
7
|
* ### useFormValidFields
|
|
8
8
|
*
|
|
9
9
|
* Record field names as key and boolean as value indicating whether the field is valid
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Please use TextInputElement, SelectElement, etc. with the showValid prop
|
|
12
10
|
*/
|
|
13
11
|
export function useFormValidFields<TFieldValues extends FieldValues>(
|
|
14
12
|
form: Pick<UseFormReturn<TFieldValues>, 'watch' | 'formState'>,
|