@graphcommerce/magento-wishlist 9.0.0-canary.99 → 9.0.0

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.
@@ -1,9 +1,10 @@
1
1
  import React from 'react'
2
- import { ProductWishlistIconButton, ProductWishlistChipProps } from './ProductWishlistIconButton'
2
+ import type { ProductWishlistChipProps } from './ProductWishlistIconButton'
3
+ import { ProductWishlistIconButton } from './ProductWishlistIconButton'
3
4
 
4
5
  /**
5
6
  * @deprecated use ProductWishlistIconButton with an sx prop.
6
7
  */
7
- export const ProductWishlistChipDetail = React.memo<ProductWishlistChipProps>((props) => {
8
- return <ProductWishlistIconButton sx={{ boxShadow: 6 }} {...props} />
9
- })
8
+ export const ProductWishlistChipDetail = React.memo<ProductWishlistChipProps>((props) => (
9
+ <ProductWishlistIconButton sx={{ boxShadow: 6 }} {...props} />
10
+ ))
@@ -1,28 +1,31 @@
1
- import { ProductListItemFragment } from '@graphcommerce/magento-product'
1
+ import type { ProductListItemFragment } from '@graphcommerce/magento-product'
2
+ import type { IconSvgProps } from '@graphcommerce/next-ui'
2
3
  import {
3
4
  IconSvg,
4
- iconHeart,
5
- extendableComponent,
6
5
  MessageSnackbar,
6
+ extendableComponent,
7
7
  iconChevronRight,
8
+ iconHeart,
8
9
  } from '@graphcommerce/next-ui'
9
10
  import { i18n } from '@lingui/core'
10
11
  import { Trans } from '@lingui/react'
11
- import { SxProps, Theme, IconButton, Box, IconButtonProps, Button } from '@mui/material'
12
+ import type { IconButtonProps, SxProps, Theme } from '@mui/material'
13
+ import { Box, Button, IconButton } from '@mui/material'
12
14
  import React from 'react'
13
- import { useWishlistEnabled, useAddProductToWishlistAction } from '../../hooks'
15
+ import { useAddProductToWishlistAction, useWishlistEnabled } from '../../hooks'
14
16
 
15
17
  export type ProductWishlistChipProps = ProductListItemFragment & {
16
18
  sx?: SxProps<Theme>
17
19
  buttonProps?: IconButtonProps
20
+ iconSvgProps?: Partial<IconSvgProps>
18
21
  }
19
22
 
20
- const compName = 'ProductWishlistChipBase' as const
23
+ const compName = 'ProductWishlistChipBase'
21
24
  const parts = ['root', 'wishlistIcon', 'wishlistIconActive', 'wishlistButton'] as const
22
25
  const { classes } = extendableComponent(compName, parts)
23
26
 
24
27
  export const ProductWishlistIconButton = React.memo<ProductWishlistChipProps>((props) => {
25
- const { buttonProps, sx = [], ...product } = props
28
+ const { buttonProps, iconSvgProps, sx = [], ...product } = props
26
29
  const enabled = useWishlistEnabled()
27
30
  const { current, onClick, cancelBubble, showSuccess, hideShowSuccess } =
28
31
  useAddProductToWishlistAction({ product, index: 0 })
@@ -52,6 +55,7 @@ export const ProductWishlistIconButton = React.memo<ProductWishlistChipProps>((p
52
55
  size='medium'
53
56
  className={classes.wishlistIconActive}
54
57
  sx={(theme) => ({ color: theme.palette.primary.main, fill: 'currentcolor' })}
58
+ {...iconSvgProps}
55
59
  />
56
60
  ) : (
57
61
  <IconSvg
@@ -71,6 +75,7 @@ export const ProductWishlistIconButton = React.memo<ProductWishlistChipProps>((p
71
75
  : theme.palette.primary.contrastText,
72
76
  },
73
77
  })}
78
+ {...iconSvgProps}
74
79
  />
75
80
  )}
76
81
  </IconButton>
