intl-tel-input 24.3.1 → 24.3.2

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/build/js/utils.js CHANGED
@@ -518,12 +518,12 @@ function vb(a){for(var b=a.g.toString(),c=a.j.length,d=0;d<c;++d){var e=a.j[d],f
518
518
  function tb(a){var b=a.g.toString();if(3<=b.length){for(var c=a.ca&&0==a.o.length&&0<x(a.l,20)?u(a.l,20):u(a.l,19),d=c.length,e=0;e<d;++e){var f=c[e];0<a.o.length&&Za(w(f,4))&&!r(f,6)&&!q(f,5)||(0!=a.o.length||a.ca||Za(w(f,4))||r(f,6))&&kb.test(w(f,2))&&a.j.push(f)}nb(a,b);b=vb(a);return 0<b.length?b:mb(a)?wb(a):a.s.toString()}return Y(a,b)}function wb(a){var b=a.g.toString(),c=b.length;if(0<c){for(var d="",e=0;e<c;e++)d=ub(a,b.charAt(e));return a.u?Y(a,d):a.s.toString()}return a.h.toString()}
519
519
  function sb(a){var b=a.g.toString(),c=0;if(1!=r(a.l,10))var d=!1;else d=a.g.toString(),d="1"==d.charAt(0)&&"0"!=d.charAt(1)&&"1"!=d.charAt(1);d?(c=1,a.h.g("1").g(" "),a.ca=!0):q(a.l,15)&&(d=new RegExp("^(?:"+r(a.l,15)+")"),d=b.match(d),null!=d&&null!=d[0]&&0<d[0].length&&(a.ca=!0,c=d[0].length,a.h.g(b.substring(0,c))));D(a.g);a.g.g(b.substring(c));return b.substring(0,c)}
520
520
  function pb(a){var b=a.ba.toString(),c=new RegExp("^(?:\\+|"+r(a.l,11)+")");c=b.match(c);return null!=c&&null!=c[0]&&0<c[0].length?(a.ca=!0,c=c[0].length,D(a.g),a.g.g(b.substring(c)),D(a.h),a.h.g(b.substring(0,c)),"+"!=b.charAt(0)&&a.h.g(" "),!0):!1}function qb(a){if(0==a.g.h.length)return!1;var b=new C,c=db(a.g,b);if(0==c)return!1;D(a.g);a.g.g(b.toString());b=R(c);"001"==b?a.l=S(a.ga,""+c):b!=a.ka&&(a.l=ib(a,b));a.h.g(""+c).g(" ");a.o="";return!0}
521
- function ub(a,b){var c=a.v.toString();if(0<=c.substring(a.$).search(a.fa)){var d=c.search(a.fa);b=c.replace(a.fa,b);D(a.v);a.v.g(b);a.$=d;return b.substring(0,a.$+1)}1==a.j.length&&(a.u=!1);a.da="";return a.s.toString()};const Z={FIXED_LINE:0,MOBILE:1,FIXED_LINE_OR_MOBILE:2,TOLL_FREE:3,PREMIUM_RATE:4,SHARED_COST:5,VOIP:6,PERSONAL_NUMBER:7,PAGER:8,UAN:9,VOICEMAIL:10,UNKNOWN:-1};m("intlTelInputUtilsTemp",{});m("intlTelInputUtilsTemp.formatNumberAsYouType",(a,b)=>{try{const c=a.replace(/[^+0-9]/g,""),d=new hb(b);b="";for(let e=0;e<c.length;e++)d.ja=ob(d,c.charAt(e)),b=d.ja;return b}catch(c){return a}});
522
- m("intlTelInputUtilsTemp.formatNumber",(a,b,c)=>{try{const e=J.g(),f=X(e,a,b);var d=W(e,f,-1);return 0==d||4==d?e.format(f,"undefined"===typeof c?0:c):a}catch(e){return a}});m("intlTelInputUtilsTemp.getExampleNumber",(a,b,c,d)=>{try{const l=J.g();a:{var e=l;if(O(a)){var f=T(S(e,a),c);try{if(q(f,6)){var g=r(f,6);var h=gb(e,g,a,!1);break a}}catch(A){}}h=null}return l.format(h,d?0:b?2:1)}catch(l){return""}});m("intlTelInputUtilsTemp.getExtension",(a,b)=>{try{return r(X(J.g(),a,b),3)}catch(c){return""}});
523
- m("intlTelInputUtilsTemp.getNumberType",(a,b)=>{try{const g=J.g(),h=X(g,a,b);var c=bb(g,h),d=Q(g,w(h,1),c);if(null==d)var e=-1;else{var f=P(h);e=ab(f,d)}return e}catch(g){return-99}});
524
- m("intlTelInputUtilsTemp.getValidationError",(a,b)=>{try{const c=J.g(),d=X(c,a,b);return W(c,d,-1)}catch(c){return"Invalid country calling code"===c.message?1:3>=a.length||"Phone number too short after IDD"===c.message||"The string supplied is too short to be a phone number"===c.message?2:"The string supplied is too long to be a phone number"===c.message?3:-99}});
525
- m("intlTelInputUtilsTemp.isValidNumber",(a,b)=>{try{const l=J.g();var c=X(l,a,b),d=bb(l,c);a=l;var e=w(c,1),f=Q(a,e,d);if(null==f||"001"!=d&&e!=cb(a,d))var g=!1;else{var h=P(c);g=-1!=ab(h,f)}return g}catch(l){return!1}});m("intlTelInputUtilsTemp.isPossibleNumber",(a,b,c)=>{try{const d=J.g(),e=X(d,a,b);if(c){const f=0===W(d,e,Z[c]);if("FIXED_LINE_OR_MOBILE"===c){const g=0===W(d,e,Z.MOBILE),h=0===W(d,e,Z.FIXED_LINE);return g||h||f}return f}return 0===W(d,e,-1)}catch(d){return!1}});
526
- m("intlTelInputUtilsTemp.getCoreNumber",(a,b)=>{try{return r(X(J.g(),a,b),2).toString()}catch(c){return""}});m("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3});m("intlTelInputUtilsTemp.numberType",Z);m("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5});})();
521
+ function ub(a,b){var c=a.v.toString();if(0<=c.substring(a.$).search(a.fa)){var d=c.search(a.fa);b=c.replace(a.fa,b);D(a.v);a.v.g(b);a.$=d;return b.substring(0,a.$+1)}1==a.j.length&&(a.u=!1);a.da="";return a.s.toString()};const Z={FIXED_LINE:0,MOBILE:1,FIXED_LINE_OR_MOBILE:2,TOLL_FREE:3,PREMIUM_RATE:4,SHARED_COST:5,VOIP:6,PERSONAL_NUMBER:7,PAGER:8,UAN:9,VOICEMAIL:10,UNKNOWN:-1};m("intlTelInputUtilsTemp",{});m("intlTelInputUtilsTemp.formatNumberAsYouType",(a,b)=>{try{const c=a.replace(/[^+0-9]/g,""),d=new hb(b);b="";for(let e=0;e<c.length;e++)d.ja=ob(d,c.charAt(e)),b=d.ja;return b}catch{return a}});
522
+ m("intlTelInputUtilsTemp.formatNumber",(a,b,c)=>{try{const e=J.g(),f=X(e,a,b);var d=W(e,f,-1);return 0==d||4==d?e.format(f,"undefined"===typeof c?0:c):a}catch{return a}});m("intlTelInputUtilsTemp.getExampleNumber",(a,b,c,d)=>{try{const l=J.g();a:{var e=l;if(O(a)){var f=T(S(e,a),c);try{if(q(f,6)){var g=r(f,6);var h=gb(e,g,a,!1);break a}}catch(A){}}h=null}return l.format(h,d?0:b?2:1)}catch{return""}});m("intlTelInputUtilsTemp.getExtension",(a,b)=>{try{return r(X(J.g(),a,b),3)}catch{return""}});
523
+ m("intlTelInputUtilsTemp.getNumberType",(a,b)=>{try{const g=J.g(),h=X(g,a,b);var c=bb(g,h),d=Q(g,w(h,1),c);if(null==d)var e=-1;else{var f=P(h);e=ab(f,d)}return e}catch{return-99}});
524
+ m("intlTelInputUtilsTemp.getValidationError",(a,b)=>{if(!b)return 1;try{const c=J.g(),d=X(c,a,b);return W(c,d,-1)}catch(c){return"Invalid country calling code"===c.message?1:3>=a.length||"Phone number too short after IDD"===c.message||"The string supplied is too short to be a phone number"===c.message?2:"The string supplied is too long to be a phone number"===c.message?3:-99}});
525
+ m("intlTelInputUtilsTemp.isValidNumber",(a,b)=>{try{const l=J.g();var c=X(l,a,b),d=bb(l,c);a=l;var e=w(c,1),f=Q(a,e,d);if(null==f||"001"!=d&&e!=cb(a,d))var g=!1;else{var h=P(c);g=-1!=ab(h,f)}return g}catch{return!1}});m("intlTelInputUtilsTemp.isPossibleNumber",(a,b,c)=>{try{const d=J.g(),e=X(d,a,b);if(c){const f=0===W(d,e,Z[c]);if("FIXED_LINE_OR_MOBILE"===c){const g=0===W(d,e,Z.MOBILE),h=0===W(d,e,Z.FIXED_LINE);return g||h||f}return f}return 0===W(d,e,-1)}catch{return!1}});
526
+ m("intlTelInputUtilsTemp.getCoreNumber",(a,b)=>{try{return r(X(J.g(),a,b),2).toString()}catch{return""}});m("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3});m("intlTelInputUtilsTemp.numberType",Z);m("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5});})();
527
527
  const utils = window.intlTelInputUtilsTemp;
