@graphcommerce/magento-cart 4.6.0 → 4.6.3

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,42 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1570](https://github.com/graphcommerce-org/graphcommerce/pull/1570) [`d92780d5c`](https://github.com/graphcommerce-org/graphcommerce/commit/d92780d5c3bb80b5a1519c087338548303e4cc2f) Thanks [@paales](https://github.com/paales)! - Always skip hydration phase by default when running useCurrentCartId / useCustomerSession
8
+
9
+ - Updated dependencies [[`a88f166f0`](https://github.com/graphcommerce-org/graphcommerce/commit/a88f166f0115c58254fe47171da51a5850658a32), [`d92780d5c`](https://github.com/graphcommerce-org/graphcommerce/commit/d92780d5c3bb80b5a1519c087338548303e4cc2f)]:
10
+ - @graphcommerce/next-ui@4.15.1
11
+ - @graphcommerce/magento-customer@4.8.3
12
+ - @graphcommerce/ecommerce-ui@1.1.6
13
+ - @graphcommerce/framer-scroller@2.1.26
14
+ - @graphcommerce/magento-store@4.2.21
15
+
16
+ ## 4.6.2
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`e167992df`](https://github.com/graphcommerce-org/graphcommerce/commit/e167992dfdc6964a392af719667f8a188626ab1b), [`9c2504b4e`](https://github.com/graphcommerce-org/graphcommerce/commit/9c2504b4ed75f41d3003c4d3339814010e85e37e)]:
21
+ - @graphcommerce/next-ui@4.15.0
22
+ - @graphcommerce/ecommerce-ui@1.1.5
23
+ - @graphcommerce/framer-scroller@2.1.25
24
+ - @graphcommerce/magento-customer@4.8.2
25
+ - @graphcommerce/magento-store@4.2.20
26
+
27
+ ## 4.6.1
28
+
29
+ ### Patch Changes
30
+
31
+ - [#1557](https://github.com/graphcommerce-org/graphcommerce/pull/1557) [`2ce406727`](https://github.com/graphcommerce-org/graphcommerce/commit/2ce406727c01a3367cea26c331d8455748592ce9) Thanks [@paales](https://github.com/paales)! - Solves hydration warning for the CartFab when products are in the cart
32
+
33
+ - Updated dependencies [[`01f1588c9`](https://github.com/graphcommerce-org/graphcommerce/commit/01f1588c9200bb39dd61146e260bfa2b32060612), [`84428ccab`](https://github.com/graphcommerce-org/graphcommerce/commit/84428ccab8d1d263893766197076651eae68759c), [`c0a7f9427`](https://github.com/graphcommerce-org/graphcommerce/commit/c0a7f9427466f0a3886b2c3ebf2f0aa5d79ee081)]:
34
+ - @graphcommerce/graphql@3.4.3
35
+ - @graphcommerce/magento-customer@4.8.1
36
+ - @graphcommerce/ecommerce-ui@1.1.4
37
+ - @graphcommerce/magento-store@4.2.19
38
+ - @graphcommerce/magento-graphql@3.1.3
39
+
3
40
  ## 4.6.0
4
41
 
5
42
  ### Minor Changes
@@ -1,3 +1,4 @@
1
+ import { WaitForQueries } from '@graphcommerce/ecommerce-ui'
1
2
  import {
2
3
  extendableComponent,
3
4
  iconShoppingBag,
@@ -69,13 +70,14 @@ function CartFabContent(props: CartFabContentProps) {
69
70
  })}
70
71
  {...fabProps}
71
72
  >
72
- {total_quantity > 0 ? (
73
- <DesktopHeaderBadge color='primary' variant='dot' overlap='circular'>
74
- {cartIcon}
75
- </DesktopHeaderBadge>
76
- ) : (
77
- cartIcon
78
- )}
73
+ <DesktopHeaderBadge
74
+ color='primary'
75
+ variant='dot'
76
+ overlap='circular'
77
+ badgeContent={total_quantity}
78
+ >
79
+ {cartIcon}
80
+ </DesktopHeaderBadge>
79
81
  </MotionFab>
80
82
  </PageLink>
81
83
  <MotionDiv
@@ -109,15 +111,14 @@ function CartFabContent(props: CartFabContentProps) {
109
111
  * product to the cart. This would mean that it would immediately start executing this query.
110
112
  */
111
113
  export function CartFab(props: CartFabProps) {
112
- const { data, loading, called } = useCartQuery(CartFabDocument, {
114
+ const cartQuery = useCartQuery(CartFabDocument, {
113
115
  fetchPolicy: 'cache-only',
114
116
  nextFetchPolicy: 'cache-first',
115
117
  })
116
- const qty = data?.cart?.total_quantity ?? 0
117
118
 
118
- if (loading || !called) {
119
- return <CartFabContent {...props} total_quantity={0} />
120
- }
121
-
122
- return <CartFabContent total_quantity={qty} {...props} />
119
+ return (
120
+ <WaitForQueries waitFor={cartQuery} fallback={<CartFabContent {...props} total_quantity={0} />}>
121
+ <CartFabContent total_quantity={cartQuery.data?.cart?.total_quantity ?? 0} {...props} />
122
+ </WaitForQueries>
123
+ )
123
124
  }
@@ -1,6 +1,6 @@
1
1
  import { useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
2
2
  import { QueryHookOptions, useQuery } from '@graphcommerce/graphql'
3
- import { useState } from 'react'
3
+ import { startTransition, useState } from 'react'
4
4
  import { CurrentCartIdDocument, CurrentCartIdQuery } from './CurrentCartId.gql'
5
5
  import {} from 'react-dom'
6
6
 
@@ -10,9 +10,9 @@ type UseCurrentCartIdOptions<Q, V> = QueryHookOptions<
10
10
  > & { hydration?: boolean }
11
11
 
12
12
  export function useCurrentCartId<Q, V>(options: UseCurrentCartIdOptions<Q, V> = {}) {
13
- const { hydration = true, ...queryOptions } = options
13
+ const { hydration = false, ...queryOptions } = options
14
14
  const [hydrating, setHydrating] = useState(!hydration)
15
- useIsomorphicLayoutEffect(() => setHydrating(false), [])
15
+ useIsomorphicLayoutEffect(() => startTransition(() => setHydrating(false)), [])
16
16
  const skip = options.skip !== undefined ? options.skip : hydrating
17
17
 
18
18
  const { data, ...queryResults } = useQuery(CurrentCartIdDocument, { ...queryOptions, skip })
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": "4.6.0",
5
+ "version": "4.6.3",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,16 +18,16 @@
18
18
  "@playwright/test": "^1.21.1"
19
19
  },
20
20
  "dependencies": {
21
- "@graphcommerce/ecommerce-ui": "1.1.3",
21
+ "@graphcommerce/ecommerce-ui": "1.1.6",
22
22
  "@graphcommerce/framer-utils": "3.1.4",
23
23
  "@graphcommerce/framer-next-pages": "3.2.4",
24
- "@graphcommerce/framer-scroller": "2.1.24",
25
- "@graphcommerce/graphql": "3.4.2",
24
+ "@graphcommerce/framer-scroller": "2.1.26",
25
+ "@graphcommerce/graphql": "3.4.3",
26
26
  "@graphcommerce/image": "3.1.7",
27
- "@graphcommerce/magento-customer": "4.8.0",
28
- "@graphcommerce/magento-graphql": "3.1.2",
29
- "@graphcommerce/magento-store": "4.2.18",
30
- "@graphcommerce/next-ui": "4.14.0",
27
+ "@graphcommerce/magento-customer": "4.8.3",
28
+ "@graphcommerce/magento-graphql": "3.1.3",
29
+ "@graphcommerce/magento-store": "4.2.21",
30
+ "@graphcommerce/next-ui": "4.15.1",
31
31
  "@graphcommerce/react-hook-form": "3.3.1"
32
32
  },
33
33
  "peerDependencies": {