@ikas/storefront 0.0.158-alpha.7 → 0.0.158-alpha.9

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
@@ -11061,6 +11061,8 @@ var IkasCategoryPath = /** @class */ (function () {
11061
11061
  }());
11062
11062
  var IkasFilterCategory = /** @class */ (function () {
11063
11063
  function IkasFilterCategory(data) {
11064
+ // Extra
11065
+ this._isSelected = false;
11064
11066
  this.id = data.id || "";
11065
11067
  this.name = data.name || "";
11066
11068
  this.slug = data.slug || "";
@@ -11068,8 +11070,16 @@ var IkasFilterCategory = /** @class */ (function () {
11068
11070
  data.resultCount !== undefined && data.resultCount !== null
11069
11071
  ? data.resultCount
11070
11072
  : null;
11073
+ this._isSelected = data.isSelected || false;
11071
11074
  makeAutoObservable(this);
11072
11075
  }
11076
+ Object.defineProperty(IkasFilterCategory.prototype, "isSelected", {
11077
+ get: function () {
11078
+ return this._isSelected;
11079
+ },
11080
+ enumerable: false,
11081
+ configurable: true
11082
+ });
11073
11083
  Object.defineProperty(IkasFilterCategory.prototype, "href", {
11074
11084
  get: function () {
11075
11085
  if (!this.slug)
@@ -11079,6 +11089,9 @@ var IkasFilterCategory = /** @class */ (function () {
11079
11089
  enumerable: false,
11080
11090
  configurable: true
11081
11091
  });
11092
+ IkasFilterCategory.prototype.toJSON = function () {
11093
+ return __assign(__assign({}, this), { isSelected: this._isSelected });
11094
+ };
11082
11095
  return IkasFilterCategory;
11083
11096
  }());
11084
11097
 
@@ -17869,17 +17882,25 @@ var IkasCustomerStore = /** @class */ (function () {
17869
17882
  });
17870
17883
  };
17871
17884
  IkasCustomerStore.prototype.saveLastViewedProducts = function () {
17885
+ if (isServer$3)
17886
+ return;
17872
17887
  window.localStorage.setItem(LS_LAST_VIEWED_PRODUCTS_KEY, JSON.stringify(this._lastViewedProducts));
17873
17888
  };
17874
17889
  IkasCustomerStore.prototype.loadLastViewedProducts = function () {
17890
+ if (isServer$3)
17891
+ return;
17875
17892
  try {
17876
17893
  var lvpStr = window.localStorage.getItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17877
- if (lvpStr)
17894
+ if (lvpStr) {
17878
17895
  this._lastViewedProducts = JSON.parse(lvpStr);
17896
+ this._lastViewedProducts = this._lastViewedProducts.reverse();
17897
+ }
17879
17898
  }
17880
17899
  catch (err) { }
17881
17900
  };
17882
17901
  IkasCustomerStore.prototype.removeLastViewedProducts = function () {
17902
+ if (isServer$3)
17903
+ return;
17883
17904
  window.localStorage.removeItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17884
17905
  };
17885
17906
  IkasCustomerStore.prototype.onProductView = function (productId, variantId) {
@@ -17919,36 +17940,46 @@ var IkasCustomerStore = /** @class */ (function () {
17919
17940
  return __generator(this, function (_a) {
17920
17941
  switch (_a.label) {
17921
17942
  case 0:
17922
- _a.trys.push([0, 3, , 4]);
17943
+ if (isServer$3)
17944
+ return [2 /*return*/];
17945
+ _a.label = 1;
17946
+ case 1:
17947
+ _a.trys.push([1, 4, , 5]);
17923
17948
  this.loadLastViewedProducts();
17924
- if (!this._lastViewedProducts.length) return [3 /*break*/, 2];
17949
+ if (!this._lastViewedProducts.length) return [3 /*break*/, 3];
17925
17950
  return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
17926
17951
  customerId: this.customer.id,
17927
17952
  products: this._lastViewedProducts,
17928
17953
  })];
17929
- case 1:
17954
+ case 2:
17930
17955
  isSuccess = _a.sent();
17931
17956
  if (isSuccess) {
17932
17957
  this.removeLastViewedProducts();
17933
17958
  }
17934
- _a.label = 2;
17935
- case 2: return [3 /*break*/, 4];
17936
- case 3:
17959
+ _a.label = 3;
17960
+ case 3: return [3 /*break*/, 5];
17961
+ case 4:
17937
17962
  _a.sent();
17938
- return [3 /*break*/, 4];
17939
- case 4: return [2 /*return*/];
17963
+ return [3 /*break*/, 5];
17964
+ case 5: return [2 /*return*/];
17940
17965
  }
17941
17966
  });
17942
17967
  });
17943
17968
  };
17944
17969
  IkasCustomerStore.prototype.saveCustomerConsent = function () {
17970
+ if (isServer$3)
17971
+ return;
17945
17972
  this._customerConsentGranted = true;
17946
17973
  window.localStorage.setItem(LS_CUSTOMER_CONSENT, "true");
17947
17974
  };
17948
17975
  IkasCustomerStore.prototype.loadCustomerConsent = function () {
17976
+ if (isServer$3)
17977
+ return;
17949
17978
  this._customerConsentGranted = !!window.localStorage.getItem(LS_CUSTOMER_CONSENT);
17950
17979
  };
17951
17980
  IkasCustomerStore.prototype.removeCustomerConsent = function () {
17981
+ if (isServer$3)
17982
+ return;
17952
17983
  window.localStorage.removeItem(LS_CUSTOMER_CONSENT);
17953
17984
  };
17954
17985
  IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
@@ -21636,18 +21667,6 @@ var IkasProductList = /** @class */ (function () {
21636
21667
  }
21637
21668
  }
21638
21669
  }
