@moddi3/ngx-intl-tel-input 16.0.0 → 22.0.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 (44) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +119 -103
  3. package/fesm2022/moddi3-ngx-intl-tel-input.mjs +2361 -1201
  4. package/fesm2022/moddi3-ngx-intl-tel-input.mjs.map +1 -1
  5. package/package.json +22 -21
  6. package/types/moddi3-ngx-intl-tel-input.d.ts +497 -0
  7. package/types/moddi3-ngx-intl-tel-input.d.ts.map +1 -0
  8. package/esm2022/lib/data/country-code.mjs +0 -325
  9. package/esm2022/lib/directives/native-element-injector.directive.mjs +0 -33
  10. package/esm2022/lib/enums/country-iso.enum.mjs +0 -247
  11. package/esm2022/lib/enums/phone-number-format.enum.mjs +0 -6
  12. package/esm2022/lib/enums/search-country-field.enum.mjs +0 -8
  13. package/esm2022/lib/interfaces/change-data.mjs +0 -2
  14. package/esm2022/lib/model/country.model.mjs +0 -2
  15. package/esm2022/lib/ngx-intl-tel-input.component.mjs +0 -515
  16. package/esm2022/lib/ngx-intl-tel-input.module.mjs +0 -23
  17. package/esm2022/lib/ngx-intl-tel-input.validator.mjs +0 -59
  18. package/esm2022/moddi3-ngx-intl-tel-input.mjs +0 -5
  19. package/esm2022/public_api.mjs +0 -11
  20. package/index.d.ts +0 -6
  21. package/lib/data/country-code.d.ts +0 -7
  22. package/lib/data/country-code.d.ts.map +0 -1
  23. package/lib/directives/native-element-injector.directive.d.ts +0 -12
  24. package/lib/directives/native-element-injector.directive.d.ts.map +0 -1
  25. package/lib/enums/country-iso.enum.d.ts +0 -246
  26. package/lib/enums/country-iso.enum.d.ts.map +0 -1
  27. package/lib/enums/phone-number-format.enum.d.ts +0 -5
  28. package/lib/enums/phone-number-format.enum.d.ts.map +0 -1
  29. package/lib/enums/search-country-field.enum.d.ts +0 -7
  30. package/lib/enums/search-country-field.enum.d.ts.map +0 -1
  31. package/lib/interfaces/change-data.d.ts +0 -9
  32. package/lib/interfaces/change-data.d.ts.map +0 -1
  33. package/lib/model/country.model.d.ts +0 -12
  34. package/lib/model/country.model.d.ts.map +0 -1
  35. package/lib/ngx-intl-tel-input.component.d.ts +0 -103
  36. package/lib/ngx-intl-tel-input.component.d.ts.map +0 -1
  37. package/lib/ngx-intl-tel-input.module.d.ts +0 -15
  38. package/lib/ngx-intl-tel-input.module.d.ts.map +0 -1
  39. package/lib/ngx-intl-tel-input.validator.d.ts +0 -6
  40. package/lib/ngx-intl-tel-input.validator.d.ts.map +0 -1
  41. package/moddi3-ngx-intl-tel-input-16.0.0.tgz +0 -0
  42. package/moddi3-ngx-intl-tel-input.d.ts.map +0 -1
  43. package/public_api.d.ts +0 -8
  44. package/public_api.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # @moddi3/ngx-intl-tel-input
