UNPKG

@schoolbelle/common

Version:

Demo library to showcase Angular packaging format

1,220 lines (1,197 loc) 142 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('lodash'), require('@angular/forms'), require('@angular/common'), require('ngx-bootstrap/dropdown'), require('libphonenumber-js')) : typeof define === 'function' && define.amd ? define('@schoolbelle/common/components/intl-tel-input', ['exports', '@angular/core', 'lodash', '@angular/forms', '@angular/common', 'ngx-bootstrap/dropdown', 'libphonenumber-js'], factory) : (factory((global.schoolbelle = global.schoolbelle || {}, global.schoolbelle.common = global.schoolbelle.common || {}, global.schoolbelle.common.components = global.schoolbelle.common.components || {}, global.schoolbelle.common.components['intl-tel-input'] = {}),global.ng.core,null,global.ng.forms,global.ng.common,null,null)); }(this, (function (exports,core,lodash,forms,common,dropdown,_) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ INTL_TEL_INPUT_CONFIG = new core.InjectionToken('IntlTelCountryConfigInterface'); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ IntlTelCountryConfigDefault = { preSelectedCountry: /** @type {?} */ ('KR'), allowedCountries: /** @type {?} */ (['KR', 'RU']), preferredCountries: [] }; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CountryCode = (function () { function CountryCode() { this.allCountries = [ ['Afghanistan (‫افغانستان‬‎)', 'af', '93'], ['Albania (Shqipëri)', 'al', '355'], ['Algeria (‫الجزائر‬‎)', 'dz', '213'], ['American Samoa', 'as', '1684'], ['Andorra', 'ad', '376'], ['Angola', 'ao', '244'], ['Anguilla', 'ai', '1264'], ['Antigua and Barbuda', 'ag', '1268'], ['Argentina', 'ar', '54'], ['Armenia (Հայաստան)', 'am', '374'], ['Aruba', 'aw', '297'], ['Australia', 'au', '61', 0], ['Austria (Österreich)', 'at', '43'], ['Azerbaijan (Azərbaycan)', 'az', '994'], ['Bahamas', 'bs', '1242'], ['Bahrain (‫البحرين‬‎)', 'bh', '973'], ['Bangladesh (বাংলাদেশ)', 'bd', '880'], ['Barbados', 'bb', '1246'], ['Belarus (Беларусь)', 'by', '375'], ['Belgium (België)', 'be', '32'], ['Belize', 'bz', '501'], ['Benin (Bénin)', 'bj', '229'], ['Bermuda', 'bm', '1441'], ['Bhutan (འབྲུག)', 'bt', '975'], ['Bolivia', 'bo', '591'], ['Bosnia and Herzegovina (Босна и Херцеговина)', 'ba', '387'], ['Botswana', 'bw', '267'], ['Brazil (Brasil)', 'br', '55'], ['British Indian Ocean Territory', 'io', '246'], ['British Virgin Islands', 'vg', '1284'], ['Brunei', 'bn', '673'], ['Bulgaria (България)', 'bg', '359'], ['Burkina Faso', 'bf', '226'], ['Burundi (Uburundi)', 'bi', '257'], ['Cambodia (កម្ពុជា)', 'kh', '855'], ['Cameroon (Cameroun)', 'cm', '237'], [ 'Canada', 'ca', '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)', 'cv', '238'], ['Caribbean Netherlands', 'bq', '599', 1], ['Cayman Islands', 'ky', '1345'], ['Central African Republic (République centrafricaine)', 'cf', '236'], ['Chad (Tchad)', 'td', '235'], ['Chile', 'cl', '56'], ['China (中国)', 'cn', '86'], ['Christmas Island', 'cx', '61', 2], ['Cocos (Keeling) Islands', 'cc', '61', 1], ['Colombia', 'co', '57'], ['Comoros (‫جزر القمر‬‎)', 'km', '269'], ['Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)', 'cd', '243'], ['Congo (Republic) (Congo-Brazzaville)', 'cg', '242'], ['Cook Islands', 'ck', '682'], ['Costa Rica', 'cr', '506'], ['Côte d’Ivoire', 'ci', '225'], ['Croatia (Hrvatska)', 'hr', '385'], ['Cuba', 'cu', '53'], ['Curaçao', 'cw', '599', 0], ['Cyprus (Κύπρος)', 'cy', '357'], ['Czech Republic (Česká republika)', 'cz', '420'], ['Denmark (Danmark)', 'dk', '45'], ['Djibouti', 'dj', '253'], ['Dominica', 'dm', '1767'], [ 'Dominican Republic (República Dominicana)', 'do', '1', 2, ['809', '829', '849'] ], ['Ecuador', 'ec', '593'], ['Egypt (‫مصر‬‎)', 'eg', '20'], ['El Salvador', 'sv', '503'], ['Equatorial Guinea (Guinea Ecuatorial)', 'gq', '240'], ['Eritrea', 'er', '291'], ['Estonia (Eesti)', 'ee', '372'], ['Ethiopia', 'et', '251'], ['Falkland Islands (Islas Malvinas)', 'fk', '500'], ['Faroe Islands (Føroyar)', 'fo', '298'], ['Fiji', 'fj', '679'], ['Finland (Suomi)', 'fi', '358', 0], ['France', 'fr', '33'], ['French Guiana (Guyane française)', 'gf', '594'], ['French Polynesia (Polynésie française)', 'pf', '689'], ['Gabon', 'ga', '241'], ['Gambia', 'gm', '220'], ['Georgia (საქართველო)', 'ge', '995'], ['Germany (Deutschland)', 'de', '49'], ['Ghana (Gaana)', 'gh', '233'], ['Gibraltar', 'gi', '350'], ['Greece (Ελλάδα)', 'gr', '30'], ['Greenland (Kalaallit Nunaat)', 'gl', '299'], ['Grenada', 'gd', '1473'], ['Guadeloupe', 'gp', '590', 0], ['Guam', 'gu', '1671'], ['Guatemala', 'gt', '502'], ['Guernsey', 'gg', '44', 1], ['Guinea (Guinée)', 'gn', '224'], ['Guinea-Bissau (Guiné Bissau)', 'gw', '245'], ['Guyana', 'gy', '592'], ['Haiti', 'ht', '509'], ['Honduras', 'hn', '504'], ['Hong Kong (香港)', 'hk', '852'], ['Hungary (Magyarország)', 'hu', '36'], ['Iceland (Ísland)', 'is', '354'], ['India (भारत)', 'in', '91'], ['Indonesia', 'id', '62'], ['Iran (‫ایران‬‎)', 'ir', '98'], ['Iraq (‫العراق‬‎)', 'iq', '964'], ['Ireland', 'ie', '353'], ['Isle of Man', 'im', '44', 2], ['Israel (‫ישראל‬‎)', 'il', '972'], ['Italy (Italia)', 'it', '39', 0], ['Jamaica', 'jm', '1876'], ['Japan (日本)', 'jp', '81'], ['Jersey', 'je', '44', 3], ['Jordan (‫الأردن‬‎)', 'jo', '962'], ['Kazakhstan (Казахстан)', 'kz', '7', 1], ['Kenya', 'ke', '254'], ['Kiribati', 'ki', '686'], ['Kosovo', 'xk', '383'], ['Kuwait (‫الكويت‬‎)', 'kw', '965'], ['Kyrgyzstan (Кыргызстан)', 'kg', '996'], ['Laos (ລາວ)', 'la', '856'], ['Latvia (Latvija)', 'lv', '371'], ['Lebanon (‫لبنان‬‎)', 'lb', '961'], ['Lesotho', 'ls', '266'], ['Liberia', 'lr', '231'], ['Libya (‫ليبيا‬‎)', 'ly', '218'], ['Liechtenstein', 'li', '423'], ['Lithuania (Lietuva)', 'lt', '370'], ['Luxembourg', 'lu', '352'], ['Macau (澳門)', 'mo', '853'], ['Macedonia (FYROM) (Македонија)', 'mk', '389'], ['Madagascar (Madagasikara)', 'mg', '261'], ['Malawi', 'mw', '265'], ['Malaysia', 'my', '60'], ['Maldives', 'mv', '960'], ['Mali', 'ml', '223'], ['Malta', 'mt', '356'], ['Marshall Islands', 'mh', '692'], ['Martinique', 'mq', '596'], ['Mauritania (‫موريتانيا‬‎)', 'mr', '222'], ['Mauritius (Moris)', 'mu', '230'], ['Mayotte', 'yt', '262', 1], ['Mexico (México)', 'mx', '52'], ['Micronesia', 'fm', '691'], ['Moldova (Republica Moldova)', 'md', '373'], ['Monaco', 'mc', '377'], ['Mongolia (Монгол)', 'mn', '976'], ['Montenegro (Crna Gora)', 'me', '382'], ['Montserrat', 'ms', '1664'], ['Morocco (‫المغرب‬‎)', 'ma', '212', 0], ['Mozambique (Moçambique)', 'mz', '258'], ['Myanmar (Burma) (မြန်မာ)', 'mm', '95'], ['Namibia (Namibië)', 'na', '264'], ['Nauru', 'nr', '674'], ['Nepal (नेपाल)', 'np', '977'], ['Netherlands (Nederland)', 'nl', '31'], ['New Caledonia (Nouvelle-Calédonie)', 'nc', '687'], ['New Zealand', 'nz', '64'], ['Nicaragua', 'ni', '505'], ['Niger (Nijar)', 'ne', '227'], ['Nigeria', 'ng', '234'], ['Niue', 'nu', '683'], ['Norfolk Island', 'nf', '672'], ['North Korea (조선 민주주의 인민 공화국)', 'kp', '850'], ['Northern Mariana Islands', 'mp', '1670'], ['Norway (Norge)', 'no', '47', 0], ['Oman (‫عُمان‬‎)', 'om', '968'], ['Pakistan (‫پاکستان‬‎)', 'pk', '92'], ['Palau', 'pw', '680'], ['Palestine (‫فلسطين‬‎)', 'ps', '970'], ['Panama (Panamá)', 'pa', '507'], ['Papua New Guinea', 'pg', '675'], ['Paraguay', 'py', '595'], ['Peru (Perú)', 'pe', '51'], ['Philippines', 'ph', '63'], ['Poland (Polska)', 'pl', '48'], ['Portugal', 'pt', '351'], ['Puerto Rico', 'pr', '1', 3, ['787', '939']], ['Qatar (‫قطر‬‎)', 'qa', '974'], ['Réunion (La Réunion)', 're', '262', 0], ['Romania (România)', 'ro', '40'], ['Russia (Россия)', 'ru', '7', 0], ['Rwanda', 'rw', '250'], ['Saint Barthélemy (Saint-Barthélemy)', 'bl', '590', 1], ['Saint Helena', 'sh', '290'], ['Saint Kitts and Nevis', 'kn', '1869'], ['Saint Lucia', 'lc', '1758'], ['Saint Martin (Saint-Martin (partie française))', 'mf', '590', 2], ['Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)', 'pm', '508'], ['Saint Vincent and the Grenadines', 'vc', '1784'], ['Samoa', 'ws', '685'], ['San Marino', 'sm', '378'], ['São Tomé and Príncipe (São Tomé e Príncipe)', 'st', '239'], ['Saudi Arabia (‫المملكة العربية السعودية‬‎)', 'sa', '966'], ['Senegal (Sénégal)', 'sn', '221'], ['Serbia (Србија)', 'rs', '381'], ['Seychelles', 'sc', '248'], ['Sierra Leone', 'sl', '232'], ['Singapore', 'sg', '65'], ['Sint Maarten', 'sx', '1721'], ['Slovakia (Slovensko)', 'sk', '421'], ['Slovenia (Slovenija)', 'si', '386'], ['Solomon Islands', 'sb', '677'], ['Somalia (Soomaaliya)', 'so', '252'], ['South Africa', 'za', '27'], ['South Korea (대한민국)', 'kr', '82'], ['South Sudan (‫جنوب السودان‬‎)', 'ss', '211'], ['Spain (España)', 'es', '34'], ['Sri Lanka (ශ්‍රී ලංකාව)', 'lk', '94'], ['Sudan (‫السودان‬‎)', 'sd', '249'], ['Suriname', 'sr', '597'], ['Svalbard and Jan Mayen', 'sj', '47', 1], ['Swaziland', 'sz', '268'], ['Sweden (Sverige)', 'se', '46'], ['Switzerland (Schweiz)', 'ch', '41'], ['Syria (‫سوريا‬‎)', 'sy', '963'], ['Taiwan (台灣)', 'tw', '886'], ['Tajikistan', 'tj', '992'], ['Tanzania', 'tz', '255'], ['Thailand (ไทย)', 'th', '66'], ['Timor-Leste', 'tl', '670'], ['Togo', 'tg', '228'], ['Tokelau', 'tk', '690'], ['Tonga', 'to', '676'], ['Trinidad and Tobago', 'tt', '1868'], ['Tunisia (‫تونس‬‎)', 'tn', '216'], ['Turkey (Türkiye)', 'tr', '90'], ['Turkmenistan', 'tm', '993'], ['Turks and Caicos Islands', 'tc', '1649'], ['Tuvalu', 'tv', '688'], ['U.S. Virgin Islands', 'vi', '1340'], ['Uganda', 'ug', '256'], ['Ukraine (Україна)', 'ua', '380'], ['United Arab Emirates (‫الإمارات العربية المتحدة‬‎)', 'ae', '971'], ['United Kingdom', 'gb', '44', 0], ['United States', 'us', '1', 0], ['Uruguay', 'uy', '598'], ['Uzbekistan (Oʻzbekiston)', 'uz', '998'], ['Vanuatu', 'vu', '678'], ['Vatican City (Città del Vaticano)', 'va', '39', 1], ['Venezuela', 've', '58'], ['Vietnam (Việt Nam)', 'vn', '84'], ['Wallis and Futuna', 'wf', '681'], ['Western Sahara (‫الصحراء الغربية‬‎)', 'eh', '212', 1], ['Yemen (‫اليمن‬‎)', 'ye', '967'], ['Zambia', 'zm', '260'], ['Zimbabwe', 'zw', '263'], ['Åland Islands', 'ax', '358', 1] ]; } return CountryCode; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Country = (function () { function Country() { } return Country; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var IntTelCountryService = (function () { function IntTelCountryService(countryCodeData, intltelInputConfig) { var _this = this; this.countryCodeData = countryCodeData; this.allCountries = []; this.preferredCountries = []; var /** @type {?} */ defaultIntlTelInputConfig = IntlTelCountryConfigDefault; this.intltelInputConfig = __assign({}, defaultIntlTelInputConfig, intltelInputConfig); this.fetchCountryData(); if (this.intltelInputConfig.preferredCountries.length) { this.intltelInputConfig.preferredCountries.forEach(function (iso2) { var /** @type {?} */ preferredCountry = _this.allCountries.filter(function (c) { return c.iso2 === iso2; }); _this.preferredCountries.push(preferredCountry[0]); }); } // if (this.intltelInputConfig.preSelectedCountry) { // this.allCountries.forEach(country=>{ // if (country.iso2 === this.intltelInputConfig.preSelectedCountry) this.selectedCountry = country; // }); // } } /** * @param {?} conditions * @return {?} */ IntTelCountryService.prototype.find = /** * @param {?} conditions * @return {?} */ function (conditions) { return lodash.find(this.allCountries, conditions); }; /** * @return {?} */ IntTelCountryService.prototype.fetchCountryData = /** * @return {?} */ function () { var _this = this; this.countryCodeData.allCountries.forEach(function (c) { var /** @type {?} */ iso2 = (c[1].toString().toUpperCase()); if (!_this.intltelInputConfig.allowedCountries || _this.intltelInputConfig.allowedCountries.indexOf(iso2) !== -1) { var /** @type {?} */ country = new Country(); country.name = c[0].toString(); (country.iso2 = iso2), (country.dialCode = c[2].toString()); country.priority = +c[3] || 0; country.areaCode = +c[4] || null; country.flagClass = country.iso2.toLocaleLowerCase(); _this.allCountries.push(country); } }); }; IntTelCountryService.decorators = [ { type: core.Injectable }, ]; /** @nocollapse */ IntTelCountryService.ctorParameters = function () { return [ { type: CountryCode, }, { type: undefined, decorators: [{ type: core.Inject, args: [INTL_TEL_INPUT_CONFIG,] },] }, ]; }; return IntTelCountryService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ CountrySelectComponentValueAccessor = { provide: forms.NG_VALUE_ACCESSOR, useExisting: core.forwardRef(function () { return CountrySelectComponent; }), multi: true }; var CountrySelectComponent = (function () { function CountrySelectComponent(intTelCountryService) { this.intTelCountryService = intTelCountryService; this.onChange = function (_$$1) { }; this.onTouched = function () { }; } Object.defineProperty(CountrySelectComponent.prototype, "value", { get: /** * @return {?} */ function () { return this.countryDialCode; }, set: /** * @param {?} v * @return {?} */ function (v) { if (v !== this.countryDialCode) { var /** @type {?} */ country = this.intTelCountryService.find({ dialCode: v }); if (country) { this.country = country; this.countryDialCode = v; this.onChange(v); } } }, enumerable: true, configurable: true }); /** * @param {?} value * @return {?} */ CountrySelectComponent.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { var /** @type {?} */ country = this.intTelCountryService.find({ dialCode: value }); if (country) this.onCountrySelect(country); }; /** * @param {?} fn * @return {?} */ CountrySelectComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ CountrySelectComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ CountrySelectComponent.prototype.setDisabledState = /** * @param {?} isDisabled * @return {?} */ function (isDisabled) { this.disabled = isDisabled; }; /** * @return {?} */ CountrySelectComponent.prototype.ngOnInit = /** * @return {?} */ function () { var /** @type {?} */ country = this.intTelCountryService.find({ dialCode: this.countryDialCode }); if (country) this.onCountrySelect(country); }; /** * @param {?} country * @return {?} */ CountrySelectComponent.prototype.onCountrySelect = /** * @param {?} country * @return {?} */ function (country) { this.value = country.dialCode; }; CountrySelectComponent.decorators = [ { type: core.Component, args: [{ selector: 'country-select', template: "<div dropdown [isDisabled]=\"disabled\">\n <button type=\"button\" \n class=\"btn dropdown-toggle\"\n [ngClass]=\"{'btn-danger':ngClass && ngClass['is-invalid'], 'btn-success':ngClass && ngClass['is-valid'], 'btn-sm': size === 'sm'}\"\n dropdownToggle>\n <span class=\"flag-icon flag-icon-{{country?.flagClass}}\"></span>\n <!-- <intl-flag [countryDialCode]=\"country?.dialCode\"></intl-flag> -->\n </button>\n <ul class=\"dropdown-menu\" *dropdownMenu>\n <li class=\"dropdown-item\" *ngFor=\"let country of intTelCountryService.preferredCountries\" (click)=\"onCountrySelect(country)\">\n <span class=\"flag-icon flag-icon-{{country.flagClass}}\"></span>\n <span class=\"country-name\">{{country.name}}</span>\n <span class=\"dial-code\">+{{country.dialCode}}</span>\n </li>\n <li *ngIf=\"intTelCountryService.allCountries.length !== 0 && intTelCountryService.preferredCountries.length !== 0\" class=\"divider\"></li>\n <li class=\"dropdown-item\" *ngFor=\"let country of intTelCountryService.allCountries\" (click)=\"onCountrySelect(country)\">\n <span class=\"flag-icon flag-icon-{{country.flagClass}}\"></span>\n <span class=\"country-name\">{{country.name}}</span>\n <span class=\"dial-code\">+{{country.dialCode}}</span>\n </li>\n </ul>\n</div>\n", styles: ["div[dropdown]{position:absolute;height:100%}div[dropdown] button{padding:.3em .3em .3em 1em;height:100%;font-size:1em}"], providers: [CountrySelectComponentValueAccessor] },] }, ]; /** @nocollapse */ CountrySelectComponent.ctorParameters = function () { return [ { type: IntTelCountryService, }, ]; }; CountrySelectComponent.propDecorators = { "size": [{ type: core.Input, args: ['size',] },], "ngClass": [{ type: core.Input, args: ['ngClass',] },], }; return CountrySelectComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CountrySelectModule = (function () { function CountrySelectModule() { } CountrySelectModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule, forms.FormsModule, dropdown.BsDropdownModule], declarations: [CountrySelectComponent], exports: [CountrySelectComponent] },] }, ]; return CountrySelectModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var IntlFlagComponent = (function () { function IntlFlagComponent(intTelCountryService, cdRef) { this.intTelCountryService = intTelCountryService; this.cdRef = cdRef; } /** * @param {?} change * @return {?} */ IntlFlagComponent.prototype.ngOnChanges = /** * @param {?} change * @return {?} */ function (change) { if (change && change.intlTel) { var /** @type {?} */ value = change.intlTel.currentValue; var /** @type {?} */ parsed = void 0, /** @type {?} */ countryDialCode = void 0; try { parsed = _.parseNumber(value, { extended: true }); countryDialCode = parsed.countryCallingCode; } catch (e) { } this.country = this.intTelCountryService.find({ dialCode: countryDialCode }); } }; IntlFlagComponent.decorators = [ { type: core.Component, args: [{ selector: 'intl-flag', template: "<span class=\"flag-icon flag-icon-{{country?.flagClass}}\"></span>\n", styles: [""], changeDetection: core.ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ IntlFlagComponent.ctorParameters = function () { return [ { type: IntTelCountryService, }, { type: core.ChangeDetectorRef, }, ]; }; IntlFlagComponent.propDecorators = { "intlTel": [{ type: core.Input, args: ['intlTel',] },], }; return IntlFlagComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var IntlFlagModule = (function () { function IntlFlagModule() { } IntlFlagModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule], declarations: [IntlFlagComponent], exports: [IntlFlagComponent] },] }, ]; return IntlFlagModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ TEL_VALUE_ACCESSOR = { provide: forms.NG_VALUE_ACCESSOR, useExisting: core.forwardRef(function () { return LocalTelInputDirective; }), multi: true }; var LocalTelInputDirective = (function () { function LocalTelInputDirective(renderer, elementRef, intTelCountryService) { this.renderer = renderer; this.elementRef = elementRef; this.intTelCountryService = intTelCountryService; this.cursor = 0; } /** * @param {?} v * @return {?} */ LocalTelInputDirective.prototype.ngOnChanges = /** * @param {?} v * @return {?} */ function (v) { if (v.countryDialCode && v.countryDialCode.currentValue) { var /** @type {?} */ formatted_n = this.formatter(this.elementRef.nativeElement.value || ''); this.renderer.setProperty(this.elementRef.nativeElement, 'value', formatted_n); } }; Object.defineProperty(LocalTelInputDirective.prototype, "iso2", { get: /** * @return {?} */ function () { var /** @type {?} */ country = this.intTelCountryService.find({ dialCode: this.countryDialCode }); return country ? country.iso2 : undefined; }, enumerable: true, configurable: true }); /** * @param {?} elm * @return {?} */ LocalTelInputDirective.prototype.getCaretPosition = /** * @param {?} elm * @return {?} */ function (elm) { var /** @type {?} */ pos = 0; // Firefox support if (elm.selectionStart || elm.selectionStart == '0') { pos = elm.selectionStart; } else if (((document)).selection) { // IE Support // Set focus on the element elm.focus(); // To get cursor position, get empty selection range var /** @type {?} */ selection = ((document)).selection.createRange(); // Move selection start to 0 position selection.moveStart('character', -elm.value.length); // The caret position is selection length pos = selection.text.length; } // Return results return pos; }; /** * @param {?} elm * @param {?} caretPos * @return {?} */ LocalTelInputDirective.prototype.setCaretPosition = /** * @param {?} elm * @param {?} caretPos * @return {?} */ function (elm, caretPos) { if (elm !== null) { this.cursor = caretPos; if (elm.createTextRange) { setTimeout(function () { var /** @type {?} */ range = elm.createTextRange(); range.move('character', caretPos); range.select(); }, 0); } else { if (elm.setSelectionRange) { elm.focus(); setTimeout(function () { return elm.setSelectionRange(caretPos, caretPos); }, 0); } else { elm.focus(); } } } }; /** * @param {?=} value * @return {?} */ LocalTelInputDirective.prototype.formatter = /** * @param {?=} value * @return {?} */ function (value) { if (value === void 0) { value = ''; } return new _.AsYouType(this.iso2).input(value); }; /** * @param {?} $event * @return {?} */ LocalTelInputDirective.prototype.refreshCaretPosition = /** * @param {?} $event * @return {?} */ function ($event) { this.cursor = this.getCaretPosition(this.elementRef.nativeElement); }; /** * @param {?=} $event * @return {?} */ LocalTelInputDirective.prototype.onInputChange = /** * @param {?=} $event * @return {?} */ function ($event) { if ($event === void 0) { $event = undefined; } var /** @type {?} */ formatted_o = $event.target.value; var /** @type {?} */ formatted_n = this.formatter(formatted_o || ''); // update model value this.onChange(formatted_n.replace(/\D/g, '')); var /** @type {?} */ formattingCharacterIsAdded = formatted_n.replace(/[\d]/g, '').length - formatted_o.replace(/[\d]/g, '').length; if ($event.key.match(/\d/) || $event.key === 'Backspace') { // press number key // if formatting charater ex - or ) is added, // 1. render to the screen // 2. correct cursor position accordingly. if (formattingCharacterIsAdded > 0) { this.renderer.setProperty(this.elementRef.nativeElement, 'value', formatted_n); this.setCaretPosition(this.elementRef.nativeElement, this.cursor + 1 + formattingCharacterIsAdded); } } else if ($event.key === 'ArrowLeft') { // press left // remember change in cursor position this.cursor--; } else if ($event.key === 'ArrowRight') { // press right // remember change in cursor position this.cursor++; } }; /** * @param {?} $event * @return {?} */ LocalTelInputDirective.prototype.preventNonNumericInput = /** * @param {?} $event * @return {?} */ function ($event) { var /** @type {?} */ pattern = /[\d]/; var /** @type {?} */ inputChar = String.fromCharCode($event.charCode); if (!pattern.test(inputChar)) { event.preventDefault(); } }; /** * @param {?} value * @return {?} */ LocalTelInputDirective.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { var /** @type {?} */ formatted = this.formatter(value || ''); this.renderer.setProperty(this.elementRef.nativeElement, 'value', formatted); }; /** * @param {?} fn * @return {?} */ LocalTelInputDirective.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ LocalTelInputDirective.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ LocalTelInputDirective.prototype.setDisabledState = /** * @param {?} isDisabled * @return {?} */ function (isDisabled) { this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', isDisabled); }; LocalTelInputDirective.decorators = [ { type: core.Directive, args: [{ selector: '[local-tel][formControlName],[local-tel][formControl],[local-tel][ngModel]', providers: [TEL_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ LocalTelInputDirective.ctorParameters = function () { return [ { type: core.Renderer2, }, { type: core.ElementRef, }, { type: IntTelCountryService, }, ]; }; LocalTelInputDirective.propDecorators = { "countryDialCode": [{ type: core.Input },], "refreshCaretPosition": [{ type: core.HostListener, args: ['keydown', ['$event'],] }, { type: core.HostListener, args: ['click', ['$event'],] }, { type: core.HostListener, args: ['focus', ['$event'],] },], "onInputChange": [{ type: core.HostListener, args: ['keyup', ['$event'],] },], "preventNonNumericInput": [{ type: core.HostListener, args: ['keypress', ['$event'],] },], }; return LocalTelInputDirective; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var LocalTelInputModule = (function () { function LocalTelInputModule() { } LocalTelInputModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule, forms.FormsModule], declarations: [LocalTelInputDirective], exports: [LocalTelInputDirective] },] }, ]; return LocalTelInputModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ IntlTelInputComponentValueAccessor = { provide: forms.NG_VALUE_ACCESSOR, useExisting: core.forwardRef(function () { return IntlTelInputComponent; }), multi: true }; var IntlTelInputComponent = (function () { function IntlTelInputComponent(cdRef, elementRef, renderer) { this.cdRef = cdRef; this.elementRef = elementRef; this.renderer = renderer; this.onChange = function (_$$1) { }; this.onTouched = function () { }; this.subscriptions = []; } /** * @param {?=} value * @return {?} */ IntlTelInputComponent.prototype.writeValue = /** * @param {?=} value * @return {?} */ function (value) { if (value === void 0) { value = ''; } if (typeof value === 'string') { var /** @type {?} */ parsed = void 0, /** @type {?} */ tel = void 0, /** @type {?} */ countryDialCode = void 0; try { parsed = _.parseNumber(value, { extended: true }); countryDialCode = parsed.countryCallingCode; tel = _.formatNumber(parsed, 'National').replace(/\D/g, ''); } catch (e) { } if (tel) this.tel.setValue(tel); if (countryDialCode) this.countryDialCode.setValue(countryDialCode); if (tel || countryDialCode) this.cdRef.detectChanges(); } }; /** * @param {?} fn * @return {?} */ IntlTelInputComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ IntlTelInputComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ IntlTelInputComponent.prototype.setDisabledState = /** * @param {?} isDisabled * @return {?} */ function (isDisabled) { this.disabled = isDisabled; if (isDisabled) { this.tel.disable(); this.countryDialCode.disable(); } else { this.tel.enable(); this.countryDialCode.enable(); } }; /** * @return {?} */ IntlTelInputComponent.prototype.updateIntlTel = /** * @return {?} */ function () { this.value = '+' + this.countryDialCode.value + parseInt(this.tel.value); this.onChange(this.value); }; /** * @return {?} */ IntlTelInputComponent.prototype.createFormControls = /** * @return {?} */ function () { this.tel = new forms.FormControl({ value: '', disabled: this.disabled }); this.countryDialCode = new forms.FormControl({ value: '', disabled: this.disabled }); }; /** * @return {?} */ IntlTelInputComponent.prototype.createForm = /** * @return {?} */ function () { this.form = new forms.FormGroup({ countryDialCode: this.countryDialCode, tel: this.tel }); }; /** * @return {?} */ IntlTelInputComponent.prototype.focus = /** * @return {?} */ function () { this.renderer.addClass(this.elementRef.nativeElement, 'focus'); }; /** * @return {?} */ IntlTelInputComponent.prototype.blur = /** * @return {?} */ function () { this.renderer.removeClass(this.elementRef.nativeElement, 'focus'); }; /** * @return {?} */ IntlTelInputComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.createFormControls(); this.createForm(); this.subscriptions.push(this.form.valueChanges.subscribe(function () { return _this.updateIntlTel(); })); }; /** * @return {?} */ IntlTelInputComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); }); }; IntlTelInputComponent.decorators = [ { type: core.Component, args: [{ selector: 'intl-tel-input', styles: ["input{border:none;padding:.375em .75em .375em 4.3em;display:block;width:100%;line-height:1.5;color:#495057;text-align:inherit;background-color:transparent}input:focus{outline:0;box-shadow:none}input:disabled,input[readonly]{background-color:#e9ecef;opacity:1}"], template: "<form novalidate\n[formGroup]=\"form\">\n <div [ngClass]=\"{'input-group-lg':size === 'lg', 'input-group-sm':size === 'sm' }\" style=\"position: relative;\">\n <country-select \n formControlName=\"countryDialCode\" \n required></country-select>\n \n <input\n type=\"text\" \n formControlName=\"tel\"\n [countryDialCode]=\"countryDialCode.value\"\n (focus)=\"focus()\" \n (blur)=\"blur()\" \n local-tel \n required \n autocomplete=\"off\" \n i18n-placeholder=\"@@schoolbelleIntlTelInputPlaceHolder\"\n placeholder=\"\uC804\uD654\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694.\">\n </div>\n</form>", providers: [IntlTelInputComponentValueAccessor], changeDetection: core.ChangeDetectionStrategy.OnPush, encapsulation: core.ViewEncapsulation.Emulated },] }, ]; /** @nocollapse */ IntlTelInputComponent.ctorParameters = function () { return [ { type: core.ChangeDetectorRef, }, { type: core.ElementRef, }, { type: core.Renderer2, }, ]; }; IntlTelInputComponent.propDecorators = { "ngClass": [{ type: core.Input, args: ['ngClass',] },], "size": [{ type: core.Input, args: ['size',] },], }; return IntlTelInputComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var IntlTelInputModule = (function () { function IntlTelInputModule() { } /** * @param {?=} config * @return {?} */ IntlTelInputModule.forRoot = /** * @param {?=} config * @return {?} */ function (config) { if (config === void 0) { config = IntlTelCountryConfigDefault; } return { ngModule: IntlTelInputModule, providers: [ { provide: INTL_TEL_INPUT_CONFIG, useValue: config }, CountryCode, IntTelCountryService ] }; }; IntlTelInputModule.decorators = [ { type: core.NgModule, args: [{ imports: [ common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule, CountrySelectModule, IntlFlagModule, LocalTelInputModule, dropdown.BsDropdownModule.forRoot() ], declarations: [IntlTelInputComponent], exports: [ CountrySelectModule, IntlFlagModule, LocalTelInputModule, IntlTelInputComponent ] },] }, ]; return IntlTelInputModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @param {?} control * @return {?} */ function IntlTelValidatorFn(control) { if (control.value) { if (control.value.match(/\+82000/)) { return null; } else { var /** @type {?} */ valid = false; try { valid = _.isValidNumber(_.parse(control.value)); } catch (e) { valid = false; } if (!valid) { return { intltel: true }; } } } return null; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ exports.IntlTelInputModule = IntlTelInputModule; exports.IntlTelValidatorFn = IntlTelValidatorFn; exports.IntTelCountryService = IntTelCountryService; exports.ɵc = CountrySelectComponent; exports.ɵb = CountrySelectComponentValueAccessor; exports.ɵa = CountrySelectModule; exports.ɵh = IntlFlagComponent; exports.ɵg = IntlFlagModule; exports.ɵm = IntlTelCountryConfigDefault; exports.ɵd = INTL_TEL_INPUT_CONFIG; exports.ɵj = LocalTelInputDirective; exports.ɵi = LocalTelInputModule; exports.ɵl = IntlTelInputComponent; exports.ɵk = IntlTelInputComponentValueAccessor; exports.ɵe = CountryCode; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nob29sYmVsbGUtY29tbW9uLWNvbXBvbmVudHMtaW50bC10ZWwtaW5wdXQudW1kLmpzLm1hcCIsInNvdXJjZXMiOlsibmc6Ly9Ac2Nob29sYmVsbGUvY29tbW9uL2NvbXBvbmVudHMvaW50bC10ZWwtaW5wdXQvc3JjL2NvbmZpZ3MvaW50bC10ZWwtY291bnRyeS50b2tlbi50cyIsIm5nOi8vQHNjaG9vbGJlbGxlL2NvbW1vbi9jb21wb25lbnRzL2ludGwtdGVsLWlucHV0L3NyYy9jb25maWdzL2ludGwtdGVsLWNvdW50cnktY29uZmlnLmRlZmF1bHQudHMiLG5