@getlupa/client 0.6.0-alpha-15 → 0.6.0-alpha-18

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.
@@ -1,7 +1,7 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
2
  import { CallbackContext, FacetFilterQuery, FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
- import { ProductListOptions } from "./types/product-list/ProductListOptions";
4
+ import { CategoryFilterOptions, ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
6
6
  import { SearchBoxPanelType } from "./types/search-box/SearchBoxPanel";
7
7
  import { RoutingBehavior } from "./types/search-results/RoutingBehavior";
@@ -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, SearchResultEventCallbacks, CallbackContext, FacetFilterQuery, };
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, CallbackContext, FacetFilterQuery, CategoryFilterOptions, };
21
21
  export default lupaSearch;
@@ -24332,10 +24332,19 @@ defaultPageSize) {
24332
24332
  }
24333
24333
  }
24334
24334
 
24335
+ publicQuery.sort = publicQuery.sort || getDefaultSort(sortOptions);
24335
24336
  publicQuery.filters = queryParams.filters;
24336
24337
  return publicQuery;
24337
24338
  };
24338
24339
 
24340
+ var getDefaultSort = function getDefaultSort(sortOptions) {
24341
+ var _a;
24342
+
24343
+ return ((_a = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.find(function (s) {
24344
+ return Boolean(s.default);
24345
+ })) === null || _a === void 0 ? void 0 : _a.config) || undefined;
24346
+ };
24347
+
24339
24348
  var getOffset = function getOffset(page) {
24340
24349
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
24341
24350
  if (!page || page === 1 || page < 0) return 0;
@@ -30053,23 +30062,33 @@ var CategoryFilter = /*#__PURE__*/function (_Vue) {
30053
30062
  }, {
30054
30063
  key: "mounted",
30055
30064
  value: function mounted() {
30065
+ var _a;
30066
+
30056
30067
  return __awaiter$1(this, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
30057
30068
  var result;
30058
30069
  return regenerator.wrap(function _callee$(_context) {
30059
30070
  while (1) {
30060
30071
  switch (_context.prev = _context.next) {
30061
30072
  case 0:
30062
- _context.next = 2;
30073
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.queryKey) {
30074
+ _context.next = 2;
30075
+ break;
30076
+ }
30077
+
30078
+ return _context.abrupt("return");
30079
+
30080
+ case 2:
30081
+ _context.next = 4;
30063
30082
  return getLupaSdk.query(this.options.queryKey, {
30064
30083
  searchText: "",
30065
30084
  filters: this.options.filters
30066
30085
  }, this.envOptions);
30067
30086
 
30068
- case 2:
30087
+ case 4:
30069
30088
  result = _context.sent;
30070
30089
  this.handleResult(result);
30071
30090
 
30072
- case 4:
30091
+ case 6:
30073
30092
  case "end":
30074
30093
  return _context.stop();
30075
30094
  }
@@ -30080,14 +30099,14 @@ var CategoryFilter = /*#__PURE__*/function (_Vue) {
30080
30099
  }, {
30081
30100
  key: "handleResult",
30082
30101
  value: function handleResult(result) {
30083
- var _a, _b;
30102
+ var _a, _b, _c;
30084
30103
 
30085
- if (!result.success) {
30104
+ if (!result.success || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.queryKey)) {
30086
30105
  return;
30087
30106
  }
30088
30107
 
30089
30108
  this.categoryChildren = result.items;
30090
- (_b = (_a = this.searchResultOptions.callbacks) === null || _a === void 0 ? void 0 : _a.onCategoryFilterResults) === null || _b === void 0 ? void 0 : _b.call(_a, {
30109
+ (_c = (_b = this.searchResultOptions.callbacks) === null || _b === void 0 ? void 0 : _b.onCategoryFilterResults) === null || _c === void 0 ? void 0 : _c.call(_b, {
30091
30110
  queryKey: this.options.queryKey,
30092
30111
  hasResults: result.total > 0
30093
30112
  });
@@ -34853,6 +34872,8 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34853
34872
  }, {
34854
34873
  key: "mounted",
34855
34874
  value: function mounted() {
34875
+ var _a, _b;
34876
+
34856
34877
  window.addEventListener("resize", this.handleResize);
34857
34878
  this.setSearchResultOptions({
34858
34879
  options: this.options
@@ -34861,6 +34882,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34861
34882
  this.setInitialFilters({
34862
34883
  initialFilters: this.initialFilters
34863
34884
  });
34885
+ (_b = (_a = this.options.callbacks) === null || _a === void 0 ? void 0 : _a.onMounted) === null || _b === void 0 ? void 0 : _b.call(_a);
34864
34886
  }
34865
34887
  }, {
34866
34888
  key: "beforeDestroy",
@@ -35281,8 +35303,11 @@ var __vue_render__$2 = function __vue_render__() {
35281
35303
  }, [_c("div", {
35282
35304
  staticClass: "lupa-category-title"
35283
35305
  }, [_vm._v(_vm._s(_vm.title))]), _vm._v(" "), _c("div", {
35284
- staticClass: "lupa-category-description"
35285
- }, [_vm._v(_vm._s(_vm.description))])]) : _vm._e();
35306
+ staticClass: "lupa-category-description",
35307
+ domProps: {
35308
+ innerHTML: _vm._s(_vm.description)
35309
+ }
35310
+ })]) : _vm._e();
35286
35311
  };
35287
35312
 
35288
35313
  var __vue_staticRenderFns__$2 = [];
@@ -2,7 +2,7 @@ import { FilterGroup } from "@getlupa/client-sdk/Types";
2
2
  import { RoutingBehavior } from "../search-results/RoutingBehavior";
3
3
  import { SearchResultsOptions } from "../search-results/SearchResultsOptions";
4
4
  export declare type CategoryFilterOptions = {
5
- queryKey: string;
5
+ queryKey?: string;
6
6
  routingBehavior?: RoutingBehavior;
7
7
  keys: {
8
8
  titleKey?: string;
@@ -24,5 +24,5 @@ export declare type CategoryFilterOptions = {
24
24
  };
25
25
  export declare type ProductListOptions = SearchResultsOptions & {
26
26
  initialFilters?: FilterGroup;
27
- categories: CategoryFilterOptions;
27
+ categories?: CategoryFilterOptions;
28
28
  };
@@ -27,6 +27,7 @@ export declare type SearchResultEventCallbacks = {
27
27
  onSearchResults?: (context: CallbackContext) => unknown;
28
28
  onAdditionalPanelResults?: (context: CallbackContext) => unknown;
29
29
  onCategoryFilterResults?: (context: CallbackContext) => unknown;
30
+ onMounted?: () => unknown;
30
31
  };
31
32
  export declare type SearchResultsOptionLabels = SearchResultsPaginationLabels & SearchResultsDidYouMeanLabels & SearchResultsSimilarQueriesLabels & {
32
33
  sortBy: string;
@@ -1,7 +1,7 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
2
  import { CallbackContext, FacetFilterQuery, FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
- import { ProductListOptions } from "./types/product-list/ProductListOptions";
4
+ import { CategoryFilterOptions, ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
6
6
  import { SearchBoxPanelType } from "./types/search-box/SearchBoxPanel";
7
7
  import { RoutingBehavior } from "./types/search-results/RoutingBehavior";
@@ -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, SearchResultEventCallbacks, CallbackContext, FacetFilterQuery, };
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, CallbackContext, FacetFilterQuery, CategoryFilterOptions, };
21
21
  export default lupaSearch;
@@ -24328,10 +24328,19 @@ defaultPageSize) {
24328
24328
  }
24329
24329
  }
24330
24330
 
24331
+ publicQuery.sort = publicQuery.sort || getDefaultSort(sortOptions);
24331
24332
  publicQuery.filters = queryParams.filters;
24332
24333
  return publicQuery;
24333
24334
  };
24334
24335
 
24336
+ var getDefaultSort = function getDefaultSort(sortOptions) {
24337
+ var _a;
24338
+
24339
+ return ((_a = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.find(function (s) {
24340
+ return Boolean(s.default);
24341
+ })) === null || _a === void 0 ? void 0 : _a.config) || undefined;
24342
+ };
24343
+
24335
24344
  var getOffset = function getOffset(page) {
24336
24345
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
24337
24346
  if (!page || page === 1 || page < 0) return 0;
@@ -30049,23 +30058,33 @@ var CategoryFilter = /*#__PURE__*/function (_Vue) {
30049
30058
  }, {
30050
30059
  key: "mounted",
30051
30060
  value: function mounted() {
30061
+ var _a;
30062
+
30052
30063
  return __awaiter$1(this, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
30053
30064
  var result;
30054
30065
  return regenerator.wrap(function _callee$(_context) {
30055
30066
  while (1) {
30056
30067
  switch (_context.prev = _context.next) {
30057
30068
  case 0:
30058
- _context.next = 2;
30069
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.queryKey) {
30070
+ _context.next = 2;
30071
+ break;
30072
+ }
30073
+
30074
+ return _context.abrupt("return");
30075
+
30076
+ case 2:
30077
+ _context.next = 4;
30059
30078
  return getLupaSdk.query(this.options.queryKey, {
30060
30079
  searchText: "",
30061
30080
  filters: this.options.filters
30062
30081
  }, this.envOptions);
30063
30082
 
30064
- case 2:
30083
+ case 4:
30065
30084
  result = _context.sent;
30066
30085
  this.handleResult(result);
30067
30086
 
30068
- case 4:
30087
+ case 6:
30069
30088
  case "end":
30070
30089
  return _context.stop();
30071
30090
  }
@@ -30076,14 +30095,14 @@ var CategoryFilter = /*#__PURE__*/function (_Vue) {
30076
30095
  }, {
30077
30096
  key: "handleResult",
30078
30097
  value: function handleResult(result) {
30079
- var _a, _b;
30098
+ var _a, _b, _c;
30080
30099
 
30081
- if (!result.success) {
30100
+ if (!result.success || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.queryKey)) {
30082
30101
  return;
30083
30102
  }
30084
30103
 
30085
30104
  this.categoryChildren = result.items;
30086
- (_b = (_a = this.searchResultOptions.callbacks) === null || _a === void 0 ? void 0 : _a.onCategoryFilterResults) === null || _b === void 0 ? void 0 : _b.call(_a, {
30105
+ (_c = (_b = this.searchResultOptions.callbacks) === null || _b === void 0 ? void 0 : _b.onCategoryFilterResults) === null || _c === void 0 ? void 0 : _c.call(_b, {
30087
30106
  queryKey: this.options.queryKey,
30088
30107
  hasResults: result.total > 0
30089
30108
  });
@@ -34849,6 +34868,8 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34849
34868
  }, {
34850
34869
  key: "mounted",
34851
34870
  value: function mounted() {
34871
+ var _a, _b;
34872
+
34852
34873
  window.addEventListener("resize", this.handleResize);
34853
34874
  this.setSearchResultOptions({
34854
34875
  options: this.options
@@ -34857,6 +34878,7 @@ var SearchResults = /*#__PURE__*/function (_Vue) {
34857
34878
  this.setInitialFilters({
34858
34879
  initialFilters: this.initialFilters
34859
34880
  });
34881
+ (_b = (_a = this.options.callbacks) === null || _a === void 0 ? void 0 : _a.onMounted) === null || _b === void 0 ? void 0 : _b.call(_a);
34860
34882
  }
34861
34883
  }, {
34862
34884
  key: "beforeDestroy",
@@ -35277,8 +35299,11 @@ var __vue_render__$2 = function __vue_render__() {
35277
35299
  }, [_c("div", {
35278
35300
  staticClass: "lupa-category-title"
35279
35301
  }, [_vm._v(_vm._s(_vm.title))]), _vm._v(" "), _c("div", {
35280
- staticClass: "lupa-category-description"
35281
- }, [_vm._v(_vm._s(_vm.description))])]) : _vm._e();
35302
+ staticClass: "lupa-category-description",
35303
+ domProps: {
35304
+ innerHTML: _vm._s(_vm.description)
35305
+ }
35306
+ })]) : _vm._e();
35282
35307
  };
35283
35308
 
35284
35309
  var __vue_staticRenderFns__$2 = [];
@@ -2,7 +2,7 @@ import { FilterGroup } from "@getlupa/client-sdk/Types";
2
2
  import { RoutingBehavior } from "../search-results/RoutingBehavior";
3
3
  import { SearchResultsOptions } from "../search-results/SearchResultsOptions";
4
4
  export declare type CategoryFilterOptions = {
5
- queryKey: string;
5
+ queryKey?: string;
6
6
  routingBehavior?: RoutingBehavior;
7
7
  keys: {
8
8
  titleKey?: string;
@@ -24,5 +24,5 @@ export declare type CategoryFilterOptions = {
24
24
  };
25
25
  export declare type ProductListOptions = SearchResultsOptions & {
26
26
  initialFilters?: FilterGroup;
27
- categories: CategoryFilterOptions;
27
+ categories?: CategoryFilterOptions;
28
28
  };
@@ -27,6 +27,7 @@ export declare type SearchResultEventCallbacks = {
27
27
  onSearchResults?: (context: CallbackContext) => unknown;
28
28
  onAdditionalPanelResults?: (context: CallbackContext) => unknown;
29
29
  onCategoryFilterResults?: (context: CallbackContext) => unknown;
30
+ onMounted?: () => unknown;
30
31
  };
31
32
  export declare type SearchResultsOptionLabels = SearchResultsPaginationLabels & SearchResultsDidYouMeanLabels & SearchResultsSimilarQueriesLabels & {
32
33
  sortBy: string;
@@ -1,7 +1,7 @@
1
1
  import { SearchBoxOptions } from "./types/search-box/SearchBoxOptions";
2
2
  import { CallbackContext, FacetFilterQuery, FacetStyle, SearchResultEventCallbacks, SearchResultsOptions } from "./types/search-results/SearchResultsOptions";
3
3
  import { SdkOptions, TrackingOptions, Environment, SortDirection } from "./types/General";
4
- import { ProductListOptions } from "./types/product-list/ProductListOptions";
4
+ import { CategoryFilterOptions, ProductListOptions } from "./types/product-list/ProductListOptions";
5
5
  import { AddToCartElement, CustomDocumentElement, CustomHtmlElement, DescriptionDocumentElement, DocumentElement, DocumentElementType, ImageDocumentElement, PriceElement, RatingElement, RegularPriceDocumentElement, TitleDocumentElement } from "./types/DocumentElement";
6
6
  import { SearchBoxPanelType } from "./types/search-box/SearchBoxPanel";
7
7
  import { RoutingBehavior } from "./types/search-results/RoutingBehavior";
@@ -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, SearchResultEventCallbacks, CallbackContext, FacetFilterQuery, };
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, CallbackContext, FacetFilterQuery, CategoryFilterOptions, };
21
21
  export default lupaSearch;