intl-tel-input 25.13.1 → 25.13.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 +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +27 -11
- package/angular/build/IntlTelInputWithUtils.js +189 -156
- package/angular/build/types/modules/core/ui.d.ts +3 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +3 -1
- package/build/js/intlTelInput.js +30 -12
- package/build/js/intlTelInput.min.js +3 -3
- package/build/js/intlTelInputWithUtils.js +192 -157
- package/build/js/intlTelInputWithUtils.min.js +3 -3
- package/build/js/utils.js +42 -42
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +29 -11
- package/react/build/IntlTelInput.d.ts +3 -1
- package/react/build/IntlTelInput.js +29 -11
- package/react/build/IntlTelInputWithUtils.cjs +191 -156
- package/react/build/IntlTelInputWithUtils.js +191 -156
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +125 -118
- package/vue/build/IntlTelInputWithUtils.mjs +292 -268
package/README.md
CHANGED
|
@@ -81,16 +81,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
81
81
|
## Getting Started (Using a CDN)
|
|
82
82
|
1. Add the CSS
|
|
83
83
|
```html
|
|
84
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.
|
|
84
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/css/intlTelInput.css">
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
2. Add the plugin script and initialise it on your input element
|
|
88
88
|
```html
|
|
89
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.
|
|
89
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/js/intlTelInput.min.js"></script>
|
|
90
90
|
<script>
|
|
91
91
|
const input = document.querySelector("#phone");
|
|
92
92
|
window.intlTelInput(input, {
|
|
93
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.
|
|
93
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/js/utils.js"),
|
|
94
94
|
});
|
|
95
95
|
</script>
|
|
96
96
|
```
|
|
@@ -328,12 +328,12 @@ Set the initial country selection by specifying its country code, e.g. `"us"` fo
|
|
|
328
328
|
Type: `() => Promise<module>` Default: `null`
|
|
329
329
|
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.
|
|
330
330
|
|
|
331
|
-
The `loadUtils` option takes a function that returns a Promise resolving to the utils module (see example code below). You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.
|
|
331
|
+
The `loadUtils` option takes a function that returns a Promise resolving to the utils module (see example code below). You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/js/utils.js), or (C) if you use a bundler like Webpack, Vite or Parcel, you can import it directly from the package.
|
|
332
332
|
|
|
333
333
|
```js
|
|
334
334
|
// (A) import utils module from a CDN
|
|
335
335
|
intlTelInput(htmlInputElement, {
|
|
336
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.
|
|
336
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/js/utils.js"),
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
// (B) import utils module from your own hosted version of utils.js
|
package/angular/README.md
CHANGED
|
@@ -54,7 +54,7 @@ import "intl-tel-input/styles";
|
|
|
54
54
|
|
|
55
55
|
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, or check out the [form demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/form/form.component.ts) for an alternative approach using `ReactiveFormsModule`.
|
|
56
56
|
|
|
57
|
-
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 { IntlTelInputComponent } 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.13.
|
|
57
|
+
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 { IntlTelInputComponent } 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.13.3/build/js/utils.js"`.
|
|
58
58
|
|
|
59
59
|
## Props
|
|
60
60
|
|
|
@@ -2232,6 +2232,7 @@ var buildClearIcon = (id2) => {
|
|
|
2232
2232
|
var UI = class {
|
|
2233
2233
|
constructor(input, options, id2) {
|
|
2234
2234
|
this.highlightedItem = null;
|
|
2235
|
+
this.selectedItem = null;
|
|
2235
2236
|
input.dataset.intlTelInputId = id2.toString();
|
|
2236
2237
|
this.telInput = input;
|
|
2237
2238
|
this.options = options;
|
|
@@ -2432,8 +2433,7 @@ var UI = class {
|
|
|
2432
2433
|
for (let i = 0; i < this.countries.length; i++) {
|
|
2433
2434
|
const c = this.countries[i];
|
|
2434
2435
|
const liClass = buildClassNames({
|
|
2435
|
-
[CLASSES.COUNTRY_ITEM]: true
|
|
2436
|
-
[CLASSES.HIGHLIGHT]: i === 0
|
|
2436
|
+
[CLASSES.COUNTRY_ITEM]: true
|
|
2437
2437
|
});
|
|
2438
2438
|
const listItem = createEl("li", {
|
|
2439
2439
|
id: `iti-${this.id}__item-${c.iso2}`,
|
|
@@ -2529,17 +2529,15 @@ var UI = class {
|
|
|
2529
2529
|
container.scrollTop = newScrollTop - heightDifference;
|
|
2530
2530
|
}
|
|
2531
2531
|
}
|
|
2532
|
-
//* Remove highlighting from
|
|
2532
|
+
//* Remove highlighting from the previous list item and highlight the new one.
|
|
2533
2533
|
highlightListItem(listItem, shouldFocus) {
|
|
2534
2534
|
const prevItem = this.highlightedItem;
|
|
2535
2535
|
if (prevItem) {
|
|
2536
2536
|
prevItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
2537
|
-
prevItem.setAttribute(ARIA.SELECTED, "false");
|
|
2538
2537
|
}
|
|
2539
2538
|
this.highlightedItem = listItem;
|
|
2540
2539
|
if (this.highlightedItem) {
|
|
2541
2540
|
this.highlightedItem.classList.add(CLASSES.HIGHLIGHT);
|
|
2542
|
-
this.highlightedItem.setAttribute(ARIA.SELECTED, "true");
|
|
2543
2541
|
if (this.options.countrySearch) {
|
|
2544
2542
|
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2545
2543
|
this.searchInput.setAttribute(ARIA.ACTIVE_DESCENDANT, activeDescendant);
|
|
@@ -2549,6 +2547,19 @@ var UI = class {
|
|
|
2549
2547
|
this.highlightedItem.focus();
|
|
2550
2548
|
}
|
|
2551
2549
|
}
|
|
2550
|
+
updateSelectedItem(iso2) {
|
|
2551
|
+
if (this.selectedItem && this.selectedItem.dataset.countryCode !== iso2) {
|
|
2552
|
+
this.selectedItem.setAttribute(ARIA.SELECTED, "false");
|
|
2553
|
+
this.selectedItem = null;
|
|
2554
|
+
}
|
|
2555
|
+
if (iso2 && !this.selectedItem) {
|
|
2556
|
+
const newListItem = this.countryList.querySelector(`[data-country-code="${iso2}"]`);
|
|
2557
|
+
if (newListItem) {
|
|
2558
|
+
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
2559
|
+
this.selectedItem = newListItem;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2552
2563
|
//* Country search: Filter the country list to the given array of countries.
|
|
2553
2564
|
filterCountries(matchedCountries) {
|
|
2554
2565
|
this.countryList.innerHTML = "";
|
|
@@ -2600,6 +2611,7 @@ var UI = class {
|
|
|
2600
2611
|
this.hiddenInput = null;
|
|
2601
2612
|
this.hiddenInputCountry = null;
|
|
2602
2613
|
this.highlightedItem = null;
|
|
2614
|
+
this.selectedItem = null;
|
|
2603
2615
|
for (const c of this.countries) {
|
|
2604
2616
|
delete c.nodeById[this.id];
|
|
2605
2617
|
}
|
|
@@ -3456,11 +3468,14 @@ var Iti = class _Iti {
|
|
|
3456
3468
|
}
|
|
3457
3469
|
return null;
|
|
3458
3470
|
}
|
|
3459
|
-
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and
|
|
3471
|
+
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
3460
3472
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3461
3473
|
_setCountry(iso2) {
|
|
3462
|
-
const { separateDialCode, showFlags, i18n } = this.options;
|
|
3474
|
+
const { separateDialCode, showFlags, i18n, allowDropdown } = this.options;
|
|
3463
3475
|
const prevIso2 = this.selectedCountryData.iso2 || "";
|
|
3476
|
+
if (allowDropdown) {
|
|
3477
|
+
this.ui.updateSelectedItem(iso2);
|
|
3478
|
+
}
|
|
3464
3479
|
this.selectedCountryData = iso2 ? this.countryByIso2.get(iso2) : {};
|
|
3465
3480
|
if (this.selectedCountryData.iso2) {
|
|
3466
3481
|
this.defaultCountry = this.selectedCountryData.iso2;
|
|
@@ -3549,11 +3564,12 @@ var Iti = class _Iti {
|
|
|
3549
3564
|
}
|
|
3550
3565
|
this.ui.dropdownContent.classList.add(CLASSES.HIDE);
|
|
3551
3566
|
this.ui.selectedCountry.setAttribute(ARIA.EXPANDED, "false");
|
|
3552
|
-
if (this.ui.highlightedItem) {
|
|
3553
|
-
this.ui.highlightedItem.setAttribute(ARIA.SELECTED, "false");
|
|
3554
|
-
}
|
|
3555
3567
|
if (this.options.countrySearch) {
|
|
3556
3568
|
this.ui.searchInput.removeAttribute(ARIA.ACTIVE_DESCENDANT);
|
|
3569
|
+
if (this.ui.highlightedItem) {
|
|
3570
|
+
this.ui.highlightedItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
3571
|
+
this.ui.highlightedItem = null;
|
|
3572
|
+
}
|
|
3557
3573
|
}
|
|
3558
3574
|
this.ui.dropdownArrow.classList.remove(CLASSES.ARROW_UP);
|
|
3559
3575
|
this.dropdownAbortController.abort();
|
|
@@ -3859,7 +3875,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3859
3875
|
attachUtils,
|
|
3860
3876
|
startedLoadingUtilsScript: false,
|
|
3861
3877
|
startedLoadingAutoCountry: false,
|
|
3862
|
-
version: "25.13.
|
|
3878
|
+
version: "25.13.3"
|
|
3863
3879
|
});
|
|
3864
3880
|
var intl_tel_input_default = intlTelInput;
|
|
3865
3881
|
|