528
528
  delete window.intlTelInputUtilsTemp;
529
529
  export default utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "24.3.1",
3
+ "version": "24.3.2",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
package/react/README.md CHANGED
@@ -29,7 +29,7 @@ import "intl-tel-input/styles";
29
29
 
30
30
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
31
31
 
32
- 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"` instead, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `utilsScript` 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.3.1/build/js/utils.js"`.
32
+ 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"` instead, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `utilsScript` 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.3.2/build/js/utils.js"`.
33
33
 
34
34
  ## Props
35
35
  Here's a list of all of the current props you can pass to the IntlTelInput react component.
@@ -2989,6 +2989,9 @@ var Iti = class {
2989
2989
  }
2990
2990
  //* Validate the input val
2991
2991
  isValidNumber() {
2992
+ if (!this.selectedCountryData.iso2) {
2993
+ return false;
2994
+ }
2992
2995
  const val = this._getFullNumber();
2993
2996
  const alphaCharPosition = val.search(/\p{L}/u);
2994
2997
  if (alphaCharPosition > -1) {
@@ -3004,6 +3007,9 @@ var Iti = class {
3004
3007
  }
3005
3008
  //* Validate the input val (precise)
3006
3009
  isValidNumberPrecise() {
3010
+ if (!this.selectedCountryData.iso2) {
3011
+ return false;
3012
+ }
3007
3013
  const val = this._getFullNumber();
3008
3014
  const alphaCharPosition = val.search(/\p{L}/u);
3009
3015
  if (alphaCharPosition > -1) {
@@ -3093,7 +3099,7 @@ var intlTelInput = Object.assign(
3093
3099
  //* A map from instance ID to instance object.
3094
3100
  instances: {},
3095
3101
  loadUtils,
3096
- version: "24.3.1"
3102
+ version: "24.3.2"
3097
3103
  }
3098
3104
  );
3099
3105
  var intl_tel_input_default = intlTelInput;
@@ -2953,6 +2953,9 @@ var Iti = class {
2953
2953
  }
2954
2954
  //* Validate the input val
2955
2955
  isValidNumber() {
2956
+ if (!this.selectedCountryData.iso2) {
2957
+ return false;
2958
+ }
2956
2959
  const val = this._getFullNumber();
2957
2960
  const alphaCharPosition = val.search(/\p{L}/u);
2958
2961
  if (alphaCharPosition > -1) {
@@ -2968,6 +2971,9 @@ var Iti = class {
2968
2971
  }
2969
2972
  //* Validate the input val (precise)
2970
2973
  isValidNumberPrecise() {
2974
+ if (!this.selectedCountryData.iso2) {
2975
+ return false;
2976
+ }
2971
2977
  const val = this._getFullNumber();
2972
2978
  const alphaCharPosition = val.search(/\p{L}/u);
2973
2979
  if (alphaCharPosition > -1) {
@@ -3057,7 +3063,7 @@ var intlTelInput = Object.assign(
3057
3063
  //* A map from instance ID to instance object.
3058
3064
  instances: {},
3059
3065
  loadUtils,
3060
- version: "24.3.1"
3066
+ version: "24.3.2"
3061
3067
  }
3062
3068
  );
3063
3069
  var intl_tel_input_default = intlTelInput;
@@ -2989,6 +2989,9 @@ var Iti = class {
2989
2989
  }
2990
2990
  //* Validate the input val
2991
2991
  isValidNumber() {
2992
+ if (!this.selectedCountryData.iso2) {
2993
+ return false;
2994
+ }
2992
2995
  const val = this._getFullNumber();
2993
2996
  const alphaCharPosition = val.search(/\p{L}/u);
2994
2997
  if (alphaCharPosition > -1) {
@@ -3004,6 +3007,9 @@ var Iti = class {
3004
3007
  }
3005
3008
  //* Validate the input val (precise)
3006
3009
  isValidNumberPrecise() {
3010
+ if (!this.selectedCountryData.iso2) {
3011
+ return false;
3012
+ }
3007
3013
  const val = this._getFullNumber();
3008
3014
  const alphaCharPosition = val.search(/\p{L}/u);
3009
3015
  if (alphaCharPosition > -1) {
@@ -3093,7 +3099,7 @@ var intlTelInput = Object.assign(
3093
3099
  //* A map from instance ID to instance object.
3094
3100
  instances: {},
3095
3101
  loadUtils,
3096
- version: "24.3.1"
3102
+ version: "24.3.2"
3097
3103
  }
3098
3104
  );
3099
3105
  var intl_tel_input_default = intlTelInput;
@@ -9236,7 +9242,7 @@ var intl_tel_input_default = intlTelInput;
9236
9242
  b = "";
9237
9243
  for (let e = 0; e < c.length; e++) d.ja = ob(d, c.charAt(e)), b = d.ja;
9238
9244
  return b;
9239
- } catch (c) {
9245
+ } catch {
9240
9246
  return a;
9241
9247
  }
9242
9248
  });
@@ -9245,7 +9251,7 @@ var intl_tel_input_default = intlTelInput;
9245
9251
  const e = J.g(), f = X(e, a, b);
9246
9252
  var d = W(e, f, -1);
9247
9253
  return 0 == d || 4 == d ? e.format(f, "undefined" === typeof c ? 0 : c) : a;
9248
- } catch (e) {
9254
+ } catch {
9249
9255
  return a;
9250
9256
  }
9251
9257
  });
@@ -9268,14 +9274,14 @@ var intl_tel_input_default = intlTelInput;
9268
9274
  h = null;
9269
9275
  }
9270
9276
  return l.format(h, d ? 0 : b ? 2 : 1);
9271
- } catch (l) {
9277
+ } catch {
9272
9278
  return "";
9273
9279
  }
9274
9280
  });
