@graphcommerce/react-hook-form 9.1.0-canary.54 → 10.0.0-canary.56

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,95 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.0-canary.56
4
+
5
+ ### Major Changes
6
+
7
+ - [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
8
+
9
+ This major release brings full Turbopack compatibility, dramatically improving development speed.
10
+
11
+ ### 🚀 Turbopack-Compatible Interceptor System
12
+
13
+ The entire plugin/interceptor system has been rewritten to work with Turbopack:
14
+
15
+ - **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
16
+ - **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
17
+ - **Direct imports** - Interceptors import from `.original` files instead of embedding source
18
+ - **New CLI commands**:
19
+ - `graphcommerce codegen-interceptors` - Generate interceptor files
20
+ - `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
21
+ - **Stable file hashing** - Deterministic interceptor generation for better caching
22
+
23
+ ### ⚙️ Treeshakable Configuration System
24
+
25
+ Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
26
+
27
+ - **New `codegen-config-values` command** - Generates TypeScript files with precise typing
28
+ - **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
29
+ - **Fully treeshakable** - Unused config values are eliminated from the bundle
30
+ - **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
31
+ - **Separate files for nested objects** - Optimal treeshaking for complex configurations
32
+
33
+ ### 🔧 withGraphCommerce Changes
34
+
35
+ - **Removed** `InterceptorPlugin` - No longer needed with file-based interception
36
+ - **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
37
+ - **Removed** `@mui/*` alias rewrites - No longer required
38
+ - **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
39
+ - **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
40
+ - **Added** `optimizePackageImports` for better bundle optimization
41
+ - **Added** `images.qualities: [52, 75]` for Next.js image optimization
42
+
43
+ ### 📦 Lingui Configuration
44
+
45
+ - **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
46
+ - **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
47
+ - **Simplified** formatter options
48
+
49
+ ### ⚛️ React 19 & Next.js 16 Compatibility
50
+
51
+ - Updated `RefObject<T>` types for React 19 (now includes `null` by default)
52
+ - Replaced deprecated `React.VFC` with `React.FC`
53
+ - Fixed `useRef` calls to require explicit initial values
54
+ - Updated `MutableRefObject` usage in `framer-scroller`
55
+
56
+ ### 📋 ESLint 9 Flat Config
57
+
58
+ - Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
59
+ - Updated `@typescript-eslint/*` packages to v8
60
+ - Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
61
+
62
+ ### 🔄 Apollo Client
63
+
64
+ - Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
65
+ - Updated error handling types to accept `ApolloError | null | undefined`
66
+
67
+ ### ⚠️ Breaking Changes
68
+
69
+ - **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
70
+ - **Interceptor files changed** - Original components now at `.original.tsx`
71
+ - **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
72
+ - **ESLint config format** - Must use flat config (`eslint.config.mjs`)
73
+ - **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
74
+
75
+ ### 🗑️ Removed
76
+
77
+ - `InterceptorPlugin` webpack plugin
78
+ - `configToImportMeta` utility
79
+ - Webpack `DefinePlugin` usage for config
80
+ - `@mui/*` modern alias rewrites
81
+ - Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
82
+
83
+ ## 9.1.0-canary.55
84
+
85
+ ### Patch Changes
86
+
87
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`5036171`](https://github.com/graphcommerce-org/graphcommerce/commit/5036171618492d7587cc02c557a4e9343e8240cd) - Fix typescript infer ([@paales](https://github.com/paales))
88
+
89
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`31ef9c5`](https://github.com/graphcommerce-org/graphcommerce/commit/31ef9c59b18dd58fbb3625abf586f0a53f3d63cb) - Solve an issue where the false value of the useFormGql was incorrectly interpreted as an error while it was a SKIP. Fixes an issue where the CustomerAddressForm is not submitting properly when the user is adding a new address. ([@paales](https://github.com/paales))
90
+
91
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`9bf02b6`](https://github.com/graphcommerce-org/graphcommerce/commit/9bf02b6dd20c086db0c93fe9efea140b673bc4a2) - Solve issue with react-hook-form causing ts errors, now version is fixed and the ts error is solved ([@paales](https://github.com/paales))
92
+
3
93
  ## 9.1.0-canary.54
4
94
 
5
95
  ## 9.1.0-canary.53
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from 'react-hook-form'
2
+ export { default as diff } from './src/diff'
2
3
  export * from './src/ComposedForm'
3
4
  export * from './src/useFormAutoSubmit'
4
5
  export * from './src/useFormGql'
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": "9.1.0-canary.54",
5
+ "version": "10.0.0-canary.56",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -13,17 +13,20 @@
13
13
  },
14
14
  "peerDependencies": {
15
15
  "@apollo/client": "*",
16
- "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.54",
17
- "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.54",
18
- "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.54",
16
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.56",
17
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.56",
18
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.56",
19
19
  "@mui/utils": "^5",
20
20
  "graphql": "^16.6.0",
21
- "react": "^18.2.0",
22
- "react-dom": "^18.2.0",
21
+ "react": "^19.2.0",
22
+ "react-dom": "^19.2.0",
23
23
  "react-hook-form": "^7"
24
24
  },
25
25
  "dependencies": {
26
- "@types/lodash": "^4.17.13",
26
+ "@types/lodash": "^4.17.21",
27
27
  "lodash": "^4.17.21"
28
+ },
29
+ "exports": {
30
+ ".": "./index.ts"
28
31
  }
29
32
  }
@@ -86,5 +86,5 @@ export type ComposedFormReducer = React.Reducer<ComposedFormState, Actions>
86
86
 
87
87
  export type ComposedFormContext = [
88
88
  React.ReducerState<ComposedFormReducer>,
89
- React.Dispatch<React.ReducerAction<ComposedFormReducer>>,
89
+ React.Dispatch<Actions>,
90
90
  ]
@@ -6,9 +6,10 @@ import { cloneDeep } from '@apollo/client/utilities'
6
6
  import { debounce } from '@mui/material'
7
7
  import React, { useCallback, useEffect, useRef, useState } from 'react'
8
8
  import type {
9
- DeepPartialSkipArrayKey,
10
9
  FieldPath,
11
10
  FieldValues,
11
+ Path,
12
+ PathValue,
12
13
  UseFormHandleSubmit,
13
14
  UseFormReturn,
14
15
  UseWatchProps,
@@ -125,7 +126,8 @@ export type FormAutoSubmitProps<TFieldValues extends FieldValues = FieldValues>
125
126
  * @deprecated Please use leading instead
126
127
  */
127
128
  initialWait?: number
128
- } & Omit<UseWatchProps<TFieldValues>, 'defaultValue'> &
129
+ name?: readonly [...FieldPath<TFieldValues>[]]
130
+ } & Omit<UseWatchProps<TFieldValues>, 'defaultValue' | 'compute'> &
129
131
  DebounceSettings
