@graphcommerce/react-hook-form 2.102.14 → 2.104.1
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 +39 -0
- package/package.json +4 -5
- package/src/ComposedForm/ComposedForm.tsx +2 -2
- package/src/ComposedForm/ComposedSubmit.tsx +3 -3
- package/src/ComposedForm/context.ts +1 -3
- package/src/useFormGqlMutation.tsx +1 -1
- package/src/useFormMuiRegister.tsx +1 -1
- package/src/useFormPersist.tsx +1 -1
- package/src/useGqlDocumentHandler.tsx +0 -3
- package/src/useLazyQueryPromise.tsx +1 -0
- package/src/validationPatterns.tsx +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.104.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/react-hook-form@2.104.0...@graphcommerce/react-hook-form@2.104.1) (2021-12-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* make the headerHeight properly configurable ([c39c942](https://github.com/ho-nl/m2-pwa/commit/c39c942a62a9bb9687ea553be28e37fb49a6b065))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [2.104.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/react-hook-form@2.103.1...@graphcommerce/react-hook-form@2.104.0) (2021-11-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* added tons of translations ([9bb0ac7](https://github.com/ho-nl/m2-pwa/commit/9bb0ac709b58df6ea6141e92e4923a5ca9ae2963))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [2.103.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/react-hook-form@2.102.14...@graphcommerce/react-hook-form@2.103.0) (2021-11-03)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* add x-recaptcha header to apollo link context when using mutations ([380fe52](https://github.com/ho-nl/m2-pwa/commit/380fe52ebd283df034d8a2c6a4f6a3713955bdd3))
|
|
34
|
+
* **use-form-gql:** context type ([f355495](https://github.com/ho-nl/m2-pwa/commit/f3554951697fe394a76dd75ecf119f038f8d9bbc))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* google recaptcha v3 integration ([a9fcc16](https://github.com/ho-nl/m2-pwa/commit/a9fcc16f93951e61378c99a2e183e2d754da1d50))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
6
45
|
## [2.102.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/react-hook-form@2.102.0...@graphcommerce/react-hook-form@2.102.1) (2021-09-27)
|
|
7
46
|
|
|
8
47
|
**Note:** Version bump only for package @graphcommerce/react-hook-form
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/react-hook-form",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.104.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "14.x"
|
|
@@ -17,19 +17,18 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@graphcommerce/browserslist-config-pwa": "^3.0.2",
|
|
20
|
-
"@graphcommerce/eslint-config-pwa": "^3.1.
|
|
21
|
-
"@graphcommerce/prettier-config-pwa": "^3.0.
|
|
20
|
+
"@graphcommerce/eslint-config-pwa": "^3.1.6",
|
|
21
|
+
"@graphcommerce/prettier-config-pwa": "^3.0.4",
|
|
22
22
|
"@graphcommerce/typescript-config-pwa": "^3.1.1",
|
|
23
23
|
"@playwright/test": "^1.16.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@apollo/client": "^3.4.16",
|
|
27
|
-
"@graphql-typed-document-node/core": "^3.1.0",
|
|
28
27
|
"graphql": "^15.6.1",
|
|
29
28
|
"react": "^17.0.2",
|
|
30
29
|
"react-dom": "^17.0.2",
|
|
31
30
|
"react-hook-form": "7.16.2",
|
|
32
31
|
"type-fest": "^2.5.1"
|
|
33
32
|
},
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "8f156415c7f5a963e363f0d6d18fe5d6bbd5dba2"
|
|
35
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useReducer } from 'react'
|
|
1
|
+
import React, { useMemo, useReducer } from 'react'
|
|
2
2
|
import { composedFormContext } from './context'
|
|
3
3
|
import { composedFormReducer } from './reducer'
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ export default function ComposedForm(props: ComposedFormProps) {
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<composedFormContext.Provider value={[state, dispatch]}>
|
|
28
|
+
<composedFormContext.Provider value={useMemo(() => [state, dispatch], [state])}>
|
|
29
29
|
{children}
|
|
30
30
|
</composedFormContext.Provider>
|
|
31
31
|
)
|
|
@@ -46,9 +46,9 @@ export default function ComposedSubmit(props: ComposedSubmitProps) {
|
|
|
46
46
|
* If we have forms that are have errors, we don't need to actually submit anything yet. We can
|
|
47
47
|
* trigger the submission of the invalid forms and highlight the errors in those forms.
|
|
48
48
|
*/
|
|
49
|
-
let formsToSubmit = formEntries.filter(
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
let formsToSubmit = formEntries.filter(
|
|
50
|
+
([, f]) => Object.keys(f.form?.formState.errors ?? {}).length > 0,
|
|
51
|
+
)
|
|
52
52
|
|
|
53
53
|
// We have no errors and no invalid forms, this means we can submit everything.
|
|
54
54
|
if (!formsToSubmit.length) formsToSubmit = formEntries
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { ComposedFormContext } from './types'
|
|
3
3
|
|
|
4
|
-
export const composedFormContext = React.createContext(
|
|
5
|
-
(undefined as unknown) as ComposedFormContext,
|
|
6
|
-
)
|
|
4
|
+
export const composedFormContext = React.createContext(undefined as unknown as ComposedFormContext)
|
|
@@ -6,7 +6,7 @@ import { useFormValidFields, UseFormValidReturn } from './useFormValidFields'
|
|
|
6
6
|
|
|
7
7
|
export type UseFormGqlMutationReturn<
|
|
8
8
|
Q extends Record<string, any> = Record<string, any>,
|
|
9
|
-
V extends Record<string, any> = Record<string, any
|
|
9
|
+
V extends Record<string, any> = Record<string, any>,
|
|
10
10
|
> = UseFormGqlMethods<Q, V> &
|
|
11
11
|
UseFormReturn<V> & { muiRegister: UseMuiFormRegister<V>; valid: UseFormValidReturn<V> }
|
|
12
12
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from 'react-hook-form'
|
|
8
8
|
|
|
9
9
|
export type UseMuiFormRegister<TFieldValues extends FieldValues> = <
|
|
10
|
-
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues
|
|
10
|
+
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
11
11
|
>(
|
|
12
12
|
name: TFieldName,
|
|
13
13
|
options?: RegisterOptions<TFieldValues, TFieldName>,
|
package/src/useFormPersist.tsx
CHANGED
|
@@ -42,7 +42,7 @@ export function useFormPersist<V>(options: UseFormPersistOptions<V>) {
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
try {
|
|
44
44
|
if (typeof window === 'undefined') return
|
|
45
|
-
const storedFormStr = window[storage][name]
|
|
45
|
+
const storedFormStr = window[storage][name] as string
|
|
46
46
|
if (!storedFormStr) return
|
|
47
47
|
|
|
48
48
|
const storedValues = JSON.parse(storedFormStr) as FieldValues
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export const emailPattern =
|
|
2
|
-
|
|
1
|
+
export const emailPattern =
|
|
2
|
+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
3
|
+
export const phonePattern =
|
|
4
|
+
/^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/
|
|
3
5
|
|
|
4
6
|
export const houseNumberPattern = /^\d+([-\\/]\d+)*$/
|