intl-tel-input 21.1.3 → 21.2.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 (77) hide show
  1. package/README.md +21 -8
  2. package/build/js/data.js +499 -244
  3. package/build/js/data.min.js +2 -2
  4. package/build/js/i18n/ar/countries.mjs +251 -0
  5. package/build/js/i18n/ar/index.mjs +4 -0
  6. package/build/js/i18n/ar/interface.mjs +10 -0
  7. package/build/js/i18n/bg/countries.mjs +251 -0
  8. package/build/js/i18n/bg/index.mjs +4 -0
  9. package/build/js/i18n/bg/interface.mjs +10 -0
  10. package/build/js/i18n/bn/countries.mjs +251 -0
  11. package/build/js/i18n/bn/index.mjs +4 -0
  12. package/build/js/i18n/bn/interface.mjs +10 -0
  13. package/build/js/i18n/de/countries.mjs +251 -0
  14. package/build/js/i18n/de/index.mjs +4 -0
  15. package/build/js/i18n/de/interface.mjs +10 -0
  16. package/build/js/i18n/el/countries.mjs +251 -0
  17. package/build/js/i18n/el/index.mjs +4 -0
  18. package/build/js/i18n/el/interface.mjs +10 -0
  19. package/build/js/i18n/en/countries.mjs +251 -0
  20. package/build/js/i18n/en/index.mjs +4 -0
  21. package/build/js/i18n/en/interface.mjs +10 -0
  22. package/build/js/i18n/es/countries.mjs +251 -0
  23. package/build/js/i18n/es/index.mjs +4 -0
  24. package/build/js/i18n/es/interface.mjs +10 -0
  25. package/build/js/i18n/fr/countries.mjs +251 -0
  26. package/build/js/i18n/fr/index.mjs +4 -0
  27. package/build/js/i18n/fr/interface.mjs +10 -0
  28. package/build/js/i18n/hi/countries.mjs +251 -0
  29. package/build/js/i18n/hi/index.mjs +4 -0
  30. package/build/js/i18n/hi/interface.mjs +10 -0
  31. package/build/js/i18n/hu/countries.mjs +251 -0
  32. package/build/js/i18n/hu/index.mjs +4 -0
  33. package/build/js/i18n/hu/interface.mjs +10 -0
  34. package/build/js/i18n/id/countries.mjs +251 -0
  35. package/build/js/i18n/id/index.mjs +4 -0
  36. package/build/js/i18n/id/interface.mjs +10 -0
  37. package/build/js/i18n/index.mjs +22 -0
  38. package/build/js/i18n/ja/countries.mjs +251 -0
  39. package/build/js/i18n/ja/index.mjs +4 -0
  40. package/build/js/i18n/ja/interface.mjs +10 -0
  41. package/build/js/i18n/ko/countries.mjs +251 -0
  42. package/build/js/i18n/ko/index.mjs +4 -0
  43. package/build/js/i18n/ko/interface.mjs +10 -0
  44. package/build/js/i18n/mr/countries.mjs +251 -0
  45. package/build/js/i18n/mr/index.mjs +4 -0
  46. package/build/js/i18n/mr/interface.mjs +10 -0
  47. package/build/js/i18n/nl/countries.mjs +251 -0
  48. package/build/js/i18n/nl/index.mjs +4 -0
  49. package/build/js/i18n/nl/interface.mjs +10 -0
  50. package/build/js/i18n/pt/countries.mjs +251 -0
  51. package/build/js/i18n/pt/index.mjs +4 -0
  52. package/build/js/i18n/pt/interface.mjs +10 -0
  53. package/build/js/i18n/ro/countries.mjs +251 -0
  54. package/build/js/i18n/ro/index.mjs +4 -0
  55. package/build/js/i18n/ro/interface.mjs +10 -0
  56. package/build/js/i18n/ru/countries.mjs +251 -0
  57. package/build/js/i18n/ru/index.mjs +4 -0
  58. package/build/js/i18n/ru/interface.mjs +10 -0
  59. package/build/js/i18n/te/countries.mjs +251 -0
  60. package/build/js/i18n/te/index.mjs +4 -0
  61. package/build/js/i18n/te/interface.mjs +10 -0
  62. package/build/js/i18n/th/countries.mjs +251 -0
  63. package/build/js/i18n/th/index.mjs +4 -0
  64. package/build/js/i18n/th/interface.mjs +10 -0
  65. package/build/js/i18n/tr/countries.mjs +251 -0
  66. package/build/js/i18n/tr/index.mjs +4 -0
  67. package/build/js/i18n/tr/interface.mjs +10 -0
  68. package/build/js/i18n/ur/countries.mjs +251 -0
  69. package/build/js/i18n/ur/index.mjs +4 -0
  70. package/build/js/i18n/ur/interface.mjs +10 -0
  71. package/build/js/intlTelInput.d.ts +268 -0
  72. package/build/js/intlTelInput.js +518 -253
  73. package/build/js/intlTelInput.min.js +2 -2
  74. package/package.json +4 -1
  75. package/react/build/IntlTelInput.cjs +1 -1
  76. package/react/build/IntlTelInput.d.ts +268 -0
  77. package/react/build/IntlTelInput.js +1 -1
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # International Telephone Input [![Build Status](https://app.travis-ci.com/jackocnr/intl-tel-input.svg?branch=master)](https://app.travis-ci.com/jackocnr/intl-tel-input) <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
2
2
 
3
- 🎉 NEWS: we now have our own <a href="https://intl-tel-input.com/examples/react-component.html">React component</a>! Play with it on <a href="https://intl-tel-input.com/storybook/">Storybook</a>! 🎉
3
+ <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/react.png" alt="React logo" width="16px" /> NEWS: we now have our own <a href="https://intl-tel-input.com/examples/react-component.html">React component</a>! Play with it on <a href="https://intl-tel-input.com/storybook/">Storybook</a>.
4
4
 
5
- <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/typescript.png" alt="Typescript logo" width="18px" /> ANNOUNCEMENT: since v21.0.6 we have our own Typescript type definitions (for both the pure JavaScript and the React plugin), so no need to use `@types/intl-tel-input` any more!
5
+ <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/typescript.png" alt="Typescript logo" width="16px" /> NEWS: we now have our own Typescript type definitions (for both [the JavaScript plugin](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/intlTelInput.d.ts) and [the React component](https://github.com/jackocnr/intl-tel-input/blob/master/react/build/IntlTelInput.d.ts)), so no need to use `@types/intl-tel-input` any more!
6
6
 
7
- A JavaScript plugin for entering and validating international telephone numbers. It adds a (searchable) country dropdown to any input, detects the user's country, displays a relevant placeholder number, formats the number as you type, and provides comprehensive validation methods.
7
+ 🗣️ NEWS: we now provide [translation files](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) for several common languages! [See them in action](https://intl-tel-input.com/examples/localise-countries.html).
8
+
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.
8
10
 
9
11
  <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vanilla-search.png" alt="Screenshot" width="238px" style="max-width: 100%" />
10
12
 
@@ -17,11 +19,12 @@ Use <a href="https://www.twilio.com/blog/international-telephone-input-twilio?ut
17
19
  ## Table of Contents
18
20
 
19
21
  - [Demo and Examples](#demo-and-examples)
22
+ - [Mobile](#mobile)
20
23
  - [Features](#features)
21
24
  - [Browser Compatibility](#browser-compatibility)
22
25
  - [Getting Started](#getting-started-using-a-cdn)
23
26
  - [Recommended Usage](#recommended-usage)
24
- - [Options](#initialisation-options)
27
+ - [Initialisation Options](#initialisation-options)
25
28
  - [Public Methods](#public-methods)
26
29
  - [Static Methods](#static-methods)
27
30
  - [Events](#events)
@@ -52,6 +55,7 @@ By default, on mobile devices we show a fullscreen popup instead of the inline d
52
55
  * Typescript type definitions provided
53
56
  * Easily customise styles by overriding the provided CSS variables
54
57
  * React component included
58
+ * Translations for all country names (etc) provided in many different languages
55
59
 
56
60
  ## Browser Compatibility
57
61
  | Chrome | Firefox | Safari | Edge |
@@ -63,16 +67,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
63
67
  ## Getting Started (Using a CDN)
64
68
  1. Add the CSS
65
69
  ```html
66
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@21.1.3/build/css/intlTelInput.css">
70
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.0/build/css/intlTelInput.css">
67
71
  ```
68
72
 
69
73
  2. Add the plugin script and initialise it on your input element
70
74
  ```html
71
- <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@21.1.3/build/js/intlTelInput.min.js"></script>
75
+ <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.0/build/js/intlTelInput.min.js"></script>
72
76
  <script>
73
77
  const input = document.querySelector("#phone");
74
78
  window.intlTelInput(input, {
75
- utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@21.1.3/build/js/utils.js",
79
+ utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.0/build/js/utils.js",
76
80
  });
77
81
  </script>
78
82
  ```
@@ -138,6 +142,8 @@ You can always get the full international number (including country code) using
138
142
 
139
143
  If you know the user's country, you can set it with `initialCountry` (e.g. `"us"` for the United States), and if you don't, we recommend setting `initialCountry` to `"auto"` (along with the `geoIpLookup` option) to determine the user's country based on their IP address.
140
144
 
145
+ If you know the user's language, you can utilise the included translations to localise the country names (etc) - [see example](https://intl-tel-input.com/examples/localise-countries.html).
146
+
141
147
  ## Initialisation Options
142
148
  When you initialise the plugin, the first argument is the input element, and the second is an object containing any initialisation options you want, which are detailed below. Note: any options that take country codes should be [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) codes.
143
149
 
@@ -233,9 +239,16 @@ Which will generate the following (hidden) elements, which will be automatically
233
239
 
234
240
  **i18n**
235
241
  Type: `Object` Default: `{}`
236
- Allow localisation/customisation of country names and other plugin text. To localise a country name, the key should be the iso2 country code, and the value should be the localised country name. [See example](https://intl-tel-input.com/examples/localise-countries.html).
242
+ Allow localisation/customisation of country names and other plugin text. There are two options: either import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) (see option 1 below), or define your own custom translations (see option 2 below). If defining your own, you will need to specify all country names (over 200 at last count - [see full list](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/intl-tel-input/data.ts)) using their 2-character iso2 name, as well as the 7 interface keys listed below. [See example](https://intl-tel-input.com/examples/localise-countries.html).
237
243
 
238
244
  ```js
245
+ // OPTION 1: import one of the provided translation modules
246
+ import fr from "intl-tel-input/i18n/fr";
247
+
248
+ intlTelInput(input, { i18n: fr });
249
+
250
+
251
+ // OPTION 2: define your own custom translations
239
252
  intlTelInput(input, {
240
253
  i18n: {
241
254
  // Country names (see full list here: https://github.com/jackocnr/intl-tel-input/blob/master/src/js/data.js)