@graphcommerce/magento-product 11.0.0-canary.49 → 11.0.0-canary.52
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,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-canary.52
|
|
4
|
+
|
|
5
|
+
## 11.0.0-canary.51
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#2709](https://github.com/graphcommerce-org/graphcommerce/pull/2709) [`9c2a218`](https://github.com/graphcommerce-org/graphcommerce/commit/9c2a21881c446b78986865c6fec1a161824bf6f1) - `ProductFiltersPro` submits only when the filters differ from the current product list. The filter fields add empty filters to the form when they mount, so with `productFiltersLayout: 'SIDEBAR'` a direct load of `/shoes/page/2` or `/shoes?gclid=abc` went to `/shoes`. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
10
|
+
|
|
11
|
+
## 11.0.0-canary.50
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#2707](https://github.com/graphcommerce-org/graphcommerce/pull/2707) [`abcfce1`](https://github.com/graphcommerce-org/graphcommerce/commit/abcfce130beaf5544a6ceec794fdeb99e4b3e3ba) - **Breaking change:** configuration fields are server-only, unless their definition in `Config.graphqls` has `@public`. In the browser, `@graphcommerce/next-config/config` resolves to a file with only the `@public` fields, so secrets such as `previewSecret` and `hygraphSecret` stay out of the client JavaScript and its source maps. Turbopack stops the build on a browser import of a server-only field. See [docs/upgrading/graphcommerce-10-to-11.md](docs/upgrading/graphcommerce-10-to-11.md). ([@paales](https://github.com/paales))
|
|
16
|
+
|
|
3
17
|
## 11.0.0-canary.49
|
|
4
18
|
|
|
5
19
|
## 11.0.0-canary.48
|
package/Config.graphqls
CHANGED
|
@@ -12,14 +12,14 @@ extend input GraphCommerceConfig {
|
|
|
12
12
|
"""
|
|
13
13
|
Product filters with better UI for mobile and desktop.
|
|
14
14
|
"""
|
|
15
|
-
productFiltersPro: Boolean
|
|
15
|
+
productFiltersPro: Boolean @public
|
|
16
16
|
|
|
17
17
|
"""
|
|
18
18
|
Layout how the filters are rendered.
|
|
19
19
|
DEFAULT: Will be rendered as horzontal chips on desktop and mobile
|
|
20
20
|
SIDEBAR: Will be rendered as a sidebar on desktop and horizontal chips on mobile
|
|
21
21
|
"""
|
|
22
|
-
productFiltersLayout: ProductFiltersLayout = DEFAULT
|
|
22
|
+
productFiltersLayout: ProductFiltersLayout = DEFAULT @public
|
|
23
23
|
|
|
24
24
|
"""
|
|
25
25
|
By default we route products to /p/[url] but you can change this to /product/[url] if you wish.
|
|
@@ -27,21 +27,21 @@ extend input GraphCommerceConfig {
|
|
|
27
27
|
Default: '/p/'
|
|
28
28
|
Example: '/product/'
|
|
29
29
|
"""
|
|
30
|
-
productRoute: String
|
|
30
|
+
productRoute: String @public
|
|
31
31
|
|
|
32
32
|
"""
|
|
33
33
|
Determines if, after adding a cross-sell item to the cart, the user should be redirected to the cross-sell items of the product they just added.
|
|
34
34
|
|
|
35
35
|
Default: 'false'
|
|
36
36
|
"""
|
|
37
|
-
crossSellsRedirectItems: Boolean = false
|
|
37
|
+
crossSellsRedirectItems: Boolean = false @public
|
|
38
38
|
|
|
39
39
|
"""
|
|
40
40
|
Determines if cross sell items should be shown when the user already has the product in their cart. This will result in a product will popping off the screen when you add it to the cart.
|
|
41
41
|
|
|
42
42
|
Default: 'false'
|
|
43
43
|
"""
|
|
44
|
-
crossSellsHideCartItems: Boolean = false
|
|
44
|
+
crossSellsHideCartItems: Boolean = false @public
|
|
45
45
|
|
|
46
46
|
"""
|
|
47
47
|
Pagination variant for the product listings.
|
|
@@ -49,5 +49,5 @@ extend input GraphCommerceConfig {
|
|
|
49
49
|
COMPACT means: "< Page X of Y >"
|
|
50
50
|
EXTENDED means: "< 1 2 ... 4 [5] 6 ... 10 11 >"
|
|
51
51
|
"""
|
|
52
|
-
productListPaginationVariant: PaginationVariant = COMPACT
|
|
52
|
+
productListPaginationVariant: PaginationVariant = COMPACT @public
|
|
53
53
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ProductFiltersProContext } from '@graphcommerce/magento-product'
|
|
2
|
+
import { ProductFiltersPro, useProductFiltersPro } from '@graphcommerce/magento-product'
|
|
3
|
+
import { createTheme, ThemeProvider } from '@mui/material'
|
|
4
|
+
import { renderToString } from 'react-dom/server'
|
|
5
|
+
import { beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import type { ProductListParams } from '../ProductListItems/filterTypes'
|
|
7
|
+
|
|
8
|
+
const router = vi.hoisted(() => ({
|
|
9
|
+
asPath: '',
|
|
10
|
+
query: {},
|
|
11
|
+
push: vi.fn(async () => true),
|
|
12
|
+
replace: vi.fn(async () => true),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
vi.mock('next/router', () => ({ useRouter: () => router }))
|
|
16
|
+
|
|
17
|
+
const theme = { ...createTheme(), appShell: { headerHeightSm: '0px' } }
|
|
18
|
+
|
|
19
|
+
function renderFilters(params: Partial<ProductListParams>) {
|
|
20
|
+
let context: ProductFiltersProContext | undefined
|
|
21
|
+
|
|
22
|
+
function ReadContext() {
|
|
23
|
+
context = useProductFiltersPro()
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
renderToString(
|
|
28
|
+
<ThemeProvider theme={theme}>
|
|
29
|
+
<ProductFiltersPro
|
|
30
|
+
params={{ url: 'shoes', filters: {}, sort: {}, pageSize: null, search: null, ...params }}
|
|
31
|
+
aggregations={[]}
|
|
32
|
+
appliedAggregations={[]}
|
|
33
|
+
filterTypes={{}}
|
|
34
|
+
>
|
|
35
|
+
<ReadContext />
|
|
36
|
+
</ProductFiltersPro>
|
|
37
|
+
</ThemeProvider>,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return context as ProductFiltersProContext
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
router.push.mockClear()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('stays on the page of the list when the filter fields add empty filters', async () => {
|
|
48
|
+
router.asPath = '/shoes/page/2'
|
|
49
|
+
const { form, submit } = renderFilters({ currentPage: 2 })
|
|
50
|
+
|
|
51
|
+
form.setValue('filters.color', {})
|
|
52
|
+
await submit()
|
|
53
|
+
|
|
54
|
+
expect(router.push).not.toHaveBeenCalled()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('keeps the query string of the request when the filter fields add empty filters', async () => {
|
|
58
|
+
router.asPath = '/shoes?gclid=abc'
|
|
59
|
+
const { form, submit } = renderFilters({ currentPage: 1 })
|
|
60
|
+
|
|
61
|
+
form.setValue('filters.color', {})
|
|
62
|
+
await submit()
|
|
63
|
+
|
|
64
|
+
expect(router.push).not.toHaveBeenCalled()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('goes to the first page of the list for a changed filter', async () => {
|
|
68
|
+
router.asPath = '/shoes/page/2'
|
|
69
|
+
const { form, submit } = renderFilters({ currentPage: 2 })
|
|
70
|
+
|
|
71
|
+
form.setValue('filters.color', { in: ['red'] })
|
|
72
|
+
await submit()
|
|
73
|
+
|
|
74
|
+
expect(router.push).toHaveBeenCalledWith(
|
|
75
|
+
'/c/shoes/q/color/red',
|
|
76
|
+
'/c/shoes/q/color/red',
|
|
77
|
+
expect.anything(),
|
|
78
|
+
)
|
|
79
|
+
})
|
|
@@ -120,6 +120,10 @@ export function ProductFiltersPro(props: FilterFormProviderProps) {
|
|
|
120
120
|
|
|
121
121
|
const submit = useEventCallback(
|
|
122
122
|
form.handleSubmit(async (formValues) => {
|
|
123
|
+
// The filter fields add empty filters to the form when they mount.
|
|
124
|
+
if (productListLinkFromFilter(formValues) === productListLinkFromFilter(defaultValues))
|
|
125
|
+
return false
|
|
126
|
+
|
|
123
127
|
const path = productListLinkFromFilter({ ...formValues, currentPage: 1 })
|
|
124
128
|
if (router.asPath === path) return false
|
|
125
129
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-product",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "11.0.0-canary.
|
|
5
|
+
"version": "11.0.0-canary.52",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"typescript": "5.9.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@graphcommerce/ecommerce-ui": "^11.0.0-canary.
|
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-next-pages": "^11.0.0-canary.
|
|
24
|
-
"@graphcommerce/framer-scroller": "^11.0.0-canary.
|
|
25
|
-
"@graphcommerce/graphql": "^11.0.0-canary.
|
|
26
|
-
"@graphcommerce/graphql-mesh": "^11.0.0-canary.
|
|
27
|
-
"@graphcommerce/image": "^11.0.0-canary.
|
|
28
|
-
"@graphcommerce/magento-cart": "^11.0.0-canary.
|
|
29
|
-
"@graphcommerce/magento-store": "^11.0.0-canary.
|
|
30
|
-
"@graphcommerce/next-ui": "^11.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.
|
|
21
|
+
"@graphcommerce/ecommerce-ui": "^11.0.0-canary.52",
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.52",
|
|
23
|
+
"@graphcommerce/framer-next-pages": "^11.0.0-canary.52",
|
|
24
|
+
"@graphcommerce/framer-scroller": "^11.0.0-canary.52",
|
|
25
|
+
"@graphcommerce/graphql": "^11.0.0-canary.52",
|
|
26
|
+
"@graphcommerce/graphql-mesh": "^11.0.0-canary.52",
|
|
27
|
+
"@graphcommerce/image": "^11.0.0-canary.52",
|
|
28
|
+
"@graphcommerce/magento-cart": "^11.0.0-canary.52",
|
|
29
|
+
"@graphcommerce/magento-store": "^11.0.0-canary.52",
|
|
30
|
+
"@graphcommerce/next-ui": "^11.0.0-canary.52",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.52",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.52",
|
|
33
33
|
"@lingui/core": "^5",
|
|
34
34
|
"@lingui/macro": "^5",
|
|
35
35
|
"@lingui/react": "^5",
|