ngxsmk-tel-input 1.6.7 → 1.6.9
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 +94 -39
- package/fesm2022/ngxsmk-tel-input.mjs +3330 -0
- package/fesm2022/ngxsmk-tel-input.mjs.map +1 -0
- package/index.d.ts +6 -0
- 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 +354 -0
- package/lib/ngxsmk-tel-input.component.d.ts.map +1 -0
- package/lib/ngxsmk-tel-input.service.d.ts +112 -0
- package/lib/ngxsmk-tel-input.service.d.ts.map +1 -0
- package/lib/phone-input.utils.d.ts +159 -0
- package/lib/phone-input.utils.d.ts.map +1 -0
- 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/theme.service.d.ts +46 -0
- package/lib/theme.service.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/lib/types.d.ts +10 -0
- package/lib/types.d.ts.map +1 -0
- package/ngxsmk-tel-input.d.ts.map +1 -0
- package/package.json +69 -88
- package/public-api.d.ts +29 -0
- package/public-api.d.ts.map +1 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.editorconfig +0 -17
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/dependabot.yml +0 -117
- package/.github/renovate.json +0 -10
- package/.github/workflows/publish.yml +0 -30
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/settings.json +0 -3
- package/.vscode/tasks.json +0 -42
- package/CHANGELOG.md +0 -50
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -66
- package/LICENSE +0 -21
- package/OPTIMIZATION_NOTES.md +0 -140
- package/SECURITY.md +0 -105
- package/THEME_DOCUMENTATION.md +0 -311
- package/angular.json +0 -147
- package/projects/demo/public/favicon.ico +0 -0
- package/projects/demo/src/app/app.component.html +0 -0
- package/projects/demo/src/app/app.component.scss +0 -460
- package/projects/demo/src/app/app.component.spec.ts +0 -29
- package/projects/demo/src/app/app.component.ts +0 -293
- package/projects/demo/src/app/app.config.ts +0 -8
- package/projects/demo/src/app/app.routes.ts +0 -3
- package/projects/demo/src/index.html +0 -13
- package/projects/demo/src/main.ts +0 -6
- package/projects/demo/src/styles.scss +0 -251
- package/projects/demo/tsconfig.app.json +0 -15
- package/projects/demo/tsconfig.spec.json +0 -15
- package/projects/ngxsmk-tel-input/.changeset/README.md +0 -8
- package/projects/ngxsmk-tel-input/.changeset/config.json +0 -11
- package/projects/ngxsmk-tel-input/README.md +0 -363
- package/projects/ngxsmk-tel-input/docs/invalid.png +0 -0
- package/projects/ngxsmk-tel-input/docs/kr.png +0 -0
- package/projects/ngxsmk-tel-input/docs/valid.png +0 -0
- package/projects/ngxsmk-tel-input/ng-package.json +0 -8
- package/projects/ngxsmk-tel-input/package-lock.json +0 -139
- package/projects/ngxsmk-tel-input/package.json +0 -59
- package/projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.component.scss +0 -341
- package/projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.component.spec.ts +0 -24
- package/projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.component.ts +0 -803
- package/projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.service.spec.ts +0 -15
- package/projects/ngxsmk-tel-input/src/lib/ngxsmk-tel-input.service.ts +0 -61
- package/projects/ngxsmk-tel-input/src/lib/phone-input.utils.ts +0 -109
- package/projects/ngxsmk-tel-input/src/lib/theme.service.ts +0 -184
- package/projects/ngxsmk-tel-input/src/lib/types.ts +0 -11
- package/projects/ngxsmk-tel-input/src/public-api.ts +0 -5
- package/projects/ngxsmk-tel-input/tsconfig.lib.json +0 -14
- package/projects/ngxsmk-tel-input/tsconfig.spec.json +0 -13
- package/tsconfig.json +0 -31
package/README.md
CHANGED
|
@@ -17,20 +17,24 @@ Wraps [`intl-tel-input`](https://github.com/jackocnr/intl-tel-input) for the UI
|
|
|
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
|
+
* **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**: Comprehensive theme system with automatic system preference detection
|
|
23
|
+
* **Accessibility**: Full ARIA support, screen reader compatibility, keyboard navigation
|
|
20
24
|
* SSR‑friendly (no `window` on the server)
|
|
21
25
|
* Easy theming via CSS variables
|
|
22
26
|
* Nice UX options: label/hint/error text, sizes, variants, clear button, autofocus, select-on-focus
|
|
23
|
-
*
|
|
24
|
-
*
|
|
27
|
+
* Masking & caret-friendly as-you-type formatting (optional)
|
|
28
|
+
* Format only when valid (formatWhenValid) and lock once valid (lockWhenValid) to prevent extra digits
|
|
25
29
|
|
|
26
30
|
---
|
|
27
31
|
|
|
28
32
|
## ✅ Requirements
|
|
29
33
|
|
|
30
|
-
* Angular **17
|
|
34
|
+
* Angular **17+** (17, 18, 19, 20, 21+)
|
|
31
35
|
* Node **18** or **20**
|
|
32
36
|
|
|
33
|
-
> Library `peerDependencies` target Angular `>=17
|
|
37
|
+
> Library `peerDependencies` target Angular `>=17`. Fully compatible with Angular 17, 18, 19, 20, 21, and future versions.
|
|
34
38
|
|
|
35
39
|
---
|
|
36
40
|
|
|
@@ -204,37 +208,38 @@ Arabic + RTL example
|
|
|
204
208
|
|
|
205
209
|
### Inputs
|
|
206
210
|
|
|
207
|
-
| Name | Type | Default | Description
|
|
208
|
-
|
|
209
|
-
| `initialCountry` | `CountryCode \| 'auto'` | `'US'` | Starting country. `'auto'` uses geoIp stub (`US` by default).
|
|
210
|
-
| `preferredCountries` | `CountryCode[]` | `['US','GB']` | Pin these at the top.
|
|
211
|
-
| `onlyCountries` | `CountryCode[]` | — | Limit selectable countries.
|
|
212
|
-
| `nationalMode` | `boolean` | `false` | If `true`, **display** national format in the input. Value still emits E.164.
|
|
213
|
-
| `separateDialCode` | `boolean` | `false` | Show dial code outside the input.
|
|
214
|
-
| `allowDropdown` | `boolean` | `true` | Enable/disable dropdown.
|
|
215
|
-
| `placeholder` | `string` | `'Enter phone number'` | Input placeholder.
|
|
216
|
-
| `autocomplete` | `string` | `'tel'` | Native autocomplete.
|
|
217
|
-
| `disabled` | `boolean` | `false` | Disable the control.
|
|
218
|
-
| `label` | `string` | — | Optional floating label text.
|
|
219
|
-
| `hint` | `string` | — | Helper text below the control.
|
|
220
|
-
| `errorText` | `string` | — | Custom error text.
|
|
221
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Control height/typography.
|
|
222
|
-
| `variant` | `'outline' \| 'filled' \| 'underline'` | `'outline'` | Visual variant.
|
|
223
|
-
| `showClear` | `boolean` | `true` | Show a clear (×) button when not empty.
|
|
224
|
-
| `autoFocus` | `boolean` | `false` | Focus on init.
|
|
225
|
-
| `selectOnFocus` | `boolean` | `false` | Select all text on focus.
|
|
226
|
-
| `formatOnBlur` | `boolean` | `true` | Pretty‑print on blur (national if `nationalMode`).
|
|
227
|
-
| `showErrorWhenTouched` | `boolean` | `true` | Show error styles only after blur.
|
|
228
|
-
| `dropdownAttachToBody` | `boolean` | `true` | Attach dropdown to `<body>` (avoids clipping/overflow).
|
|
229
|
-
| `dropdownZIndex` | `number` | `2000` | Z‑index for dropdown panel.
|
|
230
|
-
| `i18n` | `IntlTelI18n` | — | Localize dropdown/search/ARIA labels.
|
|
231
|
-
| `localizedCountries` | `Partial<Record<CountryCode, string>>` | — | Override country display names (ISO-2 keys).
|
|
232
|
-
| `dir` | `'ltr' \| 'rtl'` | `'ltr'` | Text direction for the control.
|
|
233
|
-
| `autoPlaceholder` | `'off' \| 'polite' \| 'aggressive'` | `'polite'` | Example placeholders. Requires `utilsScript` unless `off`.
|
|
234
|
-
| `utilsScript` | `string` | — | Path/URL to `utils.js` (needed for example placeholders).
|
|
235
|
-
| `customPlaceholder` | `(example: string, country: any) => string` | — | Transform the example placeholder.
|
|
236
|
-
| `clearAriaLabel` | `string` | `'Clear phone number'` | ARIA label for the clear button.
|
|
211
|
+
| Name | Type | Default | Description |
|
|
212
|
+
|------------------------|---------------------------------------------|-------------------------|-------------------------------------------------------------------------------|
|
|
213
|
+
| `initialCountry` | `CountryCode \| 'auto'` | `'US'` | Starting country. `'auto'` uses geoIp stub (`US` by default). |
|
|
214
|
+
| `preferredCountries` | `CountryCode[]` | `['US','GB']` | Pin these at the top. |
|
|
215
|
+
| `onlyCountries` | `CountryCode[]` | — | Limit selectable countries. |
|
|
216
|
+
| `nationalMode` | `boolean` | `false` | If `true`, **display** national format in the input. Value still emits E.164. |
|
|
217
|
+
| `separateDialCode` | `boolean` | `false` | Show dial code outside the input. |
|
|
218
|
+
| `allowDropdown` | `boolean` | `true` | Enable/disable dropdown. |
|
|
219
|
+
| `placeholder` | `string` | `'Enter phone number'` | Input placeholder. |
|
|
220
|
+
| `autocomplete` | `string` | `'tel'` | Native autocomplete. |
|
|
221
|
+
| `disabled` | `boolean` | `false` | Disable the control. |
|
|
222
|
+
| `label` | `string` | — | Optional floating label text. |
|
|
223
|
+
| `hint` | `string` | — | Helper text below the control. |
|
|
224
|
+
| `errorText` | `string` | — | Custom error text. |
|
|
225
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Control height/typography. |
|
|
226
|
+
| `variant` | `'outline' \| 'filled' \| 'underline'` | `'outline'` | Visual variant. |
|
|
227
|
+
| `showClear` | `boolean` | `true` | Show a clear (×) button when not empty. |
|
|
228
|
+
| `autoFocus` | `boolean` | `false` | Focus on init. |
|
|
229
|
+
| `selectOnFocus` | `boolean` | `false` | Select all text on focus. |
|
|
230
|
+
| `formatOnBlur` | `boolean` | `true` | Pretty‑print on blur (national if `nationalMode`). |
|
|
231
|
+
| `showErrorWhenTouched` | `boolean` | `true` | Show error styles only after blur. |
|
|
232
|
+
| `dropdownAttachToBody` | `boolean` | `true` | Attach dropdown to `<body>` (avoids clipping/overflow). |
|
|
233
|
+
| `dropdownZIndex` | `number` | `2000` | Z‑index for dropdown panel. |
|
|
234
|
+
| `i18n` | `IntlTelI18n` | — | Localize dropdown/search/ARIA labels. |
|
|
235
|
+
| `localizedCountries` | `Partial<Record<CountryCode, string>>` | — | Override country display names (ISO-2 keys). |
|
|
236
|
+
| `dir` | `'ltr' \| 'rtl'` | `'ltr'` | Text direction for the control. |
|
|
237
|
+
| `autoPlaceholder` | `'off' \| 'polite' \| 'aggressive'` | `'polite'` | Example placeholders. Requires `utilsScript` unless `off`. |
|
|
238
|
+
| `utilsScript` | `string` | — | Path/URL to `utils.js` (needed for example placeholders). |
|
|
239
|
+
| `customPlaceholder` | `(example: string, country: any) => string` | — | Transform the example placeholder. |
|
|
240
|
+
| `clearAriaLabel` | `string` | `'Clear phone number'` | ARIA label for the clear button. |
|
|
237
241
|
| `lockWhenValid` | `boolean` | `true` | Prevent appending extra digits once the number is valid (editing/replacing still allowed). |
|
|
242
|
+
| `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Theme preference for the component. |
|
|
238
243
|
|
|
239
244
|
> `CountryCode` is the ISO‑2 uppercase code from `libphonenumber-js` (e.g. `US`, `GB`).
|
|
240
245
|
|
|
@@ -265,8 +270,9 @@ For rare patterns not covered by libphonenumber-js, the control falls back to ra
|
|
|
265
270
|
|
|
266
271
|
---
|
|
267
272
|
|
|
273
|
+
## 🎨 Theming
|
|
268
274
|
|
|
269
|
-
|
|
275
|
+
### CSS Variables
|
|
270
276
|
|
|
271
277
|
Override on the element or a parent container:
|
|
272
278
|
|
|
@@ -285,7 +291,36 @@ Available tokens:
|
|
|
285
291
|
* Input: `--tel-bg`, `--tel-fg`, `--tel-border`, `--tel-border-hover`, `--tel-ring`, `--tel-placeholder`, `--tel-error`, `--tel-radius`, `--tel-focus-shadow`
|
|
286
292
|
* 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
293
|
|
|
288
|
-
|
|
294
|
+
### Theme Support
|
|
295
|
+
|
|
296
|
+
The component supports light, dark, and auto themes:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
import { NgxsmkTelInputComponent, ThemeService } from 'ngxsmk-tel-input';
|
|
300
|
+
|
|
301
|
+
// Component-level theme
|
|
302
|
+
<ngxsmk-tel-input [theme]="'dark'"></ngxsmk-tel-input>
|
|
303
|
+
|
|
304
|
+
// Global theme management
|
|
305
|
+
@Component({})
|
|
306
|
+
export class MyComponent {
|
|
307
|
+
private themeService = inject(ThemeService);
|
|
308
|
+
|
|
309
|
+
setDarkTheme() {
|
|
310
|
+
this.themeService.setTheme('dark');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Subscribe to theme changes
|
|
314
|
+
theme$ = this.themeService.currentTheme$;
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Themes:
|
|
319
|
+
- `'light'`: Light theme
|
|
320
|
+
- `'dark'`: Dark theme
|
|
321
|
+
- `'auto'`: Automatically follows system preference (default)
|
|
322
|
+
|
|
323
|
+
Dark mode: wrap in a `.dark` parent or use `[theme]="'dark'"` — tokens adapt automatically.
|
|
289
324
|
|
|
290
325
|
---
|
|
291
326
|
|
|
@@ -296,10 +331,30 @@ Dark mode: wrap in a `.dark` parent — tokens adapt automatically.
|
|
|
296
331
|
|
|
297
332
|
<div class="error" *ngIf="fg.get('phone')?.hasError('required')">Phone is required</div>
|
|
298
333
|
<div class="error" *ngIf="fg.get('phone')?.hasError('phoneInvalid')">Please enter a valid phone number</div>
|
|
334
|
+
<div class="error" *ngIf="fg.get('phone')?.hasError('phoneInvalidCountryCode')">Invalid country code</div>
|
|
299
335
|
```
|
|
300
336
|
|
|
337
|
+
### Enhanced Validation Features
|
|
338
|
+
|
|
339
|
+
The component now includes enhanced validation that detects and handles various invalid phone number scenarios:
|
|
340
|
+
|
|
341
|
+
#### **Invalid Country Code Detection**
|
|
342
|
+
- **Input**: `"1123456789"` or `"99123456789"`
|
|
343
|
+
- **Error**: `phoneInvalidCountryCode`
|
|
344
|
+
- **Reason**: "11" and "99" are not valid country codes
|
|
345
|
+
|
|
346
|
+
#### **Valid Country Code, Invalid Number**
|
|
347
|
+
- **Input**: `"+9111023533"` (India country code, Delhi area code, but incomplete subscriber number)
|
|
348
|
+
- **Error**: `phoneInvalid`
|
|
349
|
+
- **Reason**: Valid country/area codes but invalid number format
|
|
350
|
+
|
|
351
|
+
#### **Valid Numbers**
|
|
352
|
+
- **Input**: `"+12025551234"` (US), `"+442071234567"` (UK), `"+91112345678"` (India)
|
|
353
|
+
- **Status**: Valid
|
|
354
|
+
- **Output**: E.164 format string
|
|
355
|
+
|
|
301
356
|
* When **valid** → control value = **E.164** string
|
|
302
|
-
* When **invalid/empty** → value = **null**, and validator sets
|
|
357
|
+
* When **invalid/empty** → value = **null**, and validator sets appropriate error type
|
|
303
358
|
|
|
304
359
|
> Need national string instead of E.164? Use `(inputChange)` and store `raw`/`national` yourself, or adapt the emitter to output national.
|
|
305
360
|
|
|
@@ -345,7 +400,7 @@ Ensure the assets copy exists under `/assets/intl-tel-input/img` and add the CSS
|
|
|
345
400
|
Build the library first so `dist/ngxsmk-tel-input` exists. If using workspace aliasing, add a `paths` entry to the root `tsconfig.base.json`.
|
|
346
401
|
|
|
347
402
|
**Peer dependency conflict when installing**
|
|
348
|
-
The lib peers are `@angular/* >=17
|
|
403
|
+
The lib peers are `@angular/* >=17`. Ensure your app uses Angular 17 or higher.
|
|
349
404
|
|
|
350
405
|
**Vite/Angular “Failed to resolve import …”**
|
|
351
406
|
Clear `.angular/cache`, rebuild the lib, and restart `ng serve`.
|
|
@@ -361,4 +416,4 @@ Clear `.angular/cache`, rebuild the lib, and restart `ng serve`.
|
|
|
361
416
|
* UI powered by [`intl-tel-input`](https://github.com/jackocnr/intl-tel-input)
|
|
362
417
|
* Parsing & validation by [`libphonenumber-js`](https://github.com/catamphetamine/libphonenumber-js)
|
|
363
418
|
|
|
364
|
-
Last updated: 2025-
|
|
419
|
+
Last updated: 2025-01-21
|