intl-tel-input 28.0.5 → 28.0.7
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/dist/js/data.js +1 -1
- package/dist/js/data.min.js +1 -1
- package/dist/js/intlTelInput.js +34 -3
- package/dist/js/intlTelInput.min.js +2 -2
- package/dist/js/intlTelInput.mjs +33 -2
- package/dist/js/intlTelInputWithUtils.js +34 -3
- package/dist/js/intlTelInputWithUtils.min.js +2 -2
- package/dist/js/intlTelInputWithUtils.mjs +33 -2
- package/package.json +1 -1
|
@@ -2467,6 +2467,7 @@ var UI = class _UI {
|
|
|
2467
2467
|
#highlightedListItemEl = null;
|
|
2468
2468
|
#listItemByIso2 = /* @__PURE__ */ new Map();
|
|
2469
2469
|
#dropdownAbortController = null;
|
|
2470
|
+
#resizeObserver;
|
|
2470
2471
|
// public
|
|
2471
2472
|
telInputEl;
|
|
2472
2473
|
hadInitialPlaceholder;
|
|
@@ -2508,6 +2509,7 @@ var UI = class _UI {
|
|
|
2508
2509
|
this.#buildCountryContainer(wrapper);
|
|
2509
2510
|
wrapper.appendChild(this.telInputEl);
|
|
2510
2511
|
this.#updateInputPaddingAndReveal();
|
|
2512
|
+
this.#observeSelectedCountryResize();
|
|
2511
2513
|
this.#buildHiddenInputs(wrapper);
|
|
2512
2514
|
this.ensureDropdownWidthSet();
|
|
2513
2515
|
}
|
|
@@ -2515,6 +2517,7 @@ var UI = class _UI {
|
|
|
2515
2517
|
const { allowDropdown, showFlags, containerClass, useFullscreenPopup } = this.#options;
|
|
2516
2518
|
const parentClasses = buildClassNames({
|
|
2517
2519
|
iti: true,
|
|
2520
|
+
"iti--input-container": true,
|
|
2518
2521
|
"iti--allow-dropdown": allowDropdown,
|
|
2519
2522
|
"iti--show-flags": showFlags,
|
|
2520
2523
|
"iti--inline-dropdown": !useFullscreenPopup,
|
|
@@ -2800,6 +2803,18 @@ var UI = class _UI {
|
|
|
2800
2803
|
this.telInputEl.style.paddingLeft = `${inputPadding}px`;
|
|
2801
2804
|
}
|
|
2802
2805
|
}
|
|
2806
|
+
//* Keep the input padding in sync when the selected country's rendered width changes — e.g. responsive font-size shifts that change the dial code text width. Skip while hidden (offsetWidth === 0) so we don't waste work or clobber the padding using a fallback constant.
|
|
2807
|
+
#observeSelectedCountryResize() {
|
|
2808
|
+
if (!this.#selectedCountryEl || typeof ResizeObserver === "undefined") {
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2811
|
+
this.#resizeObserver = new ResizeObserver(() => {
|
|
2812
|
+
if (this.#selectedCountryEl?.offsetWidth) {
|
|
2813
|
+
this.#updateInputPadding();
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2816
|
+
this.#resizeObserver.observe(this.#selectedCountryEl);
|
|
2817
|
+
}
|
|
2803
2818
|
static #getBody() {
|
|
2804
2819
|
let body;
|
|
2805
2820
|
try {
|
|
@@ -3375,6 +3390,7 @@ var UI = class _UI {
|
|
|
3375
3390
|
destroy() {
|
|
3376
3391
|
this.telInputEl.iti = void 0;
|
|
3377
3392
|
delete this.telInputEl.dataset[DATA_KEYS.INSTANCE_ID];
|
|
3393
|
+
this.#resizeObserver?.disconnect();
|
|
3378
3394
|
this.telInputEl.style.paddingLeft = this.#originalPaddingLeft;
|
|
3379
3395
|
const wrapper = this.telInputEl.parentNode;
|
|
3380
3396
|
if (wrapper) {
|
|
@@ -3767,17 +3783,32 @@ var Iti = class _Iti {
|
|
|
3767
3783
|
}
|
|
3768
3784
|
intlTelInput.startedLoadingAutoCountry = true;
|
|
3769
3785
|
if (typeof this.#options.geoIpLookup === "function") {
|
|
3786
|
+
let timeoutId;
|
|
3770
3787
|
try {
|
|
3771
|
-
const iso2 = await
|
|
3788
|
+
const iso2 = await Promise.race([
|
|
3789
|
+
this.#options.geoIpLookup(),
|
|
3790
|
+
new Promise((_, reject) => {
|
|
3791
|
+
timeoutId = setTimeout(
|
|
3792
|
+
() => reject(new Error("intl-tel-input: geoIpLookup timed out after 10s")),
|
|
3793
|
+
1e4
|
|
3794
|
+
);
|
|
3795
|
+
})
|
|
3796
|
+
]);
|
|
3772
3797
|
const iso2Lower = typeof iso2 === "string" ? iso2.toLowerCase() : "";
|
|
3773
3798
|
if (!isIso2(iso2Lower)) {
|
|
3799
|
+
intlTelInput.startedLoadingAutoCountry = false;
|
|
3774
3800
|
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3775
3801
|
return;
|
|
3776
3802
|
}
|
|
3777
3803
|
intlTelInput.autoCountry = iso2Lower;
|
|
3778
3804
|
setTimeout(() => _Iti.forEachInstance("handleAutoCountryLoaded"));
|
|
3779
3805
|
} catch {
|
|
3806
|
+
intlTelInput.startedLoadingAutoCountry = false;
|
|
3780
3807
|
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3808
|
+
} finally {
|
|
3809
|
+
if (timeoutId !== void 0) {
|
|
3810
|
+
clearTimeout(timeoutId);
|
|
3811
|
+
}
|
|
3781
3812
|
}
|
|
3782
3813
|
}
|
|
3783
3814
|
}
|
|
@@ -4683,7 +4714,7 @@ var intlTelInput = Object.assign(
|
|
|
4683
4714
|
attachUtils,
|
|
4684
4715
|
startedLoadingUtils: false,
|
|
4685
4716
|
startedLoadingAutoCountry: false,
|
|
4686
|
-
version: "28.0.
|
|
4717
|
+
version: "28.0.7",
|
|
4687
4718
|
NUMBER_FORMAT,
|
|
4688
4719
|
NUMBER_TYPE,
|
|
4689
4720
|
VALIDATION_ERROR
|