@scayle/storefront-product-listing 2.0.2 → 2.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/CHANGELOG.md +24 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/runtime/utils/filters.d.ts +12 -6
- package/dist/runtime/utils/filters.js +27 -27
- package/package.json +16 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @scayle/storefront-product-listing
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Use latest `nuxt@3.19.2` for build. Compatibility with previous version has not changed and is specified via package `peerDependencies` and Nuxt `compatibility` flag.
|
|
8
|
+
|
|
9
|
+
## 2.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Added support for custom filter prefix for filter utility functions.
|
|
14
|
+
|
|
15
|
+
Following functions now accept a `filterPrefix` parameter that can be used to customize the filter prefix.
|
|
16
|
+
|
|
17
|
+
- `parseFilterDataFromRoute`
|
|
18
|
+
- `createNewAttributeQuery`
|
|
19
|
+
- `createNewPriceQuery`
|
|
20
|
+
- `createNewReductionQuery`
|
|
21
|
+
- `createNewBoolAttributeQuery`
|
|
22
|
+
- `getClearedPriceQuery`
|
|
23
|
+
- `getClearedReductionQuery`
|
|
24
|
+
- `getClearedFilterQueryByKey`
|
|
25
|
+
- `buildQueryFromCategoryFilters`
|
|
26
|
+
|
|
3
27
|
## 2.0.2
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/module.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
3
|
"configKey": "product-listing",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"compatibility": {
|
|
6
6
|
"bridge": false,
|
|
7
7
|
"nuxt": ">=3.13"
|
|
8
8
|
},
|
|
9
9
|
"builder": {
|
|
10
|
-
"@nuxt/module-builder": "1.0.
|
|
11
|
-
"unbuild": "3.
|
|
10
|
+
"@nuxt/module-builder": "1.0.2",
|
|
11
|
+
"unbuild": "3.6.1"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const PACKAGE_NAME = "@scayle/storefront-product-listing";
|
|
4
|
-
const PACKAGE_VERSION = "2.
|
|
4
|
+
const PACKAGE_VERSION = "2.1.1";
|
|
5
5
|
const module = defineNuxtModule({
|
|
6
6
|
meta: {
|
|
7
7
|
name: PACKAGE_NAME,
|
|
@@ -18,33 +18,36 @@ export declare const parseFilterDataFromRoute: (query: LocationQuery, filtersPre
|
|
|
18
18
|
* @param param An object containing the slug and ID of the attribute.
|
|
19
19
|
* @param param.slug The slug of the attribute.
|
|
20
20
|
* @param param.id The ID of the attribute.
|
|
21
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
21
22
|
*
|
|
22
23
|
* @returns A new query object with the updated attribute filter.
|
|
23
24
|
*/
|
|
24
25
|
export declare const createNewAttributeQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, { slug, id }: {
|
|
25
26
|
slug: string;
|
|
26
27
|
id: number;
|
|
27
|
-
}) => LocationQuery;
|
|
28
|
+
}, filterPrefix?: string) => LocationQuery;
|
|
28
29
|
/**
|
|
29
30
|
* Creates a new price filter query object.
|
|
30
31
|
*
|
|
31
32
|
* @param {RouteLocationNormalizedLoadedGeneric} route - The Vue Router route object.
|
|
32
33
|
* @param {ProductSearchQuery} appliedFilter - The currently applied filter.
|
|
33
34
|
* @param {RangeTuple} prices - The new price range.
|
|
35
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
34
36
|
*
|
|
35
37
|
* @returns {LocationQuery} A new query object with the updated price filter.
|
|
36
38
|
*/
|
|
37
|
-
export declare const createNewPriceQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, prices: RangeTuple) => LocationQuery;
|
|
39
|
+
export declare const createNewPriceQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, prices: RangeTuple, filterPrefix?: string) => LocationQuery;
|
|
38
40
|
/**
|
|
39
41
|
* Creates a new reduction filter query object.
|
|
40
42
|
*
|
|
41
43
|
* @param route - The Vue Router route object.
|
|
42
44
|
* @param appliedFilter - The currently applied filter.
|
|
43
45
|
* @param reductions - The new reduction range.
|
|
46
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
44
47
|
*
|
|
45
48
|
* @returns A new query object with the updated reduction filter.
|
|
46
49
|
*/
|
|
47
|
-
export declare const createNewReductionQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, reductions: RangeTuple) => LocationQuery;
|
|
50
|
+
export declare const createNewReductionQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, reductions: RangeTuple, filterPrefix?: string) => LocationQuery;
|
|
48
51
|
/**
|
|
49
52
|
* Creates a new boolean attribute filter query object.
|
|
50
53
|
*
|
|
@@ -53,27 +56,30 @@ export declare const createNewReductionQuery: (route: RouteLocationNormalizedLoa
|
|
|
53
56
|
* @param param - An object containing the slug and value of the boolean attribute.
|
|
54
57
|
* @param param.slug - The slug of the attribute.
|
|
55
58
|
* @param param.value - The value of the attribute.
|
|
59
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
56
60
|
*
|
|
57
61
|
* @returns A new query object with the updated boolean attribute filter.
|
|
58
62
|
*/
|
|
59
63
|
export declare const createNewBoolAttributeQuery: (route: RouteLocationNormalizedLoadedGeneric, appliedFilter: ProductSearchQuery, { slug, value }: {
|
|
60
64
|
slug: string;
|
|
61
65
|
value: boolean;
|
|
62
|
-
}) => LocationQuery;
|
|
66
|
+
}, filterPrefix?: string) => LocationQuery;
|
|
63
67
|
/**
|
|
64
68
|
* Returns a new query object with the filter for the specified key cleared.
|
|
65
69
|
*
|
|
66
70
|
* @param route - The Vue Router route object.
|
|
67
71
|
* @param key - The key of the filter to clear.
|
|
72
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
68
73
|
*
|
|
69
74
|
* @returns A new query object with the filter cleared.
|
|
70
75
|
*/
|
|
71
|
-
export declare const getClearedFilterQueryByKey: (route: RouteLocationNormalizedLoadedGeneric, key: string) => LocationQuery;
|
|
76
|
+
export declare const getClearedFilterQueryByKey: (route: RouteLocationNormalizedLoadedGeneric, key: string, filterPrefix?: string) => LocationQuery;
|
|
72
77
|
/**
|
|
73
78
|
* Builds a new query object from category filters.
|
|
74
79
|
*
|
|
75
80
|
* @param filters - Category filters.
|
|
81
|
+
* @param filterPrefix The prefix used for filter query parameters.
|
|
76
82
|
*
|
|
77
83
|
* @returns A new query object from Category filters.
|
|
78
84
|
*/
|
|
79
|
-
export declare const buildQueryFromCategoryFilters: (filters: CategoryFilter[]) => LocationQuery;
|
|
85
|
+
export declare const buildQueryFromCategoryFilters: (filters: CategoryFilter[], filterPrefix?: string) => LocationQuery;
|
|
@@ -50,11 +50,11 @@ export const parseFilterDataFromRoute = (query, filtersPrefix) => {
|
|
|
50
50
|
});
|
|
51
51
|
return productSearchQuery;
|
|
52
52
|
};
|
|
53
|
-
export const createNewAttributeQuery = (route, appliedFilter, { slug, id }) => {
|
|
53
|
+
export const createNewAttributeQuery = (route, appliedFilter, { slug, id }, filterPrefix = "filters") => {
|
|
54
54
|
const attributeFilterQuery = {};
|
|
55
55
|
const query = { ...route.query };
|
|
56
56
|
const attribute = appliedFilter.attributes?.find(({ key: key2 }) => key2 === slug);
|
|
57
|
-
const key =
|
|
57
|
+
const key = `${filterPrefix}[${slug}]`;
|
|
58
58
|
if (!attribute) {
|
|
59
59
|
attributeFilterQuery[key] = `${id}`;
|
|
60
60
|
return { ...query, ...attributeFilterQuery };
|
|
@@ -76,32 +76,32 @@ export const createNewAttributeQuery = (route, appliedFilter, { slug, id }) => {
|
|
|
76
76
|
attributeFilterQuery[key] = values.join(",");
|
|
77
77
|
return { ...query, ...attributeFilterQuery };
|
|
78
78
|
};
|
|
79
|
-
export const createNewPriceQuery = (route, appliedFilter, prices) => {
|
|
79
|
+
export const createNewPriceQuery = (route, appliedFilter, prices, filterPrefix = "filters") => {
|
|
80
80
|
const priceFilterQuery = {};
|
|
81
81
|
const query = { ...route.query };
|
|
82
82
|
if (appliedFilter.minPrice !== prices[0]) {
|
|
83
|
-
priceFilterQuery[
|
|
83
|
+
priceFilterQuery[`${filterPrefix}[minPrice]`] = prices[0].toString();
|
|
84
84
|
}
|
|
85
85
|
if (appliedFilter.maxPrice !== prices[1]) {
|
|
86
|
-
priceFilterQuery[
|
|
86
|
+
priceFilterQuery[`${filterPrefix}[maxPrice]`] = prices[1].toString();
|
|
87
87
|
}
|
|
88
88
|
return { ...query, ...priceFilterQuery };
|
|
89
89
|
};
|
|
90
|
-
export const createNewReductionQuery = (route, appliedFilter, reductions) => {
|
|
90
|
+
export const createNewReductionQuery = (route, appliedFilter, reductions, filterPrefix = "filters") => {
|
|
91
91
|
const priceFilterQuery = {};
|
|
92
92
|
if (appliedFilter.minReduction !== reductions[0]) {
|
|
93
|
-
priceFilterQuery[
|
|
93
|
+
priceFilterQuery[`${filterPrefix}[minReduction]`] = reductions[0].toString();
|
|
94
94
|
}
|
|
95
95
|
if (appliedFilter.maxReduction !== reductions[1]) {
|
|
96
|
-
priceFilterQuery[
|
|
96
|
+
priceFilterQuery[`${filterPrefix}[maxReduction]`] = reductions[1].toString();
|
|
97
97
|
}
|
|
98
98
|
return { ...route.query, ...priceFilterQuery };
|
|
99
99
|
};
|
|
100
|
-
export const createNewBoolAttributeQuery = (route, appliedFilter, { slug, value }) => {
|
|
100
|
+
export const createNewBoolAttributeQuery = (route, appliedFilter, { slug, value }, filterPrefix = "filters") => {
|
|
101
101
|
const booleanFilterQuery = {};
|
|
102
102
|
const query = { ...route.query };
|
|
103
103
|
const attribute = appliedFilter.attributes?.find(({ key: key2 }) => key2 === slug);
|
|
104
|
-
const key =
|
|
104
|
+
const key = `${filterPrefix}[${slug}]`;
|
|
105
105
|
if (!attribute) {
|
|
106
106
|
booleanFilterQuery[key] = String(value);
|
|
107
107
|
return { ...query, ...booleanFilterQuery };
|
|
@@ -116,52 +116,52 @@ export const createNewBoolAttributeQuery = (route, appliedFilter, { slug, value
|
|
|
116
116
|
booleanFilterQuery[key] = String(value);
|
|
117
117
|
return { ...query, ...booleanFilterQuery };
|
|
118
118
|
};
|
|
119
|
-
const getClearedPriceQuery = (route) => {
|
|
119
|
+
const getClearedPriceQuery = (route, filterPrefix = "filters") => {
|
|
120
120
|
const query = { ...route.query };
|
|
121
|
-
if (query[
|
|
122
|
-
delete query[
|
|
121
|
+
if (query[`${filterPrefix}[maxPrice]`]) {
|
|
122
|
+
delete query[`${filterPrefix}[maxPrice]`];
|
|
123
123
|
}
|
|
124
|
-
if (query[
|
|
125
|
-
delete query[
|
|
124
|
+
if (query[`${filterPrefix}[minPrice]`]) {
|
|
125
|
+
delete query[`${filterPrefix}[minPrice]`];
|
|
126
126
|
}
|
|
127
127
|
return query;
|
|
128
128
|
};
|
|
129
|
-
const getClearedReductionQuery = (route) => {
|
|
129
|
+
const getClearedReductionQuery = (route, filterPrefix = "filters") => {
|
|
130
130
|
const query = { ...route.query };
|
|
131
|
-
if (query[
|
|
132
|
-
delete query[
|
|
131
|
+
if (query[`${filterPrefix}[maxReduction]`]) {
|
|
132
|
+
delete query[`${filterPrefix}[maxReduction]`];
|
|
133
133
|
}
|
|
134
|
-
if (query[
|
|
135
|
-
delete query[
|
|
134
|
+
if (query[`${filterPrefix}[minReduction]`]) {
|
|
135
|
+
delete query[`${filterPrefix}[minReduction]`];
|
|
136
136
|
}
|
|
137
137
|
return query;
|
|
138
138
|
};
|
|
139
|
-
export const getClearedFilterQueryByKey = (route, key) => {
|
|
139
|
+
export const getClearedFilterQueryByKey = (route, key, filterPrefix = "filters") => {
|
|
140
140
|
if (key === "prices") {
|
|
141
|
-
return getClearedPriceQuery(route);
|
|
141
|
+
return getClearedPriceQuery(route, filterPrefix);
|
|
142
142
|
}
|
|
143
143
|
if (key === "reductions") {
|
|
144
|
-
return getClearedReductionQuery(route);
|
|
144
|
+
return getClearedReductionQuery(route, filterPrefix);
|
|
145
145
|
}
|
|
146
146
|
const query = { ...route.query };
|
|
147
|
-
const filterKey =
|
|
147
|
+
const filterKey = `${filterPrefix}[${key}]`;
|
|
148
148
|
if (query[filterKey]) {
|
|
149
149
|
delete query[filterKey];
|
|
150
150
|
}
|
|
151
151
|
return query;
|
|
152
152
|
};
|
|
153
|
-
export const buildQueryFromCategoryFilters = (filters) => {
|
|
153
|
+
export const buildQueryFromCategoryFilters = (filters, filterPrefix = "filters") => {
|
|
154
154
|
return filters.reduce((query, filter) => {
|
|
155
155
|
switch (filter.type) {
|
|
156
156
|
case "attribute":
|
|
157
157
|
return {
|
|
158
158
|
...query,
|
|
159
|
-
[
|
|
159
|
+
[`${filterPrefix}[${filter.attributeFilter.group.key}]`]: filter.attributeFilter.values.map(({ id }) => id).join(",")
|
|
160
160
|
};
|
|
161
161
|
case "boolean":
|
|
162
162
|
return {
|
|
163
163
|
...query,
|
|
164
|
-
[
|
|
164
|
+
[`${filterPrefix}[${filter.booleanFilter.slug}]`]: "true"
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
return query;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.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",
|
|
@@ -41,29 +41,30 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@arethetypeswrong/cli": "0.18.2",
|
|
44
|
-
"@nuxt/kit": "3.
|
|
45
|
-
"@nuxt/module-builder": "1.0.
|
|
46
|
-
"@nuxt/schema": "3.
|
|
44
|
+
"@nuxt/kit": "3.19.2",
|
|
45
|
+
"@nuxt/module-builder": "1.0.2",
|
|
46
|
+
"@nuxt/schema": "3.19.2",
|
|
47
47
|
"@nuxt/test-utils": "3.19.2",
|
|
48
|
-
"@types/node": "22.
|
|
48
|
+
"@types/node": "22.18.3",
|
|
49
49
|
"@vitest/coverage-v8": "3.2.4",
|
|
50
|
-
"@vueuse/core": "13.
|
|
51
|
-
"dprint": "0.50.
|
|
50
|
+
"@vueuse/core": "13.9.0",
|
|
51
|
+
"dprint": "0.50.2",
|
|
52
52
|
"eslint-formatter-gitlab": "6.0.1",
|
|
53
|
-
"eslint": "9.
|
|
53
|
+
"eslint": "9.35.0",
|
|
54
54
|
"fishery": "2.3.1",
|
|
55
55
|
"happy-dom": "18.0.1",
|
|
56
|
-
"nuxt": "3.
|
|
56
|
+
"nuxt": "3.19.2",
|
|
57
57
|
"publint": "0.3.12",
|
|
58
58
|
"schema-dts": "1.1.5",
|
|
59
|
-
"typescript": "5.
|
|
60
|
-
"unbuild": "3.
|
|
59
|
+
"typescript": "5.9.2",
|
|
60
|
+
"unbuild": "3.6.1",
|
|
61
61
|
"vitest": "3.2.4",
|
|
62
62
|
"vue-router": "4.5.1",
|
|
63
|
-
"vue-tsc": "3.0.
|
|
64
|
-
"vue": "3.5.
|
|
65
|
-
"@scayle/storefront
|
|
66
|
-
"@scayle/
|
|
63
|
+
"vue-tsc": "3.0.7",
|
|
64
|
+
"vue": "3.5.21",
|
|
65
|
+
"@scayle/eslint-config-storefront": "4.7.8",
|
|
66
|
+
"@scayle/storefront-nuxt": "8.44.1",
|
|
67
|
+
"@scayle/vitest-config-storefront": "1.0.0"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"build": "nuxt-module-build build",
|