21639
- Object.defineProperty(IkasProductList.prototype, "id", {
21640
- get: function () {
21641
- var id = this._productListPropValue.id;
21642
- if (this._filterCategoryId)
21643
- id += this._filterCategoryId;
21644
- if (this._filterBrandId)
21645
- id += this._filterBrandId;
21646
- return id;
21647
- },
21648
- enumerable: false,
21649
- configurable: true
21650
- });
21651
21670
  Object.defineProperty(IkasProductList.prototype, "sort", {
21652
21671
  get: function () {
21653
21672
  return this._sort;
@@ -22036,22 +22055,29 @@ var IkasProductList = /** @class */ (function () {
22036
22055
  });
22037
22056
  };
22038
22057
  IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22039
- var _a;
22058
+ var _a, _b;
22040
22059
  if (disableRoute === void 0) { disableRoute = false; }
22041
22060
  return __awaiter(this, void 0, void 0, function () {
22042
- return __generator(this, function (_b) {
22043
- switch (_b.label) {
22061
+ return __generator(this, function (_c) {
22062
+ switch (_c.label) {
22044
22063
  case 0:
22045
22064
  if (!disableRoute) return [3 /*break*/, 2];
22046
- this._filterCategoryId = filterCategory.id;
22065
+ if (this._filterCategoryId === filterCategory.id)
22066
+ this._filterCategoryId = undefined;
22067
+ else
22068
+ this._filterCategoryId = filterCategory.id;
22069
+ (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22070
+ //@ts-ignore
22071
+ fc._isSelected = fc.id === filterCategory.id;
22072
+ });
22047
22073
  return [4 /*yield*/, this.applyFilters()];
22048
22074
  case 1:
22049
- _b.sent();
22075
+ _c.sent();
22050
22076
  return [3 /*break*/, 3];
22051
22077
  case 2:
22052
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22078
+ (_b = this.router) === null || _b === void 0 ? void 0 : _b.push(filterCategory.href +
22053
22079
  (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22054
- _b.label = 3;
22080
+ _c.label = 3;
22055
22081
  case 3: return [2 /*return*/];
22056
22082
  }
22057
22083
  });
package/build/index.js CHANGED
@@ -11075,6 +11075,8 @@ var IkasCategoryPath = /** @class */ (function () {
11075
11075
  }());
11076
11076
  var IkasFilterCategory = /** @class */ (function () {
11077
11077
  function IkasFilterCategory(data) {
11078
+ // Extra
11079
+ this._isSelected = false;
11078
11080
  this.id = data.id || "";
11079
11081
  this.name = data.name || "";
11080
11082
  this.slug = data.slug || "";
@@ -11082,8 +11084,16 @@ var IkasFilterCategory = /** @class */ (function () {
11082
11084
  data.resultCount !== undefined && data.resultCount !== null
11083
11085
  ? data.resultCount
11084
11086
  : null;
11087
+ this._isSelected = data.isSelected || false;
11085
11088
  mobx.makeAutoObservable(this);
11086
11089
  }
11090
+ Object.defineProperty(IkasFilterCategory.prototype, "isSelected", {
11091
+ get: function () {
11092
+ return this._isSelected;
11093
+ },
11094
+ enumerable: false,
11095
+ configurable: true
11096
+ });
11087
11097
  Object.defineProperty(IkasFilterCategory.prototype, "href", {
11088
11098
  get: function () {
11089
11099
  if (!this.slug)
@@ -11093,6 +11103,9 @@ var IkasFilterCategory = /** @class */ (function () {
11093
11103
  enumerable: false,
11094
11104
  configurable: true
11095
11105
  });
11106
+ IkasFilterCategory.prototype.toJSON = function () {
11107
+ return __assign(__assign({}, this), { isSelected: this._isSelected });
11108
+ };
11096
11109
  return IkasFilterCategory;
11097
11110
  }());
11098
11111
 
@@ -17875,17 +17888,25 @@ var IkasCustomerStore = /** @class */ (function () {
17875
17888
  });
17876
17889
  };
17877
17890
  IkasCustomerStore.prototype.saveLastViewedProducts = function () {
17891
+ if (isServer$3)
17892
+ return;
17878
17893
  window.localStorage.setItem(LS_LAST_VIEWED_PRODUCTS_KEY, JSON.stringify(this._lastViewedProducts));
17879
17894
  };
17880
17895
  IkasCustomerStore.prototype.loadLastViewedProducts = function () {
17896
+ if (isServer$3)
17897
+ return;
17881
17898
  try {
17882
17899
  var lvpStr = window.localStorage.getItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17883
- if (lvpStr)
17900
+ if (lvpStr) {
17884
17901
  this._lastViewedProducts = JSON.parse(lvpStr);
17902
+ this._lastViewedProducts = this._lastViewedProducts.reverse();
17903
+ }
17885
17904
  }
17886
17905
  catch (err) { }
17887
17906
  };
17888
17907
  IkasCustomerStore.prototype.removeLastViewedProducts = function () {
17908
+ if (isServer$3)
17909
+ return;
17889
17910
  window.localStorage.removeItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17890
17911
  };
17891
17912
  IkasCustomerStore.prototype.onProductView = function (productId, variantId) {
@@ -17925,36 +17946,46 @@ var IkasCustomerStore = /** @class */ (function () {
17925
17946
  return __generator(this, function (_a) {
17926
17947
  switch (_a.label) {
17927
17948
  case 0:
17928
- _a.trys.push([0, 3, , 4]);
17949
+ if (isServer$3)
17950
+ return [2 /*return*/];
17951
+ _a.label = 1;
17952
+ case 1:
17953
+ _a.trys.push([1, 4, , 5]);
17929
17954
  this.loadLastViewedProducts();
17930
- if (!this._lastViewedProducts.length) return [3 /*break*/, 2];
17955
+ if (!this._lastViewedProducts.length) return [3 /*break*/, 3];
17931
17956
  return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
17932
17957
  customerId: this.customer.id,
17933
17958
  products: this._lastViewedProducts,
17934
17959
  })];
17935
- case 1:
17960
+ case 2:
17936
17961
  isSuccess = _a.sent();
17937
17962
  if (isSuccess) {
17938
17963
  this.removeLastViewedProducts();
17939
17964
  }
17940
- _a.label = 2;
17941
- case 2: return [3 /*break*/, 4];
17942
- case 3:
17965
+ _a.label = 3;
17966
+ case 3: return [3 /*break*/, 5];
17967
+ case 4:
17943
17968
  _a.sent();
17944
- return [3 /*break*/, 4];
17945
- case 4: return [2 /*return*/];
17969
+ return [3 /*break*/, 5];
17970
+ case 5: return [2 /*return*/];
17946
17971
  }
17947
17972
  });
17948
17973
  });
17949
17974
  };
17950
17975
  IkasCustomerStore.prototype.saveCustomerConsent = function () {
17976
+ if (isServer$3)
17977
+ return;
17951
17978
  this._customerConsentGranted = true;
17952
17979
  window.localStorage.setItem(LS_CUSTOMER_CONSENT, "true");
17953
17980
  };
17954
17981
  IkasCustomerStore.prototype.loadCustomerConsent = function () {
17982
+ if (isServer$3)
17983
+ return;
17955
17984
  this._customerConsentGranted = !!window.localStorage.getItem(LS_CUSTOMER_CONSENT);
17956
17985
  };
17957
17986
  IkasCustomerStore.prototype.removeCustomerConsent = function () {
17987
+ if (isServer$3)
17988
+ return;
17958
17989
  window.localStorage.removeItem(LS_CUSTOMER_CONSENT);
17959
17990
  };
17960
17991
  IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
@@ -21619,18 +21650,6 @@ var IkasProductList = /** @class */ (function () {
21619
21650
  }
21620
21651
  }
21621
21652
  }
21622
- Object.defineProperty(IkasProductList.prototype, "id", {
21623
- get: function () {
21624
- var id = this._productListPropValue.id;
21625
- if (this._filterCategoryId)
21626
- id += this._filterCategoryId;
21627
- if (this._filterBrandId)
21628
- id += this._filterBrandId;
21629
- return id;
21630
- },
21631
- enumerable: false,
21632
- configurable: true
21633
- });
21634
21653
  Object.defineProperty(IkasProductList.prototype, "sort", {
21635
21654
  get: function () {
21636
21655
  return this._sort;
@@ -22019,22 +22038,29 @@ var IkasProductList = /** @class */ (function () {
22019
22038
  });
22020
22039
  };
22021
22040
  IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22022
- var _a;
22041
+ var _a, _b;
22023
22042
  if (disableRoute === void 0) { disableRoute = false; }
22024
22043
  return __awaiter(this, void 0, void 0, function () {
22025
- return __generator(this, function (_b) {
22026
- switch (_b.label) {
22044
+ return __generator(this, function (_c) {
22045
+ switch (_c.label) {
22027
22046
  case 0:
22028
22047
  if (!disableRoute) return [3 /*break*/, 2];
22029
- this._filterCategoryId = filterCategory.id;
22048
+ if (this._filterCategoryId === filterCategory.id)
22049
+ this._filterCategoryId = undefined;
22050
+ else
22051
+ this._filterCategoryId = filterCategory.id;
22052
+ (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22053
+ //@ts-ignore
22054
+ fc._isSelected = fc.id === filterCategory.id;
22055
+ });
22030
22056
  return [4 /*yield*/, this.applyFilters()];
22031
22057
  case 1:
22032
- _b.sent();
22058
+ _c.sent();
22033
22059
  return [3 /*break*/, 3];
22034
22060
  case 2:
22035
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22061
+ (_b = this.router) === null || _b === void 0 ? void 0 : _b.push(filterCategory.href +
22036
22062
  (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22037
- _b.label = 3;
22063
+ _c.label = 3;
22038
22064
  case 3: return [2 /*return*/];
22039
22065
  }
22040
22066
  });
@@ -22,6 +22,11 @@ export declare class IkasFilterCategory {
22
22
  name: string;
23
23
  slug?: string | null;
24
24
  resultCount?: number | null;
25
+ private _isSelected?;
25
26
  constructor(data: Partial<IkasFilterCategory>);
27
+ get isSelected(): boolean | undefined;
26
28
  get href(): string;
29
+ toJSON(): this & {
30
+ isSelected: boolean | undefined;
31
+ };
27
32
  }
@@ -25,7 +25,6 @@ export declare class IkasProductList {
25
25
  private _fetchRequestTime;
26
26
  private router?;
27
27
  constructor(data: IkasProductListParams, router?: NextRouter);
28
- private get id();
29
28
  get sort(): IkasProductListSortType;
30
29
  get limit(): number;
31
30
  get pageType(): IkasThemePageType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.158-alpha.7",
3
+ "version": "0.0.158-alpha.9",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",