@getlupa/client 1.4.0 → 1.4.2

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.
@@ -7534,6 +7534,10 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7534
7534
  };
7535
7535
  })
7536
7536
  );
7537
+ const hasAnyResults = computed(() => {
7538
+ var _a;
7539
+ return (_a = panelItemCounts.value) == null ? void 0 : _a.some((p2) => p2.count > 0);
7540
+ });
7537
7541
  const totalCount = computed(
7538
7542
  () => {
7539
7543
  var _a, _b;
@@ -7586,6 +7590,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7586
7590
  [queryKey]: flattenSuggestions(result.items, (_a = publicQuery.searchText) != null ? _a : "")
7587
7591
  });
7588
7592
  inputValue.value = publicQuery.searchText;
7593
+ emitSearchResultsCallback();
7589
7594
  return {
7590
7595
  suggestions: result.items
7591
7596
  };
@@ -7597,6 +7602,19 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7597
7602
  return { suggestions: void 0 };
7598
7603
  }
7599
7604
  });
7605
+ const emitSearchResultsCallback = () => {
7606
+ var _a;
7607
+ if ((_a = options.value.callbacks) == null ? void 0 : _a.onSearchBoxResults) {
7608
+ options.value.callbacks.onSearchBoxResults({
7609
+ hasAnyResults: hasAnyResults.value,
7610
+ docResults: docResults.value,
7611
+ suggestionResults: suggestionResults.value,
7612
+ totalCount: totalCount.value,
7613
+ panelItemCounts: panelItemCounts.value,
7614
+ inputValue: inputValue.value
7615
+ });
7616
+ }
7617
+ };
7600
7618
  const queryDocuments = (_0) => __async(void 0, [_0], function* ({
7601
7619
  queryKey,
7602
7620
  publicQuery,
@@ -7610,6 +7628,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7610
7628
  }
7611
7629
  highlightChange({ action: "clear" });
7612
7630
  docResults.value = __spreadProps2(__spreadValues2({}, docResults.value), { [queryKey]: result });
7631
+ emitSearchResultsCallback();
7613
7632
  return { queryKey, result };
7614
7633
  } catch (err) {
7615
7634
  console.error(err);
@@ -7646,6 +7665,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7646
7665
  totalCount,
7647
7666
  highlightedItem,
7648
7667
  highlightedDocument,
7668
+ hasAnyResults,
7649
7669
  querySuggestions,
7650
7670
  queryDocuments,
7651
7671
  highlightChange,
@@ -7654,16 +7674,16 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7654
7674
  resetHighlightIndex
7655
7675
  };
7656
7676
  });
7657
- const _hoisted_1$1a = { id: "lupa-search-box-input-container" };
7677
+ const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
7658
7678
  const _hoisted_2$O = { class: "lupa-input-clear" };
7659
7679
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7660
- const _hoisted_4$r = ["value"];
7680
+ const _hoisted_4$q = ["value"];
7661
7681
  const _hoisted_5$f = ["placeholder"];
7662
7682
  const _hoisted_6$8 = {
7663
7683
  key: 0,
7664
7684
  class: "lupa-close-label"
7665
7685
  };
