@ikas/storefront 0.0.152 → 0.0.154

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
@@ -19966,7 +19966,10 @@ var IkasProductDetail = /** @class */ (function () {
19966
19966
  .map(function (vv) { return vv.slug; })
19967
19967
  .join("-");
19968
19968
  var isShallow = process.env.NODE_ENV !== "production";
19969
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, { shallow: isShallow });
19969
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, {
19970
+ shallow: isShallow,
19971
+ scroll: false,
19972
+ });
19970
19973
  };
19971
19974
  return IkasProductDetail;
19972
19975
  }());
@@ -21138,7 +21141,7 @@ var IkasProductList = /** @class */ (function () {
21138
21141
  _b.label = 1;
21139
21142
  case 1:
21140
21143
  _b.trys.push([1, 5, 6, 7]);
21141
- page = 1;
21144
+ page = this._page || 1;
21142
21145
  limit = this._limit;
21143
21146
  if (!(this.isFilterable && !this.filters)) return [3 /*break*/, 3];
21144
21147
  return [4 /*yield*/, this.getFilters()];
@@ -21360,11 +21363,16 @@ var IkasProductList = /** @class */ (function () {
21360
21363
  : null;
21361
21364
  this.router = router;
21362
21365
  makeAutoObservable(this);
21363
- if (this.isBrowser() &&
21364
- location.search &&
21365
- (this.isFilterable || this._type === IkasProductListType.SEARCH)) {
21366
- var queryParams = this.getQueryParams();
21367
- this.getInitial(queryParams);
21366
+ if (this.isBrowser()) {
21367
+ this.checkRestoreInfiniteScroll();
21368
+ if (location.search &&
21369
+ (this.isFilterable || this._type === IkasProductListType.SEARCH)) {
21370
+ var queryParams = this.getQueryParams();
21371
+ this.getInitial(queryParams);
21372
+ }
21373
+ else if (this._page > 1) {
21374
+ this.getInitial();
21375
+ }
21368
21376
  }
21369
21377
  }
21370
21378
  Object.defineProperty(IkasProductList.prototype, "sort", {
@@ -21381,6 +21389,13 @@ var IkasProductList = /** @class */ (function () {
21381
21389
  enumerable: false,
21382
21390
  configurable: true
21383
21391
  });
21392
+ Object.defineProperty(IkasProductList.prototype, "pageType", {
21393
+ get: function () {
21394
+ return this._pageType;
21395
+ },
21396
+ enumerable: false,
21397
+ configurable: true
21398
+ });
21384
21399
  Object.defineProperty(IkasProductList.prototype, "page", {
21385
21400
  get: function () {
21386
21401
  return this._page;
@@ -21752,6 +21767,11 @@ var IkasProductList = /** @class */ (function () {
21752
21767
  });
21753
21768
  });
21754
21769
  };
21770
+ IkasProductList.prototype.setVisibleInfiniteScrollPage = function (page) {
21771
+ //@ts-ignore
21772
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21773
+ infiniteScrollPages[this._productListPropValue.id] = page;
21774
+ };
21755
21775
  IkasProductList.prototype.toJSON = function () {
21756
21776
  return {
21757
21777
  data: this.data,
@@ -21772,6 +21792,22 @@ var IkasProductList = /** @class */ (function () {
21772
21792
  productListPropValue: this._productListPropValue,
21773
21793
  };
21774
21794
  };
21795
+ IkasProductList.prototype.checkRestoreInfiniteScroll = function () {
21796
+ //@ts-ignore
21797
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21798
+ var page = infiniteScrollPages[this._productListPropValue.id];
21799
+ if (page) {
21800
+ if (this.hasForwardRoute()) {
21801
+ this._page = page;
21802
+ }
21803
+ else {
21804
+ delete infiniteScrollPages[this._productListPropValue.id];
21805
+ }
21806
+ }
21807
+ };
21808
+ IkasProductList.prototype.hasForwardRoute = function () {
21809
+ return this.isBrowser() && !!window.history.forward;
21810
+ };
21775
21811
  IkasProductList.prototype.getQueryParams = function () {
21776
21812
  if (!this.isBrowser())
21777
21813
  return;
@@ -23709,6 +23745,7 @@ var IkasProductListPropValue = /** @class */ (function () {
23709
23745
  // Example collections/man -> lists products inside the "man" category
23710
23746
  this.usePageFilter = null;
23711
23747
  this.category = null;
23748
+ this.id = data.id || "";
23712
23749
  this.productListType = data.productListType || IkasProductListType.ALL;
23713
23750
  this.initialSort = data.initialSort || IkasProductListSortType.LAST_ADDED;
23714
23751
  this.initialLimit = data.initialLimit || 20;
@@ -31366,6 +31403,7 @@ var IkasBaseStore = /** @class */ (function () {
31366
31403
  this.showLocaleOptions = false;
31367
31404
  this.localeChecked = false;
31368
31405
  this.settingsSet = false;
31406
+ this.infiniteScrollPages = {}; // key is productListPropValueId
31369
31407
  this.customerStore = new IkasCustomerStore(this);
31370
31408
  this.cartStore = new IkasCartStore(this);
31371
31409
  makeObservable(this, {
package/build/index.js CHANGED
@@ -19949,7 +19949,10 @@ var IkasProductDetail = /** @class */ (function () {
19949
19949
  .map(function (vv) { return vv.slug; })
19950
19950
  .join("-");
19951
19951
  var isShallow = process.env.NODE_ENV !== "production";
19952
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, { shallow: isShallow });
19952
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, {
19953
+ shallow: isShallow,
19954
+ scroll: false,
19955
+ });
19953
19956
  };
19954
19957
  return IkasProductDetail;
19955
19958
  }());
@@ -21121,7 +21124,7 @@ var IkasProductList = /** @class */ (function () {
21121
21124
  _b.label = 1;
21122
21125
  case 1:
21123
21126
  _b.trys.push([1, 5, 6, 7]);
21124
- page = 1;
21127
+ page = this._page || 1;
21125
21128
  limit = this._limit;
21126
21129
  if (!(this.isFilterable && !this.filters)) return [3 /*break*/, 3];
21127
21130
  return [4 /*yield*/, this.getFilters()];
@@ -21343,11 +21346,16 @@ var IkasProductList = /** @class */ (function () {
21343
21346
  : null;
21344
21347
  this.router = router;
21345
21348
  mobx.makeAutoObservable(this);
21346
- if (this.isBrowser() &&
21347
- location.search &&
21348
- (this.isFilterable || this._type === exports.IkasProductListType.SEARCH)) {
21349
- var queryParams = this.getQueryParams();
21350
- this.getInitial(queryParams);
21349
+ if (this.isBrowser()) {
21350
+ this.checkRestoreInfiniteScroll();
21351
+ if (location.search &&
21352
+ (this.isFilterable || this._type === exports.IkasProductListType.SEARCH)) {
21353
+ var queryParams = this.getQueryParams();
21354
+ this.getInitial(queryParams);
21355
+ }
21356
+ else if (this._page > 1) {
21357
+ this.getInitial();
21358
+ }
21351
21359
  }
21352
21360
  }
21353
21361
  Object.defineProperty(IkasProductList.prototype, "sort", {
@@ -21364,6 +21372,13 @@ var IkasProductList = /** @class */ (function () {
21364
21372
  enumerable: false,
21365
21373
  configurable: true
21366
21374
  });
21375
+ Object.defineProperty(IkasProductList.prototype, "pageType", {
21376
+ get: function () {
21377
+ return this._pageType;
21378
+ },
21379
+ enumerable: false,
21380
+ configurable: true
21381
+ });
21367
21382
  Object.defineProperty(IkasProductList.prototype, "page", {
21368
21383
  get: function () {
21369
21384
  return this._page;
@@ -21735,6 +21750,11 @@ var IkasProductList = /** @class */ (function () {
21735
21750
  });
21736
21751
  });
21737
21752
  };
21753
+ IkasProductList.prototype.setVisibleInfiniteScrollPage = function (page) {
21754
+ //@ts-ignore
21755
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21756
+ infiniteScrollPages[this._productListPropValue.id] = page;
21757
+ };
21738
21758
  IkasProductList.prototype.toJSON = function () {
21739
21759
  return {
21740
21760
  data: this.data,
@@ -21755,6 +21775,22 @@ var IkasProductList = /** @class */ (function () {
21755
21775
  productListPropValue: this._productListPropValue,
21756
21776
  };
21757
21777
  };
21778
+ IkasProductList.prototype.checkRestoreInfiniteScroll = function () {
21779
+ //@ts-ignore
21780
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21781
+ var page = infiniteScrollPages[this._productListPropValue.id];
21782
+ if (page) {
21783
+ if (this.hasForwardRoute()) {
21784
+ this._page = page;
21785
+ }
21786
+ else {
21787
+ delete infiniteScrollPages[this._productListPropValue.id];
21788
+ }
21789
+ }
21790
+ };
21791
+ IkasProductList.prototype.hasForwardRoute = function () {
21792
+ return this.isBrowser() && !!window.history.forward;
21793
+ };
21758
21794
  IkasProductList.prototype.getQueryParams = function () {
21759
21795
  if (!this.isBrowser())
21760
21796
  return;
@@ -23689,6 +23725,7 @@ var IkasProductListPropValue = /** @class */ (function () {
23689
23725
  // Example collections/man -> lists products inside the "man" category
23690
23726
  this.usePageFilter = null;
23691
23727
  this.category = null;
23728
+ this.id = data.id || "";
23692
23729
  this.productListType = data.productListType || exports.IkasProductListType.ALL;
23693
23730
  this.initialSort = data.initialSort || exports.IkasProductListSortType.LAST_ADDED;
23694
23731
  this.initialLimit = data.initialLimit || 20;
@@ -31345,6 +31382,7 @@ var IkasBaseStore = /** @class */ (function () {
31345
31382
  this.showLocaleOptions = false;
31346
31383
  this.localeChecked = false;
31347
31384
  this.settingsSet = false;
31385
+ this.infiniteScrollPages = {}; // key is productListPropValueId
31348
31386
  this.customerStore = new IkasCustomerStore(this);
31349
31387
  this.cartStore = new IkasCartStore(this);
31350
31388
  mobx.makeObservable(this, {
@@ -1,5 +1,6 @@
1
1
  import { IkasProductListSortType, IkasProductListType } from "../../../../ui/index";
2
2
  export declare class IkasProductListPropValue {
3
+ id: string;
3
4
  productListType: IkasProductListType;
4
5
  initialSort?: IkasProductListSortType | null;
5
6
  initialLimit?: number | null;
@@ -26,6 +26,7 @@ export declare class IkasProductList {
26
26
  constructor(data: IkasProductListParams, router?: NextRouter);
27
27
  get sort(): IkasProductListSortType;
28
28
  get limit(): number;
29
+ get pageType(): IkasThemePageType;
29
30
  get page(): number;
30
31
  get count(): number;
31
32
  get pageCount(): number;
@@ -57,6 +58,7 @@ export declare class IkasProductList {
57
58
  getPage: (page: number) => Promise<void>;
58
59
  setSortType(sortType: IkasProductListSortType): Promise<void>;
59
60
  onFilterCategoryClick(filterCategory: IkasFilterCategory, disableRoute?: boolean): Promise<void>;
61
+ setVisibleInfiniteScrollPage(page: number): void;
60
62
  toJSON(): {
61
63
  data: IkasProductDetail[];
62
64
  type: IkasProductListType;
@@ -75,6 +77,8 @@ export declare class IkasProductList {
75
77
  recommendFor: string | null | undefined;
76
78
  productListPropValue: IkasProductListPropValue;
77
79
  };
80
+ private checkRestoreInfiniteScroll;
81
+ private hasForwardRoute;
78
82
  private getQueryParams;
79
83
  private isBrowser;
80
84
  private searchDebouncer;
@@ -10,6 +10,7 @@ export declare class IkasBaseStore {
10
10
  showLocaleOptions: boolean;
11
11
  private localeChecked;
12
12
  private settingsSet;
13
+ private infiniteScrollPages;
13
14
  constructor();
14
15
  checkLocalization(): Promise<void>;
15
16
  setLocalization(localeOption: IkasLocaleOption): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.152",
3
+ "version": "0.0.154",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",