UNPKG

ngx-material-intl-tel-input

Version:
1,090 lines (1,084 loc) 820 kB
import { AsyncPipe, NgClass, NgTemplateOutlet } from '@angular/common'; import * as i0 from '@angular/core'; import { Injectable, viewChild, model, input, output, signal, effect, ChangeDetectionStrategy, Component } from '@angular/core'; import * as i4 from '@angular/forms'; import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms'; import * as i6 from '@angular/material/select'; import { MatSelectModule, MAT_SELECT_CONFIG } from '@angular/material/select'; import * as i8 from 'ngx-mat-select-search'; import { NgxMatSelectSearchModule } from 'ngx-mat-select-search'; import { ReplaySubject, Subject, takeUntil, take } from 'rxjs'; import { PhoneNumberFormat, PhoneNumberUtil, PhoneNumberType } from 'google-libphonenumber'; import * as i5 from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field'; import * as i9 from '@angular/material/input'; import { MatInputModule } from '@angular/material/input'; import * as i1 from '@angular/common/http'; import * as i10 from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip'; import * as i11 from 'angular-imask'; import { IMaskModule } from 'angular-imask'; import * as i7 from '@angular/material/core'; 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 = {})); class CountryCode { constructor() { this.allCountries = [ ['🇦🇫', '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] ]; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryCode, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryCode }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryCode, decorators: [{ type: Injectable }] }); class TelValidators { static isValidNumber(telForm, includeDialCode = false, allCountries, outputNumberFormat = PhoneNumberFormat.INTERNATIONAL) { return (control) => { try { const phoneNumberUtil = PhoneNumberUtil.getInstance(); if (!control.value) { return null; } // NOTE: the PhoneNumberUtil.parse() method does NOT appear to correctly parse phone numbers with // country codes which include the 'area code' eg. Dominica (+1767), Grenada (+1473), etc. // Instead, the returned phone number is for the US (+1) country code. const parsed = phoneNumberUtil.parse(control.value); const setPrefixControlValue = (countryCode, allCountries, telForm) => { const country = allCountries.find((c) => { if (c.dialCode === countryCode?.toString()) { if (c.areaCodes) { // Checking the area codes only works because the countries using the same country code as the // US (+1) and UK (+44) are ALL defined earlier in the list of all countries (country-code.ts) // and are checked before defaulting to the US or UK (which are defined without area codes and // have the highest priority (0)). return c.areaCodes?.find((ac) => parsed.getNationalNumber()?.toString().startsWith(ac)); } else if (c.priority === 0) { // If a country does NOT have any area codes but shares a country code with another country, // return the country with the highest priority (0), eg. country code '599' belongs to both // 'Carribean Netherlands' (priority 1) and 'Curaçao' (priority 0). return c; } } return undefined; }); if (country && country.iso2 !== telForm?.value?.prefixCtrl?.iso2) { telForm.get('prefixCtrl')?.setValue(country, { emitEvent: false }); } }; if (includeDialCode) { const countryDialCode = telForm?.value?.prefixCtrl?.dialCode || parsed.getCountryCode(); if (countryDialCode) { setPrefixControlValue(countryDialCode, allCountries, telForm); } } const formattedOnlyNumber = phoneNumberUtil.format(parsed, includeDialCode || telForm?.value?.prefixCtrl?.iso2 === 'mp' ? outputNumberFormat : PhoneNumberFormat.NATIONAL); telForm .get('numberControl') ?.setValue(formattedOnlyNumber, { emitEvent: false }); const isValidNumber = phoneNumberUtil.isValidNumber(parsed); setPrefixControlValue(parsed.getCountryCode(), allCountries, telForm); if (!isValidNumber) { control.setErrors({ invalidNumber: true }); telForm.get('numberControl')?.setErrors({ invalidNumber: true }); return { invalidNumber: true }; } else { control.setErrors(null); telForm.get('numberControl')?.setErrors(null); return null; } } catch { control.setErrors({ invalidNumber: true }); telForm.get('numberControl')?.setErrors({ invalidNumber: true }); return { invalidNumber: true }; } }; } } class GeoIpService { constructor(http) { this.http = http; } /** * geoIpLookup function makes an HTTP GET request to retrieve geographical data based on the client's IP address. * * @return {Observable<GeoData>} an observable of GeoData containing geographical information */ geoIpLookup() { return this.http.get('https://ipapi.co/json'); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: GeoIpService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: GeoIpService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: GeoIpService, decorators: [{ type: Injectable }], ctorParameters: () => [{ type: i1.HttpClient }] }); class CountryDataService { constructor() { this.phoneNumberUtil = PhoneNumberUtil.getInstance(); } /** * Retrieves a Country object based on the provided country data and placeholder flag. * * @param {CountryData} countryData - the country data used to create the Country object * @param {boolean} enablePlaceholder - a flag indicating whether to include a placeholder value * @return {Country} the generated Country object */ getCountryObject(countryData, enablePlaceholder, includeDialCode, useMask, forceSelectedCountryCode, showMaskPlaceholder, outputNumberFormat) { const phoneNumberPlaceholder = this.getPhoneNumberPlaceholder(countryData[2].toString().toUpperCase(), includeDialCode, outputNumberFormat); const country = { emojiFlag: countryData[0].toString(), name: countryData[1].toString(), iso2: countryData[2].toString(), dialCode: countryData[3].toString(), priority: (countryData?.[4] && +countryData[4]) || 0, areaCodes: countryData[5] || undefined, htmlId: `country-code__${countryData[2].toString()}`, flagClass: `country-code__${countryData[2].toString().toLocaleLowerCase()}`, placeHolder: enablePlaceholder ? phoneNumberPlaceholder : '' }; if (useMask) { let mask = ''; if (forceSelectedCountryCode) { mask = this.formatPhoneNumberWithPrefix(phoneNumberPlaceholder, false); } else { mask = this.formatPhoneNumberWithPrefix(phoneNumberPlaceholder, true); } country.mask = { mask: mask, lazy: !showMaskPlaceholder }; } return country; } /** * Sorts the array of countries based on the preferred countries list. * * @param {Country[]} allCountries - the array of all countries to be sorted * @param {string[]} preferredCountries - the list of preferred countries * @return {Country[]} the sorted array of countries */ sortCountries(allCountries, preferredCountries) { if (preferredCountries?.length) { return allCountries.sort((a, b) => { if (preferredCountries.includes(a.iso2) && !preferredCountries.includes(b.iso2)) { return -1; } else if (!preferredCountries.includes(a.iso2) && preferredCountries.includes(b.iso2)) { return 1; } return 0; }); } return allCountries; } /** * Retrieves the placeholder for a phone number based on the provided country code. * * @param {string} countryCode - The country code for the phone number. * @return {string} The formatted phone number placeholder. */ getPhoneNumberPlaceholder(countryCode, includeDialCode, outputNumberFormat) { try { return this.phoneNumberUtil.format(this.phoneNumberUtil.getExampleNumberForType(countryCode, PhoneNumberType.MOBILE), includeDialCode || countryCode === 'MP' ? outputNumberFormat : PhoneNumberFormat.NATIONAL); } catch { return ''; } } /** * Process the list of countries based on the provided data and parameters. * * @param {CountryCode} countryCodeData - the data containing country codes * @param {boolean} enablePlaceholder - flag to enable placeholder * @param {(CountryISO | string)[]} [visibleCountries] - optional array of visible country ISO codes or country names * @param {(CountryISO | string)[]} [preferredCountries] - optional array of preferred country ISO codes or country names * @param {(CountryISO | string)[]} [excludedCountries] - optional array of excluded country ISO codes or country names * @return {Country[]} the processed and sorted list of countries */ processCountries(countryCodeData, enablePlaceholder, includeDialCode, visibleCountries, preferredCountries, excludedCountries, useMask = false, forceSelectedCountryCode = false, showMaskPlaceholder = false, outputNumberFormat = PhoneNumberFormat.INTERNATIONAL) { const allCountries = countryCodeData.allCountries.map((countryData) => this.getCountryObject(countryData, enablePlaceholder, includeDialCode, useMask, forceSelectedCountryCode, showMaskPlaceholder, outputNumberFormat)); const filteredVisibleCountries = visibleCountries?.length ? allCountries.filter((country) => visibleCountries.includes(country.iso2)) : allCountries; const filteredCountries = excludedCountries?.length ? filteredVisibleCountries.filter((country) => !excludedCountries.includes(country.iso2)) : filteredVisibleCountries; const sortedCountries = this.sortCountries(filteredCountries, preferredCountries); return sortedCountries; } /** * Formats a phone number by masking its digits while optionally masking the prefix. * * @param {string} phoneNumber - The phone number to be formatted. * @param {boolean} maskPrefix - Flag indicating whether to mask the prefix digits. * @return {string} The formatted phone number with masked digits and optionally masked prefix. */ formatPhoneNumberWithPrefix(phoneNumber, maskPrefix) { // Match the prefix (variable number of digits) const prefixMatch = phoneNumber.match(/^\+\d+/); if (prefixMatch) { // Extract the prefix const prefix = prefixMatch[0]; // Determine how to format the prefix based on the maskPrefix parameter const formattedPrefix = maskPrefix ? `+{${'0'.repeat(prefix.length - 1)}}` // Replace prefix digits with 0s : `+{${prefix.slice(1)}}`; // Keep the original prefix digits // Extract the rest of the phone number const restOfNumber = phoneNumber.slice(prefix.length); // Replace all digits in the rest of the phone number with zeros const maskedNumber = restOfNumber.replace(/\d/g, '0'); // Combine the formatted prefix with the masked number return `${formattedPrefix}${maskedNumber}`; } // If no prefix is found, replace all digits in the entire phone number return phoneNumber.replace(/\d/g, '0'); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryDataService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CountryDataService, decorators: [{ type: Injectable }] }); class NgxMaterialIntlTelInputComponent { constructor(countryCodeData, geoIpService, countryDataService, controlContainer) { this.countryCodeData = countryCodeData; this.geoIpService = geoIpService; this.countryDataService = countryDataService; this.controlContainer = controlContainer; /** control for the selected country prefix */ this.prefixCtrl = new FormControl(null); /** control for the MatSelect filter keyword */ this.prefixFilterCtrl = new FormControl(''); /** list of countries filtered by search keyword */ this.filteredCountries = new ReplaySubject(1); this.singleSelect = viewChild('singleSelect'); this.numberInput = viewChild('numberInput'); /** Subject that emits when the component has been destroyed. */ this._onDestroy = new Subject(); this.allCountries = []; this.phoneNumberUtil = PhoneNumberUtil.getInstance(); this.telForm = new FormGroup({ prefixCtrl: this.prefixCtrl, numberControl: new FormControl('') }); this.fieldControl = model(new FormControl('')); this.fieldControlName = input(''); this.required = model(false); this.disabled = model(false); this.appearance = input('fill'); this.enablePlaceholder = input(true); this.autoIpLookup = input(true); this.autoSelectCountry = input(true); this.autoSelectedCountry = input(''); this.numberValidation = input(true); this.iconMakeCall = input(true); this.initialValue = model(''); this.enableSearch = input(true); this.includeDialCode = input(false); this.emojiFlags = input(false); this.hidePhoneIcon = input(false); this.preferredCountries = input([]); this.visibleCountries = input([]); this.excludedCountries = input([]); this.textLabels = input({ mainLabel: 'Phone number', codePlaceholder: 'Code', searchPlaceholderLabel: 'Search', noEntriesFoundLabel: 'No countries found', nationalNumberLabel: 'Number', hintLabel: 'Select country and type your phone number', invalidNumberError: 'Number is not valid', requiredError: 'This field is required' }); this.useMask = input(false); this.forceSelectedCountryCode = input(false); this.showMaskPlaceholder = input(false); this.outputNumberFormat = input(PhoneNumberFormat.INTERNATIONAL); this.currentValue = output(); this.currentCountryCode = output(); this.currentCountryISO = output(); this.isFocused = signal(false); this.isLoading = signal(true); effect(() => { this.setRequiredValidators(); this.setDisabledState(); }); } /** * Initialize the component and perform necessary setup tasks. * */ ngOnInit() { this.setFieldControl(); this.fetchCountryData(); this.addValidations(); // load the initial countries list this.filteredCountries.next(this.allCountries.slice()); // listen for search field value changes this.prefixFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterCountries(); }); this.startTelFormValueChangesListener(); this.startPrefixValueChangesListener(); setTimeout(() => { this.setInitialTelValue(); }); this.startFieldControlValueChangesListener(); this.startFieldControlStatusChangesListener(); } /** * Fetches country data and populates the allCountries array. */ fetchCountryData() { const processedCountries = this.countryDataService.processCountries(this.countryCodeData, this.enablePlaceholder(), this.includeDialCode(), this.visibleCountries(), this.preferredCountries(), this.excludedCountries(), this.useMask(), this.forceSelectedCountryCode(), this.showMaskPlaceholder(), this.outputNumberFormat()); this.allCountries = processedCountries; } /** * Adds validations to the form field based on the current configuration. * It sets required validators and disabled state, and if number validation is enabled, * it adds a custom validator to check the validity of the phone number. */ addValidations() { this.setRequiredValidators(); this.setDisabledState(); if (this.numberValidation()) { this.fieldControl()?.addValidators(TelValidators.isValidNumber(this.telForm, this.includeDialCode(), this.allCountries, this.outputNumberFormat())); } } /** * Sets the required validators for the field control based on the 'required' input property. * If 'required' is true, adds a 'Validators.required' validator to the field control. * If 'required' is false, removes the 'Validators.required' validator from the field control. */ setRequiredValidators() { if (this.required()) { this.fieldControl()?.addValidators(Validators.required); } else { this.fieldControl()?.removeValidators(Validators.required); } } /** * Sets the disabled state of the telForm and fieldControl based on the 'disabled' input property. * If 'disabled' is true, both telForm and fieldControl are disabled. * If 'disabled' is false, both telForm and fieldControl are enabled. */ setDisabledState() { if (this.disabled()) { this.telForm?.disable(); this.fieldControl()?.disable(); } else { this.telForm?.enable(); this.fieldControl()?.enable(); } } /** * A lifecycle hook that is called after Angular has fully initialized a component's view. * * @return {void} */ ngAfterViewInit() { this.setInitialPrefixValue(); } /** * Method called when the component is destroyed. * */ ngOnDestroy() { this._onDestroy.next(); this._onDestroy.complete(); } /** * Performs a geo IP lookup and sets the prefix control value based on the country retrieved. */ geoIpLookup() { this.geoIpService.geoIpLookup().subscribe({ next: (data) => { const country = this.allCountries?.find((c) => c.iso2 === data.country_code?.toLowerCase()) || null; if (country) { this.prefixCtrl.setValue(country); } else { this.setAutoSelectedCountry(); } }, error: () => { this.setAutoSelectedCountry(); }, complete: () => { this.isLoading.set(false); } }); } /** * Sets the initial value after the filteredCountries are loaded initially */ setInitialPrefixValue() { this.filteredCountries .pipe(take