@bravura/ui 1.6.0 → 1.8.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +36 -11
  2. package/LICENSE +6 -6
  3. package/behavior/behavior.module.d.ts +12 -12
  4. package/behavior/bravura-ui-behavior.d.ts +5 -5
  5. package/behavior/public-api.d.ts +3 -3
  6. package/behavior/sizing-monitor.directive.d.ts +23 -23
  7. package/behavior/sizing.directive.d.ts +94 -88
  8. package/bravura-ui.d.ts +5 -5
  9. package/bundles/bravura-ui-behavior.umd.js +631 -601
  10. package/bundles/bravura-ui-behavior.umd.js.map +1 -1
  11. package/bundles/bravura-ui-discrete-input.umd.js +695 -697
  12. package/bundles/bravura-ui-discrete-input.umd.js.map +1 -1
  13. package/bundles/bravura-ui-form-field.umd.js +440 -434
  14. package/bundles/bravura-ui-form-field.umd.js.map +1 -1
  15. package/bundles/bravura-ui-icon-font.umd.js +488 -490
  16. package/bundles/bravura-ui-icon-font.umd.js.map +1 -1
  17. package/bundles/bravura-ui-phone-number.umd.js +634 -636
  18. package/bundles/bravura-ui-phone-number.umd.js.map +1 -1
  19. package/bundles/bravura-ui-radio-panel.umd.js +466 -468
  20. package/bundles/bravura-ui-radio-panel.umd.js.map +1 -1
  21. package/bundles/bravura-ui-selection-panel.umd.js +613 -615
  22. package/bundles/bravura-ui-selection-panel.umd.js.map +1 -1
  23. package/bundles/bravura-ui-tooltip.umd.js +518 -479
  24. package/bundles/bravura-ui-tooltip.umd.js.map +1 -1
  25. package/bundles/bravura-ui.umd.js +4 -4
  26. package/bundles/bravura-ui.umd.js.map +1 -1
  27. package/discrete-input/bravura-ui-discrete-input.d.ts +5 -5
  28. package/discrete-input/discrete-input.component.d.ts +138 -138
  29. package/discrete-input/discrete-input.module.d.ts +11 -11
  30. package/discrete-input/public-api.d.ts +2 -2
  31. package/esm2015/behavior/behavior.module.js +21 -21
  32. package/esm2015/behavior/bravura-ui-behavior.js +4 -4
  33. package/esm2015/behavior/public-api.js +3 -3
  34. package/esm2015/behavior/sizing-monitor.directive.js +30 -30
  35. package/esm2015/behavior/sizing.directive.js +245 -217
  36. package/esm2015/bravura-ui.js +4 -4
  37. package/esm2015/discrete-input/bravura-ui-discrete-input.js +4 -4
  38. package/esm2015/discrete-input/discrete-input.component.js +332 -332
  39. package/esm2015/discrete-input/discrete-input.module.js +19 -19
  40. package/esm2015/discrete-input/public-api.js +2 -2
  41. package/esm2015/form-field/bravura-ui-form-field.js +4 -4
  42. package/esm2015/form-field/form-field.component.js +104 -96
  43. package/esm2015/form-field/form-field.module.js +19 -19
  44. package/esm2015/form-field/public-api.js +2 -2
  45. package/esm2015/icon-font/bravura-ui-icon-font.js +4 -4
  46. package/esm2015/icon-font/icon-font.module.js +21 -21
  47. package/esm2015/icon-font/icon.directive.js +101 -101
  48. package/esm2015/icon-font/public-api.js +3 -3
  49. package/esm2015/icon-font/utilities.js +50 -50
  50. package/esm2015/phone-number/bravura-ui-phone-number.js +4 -4
  51. package/esm2015/phone-number/phone-number.directive.js +191 -191
  52. package/esm2015/phone-number/phone-number.module.js +23 -23
  53. package/esm2015/phone-number/phone-number.pipe.js +46 -46
  54. package/esm2015/phone-number/phone-number.validator.js +63 -63
  55. package/esm2015/phone-number/public-api.js +1 -1
  56. package/esm2015/public-api.js +2 -2
  57. package/esm2015/radio-panel/bravura-ui-radio-panel.js +4 -4
  58. package/esm2015/radio-panel/public-api.js +4 -4
  59. package/esm2015/radio-panel/radio-panel-item.component.js +76 -76
  60. package/esm2015/radio-panel/radio-panel.directive.js +59 -59
  61. package/esm2015/radio-panel/radio-panel.module.js +24 -24
  62. package/esm2015/selection-panel/bravura-ui-selection-panel.js +4 -4
  63. package/esm2015/selection-panel/public-api.js +3 -3
  64. package/esm2015/selection-panel/selection-panel-item.component.js +143 -143
  65. package/esm2015/selection-panel/selection-panel.directive.js +116 -116
  66. package/esm2015/selection-panel/selection-panel.module.js +20 -20
  67. package/esm2015/tooltip/bravura-ui-tooltip.js +4 -4
  68. package/esm2015/tooltip/public-api.js +2 -2
  69. package/esm2015/tooltip/tooltip.component.js +52 -44
  70. package/esm2015/tooltip/tooltip.directive.js +110 -83
  71. package/esm2015/tooltip/tooltip.module.js +25 -25
  72. package/fesm2015/bravura-ui-behavior.js +281 -253
  73. package/fesm2015/bravura-ui-behavior.js.map +1 -1
  74. package/fesm2015/bravura-ui-discrete-input.js +332 -332
  75. package/fesm2015/bravura-ui-form-field.js +111 -103
  76. package/fesm2015/bravura-ui-form-field.js.map +1 -1
  77. package/fesm2015/bravura-ui-icon-font.js +162 -162
  78. package/fesm2015/bravura-ui-phone-number.js +300 -300
  79. package/fesm2015/bravura-ui-radio-panel.js +135 -135
  80. package/fesm2015/bravura-ui-selection-panel.js +258 -258
  81. package/fesm2015/bravura-ui-tooltip.js +163 -128
  82. package/fesm2015/bravura-ui-tooltip.js.map +1 -1
  83. package/fesm2015/bravura-ui.js +2 -2
  84. package/fesm2015/bravura-ui.js.map +1 -1
  85. package/form-field/bravura-ui-form-field.d.ts +5 -5
  86. package/form-field/form-field.component.d.ts +27 -27
  87. package/form-field/form-field.module.d.ts +10 -10
  88. package/form-field/public-api.d.ts +2 -2
  89. package/icon-font/bravura-ui-icon-font.d.ts +5 -5
  90. package/icon-font/icon-font.module.d.ts +12 -12
  91. package/icon-font/icon.directive.d.ts +46 -46
  92. package/icon-font/public-api.d.ts +3 -3
  93. package/icon-font/utilities.d.ts +20 -20
  94. package/package.json +1 -1
  95. package/phone-number/bravura-ui-phone-number.d.ts +5 -5
  96. package/phone-number/phone-number.directive.d.ts +66 -66
  97. package/phone-number/phone-number.module.d.ts +17 -17
  98. package/phone-number/phone-number.pipe.d.ts +13 -13
  99. package/phone-number/phone-number.validator.d.ts +31 -31
  100. package/phone-number/public-api.d.ts +1 -1
  101. package/public-api.d.ts +1 -1
  102. package/radio-panel/bravura-ui-radio-panel.d.ts +5 -5
  103. package/radio-panel/public-api.d.ts +3 -3
  104. package/radio-panel/radio-panel-item.component.d.ts +17 -17
  105. package/radio-panel/radio-panel.directive.d.ts +26 -26
  106. package/radio-panel/radio-panel.module.d.ts +15 -15
  107. package/selection-panel/bravura-ui-selection-panel.d.ts +5 -5
  108. package/selection-panel/public-api.d.ts +3 -3
  109. package/selection-panel/selection-panel-item.component.d.ts +63 -63
  110. package/selection-panel/selection-panel.directive.d.ts +67 -67
  111. package/selection-panel/selection-panel.module.d.ts +12 -12
  112. package/tooltip/bravura-ui-tooltip.d.ts +5 -5
  113. package/tooltip/public-api.d.ts +2 -2
  114. package/tooltip/tooltip.component.d.ts +24 -14
  115. package/tooltip/tooltip.directive.d.ts +39 -36
  116. package/tooltip/tooltip.module.d.ts +13 -13
