@ikas/storefront 0.0.158-alpha.11 → 0.0.158-alpha.12

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/build/index.es.js CHANGED
@@ -21747,11 +21747,11 @@ var IkasProductList = /** @class */ (function () {
21747
21747
  });
21748
21748
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21749
21749
  get: function () {
21750
- var _a;
21750
+ var _a, _b;
21751
21751
  return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) ||
21752
21752
  !!this._searchKeyword ||
21753
21753
  (this._pageType !== IkasThemePageType.CATEGORY &&
21754
- !!this._filterCategoryId));
21754
+ (!!this._filterCategoryId || ((_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.some(function (fc) { return fc.isSelected; })))));
21755
21755
  },
21756
21756
  enumerable: false,
21757
21757
  configurable: true
@@ -21822,7 +21822,7 @@ var IkasProductList = /** @class */ (function () {
21822
21822
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
21823
21823
  get: function () {
21824
21824
  var _this = this;
21825
- var _a, _b, _c;
21825
+ var _a, _b, _c, _d;
21826
21826
  var queryParams = {};
21827
21827
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
21828
21828
  if (f.keyList.length)
@@ -21832,11 +21832,17 @@ var IkasProductList = /** @class */ (function () {
21832
21832
  queryParams.s = this._searchKeyword;
21833
21833
  if (this._infiniteScrollPage)
21834
21834
  queryParams.page = this._infiniteScrollPage;
21835
- if (this._pageType !== IkasThemePageType.CATEGORY &&
21836
- this._filterCategoryId) {
21837
- var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
21838
- if (slug)
21839
- queryParams.c = slug;
21835
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
21836
+ var selectedCategories = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.filter(function (fc) { return fc.isSelected; });
21837
+ var hasSelectedCategory = !!(selectedCategories === null || selectedCategories === void 0 ? void 0 : selectedCategories.length);
21838
+ if (hasSelectedCategory) {
21839
+ queryParams.c = selectedCategories === null || selectedCategories === void 0 ? void 0 : selectedCategories.map(function (sc) { return sc.slug; });
21840
+ }
21841
+ else if (this._filterCategoryId) {
21842
+ var slug = (_d = (_c = this.filterCategories) === null || _c === void 0 ? void 0 : _c.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _d === void 0 ? void 0 : _d.slug;
21843
+ if (slug)
21844
+ queryParams.c = slug;
21845
+ }
21840
21846
  }
21841
21847
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
21842
21848
  },
@@ -21902,11 +21908,11 @@ var IkasProductList = /** @class */ (function () {
21902
21908
  };
21903
21909
  };
21904
21910
  IkasProductList.prototype.searchProducts = function (page, limit, productIdList) {
21905
- var _a, _b;
21911
+ var _a, _b, _c;
21906
21912
  return __awaiter(this, void 0, void 0, function () {
21907
- var filterList;
21908
- return __generator(this, function (_c) {
21909
- switch (_c.label) {
21913
+ var filterList, selectedCategoryIds;
21914
+ return __generator(this, function (_d) {
21915
+ switch (_d.label) {
21910
21916
  case 0:
21911
21917
  filterList = [];
21912
21918
  if (this._filterBrandId) {
@@ -21925,40 +21931,51 @@ var IkasProductList = /** @class */ (function () {
21925
21931
  }));
21926
21932
  }
21927
21933
  });
21934
+ selectedCategoryIds = (_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.filter(function (fc) { return fc.isSelected; }).map(function (fc) { return fc.id; });
21928
21935
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
21929
21936
  page: page,
21930
21937
  perPage: limit,
21931
21938
  productIdList: this.isStatic
21932
- ? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : productIdList,
21939
+ ? (_c = this._productListPropValue.productIds) === null || _c === void 0 ? void 0 : _c.map(function (p) { return p.productId; }) : productIdList,
21933
21940
  filterList: filterList,
21934
21941
  brandId: this._pageType === IkasThemePageType.BRAND &&
21935
21942
  this._type !== IkasProductListType.SEARCH
21936
21943
  ? this._filterBrandId
21937
21944
  : undefined,
21938
- categoryIdList: this._filterCategoryId
21939
- ? [this._filterCategoryId]
21940
- : undefined,
21945
+ categoryIdList: selectedCategoryIds && selectedCategoryIds.length
21946
+ ? selectedCategoryIds
21947
+ : this._filterCategoryId
21948
+ ? [this._filterCategoryId]
21949
+ : undefined,
21941
21950
  priceListId: IkasStorefrontConfig.priceListId,
21942
21951
  salesChannelId: IkasStorefrontConfig.salesChannelId,
21943
21952
  query: this._searchKeyword,
21944
21953
  order: [this.getSortParams()],
21945
21954
  })];
21946
- case 1: return [2 /*return*/, _c.sent()];
21955
+ case 1: return [2 /*return*/, _d.sent()];
21947
21956
  }
21948
21957
  });
21949
21958
  });
21950
21959
  };
21951
21960
  IkasProductList.prototype.getFilters = function () {
21961
+ var _a;
21952
21962
  return __awaiter(this, void 0, void 0, function () {
21953
- var getFiltersResponse;
21963
+ var getFiltersResponse, filterCategory;
21954
21964
  var _this = this;
21955
- return __generator(this, function (_a) {
21956
- switch (_a.label) {
21965
+ return __generator(this, function (_b) {
21966
+ switch (_b.label) {
21957
21967
  case 0: return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData(this._filterCategoryId ? this._filterCategoryId : undefined)];
21958
21968
  case 1:
21959
- getFiltersResponse = _a.sent();
21969
+ getFiltersResponse = _b.sent();
21960
21970
  this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters.map(function (f) { return new IkasProductFilter(f, _this); });
21961
21971
  this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
21972
+ if (this.pageType !== IkasThemePageType.CATEGORY &&
21973
+ this._filterCategoryId) {
21974
+ filterCategory = (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.id === _this._filterCategoryId; });
21975
+ //@ts-ignore
21976
+ if (filterCategory)
21977
+ filterCategory._isSelected = true;
21978
+ }
21962
21979
  if (this.filters)
21963
21980
  this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
21964
21981
  return [2 /*return*/];
@@ -21981,12 +21998,13 @@ var IkasProductList = /** @class */ (function () {
21981
21998
  if (querySearch)
21982
21999
  this._searchKeyword = querySearch;
21983
22000
  if (this._pageType !== IkasThemePageType.CATEGORY) {
21984
- var queryCategory_1 = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
21985
- if (queryCategory_1) {
21986
- var filterCategory = (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.slug === queryCategory_1; });
21987
- if (filterCategory) {
21988
- this._filterCategoryId = filterCategory.id;
21989
- }
22001
+ var queryCategory = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
22002
+ var categorySlugs_1 = queryCategory === null || queryCategory === void 0 ? void 0 : queryCategory.split(",");
22003
+ if (categorySlugs_1 && categorySlugs_1.length) {
22004
+ (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22005
+ //@ts-ignore
22006
+ fc._isSelected = categorySlugs_1.some(function (slug) { return slug === fc.slug; });
22007
+ });
21990
22008
  }
21991
22009
  }
21992
22010
  }
@@ -22032,11 +22050,13 @@ var IkasProductList = /** @class */ (function () {
22032
22050
  }
22033
22051
  };
22034
22052
  IkasProductList.prototype.clearFilters = function () {
22035
- var _a;
22053
+ var _a, _b;
22036
22054
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22037
22055
  this._searchKeyword = "";
22038
22056
  if (this._pageType !== IkasThemePageType.CATEGORY) {
22039
22057
  this._filterCategoryId = undefined;
22058
+ //@ts-ignore
22059
+ (_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (fc) { return (fc._isSelected = false); });
22040
22060
  }
22041
22061
  this.applyFilters();
22042
22062
  };
@@ -22058,18 +22078,15 @@ var IkasProductList = /** @class */ (function () {
22058
22078
  var _a, _b;
22059
22079
  if (disableRoute === void 0) { disableRoute = false; }
22060
22080
  return __awaiter(this, void 0, void 0, function () {
22061
- var _this = this;
22062
22081
  return __generator(this, function (_c) {
22063
22082
  switch (_c.label) {
22064
22083
  case 0:
22065
22084
  if (!disableRoute) return [3 /*break*/, 2];
22066
- if (this._filterCategoryId === filterCategory.id)
22067
- this._filterCategoryId = undefined;
22068
- else
22069
- this._filterCategoryId = filterCategory.id;
22070
22085
  (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22071
- //@ts-ignore
22072
- fc._isSelected = fc.id === _this._filterCategoryId;
22086
+ if (fc.id === filterCategory.id) {
22087
+ //@ts-ignore
22088
+ fc._isSelected = !fc.isSelected;
22089
+ }
22073
22090
  });
22074
22091
  return [4 /*yield*/, this.applyFilters()];
22075
22092
  case 1:
package/build/index.js CHANGED
@@ -21730,11 +21730,11 @@ var IkasProductList = /** @class */ (function () {
21730
21730
  });
21731
21731
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21732
21732
  get: function () {
21733
- var _a;
21733
+ var _a, _b;
21734
21734
  return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) ||
21735
21735
  !!this._searchKeyword ||
21736
21736
  (this._pageType !== exports.IkasThemePageType.CATEGORY &&
21737
- !!this._filterCategoryId));
21737
+ (!!this._filterCategoryId || ((_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.some(function (fc) { return fc.isSelected; })))));
21738
21738
  },
21739
21739
  enumerable: false,
21740
21740
  configurable: true
@@ -21805,7 +21805,7 @@ var IkasProductList = /** @class */ (function () {
21805
21805
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
21806
21806
  get: function () {
21807
21807
  var _this = this;
21808
- var _a, _b, _c;
21808
+ var _a, _b, _c, _d;
21809
21809
  var queryParams = {};
21810
21810
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
21811
21811
  if (f.keyList.length)
@@ -21815,11 +21815,17 @@ var IkasProductList = /** @class */ (function () {
21815
21815
  queryParams.s = this._searchKeyword;
21816
21816
  if (this._infiniteScrollPage)
21817
21817
  queryParams.page = this._infiniteScrollPage;
21818
- if (this._pageType !== exports.IkasThemePageType.CATEGORY &&
21819
- this._filterCategoryId) {
21820
- var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
21821
- if (slug)
21822
- queryParams.c = slug;
21818
+ if (this._pageType !== exports.IkasThemePageType.CATEGORY) {
21819
+ var selectedCategories = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.filter(function (fc) { return fc.isSelected; });
21820
+ var hasSelectedCategory = !!(selectedCategories === null || selectedCategories === void 0 ? void 0 : selectedCategories.length);
21821
+ if (hasSelectedCategory) {
21822
+ queryParams.c = selectedCategories === null || selectedCategories === void 0 ? void 0 : selectedCategories.map(function (sc) { return sc.slug; });
21823
+ }
21824
+ else if (this._filterCategoryId) {
21825
+ var slug = (_d = (_c = this.filterCategories) === null || _c === void 0 ? void 0 : _c.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _d === void 0 ? void 0 : _d.slug;
21826
+ if (slug)
21827
+ queryParams.c = slug;
21828
+ }
21823
21829
  }
21824
21830
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
21825
21831
  },
@@ -21885,11 +21891,11 @@ var IkasProductList = /** @class */ (function () {
21885
21891
  };
21886
21892
  };
21887
21893
  IkasProductList.prototype.searchProducts = function (page, limit, productIdList) {
21888
- var _a, _b;
21894
+ var _a, _b, _c;
21889
21895
  return __awaiter(this, void 0, void 0, function () {
21890
- var filterList;
21891
- return __generator(this, function (_c) {
21892
- switch (_c.label) {
21896
+ var filterList, selectedCategoryIds;
21897
+ return __generator(this, function (_d) {
21898
+ switch (_d.label) {
21893
21899
  case 0:
21894
21900
  filterList = [];
21895
21901
  if (this._filterBrandId) {
@@ -21908,40 +21914,51 @@ var IkasProductList = /** @class */ (function () {
21908
21914
  }));
21909
21915
  }
21910
21916
  });
21917
+ selectedCategoryIds = (_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.filter(function (fc) { return fc.isSelected; }).map(function (fc) { return fc.id; });
21911
21918
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
21912
21919
  page: page,
21913
21920
  perPage: limit,
21914
21921
  productIdList: this.isStatic
21915
- ? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : productIdList,
21922
+ ? (_c = this._productListPropValue.productIds) === null || _c === void 0 ? void 0 : _c.map(function (p) { return p.productId; }) : productIdList,
21916
21923
  filterList: filterList,
21917
21924
  brandId: this._pageType === exports.IkasThemePageType.BRAND &&
21918
21925
  this._type !== exports.IkasProductListType.SEARCH
21919
21926
  ? this._filterBrandId
21920
21927
  : undefined,
21921
- categoryIdList: this._filterCategoryId
21922
- ? [this._filterCategoryId]
21923
- : undefined,
21928
+ categoryIdList: selectedCategoryIds && selectedCategoryIds.length
21929
+ ? selectedCategoryIds
21930
+ : this._filterCategoryId
21931
+ ? [this._filterCategoryId]
21932
+ : undefined,
21924
21933
  priceListId: IkasStorefrontConfig.priceListId,
21925
21934
  salesChannelId: IkasStorefrontConfig.salesChannelId,
21926
21935
  query: this._searchKeyword,
21927
21936
  order: [this.getSortParams()],
21928
21937
  })];
21929
- case 1: return [2 /*return*/, _c.sent()];
21938
+ case 1: return [2 /*return*/, _d.sent()];
21930
21939
  }
21931
21940
  });
21932
21941
  });
21933
21942
  };
21934
21943
  IkasProductList.prototype.getFilters = function () {
21944
+ var _a;
21935
21945
  return __awaiter(this, void 0, void 0, function () {
21936
- var getFiltersResponse;
21946
+ var getFiltersResponse, filterCategory;
21937
21947
  var _this = this;
21938
- return __generator(this, function (_a) {
21939
- switch (_a.label) {
21948
+ return __generator(this, function (_b) {
21949
+ switch (_b.label) {
21940
21950
  case 0: return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData(this._filterCategoryId ? this._filterCategoryId : undefined)];
21941
21951
  case 1:
21942
- getFiltersResponse = _a.sent();
21952
+ getFiltersResponse = _b.sent();
21943
21953
  this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters.map(function (f) { return new IkasProductFilter(f, _this); });
21944
21954
  this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
21955
+ if (this.pageType !== exports.IkasThemePageType.CATEGORY &&
21956
+ this._filterCategoryId) {
21957
+ filterCategory = (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.id === _this._filterCategoryId; });
21958
+ //@ts-ignore
21959
+ if (filterCategory)
21960
+ filterCategory._isSelected = true;
21961
+ }
21945
21962
  if (this.filters)
21946
21963
  this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
21947
21964
  return [2 /*return*/];
@@ -21964,12 +21981,13 @@ var IkasProductList = /** @class */ (function () {
21964
21981
  if (querySearch)
21965
21982
  this._searchKeyword = querySearch;
21966
21983
  if (this._pageType !== exports.IkasThemePageType.CATEGORY) {
21967
- var queryCategory_1 = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
21968
- if (queryCategory_1) {
21969
- var filterCategory = (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.slug === queryCategory_1; });
21970
- if (filterCategory) {
21971
- this._filterCategoryId = filterCategory.id;
21972
- }
21984
+ var queryCategory = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
21985
+ var categorySlugs_1 = queryCategory === null || queryCategory === void 0 ? void 0 : queryCategory.split(",");
21986
+ if (categorySlugs_1 && categorySlugs_1.length) {
21987
+ (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
21988
+ //@ts-ignore
21989
+ fc._isSelected = categorySlugs_1.some(function (slug) { return slug === fc.slug; });
21990
+ });
21973
21991
  }
21974
21992
  }
21975
21993
  }
@@ -22015,11 +22033,13 @@ var IkasProductList = /** @class */ (function () {
22015
22033
  }
22016
22034
  };
22017
22035
  IkasProductList.prototype.clearFilters = function () {
22018
- var _a;
22036
+ var _a, _b;
22019
22037
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22020
22038
  this._searchKeyword = "";
22021
22039
  if (this._pageType !== exports.IkasThemePageType.CATEGORY) {
22022
22040
  this._filterCategoryId = undefined;
22041
+ //@ts-ignore
22042
+ (_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (fc) { return (fc._isSelected = false); });
22023
22043
  }
22024
22044
  this.applyFilters();
22025
22045
  };
@@ -22041,18 +22061,15 @@ var IkasProductList = /** @class */ (function () {
22041
22061
  var _a, _b;
22042
22062
  if (disableRoute === void 0) { disableRoute = false; }
22043
22063
  return __awaiter(this, void 0, void 0, function () {
22044
- var _this = this;
22045
22064
  return __generator(this, function (_c) {
22046
22065
  switch (_c.label) {
22047
22066
  case 0:
22048
22067
  if (!disableRoute) return [3 /*break*/, 2];
22049
- if (this._filterCategoryId === filterCategory.id)
22050
- this._filterCategoryId = undefined;
22051
- else
22052
- this._filterCategoryId = filterCategory.id;
22053
22068
  (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22054
- //@ts-ignore
22055
- fc._isSelected = fc.id === _this._filterCategoryId;
22069
+ if (fc.id === filterCategory.id) {
22070
+ //@ts-ignore
22071
+ fc._isSelected = !fc.isSelected;
22072
+ }
22056
22073
  });
22057
22074
  return [4 /*yield*/, this.applyFilters()];
22058
22075
  case 1:
@@ -36,7 +36,7 @@ export declare class IkasProductList {
36
36
  set searchKeyword(value: string);
37
37
  get isInitialized(): boolean;
38
38
  get isFilterable(): boolean;
39
- get isFiltered(): boolean;
39
+ get isFiltered(): boolean | undefined;
40
40
  get isStatic(): boolean;
41
41
  get isDiscounted(): boolean;
42
42
  get isRecommended(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.158-alpha.11",
3
+ "version": "0.0.158-alpha.12",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",