@getlupa/client 0.5.1-alpha-10 → 0.5.1-alpha-13

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.
@@ -19708,8 +19708,36 @@ var linksMatch = function linksMatch(link1, link2) {
19708
19708
  return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
19709
19709
  };
19710
19710
 
19711
+ var emitRoutingEvent = function emitRoutingEvent(url) {
19712
+ var event = new CustomEvent(LUPA_ROUTING_EVENT, {
19713
+ detail: url
19714
+ });
19715
+ window.dispatchEvent(event);
19716
+ };
19717
+ var handleRoutingEvent = function handleRoutingEvent(link, event) {
19718
+ var hasEventRouting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19719
+
19720
+ if (!hasEventRouting) {
19721
+ return;
19722
+ }
19723
+
19724
+ event === null || event === void 0 ? void 0 : event.preventDefault();
19725
+ emitRoutingEvent(link);
19726
+ };
19727
+ var redirectToResultsPage = function redirectToResultsPage(link, searchText, facet) {
19728
+ var routingBehavior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "direct-link";
19729
+ var url = generateResultLink(link, searchText, facet);
19730
+
19731
+ if (routingBehavior === "event") {
19732
+ emitRoutingEvent(url);
19733
+ } else {
19734
+ window.location.assign(url);
19735
+ }
19736
+ };
19737
+
19711
19738
  var history$3 = namespace("history");
19712
19739
  var tracking$5 = namespace("tracking");
19740
+ var options$9 = namespace("options");
19713
19741
 
19714
19742
  var SearchBoxProduct = /*#__PURE__*/function (_Vue) {
19715
19743
  _inherits(SearchBoxProduct, _Vue);
@@ -19758,7 +19786,7 @@ var SearchBoxProduct = /*#__PURE__*/function (_Vue) {
19758
19786
  }
19759
19787
  }, {
19760
19788
  key: "handleClick",
19761
- value: function handleClick() {
19789
+ value: function handleClick(event) {
19762
19790
  if (this.panelOptions.titleKey) {
19763
19791
  this.addHistory({
19764
19792
  item: this.item[this.panelOptions.titleKey] || ""
@@ -19781,6 +19809,12 @@ var SearchBoxProduct = /*#__PURE__*/function (_Vue) {
19781
19809
  }
19782
19810
  }
19783
19811
  });
19812
+
19813
+ if (!this.link) {
19814
+ return;
19815
+ }
19816
+
19817
+ handleRoutingEvent(this.link, event, this.boxRoutingBehavior === "event");
19784
19818
  }
19785
19819
  }]);
19786
19820
 
@@ -19801,6 +19835,8 @@ __decorate([Prop({
19801
19835
  default: false
19802
19836
  })], SearchBoxProduct.prototype, "highlighted", void 0);
19803
19837
 
19838
+ __decorate([options$9.Getter("boxRoutingBehavior")], SearchBoxProduct.prototype, "boxRoutingBehavior", void 0);
19839
+
19804
19840
  __decorate([tracking$5.Action("track")], SearchBoxProduct.prototype, "trackClick", void 0);
19805
19841
 
19806
19842
  __decorate([history$3.Action("add")], SearchBoxProduct.prototype, "addHistory", void 0);
@@ -21889,8 +21925,8 @@ var DEFAULT_OPTIONS_RESULTS = {
21889
21925
  }]
21890
21926
  };
21891
21927
 