2
+
3
+ ## 22.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Requires Angular 22. The library is built and tested against Angular 22.2; peer dependencies are now
8
+ `@angular/common`, `@angular/core` and `@angular/forms` `^22.0.0`.
9
+ - The country dropdown uses the Angular Aria combobox (`@angular/aria`) instead of ngx-bootstrap `BsDropdown`.
10
+ `ngx-bootstrap` is no longer a peer dependency, and `dropdownModuleForRoot` is no longer exported.
11
+ Add `@angular/aria` `~22.2.0` to your app. The peer is pinned to the minor the library is built against because the
12
+ Aria combobox API has changed between releases.
13
+ - `NgxIntlTelInputComponent` and `NativeElementInjectorDirective` are standalone. Import them directly, or keep
14
+ importing `NgxIntlTelInputModule`, which now re-exports both.
15
+ - The bundled copy of the Bootstrap dropdown CSS was removed; the component styles its own dropdown. The `iti__*`
16
+ and `dropdown-menu` classes are kept, but custom CSS that relied on ngx-bootstrap's dropdown markup or state
17
+ classes may need updating.
18
+ - `intl-tel-input` `^17.0.0 || ^19.0.0` is accepted as a peer (16.0.0 required `^19.0.0`).
19
+
20
+ ### Patch Changes
21
+
22
+ - With `separateDialCode`, a typed Ukrainian number is validated as typed. Before, the hard-coded `+380 31 123 4567`
23
+ placeholder example replaced it in the formatted value, so validation checked the example instead of the input.
24
+ - Picking a country from the list re-validates the current number against it, and the search field stays in sync
25
+ with `ngModelChange`. Keyboard navigation scrolls the country list itself instead of the page.
package/README.md CHANGED
@@ -1,154 +1,170 @@
1
- # International Telephone Input for Angular (NgxIntlTelInput)
1
+ # @moddi3/ngx-intl-tel-input
2
2
 
