Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-international-phone

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-international-phone - npm Package Compare versions

Comparing version 3.0.2 to 3.1.0

1

build/components/CountrySelector/CountrySelector.d.ts

@@ -27,2 +27,3 @@ import './CountrySelector.style.scss';

countries?: CountryData[];
flags?: CountrySelectorDropdownProps['flags'];
renderButtonWrapper?: (props: {

@@ -29,0 +30,0 @@ children: React.ReactNode;

3

build/components/CountrySelector/CountrySelectorDropdown.d.ts
import './CountrySelectorDropdown.style.scss';
import React from 'react';
import { CountryData, CountryIso2, ParsedCountry } from '../../types';
import { CountryData, CountryIso2, CustomFlagImage, ParsedCountry } from '../../types';
export interface CountrySelectorDropdownStyleProps {

@@ -21,2 +21,3 @@ style?: React.CSSProperties;

countries?: CountryData[];
flags?: CustomFlagImage[];
onSelect?: (country: ParsedCountry) => void;

@@ -23,0 +24,0 @@ onClose?: () => void;

@@ -5,5 +5,26 @@ import './FlagEmoji.style.scss';

interface FlagEmojiProps extends React.HTMLAttributes<HTMLImageElement> {
/**
* @description iso2 code of country flag
* @required
*/
iso2?: ParsedCountry['iso2'];
/**
* @description Size of flag
* @default undefined
*/
size?: CSSProperties['width'];
/**
* @description Custom src of flag
* @default undefined
*/
src?: string;
/**
* @description Protocol to use with twemoji cnd
* @default "https"
*/
protocol?: 'http' | 'https';
/**
* @description Disable lazy loading of flags (loading="lazy" attribute will not be set)
* @default undefined
*/
disableLazyLoading?: boolean;

@@ -10,0 +31,0 @@ }

@@ -44,2 +44,7 @@ import './PhoneInput.style.scss';

/**
* @description Custom flag URLs array
* @default undefined
*/
flags?: CountrySelectorProps['flags'];
/**
* @description Callback that calls on phone change

@@ -46,0 +51,0 @@ * @params `phone` - new phone value, `country` - country iso2 value

@@ -1,1 +0,1 @@

"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var a=true;var o=false;var i,l;try{for(t=t.call(e);!(a=(i=t.next()).done);a=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){o=true;l=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw l}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var a=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}a.forEach(function(r){n(e,r,t[r])})}return e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function d(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,r){if(e==null)return{};var t=f(e,r);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++){n=o[a];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function f(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++){a=n[o];if(r.indexOf(a)>=0)continue;t[a]=e[a]}return t}function v(e,t){return r(e)||o(e,t)||p(e,t)||i()}function y(e){return t(e)||a(e)||p(e)||l()}function p(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}var m=Object.create;var h=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var D=function(e,r){for(var t in r)h(e,t,{get:r[t],enumerable:!0})},S=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var l=function(){var a=c.value;!w.call(e,a)&&a!==t&&h(e,a,{get:function(){return r[a]},enumerable:!(n=C(r,a))||n.enumerable})};for(var u=b(r)[Symbol.iterator](),c;!(a=(c=u.next()).done);a=true)l()}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return e};var P=function(e,r,t){return t=e!=null?m(g(e)):{},S(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)},x=function(e){return S(h({},"__esModule",{value:!0}),e)};var k={};D(k,{CountrySelector:function(){return et},CountrySelectorDropdown:function(){return er},DialCodePreview:function(){return ea},FlagEmoji:function(){return $},PhoneInput:function(){return ep},buildCountryData:function(){return _},defaultCountries:function(){return A},parseCountry:function(){return B},usePhoneInput:function(){return ey}});module.exports=x(k);var N=P(require("react"));var A=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54","(..) ........",0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",". .... ....",0],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) ........."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["C\xf4te d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xe7ao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253"],["Dominica","dm","1767"],["Dominican Republic","do","1","",2],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251"],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49",".... ........"],["Ghana","gh","233"],["Greece","gr","30"],["Grenada","gd","1473"],["Guadeloupe","gp","590","",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",".. ........"],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968"],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63",".... ......."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","",3],["Qatar","qa","974"],["R\xe9union","re","262"],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xe3o Tom\xe9 and Pr\xedncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","(...) ...-..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]];var j="react-international-phone-",E=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.filter(function(e){return!!e}).join(" ").trim()},O=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return E.apply(void 0,y(r)).split(" ").map(function(e){return"".concat(j).concat(e)}).join(" ")},M=function(e){var r=e.addPrefix,t=e.rawClassNames;return E.apply(void 0,[O.apply(void 0,y(r))].concat(y(t)))};var I=function(e){var r=e.value,t=e.mask,n=e.maskSymbol,a=e.offset,o=a===void 0?0:a,i=e.trimNonMaskCharsLeftover,l=i===void 0?!1:i;if(r.length<o)return r;var u=r.slice(0,o),c=r.slice(o),d=u,s=0;var f=true,v=false,y=undefined;try{for(var p=t.split("")[Symbol.iterator](),m;!(f=(m=p.next()).done);f=true){var h=m.value;if(s>=c.length){if(!l&&h!==n){d+=h;continue}break}h===n?(d+=c[s],s+=1):d+=h}}catch(e){v=true;y=e}finally{try{if(!f&&p.return!=null){p.return()}}finally{if(v){throw y}}}return d};var L=function(e){return e.replace(/\D/g,"")};var z=function(e,r){var t=e.style.display;t!=="block"&&(e.style.display="block");var n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.top-n.top,i=n.bottom-a.bottom;o>=0&&i>=0||(Math.abs(o)<Math.abs(i)?e.scrollTop+=o:e.scrollTop-=i),e.style.display=t};var _=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,l=[r,t,n,a,o,i];for(var u=0;u<l.length;u+=1){if(u===0)continue;var c=l[u-1],d=l[u];if(c===void 0&&d!==void 0){var s=JSON.stringify(l,function(e,r){return r===void 0?"__undefined":r}).replace(/"__undefined"/g,"undefined");throw new Error("[react-international-phone] invalid country values passed to buildCountryData. Check ".concat(c," in: ").concat(s))}}return l.filter(function(e){return e!==void 0})};var B=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],l=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:l}};var R=function(e){return'Field "'.concat(e,'" is not supported')},G=function(e){var r=e.value,t=e.field,n=e.countries;if(["priority"].includes(t))throw new Error(R(t));var a=n.find(function(e){var n=B(e);return r===n[t]});if(a)return B(a)};var T=function(e){var r=e.phone,t=e.countries,n=e.currentCountryIso2;var a={country:void 0,fullDialCodeMatch:!1};if(!r)return a;var o=L(r);if(!o)return a;var i=a,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,l;var u=r.dialCode===((n=i.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((l=(a=i.country)===null||a===void 0?void 0:a.priority)!==null&&l!==void 0?l:0);(!u||c)&&(i={country:r,fullDialCodeMatch:t})};var u=true,c=false,d=undefined;try{for(var s=t[Symbol.iterator](),f;!(u=(f=s.next()).done);u=true){var v=f.value;var y=B(v),p=y.dialCode,m=y.areaCodes;if(o.startsWith(p)){var h=i.country?Number(p)>=Number(i.country.dialCode):!0;if(m){var C=o.substring(p.length);var b=true,g=false,w=undefined;try{for(var D=m[Symbol.iterator](),S;!(b=(S=D.next()).done);b=true){var P=S.value;if(C.startsWith(P))return{country:y,fullDialCodeMatch:!0}}}catch(e){g=true;w=e}finally{try{if(!b&&D.return!=null){D.return()}}finally{if(g){throw w}}}}(h||p===o||!i.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}i.fullDialCodeMatch||o.length<p.length&&p.startsWith(o)&&(!i.country||Number(p)<=Number(i.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){c=true;d=e}finally{try{if(!u&&s.return!=null){s.return()}}finally{if(c){throw d}}}if(n){var x;var k=G({value:n,field:"iso2",countries:t});if(!k)return i;var N=k?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=o.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(k):!1;!!i&&((x=i.country)===null||x===void 0?void 0:x.dialCode)===k.dialCode&&i.country!==k&&i.fullDialCodeMatch&&(!k.areaCodes||N)&&(i={country:k,fullDialCodeMatch:!0})}return i};var q=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;if(!r||!t)return r;var l=r;return l.startsWith(a)&&(l=l.replace(a,"")),l.startsWith(t)?(l=l.replace(t,""),l.startsWith(i)&&(l=l.replace(i,"")),l):r};var K=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;return"".concat(a).concat(t).concat(i).concat(q({phone:r,dialCode:t,charAfterDialCode:i,prefix:a}))};var W=function(e,r){var t=r.disableDialCodeAndPrefix?!1:r.forceDialCode,n=r.disableDialCodeAndPrefix?!1:r.insertDialCodeOnEmpty,a=e,o=function(e){return r.trimNonDigitsEnd?e.trim():e};if(!a)return n&&!a.length||t?o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode)):o(a);if(a=L(a),a===r.dialCode&&!r.disableDialCodeAndPrefix)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(r.dialCode.startsWith(a)&&!r.disableDialCodeAndPrefix)return o(t?"".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode):"".concat(r.prefix).concat(a));if(!a.startsWith(r.dialCode)&&!r.disableDialCodeAndPrefix){if(t)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(a.length<r.dialCode.length)return o("".concat(r.prefix).concat(a))}var i=function(){var e=r.dialCode.length;r.disableDialCodeAndPrefix&&(e=0);var t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},l=i(),u=l.phoneLeftSide,c=l.phoneRightSide;return u="".concat(r.prefix).concat(u).concat(r.charAfterDialCode),c=I({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd}),r.disableDialCodeAndPrefix&&(u=""),o("".concat(u).concat(c))};var F=function(e){return/\d/.test(e)},U=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,l=e.deletion;if(a<i)return i;if(!r)return n.length;var u=l==="backward";if(a===0&&t.length>0&&n.length>0){if(u)return 0;for(var c=0;c<n.length;c+=1)if(F(n[c]))return c;return n.length}if(t.length<r.length&&t.length===1)return n.length;var d=null;for(var s=a-1;s>=0;s-=1)if(F(t[s])){d=s;break}if(d===null)return a!==0?a:n.length;var f=0;for(var v=0;v<d;v+=1)F(t[v])&&(f+=1);u&&(f-=1);var y=0,p=0;for(var m=0;m<n.length&&(y+=1,F(n[m])&&(p+=1),p!==f+1);m+=1);for(;!F(n[y])&&y<n.length;)y+=1;return u&&(y+=1),y};var V=P(require("react"));var H=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},J="abcdefghijklmnopqrstuvwxyz",Z="1f1e6",Q=J.split("").reduce(function(e,r,t){return d(u({},e),n({},r,H(Z,t)))},{}),Y=function(e){return[Q[e[0]],Q[e[1]]].join("-")},$=function(e){var r=e.iso2,t=e.size,n=t===void 0?"24px":t,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,l=e.className,c=s(e,["iso2","size","protocol","disableLazyLoading","className"]);if(!r)return V.default.createElement("img",u({width:n,height:n},c));var d=Y(r),f="".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(d,".svg");return V.default.createElement("img",u({className:M({addPrefix:["flag-emoji"],rawClassNames:[l]}),src:f,width:n,height:n,draggable:!1,"data-country":r,loading:i?void 0:"lazy"},c))};var X=P(require("react"));var ee=1e3,er=function(e){var r=e.show,t=e.dialCodePrefix,n=t===void 0?"+":t,a=e.selectedCountry,o=e.countries,i=o===void 0?A:o,l=e.onSelect,c=e.onClose,d=s(e,["show","dialCodePrefix","selectedCountry","countries","onSelect","onClose"]);var f=(0,X.useRef)(null),y=(0,X.useRef)(),p=(0,X.useRef)({updatedAt:void 0,value:""}),m=function(e){var r=p.current.updatedAt&&new Date().getTime()-p.current.updatedAt.getTime()>ee;p.current={value:r?e:"".concat(p.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return B(e).name.toLowerCase().startsWith(p.current.value)});t!==-1&&g(t)},h=(0,X.useCallback)(function(e){return i.findIndex(function(r){return B(r).iso2===e})},[i]),C=v((0,X.useState)(h(a)),2),b=C[0],g=C[1],w=function(){y.current!==a&&g(h(a))},D=(0,X.useCallback)(function(e){var r;g(h(e.iso2)),(r=l)===null||r===void 0?void 0:r(e)},[l,h]),S=function(e){var r=i.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};g(function(e){var n=t(e);return n<0?0:n>r?r:n})},P=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=B(i[b]);D(r);return}if(e.key==="Escape"){var t;(t=c)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),S("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),S("next");return}if(e.key==="PageUp"){e.preventDefault(),S("first");return}if(e.key==="PageDown"){e.preventDefault(),S("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&m(e.key.toLocaleLowerCase())},x=(0,X.useCallback)(function(){if(!f.current||b===void 0)return;var e=B(i[b]).iso2;if(e===y.current)return;var r=f.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(f.current,r),y.current=e)},[b,i]);return(0,X.useEffect)(function(){x()},[b,x]),(0,X.useEffect)(function(){f.current&&(r?f.current.focus():w())},[r]),(0,X.useEffect)(function(){w()},[a]),X.default.createElement("ul",{ref:f,role:"listbox",className:M({addPrefix:["country-selector-dropdown"],rawClassNames:[d.className]}),style:u({display:r?"block":"none"},d.style),onKeyDown:P,onBlur:c,tabIndex:-1,"aria-activedescendant":"".concat(B(i[b]).iso2,"-option")},i.map(function(e,r){var t=B(e),o=t.iso2===a,i=r===b;return X.default.createElement("li",{key:t.iso2,"data-country":t.iso2,role:"option","aria-selected":o,"aria-label":"".concat(t.name," ").concat(n).concat(t.dialCode),id:"".concat(t.iso2,"-option"),className:M({addPrefix:["country-selector-dropdown__list-item",o&&"country-selector-dropdown__list-item--selected",i&&"country-selector-dropdown__list-item--focused"],rawClassNames:[d.listItemClassName]}),onClick:function(){return D(t)},style:d.listItemStyle},X.default.createElement($,{iso2:t.iso2,className:M({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[d.listItemFlagClassName]}),style:d.listItemFlagStyle}),X.default.createElement("span",{className:M({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[d.listItemCountryNameClassName]}),style:d.listItemCountryNameStyle},t.name),X.default.createElement("span",{className:M({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[d.listItemDialCodeClassName]}),style:d.listItemDialCodeStyle},n,t.dialCode))}))};var et=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?A:o,l=e.renderButtonWrapper,c=s(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","renderButtonWrapper"]);var f=v((0,N.useState)(!1),2),y=f[0],p=f[1],m=(0,N.useMemo)(function(){if(r)return G({value:r,field:"iso2",countries:i})},[i,r]),h=(0,N.useRef)(null),C=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),p(!0))},b=function(){var e;var t={title:(e=m)===null||e===void 0?void 0:e.name,onClick:function(){return p(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:C,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":y},o=N.default.createElement("div",{className:M({addPrefix:["country-selector-button__button-content"],rawClassNames:[c.buttonContentWrapperClassName]}),style:c.buttonContentWrapperStyle},N.default.createElement($,{iso2:r,className:M({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[c.flagClassName]}),style:u({visibility:r?"visible":"hidden"},c.flagStyle)}),!a&&N.default.createElement("div",{className:M({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",y&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[c.dropdownArrowClassName]}),style:c.dropdownArrowStyle}));return l?l({children:o,rootProps:t}):N.default.createElement("button",d(u({},t),{type:"button",className:M({addPrefix:["country-selector-button",y&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[c.buttonClassName]}),"data-country":r,style:c.buttonStyle}),o)};return N.default.createElement("div",{className:M({addPrefix:["country-selector"],rawClassNames:[c.className]}),style:c.style,ref:h},b(),N.default.createElement(er,u({show:y,countries:i,onSelect:function(e){var r;p(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){p(!1)}},c.dropdownStyleProps)))};var en=P(require("react"));var ea=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return en.default.createElement("div",{className:M({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eo=P(require("react"));var ei=require("react");var el=require("react");var eu=require("react"),ec=function(){var e=(0,eu.useRef)(),r=(0,eu.useRef)(Date.now());return{check:function(){var t=Date.now(),n=e.current?t-r.current:void 0;return e.current=r.current,r.current=t,n}}};var ed={size:20,overrideLastItemDebounceMS:-1};function es(e,r){var t=u({},ed,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,el.useState)(e),2),l=i[0],c=i[1],d=v((0,el.useState)([l]),2),s=d[0],f=d[1],p=v((0,el.useState)(0),2),m=p[0],h=p[1],C=ec();return[l,function(e,r){var t,i;if(typeof e=="object"&&Object.entries(e).toString()===Object.entries(l).toString()||e===l)return;var u=a>0,d=C.check(),v=u&&d!==void 0?d>a:!0;if(((t=r)===null||t===void 0?void 0:t.overrideLastItem)!==void 0?r.overrideLastItem:!v)f(function(r){return y(r.slice(0,m)).concat([e])});else{var p=s.length>=n;f(function(r){return y(r.slice(p?1:0,m+1)).concat([e])}),p||h(function(e){return e+1})}c(e),(i=o)===null||i===void 0?void 0:i(e)},function(){var e;if(m<=0)return{success:!1};var r=s[m-1];return c(r),h(function(e){return e-1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}},function(){var e;if(m+1>=s.length)return{success:!1};var r=s[m+1];return c(r),h(function(e){return e+1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}}]}var ef=".",ev={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,countries:A},ey=function(e){var r=e.defaultCountry,t=r===void 0?ev.defaultCountry:r,n=e.value,a=n===void 0?ev.value:n,o=e.countries,i=o===void 0?ev.countries:o,l=e.prefix,u=l===void 0?ev.prefix:l,c=e.defaultMask,d=c===void 0?ev.defaultMask:c,s=e.charAfterDialCode,f=s===void 0?ev.charAfterDialCode:s,y=e.historySaveDebounceMS,p=y===void 0?ev.historySaveDebounceMS:y,m=e.disableCountryGuess,h=m===void 0?ev.disableCountryGuess:m,C=e.disableDialCodePrefill,b=C===void 0?ev.disableDialCodePrefill:C,g=e.forceDialCode,w=g===void 0?ev.forceDialCode:g,D=e.disableDialCodeAndPrefix,S=D===void 0?ev.disableDialCodeAndPrefix:D,P=e.onChange;var x=S?!1:!h,k=(0,ei.useRef)(null),N=function(e){var r=e.value,t=e.country,n=e.trimNonDigitsEnd,a=e.insertDialCodeOnEmpty,o=e.forceDisableCountryGuess;var l;var c;var s=!o&&x?T({phone:r,countries:i,currentCountryIso2:t.iso2}):void 0,v=(c=(l=s)===null||l===void 0?void 0:l.country)!==null&&c!==void 0?c:t;return{phone:v?W(r,{prefix:u,mask:v.format||d,maskChar:ef,dialCode:v.dialCode,trimNonDigitsEnd:n,charAfterDialCode:f,forceDialCode:w,insertDialCodeOnEmpty:a,disableDialCodeAndPrefix:S}):r,countryGuessResult:s,formatCountry:v}},A=function(e){Promise.resolve().then(function(){var r;(r=k.current)===null||r===void 0?void 0:r.setSelectionRange(e,e)})},j=v(es(function(){var e=T({phone:a,countries:i,currentCountryIso2:t}).country||G({value:t,field:"iso2",countries:i});e||console.error('[react-international-phone]: can not find a country with "'.concat(t,'" iso2 code'));var r=e||B(i.find(function(e){return B(e).iso2==="us"})),n=N({value:a,country:r,insertDialCodeOnEmpty:!b}).phone;return A(n.length),{phone:n,country:r.iso2}},{overrideLastItemDebounceMS:p,onChange:P}),4),E=j[0],O=E.phone,M=E.country,I=j[1],z=j[2],_=j[3],R=(0,ei.useMemo)(function(){return G({value:M,field:"iso2",countries:i})},[i,M]),q=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=r.deletion,n=r.cursorPosition,a=r.insertDialCodeOnEmpty,o=r.inserted;var i,l,c;var d=e,s=n;w&&!S&&R&&!L(e).startsWith(R.dialCode)&&e&&(o&&e.startsWith(u)&&e.length-(n!==null&&n!==void 0?n:0)===0?d=e:(d=O,s=0));var v=N({value:d,country:R,trimNonDigitsEnd:t==="backward",insertDialCodeOnEmpty:a,forceDisableCountryGuess:w&&!!t&&L(d).length<R.dialCode.length}),y=v.phone,p=v.countryGuessResult,m=R;x&&((i=p)===null||i===void 0?void 0:i.country)&&p.country.name!==M&&p.fullDialCodeMatch&&(m=p.country);var h;var C=U({cursorPositionAfterInput:s!==null&&s!==void 0?s:0,phoneBeforeInput:O,phoneAfterInput:e,phoneAfterFormatted:y,leftOffset:w?u.length+((h=(c=R)===null||c===void 0?void 0:(l=c.dialCode)===null||l===void 0?void 0:l.length)!==null&&h!==void 0?h:0)+f.length:0,deletion:t});return I({phone:y,country:m.iso2}),A(C),y};(0,ei.useEffect)(function(){var e=k.current;if(!e)return;var r=function(e){if(!e.key)return;var r=e.ctrlKey,t=e.shiftKey,n=e.key.toLowerCase()==="z";!r||!n||(t?_():z())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[k,z,_]);var F=function(e){var r;e.preventDefault();var t;var n=e.nativeEvent.inputType,a=function(){var e,r;var t;if((t=(e=n)===null||e===void 0?void 0:e.toLocaleLowerCase().includes("delete"))!==null&&t!==void 0?t:!1)return((r=n)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("forward"))?"forward":"backward"},o=(r=n)===null||r===void 0?void 0:r.startsWith("insertFrom"),i=q(e.target.value,{deletion:a(),inserted:o,cursorPosition:(t=e.target.selectionStart)!==null&&t!==void 0?t:0});return S&&R?K({phone:i,dialCode:R.dialCode,charAfterDialCode:f,prefix:u}):i},V=function(e){var r=G({value:e,field:"iso2",countries:i});if(!r)return;var t=S?"":"".concat(u).concat(r.dialCode).concat(f);I({phone:t,country:r.iso2}),Promise.resolve().then(function(){var e;(e=k.current)===null||e===void 0?void 0:e.focus()})},H=v((0,ei.useState)(!1),2),J=H[0],Z=H[1];return(0,ei.useEffect)(function(){if(!J){var e;Z(!0),a!==O&&((e=P)===null||e===void 0?void 0:e({phone:O,country:M}));return}a!==O&&q(a)},[a]),{phone:O,country:M,setCountry:V,handlePhoneValueChange:F,inputRef:k}};var ep=function(e){var r=e.hideDropdown,t=e.placeholder,n=e.disabled,a=e.showDisabledDialCodeAndPrefix,o=e.inputProps,i=e.onChange,l=e.style,c=e.className,f=e.inputStyle,v=e.inputClassName,y=e.countrySelectorStyleProps,p=e.dialCodePreviewStyleProps,m=e.value,h=e.countries,C=h===void 0?A:h,b=s(e,["hideDropdown","placeholder","disabled","showDisabledDialCodeAndPrefix","inputProps","onChange","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","value","countries"]);var g;var w=ey(d(u({value:m,countries:C},b),{onChange:function(e){var r;(r=i)===null||r===void 0?void 0:r(e.phone,e.country)}})),D=w.phone,S=w.inputRef,P=w.country,x=w.setCountry,k=w.handlePhoneValueChange,N=(0,eo.useMemo)(function(){if(P)return G({value:P,field:"iso2",countries:C})},[C,P]),j=b.disableDialCodeAndPrefix&&a&&((g=N)===null||g===void 0?void 0:g.dialCode);var E;return eo.default.createElement("div",{className:M({addPrefix:["input-container"],rawClassNames:[c]}),style:l},eo.default.createElement(et,u({onSelect:function(e){return x(e.iso2)},selectedCountry:P,countries:C,disabled:n,hideDropdown:r},y)),j&&eo.default.createElement(ea,u({dialCode:N.dialCode,prefix:(E=b.prefix)!==null&&E!==void 0?E:"+",disabled:n},p)),eo.default.createElement("input",u({onChange:k,value:D,type:"tel",ref:S,className:M({addPrefix:["input",n&&"input--disabled"],rawClassNames:[v]}),placeholder:t,disabled:n,style:f},o)))};0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagEmoji:FlagEmoji,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,parseCountry:parseCountry,usePhoneInput:usePhoneInput});
"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var a=true;var o=false;var i,l;try{for(t=t.call(e);!(a=(i=t.next()).done);a=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){o=true;l=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw l}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var a=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}a.forEach(function(r){n(e,r,t[r])})}return e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function s(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function d(e,r){if(e==null)return{};var t=f(e,r);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++){n=o[a];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function f(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++){a=n[o];if(r.indexOf(a)>=0)continue;t[a]=e[a]}return t}function v(e,t){return r(e)||o(e,t)||p(e,t)||i()}function y(e){return t(e)||a(e)||p(e)||l()}function p(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}var m=Object.create;var h=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var D=function(e,r){for(var t in r)h(e,t,{get:r[t],enumerable:!0})},S=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var l=function(){var a=c.value;!w.call(e,a)&&a!==t&&h(e,a,{get:function(){return r[a]},enumerable:!(n=C(r,a))||n.enumerable})};for(var u=b(r)[Symbol.iterator](),c;!(a=(c=u.next()).done);a=true)l()}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return e};var P=function(e,r,t){return t=e!=null?m(g(e)):{},S(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)},x=function(e){return S(h({},"__esModule",{value:!0}),e)};var k={};D(k,{CountrySelector:function(){return et},CountrySelectorDropdown:function(){return er},DialCodePreview:function(){return ea},FlagEmoji:function(){return $},PhoneInput:function(){return ep},buildCountryData:function(){return _},defaultCountries:function(){return A},parseCountry:function(){return B},usePhoneInput:function(){return ey}});module.exports=x(k);var N=P(require("react"));var A=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54","(..) ........",0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",". .... ....",0],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) ........."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["C\xf4te d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xe7ao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253"],["Dominica","dm","1767"],["Dominican Republic","do","1","",2],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251"],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49",".... ........"],["Ghana","gh","233"],["Greece","gr","30"],["Grenada","gd","1473"],["Guadeloupe","gp","590","",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",".. ........"],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968"],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63",".... ......."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","",3],["Qatar","qa","974"],["R\xe9union","re","262"],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xe3o Tom\xe9 and Pr\xedncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","(...) ...-..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]];var j="react-international-phone-",E=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.filter(function(e){return!!e}).join(" ").trim()},O=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return E.apply(void 0,y(r)).split(" ").map(function(e){return"".concat(j).concat(e)}).join(" ")},M=function(e){var r=e.addPrefix,t=e.rawClassNames;return E.apply(void 0,[O.apply(void 0,y(r))].concat(y(t)))};var I=function(e){var r=e.value,t=e.mask,n=e.maskSymbol,a=e.offset,o=a===void 0?0:a,i=e.trimNonMaskCharsLeftover,l=i===void 0?!1:i;if(r.length<o)return r;var u=r.slice(0,o),c=r.slice(o),s=u,d=0;var f=true,v=false,y=undefined;try{for(var p=t.split("")[Symbol.iterator](),m;!(f=(m=p.next()).done);f=true){var h=m.value;if(d>=c.length){if(!l&&h!==n){s+=h;continue}break}h===n?(s+=c[d],d+=1):s+=h}}catch(e){v=true;y=e}finally{try{if(!f&&p.return!=null){p.return()}}finally{if(v){throw y}}}return s};var L=function(e){return e.replace(/\D/g,"")};var z=function(e,r){var t=e.style.display;t!=="block"&&(e.style.display="block");var n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.top-n.top,i=n.bottom-a.bottom;o>=0&&i>=0||(Math.abs(o)<Math.abs(i)?e.scrollTop+=o:e.scrollTop-=i),e.style.display=t};var _=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,l=[r,t,n,a,o,i];for(var u=0;u<l.length;u+=1){if(u===0)continue;var c=l[u-1],s=l[u];if(c===void 0&&s!==void 0){var d=JSON.stringify(l,function(e,r){return r===void 0?"__undefined":r}).replace(/"__undefined"/g,"undefined");throw new Error("[react-international-phone] invalid country values passed to buildCountryData. Check ".concat(c," in: ").concat(d))}}return l.filter(function(e){return e!==void 0})};var B=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],l=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:l}};var R=function(e){return'Field "'.concat(e,'" is not supported')},G=function(e){var r=e.value,t=e.field,n=e.countries;if(["priority"].includes(t))throw new Error(R(t));var a=n.find(function(e){var n=B(e);return r===n[t]});if(a)return B(a)};var T=function(e){var r=e.phone,t=e.countries,n=e.currentCountryIso2;var a={country:void 0,fullDialCodeMatch:!1};if(!r)return a;var o=L(r);if(!o)return a;var i=a,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,l;var u=r.dialCode===((n=i.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((l=(a=i.country)===null||a===void 0?void 0:a.priority)!==null&&l!==void 0?l:0);(!u||c)&&(i={country:r,fullDialCodeMatch:t})};var u=true,c=false,s=undefined;try{for(var d=t[Symbol.iterator](),f;!(u=(f=d.next()).done);u=true){var v=f.value;var y=B(v),p=y.dialCode,m=y.areaCodes;if(o.startsWith(p)){var h=i.country?Number(p)>=Number(i.country.dialCode):!0;if(m){var C=o.substring(p.length);var b=true,g=false,w=undefined;try{for(var D=m[Symbol.iterator](),S;!(b=(S=D.next()).done);b=true){var P=S.value;if(C.startsWith(P))return{country:y,fullDialCodeMatch:!0}}}catch(e){g=true;w=e}finally{try{if(!b&&D.return!=null){D.return()}}finally{if(g){throw w}}}}(h||p===o||!i.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}i.fullDialCodeMatch||o.length<p.length&&p.startsWith(o)&&(!i.country||Number(p)<=Number(i.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){c=true;s=e}finally{try{if(!u&&d.return!=null){d.return()}}finally{if(c){throw s}}}if(n){var x;var k=G({value:n,field:"iso2",countries:t});if(!k)return i;var N=k?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=o.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(k):!1;!!i&&((x=i.country)===null||x===void 0?void 0:x.dialCode)===k.dialCode&&i.country!==k&&i.fullDialCodeMatch&&(!k.areaCodes||N)&&(i={country:k,fullDialCodeMatch:!0})}return i};var q=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;if(!r||!t)return r;var l=r;return l.startsWith(a)&&(l=l.replace(a,"")),l.startsWith(t)?(l=l.replace(t,""),l.startsWith(i)&&(l=l.replace(i,"")),l):r};var K=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;return"".concat(a).concat(t).concat(i).concat(q({phone:r,dialCode:t,charAfterDialCode:i,prefix:a}))};var W=function(e,r){var t=r.disableDialCodeAndPrefix?!1:r.forceDialCode,n=r.disableDialCodeAndPrefix?!1:r.insertDialCodeOnEmpty,a=e,o=function(e){return r.trimNonDigitsEnd?e.trim():e};if(!a)return n&&!a.length||t?o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode)):o(a);if(a=L(a),a===r.dialCode&&!r.disableDialCodeAndPrefix)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(r.dialCode.startsWith(a)&&!r.disableDialCodeAndPrefix)return o(t?"".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode):"".concat(r.prefix).concat(a));if(!a.startsWith(r.dialCode)&&!r.disableDialCodeAndPrefix){if(t)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(a.length<r.dialCode.length)return o("".concat(r.prefix).concat(a))}var i=function(){var e=r.dialCode.length;r.disableDialCodeAndPrefix&&(e=0);var t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},l=i(),u=l.phoneLeftSide,c=l.phoneRightSide;return u="".concat(r.prefix).concat(u).concat(r.charAfterDialCode),c=I({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd}),r.disableDialCodeAndPrefix&&(u=""),o("".concat(u).concat(c))};var F=function(e){return/\d/.test(e)},U=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,l=e.deletion;if(a<i)return i;if(!r)return n.length;var u=l==="backward";if(a===0&&t.length>0&&n.length>0){if(u)return 0;for(var c=0;c<n.length;c+=1)if(F(n[c]))return c;return n.length}if(t.length<r.length&&t.length===1)return n.length;var s=null;for(var d=a-1;d>=0;d-=1)if(F(t[d])){s=d;break}if(s===null)return a!==0?a:n.length;var f=0;for(var v=0;v<s;v+=1)F(t[v])&&(f+=1);u&&(f-=1);var y=0,p=0;for(var m=0;m<n.length&&(y+=1,F(n[m])&&(p+=1),p!==f+1);m+=1);for(;!F(n[y])&&y<n.length;)y+=1;return u&&(y+=1),y};var V=P(require("react"));var H=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},J="abcdefghijklmnopqrstuvwxyz",Z="1f1e6",Q=J.split("").reduce(function(e,r,t){return s(u({},e),n({},r,H(Z,t)))},{}),Y=function(e){return[Q[e[0]],Q[e[1]]].join("-")},$=function(e){var r=e.iso2,t=e.size,n=e.src,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,l=e.className,c=e.style,s=d(e,["iso2","size","src","protocol","disableLazyLoading","className","style"]);if(!r)return V.default.createElement("img",u({className:M({addPrefix:["flag-emoji"],rawClassNames:[l]}),width:t,height:t},s));var f=function(){if(n)return n;var e=Y(r);return"".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(e,".svg")};return V.default.createElement("img",u({className:M({addPrefix:["flag-emoji"],rawClassNames:[l]}),src:f(),width:t,height:t,draggable:!1,"data-country":r,loading:i?void 0:"lazy",style:u({width:t,height:t},c)},s))};var X=P(require("react"));var ee=1e3,er=function(e){var r=e.show,t=e.dialCodePrefix,n=t===void 0?"+":t,a=e.selectedCountry,o=e.countries,i=o===void 0?A:o,l=e.flags,c=e.onSelect,s=e.onClose,f=d(e,["show","dialCodePrefix","selectedCountry","countries","flags","onSelect","onClose"]);var y=(0,X.useRef)(null),p=(0,X.useRef)(),m=(0,X.useRef)({updatedAt:void 0,value:""}),h=function(e){var r=m.current.updatedAt&&new Date().getTime()-m.current.updatedAt.getTime()>ee;m.current={value:r?e:"".concat(m.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return B(e).name.toLowerCase().startsWith(m.current.value)});t!==-1&&w(t)},C=(0,X.useCallback)(function(e){return i.findIndex(function(r){return B(r).iso2===e})},[i]),b=v((0,X.useState)(C(a)),2),g=b[0],w=b[1],D=function(){p.current!==a&&w(C(a))},S=(0,X.useCallback)(function(e){var r;w(C(e.iso2)),(r=c)===null||r===void 0?void 0:r(e)},[c,C]),P=function(e){var r=i.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};w(function(e){var n=t(e);return n<0?0:n>r?r:n})},x=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=B(i[g]);S(r);return}if(e.key==="Escape"){var t;(t=s)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),P("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),P("next");return}if(e.key==="PageUp"){e.preventDefault(),P("first");return}if(e.key==="PageDown"){e.preventDefault(),P("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&h(e.key.toLocaleLowerCase())},k=(0,X.useCallback)(function(){if(!y.current||g===void 0)return;var e=B(i[g]).iso2;if(e===p.current)return;var r=y.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(y.current,r),p.current=e)},[g,i]);return(0,X.useEffect)(function(){k()},[g,k]),(0,X.useEffect)(function(){y.current&&(r?y.current.focus():D())},[r]),(0,X.useEffect)(function(){D()},[a]),X.default.createElement("ul",{ref:y,role:"listbox",className:M({addPrefix:["country-selector-dropdown"],rawClassNames:[f.className]}),style:u({display:r?"block":"none"},f.style),onKeyDown:x,onBlur:s,tabIndex:-1,"aria-activedescendant":"".concat(B(i[g]).iso2,"-option")},i.map(function(e,r){var t,o;var i=B(e),u=i.iso2===a,c=r===g,s=(t=l)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return X.default.createElement("li",{key:i.iso2,"data-country":i.iso2,role:"option","aria-selected":u,"aria-label":"".concat(i.name," ").concat(n).concat(i.dialCode),id:"".concat(i.iso2,"-option"),className:M({addPrefix:["country-selector-dropdown__list-item",u&&"country-selector-dropdown__list-item--selected",c&&"country-selector-dropdown__list-item--focused"],rawClassNames:[f.listItemClassName]}),onClick:function(){return S(i)},style:f.listItemStyle},X.default.createElement($,{iso2:i.iso2,src:(o=s)===null||o===void 0?void 0:o.src,className:M({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[f.listItemFlagClassName]}),style:f.listItemFlagStyle}),X.default.createElement("span",{className:M({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[f.listItemCountryNameClassName]}),style:f.listItemCountryNameStyle},i.name),X.default.createElement("span",{className:M({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[f.listItemDialCodeClassName]}),style:f.listItemDialCodeStyle},n,i.dialCode))}))};var et=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?A:o,l=e.flags,c=e.renderButtonWrapper,f=d(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","flags","renderButtonWrapper"]);var y=v((0,N.useState)(!1),2),p=y[0],m=y[1],h=(0,N.useMemo)(function(){if(r)return G({value:r,field:"iso2",countries:i})},[i,r]),C=(0,N.useRef)(null),b=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),m(!0))},g=function(){var e,t,o;var i={title:(e=h)===null||e===void 0?void 0:e.name,onClick:function(){return m(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:b,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":p},d=N.default.createElement("div",{className:M({addPrefix:["country-selector-button__button-content"],rawClassNames:[f.buttonContentWrapperClassName]}),style:f.buttonContentWrapperStyle},N.default.createElement($,{iso2:r,src:(o=l)===null||o===void 0?void 0:(t=o.find(function(e){return e.iso2===r}))===null||t===void 0?void 0:t.src,className:M({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[f.flagClassName]}),style:u({visibility:r?"visible":"hidden"},f.flagStyle)}),!a&&N.default.createElement("div",{className:M({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",p&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[f.dropdownArrowClassName]}),style:f.dropdownArrowStyle}));return c?c({children:d,rootProps:i}):N.default.createElement("button",s(u({},i),{type:"button",className:M({addPrefix:["country-selector-button",p&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[f.buttonClassName]}),"data-country":r,style:f.buttonStyle}),d)};return N.default.createElement("div",{className:M({addPrefix:["country-selector"],rawClassNames:[f.className]}),style:f.style,ref:C},g(),N.default.createElement(er,u({show:p,countries:i,flags:l,onSelect:function(e){var r;m(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){m(!1)}},f.dropdownStyleProps)))};var en=P(require("react"));var ea=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return en.default.createElement("div",{className:M({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eo=P(require("react"));var ei=require("react");var el=require("react");var eu=require("react"),ec=function(){var e=(0,eu.useRef)(),r=(0,eu.useRef)(Date.now());return{check:function(){var t=Date.now(),n=e.current?t-r.current:void 0;return e.current=r.current,r.current=t,n}}};var es={size:20,overrideLastItemDebounceMS:-1};function ed(e,r){var t=u({},es,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,el.useState)(e),2),l=i[0],c=i[1],s=v((0,el.useState)([l]),2),d=s[0],f=s[1],p=v((0,el.useState)(0),2),m=p[0],h=p[1],C=ec();return[l,function(e,r){var t,i;if(typeof e=="object"&&Object.entries(e).toString()===Object.entries(l).toString()||e===l)return;var u=a>0,s=C.check(),v=u&&s!==void 0?s>a:!0;if(((t=r)===null||t===void 0?void 0:t.overrideLastItem)!==void 0?r.overrideLastItem:!v)f(function(r){return y(r.slice(0,m)).concat([e])});else{var p=d.length>=n;f(function(r){return y(r.slice(p?1:0,m+1)).concat([e])}),p||h(function(e){return e+1})}c(e),(i=o)===null||i===void 0?void 0:i(e)},function(){var e;if(m<=0)return{success:!1};var r=d[m-1];return c(r),h(function(e){return e-1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}},function(){var e;if(m+1>=d.length)return{success:!1};var r=d[m+1];return c(r),h(function(e){return e+1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}}]}var ef=".",ev={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,countries:A},ey=function(e){var r=e.defaultCountry,t=r===void 0?ev.defaultCountry:r,n=e.value,a=n===void 0?ev.value:n,o=e.countries,i=o===void 0?ev.countries:o,l=e.prefix,u=l===void 0?ev.prefix:l,c=e.defaultMask,s=c===void 0?ev.defaultMask:c,d=e.charAfterDialCode,f=d===void 0?ev.charAfterDialCode:d,y=e.historySaveDebounceMS,p=y===void 0?ev.historySaveDebounceMS:y,m=e.disableCountryGuess,h=m===void 0?ev.disableCountryGuess:m,C=e.disableDialCodePrefill,b=C===void 0?ev.disableDialCodePrefill:C,g=e.forceDialCode,w=g===void 0?ev.forceDialCode:g,D=e.disableDialCodeAndPrefix,S=D===void 0?ev.disableDialCodeAndPrefix:D,P=e.onChange;var x=S?!1:!h,k=(0,ei.useRef)(null),N=function(e){var r=e.value,t=e.country,n=e.trimNonDigitsEnd,a=e.insertDialCodeOnEmpty,o=e.forceDisableCountryGuess;var l;var c;var d=!o&&x?T({phone:r,countries:i,currentCountryIso2:t.iso2}):void 0,v=(c=(l=d)===null||l===void 0?void 0:l.country)!==null&&c!==void 0?c:t;return{phone:v?W(r,{prefix:u,mask:v.format||s,maskChar:ef,dialCode:v.dialCode,trimNonDigitsEnd:n,charAfterDialCode:f,forceDialCode:w,insertDialCodeOnEmpty:a,disableDialCodeAndPrefix:S}):r,countryGuessResult:d,formatCountry:v}},A=function(e){Promise.resolve().then(function(){var r;(r=k.current)===null||r===void 0?void 0:r.setSelectionRange(e,e)})},j=v(ed(function(){var e=T({phone:a,countries:i,currentCountryIso2:t}).country||G({value:t,field:"iso2",countries:i});e||console.error('[react-international-phone]: can not find a country with "'.concat(t,'" iso2 code'));var r=e||B(i.find(function(e){return B(e).iso2==="us"})),n=N({value:a,country:r,insertDialCodeOnEmpty:!b}).phone;return A(n.length),{phone:n,country:r.iso2}},{overrideLastItemDebounceMS:p,onChange:P}),4),E=j[0],O=E.phone,M=E.country,I=j[1],z=j[2],_=j[3],R=(0,ei.useMemo)(function(){return G({value:M,field:"iso2",countries:i})},[i,M]),q=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=r.deletion,n=r.cursorPosition,a=r.insertDialCodeOnEmpty,o=r.inserted;var i,l,c;var s=e,d=n;w&&!S&&R&&!L(e).startsWith(R.dialCode)&&e&&(o&&e.startsWith(u)&&e.length-(n!==null&&n!==void 0?n:0)===0?s=e:(s=O,d=0));var v=N({value:s,country:R,trimNonDigitsEnd:t==="backward",insertDialCodeOnEmpty:a,forceDisableCountryGuess:w&&!!t&&L(s).length<R.dialCode.length}),y=v.phone,p=v.countryGuessResult,m=R;x&&((i=p)===null||i===void 0?void 0:i.country)&&p.country.name!==M&&p.fullDialCodeMatch&&(m=p.country);var h;var C=U({cursorPositionAfterInput:d!==null&&d!==void 0?d:0,phoneBeforeInput:O,phoneAfterInput:e,phoneAfterFormatted:y,leftOffset:w?u.length+((h=(c=R)===null||c===void 0?void 0:(l=c.dialCode)===null||l===void 0?void 0:l.length)!==null&&h!==void 0?h:0)+f.length:0,deletion:t});return I({phone:y,country:m.iso2}),A(C),y};(0,ei.useEffect)(function(){var e=k.current;if(!e)return;var r=function(e){if(!e.key)return;var r=e.ctrlKey,t=e.shiftKey,n=e.key.toLowerCase()==="z";!r||!n||(t?_():z())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[k,z,_]);var F=function(e){var r;e.preventDefault();var t;var n=e.nativeEvent.inputType,a=function(){var e,r;var t;if((t=(e=n)===null||e===void 0?void 0:e.toLocaleLowerCase().includes("delete"))!==null&&t!==void 0?t:!1)return((r=n)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("forward"))?"forward":"backward"},o=(r=n)===null||r===void 0?void 0:r.startsWith("insertFrom"),i=q(e.target.value,{deletion:a(),inserted:o,cursorPosition:(t=e.target.selectionStart)!==null&&t!==void 0?t:0});return S&&R?K({phone:i,dialCode:R.dialCode,charAfterDialCode:f,prefix:u}):i},V=function(e){var r=G({value:e,field:"iso2",countries:i});if(!r)return;var t=S?"":"".concat(u).concat(r.dialCode).concat(f);I({phone:t,country:r.iso2}),Promise.resolve().then(function(){var e;(e=k.current)===null||e===void 0?void 0:e.focus()})},H=v((0,ei.useState)(!1),2),J=H[0],Z=H[1];return(0,ei.useEffect)(function(){if(!J){var e;Z(!0),a!==O&&((e=P)===null||e===void 0?void 0:e({phone:O,country:M}));return}a!==O&&q(a)},[a]),{phone:O,country:M,setCountry:V,handlePhoneValueChange:F,inputRef:k}};var ep=function(e){var r=e.hideDropdown,t=e.placeholder,n=e.disabled,a=e.showDisabledDialCodeAndPrefix,o=e.inputProps,i=e.flags,l=e.onChange,c=e.style,f=e.className,v=e.inputStyle,y=e.inputClassName,p=e.countrySelectorStyleProps,m=e.dialCodePreviewStyleProps,h=e.value,C=e.countries,b=C===void 0?A:C,g=d(e,["hideDropdown","placeholder","disabled","showDisabledDialCodeAndPrefix","inputProps","flags","onChange","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","value","countries"]);var w;var D=ey(s(u({value:h,countries:b},g),{onChange:function(e){var r;(r=l)===null||r===void 0?void 0:r(e.phone,e.country)}})),S=D.phone,P=D.inputRef,x=D.country,k=D.setCountry,N=D.handlePhoneValueChange,j=(0,eo.useMemo)(function(){if(x)return G({value:x,field:"iso2",countries:b})},[b,x]),E=g.disableDialCodeAndPrefix&&a&&((w=j)===null||w===void 0?void 0:w.dialCode);var O;return eo.default.createElement("div",{className:M({addPrefix:["input-container"],rawClassNames:[f]}),style:c},eo.default.createElement(et,u({onSelect:function(e){return k(e.iso2)},flags:i,selectedCountry:x,countries:b,disabled:n,hideDropdown:r},p)),E&&eo.default.createElement(ea,u({dialCode:j.dialCode,prefix:(O=g.prefix)!==null&&O!==void 0?O:"+",disabled:n},m)),eo.default.createElement("input",u({onChange:N,value:S,type:"tel",ref:P,className:M({addPrefix:["input",n&&"input--disabled"],rawClassNames:[y]}),placeholder:t,disabled:n,style:v},o)))};0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagEmoji:FlagEmoji,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,parseCountry:parseCountry,usePhoneInput:usePhoneInput});

@@ -32,2 +32,6 @@ export type CountryIso2 = (string & {}) | 'af' | 'al' | 'dz' | 'ad' | 'ao' | 'ag' | 'ar' | 'am' | 'aw' | 'au' | 'at' | 'az' | 'bs' | 'bh' | 'bd' | 'bb' | 'by' | 'be' | 'bz' | 'bj' | 'bt' | 'bo' | 'ba' | 'bw' | 'br' | 'io' | 'bn' | 'bg' | 'bf' | 'bi' | 'kh' | 'cm' | 'ca' | 'cv' | 'bq' | 'cf' | 'td' | 'cl' | 'cn' | 'co' | 'km' | 'cd' | 'cg' | 'cr' | 'ci' | 'hr' | 'cu' | 'cw' | 'cy' | 'cz' | 'dk' | 'dj' | 'dm' | 'do' | 'ec' | 'eg' | 'sv' | 'gq' | 'er' | 'ee' | 'et' | 'fj' | 'fi' | 'fr' | 'gf' | 'pf' | 'ga' | 'gm' | 'ge' | 'de' | 'gh' | 'gr' | 'gd' | 'gp' | 'gu' | 'gt' | 'gn' | 'gw' | 'gy' | 'ht' | 'hn' | 'hk' | 'hu' | 'is' | 'in' | 'id' | 'ir' | 'iq' | 'ie' | 'il' | 'it' | 'jm' | 'jp' | 'jo' | 'kz' | 'ke' | 'ki' | 'xk' | 'kw' | 'kg' | 'la' | 'lv' | 'lb' | 'ls' | 'lr' | 'ly' | 'li' | 'lt' | 'lu' | 'mo' | 'mk' | 'mg' | 'mw' | 'my' | 'mv' | 'ml' | 'mt' | 'mh' | 'mq' | 'mr' | 'mu' | 'mx' | 'fm' | 'md' | 'mc' | 'mn' | 'me' | 'ma' | 'mz' | 'mm' | 'na' | 'nr' | 'np' | 'nl' | 'nc' | 'nz' | 'ni' | 'ne' | 'ng' | 'kp' | 'no' | 'om' | 'pk' | 'pw' | 'ps' | 'pa' | 'pg' | 'py' | 'pe' | 'ph' | 'pl' | 'pt' | 'pr' | 'qa' | 're' | 'ro' | 'ru' | 'rw' | 'kn' | 'lc' | 'vc' | 'ws' | 'sm' | 'st' | 'sa' | 'sn' | 'rs' | 'sc' | 'sl' | 'sg' | 'sk' | 'si' | 'sb' | 'so' | 'za' | 'kr' | 'ss' | 'es' | 'lk' | 'sd' | 'sr' | 'sz' | 'se' | 'ch' | 'sy' | 'tw' | 'tj' | 'tz' | 'th' | 'tl' | 'tg' | 'to' | 'tt' | 'tn' | 'tr' | 'tm' | 'tv' | 'ug' | 'ua' | 'ae' | 'gb' | 'us' | 'uy' | 'uz' | 'vu' | 'va' | 've' | 'vn' | 'ye' | 'zm' | 'zw';

}
export interface CustomFlagImage {
src: string;
iso2: CountryIso2;
}
export {};
{
"name": "react-international-phone",
"version": "3.0.2",
"version": "3.1.0",
"description": "☎️ International phone input component for React",

@@ -41,2 +41,3 @@ "keywords": [

"scripts": {
"cm": "cz",
"build": "tsup && tsc --emitDeclarationOnly",

@@ -47,2 +48,3 @@ "test": "jest",

"storybook:build": "sb build",
"storybook:preview": "npx http-server ./storybook-static",
"storybook-test:chrome": "npx playwright test ./.storybook/browser.test --headed --browser=chromium",

@@ -52,5 +54,6 @@ "storybook-test:firefox": "npx playwright test ./.storybook/browser.test --headed --browser=firefox",

"lint": "pnpm lint:ts && pnpm lint:scss",
"lint:ts": "eslint ./src --ext .ts,.tsx --config .eslintrc --fix",
"lint:scss": "stylelint \"**/*{.css,.scss}\" --custom-syntax postcss-scss --fix",
"lint:ts": "eslint ./src --ext .ts,.tsx --config .eslintrc",
"lint:scss": "stylelint \"**/*{.css,.scss}\" --custom-syntax postcss-scss",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky install",

@@ -101,2 +104,4 @@ "semantic-release": "semantic-release",

"antd": "^5.0.2",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"esbuild-sass-plugin": "^2.12.0",

@@ -103,0 +108,0 @@ "eslint": "^7.32.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc