@scayle/storefront-product-listing 1.0.0 → 1.1.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.
- package/dist/module.json +1 -1
- package/dist/runtime/composables/useFiltersForListing.d.ts +2 -2
- package/dist/runtime/composables/useFiltersForListing.js +10 -7
- package/dist/runtime/composables/useProductsForListing.d.ts +2 -2
- package/dist/runtime/composables/useProductsForListing.js +7 -7
- package/package.json +3 -3
package/dist/module.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type FetchFiltersParams } from '@scayle/storefront-nuxt';
|
|
2
2
|
import { useFilters } from '@scayle/storefront-nuxt/composables';
|
|
3
|
-
import { type ComputedRef, type
|
|
3
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
4
4
|
import type { FilterItemWithValues } from '@scayle/storefront-api';
|
|
5
5
|
export type FiltersForListingOptions = Partial<{
|
|
6
|
-
params:
|
|
6
|
+
params: Ref<Omit<FetchFiltersParams, 'category'>>;
|
|
7
7
|
fetchingOptions: Partial<{
|
|
8
8
|
lazy: boolean;
|
|
9
9
|
immediate: boolean;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { extendPromise } from "@scayle/storefront-nuxt";
|
|
2
2
|
import { useFilters } from "@scayle/storefront-nuxt/composables";
|
|
3
|
-
import { computed,
|
|
3
|
+
import { computed, ref } from "vue";
|
|
4
4
|
export function useFiltersForListing({
|
|
5
|
-
params = {
|
|
5
|
+
params = ref({
|
|
6
6
|
includeSellableForFree: false,
|
|
7
7
|
includeSoldOut: false
|
|
8
|
-
},
|
|
8
|
+
}),
|
|
9
9
|
fetchingKey,
|
|
10
10
|
fetchingOptions
|
|
11
11
|
} = {}) {
|
|
12
|
-
const filterData = useFilters(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const filterData = useFilters(
|
|
13
|
+
{
|
|
14
|
+
params: params?.value,
|
|
15
|
+
options: fetchingOptions
|
|
16
|
+
},
|
|
17
|
+
fetchingKey ?? params?.value.categoryId ? `${params?.value.categoryId}-filters` : "search-filters"
|
|
18
|
+
);
|
|
16
19
|
const {
|
|
17
20
|
data,
|
|
18
21
|
refresh,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FetchProductsByCategoryParams, type Product } from '@scayle/storefront-nuxt';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
3
3
|
import { useProducts } from '@scayle/storefront-nuxt/composables';
|
|
4
4
|
import type { Pagination } from '@scayle/storefront-api';
|
|
5
5
|
export type UseProductsForListingReturn = Pick<Awaited<ReturnType<typeof useProducts>>, 'error' | 'status'> & {
|
|
@@ -12,7 +12,7 @@ export type UseProductsForListingReturn = Pick<Awaited<ReturnType<typeof useProd
|
|
|
12
12
|
paginationOffset: ComputedRef<number>;
|
|
13
13
|
};
|
|
14
14
|
export interface ProductsForListingOptions {
|
|
15
|
-
params:
|
|
15
|
+
params: Ref<Omit<FetchProductsByCategoryParams, 'category'>>;
|
|
16
16
|
fetchingOptions: Partial<{
|
|
17
17
|
lazy: boolean;
|
|
18
18
|
immediate: boolean;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
extendPromise
|
|
3
3
|
} from "@scayle/storefront-nuxt";
|
|
4
|
-
import { computed,
|
|
4
|
+
import { computed, ref } from "vue";
|
|
5
5
|
import { useProducts } from "@scayle/storefront-nuxt/composables";
|
|
6
6
|
export function useProductsForListing({
|
|
7
|
-
params = {
|
|
7
|
+
params = ref({
|
|
8
8
|
includeSoldOut: false,
|
|
9
9
|
includeSellableForFree: false,
|
|
10
10
|
pricePromotionKey: "",
|
|
11
11
|
sort: {}
|
|
12
|
-
},
|
|
12
|
+
}),
|
|
13
13
|
fetchingKey,
|
|
14
14
|
fetchingOptions
|
|
15
15
|
} = {}) {
|
|
@@ -19,11 +19,11 @@ export function useProductsForListing({
|
|
|
19
19
|
// as this logs the search term on every page request.
|
|
20
20
|
// Instead, we log the term only once, when the search is first performed.
|
|
21
21
|
// See: https://scayle.dev/en/developer-guide/products/search#scayle-search-analytics
|
|
22
|
-
trackSearchAnalyticsEvent: !!(
|
|
23
|
-
...
|
|
22
|
+
trackSearchAnalyticsEvent: !!(params.value.page === 1 && params.value?.where?.term),
|
|
23
|
+
...params.value
|
|
24
24
|
}),
|
|
25
25
|
options: fetchingOptions
|
|
26
|
-
}, fetchingKey || `${
|
|
26
|
+
}, fetchingKey || `${params.value.categoryId ?? 0}-products`);
|
|
27
27
|
const products = computed(() => {
|
|
28
28
|
return productsData.data.value?.products ?? [];
|
|
29
29
|
});
|
|
@@ -35,7 +35,7 @@ export function useProductsForListing({
|
|
|
35
35
|
});
|
|
36
36
|
const paginationOffset = computed(() => {
|
|
37
37
|
const page = pagination.value?.page ?? 1;
|
|
38
|
-
const perPage = pagination.value?.perPage ??
|
|
38
|
+
const perPage = pagination.value?.perPage ?? params.value.perPage ?? 0;
|
|
39
39
|
return (page - 1) * perPage;
|
|
40
40
|
});
|
|
41
41
|
return extendPromise(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"@nuxt/module-builder": "0.8.4",
|
|
57
57
|
"@nuxt/schema": "3.13.2",
|
|
58
58
|
"@nuxt/test-utils": "3.15.1",
|
|
59
|
-
"@scayle/eslint-config-storefront": "4.
|
|
59
|
+
"@scayle/eslint-config-storefront": "4.4.0",
|
|
60
60
|
"@scayle/storefront-nuxt": "8.1.3",
|
|
61
61
|
"@types/node": "22.10.2",
|
|
62
62
|
"@vue/test-utils": "2.4.6",
|
|
63
63
|
"@vueuse/core": "12.0.0",
|
|
64
64
|
"dprint": "0.47.6",
|
|
65
|
-
"eslint": "9.
|
|
65
|
+
"eslint": "9.17.0",
|
|
66
66
|
"happy-dom": "15.11.7",
|
|
67
67
|
"eslint-formatter-gitlab": "5.1.0",
|
|
68
68
|
"nuxt": "3.13.2",
|