@graphcommerce/magento-product 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/Api/ProductListItem.graphql +1 -2
- package/Api/ProductPageItem.graphql +1 -1
- package/CHANGELOG.md +278 -84
- package/Config.graphqls +13 -0
- package/components/AddProductsToCart/AddProductsToCartButton.tsx +17 -4
- package/components/AddProductsToCart/AddProductsToCartFab.tsx +7 -2
- package/components/AddProductsToCart/AddProductsToCartForm.tsx +31 -29
- package/components/AddProductsToCart/AddProductsToCartSnackbar.tsx +14 -63
- package/components/AddProductsToCart/AddProductsToCartSnackbarMessage.tsx +84 -0
- package/components/AddProductsToCart/UseAddProductsToCartAction.graphql +1 -1
- package/components/AddProductsToCart/findAddedItems.ts +1 -4
- package/components/AddProductsToCart/index.ts +1 -0
- package/components/AddProductsToCart/useAddProductsToCartAction.ts +2 -1
- package/components/AddProductsToCart/useFormAddProductsToCart.ts +1 -2
- package/components/JsonLdProduct/JsonLdProduct.graphql +1 -1
- package/components/JsonLdProduct/ProductPageJsonLd.tsx +1 -1
- package/components/ProductAddToCart/ProductAddToCart.tsx +6 -8
- package/components/ProductCustomizable/CustomizableCheckboxOption.tsx +3 -4
- package/components/ProductCustomizable/CustomizableMultipleOption.tsx +2 -2
- package/components/ProductCustomizable/CustomizableRadioOption.tsx +2 -2
- package/components/ProductCustomizable/ProductCustomizable.graphql +1 -1
- package/components/ProductCustomizable/index.ts +1 -0
- package/components/ProductCustomizable/productCustomizableSelectors.ts +59 -0
- package/components/ProductFiltersPro/PriceSlider.tsx +1 -2
- package/components/ProductFiltersPro/ProductFilterEqualChip.tsx +4 -5
- package/components/ProductFiltersPro/ProductFilterEqualSection.tsx +6 -7
- package/components/ProductFiltersPro/ProductFilterRangeChip.tsx +1 -1
- package/components/ProductFiltersPro/ProductFilterRangeSection.tsx +1 -1
- package/components/ProductFiltersPro/ProductFiltersPro.tsx +103 -19
- package/components/ProductFiltersPro/ProductFiltersProAggregations.tsx +41 -20
- package/components/ProductFiltersPro/ProductFiltersProAllFiltersChip.tsx +6 -10
- package/components/ProductFiltersPro/ProductFiltersProAllFiltersSidebar.tsx +18 -8
- package/components/ProductFiltersPro/ProductFiltersProCategorySection.tsx +130 -0
- package/components/ProductFiltersPro/ProductFiltersProChips.tsx +10 -8
- package/components/ProductFiltersPro/ProductFiltersProClearAll.tsx +4 -16
- package/components/ProductFiltersPro/ProductFiltersProLayoutSidebar.tsx +15 -7
- package/components/ProductFiltersPro/ProductFiltersProLimitChip.tsx +2 -8
- package/components/ProductFiltersPro/ProductFiltersProLimitSection.tsx +7 -10
- package/components/ProductFiltersPro/ProductFiltersProNoResults.tsx +79 -0
- package/components/ProductFiltersPro/ProductFiltersProSortChip.tsx +5 -7
- package/components/ProductFiltersPro/ProductFiltersProSortDirectionArrow.tsx +2 -4
- package/components/ProductFiltersPro/ProductFiltersProSortSection.tsx +11 -3
- package/components/ProductFiltersPro/activeAggregations.ts +5 -9
- package/components/ProductFiltersPro/applyAggregationCount.ts +14 -8
- package/components/ProductFiltersPro/index.ts +9 -0
- package/components/ProductFiltersPro/{useClearAllFiltersHandler.ts → useProductFiltersProClearAllAction.ts} +1 -1
- package/components/ProductFiltersPro/useProductFiltersProHasFiltersApplied.ts +21 -0
- package/components/ProductFiltersPro/useProductFiltersProSort.tsx +7 -3
- package/components/ProductList/ProductList.graphql +8 -5
- package/components/ProductListCount/ProductListCount.tsx +3 -1
- package/components/ProductListFilters/ProductFilters.graphql +11 -2
- package/components/ProductListFilters/ProductListFilters.graphql +1 -1
- package/components/ProductListFilters/ProductListFilters.tsx +13 -19
- package/components/ProductListFiltersContainer/ProductListFiltersContainer.tsx +2 -4
- package/components/ProductListItem/ProductDiscountLabel.tsx +2 -3
- package/components/ProductListItem/ProductListItem.tsx +3 -3
- package/components/ProductListItem/ProductListItemTitleAndPrice.tsx +18 -15
- package/components/ProductListItems/ProductFilterTypes.graphql +8 -0
- package/components/ProductListItems/ProductListItemsBase.tsx +71 -30
- package/components/ProductListItems/filterTypes.tsx +14 -7
- package/components/ProductListItems/filteredProductList.tsx +44 -17
- package/components/ProductListItems/getFilterTypes.ts +33 -4
- package/components/ProductListItems/productListApplyCategoryDefaults.ts +50 -4
- package/components/ProductListItems/renderer.tsx +8 -2
- package/components/ProductListPagination/ProductListPagination.tsx +39 -20
- package/components/ProductListPrice/ProductListPrice.tsx +9 -4
- package/components/ProductListSuggestions/ProductListSuggestions.graphql +5 -0
- package/components/ProductListSuggestions/ProductListSuggestions.tsx +42 -0
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.graphql +3 -0
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.tsx +3 -0
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumbs.tsx +40 -0
- package/components/ProductPageBreadcrumb/index.ts +1 -0
- package/components/ProductPageDescription/ComplexTextValue.graphql +1 -1
- package/components/ProductPageDescription/ProductPageDescription.tsx +1 -1
- package/components/ProductPageGallery/ProductImage.graphql +1 -0
- package/components/ProductPageGallery/ProductPageGallery.tsx +14 -8
- package/components/ProductPagePrice/ProductPagePrice.graphql +0 -6
- package/components/ProductPagePrice/ProductPagePrice.tsx +19 -12
- package/components/ProductPagePrice/ProductPagePriceTiers.tsx +4 -3
- package/components/ProductPagePrice/useCustomizableOptionPrice.ts +11 -53
- package/components/ProductShortDescription/ProductShortDescription.tsx +2 -0
- package/components/ProductSpecs/ProductSpecs.graphql +21 -1
- package/components/ProductSpecs/ProductSpecs.tsx +5 -11
- package/components/ProductSpecs/ProductSpecsAggregations.tsx +34 -0
- package/components/ProductSpecs/ProductSpecsCustomAttributes.tsx +45 -0
- package/components/ProductSpecs/ProductSpecsTypes.graphql +8 -0
- package/components/ProductStaticPaths/getProductStaticPaths.ts +1 -1
- package/components/ProductWeight/ProductWeight.tsx +12 -9
- package/components/index.ts +2 -0
- package/hooks/useProductLink.ts +4 -0
- package/hooks/useProductList.ts +148 -0
- package/hooks/useProductListLink.ts +6 -3
- package/index.ts +1 -0
- package/package.json +14 -14
@@ -0,0 +1,148 @@
|
|
1
|
+
import { debounce } from '@graphcommerce/ecommerce-ui'
|
2
|
+
import {
|
3
|
+
ApolloClient,
|
4
|
+
useQuery,
|
5
|
+
useInContextQuery,
|
6
|
+
getInContextInput,
|
7
|
+
} from '@graphcommerce/graphql'
|
8
|
+
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
9
|
+
import { showPageLoadIndicator } from '@graphcommerce/next-ui'
|
10
|
+
import { useEventCallback } from '@mui/material'
|
11
|
+
import {
|
12
|
+
FilterFormProviderProps,
|
13
|
+
ProductFiltersDocument,
|
14
|
+
ProductFiltersQuery,
|
15
|
+
ProductFiltersQueryVariables,
|
16
|
+
} from '../components'
|
17
|
+
import {
|
18
|
+
ProductListDocument,
|
19
|
+
ProductListQuery,
|
20
|
+
ProductListQueryVariables,
|
21
|
+
} from '../components/ProductList/ProductList.gql'
|
22
|
+
import { CategoryDefaultFragment } from '../components/ProductListItems/CategoryDefault.gql'
|
23
|
+
import { ProductListParams, toProductListParams } from '../components/ProductListItems/filterTypes'
|
24
|
+
import { useRouterFilterParams } from '../components/ProductListItems/filteredProductList'
|
25
|
+
import {
|
26
|
+
productListApplyCategoryDefaults,
|
27
|
+
categoryDefaultsToProductListFilters,
|
28
|
+
useProductListApplyCategoryDefaults,
|
29
|
+
} from '../components/ProductListItems/productListApplyCategoryDefaults'
|
30
|
+
|
31
|
+
const productListQueries: Array<Promise<any>> = []
|
32
|
+
|
33
|
+
type Next = Parameters<NonNullable<FilterFormProviderProps['handleSubmit']>>[1]
|
34
|
+
|
35
|
+
export const prefetchProductList = debounce(
|
36
|
+
async (
|
37
|
+
variables: ProductListQueryVariables,
|
38
|
+
filtersVariables: ProductFiltersQueryVariables,
|
39
|
+
next: Next,
|
40
|
+
client: ApolloClient<any>,
|
41
|
+
shallow: boolean,
|
42
|
+
) => {
|
43
|
+
if (!shallow) return next(shallow)
|
44
|
+
|
45
|
+
showPageLoadIndicator.set(true)
|
46
|
+
|
47
|
+
const context = getInContextInput(client)
|
48
|
+
const productList = client.query({
|
49
|
+
query: ProductListDocument,
|
50
|
+
variables: { ...variables, context },
|
51
|
+
})
|
52
|
+
|
53
|
+
// const productFilters = client.query({
|
54
|
+
// query: ProductFiltersDocument,
|
55
|
+
// variables: {
|
56
|
+
// ...filtersVariables,
|
57
|
+
// context,
|
58
|
+
// },
|
59
|
+
// })
|
60
|
+
|
61
|
+
const both = Promise.all([productList])
|
62
|
+
|
63
|
+
// Push the query to the queue array.
|
64
|
+
productListQueries.push(both)
|
65
|
+
|
66
|
+
// Since we're waiting here the form will be submitting for longer.
|
67
|
+
await both
|
68
|
+
|
69
|
+
const includes = productListQueries.includes(both)
|
70
|
+
|
71
|
+
// Remove all requests that are before the current request
|
72
|
+
const index = productListQueries.indexOf(both)
|
73
|
+
if (index > -1) {
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
75
|
+
productListQueries.splice(0, index + 1)
|
76
|
+
}
|
77
|
+
|
78
|
+
if (productListQueries.length === 0) showPageLoadIndicator.set(false)
|
79
|
+
|
80
|
+
if (includes) {
|
81
|
+
// todo: When navigating a category, it should now be a shallow route
|
82
|
+
|
83
|
+
// If the resolved request is still in the array, it may be rendered (URL may be updated)
|
84
|
+
await next(shallow)
|
85
|
+
}
|
86
|
+
|
87
|
+
return undefined
|
88
|
+
},
|
89
|
+
200,
|
90
|
+
// the maxWait is now set to a somewhat shorter time than the average query time.
|
91
|
+
{ leading: true, maxWait: 700, trailing: true },
|
92
|
+
)
|
93
|
+
|
94
|
+
/**
|
95
|
+
* - Handles shallow routing requests
|
96
|
+
* - Handles customer specific product list queries
|
97
|
+
*/
|
98
|
+
export function useProductList<
|
99
|
+
T extends ProductListQuery &
|
100
|
+
ProductFiltersQuery & {
|
101
|
+
params?: ProductListParams
|
102
|
+
category?: CategoryDefaultFragment | null | undefined
|
103
|
+
},
|
104
|
+
>(props: T) {
|
105
|
+
const { category } = props
|
106
|
+
const { params, shallow } = useRouterFilterParams(props)
|
107
|
+
const variables = useProductListApplyCategoryDefaults(params, category)
|
108
|
+
|
109
|
+
const result = useInContextQuery(ProductListDocument, { variables, skip: !shallow }, props)
|
110
|
+
const filters = useInContextQuery(
|
111
|
+
ProductFiltersDocument,
|
112
|
+
{ variables: categoryDefaultsToProductListFilters(variables), skip: !shallow },
|
113
|
+
props,
|
114
|
+
)
|
115
|
+
|
116
|
+
const storeConfig = useQuery(StoreConfigDocument).data
|
117
|
+
|
118
|
+
const handleSubmit: NonNullable<FilterFormProviderProps['handleSubmit']> = useEventCallback(
|
119
|
+
async (formValues, next) => {
|
120
|
+
if (!storeConfig) return
|
121
|
+
|
122
|
+
const vars = await productListApplyCategoryDefaults(
|
123
|
+
toProductListParams(formValues),
|
124
|
+
storeConfig,
|
125
|
+
category,
|
126
|
+
)
|
127
|
+
|
128
|
+
const shallowNow =
|
129
|
+
JSON.stringify(vars.filters?.category_uid) === JSON.stringify(params?.filters.category_uid)
|
130
|
+
await prefetchProductList(
|
131
|
+
vars,
|
132
|
+
categoryDefaultsToProductListFilters(vars),
|
133
|
+
next,
|
134
|
+
result.client,
|
135
|
+
shallowNow,
|
136
|
+
)
|
137
|
+
},
|
138
|
+
)
|
139
|
+
|
140
|
+
return {
|
141
|
+
...props,
|
142
|
+
filters: filters.data.filters,
|
143
|
+
...result.data,
|
144
|
+
params,
|
145
|
+
mask: result.mask,
|
146
|
+
handleSubmit,
|
147
|
+
}
|
148
|
+
}
|
@@ -8,11 +8,14 @@ import {
|
|
8
8
|
} from '../components/ProductListItems/filterTypes'
|
9
9
|
|
10
10
|
export function productListLinkFromFilter(props: ProductFilterParams): string {
|
11
|
-
const { url, sort, dir, currentPage, pageSize, filters: incoming } = props
|
11
|
+
const { url, sort, dir, currentPage, pageSize, filters: incoming, search } = props
|
12
12
|
const isSearch = url.startsWith('search')
|
13
13
|
const filters = isSearch ? incoming : { ...incoming, category_uid: undefined }
|
14
14
|
const uid = incoming?.category_uid?.eq || incoming?.category_uid?.in?.[0]
|
15
15
|
|
16
|
+
let urlBase = url
|
17
|
+
if (isSearch) urlBase = search ? `search/${search}` : 'search'
|
18
|
+
|
16
19
|
// base url path generation
|
17
20
|
let paginateSort = ``
|
18
21
|
let query = ``
|
@@ -38,9 +41,9 @@ export function productListLinkFromFilter(props: ProductFilterParams): string {
|
|
38
41
|
|
39
42
|
// it's a category with filters, use the /c/ route.
|
40
43
|
if (query && !isSearch)
|
41
|
-
return `/c/${
|
44
|
+
return `/c/${urlBase}${paginateSort}/q${uid ? `/category_uid/${uid}` : ''}${query}`
|
42
45
|
|
43
|
-
return query ? `/${
|
46
|
+
return query ? `/${urlBase}${paginateSort}/q${query}` : `/${urlBase}${paginateSort}`
|
44
47
|
}
|
45
48
|
|
46
49
|
export function productListLink(props: ProductListParams): string {
|
package/index.ts
CHANGED
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": "
|
5
|
+
"version": "9.0.0-canary.101",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -15,21 +15,21 @@
|
|
15
15
|
"schema-dts": "^1.1.2"
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
|
-
"typescript": "5.
|
18
|
+
"typescript": "5.6.2"
|
19
19
|
},
|
20
20
|
"peerDependencies": {
|
21
|
-
"@graphcommerce/ecommerce-ui": "^
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^
|
23
|
-
"@graphcommerce/framer-next-pages": "^
|
24
|
-
"@graphcommerce/framer-scroller": "^
|
25
|
-
"@graphcommerce/graphql": "^
|
26
|
-
"@graphcommerce/graphql-mesh": "^
|
27
|
-
"@graphcommerce/image": "^
|
28
|
-
"@graphcommerce/magento-cart": "^
|
29
|
-
"@graphcommerce/magento-store": "^
|
30
|
-
"@graphcommerce/next-ui": "^
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^
|
21
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.101",
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.101",
|
23
|
+
"@graphcommerce/framer-next-pages": "^9.0.0-canary.101",
|
24
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.101",
|
25
|
+
"@graphcommerce/graphql": "^9.0.0-canary.101",
|
26
|
+
"@graphcommerce/graphql-mesh": "^9.0.0-canary.101",
|
27
|
+
"@graphcommerce/image": "^9.0.0-canary.101",
|
28
|
+
"@graphcommerce/magento-cart": "^9.0.0-canary.101",
|
29
|
+
"@graphcommerce/magento-store": "^9.0.0-canary.101",
|
30
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.101",
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.101",
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.101",
|
33
33
|
"@lingui/core": "^4.2.1",
|
34
34
|
"@lingui/macro": "^4.2.1",
|
35
35
|
"@lingui/react": "^4.2.1",
|