@scayle/storefront-product-listing 0.1.1 → 0.1.2
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LocationQuery, RouteLocationNormalizedLoadedGeneric } from 'vue-router';
|
|
2
2
|
import type { ProductSearchQuery } from '@scayle/storefront-api';
|
|
3
|
-
import type { RangeTuple } from '
|
|
3
|
+
import type { RangeTuple } from '~/src';
|
|
4
4
|
export declare const parseFilterDataFromRoute: (route: RouteLocationNormalizedLoadedGeneric, filtersPrefix: string) => ProductSearchQuery;
|
|
5
5
|
export declare const getClearedFilterQueryByKey: (route: RouteLocationNormalizedLoadedGeneric, key: string) => LocationQuery | undefined;
|
|
6
6
|
export declare const getNewQueryFilters: (route: RouteLocationNormalizedLoadedGeneric, filter: LocationQuery) => LocationQuery;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
const getAttributeValues = (value) => {
|
|
2
|
-
return value.split(",").map((v) => Number(v)).filter((v) => !isNaN(v));
|
|
2
|
+
return value.split(",").filter((v) => v !== "").map((v) => Number(v)).filter((v) => !isNaN(v));
|
|
3
3
|
};
|
|
4
4
|
export const parseFilterDataFromRoute = (route, filtersPrefix) => {
|
|
5
5
|
const queryKeys = Object.keys(route.query);
|
|
6
6
|
const productSearchQuery = { attributes: [] };
|
|
7
7
|
queryKeys.forEach((queryKey) => {
|
|
8
8
|
const value = route.query[queryKey];
|
|
9
|
-
if (!value) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
9
|
if (!queryKey.includes(filtersPrefix)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
@@ -52,21 +49,17 @@ export const getClearedFilterQueryByKey = (route, key) => {
|
|
|
52
49
|
const query = { ...route.query };
|
|
53
50
|
const filterKey = `filters[${key}]`;
|
|
54
51
|
if (!query[filterKey]) {
|
|
55
|
-
return;
|
|
52
|
+
return query;
|
|
56
53
|
}
|
|
57
54
|
delete query[filterKey];
|
|
58
55
|
return query;
|
|
59
56
|
};
|
|
60
57
|
export const getNewQueryFilters = (route, filter) => {
|
|
61
|
-
|
|
58
|
+
return {
|
|
62
59
|
sort: route.query.sort,
|
|
63
60
|
term: route.query.term,
|
|
64
61
|
...filter
|
|
65
62
|
};
|
|
66
|
-
if ("page" in newQuery) {
|
|
67
|
-
delete newQuery.page;
|
|
68
|
-
}
|
|
69
|
-
return newQuery;
|
|
70
63
|
};
|
|
71
64
|
export const createNewAttributeQuery = (route, appliedFilter, { slug, id }) => {
|
|
72
65
|
const attributeFilterQuery = {};
|
|
@@ -111,9 +104,6 @@ export const createNewBoolAttributeQuery = (route, appliedFilter, { slug, value
|
|
|
111
104
|
const attribute = appliedFilter.attributes?.find(({ key: key2 }) => key2 === slug);
|
|
112
105
|
const key = `filters[${slug}]`;
|
|
113
106
|
if (!attribute) {
|
|
114
|
-
if (!value) {
|
|
115
|
-
return query;
|
|
116
|
-
}
|
|
117
107
|
booleanFilterQuery[key] = String(value);
|
|
118
108
|
return { ...query, ...booleanFilterQuery };
|
|
119
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Collection of essential composables and utilities to work with product listing",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,13 +57,13 @@
|
|
|
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": "7.
|
|
60
|
+
"@scayle/storefront-nuxt": "7.95.0",
|
|
61
61
|
"@types/node": "22.9.0",
|
|
62
62
|
"@vue/test-utils": "2.4.6",
|
|
63
63
|
"@vueuse/core": "11.2.0",
|
|
64
64
|
"dprint": "0.47.5",
|
|
65
65
|
"eslint": "9.14.0",
|
|
66
|
-
"happy-dom": "15.11.
|
|
66
|
+
"happy-dom": "15.11.4",
|
|
67
67
|
"eslint-formatter-gitlab": "5.1.0",
|
|
68
68
|
"nuxt": "3.13.2",
|
|
69
69
|
"publint": "0.2.12",
|