@@ -8,314 +8,314 @@ import * as i1 from '@angular/forms';
8
8
  import { NG_VALIDATORS } from '@angular/forms';
9
9
  import * as i2 from '@angular/material/form-field';
10
10
 
11
- /**
12
- * @internal
13
- */
14
- class PhoneNumberPipe {
15
- constructor(_locale) {
16
- this._locale = _locale;
17
- }
18
- transform(value, mode, renderLink) {
19
- if (!value) {
20
- return value;
21
- }
22
- const countryCode = getCountryCodeFromLocale(this._locale);
23
- let format;
24
- switch (mode) {
25
- case 'NATIONAL':
26
- format = intlTelInputUtils.numberFormat.NATIONAL;
27
- break;
28
- default:
29
- format = intlTelInputUtils.numberFormat.INTERNATIONAL;
30
- }
31
- const result = intlTelInputUtils.formatNumber(value, countryCode, format);
32
- if (renderLink) {
33
- return `<a href="tel:${result}">${result}</a>`;
34
- }
35
- else {
36
- return result;
37
- }
38
- }
39
- }
40
- PhoneNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
41
- PhoneNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberPipe, name: "buiPhone" });
42
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberPipe, decorators: [{
43
- type: Pipe,
44
- args: [{
45
- name: 'buiPhone',
46
- pure: true
47
- }]
48
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
49
- type: Inject,
50
- args: [LOCALE_ID]
51
- }] }]; } });
52
- function getCountryCodeFromLocale(locale) {
53
- return locale.replace(/.+[-_]([a-z][a-z])$/i, '$1');
11
+ /**
12
+ * @internal
13
+ */
14
+ class PhoneNumberPipe {
15
+ constructor(_locale) {
16
+ this._locale = _locale;
17
+ }
18
+ transform(value, mode, renderLink) {
19
+ if (!value) {
20
+ return value;
21
+ }
22
+ const countryCode = getCountryCodeFromLocale(this._locale);
23
+ let format;
24
+ switch (mode) {
25
+ case 'NATIONAL':
26
+ format = intlTelInputUtils.numberFormat.NATIONAL;
27
+ break;
28
+ default:
29
+ format = intlTelInputUtils.numberFormat.INTERNATIONAL;
30
+ }
31
+ const result = intlTelInputUtils.formatNumber(value, countryCode, format);
32
+ if (renderLink) {
33
+ return `<a href="tel:${result}">${result}</a>`;
34
+ }
35
+ else {
36
+ return result;
37
+ }
38
+ }
39
+ }
40
+ PhoneNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
41
+ PhoneNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberPipe, name: "buiPhone" });
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberPipe, decorators: [{
43
+ type: Pipe,
44
+ args: [{
45
+ name: 'buiPhone',
46
+ pure: true
47
+ }]
48
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
49
+ type: Inject,
50
+ args: [LOCALE_ID]
51
+ }] }]; } });
52
+ function getCountryCodeFromLocale(locale) {
53
+ return locale.replace(/.+[-_]([a-z][a-z])$/i, '$1');
54
54
  }
