@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.
- package/CHANGELOG.md +25 -0
- package/README.md +119 -103
- package/fesm2022/moddi3-ngx-intl-tel-input.mjs +2361 -1201
- package/fesm2022/moddi3-ngx-intl-tel-input.mjs.map +1 -1
- package/package.json +22 -21
- package/types/moddi3-ngx-intl-tel-input.d.ts +497 -0
- package/types/moddi3-ngx-intl-tel-input.d.ts.map +1 -0
- package/esm2022/lib/data/country-code.mjs +0 -325
- package/esm2022/lib/directives/native-element-injector.directive.mjs +0 -33
- package/esm2022/lib/enums/country-iso.enum.mjs +0 -247
- package/esm2022/lib/enums/phone-number-format.enum.mjs +0 -6
- package/esm2022/lib/enums/search-country-field.enum.mjs +0 -8
- package/esm2022/lib/interfaces/change-data.mjs +0 -2
- package/esm2022/lib/model/country.model.mjs +0 -2
- package/esm2022/lib/ngx-intl-tel-input.component.mjs +0 -515
- package/esm2022/lib/ngx-intl-tel-input.module.mjs +0 -23
- package/esm2022/lib/ngx-intl-tel-input.validator.mjs +0 -59
- package/esm2022/moddi3-ngx-intl-tel-input.mjs +0 -5
- package/esm2022/public_api.mjs +0 -11
- package/index.d.ts +0 -6
- package/lib/data/country-code.d.ts +0 -7
- package/lib/data/country-code.d.ts.map +0 -1
- package/lib/directives/native-element-injector.directive.d.ts +0 -12
- package/lib/directives/native-element-injector.directive.d.ts.map +0 -1
- package/lib/enums/country-iso.enum.d.ts +0 -246
- package/lib/enums/country-iso.enum.d.ts.map +0 -1
- package/lib/enums/phone-number-format.enum.d.ts +0 -5
- package/lib/enums/phone-number-format.enum.d.ts.map +0 -1
- package/lib/enums/search-country-field.enum.d.ts +0 -7
- package/lib/enums/search-country-field.enum.d.ts.map +0 -1
- package/lib/interfaces/change-data.d.ts +0 -9
- package/lib/interfaces/change-data.d.ts.map +0 -1
- package/lib/model/country.model.d.ts +0 -12
- package/lib/model/country.model.d.ts.map +0 -1
- package/lib/ngx-intl-tel-input.component.d.ts +0 -103
- package/lib/ngx-intl-tel-input.component.d.ts.map +0 -1
- package/lib/ngx-intl-tel-input.module.d.ts +0 -15
- package/lib/ngx-intl-tel-input.module.d.ts.map +0 -1
- package/lib/ngx-intl-tel-input.validator.d.ts +0 -6
- package/lib/ngx-intl-tel-input.validator.d.ts.map +0 -1
- package/moddi3-ngx-intl-tel-input-16.0.0.tgz +0 -0
- package/moddi3-ngx-intl-tel-input.d.ts.map +0 -1
- package/public_api.d.ts +0 -8
- 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
|
-
#
|
|
1
|
+
# @moddi3/ngx-intl-tel-input
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/ngx-intl-tel-input)
|
|
7
|
-
[](https://www.npmjs.com/package/ngx-intl-tel-input)
|
|
3
|
+
[](https://github.com/moddi3/ngx-intl-tel-input/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@moddi3/ngx-intl-tel-input)
|
|
5
|
+
[](LICENSE)
|
|
8
6
|
|
|
9
|
-
[
|
|
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
|
-
|
|
9
|
+

|
|
12
10
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
## Compatibility
|
|
18
18
|
|
|
19
|
-
| ngx-intl-tel-input | Angular |
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
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
|
-
|
|
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
|
-
|
|
27
|
+
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
1. Install the package and its peer dependencies:
|
|
30
30
|
|
|
31
|
-
|
|
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
|
-
|
|
35
|
+
`intl-tel-input` 17 also works. The package uses only its CSS and flag images.
|
|
34
36
|
|
|
35
|
-
|
|
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
|
-
|
|
39
|
-
|
|
39
|
+
```json
|
|
40
|
+
"styles": [
|
|
41
|
+
"node_modules/intl-tel-input/build/css/intlTelInput.css",
|
|
42
|
+
"src/styles.css"
|
|
43
|
+
]
|
|
44
|
+
```
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
Without this file, the flags and the layout of the field do not render.
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
## Use
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
Import `NgxIntlTelInputModule` in the component that renders the form:
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
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
|
-
|
|
74
|
+
The module exports two standalone pieces. You can import them directly instead:
|
|
59
75
|
|
|
60
|
-
|
|
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
|
-
##
|
|
79
|
+
## Read the value
|
|
63
80
|
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
+
## Inputs and outputs
|
|
79
99
|
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
124
|
+
## Keyboard and screen readers
|
|
85
125
|
|
|
86
|
-
|
|
126
|
+
With `searchCountryFlag`, the flag is a button that opens a dialog with the search box and the country list:
|
|
87
127
|
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
</
|
|
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
|
-
|
|
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
|
-
|
|
136
|
+
In both modes, focus stays on one element and the active country is announced through `aria-activedescendant`.
|
|
118
137
|
|
|
119
|
-
|
|
138
|
+
## Develop
|
|
120
139
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
147
|
+
To try a local build in your app, run `npm run package` here and install the tarball in your app:
|
|
126
148
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
161
|
+
To see what the pending changesets will release, run `npm run changeset -- status`.
|
|
146
162
|
|
|
147
|
-
|
|
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
|
-
|
|
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 -->
|