intl-tel-input 18.5.3 → 19.0.1

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 (34) hide show
  1. package/README.md +42 -28
  2. package/build/css/demo.css +1 -1
  3. package/build/css/intlTelInput.css +29 -20
  4. package/build/js/data.js +1 -1
  5. package/build/js/data.min.js +1 -1
  6. package/build/js/intlTelInput-jquery.js +158 -151
  7. package/build/js/intlTelInput-jquery.min.js +3 -3
  8. package/build/js/intlTelInput.js +158 -151
  9. package/build/js/intlTelInput.min.js +3 -3
  10. package/composer.json +1 -1
  11. package/demo.html +5 -5
  12. package/grunt/replace.js +1 -7
  13. package/package.json +1 -1
  14. package/spec.html +6 -4
  15. package/src/css/demo.scss +1 -1
  16. package/src/css/intlTelInput.scss +42 -30
  17. package/src/js/intlTelInput.js +76 -125
  18. package/src/spec/helpers/helpers.js +23 -10
  19. package/src/spec/tests/core/countrychangeEvent.js +1 -1
  20. package/src/spec/tests/core/dropdownShortcuts.js +3 -2
  21. package/src/spec/tests/core/initialValues.js +2 -3
  22. package/src/spec/tests/methods/getSelectedCountryData.js +1 -1
  23. package/src/spec/tests/methods/isValidNumber.js +15 -32
  24. package/src/spec/tests/methods/isValidNumberPrecise.js +73 -0
  25. package/src/spec/tests/methods/setCountry.js +4 -4
  26. package/src/spec/tests/options/allowDropdown.js +3 -3
  27. package/src/spec/tests/options/autoInsertDialCode.js +1 -3
  28. package/src/spec/tests/options/autoPlaceholder.js +5 -5
  29. package/src/spec/tests/options/{customContainer.js → containerClass.js} +3 -3
  30. package/src/spec/tests/options/countrySearch.js +63 -0
  31. package/src/spec/tests/options/customPlaceholder.js +1 -1
  32. package/src/spec/tests/options/preferredCountries.js +3 -1
  33. package/src/spec/tests/options/{separateDialCode.js → showSelectedDialCode.js} +7 -7
  34. package/src/spec/tests/methods/isPossibleNumber.js +0 -56
package/README.md CHANGED
@@ -119,7 +119,7 @@ _Note: We have now dropped support for all versions of Internet Explorer because
119
119
  ```
120
120
 
121
121
  ## Recommended Usage
122
- We highly recommend you (lazy) load the included utils.js using the `utilsScript` option. Then the plugin is built to always deal with numbers in the full international format (e.g. "+17024181234") and convert them accordingly - even when `nationalMode` or `separateDialCode` is enabled. We recommend you get, store, and set numbers exclusively in this format for simplicity - then you don't have to deal with handling the country code separately, as full international numbers include the country code information.
122
+ We highly recommend you (lazy) load the included utils.js using the `utilsScript` option. Then the plugin is built to always deal with numbers in the full international format (e.g. "+17024181234") and convert them accordingly - even when `nationalMode` or `showSelectedDialCode` is enabled. We recommend you get, store, and set numbers exclusively in this format for simplicity - then you don't have to deal with handling the country code separately, as full international numbers include the country code information.
123
123
 
124
124
  You can always get the full international number (including country code) using `getNumber`, then you only have to store that one string in your database (you don't have to store the country separately), and then the next time you initialise the plugin with that number it will automatically set the country and format it according to the options you specify (e.g. when using `nationalMode` it will automatically display the number in national format, removing the international dial code).
125
125
 
@@ -141,14 +141,14 @@ When enabled (requires `nationalMode` to be disabled), the international dial co
141
141
  Type: `String` Default: `"polite"`
142
142
  Set the input's placeholder to an example number for the selected country, and update it if the country changes. You can specify the number type using the `placeholderNumberType` option. By default it is set to `"polite"`, which means it will only set the placeholder if the input doesn't already have one. You can also set it to `"aggressive"`, which will replace any existing placeholder, or `"off"`. Requires the `utilsScript` option.
143
143
 
144
+ **containerClass**
145
+ Type: `String` Default: `""`
146
+ Additional classes to add to the (injected) wrapper `<div>`.
147
+
144
148
  **countrySearch**
145
149
  Type: `Boolean` Default: `false`
146
150
  Add a search input to the top of the dropdown, so users can filter the displayed countries.
147
151
 
148
- **customContainer**
149
- Type: `String` Default: `""`
150
- Additional classes to add to the parent div.
151
-
152
152
  **customPlaceholder**
153
153
  Type: `Function` Default: `null`
154
154
  Change the placeholder generated by autoPlaceholder. Must return a string.
@@ -191,27 +191,30 @@ intlTelInput(input, {
191
191
  .then(function(data) { callback(data.country_code); })
192
192
  .catch(function() { callback("us"); });
193
193
  }
194
- })
194
+ });
195
195
  ```
