ngxsmk-tel-input 1.6.8 → 1.6.10
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/README.md +72 -25
- package/fesm2022/ngxsmk-tel-input.mjs +2445 -269
- package/fesm2022/ngxsmk-tel-input.mjs.map +1 -1
- package/lib/integrations/aws-sns.service.d.ts +30 -0
- package/lib/integrations/aws-sns.service.d.ts.map +1 -0
- package/lib/integrations/twilio.service.d.ts +31 -0
- package/lib/integrations/twilio.service.d.ts.map +1 -0
- package/lib/integrations/verification.service.d.ts +30 -0
- package/lib/integrations/verification.service.d.ts.map +1 -0
- package/lib/integrations/vonage.service.d.ts +30 -0
- package/lib/integrations/vonage.service.d.ts.map +1 -0
- package/lib/ngxsmk-tel-input.component.d.ts +243 -12
- package/lib/ngxsmk-tel-input.component.d.ts.map +1 -1
- package/lib/ngxsmk-tel-input.service.d.ts +94 -14
- package/lib/ngxsmk-tel-input.service.d.ts.map +1 -1
- package/lib/phone-input.utils.d.ts +125 -13
- package/lib/phone-input.utils.d.ts.map +1 -1
- package/lib/phone-intelligence.service.d.ts +47 -0
- package/lib/phone-intelligence.service.d.ts.map +1 -0
- package/lib/signals.d.ts +50 -0
- package/lib/signals.d.ts.map +1 -0
- package/lib/testing/e2e-helpers.d.ts +116 -0
- package/lib/testing/e2e-helpers.d.ts.map +1 -0
- package/lib/testing/mock-phone-service.d.ts +39 -0
- package/lib/testing/mock-phone-service.d.ts.map +1 -0
- package/lib/testing/test-fixtures.d.ts +120 -0
- package/lib/testing/test-fixtures.d.ts.map +1 -0
- package/lib/testing/testing.module.d.ts +11 -0
- package/lib/testing/testing.module.d.ts.map +1 -0
- package/lib/themes/material.theme.d.ts +24 -0
- package/lib/themes/material.theme.d.ts.map +1 -0
- package/lib/themes/primeng.theme.d.ts +22 -0
- package/lib/themes/primeng.theme.d.ts.map +1 -0
- package/lib/types-enhanced.d.ts +135 -0
- package/lib/types-enhanced.d.ts.map +1 -0
- package/package.json +4 -4
- package/public-api.d.ts +23 -0
- package/public-api.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
# ngxsmk-tel-input
|
|
2
2
|
|
|
3
|
-
An Angular **telephone input** component with country dropdown, flags, and robust validation
|
|
4
|
-
|
|
3
|
+
An Angular **phone input / telephone input** component with country dropdown, flags, international formatting, and robust validation.
|
|
4
|
+
Built on top of [`intl-tel-input`](https://github.com/jackocnr/intl-tel-input) + [`libphonenumber-js`](https://github.com/catamphetamine/libphonenumber-js), and fully compatible with Angular Reactive Forms and template-driven forms through `ControlValueAccessor`.
|
|
5
5
|
|
|
6
6
|
> Emits **E.164** by default (e.g. `+14155550123`). SSR‑safe via lazy browser‑only import.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Try it live on StackBlitz
|
|
9
9
|
|
|
10
10
|
[](https://stackblitz.com/~/github.com/toozuuu/ngxsmk-tel-input)
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Features
|
|
15
15
|
|
|
16
16
|
* Country dropdown with flags
|
|
17
17
|
* E.164 output (display can be national with `nationalMode`)
|
|
18
18
|
* Reactive & template‑driven Forms support (CVA)
|
|
19
19
|
* Built‑in validation using libphonenumber‑js
|
|
20
20
|
* **Enhanced validation**: Detects invalid country codes (like "11", "99") and shows appropriate error states
|
|
21
|
+
* **Mobile responsive**: Optimized for touch devices with proper tap targets, prevents iOS zoom, and responsive dropdown
|
|
22
|
+
* **Dark & Light themes**: Improved dark-mode contrast, consistent code/readout colors, and automatic system preference detection
|
|
23
|
+
* **Accessibility**: Full ARIA support, screen reader compatibility, keyboard navigation
|
|
21
24
|
* SSR‑friendly (no `window` on the server)
|
|
22
25
|
* Easy theming via CSS variables
|
|
23
26
|
* Nice UX options: label/hint/error text, sizes, variants, clear button, autofocus, select-on-focus
|
|
24
|
-
*
|
|
25
|
-
*
|
|
27
|
+
* Masking & caret-friendly as-you-type formatting (optional)
|
|
28
|
+
* Format only when valid (formatWhenValid) and lock once valid (lockWhenValid) to prevent extra digits
|
|
29
|
+
|
|
30
|
+
### Demo app highlights
|
|
31
|
+
|
|
32
|
+
The workspace demo (`ng serve demo`) now includes:
|
|
33
|
+
|
|
34
|
+
* polished documentation-style layout with improved spacing and visual hierarchy
|
|
35
|
+
* responsive sidebar/header behavior for mobile and desktop
|
|
36
|
+
* cleaner dark-mode palette with better text/background contrast
|
|
37
|
+
* improved focus states and reduced-motion support for accessibility
|
|
26
38
|
|
|
27
39
|
---
|
|
28
40
|
|
|
29
|
-
##
|
|
41
|
+
## Requirements
|
|
30
42
|
|
|
31
|
-
* Angular **17
|
|
43
|
+
* Angular **17+** (17, 18, 19, 20, 21+)
|
|
32
44
|
* Node **18** or **20**
|
|
33
45
|
|
|
34
|
-
> Library `peerDependencies` target Angular `>=17
|
|
46
|
+
> Library `peerDependencies` target Angular `>=17`. Fully compatible with Angular 17, 18, 19, 20, 21, and future versions.
|
|
35
47
|
|
|
36
48
|
---
|
|
37
49
|
|
|
38
|
-
##
|
|
50
|
+
## Install
|
|
39
51
|
|
|
40
52
|
```bash
|
|
41
53
|
npm i ngxsmk-tel-input intl-tel-input libphonenumber-js
|
|
@@ -79,7 +91,7 @@ Restart the dev server after changes.
|
|
|
79
91
|
|
|
80
92
|
---
|
|
81
93
|
|
|
82
|
-
##
|
|
94
|
+
## Quick start (Reactive Forms)
|
|
83
95
|
|
|
84
96
|
```ts
|
|
85
97
|
// app.component.ts
|
|
@@ -140,7 +152,7 @@ export class AppComponent {
|
|
|
140
152
|
|
|
141
153
|
---
|
|
142
154
|
|
|
143
|
-
##
|
|
155
|
+
## Template‑driven usage
|
|
144
156
|
|
|
145
157
|
```html
|
|
146
158
|
<form #f="ngForm">
|
|
@@ -151,7 +163,7 @@ export class AppComponent {
|
|
|
151
163
|
|
|
152
164
|
---
|
|
153
165
|
|
|
154
|
-
##
|
|
166
|
+
## Localization & RTL
|
|
155
167
|
|
|
156
168
|
You can localize the dropdown/search labels and override country names.
|
|
157
169
|
|
|
@@ -201,7 +213,7 @@ Arabic + RTL example
|
|
|
201
213
|
```
|
|
202
214
|
|
|
203
215
|
|
|
204
|
-
##
|
|
216
|
+
## ️ API
|
|
205
217
|
|
|
206
218
|
### Inputs
|
|
207
219
|
|
|
@@ -236,6 +248,7 @@ Arabic + RTL example
|
|
|
236
248
|
| `customPlaceholder` | `(example: string, country: any) => string` | — | Transform the example placeholder. |
|
|
237
249
|
| `clearAriaLabel` | `string` | `'Clear phone number'` | ARIA label for the clear button. |
|
|
238
250
|
| `lockWhenValid` | `boolean` | `true` | Prevent appending extra digits once the number is valid (editing/replacing still allowed). |
|
|
251
|
+
| `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Theme preference for the component. |
|
|
239
252
|
|
|
240
253
|
> `CountryCode` is the ISO‑2 uppercase code from `libphonenumber-js` (e.g. `US`, `GB`).
|
|
241
254
|
|
|
@@ -246,15 +259,18 @@ Arabic + RTL example
|
|
|
246
259
|
| `countryChange` | `{ iso2: CountryCode }` | Fired when selected country changes. |
|
|
247
260
|
| `validityChange` | `boolean` | Fired when validity flips. |
|
|
248
261
|
| `inputChange` | `{ raw: string; e164: string \| null; iso2: CountryCode }` | Emitted on every keystroke. |
|
|
262
|
+
| `ready` | `void` | Emitted after plugin + listeners finish wiring (including each re-init cycle). |
|
|
249
263
|
|
|
250
264
|
### Public methods
|
|
251
265
|
|
|
252
266
|
* `focus(): void`
|
|
253
267
|
* `selectCountry(iso2: CountryCode): void`
|
|
254
268
|
|
|
269
|
+
For deterministic first render behavior, prefer setting `[initialCountry]` directly. If you call imperative APIs like `selectCountry(...)` immediately after mount, wait for `(ready)` first.
|
|
270
|
+
|
|
255
271
|
---
|
|
256
272
|
|
|
257
|
-
##
|
|
273
|
+
## Formatting & validity behavior
|
|
258
274
|
|
|
259
275
|
* No formatting while invalid. As-you-type masking only starts when the digits form a valid number for the selected country.
|
|
260
276
|
|
|
@@ -266,7 +282,9 @@ For rare patterns not covered by libphonenumber-js, the control falls back to ra
|
|
|
266
282
|
|
|
267
283
|
---
|
|
268
284
|
|
|
269
|
-
##
|
|
285
|
+
## Theming
|
|
286
|
+
|
|
287
|
+
### CSS Variables
|
|
270
288
|
|
|
271
289
|
Override on the element or a parent container:
|
|
272
290
|
|
|
@@ -285,11 +303,40 @@ Available tokens:
|
|
|
285
303
|
* Input: `--tel-bg`, `--tel-fg`, `--tel-border`, `--tel-border-hover`, `--tel-ring`, `--tel-placeholder`, `--tel-error`, `--tel-radius`, `--tel-focus-shadow`
|
|
286
304
|
* Dropdown: `--tel-dd-bg`, `--tel-dd-border`, `--tel-dd-shadow`, `--tel-dd-radius`, `--tel-dd-item-hover`, `--tel-dd-search-bg`, `--tel-dd-z`
|
|
287
305
|
|
|
288
|
-
|
|
306
|
+
### Theme Support
|
|
307
|
+
|
|
308
|
+
The component supports light, dark, and auto themes:
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
import { NgxsmkTelInputComponent, ThemeService } from 'ngxsmk-tel-input';
|
|
312
|
+
|
|
313
|
+
// Component-level theme
|
|
314
|
+
<ngxsmk-tel-input [theme]="'dark'"></ngxsmk-tel-input>
|
|
315
|
+
|
|
316
|
+
// Global theme management
|
|
317
|
+
@Component({})
|
|
318
|
+
export class MyComponent {
|
|
319
|
+
private themeService = inject(ThemeService);
|
|
320
|
+
|
|
321
|
+
setDarkTheme() {
|
|
322
|
+
this.themeService.setTheme('dark');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Subscribe to theme changes
|
|
326
|
+
theme$ = this.themeService.currentTheme$;
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Themes:
|
|
331
|
+
- `'light'`: Light theme
|
|
332
|
+
- `'dark'`: Dark theme
|
|
333
|
+
- `'auto'`: Automatically follows system preference (default)
|
|
334
|
+
|
|
335
|
+
Dark mode: wrap in a `.dark` parent or use `[theme]="'dark'"` — tokens adapt automatically.
|
|
289
336
|
|
|
290
337
|
---
|
|
291
338
|
|
|
292
|
-
##
|
|
339
|
+
## ️ Validation patterns
|
|
293
340
|
|
|
294
341
|
```html
|
|
295
342
|
<ngxsmk-tel-input formControlName="phone"></ngxsmk-tel-input>
|
|
@@ -325,14 +372,14 @@ The component now includes enhanced validation that detects and handles various
|
|
|
325
372
|
|
|
326
373
|
---
|
|
327
374
|
|
|
328
|
-
##
|
|
375
|
+
## SSR notes
|
|
329
376
|
|
|
330
377
|
* The library lazy‑imports `intl-tel-input` only in the **browser** (guards with `isPlatformBrowser`).
|
|
331
378
|
* No `window`/`document` usage on the server path.
|
|
332
379
|
|
|
333
380
|
---
|
|
334
381
|
|
|
335
|
-
##
|
|
382
|
+
## Local development
|
|
336
383
|
|
|
337
384
|
This repo is an Angular workspace with a library.
|
|
338
385
|
|
|
@@ -353,7 +400,7 @@ npm i ../path-to-workspace/dist/ngxsmk-tel-input/ngxsmk-tel-input-<version>.tgz
|
|
|
353
400
|
|
|
354
401
|
---
|
|
355
402
|
|
|
356
|
-
##
|
|
403
|
+
## Troubleshooting
|
|
357
404
|
|
|
358
405
|
**UI looks unstyled / bullets in dropdown**
|
|
359
406
|
Add the CSS and assets in `angular.json` (see Install). Restart the dev server.
|
|
@@ -365,20 +412,20 @@ Ensure the assets copy exists under `/assets/intl-tel-input/img` and add the CSS
|
|
|
365
412
|
Build the library first so `dist/ngxsmk-tel-input` exists. If using workspace aliasing, add a `paths` entry to the root `tsconfig.base.json`.
|
|
366
413
|
|
|
367
414
|
**Peer dependency conflict when installing**
|
|
368
|
-
The lib peers are `@angular/* >=17
|
|
415
|
+
The lib peers are `@angular/* >=17`. Ensure your app uses Angular 17 or higher.
|
|
369
416
|
|
|
370
417
|
**Vite/Angular “Failed to resolve import …”**
|
|
371
418
|
Clear `.angular/cache`, rebuild the lib, and restart `ng serve`.
|
|
372
419
|
|
|
373
420
|
---
|
|
374
421
|
|
|
375
|
-
##
|
|
422
|
+
## License
|
|
376
423
|
|
|
377
424
|
[MIT](./LICENSE)
|
|
378
425
|
|
|
379
|
-
##
|
|
426
|
+
## Credits
|
|
380
427
|
|
|
381
428
|
* UI powered by [`intl-tel-input`](https://github.com/jackocnr/intl-tel-input)
|
|
382
429
|
* Parsing & validation by [`libphonenumber-js`](https://github.com/catamphetamine/libphonenumber-js)
|
|
383
430
|
|
|
384
|
-
Last updated:
|
|
431
|
+
Last updated: 2026-05-01
|