@dcrackel/hematournamentui 1.0.588 → 1.0.590

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(() => {
@@ -30033,11 +30043,15 @@ const IO = /* @__PURE__ */ oe(dO, [["render", pO]]), BO = {
30033
30043
  },
30034
30044
  handleSubmit() {
30035
30045
  this.$emit("submit:location", this.formData), this.showNewLocation = !1, this.showDropdown = !1, this.showAddNew = !1;
30046
+ },
30047
+ handleClickOutside(n) {
30048
+ this.$refs.showNewLocation && !this.$refs.showNewLocation.contains(n.target) && this.restorePreviousValue();
30036
30049
  }
30037
30050
  }
30038
30051
  }, EO = {
30039
30052
  key: 0,
30040
- class: "relative"
30053
+ class: "relative",
30054
+ ref: "showNewLocation"
30041
30055
  }, QO = {
30042
30056
  key: 0,
30043
30057
  class: "absolute z-10 w-full bg-white border rounded-md mt-1 max-h-60 overflow-y-auto"
@@ -30051,8 +30065,9 @@ function yO(n, e, t, r, o, i) {
30051
30065
  value: o.inputValue,
30052
30066
  invalid: t.invalid,
30053
30067
  placeholder: "Enter Location Name",
30068
+ onClick: i.clearInput,
30054
30069
  onInput: i.updateInput
30055
- }, null, 8, ["addBorder", "value", "invalid", "onInput"]),
30070
+ }, null, 8, ["addBorder", "value", "invalid", "onClick", "onInput"]),
30056
30071
  o.showDropdown && o.showAddNew ? (m(), I("div", QO, [
30057
30072
  f("ul", null, [
30058
30073
  (m(!0), I(ae, null, Qe(o.filteredLocations, (u, d) => (m(), I("li", {
@@ -30073,7 +30088,7 @@ function yO(n, e, t, r, o, i) {
30073
30088
  })
30074
30089
  ])
30075
30090
  ])) : Q("", !0)
30076
- ])),
30091
+ ], 512)),
30077
30092
  o.showNewLocation ? (m(), I("div", wO, [
30078
30093
  h(c, {
30079
30094
  show: o.showNewLocation,