react-international-phone
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -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,u;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;u=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw u}}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 u(){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 l(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)||y(e,t)||i()}function p(e){return t(e)||a(e)||y(e)||u()}function y(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 b=Object.getOwnPropertyDescriptor;var C=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})},P=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var u=function(){var a=c.value;!w.call(e,a)&&a!==t&&h(e,a,{get:function(){return r[a]},enumerable:!(n=b(r,a))||n.enumerable})};for(var l=C(r)[Symbol.iterator](),c;!(a=(c=l.next()).done);a=true)u()}catch(e){o=true;i=e}finally{try{if(!a&&l.return!=null){l.return()}}finally{if(o){throw i}}}return e};var S=function(e,r,t){return t=e!=null?m(g(e)):{},P(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)},x=function(e){return P(h({},"__esModule",{value:!0}),e)};var k={};D(k,{CountrySelector:function(){return em},CountrySelectorDropdown:function(){return ey},DialCodePreview:function(){return eb},FlagImage:function(){return ef},PhoneInput:function(){return eg},buildCountryData:function(){return B},defaultCountries:function(){return A},getActiveFormattingMask:function(){return er},getCountry:function(){return ea},guessCountryByPartialPhoneNumber:function(){return eo},parseCountry:function(){return et},removeDialCode:function(){return V},usePhoneInput:function(){return ee}});module.exports=x(k);var N=S(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",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ..."},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 E="react-international-phone-",M=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 M.apply(void 0,p(r)).split(" ").map(function(e){return"".concat(E).concat(e)}).join(" ")},j=function(e){var r=e.addPrefix,t=e.rawClassNames;return M.apply(void 0,[O.apply(void 0,p(r))].concat(p(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,u=i===void 0?!1:i;if(r.length<o)return r;var l=r.slice(0,o),c=r.slice(o),s=l,d=0;var f=true,v=false,p=undefined;try{for(var y=t.split("")[Symbol.iterator](),m;!(f=(m=y.next()).done);f=true){var h=m.value;if(d>=c.length){if(!u&&h!==n){s+=h;continue}break}h===n?(s+=c[d],d+=1):s+=h}}catch(e){v=true;p=e}finally{try{if(!f&&y.return!=null){y.return()}}finally{if(v){throw p}}}return s};var L=function(e){return e?/^\d+$/.test(e):!1};var _=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 B=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,u=[r,t,n,a,o,i];for(var l=0;l<u.length;l+=1){if(l===0)continue;var c=u[l-1],s=u[l];if(c===void 0&&s!==void 0){var d=JSON.stringify(u,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 u.filter(function(e){return e!==void 0})};var F=require("react");var V=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 u=r;return u.startsWith(a)&&(u=u.replace(a,"")),u.startsWith(t)?(u=u.replace(t,""),u.startsWith(i)&&(u=u.replace(i,"")),u):r};var R=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=_(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,t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},u=i(),l=u.phoneLeftSide,c=u.phoneRightSide;return l="".concat(r.prefix).concat(l).concat(r.charAfterDialCode),c=I({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd||r.disableDialCodeAndPrefix&&c.length===0}),r.disableDialCodeAndPrefix&&(l=""),o("".concat(l).concat(c))};var G=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,u=e.deletion;if(a<i)return i;if(!r)return n.length;var l=null;for(var c=a-1;c>=0;c-=1)if(L(t[c])){l=c;break}if(l===null){for(var s=0;s<t.length;s+=1)if(L(n[s]))return s;return t.length}var d=0;for(var f=0;f<l;f+=1)L(t[f])&&(d+=1);var v=0,p=0;for(var y=0;y<n.length&&(v+=1,L(n[y])&&(p+=1),!(p>=d+1));y+=1);if(u!=="backward")for(;!L(n[v])&&v<n.length;)v+=1;return v};var T=function(e){var r=e.phone,t=e.prefix;return r?"".concat(t).concat(_(r)):""};function q(e){var r=e.value,t=e.country,n=e.insertDialCodeOnEmpty,a=e.trimNonDigitsEnd,o=e.countries,i=e.prefix,u=e.charAfterDialCode,l=e.forceDialCode,c=e.disableDialCodeAndPrefix,s=e.defaultMask,d=e.countryGuessingEnabled,f=e.disableFormatting;var v,p,y;var m=r;c&&(m=m.startsWith("".concat(i))?m:"".concat(i).concat(t.dialCode).concat(m));var h;var b=d?eo({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,C=(h=(p=b)===null||p===void 0?void 0:p.country)!==null&&h!==void 0?h:t,g=R(m,{prefix:i,mask:er({phone:m,country:C,defaultMask:s,disableFormatting:f}),maskChar:Y,dialCode:C.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=d&&!((y=b)===null||y===void 0?void 0:y.fullDialCodeMatch)?t:C;return{phone:T({phone:c?"".concat(w.dialCode).concat(g):g,prefix:i}),inputValue:g,country:w}}var K=function(e){var r,t;var n;if((n=(r=e)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("delete"))!==null&&n!==void 0?n:!1)return((t=e)===null||t===void 0?void 0:t.toLocaleLowerCase().includes("forward"))?"forward":"backward"},W=function(e,r){var t=r.country,n=r.insertDialCodeOnEmpty,a=r.phoneBeforeInput,o=r.prefix,i=r.charAfterDialCode,u=r.forceDialCode,l=r.disableDialCodeAndPrefix,c=r.countryGuessingEnabled,s=r.defaultMask,d=r.disableFormatting,f=r.countries;var v,p,y,m;var h;var b=e.nativeEvent,C=b.inputType,g=K(C),w=!!((v=C)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=C==="insertText",P=((p=b)===null||p===void 0?void 0:p.data)||void 0,S=e.target.value,x=(h=e.target.selectionStart)!==null&&h!==void 0?h:0;if((y=C)===null||y===void 0?void 0:y.includes("history"))return{inputValue:a,phone:T({phone:a,prefix:o}),cursorPosition:a.length,country:t};var k;if(D&&!L(P)&&S!==o)return{inputValue:a,phone:T({phone:l?"".concat(t.dialCode).concat(a):a,prefix:o}),cursorPosition:x-((k=(m=P)===null||m===void 0?void 0:m.length)!==null&&k!==void 0?k:0),country:t};if(u&&!S.startsWith("".concat(o).concat(t.dialCode))&&!w){var N=S?a:"".concat(o).concat(t.dialCode).concat(i);return{inputValue:N,phone:T({phone:N,prefix:o}),cursorPosition:o.length+t.dialCode.length+i.length,country:t}}var A=q({value:S,country:t,trimNonDigitsEnd:g==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:c,countries:f,prefix:o,charAfterDialCode:i,forceDialCode:u,disableDialCodeAndPrefix:l,disableFormatting:d,defaultMask:s}),E=A.phone,M=A.inputValue,O=A.country,j=G({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:M,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:E,inputValue:M,cursorPosition:j,country:O}};var U=require("react");var H=function(e,r){var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;var a=true,o=false,i=undefined;try{for(var u=t[Symbol.iterator](),l;!(a=(l=u.next()).done);a=true){var c=l.value;if(e[c]!==r[c])return!1}}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return!0};var J=require("react"),Z=function(){var e=(0,J.useRef)(),r=(0,J.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 $={size:20,overrideLastItemDebounceMS:-1};function Q(e,r){var t=l({},$,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,U.useState)(e),2),u=i[0],c=i[1],s=v((0,U.useState)([u]),2),d=s[0],f=s[1],y=v((0,U.useState)(0),2),m=y[0],h=y[1],b=Z();return[u,function(e,r){var t,i;if(typeof e=="object"&&typeof u=="object"&&H(e,u)||e===u)return;var l=a>0,s=b.check(),v=l&&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 p(r.slice(0,m)).concat([e])});else{var y=d.length>=n;f(function(r){return p(r.slice(y?1:0,m+1)).concat([e])}),y||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 Y=".",X={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,countries:A},ee=function(e){var r=e.defaultCountry,t=r===void 0?X.defaultCountry:r,n=e.value,a=n===void 0?X.value:n,o=e.countries,i=o===void 0?X.countries:o,u=e.prefix,c=u===void 0?X.prefix:u,s=e.defaultMask,d=s===void 0?X.defaultMask:s,f=e.charAfterDialCode,p=f===void 0?X.charAfterDialCode:f,y=e.historySaveDebounceMS,m=y===void 0?X.historySaveDebounceMS:y,h=e.disableCountryGuess,b=h===void 0?X.disableCountryGuess:h,C=e.disableDialCodePrefill,g=C===void 0?X.disableDialCodePrefill:C,w=e.forceDialCode,D=w===void 0?X.forceDialCode:w,P=e.disableDialCodeAndPrefix,S=P===void 0?X.disableDialCodeAndPrefix:P,x=e.disableFormatting,k=x===void 0?X.disableFormatting:x,N=e.onChange,A=e.inputRef;var E={countries:i,prefix:c,charAfterDialCode:p,forceDialCode:S?!1:D,disableDialCodeAndPrefix:S,defaultMask:d,countryGuessingEnabled:!b,disableFormatting:k},M=(0,F.useRef)(null),O=A||M,j=function(e){Promise.resolve().then(function(){var r;(r=O.current)===null||r===void 0?void 0:r.setSelectionRange(e,e)})},I=v(Q(function(){var e=ea({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||ea({value:"us",field:"iso2",countries:i}),n=q(l({value:a,country:r,insertDialCodeOnEmpty:!g},E)),o=n.phone,u=n.inputValue,c=n.country;return j(u.length),{phone:o,inputValue:u,country:c.iso2}},{overrideLastItemDebounceMS:m,onChange:function(e){var r=e.inputValue,t=e.phone,n=e.country;if(!N)return;var a=T(n);N({phone:t,inputValue:r,country:a})}}),4),L=I[0],_=L.phone,z=L.inputValue,B=L.country,V=I[1],R=I[2],G=I[3],T=(0,F.useCallback)(function(e){return ea({value:e,field:"iso2",countries:i})},[i]),K=(0,F.useMemo)(function(){return T(B)},[B,T]);(0,F.useEffect)(function(){var e=O.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?G():R())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[O,R,G]);var U=function(e){e.preventDefault();var r=W(e,l({country:K,phoneBeforeInput:z,insertDialCodeOnEmpty:!1},E)),t=r.phone,n=r.inputValue,o=r.country,i=r.cursorPosition;return V({inputValue:n,phone:t,country:o.iso2}),j(i),a},H=function(e){var r=ea({value:e,field:"iso2",countries:i});if(!r){console.error('[react-international-phone]: can not find a country with "'.concat(e,'" iso2 code'));return}var t=S?"":"".concat(c).concat(r.dialCode).concat(p);V({inputValue:t,phone:"".concat(c).concat(r.dialCode),country:r.iso2}),Promise.resolve().then(function(){var e;(e=O.current)===null||e===void 0?void 0:e.focus()})},J=v((0,F.useState)(!1),2),Z=J[0],$=J[1];return(0,F.useEffect)(function(){if(!Z){var e;$(!0),a!==_&&((e=N)===null||e===void 0?void 0:e({inputValue:z,phone:_,country:K}));return}if(a===_)return;var r=q(l({value:a,country:K,insertDialCodeOnEmpty:!g},E)),t=r.phone,n=r.inputValue,o=r.country;V({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:_,inputValue:z,country:K,setCountry:H,handlePhoneValueChange:U,inputRef:O}};var er=function(e){var r=e.phone,t=e.country,n=e.defaultMask,a=n===void 0?"............":n,o=e.disableFormatting,i=o===void 0?!1:o;var u=t.format,l=function(e){return i?e.replace(new RegExp("[^".concat(Y,"]"),"g"),""):e};if(!u)return l(a);if(typeof u=="string")return l(u);if(!u.default)return console.error("[react-international-phone]: default mask for ".concat(t.iso2," is not provided")),l(a);var c=Object.keys(u).find(function(e){if(e==="default")return!1;if(!(e.charAt(0)==="/"&&e.charAt(e.length-1)==="/"))return console.error('[react-international-phone]: format regex "'.concat(e,'" for ').concat(t.iso2," is not valid")),!1;var n=new RegExp(e.substring(1,e.length-1)),a=r.replace(t.dialCode,"");return n.test(_(a))});return l(c?u[c]:u.default)};var et=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],u=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:u}};var en=function(e){return'Field "'.concat(e,'" is not supported')},ea=function(e){var r=e.field,t=e.value,n=e.countries,a=n===void 0?A:n;if(["priority"].includes(r))throw new Error(en(r));var o=a.find(function(e){var n=et(e);return t===n[r]});if(o)return et(o)};var eo=function(e){var r=e.phone,t=e.countries,n=t===void 0?A:t,a=e.currentCountryIso2;var o={country:void 0,fullDialCodeMatch:!1};if(!r)return o;var i=_(r);if(!i)return o;var u=o,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,i;var l=r.dialCode===((n=u.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((i=(a=u.country)===null||a===void 0?void 0:a.priority)!==null&&i!==void 0?i:0);(!l||c)&&(u={country:r,fullDialCodeMatch:t})};var c=true,s=false,d=undefined;try{for(var f=n[Symbol.iterator](),v;!(c=(v=f.next()).done);c=true){var p=v.value;var y=et(p),m=y.dialCode,h=y.areaCodes;if(i.startsWith(m)){var b=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var C=i.substring(m.length);var g=true,w=false,D=undefined;try{for(var P=h[Symbol.iterator](),S;!(g=(S=P.next()).done);g=true){var x=S.value;if(C.startsWith(x))return{country:y,fullDialCodeMatch:!0}}}catch(e){w=true;D=e}finally{try{if(!g&&P.return!=null){P.return()}}finally{if(w){throw D}}}}(b||m===i||!u.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}u.fullDialCodeMatch||i.length<m.length&&m.startsWith(i)&&(!u.country||Number(m)<=Number(u.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){s=true;d=e}finally{try{if(!c&&f.return!=null){f.return()}}finally{if(s){throw d}}}if(a){var k;var N=ea({value:a,field:"iso2",countries:n});if(!N)return u;var E=N?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=i.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(N):!1;!!u&&((k=u.country)===null||k===void 0?void 0:k.dialCode)===N.dialCode&&u.country!==N&&u.fullDialCodeMatch&&(!N.areaCodes||E)&&(u={country:N,fullDialCodeMatch:!0})}return u};var ei=S(require("react"));var eu=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},el="abcdefghijklmnopqrstuvwxyz",ec="1f1e6",es=el.split("").reduce(function(e,r,t){return s(l({},e),n({},r,eu(ec,t)))},{}),ed=function(e){return[es[e[0]],es[e[1]]].join("-")},ef=function(e){var r=e.iso2,t=e.size,n=e.src,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,u=e.className,c=e.style,s=d(e,["iso2","size","src","protocol","disableLazyLoading","className","style"]);if(!r)return ei.default.createElement("img",l({className:j({addPrefix:["flag-emoji"],rawClassNames:[u]}),width:t,height:t},s));var f=function(){if(n)return n;var e=ed(r);return"".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(e,".svg")};return ei.default.createElement("img",l({className:j({addPrefix:["flag-emoji"],rawClassNames:[u]}),src:f(),width:t,height:t,draggable:!1,"data-country":r,loading:i?void 0:"lazy",style:l({width:t,height:t},c),alt:""},s))};var ev=S(require("react"));var ep=1e3,ey=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,u=e.flags,c=e.onSelect,s=e.onClose,f=d(e,["show","dialCodePrefix","selectedCountry","countries","flags","onSelect","onClose"]);var p=(0,ev.useRef)(null),y=(0,ev.useRef)(),m=(0,ev.useRef)({updatedAt:void 0,value:""}),h=function(e){var r=m.current.updatedAt&&new Date().getTime()-m.current.updatedAt.getTime()>ep;m.current={value:r?e:"".concat(m.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return et(e).name.toLowerCase().startsWith(m.current.value)});t!==-1&&w(t)},b=(0,ev.useCallback)(function(e){return i.findIndex(function(r){return et(r).iso2===e})},[i]),C=v((0,ev.useState)(b(a)),2),g=C[0],w=C[1],D=function(){y.current!==a&&w(b(a))},P=(0,ev.useCallback)(function(e){var r;w(b(e.iso2)),(r=c)===null||r===void 0?void 0:r(e)},[c,b]),S=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=et(i[g]);P(r);return}if(e.key==="Escape"){var t;(t=s)===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&&h(e.key.toLocaleLowerCase())},k=(0,ev.useCallback)(function(){if(!p.current||g===void 0)return;var e=et(i[g]).iso2;if(e===y.current)return;var r=p.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(p.current,r),y.current=e)},[g,i]);return(0,ev.useEffect)(function(){k()},[g,k]),(0,ev.useEffect)(function(){p.current&&(r?p.current.focus():D())},[r]),(0,ev.useEffect)(function(){D()},[a]),ev.default.createElement("ul",{ref:p,role:"listbox",className:j({addPrefix:["country-selector-dropdown"],rawClassNames:[f.className]}),style:l({display:r?"block":"none"},f.style),onKeyDown:x,onBlur:s,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(et(i[g]).iso2,"-option")},i.map(function(e,r){var t,o;var i=et(e),l=i.iso2===a,c=r===g,s=(t=u)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ev.default.createElement("li",{key:i.iso2,"data-country":i.iso2,role:"option","aria-selected":l,"aria-label":"".concat(i.name," ").concat(n).concat(i.dialCode),id:"react-international-phone__".concat(i.iso2,"-option"),className:j({addPrefix:["country-selector-dropdown__list-item",l&&"country-selector-dropdown__list-item--selected",c&&"country-selector-dropdown__list-item--focused"],rawClassNames:[f.listItemClassName]}),onClick:function(){return P(i)},style:f.listItemStyle,title:i.name},ev.default.createElement(ef,{iso2:i.iso2,src:(o=s)===null||o===void 0?void 0:o.src,className:j({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[f.listItemFlagClassName]}),style:f.listItemFlagStyle}),ev.default.createElement("span",{className:j({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[f.listItemCountryNameClassName]}),style:f.listItemCountryNameStyle},i.name),ev.default.createElement("span",{className:j({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[f.listItemDialCodeClassName]}),style:f.listItemDialCodeStyle},n,i.dialCode))}))};var em=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?A:o,u=e.flags,c=e.renderButtonWrapper,f=d(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","flags","renderButtonWrapper"]);var p=v((0,N.useState)(!1),2),y=p[0],m=p[1],h=(0,N.useMemo)(function(){if(r)return ea({value:r,field:"iso2",countries:i})},[i,r]),b=(0,N.useRef)(null),C=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:C,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":y},d=N.default.createElement("div",{className:j({addPrefix:["country-selector-button__button-content"],rawClassNames:[f.buttonContentWrapperClassName]}),style:f.buttonContentWrapperStyle},N.default.createElement(ef,{iso2:r,src:(o=u)===null||o===void 0?void 0:(t=o.find(function(e){return e.iso2===r}))===null||t===void 0?void 0:t.src,className:j({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[f.flagClassName]}),style:l({visibility:r?"visible":"hidden"},f.flagStyle)}),!a&&N.default.createElement("div",{className:j({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",y&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[f.dropdownArrowClassName]}),style:f.dropdownArrowStyle}));return c?c({children:d,rootProps:i}):N.default.createElement("button",s(l({},i),{type:"button",className:j({addPrefix:["country-selector-button",y&&"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:j({addPrefix:["country-selector"],rawClassNames:[f.className]}),style:f.style,ref:b},g(),N.default.createElement(ey,l({show:y,countries:i,flags:u,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 eh=S(require("react"));var eb=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eh.default.createElement("div",{className:j({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eC=S(require("react"));var eg=(0,eC.forwardRef)(function(e,r){var t=e.value,n=e.onChange,a=e.countries,o=a===void 0?A:a,i=e.hideDropdown,u=e.showDisabledDialCodeAndPrefix,c=e.flags,f=e.style,v=e.className,p=e.inputStyle,y=e.inputClassName,m=e.countrySelectorStyleProps,h=e.dialCodePreviewStyleProps,b=e.inputProps,C=e.placeholder,g=e.disabled,w=e.name,D=e.onFocus,P=e.onBlur,S=e.required,x=e.autoFocus,k=d(e,["value","onChange","countries","hideDropdown","showDisabledDialCodeAndPrefix","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var N;var E=ee(s(l({value:t,countries:o},k),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),M=E.phone,O=E.inputValue,I=E.inputRef,L=E.country,_=E.setCountry,z=E.handlePhoneValueChange,B=k.disableDialCodeAndPrefix&&u&&((N=L)===null||N===void 0?void 0:N.dialCode);var F;return(0,eC.useImperativeHandle)(r,function(){return I.current?Object.assign(I.current,{setCountry:_,state:{phone:M,inputValue:O,country:L}}):null},[I,_,M,O,L]),eC.default.createElement("div",{ref:r,className:j({addPrefix:["input-container"],rawClassNames:[v]}),style:f},eC.default.createElement(em,l({onSelect:function(e){return _(e.iso2)},flags:c,selectedCountry:L.iso2,countries:o,disabled:g,hideDropdown:i},m)),B&&eC.default.createElement(eb,l({dialCode:L.dialCode,prefix:(F=k.prefix)!==null&&F!==void 0?F:"+",disabled:g},h)),eC.default.createElement("input",l({onChange:z,value:O,type:"tel",ref:I,className:j({addPrefix:["input",g&&"input--disabled"],rawClassNames:[y]}),placeholder:C,disabled:g,style:p,name:w,onFocus:D,onBlur:P,autoFocus:x,required:S},b)))});0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagImage:FlagImage,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,getActiveFormattingMask:getActiveFormattingMask,getCountry:getCountry,guessCountryByPartialPhoneNumber:guessCountryByPartialPhoneNumber,parseCountry:parseCountry,removeDialCode:removeDialCode,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,u;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;u=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw u}}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 u(){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 l(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)||y(e,t)||i()}function p(e){return t(e)||a(e)||y(e)||u()}function y(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 b=Object.getOwnPropertyDescriptor;var C=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})},P=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var u=function(){var a=c.value;!w.call(e,a)&&a!==t&&h(e,a,{get:function(){return r[a]},enumerable:!(n=b(r,a))||n.enumerable})};for(var l=C(r)[Symbol.iterator](),c;!(a=(c=l.next()).done);a=true)u()}catch(e){o=true;i=e}finally{try{if(!a&&l.return!=null){l.return()}}finally{if(o){throw i}}}return e};var S=function(e,r,t){return t=e!=null?m(g(e)):{},P(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)},x=function(e){return P(h({},"__esModule",{value:!0}),e)};var k={};D(k,{CountrySelector:function(){return em},CountrySelectorDropdown:function(){return ey},DialCodePreview:function(){return eb},FlagImage:function(){return ef},PhoneInput:function(){return eg},buildCountryData:function(){return B},defaultCountries:function(){return A},getActiveFormattingMask:function(){return er},getCountry:function(){return ea},guessCountryByPartialPhoneNumber:function(){return eo},parseCountry:function(){return et},removeDialCode:function(){return V},usePhoneInput:function(){return ee}});module.exports=x(k);var N=S(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",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ..."},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 E="react-international-phone-",M=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 M.apply(void 0,p(r)).split(" ").map(function(e){return"".concat(E).concat(e)}).join(" ")},j=function(e){var r=e.addPrefix,t=e.rawClassNames;return M.apply(void 0,[O.apply(void 0,p(r))].concat(p(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,u=i===void 0?!1:i;if(r.length<o)return r;var l=r.slice(0,o),c=r.slice(o),s=l,d=0;var f=true,v=false,p=undefined;try{for(var y=t.split("")[Symbol.iterator](),m;!(f=(m=y.next()).done);f=true){var h=m.value;if(d>=c.length){if(!u&&h!==n){s+=h;continue}break}h===n?(s+=c[d],d+=1):s+=h}}catch(e){v=true;p=e}finally{try{if(!f&&y.return!=null){y.return()}}finally{if(v){throw p}}}return s};var L=function(e){return e?/^\d+$/.test(e):!1};var _=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 B=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,u=[r,t,n,a,o,i];for(var l=0;l<u.length;l+=1){if(l===0)continue;var c=u[l-1],s=u[l];if(c===void 0&&s!==void 0){var d=JSON.stringify(u,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 u.filter(function(e){return e!==void 0})};var F=require("react");var V=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 u=r;return u.startsWith(a)&&(u=u.replace(a,"")),u.startsWith(t)?(u=u.replace(t,""),u.startsWith(i)&&(u=u.replace(i,"")),u):r};var R=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=_(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,t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},u=i(),l=u.phoneLeftSide,c=u.phoneRightSide;return l="".concat(r.prefix).concat(l).concat(r.charAfterDialCode),c=I({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd||r.disableDialCodeAndPrefix&&c.length===0}),r.disableDialCodeAndPrefix&&(l=""),o("".concat(l).concat(c))};var G=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,u=e.deletion;if(a<i)return i;if(!r)return n.length;var l=null;for(var c=a-1;c>=0;c-=1)if(L(t[c])){l=c;break}if(l===null){for(var s=0;s<t.length;s+=1)if(L(n[s]))return s;return t.length}var d=0;for(var f=0;f<l;f+=1)L(t[f])&&(d+=1);var v=0,p=0;for(var y=0;y<n.length&&(v+=1,L(n[y])&&(p+=1),!(p>=d+1));y+=1);if(u!=="backward")for(;!L(n[v])&&v<n.length;)v+=1;return v};var T=function(e){var r=e.phone,t=e.prefix;return r?"".concat(t).concat(_(r)):""};function q(e){var r=e.value,t=e.country,n=e.insertDialCodeOnEmpty,a=e.trimNonDigitsEnd,o=e.countries,i=e.prefix,u=e.charAfterDialCode,l=e.forceDialCode,c=e.disableDialCodeAndPrefix,s=e.defaultMask,d=e.countryGuessingEnabled,f=e.disableFormatting;var v,p,y;var m=r;c&&(m=m.startsWith("".concat(i))?m:"".concat(i).concat(t.dialCode).concat(m));var h;var b=d?eo({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,C=(h=(p=b)===null||p===void 0?void 0:p.country)!==null&&h!==void 0?h:t,g=R(m,{prefix:i,mask:er({phone:m,country:C,defaultMask:s,disableFormatting:f}),maskChar:Y,dialCode:C.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=d&&!((y=b)===null||y===void 0?void 0:y.fullDialCodeMatch)?t:C;return{phone:T({phone:c?"".concat(w.dialCode).concat(g):g,prefix:i}),inputValue:g,country:w}}var K=function(e){var r,t;var n;if((n=(r=e)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("delete"))!==null&&n!==void 0?n:!1)return((t=e)===null||t===void 0?void 0:t.toLocaleLowerCase().includes("forward"))?"forward":"backward"},W=function(e,r){var t=r.country,n=r.insertDialCodeOnEmpty,a=r.phoneBeforeInput,o=r.prefix,i=r.charAfterDialCode,u=r.forceDialCode,l=r.disableDialCodeAndPrefix,c=r.countryGuessingEnabled,s=r.defaultMask,d=r.disableFormatting,f=r.countries;var v,p,y,m;var h;var b=e.nativeEvent,C=b.inputType,g=K(C),w=!!((v=C)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=C==="insertText",P=((p=b)===null||p===void 0?void 0:p.data)||void 0,S=e.target.value,x=(h=e.target.selectionStart)!==null&&h!==void 0?h:0;if((y=C)===null||y===void 0?void 0:y.includes("history"))return{inputValue:a,phone:T({phone:a,prefix:o}),cursorPosition:a.length,country:t};var k;if(D&&!L(P)&&S!==o)return{inputValue:a,phone:T({phone:l?"".concat(t.dialCode).concat(a):a,prefix:o}),cursorPosition:x-((k=(m=P)===null||m===void 0?void 0:m.length)!==null&&k!==void 0?k:0),country:t};if(u&&!S.startsWith("".concat(o).concat(t.dialCode))&&!w){var N=S?a:"".concat(o).concat(t.dialCode).concat(i);return{inputValue:N,phone:T({phone:N,prefix:o}),cursorPosition:o.length+t.dialCode.length+i.length,country:t}}var A=q({value:S,country:t,trimNonDigitsEnd:g==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:c,countries:f,prefix:o,charAfterDialCode:i,forceDialCode:u,disableDialCodeAndPrefix:l,disableFormatting:d,defaultMask:s}),E=A.phone,M=A.inputValue,O=A.country,j=G({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:M,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:E,inputValue:M,cursorPosition:j,country:O}};var U=require("react");var H=function(e,r){var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;var a=true,o=false,i=undefined;try{for(var u=t[Symbol.iterator](),l;!(a=(l=u.next()).done);a=true){var c=l.value;if(e[c]!==r[c])return!1}}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return!0};var J=require("react"),Z=function(){var e=(0,J.useRef)(),r=(0,J.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 $={size:20,overrideLastItemDebounceMS:-1};function Q(e,r){var t=l({},$,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,U.useState)(e),2),u=i[0],c=i[1],s=v((0,U.useState)([u]),2),d=s[0],f=s[1],y=v((0,U.useState)(0),2),m=y[0],h=y[1],b=Z();return[u,function(e,r){var t,i;if(typeof e=="object"&&typeof u=="object"&&H(e,u)||e===u)return;var l=a>0,s=b.check(),v=l&&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 p(r.slice(0,m)).concat([e])});else{var y=d.length>=n;f(function(r){return p(r.slice(y?1:0,m+1)).concat([e])}),y||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 Y=".",X={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,countries:A},ee=function(e){var r=e.defaultCountry,t=r===void 0?X.defaultCountry:r,n=e.value,a=n===void 0?X.value:n,o=e.countries,i=o===void 0?X.countries:o,u=e.prefix,c=u===void 0?X.prefix:u,s=e.defaultMask,d=s===void 0?X.defaultMask:s,f=e.charAfterDialCode,p=f===void 0?X.charAfterDialCode:f,y=e.historySaveDebounceMS,m=y===void 0?X.historySaveDebounceMS:y,h=e.disableCountryGuess,b=h===void 0?X.disableCountryGuess:h,C=e.disableDialCodePrefill,g=C===void 0?X.disableDialCodePrefill:C,w=e.forceDialCode,D=w===void 0?X.forceDialCode:w,P=e.disableDialCodeAndPrefix,S=P===void 0?X.disableDialCodeAndPrefix:P,x=e.disableFormatting,k=x===void 0?X.disableFormatting:x,N=e.onChange,A=e.inputRef;var E={countries:i,prefix:c,charAfterDialCode:p,forceDialCode:S?!1:D,disableDialCodeAndPrefix:S,defaultMask:d,countryGuessingEnabled:!b,disableFormatting:k},M=(0,F.useRef)(null),O=A||M,j=function(e){Promise.resolve().then(function(){var r;(r=O.current)===null||r===void 0?void 0:r.setSelectionRange(e,e)})},I=v(Q(function(){var e=ea({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||ea({value:"us",field:"iso2",countries:i}),n=q(l({value:a,country:r,insertDialCodeOnEmpty:!g},E)),o=n.phone,u=n.inputValue,c=n.country;return j(u.length),{phone:o,inputValue:u,country:c.iso2}},{overrideLastItemDebounceMS:m,onChange:function(e){var r=e.inputValue,t=e.phone,n=e.country;if(!N)return;var a=T(n);N({phone:t,inputValue:r,country:a})}}),4),L=I[0],_=L.phone,z=L.inputValue,B=L.country,V=I[1],R=I[2],G=I[3],T=(0,F.useCallback)(function(e){return ea({value:e,field:"iso2",countries:i})},[i]),K=(0,F.useMemo)(function(){return T(B)},[B,T]);(0,F.useEffect)(function(){var e=O.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?G():R())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[O,R,G]);var U=function(e){e.preventDefault();var r=W(e,l({country:K,phoneBeforeInput:z,insertDialCodeOnEmpty:!1},E)),t=r.phone,n=r.inputValue,o=r.country,i=r.cursorPosition;return V({inputValue:n,phone:t,country:o.iso2}),j(i),a},H=function(e){var r=ea({value:e,field:"iso2",countries:i});if(!r){console.error('[react-international-phone]: can not find a country with "'.concat(e,'" iso2 code'));return}var t=S?"":"".concat(c).concat(r.dialCode).concat(p);V({inputValue:t,phone:"".concat(c).concat(r.dialCode),country:r.iso2}),Promise.resolve().then(function(){var e;(e=O.current)===null||e===void 0?void 0:e.focus()})},J=v((0,F.useState)(!1),2),Z=J[0],$=J[1];return(0,F.useEffect)(function(){if(!Z){var e;$(!0),a!==_&&((e=N)===null||e===void 0?void 0:e({inputValue:z,phone:_,country:K}));return}if(a===_)return;var r=q(l({value:a,country:K,insertDialCodeOnEmpty:!g},E)),t=r.phone,n=r.inputValue,o=r.country;V({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:_,inputValue:z,country:K,setCountry:H,handlePhoneValueChange:U,inputRef:O}};var er=function(e){var r=e.phone,t=e.country,n=e.defaultMask,a=n===void 0?"............":n,o=e.disableFormatting,i=o===void 0?!1:o;var u=t.format,l=function(e){return i?e.replace(new RegExp("[^".concat(Y,"]"),"g"),""):e};if(!u)return l(a);if(typeof u=="string")return l(u);if(!u.default)return console.error("[react-international-phone]: default mask for ".concat(t.iso2," is not provided")),l(a);var c=Object.keys(u).find(function(e){if(e==="default")return!1;if(!(e.charAt(0)==="/"&&e.charAt(e.length-1)==="/"))return console.error('[react-international-phone]: format regex "'.concat(e,'" for ').concat(t.iso2," is not valid")),!1;var n=new RegExp(e.substring(1,e.length-1)),a=r.replace(t.dialCode,"");return n.test(_(a))});return l(c?u[c]:u.default)};var et=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],u=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:u}};var en=function(e){return'Field "'.concat(e,'" is not supported')},ea=function(e){var r=e.field,t=e.value,n=e.countries,a=n===void 0?A:n;if(["priority"].includes(r))throw new Error(en(r));var o=a.find(function(e){var n=et(e);return t===n[r]});if(o)return et(o)};var eo=function(e){var r=e.phone,t=e.countries,n=t===void 0?A:t,a=e.currentCountryIso2;var o={country:void 0,fullDialCodeMatch:!1};if(!r)return o;var i=_(r);if(!i)return o;var u=o,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,i;var l=r.dialCode===((n=u.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((i=(a=u.country)===null||a===void 0?void 0:a.priority)!==null&&i!==void 0?i:0);(!l||c)&&(u={country:r,fullDialCodeMatch:t})};var c=true,s=false,d=undefined;try{for(var f=n[Symbol.iterator](),v;!(c=(v=f.next()).done);c=true){var p=v.value;var y=et(p),m=y.dialCode,h=y.areaCodes;if(i.startsWith(m)){var b=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var C=i.substring(m.length);var g=true,w=false,D=undefined;try{for(var P=h[Symbol.iterator](),S;!(g=(S=P.next()).done);g=true){var x=S.value;if(C.startsWith(x))return{country:y,fullDialCodeMatch:!0}}}catch(e){w=true;D=e}finally{try{if(!g&&P.return!=null){P.return()}}finally{if(w){throw D}}}}(b||m===i||!u.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}u.fullDialCodeMatch||i.length<m.length&&m.startsWith(i)&&(!u.country||Number(m)<=Number(u.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){s=true;d=e}finally{try{if(!c&&f.return!=null){f.return()}}finally{if(s){throw d}}}if(a){var k;var N=ea({value:a,field:"iso2",countries:n});if(!N)return u;var E=N?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=i.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(N):!1;!!u&&((k=u.country)===null||k===void 0?void 0:k.dialCode)===N.dialCode&&u.country!==N&&u.fullDialCodeMatch&&(!N.areaCodes||E)&&(u={country:N,fullDialCodeMatch:!0})}return u};var ei=S(require("react"));var eu=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},el="abcdefghijklmnopqrstuvwxyz",ec="1f1e6",es=el.split("").reduce(function(e,r,t){return s(l({},e),n({},r,eu(ec,t)))},{}),ed=function(e){return[es[e[0]],es[e[1]]].join("-")},ef=function(e){var r=e.iso2,t=e.size,n=e.src,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,u=e.className,c=e.style,s=d(e,["iso2","size","src","protocol","disableLazyLoading","className","style"]);if(!r)return ei.default.createElement("img",l({className:j({addPrefix:["flag-emoji"],rawClassNames:[u]}),width:t,height:t},s));var f=function(){if(n)return n;var e=ed(r);return"".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(e,".svg")};return ei.default.createElement("img",l({className:j({addPrefix:["flag-emoji"],rawClassNames:[u]}),src:f(),width:t,height:t,draggable:!1,"data-country":r,loading:i?void 0:"lazy",style:l({width:t,height:t},c),alt:""},s))};var ev=S(require("react"));var ep=1e3,ey=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,u=e.flags,c=e.onSelect,s=e.onClose,f=d(e,["show","dialCodePrefix","selectedCountry","countries","flags","onSelect","onClose"]);var p=(0,ev.useRef)(null),y=(0,ev.useRef)(),m=(0,ev.useRef)({updatedAt:void 0,value:""}),h=function(e){var r=m.current.updatedAt&&new Date().getTime()-m.current.updatedAt.getTime()>ep;m.current={value:r?e:"".concat(m.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return et(e).name.toLowerCase().startsWith(m.current.value)});t!==-1&&w(t)},b=(0,ev.useCallback)(function(e){return i.findIndex(function(r){return et(r).iso2===e})},[i]),C=v((0,ev.useState)(b(a)),2),g=C[0],w=C[1],D=function(){y.current!==a&&w(b(a))},P=(0,ev.useCallback)(function(e){var r;w(b(e.iso2)),(r=c)===null||r===void 0?void 0:r(e)},[c,b]),S=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=et(i[g]);P(r);return}if(e.key==="Escape"){var t;(t=s)===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&&h(e.key.toLocaleLowerCase())},k=(0,ev.useCallback)(function(){if(!p.current||g===void 0)return;var e=et(i[g]).iso2;if(e===y.current)return;var r=p.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(p.current,r),y.current=e)},[g,i]);return(0,ev.useEffect)(function(){k()},[g,k]),(0,ev.useEffect)(function(){p.current&&(r?p.current.focus():D())},[r]),(0,ev.useEffect)(function(){D()},[a]),ev.default.createElement("ul",{ref:p,role:"listbox",className:j({addPrefix:["country-selector-dropdown"],rawClassNames:[f.className]}),style:l({display:r?"block":"none"},f.style),onKeyDown:x,onBlur:s,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(et(i[g]).iso2,"-option")},i.map(function(e,r){var t,o;var i=et(e),l=i.iso2===a,c=r===g,s=(t=u)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ev.default.createElement("li",{key:i.iso2,"data-country":i.iso2,role:"option","aria-selected":l,"aria-label":"".concat(i.name," ").concat(n).concat(i.dialCode),id:"react-international-phone__".concat(i.iso2,"-option"),className:j({addPrefix:["country-selector-dropdown__list-item",l&&"country-selector-dropdown__list-item--selected",c&&"country-selector-dropdown__list-item--focused"],rawClassNames:[f.listItemClassName]}),onClick:function(){return P(i)},style:f.listItemStyle,title:i.name},ev.default.createElement(ef,{iso2:i.iso2,src:(o=s)===null||o===void 0?void 0:o.src,className:j({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[f.listItemFlagClassName]}),style:f.listItemFlagStyle}),ev.default.createElement("span",{className:j({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[f.listItemCountryNameClassName]}),style:f.listItemCountryNameStyle},i.name),ev.default.createElement("span",{className:j({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[f.listItemDialCodeClassName]}),style:f.listItemDialCodeStyle},n,i.dialCode))}))};var em=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?A:o,u=e.flags,c=e.renderButtonWrapper,f=d(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","flags","renderButtonWrapper"]);var p=v((0,N.useState)(!1),2),y=p[0],m=p[1],h=(0,N.useMemo)(function(){if(r)return ea({value:r,field:"iso2",countries:i})},[i,r]),b=(0,N.useRef)(null),C=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:C,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":y},d=N.default.createElement("div",{className:j({addPrefix:["country-selector-button__button-content"],rawClassNames:[f.buttonContentWrapperClassName]}),style:f.buttonContentWrapperStyle},N.default.createElement(ef,{iso2:r,src:(o=u)===null||o===void 0?void 0:(t=o.find(function(e){return e.iso2===r}))===null||t===void 0?void 0:t.src,className:j({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[f.flagClassName]}),style:l({visibility:r?"visible":"hidden"},f.flagStyle)}),!a&&N.default.createElement("div",{className:j({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",y&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[f.dropdownArrowClassName]}),style:f.dropdownArrowStyle}));return c?c({children:d,rootProps:i}):N.default.createElement("button",s(l({},i),{type:"button",className:j({addPrefix:["country-selector-button",y&&"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:j({addPrefix:["country-selector"],rawClassNames:[f.className]}),style:f.style,ref:b},g(),N.default.createElement(ey,l({show:y,countries:i,flags:u,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 eh=S(require("react"));var eb=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eh.default.createElement("div",{className:j({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eC=S(require("react"));var eg=(0,eC.forwardRef)(function(e,r){var t=e.value,n=e.onChange,a=e.countries,o=a===void 0?A:a,i=e.hideDropdown,u=e.showDisabledDialCodeAndPrefix,c=e.flags,f=e.style,v=e.className,p=e.inputStyle,y=e.inputClassName,m=e.countrySelectorStyleProps,h=e.dialCodePreviewStyleProps,b=e.inputProps,C=e.placeholder,g=e.disabled,w=e.name,D=e.onFocus,P=e.onBlur,S=e.required,x=e.autoFocus,k=d(e,["value","onChange","countries","hideDropdown","showDisabledDialCodeAndPrefix","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var N;var E=ee(s(l({value:t,countries:o},k),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),M=E.phone,O=E.inputValue,I=E.inputRef,L=E.country,_=E.setCountry,z=E.handlePhoneValueChange,B=k.disableDialCodeAndPrefix&&u&&((N=L)===null||N===void 0?void 0:N.dialCode);var F;return(0,eC.useImperativeHandle)(r,function(){return I.current?Object.assign(I.current,{setCountry:_,state:{phone:M,inputValue:O,country:L}}):null},[I,_,M,O,L]),eC.default.createElement("div",{ref:r,className:j({addPrefix:["input-container"],rawClassNames:[v]}),style:f},eC.default.createElement(em,l({onSelect:function(e){return _(e.iso2)},flags:c,selectedCountry:L.iso2,countries:o,disabled:g,hideDropdown:i},m)),B&&eC.default.createElement(eb,l({dialCode:L.dialCode,prefix:(F=k.prefix)!==null&&F!==void 0?F:"+",disabled:g},h)),eC.default.createElement("input",l({onChange:z,value:O,type:"tel",ref:I,className:j({addPrefix:["input",g&&"input--disabled"],rawClassNames:[y]}),placeholder:C,disabled:g,style:p,name:w,onFocus:D,onBlur:P,autoFocus:x,required:S},b)))});0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagImage:FlagImage,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,getActiveFormattingMask:getActiveFormattingMask,getCountry:getCountry,guessCountryByPartialPhoneNumber:guessCountryByPartialPhoneNumber,parseCountry:parseCountry,removeDialCode:removeDialCode,usePhoneInput:usePhoneInput}); |
{ | ||
"name": "react-international-phone", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "☎️ International phone input component for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97570