@getlupa/client 0.6.0-alpha-21 → 0.6.0-alpha-22

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 { SearchResultsFilterOptions } from "@/types/search-results/SearchResults
2
2
  import Vue from "vue";
3
3
  export default class MobileFilterSidebar extends Vue {
4
4
  options: SearchResultsFilterOptions;
5
- setSidebarVisibility: ({ visible, }: {
5
+ setSidebarState: ({ visible, }: {
6
6
  visible: boolean;
7
7
  }) => void;
8
8
  isMobileSidebarVisible: boolean;
@@ -3,7 +3,7 @@ export default class SearchResultsMobileToggle extends Vue {
3
3
  label: string;
4
4
  showFilterCount: boolean;
5
5
  currentFilterCount: number;
6
- setSidebarVisibility: ({ visible, }: {
6
+ setSidebarState: ({ visible, }: {
7
7
  visible: boolean;
8
8
  }) => void;
9
9
  handleMobileToggle(): void;
@@ -15760,6 +15760,17 @@ const scrollTo = (elementId) => {
15760
15760
  top: el.offsetTop,
15761
15761
  behavior: "smooth",
15762
15762
  });
15763
+ };
15764
+ const disableBodyScroll = () => {
15765
+ const scrollY = window.scrollY;
15766
+ document.body.style.position = "fixed";
15767
+ document.body.style.top = `-${scrollY}px`;
15768
+ };
15769
+ const enableBodyScroll = () => {
15770
+ const scrollY = document.body.style.top;
15771
+ document.body.style.position = "";
15772
+ document.body.style.top = "";
15773
+ window.scrollTo(0, parseInt(scrollY || "0") * -1);
15763
15774
  };
15764
15775
 
15765
15776
  const searchResult$g = namespace("searchResult");
@@ -16278,15 +16289,15 @@ let MobileFilterSidebar = class MobileFilterSidebar extends Vue$1 {
16278
16289
  return !((_b = (_a = this.options.currentFilters) === null || _a === void 0 ? void 0 : _a.mobileSidebar) === null || _b === void 0 ? void 0 : _b.activeFiltersExpanded);
16279
16290
  }
16280
16291
  handleMobileToggle() {
16281
- this.setSidebarVisibility({ visible: false });
16292
+ this.setSidebarState({ visible: false });
16282
16293
  }
16283
16294
  };
16284
16295
  __decorate([
16285
16296
  Prop()
16286
16297
  ], MobileFilterSidebar.prototype, "options", void 0);
16287
16298
  __decorate([
16288
- searchResult$f.Mutation("setSidebarVisibility")
16289
- ], MobileFilterSidebar.prototype, "setSidebarVisibility", void 0);
16299
+ searchResult$f.Action("setSidebarState")
16300
+ ], MobileFilterSidebar.prototype, "setSidebarState", void 0);
16290
16301
  __decorate([
16291
16302
  searchResult$f.State((state) => state.isMobileSidebarVisible)
16292
16303
  ], MobileFilterSidebar.prototype, "isMobileSidebarVisible", void 0);
@@ -19106,7 +19117,7 @@ __vue_render__$f._withStripped = true;
19106
19117
  const searchResult$8 = namespace("searchResult");
19107
19118
  let SearchResultsMobileToggle = class SearchResultsMobileToggle extends Vue$1 {
19108
19119
  handleMobileToggle() {
19109
- this.setSidebarVisibility({ visible: true });
19120
+ this.setSidebarState({ visible: true });
19110
19121
  }
19111
19122
  };
19112
19123
  __decorate([
@@ -19119,8 +19130,8 @@ __decorate([
19119
19130
  searchResult$8.Getter("currentFilterCount")
19120
19131
  ], SearchResultsMobileToggle.prototype, "currentFilterCount", void 0);
19121
19132
  __decorate([
19122
- searchResult$8.Mutation("setSidebarVisibility")
19123
- ], SearchResultsMobileToggle.prototype, "setSidebarVisibility", void 0);
19133
+ searchResult$8.Action("setSidebarState")
19134
+ ], SearchResultsMobileToggle.prototype, "setSidebarState", void 0);
19124
19135
  SearchResultsMobileToggle = __decorate([
19125
19136
  Component({
19126
19137
  name: "searchResultsMobileToggle",
@@ -19887,10 +19898,7 @@ var __vue_render__$8 = function () {
19887
19898
  var _c = _vm._self._c || _h;
19888
19899
  return _c(
19889
19900
  "div",
19890
- {
19891
- style: { display: _vm.isMobileSidebarVisible ? "none" : "block" },
19892
- attrs: { id: "lupa-search-results-products" },
19893
- },
19901
+ { attrs: { id: "lupa-search-results-products" } },
19894
19902
  [
19895
19903
  _vm.loading && !_vm.isMobileSidebarVisible
19896
19904
  ? _c("spinner", { staticClass: "lupa-loader" })
@@ -21702,6 +21710,16 @@ let SearchResultModule = class SearchResultModule extends VuexModule {
21702
21710
  var _a;
21703
21711
  return (this.hasResults && ((_a = this.searchResult.offset) !== null && _a !== void 0 ? _a : 0) >= this.totalItems);
21704
21712
  }
21713
+ setSidebarState({ visible }) {
21714
+ // Disable body scroll when sidebar is open and preserve scroll position when scrolling is closed
21715
+ if (visible) {
21716
+ disableBodyScroll();
21717
+ }
21718
+ else {
21719
+ enableBodyScroll();
21720
+ }
21721
+ return { visible };
21722
+ }
21705
21723
  setSidebarVisibility({ visible }) {
21706
21724
  this.isMobileSidebarVisible = visible;
21707
21725
  }
@@ -21781,6 +21799,9 @@ let SearchResultModule = class SearchResultModule extends VuexModule {
21781
21799
  return loading || false;
21782
21800
  }
21783
21801
  };
21802
+ __decorate([
21803
+ Action({ commit: "setSidebarVisibility" })
21804
+ ], SearchResultModule.prototype, "setSidebarState", null);
21784
21805
  __decorate([
21785
21806
  Mutation
21786
21807
  ], SearchResultModule.prototype, "setSidebarVisibility", null);
@@ -27,6 +27,11 @@ export default class SearchResultModule extends VuexModule {
27
27
  get isMobileWidth(): boolean;
28
28
  get currentScreenWidth(): ScreenSize;
29
29
  get isPageEmpty(): boolean;
30
+ setSidebarState({ visible }: {
31
+ visible: boolean;
32
+ }): {
33
+ visible: boolean;
34
+ };
30
35
  setSidebarVisibility({ visible }: {
31
36
  visible: boolean;
32
37
  }): void;
@@ -1,2 +1,4 @@
1
1
  export declare const scrollToSearchResults: (timeout?: number) => void;
2
2
  export declare const scrollTo: (elementId: string) => void;
3
+ export declare const disableBodyScroll: () => void;
4
+ export declare const enableBodyScroll: () => void;
@@ -2,7 +2,7 @@ import { SearchResultsFilterOptions } from "@/types/search-results/SearchResults
2
2
  import Vue from "vue";
3
3
  export default class MobileFilterSidebar extends Vue {
4
4
  options: SearchResultsFilterOptions;
5
- setSidebarVisibility: ({ visible, }: {
5
+ setSidebarState: ({ visible, }: {
6
6
  visible: boolean;
7
7
  }) => void;
8
8
  isMobileSidebarVisible: boolean;
@@ -3,7 +3,7 @@ export default class SearchResultsMobileToggle extends Vue {
3
3
  label: string;
4
4
  showFilterCount: boolean;
5
5
  currentFilterCount: number;
6
- setSidebarVisibility: ({ visible, }: {
6
+ setSidebarState: ({ visible, }: {
7
7
  visible: boolean;
8
8
  }) => void;
9
9
  handleMobileToggle(): void;
@@ -15756,6 +15756,17 @@ const scrollTo = (elementId) => {
15756
15756
  top: el.offsetTop,
15757
15757
  behavior: "smooth",
15758
15758
  });
15759
+ };
15760
+ const disableBodyScroll = () => {
15761
+ const scrollY = window.scrollY;
15762
+ document.body.style.position = "fixed";
15763
+ document.body.style.top = `-${scrollY}px`;
15764
+ };
15765
+ const enableBodyScroll = () => {
15766
+ const scrollY = document.body.style.top;
15767
+ document.body.style.position = "";
15768
+ document.body.style.top = "";
15769
+ window.scrollTo(0, parseInt(scrollY || "0") * -1);
15759
15770
  };
15760
15771
 
15761
15772
  const searchResult$g = namespace("searchResult");
@@ -16274,15 +16285,15 @@ let MobileFilterSidebar = class MobileFilterSidebar extends Vue$1 {
16274
16285
  return !((_b = (_a = this.options.currentFilters) === null || _a === void 0 ? void 0 : _a.mobileSidebar) === null || _b === void 0 ? void 0 : _b.activeFiltersExpanded);
16275
16286
  }
16276
16287
  handleMobileToggle() {
16277
- this.setSidebarVisibility({ visible: false });
16288
+ this.setSidebarState({ visible: false });
16278
16289
  }
16279
16290
  };
16280
16291
  __decorate([
16281
16292
  Prop()
16282
16293
  ], MobileFilterSidebar.prototype, "options", void 0);
16283
16294
  __decorate([
16284
- searchResult$f.Mutation("setSidebarVisibility")
16285
- ], MobileFilterSidebar.prototype, "setSidebarVisibility", void 0);
16295
+ searchResult$f.Action("setSidebarState")
16296
+ ], MobileFilterSidebar.prototype, "setSidebarState", void 0);
16286
16297
  __decorate([
16287
16298
  searchResult$f.State((state) => state.isMobileSidebarVisible)
16288
16299
  ], MobileFilterSidebar.prototype, "isMobileSidebarVisible", void 0);
@@ -19102,7 +19113,7 @@ __vue_render__$f._withStripped = true;
19102
19113
  const searchResult$8 = namespace("searchResult");
19103
19114
  let SearchResultsMobileToggle = class SearchResultsMobileToggle extends Vue$1 {
19104
19115
  handleMobileToggle() {
19105
- this.setSidebarVisibility({ visible: true });
19116
+ this.setSidebarState({ visible: true });
19106
19117
  }
19107
19118
  };
19108
19119
  __decorate([
@@ -19115,8 +19126,8 @@ __decorate([
19115
19126
  searchResult$8.Getter("currentFilterCount")
19116
19127
  ], SearchResultsMobileToggle.prototype, "currentFilterCount", void 0);
19117
19128
  __decorate([
19118
- searchResult$8.Mutation("setSidebarVisibility")
19119
- ], SearchResultsMobileToggle.prototype, "setSidebarVisibility", void 0);
19129
+ searchResult$8.Action("setSidebarState")
19130
+ ], SearchResultsMobileToggle.prototype, "setSidebarState", void 0);
19120
19131
  SearchResultsMobileToggle = __decorate([
19121
19132
  Component({
19122
19133
  name: "searchResultsMobileToggle",
@@ -19883,10 +19894,7 @@ var __vue_render__$8 = function () {
19883
19894
  var _c = _vm._self._c || _h;
19884
19895
  return _c(
19885
19896
  "div",
19886
- {
19887
- style: { display: _vm.isMobileSidebarVisible ? "none" : "block" },
19888
- attrs: { id: "lupa-search-results-products" },
19889
- },
19897
+ { attrs: { id: "lupa-search-results-products" } },
19890
19898
  [
19891
19899
  _vm.loading && !_vm.isMobileSidebarVisible
19892
19900
  ? _c("spinner", { staticClass: "lupa-loader" })
@@ -21698,6 +21706,16 @@ let SearchResultModule = class SearchResultModule extends VuexModule {
21698
21706
  var _a;
21699
21707
  return (this.hasResults && ((_a = this.searchResult.offset) !== null && _a !== void 0 ? _a : 0) >= this.totalItems);
21700
21708
  }
21709
+ setSidebarState({ visible }) {
21710
+ // Disable body scroll when sidebar is open and preserve scroll position when scrolling is closed
21711
+ if (visible) {
21712
+ disableBodyScroll();
21713
+ }
21714
+ else {
21715
+ enableBodyScroll();
21716
+ }
21717
+ return { visible };
21718
+ }
21701
21719
  setSidebarVisibility({ visible }) {
21702
21720
  this.isMobileSidebarVisible = visible;
21703
21721
  }
@@ -21777,6 +21795,9 @@ let SearchResultModule = class SearchResultModule extends VuexModule {
21777
21795
  return loading || false;
21778
21796
  }
21779
21797
  };
21798
+ __decorate([
21799
+ Action({ commit: "setSidebarVisibility" })
21800
+ ], SearchResultModule.prototype, "setSidebarState", null);
21780
21801
  __decorate([
21781
21802
  Mutation
21782
21803
  ], SearchResultModule.prototype, "setSidebarVisibility", null);
@@ -27,6 +27,11 @@ export default class SearchResultModule extends VuexModule {
27
27
  get isMobileWidth(): boolean;
28
28
  get currentScreenWidth(): ScreenSize;
29
29
  get isPageEmpty(): boolean;
30
+ setSidebarState({ visible }: {
31
+ visible: boolean;
32
+ }): {
33
+ visible: boolean;
34
+ };
30
35
  setSidebarVisibility({ visible }: {
31
36
  visible: boolean;
32
37
  }): void;
@@ -1,2 +1,4 @@
1
1
  export declare const scrollToSearchResults: (timeout?: number) => void;
2
2
  export declare const scrollTo: (elementId: string) => void;
3
+ export declare const disableBodyScroll: () => void;
4
+ export declare const enableBodyScroll: () => void;
@@ -2,7 +2,7 @@ import { SearchResultsFilterOptions } from "@/types/search-results/SearchResults
2
2
  import Vue from "vue";
3
3
  export default class MobileFilterSidebar extends Vue {
4
4
  options: SearchResultsFilterOptions;
5
- setSidebarVisibility: ({ visible, }: {
5
+ setSidebarState: ({ visible, }: {
6
6
  visible: boolean;
7
7
  }) => void;
8
8
  isMobileSidebarVisible: boolean;
@@ -3,7 +3,7 @@ export default class SearchResultsMobileToggle extends Vue {
3
3
  label: string;
4
4
  showFilterCount: boolean;
5
5
  currentFilterCount: number;
6
- setSidebarVisibility: ({ visible, }: {
6
+ setSidebarState: ({ visible, }: {
7
7
  visible: boolean;
8
8
  }) => void;
9
9
  handleMobileToggle(): void;