react-simple-phone-input
Advanced tools
Comparing version 4.0.2 to 4.0.5
@@ -1,2 +0,1370 @@ | ||
"use strict";var o=require("react/jsx-runtime"),n=require("react");const e=[{country:"Afghanistan",countryCode:"AF",callingCode:"+93"},{country:"Albania",countryCode:"AL",callingCode:"+355"},{country:"Algeria",countryCode:"DZ",callingCode:"+213"},{country:"American Samoa",countryCode:"AS",callingCode:"+1684"},{country:"Andorra",countryCode:"AD",callingCode:"+376"},{country:"Angola",countryCode:"AO",callingCode:"+244"},{country:"Anguilla",countryCode:"AI",callingCode:"+1264"},{country:"Antarctica",countryCode:"AQ",callingCode:"+672"},{country:"Antigua and Barbuda",countryCode:"AG",callingCode:"+1268"},{country:"Argentina",countryCode:"AR",callingCode:"+54"},{country:"Armenia",countryCode:"AM",callingCode:"+374"},{country:"Aruba",countryCode:"AW",callingCode:"+297"},{country:"Australia",countryCode:"AU",callingCode:"+61"},{country:"Austria",countryCode:"AT",callingCode:"+43"},{country:"Azerbaijan",countryCode:"AZ",callingCode:"+994"},{country:"Bahamas",countryCode:"BS",callingCode:"+1242"},{country:"Bahrain",countryCode:"BH",callingCode:"+973"},{country:"Bangladesh",countryCode:"BD",callingCode:"+880"},{country:"Barbados",countryCode:"BB",callingCode:"+1246"},{country:"Belarus",countryCode:"BY",callingCode:"+375"},{country:"Belgium",countryCode:"BE",callingCode:"+32"},{country:"Belize",countryCode:"BZ",callingCode:"+501"},{country:"Benin",countryCode:"BJ",callingCode:"+229"},{country:"Bermuda",countryCode:"BM",callingCode:"+1441"},{country:"Bhutan",countryCode:"BT",callingCode:"+975"},{country:"Bolivia",countryCode:"BO",callingCode:"+591"},{country:"Bosnia and Herzegovina",countryCode:"BA",callingCode:"+387"},{country:"Botswana",countryCode:"BW",callingCode:"+267"},{country:"Bouvet Island",countryCode:"BV",callingCode:"+47"},{country:"Brazil",countryCode:"BR",callingCode:"+55"},{country:"British Indian Ocean Territory",countryCode:"IO",callingCode:"+246"},{country:"British Virgin Islands",countryCode:"VG",callingCode:"+1284"},{country:"Brunei",countryCode:"BN",callingCode:"+673"},{country:"Bulgaria",countryCode:"BG",callingCode:"+359"},{country:"Burkina Faso",countryCode:"BF",callingCode:"+226"},{country:"Burundi",countryCode:"BI",callingCode:"+257"},{country:"Cambodia",countryCode:"KH",callingCode:"+855"},{country:"Cameroon",countryCode:"CM",callingCode:"+237"},{country:"Canada",countryCode:"CA",callingCode:"+1"},{country:"Cape Verde",countryCode:"CV",callingCode:"+238"},{country:"Cayman Islands",countryCode:"KY",callingCode:"+1345"},{country:"Central African Republic",countryCode:"CF",callingCode:"+236"},{country:"Chad",countryCode:"TD",callingCode:"+235"},{country:"Chile",countryCode:"CL",callingCode:"+56"},{country:"China",countryCode:"CN",callingCode:"+86"},{country:"Christmas Island",countryCode:"CX",callingCode:"+61"},{country:"Cocos Islands",countryCode:"CC",callingCode:"+61"},{country:"Colombia",countryCode:"CO",callingCode:"+57"},{country:"Comoros",countryCode:"KM",callingCode:"+269"},{country:"Cook Islands",countryCode:"CK",callingCode:"+682"},{country:"Costa Rica",countryCode:"CR",callingCode:"+506"},{country:"Croatia",countryCode:"HR",callingCode:"+385"},{country:"Cuba",countryCode:"CU",callingCode:"+53"},{country:"Cyprus",countryCode:"CY",callingCode:"+357"},{country:"Czech Republic",countryCode:"CZ",callingCode:"+420"},{country:"Democratic Republic of the Congo",countryCode:"CD",callingCode:"+243"},{country:"Denmark",countryCode:"DK",callingCode:"+45"},{country:"Djibouti",countryCode:"DJ",callingCode:"+253"},{country:"Dominica",countryCode:"DM",callingCode:"+1767"},{country:"Dominican Republic",countryCode:"DO",callingCode:"+1"},{country:"East Timor",countryCode:"TL",callingCode:"+670"},{country:"Ecuador",countryCode:"EC",callingCode:"+593"},{country:"Egypt",countryCode:"EG",callingCode:"+20"},{country:"El Salvador",countryCode:"SV",callingCode:"+503"},{country:"Equatorial Guinea",countryCode:"GQ",callingCode:"+240"},{country:"Eritrea",countryCode:"ER",callingCode:"+291"},{country:"Estonia",countryCode:"EE",callingCode:"+372"},{country:"Ethiopia",countryCode:"ET",callingCode:"+251"},{country:"Falkland Islands",countryCode:"FK",callingCode:"+500"},{country:"Faroe Islands",countryCode:"FO",callingCode:"+298"},{country:"Fiji",countryCode:"FJ",callingCode:"+679"},{country:"Finland",countryCode:"FI",callingCode:"+358"},{country:"France",countryCode:"FR",callingCode:"+33"},{country:"French Guiana",countryCode:"GF",callingCode:"+594"},{country:"French Polynesia",countryCode:"PF",callingCode:"+689"},{country:"French Southern Territories",countryCode:"TF",callingCode:"+262"},{country:"Gabon",countryCode:"GA",callingCode:"+241"},{country:"Gambia",countryCode:"GM",callingCode:"+220"},{country:"Georgia",countryCode:"GE",callingCode:"+995"},{country:"Germany",countryCode:"DE",callingCode:"+49"},{country:"Ghana",countryCode:"GH",callingCode:"+233"},{country:"Gibraltar",countryCode:"GI",callingCode:"+350"},{country:"Greece",countryCode:"GR",callingCode:"+30"},{country:"Greenland",countryCode:"GL",callingCode:"+299"},{country:"Grenada",countryCode:"GD",callingCode:"+473"},{country:"Guadeloupe",countryCode:"GP",callingCode:"+590"},{country:"Guam",countryCode:"GU",callingCode:"+1671"},{country:"Guatemala",countryCode:"GT",callingCode:"+502"},{country:"Guinea",countryCode:"GN",callingCode:"+224"},{country:"Guinea-Bissau",countryCode:"GW",callingCode:"+245"},{country:"Guyana",countryCode:"GY",callingCode:"+592"},{country:"Haiti",countryCode:"HT",callingCode:"+509"},{country:"Honduras",countryCode:"HN",callingCode:"+504"},{country:"Hong Kong",countryCode:"HK",callingCode:"+852"},{country:"Hungary",countryCode:"HU",callingCode:"+36"},{country:"Iceland",countryCode:"IS",callingCode:"+354"},{country:"India",countryCode:"IN",callingCode:"+91"},{country:"Indonesia",countryCode:"ID",callingCode:"+62"},{country:"Iran",countryCode:"IR",callingCode:"+98"},{country:"Iraq",countryCode:"IQ",callingCode:"+964"},{country:"Ireland",countryCode:"IE",callingCode:"+353"},{country:"Israel",countryCode:"IL",callingCode:"+972"},{country:"Italy",countryCode:"IT",callingCode:"+39"},{country:"Ivory Coast",countryCode:"CI",callingCode:"+225"},{country:"Jamaica",countryCode:"JM",callingCode:"+1876"},{country:"Japan",countryCode:"JP",callingCode:"+81"},{country:"Jordan",countryCode:"JO",callingCode:"+962"},{country:"Kazakhstan",countryCode:"KZ",callingCode:"+7"},{country:"Kenya",countryCode:"KE",callingCode:"+254"},{country:"Kiribati",countryCode:"KI",callingCode:"+686"},{country:"Kuwait",countryCode:"KW",callingCode:"+965"},{country:"Kyrgyzstan",countryCode:"KG",callingCode:"+996"},{country:"Laos",countryCode:"LA",callingCode:"+856"},{country:"Latvia",countryCode:"LV",callingCode:"+371"},{country:"Lebanon",countryCode:"LB",callingCode:"+961"},{country:"Lesotho",countryCode:"LS",callingCode:"+266"},{country:"Liberia",countryCode:"LR",callingCode:"+231"},{country:"Libya",countryCode:"LY",callingCode:"+218"},{country:"Liechtenstein",countryCode:"LI",callingCode:"+423"},{country:"Lithuania",countryCode:"LT",callingCode:"+370"},{country:"Luxembourg",countryCode:"LU",callingCode:"+352"},{country:"Macao",countryCode:"MO",callingCode:"+853"},{country:"Macedonia",countryCode:"MK",callingCode:"+389"},{country:"Madagascar",countryCode:"MG",callingCode:"+261"},{country:"Malawi",countryCode:"MW",callingCode:"+265"},{country:"Malaysia",countryCode:"MY",callingCode:"+60"},{country:"Maldives",countryCode:"MV",callingCode:"+960"},{country:"Mali",countryCode:"ML",callingCode:"+223"},{country:"Malta",countryCode:"MT",callingCode:"+356"},{country:"Marshall Islands",countryCode:"MH",callingCode:"+692"},{country:"Martinique",countryCode:"MQ",callingCode:"+596"},{country:"Mauritania",countryCode:"MR",callingCode:"+222"},{country:"Mauritius",countryCode:"MU",callingCode:"+230"},{country:"Mayotte",countryCode:"YT",callingCode:"+262"},{country:"Mexico",countryCode:"MX",callingCode:"+52"},{country:"Micronesia",countryCode:"FM",callingCode:"+691"},{country:"Moldova",countryCode:"MD",callingCode:"+373"},{country:"Monaco",countryCode:"MC",callingCode:"+377"},{country:"Mongolia",countryCode:"MN",callingCode:"+976"},{country:"Montserrat",countryCode:"MS",callingCode:"+1664"},{country:"Morocco",countryCode:"MA",callingCode:"+212"},{country:"Mozambique",countryCode:"MZ",callingCode:"+258"},{country:"Myanmar",countryCode:"MM",callingCode:"+95"},{country:"Namibia",countryCode:"NA",callingCode:"+264"},{country:"Nauru",countryCode:"NR",callingCode:"+674"},{country:"Nepal",countryCode:"NP",callingCode:"+977"},{country:"Netherlands",countryCode:"NL",callingCode:"+31"},{country:"New Caledonia",countryCode:"NC",callingCode:"+687"},{country:"New Zealand",countryCode:"NZ",callingCode:"+64"},{country:"Nicaragua",countryCode:"NI",callingCode:"+505"},{country:"Niger",countryCode:"NE",callingCode:"+227"},{country:"Nigeria",countryCode:"NG",callingCode:"+234"},{country:"Niue",countryCode:"NU",callingCode:"+683"},{country:"Norfolk Island",countryCode:"NF",callingCode:"+672"},{country:"North Korea",countryCode:"KP",callingCode:"+850"},{country:"Northern Mariana Islands",countryCode:"MP",callingCode:"+1670"},{country:"Norway",countryCode:"NO",callingCode:"+47"},{country:"Oman",countryCode:"OM",callingCode:"+968"},{country:"Pakistan",countryCode:"PK",callingCode:"+92"},{country:"Palau",countryCode:"PW",callingCode:"+680"},{country:"Palestinian Territory",countryCode:"PS",callingCode:"+970"},{country:"Panama",countryCode:"PA",callingCode:"+507"},{country:"Papua New Guinea",countryCode:"PG",callingCode:"+675"},{country:"Paraguay",countryCode:"PY",callingCode:"+595"},{country:"Peru",countryCode:"PE",callingCode:"+51"},{country:"Philippines",countryCode:"PH",callingCode:"+63"},{country:"Pitcairn",countryCode:"PN",callingCode:"+872"},{country:"Poland",countryCode:"PL",callingCode:"+48"},{country:"Portugal",countryCode:"PT",callingCode:"+351"},{country:"Puerto Rico",countryCode:"PR",callingCode:"+1"},{country:"Qatar",countryCode:"QA",callingCode:"+974"},{country:"Republic of the Congo",countryCode:"CG",callingCode:"+242"},{country:"Reunion",countryCode:"RE",callingCode:"+262"},{country:"Romania",countryCode:"RO",callingCode:"+40"},{country:"Russia",countryCode:"RU",callingCode:"+7"},{country:"Rwanda",countryCode:"RW",callingCode:"+250"},{country:"Saint Helena",countryCode:"SH",callingCode:"+290"},{country:"Saint Kitts and Nevis",countryCode:"KN",callingCode:"+1869"},{country:"Saint Lucia",countryCode:"LC",callingCode:"+1758"},{country:"Saint Pierre and Miquelon",countryCode:"PM",callingCode:"+508"},{country:"Saint Vincent and the Grenadines",countryCode:"VC",callingCode:"+1784"},{country:"Samoa",countryCode:"WS",callingCode:"+685"},{country:"San Marino",countryCode:"SM",callingCode:"+378"},{country:"Sao Tome and Principe",countryCode:"ST",callingCode:"+239"},{country:"Saudi Arabia",countryCode:"SA",callingCode:"+966"},{country:"Senegal",countryCode:"SN",callingCode:"+221"},{country:"Seychelles",countryCode:"SC",callingCode:"+248"},{country:"Sierra Leone",countryCode:"SL",callingCode:"+232"},{country:"Singapore",countryCode:"SG",callingCode:"+65"},{country:"Slovakia",countryCode:"SK",callingCode:"+421"},{country:"Slovenia",countryCode:"SI",callingCode:"+386"},{country:"Solomon Islands",countryCode:"SB",callingCode:"+677"},{country:"Somalia",countryCode:"SO",callingCode:"+252"},{country:"South Africa",countryCode:"ZA",callingCode:"+27"},{country:"South Georgia and the South Sandwich Islands",countryCode:"GS",callingCode:"+500"},{country:"South Korea",countryCode:"KR",callingCode:"+82"},{country:"Spain",countryCode:"ES",callingCode:"+34"},{country:"Sri Lanka",countryCode:"LK",callingCode:"+94"},{country:"Sudan",countryCode:"SD",callingCode:"+249"},{country:"Suriname",countryCode:"SR",callingCode:"+597"},{country:"Svalbard and Jan Mayen",countryCode:"SJ",callingCode:"+47"},{country:"Swaziland",countryCode:"SZ",callingCode:"+268"},{country:"Sweden",countryCode:"SE",callingCode:"+46"},{country:"Switzerland",countryCode:"CH",callingCode:"+41"},{country:"Syria",countryCode:"SY",callingCode:"+963"},{country:"Taiwan",countryCode:"TW",callingCode:"+886"},{country:"Tajikistan",countryCode:"TJ",callingCode:"+992"},{country:"Tanzania",countryCode:"TZ",callingCode:"+255"},{country:"Thailand",countryCode:"TH",callingCode:"+66"},{country:"Togo",countryCode:"TG",callingCode:"+228"},{country:"Tokelau",countryCode:"TK",callingCode:"+690"},{country:"Tonga",countryCode:"TO",callingCode:"+676"},{country:"Trinidad and Tobago",countryCode:"TT",callingCode:"+1868"},{country:"Tunisia",countryCode:"TN",callingCode:"+216"},{country:"Turkey",countryCode:"TR",callingCode:"+90"},{country:"Turkmenistan",countryCode:"TM",callingCode:"+993"},{country:"Turks and Caicos Islands",countryCode:"TC",callingCode:"+1649"},{country:"Tuvalu",countryCode:"TV",callingCode:"+688"},{country:"U.S. Virgin Islands",countryCode:"VI",callingCode:"+1340"},{country:"Uganda",countryCode:"UG",callingCode:"+256"},{country:"Ukraine",countryCode:"UA",callingCode:"+380"},{country:"United Arab Emirates",countryCode:"AE",callingCode:"+971"},{country:"United Kingdom",countryCode:"GB",callingCode:"+44"},{country:"United States",countryCode:"US",callingCode:"+1"},{country:"United States Minor Outlying Islands",countryCode:"UM",callingCode:"+1"},{country:"Uruguay",countryCode:"UY",callingCode:"+598"},{country:"Uzbekistan",countryCode:"UZ",callingCode:"+998"},{country:"Vanuatu",countryCode:"VU",callingCode:"+678"},{country:"Vatican",countryCode:"VA",callingCode:"+379"},{country:"Venezuela",countryCode:"VE",callingCode:"+58"},{country:"Vietnam",countryCode:"VN",callingCode:"+84"},{country:"Wallis and Futuna",countryCode:"WF",callingCode:"+681"},{country:"Western Sahara",countryCode:"EH",callingCode:"+212"},{country:"Yemen",countryCode:"YE",callingCode:"+967"},{country:"Zambia",countryCode:"ZM",callingCode:"+260"},{country:"Zimbabwe",countryCode:"ZW",callingCode:"+263"}],c=o=>e.find((n=>n.countryCode===o));exports.PhoneInput=({placeholder:r,country:t,onChange:l,value:a,iconComponent:d,inputProps:u,onlyCountries:i,excludeCountries:C,preferredCountries:y,showDropdownIcon:g=!0,dialCodeInputField:s=!1,search:h=!0,searchPlaceholder:p="Search country",showSearchIcon:m=!0,searchIconComponent:S,searchProps:M,searchNotFound:N="Not found"})=>{const[v,B]=n.useState({}),[I,A]=n.useState(!1),[G,T]=n.useState(a||""),[w,x]=n.useState(e),[f,E]=n.useState(0),b=n.useRef(null),P=n.useRef(null);var L,R;L=b,R=()=>A(!1),n.useEffect((()=>{const o=o=>{L.current&&!L.current.contains(o.target)&&R(o)};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}}),[L,R]);const j=o=>{I&&("ArrowDown"===o.key&&(o.preventDefault(),E((o=>o<w.length-1?o+1:o))),"ArrowUp"===o.key&&(o.preventDefault(),E((o=>o>0?o-1:0))),"Escape"===o.key&&A(!1),"Enter"===o.key&&f>=0&&(B(w[f]),A(!1)))};return n.useEffect((()=>{if(f<0||f>w.length||!P)return()=>{};if(I&&P&&w.length>0){let n=Array.from(P.current?.children);n[f]&&(o=n[f].offsetTop-65,h&&w.length>0&&P.current?.scrollTo({top:o,behavior:"smooth"}))}var o}),[f]),n.useMemo((()=>{if(s){const o=G?.replace(v.callingCode,c(t).callingCode);console.log(o),T(o.length>0?o:c(t).callingCode)}B(c(t))}),[t,s]),n.useMemo((()=>{x(((o,n,c)=>{let r=[];return r=n&&n.length>0?e.filter((o=>!n?.includes(o.countryCode))):o&&o?.length>0?e.filter((n=>o?.includes(n.countryCode))):e,r.sort(((o,n)=>Number(c?.includes(n.countryCode))-Number(c?.includes(o.countryCode))||c?.indexOf(o.countryCode)-c?.indexOf(n.countryCode)))})(i,C,y))}),[i,C,y]),o.jsx("div",{className:"simple-phone-input-sri198-container",onKeyDown:o=>j(o),tabIndex:-1,children:o.jsxs("div",{className:"simple-phone-input-sri198-main",children:[o.jsxs("div",{className:"simple-phone-input-sri198-dropdown-container",ref:b,children:[o.jsxs("div",{onClick:()=>A(!I),className:s?"simple-phone-input-sri198-dropdown-container-button dial":"simple-phone-input-sri198-dropdown-container-button",children:[o.jsx("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+v.countryCode+".svg",alt:v.country,width:"20px"}),!s&&o.jsx("span",{className:"simple-phone-input-sri198-selected-code",children:v.callingCode}),g&&o.jsx("div",{className:I?"simple-phone-input-sri198-dropdown-icon":"simple-phone-input-sri198-dropdown-icon active",children:d||o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",children:o.jsx("path",{fill:"currentColor",d:"m7 10l5 5l5-5z"})})})]}),o.jsxs("ul",{className:I?"simple-phone-input-sri198-dropdown active":"simple-phone-input-sri198-dropdown",ref:P,children:[h&&o.jsxs("div",{className:"simple-phone-input-sri198-search-container",children:[o.jsx("input",{placeholder:p,...M,onChange:o=>{const n=o.target.value;x(((o,n,c)=>{let r=[];return r=c&&c.length>0?e.filter((o=>!c?.includes(o.countryCode))):n&&n?.length>0?e.filter((o=>n?.includes(o.countryCode))):e,r.filter((n=>{const e=new RegExp(o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"gi");return n.country.match(e)}))})(n,i,C))}}),m&&o.jsx("div",{className:"simple-phone-input-sri198-search-icon",children:S??o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 48 48",children:[o.jsxs("g",{fill:"#616161",children:[o.jsx("path",{d:"m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z"}),o.jsx("circle",{cx:"20",cy:"20",r:"16"})]}),o.jsx("path",{fill:"#37474F",d:"m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z"}),o.jsx("circle",{cx:"20",cy:"20",r:"13",fill:"#64B5F6"}),o.jsx("path",{fill:"#BBDEFB",d:"M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z"})]})})]}),0===w.length&&o.jsx("div",{className:"simple-phone-input-sri198-not-found",children:N}),w.map(((n,e)=>o.jsxs("li",{onClick:()=>((o,n)=>{if(s){const n=G?.replace(v.callingCode,o.callingCode);T(n.length>0?n:o.callingCode),l(n.length>0?n:o.callingCode)}else l(o.callingCode+G);B(o),A(!1),E(n)})(n,e),className:e===f?"active":"",children:[o.jsx("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+n.countryCode+".svg",alt:n.country,width:"20px"}),o.jsx("span",{className:"simple-phone-input-sri198-dropdown-text",children:n.country}),o.jsx("span",{className:"simple-phone-input-sri198-dropdown-country-code",children:n.callingCode})]},e)))]})]}),o.jsx("input",{className:"simple-phone-input-sri198-input",placeholder:r,onChange:o=>{const n=o.target.value.replace(/\D/g,"");s?(l("+"+n),T("+"+n)):(T(n),l(v.callingCode+n))},type:"tel",onInput:o=>{if(s){const n=G.slice(v.callingCode.length);o.target.value.startsWith(v.callingCode)?o.target.value=o.target.value:o.target.value=v.callingCode+n}},onKeyDown:o=>j(o),value:G,...u})]})})}; | ||
'use strict'; | ||
var jsxRuntime = require('react/jsx-runtime'); | ||
var React = require('react'); | ||
const countryData = [ | ||
{ | ||
country: "Afghanistan", | ||
countryCode: "AF", | ||
callingCode: "+93" | ||
}, | ||
{ | ||
country: "Albania", | ||
countryCode: "AL", | ||
callingCode: "+355" | ||
}, | ||
{ | ||
country: "Algeria", | ||
countryCode: "DZ", | ||
callingCode: "+213" | ||
}, | ||
{ | ||
country: "American Samoa", | ||
countryCode: "AS", | ||
callingCode: "+1684" | ||
}, | ||
{ | ||
country: "Andorra", | ||
countryCode: "AD", | ||
callingCode: "+376" | ||
}, | ||
{ | ||
country: "Angola", | ||
countryCode: "AO", | ||
callingCode: "+244" | ||
}, | ||
{ | ||
country: "Anguilla", | ||
countryCode: "AI", | ||
callingCode: "+1264" | ||
}, | ||
{ | ||
country: "Antarctica", | ||
countryCode: "AQ", | ||
callingCode: "+672" | ||
}, | ||
{ | ||
country: "Antigua and Barbuda", | ||
countryCode: "AG", | ||
callingCode: "+1268" | ||
}, | ||
{ | ||
country: "Argentina", | ||
countryCode: "AR", | ||
callingCode: "+54" | ||
}, | ||
{ | ||
country: "Armenia", | ||
countryCode: "AM", | ||
callingCode: "+374" | ||
}, | ||
{ | ||
country: "Aruba", | ||
countryCode: "AW", | ||
callingCode: "+297" | ||
}, | ||
{ | ||
country: "Australia", | ||
countryCode: "AU", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Austria", | ||
countryCode: "AT", | ||
callingCode: "+43" | ||
}, | ||
{ | ||
country: "Azerbaijan", | ||
countryCode: "AZ", | ||
callingCode: "+994" | ||
}, | ||
{ | ||
country: "Bahamas", | ||
countryCode: "BS", | ||
callingCode: "+1242" | ||
}, | ||
{ | ||
country: "Bahrain", | ||
countryCode: "BH", | ||
callingCode: "+973" | ||
}, | ||
{ | ||
country: "Bangladesh", | ||
countryCode: "BD", | ||
callingCode: "+880" | ||
}, | ||
{ | ||
country: "Barbados", | ||
countryCode: "BB", | ||
callingCode: "+1246" | ||
}, | ||
{ | ||
country: "Belarus", | ||
countryCode: "BY", | ||
callingCode: "+375" | ||
}, | ||
{ | ||
country: "Belgium", | ||
countryCode: "BE", | ||
callingCode: "+32" | ||
}, | ||
{ | ||
country: "Belize", | ||
countryCode: "BZ", | ||
callingCode: "+501" | ||
}, | ||
{ | ||
country: "Benin", | ||
countryCode: "BJ", | ||
callingCode: "+229" | ||
}, | ||
{ | ||
country: "Bermuda", | ||
countryCode: "BM", | ||
callingCode: "+1441" | ||
}, | ||
{ | ||
country: "Bhutan", | ||
countryCode: "BT", | ||
callingCode: "+975" | ||
}, | ||
{ | ||
country: "Bolivia", | ||
countryCode: "BO", | ||
callingCode: "+591" | ||
}, | ||
{ | ||
country: "Bosnia and Herzegovina", | ||
countryCode: "BA", | ||
callingCode: "+387" | ||
}, | ||
{ | ||
country: "Botswana", | ||
countryCode: "BW", | ||
callingCode: "+267" | ||
}, | ||
{ | ||
country: "Bouvet Island", | ||
countryCode: "BV", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Brazil", | ||
countryCode: "BR", | ||
callingCode: "+55" | ||
}, | ||
{ | ||
country: "British Indian Ocean Territory", | ||
countryCode: "IO", | ||
callingCode: "+246" | ||
}, | ||
{ | ||
country: "British Virgin Islands", | ||
countryCode: "VG", | ||
callingCode: "+1284" | ||
}, | ||
{ | ||
country: "Brunei", | ||
countryCode: "BN", | ||
callingCode: "+673" | ||
}, | ||
{ | ||
country: "Bulgaria", | ||
countryCode: "BG", | ||
callingCode: "+359" | ||
}, | ||
{ | ||
country: "Burkina Faso", | ||
countryCode: "BF", | ||
callingCode: "+226" | ||
}, | ||
{ | ||
country: "Burundi", | ||
countryCode: "BI", | ||
callingCode: "+257" | ||
}, | ||
{ | ||
country: "Cambodia", | ||
countryCode: "KH", | ||
callingCode: "+855" | ||
}, | ||
{ | ||
country: "Cameroon", | ||
countryCode: "CM", | ||
callingCode: "+237" | ||
}, | ||
{ | ||
country: "Canada", | ||
countryCode: "CA", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Cape Verde", | ||
countryCode: "CV", | ||
callingCode: "+238" | ||
}, | ||
{ | ||
country: "Cayman Islands", | ||
countryCode: "KY", | ||
callingCode: "+1345" | ||
}, | ||
{ | ||
country: "Central African Republic", | ||
countryCode: "CF", | ||
callingCode: "+236" | ||
}, | ||
{ | ||
country: "Chad", | ||
countryCode: "TD", | ||
callingCode: "+235" | ||
}, | ||
{ | ||
country: "Chile", | ||
countryCode: "CL", | ||
callingCode: "+56" | ||
}, | ||
{ | ||
country: "China", | ||
countryCode: "CN", | ||
callingCode: "+86" | ||
}, | ||
{ | ||
country: "Christmas Island", | ||
countryCode: "CX", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Cocos Islands", | ||
countryCode: "CC", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Colombia", | ||
countryCode: "CO", | ||
callingCode: "+57" | ||
}, | ||
{ | ||
country: "Comoros", | ||
countryCode: "KM", | ||
callingCode: "+269" | ||
}, | ||
{ | ||
country: "Cook Islands", | ||
countryCode: "CK", | ||
callingCode: "+682" | ||
}, | ||
{ | ||
country: "Costa Rica", | ||
countryCode: "CR", | ||
callingCode: "+506" | ||
}, | ||
{ | ||
country: "Croatia", | ||
countryCode: "HR", | ||
callingCode: "+385" | ||
}, | ||
{ | ||
country: "Cuba", | ||
countryCode: "CU", | ||
callingCode: "+53" | ||
}, | ||
{ | ||
country: "Cyprus", | ||
countryCode: "CY", | ||
callingCode: "+357" | ||
}, | ||
{ | ||
country: "Czech Republic", | ||
countryCode: "CZ", | ||
callingCode: "+420" | ||
}, | ||
{ | ||
country: "Democratic Republic of the Congo", | ||
countryCode: "CD", | ||
callingCode: "+243" | ||
}, | ||
{ | ||
country: "Denmark", | ||
countryCode: "DK", | ||
callingCode: "+45" | ||
}, | ||
{ | ||
country: "Djibouti", | ||
countryCode: "DJ", | ||
callingCode: "+253" | ||
}, | ||
{ | ||
country: "Dominica", | ||
countryCode: "DM", | ||
callingCode: "+1767" | ||
}, | ||
{ | ||
country: "Dominican Republic", | ||
countryCode: "DO", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "East Timor", | ||
countryCode: "TL", | ||
callingCode: "+670" | ||
}, | ||
{ | ||
country: "Ecuador", | ||
countryCode: "EC", | ||
callingCode: "+593" | ||
}, | ||
{ | ||
country: "Egypt", | ||
countryCode: "EG", | ||
callingCode: "+20" | ||
}, | ||
{ | ||
country: "El Salvador", | ||
countryCode: "SV", | ||
callingCode: "+503" | ||
}, | ||
{ | ||
country: "Equatorial Guinea", | ||
countryCode: "GQ", | ||
callingCode: "+240" | ||
}, | ||
{ | ||
country: "Eritrea", | ||
countryCode: "ER", | ||
callingCode: "+291" | ||
}, | ||
{ | ||
country: "Estonia", | ||
countryCode: "EE", | ||
callingCode: "+372" | ||
}, | ||
{ | ||
country: "Ethiopia", | ||
countryCode: "ET", | ||
callingCode: "+251" | ||
}, | ||
{ | ||
country: "Falkland Islands", | ||
countryCode: "FK", | ||
callingCode: "+500" | ||
}, | ||
{ | ||
country: "Faroe Islands", | ||
countryCode: "FO", | ||
callingCode: "+298" | ||
}, | ||
{ | ||
country: "Fiji", | ||
countryCode: "FJ", | ||
callingCode: "+679" | ||
}, | ||
{ | ||
country: "Finland", | ||
countryCode: "FI", | ||
callingCode: "+358" | ||
}, | ||
{ | ||
country: "France", | ||
countryCode: "FR", | ||
callingCode: "+33" | ||
}, | ||
{ | ||
country: "French Guiana", | ||
countryCode: "GF", | ||
callingCode: "+594" | ||
}, | ||
{ | ||
country: "French Polynesia", | ||
countryCode: "PF", | ||
callingCode: "+689" | ||
}, | ||
{ | ||
country: "French Southern Territories", | ||
countryCode: "TF", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Gabon", | ||
countryCode: "GA", | ||
callingCode: "+241" | ||
}, | ||
{ | ||
country: "Gambia", | ||
countryCode: "GM", | ||
callingCode: "+220" | ||
}, | ||
{ | ||
country: "Georgia", | ||
countryCode: "GE", | ||
callingCode: "+995" | ||
}, | ||
{ | ||
country: "Germany", | ||
countryCode: "DE", | ||
callingCode: "+49" | ||
}, | ||
{ | ||
country: "Ghana", | ||
countryCode: "GH", | ||
callingCode: "+233" | ||
}, | ||
{ | ||
country: "Gibraltar", | ||
countryCode: "GI", | ||
callingCode: "+350" | ||
}, | ||
{ | ||
country: "Greece", | ||
countryCode: "GR", | ||
callingCode: "+30" | ||
}, | ||
{ | ||
country: "Greenland", | ||
countryCode: "GL", | ||
callingCode: "+299" | ||
}, | ||
{ | ||
country: "Grenada", | ||
countryCode: "GD", | ||
callingCode: "+473" | ||
}, | ||
{ | ||
country: "Guadeloupe", | ||
countryCode: "GP", | ||
callingCode: "+590" | ||
}, | ||
{ | ||
country: "Guam", | ||
countryCode: "GU", | ||
callingCode: "+1671" | ||
}, | ||
{ | ||
country: "Guatemala", | ||
countryCode: "GT", | ||
callingCode: "+502" | ||
}, | ||
{ | ||
country: "Guinea", | ||
countryCode: "GN", | ||
callingCode: "+224" | ||
}, | ||
{ | ||
country: "Guinea-Bissau", | ||
countryCode: "GW", | ||
callingCode: "+245" | ||
}, | ||
{ | ||
country: "Guyana", | ||
countryCode: "GY", | ||
callingCode: "+592" | ||
}, | ||
{ | ||
country: "Haiti", | ||
countryCode: "HT", | ||
callingCode: "+509" | ||
}, | ||
{ | ||
country: "Honduras", | ||
countryCode: "HN", | ||
callingCode: "+504" | ||
}, | ||
{ | ||
country: "Hong Kong", | ||
countryCode: "HK", | ||
callingCode: "+852" | ||
}, | ||
{ | ||
country: "Hungary", | ||
countryCode: "HU", | ||
callingCode: "+36" | ||
}, | ||
{ | ||
country: "Iceland", | ||
countryCode: "IS", | ||
callingCode: "+354" | ||
}, | ||
{ | ||
country: "India", | ||
countryCode: "IN", | ||
callingCode: "+91" | ||
}, | ||
{ | ||
country: "Indonesia", | ||
countryCode: "ID", | ||
callingCode: "+62" | ||
}, | ||
{ | ||
country: "Iran", | ||
countryCode: "IR", | ||
callingCode: "+98" | ||
}, | ||
{ | ||
country: "Iraq", | ||
countryCode: "IQ", | ||
callingCode: "+964" | ||
}, | ||
{ | ||
country: "Ireland", | ||
countryCode: "IE", | ||
callingCode: "+353" | ||
}, | ||
{ | ||
country: "Israel", | ||
countryCode: "IL", | ||
callingCode: "+972" | ||
}, | ||
{ | ||
country: "Italy", | ||
countryCode: "IT", | ||
callingCode: "+39" | ||
}, | ||
{ | ||
country: "Ivory Coast", | ||
countryCode: "CI", | ||
callingCode: "+225" | ||
}, | ||
{ | ||
country: "Jamaica", | ||
countryCode: "JM", | ||
callingCode: "+1876" | ||
}, | ||
{ | ||
country: "Japan", | ||
countryCode: "JP", | ||
callingCode: "+81" | ||
}, | ||
{ | ||
country: "Jordan", | ||
countryCode: "JO", | ||
callingCode: "+962" | ||
}, | ||
{ | ||
country: "Kazakhstan", | ||
countryCode: "KZ", | ||
callingCode: "+7" | ||
}, | ||
{ | ||
country: "Kenya", | ||
countryCode: "KE", | ||
callingCode: "+254" | ||
}, | ||
{ | ||
country: "Kiribati", | ||
countryCode: "KI", | ||
callingCode: "+686" | ||
}, | ||
{ | ||
country: "Kuwait", | ||
countryCode: "KW", | ||
callingCode: "+965" | ||
}, | ||
{ | ||
country: "Kyrgyzstan", | ||
countryCode: "KG", | ||
callingCode: "+996" | ||
}, | ||
{ | ||
country: "Laos", | ||
countryCode: "LA", | ||
callingCode: "+856" | ||
}, | ||
{ | ||
country: "Latvia", | ||
countryCode: "LV", | ||
callingCode: "+371" | ||
}, | ||
{ | ||
country: "Lebanon", | ||
countryCode: "LB", | ||
callingCode: "+961" | ||
}, | ||
{ | ||
country: "Lesotho", | ||
countryCode: "LS", | ||
callingCode: "+266" | ||
}, | ||
{ | ||
country: "Liberia", | ||
countryCode: "LR", | ||
callingCode: "+231" | ||
}, | ||
{ | ||
country: "Libya", | ||
countryCode: "LY", | ||
callingCode: "+218" | ||
}, | ||
{ | ||
country: "Liechtenstein", | ||
countryCode: "LI", | ||
callingCode: "+423" | ||
}, | ||
{ | ||
country: "Lithuania", | ||
countryCode: "LT", | ||
callingCode: "+370" | ||
}, | ||
{ | ||
country: "Luxembourg", | ||
countryCode: "LU", | ||
callingCode: "+352" | ||
}, | ||
{ | ||
country: "Macao", | ||
countryCode: "MO", | ||
callingCode: "+853" | ||
}, | ||
{ | ||
country: "Macedonia", | ||
countryCode: "MK", | ||
callingCode: "+389" | ||
}, | ||
{ | ||
country: "Madagascar", | ||
countryCode: "MG", | ||
callingCode: "+261" | ||
}, | ||
{ | ||
country: "Malawi", | ||
countryCode: "MW", | ||
callingCode: "+265" | ||
}, | ||
{ | ||
country: "Malaysia", | ||
countryCode: "MY", | ||
callingCode: "+60" | ||
}, | ||
{ | ||
country: "Maldives", | ||
countryCode: "MV", | ||
callingCode: "+960" | ||
}, | ||
{ | ||
country: "Mali", | ||
countryCode: "ML", | ||
callingCode: "+223" | ||
}, | ||
{ | ||
country: "Malta", | ||
countryCode: "MT", | ||
callingCode: "+356" | ||
}, | ||
{ | ||
country: "Marshall Islands", | ||
countryCode: "MH", | ||
callingCode: "+692" | ||
}, | ||
{ | ||
country: "Martinique", | ||
countryCode: "MQ", | ||
callingCode: "+596" | ||
}, | ||
{ | ||
country: "Mauritania", | ||
countryCode: "MR", | ||
callingCode: "+222" | ||
}, | ||
{ | ||
country: "Mauritius", | ||
countryCode: "MU", | ||
callingCode: "+230" | ||
}, | ||
{ | ||
country: "Mayotte", | ||
countryCode: "YT", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Mexico", | ||
countryCode: "MX", | ||
callingCode: "+52" | ||
}, | ||
{ | ||
country: "Micronesia", | ||
countryCode: "FM", | ||
callingCode: "+691" | ||
}, | ||
{ | ||
country: "Moldova", | ||
countryCode: "MD", | ||
callingCode: "+373" | ||
}, | ||
{ | ||
country: "Monaco", | ||
countryCode: "MC", | ||
callingCode: "+377" | ||
}, | ||
{ | ||
country: "Mongolia", | ||
countryCode: "MN", | ||
callingCode: "+976" | ||
}, | ||
{ | ||
country: "Montserrat", | ||
countryCode: "MS", | ||
callingCode: "+1664" | ||
}, | ||
{ | ||
country: "Morocco", | ||
countryCode: "MA", | ||
callingCode: "+212" | ||
}, | ||
{ | ||
country: "Mozambique", | ||
countryCode: "MZ", | ||
callingCode: "+258" | ||
}, | ||
{ | ||
country: "Myanmar", | ||
countryCode: "MM", | ||
callingCode: "+95" | ||
}, | ||
{ | ||
country: "Namibia", | ||
countryCode: "NA", | ||
callingCode: "+264" | ||
}, | ||
{ | ||
country: "Nauru", | ||
countryCode: "NR", | ||
callingCode: "+674" | ||
}, | ||
{ | ||
country: "Nepal", | ||
countryCode: "NP", | ||
callingCode: "+977" | ||
}, | ||
{ | ||
country: "Netherlands", | ||
countryCode: "NL", | ||
callingCode: "+31" | ||
}, | ||
{ | ||
country: "New Caledonia", | ||
countryCode: "NC", | ||
callingCode: "+687" | ||
}, | ||
{ | ||
country: "New Zealand", | ||
countryCode: "NZ", | ||
callingCode: "+64" | ||
}, | ||
{ | ||
country: "Nicaragua", | ||
countryCode: "NI", | ||
callingCode: "+505" | ||
}, | ||
{ | ||
country: "Niger", | ||
countryCode: "NE", | ||
callingCode: "+227" | ||
}, | ||
{ | ||
country: "Nigeria", | ||
countryCode: "NG", | ||
callingCode: "+234" | ||
}, | ||
{ | ||
country: "Niue", | ||
countryCode: "NU", | ||
callingCode: "+683" | ||
}, | ||
{ | ||
country: "Norfolk Island", | ||
countryCode: "NF", | ||
callingCode: "+672" | ||
}, | ||
{ | ||
country: "North Korea", | ||
countryCode: "KP", | ||
callingCode: "+850" | ||
}, | ||
{ | ||
country: "Northern Mariana Islands", | ||
countryCode: "MP", | ||
callingCode: "+1670" | ||
}, | ||
{ | ||
country: "Norway", | ||
countryCode: "NO", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Oman", | ||
countryCode: "OM", | ||
callingCode: "+968" | ||
}, | ||
{ | ||
country: "Pakistan", | ||
countryCode: "PK", | ||
callingCode: "+92" | ||
}, | ||
{ | ||
country: "Palau", | ||
countryCode: "PW", | ||
callingCode: "+680" | ||
}, | ||
{ | ||
country: "Palestinian Territory", | ||
countryCode: "PS", | ||
callingCode: "+970" | ||
}, | ||
{ | ||
country: "Panama", | ||
countryCode: "PA", | ||
callingCode: "+507" | ||
}, | ||
{ | ||
country: "Papua New Guinea", | ||
countryCode: "PG", | ||
callingCode: "+675" | ||
}, | ||
{ | ||
country: "Paraguay", | ||
countryCode: "PY", | ||
callingCode: "+595" | ||
}, | ||
{ | ||
country: "Peru", | ||
countryCode: "PE", | ||
callingCode: "+51" | ||
}, | ||
{ | ||
country: "Philippines", | ||
countryCode: "PH", | ||
callingCode: "+63" | ||
}, | ||
{ | ||
country: "Pitcairn", | ||
countryCode: "PN", | ||
callingCode: "+872" | ||
}, | ||
{ | ||
country: "Poland", | ||
countryCode: "PL", | ||
callingCode: "+48" | ||
}, | ||
{ | ||
country: "Portugal", | ||
countryCode: "PT", | ||
callingCode: "+351" | ||
}, | ||
{ | ||
country: "Puerto Rico", | ||
countryCode: "PR", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Qatar", | ||
countryCode: "QA", | ||
callingCode: "+974" | ||
}, | ||
{ | ||
country: "Republic of the Congo", | ||
countryCode: "CG", | ||
callingCode: "+242" | ||
}, | ||
{ | ||
country: "Reunion", | ||
countryCode: "RE", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Romania", | ||
countryCode: "RO", | ||
callingCode: "+40" | ||
}, | ||
{ | ||
country: "Russia", | ||
countryCode: "RU", | ||
callingCode: "+7" | ||
}, | ||
{ | ||
country: "Rwanda", | ||
countryCode: "RW", | ||
callingCode: "+250" | ||
}, | ||
{ | ||
country: "Saint Helena", | ||
countryCode: "SH", | ||
callingCode: "+290" | ||
}, | ||
{ | ||
country: "Saint Kitts and Nevis", | ||
countryCode: "KN", | ||
callingCode: "+1869" | ||
}, | ||
{ | ||
country: "Saint Lucia", | ||
countryCode: "LC", | ||
callingCode: "+1758" | ||
}, | ||
{ | ||
country: "Saint Pierre and Miquelon", | ||
countryCode: "PM", | ||
callingCode: "+508" | ||
}, | ||
{ | ||
country: "Saint Vincent and the Grenadines", | ||
countryCode: "VC", | ||
callingCode: "+1784" | ||
}, | ||
{ | ||
country: "Samoa", | ||
countryCode: "WS", | ||
callingCode: "+685" | ||
}, | ||
{ | ||
country: "San Marino", | ||
countryCode: "SM", | ||
callingCode: "+378" | ||
}, | ||
{ | ||
country: "Sao Tome and Principe", | ||
countryCode: "ST", | ||
callingCode: "+239" | ||
}, | ||
{ | ||
country: "Saudi Arabia", | ||
countryCode: "SA", | ||
callingCode: "+966" | ||
}, | ||
{ | ||
country: "Senegal", | ||
countryCode: "SN", | ||
callingCode: "+221" | ||
}, | ||
{ | ||
country: "Seychelles", | ||
countryCode: "SC", | ||
callingCode: "+248" | ||
}, | ||
{ | ||
country: "Sierra Leone", | ||
countryCode: "SL", | ||
callingCode: "+232" | ||
}, | ||
{ | ||
country: "Singapore", | ||
countryCode: "SG", | ||
callingCode: "+65" | ||
}, | ||
{ | ||
country: "Slovakia", | ||
countryCode: "SK", | ||
callingCode: "+421" | ||
}, | ||
{ | ||
country: "Slovenia", | ||
countryCode: "SI", | ||
callingCode: "+386" | ||
}, | ||
{ | ||
country: "Solomon Islands", | ||
countryCode: "SB", | ||
callingCode: "+677" | ||
}, | ||
{ | ||
country: "Somalia", | ||
countryCode: "SO", | ||
callingCode: "+252" | ||
}, | ||
{ | ||
country: "South Africa", | ||
countryCode: "ZA", | ||
callingCode: "+27" | ||
}, | ||
{ | ||
country: "South Georgia and the South Sandwich Islands", | ||
countryCode: "GS", | ||
callingCode: "+500" | ||
}, | ||
{ | ||
country: "South Korea", | ||
countryCode: "KR", | ||
callingCode: "+82" | ||
}, | ||
{ | ||
country: "Spain", | ||
countryCode: "ES", | ||
callingCode: "+34" | ||
}, | ||
{ | ||
country: "Sri Lanka", | ||
countryCode: "LK", | ||
callingCode: "+94" | ||
}, | ||
{ | ||
country: "Sudan", | ||
countryCode: "SD", | ||
callingCode: "+249" | ||
}, | ||
{ | ||
country: "Suriname", | ||
countryCode: "SR", | ||
callingCode: "+597" | ||
}, | ||
{ | ||
country: "Svalbard and Jan Mayen", | ||
countryCode: "SJ", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Swaziland", | ||
countryCode: "SZ", | ||
callingCode: "+268" | ||
}, | ||
{ | ||
country: "Sweden", | ||
countryCode: "SE", | ||
callingCode: "+46" | ||
}, | ||
{ | ||
country: "Switzerland", | ||
countryCode: "CH", | ||
callingCode: "+41" | ||
}, | ||
{ | ||
country: "Syria", | ||
countryCode: "SY", | ||
callingCode: "+963" | ||
}, | ||
{ | ||
country: "Taiwan", | ||
countryCode: "TW", | ||
callingCode: "+886" | ||
}, | ||
{ | ||
country: "Tajikistan", | ||
countryCode: "TJ", | ||
callingCode: "+992" | ||
}, | ||
{ | ||
country: "Tanzania", | ||
countryCode: "TZ", | ||
callingCode: "+255" | ||
}, | ||
{ | ||
country: "Thailand", | ||
countryCode: "TH", | ||
callingCode: "+66" | ||
}, | ||
{ | ||
country: "Togo", | ||
countryCode: "TG", | ||
callingCode: "+228" | ||
}, | ||
{ | ||
country: "Tokelau", | ||
countryCode: "TK", | ||
callingCode: "+690" | ||
}, | ||
{ | ||
country: "Tonga", | ||
countryCode: "TO", | ||
callingCode: "+676" | ||
}, | ||
{ | ||
country: "Trinidad and Tobago", | ||
countryCode: "TT", | ||
callingCode: "+1868" | ||
}, | ||
{ | ||
country: "Tunisia", | ||
countryCode: "TN", | ||
callingCode: "+216" | ||
}, | ||
{ | ||
country: "Turkey", | ||
countryCode: "TR", | ||
callingCode: "+90" | ||
}, | ||
{ | ||
country: "Turkmenistan", | ||
countryCode: "TM", | ||
callingCode: "+993" | ||
}, | ||
{ | ||
country: "Turks and Caicos Islands", | ||
countryCode: "TC", | ||
callingCode: "+1649" | ||
}, | ||
{ | ||
country: "Tuvalu", | ||
countryCode: "TV", | ||
callingCode: "+688" | ||
}, | ||
{ | ||
country: "U.S. Virgin Islands", | ||
countryCode: "VI", | ||
callingCode: "+1340" | ||
}, | ||
{ | ||
country: "Uganda", | ||
countryCode: "UG", | ||
callingCode: "+256" | ||
}, | ||
{ | ||
country: "Ukraine", | ||
countryCode: "UA", | ||
callingCode: "+380" | ||
}, | ||
{ | ||
country: "United Arab Emirates", | ||
countryCode: "AE", | ||
callingCode: "+971" | ||
}, | ||
{ | ||
country: "United Kingdom", | ||
countryCode: "GB", | ||
callingCode: "+44" | ||
}, | ||
{ | ||
country: "United States", | ||
countryCode: "US", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "United States Minor Outlying Islands", | ||
countryCode: "UM", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Uruguay", | ||
countryCode: "UY", | ||
callingCode: "+598" | ||
}, | ||
{ | ||
country: "Uzbekistan", | ||
countryCode: "UZ", | ||
callingCode: "+998" | ||
}, | ||
{ | ||
country: "Vanuatu", | ||
countryCode: "VU", | ||
callingCode: "+678" | ||
}, | ||
{ | ||
country: "Vatican", | ||
countryCode: "VA", | ||
callingCode: "+379" | ||
}, | ||
{ | ||
country: "Venezuela", | ||
countryCode: "VE", | ||
callingCode: "+58" | ||
}, | ||
{ | ||
country: "Vietnam", | ||
countryCode: "VN", | ||
callingCode: "+84" | ||
}, | ||
{ | ||
country: "Wallis and Futuna", | ||
countryCode: "WF", | ||
callingCode: "+681" | ||
}, | ||
{ | ||
country: "Western Sahara", | ||
countryCode: "EH", | ||
callingCode: "+212" | ||
}, | ||
{ | ||
country: "Yemen", | ||
countryCode: "YE", | ||
callingCode: "+967" | ||
}, | ||
{ | ||
country: "Zambia", | ||
countryCode: "ZM", | ||
callingCode: "+260" | ||
}, | ||
{ | ||
country: "Zimbabwe", | ||
countryCode: "ZW", | ||
callingCode: "+263" | ||
} | ||
]; | ||
//Get default country function | ||
const getDefaultCountry = (code) => { | ||
const result = countryData.find((item) => item.countryCode === code); | ||
return result; | ||
}; | ||
//Get country data by search | ||
const getBySearch = (search, onlyCountry, excludeCountry) => { | ||
let countries = []; | ||
if (excludeCountry && excludeCountry.length > 0) { | ||
countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode)); | ||
} | ||
else if (onlyCountry && onlyCountry?.length > 0) { | ||
countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode)); | ||
} | ||
else { | ||
countries = countryData; | ||
} | ||
const result = countries.filter((item) => { | ||
const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | ||
const regex = new RegExp(escapeRegExp(search), "gi"); | ||
return item.country.match(regex); | ||
}); | ||
return result; | ||
}; | ||
//Get country data by filter | ||
const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => { | ||
let countries = []; | ||
if (excludeCountry && excludeCountry.length > 0) { | ||
countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode)); | ||
} | ||
else if (onlyCountry && onlyCountry?.length > 0) { | ||
countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode)); | ||
} | ||
else { | ||
countries = countryData; | ||
} | ||
const result = countries.sort((a, b) => (Number(preferredCountry?.includes(b.countryCode)) - Number(preferredCountry?.includes(a.countryCode))) | ||
|| (preferredCountry?.indexOf(a.countryCode) - preferredCountry?.indexOf(b.countryCode))); | ||
return result; | ||
}; | ||
//Click out side hook | ||
function useOnClickOutside(ref, handler) { | ||
React.useEffect(() => { | ||
const listener = (event) => { | ||
if (!ref.current || ref.current.contains(event.target)) { | ||
return; | ||
} | ||
handler(event); | ||
}; | ||
document.addEventListener("mousedown", listener); | ||
document.addEventListener("touchstart", listener); | ||
return () => { | ||
document.removeEventListener("mousedown", listener); | ||
document.removeEventListener("touchstart", listener); | ||
}; | ||
}, [ref, handler]); | ||
} | ||
//Component | ||
const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inputProps, onlyCountries, excludeCountries, preferredCountries, showDropdownIcon = true, dialCodeInputField = false, search = true, searchPlaceholder = "Search country", showSearchIcon = true, searchIconComponent, searchProps, searchNotFound = "Not found" }) => { | ||
//State | ||
const [selected, setSelected] = React.useState({}); | ||
const [isDropdown, setDropdown] = React.useState(false); | ||
const [inputValue, setInputValue] = React.useState(value || ""); | ||
const [countryDataInfo, setCountryData] = React.useState(countryData); | ||
const [cursor, setCursor] = React.useState(0); | ||
//Ref | ||
const dropdownRef = React.useRef(null); | ||
const listRef = React.useRef(null); | ||
//Custom Hook Call | ||
useOnClickOutside(dropdownRef, () => setDropdown(false)); | ||
//Handler | ||
//---Input Onchange Handler// | ||
const handleChange = (e) => { | ||
const onlyNumber = e.target.value.replace(/\D/g, ''); | ||
if (dialCodeInputField) { | ||
onChange("+" + onlyNumber); | ||
setInputValue("+" + onlyNumber); | ||
} | ||
else { | ||
setInputValue(onlyNumber); | ||
onChange(selected.callingCode + onlyNumber); | ||
} | ||
}; | ||
//---Search Input Onchange Handler// | ||
const onSearchHandler = (e) => { | ||
const search = e.target.value; | ||
setCountryData(getBySearch(search, onlyCountries, excludeCountries)); | ||
}; | ||
//---Set Selected Handler// | ||
const handleSelected = (item, i) => { | ||
if (dialCodeInputField) { | ||
const result = inputValue?.replace(selected.callingCode, item.callingCode); | ||
setInputValue(result.length > 0 ? result : item.callingCode); | ||
onChange(result.length > 0 ? result : item.callingCode); | ||
} | ||
else { | ||
onChange(item.callingCode + inputValue); | ||
} | ||
setSelected(item); | ||
setDropdown(false); | ||
setCursor(i); | ||
}; | ||
//---Scroll To View Handler// | ||
const scrollIntoView = (position) => { | ||
if (search) { | ||
if (countryDataInfo.length > 0) { | ||
listRef.current?.scrollTo({ | ||
top: position, | ||
behavior: "smooth" | ||
}); | ||
} | ||
} | ||
}; | ||
//---Keyboard Navigation// | ||
const keyBoardNav = (e) => { | ||
if (isDropdown) { | ||
if (e.key === "ArrowDown") { | ||
e.preventDefault(); | ||
setCursor(c => (c < countryDataInfo.length - 1 ? c + 1 : c)); | ||
} | ||
if (e.key === "ArrowUp") { | ||
e.preventDefault(); | ||
setCursor(c => (c > 0 ? c - 1 : 0)); | ||
} | ||
if (e.key === "Escape") { | ||
setDropdown(false); | ||
} | ||
if (e.key === "Enter" && cursor >= 0) { | ||
setSelected(countryDataInfo[cursor]); | ||
setDropdown(false); | ||
} | ||
} | ||
}; | ||
//React Hook | ||
//---Scroll to view hook// | ||
React.useEffect(() => { | ||
if (cursor < 0 || cursor > countryDataInfo.length || !listRef) { | ||
return () => { | ||
}; | ||
} | ||
if (isDropdown && listRef) { | ||
if (countryDataInfo.length > 0) { | ||
let listItems = Array.from(listRef.current?.children); | ||
listItems[cursor] && scrollIntoView(listItems[cursor].offsetTop - 65); | ||
} | ||
} | ||
}, [cursor]); | ||
//---Dial Code Field Effect// | ||
React.useMemo(() => { | ||
if (dialCodeInputField) { | ||
const result = inputValue?.replace(selected.callingCode, getDefaultCountry(country).callingCode); | ||
console.log(result); | ||
setInputValue(result.length > 0 ? result : getDefaultCountry(country).callingCode); | ||
} | ||
setSelected(getDefaultCountry(country)); | ||
}, [country, dialCodeInputField]); | ||
//---Country search hook// | ||
React.useMemo(() => { | ||
setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries)); | ||
}, [onlyCountries, excludeCountries, preferredCountries]); | ||
return (jsxRuntime.jsx("div", { className: "simple-phone-input-sri198-container", onKeyDown: (e) => keyBoardNav(e), tabIndex: -1, children: jsxRuntime.jsxs("div", { className: "simple-phone-input-sri198-main", children: [jsxRuntime.jsxs("div", { className: "simple-phone-input-sri198-dropdown-container", ref: dropdownRef, children: [jsxRuntime.jsxs("div", { onClick: () => setDropdown(!isDropdown), className: dialCodeInputField ? "simple-phone-input-sri198-dropdown-container-button dial" : "simple-phone-input-sri198-dropdown-container-button", children: [jsxRuntime.jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + selected.countryCode + ".svg", alt: selected.country, width: "20px" }), !dialCodeInputField && | ||
jsxRuntime.jsx("span", { className: "simple-phone-input-sri198-selected-code", children: selected.callingCode }), showDropdownIcon && | ||
jsxRuntime.jsx("div", { className: isDropdown ? "simple-phone-input-sri198-dropdown-icon" : "simple-phone-input-sri198-dropdown-icon active", children: iconComponent ? iconComponent : (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { fill: "currentColor", d: "m7 10l5 5l5-5z" }) })) })] }), jsxRuntime.jsxs("ul", { className: isDropdown ? "simple-phone-input-sri198-dropdown active" : "simple-phone-input-sri198-dropdown", ref: listRef, children: [search && | ||
jsxRuntime.jsxs("div", { className: "simple-phone-input-sri198-search-container", children: [jsxRuntime.jsx("input", { placeholder: searchPlaceholder, ...searchProps, onChange: onSearchHandler }), showSearchIcon && | ||
jsxRuntime.jsx("div", { className: "simple-phone-input-sri198-search-icon", children: searchIconComponent ?? (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 48 48", children: [jsxRuntime.jsxs("g", { fill: "#616161", children: [jsxRuntime.jsx("path", { d: "m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z" }), jsxRuntime.jsx("circle", { cx: "20", cy: "20", r: "16" })] }), jsxRuntime.jsx("path", { fill: "#37474F", d: "m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z" }), jsxRuntime.jsx("circle", { cx: "20", cy: "20", r: "13", fill: "#64B5F6" }), jsxRuntime.jsx("path", { fill: "#BBDEFB", d: "M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z" })] })) })] }), countryDataInfo.length === 0 && | ||
jsxRuntime.jsx("div", { className: "simple-phone-input-sri198-not-found", children: searchNotFound }), countryDataInfo.map((item, i) => (jsxRuntime.jsxs("li", { onClick: () => handleSelected(item, i), className: i === cursor ? "active" : "", children: [jsxRuntime.jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + item.countryCode + ".svg", alt: item.country, width: "20px" }), jsxRuntime.jsx("span", { className: "simple-phone-input-sri198-dropdown-text", children: item.country }), jsxRuntime.jsx("span", { className: "simple-phone-input-sri198-dropdown-country-code", children: item.callingCode })] }, i)))] })] }), jsxRuntime.jsx("input", { className: "simple-phone-input-sri198-input", placeholder: placeholder, onChange: handleChange, type: "tel", onInput: (e) => { | ||
if (dialCodeInputField) { | ||
const oldVal = inputValue.slice(selected.callingCode.length); | ||
if (e.target.value.startsWith(selected.callingCode)) { | ||
e.target.value = e.target.value; | ||
} | ||
else { | ||
e.target.value = selected.callingCode + oldVal; | ||
} | ||
} | ||
}, onKeyDown: (e) => keyBoardNav(e), value: inputValue, ...inputProps })] }) })); | ||
}; | ||
exports.PhoneInput = PhoneInput; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1368 @@ | ||
import{jsx as o,jsxs as n}from"react/jsx-runtime";import e from"react";const c=[{country:"Afghanistan",countryCode:"AF",callingCode:"+93"},{country:"Albania",countryCode:"AL",callingCode:"+355"},{country:"Algeria",countryCode:"DZ",callingCode:"+213"},{country:"American Samoa",countryCode:"AS",callingCode:"+1684"},{country:"Andorra",countryCode:"AD",callingCode:"+376"},{country:"Angola",countryCode:"AO",callingCode:"+244"},{country:"Anguilla",countryCode:"AI",callingCode:"+1264"},{country:"Antarctica",countryCode:"AQ",callingCode:"+672"},{country:"Antigua and Barbuda",countryCode:"AG",callingCode:"+1268"},{country:"Argentina",countryCode:"AR",callingCode:"+54"},{country:"Armenia",countryCode:"AM",callingCode:"+374"},{country:"Aruba",countryCode:"AW",callingCode:"+297"},{country:"Australia",countryCode:"AU",callingCode:"+61"},{country:"Austria",countryCode:"AT",callingCode:"+43"},{country:"Azerbaijan",countryCode:"AZ",callingCode:"+994"},{country:"Bahamas",countryCode:"BS",callingCode:"+1242"},{country:"Bahrain",countryCode:"BH",callingCode:"+973"},{country:"Bangladesh",countryCode:"BD",callingCode:"+880"},{country:"Barbados",countryCode:"BB",callingCode:"+1246"},{country:"Belarus",countryCode:"BY",callingCode:"+375"},{country:"Belgium",countryCode:"BE",callingCode:"+32"},{country:"Belize",countryCode:"BZ",callingCode:"+501"},{country:"Benin",countryCode:"BJ",callingCode:"+229"},{country:"Bermuda",countryCode:"BM",callingCode:"+1441"},{country:"Bhutan",countryCode:"BT",callingCode:"+975"},{country:"Bolivia",countryCode:"BO",callingCode:"+591"},{country:"Bosnia and Herzegovina",countryCode:"BA",callingCode:"+387"},{country:"Botswana",countryCode:"BW",callingCode:"+267"},{country:"Bouvet Island",countryCode:"BV",callingCode:"+47"},{country:"Brazil",countryCode:"BR",callingCode:"+55"},{country:"British Indian Ocean Territory",countryCode:"IO",callingCode:"+246"},{country:"British Virgin Islands",countryCode:"VG",callingCode:"+1284"},{country:"Brunei",countryCode:"BN",callingCode:"+673"},{country:"Bulgaria",countryCode:"BG",callingCode:"+359"},{country:"Burkina Faso",countryCode:"BF",callingCode:"+226"},{country:"Burundi",countryCode:"BI",callingCode:"+257"},{country:"Cambodia",countryCode:"KH",callingCode:"+855"},{country:"Cameroon",countryCode:"CM",callingCode:"+237"},{country:"Canada",countryCode:"CA",callingCode:"+1"},{country:"Cape Verde",countryCode:"CV",callingCode:"+238"},{country:"Cayman Islands",countryCode:"KY",callingCode:"+1345"},{country:"Central African Republic",countryCode:"CF",callingCode:"+236"},{country:"Chad",countryCode:"TD",callingCode:"+235"},{country:"Chile",countryCode:"CL",callingCode:"+56"},{country:"China",countryCode:"CN",callingCode:"+86"},{country:"Christmas Island",countryCode:"CX",callingCode:"+61"},{country:"Cocos Islands",countryCode:"CC",callingCode:"+61"},{country:"Colombia",countryCode:"CO",callingCode:"+57"},{country:"Comoros",countryCode:"KM",callingCode:"+269"},{country:"Cook Islands",countryCode:"CK",callingCode:"+682"},{country:"Costa Rica",countryCode:"CR",callingCode:"+506"},{country:"Croatia",countryCode:"HR",callingCode:"+385"},{country:"Cuba",countryCode:"CU",callingCode:"+53"},{country:"Cyprus",countryCode:"CY",callingCode:"+357"},{country:"Czech Republic",countryCode:"CZ",callingCode:"+420"},{country:"Democratic Republic of the Congo",countryCode:"CD",callingCode:"+243"},{country:"Denmark",countryCode:"DK",callingCode:"+45"},{country:"Djibouti",countryCode:"DJ",callingCode:"+253"},{country:"Dominica",countryCode:"DM",callingCode:"+1767"},{country:"Dominican Republic",countryCode:"DO",callingCode:"+1"},{country:"East Timor",countryCode:"TL",callingCode:"+670"},{country:"Ecuador",countryCode:"EC",callingCode:"+593"},{country:"Egypt",countryCode:"EG",callingCode:"+20"},{country:"El Salvador",countryCode:"SV",callingCode:"+503"},{country:"Equatorial Guinea",countryCode:"GQ",callingCode:"+240"},{country:"Eritrea",countryCode:"ER",callingCode:"+291"},{country:"Estonia",countryCode:"EE",callingCode:"+372"},{country:"Ethiopia",countryCode:"ET",callingCode:"+251"},{country:"Falkland Islands",countryCode:"FK",callingCode:"+500"},{country:"Faroe Islands",countryCode:"FO",callingCode:"+298"},{country:"Fiji",countryCode:"FJ",callingCode:"+679"},{country:"Finland",countryCode:"FI",callingCode:"+358"},{country:"France",countryCode:"FR",callingCode:"+33"},{country:"French Guiana",countryCode:"GF",callingCode:"+594"},{country:"French Polynesia",countryCode:"PF",callingCode:"+689"},{country:"French Southern Territories",countryCode:"TF",callingCode:"+262"},{country:"Gabon",countryCode:"GA",callingCode:"+241"},{country:"Gambia",countryCode:"GM",callingCode:"+220"},{country:"Georgia",countryCode:"GE",callingCode:"+995"},{country:"Germany",countryCode:"DE",callingCode:"+49"},{country:"Ghana",countryCode:"GH",callingCode:"+233"},{country:"Gibraltar",countryCode:"GI",callingCode:"+350"},{country:"Greece",countryCode:"GR",callingCode:"+30"},{country:"Greenland",countryCode:"GL",callingCode:"+299"},{country:"Grenada",countryCode:"GD",callingCode:"+473"},{country:"Guadeloupe",countryCode:"GP",callingCode:"+590"},{country:"Guam",countryCode:"GU",callingCode:"+1671"},{country:"Guatemala",countryCode:"GT",callingCode:"+502"},{country:"Guinea",countryCode:"GN",callingCode:"+224"},{country:"Guinea-Bissau",countryCode:"GW",callingCode:"+245"},{country:"Guyana",countryCode:"GY",callingCode:"+592"},{country:"Haiti",countryCode:"HT",callingCode:"+509"},{country:"Honduras",countryCode:"HN",callingCode:"+504"},{country:"Hong Kong",countryCode:"HK",callingCode:"+852"},{country:"Hungary",countryCode:"HU",callingCode:"+36"},{country:"Iceland",countryCode:"IS",callingCode:"+354"},{country:"India",countryCode:"IN",callingCode:"+91"},{country:"Indonesia",countryCode:"ID",callingCode:"+62"},{country:"Iran",countryCode:"IR",callingCode:"+98"},{country:"Iraq",countryCode:"IQ",callingCode:"+964"},{country:"Ireland",countryCode:"IE",callingCode:"+353"},{country:"Israel",countryCode:"IL",callingCode:"+972"},{country:"Italy",countryCode:"IT",callingCode:"+39"},{country:"Ivory Coast",countryCode:"CI",callingCode:"+225"},{country:"Jamaica",countryCode:"JM",callingCode:"+1876"},{country:"Japan",countryCode:"JP",callingCode:"+81"},{country:"Jordan",countryCode:"JO",callingCode:"+962"},{country:"Kazakhstan",countryCode:"KZ",callingCode:"+7"},{country:"Kenya",countryCode:"KE",callingCode:"+254"},{country:"Kiribati",countryCode:"KI",callingCode:"+686"},{country:"Kuwait",countryCode:"KW",callingCode:"+965"},{country:"Kyrgyzstan",countryCode:"KG",callingCode:"+996"},{country:"Laos",countryCode:"LA",callingCode:"+856"},{country:"Latvia",countryCode:"LV",callingCode:"+371"},{country:"Lebanon",countryCode:"LB",callingCode:"+961"},{country:"Lesotho",countryCode:"LS",callingCode:"+266"},{country:"Liberia",countryCode:"LR",callingCode:"+231"},{country:"Libya",countryCode:"LY",callingCode:"+218"},{country:"Liechtenstein",countryCode:"LI",callingCode:"+423"},{country:"Lithuania",countryCode:"LT",callingCode:"+370"},{country:"Luxembourg",countryCode:"LU",callingCode:"+352"},{country:"Macao",countryCode:"MO",callingCode:"+853"},{country:"Macedonia",countryCode:"MK",callingCode:"+389"},{country:"Madagascar",countryCode:"MG",callingCode:"+261"},{country:"Malawi",countryCode:"MW",callingCode:"+265"},{country:"Malaysia",countryCode:"MY",callingCode:"+60"},{country:"Maldives",countryCode:"MV",callingCode:"+960"},{country:"Mali",countryCode:"ML",callingCode:"+223"},{country:"Malta",countryCode:"MT",callingCode:"+356"},{country:"Marshall Islands",countryCode:"MH",callingCode:"+692"},{country:"Martinique",countryCode:"MQ",callingCode:"+596"},{country:"Mauritania",countryCode:"MR",callingCode:"+222"},{country:"Mauritius",countryCode:"MU",callingCode:"+230"},{country:"Mayotte",countryCode:"YT",callingCode:"+262"},{country:"Mexico",countryCode:"MX",callingCode:"+52"},{country:"Micronesia",countryCode:"FM",callingCode:"+691"},{country:"Moldova",countryCode:"MD",callingCode:"+373"},{country:"Monaco",countryCode:"MC",callingCode:"+377"},{country:"Mongolia",countryCode:"MN",callingCode:"+976"},{country:"Montserrat",countryCode:"MS",callingCode:"+1664"},{country:"Morocco",countryCode:"MA",callingCode:"+212"},{country:"Mozambique",countryCode:"MZ",callingCode:"+258"},{country:"Myanmar",countryCode:"MM",callingCode:"+95"},{country:"Namibia",countryCode:"NA",callingCode:"+264"},{country:"Nauru",countryCode:"NR",callingCode:"+674"},{country:"Nepal",countryCode:"NP",callingCode:"+977"},{country:"Netherlands",countryCode:"NL",callingCode:"+31"},{country:"New Caledonia",countryCode:"NC",callingCode:"+687"},{country:"New Zealand",countryCode:"NZ",callingCode:"+64"},{country:"Nicaragua",countryCode:"NI",callingCode:"+505"},{country:"Niger",countryCode:"NE",callingCode:"+227"},{country:"Nigeria",countryCode:"NG",callingCode:"+234"},{country:"Niue",countryCode:"NU",callingCode:"+683"},{country:"Norfolk Island",countryCode:"NF",callingCode:"+672"},{country:"North Korea",countryCode:"KP",callingCode:"+850"},{country:"Northern Mariana Islands",countryCode:"MP",callingCode:"+1670"},{country:"Norway",countryCode:"NO",callingCode:"+47"},{country:"Oman",countryCode:"OM",callingCode:"+968"},{country:"Pakistan",countryCode:"PK",callingCode:"+92"},{country:"Palau",countryCode:"PW",callingCode:"+680"},{country:"Palestinian Territory",countryCode:"PS",callingCode:"+970"},{country:"Panama",countryCode:"PA",callingCode:"+507"},{country:"Papua New Guinea",countryCode:"PG",callingCode:"+675"},{country:"Paraguay",countryCode:"PY",callingCode:"+595"},{country:"Peru",countryCode:"PE",callingCode:"+51"},{country:"Philippines",countryCode:"PH",callingCode:"+63"},{country:"Pitcairn",countryCode:"PN",callingCode:"+872"},{country:"Poland",countryCode:"PL",callingCode:"+48"},{country:"Portugal",countryCode:"PT",callingCode:"+351"},{country:"Puerto Rico",countryCode:"PR",callingCode:"+1"},{country:"Qatar",countryCode:"QA",callingCode:"+974"},{country:"Republic of the Congo",countryCode:"CG",callingCode:"+242"},{country:"Reunion",countryCode:"RE",callingCode:"+262"},{country:"Romania",countryCode:"RO",callingCode:"+40"},{country:"Russia",countryCode:"RU",callingCode:"+7"},{country:"Rwanda",countryCode:"RW",callingCode:"+250"},{country:"Saint Helena",countryCode:"SH",callingCode:"+290"},{country:"Saint Kitts and Nevis",countryCode:"KN",callingCode:"+1869"},{country:"Saint Lucia",countryCode:"LC",callingCode:"+1758"},{country:"Saint Pierre and Miquelon",countryCode:"PM",callingCode:"+508"},{country:"Saint Vincent and the Grenadines",countryCode:"VC",callingCode:"+1784"},{country:"Samoa",countryCode:"WS",callingCode:"+685"},{country:"San Marino",countryCode:"SM",callingCode:"+378"},{country:"Sao Tome and Principe",countryCode:"ST",callingCode:"+239"},{country:"Saudi Arabia",countryCode:"SA",callingCode:"+966"},{country:"Senegal",countryCode:"SN",callingCode:"+221"},{country:"Seychelles",countryCode:"SC",callingCode:"+248"},{country:"Sierra Leone",countryCode:"SL",callingCode:"+232"},{country:"Singapore",countryCode:"SG",callingCode:"+65"},{country:"Slovakia",countryCode:"SK",callingCode:"+421"},{country:"Slovenia",countryCode:"SI",callingCode:"+386"},{country:"Solomon Islands",countryCode:"SB",callingCode:"+677"},{country:"Somalia",countryCode:"SO",callingCode:"+252"},{country:"South Africa",countryCode:"ZA",callingCode:"+27"},{country:"South Georgia and the South Sandwich Islands",countryCode:"GS",callingCode:"+500"},{country:"South Korea",countryCode:"KR",callingCode:"+82"},{country:"Spain",countryCode:"ES",callingCode:"+34"},{country:"Sri Lanka",countryCode:"LK",callingCode:"+94"},{country:"Sudan",countryCode:"SD",callingCode:"+249"},{country:"Suriname",countryCode:"SR",callingCode:"+597"},{country:"Svalbard and Jan Mayen",countryCode:"SJ",callingCode:"+47"},{country:"Swaziland",countryCode:"SZ",callingCode:"+268"},{country:"Sweden",countryCode:"SE",callingCode:"+46"},{country:"Switzerland",countryCode:"CH",callingCode:"+41"},{country:"Syria",countryCode:"SY",callingCode:"+963"},{country:"Taiwan",countryCode:"TW",callingCode:"+886"},{country:"Tajikistan",countryCode:"TJ",callingCode:"+992"},{country:"Tanzania",countryCode:"TZ",callingCode:"+255"},{country:"Thailand",countryCode:"TH",callingCode:"+66"},{country:"Togo",countryCode:"TG",callingCode:"+228"},{country:"Tokelau",countryCode:"TK",callingCode:"+690"},{country:"Tonga",countryCode:"TO",callingCode:"+676"},{country:"Trinidad and Tobago",countryCode:"TT",callingCode:"+1868"},{country:"Tunisia",countryCode:"TN",callingCode:"+216"},{country:"Turkey",countryCode:"TR",callingCode:"+90"},{country:"Turkmenistan",countryCode:"TM",callingCode:"+993"},{country:"Turks and Caicos Islands",countryCode:"TC",callingCode:"+1649"},{country:"Tuvalu",countryCode:"TV",callingCode:"+688"},{country:"U.S. Virgin Islands",countryCode:"VI",callingCode:"+1340"},{country:"Uganda",countryCode:"UG",callingCode:"+256"},{country:"Ukraine",countryCode:"UA",callingCode:"+380"},{country:"United Arab Emirates",countryCode:"AE",callingCode:"+971"},{country:"United Kingdom",countryCode:"GB",callingCode:"+44"},{country:"United States",countryCode:"US",callingCode:"+1"},{country:"United States Minor Outlying Islands",countryCode:"UM",callingCode:"+1"},{country:"Uruguay",countryCode:"UY",callingCode:"+598"},{country:"Uzbekistan",countryCode:"UZ",callingCode:"+998"},{country:"Vanuatu",countryCode:"VU",callingCode:"+678"},{country:"Vatican",countryCode:"VA",callingCode:"+379"},{country:"Venezuela",countryCode:"VE",callingCode:"+58"},{country:"Vietnam",countryCode:"VN",callingCode:"+84"},{country:"Wallis and Futuna",countryCode:"WF",callingCode:"+681"},{country:"Western Sahara",countryCode:"EH",callingCode:"+212"},{country:"Yemen",countryCode:"YE",callingCode:"+967"},{country:"Zambia",countryCode:"ZM",callingCode:"+260"},{country:"Zimbabwe",countryCode:"ZW",callingCode:"+263"}],r=o=>c.find((n=>n.countryCode===o));const t=({placeholder:t,country:l,onChange:a,value:d,iconComponent:u,inputProps:i,onlyCountries:C,excludeCountries:y,preferredCountries:g,showDropdownIcon:s=!0,dialCodeInputField:h=!1,search:p=!0,searchPlaceholder:m="Search country",showSearchIcon:S=!0,searchIconComponent:M,searchProps:N,searchNotFound:v="Not found"})=>{const[B,A]=e.useState({}),[I,G]=e.useState(!1),[T,w]=e.useState(d||""),[f,E]=e.useState(c),[b,P]=e.useState(0),L=e.useRef(null),R=e.useRef(null);var K,F;K=L,F=()=>G(!1),e.useEffect((()=>{const o=o=>{K.current&&!K.current.contains(o.target)&&F(o)};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}}),[K,F]);const D=o=>{I&&("ArrowDown"===o.key&&(o.preventDefault(),P((o=>o<f.length-1?o+1:o))),"ArrowUp"===o.key&&(o.preventDefault(),P((o=>o>0?o-1:0))),"Escape"===o.key&&G(!1),"Enter"===o.key&&b>=0&&(A(f[b]),G(!1)))};return e.useEffect((()=>{if(b<0||b>f.length||!R)return()=>{};if(I&&R&&f.length>0){let n=Array.from(R.current?.children);n[b]&&(o=n[b].offsetTop-65,p&&f.length>0&&R.current?.scrollTo({top:o,behavior:"smooth"}))}var o}),[b]),e.useMemo((()=>{if(h){const o=T?.replace(B.callingCode,r(l).callingCode);console.log(o),w(o.length>0?o:r(l).callingCode)}A(r(l))}),[l,h]),e.useMemo((()=>{E(((o,n,e)=>{let r=[];return r=n&&n.length>0?c.filter((o=>!n?.includes(o.countryCode))):o&&o?.length>0?c.filter((n=>o?.includes(n.countryCode))):c,r.sort(((o,n)=>Number(e?.includes(n.countryCode))-Number(e?.includes(o.countryCode))||e?.indexOf(o.countryCode)-e?.indexOf(n.countryCode)))})(C,y,g))}),[C,y,g]),o("div",{className:"simple-phone-input-sri198-container",onKeyDown:o=>D(o),tabIndex:-1,children:n("div",{className:"simple-phone-input-sri198-main",children:[n("div",{className:"simple-phone-input-sri198-dropdown-container",ref:L,children:[n("div",{onClick:()=>G(!I),className:h?"simple-phone-input-sri198-dropdown-container-button dial":"simple-phone-input-sri198-dropdown-container-button",children:[o("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+B.countryCode+".svg",alt:B.country,width:"20px"}),!h&&o("span",{className:"simple-phone-input-sri198-selected-code",children:B.callingCode}),s&&o("div",{className:I?"simple-phone-input-sri198-dropdown-icon":"simple-phone-input-sri198-dropdown-icon active",children:u||o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",children:o("path",{fill:"currentColor",d:"m7 10l5 5l5-5z"})})})]}),n("ul",{className:I?"simple-phone-input-sri198-dropdown active":"simple-phone-input-sri198-dropdown",ref:R,children:[p&&n("div",{className:"simple-phone-input-sri198-search-container",children:[o("input",{placeholder:m,...N,onChange:o=>{const n=o.target.value;E(((o,n,e)=>{let r=[];return r=e&&e.length>0?c.filter((o=>!e?.includes(o.countryCode))):n&&n?.length>0?c.filter((o=>n?.includes(o.countryCode))):c,r.filter((n=>{const e=new RegExp(o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"gi");return n.country.match(e)}))})(n,C,y))}}),S&&o("div",{className:"simple-phone-input-sri198-search-icon",children:M??n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 48 48",children:[n("g",{fill:"#616161",children:[o("path",{d:"m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z"}),o("circle",{cx:"20",cy:"20",r:"16"})]}),o("path",{fill:"#37474F",d:"m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z"}),o("circle",{cx:"20",cy:"20",r:"13",fill:"#64B5F6"}),o("path",{fill:"#BBDEFB",d:"M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z"})]})})]}),0===f.length&&o("div",{className:"simple-phone-input-sri198-not-found",children:v}),f.map(((e,c)=>n("li",{onClick:()=>((o,n)=>{if(h){const n=T?.replace(B.callingCode,o.callingCode);w(n.length>0?n:o.callingCode),a(n.length>0?n:o.callingCode)}else a(o.callingCode+T);A(o),G(!1),P(n)})(e,c),className:c===b?"active":"",children:[o("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+e.countryCode+".svg",alt:e.country,width:"20px"}),o("span",{className:"simple-phone-input-sri198-dropdown-text",children:e.country}),o("span",{className:"simple-phone-input-sri198-dropdown-country-code",children:e.callingCode})]},c)))]})]}),o("input",{className:"simple-phone-input-sri198-input",placeholder:t,onChange:o=>{const n=o.target.value.replace(/\D/g,"");h?(a("+"+n),w("+"+n)):(w(n),a(B.callingCode+n))},type:"tel",onInput:o=>{if(h){const n=T.slice(B.callingCode.length);o.target.value.startsWith(B.callingCode)?o.target.value=o.target.value:o.target.value=B.callingCode+n}},onKeyDown:o=>D(o),value:T,...i})]})})};export{t as PhoneInput}; | ||
import { jsx, jsxs } from 'react/jsx-runtime'; | ||
import React from 'react'; | ||
const countryData = [ | ||
{ | ||
country: "Afghanistan", | ||
countryCode: "AF", | ||
callingCode: "+93" | ||
}, | ||
{ | ||
country: "Albania", | ||
countryCode: "AL", | ||
callingCode: "+355" | ||
}, | ||
{ | ||
country: "Algeria", | ||
countryCode: "DZ", | ||
callingCode: "+213" | ||
}, | ||
{ | ||
country: "American Samoa", | ||
countryCode: "AS", | ||
callingCode: "+1684" | ||
}, | ||
{ | ||
country: "Andorra", | ||
countryCode: "AD", | ||
callingCode: "+376" | ||
}, | ||
{ | ||
country: "Angola", | ||
countryCode: "AO", | ||
callingCode: "+244" | ||
}, | ||
{ | ||
country: "Anguilla", | ||
countryCode: "AI", | ||
callingCode: "+1264" | ||
}, | ||
{ | ||
country: "Antarctica", | ||
countryCode: "AQ", | ||
callingCode: "+672" | ||
}, | ||
{ | ||
country: "Antigua and Barbuda", | ||
countryCode: "AG", | ||
callingCode: "+1268" | ||
}, | ||
{ | ||
country: "Argentina", | ||
countryCode: "AR", | ||
callingCode: "+54" | ||
}, | ||
{ | ||
country: "Armenia", | ||
countryCode: "AM", | ||
callingCode: "+374" | ||
}, | ||
{ | ||
country: "Aruba", | ||
countryCode: "AW", | ||
callingCode: "+297" | ||
}, | ||
{ | ||
country: "Australia", | ||
countryCode: "AU", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Austria", | ||
countryCode: "AT", | ||
callingCode: "+43" | ||
}, | ||
{ | ||
country: "Azerbaijan", | ||
countryCode: "AZ", | ||
callingCode: "+994" | ||
}, | ||
{ | ||
country: "Bahamas", | ||
countryCode: "BS", | ||
callingCode: "+1242" | ||
}, | ||
{ | ||
country: "Bahrain", | ||
countryCode: "BH", | ||
callingCode: "+973" | ||
}, | ||
{ | ||
country: "Bangladesh", | ||
countryCode: "BD", | ||
callingCode: "+880" | ||
}, | ||
{ | ||
country: "Barbados", | ||
countryCode: "BB", | ||
callingCode: "+1246" | ||
}, | ||
{ | ||
country: "Belarus", | ||
countryCode: "BY", | ||
callingCode: "+375" | ||
}, | ||
{ | ||
country: "Belgium", | ||
countryCode: "BE", | ||
callingCode: "+32" | ||
}, | ||
{ | ||
country: "Belize", | ||
countryCode: "BZ", | ||
callingCode: "+501" | ||
}, | ||
{ | ||
country: "Benin", | ||
countryCode: "BJ", | ||
callingCode: "+229" | ||
}, | ||
{ | ||
country: "Bermuda", | ||
countryCode: "BM", | ||
callingCode: "+1441" | ||
}, | ||
{ | ||
country: "Bhutan", | ||
countryCode: "BT", | ||
callingCode: "+975" | ||
}, | ||
{ | ||
country: "Bolivia", | ||
countryCode: "BO", | ||
callingCode: "+591" | ||
}, | ||
{ | ||
country: "Bosnia and Herzegovina", | ||
countryCode: "BA", | ||
callingCode: "+387" | ||
}, | ||
{ | ||
country: "Botswana", | ||
countryCode: "BW", | ||
callingCode: "+267" | ||
}, | ||
{ | ||
country: "Bouvet Island", | ||
countryCode: "BV", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Brazil", | ||
countryCode: "BR", | ||
callingCode: "+55" | ||
}, | ||
{ | ||
country: "British Indian Ocean Territory", | ||
countryCode: "IO", | ||
callingCode: "+246" | ||
}, | ||
{ | ||
country: "British Virgin Islands", | ||
countryCode: "VG", | ||
callingCode: "+1284" | ||
}, | ||
{ | ||
country: "Brunei", | ||
countryCode: "BN", | ||
callingCode: "+673" | ||
}, | ||
{ | ||
country: "Bulgaria", | ||
countryCode: "BG", | ||
callingCode: "+359" | ||
}, | ||
{ | ||
country: "Burkina Faso", | ||
countryCode: "BF", | ||
callingCode: "+226" | ||
}, | ||
{ | ||
country: "Burundi", | ||
countryCode: "BI", | ||
callingCode: "+257" | ||
}, | ||
{ | ||
country: "Cambodia", | ||
countryCode: "KH", | ||
callingCode: "+855" | ||
}, | ||
{ | ||
country: "Cameroon", | ||
countryCode: "CM", | ||
callingCode: "+237" | ||
}, | ||
{ | ||
country: "Canada", | ||
countryCode: "CA", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Cape Verde", | ||
countryCode: "CV", | ||
callingCode: "+238" | ||
}, | ||
{ | ||
country: "Cayman Islands", | ||
countryCode: "KY", | ||
callingCode: "+1345" | ||
}, | ||
{ | ||
country: "Central African Republic", | ||
countryCode: "CF", | ||
callingCode: "+236" | ||
}, | ||
{ | ||
country: "Chad", | ||
countryCode: "TD", | ||
callingCode: "+235" | ||
}, | ||
{ | ||
country: "Chile", | ||
countryCode: "CL", | ||
callingCode: "+56" | ||
}, | ||
{ | ||
country: "China", | ||
countryCode: "CN", | ||
callingCode: "+86" | ||
}, | ||
{ | ||
country: "Christmas Island", | ||
countryCode: "CX", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Cocos Islands", | ||
countryCode: "CC", | ||
callingCode: "+61" | ||
}, | ||
{ | ||
country: "Colombia", | ||
countryCode: "CO", | ||
callingCode: "+57" | ||
}, | ||
{ | ||
country: "Comoros", | ||
countryCode: "KM", | ||
callingCode: "+269" | ||
}, | ||
{ | ||
country: "Cook Islands", | ||
countryCode: "CK", | ||
callingCode: "+682" | ||
}, | ||
{ | ||
country: "Costa Rica", | ||
countryCode: "CR", | ||
callingCode: "+506" | ||
}, | ||
{ | ||
country: "Croatia", | ||
countryCode: "HR", | ||
callingCode: "+385" | ||
}, | ||
{ | ||
country: "Cuba", | ||
countryCode: "CU", | ||
callingCode: "+53" | ||
}, | ||
{ | ||
country: "Cyprus", | ||
countryCode: "CY", | ||
callingCode: "+357" | ||
}, | ||
{ | ||
country: "Czech Republic", | ||
countryCode: "CZ", | ||
callingCode: "+420" | ||
}, | ||
{ | ||
country: "Democratic Republic of the Congo", | ||
countryCode: "CD", | ||
callingCode: "+243" | ||
}, | ||
{ | ||
country: "Denmark", | ||
countryCode: "DK", | ||
callingCode: "+45" | ||
}, | ||
{ | ||
country: "Djibouti", | ||
countryCode: "DJ", | ||
callingCode: "+253" | ||
}, | ||
{ | ||
country: "Dominica", | ||
countryCode: "DM", | ||
callingCode: "+1767" | ||
}, | ||
{ | ||
country: "Dominican Republic", | ||
countryCode: "DO", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "East Timor", | ||
countryCode: "TL", | ||
callingCode: "+670" | ||
}, | ||
{ | ||
country: "Ecuador", | ||
countryCode: "EC", | ||
callingCode: "+593" | ||
}, | ||
{ | ||
country: "Egypt", | ||
countryCode: "EG", | ||
callingCode: "+20" | ||
}, | ||
{ | ||
country: "El Salvador", | ||
countryCode: "SV", | ||
callingCode: "+503" | ||
}, | ||
{ | ||
country: "Equatorial Guinea", | ||
countryCode: "GQ", | ||
callingCode: "+240" | ||
}, | ||
{ | ||
country: "Eritrea", | ||
countryCode: "ER", | ||
callingCode: "+291" | ||
}, | ||
{ | ||
country: "Estonia", | ||
countryCode: "EE", | ||
callingCode: "+372" | ||
}, | ||
{ | ||
country: "Ethiopia", | ||
countryCode: "ET", | ||
callingCode: "+251" | ||
}, | ||
{ | ||
country: "Falkland Islands", | ||
countryCode: "FK", | ||
callingCode: "+500" | ||
}, | ||
{ | ||
country: "Faroe Islands", | ||
countryCode: "FO", | ||
callingCode: "+298" | ||
}, | ||
{ | ||
country: "Fiji", | ||
countryCode: "FJ", | ||
callingCode: "+679" | ||
}, | ||
{ | ||
country: "Finland", | ||
countryCode: "FI", | ||
callingCode: "+358" | ||
}, | ||
{ | ||
country: "France", | ||
countryCode: "FR", | ||
callingCode: "+33" | ||
}, | ||
{ | ||
country: "French Guiana", | ||
countryCode: "GF", | ||
callingCode: "+594" | ||
}, | ||
{ | ||
country: "French Polynesia", | ||
countryCode: "PF", | ||
callingCode: "+689" | ||
}, | ||
{ | ||
country: "French Southern Territories", | ||
countryCode: "TF", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Gabon", | ||
countryCode: "GA", | ||
callingCode: "+241" | ||
}, | ||
{ | ||
country: "Gambia", | ||
countryCode: "GM", | ||
callingCode: "+220" | ||
}, | ||
{ | ||
country: "Georgia", | ||
countryCode: "GE", | ||
callingCode: "+995" | ||
}, | ||
{ | ||
country: "Germany", | ||
countryCode: "DE", | ||
callingCode: "+49" | ||
}, | ||
{ | ||
country: "Ghana", | ||
countryCode: "GH", | ||
callingCode: "+233" | ||
}, | ||
{ | ||
country: "Gibraltar", | ||
countryCode: "GI", | ||
callingCode: "+350" | ||
}, | ||
{ | ||
country: "Greece", | ||
countryCode: "GR", | ||
callingCode: "+30" | ||
}, | ||
{ | ||
country: "Greenland", | ||
countryCode: "GL", | ||
callingCode: "+299" | ||
}, | ||
{ | ||
country: "Grenada", | ||
countryCode: "GD", | ||
callingCode: "+473" | ||
}, | ||
{ | ||
country: "Guadeloupe", | ||
countryCode: "GP", | ||
callingCode: "+590" | ||
}, | ||
{ | ||
country: "Guam", | ||
countryCode: "GU", | ||
callingCode: "+1671" | ||
}, | ||
{ | ||
country: "Guatemala", | ||
countryCode: "GT", | ||
callingCode: "+502" | ||
}, | ||
{ | ||
country: "Guinea", | ||
countryCode: "GN", | ||
callingCode: "+224" | ||
}, | ||
{ | ||
country: "Guinea-Bissau", | ||
countryCode: "GW", | ||
callingCode: "+245" | ||
}, | ||
{ | ||
country: "Guyana", | ||
countryCode: "GY", | ||
callingCode: "+592" | ||
}, | ||
{ | ||
country: "Haiti", | ||
countryCode: "HT", | ||
callingCode: "+509" | ||
}, | ||
{ | ||
country: "Honduras", | ||
countryCode: "HN", | ||
callingCode: "+504" | ||
}, | ||
{ | ||
country: "Hong Kong", | ||
countryCode: "HK", | ||
callingCode: "+852" | ||
}, | ||
{ | ||
country: "Hungary", | ||
countryCode: "HU", | ||
callingCode: "+36" | ||
}, | ||
{ | ||
country: "Iceland", | ||
countryCode: "IS", | ||
callingCode: "+354" | ||
}, | ||
{ | ||
country: "India", | ||
countryCode: "IN", | ||
callingCode: "+91" | ||
}, | ||
{ | ||
country: "Indonesia", | ||
countryCode: "ID", | ||
callingCode: "+62" | ||
}, | ||
{ | ||
country: "Iran", | ||
countryCode: "IR", | ||
callingCode: "+98" | ||
}, | ||
{ | ||
country: "Iraq", | ||
countryCode: "IQ", | ||
callingCode: "+964" | ||
}, | ||
{ | ||
country: "Ireland", | ||
countryCode: "IE", | ||
callingCode: "+353" | ||
}, | ||
{ | ||
country: "Israel", | ||
countryCode: "IL", | ||
callingCode: "+972" | ||
}, | ||
{ | ||
country: "Italy", | ||
countryCode: "IT", | ||
callingCode: "+39" | ||
}, | ||
{ | ||
country: "Ivory Coast", | ||
countryCode: "CI", | ||
callingCode: "+225" | ||
}, | ||
{ | ||
country: "Jamaica", | ||
countryCode: "JM", | ||
callingCode: "+1876" | ||
}, | ||
{ | ||
country: "Japan", | ||
countryCode: "JP", | ||
callingCode: "+81" | ||
}, | ||
{ | ||
country: "Jordan", | ||
countryCode: "JO", | ||
callingCode: "+962" | ||
}, | ||
{ | ||
country: "Kazakhstan", | ||
countryCode: "KZ", | ||
callingCode: "+7" | ||
}, | ||
{ | ||
country: "Kenya", | ||
countryCode: "KE", | ||
callingCode: "+254" | ||
}, | ||
{ | ||
country: "Kiribati", | ||
countryCode: "KI", | ||
callingCode: "+686" | ||
}, | ||
{ | ||
country: "Kuwait", | ||
countryCode: "KW", | ||
callingCode: "+965" | ||
}, | ||
{ | ||
country: "Kyrgyzstan", | ||
countryCode: "KG", | ||
callingCode: "+996" | ||
}, | ||
{ | ||
country: "Laos", | ||
countryCode: "LA", | ||
callingCode: "+856" | ||
}, | ||
{ | ||
country: "Latvia", | ||
countryCode: "LV", | ||
callingCode: "+371" | ||
}, | ||
{ | ||
country: "Lebanon", | ||
countryCode: "LB", | ||
callingCode: "+961" | ||
}, | ||
{ | ||
country: "Lesotho", | ||
countryCode: "LS", | ||
callingCode: "+266" | ||
}, | ||
{ | ||
country: "Liberia", | ||
countryCode: "LR", | ||
callingCode: "+231" | ||
}, | ||
{ | ||
country: "Libya", | ||
countryCode: "LY", | ||
callingCode: "+218" | ||
}, | ||
{ | ||
country: "Liechtenstein", | ||
countryCode: "LI", | ||
callingCode: "+423" | ||
}, | ||
{ | ||
country: "Lithuania", | ||
countryCode: "LT", | ||
callingCode: "+370" | ||
}, | ||
{ | ||
country: "Luxembourg", | ||
countryCode: "LU", | ||
callingCode: "+352" | ||
}, | ||
{ | ||
country: "Macao", | ||
countryCode: "MO", | ||
callingCode: "+853" | ||
}, | ||
{ | ||
country: "Macedonia", | ||
countryCode: "MK", | ||
callingCode: "+389" | ||
}, | ||
{ | ||
country: "Madagascar", | ||
countryCode: "MG", | ||
callingCode: "+261" | ||
}, | ||
{ | ||
country: "Malawi", | ||
countryCode: "MW", | ||
callingCode: "+265" | ||
}, | ||
{ | ||
country: "Malaysia", | ||
countryCode: "MY", | ||
callingCode: "+60" | ||
}, | ||
{ | ||
country: "Maldives", | ||
countryCode: "MV", | ||
callingCode: "+960" | ||
}, | ||
{ | ||
country: "Mali", | ||
countryCode: "ML", | ||
callingCode: "+223" | ||
}, | ||
{ | ||
country: "Malta", | ||
countryCode: "MT", | ||
callingCode: "+356" | ||
}, | ||
{ | ||
country: "Marshall Islands", | ||
countryCode: "MH", | ||
callingCode: "+692" | ||
}, | ||
{ | ||
country: "Martinique", | ||
countryCode: "MQ", | ||
callingCode: "+596" | ||
}, | ||
{ | ||
country: "Mauritania", | ||
countryCode: "MR", | ||
callingCode: "+222" | ||
}, | ||
{ | ||
country: "Mauritius", | ||
countryCode: "MU", | ||
callingCode: "+230" | ||
}, | ||
{ | ||
country: "Mayotte", | ||
countryCode: "YT", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Mexico", | ||
countryCode: "MX", | ||
callingCode: "+52" | ||
}, | ||
{ | ||
country: "Micronesia", | ||
countryCode: "FM", | ||
callingCode: "+691" | ||
}, | ||
{ | ||
country: "Moldova", | ||
countryCode: "MD", | ||
callingCode: "+373" | ||
}, | ||
{ | ||
country: "Monaco", | ||
countryCode: "MC", | ||
callingCode: "+377" | ||
}, | ||
{ | ||
country: "Mongolia", | ||
countryCode: "MN", | ||
callingCode: "+976" | ||
}, | ||
{ | ||
country: "Montserrat", | ||
countryCode: "MS", | ||
callingCode: "+1664" | ||
}, | ||
{ | ||
country: "Morocco", | ||
countryCode: "MA", | ||
callingCode: "+212" | ||
}, | ||
{ | ||
country: "Mozambique", | ||
countryCode: "MZ", | ||
callingCode: "+258" | ||
}, | ||
{ | ||
country: "Myanmar", | ||
countryCode: "MM", | ||
callingCode: "+95" | ||
}, | ||
{ | ||
country: "Namibia", | ||
countryCode: "NA", | ||
callingCode: "+264" | ||
}, | ||
{ | ||
country: "Nauru", | ||
countryCode: "NR", | ||
callingCode: "+674" | ||
}, | ||
{ | ||
country: "Nepal", | ||
countryCode: "NP", | ||
callingCode: "+977" | ||
}, | ||
{ | ||
country: "Netherlands", | ||
countryCode: "NL", | ||
callingCode: "+31" | ||
}, | ||
{ | ||
country: "New Caledonia", | ||
countryCode: "NC", | ||
callingCode: "+687" | ||
}, | ||
{ | ||
country: "New Zealand", | ||
countryCode: "NZ", | ||
callingCode: "+64" | ||
}, | ||
{ | ||
country: "Nicaragua", | ||
countryCode: "NI", | ||
callingCode: "+505" | ||
}, | ||
{ | ||
country: "Niger", | ||
countryCode: "NE", | ||
callingCode: "+227" | ||
}, | ||
{ | ||
country: "Nigeria", | ||
countryCode: "NG", | ||
callingCode: "+234" | ||
}, | ||
{ | ||
country: "Niue", | ||
countryCode: "NU", | ||
callingCode: "+683" | ||
}, | ||
{ | ||
country: "Norfolk Island", | ||
countryCode: "NF", | ||
callingCode: "+672" | ||
}, | ||
{ | ||
country: "North Korea", | ||
countryCode: "KP", | ||
callingCode: "+850" | ||
}, | ||
{ | ||
country: "Northern Mariana Islands", | ||
countryCode: "MP", | ||
callingCode: "+1670" | ||
}, | ||
{ | ||
country: "Norway", | ||
countryCode: "NO", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Oman", | ||
countryCode: "OM", | ||
callingCode: "+968" | ||
}, | ||
{ | ||
country: "Pakistan", | ||
countryCode: "PK", | ||
callingCode: "+92" | ||
}, | ||
{ | ||
country: "Palau", | ||
countryCode: "PW", | ||
callingCode: "+680" | ||
}, | ||
{ | ||
country: "Palestinian Territory", | ||
countryCode: "PS", | ||
callingCode: "+970" | ||
}, | ||
{ | ||
country: "Panama", | ||
countryCode: "PA", | ||
callingCode: "+507" | ||
}, | ||
{ | ||
country: "Papua New Guinea", | ||
countryCode: "PG", | ||
callingCode: "+675" | ||
}, | ||
{ | ||
country: "Paraguay", | ||
countryCode: "PY", | ||
callingCode: "+595" | ||
}, | ||
{ | ||
country: "Peru", | ||
countryCode: "PE", | ||
callingCode: "+51" | ||
}, | ||
{ | ||
country: "Philippines", | ||
countryCode: "PH", | ||
callingCode: "+63" | ||
}, | ||
{ | ||
country: "Pitcairn", | ||
countryCode: "PN", | ||
callingCode: "+872" | ||
}, | ||
{ | ||
country: "Poland", | ||
countryCode: "PL", | ||
callingCode: "+48" | ||
}, | ||
{ | ||
country: "Portugal", | ||
countryCode: "PT", | ||
callingCode: "+351" | ||
}, | ||
{ | ||
country: "Puerto Rico", | ||
countryCode: "PR", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Qatar", | ||
countryCode: "QA", | ||
callingCode: "+974" | ||
}, | ||
{ | ||
country: "Republic of the Congo", | ||
countryCode: "CG", | ||
callingCode: "+242" | ||
}, | ||
{ | ||
country: "Reunion", | ||
countryCode: "RE", | ||
callingCode: "+262" | ||
}, | ||
{ | ||
country: "Romania", | ||
countryCode: "RO", | ||
callingCode: "+40" | ||
}, | ||
{ | ||
country: "Russia", | ||
countryCode: "RU", | ||
callingCode: "+7" | ||
}, | ||
{ | ||
country: "Rwanda", | ||
countryCode: "RW", | ||
callingCode: "+250" | ||
}, | ||
{ | ||
country: "Saint Helena", | ||
countryCode: "SH", | ||
callingCode: "+290" | ||
}, | ||
{ | ||
country: "Saint Kitts and Nevis", | ||
countryCode: "KN", | ||
callingCode: "+1869" | ||
}, | ||
{ | ||
country: "Saint Lucia", | ||
countryCode: "LC", | ||
callingCode: "+1758" | ||
}, | ||
{ | ||
country: "Saint Pierre and Miquelon", | ||
countryCode: "PM", | ||
callingCode: "+508" | ||
}, | ||
{ | ||
country: "Saint Vincent and the Grenadines", | ||
countryCode: "VC", | ||
callingCode: "+1784" | ||
}, | ||
{ | ||
country: "Samoa", | ||
countryCode: "WS", | ||
callingCode: "+685" | ||
}, | ||
{ | ||
country: "San Marino", | ||
countryCode: "SM", | ||
callingCode: "+378" | ||
}, | ||
{ | ||
country: "Sao Tome and Principe", | ||
countryCode: "ST", | ||
callingCode: "+239" | ||
}, | ||
{ | ||
country: "Saudi Arabia", | ||
countryCode: "SA", | ||
callingCode: "+966" | ||
}, | ||
{ | ||
country: "Senegal", | ||
countryCode: "SN", | ||
callingCode: "+221" | ||
}, | ||
{ | ||
country: "Seychelles", | ||
countryCode: "SC", | ||
callingCode: "+248" | ||
}, | ||
{ | ||
country: "Sierra Leone", | ||
countryCode: "SL", | ||
callingCode: "+232" | ||
}, | ||
{ | ||
country: "Singapore", | ||
countryCode: "SG", | ||
callingCode: "+65" | ||
}, | ||
{ | ||
country: "Slovakia", | ||
countryCode: "SK", | ||
callingCode: "+421" | ||
}, | ||
{ | ||
country: "Slovenia", | ||
countryCode: "SI", | ||
callingCode: "+386" | ||
}, | ||
{ | ||
country: "Solomon Islands", | ||
countryCode: "SB", | ||
callingCode: "+677" | ||
}, | ||
{ | ||
country: "Somalia", | ||
countryCode: "SO", | ||
callingCode: "+252" | ||
}, | ||
{ | ||
country: "South Africa", | ||
countryCode: "ZA", | ||
callingCode: "+27" | ||
}, | ||
{ | ||
country: "South Georgia and the South Sandwich Islands", | ||
countryCode: "GS", | ||
callingCode: "+500" | ||
}, | ||
{ | ||
country: "South Korea", | ||
countryCode: "KR", | ||
callingCode: "+82" | ||
}, | ||
{ | ||
country: "Spain", | ||
countryCode: "ES", | ||
callingCode: "+34" | ||
}, | ||
{ | ||
country: "Sri Lanka", | ||
countryCode: "LK", | ||
callingCode: "+94" | ||
}, | ||
{ | ||
country: "Sudan", | ||
countryCode: "SD", | ||
callingCode: "+249" | ||
}, | ||
{ | ||
country: "Suriname", | ||
countryCode: "SR", | ||
callingCode: "+597" | ||
}, | ||
{ | ||
country: "Svalbard and Jan Mayen", | ||
countryCode: "SJ", | ||
callingCode: "+47" | ||
}, | ||
{ | ||
country: "Swaziland", | ||
countryCode: "SZ", | ||
callingCode: "+268" | ||
}, | ||
{ | ||
country: "Sweden", | ||
countryCode: "SE", | ||
callingCode: "+46" | ||
}, | ||
{ | ||
country: "Switzerland", | ||
countryCode: "CH", | ||
callingCode: "+41" | ||
}, | ||
{ | ||
country: "Syria", | ||
countryCode: "SY", | ||
callingCode: "+963" | ||
}, | ||
{ | ||
country: "Taiwan", | ||
countryCode: "TW", | ||
callingCode: "+886" | ||
}, | ||
{ | ||
country: "Tajikistan", | ||
countryCode: "TJ", | ||
callingCode: "+992" | ||
}, | ||
{ | ||
country: "Tanzania", | ||
countryCode: "TZ", | ||
callingCode: "+255" | ||
}, | ||
{ | ||
country: "Thailand", | ||
countryCode: "TH", | ||
callingCode: "+66" | ||
}, | ||
{ | ||
country: "Togo", | ||
countryCode: "TG", | ||
callingCode: "+228" | ||
}, | ||
{ | ||
country: "Tokelau", | ||
countryCode: "TK", | ||
callingCode: "+690" | ||
}, | ||
{ | ||
country: "Tonga", | ||
countryCode: "TO", | ||
callingCode: "+676" | ||
}, | ||
{ | ||
country: "Trinidad and Tobago", | ||
countryCode: "TT", | ||
callingCode: "+1868" | ||
}, | ||
{ | ||
country: "Tunisia", | ||
countryCode: "TN", | ||
callingCode: "+216" | ||
}, | ||
{ | ||
country: "Turkey", | ||
countryCode: "TR", | ||
callingCode: "+90" | ||
}, | ||
{ | ||
country: "Turkmenistan", | ||
countryCode: "TM", | ||
callingCode: "+993" | ||
}, | ||
{ | ||
country: "Turks and Caicos Islands", | ||
countryCode: "TC", | ||
callingCode: "+1649" | ||
}, | ||
{ | ||
country: "Tuvalu", | ||
countryCode: "TV", | ||
callingCode: "+688" | ||
}, | ||
{ | ||
country: "U.S. Virgin Islands", | ||
countryCode: "VI", | ||
callingCode: "+1340" | ||
}, | ||
{ | ||
country: "Uganda", | ||
countryCode: "UG", | ||
callingCode: "+256" | ||
}, | ||
{ | ||
country: "Ukraine", | ||
countryCode: "UA", | ||
callingCode: "+380" | ||
}, | ||
{ | ||
country: "United Arab Emirates", | ||
countryCode: "AE", | ||
callingCode: "+971" | ||
}, | ||
{ | ||
country: "United Kingdom", | ||
countryCode: "GB", | ||
callingCode: "+44" | ||
}, | ||
{ | ||
country: "United States", | ||
countryCode: "US", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "United States Minor Outlying Islands", | ||
countryCode: "UM", | ||
callingCode: "+1" | ||
}, | ||
{ | ||
country: "Uruguay", | ||
countryCode: "UY", | ||
callingCode: "+598" | ||
}, | ||
{ | ||
country: "Uzbekistan", | ||
countryCode: "UZ", | ||
callingCode: "+998" | ||
}, | ||
{ | ||
country: "Vanuatu", | ||
countryCode: "VU", | ||
callingCode: "+678" | ||
}, | ||
{ | ||
country: "Vatican", | ||
countryCode: "VA", | ||
callingCode: "+379" | ||
}, | ||
{ | ||
country: "Venezuela", | ||
countryCode: "VE", | ||
callingCode: "+58" | ||
}, | ||
{ | ||
country: "Vietnam", | ||
countryCode: "VN", | ||
callingCode: "+84" | ||
}, | ||
{ | ||
country: "Wallis and Futuna", | ||
countryCode: "WF", | ||
callingCode: "+681" | ||
}, | ||
{ | ||
country: "Western Sahara", | ||
countryCode: "EH", | ||
callingCode: "+212" | ||
}, | ||
{ | ||
country: "Yemen", | ||
countryCode: "YE", | ||
callingCode: "+967" | ||
}, | ||
{ | ||
country: "Zambia", | ||
countryCode: "ZM", | ||
callingCode: "+260" | ||
}, | ||
{ | ||
country: "Zimbabwe", | ||
countryCode: "ZW", | ||
callingCode: "+263" | ||
} | ||
]; | ||
//Get default country function | ||
const getDefaultCountry = (code) => { | ||
const result = countryData.find((item) => item.countryCode === code); | ||
return result; | ||
}; | ||
//Get country data by search | ||
const getBySearch = (search, onlyCountry, excludeCountry) => { | ||
let countries = []; | ||
if (excludeCountry && excludeCountry.length > 0) { | ||
countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode)); | ||
} | ||
else if (onlyCountry && onlyCountry?.length > 0) { | ||
countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode)); | ||
} | ||
else { | ||
countries = countryData; | ||
} | ||
const result = countries.filter((item) => { | ||
const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | ||
const regex = new RegExp(escapeRegExp(search), "gi"); | ||
return item.country.match(regex); | ||
}); | ||
return result; | ||
}; | ||
//Get country data by filter | ||
const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => { | ||
let countries = []; | ||
if (excludeCountry && excludeCountry.length > 0) { | ||
countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode)); | ||
} | ||
else if (onlyCountry && onlyCountry?.length > 0) { | ||
countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode)); | ||
} | ||
else { | ||
countries = countryData; | ||
} | ||
const result = countries.sort((a, b) => (Number(preferredCountry?.includes(b.countryCode)) - Number(preferredCountry?.includes(a.countryCode))) | ||
|| (preferredCountry?.indexOf(a.countryCode) - preferredCountry?.indexOf(b.countryCode))); | ||
return result; | ||
}; | ||
//Click out side hook | ||
function useOnClickOutside(ref, handler) { | ||
React.useEffect(() => { | ||
const listener = (event) => { | ||
if (!ref.current || ref.current.contains(event.target)) { | ||
return; | ||
} | ||
handler(event); | ||
}; | ||
document.addEventListener("mousedown", listener); | ||
document.addEventListener("touchstart", listener); | ||
return () => { | ||
document.removeEventListener("mousedown", listener); | ||
document.removeEventListener("touchstart", listener); | ||
}; | ||
}, [ref, handler]); | ||
} | ||
//Component | ||
const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inputProps, onlyCountries, excludeCountries, preferredCountries, showDropdownIcon = true, dialCodeInputField = false, search = true, searchPlaceholder = "Search country", showSearchIcon = true, searchIconComponent, searchProps, searchNotFound = "Not found" }) => { | ||
//State | ||
const [selected, setSelected] = React.useState({}); | ||
const [isDropdown, setDropdown] = React.useState(false); | ||
const [inputValue, setInputValue] = React.useState(value || ""); | ||
const [countryDataInfo, setCountryData] = React.useState(countryData); | ||
const [cursor, setCursor] = React.useState(0); | ||
//Ref | ||
const dropdownRef = React.useRef(null); | ||
const listRef = React.useRef(null); | ||
//Custom Hook Call | ||
useOnClickOutside(dropdownRef, () => setDropdown(false)); | ||
//Handler | ||
//---Input Onchange Handler// | ||
const handleChange = (e) => { | ||
const onlyNumber = e.target.value.replace(/\D/g, ''); | ||
if (dialCodeInputField) { | ||
onChange("+" + onlyNumber); | ||
setInputValue("+" + onlyNumber); | ||
} | ||
else { | ||
setInputValue(onlyNumber); | ||
onChange(selected.callingCode + onlyNumber); | ||
} | ||
}; | ||
//---Search Input Onchange Handler// | ||
const onSearchHandler = (e) => { | ||
const search = e.target.value; | ||
setCountryData(getBySearch(search, onlyCountries, excludeCountries)); | ||
}; | ||
//---Set Selected Handler// | ||
const handleSelected = (item, i) => { | ||
if (dialCodeInputField) { | ||
const result = inputValue?.replace(selected.callingCode, item.callingCode); | ||
setInputValue(result.length > 0 ? result : item.callingCode); | ||
onChange(result.length > 0 ? result : item.callingCode); | ||
} | ||
else { | ||
onChange(item.callingCode + inputValue); | ||
} | ||
setSelected(item); | ||
setDropdown(false); | ||
setCursor(i); | ||
}; | ||
//---Scroll To View Handler// | ||
const scrollIntoView = (position) => { | ||
if (search) { | ||
if (countryDataInfo.length > 0) { | ||
listRef.current?.scrollTo({ | ||
top: position, | ||
behavior: "smooth" | ||
}); | ||
} | ||
} | ||
}; | ||
//---Keyboard Navigation// | ||
const keyBoardNav = (e) => { | ||
if (isDropdown) { | ||
if (e.key === "ArrowDown") { | ||
e.preventDefault(); | ||
setCursor(c => (c < countryDataInfo.length - 1 ? c + 1 : c)); | ||
} | ||
if (e.key === "ArrowUp") { | ||
e.preventDefault(); | ||
setCursor(c => (c > 0 ? c - 1 : 0)); | ||
} | ||
if (e.key === "Escape") { | ||
setDropdown(false); | ||
} | ||
if (e.key === "Enter" && cursor >= 0) { | ||
setSelected(countryDataInfo[cursor]); | ||
setDropdown(false); | ||
} | ||
} | ||
}; | ||
//React Hook | ||
//---Scroll to view hook// | ||
React.useEffect(() => { | ||
if (cursor < 0 || cursor > countryDataInfo.length || !listRef) { | ||
return () => { | ||
}; | ||
} | ||
if (isDropdown && listRef) { | ||
if (countryDataInfo.length > 0) { | ||
let listItems = Array.from(listRef.current?.children); | ||
listItems[cursor] && scrollIntoView(listItems[cursor].offsetTop - 65); | ||
} | ||
} | ||
}, [cursor]); | ||
//---Dial Code Field Effect// | ||
React.useMemo(() => { | ||
if (dialCodeInputField) { | ||
const result = inputValue?.replace(selected.callingCode, getDefaultCountry(country).callingCode); | ||
console.log(result); | ||
setInputValue(result.length > 0 ? result : getDefaultCountry(country).callingCode); | ||
} | ||
setSelected(getDefaultCountry(country)); | ||
}, [country, dialCodeInputField]); | ||
//---Country search hook// | ||
React.useMemo(() => { | ||
setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries)); | ||
}, [onlyCountries, excludeCountries, preferredCountries]); | ||
return (jsx("div", { className: "simple-phone-input-sri198-container", onKeyDown: (e) => keyBoardNav(e), tabIndex: -1, children: jsxs("div", { className: "simple-phone-input-sri198-main", children: [jsxs("div", { className: "simple-phone-input-sri198-dropdown-container", ref: dropdownRef, children: [jsxs("div", { onClick: () => setDropdown(!isDropdown), className: dialCodeInputField ? "simple-phone-input-sri198-dropdown-container-button dial" : "simple-phone-input-sri198-dropdown-container-button", children: [jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + selected.countryCode + ".svg", alt: selected.country, width: "20px" }), !dialCodeInputField && | ||
jsx("span", { className: "simple-phone-input-sri198-selected-code", children: selected.callingCode }), showDropdownIcon && | ||
jsx("div", { className: isDropdown ? "simple-phone-input-sri198-dropdown-icon" : "simple-phone-input-sri198-dropdown-icon active", children: iconComponent ? iconComponent : (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 24 24", children: jsx("path", { fill: "currentColor", d: "m7 10l5 5l5-5z" }) })) })] }), jsxs("ul", { className: isDropdown ? "simple-phone-input-sri198-dropdown active" : "simple-phone-input-sri198-dropdown", ref: listRef, children: [search && | ||
jsxs("div", { className: "simple-phone-input-sri198-search-container", children: [jsx("input", { placeholder: searchPlaceholder, ...searchProps, onChange: onSearchHandler }), showSearchIcon && | ||
jsx("div", { className: "simple-phone-input-sri198-search-icon", children: searchIconComponent ?? (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 48 48", children: [jsxs("g", { fill: "#616161", children: [jsx("path", { d: "m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z" }), jsx("circle", { cx: "20", cy: "20", r: "16" })] }), jsx("path", { fill: "#37474F", d: "m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z" }), jsx("circle", { cx: "20", cy: "20", r: "13", fill: "#64B5F6" }), jsx("path", { fill: "#BBDEFB", d: "M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z" })] })) })] }), countryDataInfo.length === 0 && | ||
jsx("div", { className: "simple-phone-input-sri198-not-found", children: searchNotFound }), countryDataInfo.map((item, i) => (jsxs("li", { onClick: () => handleSelected(item, i), className: i === cursor ? "active" : "", children: [jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + item.countryCode + ".svg", alt: item.country, width: "20px" }), jsx("span", { className: "simple-phone-input-sri198-dropdown-text", children: item.country }), jsx("span", { className: "simple-phone-input-sri198-dropdown-country-code", children: item.callingCode })] }, i)))] })] }), jsx("input", { className: "simple-phone-input-sri198-input", placeholder: placeholder, onChange: handleChange, type: "tel", onInput: (e) => { | ||
if (dialCodeInputField) { | ||
const oldVal = inputValue.slice(selected.callingCode.length); | ||
if (e.target.value.startsWith(selected.callingCode)) { | ||
e.target.value = e.target.value; | ||
} | ||
else { | ||
e.target.value = selected.callingCode + oldVal; | ||
} | ||
} | ||
}, onKeyDown: (e) => keyBoardNav(e), value: inputValue, ...inputProps })] }) })); | ||
}; | ||
export { PhoneInput }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-simple-phone-input", | ||
"version": "4.0.2", | ||
"version": "4.0.5", | ||
"description": "A simple react phone input component with calling code dropdown🤷", | ||
@@ -55,3 +55,2 @@ "homepage": "https://react-simple-phone-input.vercel.app", | ||
"rollup-plugin-postcss": "^4.0.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"tslib": "^2.4.1", | ||
@@ -58,0 +57,0 @@ "typescript": "^4.9.4" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
153838
13
3003
1