intl-tel-input 25.8.5 → 25.10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "25.8.5",
3
+ "version": "25.10.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
@@ -100,17 +100,18 @@
100
100
  "lint:spelling": "cspell --dot --gitignore --no-progress '**'",
101
101
  "watch": "grunt watch",
102
102
  "build": "grunt build",
103
- "prepublishOnly": "grunt build",
104
- "build:js": "grunt js",
105
- "build:jsfast": "grunt jsfast",
103
+ "build:js": "grunt build:js",
104
+ "build:jsfast": "grunt build:jsfast",
106
105
  "build:translations": "grunt build:translations",
107
106
  "build:utils": "grunt build:utils",
108
- "build:css": "grunt css",
109
- "build:img": "grunt img",
110
- "build:react": "grunt react",
111
- "build:vue": "grunt vue",
112
- "build:angular": "grunt angular",
113
- "vue:demo": "vite --config vue/demo/validation/vite.config.js"
107
+ "build:css": "grunt build:css",
108
+ "build:img": "grunt build:img",
109
+ "build:react": "grunt build:react",
110
+ "build:vue": "grunt build:vue",
111
+ "build:angular": "grunt build:angular",
112
+ "build:travis": "grunt build:travis",
113
+ "prepublishOnly": "grunt build",
114
+ "vue:demo": "vite --config vue/demo/validation/vite.config.js"
114
115
  },
115
116
  "style": "build/css/intlTelInput.css",
116
117
  "main": "./build/js/intlTelInput.js",
package/react/README.md CHANGED
@@ -28,7 +28,7 @@ import "intl-tel-input/styles";
28
28
 
29
29
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
30
30
 
31
- 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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.5/build/js/utils.js"`.
31
+ 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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.10.0/build/js/utils.js"`.
32
32
 
33
33
  ## Props
34
34
  Here's a list of all of the current props you can pass to the IntlTelInput React component.
@@ -1624,7 +1624,7 @@ var countries_default = countryTranslations;
1624
1624
 
1625
1625
  // src/js/intl-tel-input/i18n/en/interface.ts
