p-intl-input-tel-gg
Version:
Forked project with improvements
2,022 lines (2,013 loc) • 65.2 kB
JavaScript
import * as lpn from 'google-libphonenumber';
import { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil, PhoneNumber } from 'google-libphonenumber';
import * as i0 from '@angular/core';
import { Pipe, Directive, signal, EventEmitter, linkedSignal, computed, forwardRef, Output, Input, Component } from '@angular/core';
import * as i2 from '@angular/forms';
import { FormControl, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import * as i1 from 'primeng/inputtext';
import { InputTextModule } from 'primeng/inputtext';
import * as i3 from '@angular/common';
import { CommonModule } from '@angular/common';
import { Select } from 'primeng/select';
var SearchCountryField;
(function (SearchCountryField) {
SearchCountryField["DIALCODE"] = "dialCode";
SearchCountryField["ISO2"] = "iso2";
SearchCountryField["NAME"] = "name";
})(SearchCountryField || (SearchCountryField = {}));
;
class Country {
name;
iso2;
dialCode;
priority;
areaCodes;
htmlId;
flagClass;
placeHolder;
isFavorite;
constructor() {
this.name = '';
this.iso2 = '';
this.dialCode = '';
this.priority = 0;
this.areaCodes = undefined;
this.htmlId = '';
this.flagClass = '';
this.placeHolder = '';
}
}
var CountryISO;
(function (CountryISO) {
CountryISO["Afghanistan"] = "af";
CountryISO["Albania"] = "al";
CountryISO["Algeria"] = "dz";
CountryISO["AmericanSamoa"] = "as";
CountryISO["Andorra"] = "ad";
CountryISO["Angola"] = "ao";
CountryISO["Anguilla"] = "ai";
CountryISO["AntiguaAndBarbuda"] = "ag";
CountryISO["Argentina"] = "ar";
CountryISO["Armenia"] = "am";
CountryISO["Aruba"] = "aw";
CountryISO["Australia"] = "au";
CountryISO["Austria"] = "at";
CountryISO["Azerbaijan"] = "az";
CountryISO["Bahamas"] = "bs";
CountryISO["Bahrain"] = "bh";
CountryISO["Bangladesh"] = "bd";
CountryISO["Barbados"] = "bb";
CountryISO["Belarus"] = "by";
CountryISO["Belgium"] = "be";
CountryISO["Belize"] = "bz";
CountryISO["Benin"] = "bj";
CountryISO["Bermuda"] = "bm";
CountryISO["Bhutan"] = "bt";
CountryISO["Bolivia"] = "bo";
CountryISO["BosniaAndHerzegovina"] = "ba";
CountryISO["Botswana"] = "bw";
CountryISO["Brazil"] = "br";
CountryISO["BritishIndianOceanTerritory"] = "io";
CountryISO["BritishVirginIslands"] = "vg";
CountryISO["Brunei"] = "bn";
CountryISO["Bulgaria"] = "bg";
CountryISO["BurkinaFaso"] = "bf";
CountryISO["Burundi"] = "bi";
CountryISO["Cambodia"] = "kh";
CountryISO["Cameroon"] = "cm";
CountryISO["Canada"] = "ca";
CountryISO["CapeVerde"] = "cv";
CountryISO["CaribbeanNetherlands"] = "bq";
CountryISO["CaymanIslands"] = "ky";
CountryISO["CentralAfricanRepublic"] = "cf";
CountryISO["Chad"] = "td";
CountryISO["Chile"] = "cl";
CountryISO["China"] = "cn";
CountryISO["ChristmasIsland"] = "cx";
CountryISO["Cocos"] = "cc";
CountryISO["Colombia"] = "co";
CountryISO["Comoros"] = "km";
CountryISO["CongoDRCJamhuriYaKidemokrasiaYaKongo"] = "cd";
CountryISO["CongoRepublicCongoBrazzaville"] = "cg";
CountryISO["CookIslands"] = "ck";
CountryISO["CostaRica"] = "cr";
CountryISO["C\u00F4teDIvoire"] = "ci";
CountryISO["Croatia"] = "hr";
CountryISO["Cuba"] = "cu";
CountryISO["Cura\u00E7ao"] = "cw";
CountryISO["Cyprus"] = "cy";
CountryISO["CzechRepublic"] = "cz";
CountryISO["Denmark"] = "dk";
CountryISO["Djibouti"] = "dj";
CountryISO["Dominica"] = "dm";
CountryISO["DominicanRepublic"] = "do";
CountryISO["Ecuador"] = "ec";
CountryISO["Egypt"] = "eg";
CountryISO["ElSalvador"] = "sv";
CountryISO["EquatorialGuinea"] = "gq";
CountryISO["Eritrea"] = "er";
CountryISO["Estonia"] = "ee";
CountryISO["Ethiopia"] = "et";
CountryISO["FalklandIslands"] = "fk";
CountryISO["FaroeIslands"] = "fo";
CountryISO["Fiji"] = "fj";
CountryISO["Finland"] = "fi";
CountryISO["France"] = "fr";
CountryISO["FrenchGuiana"] = "gf";
CountryISO["FrenchPolynesia"] = "pf";
CountryISO["Gabon"] = "ga";
CountryISO["Gambia"] = "gm";
CountryISO["Georgia"] = "ge";
CountryISO["Germany"] = "de";
CountryISO["Ghana"] = "gh";
CountryISO["Gibraltar"] = "gi";
CountryISO["Greece"] = "gr";
CountryISO["Greenland"] = "gl";
CountryISO["Grenada"] = "gd";
CountryISO["Guadeloupe"] = "gp";
CountryISO["Guam"] = "gu";
CountryISO["Guatemala"] = "gt";
CountryISO["Guernsey"] = "gg";
CountryISO["Guinea"] = "gn";
CountryISO["GuineaBissau"] = "gw";
CountryISO["Guyana"] = "gy";
CountryISO["Haiti"] = "ht";
CountryISO["Honduras"] = "hn";
CountryISO["HongKong"] = "hk";
CountryISO["Hungary"] = "hu";
CountryISO["Iceland"] = "is";
CountryISO["India"] = "in";
CountryISO["Indonesia"] = "id";
CountryISO["Iran"] = "ir";
CountryISO["Iraq"] = "iq";
CountryISO["Ireland"] = "ie";
CountryISO["IsleOfMan"] = "im";
CountryISO["Israel"] = "il";
CountryISO["Italy"] = "it";
CountryISO["Jamaica"] = "jm";
CountryISO["Japan"] = "jp";
CountryISO["Jersey"] = "je";
CountryISO["Jordan"] = "jo";
CountryISO["Kazakhstan"] = "kz";
CountryISO["Kenya"] = "ke";
CountryISO["Kiribati"] = "ki";
CountryISO["Kosovo"] = "xk";
CountryISO["Kuwait"] = "kw";
CountryISO["Kyrgyzstan"] = "kg";
CountryISO["Laos"] = "la";
CountryISO["Latvia"] = "lv";
CountryISO["Lebanon"] = "lb";
CountryISO["Lesotho"] = "ls";
CountryISO["Liberia"] = "lr";
CountryISO["Libya"] = "ly";
CountryISO["Liechtenstein"] = "li";
CountryISO["Lithuania"] = "lt";
CountryISO["Luxembourg"] = "lu";
CountryISO["Macau"] = "mo";
CountryISO["Macedonia"] = "mk";
CountryISO["Madagascar"] = "mg";
CountryISO["Malawi"] = "mw";
CountryISO["Malaysia"] = "my";
CountryISO["Maldives"] = "mv";
CountryISO["Mali"] = "ml";
CountryISO["Malta"] = "mt";
CountryISO["MarshallIslands"] = "mh";
CountryISO["Martinique"] = "mq";
CountryISO["Mauritania"] = "mr";
CountryISO["Mauritius"] = "mu";
CountryISO["Mayotte"] = "yt";
CountryISO["Mexico"] = "mx";
CountryISO["Micronesia"] = "fm";
CountryISO["Moldova"] = "md";
CountryISO["Monaco"] = "mc";
CountryISO["Mongolia"] = "mn";
CountryISO["Montenegro"] = "me";
CountryISO["Montserrat"] = "ms";
CountryISO["Morocco"] = "ma";
CountryISO["Mozambique"] = "mz";
CountryISO["Myanmar"] = "mm";
CountryISO["Namibia"] = "na";
CountryISO["Nauru"] = "nr";
CountryISO["Nepal"] = "np";
CountryISO["Netherlands"] = "nl";
CountryISO["NewCaledonia"] = "nc";
CountryISO["NewZealand"] = "nz";
CountryISO["Nicaragua"] = "ni";
CountryISO["Niger"] = "ne";
CountryISO["Nigeria"] = "ng";
CountryISO["Niue"] = "nu";
CountryISO["NorfolkIsland"] = "nf";
CountryISO["NorthKorea"] = "kp";
CountryISO["NorthernMarianaIslands"] = "mp";
CountryISO["Norway"] = "no";
CountryISO["Oman"] = "om";
CountryISO["Pakistan"] = "pk";
CountryISO["Palau"] = "pw";
CountryISO["Palestine"] = "ps";
CountryISO["Panama"] = "pa";
CountryISO["PapuaNewGuinea"] = "pg";
CountryISO["Paraguay"] = "py";
CountryISO["Peru"] = "pe";
CountryISO["Philippines"] = "ph";
CountryISO["Poland"] = "pl";
CountryISO["Portugal"] = "pt";
CountryISO["PuertoRico"] = "pr";
CountryISO["Qatar"] = "qa";
CountryISO["R\u00E9union"] = "re";
CountryISO["Romania"] = "ro";
CountryISO["Russia"] = "ru";
CountryISO["Rwanda"] = "rw";
CountryISO["SaintBarth\u00E9lemy"] = "bl";
CountryISO["SaintHelena"] = "sh";
CountryISO["SaintKittsAndNevis"] = "kn";
CountryISO["SaintLucia"] = "lc";
CountryISO["SaintMartin"] = "mf";
CountryISO["SaintPierreAndMiquelon"] = "pm";
CountryISO["SaintVincentAndTheGrenadines"] = "vc";
CountryISO["Samoa"] = "ws";
CountryISO["SanMarino"] = "sm";
CountryISO["S\u00E3oTom\u00E9AndPr\u00EDncipe"] = "st";
CountryISO["SaudiArabia"] = "sa";
CountryISO["Senegal"] = "sn";
CountryISO["Serbia"] = "rs";
CountryISO["Seychelles"] = "sc";
CountryISO["SierraLeone"] = "sl";
CountryISO["Singapore"] = "sg";
CountryISO["SintMaarten"] = "sx";
CountryISO["Slovakia"] = "sk";
CountryISO["Slovenia"] = "si";
CountryISO["SolomonIslands"] = "sb";
CountryISO["Somalia"] = "so";
CountryISO["SouthAfrica"] = "za";
CountryISO["SouthKorea"] = "kr";
CountryISO["SouthSudan"] = "ss";
CountryISO["Spain"] = "es";
CountryISO["SriLanka"] = "lk";
CountryISO["Sudan"] = "sd";
CountryISO["Suriname"] = "sr";
CountryISO["SvalbardAndJanMayen"] = "sj";
CountryISO["Swaziland"] = "sz";
CountryISO["Sweden"] = "se";
CountryISO["Switzerland"] = "ch";
CountryISO["Syria"] = "sy";
CountryISO["Taiwan"] = "tw";
CountryISO["Tajikistan"] = "tj";
CountryISO["Tanzania"] = "tz";
CountryISO["Thailand"] = "th";
CountryISO["TimorLeste"] = "tl";
CountryISO["Togo"] = "tg";
CountryISO["Tokelau"] = "tk";
CountryISO["Tonga"] = "to";
CountryISO["TrinidadAndTobago"] = "tt";
CountryISO["Tunisia"] = "tn";
CountryISO["Turkey"] = "tr";
CountryISO["Turkmenistan"] = "tm";
CountryISO["TurksAndCaicosIslands"] = "tc";
CountryISO["Tuvalu"] = "tv";
CountryISO["USVirginIslands"] = "vi";
CountryISO["Uganda"] = "ug";
CountryISO["Ukraine"] = "ua";
CountryISO["UnitedArabEmirates"] = "ae";
CountryISO["UnitedKingdom"] = "gb";
CountryISO["UnitedStates"] = "us";
CountryISO["Uruguay"] = "uy";
CountryISO["Uzbekistan"] = "uz";
CountryISO["Vanuatu"] = "vu";
CountryISO["VaticanCity"] = "va";
CountryISO["Venezuela"] = "ve";
CountryISO["Vietnam"] = "vn";
CountryISO["WallisAndFutuna"] = "wf";
CountryISO["WesternSahara"] = "eh";
CountryISO["Yemen"] = "ye";
CountryISO["Zambia"] = "zm";
CountryISO["Zimbabwe"] = "zw";
CountryISO["\u00C5landIslands"] = "ax";
})(CountryISO || (CountryISO = {}));
const ALL_COUNTRIES = [
[
'Afghanistan (افغانستان)',
CountryISO.Afghanistan,
'93'
],
[
'Albania (Shqipëri)',
CountryISO.Albania,
'355'
],
[
'Algeria (الجزائر)',
CountryISO.Algeria,
'213'
],
[
'American Samoa',
'as',
'1',
1,
[
'684',
]
],
[
'Andorra',
CountryISO.Andorra,
'376'
],
[
'Angola',
CountryISO.Angola,
'244'
],
[
'Anguilla',
'ai',
'1',
1,
[
'264',
]
],
[
'Antigua and Barbuda',
'ag',
'1',
1,
[
'268',
]
],
[
'Argentina',
CountryISO.Argentina,
'54'
],
[
'Armenia (Հայաստան)',
CountryISO.Armenia,
'374'
],
[
'Aruba',
CountryISO.Aruba,
'297'
],
[
'Australia',
CountryISO.Australia,
'61',
0
],
[
'Austria (Österreich)',
CountryISO.Austria,
'43'
],
[
'Azerbaijan (Azərbaycan)',
CountryISO.Azerbaijan,
'994'
],
[
'Bahamas',
'bs',
'1',
1,
[
'242',
]
],
[
'Bahrain (البحرين)',
CountryISO.Bahrain,
'973'
],
[
'Bangladesh (বাংলাদেশ)',
CountryISO.Bangladesh,
'880'
],
[
'Barbados',
'bb',
'1',
1,
[
'246',
]
],
[
'Belarus (Беларусь)',
CountryISO.Belarus,
'375'
],
[
'Belgium (België)',
CountryISO.Belgium,
'32'
],
[
'Belize',
CountryISO.Belize,
'501'
],
[
'Benin (Bénin)',
CountryISO.Benin,
'229'
],
[
'Bermuda',
'bm',
'1',
1,
[
'441',
]
],
[
'Bhutan (འབྲུག)',
CountryISO.Bhutan,
'975'
],
[
'Bolivia',
CountryISO.Bolivia,
'591'
],
[
'Bosnia and Herzegovina (Босна и Херцеговина)',
CountryISO.BosniaAndHerzegovina,
'387'
],
[
'Botswana',
CountryISO.Botswana,
'267'
],
[
'Brazil (Brasil)',
CountryISO.Brazil,
'55'
],
[
'British Indian Ocean Territory',
CountryISO.BritishIndianOceanTerritory,
'246'
],
[
'British Virgin Islands',
'vg',
'1',
1,
[
'284',
]
],
[
'Brunei',
CountryISO.Brunei,
'673'
],
[
'Bulgaria (България)',
CountryISO.Bulgaria,
'359'
],
[
'Burkina Faso',
CountryISO.BurkinaFaso,
'226'
],
[
'Burundi (Uburundi)',
CountryISO.Burundi,
'257'
],
[
'Cambodia (កម្ពុជា)',
CountryISO.Cambodia,
'855'
],
[
'Cameroon (Cameroun)',
CountryISO.Cameroon,
'237'
],
[
'Canada',
CountryISO.Canada,
'1',
1,
[
'204', '226', '236', '249', '250', '289', '306', '343', '365', '387', '403', '416',
'418', '431', '437', '438', '450', '506', '514', '519', '548', '579', '581', '587',
'604', '613', '639', '647', '672', '705', '709', '742', '778', '780', '782', '807',
'819', '825', '867', '873', '902', '905'
]
],
[
'Cape Verde (Kabu Verdi)',
CountryISO.CapeVerde,
'238'
],
[
'Caribbean Netherlands',
CountryISO.CaribbeanNetherlands,
'599',
1
],
[
'Cayman Islands',
'ky',
'1',
1,
[
'345',
]
],
[
'Central African Republic (République centrafricaine)',
CountryISO.CentralAfricanRepublic,
'236'
],
[
'Chad (Tchad)',
CountryISO.Chad,
'235'
],
[
'Chile',
CountryISO.Chile,
'56'
],
[
'China (中国)',
CountryISO.China,
'86'
],
[
'Christmas Island',
CountryISO.ChristmasIsland,
'61',
2
],
[
'Cocos (Keeling) Islands',
CountryISO.Cocos,
'61',
1
],
[
'Colombia',
CountryISO.Colombia,
'57'
],
[
'Comoros (جزر القمر)',
CountryISO.Comoros,
'269'
],
[
'Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)',
CountryISO.CongoDRCJamhuriYaKidemokrasiaYaKongo,
'243'
],
[
'Congo (Republic) (Congo-Brazzaville)',
CountryISO.CongoRepublicCongoBrazzaville,
'242'
],
[
'Cook Islands',
CountryISO.CookIslands,
'682'
],
[
'Costa Rica',
CountryISO.CostaRica,
'506'
],
[
'Côte d’Ivoire',
CountryISO.CôteDIvoire,
'225'
],
[
'Croatia (Hrvatska)',
CountryISO.Croatia,
'385'
],
[
'Cuba',
CountryISO.Cuba,
'53'
],
[
'Curaçao',
CountryISO.Curaçao,
'599',
0
],
[
'Cyprus (Κύπρος)',
CountryISO.Cyprus,
'357'
],
[
'Czech Republic (Česká republika)',
CountryISO.CzechRepublic,
'420'
],
[
'Denmark (Danmark)',
CountryISO.Denmark,
'45'
],
[
'Djibouti',
CountryISO.Djibouti,
'253'
],
[
'Dominica',
CountryISO.Dominica,
'1767'
],
[
'Dominican Republic (República Dominicana)',
CountryISO.DominicanRepublic,
'1',
2,
['809', '829', '849']
],
[
'Ecuador',
CountryISO.Ecuador,
'593'
],
[
'Egypt (مصر)',
CountryISO.Egypt,
'20'
],
[
'El Salvador',
CountryISO.ElSalvador,
'503'
],
[
'Equatorial Guinea (Guinea Ecuatorial)',
CountryISO.EquatorialGuinea,
'240'
],
[
'Eritrea',
CountryISO.Eritrea,
'291'
],
[
'Estonia (Eesti)',
CountryISO.Estonia,
'372'
],
[
'Ethiopia',
CountryISO.Ethiopia,
'251'
],
[
'Falkland Islands (Islas Malvinas)',
CountryISO.FalklandIslands,
'500'
],
[
'Faroe Islands (Føroyar)',
CountryISO.FaroeIslands,
'298'
],
[
'Fiji',
CountryISO.Fiji,
'679'
],
[
'Finland (Suomi)',
CountryISO.Finland,
'358',
0
],
[
'France',
CountryISO.France,
'33'
],
[
'French Guiana (Guyane française)',
CountryISO.FrenchGuiana,
'594'
],
[
'French Polynesia (Polynésie française)',
CountryISO.FrenchPolynesia,
'689'
],
[
'Gabon',
CountryISO.Gabon,
'241'
],
[
'Gambia',
CountryISO.Gambia,
'220'
],
[
'Georgia (საქართველო)',
CountryISO.Georgia,
'995'
],
[
'Germany (Deutschland)',
CountryISO.Germany,
'49'
],
[
'Ghana (Gaana)',
CountryISO.Ghana,
'233'
],
[
'Gibraltar',
CountryISO.Gibraltar,
'350'
],
[
'Greece (Ελλάδα)',
CountryISO.Greece,
'30'
],
[
'Greenland (Kalaallit Nunaat)',
CountryISO.Greenland,
'299'
],
[
'Grenada',
CountryISO.Grenada,
'1473'
],
[
'Guadeloupe',
CountryISO.Guadeloupe,
'590',
0
],
[
'Guam',
'gu',
'1',
1,
[
'671',
]
],
[
'Guatemala',
CountryISO.Guatemala,
'502'
],
[
'Guernsey',
CountryISO.Guernsey,
'44',
1,
[1481]
],
[
'Guinea (Guinée)',
CountryISO.Guinea,
'224'
],
[
'Guinea-Bissau (Guiné Bissau)',
CountryISO.GuineaBissau,
'245'
],
[
'Guyana',
CountryISO.Guyana,
'592'
],
[
'Haiti',
CountryISO.Haiti,
'509'
],
[
'Honduras',
CountryISO.Honduras,
'504'
],
[
'Hong Kong (香港)',
CountryISO.HongKong,
'852'
],
[
'Hungary (Magyarország)',
CountryISO.Hungary,
'36'
],
[
'Iceland (Ísland)',
CountryISO.Iceland,
'354'
],
[
'India (भारत)',
CountryISO.India,
'91'
],
[
'Indonesia',
CountryISO.Indonesia,
'62'
],
[
'Iran (ایران)',
CountryISO.Iran,
'98'
],
[
'Iraq (العراق)',
CountryISO.Iraq,
'964'
],
[
'Ireland',
CountryISO.Ireland,
'353'
],
[
'Isle of Man',
CountryISO.IsleOfMan,
'44',
2,
[1624]
],
[
'Israel (ישראל)',
CountryISO.Israel,
'972'
],
[
'Italy (Italia)',
CountryISO.Italy,
'39',
0
],
[
'Jamaica',
'jm',
'1',
1,
[
'876',
]
],
[
'Japan (日本)',
CountryISO.Japan,
'81'
],
[
'Jersey',
CountryISO.Jersey,
'44',
3,
[1534]
],
[
'Jordan (الأردن)',
CountryISO.Jordan,
'962'
],
[
'Kazakhstan (Казахстан)',
CountryISO.Kazakhstan,
'7',
1
],
[
'Kenya',
CountryISO.Kenya,
'254'
],
[
'Kiribati',
CountryISO.Kiribati,
'686'
],
[
'Kosovo',
CountryISO.Kosovo,
'383'
],
[
'Kuwait (الكويت)',
CountryISO.Kuwait,
'965'
],
[
'Kyrgyzstan (Кыргызстан)',
CountryISO.Kyrgyzstan,
'996'
],
[
'Laos (ລາວ)',
CountryISO.Laos,
'856'
],
[
'Latvia (Latvija)',
CountryISO.Latvia,
'371'
],
[
'Lebanon (لبنان)',
CountryISO.Lebanon,
'961'
],
[
'Lesotho',
CountryISO.Lesotho,
'266'
],
[
'Liberia',
CountryISO.Liberia,
'231'
],
[
'Libya (ليبيا)',
CountryISO.Libya,
'218'
],
[
'Liechtenstein',
CountryISO.Liechtenstein,
'423'
],
[
'Lithuania (Lietuva)',
CountryISO.Lithuania,
'370'
],
[
'Luxembourg',
CountryISO.Luxembourg,
'352'
],
[
'Macau (澳門)',
CountryISO.Macau,
'853'
],
[
'Macedonia (FYROM) (Македонија)',
CountryISO.Macedonia,
'389'
],
[
'Madagascar (Madagasikara)',
CountryISO.Madagascar,
'261'
],
[
'Malawi',
CountryISO.Malawi,
'265'
],
[
'Malaysia',
CountryISO.Malaysia,
'60'
],
[
'Maldives',
CountryISO.Maldives,
'960'
],
[
'Mali',
CountryISO.Mali,
'223'
],
[
'Malta',
CountryISO.Malta,
'356'
],
[
'Marshall Islands',
CountryISO.MarshallIslands,
'692'
],
[
'Martinique',
CountryISO.Martinique,
'596'
],
[
'Mauritania (موريتانيا)',
CountryISO.Mauritania,
'222'
],
[
'Mauritius (Moris)',
CountryISO.Mauritius,
'230'
],
[
'Mayotte',
CountryISO.Mayotte,
'262',
1
],
[
'Mexico (México)',
CountryISO.Mexico,
'52'
],
[
'Micronesia',
CountryISO.Micronesia,
'691'
],
[
'Moldova (Republica Moldova)',
CountryISO.Moldova,
'373'
],
[
'Monaco',
CountryISO.Monaco,
'377'
],
[
'Mongolia (Монгол)',
CountryISO.Mongolia,
'976'
],
[
'Montenegro (Crna Gora)',
CountryISO.Montenegro,
'382'
],
[
'Montserrat',
'ms',
'1',
1,
[
'664',
]
],
[
'Morocco (المغرب)',
CountryISO.Morocco,
'212',
0
],
[
'Mozambique (Moçambique)',
CountryISO.Mozambique,
'258'
],
[
'Myanmar (Burma) (မြန်မာ)',
CountryISO.Myanmar,
'95'
],
[
'Namibia (Namibië)',
CountryISO.Namibia,
'264'
],
[
'Nauru',
CountryISO.Nauru,
'674'
],
[
'Nepal (नेपाल)',
CountryISO.Nepal,
'977'
],
[
'Netherlands (Nederland)',
CountryISO.Netherlands,
'31'
],
[
'New Caledonia (Nouvelle-Calédonie)',
CountryISO.NewCaledonia,
'687'
],
[
'New Zealand',
CountryISO.NewZealand,
'64'
],
[
'Nicaragua',
CountryISO.Nicaragua,
'505'
],
[
'Niger (Nijar)',
CountryISO.Niger,
'227'
],
[
'Nigeria',
CountryISO.Nigeria,
'234'
],
[
'Niue',
CountryISO.Niue,
'683'
],
[
'Norfolk Island',
CountryISO.NorfolkIsland,
'672'
],
[
'North Korea (조선 민주주의 인민 공화국)',
CountryISO.NorthKorea,
'850'
],
[
'Northern Mariana Islands',
CountryISO.NorthernMarianaIslands,
'1670'
],
[
'Norway (Norge)',
CountryISO.Norway,
'47',
0
],
[
'Oman (عُمان)',
CountryISO.Oman,
'968'
],
[
'Pakistan (پاکستان)',
CountryISO.Pakistan,
'92'
],
[
'Palau',
CountryISO.Palau,
'680'
],
[
'Palestine (فلسطين)',
CountryISO.Palestine,
'970'
],
[
'Panama (Panamá)',
CountryISO.Panama,
'507'
],
[
'Papua New Guinea',
CountryISO.PapuaNewGuinea,
'675'
],
[
'Paraguay',
CountryISO.Paraguay,
'595'
],
[
'Peru (Perú)',
CountryISO.Peru,
'51'
],
[
'Philippines',
CountryISO.Philippines,
'63'
],
[
'Poland (Polska)',
CountryISO.Poland,
'48'
],
[
'Portugal',
CountryISO.Portugal,
'351'
],
[
'Puerto Rico',
CountryISO.PuertoRico,
'1',
3,
['787', '939']
],
[
'Qatar (قطر)',
CountryISO.Qatar,
'974'
],
[
'Réunion (La Réunion)',
CountryISO.Réunion,
'262',
0
],
[
'Romania (România)',
CountryISO.Romania,
'40'
],
[
'Russia (Россия)',
CountryISO.Russia,
'7',
0
],
[
'Rwanda',
CountryISO.Rwanda,
'250'
],
[
'Saint Barthélemy (Saint-Barthélemy)',
CountryISO.SaintBarthélemy,
'590',
1
],
[
'Saint Helena',
CountryISO.SaintHelena,
'290'
],
[
'Saint Kitts and Nevis',
CountryISO.SaintKittsAndNevis,
'1869'
],
[
'Saint Lucia',
'lc',
'1',
1,
[
'758',
]
],
[
'Saint Martin (Saint-Martin (partie française))',
CountryISO.SaintMartin,
'590',
2
],
[
'Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)',
CountryISO.SaintPierreAndMiquelon,
'508'
],
[
'Saint Vincent and the Grenadines',
'vc',
'1',
1,
[
'784',
]
],
[
'Samoa',
CountryISO.Samoa,
'685'
],
[
'San Marino',
CountryISO.SanMarino,
'378'
],
[
'São Tomé and Príncipe (São Tomé e Príncipe)',
CountryISO.SãoToméAndPríncipe,
'239'
],
[
'Saudi Arabia (المملكة العربية السعودية)',
CountryISO.SaudiArabia,
'966'
],
[
'Senegal (Sénégal)',
CountryISO.Senegal,
'221'
],
[
'Serbia (Србија)',
CountryISO.Serbia,
'381'
],
[
'Seychelles',
CountryISO.Seychelles,
'248'
],
[
'Sierra Leone',
CountryISO.SierraLeone,
'232'
],
[
'Singapore',
CountryISO.Singapore,
'65'
],
[
'Sint Maarten',
'sx',
'1',
1,
[
'721',
]
],
[
'Slovakia (Slovensko)',
CountryISO.Slovakia,
'421'
],
[
'Slovenia (Slovenija)',
CountryISO.Slovenia,
'386'
],
[
'Solomon Islands',
CountryISO.SolomonIslands,
'677'
],
[
'Somalia (Soomaaliya)',
CountryISO.Somalia,
'252'
],
[
'South Africa',
CountryISO.SouthAfrica,
'27'
],
[
'South Korea (대한민국)',
CountryISO.SouthKorea,
'82'
],
[
'South Sudan (جنوب السودان)',
CountryISO.SouthSudan,
'211'
],
[
'Spain (España)',
CountryISO.Spain,
'34'
],
[
'Sri Lanka (ශ්රී ලංකාව)',
CountryISO.SriLanka,
'94'
],
[
'Sudan (السودان)',
CountryISO.Sudan,
'249'
],
[
'Suriname',
CountryISO.Suriname,
'597'
],
[
'Svalbard and Jan Mayen',
CountryISO.SvalbardAndJanMayen,
'47',
1
],
[
'Swaziland',
CountryISO.Swaziland,
'268'
],
[
'Sweden (Sverige)',
CountryISO.Sweden,
'46'
],
[
'Switzerland (Schweiz)',
CountryISO.Switzerland,
'41'
],
[
'Syria (سوريا)',
CountryISO.Syria,
'963'
],
[
'Taiwan (台灣)',
CountryISO.Taiwan,
'886'
],
[
'Tajikistan',
CountryISO.Tajikistan,
'992'
],
[
'Tanzania',
CountryISO.Tanzania,
'255'
],
[
'Thailand (ไทย)',
CountryISO.Thailand,
'66'
],
[
'Timor-Leste',
CountryISO.TimorLeste,
'670'
],
[
'Togo',
CountryISO.Togo,
'228'
],
[
'Tokelau',
CountryISO.Tokelau,
'690'
],
[
'Tonga',
CountryISO.Tonga,
'676'
],
[
'Trinidad and Tobago',
'tt',
'1',
1,
[
'868',
]
],
[
'Tunisia (تونس)',
CountryISO.Tunisia,
'216'
],
[
'Turkey (Türkiye)',
CountryISO.Turkey,
'90'
],
[
'Turkmenistan',
CountryISO.Turkmenistan,
'993'
],
[
'Turks and Caicos Islands',
CountryISO.TurksAndCaicosIslands,
'1649'
],
[
'Tuvalu',
CountryISO.Tuvalu,
'688'
],
[
'U.S. Virgin Islands',
'vi',
'1',
1,
[
'340',
]
],
[
'Uganda',
CountryISO.Uganda,
'256'
],
[
'Ukraine (Україна)',
CountryISO.Ukraine,
'380'
],
[
'United Arab Emirates (الإمارات العربية المتحدة)',
CountryISO.UnitedArabEmirates,
'971'
],
[
'United Kingdom',
CountryISO.UnitedKingdom,
'44',
0
],
[
'United States',
CountryISO.UnitedStates,
'1',
0
],
[
'Uruguay',
CountryISO.Uruguay,
'598'
],
[
'Uzbekistan (Oʻzbekiston)',
CountryISO.Uzbekistan,
'998'
],
[
'Vanuatu',
CountryISO.Vanuatu,
'678'
],
[
'Vatican City (Città del Vaticano)',
CountryISO.VaticanCity,
'39',
1
],
[
'Venezuela',
CountryISO.Venezuela,
'58'
],
[
'Vietnam (Việt Nam)',
CountryISO.Vietnam,
'84'
],
[
'Wallis and Futuna',
CountryISO.WallisAndFutuna,
'681'
],
[
'Western Sahara (الصحراء الغربية)',
CountryISO.WesternSahara,
'212',
1
],
[
'Yemen (اليمن)',
CountryISO.Yemen,
'967'
],
[
'Zambia',
CountryISO.Zambia,
'260'
],
[
'Zimbabwe',
CountryISO.Zimbabwe,
'263'
],
[
'Åland Islands',
CountryISO.ÅlandIslands,
'358',
1
]
];
class DialCodePipe {
transform(dialoCode) {
if (!dialoCode)
return '';
return `+${dialoCode}`;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DialCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.4", ngImport: i0, type: DialCodePipe, isStandalone: true, name: "dialCode" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DialCodePipe, decorators: [{
type: Pipe,
args: [{
name: 'dialCode',
standalone: true
}]
}] });
class FavoriteElementInjectorDirective {
el;
constructor(el) {
this.el = el;
}
ngOnInit() {
if (this.el.nativeElement.classList.contains('favorite')) {
this.el.nativeElement.parentNode.parentNode.classList.add('favoriteItem');
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: FavoriteElementInjectorDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.4", type: FavoriteElementInjectorDirective, isStandalone: true, selector: "[favorite]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: FavoriteElementInjectorDirective, decorators: [{
type: Directive,
args: [{
selector: '[favorite]',
standalone: true
}]
}], ctorParameters: () => [{ type: i0.ElementRef }] });
/*
"Property 'nativeElement' does not exist on type 'FormControl'".
'NativeElementInjectorDirective' injects nativeElement to each control,
so we can access it from inside validator for example.
More about this approach and reasons for this:
https://github.com/angular/angular/issues/18025
https://stackoverflow.com/a/54075119/1617590
*/
class NativeElementInjectorDirective {
controlDir;
host;
constructor(controlDir, host) {
this.controlDir = controlDir;
this.host = host;
}
ngOnInit() {
//@ts-ignore
if (this.controlDir.control)
this.controlDir.control['nativeElement'] = this.host.nativeElement;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: NativeElementInjectorDirective, deps: [{ token: i2.NgControl }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.4", type: NativeElementInjectorDirective, isStandalone: true, selector: "[ngModel], [formControl], [formControlName]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: NativeElementInjectorDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngModel], [formControl], [formControlName]',
standalone: true
}]
}], ctorParameters: () => [{ type: i2.NgControl }, { type: i0.ElementRef }] });
/* eslint-disable prefer-const */
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @angular-eslint/component-selector */
class IntlInputTelComponent {
cssClass = "form-control";
favoriteCountries = [];
onlyCountries = [];
enableAutoCountrySelect = true;
displayPlaceholder = true;
customPlaceholder;
numberFormat = PhoneNumberFormat.INTERNATIONAL;
searchCountryField = [SearchCountryField.NAME];
selectFirstCountry = true;
inputId = "phone";
selectedCountryISO;
separateDialCode = false;
showExamplePlaceholder = false;
phoneValidation = true;
_lang = signal("en", ...(ngDevMode ? [{ debugName: "_lang" }] : []));
set lang(value) {
if (value && value !== this._lang()) {
this._lang.set(value);
if (this.countriesSignal().length > 0) {
this.fetchCountryData();
}
}
}
get lang() {
return this._lang();
}
set disabled(value) {
this.setDisabledState(value);
}
countryChange = new EventEmitter();
SearchCountryField = SearchCountryField;
phoneUtil = lpn.PhoneNumberUtil.getInstance();
phoneNumberControl = new FormControl("");
destroy$ = new Subject();
// Base signals
countriesSignal = signal([], ...(ngDevMode ? [{ debugName: "countriesSignal" }] : []));
selectedCountrySignal = signal(new Country(), ...(ngDevMode ? [{ debugName: "selectedCountrySignal" }] : []));
phoneState = linkedSignal(() => {
const value = this.phoneNumberControl.value ?? "";
// If user only typed "+" or it's purely whitespace, skip any fancy logic
if (!value.trim() || value.trim() === "+") {
return {
number: null,
country: null,
valid: false,
formatted: value, // just keep the plus or empty
};
}
try {
const shouldKeepInternational = value.startsWith("+");
const currentCountry = this.selectedCountrySignal();
const number = this.phoneUtil.parseAndKeepRawInput(value, shouldKeepInternational ? "ZZ" : currentCountry.iso2);
const expectedLength = this.getCurrentMaxLength();
const nationalNumber = number.getNationalNumber()?.toString() ?? "";
const isComplete = nationalNumber.length >= expectedLength;
const isValid = this.phoneUtil.isValidNumber(number) && this.phoneUtil.isValidNumberForRegion(number, currentCountry.iso2);
return {
number,
country: currentCountry.iso2,
valid: isValid,
formatted: isValid && isComplete ? this.phoneUtil.format(number, this.numberFormat) : value,
};
}
catch {
return {
number: null,
country: this.selectedCountrySignal().iso2,
valid: false,
formatted: value,
};
}
});
// Computed values
examplePlaceholder = computed(() => {
if (!this.showExamplePlaceholder)
return "";
try {
const country = this.selectedCountrySignal();
const example = this.phoneUtil.getExampleNumberForType(country.iso2, PhoneNumberType.MOBILE);
return example ? this.phoneUtil.format(example, this.numberFormat) : "";
}
catch {
return "";
}
}, ...(ngDevMode ? [{ debugName: "examplePlaceholder" }] : []));
get favorites() {
return this.countriesSignal().filter((c) => c.isFavorite);
}
propagateChange = () => { };
onTouched = () => { };
onValidatorChange = () => { };
constructor() {
this.phoneNumberControl.valueChanges.pipe(debounceTime(300), distinctUntilChanged()).subscribe((value) => {
if (!value?.trim()) {
this.phoneNumberControl.setErrors(null);
this.propagateChange("");
return;
}
// Always parse for region detection
try {
const parsedNumber = this.phoneUtil.parseAndKeepRawInput(value, "ZZ");
const regionCode = this.phoneUtil.getRegionCodeForNumber(parsedNumber);
// Switch country if recognized
const currentCountry = this.selectedCountrySignal();
if (regionCode && regionCode.toLowerCase() !== currentCountry.iso2.toLowerCase()) {
const found = this.countriesSignal().find((c) => c.iso2.toLowerCase() === regionCode.toLowerCase());
if (found) {
this.selectedCountrySignal.set(found);
}
}
}
catch {
// ignore parse error
}
// No auto-format here, just propagate
this.propagateChange(value);
});
}
ngOnChanges(changes) {
if (!this.countriesSignal().length) {
this.init();
}
if (changes["selectedCountryISO"]) {
this.updateSelectedCountry();
}
if (changes["favoriteCountries"]) {
this.fetchCountryData();
}
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
init() {
this.fetchCountryData();
if (this.onlyCountries.length) {
this.countriesSignal.update((countries) => countries.filter((c) => this.onlyCountries.includes(c.iso2)));
}
this.updateSelectedCountry();
}
getCurrentMaxLength() {
const country = this.selectedCountrySignal();
if (!country.iso2)
return 15;
try {
const example = this.phoneUtil.getExampleNumberForType(country.iso2, PhoneNumberType.MOBILE);
if (!example)
return 15;
const currentValue = this.phoneNumberControl.value || "";
const nationalNumber = example.getNationalNumber()?.toString() || "";
return currentValue.startsWith("+") ? nationalNumber.length + country.dialCode.length + 1 : nationalNumber.length;
}
catch {
return 15;
}
}
onInputKeyPress(event) {
const allowedKeys = ["ArrowLeft", "ArrowRight", "Backspace", "Delete", "Tab", "Home", "End"];
if (allowedKeys.includes(event.key))
return;
if ((event.ctrlKey || event.metaKey) && ["a", "c", "v", "x"].includes(event.key.toLowerCase()))
return;
const input = event.target;
const currentValue = input.value;
const selectionStart = input.selectionStart || 0;
if (event.key === "+" && selectionStart === 0)
return;
if (!/^\d$/.test(event.key)) {
event.preventDefault();
return;
}
const numericValue = currentValue.replace(/\D/g, "");
const maxLength = this.getCurrentMaxLength();
const currentLength = currentValue.startsWith("+") ? numericValue.length : numericValue.length;
if (!event.ctrlKey && !event.metaKey && currentLength >= maxLength && input.selectionStart === input.selectionEnd) {
event.preventDefault();
}
}
onInputBlur() {
this.phoneNumberControl.markAsTouched();
this.onTouched();
// Force state update on blur
this.phoneState.update((state) => state);
}
onCountrySelect(country) {
this.selectedCountrySignal.set(country);
this.countryChange.emit(country);
// Force state update when country changes
this.phoneState.update((state) => state);
}
onPaste(event) {
event.preventDefault();
const pastedInput = event.clipboardData?.getData("text") || "";
if (!pastedInput)
return;
this.phoneNumberControl.setValue(pastedInput);
}
fetchCountryData() {
const regionsNames = new Intl.DisplayNames([this._lang()], { type: "region" });
const countries = ALL_COUNTRIES.map((countryArray) => {
const iso2 = countryArray[1].toString().toUpperCase();
return {
name: regionsNames.of(iso2) || "",
iso2: iso2,
dialCode: countryArray[2].toString(),
priority: +countryArray[3] || 0,
areaCodes: countryArray[4] || undefined,
htmlId: `item-${iso2}`,
flagClass: `iti__flag iti__${iso2.toLowerCase()}`,
placeHolder: this.getPlaceholder(iso2),
isFavorite: this.favoriteCountries.includes(iso2),
};
}).sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite));
this.countriesSignal.set(countries);
if (this.selectFirstCountry && !this.selectedCountrySignal().iso2) {
const firstCountry = this.favoriteCountries.length ? countries.find((c) => c.isFavorite) : countries[0];
if (firstCountry) {
this.selectedCountrySignal.set(firstCountry);
}
}
}
updateSelectedCountry() {
if (!this.selectedCountryISO)
return;
const country = this.countriesSignal().find((c) => c.iso2.toLowerCase() === this.selectedCountryISO?.toLowerCase());
if (country) {
this.selectedCountrySignal.set(country);
}
}
getPlaceholder(countryCode) {
if (!this.displayPlaceholder)
return "";
if (this.customPlaceholder)
return this.customPlaceholder;
try {
const example = this.phoneUtil.getExampleNumberForType(countryCode, PhoneNumberType.MOBILE);
return example ? this.phoneUtil.format(example, this.numberFormat) : "";
}
catch {
return "";
}
}
// ControlValueAccessor implementation
writeValue(obj) {
if (!obj) {
this.phoneNumberControl.setValue("");
return;
}
try {
const number = this.phoneUtil.parse(obj, "ZZ");
const countryCode = this.phoneUtil.getRegionCodeForNumber(number);
if (countryCode) {
const country = this.countriesSignal().find((c) => c.iso2.toLowerCase() === countryCode.toLowerCase());
if (country) {
this.selectedCountrySignal.set(country);
}
}
const formatted = this.phoneUtil.format(number, this.numberFormat);
this.phoneNumberControl.setValue(formatted, { emitEvent: false });
}
catch {
this.phoneNumberControl.setValue("");
}
}
registerOnChange(fn) {
this.propagateChange = fn;
}
registerOnTouched(fn) {
this.onTouched = fn;
}
registerOnValidatorChange(fn) {
this.onValidatorChange = fn;
}
setDisabledState(isDisabled) {
isDisabled ? this.phoneNumberControl.disable() : this.phoneNumberControl.enable();
}
// Validator implementation
validate() {
return this.phoneNumberControl.errors;
}
getErrorMessage() {
const errors = this.phoneNumberControl.errors;
if (!errors)
return "";
if (errors["parseError"])
return "Please enter a valid phone number.";
if (errors["invalidCountry"])
return "Selected country is invalid.";
if (errors["invalidNumber"])
return "Invalid phone number for the selected region.";
if (errors["formatError"])
return "Error formatting phone number.";
return "Please enter a valid phone number.";
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: IntlInputTelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.4", type: IntlInputTelComponent, isStandalone: true, selector: "p-intl-tel-input-gg", inputs: { cssClass: "cssClass", favoriteCountries: "favoriteCountries", onlyCountries: "onlyCountries", enableAutoCountrySelect: "enableAutoCountrySelect", displayPlaceholder: "displayPlaceholder", customPlaceholder: "customPlaceholder", numberFormat: "numberFormat", searchCountryField: "searchCountryField", selectFirstCountry: "selectFirstCountry", inputId: "inputId", selectedCountryISO: "selectedCountryISO", separateDialCode: "separateDialCode", showExamplePlaceholder: "showExamplePlaceholder", phoneValidation: "phoneValidation", lang: "lang", disabled: "disabled" }, outputs: { countryChange: "countryChange" }, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => IntlInputTelComponent),
multi: true,
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => IntlInputTelComponent),
multi: true,
},
], usesOnChanges: true, ngImport: i0, template: `
<div class="flex items-center gap-2 phone-input-component">
<p-select
[options]="countriesSignal()"
[filter]="true"
[filterFields]="searchCountryField"
appendTo="body"
[resetFilterOnHide]="true"
[disabled]="phoneNumberControl.disabled"
[(ngModel)]="selectedCountrySignal"
(onChange)="onCountrySelect($event.value)"
optionLabel="name"
[showClear]="false"
>
<ng-template #selectedItem let-selectedOption>
@if (selectedOption) {
<div class="flex items-center" [ngClass]="separateDialCode ? 'gap-0' : 'w-12 px-2'">
<div [ngClass]="selectedOption.flagClass"></div>
@if (separateDialCode) {
<span>+{{ selectedOption.dialCode }}</span>
}
</div>
}
</ng-template>
<ng-template #item let-country>
<div class="flex items-center gap-3 w-full px-1" [ngClass]="{ favorite: country.isFavorite }">
<div [ngClass]="country.flagClass"></div>
<div class="flex flex-col">
<span class="text-sm">{{ country.name }}</span>
<span class="text-xs t