9275
9281
  m("intlTelInputUtilsTemp.getExtension", (a, b) => {
9276
9282
  try {
9277
9283
  return r(X(J.g(), a, b), 3);
9278
- } catch (c) {
9284
+ } catch {
9279
9285
  return "";
9280
9286
  }
9281
9287
  });
@@ -9289,11 +9295,12 @@ var intl_tel_input_default = intlTelInput;
9289
9295
  e = ab(f, d);
9290
9296
  }
9291
9297
  return e;
9292
- } catch (g) {
9298
+ } catch {
9293
9299
  return -99;
9294
9300
  }
9295
9301
  });
9296
9302
  m("intlTelInputUtilsTemp.getValidationError", (a, b) => {
9303
+ if (!b) return 1;
9297
9304
  try {
9298
9305
  const c = J.g(), d = X(c, a, b);
9299
9306
  return W(c, d, -1);
@@ -9313,7 +9320,7 @@ var intl_tel_input_default = intlTelInput;
9313
9320
  g = -1 != ab(h, f);
9314
9321
  }
9315
9322
  return g;
9316
- } catch (l) {
9323
+ } catch {
9317
9324
  return false;
9318
9325
  }
9319
9326
  });
@@ -9329,14 +9336,14 @@ var intl_tel_input_default = intlTelInput;
9329
9336
  return f;
