intl-tel-input 18.1.0 → 18.1.1

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.
Files changed (61) hide show
  1. package/.eslintrc +2 -8
  2. package/.vscode/settings.json +8 -0
  3. package/CHANGELOG.md +3 -0
  4. package/Gruntfile.js +0 -2
  5. package/README.md +14 -25
  6. package/build/js/data.js +1 -1
  7. package/build/js/data.min.js +1 -1
  8. package/build/js/intlTelInput-jquery.js +160 -59
  9. package/build/js/intlTelInput-jquery.min.js +3 -3
  10. package/build/js/intlTelInput.js +160 -59
  11. package/build/js/intlTelInput.min.js +3 -3
  12. package/composer.json +1 -1
  13. package/demo.html +42 -44
  14. package/demo_rtl.html +21 -23
  15. package/grunt/template.js +2 -265
  16. package/package.json +4 -1
  17. package/src/js/intlTelInput.js +563 -333
  18. package/examples/css/countrySync.css +0 -10
  19. package/examples/css/isValidNumber.css +0 -12
  20. package/examples/css/prism.css +0 -126
  21. package/examples/gen/country-sync.html +0 -98
  22. package/examples/gen/default-country-ip.html +0 -62
  23. package/examples/gen/display-number.html +0 -47
  24. package/examples/gen/hidden-input.html +0 -54
  25. package/examples/gen/init-promise.html +0 -66
  26. package/examples/gen/is-valid-number.html +0 -86
  27. package/examples/gen/js/countrySync.js +0 -31
  28. package/examples/gen/js/defaultCountryIp.js +0 -11
  29. package/examples/gen/js/displayNumber.js +0 -4
  30. package/examples/gen/js/hiddenInput.js +0 -5
  31. package/examples/gen/js/initPromise.js +0 -9
  32. package/examples/gen/js/isValidNumber.js +0 -37
  33. package/examples/gen/js/modifyCountryData.js +0 -11
  34. package/examples/gen/js/multipleInstances.js +0 -13
  35. package/examples/gen/js/nationalMode.js +0 -18
  36. package/examples/gen/js/onlyCountriesEurope.js +0 -8
  37. package/examples/gen/modify-country-data.html +0 -52
  38. package/examples/gen/multiple-instances.html +0 -60
  39. package/examples/gen/national-mode.html +0 -63
  40. package/examples/gen/only-countries-europe.html +0 -49
  41. package/examples/js/countrySync.js.ejs +0 -31
  42. package/examples/js/defaultCountryIp.js.ejs +0 -11
  43. package/examples/js/displayNumber.js.ejs +0 -4
  44. package/examples/js/hiddenInput.js.ejs +0 -5
  45. package/examples/js/initPromise.js.ejs +0 -9
  46. package/examples/js/isValidNumber.js.ejs +0 -37
  47. package/examples/js/modifyCountryData.js.ejs +0 -11
  48. package/examples/js/multipleInstances.js.ejs +0 -13
  49. package/examples/js/nationalMode.js.ejs +0 -18
  50. package/examples/js/onlyCountriesEurope.js.ejs +0 -8
  51. package/examples/js/prism.js +0 -11
  52. package/examples/partials/countrySync.html +0 -13
  53. package/examples/partials/defaultCountryIp.html +0 -5
  54. package/examples/partials/displayNumber.html +0 -1
  55. package/examples/partials/hiddenInput.html +0 -4
  56. package/examples/partials/initPromise.html +0 -8
  57. package/examples/partials/isValidNumber.html +0 -3
  58. package/examples/partials/multipleInstances.html +0 -3
  59. package/examples/partials/nationalMode.html +0 -2
  60. package/examples/partials/simpleInput.html +0 -1
  61. package/examples/template.html.ejs +0 -43
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v18.1.0
2
+ * International Telephone Input v18.1.1
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -118,7 +118,9 @@
118
118
  return document.readyState === "complete";
