@graphcommerce/magento-cart-items 3.1.15 → 3.1.16

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.
@@ -4,13 +4,15 @@ fragment CartItem on CartItemInterface @injectable {
4
4
  product {
5
5
  uid
6
6
  ...ProductLink
7
+ sku
7
8
  name
8
9
  url_key
10
+ sku
9
11
  thumbnail {
10
- url
11
- label
12
+ ...ProductImage
12
13
  }
13
14
  }
15
+
14
16
  prices {
15
17
  discounts {
16
18
  amount {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1675](https://github.com/graphcommerce-org/graphcommerce/pull/1675) [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6) Thanks [@paales](https://github.com/paales)! - Added crosssel functionality
8
+
9
+ - Updated dependencies [[`9e630670f`](https://github.com/graphcommerce-org/graphcommerce/commit/9e630670ff6c952ab7b938d890b5509804985cf3), [`cf3518499`](https://github.com/graphcommerce-org/graphcommerce/commit/cf351849999ad6fe73ce2bb258098a7dd301d517), [`2e9fa5984`](https://github.com/graphcommerce-org/graphcommerce/commit/2e9fa5984a07ff14fc1b3a4f62189a26e8e3ecdd), [`adf13069a`](https://github.com/graphcommerce-org/graphcommerce/commit/adf13069af6460c960276b402237371c12fc6dec), [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6), [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd), [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5)]:
10
+ - @graphcommerce/next-ui@4.28.1
11
+ - @graphcommerce/graphql@3.5.0
12
+ - @graphcommerce/magento-cart@4.9.0
13
+ - @graphcommerce/magento-customer@4.12.0
14
+ - @graphcommerce/magento-product@4.7.3
15
+ - @graphcommerce/magento-store@4.3.2
16
+ - @graphcommerce/image@3.1.10
17
+
3
18
  ## 3.1.15
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,64 @@
1
+ import { Image } from '@graphcommerce/image'
2
+ import { Money } from '@graphcommerce/magento-store'
3
+ import { ActionCard, ActionCardProps, responsiveVal } from '@graphcommerce/next-ui'
4
+ import { CartItemFragment } from '../../Api/CartItem.gql'
5
+ import { RemoveItemFromCartFab } from '../../RemoveItemFromCart/RemoveItemFromCartFab'
6
+ import { UpdateItemQuantity } from '../../UpdateItemQuantity/UpdateItemQuantity'
7
+
8
+ export type ActionCartItemProps = Omit<
9
+ ActionCardProps,
10
+ 'value' | 'image' | 'price' | 'title' | 'action'
11
+ >
12
+
13
+ export const productImageSizes = {
14
+ small: responsiveVal(50, 60),
15
+ medium: responsiveVal(60, 80),
16
+ large: responsiveVal(80, 100),
17
+ }
18
+
19
+ export function ActionCartItem(props: CartItemFragment & ActionCartItemProps) {
20
+ const {
21
+ uid,
22
+ quantity,
23
+ prices,
24
+ product: { name, thumbnail },
25
+ sx = [],
26
+ details,
27
+ size = 'medium',
28
+ ...cardProps
29
+ } = props
30
+
31
+ return (
32
+ <ActionCard
33
+ {...cardProps}
34
+ value={uid}
35
+ size={size}
36
+ sx={[{}, ...(Array.isArray(sx) ? sx : [sx])]}
37
+ image={
38
+ thumbnail?.url && (
39
+ <Image
40
+ src={thumbnail?.url}
41
+ width={50}
42
+ height={50}
43
+ sx={{
44
+ width: productImageSizes[size],
45
+ height: productImageSizes[size],
46
+ display: 'block',
47
+ borderRadius: 1,
48
+ }}
49
+ sizes={productImageSizes[size]}
50
+ />
51
+ )
52
+ }
53
+ price={<Money {...prices?.row_total_including_tax} />}
54
+ title={name}
55
+ details={
56
+ <>
57
+ {details}
58
+ <UpdateItemQuantity uid={uid} quantity={quantity} />
59
+ </>
60
+ }
61
+ action={<RemoveItemFromCartFab uid={uid} />}
62
+ />
63
+ )
64
+ }
@@ -0,0 +1,16 @@
1
+ fragment SelectedCustomizableOption on SelectedCustomizableOption {
2
+ customizable_option_uid
3
+ is_required
4
+ label
5
+ type
6
+ values {
7
+ customizable_option_value_uid
8
+ label
9
+ price {
10
+ type
11
+ units
12
+ value
13
+ }
14
+ value
15
+ }
16
+ }
@@ -0,0 +1,36 @@
1
+ import { Money } from '@graphcommerce/magento-store'
2
+ import { filterNonNullableKeys, nonNullable } from '@graphcommerce/next-ui'
3
+ import { Typography } from '@mui/material'
4
+ import { CartItem_ConfigurableCartItem_Fragment } from '../../Api/CartItem.gql'
5
+ import { ActionCartItemProps } from '../ActionCartItem/ActionCartItem'
6
+ import { SelectedCustomizableOptionFragment } from './SelectedCustomizableOption.gql'
7
+
8
+ type ConfigurableActionCartItemProps = {
9
+ customizable_options?: (SelectedCustomizableOptionFragment | null | undefined)[] | null
10
+ }
11
+
12
+ export function SelectedCustomizableOptions(props: ConfigurableActionCartItemProps) {
13
+ const { customizable_options } = props
14
+
15
+ const options = filterNonNullableKeys(customizable_options, [])
16
+
17
+ if (!options.length) return null
18
+
19
+ return (
20
+ <>
21
+ {options.map((option) => (
22
+ <Typography variant='body2' component='div' key={option.customizable_option_uid}>
23
+ <Typography variant='subtitle2' component='span'>
24
+ {option.label}
25
+ </Typography>
26
+ {option.values.filter(nonNullable).map((value) => (
27
+ <span key={value.customizable_option_value_uid}>
28
+ {value.price.value > 0 && <Money value={value.price.value} />} {value?.label}
29
+ {value?.value}
30
+ </span>
31
+ ))}
32
+ </Typography>
33
+ ))}
34
+ </>
35
+ )
36
+ }
@@ -0,0 +1,2 @@
1
+ export * from './SelectedCustomizableOption.gql'
2
+ export * from './SelectedCustomizableOptions'
package/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export * from './Api/CartItem.gql'
2
2
  export * from './Api/CartItems.gql'
3
-
4
3
  export * from './CartItem/CartItem'
5
- export * from './CartItem/CartItemOptionDropdown'
6
4
  export * from './CartItems/CartItems'
5
+ export * from './components/ActionCartItem/ActionCartItem'
6
+ export * from './components/SelectedCustomizableOptions/SelectedCustomizableOptions'
7
7
  export * from './DeliveryLabel/DeliveryLabel'
8
8
  export * from './RemoveItemFromCart/RemoveItemFromCartFab'
9
9
  export * from './UpdateItemQuantity/UpdateItemQuantity'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart-items",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "3.1.15",
5
+ "version": "3.1.16",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,13 +18,13 @@
18
18
  "@playwright/test": "^1.21.1"
19
19
  },
20
20
  "dependencies": {
21
- "@graphcommerce/graphql": "3.4.8",
22
- "@graphcommerce/image": "3.1.9",
23
- "@graphcommerce/magento-cart": "4.8.7",
24
- "@graphcommerce/magento-customer": "4.11.7",
25
- "@graphcommerce/magento-product": "4.7.2",
26
- "@graphcommerce/magento-store": "4.3.1",
27
- "@graphcommerce/next-ui": "4.28.0",
21
+ "@graphcommerce/graphql": "3.5.0",
22
+ "@graphcommerce/image": "3.1.10",
23
+ "@graphcommerce/magento-cart": "4.9.0",
24
+ "@graphcommerce/magento-customer": "4.12.0",
25
+ "@graphcommerce/magento-product": "4.7.3",
26
+ "@graphcommerce/magento-store": "4.3.2",
27
+ "@graphcommerce/next-ui": "4.28.1",
28
28
  "@graphcommerce/react-hook-form": "3.3.5"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,58 +0,0 @@
1
- import { extendableComponent } from '@graphcommerce/next-ui'
2
- import { Box, MenuItem, Select, SelectProps, SxProps, Theme } from '@mui/material'
3
-
4
- export type CartItemOptionDropdownProps = {
5
- label: string
6
- sx?: SxProps<Theme>
7
- } & Pick<SelectProps, 'onChange'>
8
-
9
- const compName = 'CartItem' as const
10
- const parts = ['root', 'label', 'select'] as const
11
- const { classes } = extendableComponent(compName, parts)
12
-
13
- export function CartItemOptionDropdown(props: CartItemOptionDropdownProps) {
14
- const { onChange, label, sx = [] } = props
15
-
16
- return (
17
- <Box
18
- className={classes.root}
19
- sx={[(theme) => ({ marginRight: theme.spacings.xs }), ...(Array.isArray(sx) ? sx : [sx])]}
20
- >
21
- <Box
22
- className={classes.label}
23
- sx={(theme) => ({
24
- letterSpacing: 1,
25
- textTransform: 'uppercase',
26
- fontWeight: 500,
27
- color: theme.palette.text.disabled,
28
- })}
29
- >
30
- {label}
31
- </Box>
32
- <Select
33
- value={1}
34
- onChange={onChange}
35
- className={classes.select}
36
- sx={(theme) => ({
37
- padding: `${theme.spacings.xxs} ${theme.spacings.xxs}`,
38
- border: `1px solid ${theme.palette.divider}`,
39
- borderRadius: '8px',
40
- minWidth: 120,
41
- '&:before': {
42
- borderBottom: 'none',
43
- },
44
- '&:hover, &:active, &:focus': {
45
- '&:before': {
46
- borderBottom: 'none',
47
- },
48
- background: theme.palette.grey['100'],
49
- },
50
- })}
51
- >
52
- <MenuItem value={1}>One</MenuItem>
53
- <MenuItem value={2}>Two</MenuItem>
54
- <MenuItem value={3}>Three</MenuItem>
55
- </Select>
56
- </Box>
57
- )
58
- }