@graphcommerce/magento-product-grouped 8.1.0-canary.8 → 9.0.0-canary.54

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,97 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.54
4
+
5
+ ## 8.1.0-canary.53
6
+
7
+ ## 8.1.0-canary.52
8
+
9
+ ## 8.1.0-canary.51
10
+
11
+ ## 8.1.0-canary.50
12
+
13
+ ## 8.1.0-canary.49
14
+
15
+ ## 8.1.0-canary.48
16
+
17
+ ## 8.1.0-canary.47
18
+
19
+ ## 8.1.0-canary.46
20
+
21
+ ## 8.1.0-canary.45
22
+
23
+ ## 8.1.0-canary.44
24
+
25
+ ## 8.1.0-canary.43
26
+
27
+ ## 8.1.0-canary.42
28
+
29
+ ## 8.1.0-canary.41
30
+
31
+ ## 8.1.0-canary.40
32
+
33
+ ## 8.1.0-canary.39
34
+
35
+ ## 8.1.0-canary.38
36
+
37
+ ## 8.1.0-canary.37
38
+
39
+ ## 8.1.0-canary.36
40
+
41
+ ## 8.1.0-canary.35
42
+
43
+ ## 8.1.0-canary.34
44
+
45
+ ## 8.1.0-canary.33
46
+
47
+ ## 8.1.0-canary.32
48
+
49
+ ## 8.1.0-canary.31
50
+
51
+ ## 8.1.0-canary.30
52
+
53
+ ## 8.1.0-canary.29
54
+
55
+ ## 8.1.0-canary.28
56
+
57
+ ## 8.1.0-canary.27
58
+
59
+ ## 8.1.0-canary.26
60
+
61
+ ## 8.1.0-canary.25
62
+
63
+ ## 8.1.0-canary.24
64
+
65
+ ## 8.1.0-canary.23
66
+
67
+ ## 8.1.0-canary.22
68
+
69
+ ## 8.1.0-canary.21
70
+
71
+ ## 8.1.0-canary.20
72
+
73
+ ## 8.1.0-canary.19
74
+
75
+ ## 8.1.0-canary.18
76
+
77
+ ## 8.1.0-canary.17
78
+
79
+ ## 8.1.0-canary.16
80
+
81
+ ## 8.1.0-canary.15
82
+
83
+ ## 8.1.0-canary.14
84
+
85
+ ## 8.1.0-canary.13
86
+
87
+ ## 8.1.0-canary.12
88
+
89
+ ## 8.1.0-canary.11
90
+
91
+ ## 8.1.0-canary.10
92
+
93
+ ## 8.1.0-canary.9
94
+
3
95
  ## 8.1.0-canary.8
4
96
 
5
97
  ## 8.1.0-canary.7
