intl-tel-input 21.0.9 → 21.1.0

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v21.0.9
2
+ * International Telephone Input v21.1.0
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -1364,58 +1364,57 @@ var factoryOutput = (() => {
1364
1364
  // src/js/intl-tel-input.ts
1365
1365
  var id = 0;
1366
1366
  var defaults = {
1367
- // whether or not to allow the dropdown
1367
+ //* Whether or not to allow the dropdown.
1368
1368
  allowDropdown: true,
1369
- // add a placeholder in the input with an example number for the selected country
1369
+ //* Add a placeholder in the input with an example number for the selected country.
1370
1370
  autoPlaceholder: "polite",
1371
- // add a country search input at the top of the dropdown
1371
+ //* Add a country search input at the top of the dropdown.
1372
1372
  countrySearch: true,
1373
- // modify the parentClass
1373
+ //* Modify the parentClass.
1374
1374
  containerClass: "",
1375
- // modify the auto placeholder
1375
+ //* Modify the auto placeholder.
1376
1376
  customPlaceholder: null,
1377
- // append menu to specified element
1377
+ //* Append menu to specified element.
1378
1378
  dropdownContainer: null,
1379
- // don't display these countries
1379
+ //* Don't display these countries.
1380
1380
  excludeCountries: [],
1381
- // fix the dropdown width to the input width (rather than being as wide as the longest country name)
1381
+ //* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
1382
1382
  fixDropdownWidth: true,
1383
- // format the number as the user types
1383
+ //* Format the number as the user types
1384
1384
  formatAsYouType: true,
1385
- // format the input value during initialisation and on setNumber
1385
+ //* Format the input value during initialisation and on setNumber.
1386
1386
  formatOnDisplay: true,
1387
- // geoIp lookup function
1387
+ //* geoIp lookup function.
1388
1388
  geoIpLookup: null,
1389
- // inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber
1389
+ //* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
1390
1390
  hiddenInput: null,
1391
- // internationalise the plugin text e.g. search input placeholder, country names
1391
+ //* Internationalise the plugin text e.g. search input placeholder, country names.
1392
1392
  i18n: {},
1393
- // initial country
1393
+ //* Initial country.
1394
1394
  initialCountry: "",
1395
- // national vs international formatting for numbers e.g. placeholders and displaying existing numbers
1395
+ //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
1396
1396
  nationalMode: true,
1397
- // display only these countries
1397
+ //* Display only these countries.
1398
1398
  onlyCountries: [],
1399
- // number type to use for placeholders
1399
+ //* Number type to use for placeholders.
1400
1400
  placeholderNumberType: "MOBILE",
1401
- // the countries at the top of the list
1401
+ //* The countries at the top of the list.
1402
1402
  preferredCountries: [],
1403
- // option to hide the flags - must be used with showSelectedDialCode, or allowDropdown=false
1403
+ //* Option to hide the flags - must be used with showSelectedDialCode, or allowDropdown=false.
1404
1404
  showFlags: true,
1405
- // display the international dial code next to the selected flag
1405
+ //* Display the international dial code next to the selected flag.
1406
1406
  showSelectedDialCode: false,
1407
- // only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length
1407
+ //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1408
1408
  strictMode: false,
1409
- // use full screen popup instead of dropdown for country list
1409
+ //* Use full screen popup instead of dropdown for country list.
1410
1410
  useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? (
1411
- // we cannot just test screen size as some smartphones/website meta tags will report desktop
1412
- // resolutions
1413
- // Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
1411
+ //* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
1412
+ //* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
1414
1413
  /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1415
1414
  navigator.userAgent
1416
1415
  ) || window.innerWidth <= 500
1417
1416
  ) : false,
1418
- // specify the path to the libphonenumber script to enable validation/formatting
1417
+ //* Specify the path to the libphonenumber script to enable validation/formatting.
1419
1418
  utilsScript: ""
1420
1419
  };
1421
1420
  var regionlessNanpNumbers = [
@@ -1496,11 +1495,11 @@ var factoryOutput = (() => {
1496
1495
  Object.values(instances).forEach((instance) => instance[method]());
1497
1496
  };
1498
1497
  var Iti = class {
1499
- // can't be private as it's called from intlTelInput convenience wrapper
1498
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
1500
1499
  id;
1501
- // not private!
1500
+ //* NOT Private
1502
1501
  promise;
1503
- // private
1502
+ //* Private
1504
1503
  telInput;
1505
1504
  activeItem;
1506
1505
  highlightedItem;
@@ -1552,7 +1551,7 @@ var factoryOutput = (() => {
1552
1551
  this.options = Object.assign({}, defaults, customOptions);
1553
1552
  this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
1554
1553
  }
1555
- // can't be private as it's called from intlTelInput convenience wrapper
1554
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
1556
1555
  _init() {
1557
1556
  if (this.options.useFullscreenPopup) {
1558
1557
  this.options.fixDropdownWidth = false;
@@ -1587,8 +1586,7 @@ var factoryOutput = (() => {
1587
1586
  //********************
1588
1587
  //* PRIVATE METHODS
1589
1588
  //********************
1590
- // prepare all of the country data, including onlyCountries, excludeCountries and
1591
- // preferredCountries options
1589
+ //* Prepare all of the country data, including onlyCountries, excludeCountries and preferredCountries options.
1592
1590
  _processCountryData() {
1593
1591
  this._processAllCountries();
1594
1592
  this._processDialCodes();
@@ -1598,7 +1596,7 @@ var factoryOutput = (() => {
1598
1596
  this.countries.sort(countryNameSort);
1599
1597
  }
1600
1598
  }
1601
- // add a dial code to this.dialCodeToIso2Map
1599
+ //* Add a dial code to this.dialCodeToIso2Map.
1602
1600
  _addToDialCodeMap(iso2, dialCode, priority) {
1603
1601
  if (dialCode.length > this.dialCodeMaxLen) {
1604
1602
  this.dialCodeMaxLen = dialCode.length;
@@ -1614,7 +1612,7 @@ var factoryOutput = (() => {
1614
1612
  const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1615
1613
  this.dialCodeToIso2Map[dialCode][index] = iso2;
1616
1614
  }
1617
- // process onlyCountries or excludeCountries array if present
1615
+ //* Process onlyCountries or excludeCountries array if present.
1618
1616
  _processAllCountries() {
1619
1617
  const { onlyCountries, excludeCountries } = this.options;
1620
1618
  if (onlyCountries.length) {
@@ -1635,7 +1633,7 @@ var factoryOutput = (() => {
1635
1633
  this.countries = data_default;
1636
1634
  }
1637
1635
  }
1638
- // Translate Countries by object literal provided on config
1636
+ //* Translate Countries by object literal provided on config.
1639
1637
  _translateCountryNames() {
1640
1638
  for (let i = 0; i < this.countries.length; i++) {
1641
1639
  const iso2 = this.countries[i].iso2.toLowerCase();
@@ -1644,7 +1642,7 @@ var factoryOutput = (() => {
1644
1642
  }
1645
1643
  }
1646
1644
  }
1647
- // generate this.dialCodes and this.dialCodeToIso2Map
1645
+ //* Generate this.dialCodes and this.dialCodeToIso2Map.
1648
1646
  _processDialCodes() {
1649
1647
  this.dialCodes = {};
1650
1648
  this.dialCodeMaxLen = 0;
@@ -1672,8 +1670,7 @@ var factoryOutput = (() => {
1672
1670
  }
1673
1671
  }
1674
1672
  }
1675
- // process preferred countries - iterate through the preferences, fetching the country data for
1676
- // each one
1673
+ //* Process preferred countries - iterate through the preferences, fetching the country data for each one.
1677
1674
  _processPreferredCountries() {
1678
1675
  this.preferredCountries = [];
1679
1676
  for (let i = 0; i < this.options.preferredCountries.length; i++) {
@@ -1684,7 +1681,7 @@ var factoryOutput = (() => {
1684
1681
  }
1685
1682
  }
1686
1683
  }
1687
- // generate all of the markup for the plugin: the selected country overlay, and the dropdown
1684
+ //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
1688
1685
  _generateMarkup() {
1689
1686
  this.telInput.classList.add("iti__tel-input");
1690
1687
  if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
@@ -1855,7 +1852,7 @@ var factoryOutput = (() => {
1855
1852
  }
1856
1853
  }
1857
1854
  }
1858
- // for each of the passed countries: add a country <li> to the countryList <ul> container
1855
+ //* For each of the passed countries: add a country <li> to the countryList <ul> container.
1859
1856
  _appendListItems(countries, className, preferred) {
1860
1857
  for (let i = 0; i < countries.length; i++) {
1861
1858
  const c = countries[i];
@@ -1883,11 +1880,11 @@ var factoryOutput = (() => {
1883
1880
  listItem.insertAdjacentHTML("beforeend", content);
1884
1881
  }
1885
1882
  }
1886
- // set the initial state of the input value and the selected country by:
1887
- // 1. extracting a dial code from the given number
1888
- // 2. using explicit initialCountry
1889
- // 3. picking the first preferred country
1890
- // 4. picking the first country
1883
+ //* Set the initial state of the input value and the selected country by:
1884
+ //* 1. Extracting a dial code from the given number
1885
+ //* 2. Using explicit initialCountry
1886
+ //* 3. Picking the first preferred country
1887
+ //* 4. Picking the first country
1891
1888
  _setInitialState(overrideAutoCountry = false) {
1892
1889
  const attributeValue = this.telInput.getAttribute("value");
1893
1890
  const inputValue = this.telInput.value;
@@ -1915,7 +1912,7 @@ var factoryOutput = (() => {
1915
1912
  this._updateValFromNumber(val);
1916
1913
  }
1917
1914
  }
1918
- // initialise the main event listeners: input keyup, and click selected country
1915
+ //* Initialise the main event listeners: input keyup, and click selected country.
1919
1916
  _initListeners() {
1920
1917
  this._initTelInputListeners();
1921
1918
  if (this.options.allowDropdown) {
@@ -1925,7 +1922,7 @@ var factoryOutput = (() => {
1925
1922
  this._initHiddenInputListener();
1926
1923
  }
1927
1924
  }
1928
- // update hidden input on form submit
1925
+ //* Update hidden input on form submit.
1929
1926
  _initHiddenInputListener() {
1930
1927
  this._handleHiddenInputSubmit = () => {
1931
1928
  if (this.hiddenInput) {
@@ -1940,7 +1937,7 @@ var factoryOutput = (() => {
1940
1937
  this._handleHiddenInputSubmit
1941
1938
  );
1942
1939
  }
1943
- // initialise the dropdown listeners
1940
+ //* initialise the dropdown listeners.
1944
1941
  _initDropdownListeners() {
1945
1942
  this._handleLabelClick = (e) => {
1946
1943
  if (this.dropdownContent.classList.contains("iti__hide")) {
@@ -1975,7 +1972,7 @@ var factoryOutput = (() => {
1975
1972
  this._handleCountryContainerKeydown
1976
1973
  );
1977
1974
  }
1978
- // init many requests: utils script / geo ip lookup
1975
+ //* Init many requests: utils script / geo ip lookup.
1979
1976
  _initRequests() {
1980
1977
  if (this.options.utilsScript && !window.intlTelInputUtils) {
1981
1978
  if (window.intlTelInputGlobals.documentReady()) {
@@ -1994,7 +1991,7 @@ var factoryOutput = (() => {
1994
1991
  this.resolveAutoCountryPromise();
1995
1992
  }
1996
1993
  }
1997
- // perform the geo ip lookup
1994
+ //* Perform the geo ip lookup.
1998
1995
  _loadAutoCountry() {
1999
1996
  if (window.intlTelInputGlobals.autoCountry) {
2000
1997
  this.handleAutoCountry();
@@ -2021,7 +2018,7 @@ var factoryOutput = (() => {
2021
2018
  }
2022
2019
  }
2023
2020
  }
2024
- // initialize the tel input listeners
2021
+ //* Initialize the tel input listeners.
2025
2022
  _initTelInputListeners() {
2026
2023
  const { strictMode, formatAsYouType } = this.options;
2027
2024
  let userOverrideFormatting = false;
@@ -2065,12 +2062,12 @@ var factoryOutput = (() => {
2065
2062
  this.telInput.addEventListener("keydown", this._handleKeydownEvent);
2066
2063
  }
2067
2064
  }
2068
- // adhere to the input's maxlength attr
2065
+ //* Adhere to the input's maxlength attr.
2069
2066
  _cap(number) {
2070
2067
  const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2071
2068
  return max && number.length > max ? number.substr(0, max) : number;
2072
2069
  }
2073
- // trigger a custom event on the input
2070
+ //* Trigger a custom event on the input.
2074
2071
  _trigger(name) {
2075
2072
  const e = new Event(name, {
2076
2073
  bubbles: true,
@@ -2078,7 +2075,7 @@ var factoryOutput = (() => {
2078
2075
  });
2079
2076
  this.telInput.dispatchEvent(e);
2080
2077
  }
2081
- // open the dropdown
2078
+ //* Open the dropdown.
2082
2079
  _openDropdown() {
2083
2080
  const { fixDropdownWidth, countrySearch } = this.options;
2084
2081
  if (fixDropdownWidth) {
@@ -2104,7 +2101,7 @@ var factoryOutput = (() => {
2104
2101
  this.dropdownArrow.classList.add("iti__arrow--up");
2105
2102
  this._trigger("open:countrydropdown");
2106
2103
  }
2107
- // decide if should position dropdown above or below input (depends on position within viewport, and scroll)
2104
+ //* Decide if should position dropdown above or below input (depends on position within viewport, and scroll).
2108
2105
  _setDropdownPosition() {
2109
2106
  if (this.options.dropdownContainer) {
2110
2107
  this.options.dropdownContainer.appendChild(this.dropdown);
@@ -2131,7 +2128,7 @@ var factoryOutput = (() => {
2131
2128
  }
2132
2129
  }
2133
2130
  }
2134
- // we only bind dropdown listeners when the dropdown is open
2131
+ //* We only bind dropdown listeners when the dropdown is open.
2135
2132
  _bindDropdownListeners() {
2136
2133
  this._handleMouseoverCountryList = (e) => {
2137
2134
  const listItem = e.target?.closest(".iti__country");
@@ -2233,7 +2230,7 @@ var factoryOutput = (() => {
2233
2230
  this.countryList.scrollTop = 0;
2234
2231
  this._updateSearchResultsText();
2235
2232
  }
2236
- // update search results text (for a11y)
2233
+ //* Update search results text (for a11y).
2237
2234
  _updateSearchResultsText() {
2238
2235
  const { i18n } = this.options;
2239
2236
  const count = this.countryList.childElementCount;
@@ -2247,7 +2244,7 @@ var factoryOutput = (() => {
2247
2244
  }
2248
2245
  this.searchResultsA11yText.textContent = searchText;
2249
2246
  }
2250
- // highlight the next/prev item in the list (and ensure it is visible)
2247
+ //* Highlight the next/prev item in the list (and ensure it is visible).
2251
2248
  _handleUpDownKey(key) {
2252
2249
  let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
2253
2250
  if (next) {
@@ -2263,13 +2260,13 @@ var factoryOutput = (() => {
2263
2260
  this._highlightListItem(next, doFocus);
2264
2261
  }
2265
2262
  }
2266
- // select the currently highlighted item
2263
+ //* Select the currently highlighted item.
2267
2264
  _handleEnterKey() {
2268
2265
  if (this.highlightedItem) {
2269
2266
  this._selectListItem(this.highlightedItem);
2270
2267
  }
2271
2268
  }
2272
- // find the first list item whose name starts with the query string
2269
+ //* Find the first list item whose name starts with the query string.
2273
2270
  _searchForCountry(query) {
2274
2271
  for (let i = 0; i < this.countries.length; i++) {
2275
2272
  const c = this.countries[i];
@@ -2282,8 +2279,8 @@ var factoryOutput = (() => {
2282
2279
  }
2283
2280
  }
2284
2281
  }
2285
- // update the input's value to the given val (format first if possible)
2286
- // NOTE: this is called from _setInitialState, handleUtils and setNumber
2282
+ //* Update the input's value to the given val (format first if possible)
2283
+ //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2287
2284
  _updateValFromNumber(fullNumber) {
2288
2285
  let number = fullNumber;
2289
2286
  if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {
@@ -2299,8 +2296,8 @@ var factoryOutput = (() => {
2299
2296
  number = this._beforeSetNumber(number);
2300
2297
  this.telInput.value = number;
2301
2298
  }
2302
- // check if need to select a new country based on the given number
2303
- // Note: called from _setInitialState, keyup handler, setNumber
2299
+ //* Check if need to select a new country based on the given number
2300
+ //* Note: called from _setInitialState, keyup handler, setNumber.
2304
2301
  _updateCountryFromNumber(fullNumber) {
2305
2302
  const plusIndex = fullNumber.indexOf("+");
2306
2303
  let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
@@ -2340,7 +2337,7 @@ var factoryOutput = (() => {
2340
2337
  }
2341
2338
  return false;
2342
2339
  }
2343
- // remove highlighting from other list items and highlight the given item
2340
+ //* Remove highlighting from other list items and highlight the given item.
2344
2341
  _highlightListItem(listItem, shouldFocus) {
2345
2342
  const prevItem = this.highlightedItem;
2346
2343
  if (prevItem) {
@@ -2364,8 +2361,8 @@ var factoryOutput = (() => {
2364
2361
  this.highlightedItem.focus();
2365
2362
  }
2366
2363
  }
2367
- // find the country data for the given iso2 code
2368
- // the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2364
+ //* Find the country data for the given iso2 code
2365
+ //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2369
2366
  _getCountryData(iso2, allowFail) {
2370
2367
  for (let i = 0; i < this.countries.length; i++) {
2371
2368
  if (this.countries[i].iso2 === iso2) {
@@ -2377,8 +2374,8 @@ var factoryOutput = (() => {
2377
2374
  }
2378
2375
  throw new Error(`No country data for '${iso2}'`);
2379
2376
  }
2380
- // update the selected country, dial code (if showSelectedDialCode), placeholder, title, and active list item
2381
- // Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry
2377
+ //* Update the selected country, dial code (if showSelectedDialCode), placeholder, title, and active list item.
2378
+ //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2382
2379
  _setCountry(iso2) {
2383
2380
  const { allowDropdown, showSelectedDialCode, showFlags, countrySearch, i18n } = this.options;
2384
2381
  const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
@@ -2435,7 +2432,7 @@ var factoryOutput = (() => {
2435
2432
  }
2436
2433
  return prevCountry.iso2 !== iso2;
2437
2434
  }
2438
- // update the maximum valid number length for the currently selected country
2435
+ //* Update the maximum valid number length for the currently selected country.
2439
2436
  _updateMaxLength() {
2440
2437
  if (this.options.strictMode && window.intlTelInputUtils) {
2441
2438
  if (this.selectedCountryData.iso2) {
@@ -2472,10 +2469,10 @@ var factoryOutput = (() => {
2472
2469
  }
2473
2470
  this.selectedCountry.setAttribute("title", title);
2474
2471
  }
2475
- // when the input is in a hidden container during initialisation, we must inject some markup
2476
- // into the end of the DOM to calculate the correct offsetWidth
2477
- // NOTE: this is only used when showSelectedDialCode is enabled, so countryContainer and selectedCountry
2478
- // will definitely exist
2472
+ //* When the input is in a hidden container during initialisation, we must inject some markup
2473
+ //* into the end of the DOM to calculate the correct offsetWidth.
2474
+ //* NOTE: this is only used when showSelectedDialCode is enabled, so countryContainer and selectedCountry
2475
+ //* will definitely exist.
2479
2476
  _getHiddenSelectedCountryWidth() {
2480
2477
  if (this.telInput.parentNode) {
2481
2478
  const containerClone = this.telInput.parentNode.cloneNode(false);
@@ -2491,7 +2488,7 @@ var factoryOutput = (() => {
2491
2488
  }
2492
2489
  return 0;
2493
2490
  }
2494
- // update the input placeholder to an example number from the currently selected country
2491
+ //* Update the input placeholder to an example number from the currently selected country.
2495
2492
  _updatePlaceholder() {
2496
2493
  const {
2497
2494
  autoPlaceholder,
@@ -2514,7 +2511,7 @@ var factoryOutput = (() => {
2514
2511
  this.telInput.setAttribute("placeholder", placeholder);
2515
2512
  }
2516
2513
  }
2517
- // called when the user selects a list item from the dropdown
2514
+ //* Called when the user selects a list item from the dropdown.
2518
2515
  _selectListItem(listItem) {
2519
2516
  const countryChanged = this._setCountry(
2520
2517
  listItem.getAttribute("data-country-code")
@@ -2526,7 +2523,7 @@ var factoryOutput = (() => {
2526
2523
  this._triggerCountryChange();
2527
2524
  }
2528
2525
  }
2529
- // close the dropdown and unbind any listeners
2526
+ //* Close the dropdown and unbind any listeners.
2530
2527
  _closeDropdown() {
2531
2528
  this.dropdownContent.classList.add("iti__hide");
2532
2529
  this.selectedCountry.setAttribute("aria-expanded", "false");
@@ -2561,7 +2558,7 @@ var factoryOutput = (() => {
2561
2558
  }
2562
2559
  this._trigger("close:countrydropdown");
2563
2560
  }
2564
- // check if an element is visible within it's container, else scroll until it is
2561
+ //* Check if an element is visible within it's container, else scroll until it is.
2565
2562
  _scrollTo(element, middle) {
2566
2563
  const container = this.countryList;
2567
2564
  const windowTop = document.documentElement.scrollTop;
@@ -2586,8 +2583,8 @@ var factoryOutput = (() => {
2586
2583
  container.scrollTop = newScrollTop - heightDifference;
2587
2584
  }
2588
2585
  }
2589
- // replace any existing dial code with the new one
2590
- // Note: called from _selectListItem and setCountry
2586
+ //* Replace any existing dial code with the new one
2587
+ //* Note: called from _selectListItem and setCountry
2591
2588
  _updateDialCode(newDialCodeBare) {
2592
2589
  const inputVal = this.telInput.value;
2593
2590
  const newDialCode = `+${newDialCodeBare}`;
@@ -2602,8 +2599,8 @@ var factoryOutput = (() => {
2602
2599
  this.telInput.value = newNumber;
2603
2600
  }
2604
2601
  }
2605
- // try and extract a valid international dial code from a full telephone number
2606
- // Note: returns the raw string inc plus character and any whitespace/dots etc
2602
+ //* Try and extract a valid international dial code from a full telephone number.
2603
+ //* Note: returns the raw string inc plus character and any whitespace/dots etc.
2607
2604
  _getDialCode(number, includeAreaCode) {
2608
2605
  let dialCode = "";
2609
2606
  if (number.charAt(0) === "+") {
@@ -2630,7 +2627,7 @@ var factoryOutput = (() => {
2630
2627
  }
2631
2628
  return dialCode;
2632
2629
  }
2633
- // get the input val, adding the dial code if showSelectedDialCode is enabled
2630
+ //* Get the input val, adding the dial code if showSelectedDialCode is enabled.
2634
2631
  _getFullNumber() {
2635
2632
  const val = this.telInput.value.trim();
2636
2633
  const { dialCode } = this.selectedCountryData;
@@ -2643,8 +2640,7 @@ var factoryOutput = (() => {
2643
2640
  }
2644
2641
  return prefix + val;
2645
2642
  }
2646
- // remove the dial code if showSelectedDialCode is enabled
2647
- // also cap the length if the input has a maxlength attribute
2643
+ //* Remove the dial code if showSelectedDialCode is enabled also cap the length if the input has a maxlength attribute
2648
2644
  _beforeSetNumber(fullNumber) {
2649
2645
  let number = fullNumber;
2650
2646
  if (this.options.showSelectedDialCode) {
@@ -2657,11 +2653,11 @@ var factoryOutput = (() => {
2657
2653
  }
2658
2654
  return this._cap(number);
2659
2655
  }
2660
- // trigger the 'countrychange' event
2656
+ //* Trigger the 'countrychange' event.
2661
2657
  _triggerCountryChange() {
2662
2658
  this._trigger("countrychange");
2663
2659
  }
2664
- // format the number as the user types
2660
+ //* Format the number as the user types.
2665
2661
  _formatNumberAsYouType() {
2666
2662
  const val = this._getFullNumber();
2667
2663
  const result = window.intlTelInputUtils ? window.intlTelInputUtils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;
@@ -2675,7 +2671,7 @@ var factoryOutput = (() => {
2675
2671
  //**************************
2676
2672
  //* SECRET PUBLIC METHODS
2677
2673
  //**************************
2678
- // this is called when the geoip call returns
2674
+ //* This is called when the geoip call returns.
2679
2675
  handleAutoCountry() {
2680
2676
  if (this.options.initialCountry === "auto" && window.intlTelInputGlobals.autoCountry) {
2681
2677
  this.defaultCountry = window.intlTelInputGlobals.autoCountry;
@@ -2685,7 +2681,7 @@ var factoryOutput = (() => {
2685
2681
  this.resolveAutoCountryPromise();
2686
2682
  }
2687
2683
  }
2688
- // this is called when the utils request completes
2684
+ //* This is called when the utils request completes.
2689
2685
  handleUtils() {
2690
2686
  if (window.intlTelInputUtils) {
2691
2687
  if (this.telInput.value) {
@@ -2701,7 +2697,7 @@ var factoryOutput = (() => {
2701
2697
  //********************
2702
2698
  //* PUBLIC METHODS
2703
2699
  //********************
2704
- // remove plugin
2700
+ //* Remove plugin.
2705
2701
  destroy() {
2706
2702
  if (this.options.allowDropdown) {
2707
2703
  this._closeDropdown();
@@ -2732,7 +2728,7 @@ var factoryOutput = (() => {
2732
2728
  wrapper?.parentNode?.removeChild(wrapper);
2733
2729
  delete window.intlTelInputGlobals.instances[this.id];
2734
2730
  }
2735
- // get the extension from the current number
2731
+ //* Get the extension from the current number.
2736
2732
  getExtension() {
2737
2733
  if (window.intlTelInputUtils) {
2738
2734
  return window.intlTelInputUtils.getExtension(
@@ -2742,7 +2738,7 @@ var factoryOutput = (() => {
2742
2738
  }
2743
2739
  return "";
2744
2740
  }
2745
- // format the number to the given format
2741
+ //* Format the number to the given format.
2746
2742
  getNumber(format) {
2747
2743
  if (window.intlTelInputUtils) {
2748
2744
  const { iso2 } = this.selectedCountryData;
@@ -2754,7 +2750,7 @@ var factoryOutput = (() => {
2754
2750
  }
2755
2751
  return "";
2756
2752
  }
2757
- // get the type of the entered number e.g. landline/mobile
2753
+ //* Get the type of the entered number e.g. landline/mobile.
2758
2754
  getNumberType() {
2759
2755
  if (window.intlTelInputUtils) {
2760
2756
  return window.intlTelInputUtils.getNumberType(
@@ -2764,11 +2760,11 @@ var factoryOutput = (() => {
2764
2760
  }
2765
2761
  return -99;
2766
2762
  }
2767
- // get the country data for the currently selected country
2763
+ //* Get the country data for the currently selected country.
2768
2764
  getSelectedCountryData() {
2769
2765
  return this.selectedCountryData;
2770
2766
  }
2771
- // get the validation error
2767
+ //* Get the validation error.
2772
2768
  getValidationError() {
2773
2769
  if (window.intlTelInputUtils) {
2774
2770
  const { iso2 } = this.selectedCountryData;
@@ -2776,7 +2772,7 @@ var factoryOutput = (() => {
2776
2772
  }
2777
2773
  return -99;
2778
2774
  }
2779
- // validate the input val - assumes the global function isPossibleNumber (from utilsScript)
2775
+ //* Validate the input val - assumes the global function isPossibleNumber (from utilsScript).
2780
2776
  isValidNumber(mobileOnly = true) {
2781
2777
  const val = this._getFullNumber();
2782
2778
  if (/\p{L}/u.test(val)) {
@@ -2784,7 +2780,7 @@ var factoryOutput = (() => {
2784
2780
  }
2785
2781
  return window.intlTelInputUtils ? window.intlTelInputUtils.isPossibleNumber(val, this.selectedCountryData.iso2, mobileOnly) : null;
2786
2782
  }
2787
- // validate the input val (precise) - assumes the global function isValidNumber (from utilsScript)
2783
+ //* Validate the input val (precise) - assumes the global function isValidNumber (from utilsScript).
2788
2784
  isValidNumberPrecise() {
2789
2785
  const val = this._getFullNumber();
2790
2786
  if (/\p{L}/u.test(val)) {
@@ -2792,7 +2788,7 @@ var factoryOutput = (() => {
2792
2788
  }
2793
2789
  return window.intlTelInputUtils ? window.intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;
2794
2790
  }
2795
- // update the selected country, and update the input val accordingly
2791
+ //* Update the selected country, and update the input val accordingly.
2796
2792
  setCountry(iso2) {
2797
2793
  const iso2Lower = iso2.toLowerCase();
2798
2794
  if (this.selectedCountryData.iso2 !== iso2Lower) {
@@ -2801,7 +2797,7 @@ var factoryOutput = (() => {
2801
2797
  this._triggerCountryChange();
2802
2798
  }
2803
2799
  }
2804
- // set the input value and update the country
2800
+ //* Set the input value and update the country.
2805
2801
  setNumber(number) {
2806
2802
  const countryChanged = this._updateCountryFromNumber(number);
2807
2803
  this._updateValFromNumber(number);
@@ -2809,7 +2805,7 @@ var factoryOutput = (() => {
2809
2805
  this._triggerCountryChange();
2810
2806
  }
2811
2807
  }
2812
- // set the placeholder number typ
2808
+ //* Set the placeholder number typ
2813
2809
  setPlaceholderNumberType(type) {
2814
2810
  this.options.placeholderNumberType = type;
2815
2811
  this._updatePlaceholder();
@@ -2846,19 +2842,19 @@ var factoryOutput = (() => {
2846
2842
  if (typeof window === "object") {
2847
2843
  const intlTelInputGlobals = {
2848
2844
  defaults,
2849
- // using a global like this allows us to mock it in the tests
2845
+ //* Using a global like this allows us to mock it in the tests.
2850
2846
  documentReady: () => document.readyState === "complete",
2851
- // get the country data object
2847
+ //* Get the country data object.
2852
2848
  getCountryData: () => data_default,
2853
- // a getter for the plugin instance
2849
+ //* A getter for the plugin instance.
2854
2850
  getInstance: (input) => {
2855
2851
  const id2 = input.getAttribute("data-intl-tel-input-id");
2856
2852
  return id2 ? intlTelInputGlobals.instances[id2] : null;
2857
2853
  },
2858
- // a map from instance ID to instance object
2854
+ //* A map from instance ID to instance object.
2859
2855
  instances: {},
2860
2856
  loadUtils,
2861
- version: "21.0.9"
2857
+ version: "21.1.0"
2862
2858
  };
2863
2859
  window.intlTelInputGlobals = intlTelInputGlobals;
2864
2860
  }