@getlupa/client 1.8.8 → 1.9.1

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.
@@ -6546,7 +6546,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
6546
6546
  itemId: (_b = data.itemId) != null ? _b : "",
6547
6547
  name: data.type,
6548
6548
  userId: getUserKey(),
6549
- sessionId: getSessionKey()
6549
+ sessionId: getSessionKey(),
6550
+ filters: data.filters
6550
6551
  };
6551
6552
  LupaSearchSdk.track(queryKey, eventData, options);
6552
6553
  };
@@ -6650,9 +6651,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
6650
6651
  return;
6651
6652
  }
6652
6653
  trackAnalyticsEvent(data);
6653
- if (!hasSearchQuery) {
6654
- return;
6655
- }
6656
6654
  trackLupaEvent(queryKey, data, options);
6657
6655
  };
6658
6656
  const DEFAULT_SEARCH_BOX_OPTIONS$1 = {
@@ -6929,6 +6927,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
6929
6927
  var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
6930
6928
  SearchBoxPanelType2["SUGGESTION"] = "suggestion";
6931
6929
  SearchBoxPanelType2["DOCUMENT"] = "document";
6930
+ SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
6932
6931
  return SearchBoxPanelType2;
6933
6932
  })(SearchBoxPanelType || {});
6934
6933
  var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
@@ -7845,12 +7844,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7845
7844
  const _hoisted_2$P = { class: "lupa-input-clear" };
7846
7845
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7847
7846
  const _hoisted_4$s = ["value"];
7848
- const _hoisted_5$g = ["aria-label", "placeholder"];
7847
+ const _hoisted_5$h = ["aria-label", "placeholder"];
7849
7848
  const _hoisted_6$9 = {
7850
7849
  key: 0,
7851
7850
  class: "lupa-close-label"
7852
7851
  };
7853
- const _sfc_main$1k = /* @__PURE__ */ defineComponent({
7852
+ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
7854
7853
  __name: "SearchBoxInput",
7855
7854
  props: {
7856
7855
  options: {},
@@ -7958,7 +7957,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7958
7957
  placeholder: labels.value.placeholder,
7959
7958
  onInput: handleInput,
7960
7959
  onFocus: handleFocus
7961
- }), null, 16, _hoisted_5$g), [
7960
+ }), null, 16, _hoisted_5$h), [
7962
7961
  [vModelText, inputValue.value]
7963
7962
  ])
7964
7963
  ]),
@@ -7973,7 +7972,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7973
7972
  };
7974
7973
  }
7975
7974
  });
