@getlupa/vue 0.17.2 → 0.17.4

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.
@@ -20667,7 +20667,7 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20667
20667
  });
20668
20668
  const goToResultsDebounced = debounce$1(paramsStore.goToResults, (_a = props.options.debounce) != null ? _a : 300);
20669
20669
  vue.onMounted(() => {
20670
- var _a2;
20670
+ var _a2, _b, _c;
20671
20671
  window.addEventListener("keydown", handleKeyDown);
20672
20672
  window.addEventListener("click", handleMouseClick);
20673
20673
  paramsStore.setSearchResultsLink(props.options.links.searchResults);
@@ -20678,6 +20678,9 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20678
20678
  if (props.isSearchContainer && searchBoxInput.value) {
20679
20679
  (_a2 = searchBoxInput.value) == null ? void 0 : _a2.focus();
20680
20680
  }
20681
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onMounted) {
20682
+ (_c = props.options.callbacks) == null ? void 0 : _c.onMounted();
20683
+ }
20681
20684
  });
20682
20685
  vue.onBeforeUnmount(() => {
20683
20686
  window.removeEventListener("keydown", handleKeyDown);
@@ -20685,7 +20688,7 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20685
20688
  unbindSearchTriggers(searchTriggers.value, handleCurrentValueSearch);
20686
20689
  });
20687
20690
  const handleMouseClick = (e2) => {
20688
- var _a2, _b;
20691
+ var _a2, _b, _c, _d;
20689
20692
  const el = document.getElementById("lupa-search-box");
20690
20693
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
20691
20694
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
@@ -20701,11 +20704,18 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20701
20704
  }
20702
20705
  opened.value = false;
20703
20706
  suggestedValue.value = defaultSuggestedValue;
20707
+ if ((_c = props.options.callbacks) == null ? void 0 : _c.onClosed) {
20708
+ (_d = props.options.callbacks) == null ? void 0 : _d.onClosed();
20709
+ }
20704
20710
  };
20705
20711
  const close = () => {
20712
+ var _a2, _b;
20706
20713
  opened.value = false;
20707
20714
  focused.value = false;
20708
20715
  suggestedValue.value = defaultSuggestedValue;
20716
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onClosed) {
20717
+ (_b = props.options.callbacks) == null ? void 0 : _b.onClosed();
20718
+ }
20709
20719
  };
20710
20720
  const handleKeyDown = (e2) => {
20711
20721
  var _a2, _b;
@@ -20731,12 +20741,15 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20731
20741
  }
20732
20742
  };
20733
20743
  const handleInput = (value) => {
20734
- var _a2;
20744
+ var _a2, _b;
20735
20745
  opened.value = true;
20736
20746
  focused.value = true;
20737
20747
  inputValue.value = (_a2 = value == null ? void 0 : value.replace(/\s+$/, "")) != null ? _a2 : "";
20738
20748
  suggestedValue.value = defaultSuggestedValue;
20739
20749
  searchBoxStore.resetHighlightIndex();
20750
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onSearchBoxInput) {
20751
+ props.options.callbacks.onSearchBoxInput(value);
20752
+ }
20740
20753
  trackSearchQuery(value);
20741
20754
  if (props.isSearchContainer) {
20742
20755
  goToResultsDebounced({
@@ -20887,6 +20900,20 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20887
20900
  const slotProps = (props2) => {
20888
20901
  return __spreadValues({}, props2);
20889
20902
  };
20903
+ const onFocus = () => {
20904
+ var _a2, _b;
20905
+ opened.value = true;
20906
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onFocused) {
20907
+ (_b = props.options.callbacks) == null ? void 0 : _b.onFocused();
20908
+ }
20909
+ };
20910
+ const onBlur = () => {
20911
+ var _a2, _b;
20912
+ focused.value = false;
20913
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onBlurred) {
20914
+ (_b = props.options.callbacks) == null ? void 0 : _b.onBlurred();
20915
+ }
20916
+ };
20890
20917
  return (_ctx, _cache) => {
20891
20918
  var _a2;
20892
20919
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$W, [
@@ -20899,10 +20926,10 @@ const _sfc_main$10 = /* @__PURE__ */ vue.defineComponent({
20899
20926
  ref_key: "searchBoxInput",
20900
20927
  ref: searchBoxInput,
20901
20928
  onInput: handleInput,
20902
- onBlur: _cache[0] || (_cache[0] = ($event) => focused.value = false),
20903
- onFocus: _cache[1] || (_cache[1] = ($event) => opened.value = true),
20929
+ onBlur,
20930
+ onFocus,
20904
20931
  onSearch: handleSearch,
20905
- onClose: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("close"))
20932
+ onClose: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
20906
20933
  }, null, 8, ["options", "suggestedValue", "can-close", "emit-input-on-focus"]),
20907
20934
  opened.value || _ctx.isSearchContainer ? (vue.openBlock(), vue.createBlock(_sfc_main$11, {
20908
20935
  key: 0,
@@ -20665,7 +20665,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20665
20665
  });
20666
20666
  const goToResultsDebounced = debounce$1(paramsStore.goToResults, (_a = props.options.debounce) != null ? _a : 300);
20667
20667
  onMounted(() => {
20668
- var _a2;
20668
+ var _a2, _b, _c;
20669
20669
  window.addEventListener("keydown", handleKeyDown);
20670
20670
  window.addEventListener("click", handleMouseClick);
20671
20671
  paramsStore.setSearchResultsLink(props.options.links.searchResults);
@@ -20676,6 +20676,9 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20676
20676
  if (props.isSearchContainer && searchBoxInput.value) {
20677
20677
  (_a2 = searchBoxInput.value) == null ? void 0 : _a2.focus();
20678
20678
  }
20679
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onMounted) {
20680
+ (_c = props.options.callbacks) == null ? void 0 : _c.onMounted();
20681
+ }
20679
20682
  });
20680
20683
  onBeforeUnmount(() => {
20681
20684
  window.removeEventListener("keydown", handleKeyDown);
@@ -20683,7 +20686,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20683
20686
  unbindSearchTriggers(searchTriggers.value, handleCurrentValueSearch);
20684
20687
  });
20685
20688
  const handleMouseClick = (e2) => {
20686
- var _a2, _b;
20689
+ var _a2, _b, _c, _d;
20687
20690
  const el = document.getElementById("lupa-search-box");
20688
20691
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
20689
20692
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
@@ -20699,11 +20702,18 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20699
20702
  }
20700
20703
  opened.value = false;
20701
20704
  suggestedValue.value = defaultSuggestedValue;
20705
+ if ((_c = props.options.callbacks) == null ? void 0 : _c.onClosed) {
20706
+ (_d = props.options.callbacks) == null ? void 0 : _d.onClosed();
20707
+ }
20702
20708
  };
20703
20709
  const close = () => {
20710
+ var _a2, _b;
20704
20711
  opened.value = false;
20705
20712
  focused.value = false;
20706
20713
  suggestedValue.value = defaultSuggestedValue;
20714
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onClosed) {
20715
+ (_b = props.options.callbacks) == null ? void 0 : _b.onClosed();
20716
+ }
20707
20717
  };
