@scayle/storefront-product-listing 1.2.0 → 1.3.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 +12 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/index.d.ts +5 -0
- package/dist/runtime/composables/index.js +5 -0
- package/dist/runtime/utils/filters.d.ts +9 -1
- package/dist/runtime/utils/filters.js +22 -2
- package/package.json +28 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scayle/storefront-product-listing
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added `vue@>=3.5.13` to `peerDependencies`.
|
|
8
|
+
|
|
9
|
+
## 1.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add `buildQueryFromCategoryFilters` utility.
|
|
14
|
+
|
|
3
15
|
## 1.2.0
|
|
4
16
|
|
|
5
17
|
### Minor 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": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"compatibility": {
|
|
6
6
|
"bridge": false,
|
|
7
7
|
"nuxt": ">=3.13"
|
|
8
8
|
},
|
|
9
9
|
"builder": {
|
|
10
10
|
"@nuxt/module-builder": "0.8.4",
|
|
11
|
-
"unbuild": "
|
|
11
|
+
"unbuild": "2.0.0"
|
|
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 = "1.
|
|
4
|
+
const PACKAGE_VERSION = "1.3.1";
|
|
5
5
|
const module = defineNuxtModule({
|
|
6
6
|
meta: {
|
|
7
7
|
name: PACKAGE_NAME,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LocationQuery, RouteLocationNormalizedLoadedGeneric } from 'vue-router';
|
|
2
|
-
import type { ProductSearchQuery } from '@scayle/storefront-
|
|
2
|
+
import type { CategoryFilter, ProductSearchQuery } from '@scayle/storefront-nuxt';
|
|
3
3
|
import type { RangeTuple } from '~/src';
|
|
4
4
|
/**
|
|
5
5
|
* Parses filter data from a Vue Router route object.
|
|
@@ -59,3 +59,11 @@ export declare const createNewBoolAttributeQuery: (route: RouteLocationNormalize
|
|
|
59
59
|
* @returns A new query object with the filter cleared.
|
|
60
60
|
*/
|
|
61
61
|
export declare const getClearedFilterQueryByKey: (route: RouteLocationNormalizedLoadedGeneric, key: string) => LocationQuery;
|
|
62
|
+
/**
|
|
63
|
+
* Builds a new query object from category filters.
|
|
64
|
+
*
|
|
65
|
+
* @param filters - Category filters.
|
|
66
|
+
*
|
|
67
|
+
* @returns A new query object from Category filters.
|
|
68
|
+
*/
|
|
69
|
+
export declare const buildQueryFromCategoryFilters: (filters: CategoryFilter[]) => LocationQuery;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const getAttributeValues = (value) => {
|
|
2
|
-
return value.split(",").filter((v) => v !== "").map(
|
|
2
|
+
return value.split(",").filter((v) => v !== "").map(Number).filter((v) => !isNaN(v));
|
|
3
3
|
};
|
|
4
4
|
export const parseFilterDataFromRoute = (route, filtersPrefix) => {
|
|
5
5
|
const queryKeys = Object.keys(route.query);
|
|
@@ -9,7 +9,10 @@ export const parseFilterDataFromRoute = (route, filtersPrefix) => {
|
|
|
9
9
|
if (!queryKey.includes(filtersPrefix)) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
const filterName = queryKey.replace(filtersPrefix, "").replace(
|
|
12
|
+
const filterName = queryKey.replace(filtersPrefix, "").replace(
|
|
13
|
+
/[\[\]]/g,
|
|
14
|
+
""
|
|
15
|
+
);
|
|
13
16
|
switch (filterName) {
|
|
14
17
|
case "minPrice":
|
|
15
18
|
case "maxPrice":
|
|
@@ -122,3 +125,20 @@ export const getClearedFilterQueryByKey = (route, key) => {
|
|
|
122
125
|
}
|
|
123
126
|
return query;
|
|
124
127
|
};
|
|
128
|
+
export const buildQueryFromCategoryFilters = (filters) => {
|
|
129
|
+
return filters.reduce((query, filter) => {
|
|
130
|
+
switch (filter.type) {
|
|
131
|
+
case "attribute":
|
|
132
|
+
return {
|
|
133
|
+
...query,
|
|
134
|
+
[`filters[${filter.attributeFilter.group.key}]`]: filter.attributeFilter.values.map(({ id }) => id).join(",")
|
|
135
|
+
};
|
|
136
|
+
case "boolean":
|
|
137
|
+
return {
|
|
138
|
+
...query,
|
|
139
|
+
[`filters[${filter.booleanFilter.slug}]`]: "true"
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return query;
|
|
143
|
+
}, {});
|
|
144
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-listing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/module.d.ts",
|
|
19
19
|
"require": "./dist/module.cjs",
|
|
20
20
|
"import": "./dist/module.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./composables": {
|
|
23
|
+
"types": "./dist/runtime/composables/index.d.ts",
|
|
24
|
+
"import": "./dist/runtime/composables/index.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"main": "./dist/index.mjs",
|
|
@@ -45,34 +49,39 @@
|
|
|
45
49
|
"package:lint": "publint"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
48
|
-
"@nuxt/kit": "
|
|
52
|
+
"@nuxt/kit": ">=3.13.0",
|
|
53
|
+
"@scayle/storefront-core": "^8.0.0",
|
|
49
54
|
"@scayle/storefront-nuxt": "^8.0.0",
|
|
50
|
-
"@vue/test-utils": "2.4.6",
|
|
51
|
-
"@vueuse/core": "12.
|
|
52
|
-
"fishery": "2.2.3",
|
|
53
|
-
"vue-router": "4.5.0"
|
|
55
|
+
"@vue/test-utils": "^2.4.6",
|
|
56
|
+
"@vueuse/core": "^12.8.2 || ^13.0.0",
|
|
57
|
+
"fishery": "^2.2.3",
|
|
58
|
+
"vue-router": "^4.5.0",
|
|
59
|
+
"vue": "^3.5.13"
|
|
54
60
|
},
|
|
55
61
|
"devDependencies": {
|
|
56
|
-
"@nuxt/kit": "3.
|
|
62
|
+
"@nuxt/kit": "3.15.4",
|
|
57
63
|
"@nuxt/module-builder": "0.8.4",
|
|
58
|
-
"@nuxt/schema": "3.
|
|
59
|
-
"@nuxt/test-utils": "3.
|
|
64
|
+
"@nuxt/schema": "3.15.4",
|
|
65
|
+
"@nuxt/test-utils": "3.17.2",
|
|
60
66
|
"@scayle/eslint-config-storefront": "4.4.1",
|
|
61
|
-
"@scayle/storefront-
|
|
62
|
-
"@
|
|
67
|
+
"@scayle/storefront-api": "18.1.0",
|
|
68
|
+
"@scayle/storefront-nuxt": "8.11.11",
|
|
69
|
+
"@types/node": "22.13.10",
|
|
63
70
|
"@vue/test-utils": "2.4.6",
|
|
64
|
-
"@vueuse/core": "
|
|
71
|
+
"@vueuse/core": "13.0.0",
|
|
65
72
|
"dprint": "0.49.0",
|
|
66
|
-
"eslint": "9.20.1",
|
|
67
|
-
"happy-dom": "17.1.0",
|
|
68
73
|
"eslint-formatter-gitlab": "5.1.0",
|
|
69
|
-
"
|
|
74
|
+
"eslint": "9.22.0",
|
|
75
|
+
"fishery": "2.2.3",
|
|
76
|
+
"happy-dom": "17.4.3",
|
|
77
|
+
"nuxt": "3.15.4",
|
|
70
78
|
"publint": "0.2.12",
|
|
71
|
-
"
|
|
79
|
+
"schema-dts": "1.1.5",
|
|
80
|
+
"typescript": "5.8.2",
|
|
81
|
+
"unbuild": "2.0.0",
|
|
72
82
|
"vitest": "2.1.9",
|
|
73
|
-
"schema-dts": "1.1.2",
|
|
74
83
|
"vue-router": "4.5.0",
|
|
75
|
-
"
|
|
76
|
-
"vue
|
|
84
|
+
"vue-tsc": "2.2.8",
|
|
85
|
+
"vue": "3.5.13"
|
|
77
86
|
}
|
|
78
87
|
}
|