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