119
119
  }
120
120
  };
121
- if (typeof window === "object") window.intlTelInputGlobals = intlTelInputGlobals;
121
+ if (typeof window === "object") {
122
+ window.intlTelInputGlobals = intlTelInputGlobals;
123
+ }
122
124
  // these vars persist through all instances of the plugin
123
125
  var id = 0;
124
126
  var defaults = {
@@ -147,7 +149,7 @@
147
149
  initialCountry: "",
148
150
  // localized country names e.g. { 'de': 'Deutschland' }
149
151
  localizedCountries: null,
150
- // deal with national numbers instead of international numbers
152
+ // national vs international formatting for numbers e.g. placeholders and displaying existing numbers
151
153
  nationalMode: true,
152
154
  // display only these countries
153
155
  onlyCountries: [],
@@ -202,9 +204,13 @@
202
204
  value: function _init() {
203
205
  var _this2 = this;
204
206
  // if in nationalMode, do not insert dial codes
205
- if (this.options.nationalMode) this.options.autoInsertDialCode = false;
207
+ if (this.options.nationalMode) {
208
+ this.options.autoInsertDialCode = false;
209
+ }
206
210
  // if separateDialCode enabled, do not insert dial codes
207
- if (this.options.separateDialCode) this.options.autoInsertDialCode = false;
211
+ if (this.options.separateDialCode) {
212
+ this.options.autoInsertDialCode = false;
213
+ }
208
214
  // force showFlags=true if there's a dropdown and we're not displaying the dial code,
209
215
  // as otherwise you just have a down arrow on it's own which doesn't make sense
210
216
  var forceShowFlags = this.options.allowDropdown && !this.options.separateDialCode;
@@ -221,7 +227,9 @@
221
227
  // trigger the mobile dropdown css
222
228
  document.body.classList.add("iti-mobile");
223
229
  // on mobile, we want a full screen dropdown, so we must append it to the body
224
- if (!this.options.dropdownContainer) this.options.dropdownContainer = document.body;
230
+ if (!this.options.dropdownContainer) {
231
+ this.options.dropdownContainer = document.body;
232
+ }
225
233
  }
226
234
  // these promises get resolved when their individual requests complete
227
235
  // this way the dev can do something like iti.promise.then(...) to know when all requests are
@@ -265,7 +273,9 @@
265
273
  // process the preferredCountries
266
274
  this._processPreferredCountries();
267
275
  // translate countries according to localizedCountries option
268
- if (this.options.localizedCountries) this._translateCountriesByLocale();
276
+ if (this.options.localizedCountries) {
277
+ this._translateCountriesByLocale();
278
+ }
269
279
  // sort countries by name
270
280
  if (this.options.onlyCountries.length || this.options.localizedCountries) {
271
281
  this.countries.sort(this._countryNameSort);
@@ -282,7 +292,9 @@
282
292
  }
283
293
  // bail if we already have this country for this countryCode
284
294
  for (var i = 0; i < this.countryCodes[countryCode].length; i++) {
285
- if (this.countryCodes[countryCode][i] === iso2) return;
295
+ if (this.countryCodes[countryCode][i] === iso2) {
296
+ return;
297
+ }
286
298
  }
287
299
  // check for undefined as 0 is falsy
288
300
  var index = priority !== undefined ? priority : this.countryCodes[countryCode].length;
@@ -322,8 +334,12 @@
322
334
  }, {
323
335
  key: "_countryNameSort",
324
336
  value: function _countryNameSort(a, b) {
325
- if (a.name < b.name) return -1;
326
- if (a.name > b.name) return 1;
337
+ if (a.name < b.name) {
338
+ return -1;
339
+ }
340
+ if (a.name > b.name) {
341
+ return 1;
342
+ }
327
343
  return 0;
328
344
  }
329
345
  }, {
@@ -337,7 +353,9 @@
337
353
  // first: add dial codes
338
354
  for (var i = 0; i < this.countries.length; i++) {
339
355
  var c = this.countries[i];
340
- if (!this.dialCodes[c.dialCode]) this.dialCodes[c.dialCode] = true;
356
+ if (!this.dialCodes[c.dialCode]) {
357
+ this.dialCodes[c.dialCode] = true;
358
+ }
341
359
  this._addCountryCode(c.iso2, c.dialCode, c.priority);
342
360
  }
343
361
  // next: add area codes
@@ -372,17 +390,23 @@
372
390
  for (var i = 0; i < this.options.preferredCountries.length; i++) {
373
391
  var countryCode = this.options.preferredCountries[i].toLowerCase();
374
392
  var countryData = this._getCountryData(countryCode, false, true);
375
- if (countryData) this.preferredCountries.push(countryData);
393
+ if (countryData) {
394
+ this.preferredCountries.push(countryData);
395
+ }
376
396
  }
377
397
  }
