@getlupa/client 1.6.3 → 1.6.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.
@@ -6570,21 +6570,21 @@ const sendUaAnalyticsEvent = (data, options) => {
6570
6570
  );
6571
6571
  };
6572
6572
  const sendGa4AnalyticsEvent = (data, options) => {
6573
- var _a, _b, _c, _d, _e;
6573
+ var _a, _b, _c, _d, _e, _f, _g;
6574
6574
  if (!window || !window.dataLayer) {
6575
6575
  console.error("dataLayer object not found.");
6576
6576
  return;
6577
6577
  }
6578
6578
  const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
6579
6579
  const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
6580
- const params = {
6580
+ const params = __spreadValues2({
6581
6581
  search_text: data.searchQuery,
6582
6582
  item_title: title,
6583
6583
  item_id: data.itemId,
6584
6584
  ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
6585
- };
6585
+ }, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
6586
6586
  window.dataLayer.push(__spreadValues2({
6587
- event: (_e = (_d = data.analytics) == null ? void 0 : _d.type) != null ? _e : options.parentEventName
6587
+ event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
6588
6588
  }, params));
6589
6589
  };
6590
6590
  const processDebugEvent = (data) => {
@@ -7427,6 +7427,10 @@ const useParamsStore = defineStore("params", () => {
7427
7427
  const searchString = ref("");
7428
7428
  const optionsStore = useOptionsStore();
7429
7429
  const redirectionStore = useRedirectionStore();
7430
+ const sortParams = ref({
7431
+ selectedSortKey: "",
7432
+ previousSortKey: ""
7433
+ });
7430
7434
  const query = computed(() => params.value[QUERY_PARAMS_PARSED.QUERY]);
7431
7435
  const page = computed(() => {
7432
7436
  const page2 = Number(params.value[QUERY_PARAMS_PARSED.PAGE]) || 1;
@@ -7561,6 +7565,12 @@ const useParamsStore = defineStore("params", () => {
7561
7565
  }
7562
7566
  searchResultsLink.value = newSearchResultsLink;
7563
7567
  };
7568
+ const setSortSettings = ({ selectedSortKey, previousSortKey }) => {
7569
+ sortParams.value = {
7570
+ selectedSortKey,
7571
+ previousSortKey
7572
+ };
7573
+ };
7564
7574
  return {
7565
7575
  params,
7566
7576
  defaultLimit,
@@ -7571,6 +7581,7 @@ const useParamsStore = defineStore("params", () => {
7571
7581
  limit,
7572
7582
  sort,
7573
7583
  filters,
7584
+ sortParams,
7574
7585
  add: add2,
7575
7586
  removeAllFilters,
7576
7587
  removeParameters,
@@ -7578,7 +7589,8 @@ const useParamsStore = defineStore("params", () => {
7578
7589
  goToResults,
7579
7590
  appendParams,
7580
7591
  setDefaultLimit,
7581
- setSearchResultsLink
7592
+ setSearchResultsLink,
7593
+ setSortSettings
7582
7594
  };
7583
7595
  });
7584
7596
  const flattenFacet = (key, facets, suggestion, inputValue) => {
@@ -7623,6 +7635,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7623
7635
  const suggestionResults = ref({});
7624
7636
  const highlightedIndex = ref(-1);
7625
7637
  const inputValue = ref("");
7638
+ const resultInputValue = ref("");
7626
7639
  const historyStore = useHistoryStore();
7627
7640
  const resultsVisible = computed(() => {
7628
7641
  var _a;
@@ -7635,13 +7648,15 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7635
7648
  return {
7636
7649
  queryKey: p2.queryKey,
7637
7650
  count: (_b = (_a = suggestionResults.value[p2.queryKey]) == null ? void 0 : _a.length) != null ? _b : 0,
7638
- panel: p2
7651
+ panel: p2,
7652
+ input: resultInputValue.value
7639
7653
  };
7640
7654
  }
7641
7655
  return {
7642
7656
  queryKey: p2.queryKey,
7643
7657
  count: (_e = (_d = (_c = docResults.value[p2.queryKey]) == null ? void 0 : _c.items) == null ? void 0 : _d.length) != null ? _e : 0,
7644
- panel: p2
7658
+ panel: p2,
7659
+ input: resultInputValue.value
7645
7660
  };
7646
7661
  })
7647
7662
  );
@@ -7701,6 +7716,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7701
7716
  [queryKey]: flattenSuggestions(result.items, (_a = publicQuery.searchText) != null ? _a : "")
7702
7717
  });
7703
7718
  inputValue.value = publicQuery.searchText;
7719
+ resultInputValue.value = publicQuery.searchText;
7704
7720
  emitSearchResultsCallback();
7705
7721
  return {
7706
7722
  suggestions: result.items
@@ -7788,7 +7804,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7788
7804
  const _hoisted_1$1c = { id: "lupa-search-box-input-container" };
7789
7805
  const _hoisted_2$P = { class: "lupa-input-clear" };
7790
7806
  const _hoisted_3$B = { id: "lupa-search-box-input" };
7791
- const _hoisted_4$q = ["value"];
7807
+ const _hoisted_4$r = ["value"];
7792
7808
  const _hoisted_5$f = ["placeholder"];
7793
7809
  const _hoisted_6$9 = {
7794
7810
  key: 0,
@@ -7883,7 +7899,7 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
7883
7899
  class: "lupa-hint",
7884
7900
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7885
7901
  disabled: ""
7886
- }, null, 8, _hoisted_4$q),
7902
+ }, null, 8, _hoisted_4$r),
7887
7903
  withDirectives(createBaseVNode("input", mergeProps({
7888
7904
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7889
7905
  }, inputAttributes.value, {
@@ -8062,7 +8078,7 @@ const _hoisted_3$A = {
8062
8078
  class: "lupa-suggestion-facet",
8063
8079
  "data-cy": "lupa-suggestion-facet"
8064
8080
  };
8065
- const _hoisted_4$p = {
8081
+ const _hoisted_4$q = {
8066
8082
  class: "lupa-suggestion-facet-label",
8067
8083
  "data-cy": "lupa-suggestion-facet-label"
8068
8084
  };
@@ -8108,7 +8124,7 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
8108
8124
  innerHTML: _ctx.suggestion.displayHighlight
8109
8125
  }, null, 8, _hoisted_1$18)) : (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(_ctx.suggestion.display), 1)),
8110
8126
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$A, [
8111
- createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
8127
+ createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8112
8128
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
8113
8129
  ])) : createCommentVNode("", true)
8114
8130
  ]);
@@ -8516,7 +8532,7 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
8516
8532
  const _hoisted_1$11 = ["innerHTML"];
8517
8533
  const _hoisted_2$K = { key: 0 };
8518
8534
  const _hoisted_3$z = { key: 1 };
8519
- const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8535
+ const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8520
8536
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8521
8537
  const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8522
8538
  __name: "SearchBoxProductCustom",
@@ -8549,7 +8565,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8549
8565
  class: [className.value, "lupa-search-box-product-custom"]
8550
8566
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8551
8567
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$K, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$z, [
8552
- createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8568
+ createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8553
8569
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8554
8570
  ]))
8555
8571
  ], 16));
@@ -8887,65 +8903,10 @@ const _sfc_main$13 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
8887
8903
  };
8888
8904
  }
8889
8905
  }));
8890
- const getSearchTrackingData = (searchText, type) => {
8891
- return {
8892
- searchQuery: searchText,
8893
- analytics: {
8894
- type,
8895
- label: searchText
8896
- }
8897
- };
8898
- };
8899
- const useTrackingStore = defineStore("tracking", () => {
8900
- const optionsStore = useOptionsStore();
8901
- const trackSearch = ({
8902
- queryKey,
8903
- query,
8904
- type = "search_query"
8905
- }) => {
8906
- var _a, _b;
8907
- const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
8908
- const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
8909
- if (hasFilters) {
8910
- const data2 = getSearchTrackingData(query.searchText, "search_filters");
8911
- track(queryKey, data2, options);
8912
- return;
8913
- }
8914
- const data = getSearchTrackingData(query.searchText, type);
8915
- track(queryKey, data, options);
8916
- };
8917
- const trackResults = ({
8918
- queryKey,
8919
- results
8920
- }) => {
8921
- var _a;
8922
- const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
8923
- if (results.total > 0) {
8924
- return;
8925
- }
8926
- const data = getSearchTrackingData(results.searchText, "search_zero_results");
8927
- track(queryKey, data, options);
8928
- };
8929
- const trackEvent = ({ queryKey, data }) => {
8930
- var _a, _b, _c, _d, _e;
8931
- const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
8932
- const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
8933
- const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
8934
- const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
8935
- track(
8936
- queryKey,
8937
- __spreadProps2(__spreadValues2({}, data), {
8938
- analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
8939
- }),
8940
- options
8941
- );
8942
- };
8943
- return { trackSearch, trackResults, trackEvent };
8944
- });
8945
8906
  const _hoisted_1$_ = ["href"];
8946
8907
  const _hoisted_2$I = { class: "lupa-search-box-product-image-section" };
8947
8908
  const _hoisted_3$x = { class: "lupa-search-box-product-details-section" };
8948
- const _hoisted_4$n = {
8909
+ const _hoisted_4$o = {
8949
8910
  key: 0,
8950
8911
  class: "lupa-search-box-product-add-to-cart-section"
8951
8912
  };
@@ -8961,11 +8922,7 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
8961
8922
  emits: ["product-click"],
8962
8923
  setup(__props, { emit: emit2 }) {
8963
8924
  const props = __props;
8964
- const historyStore = useHistoryStore();
8965
- const trackingStore = useTrackingStore();
8966
- const optionsStore = useOptionsStore();
8967
8925
  const isInStock = ref(true);
8968
- const { boxRoutingBehavior } = storeToRefs(optionsStore);
8969
8926
  const link = computed(() => {
8970
8927
  var _a, _b;
8971
8928
  return generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", props.item);
@@ -8980,54 +8937,16 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
8980
8937
  (e) => e.type !== DocumentElementType.IMAGE && e.type !== DocumentElementType.ADDTOCART
8981
8938
  )) != null ? _b : [];
8982
8939
  });
8983
- const id = computed(() => {
8984
- if (props.panelOptions.idKey) {
8985
- return props.item[props.panelOptions.idKey];
8986
- }
8987
- return "";
8988
- });
8989
- const title = computed(() => {
8990
- if (!props.panelOptions.titleKey) {
8991
- return "";
8992
- }
8993
- const title2 = props.item[props.panelOptions.titleKey] || "";
8994
- historyStore.add({
8995
- item: title2
8996
- });
8997
- return title2;
8998
- });
8999
8940
  const addToCartElement = computed(() => {
9000
8941
  var _a;
9001
8942
  return (_a = props.panelOptions.elements) == null ? void 0 : _a.find((e) => e.type === DocumentElementType.ADDTOCART);
9002
8943
  });
9003
8944
  const handleClick = (event) => {
9004
- var _a;
9005
- if (props.panelOptions.titleKey) {
9006
- historyStore.add({
9007
- item: props.item[props.panelOptions.titleKey] || ""
9008
- });
9009
- }
9010
- if (!props.panelOptions.idKey) {
9011
- return;
9012
- }
9013
- trackingStore.trackEvent({
9014
- queryKey: props.panelOptions.queryKey,
9015
- data: {
9016
- itemId: id.value,
9017
- searchQuery: props.inputValue,
9018
- type: "itemClick",
9019
- analytics: {
9020
- type: "autocomplete_product_click",
9021
- label: (_a = title.value) != null ? _a : link.value,
9022
- items: [props.item]
9023
- }
9024
- }
8945
+ emit2("product-click", {
8946
+ item: props.item,
8947
+ eventType: "itemClick",
8948
+ event
9025
8949
  });
9026
- if (!link.value) {
9027
- return;
9028
- }
9029
- emit2("product-click");
9030
- handleRoutingEvent(link.value, event, boxRoutingBehavior.value === "event");
9031
8950
  };
9032
8951
  onMounted(() => {
9033
8952
  checkIfIsInStock();
@@ -9066,7 +8985,7 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
9066
8985
  }, null, 8, ["item", "element", "labels", "link"]);
9067
8986
  }), 128))
9068
8987
  ]),
9069
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8988
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
9070
8989
  createVNode(_sfc_main$13, {
9071
8990
  class: "lupa-search-box-product-element",
9072
8991
  item: _ctx.item,
@@ -9080,6 +8999,61 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
9080
8999
  };
9081
9000
  }
9082
9001
  });
9002
+ const getSearchTrackingData = (searchText, type) => {
9003
+ return {
9004
+ searchQuery: searchText,
9005
+ analytics: {
9006
+ type,
9007
+ label: searchText
9008
+ }
9009
+ };
9010
+ };
9011
+ const useTrackingStore = defineStore("tracking", () => {
9012
+ const optionsStore = useOptionsStore();
9013
+ const trackSearch = ({
9014
+ queryKey,
9015
+ query,
9016
+ type = "search_query"
9017
+ }) => {
9018
+ var _a, _b;
9019
+ const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
9020
+ const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
9021
+ if (hasFilters) {
9022
+ const data2 = getSearchTrackingData(query.searchText, "search_filters");
9023
+ track(queryKey, data2, options);
9024
+ return;
9025
+ }
9026
+ const data = getSearchTrackingData(query.searchText, type);
9027
+ track(queryKey, data, options);
9028
+ };
9029
+ const trackResults = ({
9030
+ queryKey,
9031
+ results
9032
+ }) => {
9033
+ var _a;
9034
+ const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
9035
+ if (results.total > 0) {
9036
+ return;
9037
+ }
9038
+ const data = getSearchTrackingData(results.searchText, "search_zero_results");
9039
+ track(queryKey, data, options);
9040
+ };
9041
+ const trackEvent = ({ queryKey, data }) => {
9042
+ var _a, _b, _c, _d, _e;
9043
+ const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
9044
+ const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
9045
+ const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
9046
+ const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
9047
+ track(
9048
+ queryKey,
9049
+ __spreadProps2(__spreadValues2({}, data), {
9050
+ analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
9051
+ }),
9052
+ options
9053
+ );
9054
+ };
9055
+ return { trackSearch, trackResults, trackEvent };
9056
+ });
9083
9057
  const _hoisted_1$Z = { id: "lupa-search-box-products" };
9084
9058
  const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9085
9059
  __name: "SearchBoxProducts",
@@ -9089,9 +9063,14 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9089
9063
  panelOptions: {},
9090
9064
  labels: {}
9091
9065
  },
