@skyux/phone-field 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/skyux-phone-field.umd.js +66 -66
- package/documentation.json +38 -38
- package/esm2015/lib/modules/phone-field/phone-field-adapter.service.js.map +1 -1
- package/esm2015/lib/modules/phone-field/phone-field-input.directive.js +5 -5
- package/esm2015/lib/modules/phone-field/phone-field-input.directive.js.map +1 -1
- package/esm2015/lib/modules/phone-field/phone-field.component.js +2 -2
- package/esm2015/lib/modules/phone-field/phone-field.component.js.map +1 -1
- package/esm2015/lib/modules/phone-field/phone-field.module.js +3 -3
- package/esm2015/lib/modules/phone-field/phone-field.module.js.map +1 -1
- package/esm2015/lib/modules/shared/sky-phone-field-resources.module.js +1 -1
- package/esm2015/lib/modules/shared/sky-phone-field-resources.module.js.map +1 -1
- package/esm2015/testing/phonefield/phone-field-fixture.js.map +1 -1
- package/esm2015/testing/phonefield/phone-field-testing.module.js.map +1 -1
- package/fesm2015/skyux-phone-field-testing.js.map +1 -1
- package/fesm2015/skyux-phone-field.js +10 -10
- package/fesm2015/skyux-phone-field.js.map +1 -1
- package/lib/modules/phone-field/phone-field-adapter.service.d.ts +1 -1
- package/lib/modules/phone-field/phone-field-input.directive.d.ts +1 -1
- package/package.json +6 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@skyux/phone-field', ['exports', '@angular/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux["phone-field"] = {}), global.ng.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@skyux/i18n'), require('@skyux/indicators'), require('@skyux/lookup'), require('@skyux/theme'), require('google-libphonenumber'), require('rxjs'), require('rxjs/operators'), require('@angular/animations'), require('@skyux/forms'), require('intl-tel-input')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@skyux/phone-field', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@skyux/i18n', '@skyux/indicators', '@skyux/lookup', '@skyux/theme', 'google-libphonenumber', 'rxjs', 'rxjs/operators', '@angular/animations', '@skyux/forms', 'intl-tel-input'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux["phone-field"] = {}), global.ng.common, global.ng.core, global.ng.forms, global.i1, global.i6, global.i5, global.i3, global.googleLibphonenumber, global.rxjs, global.rxjs.operators, global.ng.animations, global.i4));
|
|
5
|
+
})(this, (function (exports, i7, i0, i1$1, i1, i6, i5, i3, googleLibphonenumber, rxjs, operators, animations, i4) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
26
25
|
var i7__namespace = /*#__PURE__*/_interopNamespace(i7);
|
|
26
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
27
27
|
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
28
|
-
var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
|
|
29
28
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
+
var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
|
|
30
30
|
var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
|
|
31
31
|
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
32
32
|
var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
|
|
@@ -94,6 +94,66 @@
|
|
|
94
94
|
}]
|
|
95
95
|
}] });
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Service for interacting with the DOM elements of the phone field.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
var SkyPhoneFieldAdapterService = /** @class */ (function () {
|
|
102
|
+
function SkyPhoneFieldAdapterService(renderer, resourcesService) {
|
|
103
|
+
this.renderer = renderer;
|
|
104
|
+
this.resourcesService = resourcesService;
|
|
105
|
+
this.ngUnsubscribe = new rxjs.Subject();
|
|
106
|
+
}
|
|
107
|
+
SkyPhoneFieldAdapterService.prototype.ngOnDestroy = function () {
|
|
108
|
+
this.ngUnsubscribe.next();
|
|
109
|
+
this.ngUnsubscribe.complete();
|
|
110
|
+
};
|
|
111
|
+
SkyPhoneFieldAdapterService.prototype.addElementClass = function (elementRef, className) {
|
|
112
|
+
this.renderer.addClass(elementRef.nativeElement, className);
|
|
113
|
+
};
|
|
114
|
+
SkyPhoneFieldAdapterService.prototype.setElementDisabledState = function (elementRef, disabled) {
|
|
115
|
+
this.renderer.setProperty(elementRef.nativeElement, 'disabled', disabled);
|
|
116
|
+
};
|
|
117
|
+
SkyPhoneFieldAdapterService.prototype.setElementPlaceholder = function (elementRef, placeholder) {
|
|
118
|
+
this.renderer.setAttribute(elementRef.nativeElement, 'placeholder', placeholder);
|
|
119
|
+
};
|
|
120
|
+
SkyPhoneFieldAdapterService.prototype.setElementType = function (elementRef) {
|
|
121
|
+
this.renderer.setAttribute(elementRef.nativeElement, 'type', 'tel');
|
|
122
|
+
};
|
|
123
|
+
SkyPhoneFieldAdapterService.prototype.setElementValue = function (elementRef, value) {
|
|
124
|
+
if (value) {
|
|
125
|
+
this.renderer.setProperty(elementRef.nativeElement, 'value', value);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
SkyPhoneFieldAdapterService.prototype.setAriaLabel = function (element) {
|
|
129
|
+
var _this = this;
|
|
130
|
+
/* Sanity check */
|
|
131
|
+
/* istanbul ignore else */
|
|
132
|
+
if (!element.nativeElement.getAttribute('aria-label')) {
|
|
133
|
+
this.resourcesService
|
|
134
|
+
.getString('skyux_phone_field_default_label')
|
|
135
|
+
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
136
|
+
.subscribe(function (value) {
|
|
137
|
+
_this.renderer.setAttribute(element.nativeElement, 'aria-label', value);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
SkyPhoneFieldAdapterService.prototype.focusCountrySearchElement = function (el) {
|
|
142
|
+
var input = el.querySelector('textarea');
|
|
143
|
+
input.focus();
|
|
144
|
+
};
|
|
145
|
+
SkyPhoneFieldAdapterService.prototype.focusPhoneInput = function (el) {
|
|
146
|
+
var input = el.querySelector('.sky-phone-field-container input');
|
|
147
|
+
input.focus();
|
|
148
|
+
};
|
|
149
|
+
return SkyPhoneFieldAdapterService;
|
|
150
|
+
}());
|
|
151
|
+
SkyPhoneFieldAdapterService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService, deps: [{ token: i0__namespace.Renderer2 }, { token: i1__namespace.SkyLibResourcesService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
152
|
+
SkyPhoneFieldAdapterService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService });
|
|
153
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService, decorators: [{
|
|
154
|
+
type: i0.Injectable
|
|
155
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i1__namespace.SkyLibResourcesService }]; } });
|
|
156
|
+
|
|
97
157
|
/*! *****************************************************************************
|
|
98
158
|
Copyright (c) Microsoft Corporation.
|
|
99
159
|
|
|
@@ -412,66 +472,6 @@
|
|
|
412
472
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
413
473
|
}
|
|
414
474
|
|
|
415
|
-
/**
|
|
416
|
-
* Service for interacting with the DOM elements of the phone field.
|
|
417
|
-
* @internal
|
|
418
|
-
*/
|
|
419
|
-
var SkyPhoneFieldAdapterService = /** @class */ (function () {
|
|
420
|
-
function SkyPhoneFieldAdapterService(renderer, resourcesService) {
|
|
421
|
-
this.renderer = renderer;
|
|
422
|
-
this.resourcesService = resourcesService;
|
|
423
|
-
this.ngUnsubscribe = new rxjs.Subject();
|
|
424
|
-
}
|
|
425
|
-
SkyPhoneFieldAdapterService.prototype.ngOnDestroy = function () {
|
|
426
|
-
this.ngUnsubscribe.next();
|
|
427
|
-
this.ngUnsubscribe.complete();
|
|
428
|
-
};
|
|
429
|
-
SkyPhoneFieldAdapterService.prototype.addElementClass = function (elementRef, className) {
|
|
430
|
-
this.renderer.addClass(elementRef.nativeElement, className);
|
|
431
|
-
};
|
|
432
|
-
SkyPhoneFieldAdapterService.prototype.setElementDisabledState = function (elementRef, disabled) {
|
|
433
|
-
this.renderer.setProperty(elementRef.nativeElement, 'disabled', disabled);
|
|
434
|
-
};
|
|
435
|
-
SkyPhoneFieldAdapterService.prototype.setElementPlaceholder = function (elementRef, placeholder) {
|
|
436
|
-
this.renderer.setAttribute(elementRef.nativeElement, 'placeholder', placeholder);
|
|
437
|
-
};
|
|
438
|
-
SkyPhoneFieldAdapterService.prototype.setElementType = function (elementRef) {
|
|
439
|
-
this.renderer.setAttribute(elementRef.nativeElement, 'type', 'tel');
|
|
440
|
-
};
|
|
441
|
-
SkyPhoneFieldAdapterService.prototype.setElementValue = function (elementRef, value) {
|
|
442
|
-
if (value) {
|
|
443
|
-
this.renderer.setProperty(elementRef.nativeElement, 'value', value);
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
SkyPhoneFieldAdapterService.prototype.setAriaLabel = function (element) {
|
|
447
|
-
var _this = this;
|
|
448
|
-
/* Sanity check */
|
|
449
|
-
/* istanbul ignore else */
|
|
450
|
-
if (!element.nativeElement.getAttribute('aria-label')) {
|
|
451
|
-
this.resourcesService
|
|
452
|
-
.getString('skyux_phone_field_default_label')
|
|
453
|
-
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
454
|
-
.subscribe(function (value) {
|
|
455
|
-
_this.renderer.setAttribute(element.nativeElement, 'aria-label', value);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
SkyPhoneFieldAdapterService.prototype.focusCountrySearchElement = function (el) {
|
|
460
|
-
var input = el.querySelector('textarea');
|
|
461
|
-
input.focus();
|
|
462
|
-
};
|
|
463
|
-
SkyPhoneFieldAdapterService.prototype.focusPhoneInput = function (el) {
|
|
464
|
-
var input = el.querySelector('.sky-phone-field-container input');
|
|
465
|
-
input.focus();
|
|
466
|
-
};
|
|
467
|
-
return SkyPhoneFieldAdapterService;
|
|
468
|
-
}());
|
|
469
|
-
SkyPhoneFieldAdapterService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService, deps: [{ token: i0__namespace.Renderer2 }, { token: i1__namespace.SkyLibResourcesService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
470
|
-
SkyPhoneFieldAdapterService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService });
|
|
471
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyPhoneFieldAdapterService, decorators: [{
|
|
472
|
-
type: i0.Injectable
|
|
473
|
-
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i1__namespace.SkyLibResourcesService }]; } });
|
|
474
|
-
|
|
475
475
|
// NOTE: The no-op animation is here in order to block the input's "fade in" animation
|
|
476
476
|
// from firing on initial load. For more information on this technique you can see
|
|
477
477
|
// https://www.bennadel.com/blog/3417-using-no-op-transitions-to-prevent-animation-during-the-initial-render-of-ngfor-in-angular-5-2-6.htm
|
package/documentation.json
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"sources": [
|
|
70
70
|
{
|
|
71
71
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.module.ts",
|
|
72
|
-
"line":
|
|
72
|
+
"line": 28,
|
|
73
73
|
"character": 13
|
|
74
74
|
}
|
|
75
75
|
]
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"sources": [
|
|
105
105
|
{
|
|
106
106
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
107
|
-
"line":
|
|
107
|
+
"line": 232,
|
|
108
108
|
"character": 2
|
|
109
109
|
}
|
|
110
110
|
],
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"sources": [
|
|
255
255
|
{
|
|
256
256
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
257
|
-
"line":
|
|
257
|
+
"line": 113,
|
|
258
258
|
"character": 9
|
|
259
259
|
}
|
|
260
260
|
],
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
"sources": [
|
|
276
276
|
{
|
|
277
277
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
278
|
-
"line":
|
|
278
|
+
"line": 160,
|
|
279
279
|
"character": 9
|
|
280
280
|
}
|
|
281
281
|
],
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"sources": [
|
|
300
300
|
{
|
|
301
301
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
302
|
-
"line":
|
|
302
|
+
"line": 168,
|
|
303
303
|
"character": 9
|
|
304
304
|
}
|
|
305
305
|
],
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
"sources": [
|
|
322
322
|
{
|
|
323
323
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
324
|
-
"line":
|
|
324
|
+
"line": 164,
|
|
325
325
|
"character": 9
|
|
326
326
|
}
|
|
327
327
|
],
|
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
"sources": [
|
|
343
343
|
{
|
|
344
344
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
345
|
-
"line":
|
|
345
|
+
"line": 162,
|
|
346
346
|
"character": 9
|
|
347
347
|
}
|
|
348
348
|
],
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
"sources": [
|
|
378
378
|
{
|
|
379
379
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
380
|
-
"line":
|
|
380
|
+
"line": 166,
|
|
381
381
|
"character": 9
|
|
382
382
|
}
|
|
383
383
|
],
|
|
@@ -419,7 +419,7 @@
|
|
|
419
419
|
"sources": [
|
|
420
420
|
{
|
|
421
421
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
422
|
-
"line":
|
|
422
|
+
"line": 143,
|
|
423
423
|
"character": 9
|
|
424
424
|
}
|
|
425
425
|
],
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
"sources": [
|
|
457
457
|
{
|
|
458
458
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
459
|
-
"line":
|
|
459
|
+
"line": 158,
|
|
460
460
|
"character": 9
|
|
461
461
|
}
|
|
462
462
|
],
|
|
@@ -501,7 +501,7 @@
|
|
|
501
501
|
"sources": [
|
|
502
502
|
{
|
|
503
503
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
504
|
-
"line":
|
|
504
|
+
"line": 150,
|
|
505
505
|
"character": 9
|
|
506
506
|
}
|
|
507
507
|
],
|
|
@@ -550,7 +550,7 @@
|
|
|
550
550
|
"sources": [
|
|
551
551
|
{
|
|
552
552
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
553
|
-
"line":
|
|
553
|
+
"line": 123,
|
|
554
554
|
"character": 13
|
|
555
555
|
}
|
|
556
556
|
],
|
|
@@ -635,7 +635,7 @@
|
|
|
635
635
|
"sources": [
|
|
636
636
|
{
|
|
637
637
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
638
|
-
"line":
|
|
638
|
+
"line": 174,
|
|
639
639
|
"character": 13
|
|
640
640
|
}
|
|
641
641
|
],
|
|
@@ -698,7 +698,7 @@
|
|
|
698
698
|
"sources": [
|
|
699
699
|
{
|
|
700
700
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
701
|
-
"line":
|
|
701
|
+
"line": 326,
|
|
702
702
|
"character": 9
|
|
703
703
|
}
|
|
704
704
|
],
|
|
@@ -742,7 +742,7 @@
|
|
|
742
742
|
"sources": [
|
|
743
743
|
{
|
|
744
744
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
745
|
-
"line":
|
|
745
|
+
"line": 293,
|
|
746
746
|
"character": 9
|
|
747
747
|
}
|
|
748
748
|
],
|
|
@@ -779,7 +779,7 @@
|
|
|
779
779
|
"sources": [
|
|
780
780
|
{
|
|
781
781
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
782
|
-
"line":
|
|
782
|
+
"line": 262,
|
|
783
783
|
"character": 9
|
|
784
784
|
}
|
|
785
785
|
],
|
|
@@ -816,7 +816,7 @@
|
|
|
816
816
|
"sources": [
|
|
817
817
|
{
|
|
818
818
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
819
|
-
"line":
|
|
819
|
+
"line": 336,
|
|
820
820
|
"character": 9
|
|
821
821
|
}
|
|
822
822
|
],
|
|
@@ -860,7 +860,7 @@
|
|
|
860
860
|
"sources": [
|
|
861
861
|
{
|
|
862
862
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
863
|
-
"line":
|
|
863
|
+
"line": 349,
|
|
864
864
|
"character": 9
|
|
865
865
|
}
|
|
866
866
|
],
|
|
@@ -902,7 +902,7 @@
|
|
|
902
902
|
"sources": [
|
|
903
903
|
{
|
|
904
904
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
905
|
-
"line":
|
|
905
|
+
"line": 312,
|
|
906
906
|
"character": 9
|
|
907
907
|
}
|
|
908
908
|
],
|
|
@@ -983,7 +983,7 @@
|
|
|
983
983
|
"sources": [
|
|
984
984
|
{
|
|
985
985
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field.component.ts",
|
|
986
|
-
"line":
|
|
986
|
+
"line": 107,
|
|
987
987
|
"character": 13
|
|
988
988
|
}
|
|
989
989
|
],
|
|
@@ -1043,7 +1043,7 @@
|
|
|
1043
1043
|
"sources": [
|
|
1044
1044
|
{
|
|
1045
1045
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1046
|
-
"line":
|
|
1046
|
+
"line": 120,
|
|
1047
1047
|
"character": 2
|
|
1048
1048
|
}
|
|
1049
1049
|
],
|
|
@@ -1175,7 +1175,7 @@
|
|
|
1175
1175
|
"sources": [
|
|
1176
1176
|
{
|
|
1177
1177
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1178
|
-
"line":
|
|
1178
|
+
"line": 87,
|
|
1179
1179
|
"character": 9
|
|
1180
1180
|
}
|
|
1181
1181
|
],
|
|
@@ -1208,7 +1208,7 @@
|
|
|
1208
1208
|
"sources": [
|
|
1209
1209
|
{
|
|
1210
1210
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1211
|
-
"line":
|
|
1211
|
+
"line": 69,
|
|
1212
1212
|
"character": 13
|
|
1213
1213
|
}
|
|
1214
1214
|
],
|
|
@@ -1281,7 +1281,7 @@
|
|
|
1281
1281
|
"sources": [
|
|
1282
1282
|
{
|
|
1283
1283
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1284
|
-
"line":
|
|
1284
|
+
"line": 147,
|
|
1285
1285
|
"character": 9
|
|
1286
1286
|
}
|
|
1287
1287
|
],
|
|
@@ -1318,7 +1318,7 @@
|
|
|
1318
1318
|
"sources": [
|
|
1319
1319
|
{
|
|
1320
1320
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1321
|
-
"line":
|
|
1321
|
+
"line": 167,
|
|
1322
1322
|
"character": 9
|
|
1323
1323
|
}
|
|
1324
1324
|
],
|
|
@@ -1355,7 +1355,7 @@
|
|
|
1355
1355
|
"sources": [
|
|
1356
1356
|
{
|
|
1357
1357
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1358
|
-
"line":
|
|
1358
|
+
"line": 127,
|
|
1359
1359
|
"character": 9
|
|
1360
1360
|
}
|
|
1361
1361
|
],
|
|
@@ -1406,7 +1406,7 @@
|
|
|
1406
1406
|
"sources": [
|
|
1407
1407
|
{
|
|
1408
1408
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1409
|
-
"line":
|
|
1409
|
+
"line": 189,
|
|
1410
1410
|
"character": 9
|
|
1411
1411
|
}
|
|
1412
1412
|
],
|
|
@@ -1453,7 +1453,7 @@
|
|
|
1453
1453
|
"sources": [
|
|
1454
1454
|
{
|
|
1455
1455
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1456
|
-
"line":
|
|
1456
|
+
"line": 177,
|
|
1457
1457
|
"character": 9
|
|
1458
1458
|
}
|
|
1459
1459
|
],
|
|
@@ -1516,7 +1516,7 @@
|
|
|
1516
1516
|
"sources": [
|
|
1517
1517
|
{
|
|
1518
1518
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1519
|
-
"line":
|
|
1519
|
+
"line": 194,
|
|
1520
1520
|
"character": 9
|
|
1521
1521
|
}
|
|
1522
1522
|
],
|
|
@@ -1558,7 +1558,7 @@
|
|
|
1558
1558
|
"sources": [
|
|
1559
1559
|
{
|
|
1560
1560
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1561
|
-
"line":
|
|
1561
|
+
"line": 212,
|
|
1562
1562
|
"character": 9
|
|
1563
1563
|
}
|
|
1564
1564
|
],
|
|
@@ -1640,7 +1640,7 @@
|
|
|
1640
1640
|
"sources": [
|
|
1641
1641
|
{
|
|
1642
1642
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1643
|
-
"line":
|
|
1643
|
+
"line": 216,
|
|
1644
1644
|
"character": 9
|
|
1645
1645
|
}
|
|
1646
1646
|
],
|
|
@@ -1709,7 +1709,7 @@
|
|
|
1709
1709
|
"sources": [
|
|
1710
1710
|
{
|
|
1711
1711
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1712
|
-
"line":
|
|
1712
|
+
"line": 220,
|
|
1713
1713
|
"character": 9
|
|
1714
1714
|
}
|
|
1715
1715
|
],
|
|
@@ -1778,7 +1778,7 @@
|
|
|
1778
1778
|
"sources": [
|
|
1779
1779
|
{
|
|
1780
1780
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1781
|
-
"line":
|
|
1781
|
+
"line": 228,
|
|
1782
1782
|
"character": 9
|
|
1783
1783
|
}
|
|
1784
1784
|
],
|
|
@@ -1834,7 +1834,7 @@
|
|
|
1834
1834
|
"sources": [
|
|
1835
1835
|
{
|
|
1836
1836
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1837
|
-
"line":
|
|
1837
|
+
"line": 236,
|
|
1838
1838
|
"character": 9
|
|
1839
1839
|
}
|
|
1840
1840
|
],
|
|
@@ -1894,7 +1894,7 @@
|
|
|
1894
1894
|
"sources": [
|
|
1895
1895
|
{
|
|
1896
1896
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1897
|
-
"line":
|
|
1897
|
+
"line": 206,
|
|
1898
1898
|
"character": 9
|
|
1899
1899
|
}
|
|
1900
1900
|
],
|
|
@@ -1984,7 +1984,7 @@
|
|
|
1984
1984
|
"sources": [
|
|
1985
1985
|
{
|
|
1986
1986
|
"fileName": "projects/phone-field/src/modules/phone-field/phone-field-input.directive.ts",
|
|
1987
|
-
"line":
|
|
1987
|
+
"line": 61,
|
|
1988
1988
|
"character": 13
|
|
1989
1989
|
}
|
|
1990
1990
|
],
|
|
@@ -2227,12 +2227,12 @@
|
|
|
2227
2227
|
{
|
|
2228
2228
|
"fileName": "phone-field-demo.component.ts",
|
|
2229
2229
|
"filePath": "/projects/phone-field/documentation/code-examples/phone-field/basic/phone-field-demo.component.ts",
|
|
2230
|
-
"rawContents": "import { Component, OnInit } from '@angular/core';\
|
|
2230
|
+
"rawContents": "import { Component, OnInit } from '@angular/core';\nimport { FormControl, FormGroup } from '@angular/forms';\n\n@Component({\n selector: 'app-phone-field-demo',\n templateUrl: './phone-field-demo.component.html',\n styleUrls: ['./phone-field-demo.component.scss'],\n})\nexport class PhoneFieldDemoComponent implements OnInit {\n public phoneControl: FormControl;\n\n public phoneForm: FormGroup;\n\n public ngOnInit(): void {\n this.phoneControl = new FormControl();\n this.phoneForm = new FormGroup({\n phoneControl: this.phoneControl,\n });\n }\n}\n"
|
|
2231
2231
|
},
|
|
2232
2232
|
{
|
|
2233
2233
|
"fileName": "phone-field-demo.module.ts",
|
|
2234
2234
|
"filePath": "/projects/phone-field/documentation/code-examples/phone-field/basic/phone-field-demo.module.ts",
|
|
2235
|
-
"rawContents": "import { CommonModule } from '@angular/common';\
|
|
2235
|
+
"rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyInputBoxModule } from '@skyux/forms';\nimport { SkyStatusIndicatorModule } from '@skyux/indicators';\nimport { SkyPhoneFieldModule } from '@skyux/phone-field';\n\nimport { PhoneFieldDemoComponent } from './phone-field-demo.component';\n\n@NgModule({\n declarations: [PhoneFieldDemoComponent],\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyInputBoxModule,\n SkyPhoneFieldModule,\n SkyStatusIndicatorModule,\n ],\n exports: [PhoneFieldDemoComponent],\n})\nexport class PhoneFieldDemoModule {}\n"
|
|
2236
2236
|
}
|
|
2237
2237
|
]
|
|
2238
2238
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-field-adapter.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/phone-field/src/lib/modules/phone-field/phone-field-adapter.service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"phone-field-adapter.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/phone-field/src/lib/modules/phone-field/phone-field-adapter.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;;;AAE3C;;;GAGG;AAEH,MAAM,OAAO,2BAA2B;IAGtC,YACU,QAAmB,EACnB,gBAAwC;QADxC,aAAQ,GAAR,QAAQ,CAAW;QACnB,qBAAgB,GAAhB,gBAAgB,CAAwB;QAJ1C,kBAAa,GAAG,IAAI,OAAO,EAAE,CAAC;IAKnC,CAAC;IAEG,WAAW;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAEM,eAAe,CAAC,UAAsB,EAAE,SAAiB;QAC9D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAEM,uBAAuB,CA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CAAC,aAAa,CACzC,kCAAkC,CACnC,CAAC;QACF,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;;yHAxEU,2BAA2B;6HAA3B,2BAA2B;4FAA3B,2BAA2B;kBADvC,UAAU","sourcesContent":["import { ElementRef, Injectable, OnDestroy, Renderer2 } from '@angular/core';\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n/**\n * Service for interacting with the DOM elements of the phone field.\n * @internal\n */\n@Injectable()\nexport class SkyPhoneFieldAdapterService implements OnDestroy {\n private ngUnsubscribe = new Subject();\n\n constructor(\n private renderer: Renderer2,\n private resourcesService: SkyLibResourcesService\n ) {}\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n public addElementClass(elementRef: ElementRef, className: string): void {\n this.renderer.addClass(elementRef.nativeElement, className);\n }\n\n public setElementDisabledState(\n elementRef: ElementRef,\n disabled: boolean\n ): void {\n this.renderer.setProperty(elementRef.nativeElement, 'disabled', disabled);\n }\n\n public setElementPlaceholder(\n elementRef: ElementRef,\n placeholder: string\n ): void {\n this.renderer.setAttribute(\n elementRef.nativeElement,\n 'placeholder',\n placeholder\n );\n }\n\n public setElementType(elementRef: ElementRef): void {\n this.renderer.setAttribute(elementRef.nativeElement, 'type', 'tel');\n }\n\n public setElementValue(elementRef: ElementRef, value: string): void {\n if (value) {\n this.renderer.setProperty(elementRef.nativeElement, 'value', value);\n }\n }\n\n public setAriaLabel(element: ElementRef): void {\n /* Sanity check */\n /* istanbul ignore else */\n if (!element.nativeElement.getAttribute('aria-label')) {\n this.resourcesService\n .getString('skyux_phone_field_default_label')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((value: string) => {\n this.renderer.setAttribute(\n element.nativeElement,\n 'aria-label',\n value\n );\n });\n }\n }\n\n public focusCountrySearchElement(el: Element): void {\n const input: HTMLElement = el.querySelector('textarea');\n input.focus();\n }\n\n public focusPhoneInput(el: Element): void {\n const input: HTMLElement = el.querySelector(\n '.sky-phone-field-container input'\n );\n input.focus();\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Directive, ElementRef,
|
|
2
|
-
import {
|
|
1
|
+
import { ChangeDetectorRef, Directive, ElementRef, HostListener, Input, Optional, forwardRef, } from '@angular/core';
|
|
2
|
+
import { NG_VALIDATORS, NG_VALUE_ACCESSOR, } from '@angular/forms';
|
|
3
|
+
import { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';
|
|
3
4
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
4
5
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
|
5
|
-
import { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';
|
|
6
|
-
import { SkyPhoneFieldComponent } from './phone-field.component';
|
|
7
6
|
import { SkyPhoneFieldAdapterService } from './phone-field-adapter.service';
|
|
7
|
+
import { SkyPhoneFieldComponent } from './phone-field.component';
|
|
8
8
|
import * as i0 from "@angular/core";
|
|
9
9
|
import * as i1 from "./phone-field-adapter.service";
|
|
10
10
|
import * as i2 from "./phone-field.component";
|
|
@@ -71,7 +71,7 @@ export class SkyPhoneFieldInputDirective {
|
|
|
71
71
|
this._modelValue = value;
|
|
72
72
|
this.adapterService.setElementValue(this.elRef, value);
|
|
73
73
|
if (value) {
|
|
74
|
-
|
|
74
|
+
const formattedValue = this.formatNumber(value.toString());
|
|
75
75
|
this.onChange(formattedValue);
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-field-input.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/phone-field/src/lib/modules/phone-field/phone-field-input.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,QAAQ,GACT,MAA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AQ,CAAC","sourcesContent":["import {\n AfterViewInit,\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n} from '@angular/core';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALUE_ACCESSOR,\n NG_VALIDATORS,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport { BehaviorSubject, Subject } from 'rxjs';\n\nimport { debounceTime, takeUntil } from 'rxjs/operators';\n\nimport { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';\n\nimport { SkyPhoneFieldComponent } from './phone-field.component';\n\nimport { SkyPhoneFieldAdapterService } from './phone-field-adapter.service';\n\nimport { SkyPhoneFieldCountry } from './types/country';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_PHONE_FIELD_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyPhoneFieldInputDirective),\n multi: true,\n};\n\nconst SKY_PHONE_FIELD_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyPhoneFieldInputDirective),\n multi: true,\n};\n// tslint:enable\n\n/**\n * Creates a button, search input, and text input for entering and validating\n * international phone numbers. Place this attribute on an `input` element, and wrap\n * that element in a `sky-phone-field` component. By default, the country selector\n * button displays a flag icon for the default country, and the phone number input\n * displays a sample of the correct phone number format. When users select the country\n * selector button, they expose the country search input, which is\n * [an autocomplete input](https://developer.blackbaud.com/skyux/components/autocomplete)\n * that allows them to select different countries. When users enter `+` followed by an\n * international dial code in the phone number input, the country automatically switches\n * to the country associated with the dial code.\n * @required\n */\n@Directive({\n selector: '[skyPhoneFieldInput]',\n providers: [SKY_PHONE_FIELD_VALUE_ACCESSOR, SKY_PHONE_FIELD_VALIDATOR],\n})\nexport class SkyPhoneFieldInputDirective\n implements OnInit, OnDestroy, AfterViewInit, ControlValueAccessor, Validator\n{\n /**\n * Indicates whether to disable the phone field.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n this.phoneFieldComponent.countrySelectDisabled = value;\n this.adapterService.setElementDisabledState(this.elRef, value);\n this._disabled = value;\n }\n\n public get disabled(): boolean {\n return this._disabled || false;\n }\n\n /**\n * Indicates whether to prevent validation on the phone number input. For validation,\n * phone numbers are driven through the `ngModel` attribute that you specify on an\n * `input` element or on a `FormControl` in a reactive form. To prevent validation,\n * set this property to `true`.\n * @default false\n */\n @Input()\n public skyPhoneFieldNoValidate: boolean = false;\n\n private set modelValue(value: string) {\n this._modelValue = value;\n\n this.adapterService.setElementValue(this.elRef, value);\n\n if (value) {\n let formattedValue = this.formatNumber(value.toString());\n\n this.onChange(formattedValue);\n } else {\n this.onChange(value);\n }\n this.validatorChange();\n }\n\n private get modelValue(): string {\n return this._modelValue;\n }\n\n private control: AbstractControl;\n\n private textChanges: BehaviorSubject<string>;\n\n private ngUnsubscribe = new Subject();\n\n private phoneUtils = PhoneNumberUtil.getInstance();\n\n private _disabled: boolean;\n\n private _modelValue: string;\n\n public constructor(\n private changeDetector: ChangeDetectorRef,\n private elRef: ElementRef,\n @Optional() private adapterService: SkyPhoneFieldAdapterService,\n @Optional() private phoneFieldComponent: SkyPhoneFieldComponent\n ) {}\n\n public ngOnInit(): void {\n if (!this.phoneFieldComponent) {\n throw new Error(\n 'You must wrap the `skyPhoneFieldInput` directive within a ' +\n '`<sky-phone-field>` component!'\n );\n }\n\n this.adapterService.setElementType(this.elRef);\n this.adapterService.addElementClass(this.elRef, 'sky-form-control');\n if (this.phoneFieldComponent.selectedCountry) {\n this.adapterService.setElementPlaceholder(\n this.elRef,\n this.phoneFieldComponent.selectedCountry.exampleNumber\n );\n }\n\n this.adapterService.setAriaLabel(this.elRef);\n }\n\n public ngAfterViewInit(): void {\n this.phoneFieldComponent.selectedCountryChange\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((country: SkyPhoneFieldCountry) => {\n this.modelValue = this.elRef.nativeElement.value;\n this.adapterService.setElementPlaceholder(\n this.elRef,\n country.exampleNumber\n );\n });\n\n // This is needed to address a bug in Angular 4, where the value is not changed on the view.\n // See: https://github.com/angular/angular/issues/13792\n /* istanbul ignore else */\n if (this.control && this.modelValue) {\n this.control.setValue(this.modelValue, { emitEvent: false });\n this.changeDetector.detectChanges();\n }\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Writes the new value for reactive forms on change events on the input element\n * @param event The change event that was received\n */\n @HostListener('change', ['$event'])\n public onInputChange(event: any): void {\n if (!this.textChanges) {\n this.setupTextChangeSubscription(event.target.value);\n } else {\n this.textChanges.next(event.target.value);\n }\n }\n\n /**\n * Marks reactive form controls as touched on input blur events\n */\n @HostListener('blur')\n public onInputBlur(): void {\n this.onTouched();\n }\n\n @HostListener('input', ['$event'])\n public onInputTyping(event: any): void {\n if (!this.textChanges) {\n this.setupTextChangeSubscription(event.target.value);\n } else {\n this.textChanges.next(event.target.value);\n }\n }\n\n /**\n * Writes the new value for reactive forms\n * @param value The new value for the input\n */\n public writeValue(value: string): void {\n this.phoneFieldComponent.setCountryByDialCode(value);\n\n this.modelValue = value;\n }\n\n public registerOnChange(fn: (value: any) => any): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => any): void {\n this.onTouched = fn;\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this.validatorChange = fn;\n }\n\n /**\n * Sets the disabled state on the input\n * @param isDisabled the new value of the input's disabled state\n */\n public setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n\n /**\n * Validate's the form control's current value\n * @param control the form control for the input\n */\n public validate(control: AbstractControl): ValidationErrors {\n if (!this.control) {\n this.control = control;\n }\n\n if (this.skyPhoneFieldNoValidate) {\n return;\n }\n\n const value = control.value;\n\n if (!value) {\n return;\n }\n\n if (\n this.phoneFieldComponent.selectedCountry &&\n !this.validateNumber(value)\n ) {\n if (!this.textChanges) {\n // Mark the invalid control as touched so that the input's invalid CSS styles appear.\n // (This is only required when the invalid value is set by the FormControl constructor.)\n // We don't do this if the input is the active element so that we don't show validation\n // errors unless it is invalid on initialization or the input has been blurred.\n control.markAsTouched();\n }\n\n return {\n skyPhoneField: {\n invalid: value,\n },\n };\n }\n }\n\n private setupTextChangeSubscription(text: string) {\n this.textChanges = new BehaviorSubject(text);\n\n this.textChanges\n .pipe(debounceTime(500), takeUntil(this.ngUnsubscribe))\n .subscribe((newValue) => {\n this.writeValue(newValue);\n });\n }\n\n private validateNumber(phoneNumber: string): boolean {\n try {\n const numberObj = this.phoneUtils.parseAndKeepRawInput(\n phoneNumber,\n this.phoneFieldComponent.selectedCountry.iso2\n );\n\n if (\n !this.phoneFieldComponent.allowExtensions &&\n numberObj.getExtension()\n ) {\n return false;\n }\n\n return this.phoneUtils.isValidNumber(numberObj);\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Format's the given phone number based on the currently selected country.\n * @param phoneNumber The number to format\n */\n private formatNumber(phoneNumber: string): string {\n try {\n const numberObj = this.phoneUtils.parseAndKeepRawInput(\n phoneNumber,\n this.phoneFieldComponent.selectedCountry.iso2\n );\n if (this.phoneUtils.isPossibleNumber(numberObj)) {\n switch (this.phoneFieldComponent.returnFormat) {\n case 'international':\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.INTERNATIONAL\n );\n case 'national':\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.NATIONAL\n );\n case 'default':\n default:\n if (\n this.phoneFieldComponent.selectedCountry.iso2 !==\n this.phoneFieldComponent.defaultCountry\n ) {\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.INTERNATIONAL\n );\n } else {\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.NATIONAL\n );\n }\n }\n } else {\n return phoneNumber;\n }\n } catch (e) {\n /* sanity check */\n /* istanbul ignore next */\n return phoneNumber;\n }\n }\n\n private onChange = (_: any) => {};\n\n /* istanbul ignore next */\n private onTouched = () => {};\n\n /* istanbul ignore next */\n private validatorChange = () => {};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phone-field-input.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/phone-field/src/lib/modules/phone-field/phone-field-input.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,QAAQ,EACR,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,aAAa,EACb,iBAAiB,GAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;;;;AAGjE,sDAAsD;AACtD,MAAM,8BAA8B,GAAG;IACrC,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC;IAC1D,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC;IAC1D,KAAK,EAAE,IAAI;CACZ,CAAC;AACF,gBAAgB;AAEhB;;;;;;;;;;;;GAYG;AAKH,MAAM,OAAO,2BAA2B;IA2DtC,YACU,cAAiC,EACjC,KAAiB,EACL,cAA2C,EAC3C,mBAA2C;QAHvD,mBAAc,GAAd,cAAc,CAAmB;QACjC,UAAK,GAAL,KAAK,CAAY;QACL,mBAAc,GAAd,cAAc,CAA6B;QAC3C,wBAAmB,GAAnB,mBAAmB,CAAwB;QA7CjE;;;;;;WAMG;QAEI,4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Q;;0BACR,QAAQ;4CAvDA,QAAQ;sBADlB,KAAK;gBAmBC,uBAAuB;sBAD7B,KAAK;gBA2FC,aAAa;sBADnB,YAAY;uBAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBAa3B,WAAW;sBADjB,YAAY;uBAAC,MAAM;gBAMb,aAAa;sBADnB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import {\n AfterViewInit,\n ChangeDetectorRef,\n Directive,\n ElementRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n forwardRef,\n} from '@angular/core';\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';\nimport { BehaviorSubject, Subject } from 'rxjs';\nimport { debounceTime, takeUntil } from 'rxjs/operators';\n\nimport { SkyPhoneFieldAdapterService } from './phone-field-adapter.service';\nimport { SkyPhoneFieldComponent } from './phone-field.component';\nimport { SkyPhoneFieldCountry } from './types/country';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_PHONE_FIELD_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyPhoneFieldInputDirective),\n multi: true,\n};\n\nconst SKY_PHONE_FIELD_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyPhoneFieldInputDirective),\n multi: true,\n};\n// tslint:enable\n\n/**\n * Creates a button, search input, and text input for entering and validating\n * international phone numbers. Place this attribute on an `input` element, and wrap\n * that element in a `sky-phone-field` component. By default, the country selector\n * button displays a flag icon for the default country, and the phone number input\n * displays a sample of the correct phone number format. When users select the country\n * selector button, they expose the country search input, which is\n * [an autocomplete input](https://developer.blackbaud.com/skyux/components/autocomplete)\n * that allows them to select different countries. When users enter `+` followed by an\n * international dial code in the phone number input, the country automatically switches\n * to the country associated with the dial code.\n * @required\n */\n@Directive({\n selector: '[skyPhoneFieldInput]',\n providers: [SKY_PHONE_FIELD_VALUE_ACCESSOR, SKY_PHONE_FIELD_VALIDATOR],\n})\nexport class SkyPhoneFieldInputDirective\n implements OnInit, OnDestroy, AfterViewInit, ControlValueAccessor, Validator\n{\n /**\n * Indicates whether to disable the phone field.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n this.phoneFieldComponent.countrySelectDisabled = value;\n this.adapterService.setElementDisabledState(this.elRef, value);\n this._disabled = value;\n }\n\n public get disabled(): boolean {\n return this._disabled || false;\n }\n\n /**\n * Indicates whether to prevent validation on the phone number input. For validation,\n * phone numbers are driven through the `ngModel` attribute that you specify on an\n * `input` element or on a `FormControl` in a reactive form. To prevent validation,\n * set this property to `true`.\n * @default false\n */\n @Input()\n public skyPhoneFieldNoValidate = false;\n\n private set modelValue(value: string) {\n this._modelValue = value;\n\n this.adapterService.setElementValue(this.elRef, value);\n\n if (value) {\n const formattedValue = this.formatNumber(value.toString());\n\n this.onChange(formattedValue);\n } else {\n this.onChange(value);\n }\n this.validatorChange();\n }\n\n private get modelValue(): string {\n return this._modelValue;\n }\n\n private control: AbstractControl;\n\n private textChanges: BehaviorSubject<string>;\n\n private ngUnsubscribe = new Subject();\n\n private phoneUtils = PhoneNumberUtil.getInstance();\n\n private _disabled: boolean;\n\n private _modelValue: string;\n\n public constructor(\n private changeDetector: ChangeDetectorRef,\n private elRef: ElementRef,\n @Optional() private adapterService: SkyPhoneFieldAdapterService,\n @Optional() private phoneFieldComponent: SkyPhoneFieldComponent\n ) {}\n\n public ngOnInit(): void {\n if (!this.phoneFieldComponent) {\n throw new Error(\n 'You must wrap the `skyPhoneFieldInput` directive within a ' +\n '`<sky-phone-field>` component!'\n );\n }\n\n this.adapterService.setElementType(this.elRef);\n this.adapterService.addElementClass(this.elRef, 'sky-form-control');\n if (this.phoneFieldComponent.selectedCountry) {\n this.adapterService.setElementPlaceholder(\n this.elRef,\n this.phoneFieldComponent.selectedCountry.exampleNumber\n );\n }\n\n this.adapterService.setAriaLabel(this.elRef);\n }\n\n public ngAfterViewInit(): void {\n this.phoneFieldComponent.selectedCountryChange\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((country: SkyPhoneFieldCountry) => {\n this.modelValue = this.elRef.nativeElement.value;\n this.adapterService.setElementPlaceholder(\n this.elRef,\n country.exampleNumber\n );\n });\n\n // This is needed to address a bug in Angular 4, where the value is not changed on the view.\n // See: https://github.com/angular/angular/issues/13792\n /* istanbul ignore else */\n if (this.control && this.modelValue) {\n this.control.setValue(this.modelValue, { emitEvent: false });\n this.changeDetector.detectChanges();\n }\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Writes the new value for reactive forms on change events on the input element\n * @param event The change event that was received\n */\n @HostListener('change', ['$event'])\n public onInputChange(event: any): void {\n if (!this.textChanges) {\n this.setupTextChangeSubscription(event.target.value);\n } else {\n this.textChanges.next(event.target.value);\n }\n }\n\n /**\n * Marks reactive form controls as touched on input blur events\n */\n @HostListener('blur')\n public onInputBlur(): void {\n this.onTouched();\n }\n\n @HostListener('input', ['$event'])\n public onInputTyping(event: any): void {\n if (!this.textChanges) {\n this.setupTextChangeSubscription(event.target.value);\n } else {\n this.textChanges.next(event.target.value);\n }\n }\n\n /**\n * Writes the new value for reactive forms\n * @param value The new value for the input\n */\n public writeValue(value: string): void {\n this.phoneFieldComponent.setCountryByDialCode(value);\n\n this.modelValue = value;\n }\n\n public registerOnChange(fn: (value: any) => any): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => any): void {\n this.onTouched = fn;\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this.validatorChange = fn;\n }\n\n /**\n * Sets the disabled state on the input\n * @param isDisabled the new value of the input's disabled state\n */\n public setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n\n /**\n * Validate's the form control's current value\n * @param control the form control for the input\n */\n public validate(control: AbstractControl): ValidationErrors {\n if (!this.control) {\n this.control = control;\n }\n\n if (this.skyPhoneFieldNoValidate) {\n return;\n }\n\n const value = control.value;\n\n if (!value) {\n return;\n }\n\n if (\n this.phoneFieldComponent.selectedCountry &&\n !this.validateNumber(value)\n ) {\n if (!this.textChanges) {\n // Mark the invalid control as touched so that the input's invalid CSS styles appear.\n // (This is only required when the invalid value is set by the FormControl constructor.)\n // We don't do this if the input is the active element so that we don't show validation\n // errors unless it is invalid on initialization or the input has been blurred.\n control.markAsTouched();\n }\n\n return {\n skyPhoneField: {\n invalid: value,\n },\n };\n }\n }\n\n private setupTextChangeSubscription(text: string) {\n this.textChanges = new BehaviorSubject(text);\n\n this.textChanges\n .pipe(debounceTime(500), takeUntil(this.ngUnsubscribe))\n .subscribe((newValue) => {\n this.writeValue(newValue);\n });\n }\n\n private validateNumber(phoneNumber: string): boolean {\n try {\n const numberObj = this.phoneUtils.parseAndKeepRawInput(\n phoneNumber,\n this.phoneFieldComponent.selectedCountry.iso2\n );\n\n if (\n !this.phoneFieldComponent.allowExtensions &&\n numberObj.getExtension()\n ) {\n return false;\n }\n\n return this.phoneUtils.isValidNumber(numberObj);\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Format's the given phone number based on the currently selected country.\n * @param phoneNumber The number to format\n */\n private formatNumber(phoneNumber: string): string {\n try {\n const numberObj = this.phoneUtils.parseAndKeepRawInput(\n phoneNumber,\n this.phoneFieldComponent.selectedCountry.iso2\n );\n if (this.phoneUtils.isPossibleNumber(numberObj)) {\n switch (this.phoneFieldComponent.returnFormat) {\n case 'international':\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.INTERNATIONAL\n );\n case 'national':\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.NATIONAL\n );\n case 'default':\n default:\n if (\n this.phoneFieldComponent.selectedCountry.iso2 !==\n this.phoneFieldComponent.defaultCountry\n ) {\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.INTERNATIONAL\n );\n } else {\n return this.phoneUtils.format(\n numberObj,\n PhoneNumberFormat.NATIONAL\n );\n }\n }\n } else {\n return phoneNumber;\n }\n } catch (e) {\n /* sanity check */\n /* istanbul ignore next */\n return phoneNumber;\n }\n }\n\n private onChange = (_: any) => {};\n\n /* istanbul ignore next */\n private onTouched = () => {};\n\n /* istanbul ignore next */\n private validatorChange = () => {};\n}\n"]}
|
|
@@ -55,7 +55,7 @@ export class SkyPhoneFieldComponent {
|
|
|
55
55
|
* to the main window object.
|
|
56
56
|
*/
|
|
57
57
|
this.countries = JSON.parse(JSON.stringify(window.intlTelInputGlobals.getCountryData()));
|
|
58
|
-
for (
|
|
58
|
+
for (const country of this.countries) {
|
|
59
59
|
country.dialCode = '+' + country.dialCode;
|
|
60
60
|
if (country.dialCode.length > this.longestDialCodeLength) {
|
|
61
61
|
this.longestDialCodeLength = country.dialCode.length;
|
|
@@ -178,7 +178,7 @@ export class SkyPhoneFieldComponent {
|
|
|
178
178
|
}
|
|
179
179
|
let newCountry;
|
|
180
180
|
for (let i = 1; i < this.longestDialCodeLength + 1; i++) {
|
|
181
|
-
|
|
181
|
+
const dialCode = phoneNumber.substring(0, i);
|
|
182
182
|
let foundCountry = this.countries.find((country) => country.dialCode === dialCode && country.priority === 0);
|
|
183
183
|
if (foundCountry) {
|
|
184
184
|
// Ensure that the country that was found is one of the supported countries
|