intl-tel-input 23.9.2 → 24.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/README.md +14 -11
- package/build/css/intlTelInput.css +303 -317
- package/build/css/intlTelInput.min.css +1 -1
- package/build/img/flags.png +0 -0
- package/build/img/flags.webp +0 -0
- package/build/img/flags@2x.png +0 -0
- package/build/img/flags@2x.webp +0 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +65 -65
- 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/index.js +0 -1
- package/package.json +5 -10
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +1 -1
- package/react/build/IntlTelInput.d.ts +65 -65
- package/react/build/IntlTelInput.js +1 -1
- package/react/build/IntlTelInputWithUtils.cjs +1 -1
- package/react/build/IntlTelInputWithUtils.js +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
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.
|
|
10
10
|
|
|
11
|
-
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vanilla-
|
|
11
|
+
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vanilla-search2.png" alt="Screenshot" width="237px" height="280px" />
|
|
12
12
|
|
|
13
13
|
If you find the plugin helpful, please consider [supporting the project](https://github.com/sponsors/jackocnr).
|
|
14
14
|
|
|
@@ -73,16 +73,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
73
73
|
## Getting Started (Using a CDN)
|
|
74
74
|
1. Add the CSS
|
|
75
75
|
```html
|
|
76
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
76
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@24.0.0/build/css/intlTelInput.css">
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
2. Add the plugin script and initialise it on your input element
|
|
80
80
|
```html
|
|
81
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
81
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@24.0.0/build/js/intlTelInput.min.js"></script>
|
|
82
82
|
<script>
|
|
83
83
|
const input = document.querySelector("#phone");
|
|
84
84
|
window.intlTelInput(input, {
|
|
85
|
-
utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
85
|
+
utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@24.0.0/build/js/utils.js",
|
|
86
86
|
});
|
|
87
87
|
</script>
|
|
88
88
|
```
|
|
@@ -255,20 +255,23 @@ If we don't currently support a language you need, it's easy to [contribute this
|
|
|
255
255
|
|
|
256
256
|
```js
|
|
257
257
|
// OPTION 1: import one of the provided translation modules
|
|
258
|
-
import fr from "intl-tel-input/i18n
|
|
258
|
+
import { fr } from "intl-tel-input/i18n";
|
|
259
259
|
|
|
260
260
|
intlTelInput(input, { i18n: fr });
|
|
261
261
|
|
|
262
262
|
// or to override one or more keys, you could do something like this
|
|
263
263
|
intlTelInput(input, {
|
|
264
|
-
i18n: {
|
|
264
|
+
i18n: {
|
|
265
|
+
...fr,
|
|
266
|
+
searchPlaceholder: "Recherche de pays",
|
|
267
|
+
},
|
|
265
268
|
});
|
|
266
269
|
|
|
267
270
|
|
|
268
271
|
// OPTION 2: define your own custom translations
|
|
269
272
|
intlTelInput(input, {
|
|
270
273
|
i18n: {
|
|
271
|
-
// Country names
|
|
274
|
+
// Country names - see full list in src/js/intl-tel-input/i18n/en/countries.ts
|
|
272
275
|
af: "Afghanistan",
|
|
273
276
|
al: "Albania",
|
|
274
277
|
dz: "Algeria",
|
|
@@ -287,7 +290,7 @@ intlTelInput(input, {
|
|
|
287
290
|
zeroSearchResults: "No results found",
|
|
288
291
|
// Screen reader text for when the search produces 1 result
|
|
289
292
|
oneSearchResult: "1 result found",
|
|
290
|
-
// Screen reader text for when the search produces multiple results
|
|
293
|
+
// Screen reader text for when the search produces multiple results
|
|
291
294
|
multipleSearchResults: "${count} results found",
|
|
292
295
|
}
|
|
293
296
|
});
|
|
@@ -317,7 +320,7 @@ Set this to false to hide the flags e.g. for political reasons. Instead it will
|
|
|
317
320
|
Type: `Boolean` Default: `false`
|
|
318
321
|
Display the selected country dial code next to the input, so it looks like it's part of the typed number, except it is uneditable. When enabled, typing a plus in the telephone input will open the country dropdown and enter the plus in the search input instead, to force the user to select a country from the list rather than typing their dial code in the telephone input. Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--separatedialcode) (using the React component).
|
|
319
322
|
|
|
320
|
-
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/
|
|
323
|
+
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/separate-dial-code3.png" width="234px" height="49px" alt="Separate Dial Code">
|
|
321
324
|
|
|
322
325
|
**strictMode**
|
|
323
326
|
Type: `Boolean` Default: `false`
|
|
@@ -329,7 +332,7 @@ Control when the country list appears as a fullscreen popup vs an inline dropdow
|
|
|
329
332
|
|
|
330
333
|
**utilsScript**
|
|
331
334
|
Type: `String` Default: `""` Example: `"/build/js/utils.js"`
|
|
332
|
-
This is one way to (lazy) load the included utils.js (to enable formatting/validation etc) - see [Loading The Utilities Script](#loading-the-utilities-script) for more options. 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
335
|
+
This is one way to (lazy) load the included utils.js (to enable formatting/validation etc) - see [Loading The Utilities Script](#loading-the-utilities-script) for more options. 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.0.0/build/js/utils.js"`. The script is loaded via a [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) statement, which means the URL cannot be relative - it must be absolute. The script is only fetched when you initialise the plugin, and additionally, only when the page has finished loading (on the window load event) to prevent blocking (the script is ~260KB). When instantiating the plugin, a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object is returned under the `promise` instance property, so you can do something like `iti.promise.then(callback)` to know when initialisation requests like this have finished. See [Utilities Script](#utilities-script) for more information.
|
|
333
336
|
|
|
334
337
|
**validationNumberType**
|
|
335
338
|
Type: `String` Default: `"MOBILE"`
|
|
@@ -544,7 +547,7 @@ The utils script provides lots of great functionality (see above section), but c
|
|
|
544
547
|
If you're not concerned about filesize (e.g. you're lazy loading this script), the easiest thing to do is to just use the full bundle /build/js/intlTelInputWithUtils.js, which comes with the utils script included. This script can be used exactly like the main intlTelInput.js - so it can either be loaded directly onto the page (which defines `window.intlTelInput` like usual), or it can be imported like so: `import intlTelInput from "intl-tel-input/intlTelInputWithUtils"`.
|
|
545
548
|
|
|
546
549
|
**Option 2: utilsScript**
|
|
547
|
-
If you *are* concerned about filesize, you can lazy load the utils script when the plugin intitialises, using the `utilsScript` 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
550
|
+
If you *are* concerned about filesize, you can lazy load the utils script when the plugin intitialises, using the `utilsScript` 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 `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.0.0/build/js/utils.js"`. If you want more control over when this file is lazy loaded, you can manually invoke the `loadUtils` static method, instead of using `utilsScript`.
|
|
548
551
|
|
|
549
552
|
## Troubleshooting
|
|
550
553
|
|