7666
- const _sfc_main$1i = /* @__PURE__ */ defineComponent({
7686
+ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
7667
7687
  __name: "SearchBoxInput",
7668
7688
  props: {
7669
7689
  options: {},
@@ -7740,7 +7760,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
7740
7760
  };
7741
7761
  __expose({ focus });
7742
7762
  return (_ctx, _cache) => {
7743
- return openBlock(), createElementBlock("div", _hoisted_1$1a, [
7763
+ return openBlock(), createElementBlock("div", _hoisted_1$1b, [
7744
7764
  createBaseVNode("div", _hoisted_2$O, [
7745
7765
  createBaseVNode("div", {
7746
7766
  class: normalizeClass(["lupa-input-clear-content", { "lupa-input-clear-filled": inputValue.value }]),
@@ -7752,7 +7772,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
7752
7772
  class: "lupa-hint",
7753
7773
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7754
7774
  disabled: ""
7755
- }, null, 8, _hoisted_4$r),
7775
+ }, null, 8, _hoisted_4$q),
7756
7776
  withDirectives(createBaseVNode("input", mergeProps({
7757
7777
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7758
7778
  }, inputAttributes.value, {
@@ -7780,7 +7800,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
7780
7800
  };
7781
7801
  }
7782
7802
  });
7783
- const _sfc_main$1h = /* @__PURE__ */ defineComponent({
7803
+ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
7784
7804
  __name: "SearchBoxMoreResults",
7785
7805
  props: {
7786
7806
  labels: {},
@@ -7812,9 +7832,9 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
7812
7832
  };
7813
7833
  }
7814
7834
  });
7815
- const _hoisted_1$19 = { class: "lupa-search-box-history-item" };
7835
+ const _hoisted_1$1a = { class: "lupa-search-box-history-item" };
7816
7836
  const _hoisted_2$N = { class: "lupa-search-box-history-item-content" };
7817
- const _sfc_main$1g = /* @__PURE__ */ defineComponent({
7837
+ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
7818
7838
  __name: "SearchBoxHistoryItem",
7819
7839
  props: {
7820
7840
  item: {},
@@ -7830,7 +7850,7 @@ const _sfc_main$1g = /* @__PURE__ */ defineComponent({
7830
7850
  emit2("click", { query: props.item });
7831
7851
  };
7832
7852
  return (_ctx, _cache) => {
7833
- return openBlock(), createElementBlock("div", _hoisted_1$19, [
7853
+ return openBlock(), createElementBlock("div", _hoisted_1$1a, [
7834
7854
  createBaseVNode("div", _hoisted_2$N, [
7835
7855
  createBaseVNode("div", {
7836
7856
  class: normalizeClass(["lupa-search-box-history-item-text", { "lupa-search-box-history-item-highlighted": _ctx.highlighted }]),
@@ -7845,11 +7865,11 @@ const _sfc_main$1g = /* @__PURE__ */ defineComponent({
7845
7865
  };
7846
7866
  }
7847
7867
  });
7848
- const _hoisted_1$18 = {
7868
+ const _hoisted_1$19 = {
7849
7869
  key: 0,
7850
7870
  class: "lupa-search-box-history-panel"
7851
7871
  };
7852
- const _sfc_main$1f = /* @__PURE__ */ defineComponent({
7872
+ const _sfc_main$1g = /* @__PURE__ */ defineComponent({
7853
7873
  __name: "SearchBoxHistoryPanel",
7854
7874
  props: {
7855
7875
  options: {}
@@ -7890,9 +7910,9 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
7890
7910
  }
7891
7911
  };
7892
7912
  return (_ctx, _cache) => {
7893
- return hasHistory.value ? (openBlock(), createElementBlock("div", _hoisted_1$18, [
7913
+ return hasHistory.value ? (openBlock(), createElementBlock("div", _hoisted_1$19, [
7894
7914
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(history), (item, index) => {
7895
- return openBlock(), createBlock(_sfc_main$1g, {
7915
+ return openBlock(), createBlock(_sfc_main$1h, {
7896
7916
  key: item,
7897
7917
  item,
7898
7918
  highlighted: index === highlightIndex.value,
@@ -7908,6 +7928,18 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
7908
7928
  };
7909
7929
  }
7910
7930
  });
7931
+ const _hoisted_1$18 = { class: "lupa-search-box-no-results" };
7932
+ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
7933
+ __name: "SearchBoxNoResults",
7934
+ props: {
7935
+ labels: {}
7936
+ },
7937
+ setup(__props) {
7938
+ return (_ctx, _cache) => {
7939
+ return openBlock(), createElementBlock("p", _hoisted_1$18, toDisplayString(_ctx.labels.noResults), 1);
7940
+ };
7941
+ }
7942
+ });
7911
7943
  const _hoisted_1$17 = ["innerHTML"];
7912
7944
  const _hoisted_2$M = {
7913
7945
  key: 1,
@@ -7919,7 +7951,7 @@ const _hoisted_3$z = {
7919
7951
  class: "lupa-suggestion-facet",
7920
7952
  "data-cy": "lupa-suggestion-facet"
7921
7953
  };
7922
- const _hoisted_4$q = {
7954
+ const _hoisted_4$p = {
7923
7955
  class: "lupa-suggestion-facet-label",
7924
7956
  "data-cy": "lupa-suggestion-facet-label"
7925
7957
  };
@@ -7965,7 +7997,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
7965
7997
  innerHTML: _ctx.suggestion.displayHighlight
7966
7998
  }, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
7967
7999
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
7968
- createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8000
+ createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
7969
8001
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
7970
8002
  ])) : createCommentVNode("", true)
7971
8003
  ]);
@@ -8367,7 +8399,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8367
8399
  const _hoisted_1$10 = ["innerHTML"];
8368
8400
  const _hoisted_2$J = { key: 0 };
8369
8401
  const _hoisted_3$y = { key: 1 };
8370
- const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8402
+ const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8371
8403
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8372
8404
  const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8373
8405
  __name: "SearchBoxProductCustom",
@@ -8400,7 +8432,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8400
8432
  class: [className.value, "lupa-search-box-product-custom"]
8401
8433
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8402
8434
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8403
- createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8435
+ createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8404
8436
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8405
8437
  ]))
8406
8438
  ], 16));
@@ -8796,7 +8828,7 @@ const useTrackingStore = defineStore("tracking", () => {
8796
8828
  const _hoisted_1$Z = ["href"];
8797
8829
  const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
8798
8830
  const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
8799
- const _hoisted_4$o = {
8831
+ const _hoisted_4$n = {
8800
8832
  key: 0,
8801
8833
  class: "lupa-search-box-product-add-to-cart-section"
8802
8834
  };
@@ -8917,7 +8949,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
8917
8949
  }, null, 8, ["item", "element", "labels", "link"]);
8918
8950
  }), 128))
8919
8951
  ]),
8920
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
8952
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8921
8953
  createVNode(_sfc_main$12, {
8922
8954
  class: "lupa-search-box-product-element",
8923
8955
  item: _ctx.item,
@@ -9052,12 +9084,8 @@ const _hoisted_1$X = {
9052
9084
  key: 0,
9053
9085
  id: "lupa-search-box-panel"
9054
9086
  };
9055
- const _hoisted_2$G = {
9056
- class: "lupa-main-panel",
9057
- "data-cy": "lupa-main-panel"
9058
- };
9059
- const _hoisted_3$v = ["data-cy"];
9060
- const _hoisted_4$n = {
9087
+ const _hoisted_2$G = ["data-cy"];
9088
+ const _hoisted_3$v = {
9061
9089
  key: 1,
9062
9090
  id: "lupa-search-box-panel"
9063
9091
  };
@@ -9094,7 +9122,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9094
9122
  const panels = computed(() => props.options.panels);
9095
9123
  const sdkOptions = computed(() => props.options.options);
9096
9124
  const searchBoxStore = useSearchBoxStore();
9097
- const { suggestionResults } = storeToRefs(searchBoxStore);
9125
+ const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9098
9126
  const displayResults = computed(
9099
9127
  () => {
9100
9128
  var _a, _b;
@@ -9175,6 +9203,12 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9175
9203
  `${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
9176
9204
  );
9177
9205
  };
9206
+ const numberOfVisiblePanels = computed(() => {
9207
+ return panelItemCounts.value.filter((v) => v.count > 0).length;
9208
+ });
9209
+ const expandOnSinglePanel = computed(() => {
9210
+ return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9211
+ });
9178
9212
  return (_ctx, _cache) => {
9179
9213
  var _a;
9180
9214
  return openBlock(), createElementBlock("div", {
@@ -9182,7 +9216,11 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9182
9216
  ref: panelContainer
9183
9217
  }, [
9184
9218
  displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
9185
- createBaseVNode("div", _hoisted_2$G, [
9219
+ createBaseVNode("div", {
9220
+ class: "lupa-main-panel",
9221
+ style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
9222
+ "data-cy": "lupa-main-panel"
9223
+ }, [
9186
9224
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9187
9225
  return openBlock(), createElementBlock("div", {
9188
9226
  key: index,
@@ -9211,16 +9249,21 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9211
9249
  key: "0"
9212
9250
  } : void 0
9213
9251
  ]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
9214
- ], 10, _hoisted_3$v);
9252
+ ], 10, _hoisted_2$G);
9215
9253
  }), 128))
9216
- ]),
9217
- createVNode(_sfc_main$1h, {
9254
+ ], 4),
9255
+ !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
9256
+ key: 0,
9257
+ labels: labels.value
9258
+ }, null, 8, ["labels"])) : createCommentVNode("", true),
9259
+ unref(hasAnyResults) || !_ctx.options.hideMoreResultsButtonOnNoResults ? (openBlock(), createBlock(_sfc_main$1i, {
9260
+ key: 1,
9218
9261
  labels: labels.value,
9219
9262
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9220
9263
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9221
- }, null, 8, ["labels", "showTotalCount"])
9222
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9223
- createVNode(_sfc_main$1f, {
9264
+ }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9265
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
9266
+ createVNode(_sfc_main$1g, {
9224
9267
  options: _ctx.options.history,
9225
9268
  history: history.value,
9226
9269
  onGoToResults: handleGoToResults,
@@ -9286,7 +9329,10 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
9286
9329
  "links",
9287
9330
  "options",
9288
9331
  "debounce",
9289
- "showTotalCount"
9332
+ "showTotalCount",
9333
+ "hideMoreResultsButtonOnNoResults",
9334
+ "showNoResultsPanel",
9335
+ "expandOnSinglePanel"
9290
9336
  ])
9291
9337
  );
9292
9338
  const searchTriggers = computed(() => {
@@ -9482,7 +9528,7 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
9482
9528
  var _a2;
9483
9529
  return openBlock(), createElementBlock("div", _hoisted_1$W, [
9484
9530
  createBaseVNode("div", _hoisted_2$F, [
9485
- createVNode(_sfc_main$1i, {
9531
+ createVNode(_sfc_main$1j, {
9486
9532
  options: inputOptions.value,
9487
9533
  suggestedValue: suggestedValue.value,
9488
9534
  "can-close": (_a2 = _ctx.isSearchContainer) != null ? _a2 : false,
@@ -13955,8 +14001,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13955
14001
  const isTitleResultTopPosition = computed(() => {
13956
14002
  return props.options.searchTitlePosition === "search-results-top";
13957
14003
  });
14004
+ const handlePopState = () => {
14005
+ var _a;
14006
+ const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
14007
+ paramStore.add(parseParams(searchParams));
14008
+ };
13958
14009
  onMounted(() => {
13959
14010
  var _a, _b;
14011
+ window.addEventListener("popstate", handlePopState);
13960
14012
  window.addEventListener("resize", handleResize);
13961
14013
  if (props.initialData) {
13962
14014
  searchResultStore.add(__spreadValues2({}, props.initialData));
@@ -13967,6 +14019,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13967
14019
  });
13968
14020
  onBeforeUnmount(() => {
13969
14021
  window.removeEventListener("resize", handleResize);
14022
+ window.removeEventListener("popstate", handlePopState);
13970
14023
  });
13971
14024
  const trackItemListView = (title, items = []) => {
13972
14025
  trackingStore.trackEvent({
@@ -21169,7 +21222,7 @@ const _hoisted_4 = {
21169
21222
  class: "lupa-chat-spinner-main"
21170
21223
  };
21171
21224
  const _hoisted_5 = { class: "lupasearch-chat-input" };
21172
- const _sfc_main$1j = /* @__PURE__ */ defineComponent({
21225
+ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
21173
21226
  __name: "ChatContainer",
21174
21227
  props: {
21175
21228
  options: {}
@@ -27284,7 +27337,7 @@ const chat = (options, mountOptions) => {
27284
27337
  }
27285
27338
  return;
27286
27339
  }
27287
- const instance = createVue(options.displayOptions.containerSelector, _sfc_main$1j, {
27340
+ const instance = createVue(options.displayOptions.containerSelector, _sfc_main$1k, {
27288
27341
  options
27289
27342
  });
27290
27343
  if (!instance) {