@@ -1,13 +1,14 @@
1
- import { useCustomerSession } from '@graphcommerce/magento-customer'
2
- import { iconHeart, DesktopHeaderBadge, IconSvg, extendableComponent } from '@graphcommerce/next-ui'
1
+ import { DesktopHeaderBadge, IconSvg, extendableComponent, iconHeart } from '@graphcommerce/next-ui'
3
2
  import { i18n } from '@lingui/core'
4
- import { Fab, FabProps as FabPropsType, NoSsr, SxProps, Theme } from '@mui/material'
3
+ import type { BadgeProps, FabProps as FabPropsType, SxProps, Theme } from '@mui/material'
4
+ import { Fab, NoSsr } from '@mui/material'
5
5
  import React from 'react'
6
6
  import { useWishlistEnabled, useWishlistItems } from '../../hooks'
7
7
 
8
- type WishlistFabContentProps = {
8
+ export type WishlistFabContentProps = {
9
9
  icon?: React.ReactNode
10
10
  FabProps?: Omit<FabPropsType, 'children'>
11
+ BadgeProps?: BadgeProps
11
12
  sx?: SxProps<Theme>
12
13
  activeWishlist: boolean
13
14
  }
@@ -17,7 +18,7 @@ const parts = ['root'] as const
17
18
  const { classes } = extendableComponent(name, parts)
18
19
 
19
20
  function WishlistFabContent(props: WishlistFabContentProps) {
20
- const { icon, FabProps, sx, activeWishlist } = props
21
+ const { icon, FabProps, BadgeProps, sx, activeWishlist } = props
21
22
 
22
23
  const wishlistIcon = icon ?? <IconSvg src={iconHeart} size='large' />
23
24
 
@@ -34,7 +35,7 @@ function WishlistFabContent(props: WishlistFabContentProps) {
34
35
  >
35
36
  <NoSsr fallback={wishlistIcon}>
36
37
  {activeWishlist ? (
37
- <DesktopHeaderBadge color='primary' variant='dot' overlap='circular'>
38
+ <DesktopHeaderBadge color='primary' variant='dot' overlap='circular' {...BadgeProps}>
38
39
  {wishlistIcon}
39
40
  </DesktopHeaderBadge>
40
41
  ) : (
@@ -52,7 +53,7 @@ export function WishlistFab(props: WishlistFabProps) {
52
53
  const wishlist = useWishlistItems()
53
54
 
54
55
  if (!enabled) return null
55
- const activeWishlist = wishlist.items.length > 0 ?? false
56
+ const activeWishlist = wishlist.items.length > 0
56
57
 
57
58
  return (
58
59
  <NoSsr fallback={<WishlistFabContent {...props} activeWishlist={false} />}>
@@ -1,14 +1,16 @@
1
+ import type {
2
+ AddToCartItemSelector,
3
+ UseAddProductsToCartActionProps,
4
+ } from '@graphcommerce/magento-product'
1
5
  import {
2
- AddProductsToCartQuantity,
3
6
  AddProductsToCartButton,
7
+ AddProductsToCartQuantity,
4
8
  useFormAddProductsToCart,
5
- UseAddProductsToCartActionProps,
6
- AddToCartItemSelector,
7
9
  } from '@graphcommerce/magento-product'
8
- import { InputMaybe } from '@graphcommerce/next-config'
10
+ import type { InputMaybe } from '@graphcommerce/next-config'
9
11
  import { Box } from '@mui/material'
10
12
 
11
- type AddWishlistItemToCartProps = UseAddProductsToCartActionProps &
13
+ export type AddWishlistItemToCartProps = UseAddProductsToCartActionProps &
12
14
  AddToCartItemSelector & { selectedOptions?: InputMaybe<string[]> | undefined }
13
15
 
14
16
  export function AddWishlistItemToCart(props: AddWishlistItemToCartProps) {
@@ -5,7 +5,10 @@ import { Trans } from '@lingui/react'
5
5
  import { Button } from '@mui/material'
6
6
  import { AddWishlistItemToCart } from '../WishlistItem/AddWishlistItemToCart'
7
7
 
8
- type ConfigurableWishlistItemActionProps = Omit<WishlistItemActionCardProps, 'selectedOptions'>
8
+ export type ConfigurableWishlistItemActionProps = Omit<
9
+ WishlistItemActionCardProps,
10
+ 'selectedOptions'
11
+ >
9
12
 
10
13
  export function ConfigurableWishlistItemAction(props: ConfigurableWishlistItemActionProps) {
11
14
  const { item } = props
@@ -1,18 +1,15 @@
1
1
  import { Image } from '@graphcommerce/image'
2
2
  import { AddProductsToCartForm, useProductLink } from '@graphcommerce/magento-product'
3
3
  import { Money } from '@graphcommerce/magento-store'
4
- import { InputMaybe } from '@graphcommerce/next-config'
5
- import {
6
- extendableComponent,
7
- ActionCard,
8
- ActionCardProps,
9
- actionCardImageSizes,
10
- } from '@graphcommerce/next-ui'
4
+ import type { InputMaybe } from '@graphcommerce/next-config'
5
+ import type { ActionCardProps } from '@graphcommerce/next-ui'
6
+ import { ActionCard, actionCardImageSizes, extendableComponent } from '@graphcommerce/next-ui'
11
7
  import { Trans } from '@lingui/react'
12
- import { Button, Link, SxProps, Theme } from '@mui/material'
13
- import { ReactNode } from 'react'
8
+ import type { SxProps, Theme, ButtonProps } from '@mui/material'
9
+ import { Button, Link } from '@mui/material'
10
+ import type { ReactNode } from 'react'
14
11
  import { useRemoveProductsFromWishlist } from '../../hooks'
15
- import { WishlistItemFragment } from '../../queries/WishlistItem.gql'
12
+ import type { WishlistItemFragment } from '../../queries/WishlistItem.gql'
16
13
  import { AddWishlistItemToCart } from '../WishlistItem/AddWishlistItemToCart'
17
14
 
18
15
  export type WishlistItemActionCardProps = {
@@ -21,10 +18,11 @@ export type WishlistItemActionCardProps = {
21
18
  selectedOptions?: InputMaybe<string[]> | undefined
22
19
  isConfigurableUncompleted?: boolean
23
20
  secondaryAction?: ReactNode
21
+ actionButtonProps?: ButtonProps
24
22
  } & OwnerState &
25
23
  Omit<ActionCardProps, 'value' | 'image' | 'price' | 'title' | 'action'>
26
24
  type OwnerState = { withOptions?: boolean }
27
- const compName = 'WishlistItemActionCard' as const
25
+ const compName = 'WishlistItemActionCard'
28
26
  const parts = [
29
27
  'item',
30
28
  'picture',
@@ -52,6 +50,7 @@ export function WishlistItemActionCard(props: WishlistItemActionCardProps) {
52
50
  selectedOptions,
53
51
  secondaryAction,
54
52
  variant = 'default',
53
+ actionButtonProps,
55
54
  ...rest
56
55
  } = props
57
56
  const { id, product } = item
@@ -172,6 +171,7 @@ export function WishlistItemActionCard(props: WishlistItemActionCardProps) {
172
171
  size='medium'
173
172
  type='button'
174
173
  onClick={() => remove([id])}
174
+ {...actionButtonProps}
175
175
  >
176
176
  <Trans id='Remove' />
177
177
  </Button>
@@ -1,9 +1,11 @@
1
- import { MenuFabSecondaryItem, iconHeart, IconSvg } from '@graphcommerce/next-ui'
2
- import { Badge, NoSsr, SxProps, Theme } from '@mui/material'
3
- import React, { MouseEventHandler } from 'react'
4
- import { useWishlistEnabled, useWishlistItems } from '../../hooks'
5
-
6
- type WishlistMenuFabItemContentProps = {
1
+ import { IconSvg, MenuFabSecondaryItem, iconHeart } from '@graphcommerce/next-ui'
2
+ import type { SxProps, Theme } from '@mui/material'
3
+ import { Badge, NoSsr } from '@mui/material'
4
+ import type { MouseEventHandler } from 'react'
5
+ import React from 'react'
6
+ import { useWishlistItems } from '../../hooks'
7
+
8
+ export type WishlistMenuFabItemContentProps = {
7
9
  icon?: React.ReactNode
8
10
  children: React.ReactNode
9
11
  sx?: SxProps<Theme>
@@ -42,7 +44,7 @@ export function WishlistMenuFabItem(props: WishlistMenuFabItemProps) {
42
44
 
43
45
  if (!wishlist.enabled) return null
44
46
 
45
- const activeWishlist = wishlist.items.length > 0 ?? false
47
+ const activeWishlist = wishlist.items.length > 0
46
48
 
47
49
  return (
48
50
  <NoSsr fallback={<WishlistMenuFabItemContent {...props} activeWishlist={false} />}>
@@ -1,5 +1,4 @@
1
1
  export * from './ProductWishlistChip/ProductWishlistChipDetail'
2
- export * from './ProductWishlistChip/ProductWishlistChipDetailConfigurable'
3
2
  export * from './ProductWishlistChip/ProductWishlistChip'
4
3
  export * from './ProductWishlistChip/ProductWishlistIconButton'
5
4
  export * from './WishlistFab/WishlistFab'
@@ -1,10 +1,11 @@
1
1
  import { useWatch } from '@graphcommerce/ecommerce-ui'
2
2
  import { useCustomerSession } from '@graphcommerce/magento-customer'
3
- import { AddToCartItemSelector, useFormAddProductsToCart } from '@graphcommerce/magento-product'
3
+ import type { AddToCartItemSelector } from '@graphcommerce/magento-product'
4
+ import { useFormAddProductsToCart } from '@graphcommerce/magento-product'
4
5
  import { nonNullable } from '@graphcommerce/next-ui'
5
6
  import { useEventCallback } from '@mui/material'
6
7
  import { useState } from 'react'
7
- import { WishlistItemFragment } from '../queries/WishlistItem.gql'
8
+ import type { WishlistItemFragment } from '../queries/WishlistItem.gql'
8
9
  import { useAddProductsToWishlist } from './useAddProductsToWishlist/useAddProductsToWishlist'
9
10
  import { useRemoveProductsFromWishlist } from './useRemoveProductsFromWishlist'
10
11
  import { useWishlistItems } from './useWishlistitems'
@@ -1,12 +1,10 @@
1
1
  import { useApolloClient } from '@graphcommerce/graphql'
2
2
  import { useCustomerSession } from '@graphcommerce/magento-customer'
3
- import {
4
- AddProductToWishlistDocument,
5
- AddProductToWishlistMutationVariables,
6
- } from './AddProductToWishlist.gql'
7
- import { UseWishlistGuestDocument } from '../useWishlistitems'
8
- import { WishlistItemFragment } from '../../queries/WishlistItem.gql'
9
3
  import { useEventCallback } from '@mui/material'
4
+ import type { WishlistItemFragment } from '../../queries/WishlistItem.gql'
5
+ import { UseWishlistGuestDocument } from '../useWishlistitems'
6
+ import type { AddProductToWishlistMutationVariables } from './AddProductToWishlist.gql'
7
+ import { AddProductToWishlistDocument } from './AddProductToWishlist.gql'
10
8
 
11
9
  function isMutationVariableInput(
12
10
  input: AddProductToWishlistMutationVariables['input'] | WishlistItemFragment[],
@@ -2,8 +2,8 @@ import { useApolloClient } from '@graphcommerce/graphql'
2
2
  import { useCustomerSession } from '@graphcommerce/magento-customer'
3
3
  import { filterNonNullableKeys, nonNullable } from '@graphcommerce/next-ui'
4
4
  import { useEffect } from 'react'
5
- import { UseWishlistCustomerDocument } from './useWishlistitems/UseWishlistCustomer.gql'
6
5
  import { useAddProductsToWishlist } from './useAddProductsToWishlist/useAddProductsToWishlist'
6
+ import { UseWishlistCustomerDocument } from './useWishlistitems/UseWishlistCustomer.gql'
7
7
 
8
8
  /** Merge guest wishlist items to customer session upon login */
9
9
  export function useMergeGuestWishlistWithCustomer() {
@@ -25,6 +25,7 @@ export function useMergeGuestWishlistWithCustomer() {
25
25
  return
26
26
  }
27
27
 
28
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
28
29
  add(
29
30
  wishlist
30
31
  ?.map((item) => {
@@ -42,5 +43,5 @@ export function useMergeGuestWishlistWithCustomer() {
42
43
  })
43
44
  .filter(nonNullable),
44
45
  ).then(clearGuestList)
45
- }, [client, loggedIn])
46
+ }, [add, client, loggedIn])
46
47
  }
@@ -2,11 +2,9 @@ import { useApolloClient } from '@graphcommerce/graphql'
2
2
  import { useCustomerSession } from '@graphcommerce/magento-customer'
3
3
  import { filterNonNullableKeys } from '@graphcommerce/next-ui'
4
4
  import { useEventCallback } from '@mui/material'
5
- import {
6
- UseRemoveProductsFromWishlistDocument,
7
- UseRemoveProductsFromWishlistMutationVariables,
8
- } from './UseRemoveProductsFromWishlist.gql'
9
5
  import { UseWishlistGuestDocument } from '../useWishlistitems'
6
+ import type { UseRemoveProductsFromWishlistMutationVariables } from './UseRemoveProductsFromWishlist.gql'
7
+ import { UseRemoveProductsFromWishlistDocument } from './UseRemoveProductsFromWishlist.gql'
10
8
 
11
9
  export function useRemoveProductsFromWishlist() {
12
10
  const client = useApolloClient()
@@ -1,23 +1,19 @@
1
- import { QueryResult, useApolloClient, useQuery } from '@graphcommerce/graphql'
1
+ import type { QueryResult } from '@graphcommerce/graphql'
2
2
  import {
3
3
  useCustomerQuery,
4
4
  useCustomerSession,
5
5
  useGuestQuery,
6
6
  } from '@graphcommerce/magento-customer'
7
- import type { Get } from 'type-fest'
7
+ import { filterNonNullableKeys } from '@graphcommerce/next-ui'
8
+ import type { WishlistItemFragment } from '../../queries/WishlistItem.gql'
8
9
  import { useWishlistEnabled } from '../useWishlistEnabled/useWishlistEnabled'
9
- import {
10
- UseWishlistCustomerDocument,
10
+ import type {
11
11
  UseWishlistCustomerQuery,
12
12
  UseWishlistCustomerQueryVariables,
13
13
  } from './UseWishlistCustomer.gql'
14
- import {
15
- UseWishlistGuestDocument,
16
- UseWishlistGuestQuery,
17
- UseWishlistGuestQueryVariables,
18
- } from './UseWishlistGuest.gql'
19
- import { WishlistItemFragment } from '../../queries/WishlistItem.gql'
20
- import { filterNonNullableKeys } from '@graphcommerce/next-ui'
14
+ import { UseWishlistCustomerDocument } from './UseWishlistCustomer.gql'
15
+ import type { UseWishlistGuestQuery, UseWishlistGuestQueryVariables } from './UseWishlistGuest.gql'
16
+ import { UseWishlistGuestDocument } from './UseWishlistGuest.gql'
21
17
 
22
18
  export type UseWishlistItemsGuestReturn = {
23
19
  enabled: boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-wishlist",
3
- "version": "9.0.0-canary.99",
3
+ "version": "9.0.0",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -13,25 +13,25 @@
13
13
  }
14
14
  },
15
15
  "peerDependencies": {
16
- "@graphcommerce/ecommerce-ui": "^9.0.0-canary.99",
17
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.99",
18
- "@graphcommerce/graphql": "^9.0.0-canary.99",
19
- "@graphcommerce/graphql-mesh": "^9.0.0-canary.99",
20
- "@graphcommerce/image": "^9.0.0-canary.99",
21
- "@graphcommerce/magento-cart": "^9.0.0-canary.99",
22
- "@graphcommerce/magento-customer": "^9.0.0-canary.99",
23
- "@graphcommerce/magento-product": "^9.0.0-canary.99",
24
- "@graphcommerce/magento-product-configurable": "^9.0.0-canary.99",
25
- "@graphcommerce/magento-store": "^9.0.0-canary.99",
26
- "@graphcommerce/next-config": "^9.0.0-canary.99",
27
- "@graphcommerce/next-ui": "^9.0.0-canary.99",
28
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.99",
29
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.99",
16
+ "@graphcommerce/ecommerce-ui": "^9.0.0",
17
+ "@graphcommerce/eslint-config-pwa": "^9.0.0",
18
+ "@graphcommerce/graphql": "^9.0.0",
19
+ "@graphcommerce/graphql-mesh": "^9.0.0",
20
+ "@graphcommerce/image": "^9.0.0",
21
+ "@graphcommerce/magento-cart": "^9.0.0",
22
+ "@graphcommerce/magento-customer": "^9.0.0",
23
+ "@graphcommerce/magento-product": "^9.0.0",
24
+ "@graphcommerce/magento-product-configurable": "^9.0.0",
25
+ "@graphcommerce/magento-store": "^9.0.0",
26
+ "@graphcommerce/next-config": "^9.0.0",
27
+ "@graphcommerce/next-ui": "^9.0.0",
28
+ "@graphcommerce/prettier-config-pwa": "^9.0.0",
29
+ "@graphcommerce/typescript-config-pwa": "^9.0.0",
30
30
  "@lingui/core": "^4.2.1",
31
31
  "@lingui/macro": "^4.2.1",
32
32
  "@lingui/react": "^4.2.1",
33
33
  "@mui/material": "^5.10.16",
34
- "framer-motion": "^10.0.0",
34
+ "framer-motion": "^11.0.0",
35
35
  "next": "*",
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0"
@@ -8,7 +8,7 @@ export const config: PluginConfig = {
8
8
  module: '@graphcommerce/magento-wishlist',
9
9
  }
10
10
 
11
- export const WishlistItemActionCard = (props: PluginProps<WishlistItemActionCardProps>) => {
11
+ export function WishlistItemActionCard(props: PluginProps<WishlistItemActionCardProps>) {
12
12
  const { Prev, details, item } = props
13
13
  if (item.__typename !== 'ConfigurableWishlistItem') return <Prev {...props} />
14
14
  const { configurable_options } = item
@@ -1,9 +1,7 @@
1
1
  import { useCustomerSession } from '@graphcommerce/magento-customer'
2
- import {
3
- useFormAddProductsToCart,
4
- AddProductsToCartFormProps,
5
- } from '@graphcommerce/magento-product'
6
- import { InputMaybe, PluginConfig, PluginProps } from '@graphcommerce/next-config'
2
+ import type { AddProductsToCartFormProps } from '@graphcommerce/magento-product'
3
+ import { useFormAddProductsToCart } from '@graphcommerce/magento-product'
4
+ import type { InputMaybe, PluginConfig, PluginProps } from '@graphcommerce/next-config'
7
5
  import { useRouter } from 'next/router'
8
6
  import { useEffect, useState } from 'react'
9
7
  import { useWishlistItems } from '../hooks'
@@ -42,7 +40,7 @@ function WishlistUrlHandler() {
42
40
  ) || []
43
41
  : []
44
42
 
45
- setValue(`cartItems.0.selected_options`, wishlistItemOptions)
43
+ setValue('cartItems.0.selected_options', wishlistItemOptions)
46
44
  setWishlistItemId(router.query.wishlistItemId as string)
47
45
  setIsInitialLoad(false)
48
46
  }, [
@@ -1,8 +0,0 @@
1
- import { ProductWishlistIconButton, ProductWishlistChipProps } from './ProductWishlistIconButton'
2
-
3
- /**
4
- * @deprecated
5
- */
6
- export function ProductWishlistChipDetailConfigurable(props: ProductWishlistChipProps) {
7
- return <ProductWishlistIconButton sx={{ boxShadow: 6 }} {...props} />
8
- }