@getlupa/client 0.5.1-alpha-9 → 0.5.1-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/dist/cjs/components/search-results/SearchResults.vue.d.ts +3 -0
- package/dist/cjs/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts +5 -0
- package/dist/cjs/index.min.js +95 -12
- package/dist/cjs/store/modules/options.d.ts +3 -0
- package/dist/cjs/types/search-box/SearchBoxOptions.d.ts +2 -0
- package/dist/cjs/utils/query.utils.d.ts +1 -1
- package/dist/cjs/utils/routing.utils.d.ts +3 -0
- package/dist/es/components/search-results/SearchResults.vue.d.ts +3 -0
- package/dist/es/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts +5 -0
- package/dist/es/index.min.js +95 -12
- package/dist/es/store/modules/options.d.ts +3 -0
- package/dist/es/types/search-box/SearchBoxOptions.d.ts +2 -0
- package/dist/es/utils/query.utils.d.ts +1 -1
- package/dist/es/utils/routing.utils.d.ts +3 -0
- package/dist/iife/components/search-results/SearchResults.vue.d.ts +3 -0
- package/dist/iife/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts +5 -0
- package/dist/iife/index.min.js +1 -1
- package/dist/iife/store/modules/options.d.ts +3 -0
- package/dist/iife/types/search-box/SearchBoxOptions.d.ts +2 -0
- package/dist/iife/utils/query.utils.d.ts +1 -1
- package/dist/iife/utils/routing.utils.d.ts +3 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ export default class SearchResults extends Vue {
|
|
|
8
8
|
isProductList: boolean;
|
|
9
9
|
get productsOptions(): SearchResultsProductOptions;
|
|
10
10
|
currentQueryText: string;
|
|
11
|
+
hasResults: boolean;
|
|
12
|
+
currentFilterCount: number;
|
|
11
13
|
get didYouMeanLabels(): SearchResultsDidYouMeanLabels;
|
|
12
14
|
get showFilterSidebar(): boolean;
|
|
13
15
|
get isTitleResultTopPosition(): boolean;
|
|
@@ -51,6 +53,7 @@ export default class SearchResults extends Vue {
|
|
|
51
53
|
setLoading: (loading: boolean) => {
|
|
52
54
|
loading: boolean;
|
|
53
55
|
};
|
|
56
|
+
defaultSearchResultPageSize: number;
|
|
54
57
|
handleUrlChange(params?: URLSearchParams): void;
|
|
55
58
|
query(publicQuery: PublicQuery): void;
|
|
56
59
|
handleResults({ queryKey, results, }: {
|
package/dist/cjs/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export default class SearchResultsPageSelect extends Vue {
|
|
|
5
5
|
label: string;
|
|
6
6
|
options: PaginationPageSelect;
|
|
7
7
|
get pages(): number[];
|
|
8
|
+
get lastPage(): number | undefined;
|
|
9
|
+
get showLastPage(): boolean;
|
|
10
|
+
get showLastPageSeparator(): boolean;
|
|
11
|
+
get showFirstPage(): boolean;
|
|
12
|
+
get showFirstPageSeparator(): boolean;
|
|
8
13
|
appendParams: ({ params, paramsToRemove, }: {
|
|
9
14
|
params: {
|
|
10
15
|
name: string;
|
package/dist/cjs/index.min.js
CHANGED
|
@@ -21893,8 +21893,8 @@ var DEFAULT_OPTIONS_RESULTS = {
|
|
|
21893
21893
|
}]
|
|
21894
21894
|
};
|
|
21895
21895
|
|
|
21896
|
-
var createPublicQuery = function createPublicQuery(queryParams, sortOptions // will be removed when vuex is implemented
|
|
21897
|
-
) {
|
|
21896
|
+
var createPublicQuery = function createPublicQuery(queryParams, sortOptions, // will be removed when vuex is implemented
|
|
21897
|
+
defaultPageSize) {
|
|
21898
21898
|
var _a;
|
|
21899
21899
|
|
|
21900
21900
|
var publicQuery = {};
|
|
@@ -21912,11 +21912,11 @@ var createPublicQuery = function createPublicQuery(queryParams, sortOptions // w
|
|
|
21912
21912
|
break;
|
|
21913
21913
|
|
|
21914
21914
|
case QUERY_PARAMS_PARSED.LIMIT:
|
|
21915
|
-
publicQuery.limit = Number(value);
|
|
21915
|
+
publicQuery.limit = Number(value) || defaultPageSize;
|
|
21916
21916
|
break;
|
|
21917
21917
|
|
|
21918
21918
|
case QUERY_PARAMS_PARSED.PAGE:
|
|
21919
|
-
publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
|
|
21919
|
+
publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || defaultPageSize || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
|
|
21920
21920
|
break;
|
|
21921
21921
|
|
|
21922
21922
|
case QUERY_PARAMS_PARSED.SORT:
|
|
@@ -27454,6 +27454,16 @@ var handleRoutingEvent = function handleRoutingEvent(link, event) {
|
|
|
27454
27454
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
27455
27455
|
emitRoutingEvent(link);
|
|
27456
27456
|
};
|
|
27457
|
+
var redirectToResultsPage = function redirectToResultsPage(link, searchText, facet) {
|
|
27458
|
+
var routingBehavior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "direct-link";
|
|
27459
|
+
var url = generateResultLink(link, searchText, facet);
|
|
27460
|
+
|
|
27461
|
+
if (routingBehavior === "event") {
|
|
27462
|
+
emitRoutingEvent(url);
|
|
27463
|
+
} else {
|
|
27464
|
+
window.location.assign(url);
|
|
27465
|
+
}
|
|
27466
|
+
};
|
|
27457
27467
|
|
|
27458
27468
|
var CategoryFilterItem = /*#__PURE__*/function (_Vue) {
|
|
27459
27469
|
_inherits(CategoryFilterItem, _Vue);
|
|
@@ -30565,6 +30575,35 @@ var SearchResultsPageSelect = /*#__PURE__*/function (_Vue) {
|
|
|
30565
30575
|
return i && i >= left && i < right;
|
|
30566
30576
|
});
|
|
30567
30577
|
}
|
|
30578
|
+
}, {
|
|
30579
|
+
key: "lastPage",
|
|
30580
|
+
get: function get() {
|
|
30581
|
+
var _a;
|
|
30582
|
+
|
|
30583
|
+
return (_a = this.options.count) !== null && _a !== void 0 ? _a : undefined;
|
|
30584
|
+
}
|
|
30585
|
+
}, {
|
|
30586
|
+
key: "showLastPage",
|
|
30587
|
+
get: function get() {
|
|
30588
|
+
return Boolean(this.lastPage && !this.pages.includes(this.lastPage));
|
|
30589
|
+
}
|
|
30590
|
+
}, {
|
|
30591
|
+
key: "showLastPageSeparator",
|
|
30592
|
+
get: function get() {
|
|
30593
|
+
var _a;
|
|
30594
|
+
|
|
30595
|
+
return this.showLastPage && !this.pages.includes(((_a = this.lastPage) !== null && _a !== void 0 ? _a : 0) - 1);
|
|
30596
|
+
}
|
|
30597
|
+
}, {
|
|
30598
|
+
key: "showFirstPage",
|
|
30599
|
+
get: function get() {
|
|
30600
|
+
return !this.pages.includes(1);
|
|
30601
|
+
}
|
|
30602
|
+
}, {
|
|
30603
|
+
key: "showFirstPageSeparator",
|
|
30604
|
+
get: function get() {
|
|
30605
|
+
return this.showFirstPage && !this.pages.includes(2);
|
|
30606
|
+
}
|
|
30568
30607
|
}, {
|
|
30569
30608
|
key: "handlePageChange",
|
|
30570
30609
|
value: function handlePageChange(page) {
|
|
@@ -30621,7 +30660,16 @@ var __vue_render__$i = function __vue_render__() {
|
|
|
30621
30660
|
return _vm.handlePageChange(_vm.options.selectedPage - 1);
|
|
30622
30661
|
}
|
|
30623
30662
|
}
|
|
30624
|
-
}, [_vm._v("\n <\n ")]) : _vm._e(), _vm._v(" "), _vm.
|
|
30663
|
+
}, [_vm._v("\n <\n ")]) : _vm._e(), _vm._v(" "), _vm.showFirstPage ? [_c("div", {
|
|
30664
|
+
staticClass: "lupa-page-number lupa-page-number-first",
|
|
30665
|
+
on: {
|
|
30666
|
+
click: function click() {
|
|
30667
|
+
return _vm.handlePageChange(1);
|
|
30668
|
+
}
|
|
30669
|
+
}
|
|
30670
|
+
}, [_vm._v("\n 1\n ")]), _vm._v(" "), _vm.showFirstPageSeparator ? _c("div", {
|
|
30671
|
+
staticClass: "lupa-page-number-separator"
|
|
30672
|
+
}, [_vm._v("\n ...\n ")]) : _vm._e()] : _vm._e(), _vm._v(" "), _vm._l(_vm.pages, function (page) {
|
|
30625
30673
|
return _c("div", {
|
|
30626
30674
|
key: page,
|
|
30627
30675
|
class: ["lupa-page-number", page === _vm.options.selectedPage ? "lupa-page-number-selected" : ""],
|
|
@@ -30634,7 +30682,16 @@ var __vue_render__$i = function __vue_render__() {
|
|
|
30634
30682
|
}
|
|
30635
30683
|
}
|
|
30636
30684
|
}, [_vm._v("\n " + _vm._s(page) + "\n ")]);
|
|
30637
|
-
}), _vm._v(" "), _vm.
|
|
30685
|
+
}), _vm._v(" "), _vm.showLastPage ? [_vm.showLastPageSeparator ? _c("div", {
|
|
30686
|
+
staticClass: "lupa-page-number-separator"
|
|
30687
|
+
}, [_vm._v("\n ...\n ")]) : _vm._e(), _vm._v(" "), _c("div", {
|
|
30688
|
+
staticClass: "lupa-page-number lupa-page-number-last",
|
|
30689
|
+
on: {
|
|
30690
|
+
click: function click() {
|
|
30691
|
+
return _vm.handlePageChange(_vm.lastPage);
|
|
30692
|
+
}
|
|
30693
|
+
}
|
|
30694
|
+
}, [_vm._v("\n " + _vm._s(_vm.lastPage) + "\n ")])] : _vm._e(), _vm._v(" "), _vm.options.selectedPage < _vm.options.count ? _c("div", {
|
|
30638
30695
|
class: _vm.label === ">" ? "lupa-page-arrow" : "lupa-show-more",
|
|
30639
30696
|
attrs: {
|
|
30640
30697
|
"data-cy": "lupa-show-more"
|
|
@@ -32328,7 +32385,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32328
32385
|
get: function get() {
|
|
32329
32386
|
var _a, _b, _c;
|
|
32330
32387
|
|
|
32331
|
-
return ((_c = (_b = (_a = this.options.filters) === null || _a === void 0 ? void 0 : _a.facets) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.type) === "sidebar";
|
|
32388
|
+
return ((_c = (_b = (_a = this.options.filters) === null || _a === void 0 ? void 0 : _a.facets) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.type) === "sidebar" && (this.hasResults || this.currentFilterCount > 0);
|
|
32332
32389
|
}
|
|
32333
32390
|
}, {
|
|
32334
32391
|
key: "isTitleResultTopPosition",
|
|
@@ -32339,10 +32396,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32339
32396
|
key: "mounted",
|
|
32340
32397
|
value: function mounted() {
|
|
32341
32398
|
window.addEventListener("resize", this.handleResize);
|
|
32342
|
-
this.handleMounted();
|
|
32343
32399
|
this.setSearchResultOptions({
|
|
32344
32400
|
options: this.options
|
|
32345
32401
|
});
|
|
32402
|
+
this.handleMounted();
|
|
32346
32403
|
this.setInitialFilters({
|
|
32347
32404
|
initialFilters: this.initialFilters
|
|
32348
32405
|
});
|
|
@@ -32372,7 +32429,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32372
32429
|
key: "handleUrlChange",
|
|
32373
32430
|
value: function handleUrlChange(params) {
|
|
32374
32431
|
var searchParams = params || new URLSearchParams(window.location.search);
|
|
32375
|
-
var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort);
|
|
32432
|
+
var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort, this.defaultSearchResultPageSize);
|
|
32376
32433
|
this.setLoading(true);
|
|
32377
32434
|
this.query(getPublicQuery(publicQuery, this.initialFilters, this.isProductList));
|
|
32378
32435
|
}
|
|
@@ -32386,7 +32443,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32386
32443
|
query: publicQuery
|
|
32387
32444
|
});
|
|
32388
32445
|
var context = getLupaTrackingContext();
|
|
32389
|
-
var
|
|
32446
|
+
var limit = publicQuery.limit || this.defaultSearchResultPageSize;
|
|
32447
|
+
var query = Object.assign(Object.assign(Object.assign({}, publicQuery), context), {
|
|
32448
|
+
limit: limit
|
|
32449
|
+
});
|
|
32390
32450
|
getLupaSdk.query(this.options.queryKey, query, this.options.options).then(function (res) {
|
|
32391
32451
|
var _a, _b;
|
|
32392
32452
|
|
|
@@ -32471,6 +32531,10 @@ __decorate([Prop({
|
|
|
32471
32531
|
|
|
32472
32532
|
__decorate([searchResult$1.Getter("currentQueryText")], SearchResults.prototype, "currentQueryText", void 0);
|
|
32473
32533
|
|
|
32534
|
+
__decorate([searchResult$1.Getter("hasResults")], SearchResults.prototype, "hasResults", void 0);
|
|
32535
|
+
|
|
32536
|
+
__decorate([searchResult$1.Getter("currentFilterCount")], SearchResults.prototype, "currentFilterCount", void 0);
|
|
32537
|
+
|
|
32474
32538
|
__decorate([tracking$2.Action("trackSearch")], SearchResults.prototype, "trackSearch", void 0);
|
|
32475
32539
|
|
|
32476
32540
|
__decorate([tracking$2.Action("trackResults")], SearchResults.prototype, "trackResults", void 0);
|
|
@@ -32495,6 +32559,8 @@ __decorate([searchResult$1.Action("add")], SearchResults.prototype, "addSearchRe
|
|
|
32495
32559
|
|
|
32496
32560
|
__decorate([searchResult$1.Action("setLoading")], SearchResults.prototype, "setLoading", void 0);
|
|
32497
32561
|
|
|
32562
|
+
__decorate([options$1.Getter("defaultSearchResultPageSize")], SearchResults.prototype, "defaultSearchResultPageSize", void 0);
|
|
32563
|
+
|
|
32498
32564
|
__decorate([searchResult$1.Action("setColumnCount")], SearchResults.prototype, "setColumnCount", void 0);
|
|
32499
32565
|
|
|
32500
32566
|
SearchResults = __decorate([Component({
|
|
@@ -34209,7 +34275,7 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34209
34275
|
}, {
|
|
34210
34276
|
key: "limit",
|
|
34211
34277
|
get: function get() {
|
|
34212
|
-
return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.defaultLimit;
|
|
34278
|
+
return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.context.rootGetters["options/defaultSearchResultPageSize"] || this.defaultLimit;
|
|
34213
34279
|
}
|
|
34214
34280
|
}, {
|
|
34215
34281
|
key: "sort",
|
|
@@ -34285,6 +34351,8 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34285
34351
|
var searchText = _ref3.searchText,
|
|
34286
34352
|
facet = _ref3.facet;
|
|
34287
34353
|
|
|
34354
|
+
var _a;
|
|
34355
|
+
|
|
34288
34356
|
if (!this.searchResultsLink || this.searchResultsLink === window.location.pathname) {
|
|
34289
34357
|
var facetParam = facet ? [getFacetParam(facet.key, [facet.title])] : [];
|
|
34290
34358
|
this.context.dispatch("appendParams", {
|
|
@@ -34295,7 +34363,8 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34295
34363
|
paramsToRemove: "all"
|
|
34296
34364
|
});
|
|
34297
34365
|
} else {
|
|
34298
|
-
|
|
34366
|
+
var routing = (_a = this.context.rootGetters["options/boxRoutingBehavior"]) !== null && _a !== void 0 ? _a : "direct-link";
|
|
34367
|
+
redirectToResultsPage(this.searchResultsLink, searchText, facet, routing);
|
|
34299
34368
|
}
|
|
34300
34369
|
|
|
34301
34370
|
this.context.dispatch("tracking/track", {
|
|
@@ -34441,6 +34510,20 @@ var OptionsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34441
34510
|
get: function get() {
|
|
34442
34511
|
return this.searchResultInitialFilters;
|
|
34443
34512
|
}
|
|
34513
|
+
}, {
|
|
34514
|
+
key: "boxRoutingBehavior",
|
|
34515
|
+
get: function get() {
|
|
34516
|
+
var _a;
|
|
34517
|
+
|
|
34518
|
+
return (_a = this.searchBoxOptions.routingBehavior) !== null && _a !== void 0 ? _a : "direct-link";
|
|
34519
|
+
}
|
|
34520
|
+
}, {
|
|
34521
|
+
key: "defaultSearchResultPageSize",
|
|
34522
|
+
get: function get() {
|
|
34523
|
+
var _a, _b, _c, _d, _e;
|
|
34524
|
+
|
|
34525
|
+
return (_e = (_d = (_c = (_b = (_a = this.searchResultOptions) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.sizeSelection) === null || _c === void 0 ? void 0 : _c.sizes) === null || _d === void 0 ? void 0 : _d[0]) !== null && _e !== void 0 ? _e : DEFAULT_PAGE_SIZE;
|
|
34526
|
+
}
|
|
34444
34527
|
}, {
|
|
34445
34528
|
key: "setSearchBoxOptions",
|
|
34446
34529
|
value: function setSearchBoxOptions(_ref) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SearchBoxOptions } from "@/types/search-box/SearchBoxOptions";
|
|
2
|
+
import { RoutingBehavior } from "@/types/search-results/RoutingBehavior";
|
|
2
3
|
import { SearchResultsOptions } from "@/types/search-results/SearchResultsOptions";
|
|
3
4
|
import { FilterGroup, Options } from "@getlupa/client-sdk/Types";
|
|
4
5
|
import { VuexModule } from "vuex-module-decorators";
|
|
@@ -9,6 +10,8 @@ export default class OptionsModule extends VuexModule {
|
|
|
9
10
|
get envOptions(): Options;
|
|
10
11
|
get classMap(): Record<string, string>;
|
|
11
12
|
get initialFilters(): FilterGroup;
|
|
13
|
+
get boxRoutingBehavior(): RoutingBehavior;
|
|
14
|
+
get defaultSearchResultPageSize(): number;
|
|
12
15
|
setSearchBoxOptions({ options }: {
|
|
13
16
|
options: SearchBoxOptions;
|
|
14
17
|
}): void;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SdkOptions } from "../General";
|
|
2
|
+
import { RoutingBehavior } from "../search-results/RoutingBehavior";
|
|
2
3
|
import { SearchBoxHistory } from "./SearchBoxHistory";
|
|
3
4
|
import { SearchBoxPanel } from "./SearchBoxPanel";
|
|
4
5
|
export declare type SearchBoxOptions = SearchBoxPanelOptions & {
|
|
5
6
|
inputSelector: string;
|
|
6
7
|
searchTriggers?: string[];
|
|
8
|
+
routingBehavior?: RoutingBehavior;
|
|
7
9
|
};
|
|
8
10
|
export declare type SearchBoxOptionLabels = {
|
|
9
11
|
placeholder: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryParams } from "@/types/search-results/QueryParams";
|
|
2
2
|
import { SearchResultsSortOptions } from "@/types/search-results/SearchResultsSort";
|
|
3
3
|
import { FilterGroup, PublicQuery } from "@getlupa/client-sdk/Types";
|
|
4
|
-
export declare const createPublicQuery: (queryParams: QueryParams, sortOptions?: SearchResultsSortOptions[] | undefined) => PublicQuery;
|
|
4
|
+
export declare const createPublicQuery: (queryParams: QueryParams, sortOptions?: SearchResultsSortOptions[] | undefined, defaultPageSize?: number | undefined) => PublicQuery;
|
|
5
5
|
export declare const getPublicQuery: (publicQuery: PublicQuery, initialFilters: FilterGroup, isProductList: boolean) => PublicQuery;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { InputSuggestionFacet } from "@/types/search-box/Common";
|
|
2
|
+
import { RoutingBehavior } from "..";
|
|
1
3
|
export declare const emitRoutingEvent: (url: string) => void;
|
|
2
4
|
export declare const handleRoutingEvent: (link: string, event?: Event | undefined, hasEventRouting?: boolean) => void;
|
|
5
|
+
export declare const redirectToResultsPage: (link: string, searchText: string, facet?: InputSuggestionFacet | undefined, routingBehavior?: RoutingBehavior) => void;
|
|
@@ -8,6 +8,8 @@ export default class SearchResults extends Vue {
|
|
|
8
8
|
isProductList: boolean;
|
|
9
9
|
get productsOptions(): SearchResultsProductOptions;
|
|
10
10
|
currentQueryText: string;
|
|
11
|
+
hasResults: boolean;
|
|
12
|
+
currentFilterCount: number;
|
|
11
13
|
get didYouMeanLabels(): SearchResultsDidYouMeanLabels;
|
|
12
14
|
get showFilterSidebar(): boolean;
|
|
13
15
|
get isTitleResultTopPosition(): boolean;
|
|
@@ -51,6 +53,7 @@ export default class SearchResults extends Vue {
|
|
|
51
53
|
setLoading: (loading: boolean) => {
|
|
52
54
|
loading: boolean;
|
|
53
55
|
};
|
|
56
|
+
defaultSearchResultPageSize: number;
|
|
54
57
|
handleUrlChange(params?: URLSearchParams): void;
|
|
55
58
|
query(publicQuery: PublicQuery): void;
|
|
56
59
|
handleResults({ queryKey, results, }: {
|
package/dist/es/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export default class SearchResultsPageSelect extends Vue {
|
|
|
5
5
|
label: string;
|
|
6
6
|
options: PaginationPageSelect;
|
|
7
7
|
get pages(): number[];
|
|
8
|
+
get lastPage(): number | undefined;
|
|
9
|
+
get showLastPage(): boolean;
|
|
10
|
+
get showLastPageSeparator(): boolean;
|
|
11
|
+
get showFirstPage(): boolean;
|
|
12
|
+
get showFirstPageSeparator(): boolean;
|
|
8
13
|
appendParams: ({ params, paramsToRemove, }: {
|
|
9
14
|
params: {
|
|
10
15
|
name: string;
|
package/dist/es/index.min.js
CHANGED
|
@@ -21889,8 +21889,8 @@ var DEFAULT_OPTIONS_RESULTS = {
|
|
|
21889
21889
|
}]
|
|
21890
21890
|
};
|
|
21891
21891
|
|
|
21892
|
-
var createPublicQuery = function createPublicQuery(queryParams, sortOptions // will be removed when vuex is implemented
|
|
21893
|
-
) {
|
|
21892
|
+
var createPublicQuery = function createPublicQuery(queryParams, sortOptions, // will be removed when vuex is implemented
|
|
21893
|
+
defaultPageSize) {
|
|
21894
21894
|
var _a;
|
|
21895
21895
|
|
|
21896
21896
|
var publicQuery = {};
|
|
@@ -21908,11 +21908,11 @@ var createPublicQuery = function createPublicQuery(queryParams, sortOptions // w
|
|
|
21908
21908
|
break;
|
|
21909
21909
|
|
|
21910
21910
|
case QUERY_PARAMS_PARSED.LIMIT:
|
|
21911
|
-
publicQuery.limit = Number(value);
|
|
21911
|
+
publicQuery.limit = Number(value) || defaultPageSize;
|
|
21912
21912
|
break;
|
|
21913
21913
|
|
|
21914
21914
|
case QUERY_PARAMS_PARSED.PAGE:
|
|
21915
|
-
publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
|
|
21915
|
+
publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || defaultPageSize || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
|
|
21916
21916
|
break;
|
|
21917
21917
|
|
|
21918
21918
|
case QUERY_PARAMS_PARSED.SORT:
|
|
@@ -27450,6 +27450,16 @@ var handleRoutingEvent = function handleRoutingEvent(link, event) {
|
|
|
27450
27450
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
27451
27451
|
emitRoutingEvent(link);
|
|
27452
27452
|
};
|
|
27453
|
+
var redirectToResultsPage = function redirectToResultsPage(link, searchText, facet) {
|
|
27454
|
+
var routingBehavior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "direct-link";
|
|
27455
|
+
var url = generateResultLink(link, searchText, facet);
|
|
27456
|
+
|
|
27457
|
+
if (routingBehavior === "event") {
|
|
27458
|
+
emitRoutingEvent(url);
|
|
27459
|
+
} else {
|
|
27460
|
+
window.location.assign(url);
|
|
27461
|
+
}
|
|
27462
|
+
};
|
|
27453
27463
|
|
|
27454
27464
|
var CategoryFilterItem = /*#__PURE__*/function (_Vue) {
|
|
27455
27465
|
_inherits(CategoryFilterItem, _Vue);
|
|
@@ -30561,6 +30571,35 @@ var SearchResultsPageSelect = /*#__PURE__*/function (_Vue) {
|
|
|
30561
30571
|
return i && i >= left && i < right;
|
|
30562
30572
|
});
|
|
30563
30573
|
}
|
|
30574
|
+
}, {
|
|
30575
|
+
key: "lastPage",
|
|
30576
|
+
get: function get() {
|
|
30577
|
+
var _a;
|
|
30578
|
+
|
|
30579
|
+
return (_a = this.options.count) !== null && _a !== void 0 ? _a : undefined;
|
|
30580
|
+
}
|
|
30581
|
+
}, {
|
|
30582
|
+
key: "showLastPage",
|
|
30583
|
+
get: function get() {
|
|
30584
|
+
return Boolean(this.lastPage && !this.pages.includes(this.lastPage));
|
|
30585
|
+
}
|
|
30586
|
+
}, {
|
|
30587
|
+
key: "showLastPageSeparator",
|
|
30588
|
+
get: function get() {
|
|
30589
|
+
var _a;
|
|
30590
|
+
|
|
30591
|
+
return this.showLastPage && !this.pages.includes(((_a = this.lastPage) !== null && _a !== void 0 ? _a : 0) - 1);
|
|
30592
|
+
}
|
|
30593
|
+
}, {
|
|
30594
|
+
key: "showFirstPage",
|
|
30595
|
+
get: function get() {
|
|
30596
|
+
return !this.pages.includes(1);
|
|
30597
|
+
}
|
|
30598
|
+
}, {
|
|
30599
|
+
key: "showFirstPageSeparator",
|
|
30600
|
+
get: function get() {
|
|
30601
|
+
return this.showFirstPage && !this.pages.includes(2);
|
|
30602
|
+
}
|
|
30564
30603
|
}, {
|
|
30565
30604
|
key: "handlePageChange",
|
|
30566
30605
|
value: function handlePageChange(page) {
|
|
@@ -30617,7 +30656,16 @@ var __vue_render__$i = function __vue_render__() {
|
|
|
30617
30656
|
return _vm.handlePageChange(_vm.options.selectedPage - 1);
|
|
30618
30657
|
}
|
|
30619
30658
|
}
|
|
30620
|
-
}, [_vm._v("\n <\n ")]) : _vm._e(), _vm._v(" "), _vm.
|
|
30659
|
+
}, [_vm._v("\n <\n ")]) : _vm._e(), _vm._v(" "), _vm.showFirstPage ? [_c("div", {
|
|
30660
|
+
staticClass: "lupa-page-number lupa-page-number-first",
|
|
30661
|
+
on: {
|
|
30662
|
+
click: function click() {
|
|
30663
|
+
return _vm.handlePageChange(1);
|
|
30664
|
+
}
|
|
30665
|
+
}
|
|
30666
|
+
}, [_vm._v("\n 1\n ")]), _vm._v(" "), _vm.showFirstPageSeparator ? _c("div", {
|
|
30667
|
+
staticClass: "lupa-page-number-separator"
|
|
30668
|
+
}, [_vm._v("\n ...\n ")]) : _vm._e()] : _vm._e(), _vm._v(" "), _vm._l(_vm.pages, function (page) {
|
|
30621
30669
|
return _c("div", {
|
|
30622
30670
|
key: page,
|
|
30623
30671
|
class: ["lupa-page-number", page === _vm.options.selectedPage ? "lupa-page-number-selected" : ""],
|
|
@@ -30630,7 +30678,16 @@ var __vue_render__$i = function __vue_render__() {
|
|
|
30630
30678
|
}
|
|
30631
30679
|
}
|
|
30632
30680
|
}, [_vm._v("\n " + _vm._s(page) + "\n ")]);
|
|
30633
|
-
}), _vm._v(" "), _vm.
|
|
30681
|
+
}), _vm._v(" "), _vm.showLastPage ? [_vm.showLastPageSeparator ? _c("div", {
|
|
30682
|
+
staticClass: "lupa-page-number-separator"
|
|
30683
|
+
}, [_vm._v("\n ...\n ")]) : _vm._e(), _vm._v(" "), _c("div", {
|
|
30684
|
+
staticClass: "lupa-page-number lupa-page-number-last",
|
|
30685
|
+
on: {
|
|
30686
|
+
click: function click() {
|
|
30687
|
+
return _vm.handlePageChange(_vm.lastPage);
|
|
30688
|
+
}
|
|
30689
|
+
}
|
|
30690
|
+
}, [_vm._v("\n " + _vm._s(_vm.lastPage) + "\n ")])] : _vm._e(), _vm._v(" "), _vm.options.selectedPage < _vm.options.count ? _c("div", {
|
|
30634
30691
|
class: _vm.label === ">" ? "lupa-page-arrow" : "lupa-show-more",
|
|
30635
30692
|
attrs: {
|
|
30636
30693
|
"data-cy": "lupa-show-more"
|
|
@@ -32324,7 +32381,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32324
32381
|
get: function get() {
|
|
32325
32382
|
var _a, _b, _c;
|
|
32326
32383
|
|
|
32327
|
-
return ((_c = (_b = (_a = this.options.filters) === null || _a === void 0 ? void 0 : _a.facets) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.type) === "sidebar";
|
|
32384
|
+
return ((_c = (_b = (_a = this.options.filters) === null || _a === void 0 ? void 0 : _a.facets) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.type) === "sidebar" && (this.hasResults || this.currentFilterCount > 0);
|
|
32328
32385
|
}
|
|
32329
32386
|
}, {
|
|
32330
32387
|
key: "isTitleResultTopPosition",
|
|
@@ -32335,10 +32392,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32335
32392
|
key: "mounted",
|
|
32336
32393
|
value: function mounted() {
|
|
32337
32394
|
window.addEventListener("resize", this.handleResize);
|
|
32338
|
-
this.handleMounted();
|
|
32339
32395
|
this.setSearchResultOptions({
|
|
32340
32396
|
options: this.options
|
|
32341
32397
|
});
|
|
32398
|
+
this.handleMounted();
|
|
32342
32399
|
this.setInitialFilters({
|
|
32343
32400
|
initialFilters: this.initialFilters
|
|
32344
32401
|
});
|
|
@@ -32368,7 +32425,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32368
32425
|
key: "handleUrlChange",
|
|
32369
32426
|
value: function handleUrlChange(params) {
|
|
32370
32427
|
var searchParams = params || new URLSearchParams(window.location.search);
|
|
32371
|
-
var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort);
|
|
32428
|
+
var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort, this.defaultSearchResultPageSize);
|
|
32372
32429
|
this.setLoading(true);
|
|
32373
32430
|
this.query(getPublicQuery(publicQuery, this.initialFilters, this.isProductList));
|
|
32374
32431
|
}
|
|
@@ -32382,7 +32439,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
|
|
|
32382
32439
|
query: publicQuery
|
|
32383
32440
|
});
|
|
32384
32441
|
var context = getLupaTrackingContext();
|
|
32385
|
-
var
|
|
32442
|
+
var limit = publicQuery.limit || this.defaultSearchResultPageSize;
|
|
32443
|
+
var query = Object.assign(Object.assign(Object.assign({}, publicQuery), context), {
|
|
32444
|
+
limit: limit
|
|
32445
|
+
});
|
|
32386
32446
|
getLupaSdk.query(this.options.queryKey, query, this.options.options).then(function (res) {
|
|
32387
32447
|
var _a, _b;
|
|
32388
32448
|
|
|
@@ -32467,6 +32527,10 @@ __decorate([Prop({
|
|
|
32467
32527
|
|
|
32468
32528
|
__decorate([searchResult$1.Getter("currentQueryText")], SearchResults.prototype, "currentQueryText", void 0);
|
|
32469
32529
|
|
|
32530
|
+
__decorate([searchResult$1.Getter("hasResults")], SearchResults.prototype, "hasResults", void 0);
|
|
32531
|
+
|
|
32532
|
+
__decorate([searchResult$1.Getter("currentFilterCount")], SearchResults.prototype, "currentFilterCount", void 0);
|
|
32533
|
+
|
|
32470
32534
|
__decorate([tracking$2.Action("trackSearch")], SearchResults.prototype, "trackSearch", void 0);
|
|
32471
32535
|
|
|
32472
32536
|
__decorate([tracking$2.Action("trackResults")], SearchResults.prototype, "trackResults", void 0);
|
|
@@ -32491,6 +32555,8 @@ __decorate([searchResult$1.Action("add")], SearchResults.prototype, "addSearchRe
|
|
|
32491
32555
|
|
|
32492
32556
|
__decorate([searchResult$1.Action("setLoading")], SearchResults.prototype, "setLoading", void 0);
|
|
32493
32557
|
|
|
32558
|
+
__decorate([options$1.Getter("defaultSearchResultPageSize")], SearchResults.prototype, "defaultSearchResultPageSize", void 0);
|
|
32559
|
+
|
|
32494
32560
|
__decorate([searchResult$1.Action("setColumnCount")], SearchResults.prototype, "setColumnCount", void 0);
|
|
32495
32561
|
|
|
32496
32562
|
SearchResults = __decorate([Component({
|
|
@@ -34205,7 +34271,7 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34205
34271
|
}, {
|
|
34206
34272
|
key: "limit",
|
|
34207
34273
|
get: function get() {
|
|
34208
|
-
return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.defaultLimit;
|
|
34274
|
+
return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.context.rootGetters["options/defaultSearchResultPageSize"] || this.defaultLimit;
|
|
34209
34275
|
}
|
|
34210
34276
|
}, {
|
|
34211
34277
|
key: "sort",
|
|
@@ -34281,6 +34347,8 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34281
34347
|
var searchText = _ref3.searchText,
|
|
34282
34348
|
facet = _ref3.facet;
|
|
34283
34349
|
|
|
34350
|
+
var _a;
|
|
34351
|
+
|
|
34284
34352
|
if (!this.searchResultsLink || this.searchResultsLink === window.location.pathname) {
|
|
34285
34353
|
var facetParam = facet ? [getFacetParam(facet.key, [facet.title])] : [];
|
|
34286
34354
|
this.context.dispatch("appendParams", {
|
|
@@ -34291,7 +34359,8 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34291
34359
|
paramsToRemove: "all"
|
|
34292
34360
|
});
|
|
34293
34361
|
} else {
|
|
34294
|
-
|
|
34362
|
+
var routing = (_a = this.context.rootGetters["options/boxRoutingBehavior"]) !== null && _a !== void 0 ? _a : "direct-link";
|
|
34363
|
+
redirectToResultsPage(this.searchResultsLink, searchText, facet, routing);
|
|
34295
34364
|
}
|
|
34296
34365
|
|
|
34297
34366
|
this.context.dispatch("tracking/track", {
|
|
@@ -34437,6 +34506,20 @@ var OptionsModule = /*#__PURE__*/function (_VuexModule) {
|
|
|
34437
34506
|
get: function get() {
|
|
34438
34507
|
return this.searchResultInitialFilters;
|
|
34439
34508
|
}
|
|
34509
|
+
}, {
|
|
34510
|
+
key: "boxRoutingBehavior",
|
|
34511
|
+
get: function get() {
|
|
34512
|
+
var _a;
|
|
34513
|
+
|
|
34514
|
+
return (_a = this.searchBoxOptions.routingBehavior) !== null && _a !== void 0 ? _a : "direct-link";
|
|
34515
|
+
}
|
|
34516
|
+
}, {
|
|
34517
|
+
key: "defaultSearchResultPageSize",
|
|
34518
|
+
get: function get() {
|
|
34519
|
+
var _a, _b, _c, _d, _e;
|
|
34520
|
+
|
|
34521
|
+
return (_e = (_d = (_c = (_b = (_a = this.searchResultOptions) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.sizeSelection) === null || _c === void 0 ? void 0 : _c.sizes) === null || _d === void 0 ? void 0 : _d[0]) !== null && _e !== void 0 ? _e : DEFAULT_PAGE_SIZE;
|
|
34522
|
+
}
|
|
34440
34523
|
}, {
|
|
34441
34524
|
key: "setSearchBoxOptions",
|
|
34442
34525
|
value: function setSearchBoxOptions(_ref) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SearchBoxOptions } from "@/types/search-box/SearchBoxOptions";
|
|
2
|
+
import { RoutingBehavior } from "@/types/search-results/RoutingBehavior";
|
|
2
3
|
import { SearchResultsOptions } from "@/types/search-results/SearchResultsOptions";
|
|
3
4
|
import { FilterGroup, Options } from "@getlupa/client-sdk/Types";
|
|
4
5
|
import { VuexModule } from "vuex-module-decorators";
|
|
@@ -9,6 +10,8 @@ export default class OptionsModule extends VuexModule {
|
|
|
9
10
|
get envOptions(): Options;
|
|
10
11
|
get classMap(): Record<string, string>;
|
|
11
12
|
get initialFilters(): FilterGroup;
|
|
13
|
+
get boxRoutingBehavior(): RoutingBehavior;
|
|
14
|
+
get defaultSearchResultPageSize(): number;
|
|
12
15
|
setSearchBoxOptions({ options }: {
|
|
13
16
|
options: SearchBoxOptions;
|
|
14
17
|
}): void;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SdkOptions } from "../General";
|
|
2
|
+
import { RoutingBehavior } from "../search-results/RoutingBehavior";
|
|
2
3
|
import { SearchBoxHistory } from "./SearchBoxHistory";
|
|
3
4
|
import { SearchBoxPanel } from "./SearchBoxPanel";
|
|
4
5
|
export declare type SearchBoxOptions = SearchBoxPanelOptions & {
|
|
5
6
|
inputSelector: string;
|
|
6
7
|
searchTriggers?: string[];
|
|
8
|
+
routingBehavior?: RoutingBehavior;
|
|
7
9
|
};
|
|
8
10
|
export declare type SearchBoxOptionLabels = {
|
|
9
11
|
placeholder: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryParams } from "@/types/search-results/QueryParams";
|
|
2
2
|
import { SearchResultsSortOptions } from "@/types/search-results/SearchResultsSort";
|
|
3
3
|
import { FilterGroup, PublicQuery } from "@getlupa/client-sdk/Types";
|
|
4
|
-
export declare const createPublicQuery: (queryParams: QueryParams, sortOptions?: SearchResultsSortOptions[] | undefined) => PublicQuery;
|
|
4
|
+
export declare const createPublicQuery: (queryParams: QueryParams, sortOptions?: SearchResultsSortOptions[] | undefined, defaultPageSize?: number | undefined) => PublicQuery;
|
|
5
5
|
export declare const getPublicQuery: (publicQuery: PublicQuery, initialFilters: FilterGroup, isProductList: boolean) => PublicQuery;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { InputSuggestionFacet } from "@/types/search-box/Common";
|
|
2
|
+
import { RoutingBehavior } from "..";
|
|
1
3
|
export declare const emitRoutingEvent: (url: string) => void;
|
|
2
4
|
export declare const handleRoutingEvent: (link: string, event?: Event | undefined, hasEventRouting?: boolean) => void;
|
|
5
|
+
export declare const redirectToResultsPage: (link: string, searchText: string, facet?: InputSuggestionFacet | undefined, routingBehavior?: RoutingBehavior) => void;
|
|
@@ -8,6 +8,8 @@ export default class SearchResults extends Vue {
|
|
|
8
8
|
isProductList: boolean;
|
|
9
9
|
get productsOptions(): SearchResultsProductOptions;
|
|
10
10
|
currentQueryText: string;
|
|
11
|
+
hasResults: boolean;
|
|
12
|
+
currentFilterCount: number;
|
|
11
13
|
get didYouMeanLabels(): SearchResultsDidYouMeanLabels;
|
|
12
14
|
get showFilterSidebar(): boolean;
|
|
13
15
|
get isTitleResultTopPosition(): boolean;
|
|
@@ -51,6 +53,7 @@ export default class SearchResults extends Vue {
|
|
|
51
53
|
setLoading: (loading: boolean) => {
|
|
52
54
|
loading: boolean;
|
|
53
55
|
};
|
|
56
|
+
defaultSearchResultPageSize: number;
|
|
54
57
|
handleUrlChange(params?: URLSearchParams): void;
|
|
55
58
|
query(publicQuery: PublicQuery): void;
|
|
56
59
|
handleResults({ queryKey, results, }: {
|
package/dist/iife/components/search-results/products/pagination/SearchResultsPageSelect.vue.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export default class SearchResultsPageSelect extends Vue {
|
|
|
5
5
|
label: string;
|
|
6
6
|
options: PaginationPageSelect;
|
|
7
7
|
get pages(): number[];
|
|
8
|
+
get lastPage(): number | undefined;
|
|
9
|
+
get showLastPage(): boolean;
|
|
10
|
+
get showLastPageSeparator(): boolean;
|
|
11
|
+
get showFirstPage(): boolean;
|
|
12
|
+
get showFirstPageSeparator(): boolean;
|
|
8
13
|
appendParams: ({ params, paramsToRemove, }: {
|
|
9
14
|
params: {
|
|
10
15
|
name: string;
|