196
196
  _Note that the callback must still be called in the event of an error, hence the use of `catch()` in this example. Tip: store the result in a cookie to avoid repeat lookups!_
197
197
 
198
198
  **hiddenInput**
199
- Type: `String` Default: `""`
200
- Add a hidden input with the given name. Alternatively, if your input name contains square brackets (e.g. `name="phone_number[main]"`) then it will give the hidden input the same name, replacing the contents of the brackets with the given name (e.g. if you init the plugin with `hiddenInput: "full"`, then in this case the hidden input would have `name="phone_number[full]"`). On submit, it will automatically populate the hidden input with the full international number (using `getNumber`). This is a quick way for people using non-Ajax forms to get the full international number, even when `nationalMode` is enabled. Avoid this option when using Ajax forms and instead just call `getNumber` to get the full international number to send in the request. _Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the `utilsScript` option, and secondly it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through._
201
-
202
- **initialCountry**
203
- Type: `String` Default: `""`
204
- Set the initial country selection by specifying its country code. You can also set it to `"auto"`, which will lookup the user's country based on their IP address (requires the `geoIpLookup` option - [see example](https://intl-tel-input.com/examples/lookup-country.html)). Note that the `"auto"` option will not update the country selection if the input already contains a number.
199
+ Type: `Function` Default: `null`
200
+ Creates a hidden input which gets populated with the full international number on submit. You must provide a function (which receives the main telephone input name as an argument, in case that's useful) and it must return the name to use for the hidden input. This is a quick way for people using non-Ajax forms to get the full international number, even when `nationalMode` is enabled. Avoid this option when using Ajax forms and instead just call `getNumber` to get the full international number to send in the request. _Note: requires the input to be inside a `<form>` element, as this feature works by listening for the `submit` event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the `utilsScript` option, and secondly it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through._
205
201
 
206
- If you leave `initialCountry` blank, it will default to the first country in the list.
202
+ ```js
203
+ intlTelInput(input, {
204
+ hiddenInput: function(telInputName) {
205
+ return "phone_full"
206
+ }
207
+ });
208
+ ```
207
209
 
208
- **localizedCountries**
210
+ **i18n**
209
211
  Type: `Object` Default: `{}`
210
- Allow localisation of country names. For each country, 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).
212
+ 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).
211
213
 
212
214
  ```js
213
- // Country names in German
214
- {
215
+ intlTelInput(input, {
216
+ i18n: {
217
+ // Country names
215
218
  fr: "Frankreich",
216
219
  de: "Deutschland",
217
220
  es: "Spanien",
@@ -220,9 +223,20 @@ Allow localisation of country names. For each country, the key should be the iso
220
223
  nl: "Niederlande",
221
224
  at: "Österreich",
222
225
  dk: "Dänemark",
226
+ // Other plugin text
227
+ selectedCountryAriaLabel: 'Ausgewähltes Land',
228
+ countryListAriaLabel: 'Liste der Länder',
229
+ searchPlaceholder: 'Suchen',
223
230
  }
231
+ });
224
232
  ```
225
233
 
234
+ **initialCountry**
235
+ Type: `String` Default: `""`
236
+ Set the initial country selection by specifying its country code. You can also set it to `"auto"`, which will lookup the user's country based on their IP address (requires the `geoIpLookup` option - [see example](https://intl-tel-input.com/examples/lookup-country.html)). Note that the `"auto"` option will not update the country selection if the input already contains a number.
237
+
238
+ If you leave `initialCountry` blank, it will default to the first country in the list.
239
+
226
240
  **nationalMode**
227
241
  Type: `Boolean` Default: `true`
228
242
  Format numbers in the national format, rather than the international format. This applies to placeholder numbers, and when displaying user's existing numbers. Note that it's fine for user's to type their numbers in national format - as long as they have selected the right country, you can use `getNumber` to extract a full international number - [see example](https://intl-tel-input.com/examples/national-mode.html). It is recommended to leave this option enabled, to encourage users to enter their numbers in national format as this is usually more familiar to them and so it creates a better user experience.