9092
- setup(__props) {
9066
+ emits: ["product-click"],
9067
+ setup(__props, { emit: emit2 }) {
9093
9068
  const props = __props;
9094
9069
  const searchBoxStore = useSearchBoxStore();
9070
+ const historyStore = useHistoryStore();
9071
+ const trackingStore = useTrackingStore();
9072
+ const optionsStore = useOptionsStore();
9073
+ const { boxRoutingBehavior } = storeToRefs(optionsStore);
9095
9074
  const { highlightedItem } = storeToRefs(searchBoxStore);
9096
9075
  const highlightedIndex = computed(() => {
9097
9076
  var _a, _b, _c;
@@ -9100,6 +9079,42 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9100
9079
  }
9101
9080
  return (_c = (_b = highlightedItem.value) == null ? void 0 : _b.index) != null ? _c : -1;
9102
9081
  });
9082
+ const handleProductClick = ({
9083
+ item,
9084
+ eventType,
9085
+ event
9086
+ }) => {
9087
+ var _a, _b;
9088
+ const link = generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", item);
9089
+ const title = props.panelOptions.titleKey ? item[props.panelOptions.titleKey] || "" : "";
9090
+ const id = props.panelOptions.idKey ? item[props.panelOptions.idKey] : "";
9091
+ if (props.panelOptions.titleKey) {
9092
+ historyStore.add({
9093
+ item: item[props.panelOptions.titleKey] || ""
9094
+ });
9095
+ }
9096
+ if (!props.panelOptions.idKey) {
9097
+ return;
9098
+ }
9099
+ trackingStore.trackEvent({
9100
+ queryKey: props.panelOptions.queryKey,
9101
+ data: {
9102
+ itemId: id,
9103
+ searchQuery: props.inputValue,
9104
+ type: eventType || "itemClick",
9105
+ analytics: {
9106
+ type: "autocomplete_product_click",
9107
+ label: title != null ? title : link,
9108
+ items: [item]
9109
+ }
9110
+ }
9111
+ });
9112
+ if (!link) {
9113
+ return;
9114
+ }
9115
+ emit2("product-click");
9116
+ handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
9117
+ };
9103
9118
  return (_ctx, _cache) => {
9104
9119
  return openBlock(), createElementBlock("div", _hoisted_1$Z, [
9105
9120
  _ctx.$slots.productCard ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.items, (item, index) => {
@@ -9110,7 +9125,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9110
9125
  labels: _ctx.labels,
9111
9126
  highlighted: index === highlightedIndex.value,
9112
9127
  inputValue: _ctx.inputValue,
9113
- onProductClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("product-click"))
9128
+ itemClicked: handleProductClick
9114
9129
  });
9115
9130
  }), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.items, (item, index) => {
9116
9131
  return openBlock(), createBlock(_sfc_main$12, {
@@ -9120,7 +9135,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9120
9135
  labels: _ctx.labels,
9121
9136
  highlighted: index === highlightedIndex.value,
9122
9137
  inputValue: _ctx.inputValue,
9123
- onProductClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("product-click"))
9138
+ onProductClick: handleProductClick
9124
9139
  }, null, 8, ["item", "panelOptions", "labels", "highlighted", "inputValue"]);
9125
9140
  }), 128))
9126
9141
  ]);
@@ -9203,6 +9218,10 @@ const _hoisted_1$Y = {
9203
9218
  };
9204
9219
  const _hoisted_2$H = ["data-cy"];
9205
9220
  const _hoisted_3$w = {
9221
+ key: 0,
9222
+ class: "lupa-panel-title"
9223
+ };
9224
+ const _hoisted_4$n = {
9206
9225
  key: 1,
9207
9226
  id: "lupa-search-box-panel"
9208
9227
  };
@@ -9240,16 +9259,14 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9240
9259
  const sdkOptions = computed(() => props.options.options);
9241
9260
  const searchBoxStore = useSearchBoxStore();
9242
9261
  const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9243
- const displayResults = computed(
9244
- () => {
9245
- var _a, _b;
9246
- return ((_a = props.inputValue) == null ? void 0 : _a.length) > 0 && ((_b = props.inputValue) == null ? void 0 : _b.length) >= props.options.minInputLength;
9247
- }
9248
- );
9262
+ const displayResults = computed(() => {
9263
+ var _a;
9264
+ return ((_a = props.inputValue) == null ? void 0 : _a.length) >= props.options.minInputLength;
9265
+ });
9249
9266
  const displayHistory = computed(
9250
9267
  () => {
9251
9268
  var _a;
9252
- return Boolean(props.options.history) && ((_a = props.inputValue) == null ? void 0 : _a.length) < 1;
9269
+ return Boolean(props.options.history) && ((_a = props.inputValue) == null ? void 0 : _a.length) < 1 && props.options.minInputLength > 0;
9253
9270
  }
9254
9271
  );
