react-simple-phone-input 4.0.2 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,2 +1,1368 @@
1
- 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};
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import React from 'react';
3
+
4
+ const countryData = [
5
+ {
6
+ country: "Afghanistan",
7
+ countryCode: "AF",
8
+ callingCode: "+93"
9
+ },
10
+ {
11
+ country: "Albania",
12
+ countryCode: "AL",
13
+ callingCode: "+355"
14
+ },
15
+ {
16
+ country: "Algeria",
17
+ countryCode: "DZ",
18
+ callingCode: "+213"
19
+ },
20
+ {
21
+ country: "American Samoa",
22
+ countryCode: "AS",
23
+ callingCode: "+1684"
24
+ },
25
+ {
26
+ country: "Andorra",
27
+ countryCode: "AD",
28
+ callingCode: "+376"
29
+ },
30
+ {
31
+ country: "Angola",
32
+ countryCode: "AO",
33
+ callingCode: "+244"
34
+ },
35
+ {
36
+ country: "Anguilla",
37
+ countryCode: "AI",
38
+ callingCode: "+1264"
39
+ },
40
+ {
41
+ country: "Antarctica",
42
+ countryCode: "AQ",
43
+ callingCode: "+672"
44
+ },
45
+ {
46
+ country: "Antigua and Barbuda",
47
+ countryCode: "AG",
48
+ callingCode: "+1268"
49
+ },
50
+ {
51
+ country: "Argentina",
52
+ countryCode: "AR",
53
+ callingCode: "+54"
54
+ },
55
+ {
56
+ country: "Armenia",
57
+ countryCode: "AM",
58
+ callingCode: "+374"
59
+ },
60
+ {
61
+ country: "Aruba",
62
+ countryCode: "AW",
63
+ callingCode: "+297"
64
+ },
65
+ {
66
+ country: "Australia",
67
+ countryCode: "AU",
68
+ callingCode: "+61"
69
+ },
70
+ {
71
+ country: "Austria",
72
+ countryCode: "AT",
73
+ callingCode: "+43"
74
+ },
75
+ {
76
+ country: "Azerbaijan",
77
+ countryCode: "AZ",
78
+ callingCode: "+994"
79
+ },
80
+ {
81
+ country: "Bahamas",
82
+ countryCode: "BS",
83
+ callingCode: "+1242"
84
+ },
85
+ {
86
+ country: "Bahrain",
87
+ countryCode: "BH",
88
+ callingCode: "+973"
89
+ },
90
+ {
91
+ country: "Bangladesh",
92
+ countryCode: "BD",
93
+ callingCode: "+880"
94
+ },
95
+ {
96
+ country: "Barbados",
97
+ countryCode: "BB",
98
+ callingCode: "+1246"
99
+ },
100
+ {
101
+ country: "Belarus",
102
+ countryCode: "BY",
103
+ callingCode: "+375"
104
+ },
105
+ {
106
+ country: "Belgium",
107
+ countryCode: "BE",
108
+ callingCode: "+32"
109
+ },
110
+ {
111
+ country: "Belize",
112
+ countryCode: "BZ",
113
+ callingCode: "+501"
114
+ },
115
+ {
116
+ country: "Benin",
117
+ countryCode: "BJ",
118
+ callingCode: "+229"
119
+ },
120
+ {
121
+ country: "Bermuda",
122
+ countryCode: "BM",
123
+ callingCode: "+1441"
124
+ },
125
+ {
126
+ country: "Bhutan",
127
+ countryCode: "BT",
128
+ callingCode: "+975"
129
+ },
130
+ {
131
+ country: "Bolivia",
132
+ countryCode: "BO",
133
+ callingCode: "+591"
134
+ },
135
+ {
136
+ country: "Bosnia and Herzegovina",
137
+ countryCode: "BA",
138
+ callingCode: "+387"
139
+ },
140
+ {
141
+ country: "Botswana",
142
+ countryCode: "BW",
143
+ callingCode: "+267"
144
+ },
145
+ {
146
+ country: "Bouvet Island",
147
+ countryCode: "BV",
148
+ callingCode: "+47"
149
+ },
150
+ {
151
+ country: "Brazil",
152
+ countryCode: "BR",
153
+ callingCode: "+55"
154
+ },
155
+ {
156
+ country: "British Indian Ocean Territory",
157
+ countryCode: "IO",
158
+ callingCode: "+246"
159
+ },
160
+ {
161
+ country: "British Virgin Islands",
162
+ countryCode: "VG",
163
+ callingCode: "+1284"
164
+ },
165
+ {
166
+ country: "Brunei",
167
+ countryCode: "BN",
168
+ callingCode: "+673"
169
+ },
170
+ {
171
+ country: "Bulgaria",
172
+ countryCode: "BG",
173
+ callingCode: "+359"
174
+ },
175
+ {
176
+ country: "Burkina Faso",
177
+ countryCode: "BF",
178
+ callingCode: "+226"
179
+ },
180
+ {
181
+ country: "Burundi",
182
+ countryCode: "BI",
183
+ callingCode: "+257"
184
+ },
185
+ {
186
+ country: "Cambodia",
187
+ countryCode: "KH",
188
+ callingCode: "+855"
189
+ },
190
+ {
191
+ country: "Cameroon",
192
+ countryCode: "CM",
193
+ callingCode: "+237"
194
+ },
195
+ {
196
+ country: "Canada",
197
+ countryCode: "CA",
198
+ callingCode: "+1"
199
+ },
200
+ {
201
+ country: "Cape Verde",
202
+ countryCode: "CV",
203
+ callingCode: "+238"
204
+ },
205
+ {
206
+ country: "Cayman Islands",
207
+ countryCode: "KY",
208
+ callingCode: "+1345"
209
+ },
210
+ {
211
+ country: "Central African Republic",
212
+ countryCode: "CF",
213
+ callingCode: "+236"
214
+ },
215
+ {
216
+ country: "Chad",
217
+ countryCode: "TD",
218
+ callingCode: "+235"
219
+ },
220
+ {
221
+ country: "Chile",
222
+ countryCode: "CL",
223
+ callingCode: "+56"
224
+ },
225
+ {
226
+ country: "China",
227
+ countryCode: "CN",
228
+ callingCode: "+86"
229
+ },
230
+ {
231
+ country: "Christmas Island",
232
+ countryCode: "CX",
233
+ callingCode: "+61"
234
+ },
235
+ {
236
+ country: "Cocos Islands",
237
+ countryCode: "CC",
238
+ callingCode: "+61"
239
+ },
240
+ {
241
+ country: "Colombia",
242
+ countryCode: "CO",
243
+ callingCode: "+57"
244
+ },
245
+ {
246
+ country: "Comoros",
247
+ countryCode: "KM",
248
+ callingCode: "+269"
249
+ },
250
+ {
251
+ country: "Cook Islands",
252
+ countryCode: "CK",
253
+ callingCode: "+682"
254
+ },
255
+ {
256
+ country: "Costa Rica",
257
+ countryCode: "CR",
258
+ callingCode: "+506"
259
+ },
260
+ {
261
+ country: "Croatia",
262
+ countryCode: "HR",
263
+ callingCode: "+385"
264
+ },
265
+ {
266
+ country: "Cuba",
267
+ countryCode: "CU",
268
+ callingCode: "+53"
269
+ },
270
+ {
271
+ country: "Cyprus",
272
+ countryCode: "CY",
273
+ callingCode: "+357"
274
+ },
275
+ {
276
+ country: "Czech Republic",
277
+ countryCode: "CZ",
278
+ callingCode: "+420"
279
+ },
280
+ {
281
+ country: "Democratic Republic of the Congo",
282
+ countryCode: "CD",
283
+ callingCode: "+243"
284
+ },
285
+ {
286
+ country: "Denmark",
287
+ countryCode: "DK",
288
+ callingCode: "+45"
289
+ },
290
+ {
291
+ country: "Djibouti",
292
+ countryCode: "DJ",
293
+ callingCode: "+253"
294
+ },
295
+ {
296
+ country: "Dominica",
297
+ countryCode: "DM",
298
+ callingCode: "+1767"
299
+ },
300
+ {
301
+ country: "Dominican Republic",
302
+ countryCode: "DO",
303
+ callingCode: "+1"
304
+ },
305
+ {
306
+ country: "East Timor",
307
+ countryCode: "TL",
308
+ callingCode: "+670"
309
+ },
310
+ {
311
+ country: "Ecuador",
312
+ countryCode: "EC",
313
+ callingCode: "+593"
314
+ },
315
+ {
316
+ country: "Egypt",
317
+ countryCode: "EG",
318
+ callingCode: "+20"
319
+ },
320
+ {
321
+ country: "El Salvador",
322
+ countryCode: "SV",
323
+ callingCode: "+503"
324
+ },
325
+ {
326
+ country: "Equatorial Guinea",
327
+ countryCode: "GQ",
328
+ callingCode: "+240"
329
+ },
330
+ {
331
+ country: "Eritrea",
332
+ countryCode: "ER",
333
+ callingCode: "+291"
334
+ },
335
+ {
336
+ country: "Estonia",
337
+ countryCode: "EE",
338
+ callingCode: "+372"
339
+ },
340
+ {
341
+ country: "Ethiopia",
342
+ countryCode: "ET",
343
+ callingCode: "+251"
344
+ },
345
+ {
346
+ country: "Falkland Islands",
347
+ countryCode: "FK",
348
+ callingCode: "+500"
349
+ },
350
+ {
351
+ country: "Faroe Islands",
352
+ countryCode: "FO",
353
+ callingCode: "+298"
354
+ },
355
+ {
356
+ country: "Fiji",
357
+ countryCode: "FJ",
358
+ callingCode: "+679"
359
+ },
360
+ {
361
+ country: "Finland",
362
+ countryCode: "FI",
363
+ callingCode: "+358"
364
+ },
365
+ {
366
+ country: "France",
367
+ countryCode: "FR",
368
+ callingCode: "+33"
369
+ },
370
+ {
371
+ country: "French Guiana",
372
+ countryCode: "GF",
373
+ callingCode: "+594"
374
+ },
375
+ {
376
+ country: "French Polynesia",
377
+ countryCode: "PF",
378
+ callingCode: "+689"
379
+ },
380
+ {
381
+ country: "French Southern Territories",
382
+ countryCode: "TF",
383
+ callingCode: "+262"
384
+ },
385
+ {
386
+ country: "Gabon",
387
+ countryCode: "GA",
388
+ callingCode: "+241"
389
+ },
390
+ {
391
+ country: "Gambia",
392
+ countryCode: "GM",
393
+ callingCode: "+220"
394
+ },
395
+ {
396
+ country: "Georgia",
397
+ countryCode: "GE",
398
+ callingCode: "+995"
399
+ },
400
+ {
401
+ country: "Germany",
402
+ countryCode: "DE",
403
+ callingCode: "+49"
404
+ },
405
+ {
406
+ country: "Ghana",
407
+ countryCode: "GH",
408
+ callingCode: "+233"
409
+ },
410
+ {
411
+ country: "Gibraltar",
412
+ countryCode: "GI",
413
+ callingCode: "+350"
414
+ },
415
+ {
416
+ country: "Greece",
417
+ countryCode: "GR",
418
+ callingCode: "+30"
419
+ },
420
+ {
421
+ country: "Greenland",
422
+ countryCode: "GL",
423
+ callingCode: "+299"
424
+ },
425
+ {
426
+ country: "Grenada",
427
+ countryCode: "GD",
428
+ callingCode: "+473"
429
+ },
430
+ {
431
+ country: "Guadeloupe",
432
+ countryCode: "GP",
433
+ callingCode: "+590"
434
+ },
435
+ {
436
+ country: "Guam",
437
+ countryCode: "GU",
438
+ callingCode: "+1671"
439
+ },
440
+ {
441
+ country: "Guatemala",
442
+ countryCode: "GT",
443
+ callingCode: "+502"
444
+ },
445
+ {
446
+ country: "Guinea",
447
+ countryCode: "GN",
448
+ callingCode: "+224"
449
+ },
450
+ {
451
+ country: "Guinea-Bissau",
452
+ countryCode: "GW",
453
+ callingCode: "+245"
454
+ },
455
+ {
456
+ country: "Guyana",
457
+ countryCode: "GY",
458
+ callingCode: "+592"
459
+ },
460
+ {
461
+ country: "Haiti",
462
+ countryCode: "HT",
463
+ callingCode: "+509"
464
+ },
465
+ {
466
+ country: "Honduras",
467
+ countryCode: "HN",
468
+ callingCode: "+504"
469
+ },
470
+ {
471
+ country: "Hong Kong",
472
+ countryCode: "HK",
473
+ callingCode: "+852"
474
+ },
475
+ {
476
+ country: "Hungary",
477
+ countryCode: "HU",
478
+ callingCode: "+36"
479
+ },
480
+ {
481
+ country: "Iceland",
482
+ countryCode: "IS",
483
+ callingCode: "+354"
484
+ },
485
+ {
486
+ country: "India",
487
+ countryCode: "IN",
488
+ callingCode: "+91"
489
+ },
490
+ {
491
+ country: "Indonesia",
492
+ countryCode: "ID",
493
+ callingCode: "+62"
494
+ },
495
+ {
496
+ country: "Iran",
497
+ countryCode: "IR",
498
+ callingCode: "+98"
499
+ },
500
+ {
501
+ country: "Iraq",
502
+ countryCode: "IQ",
503
+ callingCode: "+964"
504
+ },
505
+ {
506
+ country: "Ireland",
507
+ countryCode: "IE",
508
+ callingCode: "+353"
509
+ },
510
+ {
511
+ country: "Israel",
512
+ countryCode: "IL",
513
+ callingCode: "+972"
514
+ },
515
+ {
516
+ country: "Italy",
517
+ countryCode: "IT",
518
+ callingCode: "+39"
519
+ },
520
+ {
521
+ country: "Ivory Coast",
522
+ countryCode: "CI",
523
+ callingCode: "+225"
524
+ },
525
+ {
526
+ country: "Jamaica",
527
+ countryCode: "JM",
528
+ callingCode: "+1876"
529
+ },
530
+ {
531
+ country: "Japan",
532
+ countryCode: "JP",
533
+ callingCode: "+81"
534
+ },
535
+ {
536
+ country: "Jordan",
537
+ countryCode: "JO",
538
+ callingCode: "+962"
539
+ },
540
+ {
541
+ country: "Kazakhstan",
542
+ countryCode: "KZ",
543
+ callingCode: "+7"
544
+ },
545
+ {
546
+ country: "Kenya",
547
+ countryCode: "KE",
548
+ callingCode: "+254"
549
+ },
550
+ {
551
+ country: "Kiribati",
552
+ countryCode: "KI",
553
+ callingCode: "+686"
554
+ },
555
+ {
556
+ country: "Kuwait",
557
+ countryCode: "KW",
558
+ callingCode: "+965"
559
+ },
560
+ {
561
+ country: "Kyrgyzstan",
562
+ countryCode: "KG",
563
+ callingCode: "+996"
564
+ },
565
+ {
566
+ country: "Laos",
567
+ countryCode: "LA",
568
+ callingCode: "+856"
569
+ },
570
+ {
571
+ country: "Latvia",
572
+ countryCode: "LV",
573
+ callingCode: "+371"
574
+ },
575
+ {
576
+ country: "Lebanon",
577
+ countryCode: "LB",
578
+ callingCode: "+961"
579
+ },
580
+ {
581
+ country: "Lesotho",
582
+ countryCode: "LS",
583
+ callingCode: "+266"
584
+ },
585
+ {
586
+ country: "Liberia",
587
+ countryCode: "LR",
588
+ callingCode: "+231"
589
+ },
590
+ {
591
+ country: "Libya",
592
+ countryCode: "LY",
593
+ callingCode: "+218"
594
+ },
595
+ {
596
+ country: "Liechtenstein",
597
+ countryCode: "LI",
598
+ callingCode: "+423"
599
+ },
600
+ {
601
+ country: "Lithuania",
602
+ countryCode: "LT",
603
+ callingCode: "+370"
604
+ },
605
+ {
606
+ country: "Luxembourg",
607
+ countryCode: "LU",
608
+ callingCode: "+352"
609
+ },
610
+ {
611
+ country: "Macao",
612
+ countryCode: "MO",
613
+ callingCode: "+853"
614
+ },
615
+ {
616
+ country: "Macedonia",
617
+ countryCode: "MK",
618
+ callingCode: "+389"
619
+ },
620
+ {
621
+ country: "Madagascar",
622
+ countryCode: "MG",
623
+ callingCode: "+261"
624
+ },
625
+ {
626
+ country: "Malawi",
627
+ countryCode: "MW",
628
+ callingCode: "+265"
629
+ },
630
+ {
631
+ country: "Malaysia",
632
+ countryCode: "MY",
633
+ callingCode: "+60"
634
+ },
635
+ {
636
+ country: "Maldives",
637
+ countryCode: "MV",
638
+ callingCode: "+960"
639
+ },
640
+ {
641
+ country: "Mali",
642
+ countryCode: "ML",
643
+ callingCode: "+223"
644
+ },
645
+ {
646
+ country: "Malta",
647
+ countryCode: "MT",
648
+ callingCode: "+356"
649
+ },
650
+ {
651
+ country: "Marshall Islands",
652
+ countryCode: "MH",
653
+ callingCode: "+692"
654
+ },
655
+ {
656
+ country: "Martinique",
657
+ countryCode: "MQ",
658
+ callingCode: "+596"
659
+ },
660
+ {
661
+ country: "Mauritania",
662
+ countryCode: "MR",
663
+ callingCode: "+222"
664
+ },
665
+ {
666
+ country: "Mauritius",
667
+ countryCode: "MU",
668
+ callingCode: "+230"
669
+ },
670
+ {
671
+ country: "Mayotte",
672
+ countryCode: "YT",
673
+ callingCode: "+262"
674
+ },
675
+ {
676
+ country: "Mexico",
677
+ countryCode: "MX",
678
+ callingCode: "+52"
679
+ },
680
+ {
681
+ country: "Micronesia",
682
+ countryCode: "FM",
683
+ callingCode: "+691"
684
+ },
685
+ {
686
+ country: "Moldova",
687
+ countryCode: "MD",
688
+ callingCode: "+373"
689
+ },
690
+ {
691
+ country: "Monaco",
692
+ countryCode: "MC",
693
+ callingCode: "+377"
694
+ },
695
+ {
696
+ country: "Mongolia",
697
+ countryCode: "MN",
698
+ callingCode: "+976"
699
+ },
700
+ {
701
+ country: "Montserrat",
702
+ countryCode: "MS",
703
+ callingCode: "+1664"
704
+ },
705
+ {
706
+ country: "Morocco",
707
+ countryCode: "MA",
708
+ callingCode: "+212"
709
+ },
710
+ {
711
+ country: "Mozambique",
712
+ countryCode: "MZ",
713
+ callingCode: "+258"
714
+ },
715
+ {
716
+ country: "Myanmar",
717
+ countryCode: "MM",
718
+ callingCode: "+95"
719
+ },
720
+ {
721
+ country: "Namibia",
722
+ countryCode: "NA",
723
+ callingCode: "+264"
724
+ },
725
+ {
726
+ country: "Nauru",
727
+ countryCode: "NR",
728
+ callingCode: "+674"
729
+ },
730
+ {
731
+ country: "Nepal",
732
+ countryCode: "NP",
733
+ callingCode: "+977"
734
+ },
735
+ {
736
+ country: "Netherlands",
737
+ countryCode: "NL",
738
+ callingCode: "+31"
739
+ },
740
+ {
741
+ country: "New Caledonia",
742
+ countryCode: "NC",
743
+ callingCode: "+687"
744
+ },
745
+ {
746
+ country: "New Zealand",
747
+ countryCode: "NZ",
748
+ callingCode: "+64"
749
+ },
750
+ {
751
+ country: "Nicaragua",
752
+ countryCode: "NI",
753
+ callingCode: "+505"
754
+ },
755
+ {
756
+ country: "Niger",
757
+ countryCode: "NE",
758
+ callingCode: "+227"
759
+ },
760
+ {
761
+ country: "Nigeria",
762
+ countryCode: "NG",
763
+ callingCode: "+234"
764
+ },
765
+ {
766
+ country: "Niue",
767
+ countryCode: "NU",
768
+ callingCode: "+683"
769
+ },
770
+ {
771
+ country: "Norfolk Island",
772
+ countryCode: "NF",
773
+ callingCode: "+672"
774
+ },
775
+ {
776
+ country: "North Korea",
777
+ countryCode: "KP",
778
+ callingCode: "+850"
779
+ },
780
+ {
781
+ country: "Northern Mariana Islands",
782
+ countryCode: "MP",
783
+ callingCode: "+1670"
784
+ },
785
+ {
786
+ country: "Norway",
787
+ countryCode: "NO",
788
+ callingCode: "+47"
789
+ },
790
+ {
791
+ country: "Oman",
792
+ countryCode: "OM",
793
+ callingCode: "+968"
794
+ },
795
+ {
796
+ country: "Pakistan",
797
+ countryCode: "PK",
798
+ callingCode: "+92"
799
+ },
800
+ {
801
+ country: "Palau",
802
+ countryCode: "PW",
803
+ callingCode: "+680"
804
+ },
805
+ {
806
+ country: "Palestinian Territory",
807
+ countryCode: "PS",
808
+ callingCode: "+970"
809
+ },
810
+ {
811
+ country: "Panama",
812
+ countryCode: "PA",
813
+ callingCode: "+507"
814
+ },
815
+ {
816
+ country: "Papua New Guinea",
817
+ countryCode: "PG",
818
+ callingCode: "+675"
819
+ },
820
+ {
821
+ country: "Paraguay",
822
+ countryCode: "PY",
823
+ callingCode: "+595"
824
+ },
825
+ {
826
+ country: "Peru",
827
+ countryCode: "PE",
828
+ callingCode: "+51"
829
+ },
830
+ {
831
+ country: "Philippines",
832
+ countryCode: "PH",
833
+ callingCode: "+63"
834
+ },
835
+ {
836
+ country: "Pitcairn",
837
+ countryCode: "PN",
838
+ callingCode: "+872"
839
+ },
840
+ {
841
+ country: "Poland",
842
+ countryCode: "PL",
843
+ callingCode: "+48"
844
+ },
845
+ {
846
+ country: "Portugal",
847
+ countryCode: "PT",
848
+ callingCode: "+351"
849
+ },
850
+ {
851
+ country: "Puerto Rico",
852
+ countryCode: "PR",
853
+ callingCode: "+1"
854
+ },
855
+ {
856
+ country: "Qatar",
857
+ countryCode: "QA",
858
+ callingCode: "+974"
859
+ },
860
+ {
861
+ country: "Republic of the Congo",
862
+ countryCode: "CG",
863
+ callingCode: "+242"
864
+ },
865
+ {
866
+ country: "Reunion",
867
+ countryCode: "RE",
868
+ callingCode: "+262"
869
+ },
870
+ {
871
+ country: "Romania",
872
+ countryCode: "RO",
873
+ callingCode: "+40"
874
+ },
875
+ {
876
+ country: "Russia",
877
+ countryCode: "RU",
878
+ callingCode: "+7"
879
+ },
880
+ {
881
+ country: "Rwanda",
882
+ countryCode: "RW",
883
+ callingCode: "+250"
884
+ },
885
+ {
886
+ country: "Saint Helena",
887
+ countryCode: "SH",
888
+ callingCode: "+290"
889
+ },
890
+ {
891
+ country: "Saint Kitts and Nevis",
892
+ countryCode: "KN",
893
+ callingCode: "+1869"
894
+ },
895
+ {
896
+ country: "Saint Lucia",
897
+ countryCode: "LC",
898
+ callingCode: "+1758"
899
+ },
900
+ {
901
+ country: "Saint Pierre and Miquelon",
902
+ countryCode: "PM",
903
+ callingCode: "+508"
904
+ },
905
+ {
906
+ country: "Saint Vincent and the Grenadines",
907
+ countryCode: "VC",
908
+ callingCode: "+1784"
909
+ },
910
+ {
911
+ country: "Samoa",
912
+ countryCode: "WS",
913
+ callingCode: "+685"
914
+ },
915
+ {
916
+ country: "San Marino",
917
+ countryCode: "SM",
918
+ callingCode: "+378"
919
+ },
920
+ {
921
+ country: "Sao Tome and Principe",
922
+ countryCode: "ST",
923
+ callingCode: "+239"
924
+ },
925
+ {
926
+ country: "Saudi Arabia",
927
+ countryCode: "SA",
928
+ callingCode: "+966"
929
+ },
930
+ {
931
+ country: "Senegal",
932
+ countryCode: "SN",
933
+ callingCode: "+221"
934
+ },
935
+ {
936
+ country: "Seychelles",
937
+ countryCode: "SC",
938
+ callingCode: "+248"
939
+ },
940
+ {
941
+ country: "Sierra Leone",
942
+ countryCode: "SL",
943
+ callingCode: "+232"
944
+ },
945
+ {
946
+ country: "Singapore",
947
+ countryCode: "SG",
948
+ callingCode: "+65"
949
+ },
950
+ {
951
+ country: "Slovakia",
952
+ countryCode: "SK",
953
+ callingCode: "+421"
954
+ },
955
+ {
956
+ country: "Slovenia",
957
+ countryCode: "SI",
958
+ callingCode: "+386"
959
+ },
960
+ {
961
+ country: "Solomon Islands",
962
+ countryCode: "SB",
963
+ callingCode: "+677"
964
+ },
965
+ {
966
+ country: "Somalia",
967
+ countryCode: "SO",
968
+ callingCode: "+252"
969
+ },
970
+ {
971
+ country: "South Africa",
972
+ countryCode: "ZA",
973
+ callingCode: "+27"
974
+ },
975
+ {
976
+ country: "South Georgia and the South Sandwich Islands",
977
+ countryCode: "GS",
978
+ callingCode: "+500"
979
+ },
980
+ {
981
+ country: "South Korea",
982
+ countryCode: "KR",
983
+ callingCode: "+82"
984
+ },
985
+ {
986
+ country: "Spain",
987
+ countryCode: "ES",
988
+ callingCode: "+34"
989
+ },
990
+ {
991
+ country: "Sri Lanka",
992
+ countryCode: "LK",
993
+ callingCode: "+94"
994
+ },
995
+ {
996
+ country: "Sudan",
997
+ countryCode: "SD",
998
+ callingCode: "+249"
999
+ },
1000
+ {
1001
+ country: "Suriname",
1002
+ countryCode: "SR",
1003
+ callingCode: "+597"
1004
+ },
1005
+ {
1006
+ country: "Svalbard and Jan Mayen",
1007
+ countryCode: "SJ",
1008
+ callingCode: "+47"
1009
+ },
1010
+ {
1011
+ country: "Swaziland",
1012
+ countryCode: "SZ",
1013
+ callingCode: "+268"
1014
+ },
1015
+ {
1016
+ country: "Sweden",
1017
+ countryCode: "SE",
1018
+ callingCode: "+46"
1019
+ },
1020
+ {
1021
+ country: "Switzerland",
1022
+ countryCode: "CH",
1023
+ callingCode: "+41"
1024
+ },
1025
+ {
1026
+ country: "Syria",
1027
+ countryCode: "SY",
1028
+ callingCode: "+963"
1029
+ },
1030
+ {
1031
+ country: "Taiwan",
1032
+ countryCode: "TW",
1033
+ callingCode: "+886"
1034
+ },
1035
+ {
1036
+ country: "Tajikistan",
1037
+ countryCode: "TJ",
1038
+ callingCode: "+992"
1039
+ },
1040
+ {
1041
+ country: "Tanzania",
1042
+ countryCode: "TZ",
1043
+ callingCode: "+255"
1044
+ },
1045
+ {
1046
+ country: "Thailand",
1047
+ countryCode: "TH",
1048
+ callingCode: "+66"
1049
+ },
1050
+ {
1051
+ country: "Togo",
1052
+ countryCode: "TG",
1053
+ callingCode: "+228"
1054
+ },
1055
+ {
1056
+ country: "Tokelau",
1057
+ countryCode: "TK",
1058
+ callingCode: "+690"
1059
+ },
1060
+ {
1061
+ country: "Tonga",
1062
+ countryCode: "TO",
1063
+ callingCode: "+676"
1064
+ },
1065
+ {
1066
+ country: "Trinidad and Tobago",
1067
+ countryCode: "TT",
1068
+ callingCode: "+1868"
1069
+ },
1070
+ {
1071
+ country: "Tunisia",
1072
+ countryCode: "TN",
1073
+ callingCode: "+216"
1074
+ },
1075
+ {
1076
+ country: "Turkey",
1077
+ countryCode: "TR",
1078
+ callingCode: "+90"
1079
+ },
1080
+ {
1081
+ country: "Turkmenistan",
1082
+ countryCode: "TM",
1083
+ callingCode: "+993"
1084
+ },
1085
+ {
1086
+ country: "Turks and Caicos Islands",
1087
+ countryCode: "TC",
1088
+ callingCode: "+1649"
1089
+ },
1090
+ {
1091
+ country: "Tuvalu",
1092
+ countryCode: "TV",
1093
+ callingCode: "+688"
1094
+ },
1095
+ {
1096
+ country: "U.S. Virgin Islands",
1097
+ countryCode: "VI",
1098
+ callingCode: "+1340"
1099
+ },
1100
+ {
1101
+ country: "Uganda",
1102
+ countryCode: "UG",
1103
+ callingCode: "+256"
1104
+ },
1105
+ {
1106
+ country: "Ukraine",
1107
+ countryCode: "UA",
1108
+ callingCode: "+380"
1109
+ },
1110
+ {
1111
+ country: "United Arab Emirates",
1112
+ countryCode: "AE",
1113
+ callingCode: "+971"
1114
+ },
1115
+ {
1116
+ country: "United Kingdom",
1117
+ countryCode: "GB",
1118
+ callingCode: "+44"
1119
+ },
1120
+ {
1121
+ country: "United States",
1122
+ countryCode: "US",
1123
+ callingCode: "+1"
1124
+ },
1125
+ {
1126
+ country: "United States Minor Outlying Islands",
1127
+ countryCode: "UM",
1128
+ callingCode: "+1"
1129
+ },
1130
+ {
1131
+ country: "Uruguay",
1132
+ countryCode: "UY",
1133
+ callingCode: "+598"
1134
+ },
1135
+ {
1136
+ country: "Uzbekistan",
1137
+ countryCode: "UZ",
1138
+ callingCode: "+998"
1139
+ },
1140
+ {
1141
+ country: "Vanuatu",
1142
+ countryCode: "VU",
1143
+ callingCode: "+678"
1144
+ },
1145
+ {
1146
+ country: "Vatican",
1147
+ countryCode: "VA",
1148
+ callingCode: "+379"
1149
+ },
1150
+ {
1151
+ country: "Venezuela",
1152
+ countryCode: "VE",
1153
+ callingCode: "+58"
1154
+ },
1155
+ {
1156
+ country: "Vietnam",
1157
+ countryCode: "VN",
1158
+ callingCode: "+84"
1159
+ },
1160
+ {
1161
+ country: "Wallis and Futuna",
1162
+ countryCode: "WF",
1163
+ callingCode: "+681"
1164
+ },
1165
+ {
1166
+ country: "Western Sahara",
1167
+ countryCode: "EH",
1168
+ callingCode: "+212"
1169
+ },
1170
+ {
1171
+ country: "Yemen",
1172
+ countryCode: "YE",
1173
+ callingCode: "+967"
1174
+ },
1175
+ {
1176
+ country: "Zambia",
1177
+ countryCode: "ZM",
1178
+ callingCode: "+260"
1179
+ },
1180
+ {
1181
+ country: "Zimbabwe",
1182
+ countryCode: "ZW",
1183
+ callingCode: "+263"
1184
+ }
1185
+ ];
1186
+
1187
+ //Get default country function
1188
+ const getDefaultCountry = (code) => {
1189
+ const result = countryData.find((item) => item.countryCode === code);
1190
+ return result;
1191
+ };
1192
+ //Get country data by search
1193
+ const getBySearch = (search, onlyCountry, excludeCountry) => {
1194
+ let countries = [];
1195
+ if (excludeCountry && excludeCountry.length > 0) {
1196
+ countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode));
1197
+ }
1198
+ else if (onlyCountry && onlyCountry?.length > 0) {
1199
+ countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode));
1200
+ }
1201
+ else {
1202
+ countries = countryData;
1203
+ }
1204
+ const result = countries.filter((item) => {
1205
+ const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
1206
+ const regex = new RegExp(escapeRegExp(search), "gi");
1207
+ return item.country.match(regex);
1208
+ });
1209
+ return result;
1210
+ };
1211
+ //Get country data by filter
1212
+ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
1213
+ let countries = [];
1214
+ if (excludeCountry && excludeCountry.length > 0) {
1215
+ countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode));
1216
+ }
1217
+ else if (onlyCountry && onlyCountry?.length > 0) {
1218
+ countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode));
1219
+ }
1220
+ else {
1221
+ countries = countryData;
1222
+ }
1223
+ const result = countries.sort((a, b) => (Number(preferredCountry?.includes(b.countryCode)) - Number(preferredCountry?.includes(a.countryCode)))
1224
+ || (preferredCountry?.indexOf(a.countryCode) - preferredCountry?.indexOf(b.countryCode)));
1225
+ return result;
1226
+ };
1227
+
1228
+ //Click out side hook
1229
+ function useOnClickOutside(ref, handler) {
1230
+ React.useEffect(() => {
1231
+ const listener = (event) => {
1232
+ if (!ref.current || ref.current.contains(event.target)) {
1233
+ return;
1234
+ }
1235
+ handler(event);
1236
+ };
1237
+ document.addEventListener("mousedown", listener);
1238
+ document.addEventListener("touchstart", listener);
1239
+ return () => {
1240
+ document.removeEventListener("mousedown", listener);
1241
+ document.removeEventListener("touchstart", listener);
1242
+ };
1243
+ }, [ref, handler]);
1244
+ }
1245
+
1246
+ //Component
1247
+ 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" }) => {
1248
+ //State
1249
+ const [selected, setSelected] = React.useState({});
1250
+ const [isDropdown, setDropdown] = React.useState(false);
1251
+ const [inputValue, setInputValue] = React.useState(value || "");
1252
+ const [countryDataInfo, setCountryData] = React.useState(countryData);
1253
+ const [cursor, setCursor] = React.useState(0);
1254
+ //Ref
1255
+ const dropdownRef = React.useRef(null);
1256
+ const listRef = React.useRef(null);
1257
+ //Custom Hook Call
1258
+ useOnClickOutside(dropdownRef, () => setDropdown(false));
1259
+ //Handler
1260
+ //---Input Onchange Handler//
1261
+ const handleChange = (e) => {
1262
+ const onlyNumber = e.target.value.replace(/\D/g, '');
1263
+ if (dialCodeInputField) {
1264
+ onChange("+" + onlyNumber);
1265
+ setInputValue("+" + onlyNumber);
1266
+ }
1267
+ else {
1268
+ setInputValue(onlyNumber);
1269
+ onChange(selected.callingCode + onlyNumber);
1270
+ }
1271
+ };
1272
+ //---Search Input Onchange Handler//
1273
+ const onSearchHandler = (e) => {
1274
+ const search = e.target.value;
1275
+ setCountryData(getBySearch(search, onlyCountries, excludeCountries));
1276
+ };
1277
+ //---Set Selected Handler//
1278
+ const handleSelected = (item, i) => {
1279
+ if (dialCodeInputField) {
1280
+ const result = inputValue?.replace(selected.callingCode, item.callingCode);
1281
+ setInputValue(result.length > 0 ? result : item.callingCode);
1282
+ onChange(result.length > 0 ? result : item.callingCode);
1283
+ }
1284
+ else {
1285
+ onChange(item.callingCode + inputValue);
1286
+ }
1287
+ setSelected(item);
1288
+ setDropdown(false);
1289
+ setCursor(i);
1290
+ };
1291
+ //---Scroll To View Handler//
1292
+ const scrollIntoView = (position) => {
1293
+ if (search) {
1294
+ if (countryDataInfo.length > 0) {
1295
+ listRef.current?.scrollTo({
1296
+ top: position,
1297
+ behavior: "smooth"
1298
+ });
1299
+ }
1300
+ }
1301
+ };
1302
+ //---Keyboard Navigation//
1303
+ const keyBoardNav = (e) => {
1304
+ if (isDropdown) {
1305
+ if (e.key === "ArrowDown") {
1306
+ e.preventDefault();
1307
+ setCursor(c => (c < countryDataInfo.length - 1 ? c + 1 : c));
1308
+ }
1309
+ if (e.key === "ArrowUp") {
1310
+ e.preventDefault();
1311
+ setCursor(c => (c > 0 ? c - 1 : 0));
1312
+ }
1313
+ if (e.key === "Escape") {
1314
+ setDropdown(false);
1315
+ }
1316
+ if (e.key === "Enter" && cursor >= 0) {
1317
+ setSelected(countryDataInfo[cursor]);
1318
+ setDropdown(false);
1319
+ }
1320
+ }
1321
+ };
1322
+ //React Hook
1323
+ //---Scroll to view hook//
1324
+ React.useEffect(() => {
1325
+ if (cursor < 0 || cursor > countryDataInfo.length || !listRef) {
1326
+ return () => {
1327
+ };
1328
+ }
1329
+ if (isDropdown && listRef) {
1330
+ if (countryDataInfo.length > 0) {
1331
+ let listItems = Array.from(listRef.current?.children);
1332
+ listItems[cursor] && scrollIntoView(listItems[cursor].offsetTop - 65);
1333
+ }
1334
+ }
1335
+ }, [cursor]);
1336
+ //---Dial Code Field Effect//
1337
+ React.useMemo(() => {
1338
+ if (dialCodeInputField) {
1339
+ const result = inputValue?.replace(selected.callingCode, getDefaultCountry(country).callingCode);
1340
+ console.log(result);
1341
+ setInputValue(result.length > 0 ? result : getDefaultCountry(country).callingCode);
1342
+ }
1343
+ setSelected(getDefaultCountry(country));
1344
+ }, [country, dialCodeInputField]);
1345
+ //---Country search hook//
1346
+ React.useMemo(() => {
1347
+ setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
1348
+ }, [onlyCountries, excludeCountries, preferredCountries]);
1349
+ 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 &&
1350
+ jsx("span", { className: "simple-phone-input-sri198-selected-code", children: selected.callingCode }), showDropdownIcon &&
1351
+ 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 &&
1352
+ jsxs("div", { className: "simple-phone-input-sri198-search-container", children: [jsx("input", { placeholder: searchPlaceholder, ...searchProps, onChange: onSearchHandler }), showSearchIcon &&
1353
+ 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 &&
1354
+ 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) => {
1355
+ if (dialCodeInputField) {
1356
+ const oldVal = inputValue.slice(selected.callingCode.length);
1357
+ if (e.target.value.startsWith(selected.callingCode)) {
1358
+ e.target.value = e.target.value;
1359
+ }
1360
+ else {
1361
+ e.target.value = selected.callingCode + oldVal;
1362
+ }
1363
+ }
1364
+ }, onKeyDown: (e) => keyBoardNav(e), value: inputValue, ...inputProps })] }) }));
1365
+ };
1366
+
1367
+ export { PhoneInput };
2
1368
  //# sourceMappingURL=index.js.map