intl-tel-input 25.4.0 → 25.4.2
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 +13 -11
- package/angular/README.md +86 -0
- package/angular/build/IntlTelInput.cjs +11994 -0
- package/angular/build/IntlTelInput.d.ts +1299 -0
- package/angular/build/IntlTelInput.js +11965 -0
- package/angular/build/IntlTelInputWithUtils.cjs +18368 -0
- package/angular/build/IntlTelInputWithUtils.js +18339 -0
- package/build/css/demo.css +6 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.js +2 -2
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +2 -2
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +9 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +1 -1
- package/react/build/IntlTelInput.js +1 -1
- package/react/build/IntlTelInputWithUtils.cjs +1 -1
- package/react/build/IntlTelInputWithUtils.js +1 -1
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +1 -1
- package/vue/build/IntlTelInputWithUtils.mjs +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/react.webp" alt="React logo" width="16px" /> NEWS: we now have our own <a href="https://github.com/jackocnr/intl-tel-input/tree/master/react">React component</a>! Play with it on <a href="https://intl-tel-input.com/storybook/?path=/docs/intltelinput--vanilla">Storybook</a>.
|
|
6
6
|
|
|
7
|
+
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/angular.png" alt="Angular logo" width="16px" /> NEWS: we now have our own <a href="https://github.com/jackocnr/intl-tel-input/tree/master/angular">Angular component</a>!
|
|
8
|
+
|
|
7
9
|
🗣️ NEWS: we now provide [translations](#translations) in over 30 languages! [See them in action](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--i18n).
|
|
8
10
|
|
|
9
|
-
International Telephone Input is a JavaScript plugin for entering and validating international telephone numbers. It takes a regular input field, adds a searchable country dropdown, auto-detects the user's country, displays a relevant placeholder number, formats the number as you type, and provides comprehensive validation methods. React and
|
|
11
|
+
International Telephone Input is a JavaScript plugin for entering and validating international telephone numbers. It takes a regular input field, adds a searchable country dropdown, auto-detects the user's country, displays a relevant placeholder number, formats the number as you type, and provides comprehensive validation methods. React, Vue and Angular components are also included.
|
|
10
12
|
|
|
11
13
|
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vanilla2.png" alt="Screenshot" width="265px" height="273px" />
|
|
12
14
|
|
|
@@ -19,7 +21,7 @@ Use [Twilio's API to build phone verification, SMS 2FA, appointment reminders, m
|
|
|
19
21
|
|
|
20
22
|
## Table of Contents
|
|
21
23
|
|
|
22
|
-
- [React and
|
|
24
|
+
- [React, Vue and Angular Components](#react-vue-and-angular-components)
|
|
23
25
|
- [Demo and Examples](#demo-and-examples)
|
|
24
26
|
- [Mobile](#mobile)
|
|
25
27
|
- [Features](#features)
|
|
@@ -38,8 +40,8 @@ Use [Twilio's API to build phone verification, SMS 2FA, appointment reminders, m
|
|
|
38
40
|
- [Contributing](#contributing)
|
|
39
41
|
- [Attributions](#attributions)
|
|
40
42
|
|
|
41
|
-
## React and
|
|
42
|
-
We now provide
|
|
43
|
+
## React, Vue and Angular Components
|
|
44
|
+
We now provide React, Vue and Angular components alongside the regular JavaScript plugin. This readme is for the JavaScript plugin. View the [React Component readme](https://github.com/jackocnr/intl-tel-input/blob/master/react/README.md), the [Vue Component readme](https://github.com/jackocnr/intl-tel-input/blob/master/vue/README.md) or the [Angular Component readme](https://github.com/jackocnr/intl-tel-input/blob/master/angular/README.md).
|
|
43
45
|
|
|
44
46
|
## Demo and Examples
|
|
45
47
|
You can view [a live demo](https://intl-tel-input.com) and see some examples of how to use the various options. Alternatively, try it for yourself by downloading the project and opening demo.html in a browser.
|
|
@@ -61,7 +63,7 @@ By default, on mobile devices we show a fullscreen popup instead of the inline d
|
|
|
61
63
|
* Accessibility provided via ARIA tags
|
|
62
64
|
* Typescript type definitions included
|
|
63
65
|
* Easily customise styles by overriding CSS variables
|
|
64
|
-
* React and
|
|
66
|
+
* React, Vue and Angular components also included
|
|
65
67
|
* Translations for country names (etc) provided in many different languages
|
|
66
68
|
* Lots of initialisation options for customisation, as well as instance methods/events for interaction
|
|
67
69
|
|
|
@@ -75,16 +77,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
75
77
|
## Getting Started (Using a CDN)
|
|
76
78
|
1. Add the CSS
|
|
77
79
|
```html
|
|
78
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.
|
|
80
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.2/build/css/intlTelInput.css">
|
|
79
81
|
```
|
|
80
82
|
|
|
81
83
|
2. Add the plugin script and initialise it on your input element
|
|
82
84
|
```html
|
|
83
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.
|
|
85
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.2/build/js/intlTelInput.min.js"></script>
|
|
84
86
|
<script>
|
|
85
87
|
const input = document.querySelector("#phone");
|
|
86
88
|
window.intlTelInput(input, {
|
|
87
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.
|
|
89
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.2/build/js/utils.js"),
|
|
88
90
|
});
|
|
89
91
|
</script>
|
|
90
92
|
```
|
|
@@ -320,7 +322,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
320
322
|
```js
|
|
321
323
|
// (A) import utils module from a CDN
|
|
322
324
|
intlTelInput(htmlInputElement, {
|
|
323
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.
|
|
325
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.2/build/js/utils.js"),
|
|
324
326
|
});
|
|
325
327
|
|
|
326
328
|
// (B) import utils module from your own hosted version of utils.js
|
|
@@ -572,7 +574,7 @@ Example:
|
|
|
572
574
|
## Translations
|
|
573
575
|
We provide [translations](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) for the 200+ country names, as well as other user interface text (e.g. the placeholder text for the country search input) in over 30 languages. See the `i18n` option for details on how to use them. [See them in action](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--i18n).
|
|
574
576
|
|
|
575
|
-
Supported languages: Arabic, Bengali, Bosnian, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch,
|
|
577
|
+
Supported languages: Arabic, Bengali, Bosnian, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Greek, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Marathi, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, Swedish, Telugu, Thai, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese.
|
|
576
578
|
|
|
577
579
|
If we don't currently support a language you need, it's easy to [contribute this](https://github.com/jackocnr/intl-tel-input/blob/master/.github/CONTRIBUTING.md#adding-a-new-translation) yourself - you only need to provide a handful of UI translation strings, as we automatically pull in the country names from the country-list project.
|
|
578
580
|
|
|
@@ -604,7 +606,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
604
606
|
```js
|
|
605
607
|
// (A) import utils module from a CDN
|
|
606
608
|
intlTelInput(htmlInputElement, {
|
|
607
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.
|
|
609
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.2/build/js/utils.js"),
|
|
608
610
|
});
|
|
609
611
|
|
|
610
612
|
// (B) import utils module from your own hosted version of utils.js
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# IntlTelInput Angular Component
|
|
2
|
+
An Angular component wrapper for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the [source code](https://github.com/jackocnr/intl-tel-input/blob/master/angular/src/intl-tel-input/angular.component.ts).
|
|
3
|
+
|
|
4
|
+
## Table of Contents
|
|
5
|
+
- [Demo](#demo)
|
|
6
|
+
- [Getting Started](#getting-started)
|
|
7
|
+
- [Props](#props)
|
|
8
|
+
- [Events](#events)
|
|
9
|
+
- [Accessing Instance Methods](#accessing-instance-methods)
|
|
10
|
+
- [Accessing Static Methods](#accessing-static-methods)
|
|
11
|
+
|
|
12
|
+
## Demo
|
|
13
|
+
Try it for yourself by downloading the project and opening /angular/demo/validation/index.html (etc) in a browser.
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
```html
|
|
17
|
+
import IntlTelInput from "intl-tel-input/angularWithUtils";
|
|
18
|
+
import "intl-tel-input/styles";
|
|
19
|
+
|
|
20
|
+
<intl-tel-input
|
|
21
|
+
#telInput
|
|
22
|
+
(numberChange)="handleNumberChange($event)"
|
|
23
|
+
(validityChange)="handleValidityChange($event)"
|
|
24
|
+
[initOptions]="{
|
|
25
|
+
initialCountry: 'us',
|
|
26
|
+
}"
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/validation/validation.component.ts) for a more fleshed-out example of how to handle validation.
|
|
31
|
+
|
|
32
|
+
A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.2.1/build/js/utils.js"`.
|
|
33
|
+
|
|
34
|
+
## Props
|
|
35
|
+
Here's a list of all of the current props you can pass to the IntlTelInput Angular component.
|
|
36
|
+
|
|
37
|
+
**disabled**
|
|
38
|
+
Type: `Boolean`, Default: `false`
|
|
39
|
+
Sets the disabled attribute of both the telephone input and selected country button. _Note: we recommend using this instead of `inputProps.disabled`._
|
|
40
|
+
|
|
41
|
+
**initialValue**
|
|
42
|
+
Type: `String`
|
|
43
|
+
The initial value to put in the input. This will get auto-formatted on init (according to `formatOnDisplay` initialisation option). IntlTelInput is an uncontrolled input, and so will ignore any changes to this value.
|
|
44
|
+
|
|
45
|
+
**initOptions**
|
|
46
|
+
Type: `Object`
|
|
47
|
+
An object containing the [initialisation options](https://github.com/jackocnr/intl-tel-input?tab=readme-ov-file#initialisation-options) to pass to the plugin. You can use these exactly the same way as with the main JavaScript plugin.
|
|
48
|
+
|
|
49
|
+
**inputProps**
|
|
50
|
+
Type: `Object`
|
|
51
|
+
The props to pass to the input element e.g. `class`, `placeholder`, `required` etc. _Note: we recommend using the separate `disabled` prop instead of `inputProps.disabled`._
|
|
52
|
+
|
|
53
|
+
**usePreciseValidation**
|
|
54
|
+
Type: `Boolean`, Default: `false`
|
|
55
|
+
By default we use `isValidNumber` for validation, but if you'd rather use `isValidNumberPrecise` you can set this to `true`.
|
|
56
|
+
|
|
57
|
+
## Events
|
|
58
|
+
Here's a list of all of the current events you can listen to on the IntlTelInput angular component.
|
|
59
|
+
|
|
60
|
+
**countryChange**
|
|
61
|
+
Type: `Function`
|
|
62
|
+
A handler to be called when the selected country changes. It will be passed the new country iso2 code e.g. "gb" for UK.
|
|
63
|
+
|
|
64
|
+
**errorCodeChange**
|
|
65
|
+
Type: `Function`
|
|
66
|
+
A handler to be called when the number validation error changes. It will be passed the new error code (or `null`).
|
|
67
|
+
|
|
68
|
+
**numberChange**
|
|
69
|
+
Type: `Function`
|
|
70
|
+
A handler to be called when the number changes. It will be passed the new number.
|
|
71
|
+
|
|
72
|
+
**validityChange**
|
|
73
|
+
Type: `Function`
|
|
74
|
+
A handler to be called when the number validity changes e.g. to true/false. It will be passed the new isValid boolean.
|
|
75
|
+
|
|
76
|
+
### Native Input Events
|
|
77
|
+
|
|
78
|
+
Unlike the React and Vue version where events are passed through `inputProps`, in Angular you can directly bind to any native DOM event using the standard event binding syntax `(eventName)="handlerMethod()"`. This is more aligned with Angular's templating conventions and provides better type checking and autocompletion in your IDE.
|
|
79
|
+
|
|
80
|
+
## Accessing Instance Methods
|
|
81
|
+
|
|
82
|
+
You can access all of the plugin's [instance methods](https://github.com/jackocnr/intl-tel-input/blob/master/README.md#instance-methods) (`setNumber`, `setCountry`, `setPlaceholderNumberType` etc) by using a ViewChild reference into the IntlTelInput component (using the `#ref` prop), and then calling `this.telInput.getInstance()` e.g. `this.telInput.getInstance().setNumber(...);`. See the [Set Number demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/set-number/set-number.component.tsx) for a full example. You can also access the input DOM element in a similar way: `this.telInput.getInput()`.
|
|
83
|
+
|
|
84
|
+
## Accessing Static Methods
|
|
85
|
+
|
|
86
|
+
You can access all of the plugin's [static methods](https://github.com/jackocnr/intl-tel-input/blob/master/README.md#static-methods) by importing `intlTelInput` from the same file as the angular component e.g. `import { intlTelInput } from "intl-tel-input/angular"` (note the lower case "i" in "intlTelInput"). You can then use this as you would with the main plugin e.g. `intlTelInput.getCountryData()` or `intlTelInput.utils.numberType` etc.
|