@getlupa/client 0.6.0-alpha-4 → 0.6.0-alpha-5

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.
@@ -25,10 +25,6 @@ export default class SearchResults extends Vue {
25
25
  setDefaultLimit: (defaultLimit: number) => {
26
26
  defaultLimit: number;
27
27
  };
28
- handleNoResultsFlag: ({ resultCount, noResultsParam, }: {
29
- resultCount: number;
30
- noResultsParam?: string;
31
- }) => void;
32
28
  addParams: (params: QueryParams) => {
33
29
  params: QueryParams;
34
30
  };
@@ -64,6 +60,7 @@ export default class SearchResults extends Vue {
64
60
  queryKey: string;
65
61
  results: SearchQueryResult;
66
62
  }): void;
63
+ handleNoResults(results: SearchQueryResult): void;
67
64
  setScreenWidth: ({ width, }: {
68
65
  width: number;
69
66
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
- import { FacetStyle, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
2
+ import { FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
4
  import { ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
@@ -17,5 +17,5 @@ declare const lupaSearch: {
17
17
  clearSearchResults: () => void;
18
18
  clearProductList: () => void;
19
19
  };
20
- export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, };
20
+ export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, };
21
21
  export default lupaSearch;
@@ -34857,17 +34857,24 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34857
34857
  value: function handleResults(_ref) {
34858
34858
  var queryKey = _ref.queryKey,
34859
34859
  results = _ref.results;
34860
-
34861
- var _a;
34862
-
34863
34860
  this.trackResults({
34864
34861
  queryKey: queryKey,
34865
34862
  results: results
34866
34863
  });
34867
- this.handleNoResultsFlag({
34868
- resultCount: (_a = results === null || results === void 0 ? void 0 : results.total) !== null && _a !== void 0 ? _a : 0,
34869
- noResultsParam: this.options.noResultsQueryFlag
34870
- });
34864
+ this.handleNoResults(results);
34865
+ }
34866
+ }, {
34867
+ key: "handleNoResults",
34868
+ value: function handleNoResults(results) {
34869
+ var _a, _b, _c;
34870
+
34871
+ var hasResults = Boolean(results.total > 0 || ((_a = results.similarQueries) === null || _a === void 0 ? void 0 : _a.length) || ((_b = results.didYouMean) === null || _b === void 0 ? void 0 : _b.options));
34872
+
34873
+ if (hasResults) {
34874
+ return;
34875
+ }
34876
+
34877
+ (_c = this.options.callbacks) === null || _c === void 0 ? void 0 : _c.noResults();
34871
34878
  }
34872
34879
  }, {
34873
34880
  key: "handleResize",
@@ -34913,8 +34920,6 @@ __decorate([params$1.State("searchString")], SearchResults.prototype, "searchStr
34913
34920
 
34914
34921
  __decorate([params$1.Action("setDefaultLimit")], SearchResults.prototype, "setDefaultLimit", void 0);
34915
34922
 
34916
- __decorate([params$1.Action("handleNoResultsFlag")], SearchResults.prototype, "handleNoResultsFlag", void 0);
34917
-
34918
34923
  __decorate([params$1.Action("add")], SearchResults.prototype, "addParams", void 0);
34919
34924
 
34920
34925
  __decorate([params$1.Action("removeParams")], SearchResults.prototype, "removeParams", void 0);
@@ -7,8 +7,8 @@ export declare type SearchResultsOptions = SearchResultsProductOptions & SearchR
7
7
  containerSelector: string;
8
8
  breadcrumbs: SearchResultsBreadcrumb[];
9
9
  classMap?: Record<string, string>;
10
- noResultsQueryFlag?: string;
11
10
  disallowEmptyQuery?: boolean;
11
+ callbacks?: SearchResultEventCallbacks;
12
12
  };
13
13
  export declare type SearchTitlePosition = "page-top" | "search-results-top";
14
14
  export declare type SearchResultsDidYouMeanLabels = {
@@ -19,6 +19,9 @@ export declare type SearchResultsSimilarQueriesLabels = {
19
19
  similarQuery: string;
20
20
  similarQueries: string;
21
21
  };
22
+ export declare type SearchResultEventCallbacks = {
23
+ noResults: () => void;
24
+ };
22
25
  export declare type SearchResultsOptionLabels = SearchResultsPaginationLabels & SearchResultsDidYouMeanLabels & SearchResultsSimilarQueriesLabels & {
23
26
  sortBy: string;
24
27
  currency: string;
@@ -25,10 +25,6 @@ export default class SearchResults extends Vue {
25
25
  setDefaultLimit: (defaultLimit: number) => {
26
26
  defaultLimit: number;
27
27
  };
28
- handleNoResultsFlag: ({ resultCount, noResultsParam, }: {
29
- resultCount: number;
30
- noResultsParam?: string;
31
- }) => void;
32
28
  addParams: (params: QueryParams) => {
33
29
  params: QueryParams;
34
30
  };
@@ -64,6 +60,7 @@ export default class SearchResults extends Vue {
64
60
  queryKey: string;
65
61
  results: SearchQueryResult;
66
62
  }): void;
63
+ handleNoResults(results: SearchQueryResult): void;
67
64
  setScreenWidth: ({ width, }: {
68
65
  width: number;
69
66
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
- import { FacetStyle, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
2
+ import { FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
4
  import { ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
@@ -17,5 +17,5 @@ declare const lupaSearch: {
17
17
  clearSearchResults: () => void;
18
18
  clearProductList: () => void;
19
19
  };
20
- export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, };
20
+ export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, };
21
21
  export default lupaSearch;
@@ -34853,17 +34853,24 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34853
34853
  value: function handleResults(_ref) {
34854
34854
  var queryKey = _ref.queryKey,
34855
34855
  results = _ref.results;
34856
-
34857
- var _a;
34858
-
34859
34856
  this.trackResults({
34860
34857
  queryKey: queryKey,
34861
34858
  results: results
34862
34859
  });
34863
- this.handleNoResultsFlag({
34864
- resultCount: (_a = results === null || results === void 0 ? void 0 : results.total) !== null && _a !== void 0 ? _a : 0,
34865
- noResultsParam: this.options.noResultsQueryFlag
34866
- });
34860
+ this.handleNoResults(results);
34861
+ }
34862
+ }, {
34863
+ key: "handleNoResults",
34864
+ value: function handleNoResults(results) {
34865
+ var _a, _b, _c;
34866
+
34867
+ var hasResults = Boolean(results.total > 0 || ((_a = results.similarQueries) === null || _a === void 0 ? void 0 : _a.length) || ((_b = results.didYouMean) === null || _b === void 0 ? void 0 : _b.options));
34868
+
34869
+ if (hasResults) {
34870
+ return;
34871
+ }
34872
+
34873
+ (_c = this.options.callbacks) === null || _c === void 0 ? void 0 : _c.noResults();
34867
34874
  }
34868
34875
  }, {
34869
34876
  key: "handleResize",
@@ -34909,8 +34916,6 @@ __decorate([params$1.State("searchString")], SearchResults.prototype, "searchStr
34909
34916
 
34910
34917
  __decorate([params$1.Action("setDefaultLimit")], SearchResults.prototype, "setDefaultLimit", void 0);
34911
34918
 
34912
- __decorate([params$1.Action("handleNoResultsFlag")], SearchResults.prototype, "handleNoResultsFlag", void 0);
34913
-
34914
34919
  __decorate([params$1.Action("add")], SearchResults.prototype, "addParams", void 0);
34915
34920
 
34916
34921
  __decorate([params$1.Action("removeParams")], SearchResults.prototype, "removeParams", void 0);
@@ -7,8 +7,8 @@ export declare type SearchResultsOptions = SearchResultsProductOptions & SearchR
7
7
  containerSelector: string;
8
8
  breadcrumbs: SearchResultsBreadcrumb[];
9
9
  classMap?: Record<string, string>;
10
- noResultsQueryFlag?: string;
11
10
  disallowEmptyQuery?: boolean;
11
+ callbacks?: SearchResultEventCallbacks;
12
12
  };
13
13
  export declare type SearchTitlePosition = "page-top" | "search-results-top";
14
14
  export declare type SearchResultsDidYouMeanLabels = {
@@ -19,6 +19,9 @@ export declare type SearchResultsSimilarQueriesLabels = {
19
19
  similarQuery: string;
20
20
  similarQueries: string;
21
21
  };
22
+ export declare type SearchResultEventCallbacks = {
23
+ noResults: () => void;
24
+ };
22
25
  export declare type SearchResultsOptionLabels = SearchResultsPaginationLabels & SearchResultsDidYouMeanLabels & SearchResultsSimilarQueriesLabels & {
23
26
  sortBy: string;
24
27
  currency: string;
@@ -25,10 +25,6 @@ export default class SearchResults extends Vue {
25
25
  setDefaultLimit: (defaultLimit: number) => {
26
26
  defaultLimit: number;
27
27
  };
28
- handleNoResultsFlag: ({ resultCount, noResultsParam, }: {
29
- resultCount: number;
30
- noResultsParam?: string;
31
- }) => void;
32
28
  addParams: (params: QueryParams) => {
33
29
  params: QueryParams;
34
30
  };
@@ -64,6 +60,7 @@ export default class SearchResults extends Vue {
64
60
  queryKey: string;
65
61
  results: SearchQueryResult;
66
62
  }): void;
63
+ handleNoResults(results: SearchQueryResult): void;
67
64
  setScreenWidth: ({ width, }: {
68
65
  width: number;
69
66
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
- import { FacetStyle, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
2
+ import { FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
4
  import { ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
@@ -17,5 +17,5 @@ declare const lupaSearch: {
17
17
  clearSearchResults: () => void;
18
18
  clearProductList: () => void;
19
19
  };
20
- export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, };
20
+ export { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, DocumentElementType, SearchBoxPanelType, FacetStyle, Environment, RoutingBehavior, AnchorPosition, BadgeType, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, };
21
21
  export default lupaSearch;