UNPKG

p-intl-input-tel

Version:

[![Build Status](https://travis-ci.org/jlevot/p-intl-input-tel.svg?branch=master)](https://travis-ci.org/jlevot/p-intl-input-tel) [![npm version](https://badge.fury.io/js/p-intl-input-tel.svg)](https://badge.fury.io/js/p-intl-input-tel-intl) [![npm](https

1 lines 99.1 kB
{"version":3,"file":"p-intl-input-tel.mjs","sources":["../../../projects/p-intl-input-tel/src/model/search-country-field.ts","../../../projects/p-intl-input-tel/src/model/country.model.ts","../../../projects/p-intl-input-tel/src/model/change-data.ts","../../../projects/p-intl-input-tel/src/model/country-iso.enum.ts","../../../projects/p-intl-input-tel/src/data/country-code.ts","../../../projects/p-intl-input-tel/src/utils/local-phone-utils.ts","../../../projects/p-intl-input-tel/src/validator/p-intl-input-tel.validator.ts","../../../projects/p-intl-input-tel/src/pipe/dialCode.pipe.ts","../../../projects/p-intl-input-tel/src/directives/favorite-element-injector.directive.ts","../../../projects/p-intl-input-tel/src/component/p-intl-input-tel.component.ts","../../../projects/p-intl-input-tel/src/component/p-intl-input-tel.component.html","../../../projects/p-intl-input-tel/src/directives/native-element-injector.directive.ts","../../../projects/p-intl-input-tel/p-intl-input-tel.ts"],"sourcesContent":["export enum SearchCountryField {\r\n DIALCODE = 'dialCode',\r\n ISO2 = 'iso2',\r\n NAME = 'name',\r\n};\r\n","export class Country {\r\n name: string;\r\n iso2: string;\r\n dialCode: string;\r\n priority: number;\r\n areaCodes?: string[];\r\n htmlId: string;\r\n flagClass: string;\r\n placeHolder: string;\r\n isFavorite: boolean;\r\n\r\n constructor() {\r\n this.name = '';\r\n this.iso2 = '';\r\n this.dialCode = '';\r\n this.priority = 0;\r\n this.areaCodes = undefined;\r\n this.htmlId = '';\r\n this.flagClass = '';\r\n this.placeHolder = '';\r\n }\r\n}\r\n","import { PhoneNumber, PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';\r\n\r\nexport class ChangeData {\r\n number: string;\r\n internationalNumber: string;\r\n nationalNumber: string;\r\n e164Number: string;\r\n countryCode: string | undefined;\r\n dialCode: string;\r\n\r\n constructor(phoneNumber?: PhoneNumber) {\r\n const utils = PhoneNumberUtil.getInstance();\r\n this.countryCode = phoneNumber && utils.getRegionCodeForNumber(phoneNumber) ? utils.getRegionCodeForNumber(phoneNumber) : '';\r\n this.dialCode = phoneNumber?.getCountryCode() ? `+${phoneNumber.getCountryCode()}` : '';\r\n this.e164Number = phoneNumber && utils.format(phoneNumber, PhoneNumberFormat.E164) !== '+0' ? utils.format(phoneNumber, PhoneNumberFormat.E164) : '';\r\n this.internationalNumber = phoneNumber ? utils.format(phoneNumber, PhoneNumberFormat.INTERNATIONAL) : '';\r\n this.nationalNumber = phoneNumber ? utils.format(phoneNumber, PhoneNumberFormat.NATIONAL) : '';\r\n this.number = phoneNumber ? utils.format(phoneNumber, PhoneNumberFormat.NATIONAL) : '';\r\n }\r\n}\r\n","export enum CountryISO {\r\n\tAfghanistan = 'af',\r\n\tAlbania = 'al',\r\n\tAlgeria = 'dz',\r\n\tAmericanSamoa = 'as',\r\n\tAndorra = 'ad',\r\n\tAngola = 'ao',\r\n\tAnguilla = 'ai',\r\n\tAntiguaAndBarbuda = 'ag',\r\n\tArgentina = 'ar',\r\n\tArmenia = 'am',\r\n\tAruba = 'aw',\r\n\tAustralia = 'au',\r\n\tAustria = 'at',\r\n\tAzerbaijan = 'az',\r\n\tBahamas = 'bs',\r\n\tBahrain = 'bh',\r\n\tBangladesh = 'bd',\r\n\tBarbados = 'bb',\r\n\tBelarus = 'by',\r\n\tBelgium = 'be',\r\n\tBelize = 'bz',\r\n\tBenin = 'bj',\r\n\tBermuda = 'bm',\r\n\tBhutan = 'bt',\r\n\tBolivia = 'bo',\r\n\tBosniaAndHerzegovina = 'ba',\r\n\tBotswana = 'bw',\r\n\tBrazil = 'br',\r\n\tBritishIndianOceanTerritory = 'io',\r\n\tBritishVirginIslands = 'vg',\r\n\tBrunei = 'bn',\r\n\tBulgaria = 'bg',\r\n\tBurkinaFaso = 'bf',\r\n\tBurundi = 'bi',\r\n\tCambodia = 'kh',\r\n\tCameroon = 'cm',\r\n\tCanada = 'ca',\r\n\tCapeVerde = 'cv',\r\n\tCaribbeanNetherlands = 'bq',\r\n\tCaymanIslands = 'ky',\r\n\tCentralAfricanRepublic = 'cf',\r\n\tChad = 'td',\r\n\tChile = 'cl',\r\n\tChina = 'cn',\r\n\tChristmasIsland = 'cx',\r\n\tCocos = 'cc',\r\n\tColombia = 'co',\r\n\tComoros = 'km',\r\n\tCongoDRCJamhuriYaKidemokrasiaYaKongo = 'cd',\r\n\tCongoRepublicCongoBrazzaville = 'cg',\r\n\tCookIslands = 'ck',\r\n\tCostaRica = 'cr',\r\n\tCôteDIvoire = 'ci',\r\n\tCroatia = 'hr',\r\n\tCuba = 'cu',\r\n\tCuraçao = 'cw',\r\n\tCyprus = 'cy',\r\n\tCzechRepublic = 'cz',\r\n\tDenmark = 'dk',\r\n\tDjibouti = 'dj',\r\n\tDominica = 'dm',\r\n\tDominicanRepublic = 'do',\r\n\tEcuador = 'ec',\r\n\tEgypt = 'eg',\r\n\tElSalvador = 'sv',\r\n\tEquatorialGuinea = 'gq',\r\n\tEritrea = 'er',\r\n\tEstonia = 'ee',\r\n\tEthiopia = 'et',\r\n\tFalklandIslands = 'fk',\r\n\tFaroeIslands = 'fo',\r\n\tFiji = 'fj',\r\n\tFinland = 'fi',\r\n\tFrance = 'fr',\r\n\tFrenchGuiana = 'gf',\r\n\tFrenchPolynesia = 'pf',\r\n\tGabon = 'ga',\r\n\tGambia = 'gm',\r\n\tGeorgia = 'ge',\r\n\tGermany = 'de',\r\n\tGhana = 'gh',\r\n\tGibraltar = 'gi',\r\n\tGreece = 'gr',\r\n\tGreenland = 'gl',\r\n\tGrenada = 'gd',\r\n\tGuadeloupe = 'gp',\r\n\tGuam = 'gu',\r\n\tGuatemala = 'gt',\r\n\tGuernsey = 'gg',\r\n\tGuinea = 'gn',\r\n\tGuineaBissau = 'gw',\r\n\tGuyana = 'gy',\r\n\tHaiti = 'ht',\r\n\tHonduras = 'hn',\r\n\tHongKong = 'hk',\r\n\tHungary = 'hu',\r\n\tIceland = 'is',\r\n\tIndia = 'in',\r\n\tIndonesia = 'id',\r\n\tIran = 'ir',\r\n\tIraq = 'iq',\r\n\tIreland = 'ie',\r\n\tIsleOfMan = 'im',\r\n\tIsrael = 'il',\r\n\tItaly = 'it',\r\n\tJamaica = 'jm',\r\n\tJapan = 'jp',\r\n\tJersey = 'je',\r\n\tJordan = 'jo',\r\n\tKazakhstan = 'kz',\r\n\tKenya = 'ke',\r\n\tKiribati = 'ki',\r\n\tKosovo = 'xk',\r\n\tKuwait = 'kw',\r\n\tKyrgyzstan = 'kg',\r\n\tLaos = 'la',\r\n\tLatvia = 'lv',\r\n\tLebanon = 'lb',\r\n\tLesotho = 'ls',\r\n\tLiberia = 'lr',\r\n\tLibya = 'ly',\r\n\tLiechtenstein = 'li',\r\n\tLithuania = 'lt',\r\n\tLuxembourg = 'lu',\r\n\tMacau = 'mo',\r\n\tMacedonia = 'mk',\r\n\tMadagascar = 'mg',\r\n\tMalawi = 'mw',\r\n\tMalaysia = 'my',\r\n\tMaldives = 'mv',\r\n\tMali = 'ml',\r\n\tMalta = 'mt',\r\n\tMarshallIslands = 'mh',\r\n\tMartinique = 'mq',\r\n\tMauritania = 'mr',\r\n\tMauritius = 'mu',\r\n\tMayotte = 'yt',\r\n\tMexico = 'mx',\r\n\tMicronesia = 'fm',\r\n\tMoldova = 'md',\r\n\tMonaco = 'mc',\r\n\tMongolia = 'mn',\r\n\tMontenegro = 'me',\r\n\tMontserrat = 'ms',\r\n\tMorocco = 'ma',\r\n\tMozambique = 'mz',\r\n\tMyanmar = 'mm',\r\n\tNamibia = 'na',\r\n\tNauru = 'nr',\r\n\tNepal = 'np',\r\n\tNetherlands = 'nl',\r\n\tNewCaledonia = 'nc',\r\n\tNewZealand = 'nz',\r\n\tNicaragua = 'ni',\r\n\tNiger = 'ne',\r\n\tNigeria = 'ng',\r\n\tNiue = 'nu',\r\n\tNorfolkIsland = 'nf',\r\n\tNorthKorea = 'kp',\r\n\tNorthernMarianaIslands = 'mp',\r\n\tNorway = 'no',\r\n\tOman = 'om',\r\n\tPakistan = 'pk',\r\n\tPalau = 'pw',\r\n\tPalestine = 'ps',\r\n\tPanama = 'pa',\r\n\tPapuaNewGuinea = 'pg',\r\n\tParaguay = 'py',\r\n\tPeru = 'pe',\r\n\tPhilippines = 'ph',\r\n\tPoland = 'pl',\r\n\tPortugal = 'pt',\r\n\tPuertoRico = 'pr',\r\n\tQatar = 'qa',\r\n\tRéunion = 're',\r\n\tRomania = 'ro',\r\n\tRussia = 'ru',\r\n\tRwanda = 'rw',\r\n\tSaintBarthélemy = 'bl',\r\n\tSaintHelena = 'sh',\r\n\tSaintKittsAndNevis = 'kn',\r\n\tSaintLucia = 'lc',\r\n\tSaintMartin = 'mf',\r\n\tSaintPierreAndMiquelon = 'pm',\r\n\tSaintVincentAndTheGrenadines = 'vc',\r\n\tSamoa = 'ws',\r\n\tSanMarino = 'sm',\r\n\tSãoToméAndPríncipe = 'st',\r\n\tSaudiArabia = 'sa',\r\n\tSenegal = 'sn',\r\n\tSerbia = 'rs',\r\n\tSeychelles = 'sc',\r\n\tSierraLeone = 'sl',\r\n\tSingapore = 'sg',\r\n\tSintMaarten = 'sx',\r\n\tSlovakia = 'sk',\r\n\tSlovenia = 'si',\r\n\tSolomonIslands = 'sb',\r\n\tSomalia = 'so',\r\n\tSouthAfrica = 'za',\r\n\tSouthKorea = 'kr',\r\n\tSouthSudan = 'ss',\r\n\tSpain = 'es',\r\n\tSriLanka = 'lk',\r\n\tSudan = 'sd',\r\n\tSuriname = 'sr',\r\n\tSvalbardAndJanMayen = 'sj',\r\n\tSwaziland = 'sz',\r\n\tSweden = 'se',\r\n\tSwitzerland = 'ch',\r\n\tSyria = 'sy',\r\n\tTaiwan = 'tw',\r\n\tTajikistan = 'tj',\r\n\tTanzania = 'tz',\r\n\tThailand = 'th',\r\n\tTimorLeste = 'tl',\r\n\tTogo = 'tg',\r\n\tTokelau = 'tk',\r\n\tTonga = 'to',\r\n\tTrinidadAndTobago = 'tt',\r\n\tTunisia = 'tn',\r\n\tTurkey = 'tr',\r\n\tTurkmenistan = 'tm',\r\n\tTurksAndCaicosIslands = 'tc',\r\n\tTuvalu = 'tv',\r\n\tUSVirginIslands = 'vi',\r\n\tUganda = 'ug',\r\n\tUkraine = 'ua',\r\n\tUnitedArabEmirates = 'ae',\r\n\tUnitedKingdom = 'gb',\r\n\tUnitedStates = 'us',\r\n\tUruguay = 'uy',\r\n\tUzbekistan = 'uz',\r\n\tVanuatu = 'vu',\r\n\tVaticanCity = 'va',\r\n\tVenezuela = 've',\r\n\tVietnam = 'vn',\r\n\tWallisAndFutuna = 'wf',\r\n\tWesternSahara = 'eh',\r\n\tYemen = 'ye',\r\n\tZambia = 'zm',\r\n\tZimbabwe = 'zw',\r\n\tÅlandIslands = 'ax',\r\n}\r\n","import { CountryISO } from '../model/country-iso.enum';\r\n\r\nexport const ALL_COUNTRIES = [\r\n [\r\n 'Afghanistan (‫افغانستان‬‎)',\r\n CountryISO.Afghanistan,\r\n '93'\r\n ],\r\n [\r\n 'Albania (Shqipëri)',\r\n CountryISO.Albania,\r\n '355'\r\n ],\r\n [\r\n 'Algeria (‫الجزائر‬‎)',\r\n CountryISO.Algeria,\r\n '213'\r\n ],\r\n [\r\n 'American Samoa',\r\n 'as',\r\n '1',\r\n 1,\r\n [\r\n '684',\r\n ]\r\n ],\r\n [\r\n 'Andorra',\r\n CountryISO.Andorra,\r\n '376'\r\n ],\r\n [\r\n 'Angola',\r\n CountryISO.Angola,\r\n '244'\r\n ],\r\n [\r\n 'Anguilla',\r\n 'ai',\r\n '1',\r\n 1,\r\n [\r\n '264',\r\n ]\r\n ],\r\n [\r\n 'Antigua and Barbuda',\r\n 'ag',\r\n '1',\r\n 1,\r\n [\r\n '268',\r\n ]\r\n ],\r\n [\r\n 'Argentina',\r\n CountryISO.Argentina,\r\n '54'\r\n ],\r\n [\r\n 'Armenia (Հայաստան)',\r\n CountryISO.Armenia,\r\n '374'\r\n ],\r\n [\r\n 'Aruba',\r\n CountryISO.Aruba,\r\n '297'\r\n ],\r\n [\r\n 'Australia',\r\n CountryISO.Australia,\r\n '61',\r\n 0\r\n ],\r\n [\r\n 'Austria (Österreich)',\r\n CountryISO.Austria,\r\n '43'\r\n ],\r\n [\r\n 'Azerbaijan (Azərbaycan)',\r\n CountryISO.Azerbaijan,\r\n '994'\r\n ],\r\n [\r\n 'Bahamas',\r\n 'bs',\r\n '1',\r\n 1,\r\n [\r\n '242',\r\n ]\r\n ],\r\n [\r\n 'Bahrain (‫البحرين‬‎)',\r\n CountryISO.Bahrain,\r\n '973'\r\n ],\r\n [\r\n 'Bangladesh (বাংলাদেশ)',\r\n CountryISO.Bangladesh,\r\n '880'\r\n ],\r\n [\r\n 'Barbados',\r\n 'bb',\r\n '1',\r\n 1,\r\n [\r\n '246',\r\n ]\r\n ],\r\n [\r\n 'Belarus (Беларусь)',\r\n CountryISO.Belarus,\r\n '375'\r\n ],\r\n [\r\n 'Belgium (België)',\r\n CountryISO.Belgium,\r\n '32'\r\n ],\r\n [\r\n 'Belize',\r\n CountryISO.Belize,\r\n '501'\r\n ],\r\n [\r\n 'Benin (Bénin)',\r\n CountryISO.Benin,\r\n '229'\r\n ],\r\n [\r\n 'Bermuda',\r\n 'bm',\r\n '1',\r\n 1,\r\n [\r\n '441',\r\n ]\r\n ],\r\n [\r\n 'Bhutan (འབྲུག)',\r\n CountryISO.Bhutan,\r\n '975'\r\n ],\r\n [\r\n 'Bolivia',\r\n CountryISO.Bolivia,\r\n '591'\r\n ],\r\n [\r\n 'Bosnia and Herzegovina (Босна и Херцеговина)',\r\n CountryISO.BosniaAndHerzegovina,\r\n '387'\r\n ],\r\n [\r\n 'Botswana',\r\n CountryISO.Botswana,\r\n '267'\r\n ],\r\n [\r\n 'Brazil (Brasil)',\r\n CountryISO.Brazil,\r\n '55'\r\n ],\r\n [\r\n 'British Indian Ocean Territory',\r\n CountryISO.BritishIndianOceanTerritory,\r\n '246'\r\n ],\r\n [\r\n 'British Virgin Islands',\r\n 'vg',\r\n '1',\r\n 1,\r\n [\r\n '284',\r\n ]\r\n ],\r\n [\r\n 'Brunei',\r\n CountryISO.Brunei,\r\n '673'\r\n ],\r\n [\r\n 'Bulgaria (България)',\r\n CountryISO.Bulgaria,\r\n '359'\r\n ],\r\n [\r\n 'Burkina Faso',\r\n CountryISO.BurkinaFaso,\r\n '226'\r\n ],\r\n [\r\n 'Burundi (Uburundi)',\r\n CountryISO.Burundi,\r\n '257'\r\n ],\r\n [\r\n 'Cambodia (កម្ពុជា)',\r\n CountryISO.Cambodia,\r\n '855'\r\n ],\r\n [\r\n 'Cameroon (Cameroun)',\r\n CountryISO.Cameroon,\r\n '237'\r\n ],\r\n [\r\n 'Canada',\r\n CountryISO.Canada,\r\n '1',\r\n 1,\r\n [\r\n '204', '226', '236', '249', '250', '289', '306', '343', '365', '387', '403', '416',\r\n '418', '431', '437', '438', '450', '506', '514', '519', '548', '579', '581', '587',\r\n '604', '613', '639', '647', '672', '705', '709', '742', '778', '780', '782', '807',\r\n '819', '825', '867', '873', '902', '905'\r\n ]\r\n ],\r\n [\r\n 'Cape Verde (Kabu Verdi)',\r\n CountryISO.CapeVerde,\r\n '238'\r\n ],\r\n [\r\n 'Caribbean Netherlands',\r\n CountryISO.CaribbeanNetherlands,\r\n '599',\r\n 1\r\n ],\r\n [\r\n 'Cayman Islands',\r\n 'ky',\r\n '1',\r\n 1,\r\n [\r\n '345',\r\n ]\r\n ],\r\n [\r\n 'Central African Republic (République centrafricaine)',\r\n CountryISO.CentralAfricanRepublic,\r\n '236'\r\n ],\r\n [\r\n 'Chad (Tchad)',\r\n CountryISO.Chad,\r\n '235'\r\n ],\r\n [\r\n 'Chile',\r\n CountryISO.Chile,\r\n '56'\r\n ],\r\n [\r\n 'China (中国)',\r\n CountryISO.China,\r\n '86'\r\n ],\r\n [\r\n 'Christmas Island',\r\n CountryISO.ChristmasIsland,\r\n '61',\r\n 2\r\n ],\r\n [\r\n 'Cocos (Keeling) Islands',\r\n CountryISO.Cocos,\r\n '61',\r\n 1\r\n ],\r\n [\r\n 'Colombia',\r\n CountryISO.Colombia,\r\n '57'\r\n ],\r\n [\r\n 'Comoros (‫جزر القمر‬‎)',\r\n CountryISO.Comoros,\r\n '269'\r\n ],\r\n [\r\n 'Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)',\r\n CountryISO.CongoDRCJamhuriYaKidemokrasiaYaKongo,\r\n '243'\r\n ],\r\n [\r\n 'Congo (Republic) (Congo-Brazzaville)',\r\n CountryISO.CongoRepublicCongoBrazzaville,\r\n '242'\r\n ],\r\n [\r\n 'Cook Islands',\r\n CountryISO.CookIslands,\r\n '682'\r\n ],\r\n [\r\n 'Costa Rica',\r\n CountryISO.CostaRica,\r\n '506'\r\n ],\r\n [\r\n 'Côte d’Ivoire',\r\n CountryISO.CôteDIvoire,\r\n '225'\r\n ],\r\n [\r\n 'Croatia (Hrvatska)',\r\n CountryISO.Croatia,\r\n '385'\r\n ],\r\n [\r\n 'Cuba',\r\n CountryISO.Cuba,\r\n '53'\r\n ],\r\n [\r\n 'Curaçao',\r\n CountryISO.Curaçao,\r\n '599',\r\n 0\r\n ],\r\n [\r\n 'Cyprus (Κύπρος)',\r\n CountryISO.Cyprus,\r\n '357'\r\n ],\r\n [\r\n 'Czech Republic (Česká republika)',\r\n CountryISO.CzechRepublic,\r\n '420'\r\n ],\r\n [\r\n 'Denmark (Danmark)',\r\n CountryISO.Denmark,\r\n '45'\r\n ],\r\n [\r\n 'Djibouti',\r\n CountryISO.Djibouti,\r\n '253'\r\n ],\r\n [\r\n 'Dominica',\r\n CountryISO.Dominica,\r\n '1767'\r\n ],\r\n [\r\n 'Dominican Republic (República Dominicana)',\r\n CountryISO.DominicanRepublic,\r\n '1',\r\n 2,\r\n [ '809', '829', '849' ]\r\n ],\r\n [\r\n 'Ecuador',\r\n CountryISO.Ecuador,\r\n '593'\r\n ],\r\n [\r\n 'Egypt (‫مصر‬‎)',\r\n CountryISO.Egypt,\r\n '20'\r\n ],\r\n [\r\n 'El Salvador',\r\n CountryISO.ElSalvador,\r\n '503'\r\n ],\r\n [\r\n 'Equatorial Guinea (Guinea Ecuatorial)',\r\n CountryISO.EquatorialGuinea,\r\n '240'\r\n ],\r\n [\r\n 'Eritrea',\r\n CountryISO.Eritrea,\r\n '291'\r\n ],\r\n [\r\n 'Estonia (Eesti)',\r\n CountryISO.Estonia,\r\n '372'\r\n ],\r\n [\r\n 'Ethiopia',\r\n CountryISO.Ethiopia,\r\n '251'\r\n ],\r\n [\r\n 'Falkland Islands (Islas Malvinas)',\r\n CountryISO.FalklandIslands,\r\n '500'\r\n ],\r\n [\r\n 'Faroe Islands (Føroyar)',\r\n CountryISO.FaroeIslands,\r\n '298'\r\n ],\r\n [\r\n 'Fiji',\r\n CountryISO.Fiji,\r\n '679'\r\n ],\r\n [\r\n 'Finland (Suomi)',\r\n CountryISO.Finland,\r\n '358',\r\n 0\r\n ],\r\n [\r\n 'France',\r\n CountryISO.France,\r\n '33'\r\n ],\r\n [\r\n 'French Guiana (Guyane française)',\r\n CountryISO.FrenchGuiana,\r\n '594'\r\n ],\r\n [\r\n 'French Polynesia (Polynésie française)',\r\n CountryISO.FrenchPolynesia,\r\n '689'\r\n ],\r\n [\r\n 'Gabon',\r\n CountryISO.Gabon,\r\n '241'\r\n ],\r\n [\r\n 'Gambia',\r\n CountryISO.Gambia,\r\n '220'\r\n ],\r\n [\r\n 'Georgia (საქართველო)',\r\n CountryISO.Georgia,\r\n '995'\r\n ],\r\n [\r\n 'Germany (Deutschland)',\r\n CountryISO.Germany,\r\n '49'\r\n ],\r\n [\r\n 'Ghana (Gaana)',\r\n CountryISO.Ghana,\r\n '233'\r\n ],\r\n [\r\n 'Gibraltar',\r\n CountryISO.Gibraltar,\r\n '350'\r\n ],\r\n [\r\n 'Greece (Ελλάδα)',\r\n CountryISO.Greece,\r\n '30'\r\n ],\r\n [\r\n 'Greenland (Kalaallit Nunaat)',\r\n CountryISO.Greenland,\r\n '299'\r\n ],\r\n [\r\n 'Grenada',\r\n CountryISO.Grenada,\r\n '1473'\r\n ],\r\n [\r\n 'Guadeloupe',\r\n CountryISO.Guadeloupe,\r\n '590',\r\n 0\r\n ],\r\n [\r\n 'Guam',\r\n 'gu',\r\n '1',\r\n 1,\r\n [\r\n '671',\r\n ]\r\n ],\r\n [\r\n 'Guatemala',\r\n CountryISO.Guatemala,\r\n '502'\r\n ],\r\n [\r\n 'Guernsey',\r\n CountryISO.Guernsey,\r\n '44',\r\n 1,\r\n [ 1481 ]\r\n ],\r\n [\r\n 'Guinea (Guinée)',\r\n CountryISO.Guinea,\r\n '224'\r\n ],\r\n [\r\n 'Guinea-Bissau (Guiné Bissau)',\r\n CountryISO.GuineaBissau,\r\n '245'\r\n ],\r\n [\r\n 'Guyana',\r\n CountryISO.Guyana,\r\n '592'\r\n ],\r\n [\r\n 'Haiti',\r\n CountryISO.Haiti,\r\n '509'\r\n ],\r\n [\r\n 'Honduras',\r\n CountryISO.Honduras,\r\n '504'\r\n ],\r\n [\r\n 'Hong Kong (香港)',\r\n CountryISO.HongKong,\r\n '852'\r\n ],\r\n [\r\n 'Hungary (Magyarország)',\r\n CountryISO.Hungary,\r\n '36'\r\n ],\r\n [\r\n 'Iceland (Ísland)',\r\n CountryISO.Iceland,\r\n '354'\r\n ],\r\n [\r\n 'India (भारत)',\r\n CountryISO.India,\r\n '91'\r\n ],\r\n [\r\n 'Indonesia',\r\n CountryISO.Indonesia,\r\n '62'\r\n ],\r\n [\r\n 'Iran (‫ایران‬‎)',\r\n CountryISO.Iran,\r\n '98'\r\n ],\r\n [\r\n 'Iraq (‫العراق‬‎)',\r\n CountryISO.Iraq,\r\n '964'\r\n ],\r\n [\r\n 'Ireland',\r\n CountryISO.Ireland,\r\n '353'\r\n ],\r\n [\r\n 'Isle of Man',\r\n CountryISO.IsleOfMan,\r\n '44',\r\n 2,\r\n [ 1624 ]\r\n ],\r\n [\r\n 'Israel (‫ישראל‬‎)',\r\n CountryISO.Israel,\r\n '972'\r\n ],\r\n [\r\n 'Italy (Italia)',\r\n CountryISO.Italy,\r\n '39',\r\n 0\r\n ],\r\n [\r\n 'Jamaica',\r\n 'jm',\r\n '1',\r\n 1,\r\n [\r\n '876',\r\n ]\r\n ],\r\n [\r\n 'Japan (日本)',\r\n CountryISO.Japan,\r\n '81'\r\n ],\r\n [\r\n 'Jersey',\r\n CountryISO.Jersey,\r\n '44',\r\n 3,\r\n [ 1534 ]\r\n ],\r\n [\r\n 'Jordan (‫الأردن‬‎)',\r\n CountryISO.Jordan,\r\n '962'\r\n ],\r\n [\r\n 'Kazakhstan (Казахстан)',\r\n CountryISO.Kazakhstan,\r\n '7',\r\n 1\r\n ],\r\n [\r\n 'Kenya',\r\n CountryISO.Kenya,\r\n '254'\r\n ],\r\n [\r\n 'Kiribati',\r\n CountryISO.Kiribati,\r\n '686'\r\n ],\r\n [\r\n 'Kosovo',\r\n CountryISO.Kosovo,\r\n '383'\r\n ],\r\n [\r\n 'Kuwait (‫الكويت‬‎)',\r\n CountryISO.Kuwait,\r\n '965'\r\n ],\r\n [\r\n 'Kyrgyzstan (Кыргызстан)',\r\n CountryISO.Kyrgyzstan,\r\n '996'\r\n ],\r\n [\r\n 'Laos (ລາວ)',\r\n CountryISO.Laos,\r\n '856'\r\n ],\r\n [\r\n 'Latvia (Latvija)',\r\n CountryISO.Latvia,\r\n '371'\r\n ],\r\n [\r\n 'Lebanon (‫لبنان‬‎)',\r\n CountryISO.Lebanon,\r\n '961'\r\n ],\r\n [\r\n 'Lesotho',\r\n CountryISO.Lesotho,\r\n '266'\r\n ],\r\n [\r\n 'Liberia',\r\n CountryISO.Liberia,\r\n '231'\r\n ],\r\n [\r\n 'Libya (‫ليبيا‬‎)',\r\n CountryISO.Libya,\r\n '218'\r\n ],\r\n [\r\n 'Liechtenstein',\r\n CountryISO.Liechtenstein,\r\n '423'\r\n ],\r\n [\r\n 'Lithuania (Lietuva)',\r\n CountryISO.Lithuania,\r\n '370'\r\n ],\r\n [\r\n 'Luxembourg',\r\n CountryISO.Luxembourg,\r\n '352'\r\n ],\r\n [\r\n 'Macau (澳門)',\r\n CountryISO.Macau,\r\n '853'\r\n ],\r\n [\r\n 'Macedonia (FYROM) (Македонија)',\r\n CountryISO.Macedonia,\r\n '389'\r\n ],\r\n [\r\n 'Madagascar (Madagasikara)',\r\n CountryISO.Madagascar,\r\n '261'\r\n ],\r\n [\r\n 'Malawi',\r\n CountryISO.Malawi,\r\n '265'\r\n ],\r\n [\r\n 'Malaysia',\r\n CountryISO.Malaysia,\r\n '60'\r\n ],\r\n [\r\n 'Maldives',\r\n CountryISO.Maldives,\r\n '960'\r\n ],\r\n [\r\n 'Mali',\r\n CountryISO.Mali,\r\n '223'\r\n ],\r\n [\r\n 'Malta',\r\n CountryISO.Malta,\r\n '356'\r\n ],\r\n [\r\n 'Marshall Islands',\r\n CountryISO.MarshallIslands,\r\n '692'\r\n ],\r\n [\r\n 'Martinique',\r\n CountryISO.Martinique,\r\n '596'\r\n ],\r\n [\r\n 'Mauritania (‫موريتانيا‬‎)',\r\n CountryISO.Mauritania,\r\n '222'\r\n ],\r\n [\r\n 'Mauritius (Moris)',\r\n CountryISO.Mauritius,\r\n '230'\r\n ],\r\n [\r\n 'Mayotte',\r\n CountryISO.Mayotte,\r\n '262',\r\n 1\r\n ],\r\n [\r\n 'Mexico (México)',\r\n CountryISO.Mexico,\r\n '52'\r\n ],\r\n [\r\n 'Micronesia',\r\n CountryISO.Micronesia,\r\n '691'\r\n ],\r\n [\r\n 'Moldova (Republica Moldova)',\r\n CountryISO.Moldova,\r\n '373'\r\n ],\r\n [\r\n 'Monaco',\r\n CountryISO.Monaco,\r\n '377'\r\n ],\r\n [\r\n 'Mongolia (Монгол)',\r\n CountryISO.Mongolia,\r\n '976'\r\n ],\r\n [\r\n 'Montenegro (Crna Gora)',\r\n CountryISO.Montenegro,\r\n '382'\r\n ],\r\n [\r\n 'Montserrat',\r\n 'ms',\r\n '1',\r\n 1,\r\n [\r\n '664',\r\n ]\r\n ],\r\n [\r\n 'Morocco (‫المغرب‬‎)',\r\n CountryISO.Morocco,\r\n '212',\r\n 0\r\n ],\r\n [\r\n 'Mozambique (Moçambique)',\r\n CountryISO.Mozambique,\r\n '258'\r\n ],\r\n [\r\n 'Myanmar (Burma) (မြန်မာ)',\r\n CountryISO.Myanmar,\r\n '95'\r\n ],\r\n [\r\n 'Namibia (Namibië)',\r\n CountryISO.Namibia,\r\n '264'\r\n ],\r\n [\r\n 'Nauru',\r\n CountryISO.Nauru,\r\n '674'\r\n ],\r\n [\r\n 'Nepal (नेपाल)',\r\n CountryISO.Nepal,\r\n '977'\r\n ],\r\n [\r\n 'Netherlands (Nederland)',\r\n CountryISO.Netherlands,\r\n '31'\r\n ],\r\n [\r\n 'New Caledonia (Nouvelle-Calédonie)',\r\n CountryISO.NewCaledonia,\r\n '687'\r\n ],\r\n [\r\n 'New Zealand',\r\n CountryISO.NewZealand,\r\n '64'\r\n ],\r\n [\r\n 'Nicaragua',\r\n CountryISO.Nicaragua,\r\n '505'\r\n ],\r\n [\r\n 'Niger (Nijar)',\r\n CountryISO.Niger,\r\n '227'\r\n ],\r\n [\r\n 'Nigeria',\r\n CountryISO.Nigeria,\r\n '234'\r\n ],\r\n [\r\n 'Niue',\r\n CountryISO.Niue,\r\n '683'\r\n ],\r\n [\r\n 'Norfolk Island',\r\n CountryISO.NorfolkIsland,\r\n '672'\r\n ],\r\n [\r\n 'North Korea (조선 민주주의 인민 공화국)',\r\n CountryISO.NorthKorea,\r\n '850'\r\n ],\r\n [\r\n 'Northern Mariana Islands',\r\n CountryISO.NorthernMarianaIslands,\r\n '1670'\r\n ],\r\n [\r\n 'Norway (Norge)',\r\n CountryISO.Norway,\r\n '47',\r\n 0\r\n ],\r\n [\r\n 'Oman (‫عُمان‬‎)',\r\n CountryISO.Oman,\r\n '968'\r\n ],\r\n [\r\n 'Pakistan (‫پاکستان‬‎)',\r\n CountryISO.Pakistan,\r\n '92'\r\n ],\r\n [\r\n 'Palau',\r\n CountryISO.Palau,\r\n '680'\r\n ],\r\n [\r\n 'Palestine (‫فلسطين‬‎)',\r\n CountryISO.Palestine,\r\n '970'\r\n ],\r\n [\r\n 'Panama (Panamá)',\r\n CountryISO.Panama,\r\n '507'\r\n ],\r\n [\r\n 'Papua New Guinea',\r\n CountryISO.PapuaNewGuinea,\r\n '675'\r\n ],\r\n [\r\n 'Paraguay',\r\n CountryISO.Paraguay,\r\n '595'\r\n ],\r\n [\r\n 'Peru (Perú)',\r\n CountryISO.Peru,\r\n '51'\r\n ],\r\n [\r\n 'Philippines',\r\n CountryISO.Philippines,\r\n '63'\r\n ],\r\n [\r\n 'Poland (Polska)',\r\n CountryISO.Poland,\r\n '48'\r\n ],\r\n [\r\n 'Portugal',\r\n CountryISO.Portugal,\r\n '351'\r\n ],\r\n [\r\n 'Puerto Rico',\r\n CountryISO.PuertoRico,\r\n '1',\r\n 3,\r\n [ '787', '939' ]\r\n ],\r\n [\r\n 'Qatar (‫قطر‬‎)',\r\n CountryISO.Qatar,\r\n '974'\r\n ],\r\n [\r\n 'Réunion (La Réunion)',\r\n CountryISO.Réunion,\r\n '262',\r\n 0\r\n ],\r\n [\r\n 'Romania (România)',\r\n CountryISO.Romania,\r\n '40'\r\n ],\r\n [\r\n 'Russia (Россия)',\r\n CountryISO.Russia,\r\n '7',\r\n 0\r\n ],\r\n [\r\n 'Rwanda',\r\n CountryISO.Rwanda,\r\n '250'\r\n ],\r\n [\r\n 'Saint Barthélemy (Saint-Barthélemy)',\r\n CountryISO.SaintBarthélemy,\r\n '590',\r\n 1\r\n ],\r\n [\r\n 'Saint Helena',\r\n CountryISO.SaintHelena,\r\n '290'\r\n ],\r\n [\r\n 'Saint Kitts and Nevis',\r\n CountryISO.SaintKittsAndNevis,\r\n '1869'\r\n ],\r\n [\r\n 'Saint Lucia',\r\n 'lc',\r\n '1',\r\n 1,\r\n [\r\n '758',\r\n ]\r\n ],\r\n [\r\n 'Saint Martin (Saint-Martin (partie française))',\r\n CountryISO.SaintMartin,\r\n '590',\r\n 2\r\n ],\r\n [\r\n 'Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)',\r\n CountryISO.SaintPierreAndMiquelon,\r\n '508'\r\n ],\r\n [\r\n 'Saint Vincent and the Grenadines',\r\n 'vc',\r\n '1',\r\n 1,\r\n [\r\n '784',\r\n ]\r\n ],\r\n [\r\n 'Samoa',\r\n CountryISO.Samoa,\r\n '685'\r\n ],\r\n [\r\n 'San Marino',\r\n CountryISO.SanMarino,\r\n '378'\r\n ],\r\n [\r\n 'São Tomé and Príncipe (São Tomé e Príncipe)',\r\n CountryISO.SãoToméAndPríncipe,\r\n '239'\r\n ],\r\n [\r\n 'Saudi Arabia (‫المملكة العربية السعودية‬‎)',\r\n CountryISO.SaudiArabia,\r\n '966'\r\n ],\r\n [\r\n 'Senegal (Sénégal)',\r\n CountryISO.Senegal,\r\n '221'\r\n ],\r\n [\r\n 'Serbia (Србија)',\r\n CountryISO.Serbia,\r\n '381'\r\n ],\r\n [\r\n 'Seychelles',\r\n CountryISO.Seychelles,\r\n '248'\r\n ],\r\n [\r\n 'Sierra Leone',\r\n CountryISO.SierraLeone,\r\n '232'\r\n ],\r\n [\r\n 'Singapore',\r\n CountryISO.Singapore,\r\n '65'\r\n ],\r\n [\r\n 'Sint Maarten',\r\n 'sx',\r\n '1',\r\n 1,\r\n [\r\n '721',\r\n ]\r\n ],\r\n [\r\n 'Slovakia (Slovensko)',\r\n CountryISO.Slovakia,\r\n '421'\r\n ],\r\n [\r\n 'Slovenia (Slovenija)',\r\n CountryISO.Slovenia,\r\n '386'\r\n ],\r\n [\r\n 'Solomon Islands',\r\n CountryISO.SolomonIslands,\r\n '677'\r\n ],\r\n [\r\n 'Somalia (Soomaaliya)',\r\n CountryISO.Somalia,\r\n '252'\r\n ],\r\n [\r\n 'South Africa',\r\n CountryISO.SouthAfrica,\r\n '27'\r\n ],\r\n [\r\n 'South Korea (대한민국)',\r\n CountryISO.SouthKorea,\r\n '82'\r\n ],\r\n [\r\n 'South Sudan (‫جنوب السودان‬‎)',\r\n CountryISO.SouthSudan,\r\n '211'\r\n ],\r\n [\r\n 'Spain (España)',\r\n CountryISO.Spain,\r\n '34'\r\n ],\r\n [\r\n 'Sri Lanka (ශ්‍රී ලංකාව)',\r\n CountryISO.SriLanka,\r\n '94'\r\n ],\r\n [\r\n 'Sudan (‫السودان‬‎)',\r\n CountryISO.Sudan,\r\n '249'\r\n ],\r\n [\r\n 'Suriname',\r\n CountryISO.Suriname,\r\n '597'\r\n ],\r\n [\r\n 'Svalbard and Jan Mayen',\r\n CountryISO.SvalbardAndJanMayen,\r\n '47',\r\n 1\r\n ],\r\n [\r\n 'Swaziland',\r\n CountryISO.Swaziland,\r\n '268'\r\n ],\r\n [\r\n 'Sweden (Sverige)',\r\n CountryISO.Sweden,\r\n '46'\r\n ],\r\n [\r\n 'Switzerland (Schweiz)',\r\n CountryISO.Switzerland,\r\n '41'\r\n ],\r\n [\r\n 'Syria (‫سوريا‬‎)',\r\n CountryISO.Syria,\r\n '963'\r\n ],\r\n [\r\n 'Taiwan (台灣)',\r\n CountryISO.Taiwan,\r\n '886'\r\n ],\r\n [\r\n 'Tajikistan',\r\n CountryISO.Tajikistan,\r\n '992'\r\n ],\r\n [\r\n 'Tanzania',\r\n CountryISO.Tanzania,\r\n '255'\r\n ],\r\n [\r\n 'Thailand (ไทย)',\r\n CountryISO.Thailand,\r\n '66'\r\n ],\r\n [\r\n 'Timor-Leste',\r\n CountryISO.TimorLeste,\r\n '670'\r\n ],\r\n [\r\n 'Togo',\r\n CountryISO.Togo,\r\n '228'\r\n ],\r\n [\r\n 'Tokelau',\r\n CountryISO.Tokelau,\r\n '690'\r\n ],\r\n [\r\n 'Tonga',\r\n CountryISO.Tonga,\r\n '676'\r\n ],\r\n [\r\n 'Trinidad and Tobago',\r\n 'tt',\r\n '1',\r\n 1,\r\n [\r\n '868',\r\n ]\r\n ],\r\n [\r\n 'Tunisia (‫تونس‬‎)',\r\n CountryISO.Tunisia,\r\n '216'\r\n ],\r\n [\r\n 'Turkey (Türkiye)',\r\n CountryISO.Turkey,\r\n '90'\r\n ],\r\n [\r\n 'Turkmenistan',\r\n CountryISO.Turkmenistan,\r\n '993'\r\n ],\r\n [\r\n 'Turks and Caicos Islands',\r\n CountryISO.TurksAndCaicosIslands,\r\n '1649'\r\n ],\r\n [\r\n 'Tuvalu',\r\n CountryISO.Tuvalu,\r\n '688'\r\n ],\r\n [\r\n 'U.S. Virgin Islands',\r\n 'vi',\r\n '1',\r\n 1,\r\n [\r\n '340',\r\n ]\r\n ],\r\n [\r\n 'Uganda',\r\n CountryISO.Uganda,\r\n '256'\r\n ],\r\n [\r\n 'Ukraine (Україна)',\r\n CountryISO.Ukraine,\r\n '380'\r\n ],\r\n [\r\n 'United Arab Emirates (‫الإمارات العربية المتحدة‬‎)',\r\n CountryISO.UnitedArabEmirates,\r\n '971'\r\n ],\r\n [\r\n 'United Kingdom',\r\n CountryISO.UnitedKingdom,\r\n '44',\r\n 0\r\n ],\r\n [\r\n 'United States',\r\n CountryISO.UnitedStates,\r\n '1',\r\n 0\r\n ],\r\n [\r\n 'Uruguay',\r\n CountryISO.Uruguay,\r\n '598'\r\n ],\r\n [\r\n 'Uzbekistan (Oʻzbekiston)',\r\n CountryISO.Uzbekistan,\r\n '998'\r\n ],\r\n [\r\n 'Vanuatu',\r\n CountryISO.Vanuatu,\r\n '678'\r\n ],\r\n [\r\n 'Vatican City (Città del Vaticano)',\r\n CountryISO.VaticanCity,\r\n '39',\r\n 1\r\n ],\r\n [\r\n 'Venezuela',\r\n CountryISO.Venezuela,\r\n '58'\r\n ],\r\n [\r\n 'Vietnam (Việt Nam)',\r\n CountryISO.Vietnam,\r\n '84'\r\n ],\r\n [\r\n 'Wallis and Futuna',\r\n CountryISO.WallisAndFutuna,\r\n '681'\r\n ],\r\n [\r\n 'Western Sahara (‫الصحراء الغربية‬‎)',\r\n CountryISO.WesternSahara,\r\n '212',\r\n 1\r\n ],\r\n [\r\n 'Yemen (‫اليمن‬‎)',\r\n CountryISO.Yemen,\r\n '967'\r\n ],\r\n [\r\n 'Zambia',\r\n CountryISO.Zambia,\r\n '260'\r\n ],\r\n [\r\n 'Zimbabwe',\r\n CountryISO.Zimbabwe,\r\n '263'\r\n ],\r\n [\r\n 'Åland Islands',\r\n CountryISO.ÅlandIslands,\r\n '358',\r\n 1\r\n ]\r\n];\r\n","import * as lpn from \"google-libphonenumber\";\r\nimport { PhoneNumber, PhoneNumberFormat, PhoneNumberUtil } from \"google-libphonenumber\";\r\nimport { ChangeData } from \"../model/change-data\";\r\nimport { ALL_COUNTRIES } from \"../data/country-code\";\r\n\r\nexport class LocalPhoneUtils {\r\n /**\r\n * Returns parse PhoneNumber object.\r\n * @param phoneNumber string\r\n * @param regionCode string\r\n */\r\n public static getParsedNumber(phoneNumber: string = '', regionCode: string = ''): PhoneNumber {\r\n if( !phoneNumber || !regionCode ) return new PhoneNumber();\r\n try {\r\n return lpn.PhoneNumberUtil.getInstance().parse(phoneNumber, regionCode.toUpperCase());\r\n } catch (e) {\r\n return new PhoneNumber()\r\n }\r\n }\r\n\r\n /**\r\n * Return a ChangeData object initialized with a phone number\r\n * @param phoneNumber\r\n */\r\n public static getChangeData(phoneNumber?: string): ChangeData {\r\n return new ChangeData(!phoneNumber ? new PhoneNumber() : lpn.PhoneNumberUtil.getInstance().parse(phoneNumber));\r\n }\r\n\r\n\r\n /**\r\n * Gets formatted example phone number from phoneUtil.\r\n * @param numberFormat\r\n * @param countryCode\r\n */\r\n public static getPhoneNumberPlaceHolder(numberFormat: PhoneNumberFormat, countryCode: string): string {\r\n const phoneUtil: PhoneNumberUtil = lpn.PhoneNumberUtil.getInstance();\r\n return phoneUtil.format(phoneUtil.getExampleNumber(countryCode), numberFormat);\r\n }\r\n\r\n /**\r\n * Sifts through all countries and returns iso code of the primary country\r\n * based on the number provided.\r\n * @param number PhoneNumber\r\n * @param countryCode country code in number format\r\n */\r\n public static getCountryIsoCode(number: PhoneNumber, countryCode?: number): string | undefined {\r\n if( !countryCode ) return;\r\n // Will use this to match area code from the first numbers\r\n // @ts-ignore\r\n const rawNumber = number['values_']['2'].toString();\r\n // List of all countries with countryCode (can be more than one. e.x. US, CA, DO, PR all have +1 countryCode)\r\n const countriesFiltered = ALL_COUNTRIES.filter((c) => c[2].toString() === countryCode.toString());\r\n // Main country is the country, which has no areaCodes specified in country-code.ts file.\r\n const mainCountry = countriesFiltered.find((c) => c[4] === undefined);\r\n // Secondary countries are all countries, which have areaCodes specified in country-code.ts file.\r\n const secondaryCountries = countriesFiltered.filter((c) => c[4] !== undefined);\r\n let matchedCountry = mainCountry ? mainCountry[1].toString() : undefined;\r\n\r\n /*\r\n Iterate over each secondary country and check if nationalNumber starts with any of areaCodes available.\r\n If no matches found, fallback to the main country.\r\n */\r\n secondaryCountries.forEach((country) => {\r\n // @ts-ignore\r\n country[4].forEach((areaCode) => {\r\n if( rawNumber.startsWith(areaCode) ) matchedCountry = country[1].toString();\r\n });\r\n });\r\n\r\n return matchedCountry;\r\n }\r\n}\r\n","import * as lpn from 'google-libphonenumber';\r\nimport { AbstractControl } from '@angular/forms';\r\n\r\n/**\r\n * Check if the phone number provide is in a valid format compare to the country selected\r\n * If not, an error is pushed to the FormControl: { invalidFormat: true }\r\n * It can be catched in the parent form to display a user error\r\n * @param control\r\n */\r\nexport const phoneNumberValidator = (control: AbstractControl) => {\r\n const value = control.value;\r\n if (!value) return null;\r\n\r\n try {\r\n const phoneUtil: lpn.PhoneNumberUtil = lpn.PhoneNumberUtil.getInstance();\r\n const phoneNumber: lpn.PhoneNumber = phoneUtil.parse(value);\r\n const regionCode = phoneUtil.getRegionCodeForNumber(phoneNumber);\r\n\r\n if (!phoneUtil.isValidNumberForRegion(phoneNumber, regionCode)) {\r\n return { invalidFormat: true };\r\n }\r\n } catch (error) {\r\n return { invalidFormat: true };\r\n }\r\n\r\n return null;\r\n};\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n name: 'dialCode',\r\n standalone: true\r\n})\r\nexport class DialCodePipe implements PipeTransform {\r\n transform(dialoCode: string): string {\r\n if (!dialoCode) return '';\r\n return `+${ dialoCode }`;\r\n }\r\n}\r\n","import { Directive, ElementRef, inject, input, OnInit, Renderer2 } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[favorite]',\r\n standalone: true\r\n})\r\nexport class FavoriteElementInjectorDirective implements OnInit {\r\n private el = inject(ElementRef);\r\n private renderer = inject(Renderer2);\r\n\r\n favoriteItemsCounter = input<number>();\r\n\r\n ngOnInit() {\r\n const allFavorites = document.querySelectorAll('.favorite');\r\n if (allFavorites[allFavorites.length - 1] === this.el.nativeElement && allFavorites.length === this.favoriteItemsCounter()) {\r\n this.renderer.addClass(this.el.nativeElement, 'last-favorite-option');\r\n }\r\n }\r\n}\r\n","import * as lpn from 'google-libphonenumber';\nimport { PhoneNumber, PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';\n\nimport {\n Component,\n computed,\n forwardRef,\n input,\n InputSignal,\n OnChanges,\n output,\n OutputEmitterRef,\n Signal,\n signal,\n SimpleChange,\n SimpleChanges,\n WritableSignal,\n} from '@angular/core';\nimport { FormControl, FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';\n\nimport { CountryISO } from '../model/country-iso.enum';\nimport { SearchCountryField } from '../model/search-country-field';\nimport { Country } from '../model/country.model';\nimport { BehaviorSubject } from 'rxjs';\nimport { LocalPhoneUtils } from \"../utils/local-phone-utils\";\nimport { ChangeData } from \"../model/change-data\";\nimport { ALL_COUNTRIES } from \"../data/country-code\";\nimport { phoneNumberValidator } from \"../validator/p-intl-input-tel.validator\";\nimport { DialCodePipe } from '../pipe/dialCode.pipe';\nimport { InputTextModule } from 'primeng/inputtext';\nimport { FavoriteElementInjectorDirective } from '../directives/favorite-element-injector.directive';\nimport { InputGroupModule } from 'primeng/inputgroup';\nimport { InputGroupAddonModule } from 'primeng/inputgroupaddon';\nimport { Select } from 'primeng/select';\n\n@Component({\n selector: 'p-intl-tel-input',\n templateUrl: 'p-intl-input-tel.component.html',\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => IntlInputTelComponent),\n multi: true,\n },\n {\n provide: NG_VALIDATORS,\n useValue: phoneNumberValidator,\n multi: true,\n },\n ],\n imports: [ InputTextModule, FormsModule, ReactiveFormsModule, DialCodePipe, FavoriteElementInjectorDirective,\n InputGroupModule, InputGroupAddonModule, Select ]\n})\nexport class IntlInputTelComponent implements OnChanges {\n // Custom css classes\n cssClass: InputSignal<string> = input('');\n favoriteCountries: InputSignal<string[] | undefined> = input();\n // User option to display only some countries\n onlyCountries: InputSignal<string[] | undefined> = input();\n // If true, the country will be set automatically if the user fill the region code\n enableAutoCountrySelect: InputSignal<boolean> = input(true);\n displayPlaceholder: InputSignal<boolean> = input(true);\n customPlaceholder: InputSignal<string | undefined> = input();\n numberFormat: InputSignal<PhoneNumberFormat> = input(PhoneNumberFormat.INTERNATIONAL);\n // Flag to display or not the input search for countries\n displaySearchCountry: InputSignal<boolean> = input(true);\n // Search country property\n searchCountryField: InputSignal<SearchCountryField[]> = input<SearchCountryField[]>([ SearchCountryField.NAME ]);\n searchCountryPlaceholder: InputSignal<string> = input('Search country');\n maxLength: InputSignal<number | undefined> = input();\n // User option to select by default the first item of the list, default true\n selectFirstCountry: InputSignal<boolean> = input(true);\n // Allow or not the phone validation form\n phoneValidation: InputSignal<boolean> = input(true);\n // Customize the input id\n inputId: InputSignal<string> = input('phone');\n selectedCountryISO: InputSignal<CountryISO | undefined> = input();\n separateDialCode: InputSignal<boolean> = input(false);\n // Set the language for search and display name country\n lang: InputSignal<string> = input('fr');\n // Target element to attach the overlay\n appendTo: InputSignal<any | null> = input(null);\n // Custom css classes for the select overlay panel\n panelStyleClass: InputSignal<string> = input('');\n\n protected readonly fullPanelStyleClass: Signal<string> = computed(() => `fixWidth ${this.panelStyleClass()}`.trim())\n\n\n readonly countryChange: OutputEmitterRef<Country> = output<Country>();\n\n public readonly SearchCountryField = SearchCountryField;\n public phoneUtil: PhoneNumberUtil = lpn.PhoneNumberUtil.getInstance();\n\n public selectedCountry: WritableSignal<Country> = signal<Country>(new Country());\n public countries: Country[] = [];\n public phoneNumber$ = new BehaviorSubject<PhoneNumber>(new PhoneNumber);\n public phoneNumberControl = new FormControl('');\n\n public onTouched = () => {\n };\n\n public propagateChange = (_: string) => {\n };\n\n private get favorites(): Country[] {\n return this.countries.filter(c => c.isFavorite);\n }\n\n constructor() {\n this.phoneNumberControl.valueChanges.subscribe(value => {\n this.onPhoneNumberChange(value);\n })\n this.phoneNumber$.subscribe((phoneNumber: PhoneNumber) => {\n this.propagateChange(this.phoneUtil.format(phoneNumber, this.numberFormat()));\n });\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (this.isSelectedCountryChanged(changes['selectedCountryISO']) && !changes['selectedCountryISO'].firstChange) this.updateSelectedCountry();\n if( changes['favoriteCountries'] && !changes['favoriteCountries'].firstChange) this.onFavoriteCountriesChanged();\n }\n\n public init(): void {\n this.fetchCountryData();\n if (this.onlyCountries()?.length) this.countries = this.countries.filter((c) => this.onlyCountries()?.includes(c.iso2))\n this.updateSelectedCountry();\n }\n\n /* --------------------------------- Events management -------------------------------- */\n\n public onPhoneNumberChange(value?: any): void {\n const currentCountryCode = this.selectedCountry().iso2;\n const number = LocalPhoneUtils.getParsedNumber(value, currentCountryCode);\n\n // Auto select country based on the extension (and areaCode if needed) (e.g select Canada if number starts with +1 416)\n if (this.enableAutoCountrySelect()) {\n const countryCode = LocalPhoneUtils.getCountryIsoCode(number, number?.getCountryCode()) || currentCountryCode;\n if( countryCode && countryCode !== this.selectedCountry().iso2 ){\n const newCountry = this.countries\n .sort((a, b) => a.priority - b.priority)\n .find((c) => c.iso2 === countryCode.toUpperCase());\n if( newCountry ) this.setSelectedCountry(newCountry);\n }\n }\n\n this.phoneNumber$.next(number);\n }\n\n public onCountrySelect(country: Country, el?: { focus: () => void; }): void {\n let number: PhoneNumber = new PhoneNumber();\n if( country !== this.selectedCountry() ) this.setSelectedCountry(country);\n\n const currentValue = this.phoneNumberControl.value;\n if( currentValue ) number = LocalPhoneUtils.getParsedNumber(currentValue, this.selectedCountry().iso2)\n\n this.phoneNumber$.next(number)\n\n setTimeout(() => el?.focus(), 100)\n }\n\n private onFavoriteCountriesChanged(): void {\n this.fetchCountryData();\n this.onCountrySelect(this.selectedCountry());\n }\n\n public onInputKeyPress(event: KeyboardEvent): void {\n const allowedChars = /[0-9\\+\\-\\(\\)\\ ]/;\n const allowedCtrlChars = /[axcv]/; // Allows copy-pasting\n const allowedOtherKeys = [\n 'ArrowLeft',\n 'ArrowUp',\n 'ArrowRight',\n 'ArrowDown',\n 'Home',\n 'End',\n 'Insert',\n 'Delete',\n 'Backspace',\n 'Tab'\n ];\n\n if( !allowedChars.test(event.key)\n && !(event.ctrlKey && allowedCtrlChars.test(event.key))\n && !allowedOtherKeys.includes(event.key) ) event.preventDefault();\n }\n\n /* --------------------------------- Overwrite NG_VALUE_ACCESSOR -------------------------------- */\n\n registerOnChange(fn: any): void {\n this.propagateChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n isDisabled ? this.phoneNumberControl.disable() : this.phoneNumberControl.enable();\n }\n\n writeValue(obj: string): void {\n this.init();\n const phoneNumber: ChangeData = LocalPhoneUtils.getChangeData(obj);\n this.setSelectedCountry(this.countries.find(c => c.iso2.toUpperCase() === phoneNumber.countryCode));\n this.phoneNumberControl.setValue(phoneNumber.number || '')\n }\n\n /* --------------------------------- Helpers -------------------------------- */\n\n protected fetchCountryData(): void {\n const regionsNames = new Intl.DisplayNames([ this.lang() ], {\n type: 'region',\n });\n const favorites = this.favoriteCountries()?.map(code => code.toUpperCase()) ?? [];\n\n this.countries = ALL_COUNTRIES.map(country => {\n const countryCode = country[1].toString().toUpperCase();\n return {\n name: regionsNames.of(countryCode) || '',\n iso2: countryCode,\n dialCode: country[2].toString(),\n priority: +country[3] || 0,\n areaCodes: country[4] as string[] | undefined,\n htmlId: `item-${ countryCode }`,\n flagClass: `iti__flag iti__${ countryCode.toLowerCase() }`,\n placeHolder: this.getPlaceholder(countryCode),\n isFavorite: this.favoriteCountries()?.includes(country[1].toString()) ?? false\n };\n }).sort((a, b) => {\n const indexA = favorites.indexOf(a.iso2);\n const indexB = favorites.indexOf(b.iso2);\n\n if (a.isFavorite && b.isFavorite) {\n return indexA - indexB;\n }\n\n if (a.isFavorite) return -1;\n if (b.isFavorite) return 1;\n\n return a.name.localeCompare(b.name);\n });\n\n if (this.selectFirstCountry()) {\n const country = this.favoriteCountries()?.length ? this.favorites[0] : this.countries[0];\n this.setSelectedCountry(country);\n }\n }\n\n /**\n * U