@@ -239,16 +253,16 @@ Specify [one of the keys](https://github.com/jackocnr/intl-tel-input/blob/master
239
253
  Type: `Array` Default: `["us", "gb"]`
240
254
  Specify the countries to appear at the top of the list.
241
255
 
242
- **separateDialCode**
256
+ **showFlags**
257
+ Type: `Boolean` Default: `true`
258
+ Set this to false to hide the flags e.g. for political reasons. Must be used in combination with `showSelectedDialCode` option, or with setting `allowDropdown` to `false`.
259
+
260
+ **showSelectedDialCode**
243
261
  Type: `Boolean` Default: `false`
244
262
  Display the country dial code next to the selected flag.
245
263
 
246
264
  <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/separateDialCode.png" width="257px" height="46px">
247
265
 
248
- **showFlags**
249
- Type: `Boolean` Default: `true`
250
- Set this to false to hide the flags e.g. for political reasons. Must be used in combination with `separateDialCode` option, or with setting `allowDropdown` to `false`.
251
-
252
266
  **useFullscreenPopup**
253
267
  Type: `Boolean` Default: `true on mobile devices, false otherwise`
254
268
  Control when the country list appears as a fullscreen popup vs a dropdown. By default, it will appear as a fullscreen popup on mobile devices (based on user-agent and screen width), and as a dropdown on larger devices/screens.
@@ -322,17 +336,17 @@ if (error === intlTelInputUtils.validationError.TOO_SHORT) {
322
336
  }
323
337
  ```
324
338
 
325
- **isPossibleNumber**
326
- Check if the current number is possible - [see example](https://intl-tel-input.com/examples/validation-practical.html). This is a simple form of validation that only checks the length of the number but should be sufficient for most use cases. See `isValidNumber` for more accurate validation, but the advantage of `isPossibleNumber` is that it is much more future-proof as while countries around the world regularly update their number rules, they very rarely change their number lengths. If it returns false, you can use `getValidationError` to get more information. Requires the `utilsScript` option.
339
+ **isValidNumber**
340
+ Check if the current number is valid based on its length - [see example](https://intl-tel-input.com/examples/validation-practical.html), which should be sufficient for most use cases. See `isValidNumberPrecise` for more precise validation, but the advantage of `isValidNumber` is that it is much more future-proof as while countries around the world regularly update their number rules, they very rarely change their number lengths. If it returns false, you can use `getValidationError` to get more information. Requires the `utilsScript` option.
327
341
  ```js
328
- const isPossible = iti.isPossibleNumber();
342
+ const isPossible = iti.isValidNumber();
329
343
  ```
330
344
  Returns: `true`/`false`
331
345
 
332
- **isValidNumber**
333
- Check if the current number is valid - [see example](https://intl-tel-input.com/examples/validation.html). This is a precise form of validation, with specific matching rules for each area code etc. Note that these rules change each month for various countries around the world, so you need to be careful to keep the plugin up-to-date else you will start rejecting valid numbers. For a simpler and more future-proof form of validation, see `isPossibleNumber` above. If validation fails, you can use `getValidationError` to get more information. Requires the `utilsScript` option.
346
+ **isValidNumberPrecise**
347
+ Check if the current number is valid using precise matching rules for each country/area code etc - [see example](https://intl-tel-input.com/examples/validation.html). Note that these rules change each month for various countries around the world, so you need to be careful to keep the plugin up-to-date else you will start rejecting valid numbers. For a simpler and more future-proof form of validation, see `isValidNumber` above. If validation fails, you can use `getValidationError` to get more information. Requires the `utilsScript` option.
334
348
  ```js
335
- const isValid = iti.isValidNumber();
349
+ const isValid = iti.isValidNumberPrecise();
336
350
  ```
337
351
  Returns: `true`/`false`
338
352
 
@@ -41,7 +41,7 @@ button[disabled] {
41
41
  input,
42
42
  select {
43
43
  border: 1px solid #ccc;
44
- width: 250px;
44
+ width: 220px;
45
45
  }
46
46
 
47
47
  ::placeholder,
@@ -53,28 +53,37 @@
53
53
  border-bottom: 4px solid #555;
54
54
  }
55
55
  .iti__dropdown-content {
56
+ border-radius: 3px;
57
+ background-color: white;
58
+ }
59
+ .iti--inline-dropdown .iti__dropdown-content {
56
60
  position: absolute;
57
61
  z-index: 2;
62
+ margin-top: 3px;
58
63
  margin-left: -1px;
59
- box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
60
- background-color: white;
61
64
  border: 1px solid #ccc;
62
- max-height: 200px;
63
- overflow-y: scroll;
64
- -webkit-overflow-scrolling: touch;
65
+ box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
65
66
  }
66
67
  .iti__dropdown-content--dropup {
67
68
  bottom: 100%;
68
- margin-bottom: -1px;
69
+ margin-bottom: 3px;
69
70
  }
70
71
  .iti__search-input {
71
72
  width: 100%;
72
73
  border-width: 0;
74
+ border-radius: 3px;
75
+ padding: 9px 12px;
76
+ }
77
+ .iti__search-input + .iti__country-list {
78
+ border-top: 1px solid #ccc;
73
79
  }
74
80
  .iti__country-list {
75
81
  list-style: none;
76
82
  padding: 0;
77
83
  margin: 0;
84
+ max-height: 185px;
85
+ overflow-y: scroll;
86
+ -webkit-overflow-scrolling: touch;
78
87
  }
79
88
  .iti--flexible-dropdown-width .iti__country-list {
80
89
  white-space: nowrap;
@@ -96,7 +105,7 @@
96
105
  .iti__country {
97
106
  display: flex;
98
107
  align-items: center;
99
- padding: 5px 10px;
108
+ padding: 8px 8px;
100
109
  outline: none;
101
110
  }
102
111
  .iti__dial-code {
@@ -106,35 +115,35 @@
106
115
  background-color: rgba(0, 0, 0, 0.05);
107
116
  }
108
117
  .iti__flag-box, .iti__country-name {
109
- margin-right: 6px;
118
+ margin-right: 8px;
110
119
  }
111
120
  [dir=rtl] .iti__flag-box, [dir=rtl] .iti__country-name {
112
121
  margin-right: 0;
113
- margin-left: 6px;
122
+ margin-left: 8px;
114
123
  }
115
124
  .iti--allow-dropdown input.iti__tel-input,
116
125
  .iti--allow-dropdown input.iti__tel-input[type=text],
117
- .iti--allow-dropdown input.iti__tel-input[type=tel], .iti--separate-dial-code input.iti__tel-input,
118
- .iti--separate-dial-code input.iti__tel-input[type=text],
119
- .iti--separate-dial-code input.iti__tel-input[type=tel] {
126
+ .iti--allow-dropdown input.iti__tel-input[type=tel], .iti--show-selected-dial-code input.iti__tel-input,
127
+ .iti--show-selected-dial-code input.iti__tel-input[type=text],
128
+ .iti--show-selected-dial-code input.iti__tel-input[type=tel] {
120
129
  padding-right: 6px;
121
130
  padding-left: 52px;
122
131
  margin-left: 0;
123
132
  }
124
133
  [dir=rtl] .iti--allow-dropdown input.iti__tel-input,
125
134
  [dir=rtl] .iti--allow-dropdown input.iti__tel-input[type=text],
126
- [dir=rtl] .iti--allow-dropdown input.iti__tel-input[type=tel], [dir=rtl] .iti--separate-dial-code input.iti__tel-input,
127
- [dir=rtl] .iti--separate-dial-code input.iti__tel-input[type=text],
128
- [dir=rtl] .iti--separate-dial-code input.iti__tel-input[type=tel] {
135
+ [dir=rtl] .iti--allow-dropdown input.iti__tel-input[type=tel], [dir=rtl] .iti--show-selected-dial-code input.iti__tel-input,
136
+ [dir=rtl] .iti--show-selected-dial-code input.iti__tel-input[type=text],
137
+ [dir=rtl] .iti--show-selected-dial-code input.iti__tel-input[type=tel] {
129
138
  padding-right: 52px;
130
139
  padding-left: 6px;
131
140
  margin-right: 0;
132
141
  }
133
- .iti--allow-dropdown .iti__flag-container, .iti--separate-dial-code .iti__flag-container {
142
+ .iti--allow-dropdown .iti__flag-container, .iti--show-selected-dial-code .iti__flag-container {
134
143
  right: auto;
135
144
  left: 0;
136
145
  }
137
- [dir=rtl] .iti--allow-dropdown .iti__flag-container, [dir=rtl] .iti--separate-dial-code .iti__flag-container {
146
+ [dir=rtl] .iti--allow-dropdown .iti__flag-container, [dir=rtl] .iti--show-selected-dial-code .iti__flag-container {
138
147
  right: 0;
139
148
  left: auto;
140
149
  }
@@ -152,13 +161,13 @@
152
161
  .iti--allow-dropdown .iti__flag-container:has(+ input[readonly]):hover .iti__selected-flag {
153
162
  background-color: transparent;
154
163
  }
155
- .iti--separate-dial-code .iti__selected-flag {
164
+ .iti--show-selected-dial-code .iti__selected-flag {
156
165
  background-color: rgba(0, 0, 0, 0.05);
157
166
  }
158
- .iti--separate-dial-code.iti--show-flags .iti__selected-dial-code {
167
+ .iti--show-selected-dial-code.iti--show-flags .iti__selected-dial-code {
159
168
  margin-left: 6px;
160
169
  }
161
- [dir=rtl] .iti--separate-dial-code.iti--show-flags .iti__selected-dial-code {
170
+ [dir=rtl] .iti--show-selected-dial-code.iti--show-flags .iti__selected-dial-code {
162
171
  margin-left: 0;
163
172
  margin-right: 6px;
164
173
  }
package/build/js/data.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v18.5.3
2
+ * International Telephone Input v19.0.1
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v18.5.3
2
+ * International Telephone Input v19.0.1
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */