intl-tel-input 25.8.1 → 25.8.3

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.
@@ -1588,8 +1588,8 @@ var countries_default = countryTranslations;
1588
1588
 
1589
1589
  // src/js/intl-tel-input/i18n/en/interface.ts
1590
1590
  var interfaceTranslations = {
1591
- selectedCountryAriaLabel: "Selected country",
1592
- noCountrySelected: "No country selected",
1591
+ selectedCountryAriaLabel: "Change country, selected ${country}",
1592
+ noCountrySelected: "Select country",
1593
1593
  countryListAriaLabel: "List of countries",
1594
1594
  searchPlaceholder: "Search",
1595
1595
  clearSearchAriaLabel: "Clear search",
@@ -1954,7 +1954,7 @@ var Iti = class _Iti {
1954
1954
  type: "button",
1955
1955
  class: "iti__selected-country",
1956
1956
  "aria-expanded": "false",
1957
- "aria-label": this.options.i18n.selectedCountryAriaLabel,
1957
+ "aria-label": this.options.i18n.noCountrySelected,
1958
1958
  "aria-haspopup": "dialog",
1959
1959
  "aria-controls": `iti-${this.id}__dropdown-content`
1960
1960
  },
@@ -1970,12 +1970,15 @@ var Iti = class _Iti {
1970
1970
  this.countryContainer
1971
1971
  );
1972
1972
  }
1973
- const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1974
- this.selectedCountryInner = createEl("div", { class: "iti__flag" }, selectedCountryPrimary);
1975
- this.selectedCountryA11yText = createEl(
1976
- "span",
1977
- { class: "iti__a11y-text" },
1978
- this.selectedCountryInner
1973
+ const selectedCountryPrimary = createEl(
1974
+ "div",
1975
+ { class: "iti__selected-country-primary" },
1976
+ this.selectedCountry
1977
+ );
1978
+ this.selectedCountryInner = createEl(
1979
+ "div",
1980
+ { class: "iti__flag" },
1981
+ selectedCountryPrimary
1979
1982
  );
1980
1983
  if (allowDropdown) {
1981
1984
  this.dropdownArrow = createEl(
@@ -1987,7 +1990,7 @@ var Iti = class _Iti {
1987
1990
  if (separateDialCode) {
1988
1991
  this.selectedDialCode = createEl(
1989
1992
  "div",
1990
- { class: "iti__selected-dial-code", "aria-hidden": "true", dir: "ltr" },
1993
+ { class: "iti__selected-dial-code", dir: "ltr" },
1991
1994
  this.selectedCountry
1992
1995
  );
1993
1996
  }
@@ -2229,7 +2232,8 @@ var Iti = class _Iti {
2229
2232
  label.addEventListener("click", this._handleLabelClick);
2230
2233
  }
2231
2234
  this._handleClickSelectedCountry = () => {
2232
- if (this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly) {
2235
+ const dropdownClosed = this.dropdownContent.classList.contains("iti__hide");
2236
+ if (dropdownClosed && !this.telInput.disabled && !this.telInput.readOnly) {
2233
2237
  this._openDropdown();
2234
2238
  }
2235
2239
  };
@@ -2444,17 +2448,19 @@ var Iti = class _Iti {
2444
2448
  }
2445
2449
  };
2446
2450
  this.countryList.addEventListener("click", this._handleClickCountryList);
2447
- let isOpening = true;
2448
- this._handleClickOffToClose = () => {
2449
- if (!isOpening) {
2451
+ this._handleClickOffToClose = (e) => {
2452
+ const target = e.target;
2453
+ const clickedInsideDropdown = !!target.closest(`#iti-${this.id}__dropdown-content`);
2454
+ if (!clickedInsideDropdown) {
2450
2455
  this._closeDropdown();
2451
2456
  }
2452
- isOpening = false;
2453
2457
  };
2454
- document.documentElement.addEventListener(
2455
- "click",
2456
- this._handleClickOffToClose
2457
- );
2458
+ setTimeout(() => {
2459
+ document.documentElement.addEventListener(
2460
+ "click",
2461
+ this._handleClickOffToClose
2462
+ );
2463
+ }, 0);
2458
2464
  let query = "";
2459
2465
  let queryTimer = null;
2460
2466
  this._handleKeydownOnDropdown = (e) => {
@@ -2507,14 +2513,12 @@ var Iti = class _Iti {
2507
2513
  }, 100);
2508
2514
  };
2509
2515
  this.searchInput.addEventListener("input", this._handleSearchChange);
2510
- this._handleSearchClear = (e) => {
2511
- e.stopPropagation();
2516
+ this._handleSearchClear = () => {
2512
2517
  this.searchInput.value = "";
2513
2518
  this.searchInput.focus();
2514
2519
  doFilter();
2515
2520
  };
2516
2521
  this.searchClearButton.addEventListener("click", this._handleSearchClear);
2517
- this.searchInput.addEventListener("click", (e) => e.stopPropagation());
2518
2522
  }
2519
2523
  }
2520
2524
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
@@ -2733,20 +2737,20 @@ var Iti = class _Iti {
2733
2737
  if (this.selectedCountryData.iso2) {
2734
2738
  this.defaultCountry = this.selectedCountryData.iso2;
2735
2739
  }
2736
- if (this.selectedCountryInner) {
2737
- let flagClass = "";
2738
- let a11yText = "";
2739
- if (iso2 && showFlags) {
2740
- flagClass = `iti__flag iti__${iso2}`;
2741
- a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`;
2740
+ if (this.selectedCountry) {
2741
+ const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
2742
+ let ariaLabel, title;
2743
+ if (iso2) {
2744
+ title = this.selectedCountryData.name;
2745
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name);
2742
2746
  } else {
2743
- flagClass = "iti__flag iti__globe";
2744
- a11yText = i18n.noCountrySelected;
2747
+ title = i18n.noCountrySelected;
2748
+ ariaLabel = i18n.noCountrySelected;
2745
2749
  }
2746
2750
  this.selectedCountryInner.className = flagClass;
2747
- this.selectedCountryA11yText.textContent = a11yText;
2751
+ this.selectedCountry.setAttribute("title", title);
2752
+ this.selectedCountry.setAttribute("aria-label", ariaLabel);
2748
2753
  }
2749
- this._setSelectedCountryTitleAttribute(iso2, separateDialCode);
2750
2754
  if (separateDialCode) {
2751
2755
  const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2752
2756
  this.selectedDialCode.innerHTML = dialCode;
@@ -2796,20 +2800,6 @@ var Iti = class _Iti {
2796
2800
  }
2797
2801
  }
2798
2802
  }
2799
- _setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) {
2800
- if (!this.selectedCountry) {
2801
- return;
2802
- }
2803
- let title;
2804
- if (iso2 && !separateDialCode) {
2805
- title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`;
2806
- } else if (iso2) {
2807
- title = this.selectedCountryData.name;
2808
- } else {
2809
- title = "Unknown";
2810
- }
2811
- this.selectedCountry.setAttribute("title", title);
2812
- }
2813
2803
  //* When the input is in a hidden container during initialisation, we must inject some markup
2814
2804
  //* into the end of the DOM to calculate the correct offsetWidth.
2815
2805
  //* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry
@@ -3235,7 +3225,7 @@ var intlTelInput = Object.assign(
3235
3225
  attachUtils,
3236
3226
  startedLoadingUtilsScript: false,
3237
3227
  startedLoadingAutoCountry: false,
3238
- version: "25.8.1"
3228
+ version: "25.8.3"
3239
3229
  }
3240
3230
  );
3241
3231
  var intl_tel_input_default = intlTelInput;
package/vue/README.md CHANGED
@@ -34,7 +34,7 @@ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master
34
34
  "vue:demo": "vite --config vue/demo/[demo variant]/vite.config.js"
35
35
  ```
36
36
 
37
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.8.1/build/js/utils.js"`.
37
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.8.3/build/js/utils.js"`.
38
38
 
39
39
  ## Props
40
40
  Here's a list of all of the current props you can pass to the IntlTelInput Vue component.