@ikas/storefront 0.0.57 → 0.0.58
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.
|
@@ -2,7 +2,7 @@ import { SearchInput } from "../../__generated__/global-types";
|
|
|
2
2
|
import { IkasProduct } from "../../models/index";
|
|
3
3
|
import * as SearchProductTypes from "./__generated__/searchProducts";
|
|
4
4
|
import { IkasProductFilter } from "../../models/data/product-filter/index";
|
|
5
|
-
import {
|
|
5
|
+
import { IkasFilterCategory } from "../../models/data/category/index";
|
|
6
6
|
export declare class IkasProductSearchAPI {
|
|
7
7
|
static searchProducts(input: SearchInput): Promise<{
|
|
8
8
|
data: IkasProduct[];
|
|
@@ -15,6 +15,6 @@ export declare class IkasProductSearchAPI {
|
|
|
15
15
|
} | undefined>;
|
|
16
16
|
static getProductFilterData(categoryId?: string): Promise<{
|
|
17
17
|
filters: IkasProductFilter[];
|
|
18
|
-
categories:
|
|
18
|
+
categories: IkasFilterCategory[] | null;
|
|
19
19
|
} | undefined>;
|
|
20
20
|
}
|
package/build/index.es.js
CHANGED
|
@@ -12467,6 +12467,28 @@ var IkasCategoryPath = /** @class */ (function () {
|
|
|
12467
12467
|
configurable: true
|
|
12468
12468
|
});
|
|
12469
12469
|
return IkasCategoryPath;
|
|
12470
|
+
}());
|
|
12471
|
+
var IkasFilterCategory = /** @class */ (function () {
|
|
12472
|
+
function IkasFilterCategory(data) {
|
|
12473
|
+
this.id = data.id || "";
|
|
12474
|
+
this.name = data.name || "";
|
|
12475
|
+
this.slug = data.slug || "";
|
|
12476
|
+
this.resultCount =
|
|
12477
|
+
data.resultCount !== undefined && data.resultCount !== null
|
|
12478
|
+
? data.resultCount
|
|
12479
|
+
: null;
|
|
12480
|
+
makeAutoObservable(this);
|
|
12481
|
+
}
|
|
12482
|
+
Object.defineProperty(IkasFilterCategory.prototype, "href", {
|
|
12483
|
+
get: function () {
|
|
12484
|
+
if (!this.slug)
|
|
12485
|
+
return "";
|
|
12486
|
+
return "/" + this.slug;
|
|
12487
|
+
},
|
|
12488
|
+
enumerable: false,
|
|
12489
|
+
configurable: true
|
|
12490
|
+
});
|
|
12491
|
+
return IkasFilterCategory;
|
|
12470
12492
|
}());
|
|
12471
12493
|
|
|
12472
12494
|
var IkasOrderAddress = /** @class */ (function () {
|
|
@@ -18512,7 +18534,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18512
18534
|
function IkasProductList(data, router) {
|
|
18513
18535
|
var _this = this;
|
|
18514
18536
|
this.filters = null;
|
|
18515
|
-
this.
|
|
18537
|
+
this._filterCategories = null;
|
|
18516
18538
|
this._initialized = false;
|
|
18517
18539
|
this._minPage = null;
|
|
18518
18540
|
this._filterBrandId = null;
|
|
@@ -18749,8 +18771,8 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18749
18771
|
this.filters = data.filters
|
|
18750
18772
|
? data.filters.map(function (f) { return new IkasProductFilter(f); })
|
|
18751
18773
|
: null;
|
|
18752
|
-
this.
|
|
18753
|
-
? data.filterCategories.map(function (c) { return new
|
|
18774
|
+
this._filterCategories = data.filterCategories
|
|
18775
|
+
? data.filterCategories.map(function (c) { return new IkasFilterCategory(c); })
|
|
18754
18776
|
: null;
|
|
18755
18777
|
this.router = router;
|
|
18756
18778
|
makeAutoObservable(this);
|
|
@@ -18881,6 +18903,14 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18881
18903
|
enumerable: false,
|
|
18882
18904
|
configurable: true
|
|
18883
18905
|
});
|
|
18906
|
+
Object.defineProperty(IkasProductList.prototype, "filterCategories", {
|
|
18907
|
+
get: function () {
|
|
18908
|
+
var _a;
|
|
18909
|
+
return (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.filter(function (fc) { return fc.resultCount !== 0; });
|
|
18910
|
+
},
|
|
18911
|
+
enumerable: false,
|
|
18912
|
+
configurable: true
|
|
18913
|
+
});
|
|
18884
18914
|
IkasProductList.prototype.searchProducts = function (page, limit) {
|
|
18885
18915
|
var _a, _b;
|
|
18886
18916
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -18921,11 +18951,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18921
18951
|
});
|
|
18922
18952
|
});
|
|
18923
18953
|
};
|
|
18924
|
-
IkasProductList.prototype.clear = function () {
|
|
18925
|
-
var _a;
|
|
18926
|
-
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
18927
|
-
this._searchKeyword = "";
|
|
18928
|
-
};
|
|
18929
18954
|
IkasProductList.prototype.getFilters = function () {
|
|
18930
18955
|
return __awaiter(this, void 0, void 0, function () {
|
|
18931
18956
|
var getFiltersResponse;
|
|
@@ -18935,7 +18960,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18935
18960
|
case 1:
|
|
18936
18961
|
getFiltersResponse = _a.sent();
|
|
18937
18962
|
this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters;
|
|
18938
|
-
this.
|
|
18963
|
+
this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
|
|
18939
18964
|
if (this.filters)
|
|
18940
18965
|
this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
|
|
18941
18966
|
return [2 /*return*/];
|
|
@@ -18976,7 +19001,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18976
19001
|
}
|
|
18977
19002
|
};
|
|
18978
19003
|
IkasProductList.prototype.applyFacets = function (facets) {
|
|
18979
|
-
var _a;
|
|
19004
|
+
var _a, _b;
|
|
18980
19005
|
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) {
|
|
18981
19006
|
var _a, _b, _c;
|
|
18982
19007
|
var facet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === filter.id; });
|
|
@@ -18998,10 +19023,28 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18998
19023
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (v) { return (v.resultCount = 0); });
|
|
18999
19024
|
}
|
|
19000
19025
|
});
|
|
19026
|
+
// Category facets
|
|
19027
|
+
var categoryFacet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === "category"; });
|
|
19028
|
+
if (categoryFacet) {
|
|
19029
|
+
(_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (filterCategory) {
|
|
19030
|
+
var facetValue = categoryFacet.values.find(function (fv) { return fv.id === filterCategory.id; });
|
|
19031
|
+
if (facetValue) {
|
|
19032
|
+
filterCategory.resultCount = facetValue.count;
|
|
19033
|
+
}
|
|
19034
|
+
else {
|
|
19035
|
+
filterCategory.resultCount = 0;
|
|
19036
|
+
}
|
|
19037
|
+
});
|
|
19038
|
+
}
|
|
19039
|
+
};
|
|
19040
|
+
IkasProductList.prototype.clearFilters = function () {
|
|
19041
|
+
var _a;
|
|
19042
|
+
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
19043
|
+
this._searchKeyword = "";
|
|
19001
19044
|
};
|
|
19002
|
-
IkasProductList.prototype.onFilterCategoryClick = function (
|
|
19045
|
+
IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
|
|
19003
19046
|
var _a;
|
|
19004
|
-
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(
|
|
19047
|
+
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href + window.location.search);
|
|
19005
19048
|
};
|
|
19006
19049
|
IkasProductList.prototype.toJSON = function () {
|
|
19007
19050
|
return {
|
|
@@ -19016,6 +19059,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
19016
19059
|
minPage: this._minPage,
|
|
19017
19060
|
filterBrandId: this._filterBrandId,
|
|
19018
19061
|
filterCategoryId: this._filterCategoryId,
|
|
19062
|
+
filterCategories: this._filterCategories,
|
|
19019
19063
|
filters: this.filters,
|
|
19020
19064
|
recommendFor: this._recommendFor,
|
|
19021
19065
|
productListPropValue: this._productListPropValue,
|
|
@@ -23233,7 +23277,7 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23233
23277
|
categories: data.getProductFilterData.categories
|
|
23234
23278
|
? data.getProductFilterData.categories.map(function (c) {
|
|
23235
23279
|
var _a;
|
|
23236
|
-
return new
|
|
23280
|
+
return new IkasFilterCategory({
|
|
23237
23281
|
id: c.id,
|
|
23238
23282
|
name: c.name,
|
|
23239
23283
|
slug: (_a = c.metaData) === null || _a === void 0 ? void 0 : _a.slug,
|
package/build/index.js
CHANGED
|
@@ -12478,6 +12478,28 @@ var IkasCategoryPath = /** @class */ (function () {
|
|
|
12478
12478
|
configurable: true
|
|
12479
12479
|
});
|
|
12480
12480
|
return IkasCategoryPath;
|
|
12481
|
+
}());
|
|
12482
|
+
var IkasFilterCategory = /** @class */ (function () {
|
|
12483
|
+
function IkasFilterCategory(data) {
|
|
12484
|
+
this.id = data.id || "";
|
|
12485
|
+
this.name = data.name || "";
|
|
12486
|
+
this.slug = data.slug || "";
|
|
12487
|
+
this.resultCount =
|
|
12488
|
+
data.resultCount !== undefined && data.resultCount !== null
|
|
12489
|
+
? data.resultCount
|
|
12490
|
+
: null;
|
|
12491
|
+
mobx.makeAutoObservable(this);
|
|
12492
|
+
}
|
|
12493
|
+
Object.defineProperty(IkasFilterCategory.prototype, "href", {
|
|
12494
|
+
get: function () {
|
|
12495
|
+
if (!this.slug)
|
|
12496
|
+
return "";
|
|
12497
|
+
return "/" + this.slug;
|
|
12498
|
+
},
|
|
12499
|
+
enumerable: false,
|
|
12500
|
+
configurable: true
|
|
12501
|
+
});
|
|
12502
|
+
return IkasFilterCategory;
|
|
12481
12503
|
}());
|
|
12482
12504
|
|
|
12483
12505
|
var IkasOrderAddress = /** @class */ (function () {
|
|
@@ -18493,7 +18515,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18493
18515
|
function IkasProductList(data, router) {
|
|
18494
18516
|
var _this = this;
|
|
18495
18517
|
this.filters = null;
|
|
18496
|
-
this.
|
|
18518
|
+
this._filterCategories = null;
|
|
18497
18519
|
this._initialized = false;
|
|
18498
18520
|
this._minPage = null;
|
|
18499
18521
|
this._filterBrandId = null;
|
|
@@ -18730,8 +18752,8 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18730
18752
|
this.filters = data.filters
|
|
18731
18753
|
? data.filters.map(function (f) { return new IkasProductFilter(f); })
|
|
18732
18754
|
: null;
|
|
18733
|
-
this.
|
|
18734
|
-
? data.filterCategories.map(function (c) { return new
|
|
18755
|
+
this._filterCategories = data.filterCategories
|
|
18756
|
+
? data.filterCategories.map(function (c) { return new IkasFilterCategory(c); })
|
|
18735
18757
|
: null;
|
|
18736
18758
|
this.router = router;
|
|
18737
18759
|
mobx.makeAutoObservable(this);
|
|
@@ -18862,6 +18884,14 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18862
18884
|
enumerable: false,
|
|
18863
18885
|
configurable: true
|
|
18864
18886
|
});
|
|
18887
|
+
Object.defineProperty(IkasProductList.prototype, "filterCategories", {
|
|
18888
|
+
get: function () {
|
|
18889
|
+
var _a;
|
|
18890
|
+
return (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.filter(function (fc) { return fc.resultCount !== 0; });
|
|
18891
|
+
},
|
|
18892
|
+
enumerable: false,
|
|
18893
|
+
configurable: true
|
|
18894
|
+
});
|
|
18865
18895
|
IkasProductList.prototype.searchProducts = function (page, limit) {
|
|
18866
18896
|
var _a, _b;
|
|
18867
18897
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -18902,11 +18932,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18902
18932
|
});
|
|
18903
18933
|
});
|
|
18904
18934
|
};
|
|
18905
|
-
IkasProductList.prototype.clear = function () {
|
|
18906
|
-
var _a;
|
|
18907
|
-
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
18908
|
-
this._searchKeyword = "";
|
|
18909
|
-
};
|
|
18910
18935
|
IkasProductList.prototype.getFilters = function () {
|
|
18911
18936
|
return __awaiter(this, void 0, void 0, function () {
|
|
18912
18937
|
var getFiltersResponse;
|
|
@@ -18916,7 +18941,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18916
18941
|
case 1:
|
|
18917
18942
|
getFiltersResponse = _a.sent();
|
|
18918
18943
|
this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters;
|
|
18919
|
-
this.
|
|
18944
|
+
this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
|
|
18920
18945
|
if (this.filters)
|
|
18921
18946
|
this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
|
|
18922
18947
|
return [2 /*return*/];
|
|
@@ -18957,7 +18982,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18957
18982
|
}
|
|
18958
18983
|
};
|
|
18959
18984
|
IkasProductList.prototype.applyFacets = function (facets) {
|
|
18960
|
-
var _a;
|
|
18985
|
+
var _a, _b;
|
|
18961
18986
|
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) {
|
|
18962
18987
|
var _a, _b, _c;
|
|
18963
18988
|
var facet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === filter.id; });
|
|
@@ -18979,10 +19004,28 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18979
19004
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (v) { return (v.resultCount = 0); });
|
|
18980
19005
|
}
|
|
18981
19006
|
});
|
|
19007
|
+
// Category facets
|
|
19008
|
+
var categoryFacet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === "category"; });
|
|
19009
|
+
if (categoryFacet) {
|
|
19010
|
+
(_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (filterCategory) {
|
|
19011
|
+
var facetValue = categoryFacet.values.find(function (fv) { return fv.id === filterCategory.id; });
|
|
19012
|
+
if (facetValue) {
|
|
19013
|
+
filterCategory.resultCount = facetValue.count;
|
|
19014
|
+
}
|
|
19015
|
+
else {
|
|
19016
|
+
filterCategory.resultCount = 0;
|
|
19017
|
+
}
|
|
19018
|
+
});
|
|
19019
|
+
}
|
|
19020
|
+
};
|
|
19021
|
+
IkasProductList.prototype.clearFilters = function () {
|
|
19022
|
+
var _a;
|
|
19023
|
+
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
19024
|
+
this._searchKeyword = "";
|
|
18982
19025
|
};
|
|
18983
|
-
IkasProductList.prototype.onFilterCategoryClick = function (
|
|
19026
|
+
IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
|
|
18984
19027
|
var _a;
|
|
18985
|
-
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(
|
|
19028
|
+
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href + window.location.search);
|
|
18986
19029
|
};
|
|
18987
19030
|
IkasProductList.prototype.toJSON = function () {
|
|
18988
19031
|
return {
|
|
@@ -18997,6 +19040,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18997
19040
|
minPage: this._minPage,
|
|
18998
19041
|
filterBrandId: this._filterBrandId,
|
|
18999
19042
|
filterCategoryId: this._filterCategoryId,
|
|
19043
|
+
filterCategories: this._filterCategories,
|
|
19000
19044
|
filters: this.filters,
|
|
19001
19045
|
recommendFor: this._recommendFor,
|
|
19002
19046
|
productListPropValue: this._productListPropValue,
|
|
@@ -23211,7 +23255,7 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23211
23255
|
categories: data.getProductFilterData.categories
|
|
23212
23256
|
? data.getProductFilterData.categories.map(function (c) {
|
|
23213
23257
|
var _a;
|
|
23214
|
-
return new
|
|
23258
|
+
return new IkasFilterCategory({
|
|
23215
23259
|
id: c.id,
|
|
23216
23260
|
name: c.name,
|
|
23217
23261
|
slug: (_a = c.metaData) === null || _a === void 0 ? void 0 : _a.slug,
|
|
@@ -17,3 +17,11 @@ export declare class IkasCategoryPath {
|
|
|
17
17
|
constructor(data: Partial<IkasCategoryPath>);
|
|
18
18
|
get href(): string;
|
|
19
19
|
}
|
|
20
|
+
export declare class IkasFilterCategory {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
slug?: string | null;
|
|
24
|
+
resultCount?: number | null;
|
|
25
|
+
constructor(data: Partial<IkasFilterCategory>);
|
|
26
|
+
get href(): string;
|
|
27
|
+
}
|
|
@@ -2,11 +2,11 @@ import { IkasProductListPropValue } from "../../theme/index";
|
|
|
2
2
|
import { IkasProductDetail } from "../product-detail/index";
|
|
3
3
|
import { IkasProductFilter } from "../../data/product-filter/index";
|
|
4
4
|
import { NextRouter } from "next/router";
|
|
5
|
-
import {
|
|
5
|
+
import { IkasFilterCategory } from "../../data/category/index";
|
|
6
6
|
export declare class IkasProductList {
|
|
7
7
|
data: IkasProductDetail[];
|
|
8
8
|
filters?: IkasProductFilter[] | null;
|
|
9
|
-
|
|
9
|
+
private _filterCategories?;
|
|
10
10
|
private _type;
|
|
11
11
|
private _sort;
|
|
12
12
|
private _limit;
|
|
@@ -39,17 +39,18 @@ export declare class IkasProductList {
|
|
|
39
39
|
get hasNext(): boolean;
|
|
40
40
|
get isLoading(): boolean;
|
|
41
41
|
get filterQueryParams(): string;
|
|
42
|
+
get filterCategories(): IkasFilterCategory[] | undefined;
|
|
42
43
|
private searchProducts;
|
|
43
|
-
clear(): void;
|
|
44
44
|
private getFilters;
|
|
45
45
|
private applyQueryParamFilters;
|
|
46
46
|
private applyFacets;
|
|
47
|
+
clearFilters(): void;
|
|
47
48
|
applyFilters: () => Promise<void>;
|
|
48
49
|
getInitial: (queryParams?: URLSearchParams | undefined) => Promise<void>;
|
|
49
50
|
getPrev: () => Promise<void>;
|
|
50
51
|
getNext: () => Promise<void>;
|
|
51
52
|
getPage: (page: number) => Promise<void>;
|
|
52
|
-
onFilterCategoryClick(
|
|
53
|
+
onFilterCategoryClick(filterCategory: IkasFilterCategory): void;
|
|
53
54
|
toJSON(): {
|
|
54
55
|
data: IkasProductDetail[];
|
|
55
56
|
type: IkasProductListType;
|
|
@@ -62,6 +63,7 @@ export declare class IkasProductList {
|
|
|
62
63
|
minPage: number | null | undefined;
|
|
63
64
|
filterBrandId: string | null | undefined;
|
|
64
65
|
filterCategoryId: string | null | undefined;
|
|
66
|
+
filterCategories: IkasFilterCategory[] | null | undefined;
|
|
65
67
|
filters: IkasProductFilter[] | null | undefined;
|
|
66
68
|
recommendFor: string | null | undefined;
|
|
67
69
|
productListPropValue: IkasProductListPropValue;
|
|
@@ -82,7 +84,7 @@ export declare type IkasProductListParams = {
|
|
|
82
84
|
filterBrandId?: string;
|
|
83
85
|
filterCategoryId?: string;
|
|
84
86
|
filters?: IkasProductFilter[];
|
|
85
|
-
filterCategories?:
|
|
87
|
+
filterCategories?: IkasFilterCategory[];
|
|
86
88
|
recommendFor?: string;
|
|
87
89
|
productListPropValue: IkasProductListPropValue;
|
|
88
90
|
};
|