378
398
  }, {
379
399
  key: "_createEl",
380
400
  value: function _createEl(name, attrs, container) {
381
401
  var el = document.createElement(name);
382
- if (attrs) forEachProp(attrs, function(key, value) {
383
- return el.setAttribute(key, value);
384
- });
385
- if (container) container.appendChild(el);
402
+ if (attrs) {
403
+ forEachProp(attrs, function(key, value) {
404
+ return el.setAttribute(key, value);
405
+ });
406
+ }
407
+ if (container) {
408
+ container.appendChild(el);
409
+ }
386
410
  return el;
387
411
  }
388
412
  }, {
@@ -391,16 +415,22 @@
391
415
  // if autocomplete does not exist on the element and its form, then
392
416
  // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can
393
417
  // easily put the plugin in an inconsistent state e.g. the wrong flag selected for the
394
- // autocompleted number, which on submit could mean wrong number is saved (esp in nationalMode)
418
+ // autocompleted number, which on submit could mean wrong number is saved
395
419
  if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
396
420
  this.telInput.setAttribute("autocomplete", "off");
397
421
  }
398
422
  var _this$options = this.options, allowDropdown = _this$options.allowDropdown, separateDialCode = _this$options.separateDialCode, showFlags = _this$options.showFlags, customContainer = _this$options.customContainer, hiddenInput = _this$options.hiddenInput, dropdownContainer = _this$options.dropdownContainer;
399
423
  // containers (mostly for positioning)
400
424
  var parentClass = "iti";
401
- if (allowDropdown) parentClass += " iti--allow-dropdown";
402
- if (separateDialCode) parentClass += " iti--separate-dial-code";
403
- if (showFlags) parentClass += " iti--show-flags";
425
+ if (allowDropdown) {
426
+ parentClass += " iti--allow-dropdown";
427
+ }
428
+ if (separateDialCode) {
429
+ parentClass += " iti--separate-dial-code";
430
+ }
431
+ if (showFlags) {
432
+ parentClass += " iti--show-flags";
433
+ }
404
434
  if (customContainer) {
405
435
  parentClass += " ".concat(customContainer);
406
436
  }
@@ -485,7 +515,9 @@
485
515
  var i = name.lastIndexOf("[");
486
516
  // if input name contains square brackets, then give the hidden input the same name,
487
517
  // replacing the contents of the last set of brackets with the given hiddenInput name
488
- if (i !== -1) hiddenInputName = "".concat(name.substr(0, i), "[").concat(hiddenInputName, "]");
518
+ if (i !== -1) {
519
+ hiddenInputName = "".concat(name.substr(0, i), "[").concat(hiddenInputName, "]");
520
+ }
489
521
  }