1626
1626
  var interfaceTranslations = {
1627
- selectedCountryAriaLabel: "Change country, selected ${country}",
1627
+ selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
1628
1628
  noCountrySelected: "Select country",
1629
1629
  countryListAriaLabel: "List of countries",
1630
1630
  searchPlaceholder: "Search",
@@ -1661,6 +1661,8 @@ var computeDefaultUseFullscreenPopup = () => {
1661
1661
  return false;
1662
1662
  };
1663
1663
  var defaults = {
1664
+ // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1665
+ allowPhonewords: false,
1664
1666
  //* Whether or not to allow the dropdown.
1665
1667
  allowDropdown: true,
1666
1668
  //* Add a placeholder in the input with an example number for the selected country.
@@ -2768,7 +2770,7 @@ var Iti = class _Iti {
2768
2770
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2769
2771
  _setCountry(iso2) {
2770
2772
  const { separateDialCode, showFlags, i18n } = this.options;
2771
- const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2773
+ const prevIso2 = this.selectedCountryData.iso2 || "";
2772
2774
  this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2773
2775
  if (this.selectedCountryData.iso2) {
2774
2776
  this.defaultCountry = this.selectedCountryData.iso2;
@@ -2777,8 +2779,9 @@ var Iti = class _Iti {
2777
2779
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
2778
2780
  let ariaLabel, title;
2779
2781
  if (iso2) {
2780
- title = this.selectedCountryData.name;
2781
- ariaLabel = i18n.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name);
2782
+ const { name, dialCode } = this.selectedCountryData;
2783
+ title = name;
2784
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
2782
2785
  } else {
2783
2786
  title = i18n.noCountrySelected;
2784
2787
  ariaLabel = i18n.noCountrySelected;
@@ -2794,7 +2797,7 @@ var Iti = class _Iti {
2794
2797
  }
2795
2798
  this._updatePlaceholder();
2796
2799
  this._updateMaxLength();
2797
- return prevCountry.iso2 !== iso2;
2800
+ return prevIso2 !== iso2;
2798
2801
  }
2799
2802
  //* Update the input padding to make space for the selected country/dial code.
2800
2803
  _updateInputPadding() {
@@ -3163,10 +3166,11 @@ var Iti = class _Iti {
3163
3166
  if (!this.selectedCountryData.iso2) {
3164
3167
  return false;
3165
3168
  }
3169
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3166
3170
  const val = this._getFullNumber();
3167
3171
  const alphaCharPosition = val.search(/\p{L}/u);
3168
- const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3169
- if (alphaCharPosition > -1) {
3172
+ const hasAlphaChar = alphaCharPosition > -1;
3173
+ if (hasAlphaChar && !this.options.allowPhonewords) {
3170
3174
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
3171
3175
  const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3172
3176
  const isValid = testValidity(val);
@@ -3267,7 +3271,7 @@ var intlTelInput = Object.assign(
3267
3271
  attachUtils,
3268
3272
  startedLoadingUtilsScript: false,
3269
3273
  startedLoadingAutoCountry: false,
3270
- version: "25.8.5"
3274
+ version: "25.10.0"
3271
3275
  }
3272
3276
  );
3273
3277
  var intl_tel_input_default = intlTelInput;
@@ -346,6 +346,7 @@ declare module "intl-tel-input" {
346
346
  };
347
347
  interface AllOptions {
348
348
  allowDropdown: boolean;
349
+ allowPhonewords: boolean;
349
350
  autoPlaceholder: string;
350
351
  containerClass: string;
351
352
  countryOrder: string[];
@@ -1588,7 +1588,7 @@ var countries_default = countryTranslations;
1588
1588
 
1589
1589
  // src/js/intl-tel-input/i18n/en/interface.ts
1590
1590
  var interfaceTranslations = {
1591
- selectedCountryAriaLabel: "Change country, selected ${country}",
1591
+ selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
1592
1592
  noCountrySelected: "Select country",
1593
1593
  countryListAriaLabel: "List of countries",
1594
1594
  searchPlaceholder: "Search",
@@ -1625,6 +1625,8 @@ var computeDefaultUseFullscreenPopup = () => {
1625
1625
  return false;
1626
1626
  };
1627
1627
  var defaults = {
1628
+ // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1629
+ allowPhonewords: false,
1628
1630
  //* Whether or not to allow the dropdown.
1629
1631
  allowDropdown: true,
1630
1632
  //* Add a placeholder in the input with an example number for the selected country.
@@ -2732,7 +2734,7 @@ var Iti = class _Iti {
2732
2734
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2733
2735
  _setCountry(iso2) {
2734
2736
  const { separateDialCode, showFlags, i18n } = this.options;
2735
- const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2737
+ const prevIso2 = this.selectedCountryData.iso2 || "";
2736
2738
  this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2737
2739
  if (this.selectedCountryData.iso2) {
2738
2740
  this.defaultCountry = this.selectedCountryData.iso2;
@@ -2741,8 +2743,9 @@ var Iti = class _Iti {
2741
2743
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
2742
2744
  let ariaLabel, title;
2743
2745
  if (iso2) {
2744
- title = this.selectedCountryData.name;
2745
- ariaLabel = i18n.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name);
2746
+ const { name, dialCode } = this.selectedCountryData;
2747
+ title = name;
2748
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
2746
2749
  } else {
2747
2750
  title = i18n.noCountrySelected;
2748
2751
  ariaLabel = i18n.noCountrySelected;
@@ -2758,7 +2761,7 @@ var Iti = class _Iti {
2758
2761
  }
2759
2762
  this._updatePlaceholder();
2760
2763
  this._updateMaxLength();
2761
- return prevCountry.iso2 !== iso2;
2764
+ return prevIso2 !== iso2;
2762
2765
  }
2763
2766
  //* Update the input padding to make space for the selected country/dial code.
2764
2767
  _updateInputPadding() {
@@ -3127,10 +3130,11 @@ var Iti = class _Iti {
3127
3130
  if (!this.selectedCountryData.iso2) {
3128
3131
  return false;
3129
3132
  }
3133
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3130
3134
  const val = this._getFullNumber();
3131
3135
  const alphaCharPosition = val.search(/\p{L}/u);
3132
- const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3133
- if (alphaCharPosition > -1) {
3136
+ const hasAlphaChar = alphaCharPosition > -1;
3137
+ if (hasAlphaChar && !this.options.allowPhonewords) {
3134
3138
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
3135
3139
  const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3136
3140
  const isValid = testValidity(val);
@@ -3231,7 +3235,7 @@ var intlTelInput = Object.assign(
3231
3235
  attachUtils,
3232
3236
  startedLoadingUtilsScript: false,
3233
3237
  startedLoadingAutoCountry: false,
3234
- version: "25.8.5"
3238
+ version: "25.10.0"
3235
3239
  }
3236
3240
  );
3237
3241
  var intl_tel_input_default = intlTelInput;
@@ -1624,7 +1624,7 @@ var countries_default = countryTranslations;
1624
1624
 
1625
1625
  // src/js/intl-tel-input/i18n/en/interface.ts
1626
1626
  var interfaceTranslations = {
1627
- selectedCountryAriaLabel: "Change country, selected ${country}",
1627
+ selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
1628
1628
  noCountrySelected: "Select country",
1629
1629
  countryListAriaLabel: "List of countries",
1630
1630
  searchPlaceholder: "Search",
@@ -1661,6 +1661,8 @@ var computeDefaultUseFullscreenPopup = () => {
1661
1661
  return false;
1662
1662
  };
1663
1663
  var defaults = {
1664
+ // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1665
+ allowPhonewords: false,
1664
1666
  //* Whether or not to allow the dropdown.
1665
1667
  allowDropdown: true,
1666
1668
  //* Add a placeholder in the input with an example number for the selected country.
@@ -2768,7 +2770,7 @@ var Iti = class _Iti {
2768
2770
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2769
2771
  _setCountry(iso2) {
2770
2772
  const { separateDialCode, showFlags, i18n } = this.options;
2771
- const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2773
+ const prevIso2 = this.selectedCountryData.iso2 || "";
2772
2774
  this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2773
2775
  if (this.selectedCountryData.iso2) {
2774
2776
  this.defaultCountry = this.selectedCountryData.iso2;
@@ -2777,8 +2779,9 @@ var Iti = class _Iti {
2777
2779
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
2778
2780
  let ariaLabel, title;
2779
2781
  if (iso2) {
2780
- title = this.selectedCountryData.name;
2781
- ariaLabel = i18n.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name);
2782
+ const { name, dialCode } = this.selectedCountryData;
2783
+ title = name;
2784
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
2782
2785
  } else {
2783
2786
  title = i18n.noCountrySelected;
2784
2787
  ariaLabel = i18n.noCountrySelected;
@@ -2794,7 +2797,7 @@ var Iti = class _Iti {
2794
2797
  }
2795
2798
  this._updatePlaceholder();
2796
2799
  this._updateMaxLength();
2797
- return prevCountry.iso2 !== iso2;
2800
+ return prevIso2 !== iso2;
2798
2801
  }
2799
2802
  //* Update the input padding to make space for the selected country/dial code.
2800
2803
  _updateInputPadding() {
@@ -3163,10 +3166,11 @@ var Iti = class _Iti {
3163
3166
  if (!this.selectedCountryData.iso2) {
3164
3167
  return false;
3165
3168
  }
3169
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3166
3170
  const val = this._getFullNumber();
3167
3171
  const alphaCharPosition = val.search(/\p{L}/u);
3168
- const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3169
- if (alphaCharPosition > -1) {
3172
+ const hasAlphaChar = alphaCharPosition > -1;
3173
+ if (hasAlphaChar && !this.options.allowPhonewords) {
3170
3174
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
3171
3175
  const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3172
3176
  const isValid = testValidity(val);
@@ -3267,7 +3271,7 @@ var intlTelInput = Object.assign(
3267
3271
  attachUtils,
3268
3272
  startedLoadingUtilsScript: false,
3269
3273
  startedLoadingAutoCountry: false,
3270
- version: "25.8.5"
3274
+ version: "25.10.0"
3271
3275
  }
3272
3276
  );
3273
3277
  var intl_tel_input_default = intlTelInput;
@@ -1588,7 +1588,7 @@ var countries_default = countryTranslations;
1588
1588
 
1589
1589
  // src/js/intl-tel-input/i18n/en/interface.ts
1590
1590
  var interfaceTranslations = {
1591
- selectedCountryAriaLabel: "Change country, selected ${country}",
1591
+ selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
1592
1592
  noCountrySelected: "Select country",
1593
1593
  countryListAriaLabel: "List of countries",
1594
1594
  searchPlaceholder: "Search",
@@ -1625,6 +1625,8 @@ var computeDefaultUseFullscreenPopup = () => {
1625
1625
  return false;
1626
1626
  };
1627
1627
  var defaults = {
1628
+ // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1629
+ allowPhonewords: false,
1628
1630
  //* Whether or not to allow the dropdown.
1629
1631
  allowDropdown: true,
1630
1632
  //* Add a placeholder in the input with an example number for the selected country.
@@ -2732,7 +2734,7 @@ var Iti = class _Iti {
2732
2734
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2733
2735
  _setCountry(iso2) {
2734
2736
  const { separateDialCode, showFlags, i18n } = this.options;
2735
- const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2737
+ const prevIso2 = this.selectedCountryData.iso2 || "";
2736
2738
  this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2737
2739
  if (this.selectedCountryData.iso2) {
2738
2740
  this.defaultCountry = this.selectedCountryData.iso2;
@@ -2741,8 +2743,9 @@ var Iti = class _Iti {
2741
2743
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
2742
2744
  let ariaLabel, title;
2743
2745
  if (iso2) {
2744
- title = this.selectedCountryData.name;
2745
- ariaLabel = i18n.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name);
2746
+ const { name, dialCode } = this.selectedCountryData;
2747
+ title = name;
2748
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
2746
2749
  } else {
2747
2750
  title = i18n.noCountrySelected;
2748
2751
  ariaLabel = i18n.noCountrySelected;
@@ -2758,7 +2761,7 @@ var Iti = class _Iti {
2758
2761
  }
2759
2762
  this._updatePlaceholder();
2760
2763
  this._updateMaxLength();
2761
- return prevCountry.iso2 !== iso2;
2764
+ return prevIso2 !== iso2;
2762
2765
  }
2763
2766
  //* Update the input padding to make space for the selected country/dial code.
2764
2767
  _updateInputPadding() {
@@ -3127,10 +3130,11 @@ var Iti = class _Iti {
3127
3130
  if (!this.selectedCountryData.iso2) {
3128
3131
  return false;
3129
3132
  }
3133
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3130
3134
  const val = this._getFullNumber();
3131
3135
  const alphaCharPosition = val.search(/\p{L}/u);
3132
- const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3133
- if (alphaCharPosition > -1) {
3136
+ const hasAlphaChar = alphaCharPosition > -1;
3137
+ if (hasAlphaChar && !this.options.allowPhonewords) {
3134
3138
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
3135
3139
  const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3136
3140
  const isValid = testValidity(val);
@@ -3231,7 +3235,7 @@ var intlTelInput = Object.assign(
3231
3235
  attachUtils,
3232
3236
  startedLoadingUtilsScript: false,
3233
3237
  startedLoadingAutoCountry: false,
3234
- version: "25.8.5"
3238
+ version: "25.10.0"
3235
3239
  }
3236
3240
  );
3237
3241
  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.5/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.10.0/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.