@scayle/storefront-product-listing 1.0.0 → 1.1.1

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 CHANGED
@@ -8,6 +8,6 @@
8
8
  },
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "0.8.4",
11
- "unbuild": "2.0.0"
11
+ "unbuild": "3.0.1"
12
12
  }
13
13
  }
@@ -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 MaybeRefOrGetter } from 'vue';
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: MaybeRefOrGetter<Omit<FetchFiltersParams, 'category'>>;
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, toValue } from "vue";
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
- params,
14
- options: fetchingOptions
15
- }, fetchingKey ?? `${toValue(params).categoryId}-filters`);
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 MaybeRefOrGetter, type ComputedRef } from 'vue';
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: MaybeRefOrGetter<Omit<FetchProductsByCategoryParams, 'category'>>;
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, toValue } from "vue";
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: !!(toValue(params).page === 1 && toValue(params)?.where?.term),
23
- ...toValue(params)
22
+ trackSearchAnalyticsEvent: !!(params.value.page === 1 && params.value?.where?.term),
23
+ ...params.value
24
24
  }),
25
25
  options: fetchingOptions
26
- }, fetchingKey || `${toValue(params).categoryId ?? 0}-products`);
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 ?? toValue(params).perPage ?? 0;
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.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Collection of essential composables and utilities to work with product listing",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -52,20 +52,20 @@
52
52
  "vue-router": "4.5.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@nuxt/kit": "3.13.2",
55
+ "@nuxt/kit": "3.14.1592",
56
56
  "@nuxt/module-builder": "0.8.4",
57
- "@nuxt/schema": "3.13.2",
57
+ "@nuxt/schema": "3.14.1592",
58
58
  "@nuxt/test-utils": "3.15.1",
59
- "@scayle/eslint-config-storefront": "4.3.2",
60
- "@scayle/storefront-nuxt": "8.1.3",
59
+ "@scayle/eslint-config-storefront": "4.4.0",
60
+ "@scayle/storefront-nuxt": "8.1.4",
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.16.0",
65
+ "eslint": "9.17.0",
66
66
  "happy-dom": "15.11.7",
67
67
  "eslint-formatter-gitlab": "5.1.0",
68
- "nuxt": "3.13.2",
68
+ "nuxt": "3.14.1592",
69
69
  "publint": "0.2.12",
70
70
  "typescript": "5.6.3",
71
71
  "vitest": "2.1.8",