@dcrackel/hematournamentui 1.0.589 → 1.0.591

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.
@@ -29992,6 +29992,7 @@ const IO = /* @__PURE__ */ oe(dO, [["render", pO]]), BO = {
29992
29992
  showNewLocation: !1,
29993
29993
  filteredLocations: this.locations,
29994
29994
  inputValue: this.placeholder,
29995
+ backupInputValue: this.inputValue,
29995
29996
  showDropdown: !1,
29996
29997
  showAddNew: !0,
29997
29998
  debouncedTimeout: null
@@ -30002,12 +30003,21 @@ const IO = /* @__PURE__ */ oe(dO, [["render", pO]]), BO = {
30002
30003
  this.showDropdown = n.length > 0, this.debounceSearch();
30003
30004
  }
30004
30005
  },
30006
+ mounted() {
30007
+ document.addEventListener("click", this.handleClickOutside);
30008
+ },
30009
+ beforeDestroy() {
30010
+ document.removeEventListener("click", this.handleClickOutside);
30011
+ },
30005
30012
  methods: {
30006
30013
  clearInput() {
30007
- this.locationName && (this.locationName = "");
30014
+ this.backupInputValue = this.inputValue, this.inputValue = "";
30015
+ },
30016
+ restorePreviousValue() {
30017
+ this.inputValue === "" && (this.showAddNew = !1, this.inputValue = this.backupInputValue);
30008
30018
  },
30009
30019
  updateInput(n) {
30010
- this.inputValue = n.target.value, this.inputValue.trim() === "" ? this.$emit("update:location", null) : this.debounceSearch();
30020
+ this.showAddNew = !0, this.inputValue = n.target.value, this.inputValue.trim() === "" ? this.$emit("update:location", null) : this.debounceSearch();
30011
30021
  },
30012
30022
  selectItem(n) {
30013
30023
  this.showDropdown = !1, this.inputValue = n.Name, this.$emit("update:location", n), this.$nextTick(() => {
@@ -30018,7 +30028,9 @@ const IO = /* @__PURE__ */ oe(dO, [["render", pO]]), BO = {
30018
30028
  this.$emit("add-new", this.inputValue), this.showDropdown = !1;
30019
30029
  },
30020
30030
  onInputChanged(n) {
30021
- this.showDropdown && (this.filteredLocations = this.locations.filter((e) => e.Name.toLowerCase().includes(n.toLowerCase())));
30031
+ if (!this.showDropdown) return;
30032
+ const e = (n || "").toLowerCase();
30033
+ this.filteredLocations = this.locations.filter((t) => (t.Name || "").toLowerCase().includes(e));
30022
30034
  },
30023
30035
  debounceSearch() {
30024
30036
  clearTimeout(this.debouncedTimeout), this.debouncedTimeout = setTimeout(() => {
@@ -30033,11 +30045,15 @@ const IO = /* @__PURE__ */ oe(dO, [["render", pO]]), BO = {
30033
30045
  },
30034
30046
  handleSubmit() {
30035
30047
  this.$emit("submit:location", this.formData), this.showNewLocation = !1, this.showDropdown = !1, this.showAddNew = !1;
30048
+ },
30049
+ handleClickOutside(n) {
30050
+ this.$refs.showNewLocation && !this.$refs.showNewLocation.contains(n.target) && this.restorePreviousValue();
30036
30051
  }
30037
30052
  }
30038
30053
  }, EO = {
30039
30054
  key: 0,
30040
- class: "relative"
30055
+ class: "relative",
30056
+ ref: "showNewLocation"
30041
30057
  }, QO = {
30042
30058
  key: 0,
30043
30059
  class: "absolute z-10 w-full bg-white border rounded-md mt-1 max-h-60 overflow-y-auto"
@@ -30051,8 +30067,9 @@ function yO(n, e, t, r, o, i) {
30051
30067
  value: o.inputValue,
30052
30068
  invalid: t.invalid,
30053
30069
  placeholder: "Enter Location Name",
30070
+ onClick: i.clearInput,
30054
30071
  onInput: i.updateInput
30055
- }, null, 8, ["addBorder", "value", "invalid", "onInput"]),
30072
+ }, null, 8, ["addBorder", "value", "invalid", "onClick", "onInput"]),
30056
30073
  o.showDropdown && o.showAddNew ? (m(), I("div", QO, [
30057
30074
  f("ul", null, [
30058
30075
  (m(!0), I(ae, null, Qe(o.filteredLocations, (u, d) => (m(), I("li", {
@@ -30073,7 +30090,7 @@ function yO(n, e, t, r, o, i) {
30073
30090
  })
30074
30091
  ])
30075
30092
  ])) : Q("", !0)
30076
- ])),
30093
+ ], 512)),
30077
30094
  o.showNewLocation ? (m(), I("div", wO, [
30078
30095
  h(c, {
30079
30096
  show: o.showNewLocation,