9330
9337
  }
9331
9338
  return 0 === W(d, e, -1);
9332
- } catch (d) {
9339
+ } catch {
9333
9340
  return false;
9334
9341
  }
9335
9342
  });
9336
9343
  m("intlTelInputUtilsTemp.getCoreNumber", (a, b) => {
9337
9344
  try {
9338
9345
  return r(X(J.g(), a, b), 2).toString();
9339
- } catch (c) {
9346
+ } catch {
9340
9347
  return "";
9341
9348
  }
9342
9349
  });
@@ -2953,6 +2953,9 @@ var Iti = class {
2953
2953
  }
2954
2954
  //* Validate the input val
2955
2955
  isValidNumber() {
2956
+ if (!this.selectedCountryData.iso2) {
2957
+ return false;
2958
+ }
2956
2959
  const val = this._getFullNumber();
2957
2960
  const alphaCharPosition = val.search(/\p{L}/u);
2958
2961
  if (alphaCharPosition > -1) {
@@ -2968,6 +2971,9 @@ var Iti = class {
2968
2971
  }
2969
2972
  //* Validate the input val (precise)
2970
2973
  isValidNumberPrecise() {
2974
+ if (!this.selectedCountryData.iso2) {
2975
+ return false;
2976
+ }
2971
2977
  const val = this._getFullNumber();
2972
2978
  const alphaCharPosition = val.search(/\p{L}/u);
2973
2979
  if (alphaCharPosition > -1) {
@@ -3057,7 +3063,7 @@ var intlTelInput = Object.assign(
3057
3063
  //* A map from instance ID to instance object.
3058
3064
  instances: {},
3059
3065
  loadUtils,
3060
- version: "24.3.1"
3066
+ version: "24.3.2"
3061
3067
  }
3062
3068
  );
3063
3069
  var intl_tel_input_default = intlTelInput;
@@ -9200,7 +9206,7 @@ var intl_tel_input_default = intlTelInput;
9200
9206
  b = "";
9201
9207
  for (let e = 0; e < c.length; e++) d.ja = ob(d, c.charAt(e)), b = d.ja;
9202
9208
  return b;
9203
- } catch (c) {
9209
+ } catch {
9204
9210
  return a;
9205
9211
  }
9206
9212
  });