3
- [![Build Status](https://github.com/webcat12345/ngx-intl-tel-input/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/webcat12345/ngx-intl-tel-input/actions/workflows/ci.yml)
4
- [![GitHub Pages](https://img.shields.io/badge/Demo-blue?logo=angular&label=Pages&color=7952B3)](https://webcat12345.github.io/ngx-intl-tel-input/demo/)
5
- [![license](https://img.shields.io/github/license/webcat12345/ngx-intl-tel-input)](https://github.com/webcat12345/ngx-intl-tel-input/blob/master/LICENSE)
6
- [![npm version](https://img.shields.io/npm/v/ngx-intl-tel-input)](https://badge.fury.io/js/ngx-intl-tel-input)
7
- [![npm](https://img.shields.io/npm/dm/ngx-intl-tel-input)](https://www.npmjs.com/package/ngx-intl-tel-input)
3
+ [![CI](https://github.com/moddi3/ngx-intl-tel-input/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/moddi3/ngx-intl-tel-input/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/@moddi3/ngx-intl-tel-input)](https://www.npmjs.com/package/@moddi3/ngx-intl-tel-input)
5
+ [![license](https://img.shields.io/github/license/moddi3/ngx-intl-tel-input)](LICENSE)
8
6
 
9
- [![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg)](#contributors)
7
+ An Angular form control for international phone numbers. It puts a country picker with flags next to a phone input, shows an example number for the selected country, and validates the number with [google-libphonenumber](https://github.com/ruimarinho/google-libphonenumber).
10
8
 
11
- An Angular package for entering and validating international telephone numbers. It adds a flag dropdown to any input, detects the user's country, displays a relevant placeholder and provides formatting/validation methods.
9
+ ![The phone input with the country list open](readme-assets/ngx-intl-tel-input.jpg)
12
10
 
13
- ![alt](readme-assets/ngx-intl-tel-input.jpg)
11
+ This package is a fork of [webcat12345/ngx-intl-tel-input](https://github.com/webcat12345/ngx-intl-tel-input). It differs from upstream in these ways:
14
12
 
15
- **Compatibility:**
13
+ - The country list is an [Angular Aria](https://angular.dev/guide/aria/overview) combobox. The package does not depend on ngx-bootstrap.
14
+ - The `excludeCountries` input hides countries from the list.
15
+ - The placeholder for Ukraine is `+380 31 123 4567` instead of the libphonenumber example `+380 3112 34567`.
16
16
 
17
- Validation with [google-libphonenumber](https://github.com/ruimarinho/google-libphonenumber)
17
+ ## Compatibility
18
18
 
19
- | ngx-intl-tel-input | Angular | ngx-bootstrap |
20
- | ------------------ | -------------- | ------------- |
21
- | 16.x.x | >= 16.x.x | >= 9.0.0 |
22
- | 3.x.x | 9.x.x - 15.x.x | >= 6.0.0 |
23
- | 2.x.x | 8.x.x - 9.1.x | 5.6.x |
19
+ | `@moddi3/ngx-intl-tel-input` | Angular | Country list built on |
20
+ | ---------------------------- | -------------- | --------------------------- |
21
+ | 22.x | 22.x | `@angular/aria` `~22.2.0` |
22
+ | 16.x | 16.x and later | `ngx-bootstrap` 9 and later |
23
+ | 3.x | 9.x to 15.x | `ngx-bootstrap` 6 and later |
24
24
 
25
- ## Installation
25
+ To upgrade from 16.x, read the 22.0.0 entry in the [changelog](projects/ngx-intl-tel-input/CHANGELOG.md).
26
26
 
27
- ### Install Dependencies
27
+ ## Install
28
28
 
29
- `$ npm install intl-tel-input@19 --save`
29
+ 1. Install the package and its peer dependencies:
30
30
 
31
- `$ npm install google-libphonenumber --save`
31
+ ```sh
32
+ npm install @moddi3/ngx-intl-tel-input @angular/aria@~22.2.0 google-libphonenumber intl-tel-input@19
33
+ ```
32
34
 
33
- `$ ng add ngx-bootstrap`
35
+ `intl-tel-input` 17 also works. The package uses only its CSS and flag images.
34
36
 
35
- If you do not wish to use Bootstrap's global CSS, we now package the project with only the relevant
36
- bootstrap styling needed for the dropdown. As such, you can remove the bootstrap styling from `angular.json`.
37
+ 2. Add the `intl-tel-input` styles to the `styles` array of your build target in `angular.json`:
37
38
 
38
- Further, Angular CLI should tree-shake the rest of Ngx-Boostrap away if you don't utilize other dependencies from
39
- the bootstrap package. This should keep this dependency a lean feature-add
39
+ ```json
40
+ "styles": [
41
+ "node_modules/intl-tel-input/build/css/intlTelInput.css",
42
+ "src/styles.css"
43
+ ]
44
+ ```
40
45
 
41
- ### Add Dependency Style
46
+ Without this file, the flags and the layout of the field do not render.
42
47
 
43
- Add _'intl-tel-input'_ style file:
48
+ ## Use
44
49
 
45
- `./node_modules/intl-tel-input/build/css/intlTelInput.css`
50
+ Import `NgxIntlTelInputModule` in the component that renders the form:
46
51
 
47
- to **angular.json** styles array:
48
-
49
- ```json
50
-
51
- "styles": [
52
- "./node_modules/intl-tel-input/build/css/intlTelInput.css",
53
- "src/styles.css"
54
- ],
52
+ ```ts
53
+ import { Component } from "@angular/core";
54
+ import { FormControl, FormGroup, ReactiveFormsModule } from "@angular/forms";
55
+ import type { ChangeData } from "@moddi3/ngx-intl-tel-input";
56
+ import { CountryISO, NgxIntlTelInputModule, SearchCountryField } from "@moddi3/ngx-intl-tel-input";
55
57
 
58
+ @Component({
59
+ selector: "app-phone-form",
60
+ imports: [ReactiveFormsModule, NgxIntlTelInputModule],
61
+ template: `
62
+ <form [formGroup]="form">
63
+ <ngx-intl-tel-input formControlName="phone" [preferredCountries]="[CountryISO.UnitedStates, CountryISO.UnitedKingdom]" [selectedCountryISO]="CountryISO.Ukraine" [excludeCountries]="[CountryISO.Russia]" [searchCountryFlag]="true" [searchCountryField]="[SearchCountryField.Name, SearchCountryField.DialCode]" [separateDialCode]="true" />
64
+ </form>
65
+ `,
66
+ })
67
+ export class PhoneFormComponent {
68
+ protected readonly CountryISO = CountryISO;
69
+ protected readonly SearchCountryField = SearchCountryField;
70
+ protected readonly form = new FormGroup({ phone: new FormControl<ChangeData | null>(null) });
71
+ }
56
72
  ```
57
73
 
58
- ### Install This Library
74
+ The module exports two standalone pieces. You can import them directly instead:
59
75
 
60
- `$ npm install @moddi3/ngx-intl-tel-input --save`
76
+ - `NgxIntlTelInputComponent` renders `<ngx-intl-tel-input>`.
77
+ - `NativeElementInjectorDirective` gives the phone validator access to the input element. It matches every `formControl`, `formControlName`, and `ngModel` in your template. Phone validation does not run without it.
61
78
 
62
- ## Usage
79
+ ## Read the value
63
80
 
64
- ### Import
81
+ The control value is `null` while the input is empty. Otherwise it is a `ChangeData` object. For `2015550123` with the United States selected, the value is:
65
82
 
66
- Add `NgxIntlTelInputModule` to your module file:
67
-
68
- ```javascript
69
- imports: [NgxIntlTelInputModule];
83
+ ```ts
84
+ {
85
+ number: '2015550123',
86
+ internationalNumber: '+1 201-555-0123',
87
+ nationalNumber: '(201) 555-0123',
88
+ e164Number: '+12015550123',
89
+ countryCode: 'US',
90
+ dialCode: '+1',
91
+ }
70
92
  ```
71
93
 
72
- ## Example
73
-
74
- Refer to main app in this repository for working example.
94
+ Store `e164Number`. It has no spaces or punctuation, so one phone number always gives the same string. With `separateDialCode`, `number` has no dial code and uses the `numberFormat` input.
75
95
 
76
- Or this:
96
+ When `phoneValidation` is on and the number is not valid for the selected country, the control has the error `{ validatePhoneNumber: { valid: false } }`.
77
97
 
78
- [Stackblitz Demo (Angular 8)](https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-8)
98
+ ## Inputs and outputs
79
99
 
80
- [Stackblitz Demo (Angular 9)](https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-9)
100
+ | Input | Type | Default | Description |
101
+ | -------------------------- | ---------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
102
+ | `cssClass` | `string` | `'form-control'` | CSS class of the phone `<input>`. |
103
+ | `inputId` | `string` | `'phone'` | `id` of the phone `<input>`. |
104
+ | `maxLength` | `number` | none | `maxlength` of the phone `<input>`. |
105
+ | `selectedCountryISO` | `CountryISO` | none | Country that is selected on load. |
106
+ | `selectFirstCountry` | `boolean` | `true` | Selects the first preferred country, or the first country of the list when `preferredCountries` is empty. `selectedCountryISO` overrides it. |
107
+ | `preferredCountries` | `CountryISO[]` | `[]` | Countries at the top of the list, above a divider. |
108
+ | `onlyCountries` | `CountryISO[]` | `[]` | Shows only these countries. |
109
+ | `excludeCountries` | `CountryISO[]` | `[]` | Hides these countries. |
110
+ | `enableAutoCountrySelect` | `boolean` | `true` | Selects the country from the dial code that the user types. For example, `+1 416 555 0123` selects Canada. |
111
+ | `enablePlaceholder` | `boolean` | `true` | Shows an example number of the selected country as the placeholder. |
112
+ | `customPlaceholder` | `string` | none | Placeholder text that replaces the example number. |
113
+ | `numberFormat` | `PhoneNumberFormat` | `PhoneNumberFormat.International` | Format of the example number. With `separateDialCode`, also the format of `number` in the value. |
114
+ | `separateDialCode` | `boolean` | `false` | Shows the dial code next to the flag, outside the input. |
115
+ | `searchCountryFlag` | `boolean` | `false` | Adds a search box to the country list. |
116
+ | `searchCountryField` | `SearchCountryField[]` | `[SearchCountryField.All]` | Country fields that the search box matches: `Name`, `Iso2`, `DialCode`, or `All`. |
117
+ | `searchCountryPlaceholder` | `string` | `'Search Country'` | Placeholder and accessible name of the search box. |
118
+ | `phoneValidation` | `boolean` | `true` | Validates the number for the selected country. |
81
119
 
82
- [Stackblitz Demo (Angular 10)](https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-10)
120
+ | Output | Emits |
121
+ | --------------- | ----------------------------------------------------------------------------------------------------------------------------- |
122
+ | `countryChange` | The selected country, with `name`, `iso2`, and `dialCode`. It also emits on load when `selectFirstCountry` selects a country. |
83
123
 
84
- [Stackblitz Demo (Angular 11)](https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-11)
124
+ ## Keyboard and screen readers
85
125
 
86
- [Stackblitz Demo (Angular 12)](https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-12)
126
+ With `searchCountryFlag`, the flag is a button that opens a dialog with the search box and the country list:
87
127
 
88
- ```html
89
- <form #f="ngForm" [formGroup]="phoneForm">
90
- <ngx-intl-tel-input [cssClass]="'custom'" [preferredCountries]="[CountryISO.UnitedStates, CountryISO.UnitedKingdom]" [enableAutoCountrySelect]="false" [enablePlaceholder]="true" [searchCountryFlag]="true" [searchCountryField]="[SearchCountryField.Iso2, SearchCountryField.Name]" [selectFirstCountry]="false" [selectedCountryISO]="CountryISO.India" [maxLength]="15" [phoneValidation]="true" [inputId]="my-input-id" name="phone" formControlName="phone" [excludeCountries]="[CountryISO.Russia]"></ngx-intl-tel-input>
91
- </form>
92
- ```
93
-
94
- ## Options
128
+ - <kbd>Enter</kbd>, <kbd>Space</kbd>, or <kbd>ArrowDown</kbd> on the flag opens the list and moves focus to the search box. The selected country is the active option.
129
+ - Typing moves the active option to the first match. <kbd>ArrowUp</kbd> and <kbd>ArrowDown</kbd> move it through the list.
130
+ - <kbd>Enter</kbd> selects the active country and moves focus to the phone input.
131
+ - <kbd>Escape</kbd> closes the list and returns focus to the flag.
132
+ - A click outside the list, or focus that leaves it, closes the list.
95
133
 
96
- | Options | Type | Default | Description |
97
- | ------------------------ | ------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------- |
98
- | cssClass | `string` | `control-form` | Bootstrap input css class or your own custom one. |
99
- | preferredCountries | `<CountryISO>[]` | `[]` | List of countries, which will appear at the top. |
100
- | onlyCountries | `<CountryISO>[]` | `[]` | List of manually selected countries, which will appear in the dropdown. |
101
- | enableAutoCountrySelect | `boolean` | `true` | Toggle automatic country (flag) selection based on user input. |
102
- | enablePlaceholder | `boolean` | `true` | Input placeholder text, which adapts to the country selected. |
103
- | customPlaceholder | `string` | `None` | Custom string to be inserted as a placeholder. |
104
- | numberFormat | `<PhoneNumberFormat>` | `PhoneNumberFormat.International` | Custom string to be inserted as a placeholder. |
105
- | searchCountryFlag | `boolean` | `false` | Enables input search box for countries in the flag dropdown. |
106
- | searchCountryField | `<SearchCountryField>[]` | `[SearchCountryField.All]` | Customize which fields to search in, if `searchCountryFlag` is enabled. Use `SearchCountryField` helper enum. |
107
- | searchCountryPlaceholder | `string` | `'Search Country'` | Placeholder value for `searchCountryField` |
108
- | maxLength | `number` | `None` | Add character limit. |
109
- | selectFirstCountry | `boolean` | `true` | Selects first country from `preferredCountries` if is set. If not then uses main list. |
110
- | phoneValidation | `boolean` | `true` | Disable phone validation. |
111
- | inputId | `string` | `phone` | Unique ID for `<input>` element. |
112
- | selectedCountryISO | `<CountryISO>` | `None` | Set specific country on load. |
113
- | separateDialCode | `boolean` | `false` | Visually separate dialcode into the drop down element. |
114
- | countryChange | `<Country>` | `None` | Emits country value when the user selects a country from the dropdown. |
115
- | excludeCountries | `<CountryISO>[]` | `[]` | List of exluded countries, that will not be displayed in the dropdown. |
134
+ Without `searchCountryFlag`, the flag is a [select-only combobox](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
116
135
 
117
- ## Supported Formats
136
+ In both modes, focus stays on one element and the active country is announced through `aria-activedescendant`.
118
137
 
119
- Following formats are supported
138
+ ## Develop
120
139
 
121
- - NATIONAL // Produces "044 668 18 00"
122
- - INTERNATIONAL // Produces "+41 44 668 18 00"
123
- - E164 // Produces "+41446681800"
140
+ | Command | What it does |
141
+ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
142
+ | `npm start` | Serves the demo app from `src/` at `http://localhost:4200`. |
143
+ | `npx ng test ngx-intl-tel-input` | Runs the library tests in Chrome. |
144
+ | `npm run build_package` | Builds the library into `dist/ngx-intl-tel-input` and copies `LICENSE`, `README.md`, and `CHANGELOG.md` into it. |
145
+ | `npm run package` | Builds the library and packs it into `dist/moddi3-ngx-intl-tel-input-<version>.tgz`. |
124
146
 
125
- ## Library Contributions
147
+ To try a local build in your app, run `npm run package` here and install the tarball in your app:
126
148
 
127
- - Fork repo.
128
- - Update `./projects/ngx-intl-tel-input`
129
- - Build / test library.
130
- - Update `./src/app` with new functionality.
131
- - Update README.md
132
- - Pull request.
133
-
134
- ### Helpful commands
149
+ ```sh
150
+ npm install /path/to/ngx-intl-tel-input/dist/moddi3-ngx-intl-tel-input-<version>.tgz
151
+ ```
135
152
 
136
- - Build lib: `$ npm run build_lib`
137
- - Copy license and readme files: `$ npm run copy-files`
138
- - Create package: `$ npm run npm_pack`
139
- - Build lib and create package: `$ npm run package`
153
+ ## Release
140
154
 
141
- ### Use locally
155
+ [Changesets](https://changesets.dev) versions the package. The `Release` workflow (`.github/workflows/release.yml`) publishes it. The Changesets files are in `projects/ngx-intl-tel-input/.changeset/`, so run the CLI through the root `npm run changeset` script.
142
156
 
143
- After building and creating package, you can use it locally too.
157
+ 1. In the pull request that changes the library, run `npm run changeset`. Pick the bump and write the changelog line. Commit the new `.changeset/*.md` file with the change.
158
+ 2. After the merge to `master`, the workflow opens or updates the "chore(release): version package" pull request. That pull request bumps `projects/ngx-intl-tel-input/package.json` and adds the entries to `projects/ngx-intl-tel-input/CHANGELOG.md`.
159
+ 3. Merge the release pull request. The workflow tests and builds the library, publishes `dist/ngx-intl-tel-input` to npm with provenance, pushes the `vX.Y.Z` tag, and creates the GitHub release.
144
160
 
145
- In your project run:
161
+ To see what the pending changesets will release, run `npm run changeset -- status`.
146
162
 
147
- `$ npm install --save {{path to your local '*.tgz' package file}}`
163
+ Do not run `npm publish` by hand. The workflow publishes through npm trusted publishing, and the package is the build output in `dist/ngx-intl-tel-input`, not the source folder.
148
164
 
149
165
  ## Contributors
150
166
 
151
- Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
167
+ The upstream project was built by these people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
152
168
 
153
169
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
154
170
  <!-- prettier-ignore-start -->