130
132
 
131
133
  function useAutoSubmitBase<TFieldValues extends FieldValues = FieldValues>(
@@ -141,12 +143,13 @@ function useAutoSubmitBase<TFieldValues extends FieldValues = FieldValues>(
141
143
  submit,
142
144
  parallel,
143
145
  noValidate,
146
+ name = [],
144
147
  ...watchOptions
145
148
  } = props
146
149
 
147
150
  // We create a stable object from the values, so that we can compare them later
148
- const values = useMemoObject(cloneDeep(useWatch(watchOptions)))
149
- const oldValues = useRef<DeepPartialSkipArrayKey<TFieldValues>>(values)
151
+ const values = useMemoObject(cloneDeep(useWatch({ ...watchOptions, name })))
152
+ const oldValues = useRef<PathValue<TFieldValues, Path<TFieldValues>>[]>(values)
150
153
  const { isValidating, isSubmitting, isValid } = useFormState(watchOptions)
151
154
 
152
155
  const submitDebounced = useDebounce(
@@ -22,8 +22,8 @@ type UseFormGraphQLCallbacks<Q, V extends FieldValues> = {
22
22
  * Allows you to modify the variablels computed by the form to make it compatible with the GraphQL
23
23
  * Mutation.
24
24
  *
25
- * When returning false, it will silently stop the submission. When an error is thrown, it will be
26
- * set as an ApolloError
25
+ * When returning false, it will SKIP the submission. When an Error is thrown, it will be set as
26
+ * an ApolloError.
27
27
  */
28
28
  onBeforeSubmit?: (variables: V, form?: UseFormReturn<V>) => V | false | Promise<V | false>
29
29
  /**
@@ -32,7 +32,7 @@ type UseFormGraphQLCallbacks<Q, V extends FieldValues> = {
32
32
  * When an error is thrown, it will be set as an ApolloError
33
33
  */
34
34
  onComplete?: (
35
- data: FetchResult<MaybeMasked<Q>>,
35
+ result: FetchResult<MaybeMasked<Q>>,
36
36
  variables: V,
37
37
  form?: UseFormReturn<V>,
38
38
  ) => void | Promise<void>
@@ -88,8 +88,8 @@ export type UseFormGqlMethods<Q, V extends FieldValues> = Omit<
88
88
  > &
89
89
  Pick<UseFormReturn<V>, 'handleSubmit'> & {
90
90
  data?: MaybeMasked<Q> | null
91
- error?: ApolloError
92
- submittedVariables?: V
91
+ error?: ApolloError | null
92
+ submittedVariables?: V | null
93
93
  }
94
94
 
95
95
  /**
@@ -126,12 +126,12 @@ export function useFormGql<Q, V extends FieldValues>(
126
126
  const { encode, type, ...gqlDocumentHandler } = useGqlDocumentHandler<Q, V>(document)
127
127
  const [execute, { data, error, loading }] = tuple
128
128
 
129
- const submittedVariables = useRef<V>()
130
- const returnedError = useRef<ApolloError>()
129
+ const submittedVariables = useRef<V | null>(null)
130
+ const returnedError = useRef<ApolloError | null>(null)
131
131
 
132
132
  // automatically updates the default values
133
133
  const initital = useRef(true)
134
- const controllerRef = useRef<AbortController | undefined>()
134
+ const controllerRef = useRef<AbortController | null>(null)
135
135
  const valuesString = JSON.stringify(defaultValues)
136
136
  useEffect(() => {
137
137
  if (!deprecated_useV1) return
@@ -166,8 +166,8 @@ export function useFormGql<Q, V extends FieldValues>(
166
166
  return
167
167
  }
168
168
 
169
- returnedError.current = undefined
170
- submittedVariables.current = undefined
169
+ returnedError.current = null
170
+ submittedVariables.current = null
171
171
 
172
172
  // Combine defaults with the formValues and encode
173
173
  let variables = !deprecated_useV1 ? formValues : encode({ ...defaultValues, ...formValues })
@@ -189,10 +189,7 @@ export function useFormGql<Q, V extends FieldValues>(
189
189
  return
190
190
  }
191
191
 
192
- if (onBeforeSubmitResult === false) {
193
- form.setError('root', { message: 'Form submission cancelled' })
194
- return
195
- }
192
+ if (onBeforeSubmitResult === false) return
196
193
 
197
194
  variables = onBeforeSubmitResult
198
195
 
@@ -41,7 +41,7 @@ export function assertFormGqlOperation<
41
41
  /** Bindings between react-hook-form's useForm and Apollo Client's useMutation hook. */
42
42
  export function useFormGqlMutation<Q extends Record<string, unknown>, V extends FieldValues>(
43
43
  document: TypedDocumentNode<Q, V>,
44
- options: UseFormGraphQlOptions<Q, V> = {},
44
+ options: NoInfer<UseFormGraphQlOptions<Q, V>> = {},
45
45
  operationOptions?: MutationHookOptions<Q, V>,
46
46
  ): UseFormGqlMutationReturn<Q, V> {
47
47
  const form = useForm<V>(options)