55
55
 
56
- /**
57
- * @internal
58
- */
59
- const SELECTOR = '[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]';
60
- /**
61
- * @internal
62
- */
63
- const PHONE_VALIDATOR = {
64
- provide: NG_VALIDATORS,
65
- useExisting: forwardRef(() => PhoneNumberValidator),
66
- multi: true
67
- };
68
- /**
69
- * @internal
70
- */
71
- class PhoneNumberValidator {
72
- constructor(_el) {
73
- this._el = _el;
74
- this.telType = 'FIXED_LINE';
75
- }
76
- static validateControl(inp, type, update) {
77
- const err = { tel: true };
78
- if (!inp.value) {
79
- return null;
80
- }
81
- const iti = inp.$$iti;
82
- if (!iti) {
83
- return null;
84
- }
85
- if (iti.isValidNumber()) {
86
- const n = iti.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL);
87
- if (update) {
88
- inp.value = n;
89
- }
90
- const t = iti.getNumberType();
91
- if (t !== intlTelInputUtils.numberType.FIXED_LINE_OR_MOBILE) {
92
- if ((type === 'MOBILE' && t !== intlTelInputUtils.numberType.MOBILE) ||
93
- (type === 'FIXED_LINE' && t !== intlTelInputUtils.numberType.FIXED_LINE)) {
94
- return err;
95
- }
96
- }
97
- return null;
98
- }
99
- return err;
100
- }
101
- validate(_) {
102
- return PhoneNumberValidator.validateControl(this._el.nativeElement, this.telType, false);
103
- }
104
- }
105
- PhoneNumberValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberValidator, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
106
- PhoneNumberValidator.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.4", type: PhoneNumberValidator, selector: "[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]", inputs: { telType: "telType" }, providers: [PHONE_VALIDATOR], ngImport: i0 });
107
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberValidator, decorators: [{
108
- type: Directive,
109
- args: [{
110
- selector: SELECTOR,
111
- providers: [PHONE_VALIDATOR]
112
- }]
113
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { telType: [{
114
- type: Input
56
+ /**
57
+ * @internal
58
+ */
59
+ const SELECTOR = '[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]';
60
+ /**
61
+ * @internal
62
+ */
63
+ const PHONE_VALIDATOR = {
64
+ provide: NG_VALIDATORS,
65
+ useExisting: forwardRef(() => PhoneNumberValidator),
66
+ multi: true
67
+ };
68
+ /**
69
+ * @internal
70
+ */
71
+ class PhoneNumberValidator {
72
+ constructor(_el) {
73
+ this._el = _el;
74
+ this.telType = 'FIXED_LINE';
75
+ }
76
+ static validateControl(inp, type, update) {
77
+ const err = { tel: true };
78
+ if (!inp.value) {
79
+ return null;
80
+ }
81
+ const iti = inp.$$iti;
82
+ if (!iti) {
83
+ return null;
84
+ }
85
+ if (iti.isValidNumber()) {
86
+ const n = iti.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL);
87
+ if (update) {
88
+ inp.value = n;
89
+ }
90
+ const t = iti.getNumberType();
91
+ if (t !== intlTelInputUtils.numberType.FIXED_LINE_OR_MOBILE) {
92
+ if ((type === 'MOBILE' && t !== intlTelInputUtils.numberType.MOBILE) ||
93
+ (type === 'FIXED_LINE' && t !== intlTelInputUtils.numberType.FIXED_LINE)) {
94
+ return err;
95
+ }
96
+ }
97
+ return null;
98
+ }
99
+ return err;
100
+ }
101
+ validate(_) {
102
+ return PhoneNumberValidator.validateControl(this._el.nativeElement, this.telType, false);
103
+ }
104
+ }
105
+ PhoneNumberValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberValidator, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
106
+ PhoneNumberValidator.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.7", type: PhoneNumberValidator, selector: "[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]", inputs: { telType: "telType" }, providers: [PHONE_VALIDATOR], ngImport: i0 });
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberValidator, decorators: [{
108
+ type: Directive,
109
+ args: [{
110
+ selector: SELECTOR,
111
+ providers: [PHONE_VALIDATOR]
112
+ }]
113
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { telType: [{
114
+ type: Input
115
115
  }] } });
116
116
 
117
- /**
118
- * Add phone number validation support by specifying the `type` attribute as `tel` in an `<input>` element.
119
- *
120
- * To use this feature, please install a peer dependency `intl-tel-input` in your project and add the following
121
- * to your application polyfills:
122
- *
123
- * ```javascript
124
- * import 'intl-tel-input/build/js/utils.js';
125
- * ```
126
- *
127
- * You will also need to add the following statements to one of your global SCSS files:
128
- *
129
- * ```scss
130
- * $flagsImagePath: '~intl-tel-input/build/img/' !default;
131
- * @import '~intl-tel-input/src/css/intlTelInput';
132
- * ```
133
- */
134
- class PhoneNumberDirective {
135
- constructor(_el, _ngModel, _formControlName, _formControlDirective, _locale, _zone, _matField) {
136
- this._el = _el;
137
- this._ngModel = _ngModel;
138
- this._formControlName = _formControlName;
139
- this._formControlDirective = _formControlDirective;
140
- this._locale = _locale;
141
- this._zone = _zone;
142
- this._matField = _matField;
143
- /**
144
- * The type of phone number to validate for
145
- */
146
- this.telType = 'FIXED_LINE';
147
- /**
148
- * Disable country dropdown by setting this property to `false`.
149
- */
150
- this.telDropdown = true;
151
- /**
152
- * This event is triggered when a new country is selected from the dropdown. The event detail is the ISO country code.
153
- */
154
- this.telCountryChange = new EventEmitter();
155
- this._reactive = false;
156
- this._countryChangeListener = () => null;
157
- }
158
- /** @internal */
159
- onInput() {
160
- const err = PhoneNumberValidator.validateControl(this._input, this.telType, true);
161
- this._control.patchValue(this._input.value, { emitEvent: false });
162
- if (this._reactive && err) {
163
- this._control.setErrors(Object.assign(Object.assign({}, this._control.errors), err));
164
- }
165
- }
166
- ngOnInit() {
167
- const ctrDirective = this._ngModel || this._formControlName || this._formControlDirective;
168
- this._control = ctrDirective.control;
169
- this._reactive = this._ngModel ? false : true;
170
- this._input = this._el.nativeElement;
171
- this._countryChangeListener = (() => {
172
- this._zone.run(() => {
173
- this._control.markAsDirty();
174
- this._control.updateValueAndValidity({ emitEvent: true });
175
- this.telCountryChange.emit(this._iti.getSelectedCountryData().iso2);
176
- });
177
- }).bind(this);
178
- (PhoneNumberDirective.BYPASS_SHADOW_DETECTION ? of(0) : this._zone.onStable)
179
- .pipe(debounceTime(10), take(1))
180
- .subscribe(() => this.initElement());
181
- }
182
- ngOnDestroy() {
183
- var _a;
184
- this._input.removeEventListener('countrychange', this._countryChangeListener);
185
- (_a = this._iti) === null || _a === void 0 ? void 0 : _a.destroy();
186
- }
187
- ngOnChanges(changes) {
188
- const td = changes.telDropdown;
189
- if (td && !td.firstChange) {
190
- this.ngOnDestroy();
191
- this.ngOnInit();
192
- }
193
- const type = changes.telType;
194
- if (type && !type.firstChange) {
195
- this.onInput();
196
- }
197
- }
198
- initElement() {
199
- var _a;
200
- const countryCode = getCountryCodeFromLocale(this._locale).toLowerCase();
201
- const root = this._input.getRootNode();
202
- if (!root.querySelector('#bui-tel-input-style')) {
203
- const styleTag = document.createElement('style');
204
- styleTag.id = 'bui-tel-input-style';
205
- styleTag.innerText =
206
- '.mat-form-field:not(.mat-focused) .bui-tel-input-placeholder.mat-empty { margin-left: 52px }' +
207
- '.bui-tel-input-with-value:disabled { cursor: pointer;}';
208
- (root instanceof Document ? root.querySelector('head') : root).appendChild(styleTag);
209
- }
210
- this._iti = intlTelInput(this._input, {
211
- initialCountry: countryCode,
212
- placeholderNumberType: this.telType,
213
- preferredCountries: [countryCode, ...['au', 'ca', 'nz', 'us', 'gb'].filter(c => c !== countryCode)],
214
- dropdownContainer: root instanceof ShadowRoot ? root.querySelector('overlay-root') : root.body,
215
- autoPlaceholder: 'off',
216
- allowDropdown: this.telDropdown
217
- });
218
- this._input.$$iti = this._iti;
219
- this._input.addEventListener('countrychange', this._countryChangeListener);
220
- const frameTime = Date.now();
221
- const postRenderWork = () => {
222
- var _a, _b;
223
- if (frameTime + PhoneNumberDirective.POST_RENDER_INIT_DELAY > Date.now()) {
224
- window.requestAnimationFrame(postRenderWork);
225
- return;
226
- }
227
- let label;
228
- if (((_a = this._matField) === null || _a === void 0 ? void 0 : _a.getLabelId()) && typeof root.getElementById === 'function') {
229
- label = root.getElementById(this._matField.getLabelId());
230
- label === null || label === void 0 ? void 0 : label.classList.remove('bui-tel-input-placeholder');
231
- }
232
- if (label && this.telDropdown) {
233
- label.classList.add('bui-tel-input-placeholder');
234
- }
235
- if ((_b = this._input) === null || _b === void 0 ? void 0 : _b.value) {
236
- this._input.classList.add('bui-tel-input-with-value');
237
- }
238
- };
239
- window.requestAnimationFrame(postRenderWork);
240
- this._input.addEventListener('click', () => {
241
- var _a;
242
- if (((_a = this._control) === null || _a === void 0 ? void 0 : _a.disabled) && this._control.value) {
243
- window.location.href = 'tel://' + this._control.value;
244
- }
245
- });
246
- (_a = this._control) === null || _a === void 0 ? void 0 : _a.registerOnDisabledChange(isDisabled => this._patchValueByState(isDisabled));
247
- this._patchValueByState(this._control.disabled);
248
- }
249
- _patchValueByState(isDisabled) {
250
- setTimeout(() => {
251
- var _a, _b;
252
- if (!isDisabled) {
253
- this.onInput();
254
- }
255
- else {
256
- const v = this._iti.getNumber(intlTelInputUtils.numberFormat.NATIONAL);
257
- this._input.value = v;
258
- (_a = this._control) === null || _a === void 0 ? void 0 : _a.patchValue((_b = this._input) === null || _b === void 0 ? void 0 : _b.value, { emitEvent: false });
259
- }
260
- }, 20);
261
- }
262
- }
263
- /**
264
- * @ignore
265
- */
266
- PhoneNumberDirective.POST_RENDER_INIT_DELAY = 20;
267
- /**
268
- * @ignore
269
- */
270
- PhoneNumberDirective.BYPASS_SHADOW_DETECTION = false;
271
- PhoneNumberDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberDirective, deps: [{ token: i0.ElementRef }, { token: i1.NgModel, optional: true }, { token: i1.FormControlName, optional: true }, { token: i1.FormControlDirective, optional: true }, { token: LOCALE_ID }, { token: i0.NgZone }, { token: i2.MatFormField, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
272
- PhoneNumberDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.4", type: PhoneNumberDirective, selector: "[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]", inputs: { telType: "telType", telDropdown: "telDropdown" }, outputs: { telCountryChange: "telCountryChange" }, host: { listeners: { "input": "onInput()" } }, usesOnChanges: true, ngImport: i0 });
273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneNumberDirective, decorators: [{
274
- type: Directive,
275
- args: [{
276
- selector: SELECTOR
277
- }]
278
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.NgModel, decorators: [{
279
- type: Optional
280
- }] }, { type: i1.FormControlName, decorators: [{
281
- type: Optional
282
- }] }, { type: i1.FormControlDirective, decorators: [{
283
- type: Optional
284
- }] }, { type: undefined, decorators: [{
285
- type: Inject,
286
- args: [LOCALE_ID]
287
- }] }, { type: i0.NgZone }, { type: i2.MatFormField, decorators: [{
288
- type: Optional
289
- }] }]; }, propDecorators: { telType: [{
290
- type: Input
291
- }], telDropdown: [{
292
- type: Input
293
- }], telCountryChange: [{
294
- type: Output
295
- }], onInput: [{
296
- type: HostListener,
297
- args: ['input']
117
+ /**
118
+ * Add phone number validation support by specifying the `type` attribute as `tel` in an `<input>` element.
119
+ *
120
+ * To use this feature, please install a peer dependency `intl-tel-input` in your project and add the following
121
+ * to your application polyfills:
122
+ *
123
+ * ```javascript
124
+ * import 'intl-tel-input/build/js/utils.js';
125
+ * ```
126
+ *
127
+ * You will also need to add the following statements to one of your global SCSS files:
128
+ *
129
+ * ```scss
130
+ * $flagsImagePath: '~intl-tel-input/build/img/' !default;
131
+ * @import '~intl-tel-input/src/css/intlTelInput';
132
+ * ```
133
+ */
134
+ class PhoneNumberDirective {
135
+ constructor(_el, _ngModel, _formControlName, _formControlDirective, _locale, _zone, _matField) {
136
+ this._el = _el;
137
+ this._ngModel = _ngModel;
138
+ this._formControlName = _formControlName;
139
+ this._formControlDirective = _formControlDirective;
140
+ this._locale = _locale;
141
+ this._zone = _zone;
142
+ this._matField = _matField;
143
+ /**
144
+ * The type of phone number to validate for
145
+ */
146
+ this.telType = 'FIXED_LINE';
147
+ /**
148
+ * Disable country dropdown by setting this property to `false`.
149
+ */
150
+ this.telDropdown = true;
151
+ /**
152
+ * This event is triggered when a new country is selected from the dropdown. The event detail is the ISO country code.
153
+ */
154
+ this.telCountryChange = new EventEmitter();
155
+ this._reactive = false;
156
+ this._countryChangeListener = () => null;
157
+ }
158
+ /** @internal */
159
+ onInput() {
160
+ const err = PhoneNumberValidator.validateControl(this._input, this.telType, true);
161
+ this._control.patchValue(this._input.value, { emitEvent: false });
162
+ if (this._reactive && err) {
163
+ this._control.setErrors(Object.assign(Object.assign({}, this._control.errors), err));
164
+ }
165
+ }
166
+ ngOnInit() {
167
+ const ctrDirective = this._ngModel || this._formControlName || this._formControlDirective;
168
+ this._control = ctrDirective.control;
169
+ this._reactive = this._ngModel ? false : true;
170
+ this._input = this._el.nativeElement;
171
+ this._countryChangeListener = (() => {
172
+ this._zone.run(() => {
173
+ this._control.markAsDirty();
174
+ this._control.updateValueAndValidity({ emitEvent: true });
175
+ this.telCountryChange.emit(this._iti.getSelectedCountryData().iso2);
176
+ });
177
+ }).bind(this);
178
+ (PhoneNumberDirective.BYPASS_SHADOW_DETECTION ? of(0) : this._zone.onStable)
179
+ .pipe(debounceTime(10), take(1))
180
+ .subscribe(() => this.initElement());
181
+ }
182
+ ngOnDestroy() {
183
+ var _a;
184
+ this._input.removeEventListener('countrychange', this._countryChangeListener);
185
+ (_a = this._iti) === null || _a === void 0 ? void 0 : _a.destroy();
186
+ }
187
+ ngOnChanges(changes) {
188
+ const td = changes.telDropdown;
189
+ if (td && !td.firstChange) {
190
+ this.ngOnDestroy();
191
+ this.ngOnInit();
192
+ }
193
+ const type = changes.telType;
194
+ if (type && !type.firstChange) {
195
+ this.onInput();
196
+ }
197
+ }
198
+ initElement() {
199
+ var _a;
200
+ const countryCode = getCountryCodeFromLocale(this._locale).toLowerCase();
201
+ const root = this._input.getRootNode();
202
+ if (!root.querySelector('#bui-tel-input-style')) {
203
+ const styleTag = document.createElement('style');
204
+ styleTag.id = 'bui-tel-input-style';
205
+ styleTag.innerText =
206
+ '.mat-form-field:not(.mat-focused) .bui-tel-input-placeholder.mat-empty { margin-left: 52px }' +
207
+ '.bui-tel-input-with-value:disabled { cursor: pointer;}';
208
+ (root instanceof Document ? root.querySelector('head') : root).appendChild(styleTag);
209
+ }
210
+ this._iti = intlTelInput(this._input, {
211
+ initialCountry: countryCode,
212
+ placeholderNumberType: this.telType,
213
+ preferredCountries: [countryCode, ...['au', 'ca', 'nz', 'us', 'gb'].filter(c => c !== countryCode)],
214
+ dropdownContainer: root instanceof ShadowRoot ? root.querySelector('overlay-root') : root.body,
215
+ autoPlaceholder: 'off',
216
+ allowDropdown: this.telDropdown
217
+ });
218
+ this._input.$$iti = this._iti;
219
+ this._input.addEventListener('countrychange', this._countryChangeListener);
220
+ const frameTime = Date.now();
221
+ const postRenderWork = () => {
222
+ var _a, _b;
223
+ if (frameTime + PhoneNumberDirective.POST_RENDER_INIT_DELAY > Date.now()) {
224
+ window.requestAnimationFrame(postRenderWork);
225
+ return;
226
+ }
227
+ let label;
228
+ if (((_a = this._matField) === null || _a === void 0 ? void 0 : _a.getLabelId()) && typeof root.getElementById === 'function') {
229
+ label = root.getElementById(this._matField.getLabelId());
230
+ label === null || label === void 0 ? void 0 : label.classList.remove('bui-tel-input-placeholder');
231
+ }
232
+ if (label && this.telDropdown) {
233
+ label.classList.add('bui-tel-input-placeholder');
234
+ }
235
+ if ((_b = this._input) === null || _b === void 0 ? void 0 : _b.value) {
236
+ this._input.classList.add('bui-tel-input-with-value');
237
+ }
238
+ };
239
+ window.requestAnimationFrame(postRenderWork);
240
+ this._input.addEventListener('click', () => {
241
+ var _a;
242
+ if (((_a = this._control) === null || _a === void 0 ? void 0 : _a.disabled) && this._control.value) {
243
+ window.location.href = 'tel://' + this._control.value;
244
+ }
245
+ });
246
+ (_a = this._control) === null || _a === void 0 ? void 0 : _a.registerOnDisabledChange(isDisabled => this._patchValueByState(isDisabled));
247
+ this._patchValueByState(this._control.disabled);
248
+ }
249
+ _patchValueByState(isDisabled) {
250
+ setTimeout(() => {
251
+ var _a, _b;
252
+ if (!isDisabled) {
253
+ this.onInput();
254
+ }
255
+ else {
256
+ const v = this._iti.getNumber(intlTelInputUtils.numberFormat.NATIONAL);
257
+ this._input.value = v;
258
+ (_a = this._control) === null || _a === void 0 ? void 0 : _a.patchValue((_b = this._input) === null || _b === void 0 ? void 0 : _b.value, { emitEvent: false });
259
+ }
260
+ }, 20);
261
+ }
262
+ }
263
+ /**
264
+ * @ignore
265
+ */
266
+ PhoneNumberDirective.POST_RENDER_INIT_DELAY = 20;
267
+ /**
268
+ * @ignore
269
+ */
270
+ PhoneNumberDirective.BYPASS_SHADOW_DETECTION = false;
271
+ PhoneNumberDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberDirective, deps: [{ token: i0.ElementRef }, { token: i1.NgModel, optional: true }, { token: i1.FormControlName, optional: true }, { token: i1.FormControlDirective, optional: true }, { token: LOCALE_ID }, { token: i0.NgZone }, { token: i2.MatFormField, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
272
+ PhoneNumberDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.7", type: PhoneNumberDirective, selector: "[buiTelInput], input([type=tel])[ngModel], input([type=tel])[formControlName], input([type=tel])[formControl]", inputs: { telType: "telType", telDropdown: "telDropdown" }, outputs: { telCountryChange: "telCountryChange" }, host: { listeners: { "input": "onInput()" } }, usesOnChanges: true, ngImport: i0 });
273
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneNumberDirective, decorators: [{
274
+ type: Directive,
275
+ args: [{
276
+ selector: SELECTOR
277
+ }]
278
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.NgModel, decorators: [{
279
+ type: Optional
280
+ }] }, { type: i1.FormControlName, decorators: [{
281
+ type: Optional
282
+ }] }, { type: i1.FormControlDirective, decorators: [{
283
+ type: Optional
284
+ }] }, { type: undefined, decorators: [{
285
+ type: Inject,
286
+ args: [LOCALE_ID]
287
+ }] }, { type: i0.NgZone }, { type: i2.MatFormField, decorators: [{
288
+ type: Optional
289
+ }] }]; }, propDecorators: { telType: [{
290
+ type: Input
291
+ }], telDropdown: [{
292
+ type: Input
293
+ }], telCountryChange: [{
294
+ type: Output
295
+ }], onInput: [{
296
+ type: HostListener,
297
+ args: ['input']
298
298
  }] } });
299
299
 
300
- /**
301
- * @internal
302
- */
303
- class PhoneModule {
304
- }
305
- PhoneModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
306
- PhoneModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneModule, declarations: [PhoneNumberPipe, PhoneNumberDirective, PhoneNumberValidator], imports: [CommonModule], exports: [PhoneNumberDirective, PhoneNumberPipe, PhoneNumberValidator] });
307
- PhoneModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneModule, imports: [[CommonModule]] });
308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0, type: PhoneModule, decorators: [{
309
- type: NgModule,
310
- args: [{
311
- declarations: [PhoneNumberPipe, PhoneNumberDirective, PhoneNumberValidator],
312
- imports: [CommonModule],
313
- exports: [PhoneNumberDirective, PhoneNumberPipe, PhoneNumberValidator]
314
- }]
300
+ /**
301
+ * @internal
302
+ */
303
+ class PhoneModule {
304
+ }
305
+ PhoneModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
306
+ PhoneModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneModule, declarations: [PhoneNumberPipe, PhoneNumberDirective, PhoneNumberValidator], imports: [CommonModule], exports: [PhoneNumberDirective, PhoneNumberPipe, PhoneNumberValidator] });
307
+ PhoneModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneModule, imports: [[CommonModule]] });
308
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: PhoneModule, decorators: [{
309
+ type: NgModule,
310
+ args: [{
311
+ declarations: [PhoneNumberPipe, PhoneNumberDirective, PhoneNumberValidator],
312
+ imports: [CommonModule],
313
+ exports: [PhoneNumberDirective, PhoneNumberPipe, PhoneNumberValidator]
314
+ }]
315
315
  }] });
316
316
 
317
- /**
318
- * Generated bundle index. Do not edit.
317
+ /**
318
+ * Generated bundle index. Do not edit.
319
319
  */
320
320
 
321
321
  export { PhoneModule, PhoneNumberDirective, PhoneNumberPipe, PhoneNumberValidator };