intl-tel-input 25.4.1 → 25.4.3

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 CHANGED
@@ -77,16 +77,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
77
77
  ## Getting Started (Using a CDN)
78
78
  1. Add the CSS
79
79
  ```html
80
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.1/build/css/intlTelInput.css">
80
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.3/build/css/intlTelInput.css">
81
81
  ```
82
82
 
83
83
  2. Add the plugin script and initialise it on your input element
84
84
  ```html
85
- <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.1/build/js/intlTelInput.min.js"></script>
85
+ <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.3/build/js/intlTelInput.min.js"></script>
86
86
  <script>
87
87
  const input = document.querySelector("#phone");
88
88
  window.intlTelInput(input, {
89
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.1/build/js/utils.js"),
89
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.3/build/js/utils.js"),
90
90
  });
91
91
  </script>
92
92
  ```
@@ -322,7 +322,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
322
322
  ```js
323
323
  // (A) import utils module from a CDN
324
324
  intlTelInput(htmlInputElement, {
325
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.1/build/js/utils.js"),
325
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.3/build/js/utils.js"),
326
326
  });
327
327
 
328
328
  // (B) import utils module from your own hosted version of utils.js
@@ -606,7 +606,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
606
606
  ```js
607
607
  // (A) import utils module from a CDN
608
608
  intlTelInput(htmlInputElement, {
609
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.1/build/js/utils.js"),
609
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.3/build/js/utils.js"),
610
610
  });
611
611
 
612
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.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.