21892
- var createPublicQuery = function createPublicQuery(queryParams, sortOptions // will be removed when vuex is implemented
21893
- ) {
21928
+ var createPublicQuery = function createPublicQuery(queryParams, sortOptions, // will be removed when vuex is implemented
21929
+ defaultPageSize) {
21894
21930
  var _a;
21895
21931
 
21896
21932
  var publicQuery = {};
@@ -21908,11 +21944,11 @@ var createPublicQuery = function createPublicQuery(queryParams, sortOptions // w
21908
21944
  break;
21909
21945
 
21910
21946
  case QUERY_PARAMS_PARSED.LIMIT:
21911
- publicQuery.limit = Number(value);
21947
+ publicQuery.limit = Number(value) || defaultPageSize;
21912
21948
  break;
21913
21949
 
21914
21950
  case QUERY_PARAMS_PARSED.PAGE:
21915
- publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
21951
+ publicQuery.offset = getOffset(Number(value), Number(queryParams[QUERY_PARAMS_PARSED.LIMIT]) || defaultPageSize || DEFAULT_OPTIONS_RESULTS.pagination.sizeSelection.sizes[0]);
21916
21952
  break;
21917
21953
 
21918
21954
  case QUERY_PARAMS_PARSED.SORT:
@@ -27434,23 +27470,6 @@ var __vue_component__$G = /*#__PURE__*/normalizeComponent({
27434
27470
  staticRenderFns: __vue_staticRenderFns__$G
27435
27471
  }, __vue_inject_styles__$G, __vue_script__$G, __vue_scope_id__$G, __vue_is_functional_template__$G, __vue_module_identifier__$G, false, undefined, undefined, undefined);
27436
27472
 
27437
- var emitRoutingEvent = function emitRoutingEvent(url) {
27438
- var event = new CustomEvent(LUPA_ROUTING_EVENT, {
27439
- detail: url
27440
- });
27441
- window.dispatchEvent(event);
27442
- };
27443
- var handleRoutingEvent = function handleRoutingEvent(link, event) {
27444
- var hasEventRouting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
27445
-
27446
- if (!hasEventRouting) {
27447
- return;
27448
- }
27449
-
27450
- event === null || event === void 0 ? void 0 : event.preventDefault();
27451
- emitRoutingEvent(link);
27452
- };
27453
-
27454
27473
  var CategoryFilterItem = /*#__PURE__*/function (_Vue) {
27455
27474
  _inherits(CategoryFilterItem, _Vue);
27456
27475
 
@@ -32371,7 +32390,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
32371
32390
  get: function get() {
32372
32391
  var _a, _b, _c;
32373
32392
 
32374
- 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";
32393
+ 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);
32375
32394
  }
32376
32395
  }, {
32377
32396
  key: "isTitleResultTopPosition",
@@ -32382,10 +32401,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
32382
32401
  key: "mounted",
32383
32402
  value: function mounted() {
32384
32403
  window.addEventListener("resize", this.handleResize);
32385
- this.handleMounted();
32386
32404
  this.setSearchResultOptions({
32387
32405
  options: this.options
32388
32406
  });
32407
+ this.handleMounted();
32389
32408
  this.setInitialFilters({
32390
32409
  initialFilters: this.initialFilters
32391
32410
  });
@@ -32415,7 +32434,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
32415
32434
  key: "handleUrlChange",
32416
32435
  value: function handleUrlChange(params) {
32417
32436
  var searchParams = params || new URLSearchParams(window.location.search);
32418
- var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort);
32437
+ var publicQuery = createPublicQuery(parseParams(searchParams), this.options.sort, this.defaultSearchResultPageSize);
32419
32438
  this.setLoading(true);
32420
32439
  this.query(getPublicQuery(publicQuery, this.initialFilters, this.isProductList));
32421
32440
  }
@@ -32429,7 +32448,10 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
32429
32448
  query: publicQuery
32430
32449
  });
32431
32450
  var context = getLupaTrackingContext();
32432
- var query = Object.assign(Object.assign({}, publicQuery), context);
32451
+ var limit = publicQuery.limit || this.defaultSearchResultPageSize;
32452
+ var query = Object.assign(Object.assign(Object.assign({}, publicQuery), context), {
32453
+ limit: limit
32454
+ });
32433
32455
  getLupaSdk.query(this.options.queryKey, query, this.options.options).then(function (res) {
32434
32456
  var _a, _b;
32435
32457
 
@@ -32460,30 +32482,17 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
32460
32482
  value: function handleResults(_ref) {
32461
32483
  var queryKey = _ref.queryKey,
32462
32484
  results = _ref.results;
32485
+
32486
+ var _a;
32487
+
32463
32488
  this.trackResults({
32464
32489
  queryKey: queryKey,
32465
32490
  results: results
32466
32491
  });
32467
- var noResultsParam = this.options.noResultsQueryFlag;
32468
-
32469
- if (!noResultsParam) {
32470
- return;
32471
- }
32472
-
32473
- if (results.total < 1) {
32474
- this.appendParams({
32475
- params: [{
32476
- name: noResultsParam,
32477
- value: "true"
32478
- }],
32479
- save: false
32480
- });
32481
- } else {
32482
- this.removeParams({
32483
- paramsToRemove: [noResultsParam],
32484
- save: false
32485
- });
32486
- }
32492
+ this.handleNoResultsFlag({
32493
+ resultCount: (_a = results === null || results === void 0 ? void 0 : results.total) !== null && _a !== void 0 ? _a : 0,
32494
+ noResultsParam: this.options.noResultsQueryFlag
32495
+ });
32487
32496
  }
32488
32497
  }, {
32489
32498
  key: "handleResize",
@@ -32514,6 +32523,10 @@ __decorate([Prop({
32514
32523
 
32515
32524
  __decorate([searchResult$1.Getter("currentQueryText")], SearchResults.prototype, "currentQueryText", void 0);
32516
32525
 
32526
+ __decorate([searchResult$1.Getter("hasResults")], SearchResults.prototype, "hasResults", void 0);
32527
+
32528
+ __decorate([searchResult$1.Getter("currentFilterCount")], SearchResults.prototype, "currentFilterCount", void 0);
32529
+
32517
32530
  __decorate([tracking$2.Action("trackSearch")], SearchResults.prototype, "trackSearch", void 0);
32518
32531
 
32519
32532
  __decorate([tracking$2.Action("trackResults")], SearchResults.prototype, "trackResults", void 0);
@@ -32522,6 +32535,8 @@ __decorate([params$1.State("searchString")], SearchResults.prototype, "searchStr
32522
32535
 
32523
32536
  __decorate([params$1.Action("setDefaultLimit")], SearchResults.prototype, "setDefaultLimit", void 0);
32524
32537
 
32538
+ __decorate([params$1.Action("handleNoResultsFlag")], SearchResults.prototype, "handleNoResultsFlag", void 0);
32539
+
32525
32540
  __decorate([params$1.Action("add")], SearchResults.prototype, "addParams", void 0);
32526
32541
 
32527
32542
  __decorate([params$1.Action("removeParams")], SearchResults.prototype, "removeParams", void 0);
@@ -32538,6 +32553,8 @@ __decorate([searchResult$1.Action("add")], SearchResults.prototype, "addSearchRe
32538
32553
 
32539
32554
  __decorate([searchResult$1.Action("setLoading")], SearchResults.prototype, "setLoading", void 0);
32540
32555
 
32556
+ __decorate([options$1.Getter("defaultSearchResultPageSize")], SearchResults.prototype, "defaultSearchResultPageSize", void 0);
32557
+
32541
32558
  __decorate([searchResult$1.Action("setColumnCount")], SearchResults.prototype, "setColumnCount", void 0);
32542
32559
 
32543
32560
  SearchResults = __decorate([Component({
@@ -34252,7 +34269,7 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
34252
34269
  }, {
34253
34270
  key: "limit",
34254
34271
  get: function get() {
34255
- return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.defaultLimit;
34272
+ return Number(this.params[QUERY_PARAMS_PARSED.LIMIT]) || this.context.rootGetters["options/defaultSearchResultPageSize"] || this.defaultLimit;
34256
34273
  }
34257
34274
  }, {
34258
34275
  key: "sort",
@@ -34322,11 +34339,38 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
34322
34339
  searchString: url.search
34323
34340
  } : {};
34324
34341
  }
34342
+ }, {
34343
+ key: "handleNoResultsFlag",
34344
+ value: function handleNoResultsFlag(_ref3) {
34345
+ var resultCount = _ref3.resultCount,
34346
+ noResultsParam = _ref3.noResultsParam;
34347
+
34348
+ if (!noResultsParam || this.searchResultsLink && this.searchResultsLink !== window.location.pathname) {
34349
+ return;
34350
+ }
34351
+
34352
+ if (resultCount < 1) {
34353
+ this.context.dispatch("appendParams", {
34354
+ params: [{
34355
+ name: noResultsParam,
34356
+ value: "true"
34357
+ }],
34358
+ save: false
34359
+ });
34360
+ } else {
34361
+ this.context.dispatch("removeParams", {
34362
+ paramsToRemove: [noResultsParam],
34363
+ save: false
34364
+ });
34365
+ }
34366
+ }
34325
34367
  }, {
34326
34368
  key: "goToResults",
34327
- value: function goToResults(_ref3) {
34328
- var searchText = _ref3.searchText,
34329
- facet = _ref3.facet;
34369
+ value: function goToResults(_ref4) {
34370
+ var searchText = _ref4.searchText,
34371
+ facet = _ref4.facet;
34372
+
34373
+ var _a;
34330
34374
 
34331
34375
  if (!this.searchResultsLink || this.searchResultsLink === window.location.pathname) {
34332
34376
  var facetParam = facet ? [getFacetParam(facet.key, [facet.title])] : [];
@@ -34338,7 +34382,8 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
34338
34382
  paramsToRemove: "all"
34339
34383
  });
34340
34384
  } else {
34341
- window.location.assign(generateResultLink(this.searchResultsLink, searchText, facet));
34385
+ var routing = (_a = this.context.rootGetters["options/boxRoutingBehavior"]) !== null && _a !== void 0 ? _a : "direct-link";
34386
+ redirectToResultsPage(this.searchResultsLink, searchText, facet, routing);
34342
34387
  }
34343
34388
 
34344
34389
  this.context.dispatch("tracking/track", {
@@ -34354,13 +34399,13 @@ var ParamsModule = /*#__PURE__*/function (_VuexModule) {
34354
34399
  }
34355
34400
  }, {
34356
34401
  key: "appendParams",
34357
- value: function appendParams(_ref4) {
34358
- var params = _ref4.params,
34359
- paramsToRemove = _ref4.paramsToRemove,
34360
- _ref4$encode = _ref4.encode,
34361
- encode = _ref4$encode === void 0 ? true : _ref4$encode,
34362
- _ref4$save = _ref4.save,
34363
- save = _ref4$save === void 0 ? true : _ref4$save;
34402
+ value: function appendParams(_ref5) {
34403
+ var params = _ref5.params,
34404
+ paramsToRemove = _ref5.paramsToRemove,
34405
+ _ref5$encode = _ref5.encode,
34406
+ encode = _ref5$encode === void 0 ? true : _ref5$encode,
34407
+ _ref5$save = _ref5.save,
34408
+ save = _ref5$save === void 0 ? true : _ref5$save;
34364
34409
 
34365
34410
  if (!(params === null || params === void 0 ? void 0 : params.length)) {
34366
34411
  return {
@@ -34427,6 +34472,8 @@ __decorate([Action({
34427
34472
  commit: "save"
34428
34473
  })], ParamsModule.prototype, "removeParams", null);
34429
34474
 
34475
+ __decorate([Action({})], ParamsModule.prototype, "handleNoResultsFlag", null);
34476
+
34430
34477
  __decorate([Action({})], ParamsModule.prototype, "goToResults", null);
34431
34478
 
34432
34479
  __decorate([Action({
@@ -34484,6 +34531,20 @@ var OptionsModule = /*#__PURE__*/function (_VuexModule) {
34484
34531
  get: function get() {
34485
34532
  return this.searchResultInitialFilters;
34486
34533
  }
34534
+ }, {
34535
+ key: "boxRoutingBehavior",
34536
+ get: function get() {
34537
+ var _a;
34538
+
34539
+ return (_a = this.searchBoxOptions.routingBehavior) !== null && _a !== void 0 ? _a : "direct-link";
34540
+ }
34541
+ }, {
34542
+ key: "defaultSearchResultPageSize",
34543
+ get: function get() {
34544
+ var _a, _b, _c, _d, _e;
34545
+
34546
+ 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;
34547
+ }
34487
34548
  }, {
34488
34549
  key: "setSearchBoxOptions",
34489
34550
  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;
@@ -32,6 +32,10 @@ export default class ParamsModule extends VuexModule {
32
32
  params?: QueryParams;
33
33
  searchString?: string;
34
34
  };
35
+ handleNoResultsFlag({ resultCount, noResultsParam, }: {
36
+ resultCount: number;
37
+ noResultsParam?: string;
38
+ }): void;
35
39
  goToResults({ searchText, facet, }: {
36
40
  searchText: string;
37
41
  facet?: InputSuggestionFacet;
@@ -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;
@@ -4,12 +4,14 @@ import { DocumentSearchBoxPanel } from "@/types/search-box/SearchBoxPanel";
4
4
  import { SearchBoxOptionLabels } from "@/types/search-box/SearchBoxOptions";
5
5
  import { DocumentElement } from "@/types/DocumentElement";
6
6
  import { TrackableEventData } from "@/types/search-box/Common";
7
+ import { RoutingBehavior } from "@/types/search-results/RoutingBehavior";
7
8
  export default class SearchBoxProduct extends Vue {
8
9
  item: Document;
9
10
  inputValue: string;
10
11
  panelOptions: DocumentSearchBoxPanel;
11
12
  labels?: SearchBoxOptionLabels;
12
13
  highlighted?: boolean;
14
+ boxRoutingBehavior: RoutingBehavior;
13
15
  trackClick: ({ queryKey, data, }: {
14
16
  queryKey: string;
15
17
  data: TrackableEventData;
@@ -21,5 +23,5 @@ export default class SearchBoxProduct extends Vue {
21
23
  get imageElements(): DocumentElement[];
22
24
  get detailElements(): DocumentElement[];
23
25
  get id(): string;
24
- handleClick(): void;
26
+ handleClick(event?: Event): void;
25
27
  }
@@ -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;
@@ -23,6 +25,10 @@ export default class SearchResults extends Vue {
23
25
  setDefaultLimit: (defaultLimit: number) => {
24
26
  defaultLimit: number;
25
27
  };
28
+ handleNoResultsFlag: ({ resultCount, noResultsParam, }: {
29
+ resultCount: number;
30
+ noResultsParam?: string;
31
+ }) => void;
26
32
  addParams: (params: QueryParams) => {
27
33
  params: QueryParams;
28
34
  };
@@ -51,6 +57,7 @@ export default class SearchResults extends Vue {
51
57
  setLoading: (loading: boolean) => {
52
58
  loading: boolean;
53
59
  };
60
+ defaultSearchResultPageSize: number;
54
61
  handleUrlChange(params?: URLSearchParams): void;
55
62
  query(publicQuery: PublicQuery): void;
56
63
  handleResults({ queryKey, results, }: {