@getlupa/vue 0.17.1 → 0.17.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.
@@ -20007,6 +20007,9 @@ const _sfc_main$15 = /* @__PURE__ */ vue.defineComponent({
20007
20007
  }
20008
20008
  emit("product-click");
20009
20009
  handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
20010
+ if (props.panelOptions.programmaticNavigation) {
20011
+ window.location.assign(link);
20012
+ }
20010
20013
  };
20011
20014
  return (_ctx, _cache) => {
20012
20015
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$Z, [
@@ -20627,6 +20630,7 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20627
20630
  const suggestedValue = vue.ref(defaultSuggestedValue);
20628
20631
  const opened = vue.ref(props.isSearchContainer);
20629
20632
  const focused = vue.ref(false);
20633
+ const openedAt = vue.ref(null);
20630
20634
  const searchBoxInput = vue.ref(null);
20631
20635
  const { highlightedDocument } = storeToRefs(searchBoxStore);
20632
20636
  const searchValue = vue.computed(() => {
@@ -20686,6 +20690,9 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20686
20690
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
20687
20691
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
20688
20692
  const isOutsideElement = el && !el.contains(e2.target) && !hasLupaClass;
20693
+ if (openedAt.value && Date.now() - (openedAt == null ? void 0 : openedAt.value) < 500) {
20694
+ return;
20695
+ }
20689
20696
  if (isOutsideElement && props.options.keepOpen) {
20690
20697
  focused.value = false;
20691
20698
  }
@@ -20717,6 +20724,10 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20717
20724
  handleSearch();
20718
20725
  resetValues();
20719
20726
  break;
20727
+ case "Escape":
20728
+ opened.value = false;
20729
+ focused.value = false;
20730
+ break;
20720
20731
  }
20721
20732
  };
20722
20733
  const handleInput = (value) => {
@@ -20858,6 +20869,13 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20858
20869
  });
20859
20870
  };
20860
20871
  vue.watch(() => props.options.debounce, handleCurrentValueSearch);
20872
+ vue.watch(opened, () => {
20873
+ if (opened.value) {
20874
+ openedAt.value = Date.now();
20875
+ } else {
20876
+ openedAt.value = null;
20877
+ }
20878
+ });
20861
20879
  const resetValues = () => {
20862
20880
  inputValue.value = "";
20863
20881
  suggestedValue.value = defaultSuggestedValue;
@@ -20005,6 +20005,9 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
20005
20005
  }
20006
20006
  emit("product-click");
20007
20007
  handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
20008
+ if (props.panelOptions.programmaticNavigation) {
20009
+ window.location.assign(link);
20010
+ }
20008
20011
  };
20009
20012
  return (_ctx, _cache) => {
20010
20013
  return openBlock(), createElementBlock("div", _hoisted_1$Z, [
@@ -20625,6 +20628,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20625
20628
  const suggestedValue = ref(defaultSuggestedValue);
20626
20629
  const opened = ref(props.isSearchContainer);
20627
20630
  const focused = ref(false);
20631
+ const openedAt = ref(null);
20628
20632
  const searchBoxInput = ref(null);
20629
20633
  const { highlightedDocument } = storeToRefs(searchBoxStore);
20630
20634
  const searchValue = computed(() => {
@@ -20684,6 +20688,9 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20684
20688
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
20685
20689
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
20686
20690
  const isOutsideElement = el && !el.contains(e2.target) && !hasLupaClass;
20691
+ if (openedAt.value && Date.now() - (openedAt == null ? void 0 : openedAt.value) < 500) {
20692
+ return;
20693
+ }
20687
20694
  if (isOutsideElement && props.options.keepOpen) {
20688
20695
  focused.value = false;
20689
20696
  }
@@ -20715,6 +20722,10 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20715
20722
  handleSearch();
20716
20723
  resetValues();
20717
20724
  break;
20725
+ case "Escape":
20726
+ opened.value = false;
20727
+ focused.value = false;
20728
+ break;
20718
20729
  }
20719
20730
  };
20720
20731
  const handleInput = (value) => {
@@ -20856,6 +20867,13 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20856
20867
  });
20857
20868
  };
20858
20869
  watch(() => props.options.debounce, handleCurrentValueSearch);
20870
+ watch(opened, () => {
20871
+ if (opened.value) {
20872
+ openedAt.value = Date.now();
20873
+ } else {
20874
+ openedAt.value = null;
20875
+ }
20876
+ });
20859
20877
  const resetValues = () => {
20860
20878
  inputValue.value = "";
20861
20879
  suggestedValue.value = defaultSuggestedValue;
@@ -38,6 +38,7 @@ export type DocumentSearchBoxPanel = SearchBoxPanelBase & {
38
38
  badges?: SearchBoxBadgeOptions;
39
39
  showGoToResults?: boolean;
40
40
  isInStock?: DisplayCondition | ((doc: Document) => boolean);
41
+ programmaticNavigation?: boolean;
41
42
  customDocumentHtmlAttributes?: CustomDocumentHtmlAttributes;
42
43
  };
43
44
  export type RelatedSourcePanel = Omit<DocumentSearchBoxPanel, 'type'> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",