490
522
  this.hiddenInput = this._createEl("input", {
491
523
  type: "hidden",
@@ -558,15 +590,23 @@
558
590
  }
559
591
  // NOTE: if initialCountry is set to auto, that will be handled separately
560
592
  // format - note this wont be run after _updateDialCode as that's only called if no val
561
- if (val) this._updateValFromNumber(val);
593
+ if (val) {
594
+ this._updateValFromNumber(val);
595
+ }
562
596
  }
563
597
  }, {
564
598
  key: "_initListeners",
565
599
  value: function _initListeners() {
566
600
  this._initKeyListeners();
567
- if (this.options.autoInsertDialCode) this._initBlurListeners();
568
- if (this.options.allowDropdown) this._initDropdownListeners();
569
- if (this.hiddenInput) this._initHiddenInputListener();
601
+ if (this.options.autoInsertDialCode) {
602
+ this._initBlurListeners();
603
+ }
604
+ if (this.options.allowDropdown) {
605
+ this._initDropdownListeners();
606
+ }
607
+ if (this.hiddenInput) {
608
+ this._initHiddenInputListener();
609
+ }
570
610
  }
571
611
  }, {
572
612
  key: "_initHiddenInputListener",
@@ -575,7 +615,9 @@
575
615
  this._handleHiddenInputSubmit = function() {
576
616
  _this3.hiddenInput.value = _this3.getNumber();
577
617
  };
578
- if (this.telInput.form) this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
618
+ if (this.telInput.form) {
619
+ this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
620
+ }
579
621
  }
580
622
  }, {
581
623
  key: "_getClosestLabel",
@@ -595,10 +637,16 @@
595
637
  // close it again
596
638
  this._handleLabelClick = function(e) {
597
639
  // if the dropdown is closed, then focus the input, else ignore the click
598
- if (_this4.countryList.classList.contains("iti__hide")) _this4.telInput.focus(); else e.preventDefault();
640
+ if (_this4.countryList.classList.contains("iti__hide")) {
641
+ _this4.telInput.focus();
642
+ } else {
643
+ e.preventDefault();
644
+ }
599
645
  };
600
646
  var label = this._getClosestLabel();
601
- if (label) label.addEventListener("click", this._handleLabelClick);
647
+ if (label) {
648
+ label.addEventListener("click", this._handleLabelClick);
649
+ }
602
650
  // toggle country dropdown on click
603
651
  this._handleClickSelectedFlag = function() {
604
652
  // only intercept this event if we're opening the dropdown
@@ -620,7 +668,9 @@
620
668
  _this4._showDropdown();
621
669
  }
622
670
  // allow navigation from dropdown to input on TAB
623
- if (e.key === "Tab") _this4._closeDropdown();
671
+ if (e.key === "Tab") {
672
+ _this4._closeDropdown();
673
+ }
624
674
  };
625
675
  this.flagsContainer.addEventListener("keydown", this._handleFlagsContainerKeydown);
626
676
  }
@@ -639,8 +689,14 @@
639
689
  window.intlTelInputGlobals.loadUtils(_this5.options.utilsScript);
640
690
  });
641
691
  }
642
- } else this.resolveUtilsScriptPromise();
643
- if (this.options.initialCountry === "auto") this._loadAutoCountry(); else this.resolveAutoCountryPromise();
692
+ } else {
693
+ this.resolveUtilsScriptPromise();
694
+ }
695
+ if (this.options.initialCountry === "auto") {
696
+ this._loadAutoCountry();
697
+ } else {
698
+ this.resolveAutoCountryPromise();
699
+ }
644
700
  }
645
701
  }, {
646
702
  key: "_loadAutoCountry",
@@ -705,7 +761,9 @@
705
761
  this._handleSubmitOrBlurEvent = function() {
706
762
  _this7._removeEmptyDialCode();
707
763
  };
708
- if (this.telInput.form) this.telInput.form.addEventListener("submit", this._handleSubmitOrBlurEvent);
764
+ if (this.telInput.form) {
765
+ this.telInput.form.addEventListener("submit", this._handleSubmitOrBlurEvent);
766
+ }
709
767
  this.telInput.addEventListener("blur", this._handleSubmitOrBlurEvent);
710
768
  }
