ngxsmk-tel-input 1.3.9 → 1.4.1

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.
@@ -0,0 +1,554 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, inject, PLATFORM_ID, forwardRef, Output, Input, ViewChild, Component } from '@angular/core';
3
+ import { isPlatformBrowser } from '@angular/common';
4
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
5
+ import { parsePhoneNumberFromString, AsYouType } from 'libphonenumber-js';
6
+
7
+ class NgxsmkTelInputService {
8
+ parse(input, iso2) {
9
+ const phone = parsePhoneNumberFromString(input || '', iso2);
10
+ if (!phone)
11
+ return { e164: null, national: null, isValid: false };
12
+ const isValid = phone.isValid();
13
+ return { e164: isValid ? phone.number : null, national: phone.formatNational(), isValid };
14
+ }
15
+ isValid(input, iso2) {
16
+ const phone = parsePhoneNumberFromString(input || '', iso2);
17
+ return !!phone && phone.isValid();
18
+ }
19
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxsmkTelInputService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
20
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxsmkTelInputService, providedIn: 'root' }); }
21
+ }
22
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxsmkTelInputService, decorators: [{
23
+ type: Injectable,
24
+ args: [{ providedIn: 'root' }]
25
+ }] });
26
+
27
+ class NgxsmkTelInputComponent {
28
+ set telI18n(v) {
29
+ this.i18n = v;
30
+ }
31
+ set telLocalizedCountries(v) {
32
+ this.localizedCountries = v;
33
+ }
34
+ constructor(zone, tel) {
35
+ this.zone = zone;
36
+ this.tel = tel;
37
+ /* Core config */
38
+ this.initialCountry = 'US';
39
+ this.preferredCountries = ['US', 'GB'];
40
+ this.nationalMode = false;
41
+ this.separateDialCode = false;
42
+ this.allowDropdown = true;
43
+ this.autocomplete = 'tel';
44
+ this.disabled = false;
45
+ this.size = 'md';
46
+ this.variant = 'outline';
47
+ this.showClear = true;
48
+ this.autoFocus = false;
49
+ this.selectOnFocus = false;
50
+ this.formatOnBlur = true;
51
+ this.showErrorWhenTouched = true;
52
+ /* Dropdown plumbing */
53
+ this.dropdownAttachToBody = true;
54
+ this.dropdownZIndex = 2000;
55
+ this.clearAriaLabel = 'Clear phone number';
56
+ this.dir = 'ltr';
57
+ /* Placeholders (intl-tel-input) */
58
+ this.autoPlaceholder = 'off'; // default OFF since no utils fallback
59
+ this.formatWhenValid = 'blur';
60
+ /* Digits-only controls */
61
+ this.digitsOnly = true;
62
+ this.allowLeadingPlus = true;
63
+ /* Outputs */
64
+ this.countryChange = new EventEmitter();
65
+ this.validityChange = new EventEmitter();
66
+ this.inputChange = new EventEmitter();
67
+ /* Internal */
68
+ this.iti = null;
69
+ this.onChange = () => {
70
+ };
71
+ this.onTouchedCb = () => {
72
+ };
73
+ this.lastEmittedValid = false;
74
+ this.pendingWrite = null;
75
+ this.touched = false;
76
+ this.resolvedId = this.inputId || ('tel-' + Math.random().toString(36).slice(2));
77
+ this.platformId = inject(PLATFORM_ID);
78
+ }
79
+ ngAfterViewInit() {
80
+ if (!isPlatformBrowser(this.platformId))
81
+ return;
82
+ void this.initAndWire();
83
+ }
84
+ async initAndWire() {
85
+ await this.initIntlTelInput();
86
+ this.bindDomListeners();
87
+ if (this.pendingWrite !== null) {
88
+ this.setInputValue(this.pendingWrite);
89
+ this.handleInput();
90
+ this.pendingWrite = null;
91
+ }
92
+ if (this.autoFocus)
93
+ setTimeout(() => this.focus(), 0);
94
+ }
95
+ ngOnChanges(changes) {
96
+ if (!isPlatformBrowser(this.platformId))
97
+ return;
98
+ const configChanged = [
99
+ 'initialCountry', 'preferredCountries', 'onlyCountries',
100
+ 'separateDialCode', 'allowDropdown', 'nationalMode',
101
+ 'i18n', 'localizedCountries', 'dir',
102
+ 'autoPlaceholder', 'utilsScript', 'customPlaceholder',
103
+ 'digitsOnly', 'allowLeadingPlus'
104
+ ].some(k => k in changes && !changes[k]?.firstChange);
105
+ if (configChanged && this.iti) {
106
+ this.reinitPlugin();
107
+ this.validatorChange?.();
108
+ }
109
+ }
110
+ ngOnDestroy() {
111
+ this.destroyPlugin();
112
+ }
113
+ // ----- CVA -----
114
+ writeValue(val) {
115
+ if (!this.inputRef)
116
+ return;
117
+ if (!this.iti) {
118
+ this.pendingWrite = val ?? '';
119
+ return;
120
+ }
121
+ this.setInputValue(val ?? '');
122
+ }
123
+ registerOnChange(fn) {
124
+ this.onChange = fn;
125
+ }
126
+ registerOnTouched(fn) {
127
+ this.onTouchedCb = fn;
128
+ }
129
+ setDisabledState(isDisabled) {
130
+ this.disabled = isDisabled;
131
+ if (this.inputRef)
132
+ this.inputRef.nativeElement.disabled = isDisabled;
133
+ }
134
+ // ----- Validator -----
135
+ validate(_) {
136
+ const raw = this.currentRaw();
137
+ if (!raw)
138
+ return null;
139
+ const valid = this.tel.isValid(raw, this.currentIso2());
140
+ if (valid !== this.lastEmittedValid) {
141
+ this.lastEmittedValid = valid;
142
+ this.validityChange.emit(valid);
143
+ }
144
+ return valid ? null : { phoneInvalid: true };
145
+ }
146
+ registerOnValidatorChange(fn) {
147
+ this.validatorChange = fn;
148
+ }
149
+ // ----- Public helpers -----
150
+ focus() {
151
+ this.inputRef?.nativeElement.focus();
152
+ if (this.selectOnFocus) {
153
+ const el = this.inputRef.nativeElement;
154
+ queueMicrotask(() => el.setSelectionRange(0, el.value.length));
155
+ }
156
+ }
157
+ selectCountry(iso2) {
158
+ if (this.iti) {
159
+ this.iti.setCountry(iso2.toLowerCase());
160
+ this.handleInput();
161
+ }
162
+ }
163
+ clearInput() {
164
+ this.setInputValue('');
165
+ this.handleInput();
166
+ this.inputRef.nativeElement.focus();
167
+ }
168
+ // ----- Plugin wiring -----
169
+ async initIntlTelInput() {
170
+ const [{ default: intlTelInput }] = await Promise.all([import('intl-tel-input')]);
171
+ const toLowerKeys = (m) => {
172
+ if (!m)
173
+ return undefined;
174
+ const out = {};
175
+ for (const k in m) {
176
+ if (Object.prototype.hasOwnProperty.call(m, k)) {
177
+ const v = m[k];
178
+ if (v != null)
179
+ out[k.toLowerCase()] = v;
180
+ }
181
+ }
182
+ return out;
183
+ };
184
+ const config = {
185
+ initialCountry: this.initialCountry === 'auto' ? 'auto' : (this.initialCountry?.toLowerCase() || 'us'),
186
+ preferredCountries: (this.preferredCountries ?? []).map(c => c.toLowerCase()),
187
+ onlyCountries: (this.onlyCountries ?? []).map(c => c.toLowerCase()),
188
+ nationalMode: this.nationalMode,
189
+ allowDropdown: this.allowDropdown,
190
+ separateDialCode: this.separateDialCode,
191
+ geoIpLookup: (cb) => cb('us'),
192
+ // placeholders
193
+ autoPlaceholder: this.autoPlaceholder,
194
+ utilsScript: this.utilsScript,
195
+ customPlaceholder: this.customPlaceholder,
196
+ // localization
197
+ i18n: this.i18n,
198
+ localizedCountries: toLowerKeys(this.localizedCountries),
199
+ // dropdown container
200
+ dropdownContainer: this.dropdownAttachToBody && typeof document !== 'undefined' ? document.body : undefined
201
+ };
202
+ this.zone.runOutsideAngular(() => {
203
+ this.iti = intlTelInput(this.inputRef.nativeElement, config);
204
+ });
205
+ this.inputRef.nativeElement.style.setProperty('--tel-dd-z', String(this.dropdownZIndex));
206
+ }
207
+ reinitPlugin() {
208
+ const current = this.currentRaw();
209
+ this.destroyPlugin();
210
+ this.initIntlTelInput().then(() => {
211
+ if (current) {
212
+ this.setInputValue(current);
213
+ this.handleInput();
214
+ }
215
+ });
216
+ }
217
+ destroyPlugin() {
218
+ if (this.iti) {
219
+ this.iti.destroy();
220
+ this.iti = null;
221
+ }
222
+ if (this.inputRef?.nativeElement) {
223
+ const el = this.inputRef.nativeElement;
224
+ const clone = el.cloneNode(true);
225
+ el.parentNode?.replaceChild(clone, el);
226
+ this.inputRef.nativeElement = clone;
227
+ }
228
+ }
229
+ // ----- Input filtering (digits-only) -----
230
+ sanitizeDigits(value) {
231
+ if (!this.digitsOnly)
232
+ return value;
233
+ let v = value.replace(/[^\d+]/g, '');
234
+ if (this.allowLeadingPlus) {
235
+ const hasLeadingPlus = v.startsWith('+');
236
+ v = (hasLeadingPlus ? '+' : '') + v.replace(/\+/g, '');
237
+ }
238
+ else {
239
+ v = v.replace(/\+/g, '');
240
+ }
241
+ return v;
242
+ }
243
+ bindDomListeners() {
244
+ const el = this.inputRef.nativeElement;
245
+ this.zone.runOutsideAngular(() => {
246
+ el.addEventListener('beforeinput', (ev) => {
247
+ if (!this.digitsOnly)
248
+ return;
249
+ const data = ev.data;
250
+ if (!data || ev.inputType !== 'insertText')
251
+ return;
252
+ const pos = el.selectionStart ?? 0;
253
+ const isDigit = data >= '0' && data <= '9';
254
+ const isPlusAtStart = this.allowLeadingPlus && data === '+' && pos === 0 && !el.value.includes('+');
255
+ if (!isDigit && !isPlusAtStart)
256
+ ev.preventDefault();
257
+ });
258
+ el.addEventListener('paste', (e) => {
259
+ if (!this.digitsOnly)
260
+ return;
261
+ e.preventDefault();
262
+ const text = (e.clipboardData || window.clipboardData).getData('text');
263
+ const sanitized = this.sanitizeDigits(text);
264
+ const start = el.selectionStart ?? el.value.length;
265
+ const end = el.selectionEnd ?? el.value.length;
266
+ el.setRangeText(sanitized, start, end, 'end');
267
+ queueMicrotask(() => this.handleInput());
268
+ });
269
+ el.addEventListener('input', () => {
270
+ if (this.digitsOnly) {
271
+ const val = el.value;
272
+ const sanitized = this.sanitizeDigits(val);
273
+ if (val !== sanitized) {
274
+ const caret = el.selectionStart ?? sanitized.length;
275
+ el.value = sanitized;
276
+ el.setSelectionRange(caret, caret);
277
+ }
278
+ }
279
+ this.handleInput();
280
+ });
281
+ el.addEventListener('countrychange', () => {
282
+ const iso2 = this.currentIso2();
283
+ this.zone.run(() => {
284
+ this.countryChange.emit({ iso2 });
285
+ this.validatorChange?.();
286
+ });
287
+ this.handleInput();
288
+ });
289
+ el.addEventListener('blur', () => this.onBlur());
290
+ });
291
+ }
292
+ onBlur() {
293
+ this.touched = true;
294
+ this.zone.run(() => this.onTouchedCb());
295
+ if (!this.formatOnBlur)
296
+ return;
297
+ const raw = this.currentRaw();
298
+ if (!raw)
299
+ return;
300
+ const parsed = this.tel.parse(raw, this.currentIso2());
301
+ if (this.nationalMode && parsed.national) {
302
+ this.setInputValue((parsed.national || '').replace(/\s{2,}/g, ' '));
303
+ }
304
+ }
305
+ onFocus() {
306
+ if (this.selectOnFocus) {
307
+ const el = this.inputRef.nativeElement;
308
+ queueMicrotask(() => el.setSelectionRange(0, el.value.length));
309
+ }
310
+ }
311
+ handleInput() {
312
+ let raw = this.currentRaw();
313
+ const iso2 = this.currentIso2();
314
+ // live format while typing (optional)
315
+ if (this.formatWhenValid === 'typing' && raw) {
316
+ const formatted = this.formatAsYouType(raw, iso2);
317
+ if (formatted !== raw) {
318
+ // keep caret sane (end)
319
+ this.setInputValue(formatted);
320
+ raw = formatted;
321
+ }
322
+ }
323
+ const parsed = this.tel.parse(raw, iso2);
324
+ this.zone.run(() => this.onChange(parsed.e164)); // E.164 or null
325
+ this.zone.run(() => this.inputChange.emit({ raw, e164: parsed.e164, iso2 }));
326
+ // pretty print on blur already handled; keep this for nationalMode normalization
327
+ if (raw && this.nationalMode && parsed.national) {
328
+ const normalized = parsed.national.replace(/\s{2,}/g, ' ');
329
+ if (normalized !== raw)
330
+ this.setInputValue(normalized);
331
+ }
332
+ }
333
+ formatAsYouType(raw, iso2) {
334
+ try {
335
+ // When a region is provided, AsYouType returns NATIONAL formatting
336
+ const fmt = new AsYouType(iso2);
337
+ return fmt.input(raw);
338
+ }
339
+ catch {
340
+ return raw;
341
+ }
342
+ }
343
+ currentRaw() {
344
+ return (this.inputRef?.nativeElement.value ?? '').trim();
345
+ }
346
+ currentIso2() {
347
+ const iso2 = (this.iti?.getSelectedCountryData?.().iso2 ?? this.initialCountry ?? 'US')
348
+ .toString().toUpperCase();
349
+ return iso2;
350
+ }
351
+ setInputValue(v) {
352
+ this.inputRef.nativeElement.value = v ?? '';
353
+ }
354
+ get showError() {
355
+ const invalid = !!this.validate({});
356
+ return this.showErrorWhenTouched ? (this.touched && invalid) : invalid;
357
+ }
358
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxsmkTelInputComponent, deps: [{ token: i0.NgZone }, { token: NgxsmkTelInputService }], target: i0.ɵɵFactoryTarget.Component }); }
359
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: NgxsmkTelInputComponent, isStandalone: true, selector: "ngxsmk-tel-input", inputs: { initialCountry: "initialCountry", preferredCountries: "preferredCountries", onlyCountries: "onlyCountries", nationalMode: "nationalMode", separateDialCode: "separateDialCode", allowDropdown: "allowDropdown", placeholder: "placeholder", autocomplete: "autocomplete", name: "name", inputId: "inputId", disabled: "disabled", label: "label", hint: "hint", errorText: "errorText", size: "size", variant: "variant", showClear: "showClear", autoFocus: "autoFocus", selectOnFocus: "selectOnFocus", formatOnBlur: "formatOnBlur", showErrorWhenTouched: "showErrorWhenTouched", dropdownAttachToBody: "dropdownAttachToBody", dropdownZIndex: "dropdownZIndex", i18n: "i18n", telI18n: "telI18n", localizedCountries: "localizedCountries", telLocalizedCountries: "telLocalizedCountries", clearAriaLabel: "clearAriaLabel", dir: "dir", autoPlaceholder: "autoPlaceholder", utilsScript: "utilsScript", customPlaceholder: "customPlaceholder", formatWhenValid: "formatWhenValid", digitsOnly: "digitsOnly", allowLeadingPlus: "allowLeadingPlus" }, outputs: { countryChange: "countryChange", validityChange: "validityChange", inputChange: "inputChange" }, providers: [
360
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true },
361
+ { provide: NG_VALIDATORS, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true }
362
+ ], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["telInput"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `
363
+ <div class="ngxsmk-tel"
364
+ [class.disabled]="disabled"
365
+ [attr.data-size]="size"
366
+ [attr.data-variant]="variant"
367
+ [attr.dir]="dir">
368
+ @if (label) {
369
+ <label class="ngxsmk-tel__label" [for]="resolvedId">{{ label }}</label>
370
+ }
371
+
372
+ <div class="ngxsmk-tel__wrap" [class.has-error]="showError">
373
+ <div class="ngxsmk-tel-input__wrapper">
374
+ <input
375
+ #telInput
376
+ type="tel"
377
+ class="ngxsmk-tel-input__control"
378
+ [id]="resolvedId"
379
+ [attr.name]="name || null"
380
+ [attr.placeholder]="placeholder || null"
381
+ [attr.autocomplete]="autocomplete"
382
+ [attr.inputmode]="digitsOnly ? 'numeric' : 'tel'"
383
+ [attr.pattern]="digitsOnly ? (allowLeadingPlus ? '\\\\+?[0-9]*' : '[0-9]*') : null"
384
+ [disabled]="disabled"
385
+ [attr.aria-invalid]="showError ? 'true' : 'false'"
386
+ (blur)="onBlur()"
387
+ (focus)="onFocus()"
388
+ />
389
+ </div>
390
+
391
+ @if (showClear && currentRaw()) {
392
+ <button type="button"
393
+ class="ngxsmk-tel__clear"
394
+ (click)="clearInput()"
395
+ [attr.aria-label]="clearAriaLabel">
396
+ ×
397
+ </button>
398
+ }
399
+ </div>
400
+
401
+ @if (hint && !showError) {
402
+ <div class="ngxsmk-tel__hint">{{ hint }}</div>
403
+ }
404
+
405
+ @if (showError) {
406
+ <div class="ngxsmk-tel__error">{{ errorText || 'Please enter a valid phone number.' }}</div>
407
+ }
408
+ </div>
409
+ `, isInline: true, styles: [":host{--tel-bg: #fff;--tel-fg: #0f172a;--tel-border: #c0c0c0;--tel-border-hover: #9aa0a6;--tel-ring: #2563eb;--tel-placeholder: #9ca3af;--tel-error: #ef4444;--tel-radius: 12px;--tel-focus-shadow: 0 0 0 3px rgba(37, 99, 235, .25);--tel-dd-bg: var(--tel-bg);--tel-dd-border: var(--tel-border);--tel-dd-shadow: 0 24px 60px rgba(0, 0, 0, .18);--tel-dd-radius: 12px;--tel-dd-item-hover: rgba(37, 99, 235, .08);--tel-dd-z: 2000;--tel-dd-search-bg: rgba(148, 163, 184, .08);display:block}:host-context(.dark){--tel-bg: #0b0f17;--tel-fg: #e5e7eb;--tel-border: #334155;--tel-border-hover: #475569;--tel-ring: #60a5fa;--tel-placeholder: #94a3b8;--tel-dd-bg: #0f1521;--tel-dd-border: #324056;--tel-dd-search-bg: rgba(148, 163, 184, .12)}.ngxsmk-tel{width:100%;color:var(--tel-fg)}.ngxsmk-tel.disabled{opacity:.7;cursor:not-allowed}.ngxsmk-tel__label{display:inline-block;margin-bottom:6px;font-size:.875rem;font-weight:500}.ngxsmk-tel__wrap{position:relative}.ngxsmk-tel-input__wrapper,:host ::ng-deep .iti{width:100%}.ngxsmk-tel-input__control{width:100%;height:40px;font:inherit;color:var(--tel-fg);background:var(--tel-bg);border:1px solid var(--tel-border);border-radius:var(--tel-radius);padding:10px 40px 10px 12px;outline:none;transition:border-color .15s,box-shadow .15s,background .15s}.ngxsmk-tel-input__control::placeholder{color:var(--tel-placeholder)}.ngxsmk-tel-input__control:hover{border-color:var(--tel-border-hover)}.ngxsmk-tel-input__control:focus{border-color:var(--tel-ring);box-shadow:var(--tel-focus-shadow)}[data-size=sm] .ngxsmk-tel-input__control{height:34px;font-size:13px;padding:6px 36px 6px 10px;border-radius:10px}[data-size=lg] .ngxsmk-tel-input__control{height:46px;font-size:16px;padding:12px 44px 12px 14px;border-radius:14px}[data-variant=filled] .ngxsmk-tel-input__control{background:#94a3b814}[data-variant=underline] .ngxsmk-tel-input__control{border:0;border-bottom:2px solid var(--tel-border);border-radius:0;padding-left:0;padding-right:34px}[data-variant=underline] .ngxsmk-tel-input__control:focus{border-bottom-color:var(--tel-ring);box-shadow:none}:host ::ng-deep .iti__flag-container{border-top-left-radius:var(--tel-radius);border-bottom-left-radius:var(--tel-radius);border:1px solid var(--tel-border);border-right:none;background:var(--tel-bg)}:host ::ng-deep .iti__selected-flag{height:100%;padding:0 10px;display:inline-flex;align-items:center}:host ::ng-deep .iti__country-list{background:var(--tel-dd-bg);border:1px solid var(--tel-dd-border);border-radius:var(--tel-dd-radius);box-shadow:var(--tel-dd-shadow);max-height:min(50vh,360px);overflow:auto;padding:6px 0;width:max(280px,100%);z-index:var(--tel-dd-z)}:host ::ng-deep .iti--container .iti__country-list{z-index:var(--tel-dd-z)}:host ::ng-deep .iti__search-input{position:sticky;top:0;margin:0;padding:10px 12px;width:100%;border:0;border-bottom:1px solid var(--tel-dd-border);outline:none;background:var(--tel-dd-search-bg);color:var(--tel-fg)}:host ::ng-deep .iti__country{display:grid;grid-template-columns:28px 1fr auto;align-items:center;column-gap:.5rem;padding:10px 12px;cursor:pointer}:host ::ng-deep .iti__dial-code{color:var(--tel-placeholder);font-weight:600;margin-left:10px}.ngxsmk-tel__clear{position:absolute;right:8px;top:50%;transform:translateY(-50%);border:0;background:transparent;font-size:18px;line-height:1;width:28px;height:28px;border-radius:50%;cursor:pointer;color:var(--tel-placeholder)}.ngxsmk-tel__clear:hover{background:#94a3b826}.ngxsmk-tel__hint{margin-top:6px;font-size:12px;color:var(--tel-placeholder)}.ngxsmk-tel__error{margin-top:6px;font-size:12px;color:var(--tel-error)}.ngxsmk-tel__wrap.has-error .ngxsmk-tel-input__control{border-color:var(--tel-error);box-shadow:0 0 0 3px #ef444426}\n"] }); }
410
+ }
411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxsmkTelInputComponent, decorators: [{
412
+ type: Component,
413
+ args: [{ selector: 'ngxsmk-tel-input', standalone: true, imports: [], template: `
414
+ <div class="ngxsmk-tel"
415
+ [class.disabled]="disabled"
416
+ [attr.data-size]="size"
417
+ [attr.data-variant]="variant"
418
+ [attr.dir]="dir">
419
+ @if (label) {
420
+ <label class="ngxsmk-tel__label" [for]="resolvedId">{{ label }}</label>
421
+ }
422
+
423
+ <div class="ngxsmk-tel__wrap" [class.has-error]="showError">
424
+ <div class="ngxsmk-tel-input__wrapper">
425
+ <input
426
+ #telInput
427
+ type="tel"
428
+ class="ngxsmk-tel-input__control"
429
+ [id]="resolvedId"
430
+ [attr.name]="name || null"
431
+ [attr.placeholder]="placeholder || null"
432
+ [attr.autocomplete]="autocomplete"
433
+ [attr.inputmode]="digitsOnly ? 'numeric' : 'tel'"
434
+ [attr.pattern]="digitsOnly ? (allowLeadingPlus ? '\\\\+?[0-9]*' : '[0-9]*') : null"
435
+ [disabled]="disabled"
436
+ [attr.aria-invalid]="showError ? 'true' : 'false'"
437
+ (blur)="onBlur()"
438
+ (focus)="onFocus()"
439
+ />
440
+ </div>
441
+
442
+ @if (showClear && currentRaw()) {
443
+ <button type="button"
444
+ class="ngxsmk-tel__clear"
445
+ (click)="clearInput()"
446
+ [attr.aria-label]="clearAriaLabel">
447
+ ×
448
+ </button>
449
+ }
450
+ </div>
451
+
452
+ @if (hint && !showError) {
453
+ <div class="ngxsmk-tel__hint">{{ hint }}</div>
454
+ }
455
+
456
+ @if (showError) {
457
+ <div class="ngxsmk-tel__error">{{ errorText || 'Please enter a valid phone number.' }}</div>
458
+ }
459
+ </div>
460
+ `, providers: [
461
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true },
462
+ { provide: NG_VALIDATORS, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true }
463
+ ], styles: [":host{--tel-bg: #fff;--tel-fg: #0f172a;--tel-border: #c0c0c0;--tel-border-hover: #9aa0a6;--tel-ring: #2563eb;--tel-placeholder: #9ca3af;--tel-error: #ef4444;--tel-radius: 12px;--tel-focus-shadow: 0 0 0 3px rgba(37, 99, 235, .25);--tel-dd-bg: var(--tel-bg);--tel-dd-border: var(--tel-border);--tel-dd-shadow: 0 24px 60px rgba(0, 0, 0, .18);--tel-dd-radius: 12px;--tel-dd-item-hover: rgba(37, 99, 235, .08);--tel-dd-z: 2000;--tel-dd-search-bg: rgba(148, 163, 184, .08);display:block}:host-context(.dark){--tel-bg: #0b0f17;--tel-fg: #e5e7eb;--tel-border: #334155;--tel-border-hover: #475569;--tel-ring: #60a5fa;--tel-placeholder: #94a3b8;--tel-dd-bg: #0f1521;--tel-dd-border: #324056;--tel-dd-search-bg: rgba(148, 163, 184, .12)}.ngxsmk-tel{width:100%;color:var(--tel-fg)}.ngxsmk-tel.disabled{opacity:.7;cursor:not-allowed}.ngxsmk-tel__label{display:inline-block;margin-bottom:6px;font-size:.875rem;font-weight:500}.ngxsmk-tel__wrap{position:relative}.ngxsmk-tel-input__wrapper,:host ::ng-deep .iti{width:100%}.ngxsmk-tel-input__control{width:100%;height:40px;font:inherit;color:var(--tel-fg);background:var(--tel-bg);border:1px solid var(--tel-border);border-radius:var(--tel-radius);padding:10px 40px 10px 12px;outline:none;transition:border-color .15s,box-shadow .15s,background .15s}.ngxsmk-tel-input__control::placeholder{color:var(--tel-placeholder)}.ngxsmk-tel-input__control:hover{border-color:var(--tel-border-hover)}.ngxsmk-tel-input__control:focus{border-color:var(--tel-ring);box-shadow:var(--tel-focus-shadow)}[data-size=sm] .ngxsmk-tel-input__control{height:34px;font-size:13px;padding:6px 36px 6px 10px;border-radius:10px}[data-size=lg] .ngxsmk-tel-input__control{height:46px;font-size:16px;padding:12px 44px 12px 14px;border-radius:14px}[data-variant=filled] .ngxsmk-tel-input__control{background:#94a3b814}[data-variant=underline] .ngxsmk-tel-input__control{border:0;border-bottom:2px solid var(--tel-border);border-radius:0;padding-left:0;padding-right:34px}[data-variant=underline] .ngxsmk-tel-input__control:focus{border-bottom-color:var(--tel-ring);box-shadow:none}:host ::ng-deep .iti__flag-container{border-top-left-radius:var(--tel-radius);border-bottom-left-radius:var(--tel-radius);border:1px solid var(--tel-border);border-right:none;background:var(--tel-bg)}:host ::ng-deep .iti__selected-flag{height:100%;padding:0 10px;display:inline-flex;align-items:center}:host ::ng-deep .iti__country-list{background:var(--tel-dd-bg);border:1px solid var(--tel-dd-border);border-radius:var(--tel-dd-radius);box-shadow:var(--tel-dd-shadow);max-height:min(50vh,360px);overflow:auto;padding:6px 0;width:max(280px,100%);z-index:var(--tel-dd-z)}:host ::ng-deep .iti--container .iti__country-list{z-index:var(--tel-dd-z)}:host ::ng-deep .iti__search-input{position:sticky;top:0;margin:0;padding:10px 12px;width:100%;border:0;border-bottom:1px solid var(--tel-dd-border);outline:none;background:var(--tel-dd-search-bg);color:var(--tel-fg)}:host ::ng-deep .iti__country{display:grid;grid-template-columns:28px 1fr auto;align-items:center;column-gap:.5rem;padding:10px 12px;cursor:pointer}:host ::ng-deep .iti__dial-code{color:var(--tel-placeholder);font-weight:600;margin-left:10px}.ngxsmk-tel__clear{position:absolute;right:8px;top:50%;transform:translateY(-50%);border:0;background:transparent;font-size:18px;line-height:1;width:28px;height:28px;border-radius:50%;cursor:pointer;color:var(--tel-placeholder)}.ngxsmk-tel__clear:hover{background:#94a3b826}.ngxsmk-tel__hint{margin-top:6px;font-size:12px;color:var(--tel-placeholder)}.ngxsmk-tel__error{margin-top:6px;font-size:12px;color:var(--tel-error)}.ngxsmk-tel__wrap.has-error .ngxsmk-tel-input__control{border-color:var(--tel-error);box-shadow:0 0 0 3px #ef444426}\n"] }]
464
+ }], ctorParameters: () => [{ type: i0.NgZone }, { type: NgxsmkTelInputService }], propDecorators: { inputRef: [{
465
+ type: ViewChild,
466
+ args: ['telInput', { static: true }]
467
+ }], initialCountry: [{
468
+ type: Input
469
+ }], preferredCountries: [{
470
+ type: Input
471
+ }], onlyCountries: [{
472
+ type: Input
473
+ }], nationalMode: [{
474
+ type: Input
475
+ }], separateDialCode: [{
476
+ type: Input
477
+ }], allowDropdown: [{
478
+ type: Input
479
+ }], placeholder: [{
480
+ type: Input
481
+ }], autocomplete: [{
482
+ type: Input
483
+ }], name: [{
484
+ type: Input
485
+ }], inputId: [{
486
+ type: Input
487
+ }], disabled: [{
488
+ type: Input
489
+ }], label: [{
490
+ type: Input
491
+ }], hint: [{
492
+ type: Input
493
+ }], errorText: [{
494
+ type: Input
495
+ }], size: [{
496
+ type: Input
497
+ }], variant: [{
498
+ type: Input
499
+ }], showClear: [{
500
+ type: Input
501
+ }], autoFocus: [{
502
+ type: Input
503
+ }], selectOnFocus: [{
504
+ type: Input
505
+ }], formatOnBlur: [{
506
+ type: Input
507
+ }], showErrorWhenTouched: [{
508
+ type: Input
509
+ }], dropdownAttachToBody: [{
510
+ type: Input
511
+ }], dropdownZIndex: [{
512
+ type: Input
513
+ }], i18n: [{
514
+ type: Input,
515
+ args: ['i18n']
516
+ }], telI18n: [{
517
+ type: Input,
518
+ args: ['telI18n']
519
+ }], localizedCountries: [{
520
+ type: Input,
521
+ args: ['localizedCountries']
522
+ }], telLocalizedCountries: [{
523
+ type: Input,
524
+ args: ['telLocalizedCountries']
525
+ }], clearAriaLabel: [{
526
+ type: Input
527
+ }], dir: [{
528
+ type: Input
529
+ }], autoPlaceholder: [{
530
+ type: Input
531
+ }], utilsScript: [{
532
+ type: Input
533
+ }], customPlaceholder: [{
534
+ type: Input
535
+ }], formatWhenValid: [{
536
+ type: Input
537
+ }], digitsOnly: [{
538
+ type: Input
539
+ }], allowLeadingPlus: [{
540
+ type: Input
541
+ }], countryChange: [{
542
+ type: Output
543
+ }], validityChange: [{
544
+ type: Output
545
+ }], inputChange: [{
546
+ type: Output
547
+ }] } });
548
+
549
+ /**
550
+ * Generated bundle index. Do not edit.
551
+ */
552
+
553
+ export { NgxsmkTelInputComponent, NgxsmkTelInputService };
554
+ //# sourceMappingURL=ngxsmk-tel-input.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngxsmk-tel-input.mjs","sources":["../../../projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.service.ts","../../../projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.component.ts","../../../projects/ngxsmk-tel-input/src/ngxsmk-tel-input.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\nimport { parsePhoneNumberFromString, type CountryCode } from 'libphonenumber-js';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class NgxsmkTelInputService {\r\n parse(input: string, iso2: CountryCode): { e164: string | null; national: string | null; isValid: boolean } {\r\n const phone = parsePhoneNumberFromString(input || '', iso2);\r\n if (!phone) return { e164: null, national: null, isValid: false };\r\n const isValid = phone.isValid();\r\n return { e164: isValid ? phone.number : null, national: phone.formatNational(), isValid };\r\n }\r\n\r\n isValid(input: string, iso2: CountryCode): boolean {\r\n const phone = parsePhoneNumberFromString(input || '', iso2);\r\n return !!phone && phone.isValid();\r\n }\r\n}\r\n","import {\r\n AfterViewInit,\r\n Component,\r\n ElementRef,\r\n EventEmitter,\r\n forwardRef,\r\n inject,\r\n Input,\r\n NgZone,\r\n OnChanges,\r\n OnDestroy,\r\n Output,\r\n PLATFORM_ID,\r\n SimpleChanges,\r\n ViewChild\r\n} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {\r\n AbstractControl,\r\n ControlValueAccessor,\r\n NG_VALIDATORS,\r\n NG_VALUE_ACCESSOR,\r\n ValidationErrors,\r\n Validator\r\n} from '@angular/forms';\r\nimport {AsYouType, CountryCode} from 'libphonenumber-js';\r\nimport {NgxsmkTelInputService} from './ngxsmk-tel-input.service';\r\nimport {CountryMap, IntlTelI18n} from './types';\r\n\r\ntype IntlTelInstance = any;\r\n\r\n@Component({\r\n selector: 'ngxsmk-tel-input',\r\n standalone: true,\r\n imports: [],\r\n template: `\r\n <div class=\"ngxsmk-tel\"\r\n [class.disabled]=\"disabled\"\r\n [attr.data-size]=\"size\"\r\n [attr.data-variant]=\"variant\"\r\n [attr.dir]=\"dir\">\r\n @if (label) {\r\n <label class=\"ngxsmk-tel__label\" [for]=\"resolvedId\">{{ label }}</label>\r\n }\r\n\r\n <div class=\"ngxsmk-tel__wrap\" [class.has-error]=\"showError\">\r\n <div class=\"ngxsmk-tel-input__wrapper\">\r\n <input\r\n #telInput\r\n type=\"tel\"\r\n class=\"ngxsmk-tel-input__control\"\r\n [id]=\"resolvedId\"\r\n [attr.name]=\"name || null\"\r\n [attr.placeholder]=\"placeholder || null\"\r\n [attr.autocomplete]=\"autocomplete\"\r\n [attr.inputmode]=\"digitsOnly ? 'numeric' : 'tel'\"\r\n [attr.pattern]=\"digitsOnly ? (allowLeadingPlus ? '\\\\\\\\+?[0-9]*' : '[0-9]*') : null\"\r\n [disabled]=\"disabled\"\r\n [attr.aria-invalid]=\"showError ? 'true' : 'false'\"\r\n (blur)=\"onBlur()\"\r\n (focus)=\"onFocus()\"\r\n />\r\n </div>\r\n\r\n @if (showClear && currentRaw()) {\r\n <button type=\"button\"\r\n class=\"ngxsmk-tel__clear\"\r\n (click)=\"clearInput()\"\r\n [attr.aria-label]=\"clearAriaLabel\">\r\n ×\r\n </button>\r\n }\r\n </div>\r\n\r\n @if (hint && !showError) {\r\n <div class=\"ngxsmk-tel__hint\">{{ hint }}</div>\r\n }\r\n\r\n @if (showError) {\r\n <div class=\"ngxsmk-tel__error\">{{ errorText || 'Please enter a valid phone number.' }}</div>\r\n }\r\n </div>\r\n `,\r\n styleUrls: ['./ngxsmk-tel-input.component.scss'],\r\n providers: [\r\n {provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true},\r\n {provide: NG_VALIDATORS, useExisting: forwardRef(() => NgxsmkTelInputComponent), multi: true}\r\n ]\r\n})\r\nexport class NgxsmkTelInputComponent implements AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor, Validator {\r\n\r\n @ViewChild('telInput', {static: true}) inputRef!: ElementRef<HTMLInputElement>;\r\n\r\n /* Core config */\r\n @Input() initialCountry: CountryCode | 'auto' = 'US';\r\n @Input() preferredCountries: CountryCode[] = ['US', 'GB'];\r\n @Input() onlyCountries?: CountryCode[];\r\n @Input() nationalMode: boolean = false;\r\n @Input() separateDialCode: boolean = false;\r\n @Input() allowDropdown: boolean = true;\r\n\r\n /* UX */\r\n @Input() placeholder?: string;\r\n @Input() autocomplete = 'tel';\r\n @Input() name?: string;\r\n @Input() inputId?: string;\r\n @Input() disabled: boolean = false;\r\n\r\n @Input() label?: string;\r\n @Input() hint?: string;\r\n @Input() errorText?: string;\r\n @Input() size: 'sm' | 'md' | 'lg' = 'md';\r\n @Input() variant: 'outline' | 'filled' | 'underline' = 'outline';\r\n @Input() showClear: boolean = true;\r\n @Input() autoFocus: boolean = false;\r\n @Input() selectOnFocus: boolean = false;\r\n @Input() formatOnBlur: boolean = true;\r\n @Input() showErrorWhenTouched: boolean = true;\r\n\r\n /* Dropdown plumbing */\r\n @Input() dropdownAttachToBody: boolean = true;\r\n @Input() dropdownZIndex: number = 2000;\r\n\r\n /* Localization + RTL */\r\n @Input('i18n') i18n?: IntlTelI18n;\r\n\r\n @Input('telI18n') set telI18n(v: IntlTelI18n | undefined) {\r\n this.i18n = v;\r\n }\r\n\r\n @Input('localizedCountries') localizedCountries?: CountryMap;\r\n\r\n @Input('telLocalizedCountries') set telLocalizedCountries(v: CountryMap | undefined) {\r\n this.localizedCountries = v;\r\n }\r\n\r\n @Input() clearAriaLabel: string = 'Clear phone number';\r\n @Input() dir: 'ltr' | 'rtl' = 'ltr';\r\n\r\n /* Placeholders (intl-tel-input) */\r\n @Input() autoPlaceholder: 'off' | 'polite' | 'aggressive' = 'off'; // default OFF since no utils fallback\r\n @Input() utilsScript?: string;\r\n @Input() customPlaceholder?: (example: string, country: any) => string;\r\n\r\n @Input() formatWhenValid: 'off' | 'blur' | 'typing' = 'blur';\r\n\r\n /* Digits-only controls */\r\n @Input() digitsOnly: boolean = true;\r\n @Input() allowLeadingPlus: boolean = true;\r\n\r\n /* Outputs */\r\n @Output() countryChange = new EventEmitter<{ iso2: CountryCode }>();\r\n @Output() validityChange = new EventEmitter<boolean>();\r\n @Output() inputChange = new EventEmitter<{ raw: string; e164: string | null; iso2: CountryCode }>();\r\n\r\n /* Internal */\r\n private iti: IntlTelInstance | null = null;\r\n private onChange: (val: string | null) => void = () => {\r\n };\r\n private onTouchedCb: () => void = () => {\r\n };\r\n private validatorChange?: () => void;\r\n private lastEmittedValid = false;\r\n private pendingWrite: string | null = null;\r\n private touched: boolean = false;\r\n\r\n readonly resolvedId: string = this.inputId || ('tel-' + Math.random().toString(36).slice(2));\r\n\r\n private readonly platformId = inject(PLATFORM_ID);\r\n\r\n constructor(\r\n private readonly zone: NgZone,\r\n private readonly tel: NgxsmkTelInputService\r\n ) {\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n if (!isPlatformBrowser(this.platformId)) return;\r\n void this.initAndWire();\r\n }\r\n\r\n private async initAndWire(): Promise<void> {\r\n await this.initIntlTelInput();\r\n this.bindDomListeners();\r\n\r\n if (this.pendingWrite !== null) {\r\n this.setInputValue(this.pendingWrite);\r\n this.handleInput();\r\n this.pendingWrite = null;\r\n }\r\n if (this.autoFocus) setTimeout(() => this.focus(), 0);\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if (!isPlatformBrowser(this.platformId)) return;\r\n const configChanged = [\r\n 'initialCountry', 'preferredCountries', 'onlyCountries',\r\n 'separateDialCode', 'allowDropdown', 'nationalMode',\r\n 'i18n', 'localizedCountries', 'dir',\r\n 'autoPlaceholder', 'utilsScript', 'customPlaceholder',\r\n 'digitsOnly', 'allowLeadingPlus'\r\n ].some(k => k in changes && !changes[k]?.firstChange);\r\n if (configChanged && this.iti) {\r\n this.reinitPlugin();\r\n this.validatorChange?.();\r\n }\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.destroyPlugin();\r\n }\r\n\r\n // ----- CVA -----\r\n writeValue(val: string | null): void {\r\n if (!this.inputRef) return;\r\n if (!this.iti) {\r\n this.pendingWrite = val ?? '';\r\n return;\r\n }\r\n this.setInputValue(val ?? '');\r\n }\r\n\r\n registerOnChange(fn: any): void {\r\n this.onChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this.onTouchedCb = fn;\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled = isDisabled;\r\n if (this.inputRef) this.inputRef.nativeElement.disabled = isDisabled;\r\n }\r\n\r\n // ----- Validator -----\r\n validate(_: AbstractControl): ValidationErrors | null {\r\n const raw = this.currentRaw();\r\n if (!raw) return null;\r\n const valid = this.tel.isValid(raw, this.currentIso2());\r\n if (valid !== this.lastEmittedValid) {\r\n this.lastEmittedValid = valid;\r\n this.validityChange.emit(valid);\r\n }\r\n return valid ? null : {phoneInvalid: true};\r\n }\r\n\r\n registerOnValidatorChange(fn: () => void): void {\r\n this.validatorChange = fn;\r\n }\r\n\r\n // ----- Public helpers -----\r\n focus(): void {\r\n this.inputRef?.nativeElement.focus();\r\n if (this.selectOnFocus) {\r\n const el = this.inputRef.nativeElement;\r\n queueMicrotask(() => el.setSelectionRange(0, el.value.length));\r\n }\r\n }\r\n\r\n selectCountry(iso2: CountryCode): void {\r\n if (this.iti) {\r\n this.iti.setCountry(iso2.toLowerCase());\r\n this.handleInput();\r\n }\r\n }\r\n\r\n clearInput() {\r\n this.setInputValue('');\r\n this.handleInput();\r\n this.inputRef.nativeElement.focus();\r\n }\r\n\r\n // ----- Plugin wiring -----\r\n private async initIntlTelInput() {\r\n const [{default: intlTelInput}] = await Promise.all([import('intl-tel-input')]);\r\n\r\n const toLowerKeys = (m?: CountryMap) => {\r\n if (!m) return undefined;\r\n const out: Record<string, string> = {};\r\n for (const k in m) {\r\n if (Object.prototype.hasOwnProperty.call(m, k)) {\r\n const v = (m as Record<string, string | undefined>)[k];\r\n if (v != null) out[k.toLowerCase()] = v;\r\n }\r\n }\r\n return out;\r\n };\r\n\r\n const config: any = {\r\n initialCountry: this.initialCountry === 'auto' ? 'auto' : (this.initialCountry?.toLowerCase() || 'us'),\r\n preferredCountries: (this.preferredCountries ?? []).map(c => c.toLowerCase()),\r\n onlyCountries: (this.onlyCountries ?? []).map(c => c.toLowerCase()),\r\n nationalMode: this.nationalMode,\r\n allowDropdown: this.allowDropdown,\r\n separateDialCode: this.separateDialCode,\r\n geoIpLookup: (cb: (iso2: string) => void) => cb('us'),\r\n\r\n // placeholders\r\n autoPlaceholder: this.autoPlaceholder,\r\n utilsScript: this.utilsScript,\r\n customPlaceholder: this.customPlaceholder,\r\n\r\n // localization\r\n i18n: this.i18n,\r\n localizedCountries: toLowerKeys(this.localizedCountries),\r\n\r\n // dropdown container\r\n dropdownContainer: this.dropdownAttachToBody && typeof document !== 'undefined' ? document.body : undefined\r\n };\r\n\r\n this.zone.runOutsideAngular(() => {\r\n this.iti = intlTelInput(this.inputRef.nativeElement, config);\r\n });\r\n\r\n (this.inputRef.nativeElement as HTMLElement).style.setProperty('--tel-dd-z', String(this.dropdownZIndex));\r\n }\r\n\r\n private reinitPlugin() {\r\n const current = this.currentRaw();\r\n this.destroyPlugin();\r\n this.initIntlTelInput().then(() => {\r\n if (current) {\r\n this.setInputValue(current);\r\n this.handleInput();\r\n }\r\n });\r\n }\r\n\r\n private destroyPlugin() {\r\n if (this.iti) {\r\n this.iti.destroy();\r\n this.iti = null;\r\n }\r\n if (this.inputRef?.nativeElement) {\r\n const el = this.inputRef.nativeElement;\r\n const clone = el.cloneNode(true) as HTMLInputElement;\r\n el.parentNode?.replaceChild(clone, el);\r\n (this.inputRef as any).nativeElement = clone;\r\n }\r\n }\r\n\r\n // ----- Input filtering (digits-only) -----\r\n private sanitizeDigits(value: string): string {\r\n if (!this.digitsOnly) return value;\r\n let v = value.replace(/[^\\d+]/g, '');\r\n if (this.allowLeadingPlus) {\r\n const hasLeadingPlus = v.startsWith('+');\r\n v = (hasLeadingPlus ? '+' : '') + v.replace(/\\+/g, '');\r\n } else {\r\n v = v.replace(/\\+/g, '');\r\n }\r\n return v;\r\n }\r\n\r\n private bindDomListeners() {\r\n const el = this.inputRef.nativeElement;\r\n\r\n this.zone.runOutsideAngular(() => {\r\n el.addEventListener('beforeinput', (ev: InputEvent) => {\r\n if (!this.digitsOnly) return;\r\n const data = (ev as any).data as string | null;\r\n if (!data || ev.inputType !== 'insertText') return;\r\n\r\n const pos = el.selectionStart ?? 0;\r\n const isDigit = data >= '0' && data <= '9';\r\n const isPlusAtStart = this.allowLeadingPlus && data === '+' && pos === 0 && !el.value.includes('+');\r\n\r\n if (!isDigit && !isPlusAtStart) ev.preventDefault();\r\n });\r\n\r\n el.addEventListener('paste', (e: ClipboardEvent) => {\r\n if (!this.digitsOnly) return;\r\n e.preventDefault();\r\n const text = (e.clipboardData || (window as any).clipboardData).getData('text');\r\n const sanitized = this.sanitizeDigits(text);\r\n const start = el.selectionStart ?? el.value.length;\r\n const end = el.selectionEnd ?? el.value.length;\r\n el.setRangeText(sanitized, start, end, 'end');\r\n queueMicrotask(() => this.handleInput());\r\n });\r\n\r\n el.addEventListener('input', () => {\r\n if (this.digitsOnly) {\r\n const val = el.value;\r\n const sanitized = this.sanitizeDigits(val);\r\n if (val !== sanitized) {\r\n const caret = el.selectionStart ?? sanitized.length;\r\n el.value = sanitized;\r\n el.setSelectionRange(caret, caret);\r\n }\r\n }\r\n this.handleInput();\r\n });\r\n\r\n el.addEventListener('countrychange', () => {\r\n const iso2 = this.currentIso2();\r\n this.zone.run(() => {\r\n this.countryChange.emit({iso2});\r\n this.validatorChange?.();\r\n });\r\n this.handleInput();\r\n });\r\n\r\n el.addEventListener('blur', () => this.onBlur());\r\n });\r\n }\r\n\r\n onBlur() {\r\n this.touched = true;\r\n this.zone.run(() => this.onTouchedCb());\r\n if (!this.formatOnBlur) return;\r\n const raw = this.currentRaw();\r\n if (!raw) return;\r\n const parsed = this.tel.parse(raw, this.currentIso2());\r\n if (this.nationalMode && parsed.national) {\r\n this.setInputValue((parsed.national || '').replace(/\\s{2,}/g, ' '));\r\n }\r\n }\r\n\r\n onFocus() {\r\n if (this.selectOnFocus) {\r\n const el = this.inputRef.nativeElement;\r\n queueMicrotask(() => el.setSelectionRange(0, el.value.length));\r\n }\r\n }\r\n\r\n private handleInput() {\r\n let raw = this.currentRaw();\r\n const iso2 = this.currentIso2();\r\n\r\n // live format while typing (optional)\r\n if (this.formatWhenValid === 'typing' && raw) {\r\n const formatted = this.formatAsYouType(raw, iso2);\r\n if (formatted !== raw) {\r\n // keep caret sane (end)\r\n this.setInputValue(formatted);\r\n raw = formatted;\r\n }\r\n }\r\n\r\n const parsed = this.tel.parse(raw, iso2);\r\n this.zone.run(() => this.onChange(parsed.e164)); // E.164 or null\r\n this.zone.run(() => this.inputChange.emit({ raw, e164: parsed.e164, iso2 }));\r\n\r\n // pretty print on blur already handled; keep this for nationalMode normalization\r\n if (raw && this.nationalMode && parsed.national) {\r\n const normalized = parsed.national.replace(/\\s{2,}/g, ' ');\r\n if (normalized !== raw) this.setInputValue(normalized);\r\n }\r\n }\r\n\r\n private formatAsYouType(raw: string, iso2: CountryCode): string {\r\n try {\r\n // When a region is provided, AsYouType returns NATIONAL formatting\r\n const fmt = new AsYouType(iso2);\r\n return fmt.input(raw);\r\n } catch {\r\n return raw;\r\n }\r\n }\r\n\r\n currentRaw(): string {\r\n return (this.inputRef?.nativeElement.value ?? '').trim();\r\n }\r\n\r\n private currentIso2(): CountryCode {\r\n const iso2 = (this.iti?.getSelectedCountryData?.().iso2 ?? this.initialCountry ?? 'US')\r\n .toString().toUpperCase();\r\n return iso2 as CountryCode;\r\n }\r\n\r\n private setInputValue(v: string) {\r\n this.inputRef.nativeElement.value = v ?? '';\r\n }\r\n\r\n get showError(): boolean {\r\n const invalid = !!this.validate({} as AbstractControl);\r\n return this.showErrorWhenTouched ? (this.touched && invalid) : invalid;\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.NgxsmkTelInputService"],"mappings":";;;;;;MAIa,qBAAqB,CAAA;IAChC,KAAK,CAAC,KAAa,EAAE,IAAiB,EAAA;QACpC,MAAM,KAAK,GAAG,0BAA0B,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC;AAC3D,QAAA,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,E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,KAAK;uBAAC,oBAAoB;gBAES,qBAAqB,EAAA,CAAA;sBAAxD,KAAK;uBAAC,uBAAuB;gBAIrB,cAAc,EAAA,CAAA;sBAAtB;gBACQ,GAAG,EAAA,CAAA;sBAAX;gBAGQ,eAAe,EAAA,CAAA;sBAAvB;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,iBAAiB,EAAA,CAAA;sBAAzB;gBAEQ,eAAe,EAAA,CAAA;sBAAvB;gBAGQ,UAAU,EAAA,CAAA;sBAAlB;gBACQ,gBAAgB,EAAA,CAAA;sBAAxB;gBAGS,aAAa,EAAA,CAAA;sBAAtB;gBACS,cAAc,EAAA,CAAA;sBAAvB;gBACS,WAAW,EAAA,CAAA;sBAApB;;;ACzJH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="ngxsmk-tel-input" />
5
+ export * from './public-api';
6
+ //# sourceMappingURL=ngxsmk-tel-input.d.ts.map
@@ -0,0 +1,94 @@
1
+ import { AfterViewInit, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
2
+ import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
3
+ import { CountryCode } from 'libphonenumber-js';
4
+ import { NgxsmkTelInputService } from './ngxsmk-tel-input.service';
5
+ import { CountryMap, IntlTelI18n } from './types';
6
+ import * as i0 from "@angular/core";
7
+ export declare class NgxsmkTelInputComponent implements AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor, Validator {
8
+ private readonly zone;
9
+ private readonly tel;
10
+ inputRef: ElementRef<HTMLInputElement>;
11
+ initialCountry: CountryCode | 'auto';
12
+ preferredCountries: CountryCode[];
13
+ onlyCountries?: CountryCode[];
14
+ nationalMode: boolean;
15
+ separateDialCode: boolean;
16
+ allowDropdown: boolean;
17
+ placeholder?: string;
18
+ autocomplete: string;
19
+ name?: string;
20
+ inputId?: string;
21
+ disabled: boolean;
22
+ label?: string;
23
+ hint?: string;
24
+ errorText?: string;
25
+ size: 'sm' | 'md' | 'lg';
26
+ variant: 'outline' | 'filled' | 'underline';
27
+ showClear: boolean;
28
+ autoFocus: boolean;
29
+ selectOnFocus: boolean;
30
+ formatOnBlur: boolean;
31
+ showErrorWhenTouched: boolean;
32
+ dropdownAttachToBody: boolean;
33
+ dropdownZIndex: number;
34
+ i18n?: IntlTelI18n;
35
+ set telI18n(v: IntlTelI18n | undefined);
36
+ localizedCountries?: CountryMap;
37
+ set telLocalizedCountries(v: CountryMap | undefined);
38
+ clearAriaLabel: string;
39
+ dir: 'ltr' | 'rtl';
40
+ autoPlaceholder: 'off' | 'polite' | 'aggressive';
41
+ utilsScript?: string;
42
+ customPlaceholder?: (example: string, country: any) => string;
43
+ formatWhenValid: 'off' | 'blur' | 'typing';
44
+ digitsOnly: boolean;
45
+ allowLeadingPlus: boolean;
46
+ countryChange: EventEmitter<{
47
+ iso2: CountryCode;
48
+ }>;
49
+ validityChange: EventEmitter<boolean>;
50
+ inputChange: EventEmitter<{
51
+ raw: string;
52
+ e164: string | null;
53
+ iso2: CountryCode;
54
+ }>;
55
+ private iti;
56
+ private onChange;
57
+ private onTouchedCb;
58
+ private validatorChange?;
59
+ private lastEmittedValid;
60
+ private pendingWrite;
61
+ private touched;
62
+ readonly resolvedId: string;
63
+ private readonly platformId;
64
+ constructor(zone: NgZone, tel: NgxsmkTelInputService);
65
+ ngAfterViewInit(): void;
66
+ private initAndWire;
67
+ ngOnChanges(changes: SimpleChanges): void;
68
+ ngOnDestroy(): void;
69
+ writeValue(val: string | null): void;
70
+ registerOnChange(fn: any): void;
71
+ registerOnTouched(fn: any): void;
72
+ setDisabledState(isDisabled: boolean): void;
73
+ validate(_: AbstractControl): ValidationErrors | null;
74
+ registerOnValidatorChange(fn: () => void): void;
75
+ focus(): void;
76
+ selectCountry(iso2: CountryCode): void;
77
+ clearInput(): void;
78
+ private initIntlTelInput;
79
+ private reinitPlugin;
80
+ private destroyPlugin;
81
+ private sanitizeDigits;
82
+ private bindDomListeners;
83
+ onBlur(): void;
84
+ onFocus(): void;
85
+ private handleInput;
86
+ private formatAsYouType;
87
+ currentRaw(): string;
88
+ private currentIso2;
89
+ private setInputValue;
90
+ get showError(): boolean;
91
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsmkTelInputComponent, never>;
92
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxsmkTelInputComponent, "ngxsmk-tel-input", never, { "initialCountry": { "alias": "initialCountry"; "required": false; }; "preferredCountries": { "alias": "preferredCountries"; "required": false; }; "onlyCountries": { "alias": "onlyCountries"; "required": false; }; "nationalMode": { "alias": "nationalMode"; "required": false; }; "separateDialCode": { "alias": "separateDialCode"; "required": false; }; "allowDropdown": { "alias": "allowDropdown"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "autocomplete": { "alias": "autocomplete"; "required": false; }; "name": { "alias": "name"; "required": false; }; "inputId": { "alias": "inputId"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "label": { "alias": "label"; "required": false; }; "hint": { "alias": "hint"; "required": false; }; "errorText": { "alias": "errorText"; "required": false; }; "size": { "alias": "size"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "showClear": { "alias": "showClear"; "required": false; }; "autoFocus": { "alias": "autoFocus"; "required": false; }; "selectOnFocus": { "alias": "selectOnFocus"; "required": false; }; "formatOnBlur": { "alias": "formatOnBlur"; "required": false; }; "showErrorWhenTouched": { "alias": "showErrorWhenTouched"; "required": false; }; "dropdownAttachToBody": { "alias": "dropdownAttachToBody"; "required": false; }; "dropdownZIndex": { "alias": "dropdownZIndex"; "required": false; }; "i18n": { "alias": "i18n"; "required": false; }; "telI18n": { "alias": "telI18n"; "required": false; }; "localizedCountries": { "alias": "localizedCountries"; "required": false; }; "telLocalizedCountries": { "alias": "telLocalizedCountries"; "required": false; }; "clearAriaLabel": { "alias": "clearAriaLabel"; "required": false; }; "dir": { "alias": "dir"; "required": false; }; "autoPlaceholder": { "alias": "autoPlaceholder"; "required": false; }; "utilsScript": { "alias": "utilsScript"; "required": false; }; "customPlaceholder": { "alias": "customPlaceholder"; "required": false; }; "formatWhenValid": { "alias": "formatWhenValid"; "required": false; }; "digitsOnly": { "alias": "digitsOnly"; "required": false; }; "allowLeadingPlus": { "alias": "allowLeadingPlus"; "required": false; }; }, { "countryChange": "countryChange"; "validityChange": "validityChange"; "inputChange": "inputChange"; }, never, never, true, never>;
93
+ }
94
+ //# sourceMappingURL=ngxsmk-tel-input.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngxsmk-tel-input.component.d.ts","sourceRoot":"","sources":["../../../projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,YAAY,EAIZ,MAAM,EACN,SAAS,EACT,SAAS,EAGT,aAAa,EAEd,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,oBAAoB,EAGpB,gBAAgB,EAChB,SAAS,EACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAY,WAAW,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;;AAIhD,qBA0Da,uBAAwB,YAAW,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS;IAkFhH,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAjFiB,QAAQ,EAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAGtE,cAAc,EAAE,WAAW,GAAG,MAAM,CAAQ;IAC5C,kBAAkB,EAAE,WAAW,EAAE,CAAgB;IACjD,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,YAAY,EAAE,OAAO,CA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nB,OAAO,CAAC,eAAe;IAUvB,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;IAIrB,IAAI,SAAS,IAAI,OAAO,CAGvB;yCAtYU,uBAAuB;2CAAvB,uBAAuB;CAuYnC"}
@@ -0,0 +1,13 @@
1
+ import { type CountryCode } from 'libphonenumber-js';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgxsmkTelInputService {
4
+ parse(input: string, iso2: CountryCode): {
5
+ e164: string | null;
6
+ national: string | null;
7
+ isValid: boolean;
8
+ };
9
+ isValid(input: string, iso2: CountryCode): boolean;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsmkTelInputService, never>;
11
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxsmkTelInputService>;
12
+ }
13
+ //# sourceMappingURL=ngxsmk-tel-input.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngxsmk-tel-input.service.d.ts","sourceRoot":"","sources":["../../../projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.service.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAEjF,qBACa,qBAAqB;IAChC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;IAO3G,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO;yCARvC,qBAAqB;6CAArB,qBAAqB;CAYjC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { CountryCode } from 'libphonenumber-js';
2
+ export type CountryMap = Partial<Record<CountryCode, string>>;
3
+ export interface IntlTelI18n {
4
+ selectedCountryAriaLabel?: string;
5
+ countryListAriaLabel?: string;
6
+ searchPlaceholder?: string;
7
+ zeroSearchResults?: string;
8
+ noCountrySelected?: string;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../projects/ngxsmk-tel-input/src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngxsmk-tel-input.d.ts","sourceRoot":"","sources":["../../projects/ngxsmk-tel-input/src/ngxsmk-tel-input.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngxsmk-tel-input",
3
- "version": "1.3.9",
3
+ "version": "1.4.1",
4
4
  "description": "Angular international telephone input (intl-tel-input UI + libphonenumber-js validation). ControlValueAccessor. SSR-safe.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -20,16 +20,6 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/toozuuu/ngxsmk-tel-input/issues"
22
22
  },
23
- "schematics": "./schematics/collection.json",
24
- "files": [
25
- "bundles/",
26
- "fesm*",
27
- "esm*",
28
- "schematics/",
29
- "migrations/",
30
- "README.md",
31
- "LICENSE"
32
- ],
33
23
  "keywords": [
34
24
  "ngxsmk-tel-input",
35
25
  "angular",
@@ -0,0 +1,4 @@
1
+ export { NgxsmkTelInputComponent } from './lib/ngxsmk-tel-input.component';
2
+ export { NgxsmkTelInputService } from './lib/ngxsmk-tel-input.service';
3
+ export type { IntlTelI18n, CountryMap } from './lib/types';
4
+ //# sourceMappingURL=public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../projects/ngxsmk-tel-input/src/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "http://json.schemastore.org/schematics",
3
- "schematics": {
4
- "ng-add": {
5
- "description": "Wire peer deps and intl-tel-input assets/styles",
6
- "factory": "./ng-add/index.js"
7
- }
8
- }
9
- }
@@ -1,59 +0,0 @@
1
- import { Rule, SchematicContext, Tree, chain } from '@angular-devkit/schematics';
2
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
- import { addPackageJsonDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
4
- import { updateWorkspace } from '@schematics/angular/utility/workspace';
5
-
6
- export default function ngAdd(): Rule {
7
- return chain([
8
- // 1) add peer deps and trigger install
9
- (tree: Tree, ctx: SchematicContext) => {
10
- addPackageJsonDependency(tree, {
11
- type: NodeDependencyType.Default,
12
- name: 'intl-tel-input',
13
- version: '^25.3.2',
14
- });
15
- addPackageJsonDependency(tree, {
16
- type: NodeDependencyType.Default,
17
- name: 'libphonenumber-js',
18
- version: '^1.12.11',
19
- });
20
- ctx.addTask(new NodePackageInstallTask());
21
- ctx.logger.info('✅ Added intl-tel-input and libphonenumber-js to package.json');
22
- return tree;
23
- },
24
-
25
- // 2) update angular.json (styles + assets) and persist via updateWorkspace
26
- updateWorkspace((workspace) => {
27
- const defaultProjectName =
28
- (workspace.extensions['defaultProject'] as string) ??
29
- workspace.projects.keys().next().value;
30
-
31
- const project = defaultProjectName ? workspace.projects.get(defaultProjectName) : undefined;
32
- if (!project) return;
33
-
34
- const build = project.targets.get('build');
35
- if (!build || !build.options) return;
36
-
37
- const opts = build.options as any;
38
-
39
- // add CSS
40
- const cssPath = 'node_modules/intl-tel-input/build/css/intlTelInput.css';
41
- const styles: any[] = Array.isArray(opts.styles) ? opts.styles : [];
42
- if (!styles.includes(cssPath)) styles.push(cssPath);
43
- opts.styles = styles;
44
-
45
- // add flag assets
46
- const flagsEntry = {
47
- glob: '**/*',
48
- input: 'node_modules/intl-tel-input/build/img',
49
- output: 'assets/intl-tel-input/img',
50
- };
51
- const assets: any[] = Array.isArray(opts.assets) ? opts.assets : [];
52
- const hasFlags = assets.some(
53
- (a) => a && a.input === flagsEntry.input && a.output === flagsEntry.output
54
- );
55
- if (!hasFlags) assets.push(flagsEntry);
56
- opts.assets = assets;
57
- }),
58
- ]);
59
- }