@graphcommerce/magento-cart 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,101 @@
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) [`cf44b1f`](https://github.com/graphcommerce-org/graphcommerce/commit/cf44b1f723b7f2073a21abd6821768427cb95315) - Added hideTotals to MultiCartStartCheckout ([@paales](https://github.com/paales))
88
+
89
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`af4463d`](https://github.com/graphcommerce-org/graphcommerce/commit/af4463dcbc6903241c8804ffba2f43b2b8e1a00b) - When running a cart mutation and the cartId is already passed to the form we use that value instead of retrieving the current cart again. ([@paales](https://github.com/paales))
90
+
91
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`415f9fb`](https://github.com/graphcommerce-org/graphcommerce/commit/415f9fb50454fb20cb533235969dd9ab4ffc134b) - Allow setting the cartId in the form for useFormGqlMutationCart by setting the cartId in the form AND allow setting the cartId for a whole context by wrapping with CartIdProvider ([@paales](https://github.com/paales))
92
+
93
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`4e3f3f2`](https://github.com/graphcommerce-org/graphcommerce/commit/4e3f3f2df58638ba8ffc68ee9f274cdd6c45d6d4) - Allow setting the redirect value in the AddProductsToCartForm as a form value. ([@paales](https://github.com/paales))
94
+
95
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`af4463d`](https://github.com/graphcommerce-org/graphcommerce/commit/af4463dcbc6903241c8804ffba2f43b2b8e1a00b) - Solve issue where if the onBeforeSubmit would return false, it would still error if submitted while the cart is locked. ([@paales](https://github.com/paales))
96
+
97
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`1a06135`](https://github.com/graphcommerce-org/graphcommerce/commit/1a061357f4ccb430dd13194f755815474e140520) - Allow awaitable async requests for onStart on checkout button ([@paales](https://github.com/paales))
98
+
3
99
  ## 9.1.0-canary.54
4
100
 
5
101
  ## 9.1.0-canary.53
@@ -1,4 +1,5 @@
1
1
  import { useQuery } from '@graphcommerce/graphql'
2
+ import { crossSellsHideCartItems } from '@graphcommerce/next-config/config'
2
3
  import { nonNullable } from '@graphcommerce/next-ui'
3
4
  import { useRouter } from 'next/router'
4
5
  import { useMemo } from 'react'
@@ -6,8 +7,6 @@ import { useCartQuery } from '../../hooks'
6
7
  import { CartAddedDocument } from './CartAdded.gql'
7
8
  import { CrosssellsDocument } from './Crosssells.gql'
8
9
 
9
- const crossSellsHideCartItems = Boolean(import.meta.graphCommerce.crossSellsHideCartItems)
10
-
11
10
  export function useCrosssellItems() {
12
11
  const cartAdded = useCartQuery(CartAddedDocument)
13
12
  const items = (cartAdded.data?.cart?.items ?? []).filter(nonNullable)
@@ -3,7 +3,7 @@ import { useQuery } from '@graphcommerce/graphql'
3
3
  import { extendableComponent, FormDiv } from '@graphcommerce/next-ui'
4
4
  import type { UseFormComposeOptions } from '@graphcommerce/react-hook-form'
5
5
  import { FormPersist, useForm, useFormCompose } from '@graphcommerce/react-hook-form'
6
- import { i18n } from '@lingui/core'
6
+ import { t } from '@lingui/core/macro'
7
7
  import type { SxProps, Theme } from '@mui/material'
8
8
  import { Box, Link, Typography } from '@mui/material'
9
9
  import React from 'react'
@@ -110,7 +110,7 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
110
110
  formControl={{ sx: { display: 'block' } }}
111
111
  name={`agreement${agreement.agreement_id}`}
112
112
  rules={{
113
- required: i18n._(/* i18n */ 'You have to agree in order to proceed'),
113
+ required: t`You have to agree in order to proceed`,
114
114
  }}
115
115
  label={labelContent}
116
116
  />
@@ -6,7 +6,7 @@ import {
6
6
  useFabSize,
7
7
  useScrollY,
8
8
  } from '@graphcommerce/next-ui'
9
- import { i18n } from '@lingui/core'
9
+ import { t } from '@lingui/core/macro'
10
10
  import type { BadgeProps, FabProps, SxProps, Theme } from '@mui/material'
11
11
  import { alpha, Box, Fab, styled, useTheme } from '@mui/material'
12
12
  import { m, useTransform } from 'framer-motion'
@@ -60,7 +60,7 @@ function CartFabContent(props: CartFabContentProps) {
60
60
  <MotionFab
61
61
  href='/cart'
62
62
  className={classes.cart}
63
- aria-label={i18n._(/* i18n */ 'Cart')}
63
+ aria-label={t`Cart`}
64
64
  color='inherit'
65
65
  size='responsive'
66
66
  style={{ backgroundColor }}
@@ -0,0 +1,20 @@
1
+ import { createContext, useContext } from 'react'
2
+
3
+ export const CartIdContext = createContext<string | null>(null)
4
+
5
+ /**
6
+ * By default we use the currently selected cartId.
7
+ *
8
+ * However in a MultiCart scenario we need to be able to switch the cartId in certain contexts.
9
+ */
10
+ export function CartIdProvider(props: {
11
+ children: React.ReactNode
12
+ cartId: string | null | undefined
13
+ }) {
14
+ const { children, cartId } = props
15
+ return <CartIdContext.Provider value={cartId ?? null}>{children}</CartIdContext.Provider>
16
+ }
17
+
18
+ export function useCartIdContext() {
19
+ return useContext(CartIdContext)
20
+ }
@@ -8,7 +8,7 @@ import {
8
8
  nonNullable,
9
9
  SectionContainer,
10
10
  } from '@graphcommerce/next-ui'
11
- import { Trans } from '@lingui/react'
11
+ import { Trans } from '@lingui/react/macro'
12
12
  import type { SxProps, Theme } from '@mui/material'
13
13
  import { Box, Divider } from '@mui/material'
14
14
  import { useCartQuery } from '../../hooks'
@@ -54,7 +54,7 @@ export function CartItemSummary(props: OrderSummaryProps) {
54
54
  >
55
55
  <SectionContainer
56
56
  sx={{ '& .SectionHeader-root': { mt: 0 } }}
57
- labelLeft={<Trans id='Order summary' />}
57
+ labelLeft={<Trans>Order summary</Trans>}
58
58
  variantLeft='h6'
59
59
  className={classes.items}
60
60
  >
@@ -1,8 +1,9 @@
1
1
  import { Money } from '@graphcommerce/magento-store'
2
- import { extendableComponent, iconChevronRight, IconSvg } from '@graphcommerce/next-ui'
3
- import { Trans } from '@lingui/macro'
4
- import type { ButtonProps, SxProps, Theme } from '@mui/material'
5
- import { Box, Button, Link } from '@mui/material'
2
+ import type { ButtonProps } from '@graphcommerce/next-ui'
3
+ import { Button, extendableComponent, iconChevronRight, IconSvg } from '@graphcommerce/next-ui'
4
+ import { Trans } from '@lingui/react/macro'
5
+ import type { SxProps, Theme } from '@mui/material'
6
+ import { Box, Link } from '@mui/material'
6
7
  import React from 'react'
7
8
  import { useCheckoutShouldLoginToContinue } from '../../hooks'
8
9
  import type { CartStartCheckoutFragment } from './CartStartCheckout.gql'
@@ -12,11 +13,12 @@ export type CartStartCheckoutProps = {
12
13
  sx?: SxProps<Theme>
13
14
  buttonProps?: ButtonProps<'button'>
14
15
  disabled?: boolean
16
+ hideTotal?: boolean
15
17
  cart?: CartStartCheckoutFragment | null | undefined
16
18
  onStart?: (
17
- e: React.MouseEvent<HTMLButtonElement>,
19
+ e: React.MouseEvent<HTMLButtonElement, MouseEvent>,
18
20
  cart: CartStartCheckoutFragment | null | undefined,
19
- ) => void
21
+ ) => Promise<void>
20
22
  }
21
23
 
22
24
  const name = 'CartStartCheckout'
@@ -35,6 +37,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
35
37
  onStart,
36
38
  buttonProps: { onClick, ...buttonProps } = {},
37
39
  disabled,
40
+ hideTotal = false,
38
41
  sx = [],
39
42
  cart,
40
43
  } = props
@@ -70,10 +73,9 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
70
73
  size='large'
71
74
  className={classes.checkoutButton}
72
75
  endIcon={<IconSvg src={iconChevronRight} />}
73
- onClick={(e) => {
76
+ onClick={async (e) => {
74
77
  onClick?.(e)
75
- onStart?.(e, cart)
76
- return onClick?.(e)
78
+ await onStart?.(e, cart)
77
79
  }}
78
80
  disabled={disabled || !hasTotals || hasErrors || shouldLoginToContinue}
79
81
  {...buttonProps}
@@ -88,7 +90,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
88
90
  >
89
91
  <Trans>Start Checkout</Trans>
90
92
  </Box>{' '}
91
- {hasTotals && (
93
+ {hasTotals && !hideTotal && (
92
94
  <span className={classes.checkoutMoney}>
93
95
  <Money {...cart?.prices?.grand_total} />
94
96
  </span>
@@ -1,6 +1,6 @@
1
1
  import type { LinkOrButtonProps } from '@graphcommerce/next-ui'
2
- import { iconChevronRight, IconSvg, LinkOrButton } from '@graphcommerce/next-ui'
3
- import { Trans } from '@lingui/react'
2
+ import { iconChevronRight, IconSvg, LinkOrButton, sxx } from '@graphcommerce/next-ui'
3
+ import { Trans } from '@lingui/react/macro'
4
4
  import type { SxProps, Theme } from '@mui/material'
5
5
  import React from 'react'
6
6
  import { useCheckoutShouldLoginToContinue } from '../../hooks'
@@ -8,13 +8,12 @@ import type { CartStartCheckoutFragment } from './CartStartCheckout.gql'
8
8
 
9
9
  export type CartStartCheckoutLinkOrButtonProps = {
10
10
  children?: React.ReactNode
11
- sx?: SxProps<Theme>
12
11
  disabled?: boolean
13
12
  cart?: CartStartCheckoutFragment | null | undefined
14
13
  onStart?: (
15
14
  e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement>,
16
15
  cart: CartStartCheckoutFragment | null | undefined,
17
- ) => void
16
+ ) => Promise<void>
18
17
  linkOrButtonProps?: LinkOrButtonProps
19
18
  }
20
19
 
@@ -24,6 +23,7 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt
24
23
  disabled,
25
24
  linkOrButtonProps: { onClick, button, ...linkOrButtonProps } = {},
26
25
  cart,
26
+ children,
27
27
  } = props
28
28
 
29
29
  const shouldLoginToContinue = useCheckoutShouldLoginToContinue()
@@ -34,11 +34,11 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt
34
34
  return (
35
35
  <LinkOrButton
36
36
  href='/checkout'
37
- onClick={(
37
+ onClick={async (
38
38
  e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement, MouseEvent>,
39
39
  ) => {
40
40
  onClick?.(e)
41
- onStart?.(e, cart)
41
+ await onStart?.(e, cart)
42
42
  }}
43
43
  button={{ variant: 'pill', ...button }}
44
44
  disabled={disabled || !hasTotals || hasErrors || shouldLoginToContinue}
@@ -46,7 +46,7 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt
46
46
  endIcon={<IconSvg src={iconChevronRight} />}
47
47
  {...linkOrButtonProps}
48
48
  >
49
- <Trans id='Next' />
49
+ {children ?? <Trans>Next</Trans>}
50
50
  </LinkOrButton>
51
51
  )
52
52
  }
@@ -1,6 +1,6 @@
1
1
  import { useHistoryLink } from '@graphcommerce/framer-next-pages'
2
2
  import { breakpointVal, extendableComponent, SectionContainer } from '@graphcommerce/next-ui'
3
- import { Trans } from '@lingui/react'
3
+ import { Trans } from '@lingui/react/macro'
4
4
  import type { SxProps, Theme } from '@mui/material'
5
5
  import { Box, lighten, Link, Typography } from '@mui/material'
6
6
  import React from 'react'
@@ -89,7 +89,7 @@ export function CartSummary(props: CartSummaryProps) {
89
89
  <SectionContainer
90
90
  variantLeft='h5'
91
91
  labelLeft={
92
- is_virtual ? <Trans id='Confirmation' /> : <Trans id='Confirmation + Track & trace' />
92
+ is_virtual ? <Trans>Confirmation</Trans> : <Trans>Confirmation + Track & trace</Trans>
93
93
  }
94
94
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
95
95
  />
@@ -99,7 +99,7 @@ export function CartSummary(props: CartSummaryProps) {
99
99
  <Box>
100
100
  <SectionContainer
101
101
  variantLeft='h5'
102
- labelLeft={<Trans id='Shipping method' />}
102
+ labelLeft={<Trans>Shipping method</Trans>}
103
103
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
104
104
  />
105
105
  <Typography variant='body1'>
@@ -112,7 +112,7 @@ export function CartSummary(props: CartSummaryProps) {
112
112
  <Box>
113
113
  <SectionContainer
114
114
  variantLeft='h5'
115
- labelLeft={<Trans id='Shipping address' />}
115
+ labelLeft={<Trans>Shipping address</Trans>}
116
116
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
117
117
  labelRight={
118
118
  editable ? (
@@ -123,7 +123,7 @@ export function CartSummary(props: CartSummaryProps) {
123
123
  onClick={historyOnClick}
124
124
  underline='hover'
125
125
  >
126
- <Trans id='Edit' />
126
+ <Trans>Edit</Trans>
127
127
  </Link>
128
128
  ) : undefined
129
129
  }
@@ -134,7 +134,7 @@ export function CartSummary(props: CartSummaryProps) {
134
134
  <Box>
135
135
  <SectionContainer
136
136
  variantLeft='h5'
137
- labelLeft={<Trans id='Billing address' />}
137
+ labelLeft={<Trans>Billing address</Trans>}
138
138
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
139
139
  labelRight={
140
140
  editable ? (
@@ -144,7 +144,7 @@ export function CartSummary(props: CartSummaryProps) {
144
144
  variant='body2'
145
145
  underline='hover'
146
146
  >
147
- <Trans id='Edit' />
147
+ <Trans>Edit</Trans>
148
148
  </Link>
149
149
  ) : undefined
150
150
  }
@@ -1,6 +1,7 @@
1
1
  import { Money } from '@graphcommerce/magento-store'
2
+ import { magentoVersion } from '@graphcommerce/next-config/config'
2
3
  import { breakpointVal, extendableComponent, sxx } from '@graphcommerce/next-ui'
3
- import { Trans } from '@lingui/react'
4
+ import { Trans } from '@lingui/react/macro'
4
5
  import type { SxProps, Theme } from '@mui/material'
5
6
  import { Box, Divider, lighten } from '@mui/material'
6
7
  import { useCartQuery, useDisplayInclTax } from '../../hooks'
@@ -50,7 +51,7 @@ export function CartTotals(props: CartTotalsProps) {
50
51
  const shippingMethod = shipping_addresses?.[0]?.selected_shipping_method
51
52
 
52
53
  const shippingMethodPrices =
53
- import.meta.graphCommerce.magentoVersion >= 246
54
+ magentoVersion >= 246
54
55
  ? shippingMethod
55
56
  : shipping_addresses?.[0]?.available_shipping_methods?.find(
56
57
  (avail) =>
@@ -92,7 +93,7 @@ export function CartTotals(props: CartTotalsProps) {
92
93
  sx={{ display: 'flex', justifyContent: 'space-between' }}
93
94
  >
94
95
  <Box>
95
- <Trans id='Products' />
96
+ <Trans>Products</Trans>
96
97
  </Box>
97
98
  <Box className={classes.money} sx={{ whiteSpace: 'nowrap' }}>
98
99
  <Money {...(inclTax ? prices.subtotal_including_tax : prices.subtotal_excluding_tax)} />
@@ -131,10 +132,7 @@ export function CartTotals(props: CartTotalsProps) {
131
132
  sx={{ display: 'flex', justifyContent: 'space-between' }}
132
133
  >
133
134
  <Box>
134
- <Trans
135
- id='Shipping ({0} {1})'
136
- values={{ 0: shippingMethod.carrier_title, 1: shippingMethod.method_title }}
137
- />
135
+ <Trans>Shipping ({shippingMethod.carrier_title} {shippingMethod.method_title})</Trans>
138
136
  </Box>
139
137
  <Box className={classes.money} sx={{ whiteSpace: 'nowrap' }}>
140
138
  <Money
@@ -177,7 +175,7 @@ export function CartTotals(props: CartTotalsProps) {
177
175
  })}
178
176
  >
179
177
  <Box>
180
- <Trans id='Grand total' />
178
+ <Trans>Grand total</Trans>
181
179
  </Box>
182
180
  <Box className={classes.money} sx={{ whiteSpace: 'nowrap' }}>
183
181
  <Money {...prices.grand_total} />
@@ -198,7 +196,7 @@ export function CartTotals(props: CartTotalsProps) {
198
196
  }}
199
197
  >
200
198
  <Box>
201
- <Trans id='Including {0}' values={{ 0: tax?.label }} />
199
+ <Trans>Including {tax?.label}</Trans>
202
200
  </Box>
203
201
  <Box className={classes.money} sx={{ whiteSpace: 'nowrap' }}>
204
202
  <Money {...tax?.amount} />
@@ -13,7 +13,7 @@ import {
13
13
  } from '@graphcommerce/magento-customer'
14
14
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
15
15
  import { Button, Form, FormActions, FormDivider, FormRow } from '@graphcommerce/next-ui'
16
- import { Trans } from '@lingui/react'
16
+ import { Trans } from '@lingui/react/macro'
17
17
  import type { SxProps, Theme } from '@mui/material'
18
18
  import { GetBillingAddressDocument } from '../../graphql'
19
19
  import { useCartQuery, useFormGqlMutationCart } from '../../hooks'
@@ -96,7 +96,7 @@ export function EditBillingAddressForm(props: EditBillingAddressFormProps) {
96
96
  size='large'
97
97
  loading={formState.isSubmitting}
98
98
  >
99
- <Trans id='Save changes' />
99
+ <Trans>Save changes</Trans>
100
100
  </Button>
101
101
  </FormActions>
102
102
  </Form>
@@ -1,8 +1,12 @@
1
1
  import type { FullPageMessageProps } from '@graphcommerce/next-ui'
2
- import { FullPageMessage, iconShoppingBag, IconSvg } from '@graphcommerce/next-ui'
3
- import { Trans } from '@lingui/react'
2
+ import {
3
+ FullPageMessage,
4
+ iconShoppingBag,
5
+ IconSvg,
6
+ OverlayCloseButton,
7
+ } from '@graphcommerce/next-ui'
8
+ import { Trans } from '@lingui/react/macro'
4
9
  import type { SxProps, Theme } from '@mui/material'
5
- import { Button } from '@mui/material'
6
10
  import React from 'react'
7
11
 
8
12
  export type EmptyCartProps = {
@@ -15,18 +19,22 @@ export function EmptyCart(props: EmptyCartProps) {
15
19
 
16
20
  return (
17
21
  <FullPageMessage
18
- title={<Trans id='Your cart is empty' />}
22
+ title={<Trans>Your cart is empty</Trans>}
19
23
  icon={<IconSvg src={iconShoppingBag} size='xxl' />}
20
24
  button={
21
25
  button || (
22
- <Button href='/' variant='pill' color='secondary' size='large'>
23
- <Trans id='Continue shopping' />
24
- </Button>
26
+ <OverlayCloseButton variant='pill' color='secondary' size='large'>
27
+ <Trans>Continue shopping</Trans>
28
+ </OverlayCloseButton>
25
29
  )
26
30
  }
27
31
  {...rest}
28
32
  >
29
- {children ?? <Trans id='Discover our collection and add items to your cart!' />}
33
+ {children ?? (
34
+ <Trans>
35
+ Discover our collection and add items to your cart!
36
+ </Trans>
37
+ )}
30
38
  </FullPageMessage>
31
39
  )
32
40
  }
@@ -6,7 +6,7 @@ import {
6
6
  useGuestQuery,
7
7
  } from '@graphcommerce/magento-customer'
8
8
  import { Button, extendableComponent, FormRow } from '@graphcommerce/next-ui'
9
- import { Trans } from '@lingui/react'
9
+ import { Trans } from '@lingui/react/macro'
10
10
  import type { SxProps, Theme } from '@mui/material'
11
11
  import { Box, TextField, Typography } from '@mui/material'
12
12
  import React, { useState } from 'react'
@@ -75,9 +75,9 @@ export function InlineAccount(props: InlineAccountProps) {
75
75
  >
76
76
  <div>
77
77
  <Typography variant='h4' className={classes.title} sx={{ paddingBottom: '8px' }}>
78
- {title ?? <Trans id='No account yet?' />}
78
+ {title ?? <Trans>No account yet?</Trans>}
79
79
  </Typography>
80
- {description ?? <Trans id='You can track your order status and much more!' />}
80
+ {description ?? <Trans>You can track your order status and much more!</Trans>}
81
81
  </div>
82
82
  <div>
83
83
  {!toggled && (
@@ -89,7 +89,7 @@ export function InlineAccount(props: InlineAccountProps) {
89
89
  className={classes.button}
90
90
  sx={{ minWidth: 160 }}
91
91
  >
92
- <Trans id='Create an account' />
92
+ <Trans>Create an account</Trans>
93
93
  </Button>
94
94
  )}
95
95
  </div>
@@ -99,7 +99,7 @@ export function InlineAccount(props: InlineAccountProps) {
99
99
  <FormRow>
100
100
  <TextField
101
101
  variant='outlined'
102
- label={<Trans id='Email address' />}
102
+ label={<Trans>Email address</Trans>}
103
103
  value={cart?.email}
104
104
  InputProps={{
105
105
  readOnly: true,
@@ -1,15 +1,17 @@
1
1
  export * from './ApolloCartError'
2
2
  export * from './CartAdded'
3
+ export * from './CartAddress/CartAddress.gql'
3
4
  export * from './CartAddressMultiLine/CartAddressMultiLine'
4
5
  export * from './CartAddressSingleLine/CartAddressSingleLine'
5
6
  export * from './CartAgreementsForm/CartAgreements.gql'
6
7
  export * from './CartAgreementsForm/CartAgreementsForm'
7
8
  export * from './CartFab/CartFab'
9
+ export * from './CartIdContext'
8
10
  export * from './CartItemSummary/CartItemSummary'
9
11
  export * from './CartStartCheckout'
10
12
  export * from './CartSummary/CartSummary'
11
13
  export * from './CartSummary/CartSummary.gql'
12
14
  export * from './CartTotals/CartTotals'
15
+ export * from './EditBillingAddressForm/EditBillingAddressForm'
13
16
  export * from './EmptyCart/EmptyCart'
14
17
  export * from './InlineAccount/InlineAccount'
15
- export * from './EditBillingAddressForm/EditBillingAddressForm'
@@ -1,5 +1,5 @@
1
1
  import { useApolloClient } from '@graphcommerce/graphql'
2
- import { i18n } from '@lingui/core'
2
+ import { t } from '@lingui/core/macro'
3
3
  import { CreateEmptyCartDocument } from './CreateEmptyCart.gql'
4
4
  import { readCartId, useAssignCurrentCartId } from './useAssignCurrentCartId'
5
5
 
@@ -13,7 +13,7 @@ export function useCartIdCreate() {
13
13
  if (currentCartId) return currentCartId
14
14
 
15
15
  const { data } = await client.mutate({ mutation: CreateEmptyCartDocument })
16
- if (!data?.createEmptyCart) throw Error(i18n._(/* i18n */ 'Could not create an empty cart'))
16
+ if (!data?.createEmptyCart) throw Error(t`Could not create an empty cart`)
17
17
 
18
18
  // We store the cartId that is returned as the currentCartId result
19
19
  assignCurrentCartId(data.createEmptyCart)
@@ -1,12 +1,9 @@
1
1
  import { useCustomerSession } from '@graphcommerce/magento-customer/hooks/useCustomerSession'
2
+ import { permissions } from '@graphcommerce/next-config/config'
2
3
  import { useStorefrontConfig } from '@graphcommerce/next-ui'
3
4
 
4
5
  function useCartPermissions() {
5
- return (
6
- useStorefrontConfig().permissions?.cart ??
7
- import.meta.graphCommerce.permissions?.cart ??
8
- 'ENABLED'
9
- )
6
+ return useStorefrontConfig().permissions?.cart ?? permissions?.cart ?? 'ENABLED'
10
7
  }
11
8
 
12
9
  export function useCartEnabled() {
@@ -1,12 +1,9 @@
1
1
  import { useCustomerSession } from '@graphcommerce/magento-customer/hooks/useCustomerSession'
2
+ import { permissions } from '@graphcommerce/next-config/config'
2
3
  import { useStorefrontConfig } from '@graphcommerce/next-ui'
3
4
 
4
5
  function useCheckoutPermission() {
5
- return (
6
- useStorefrontConfig().permissions?.checkout ??
7
- import.meta.graphCommerce.permissions?.checkout ??
8
- 'ENABLED'
9
- )
6
+ return useStorefrontConfig().permissions?.checkout ?? permissions?.checkout ?? 'ENABLED'
10
7
  }
11
8
 
12
9
  export function useCheckoutGuestEnabled() {
@@ -1,6 +1,5 @@
1
+ import { cartDisplayPricesInclTax } from '@graphcommerce/next-config/config'
1
2
  import { useStorefrontConfig } from '@graphcommerce/next-ui'
2
3
 
3
4
  export const useDisplayInclTax = () =>
4
- useStorefrontConfig().cartDisplayPricesInclTax ??
5
- import.meta.graphCommerce.cartDisplayPricesInclTax ??
6
- true
5
+ useStorefrontConfig().cartDisplayPricesInclTax ?? cartDisplayPricesInclTax ?? true
@@ -6,6 +6,7 @@ import type {
6
6
  } from '@graphcommerce/react-hook-form'
7
7
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
8
8
  import { GraphQLError, Kind } from 'graphql'
9
+ import { useCartIdContext } from '../components/CartIdContext'
9
10
  import { isProtectedCartOperation } from '../link/isProtectedCartOperation'
10
11
  import { CurrentCartIdDocument } from './CurrentCartId.gql'
11
12
  import { useCartIdCreate } from './useCartIdCreate'
@@ -19,7 +20,8 @@ export function useFormGqlMutationCart<
19
20
  options: UseFormGraphQlOptions<Q, V> & { submitWhileLocked?: boolean } = {},
20
21
  operationOptions?: MutationHookOptions<Q, V>,
21
22
  ): UseFormGqlMutationReturn<Q, V> {
22
- const cartId = useCartIdCreate()
23
+ const cartIdCreate = useCartIdCreate()
24
+ const cartIdFromContext = useCartIdContext()
23
25
  const client = useApolloClient()
24
26
  const shouldLoginToContinue = useCartShouldLoginToContinue()
25
27
 
@@ -34,20 +36,25 @@ export function useFormGqlMutationCart<
34
36
  document,
35
37
  {
36
38
  ...options,
37
- onBeforeSubmit: async (variables) => {
38
- if (shouldLoginToContinue && shouldBlockOperation) {
39
- return false
40
- }
41
- const vars = { ...variables, cartId: await cartId() }
39
+ onBeforeSubmit: async (incoming) => {
40
+ const variables = options.onBeforeSubmit ? await options.onBeforeSubmit(incoming) : incoming
41
+ if (variables === false) return false
42
+ if (shouldLoginToContinue && shouldBlockOperation) return false
42
43
 
43
44
  const res = client.cache.readQuery({ query: CurrentCartIdDocument })
44
- if (!options.submitWhileLocked && res?.currentCartId?.locked) {
45
- throw Error('Could not submit form, cart is locked')
46
- // console.log('Could not submit form, cart is locked', res.currentCartId.locked)
47
- // return false
45
+ const cartId = cartIdFromContext ?? incoming.cartId ?? (await cartIdCreate())
46
+
47
+ if (
48
+ cartId === res?.currentCartId?.id &&
49
+ res?.currentCartId?.locked &&
50
+ !options.submitWhileLocked
51
+ ) {
52
+ throw Error(
53
+ 'Could not submit form, cart is locked. This is a bug. You may never submit a form while the cart is locked.',
54
+ )
48
55
  }
49
56
 
50
- return options.onBeforeSubmit ? options.onBeforeSubmit(vars) : vars
57
+ return { ...variables, cartId }
51
58
  },
52
59
  },
53
60
  { errorPolicy: 'all', ...operationOptions },
package/link/cartLink.ts CHANGED
@@ -5,7 +5,8 @@ import { CustomerTokenDocument, getCustomerAccountCanSignIn } from '@graphcommer
5
5
  import type { PushRouter } from '@graphcommerce/magento-customer/link/customerLink'
6
6
  import { pushWithPromise } from '@graphcommerce/magento-customer/link/customerLink'
7
7
  import type { ErrorCategory } from '@graphcommerce/magento-graphql'
8
- import { t } from '@lingui/macro'
8
+ import { permissions } from '@graphcommerce/next-config/config'
9
+ import { t } from '@lingui/core/macro'
9
10
  import type { GraphQLFormattedError } from 'graphql'
10
11
  import { GraphQLError } from 'graphql'
11
12
  import { writeCartId } from '../hooks'
@@ -122,7 +123,7 @@ const cartPermissionLink = (router: PushRouter) =>
122
123
  export const cartLink = (router: PushRouter) => {
123
124
  const links = [cartErrorLink]
124
125
 
125
- if (!(import.meta.graphCommerce.permissions?.cart === 'ENABLED')) {
126
+ if (!(permissions?.cart === 'ENABLED')) {
126
127
  links.push(cartPermissionLink(router))
127
128
  }
128
129
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart",
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": {
@@ -11,29 +11,37 @@
11
11
  "project": "./tsconfig.json"
12
12
  }
13
13
  },
14
+ "exports": {
15
+ ".": "./index.ts",
16
+ "./components/CartAdded/useCrosssellItems": "./components/CartAdded/useCrosssellItems.ts",
17
+ "./hooks": "./hooks/index.ts",
18
+ "./plugins/CartDebuggerPlugin": "./plugins/CartDebuggerPlugin.tsx",
19
+ "./plugins/MagentoCartGraphqlProvider": "./plugins/MagentoCartGraphqlProvider.tsx",
20
+ "./plugins/useSignInFormMergeCart": "./plugins/useSignInFormMergeCart.ts"
21
+ },
14
22
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^9.1.0-canary.54",
16
- "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.54",
17
- "@graphcommerce/framer-next-pages": "^9.1.0-canary.54",
18
- "@graphcommerce/framer-scroller": "^9.1.0-canary.54",
19
- "@graphcommerce/framer-utils": "^9.1.0-canary.54",
20
- "@graphcommerce/graphql": "^9.1.0-canary.54",
21
- "@graphcommerce/image": "^9.1.0-canary.54",
22
- "@graphcommerce/magento-customer": "^9.1.0-canary.54",
23
- "@graphcommerce/magento-graphql": "^9.1.0-canary.54",
24
- "@graphcommerce/magento-store": "^9.1.0-canary.54",
25
- "@graphcommerce/next-ui": "^9.1.0-canary.54",
26
- "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.54",
27
- "@graphcommerce/react-hook-form": "^9.1.0-canary.54",
28
- "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.54",
29
- "@lingui/core": "^4.2.1",
30
- "@lingui/macro": "^4.2.1",
31
- "@lingui/react": "^4.2.1",
23
+ "@graphcommerce/ecommerce-ui": "^10.0.0-canary.56",
24
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.56",
25
+ "@graphcommerce/framer-next-pages": "^10.0.0-canary.56",
26
+ "@graphcommerce/framer-scroller": "^10.0.0-canary.56",
27
+ "@graphcommerce/framer-utils": "^10.0.0-canary.56",
28
+ "@graphcommerce/graphql": "^10.0.0-canary.56",
29
+ "@graphcommerce/image": "^10.0.0-canary.56",
30
+ "@graphcommerce/magento-customer": "^10.0.0-canary.56",
31
+ "@graphcommerce/magento-graphql": "^10.0.0-canary.56",
32
+ "@graphcommerce/magento-store": "^10.0.0-canary.56",
33
+ "@graphcommerce/next-ui": "^10.0.0-canary.56",
34
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.56",
35
+ "@graphcommerce/react-hook-form": "^10.0.0-canary.56",
36
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.56",
37
+ "@lingui/core": "^5",
38
+ "@lingui/macro": "^5",
39
+ "@lingui/react": "^5",
32
40
  "@mui/material": "^5.10.16",
33
41
  "framer-motion": "^11.0.0",
34
42
  "graphql": "^16.0.0",
35
43
  "next": "*",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0"
44
+ "react": "^19.2.0",
45
+ "react-dom": "^19.2.0"
38
46
  }
39
47
  }
@@ -1,12 +1,9 @@
1
+ import { permissions } from '@graphcommerce/next-config/config'
1
2
  import { storefrontConfig } from '@graphcommerce/next-ui'
2
3
 
3
4
  /** @public */
4
5
  function getCartPermissions(locale: string | undefined) {
5
- return (
6
- storefrontConfig(locale)?.permissions?.cart ??
7
- import.meta.graphCommerce.permissions?.cart ??
8
- 'ENABLED'
9
- )
6
+ return storefrontConfig(locale)?.permissions?.cart ?? permissions?.cart ?? 'ENABLED'
10
7
  }
11
8
 
12
9
  /** @public */
@@ -1,11 +1,8 @@
1
+ import { permissions } from '@graphcommerce/next-config/config'
1
2
  import { storefrontConfig } from '@graphcommerce/next-ui'
2
3
 
3
4
  function getCheckoutPermission(locale: string | undefined) {
4
- return (
5
- storefrontConfig(locale)?.permissions?.checkout ??
6
- import.meta.graphCommerce.permissions?.checkout ??
7
- 'ENABLED'
8
- )
5
+ return storefrontConfig(locale)?.permissions?.checkout ?? permissions?.checkout ?? 'ENABLED'
9
6
  }
10
7
 
11
8
  export function getCheckoutIsDisabled(locale: string | undefined) {