711
769
  }, {
@@ -753,7 +811,11 @@
753
811
  }, {
754
812
  key: "_toggleClass",
755
813
  value: function _toggleClass(el, className, shouldHaveClass) {
756
- if (shouldHaveClass && !el.classList.contains(className)) el.classList.add(className); else if (!shouldHaveClass && el.classList.contains(className)) el.classList.remove(className);
814
+ if (shouldHaveClass && !el.classList.contains(className)) {
815
+ el.classList.add(className);
816
+ } else if (!shouldHaveClass && el.classList.contains(className)) {
817
+ el.classList.remove(className);
818
+ }
757
819
  }
758
820
  }, {
759
821
  key: "_setDropdownPosition",
@@ -809,13 +871,17 @@
809
871
  this._handleMouseoverCountryList = function(e) {
810
872
  // handle event delegation, as we're listening for this event on the countryList
811
873
  var listItem = _this9._getClosestListItem(e.target);
812
- if (listItem) _this9._highlightListItem(listItem, false);
874
+ if (listItem) {
875
+ _this9._highlightListItem(listItem, false);
876
+ }
813
877
  };
814
878
  this.countryList.addEventListener("mouseover", this._handleMouseoverCountryList);
815
879
  // listen for country selection
816
880
  this._handleClickCountryList = function(e) {
817
881
  var listItem = _this9._getClosestListItem(e.target);
818
- if (listItem) _this9._selectListItem(listItem);
882
+ if (listItem) {
883
+ _this9._selectListItem(listItem);
884
+ }
819
885
  };
820
886
  this.countryList.addEventListener("click", this._handleClickCountryList);
821
887
  // click off to close
@@ -823,7 +889,9 @@
823
889
  // we cannot just stopPropagation as it may be needed to close another instance
824
890
  var isOpening = true;
825
891
  this._handleClickOffToClose = function() {
826
- if (!isOpening) _this9._closeDropdown();
892
+ if (!isOpening) {
893
+ _this9._closeDropdown();
894
+ }
827
895
  isOpening = false;
828
896
  };
829
897
  document.documentElement.addEventListener("click", this._handleClickOffToClose);
@@ -838,9 +906,17 @@
838
906
  // and enter key from submitting a form etc
839
907
  e.preventDefault();
840
908
  // up and down to navigate
841
- if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down") _this9._handleUpDownKey(e.key); else if (e.key === "Enter") _this9._handleEnterKey(); else if (e.key === "Escape") _this9._closeDropdown(); else if (/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
909
+ if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down") {
910
+ _this9._handleUpDownKey(e.key);
911
+ } else if (e.key === "Enter") {
912
+ _this9._handleEnterKey();
913
+ } else if (e.key === "Escape") {
914
+ _this9._closeDropdown();
915
+ } else if (/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
842
916
  // jump to countries that start with the query string
843
- if (queryTimer) clearTimeout(queryTimer);
917
+ if (queryTimer) {
918
+ clearTimeout(queryTimer);
919
+ }
844
920
  query += e.key.toLowerCase();
845
921
  _this9._searchForCountry(query);
846
922
  // if the timer hits 1 second, reset the query
@@ -866,7 +942,9 @@
866
942
  }, {
867
943
  key: "_handleEnterKey",
868
944
  value: function _handleEnterKey() {
869
- if (this.highlightedItem) this._selectListItem(this.highlightedItem);
945
+ if (this.highlightedItem) {
946
+ this._selectListItem(this.highlightedItem);
947
+ }
870
948
  }
871
949
  }, {
872
950
  key: "_searchForCountry",
@@ -902,7 +980,7 @@
902
980
  }, {
903
981
  key: "_updateFlagFromNumber",
904
982
  value: function _updateFlagFromNumber(originalNumber) {
905
- // if we're in nationalMode and we already have US/Canada selected, make sure the number starts
983
+ // if we already have US/Canada selected, make sure the number starts
906
984
  // with a +1 so _getDialCode will be able to extract the area code
907
985
  // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag
908
986
  // from the number), that means we're initialising the plugin with a number that already has a
@@ -910,8 +988,10 @@
910
988
  var number = originalNumber;
911
989
  var selectedDialCode = this.selectedCountryData.dialCode;
912
990
  var isNanp = selectedDialCode === "1";
913
- if (number && this.options.nationalMode && isNanp && number.charAt(0) !== "+") {
914
- if (number.charAt(0) !== "1") number = "1".concat(number);
991
+ if (number && isNanp && number.charAt(0) !== "+") {
992
+ if (number.charAt(0) !== "1") {
993
+ number = "1".concat(number);
994
+ }
915
995
  number = "+".concat(number);
916
996
  }
917
997
  // if separateDialCode enabled, then consider the selected dial code to be part of the number
@@ -972,11 +1052,15 @@
972
1052
  key: "_highlightListItem",
973
1053
  value: function _highlightListItem(listItem, shouldFocus) {
974
1054
  var prevItem = this.highlightedItem;
975
- if (prevItem) prevItem.classList.remove("iti__highlight");
1055
+ if (prevItem) {
1056
+ prevItem.classList.remove("iti__highlight");
1057
+ }
976
1058
  this.highlightedItem = listItem;
977
1059
  this.highlightedItem.classList.add("iti__highlight");
978
1060
  this.selectedFlag.setAttribute("aria-activedescendant", listItem.getAttribute("id"));
979
- if (shouldFocus) this.highlightedItem.focus();
1061
+ if (shouldFocus) {
1062
+ this.highlightedItem.focus();
1063
+ }
980
1064
  }
981
1065
  }, {
982
1066
  key: "_getCountryData",
@@ -1077,8 +1161,8 @@
1077
1161
  this._updateDialCode(listItem.getAttribute("data-dial-code"));
1078
1162
  // focus the input
1079
1163
  this.telInput.focus();
1080
- // put cursor at end - this fix is required for FF and IE11 (with nationalMode=false i.e. auto
1081
- // inserting dial code), who try to put the cursor at the beginning the first time
1164
+ // put cursor at end - this fix is required for FF and IE11 (with auto inserting dial code),
1165
+ // who try to put the cursor at the beginning the first time
1082
1166
  var len = this.telInput.value.length;
1083
1167
  this.telInput.setSelectionRange(len, len);
1084
1168
  if (flagChanged) {
@@ -1100,8 +1184,12 @@
1100
1184
  this.countryList.removeEventListener("click", this._handleClickCountryList);
1101
1185
  // remove menu from container
1102
1186
  if (this.options.dropdownContainer) {
1103
- if (!this.isMobile) window.removeEventListener("scroll", this._handleWindowScroll);
1104
- if (this.dropdown.parentNode) this.dropdown.parentNode.removeChild(this.dropdown);
1187
+ if (!this.isMobile) {
1188
+ window.removeEventListener("scroll", this._handleWindowScroll);
1189
+ }
1190
+ if (this.dropdown.parentNode) {
1191
+ this.dropdown.parentNode.removeChild(this.dropdown);
1192
+ }
1105
1193
  }
1106
1194
  this._trigger("close:countrydropdown");
1107
1195
  }
@@ -1121,11 +1209,15 @@
1121
1209
  var middleOffset = containerHeight / 2 - elementHeight / 2;
1122
1210
  if (elementTop < containerTop) {
1123
1211
  // scroll up
1124
- if (middle) newScrollTop -= middleOffset;
1212
+ if (middle) {
1213
+ newScrollTop -= middleOffset;
1214
+ }
1125
1215
  container.scrollTop = newScrollTop;
1126
1216
  } else if (elementBottom > containerBottom) {
1127
1217
  // scroll down
1128
- if (middle) newScrollTop += middleOffset;
1218
+ if (middle) {
1219
+ newScrollTop += middleOffset;
1220
+ }
1129
1221
  var heightDifference = containerHeight - elementHeight;
1130
1222
  container.scrollTop = newScrollTop - heightDifference;
1131
1223
  }
@@ -1138,7 +1230,7 @@
1138
1230
  var newDialCode = "+".concat(newDialCodeBare);
1139
1231
  var newNumber;
1140
1232
  if (inputVal.charAt(0) === "+") {
1141
- // there's a plus so we're dealing with a replacement (doesn't matter if nationalMode or not)
1233
+ // there's a plus so we're dealing with a replacement
1142
1234
  var prevDialCode = this._getDialCode(inputVal);
1143
1235
  if (prevDialCode) {
1144
1236
  // current number contains a valid dial code, so replace it
@@ -1272,13 +1364,19 @@
1272
1364
  this.flagsContainer.removeEventListener("keydown", this._handleFlagsContainerKeydown);
1273
1365
  // label click hack
1274
1366
  var label = this._getClosestLabel();
1275
- if (label) label.removeEventListener("click", this._handleLabelClick);
1367
+ if (label) {
1368
+ label.removeEventListener("click", this._handleLabelClick);
1369
+ }
1276
1370
  }
1277
1371
  // unbind hiddenInput listeners
1278
- if (this.hiddenInput && form) form.removeEventListener("submit", this._handleHiddenInputSubmit);
1372
+ if (this.hiddenInput && form) {
1373
+ form.removeEventListener("submit", this._handleHiddenInputSubmit);
1374
+ }
1279
1375
  // unbind autoInsertDialCode listeners
1280
1376
  if (this.options.autoInsertDialCode) {
1281
- if (form) form.removeEventListener("submit", this._handleSubmitOrBlurEvent);
1377
+ if (form) {
1378
+ form.removeEventListener("submit", this._handleSubmitOrBlurEvent);
1379
+ }
1282
1380
  this.telInput.removeEventListener("blur", this._handleSubmitOrBlurEvent);
1283
1381
  }
1284
1382
  // unbind key events, and cut/paste events
@@ -1336,8 +1434,7 @@
1336
1434
  key: "isValidNumber",
1337
1435
  value: function isValidNumber() {
1338
1436
  var val = this._getFullNumber().trim();
1339
- var countryCode = this.options.nationalMode ? this.selectedCountryData.iso2 : "";
1340
- return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null;
1437
+ return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;
1341
1438
  }
1342
1439
  }, {
1343
1440
  key: "setCountry",
@@ -1383,11 +1480,15 @@
1383
1480
  var script = document.createElement("script");
1384
1481
  script.onload = function() {
1385
1482
  forEachInstance("handleUtils");
1386
- if (handleSuccess) handleSuccess();
1483
+ if (handleSuccess) {
1484
+ handleSuccess();
1485
+ }
1387
1486
  };
1388
1487
  script.onerror = function() {
1389
1488
  forEachInstance("rejectUtilsScriptPromise");
1390
- if (handleFailure) handleFailure();
1489
+ if (handleFailure) {
1490
+ handleFailure();
1491
+ }
1391
1492
  };
1392
1493
  script.className = "iti-load-utils";
1393
1494
  script.async = true;
@@ -1416,7 +1517,7 @@
1416
1517
  // default options
1417
1518
  intlTelInputGlobals.defaults = defaults;
1418
1519
  // version
1419
- intlTelInputGlobals.version = "18.1.0";
1520
+ intlTelInputGlobals.version = "18.1.1";
1420
1521
  var pluginName = "intlTelInput";
1421
1522
  // A really lightweight plugin wrapper around the constructor,
1422
1523
  // preventing against multiple instantiations