@@ -9209,7 +9215,7 @@ var intl_tel_input_default = intlTelInput;
9209
9215
  const e = J.g(), f = X(e, a, b);
9210
9216
  var d = W(e, f, -1);
9211
9217
  return 0 == d || 4 == d ? e.format(f, "undefined" === typeof c ? 0 : c) : a;
9212
- } catch (e) {
9218
+ } catch {
9213
9219
  return a;
9214
9220
  }
9215
9221
  });
@@ -9232,14 +9238,14 @@ var intl_tel_input_default = intlTelInput;
9232
9238
  h = null;
9233
9239
  }
9234
9240
  return l.format(h, d ? 0 : b ? 2 : 1);
9235
- } catch (l) {
9241
+ } catch {
9236
9242
  return "";
9237
9243
  }
9238
9244
  });
9239
9245
  m("intlTelInputUtilsTemp.getExtension", (a, b) => {
9240
9246
  try {
9241
9247
  return r(X(J.g(), a, b), 3);
9242
- } catch (c) {
9248
+ } catch {
9243
9249
  return "";
9244
9250
  }
9245
9251
  });
@@ -9253,11 +9259,12 @@ var intl_tel_input_default = intlTelInput;
9253
9259
  e = ab(f, d);
9254
9260
  }
9255
9261
  return e;
9256
- } catch (g) {
9262
+ } catch {
9257
9263
  return -99;
9258
9264
  }
9259
9265
  });
9260
9266
  m("intlTelInputUtilsTemp.getValidationError", (a, b) => {
9267
+ if (!b) return 1;
9261
9268
  try {
9262
9269
  const c = J.g(), d = X(c, a, b);
9263
9270
  return W(c, d, -1);
@@ -9277,7 +9284,7 @@ var intl_tel_input_default = intlTelInput;
9277
9284
  g = -1 != ab(h, f);
9278
9285
  }
9279
9286
  return g;
9280
- } catch (l) {
9287
+ } catch {
9281
9288
  return false;
9282
9289
  }
9283
9290
  });
@@ -9293,14 +9300,14 @@ var intl_tel_input_default = intlTelInput;
9293
9300
  return f;
9294
9301
  }
9295
9302
  return 0 === W(d, e, -1);
9296
- } catch (d) {
9303
+ } catch {
9297
9304
  return false;
9298
9305
  }
9299
9306
  });
9300
9307
  m("intlTelInputUtilsTemp.getCoreNumber", (a, b) => {
9301
9308
  try {
9302
9309
  return r(X(J.g(), a, b), 2).toString();
9303
- } catch (c) {
9310
+ } catch {
9304
9311
  return "";
9305
9312
  }
9306
9313
  });