@@ -0,0 +1,11 @@
1
+ fragment GroupedProduct on GroupedProduct {
2
+ items {
3
+ position
4
+ qty
5
+ product {
6
+ uid
7
+ __typename
8
+ ...ProductListItem
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,166 @@
1
+ import { NumberFieldElement } from '@graphcommerce/ecommerce-ui'
2
+ import { Image } from '@graphcommerce/image'
3
+ import { ProductPageItemFragment } from '@graphcommerce/magento-product/Api/ProductPageItem.gql'
4
+ import {
5
+ AddToCartItemSelector,
6
+ useFormAddProductsToCart,
7
+ } from '@graphcommerce/magento-product/components'
8
+ import { Money } from '@graphcommerce/magento-store'
9
+ import {
10
+ ActionCard,
11
+ ActionCardProps,
12
+ actionCardImageSizes,
13
+ responsiveVal,
14
+ } from '@graphcommerce/next-ui'
15
+ import { Box, Link } from '@mui/material'
16
+
17
+ export type GroupedProductActionCardProps = ProductPageItemFragment &
18
+ Omit<ActionCardProps, 'value' | 'image' | 'price' | 'title' | 'action'> &
19
+ AddToCartItemSelector
20
+
21
+ const typographySizes = {
22
+ small: 'body2',
23
+ medium: 'body1',
24
+ large: 'subtitle1',
25
+ }
26
+
27
+ export function GroupedProductActionCard(props: GroupedProductActionCardProps) {
28
+ const {
29
+ uid,
30
+ name,
31
+ small_image,
32
+ price_range,
33
+ url_key,
34
+ sx = [],
35
+ size = 'large',
36
+ index = 0,
37
+ sku,
38
+ url_rewrites,
39
+ ...rest
40
+ } = props
41
+
42
+ const { control, register } = useFormAddProductsToCart()
43
+ if (!sku) return null
44
+ const hasUrl = (url_rewrites ?? []).length > 0
45
+ return (
46
+ <>
47
+ <input type='hidden' {...register(`cartItems.${index}.sku`)} value={sku} />
48
+ <ActionCard
49
+ variant='default'
50
+ value={uid}
51
+ sx={[
52
+ (theme) => ({
53
+ '&.ActionCard-root': {
54
+ px: 0,
55
+ py: theme.spacings.xs,
56
+ },
57
+ '& .ActionCard-title': {
58
+ width: '100%',
59
+ },
60
+ '& .ActionCard-rootInner': {
61
+ justifyContent: 'space-between',
62
+ alignItems: 'stretch',
63
+ },
64
+ '&.sizeSmall': {
65
+ px: 0,
66
+ },
67
+ '& .ActionCard-end': {
68
+ justifyContent: 'space-between',
69
+ },
70
+ '& .ActionCard-action': {
71
+ pr: theme.spacings.xs,
72
+ },
73
+ '& .ActionCard-image': {
74
+ alignSelf: 'flex-start',
75
+ },
76
+ '& .ActionCard-secondaryAction': {
77
+ typography: typographySizes[size],
78
+ display: 'flex',
79
+ alignItems: 'center',
80
+ color: 'text.secondary',
81
+ gap: '10px',
82
+ justifyContent: 'start',
83
+ },
84
+ '& .ActionCard-price': {
85
+ typography: typographySizes[size],
86
+ pr: theme.spacings.xs,
87
+ mb: { xs: 0.5, sm: 0 },
88
+ },
89
+ }),
90
+ ...(Array.isArray(sx) ? sx : [sx]),
91
+ ]}
92
+ image={
93
+ small_image?.url && (
94
+ <Image
95
+ layout='fill'
96
+ src={small_image?.url}
97
+ sx={{
98
+ width: actionCardImageSizes[size],
99
+ height: actionCardImageSizes[size],
100
+ display: 'block',
101
+ borderRadius: 1,
102
+ objectFit: 'contain',
103
+ }}
104
+ sizes={actionCardImageSizes[size]}
105
+ />
106
+ )
107
+ }
108
+ title={
109
+ url_key && hasUrl ? (
110
+ <Link
111
+ href={url_key}
112
+ underline='hover'
113
+ sx={{
114
+ color: 'inherit',
115
+ flexWrap: 'nowrap',
116
+ maxWidth: 'max-content',
117
+ }}
118
+ >
119
+ {name}
120
+ </Link>
121
+ ) : (
122
+ name
123
+ )
124
+ }
125
+ secondaryAction={
126
+ <NumberFieldElement
127
+ size='small'
128
+ inputProps={{ min: 0 }}
129
+ defaultValue={1}
130
+ control={control}
131
+ sx={{
132
+ width: responsiveVal(80, 120),
133
+ mt: 2,
134
+ '& .MuiFormHelperText-root': {
135
+ margin: 1,
136
+ width: '100%',
137
+ },
138
+ }}
139
+ name={`cartItems.${index}.quantity`}
140
+ onMouseDown={(e) => e.stopPropagation()}
141
+ />
142
+ }
143
+ price={
144
+ <Box>
145
+ <Box>
146
+ <Money {...price_range.minimum_price.final_price} />
147
+ </Box>
148
+ {price_range.minimum_price.final_price.value !==
149
+ price_range.minimum_price.regular_price.value && (
150
+ <Box
151
+ component='span'
152
+ sx={{
153
+ textDecoration: 'line-through',
154
+ color: 'text.disabled',
155
+ }}
156
+ >
157
+ <Money {...price_range.minimum_price.regular_price} />
158
+ </Box>
159
+ )}
160
+ </Box>
161
+ }
162
+ {...rest}
163
+ />
164
+ </>
165
+ )
166
+ }
@@ -0,0 +1,30 @@
1
+ import { ActionCardLayout, filterNonNullableKeys } from '@graphcommerce/next-ui'
2
+ import { useMemo } from 'react'
3
+ import { ProductPageGroupedQueryFragment } from '../ProductPageGroupedQueryFragment.gql'
4
+ import { GroupedProductActionCard } from './GroupedProductActionCard'
5
+
6
+ type GroupedProductsProps = {
7
+ product: NonNullable<NonNullable<ProductPageGroupedQueryFragment['typeProducts']>['items']>[0]
8
+ }
9
+
10
+ export function GroupedProducts(props: GroupedProductsProps) {
11
+ const { product } = props
12
+ const productItems = useMemo(() => {
13
+ if (product?.__typename !== 'GroupedProduct') return null
14
+ const { items } = product
15
+ return filterNonNullableKeys(items, ['product']).map((item, i) => ({
16
+ ...item.product,
17
+ value: item.product.sku ?? '',
18
+ index: i,
19
+ }))
20
+ }, [product])
21
+ if (!productItems) return null
22
+
23
+ return (
24
+ <ActionCardLayout>
25
+ {productItems.map((item) => (
26
+ <GroupedProductActionCard {...item} key={item.value ?? ''} size='medium' />
27
+ ))}
28
+ </ActionCardLayout>
29
+ )
30
+ }
@@ -3,19 +3,7 @@ fragment ProductPageGroupedQueryFragment on Query {
3
3
  items {
4
4
  __typename
5
5
  uid
6
- ... on GroupedProduct {
7
- items {
8
- position
9
- qty
10
- product {
11
- uid
12
- __typename
13
- ...ProductListItem
14
- ...ProductListItemSimple
15
- ...ProductListItemVirtual
16
- }
17
- }
18
- }
6
+ ...GroupedProduct
19
7
  }
20
8
  }
21
9
  }
package/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './GroupedProductPage.gql'
2
2
  export * from './ProductListItemGrouped'
3
+ export * from './GroupedProducts/GroupedProducts'
4
+ export * from './GroupedProducts/GroupedProductActionCard'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product-grouped",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.1.0-canary.8",
5
+ "version": "9.0.0-canary.54",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,17 +12,22 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.8",
16
- "@graphcommerce/graphql": "^8.1.0-canary.8",
17
- "@graphcommerce/magento-cart": "^8.1.0-canary.8",
18
- "@graphcommerce/magento-product": "^8.1.0-canary.8",
19
- "@graphcommerce/magento-product-simple": "^8.1.0-canary.8",
20
- "@graphcommerce/magento-product-virtual": "^8.1.0-canary.8",
21
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.8",
22
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.8",
15
+ "@graphcommerce/ecommerce-ui": "^9.0.0-canary.54",
16
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.54",
17
+ "@graphcommerce/graphql": "^9.0.0-canary.54",
18
+ "@graphcommerce/image": "^9.0.0-canary.54",
19
+ "@graphcommerce/magento-cart": "^9.0.0-canary.54",
20
+ "@graphcommerce/magento-product": "^9.0.0-canary.54",
21
+ "@graphcommerce/magento-product-simple": "^9.0.0-canary.54",
22
+ "@graphcommerce/magento-product-virtual": "^9.0.0-canary.54",
23
+ "@graphcommerce/magento-store": "^9.0.0-canary.54",
24
+ "@graphcommerce/next-ui": "^9.0.0-canary.54",
25
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.54",
26
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.54",
23
27
  "@lingui/core": "^4.2.1",
24
28
  "@lingui/macro": "^4.2.1",
25
29
  "@lingui/react": "^4.2.1",
30
+ "@mui/material": "5.15.17 ",
26
31
  "next": "*",
27
32
  "react": "^18.2.0",
28
33
  "react-dom": "^18.2.0"