@graphcommerce/react-hook-form 3.3.2 → 3.3.4
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,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1660](https://github.com/graphcommerce-org/graphcommerce/pull/1660) [`75ae24a93`](https://github.com/graphcommerce-org/graphcommerce/commit/75ae24a93bd74e3b9b7efda21ec7ba6fbe9a3a75) Thanks [@paales](https://github.com/paales)! - Remove heuristicEncode for GraphQL input objects provided by react-hook-form
|
|
8
|
+
|
|
9
|
+
## 3.3.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1629](https://github.com/graphcommerce-org/graphcommerce/pull/1629) [`662f510c2`](https://github.com/graphcommerce-org/graphcommerce/commit/662f510c21fc44a63036e5c7a0726ccb33c31600) Thanks [@paales](https://github.com/paales)! - The submit button would remain in a loading state when all composed forms were invalid
|
|
14
|
+
|
|
3
15
|
## 3.3.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
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": "3.3.
|
|
5
|
+
"version": "3.3.4",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -104,7 +104,12 @@ export function ComposedSubmit(props: ComposedSubmitProps) {
|
|
|
104
104
|
throw e
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
|
|
108
|
+
dispatch(
|
|
109
|
+
invalidKeys.length === 0
|
|
110
|
+
? { type: 'SUBMITTING' }
|
|
111
|
+
: { type: 'SUBMITTED', isSubmitSuccessful: false },
|
|
112
|
+
)
|
|
108
113
|
} catch (error) {
|
|
109
114
|
dispatch({ type: 'SUBMITTED', isSubmitSuccessful: false })
|
|
110
115
|
}
|
|
@@ -26,6 +26,7 @@ export function assertFormGqlOperation<V, Q = Record<string, unknown>>(
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** Bindings between react-hook-form's useForm and Apollo Client's useMutation hook. */
|
|
29
30
|
export function useFormGqlMutation<Q, V>(
|
|
30
31
|
document: TypedDocumentNode<Q, V>,
|
|
31
32
|
options: UseFormGraphQlOptions<Q, V> = {},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TypedDocumentNode } from '@apollo/client'
|
|
2
|
-
import {
|
|
2
|
+
import type {
|
|
3
3
|
DefinitionNode,
|
|
4
4
|
OperationDefinitionNode,
|
|
5
5
|
ValueNode,
|
|
@@ -116,20 +116,8 @@ export function handlerFactory<Q, V>(document: TypedDocumentNode<Q, V>): UseGqlD
|
|
|
116
116
|
const required = requiredPartial as Required
|
|
117
117
|
const encoding = encodingPartial as Encoding
|
|
118
118
|
|
|
119
|
-
function heuristicEncode(val: string) {
|
|
120
|
-
if (Number(val).toString() === val) return Number(val)
|
|
121
|
-
if (val === 'true') return true
|
|
122
|
-
if (val === 'false') return false
|
|
123
|
-
return val
|
|
124
|
-
}
|
|
125
|
-
|
|
126
119
|
function encodeItem(enc: FieldTypes, val: unknown) {
|
|
127
120
|
if (Array.isArray(val)) return val.map((v, i) => encodeItem(enc[i], v))
|
|
128
|
-
if (val && typeof val === 'object') {
|
|
129
|
-
return Object.fromEntries(
|
|
130
|
-
Object.entries(val).map(([key, v]) => [key, heuristicEncode(v as string)]),
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
121
|
if (enc === 'Boolean') return Boolean(val)
|
|
134
122
|
if (enc === 'Float' || enc === 'Int') return Number(val)
|
|
135
123
|
return val
|