@scayle/storefront-product-listing 0.4.1 → 0.5.0
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.
|
@@ -6,7 +6,7 @@ export type ProductListFilterOptions = Partial<{
|
|
|
6
6
|
immediate: boolean;
|
|
7
7
|
keyPrefix: string;
|
|
8
8
|
}>;
|
|
9
|
-
export type UseProductListFilterReturn = Pick<Awaited<ReturnType<typeof useFilters>>, 'error' | 'status' | '
|
|
9
|
+
export type UseProductListFilterReturn = Pick<Awaited<ReturnType<typeof useFilters>>, 'error' | 'status' | 'refresh'> & {
|
|
10
10
|
availableFilters: ComputedRef<FilterItemWithValues[]>;
|
|
11
11
|
clearedPriceQuery: ComputedRef<LocationQuery | undefined>;
|
|
12
12
|
unfilteredCount: ComputedRef<number>;
|
|
@@ -16,13 +16,11 @@ export function useProductListFilter(route, currentCategoryId, options = {}) {
|
|
|
16
16
|
includeSellableForFree: true,
|
|
17
17
|
includeSoldOut: false
|
|
18
18
|
})),
|
|
19
|
-
options: { immediate }
|
|
20
|
-
|
|
21
|
-
});
|
|
19
|
+
options: { immediate }
|
|
20
|
+
}, `${toValue(currentCategoryId) ?? keyPrefix}-filters`);
|
|
22
21
|
const {
|
|
23
22
|
data,
|
|
24
|
-
|
|
25
|
-
fetching,
|
|
23
|
+
refresh,
|
|
26
24
|
status,
|
|
27
25
|
error
|
|
28
26
|
} = filterData;
|
|
@@ -47,9 +45,8 @@ export function useProductListFilter(route, currentCategoryId, options = {}) {
|
|
|
47
45
|
return getClearedPriceQuery(route);
|
|
48
46
|
});
|
|
49
47
|
return extendPromise(filterData.then(() => ({})), {
|
|
50
|
-
|
|
48
|
+
refresh,
|
|
51
49
|
status,
|
|
52
|
-
fetching,
|
|
53
50
|
error,
|
|
54
51
|
availableFilters,
|
|
55
52
|
unfilteredCount,
|
|
@@ -3,7 +3,7 @@ import { type MaybeRefOrGetter, type ComputedRef } from 'vue';
|
|
|
3
3
|
import { useProducts } from '@scayle/storefront-nuxt/composables';
|
|
4
4
|
import type { Pagination } from '@scayle/storefront-api';
|
|
5
5
|
import type { RouteLocationNormalizedLoadedGeneric } from 'vue-router';
|
|
6
|
-
export type UseProductsByCategoryReturn = Pick<Awaited<ReturnType<typeof useProducts>>, 'error' | '
|
|
6
|
+
export type UseProductsByCategoryReturn = Pick<Awaited<ReturnType<typeof useProducts>>, 'error' | 'status'> & {
|
|
7
7
|
products: ComputedRef<Product[]>;
|
|
8
8
|
pagination: ComputedRef<Pagination | undefined>;
|
|
9
9
|
totalProductsCount: ComputedRef<number>;
|
|
@@ -39,11 +39,15 @@ export function useProductsByCategory(categoryId, route, {
|
|
|
39
39
|
cacheKeyPrefix: cacheKeyPrefix || `PLP:${toValue(categoryId)}`
|
|
40
40
|
},
|
|
41
41
|
where: appliedFilter.value,
|
|
42
|
+
// NOTE: We don't want to include trackSearchAnalyticsEvent parameter when paginating,
|
|
43
|
+
// as this logs the search term on every page request.
|
|
44
|
+
// Instead, we log the term only once, when the search is first performed.
|
|
45
|
+
// See: https://scayle.dev/en/developer-guide/products/search#scayle-search-analytics
|
|
46
|
+
trackSearchAnalyticsEvent: !!(params?.page === 1 && appliedFilter.value.term),
|
|
42
47
|
...params
|
|
43
48
|
}),
|
|
44
|
-
key: fetchingKey || `${toValue(categoryId)}-products`,
|
|
45
49
|
options: fetchingOptions
|
|
46
|
-
});
|
|
50
|
+
}, fetchingKey || `${toValue(categoryId)}-products`);
|
|
47
51
|
const products = computed(() => {
|
|
48
52
|
return productsData.data.value?.products ?? [];
|
|
49
53
|
});
|
|
@@ -62,7 +66,7 @@ export function useProductsByCategory(categoryId, route, {
|
|
|
62
66
|
productsData.then(() => ({})),
|
|
63
67
|
{
|
|
64
68
|
error: productsData.error,
|
|
65
|
-
|
|
69
|
+
status: productsData.status,
|
|
66
70
|
products,
|
|
67
71
|
pagination,
|
|
68
72
|
totalProductsCount,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Collection of essential composables and utilities to work with product listing",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@nuxt/kit": "^3.13.0",
|
|
48
|
-
"@scayle/storefront-nuxt": "^7.93.0",
|
|
48
|
+
"@scayle/storefront-nuxt": "^7.93.0 || ^8.0.0",
|
|
49
49
|
"@vue/test-utils": "2.4.6",
|
|
50
|
-
"@vueuse/core": "
|
|
50
|
+
"@vueuse/core": "12.0.0",
|
|
51
51
|
"fishery": "2.2.2",
|
|
52
|
-
"vue-router": "4.
|
|
52
|
+
"vue-router": "4.5.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@nuxt/kit": "3.13.2",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"@nuxt/schema": "3.13.2",
|
|
58
58
|
"@nuxt/test-utils": "3.14.4",
|
|
59
59
|
"@scayle/eslint-config-storefront": "4.3.2",
|
|
60
|
-
"@scayle/storefront-nuxt": "
|
|
61
|
-
"@types/node": "22.
|
|
60
|
+
"@scayle/storefront-nuxt": "8.0.0",
|
|
61
|
+
"@types/node": "22.10.1",
|
|
62
62
|
"@vue/test-utils": "2.4.6",
|
|
63
|
-
"@vueuse/core": "
|
|
64
|
-
"dprint": "0.47.
|
|
65
|
-
"eslint": "9.
|
|
66
|
-
"happy-dom": "15.11.
|
|
63
|
+
"@vueuse/core": "12.0.0",
|
|
64
|
+
"dprint": "0.47.6",
|
|
65
|
+
"eslint": "9.16.0",
|
|
66
|
+
"happy-dom": "15.11.7",
|
|
67
67
|
"eslint-formatter-gitlab": "5.1.0",
|
|
68
68
|
"nuxt": "3.13.2",
|
|
69
69
|
"publint": "0.2.12",
|
|
70
70
|
"typescript": "5.6.3",
|
|
71
|
-
"vitest": "2.1.
|
|
71
|
+
"vitest": "2.1.8",
|
|
72
72
|
"schema-dts": "1.1.2",
|
|
73
|
-
"vue-router": "4.
|
|
73
|
+
"vue-router": "4.5.0",
|
|
74
74
|
"fishery": "2.2.2",
|
|
75
75
|
"vue-tsc": "2.1.10"
|
|
76
76
|
}
|