9255
9272
  const displayPanels = computed(
@@ -9326,6 +9343,10 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9326
9343
  const expandOnSinglePanel = computed(() => {
9327
9344
  return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9328
9345
  });
9346
+ const showTopResultsPanelTitle = (queryKey) => {
9347
+ const panel = panelItemCounts.value.find((v) => v.queryKey === queryKey);
9348
+ return (panel == null ? void 0 : panel.count) > 0 && (panel == null ? void 0 : panel.input.length) < 1;
9349
+ };
9329
9350
  return (_ctx, _cache) => {
9330
9351
  var _a;
9331
9352
  return openBlock(), createElementBlock("div", {
@@ -9339,6 +9360,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9339
9360
  "data-cy": "lupa-main-panel"
9340
9361
  }, [
9341
9362
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9363
+ var _a2, _b;
9342
9364
  return openBlock(), createElementBlock("div", {
9343
9365
  key: index,
9344
9366
  class: normalizeClass([
@@ -9347,8 +9369,9 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9347
9369
  ]),
9348
9370
  "data-cy": "lupa-panel-" + panel.type + "-index"
9349
9371
  }, [
9372
+ ((_a2 = panel.labels) == null ? void 0 : _a2.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_3$w, toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : createCommentVNode("", true),
9350
9373
  panel.queryKey ? (openBlock(), createBlock(resolveDynamicComponent(getComponent(panel.type)), {
9351
- key: 0,
9374
+ key: 1,
9352
9375
  panel,
9353
9376
  options: sdkOptions.value,
9354
9377
  debounce: _ctx.options.debounce,
@@ -9379,7 +9402,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9379
9402
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9380
9403
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9381
9404
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9382
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$w, [
9405
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9383
9406
  createVNode(_sfc_main$1h, {
9384
9407
  options: _ctx.options.history,
9385
9408
  history: history.value,
@@ -12456,6 +12479,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
12456
12479
  if (!value) {
12457
12480
  return;
12458
12481
  }
12482
+ paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
12459
12483
  (_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
12460
12484
  paramStore.appendParams({
12461
12485
  params: [{ name: QUERY_PARAMS$1.SORT, value }],
@@ -14162,7 +14186,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14162
14186
  return (_a = props.initialFilters) != null ? _a : {};
14163
14187
  });
14164
14188
  const { currentQueryText, hasResults, currentFilterCount } = storeToRefs(searchResultStore);
14165
- const { searchString } = storeToRefs(paramStore);
14189
+ const { searchString, sortParams } = storeToRefs(paramStore);
14166
14190
  const { defaultSearchResultPageSize } = storeToRefs(optionStore);
14167
14191
  const searchResultsFilters = ref(null);
14168
14192
  const mounted = ref(false);
@@ -14199,6 +14223,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14199
14223
  window.removeEventListener("popstate", handlePopState);
14200
14224
  });
14201
14225
  const trackItemListView = (title, items = []) => {
14226
+ var _a, _b;
14202
14227
  trackingStore.trackEvent({
14203
14228
  queryKey: props.options.queryKey,
14204
14229
  data: {
@@ -14206,7 +14231,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14206
14231
  type: "view_item_list",
14207
14232
  label: title,
14208
14233
  listLabel: title,
14209
- items
14234
+ items,
14235
+ additionalParams: {
14236
+ previousSortKey: (_a = sortParams.value) == null ? void 0 : _a.previousSortKey,
14237
+ newSortKey: (_b = sortParams.value) == null ? void 0 : _b.selectedSortKey
14238
+ }
14210
14239
  },
14211
14240
  options: { allowEmptySearchQuery: true }
14212
14241
  }