@graphcommerce/magento-product-grouped 8.1.0-canary.9 → 9.0.0-canary.101

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,189 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.101
4
+
5
+ ## 9.0.0-canary.100
6
+
7
+ ## 9.0.0-canary.99
8
+
9
+ ## 9.0.0-canary.98
10
+
11
+ ## 9.0.0-canary.97
12
+
13
+ ## 9.0.0-canary.96
14
+
15
+ ## 9.0.0-canary.95
16
+
17
+ ## 9.0.0-canary.94
18
+
19
+ ## 9.0.0-canary.93
20
+
21
+ ## 9.0.0-canary.92
22
+
23
+ ## 9.0.0-canary.91
24
+
25
+ ## 9.0.0-canary.90
26
+
27
+ ## 9.0.0-canary.89
28
+
29
+ ## 9.0.0-canary.88
30
+
31
+ ## 9.0.0-canary.87
32
+
33
+ ## 9.0.0-canary.86
34
+
35
+ ## 9.0.0-canary.85
36
+
37
+ ## 9.0.0-canary.84
38
+
39
+ ## 9.0.0-canary.83
40
+
41
+ ## 9.0.0-canary.82
42
+
43
+ ## 9.0.0-canary.81
44
+
45
+ ## 9.0.0-canary.80
46
+
47
+ ## 9.0.0-canary.79
48
+
49
+ ## 9.0.0-canary.78
50
+
51
+ ## 9.0.0-canary.77
52
+
53
+ ## 9.0.0-canary.76
54
+
55
+ ## 9.0.0-canary.75
56
+
57
+ ## 9.0.0-canary.74
58
+
59
+ ## 9.0.0-canary.73
60
+
61
+ ## 9.0.0-canary.72
62
+
63
+ ## 9.0.0-canary.71
64
+
65
+ ## 9.0.0-canary.70
66
+
67
+ ## 9.0.0-canary.69
68
+
69
+ ## 9.0.0-canary.68
70
+
71
+ ## 9.0.0-canary.67
72
+
73
+ ## 9.0.0-canary.66
74
+
75
+ ## 9.0.0-canary.65
76
+
77
+ ## 9.0.0-canary.64
78
+
79
+ ## 9.0.0-canary.63
80
+
81
+ ## 9.0.0-canary.62
82
+
83
+ ## 9.0.0-canary.61
84
+
85
+ ## 9.0.0-canary.60
86
+
87
+ ## 9.0.0-canary.59
88
+
89
+ ## 9.0.0-canary.58
90
+
91
+ ## 9.0.0-canary.57
92
+
93
+ ## 9.0.0-canary.56
94
+
95
+ ## 9.0.0-canary.55
96
+
97
+ ## 9.0.0-canary.54
98
+
99
+ ## 8.1.0-canary.53
100
+
101
+ ## 8.1.0-canary.52
102
+
103
+ ## 8.1.0-canary.51
104
+
105
+ ## 8.1.0-canary.50
106
+
107
+ ## 8.1.0-canary.49
108
+
109
+ ## 8.1.0-canary.48
110
+
111
+ ## 8.1.0-canary.47
112
+
113
+ ## 8.1.0-canary.46
114
+
115
+ ## 8.1.0-canary.45
116
+
117
+ ## 8.1.0-canary.44
118
+
119
+ ## 8.1.0-canary.43
120
+
121
+ ## 8.1.0-canary.42
122
+
123
+ ## 8.1.0-canary.41
124
+
125
+ ## 8.1.0-canary.40
126
+
127
+ ## 8.1.0-canary.39
128
+
129
+ ## 8.1.0-canary.38
130
+
131
+ ## 8.1.0-canary.37
132
+
133
+ ## 8.1.0-canary.36
134
+
135
+ ## 8.1.0-canary.35
136
+
137
+ ## 8.1.0-canary.34
138
+
139
+ ## 8.1.0-canary.33
140
+
141
+ ## 8.1.0-canary.32
142
+
143
+ ## 8.1.0-canary.31
144
+
145
+ ## 8.1.0-canary.30
146
+
147
+ ## 8.1.0-canary.29
148
+
149
+ ## 8.1.0-canary.28
150
+
151
+ ## 8.1.0-canary.27
152
+
153
+ ## 8.1.0-canary.26
154
+
155
+ ## 8.1.0-canary.25
156
+
157
+ ## 8.1.0-canary.24
158
+
159
+ ## 8.1.0-canary.23
160
+
161
+ ## 8.1.0-canary.22
162
+
163
+ ## 8.1.0-canary.21
164
+
165
+ ## 8.1.0-canary.20
166
+
167
+ ## 8.1.0-canary.19
168
+
169
+ ## 8.1.0-canary.18
170
+
171
+ ## 8.1.0-canary.17
172
+
173
+ ## 8.1.0-canary.16
174
+
175
+ ## 8.1.0-canary.15
176
+
177
+ ## 8.1.0-canary.14
178
+
179
+ ## 8.1.0-canary.13
180
+
181
+ ## 8.1.0-canary.12
182
+
183
+ ## 8.1.0-canary.11
184
+
185
+ ## 8.1.0-canary.10
186
+
3
187
  ## 8.1.0-canary.9
4
188
 
5
189
  ## 8.1.0-canary.8
@@ -1338,31 +1522,31 @@
1338
1522
  All occurences of `<Trans>` and `t` need to be replaced:
1339
1523
 
1340
1524
  ```tsx
1341
- import { Trans, t } from "@lingui/macro";
1525
+ import { Trans, t } from '@lingui/macro'
1342
1526
 
1343
1527
  function MyComponent() {
1344
- const foo = "bar";
1528
+ const foo = 'bar'
1345
1529
  return (
1346
1530
  <div aria-label={t`Account ${foo}`}>
1347
1531
  <Trans>My Translation {foo}</Trans>
1348
1532
  </div>
1349
- );
1533
+ )
1350
1534
  }
1351
1535
  ```
1352
1536
 
1353
1537
  Needs to be replaced with:
1354
1538
 
1355
1539
  ```tsx
1356
- import { Trans } from "@lingui/react";
1357
- import { i18n } from "@lingui/core";
1540
+ import { Trans } from '@lingui/react'
1541
+ import { i18n } from '@lingui/core'
1358
1542
 
1359
1543
  function MyComponent() {
1360
- const foo = "bar";
1544
+ const foo = 'bar'
1361
1545
  return (
1362
1546
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1363
- <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1547
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1364
1548
  </div>
1365
- );
1549
+ )
1366
1550
  }
1367
1551
  ```
1368
1552
 
@@ -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.9",
5
+ "version": "9.0.0-canary.101",
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.9",
16
- "@graphcommerce/graphql": "^8.1.0-canary.9",
17
- "@graphcommerce/magento-cart": "^8.1.0-canary.9",
18
- "@graphcommerce/magento-product": "^8.1.0-canary.9",
19
- "@graphcommerce/magento-product-simple": "^8.1.0-canary.9",
20
- "@graphcommerce/magento-product-virtual": "^8.1.0-canary.9",
21
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.9",
22
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.9",
15
+ "@graphcommerce/ecommerce-ui": "^9.0.0-canary.101",
16
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.101",
17
+ "@graphcommerce/graphql": "^9.0.0-canary.101",
18
+ "@graphcommerce/image": "^9.0.0-canary.101",
19
+ "@graphcommerce/magento-cart": "^9.0.0-canary.101",
20
+ "@graphcommerce/magento-product": "^9.0.0-canary.101",
21
+ "@graphcommerce/magento-product-simple": "^9.0.0-canary.101",
22
+ "@graphcommerce/magento-product-virtual": "^9.0.0-canary.101",
23
+ "@graphcommerce/magento-store": "^9.0.0-canary.101",
24
+ "@graphcommerce/next-ui": "^9.0.0-canary.101",
25
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.101",
26
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.101",
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.10.16",
26
31
  "next": "*",
27
32
  "react": "^18.2.0",
28
33
  "react-dom": "^18.2.0"