@graphcommerce/react-hook-form 8.0.3-canary.4 → 8.0.3-canary.6
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
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.0.3-canary.6
|
|
4
|
+
|
|
5
|
+
## 8.0.3-canary.5
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#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
|
|
10
|
+
([@paales](https://github.com/paales))
|
|
11
|
+
|
|
3
12
|
## 8.0.3-canary.4
|
|
4
13
|
|
|
5
14
|
## 8.0.3-canary.3
|
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.3-canary.
|
|
5
|
+
"version": "8.0.3-canary.6",
|
|
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.3-canary.
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^8.0.3-canary.
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^8.0.3-canary.
|
|
19
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.3-canary.6",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.3-canary.6",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.3-canary.6",
|
|
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 */
|
|
@@ -111,6 +112,8 @@ export type FormAutoSubmitProps<TFieldValues extends FieldValues = FieldValues>
|
|
|
111
112
|
*/
|
|
112
113
|
// eslint-disable-next-line react/no-unused-prop-types
|
|
113
114
|
parallel?: boolean
|
|
115
|
+
|
|
116
|
+
noValidate?: boolean
|
|
114
117
|
} & DebounceOptions &
|
|
115
118
|
Omit<UseWatchProps<TFieldValues>, 'defaultValue'>
|
|
116
119
|
|
|
@@ -120,7 +123,7 @@ export type FormAutoSubmitProps<TFieldValues extends FieldValues = FieldValues>
|
|
|
120
123
|
function FormAutoSubmitBase<TFieldValues extends FieldValues = FieldValues>(
|
|
121
124
|
props: FormAutoSubmitProps<TFieldValues>,
|
|
122
125
|
) {
|
|
123
|
-
const { wait, initialWait, maxWait, submit, parallel, ...watchOptions } = props
|
|
126
|
+
const { wait, initialWait, maxWait, submit, parallel, noValidate, ...watchOptions } = props
|
|
124
127
|
|
|
125
128
|
// We create a stable object from the values, so that we can compare them later
|
|
126
129
|
const values = useMemoObject(cloneDeep(useWatch(watchOptions)))
|
|
@@ -139,7 +142,7 @@ function FormAutoSubmitBase<TFieldValues extends FieldValues = FieldValues>(
|
|
|
139
142
|
{ wait, initialWait, maxWait },
|
|
140
143
|
)
|
|
141
144
|
|
|
142
|
-
const valid = isValid && !isValidating
|
|
145
|
+
const valid = (noValidate ? true : isValid) && !isValidating
|
|
143
146
|
const allowed = parallel || !isSubmitting
|
|
144
147
|
const canSubmit = valid && allowed
|
|
145
148
|
|
|
@@ -3,7 +3,7 @@ import useEventCallback from '@mui/utils/useEventCallback'
|
|
|
3
3
|
import { useEffect, useRef } from 'react'
|
|
4
4
|
import debounce, { DebounceOptions } from './debounce'
|
|
5
5
|
|
|
6
|
-
export function useDebouncedCallback<T extends (...args:
|
|
6
|
+
export function useDebouncedCallback<T extends (...args: any[]) => unknown>(
|
|
7
7
|
callback: T,
|
|
8
8
|
{ initialWait, maxWait, wait }: DebounceOptions = {},
|
|
9
9
|
): T {
|