7976
- const _sfc_main$1j = /* @__PURE__ */ defineComponent({
7975
+ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
7977
7976
  __name: "SearchBoxMoreResults",
7978
7977
  props: {
7979
7978
  labels: {},
@@ -8007,7 +8006,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8007
8006
  });
8008
8007
  const _hoisted_1$1b = { class: "lupa-search-box-history-item" };
8009
8008
  const _hoisted_2$O = { class: "lupa-search-box-history-item-content" };
8010
- const _sfc_main$1i = /* @__PURE__ */ defineComponent({
8009
+ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
8011
8010
  __name: "SearchBoxHistoryItem",
8012
8011
  props: {
8013
8012
  item: {},
@@ -8042,7 +8041,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8042
8041
  key: 0,
8043
8042
  class: "lupa-search-box-history-panel"
8044
8043
  };
8045
- const _sfc_main$1h = /* @__PURE__ */ defineComponent({
8044
+ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
8046
8045
  __name: "SearchBoxHistoryPanel",
8047
8046
  props: {
8048
8047
  options: {}
@@ -8085,7 +8084,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8085
8084
  return (_ctx, _cache) => {
8086
8085
  return hasHistory.value ? (openBlock(), createElementBlock("div", _hoisted_1$1a, [
8087
8086
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(history), (item, index) => {
8088
- return openBlock(), createBlock(_sfc_main$1i, {
8087
+ return openBlock(), createBlock(_sfc_main$1j, {
8089
8088
  key: item,
8090
8089
  item,
8091
8090
  highlighted: index === highlightIndex.value,
@@ -8102,7 +8101,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8102
8101
  }
8103
8102
  });
8104
8103
  const _hoisted_1$19 = { class: "lupa-search-box-no-results" };
8105
- const _sfc_main$1g = /* @__PURE__ */ defineComponent({
8104
+ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
8106
8105
  __name: "SearchBoxNoResults",
8107
8106
  props: {
8108
8107
  labels: {}
@@ -8128,11 +8127,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8128
8127
  class: "lupa-suggestion-facet-label",
8129
8128
  "data-cy": "lupa-suggestion-facet-label"
8130
8129
  };
8131
- const _hoisted_5$f = {
8130
+ const _hoisted_5$g = {
8132
8131
  class: "lupa-suggestion-facet-value",
8133
8132
  "data-cy": "lupa-suggestion-facet-value"
8134
8133
  };
8135
- const _sfc_main$1f = /* @__PURE__ */ defineComponent({
8134
+ const _sfc_main$1g = /* @__PURE__ */ defineComponent({
8136
8135
  __name: "SearchBoxSuggestion",
8137
8136
  props: {
8138
8137
  suggestion: {},
@@ -8171,7 +8170,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8171
8170
  }, null, 8, _hoisted_1$18)) : (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(_ctx.suggestion.display), 1)),
8172
8171
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
8173
8172
  createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
8174
- createBaseVNode("span", _hoisted_5$f, toDisplayString(_ctx.suggestion.facet.title), 1)
8173
+ createBaseVNode("span", _hoisted_5$g, toDisplayString(_ctx.suggestion.facet.title), 1)
8175
8174
  ])) : createCommentVNode("", true)
8176
8175
  ]);
8177
8176
  };
@@ -8181,7 +8180,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8181
8180
  id: "lupa-search-box-suggestions",
8182
8181
  "data-cy": "lupa-search-box-suggestions"
8183
8182
  };
8184
- const _sfc_main$1e = /* @__PURE__ */ defineComponent({
8183
+ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
8185
8184
  __name: "SearchBoxSuggestions",
8186
8185
  props: {
8187
8186
  items: {},
@@ -8243,7 +8242,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8243
8242
  return (_ctx, _cache) => {
8244
8243
  return openBlock(), createElementBlock("div", _hoisted_1$17, [
8245
8244
  (openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
8246
- return openBlock(), createBlock(_sfc_main$1f, {
8245
+ return openBlock(), createBlock(_sfc_main$1g, {
8247
8246
  key: getSuggestionKey(item),
8248
8247
  class: normalizeClass(["lupa-suggestion", index === highlightedIndex.value ? "lupa-suggestion-highlighted" : ""]),
8249
8248
  suggestion: item,
@@ -8271,7 +8270,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8271
8270
  }, timeout);
8272
8271
  };
8273
8272
  };
8274
- const _sfc_main$1d = /* @__PURE__ */ defineComponent({
8273
+ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
8275
8274
  __name: "SearchBoxSuggestionsWrapper",
8276
8275
  props: {
8277
8276
  panel: {},
@@ -8312,7 +8311,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8312
8311
  };
8313
8312
  const getSuggestionsDebounced = debounce$1(getSuggestions, props.debounce);
8314
8313
  return (_ctx, _cache) => {
8315
- return openBlock(), createBlock(_sfc_main$1e, {
8314
+ return openBlock(), createBlock(_sfc_main$1f, {
8316
8315
  items: searchResult.value,
8317
8316
  highlight: _ctx.panel.highlight,
8318
8317
  queryKey: _ctx.panel.queryKey,
@@ -8398,7 +8397,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8398
8397
  return (_c = (_b = (_a = parts == null ? void 0 : parts.map((part) => part.replace(/(^\/+|\/+$)/g, ""))) == null ? void 0 : _a.filter((part) => part !== "")) == null ? void 0 : _b.join("/")) != null ? _c : "";
8399
8398
  };
8400
8399
  const _hoisted_1$16 = ["src"];
8401
- const _sfc_main$1c = /* @__PURE__ */ defineComponent({
8400
+ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
8402
8401
  __name: "ProductImage",
8403
8402
  props: {
8404
8403
  item: {},
@@ -8456,7 +8455,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8456
8455
  };
8457
8456
  }
8458
8457
  });
8459
- const _sfc_main$1b = /* @__PURE__ */ defineComponent({
8458
+ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
8460
8459
  __name: "SearchBoxProductImage",
8461
8460
  props: {
8462
8461
  item: {},
@@ -8464,7 +8463,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8464
8463
  },
8465
8464
  setup(__props) {
8466
8465
  return (_ctx, _cache) => {
8467
- return openBlock(), createBlock(_sfc_main$1c, {
8466
+ return openBlock(), createBlock(_sfc_main$1d, {
8468
8467
  item: _ctx.item,
8469
8468
  options: _ctx.options,
8470
8469
  "wrapper-class": "lupa-search-box-image-wrapper",
@@ -8478,7 +8477,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8478
8477
  key: 1,
8479
8478
  class: "lupa-search-box-product-title"
8480
8479
  };
8481
- const _sfc_main$1a = /* @__PURE__ */ defineComponent({
8480
+ const _sfc_main$1b = /* @__PURE__ */ defineComponent({
8482
8481
  __name: "SearchBoxProductTitle",
8483
8482
  props: {
8484
8483
  item: {},
@@ -8509,7 +8508,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8509
8508
  key: 1,
8510
8509
  class: "lupa-search-box-product-description"
8511
8510
  };
8512
- const _sfc_main$19 = /* @__PURE__ */ defineComponent({
8511
+ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
8513
8512
  __name: "SearchBoxProductDescription",
8514
8513
  props: {
8515
8514
  item: {},
@@ -8534,7 +8533,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8534
8533
  }
8535
8534
  });
8536
8535
  const _hoisted_1$13 = { class: "lupa-search-box-product-price" };
8537
- const _sfc_main$18 = /* @__PURE__ */ defineComponent({
8536
+ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
8538
8537
  __name: "SearchBoxProductPrice",
8539
8538
  props: {
8540
8539
  item: {},
@@ -8559,7 +8558,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8559
8558
  }
8560
8559
  });
8561
8560
  const _hoisted_1$12 = { class: "lupa-search-box-product-regular-price" };
8562
- const _sfc_main$17 = /* @__PURE__ */ defineComponent({
8561
+ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
8563
8562
  __name: "SearchBoxProductRegularPrice",
8564
8563
  props: {
8565
8564
  item: {},
@@ -8585,8 +8584,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8585
8584
  const _hoisted_2$K = { key: 0 };
8586
8585
  const _hoisted_3$y = { key: 1 };
8587
8586
  const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
8588
- const _hoisted_5$e = { class: "lupa-search-box-custom-text" };
8589
- const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8587
+ const _hoisted_5$f = { class: "lupa-search-box-custom-text" };
8588
+ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
8590
8589
  __name: "SearchBoxProductCustom",
8591
8590
  props: {
8592
8591
  item: {},
@@ -8618,14 +8617,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8618
8617
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8619
8618
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$K, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8620
8619
  createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
8621
- createBaseVNode("div", _hoisted_5$e, toDisplayString(text.value), 1)
8620
+ createBaseVNode("div", _hoisted_5$f, toDisplayString(text.value), 1)
8622
8621
  ]))
8623
8622
  ], 16));
8624
8623
  };
8625
8624
  }
8626
8625
  });
8627
8626
  const _hoisted_1$10 = ["innerHTML"];
8628
- const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8627
+ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8629
8628
  __name: "SearchBoxProductCustomHtml",
8630
8629
  props: {
8631
8630
  item: {},
@@ -8842,7 +8841,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8842
8841
  const _hoisted_1$$ = { class: "lupa-search-box-add-to-cart-wrapper" };
8843
8842
  const _hoisted_2$J = { class: "lupa-search-box-product-addtocart" };
8844
8843
  const _hoisted_3$x = ["onClick", "disabled"];
8845
- const _sfc_main$14 = /* @__PURE__ */ defineComponent({
8844
+ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8846
8845
  __name: "SearchBoxProductAddToCart",
8847
8846
  props: {
8848
8847
  item: {},
@@ -8885,17 +8884,17 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8885
8884
  });
8886
8885
  const __default__$4 = {
8887
8886
  components: {
8888
- SearchBoxProductImage: _sfc_main$1b,
8889
- SearchBoxProductTitle: _sfc_main$1a,
8890
- SearchBoxProductDescription: _sfc_main$19,
8891
- SearchBoxProductPrice: _sfc_main$18,
8892
- SearchBoxProductRegularPrice: _sfc_main$17,
8893
- SearchBoxProductCustom: _sfc_main$16,
8894
- SearchBoxProductCustomHtml: _sfc_main$15,
8895
- SearchBoxProductAddToCart: _sfc_main$14
8887
+ SearchBoxProductImage: _sfc_main$1c,
8888
+ SearchBoxProductTitle: _sfc_main$1b,
8889
+ SearchBoxProductDescription: _sfc_main$1a,
8890
+ SearchBoxProductPrice: _sfc_main$19,
8891
+ SearchBoxProductRegularPrice: _sfc_main$18,
8892
+ SearchBoxProductCustom: _sfc_main$17,
8893
+ SearchBoxProductCustomHtml: _sfc_main$16,
8894
+ SearchBoxProductAddToCart: _sfc_main$15
8896
8895
  }
8897
8896
  };
8898
- const _sfc_main$13 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValues2({}, __default__$4), {
8897
+ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValues2({}, __default__$4), {
8899
8898
  __name: "SearchBoxProductElement",
8900
8899
  props: {
8901
8900
  item: {},
@@ -8961,7 +8960,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8961
8960
  key: 0,
8962
8961
  class: "lupa-search-box-product-add-to-cart-section"
8963
8962
  };
8964
- const _sfc_main$12 = /* @__PURE__ */ defineComponent({
8963
+ const _sfc_main$13 = /* @__PURE__ */ defineComponent({
8965
8964
  __name: "SearchBoxProduct",
8966
8965
  props: {
8967
8966
  item: {},
@@ -9019,7 +9018,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9019
9018
  }), [
9020
9019
  createBaseVNode("div", _hoisted_2$I, [
9021
9020
  (openBlock(true), createElementBlock(Fragment, null, renderList(imageElements.value, (element) => {
9022
- return openBlock(), createBlock(_sfc_main$13, {
9021
+ return openBlock(), createBlock(_sfc_main$14, {
9023
9022
  class: "lupa-search-box-product-element",
9024
9023
  item: _ctx.item,
9025
9024
  element,
@@ -9031,7 +9030,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9031
9030
  ]),
9032
9031
  createBaseVNode("div", _hoisted_3$w, [
9033
9032
  (openBlock(true), createElementBlock(Fragment, null, renderList(detailElements.value, (element) => {
9034
- return openBlock(), createBlock(_sfc_main$13, {
9033
+ return openBlock(), createBlock(_sfc_main$14, {
9035
9034
  class: "lupa-search-box-product-element",
9036
9035
  item: _ctx.item,
9037
9036
  element,
@@ -9042,7 +9041,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9042
9041
  }), 128))
9043
9042
  ]),
9044
9043
  addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$p, [
9045
- createVNode(_sfc_main$13, {
9044
+ createVNode(_sfc_main$14, {
9046
9045
  class: "lupa-search-box-product-element",
9047
9046
  item: _ctx.item,
9048
9047
  element: addToCartElement.value,
@@ -9066,6 +9065,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9066
9065
  };
9067
9066
  const useTrackingStore = defineStore("tracking", () => {
9068
9067
  const optionsStore = useOptionsStore();
9068
+ const searchResultStore = useSearchResultStore();
9069
9069
  const trackSearch = ({
9070
9070
  queryKey,
9071
9071
  query,
@@ -9103,7 +9103,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9103
9103
  track(
9104
9104
  queryKey,
9105
9105
  __spreadProps2(__spreadValues2({}, data), {
9106
- analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
9106
+ analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0,
9107
+ filters: searchResultStore.hasAnyFilter ? searchResultStore.filters : void 0
9107
9108
  }),
9108
9109
  options
9109
9110
  );
@@ -9111,7 +9112,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9111
9112
  return { trackSearch, trackResults, trackEvent };
9112
9113
  });
9113
9114
  const _hoisted_1$Z = { id: "lupa-search-box-products" };
9114
- const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9115
+ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
9115
9116
  __name: "SearchBoxProducts",
9116
9117
  props: {
9117
9118
  items: {},
@@ -9184,7 +9185,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9184
9185
  itemClicked: handleProductClick
9185
9186
  });
9186
9187
  }), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.items, (item, index) => {
9187
- return openBlock(), createBlock(_sfc_main$12, {
9188
+ return openBlock(), createBlock(_sfc_main$13, {
9188
9189
  key: index,
9189
9190
  item,
9190
9191
  panelOptions: _ctx.panelOptions,
@@ -9198,7 +9199,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9198
9199
  };
9199
9200
  }
9200
9201
  });
9201
- const _sfc_main$10 = /* @__PURE__ */ defineComponent({
9202
+ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
9202
9203
  __name: "SearchBoxProductsWrapper",
9203
9204
  props: {
9204
9205
  panel: {},
@@ -9250,7 +9251,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9250
9251
  const getItemsDebounced = debounce$1(getItems, props.debounce);
9251
9252
  return (_ctx, _cache) => {
9252
9253
  var _a, _b;
9253
- return openBlock(), createBlock(_sfc_main$11, {
9254
+ return openBlock(), createBlock(_sfc_main$12, {
9254
9255
  items: (_b = (_a = searchResult.value) == null ? void 0 : _a.items) != null ? _b : [],
9255
9256
  panelOptions: _ctx.panel,
9256
9257
  labels: _ctx.labels,
@@ -9268,6 +9269,96 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9268
9269
  };
9269
9270
  }
9270
9271
  });
9272
+ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
9273
+ __name: "SearchBoxRelatedSourceWrapper",
9274
+ props: {
9275
+ panel: {},
9276
+ inputValue: {},
9277
+ options: {},
9278
+ labels: {},
9279
+ debounce: {}
9280
+ },
9281
+ emits: ["fetched"],
9282
+ setup(__props, { emit: emit2 }) {
9283
+ const props = __props;
9284
+ const searchBoxStore = useSearchBoxStore();
9285
+ const mounted = ref(false);
9286
+ const { docResults } = storeToRefs(searchBoxStore);
9287
+ const searchResult = ref(null);
9288
+ const options = computed(() => props.options);
9289
+ const relatedSourceIds = computed(() => {
9290
+ var _a, _b, _c;
9291
+ const queryKey = (_a = props.panel.sourceIds) == null ? void 0 : _a.queryKey;
9292
+ if (!queryKey) {
9293
+ return [];
9294
+ }
9295
+ const currentDocumentItems = (_c = (_b = docResults == null ? void 0 : docResults.value[queryKey]) == null ? void 0 : _b.items) != null ? _c : [];
9296
+ const allFieldValues = currentDocumentItems.map((item) => item[props.panel.sourceIds.field]).flat();
9297
+ const uniqueFieldValues = Array.from(new Set(allFieldValues));
9298
+ return uniqueFieldValues;
9299
+ });
9300
+ const relatedSourceIdsString = computed(() => relatedSourceIds.value.join(","));
9301
+ onMounted(() => {
9302
+ getItemsDebounced();
9303
+ mounted.value = true;
9304
+ });
9305
+ watch(relatedSourceIdsString, () => {
9306
+ if (mounted) {
9307
+ getItemsDebounced();
9308
+ }
9309
+ });
9310
+ const fetchRelatedItems = () => __async(this, null, function* () {
9311
+ var _a, _b;
9312
+ if (!((_a = props.panel.target) == null ? void 0 : _a.queryKey) || !relatedSourceIds.value.length) {
9313
+ return { items: [], success: true, searchText: "", total: 0 };
9314
+ }
9315
+ try {
9316
+ const result = yield LupaSearchSdk.queryByIds(
9317
+ (_b = props.panel.target) == null ? void 0 : _b.queryKey,
9318
+ relatedSourceIds.value,
9319
+ options.value
9320
+ );
9321
+ if (!result.success) {
9322
+ return { items: [], success: true, searchText: "", total: 0 };
9323
+ }
9324
+ return result;
9325
+ } catch (err) {
9326
+ console.error(err);
9327
+ if (options == null ? void 0 : options.value.onError) {
9328
+ options.value.onError(err);
9329
+ }
9330
+ return { items: [], success: true, searchText: "", total: 0 };
9331
+ }
9332
+ });
9333
+ const getItems = () => __async(this, null, function* () {
9334
+ searchResult.value = yield fetchRelatedItems();
9335
+ });
9336
+ const getItemsDebounced = debounce$1(getItems, props.debounce);
9337
+ const documentPanelOptions = computed(() => {
9338
+ return __spreadProps2(__spreadValues2({}, props.panel), {
9339
+ type: SearchBoxPanelType.DOCUMENT
9340
+ });
9341
+ });
9342
+ return (_ctx, _cache) => {
9343
+ var _a, _b;
9344
+ return openBlock(), createBlock(_sfc_main$12, {
9345
+ items: (_b = (_a = searchResult.value) == null ? void 0 : _a.items) != null ? _b : [],
9346
+ panelOptions: documentPanelOptions.value,
9347
+ labels: _ctx.labels,
9348
+ inputValue: _ctx.inputValue,
9349
+ onProductClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("product-click"))
9350
+ }, createSlots({ _: 2 }, [
9351
+ _ctx.$slots.productCard ? {
9352
+ name: "productCard",
9353
+ fn: withCtx((props2) => [
9354
+ renderSlot(_ctx.$slots, "productCard", normalizeProps(guardReactiveProps(props2)))
9355
+ ]),
9356
+ key: "0"
9357
+ } : void 0
9358
+ ]), 1032, ["items", "panelOptions", "labels", "inputValue"]);
9359
+ };
9360
+ }
9361
+ });
9271
9362
  const _hoisted_1$Y = {
9272
9363
  key: 0,
9273
9364
  id: "lupa-search-box-panel"
@@ -9275,16 +9366,21 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9275
9366
  const _hoisted_2$H = ["data-cy"];
9276
9367
  const _hoisted_3$v = {
9277
9368
  key: 0,
9278
- class: "lupa-panel-title"
9369
+ class: "lupa-panel-title lupa-panel-title-top-results"
9279
9370
  };
9280
9371
  const _hoisted_4$o = {
9372
+ key: 1,
9373
+ class: "lupa-panel-title"
9374
+ };
9375
+ const _hoisted_5$e = {
9281
9376
  key: 1,
9282
9377
  id: "lupa-search-box-panel"
9283
9378
  };
9284
9379
  const __default__$3 = {
9285
9380
  components: {
9286
- SearchBoxSuggestionsWrapper: _sfc_main$1d,
9287
- SearchBoxProductsWrapper: _sfc_main$10
9381
+ SearchBoxSuggestionsWrapper: _sfc_main$1e,
9382
+ SearchBoxProductsWrapper: _sfc_main$11,
9383
+ SearchBoxRelatedSourceWrapper: _sfc_main$10
9288
9384
  }
9289
9385
  };
9290
9386
  const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValues2({}, __default__$3), {
@@ -9378,6 +9474,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9378
9474
  switch (type) {
9379
9475
  case "suggestion":
9380
9476
  return "SearchBoxSuggestionsWrapper";
9477
+ case "related-source":
9478
+ return "SearchBoxRelatedSourceWrapper";
9381
9479
  default:
9382
9480
  return "SearchBoxProductsWrapper";
9383
9481
  }
@@ -9403,6 +9501,21 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9403
9501
  const panel = panelItemCounts.value.find((v) => v.queryKey === queryKey);
9404
9502
  return (panel == null ? void 0 : panel.count) > 0 && (panel == null ? void 0 : panel.input.length) < 1;
9405
9503
  };
9504
+ const showPanelTitle = (queryKey) => {
9505
+ const panel = panelItemCounts.value.find((v) => v.queryKey === queryKey);
9506
+ return (panel == null ? void 0 : panel.count) > 0;
9507
+ };
9508
+ const canShowPanel = (panel) => {
9509
+ var _a, _b, _c;
9510
+ if (!((_a = panel.visibility) == null ? void 0 : _a.showWhenKeyHasNoResults)) {
9511
+ return true;
9512
+ }
9513
+ const resultCountFromRelatedPanel = (_c = (_b = panelItemCounts.value.find((v) => {
9514
+ var _a2;
9515
+ return v.queryKey === ((_a2 = panel.visibility) == null ? void 0 : _a2.showWhenKeyHasNoResults);
9516
+ })) == null ? void 0 : _b.count) != null ? _c : 0;
9517
+ return resultCountFromRelatedPanel < 1;
9518
+ };
9406
9519
  return (_ctx, _cache) => {
9407
9520
  var _a;
9408
9521
  return openBlock(), createElementBlock("div", {
@@ -9416,7 +9529,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9416
9529
  "data-cy": "lupa-main-panel"
9417
9530
  }, [
9418
9531
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9419
- var _a2, _b;
9532
+ var _a2, _b, _c, _d;
9420
9533
  return openBlock(), createElementBlock("div", {
9421
9534
  key: index,
9422
9535
  class: normalizeClass([
@@ -9426,8 +9539,9 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9426
9539
  "data-cy": "lupa-panel-" + panel.type + "-index"
9427
9540
  }, [
9428
9541
  ((_a2 = panel.labels) == null ? void 0 : _a2.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_3$v, toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : createCommentVNode("", true),
9429
- panel.queryKey ? (openBlock(), createBlock(resolveDynamicComponent(getComponent(panel.type)), {
9430
- key: 1,
9542
+ ((_c = panel.labels) == null ? void 0 : _c.title) && showPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_4$o, toDisplayString((_d = panel.labels) == null ? void 0 : _d.title), 1)) : createCommentVNode("", true),
9543
+ panel.queryKey && canShowPanel(panel) ? (openBlock(), createBlock(resolveDynamicComponent(getComponent(panel.type)), {
9544
+ key: 2,
9431
9545
  panel,
9432
9546
  options: sdkOptions.value,
9433
9547
  debounce: _ctx.options.debounce,
@@ -9448,18 +9562,18 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9448
9562
  ], 10, _hoisted_2$H);
9449
9563
  }), 128))
9450
9564
  ], 4),
9451
- !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1g, {
9565
+ !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1h, {
9452
9566
  key: 0,
9453
9567
  labels: labels.value
9454
9568
  }, null, 8, ["labels"])) : createCommentVNode("", true),
9455
- unref(hasAnyResults) || !_ctx.options.hideMoreResultsButtonOnNoResults ? (openBlock(), createBlock(_sfc_main$1j, {
9569
+ unref(hasAnyResults) || !_ctx.options.hideMoreResultsButtonOnNoResults ? (openBlock(), createBlock(_sfc_main$1k, {
9456
9570
  key: 1,
9457
9571
  labels: labels.value,
9458
9572
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9459
9573
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9460
9574
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9461
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
9462
- createVNode(_sfc_main$1h, {
9575
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$e, [
9576
+ createVNode(_sfc_main$1i, {
9463
9577
  options: _ctx.options.history,
9464
9578
  history: history.value,
9465
9579
  onGoToResults: handleGoToResults,
@@ -9729,7 +9843,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9729
9843
  var _a2;
9730
9844
  return openBlock(), createElementBlock("div", _hoisted_1$X, [
9731
9845
  createBaseVNode("div", _hoisted_2$G, [
9732
- createVNode(_sfc_main$1k, {
9846
+ createVNode(_sfc_main$1l, {
9733
9847
  options: inputOptions.value,
9734
9848
  suggestedValue: suggestedValue.value,
9735
9849
  "can-close": (_a2 = _ctx.isSearchContainer) != null ? _a2 : false,
@@ -13024,7 +13138,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
13024
13138
  },
13025
13139
  setup(__props) {
13026
13140
  return (_ctx, _cache) => {
13027
- return openBlock(), createBlock(_sfc_main$1c, {
13141
+ return openBlock(), createBlock(_sfc_main$1d, {
13028
13142
  item: _ctx.item,
13029
13143
  options: _ctx.options,
13030
13144
  "wrapper-class": "lupa-search-results-image-wrapper",
@@ -21536,7 +21650,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21536
21650
  class: "lupa-chat-spinner-main"
21537
21651
  };
21538
21652
  const _hoisted_5 = { class: "lupasearch-chat-input" };
21539
- const _sfc_main$1l = /* @__PURE__ */ defineComponent({
21653
+ const _sfc_main$1m = /* @__PURE__ */ defineComponent({
21540
21654
  __name: "ChatContainer",
21541
21655
  props: {
21542
21656
  options: {}
@@ -28014,7 +28128,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28014
28128
  }
28015
28129
  return;
28016
28130
  }
28017
- const instance = createVue(options.displayOptions.containerSelector, _sfc_main$1l, {
28131
+ const instance = createVue(options.displayOptions.containerSelector, _sfc_main$1m, {
28018
28132
  options
28019
28133
  });
28020
28134
  if (!instance) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/client",
3
- "version": "1.8.8",
3
+ "version": "1.9.1",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/src/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@getlupa/client-sdk": "^1.3.4",
23
- "@getlupa/vue": "0.8.6",
23
+ "@getlupa/vue": "0.9.1",
24
24
  "@rushstack/eslint-patch": "^1.3.2",
25
25
  "@tsconfig/node18": "^2.0.1",
26
26
  "@types/jsdom": "^21.1.1",