20708
20718
  const handleKeyDown = (e2) => {
20709
20719
  var _a2, _b;
@@ -20729,12 +20739,15 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20729
20739
  }
20730
20740
  };
20731
20741
  const handleInput = (value) => {
20732
- var _a2;
20742
+ var _a2, _b;
20733
20743
  opened.value = true;
20734
20744
  focused.value = true;
20735
20745
  inputValue.value = (_a2 = value == null ? void 0 : value.replace(/\s+$/, "")) != null ? _a2 : "";
20736
20746
  suggestedValue.value = defaultSuggestedValue;
20737
20747
  searchBoxStore.resetHighlightIndex();
20748
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onSearchBoxInput) {
20749
+ props.options.callbacks.onSearchBoxInput(value);
20750
+ }
20738
20751
  trackSearchQuery(value);
20739
20752
  if (props.isSearchContainer) {
20740
20753
  goToResultsDebounced({
@@ -20885,6 +20898,20 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20885
20898
  const slotProps = (props2) => {
20886
20899
  return __spreadValues({}, props2);
20887
20900
  };
20901
+ const onFocus = () => {
20902
+ var _a2, _b;
20903
+ opened.value = true;
20904
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onFocused) {
20905
+ (_b = props.options.callbacks) == null ? void 0 : _b.onFocused();
20906
+ }
20907
+ };
20908
+ const onBlur = () => {
20909
+ var _a2, _b;
20910
+ focused.value = false;
20911
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onBlurred) {
20912
+ (_b = props.options.callbacks) == null ? void 0 : _b.onBlurred();
20913
+ }
20914
+ };
20888
20915
  return (_ctx, _cache) => {
20889
20916
  var _a2;
20890
20917
  return openBlock(), createElementBlock("div", _hoisted_1$W, [
@@ -20897,10 +20924,10 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
20897
20924
  ref_key: "searchBoxInput",
20898
20925
  ref: searchBoxInput,
20899
20926
  onInput: handleInput,
20900
- onBlur: _cache[0] || (_cache[0] = ($event) => focused.value = false),
20901
- onFocus: _cache[1] || (_cache[1] = ($event) => opened.value = true),
20927
+ onBlur,
20928
+ onFocus,
20902
20929
  onSearch: handleSearch,
20903
- onClose: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("close"))
20930
+ onClose: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
20904
20931
  }, null, 8, ["options", "suggestedValue", "can-close", "emit-input-on-focus"]),
20905
20932
  opened.value || _ctx.isSearchContainer ? (openBlock(), createBlock(_sfc_main$11, {
20906
20933
  key: 0,
@@ -57,6 +57,11 @@ export type SearchBoxResultsNavigateContext = {
57
57
  };
58
58
  };
59
59
  export type SearchBoxEventCallbacks = {
60
+ onMounted?: () => unknown;
61
+ onFocused?: () => unknown;
62
+ onBlurred?: () => unknown;
63
+ onClosed?: () => unknown;
64
+ onSearchBoxInput?: (input: string) => unknown;
60
65
  onSearchBoxResults?: (context: SearchBoxResultCallbackContext) => unknown;
61
66
  onSearchResultsNavigate?: (context: SearchBoxResultsNavigateContext) => unknown;
62
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",