intl-tel-input 25.10.11 → 25.11.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.
@@ -2086,6 +2086,7 @@ var getNumeric = (s) => s.replace(/\D/g, "");
2086
2086
  var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
2087
2087
 
2088
2088
  // src/js/modules/utils/dom.ts
2089
+ var buildClassNames = (flags) => Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
2089
2090
  var createEl = (tagName, attrs, container) => {
2090
2091
  const el = document.createElement(tagName);
2091
2092
  if (attrs) {
@@ -2097,258 +2098,23 @@ var createEl = (tagName, attrs, container) => {
2097
2098
  return el;
2098
2099
  };
2099
2100
 
2100
- // src/js/modules/data/country-data.ts
2101
- function processAllCountries(options) {
2102
- const { onlyCountries, excludeCountries } = options;
2103
- if (onlyCountries.length) {
2104
- const lowerCaseOnlyCountries = onlyCountries.map((country) => country.toLowerCase());
2105
- return data_default.filter((country) => lowerCaseOnlyCountries.includes(country.iso2));
2106
- } else if (excludeCountries.length) {
2107
- const lowerCaseExcludeCountries = excludeCountries.map((country) => country.toLowerCase());
2108
- return data_default.filter((country) => !lowerCaseExcludeCountries.includes(country.iso2));
2109
- }
2110
- return data_default;
2111
- }
2112
- function translateCountryNames(countries, options) {
2113
- for (const c of countries) {
2114
- const iso2 = c.iso2.toLowerCase();
2115
- if (options.i18n[iso2]) {
2116
- c.name = options.i18n[iso2];
2117
- }
2118
- }
2119
- }
2120
- function processDialCodes(countries, options) {
2121
- const dialCodes = /* @__PURE__ */ new Set();
2122
- let dialCodeMaxLen = 0;
2123
- const dialCodeToIso2Map = {};
2124
- const _addToDialCodeMap = (iso2, dialCode, priority) => {
2125
- if (!iso2 || !dialCode) {
2126
- return;
2127
- }
2128
- if (dialCode.length > dialCodeMaxLen) {
2129
- dialCodeMaxLen = dialCode.length;
2130
- }
2131
- if (!dialCodeToIso2Map.hasOwnProperty(dialCode)) {
2132
- dialCodeToIso2Map[dialCode] = [];
2133
- }
2134
- const iso2List = dialCodeToIso2Map[dialCode];
2135
- if (iso2List.includes(iso2)) {
2136
- return;
2137
- }
2138
- const index = priority !== void 0 ? priority : iso2List.length;
2139
- iso2List[index] = iso2;
2140
- };
2141
- for (const c of countries) {
2142
- if (!dialCodes.has(c.dialCode)) {
2143
- dialCodes.add(c.dialCode);
2144
- }
2145
- for (let k = 1; k < c.dialCode.length; k++) {
2146
- const partialDialCode = c.dialCode.substring(0, k);
2147
- _addToDialCodeMap(c.iso2, partialDialCode);
2148
- }
2149
- _addToDialCodeMap(c.iso2, c.dialCode, c.priority);
2150
- }
2151
- if (options.onlyCountries.length || options.excludeCountries.length) {
2152
- dialCodes.forEach((dialCode) => {
2153
- dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
2154
- });
2155
- }
2156
- for (const c of countries) {
2157
- if (c.areaCodes) {
2158
- const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
2159
- for (const areaCode of c.areaCodes) {
2160
- for (let k = 1; k < areaCode.length; k++) {
2161
- const partialAreaCode = areaCode.substring(0, k);
2162
- const partialDialCode = c.dialCode + partialAreaCode;
2163
- _addToDialCodeMap(rootIso2Code, partialDialCode);
2164
- _addToDialCodeMap(c.iso2, partialDialCode);
2165
- }
2166
- _addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2167
- }
2168
- }
2169
- }
2170
- return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
2171
- }
2172
- function sortCountries(countries, options) {
2173
- if (options.countryOrder) {
2174
- options.countryOrder = options.countryOrder.map((iso2) => iso2.toLowerCase());
2175
- }
2176
- countries.sort((a, b) => {
2177
- const { countryOrder } = options;
2178
- if (countryOrder) {
2179
- const aIndex = countryOrder.indexOf(a.iso2);
2180
- const bIndex = countryOrder.indexOf(b.iso2);
2181
- const aIndexExists = aIndex > -1;
2182
- const bIndexExists = bIndex > -1;
2183
- if (aIndexExists || bIndexExists) {
2184
- if (aIndexExists && bIndexExists) {
2185
- return aIndex - bIndex;
2186
- }
2187
- return aIndexExists ? -1 : 1;
2188
- }
2189
- }
2190
- return a.name.localeCompare(b.name);
2191
- });
2192
- }
2193
- function cacheSearchTokens(countries) {
2194
- for (const c of countries) {
2195
- c.normalisedName = normaliseString(c.name);
2196
- c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2197
- c.dialCodePlus = `+${c.dialCode}`;
2198
- }
2199
- }
2200
-
2201
- // src/js/modules/format/formatting.ts
2202
- function beforeSetNumber(fullNumber, dialCode, separateDialCode, selectedCountryData) {
2203
- let number = fullNumber;
2204
- if (separateDialCode) {
2205
- if (dialCode) {
2206
- dialCode = `+${selectedCountryData.dialCode}`;
2207
- const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2208
- number = number.substring(start);
2209
- }
2210
- }
2211
- return number;
2212
- }
2213
- function formatNumberAsYouType(fullNumber, telInputValue, utils2, selectedCountryData, separateDialCode) {
2214
- const result = utils2 ? utils2.formatNumberAsYouType(fullNumber, selectedCountryData.iso2) : fullNumber;
2215
- const { dialCode } = selectedCountryData;
2216
- if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2217
- const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2218
- return afterDialCode.trim();
2219
- }
2220
- return result;
2221
- }
2222
-
2223
- // src/js/modules/format/caret.ts
2224
- function translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {
2225
- if (prevCaretPos === 0 && !isDeleteForwards) {
2226
- return 0;
2227
- }
2228
- let relevantCharCount = 0;
2229
- for (let i = 0; i < formattedValue.length; i++) {
2230
- if (/[+0-9]/.test(formattedValue[i])) {
2231
- relevantCharCount++;
2232
- }
2233
- if (relevantCharCount === relevantChars && !isDeleteForwards) {
2234
- return i + 1;
2235
- }
2236
- if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
2237
- return i;
2238
- }
2239
- }
2240
- return formattedValue.length;
2241
- }
2242
-
2243
- // src/js/modules/data/nanp-regionless.ts
2244
- var regionlessNanpNumbers = [
2245
- "800",
2246
- "822",
2247
- "833",
2248
- "844",
2249
- "855",
2250
- "866",
2251
- "877",
2252
- "880",
2253
- "881",
2254
- "882",
2255
- "883",
2256
- "884",
2257
- "885",
2258
- "886",
2259
- "887",
2260
- "888",
2261
- "889"
2262
- ];
2263
- var isRegionlessNanp = (number) => {
2264
- const numeric = getNumeric(number);
2265
- if (numeric.charAt(0) === "1") {
2266
- const areaCode = numeric.substring(1, 4);
2267
- return regionlessNanpNumbers.includes(areaCode);
2268
- }
2269
- return false;
2270
- };
2271
-
2272
- // src/js/intl-tel-input.ts
2273
- for (const c of data_default) {
2274
- c.name = en_default[c.iso2];
2275
- }
2276
- var id = 0;
2277
- var iso2Set = new Set(data_default.map((c) => c.iso2));
2278
- var isIso2 = (val) => iso2Set.has(val);
2279
- var forEachInstance = (method, ...args) => {
2280
- const { instances } = intlTelInput;
2281
- Object.values(instances).forEach((instance) => instance[method](...args));
2282
- };
2283
- var Iti = class _Iti {
2284
- /**
2285
- * Build a space-delimited class string from an object map of className -> truthy/falsey.
2286
- * Only keys with truthy values are included.
2287
- */
2288
- static _buildClassNames(flags) {
2289
- return Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
2290
- }
2291
- constructor(input, customOptions = {}) {
2292
- this.id = id++;
2293
- this.telInput = input;
2101
+ // src/js/modules/core/ui.ts
2102
+ var UI = class {
2103
+ constructor(input, options, id2) {
2294
2104
  this.highlightedItem = null;
2295
- this.options = Object.assign({}, defaults, customOptions);
2105
+ input.dataset.intlTelInputId = id2.toString();
2106
+ this.telInput = input;
2107
+ this.options = options;
2108
+ this.id = id2;
2296
2109
  this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
2297
- }
2298
- _detectEnvironmentAndLayout() {
2299
- this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
2300
2110
  this.isRTL = !!this.telInput.closest("[dir=rtl]");
2301
- this.telInput.dir = "ltr";
2302
- const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode;
2303
- this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide;
2304
2111
  if (this.options.separateDialCode) {
2305
- if (this.isRTL) {
2306
- this.originalPaddingRight = this.telInput.style.paddingRight;
2307
- } else {
2308
- this.originalPaddingLeft = this.telInput.style.paddingLeft;
2309
- }
2112
+ this.originalPaddingLeft = this.telInput.style.paddingLeft;
2310
2113
  }
2311
2114
  }
2312
- _createInitPromises() {
2313
- const autoCountryPromise = new Promise((resolve, reject) => {
2314
- this.resolveAutoCountryPromise = resolve;
2315
- this.rejectAutoCountryPromise = reject;
2316
- });
2317
- const utilsScriptPromise = new Promise((resolve, reject) => {
2318
- this.resolveUtilsScriptPromise = resolve;
2319
- this.rejectUtilsScriptPromise = reject;
2320
- });
2321
- this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]);
2322
- }
2323
- //* Can't be private as it's called from intlTelInput convenience wrapper.
2324
- _init() {
2325
- applyOptionSideEffects(this.options);
2326
- this._detectEnvironmentAndLayout();
2327
- this._createInitPromises();
2328
- this.selectedCountryData = {};
2329
- this._processCountryData();
2330
- this._generateMarkup();
2331
- this._setInitialState();
2332
- this._initListeners();
2333
- this._initRequests();
2334
- }
2335
- //********************
2336
- //* PRIVATE METHODS
2337
- //********************
2338
- //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2339
- _processCountryData() {
2340
- this.countries = processAllCountries(this.options);
2341
- const dialRes = processDialCodes(this.countries, this.options);
2342
- this.dialCodes = dialRes.dialCodes;
2343
- this.dialCodeMaxLen = dialRes.dialCodeMaxLen;
2344
- this.dialCodeToIso2Map = dialRes.dialCodeToIso2Map;
2345
- translateCountryNames(this.countries, this.options);
2346
- sortCountries(this.countries, this.options);
2347
- this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
2348
- cacheSearchTokens(this.countries);
2349
- }
2350
2115
  //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
2351
- _generateMarkup() {
2116
+ generateMarkup(countries) {
2117
+ this.countries = countries;
2352
2118
  this._prepareTelInput();
2353
2119
  const wrapper = this._createWrapperAndInsert();
2354
2120
  this._maybeBuildCountryContainer(wrapper);
@@ -2358,7 +2124,7 @@ var Iti = class _Iti {
2358
2124
  }
2359
2125
  _prepareTelInput() {
2360
2126
  this.telInput.classList.add("iti__tel-input");
2361
- if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
2127
+ if (!this.telInput.hasAttribute("autocomplete") && !this.telInput.form?.hasAttribute("autocomplete")) {
2362
2128
  this.telInput.setAttribute("autocomplete", "off");
2363
2129
  }
2364
2130
  }
@@ -2369,23 +2135,22 @@ var Iti = class _Iti {
2369
2135
  containerClass,
2370
2136
  useFullscreenPopup
2371
2137
  } = this.options;
2372
- const parentClasses = _Iti._buildClassNames({
2373
- "iti": true,
2138
+ const parentClasses = buildClassNames({
2139
+ iti: true,
2374
2140
  "iti--allow-dropdown": allowDropdown,
2375
2141
  "iti--show-flags": showFlags,
2376
2142
  "iti--inline-dropdown": !useFullscreenPopup,
2377
2143
  [containerClass]: Boolean(containerClass)
2378
2144
  });
2379
2145
  const wrapper = createEl("div", { class: parentClasses });
2380
- this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
2146
+ if (this.isRTL) {
2147
+ wrapper.setAttribute("dir", "ltr");
2148
+ }
2149
+ this.telInput.before(wrapper);
2381
2150
  return wrapper;
2382
2151
  }
2383
2152
  _maybeBuildCountryContainer(wrapper) {
2384
- const {
2385
- allowDropdown,
2386
- separateDialCode,
2387
- showFlags
2388
- } = this.options;
2153
+ const { allowDropdown, separateDialCode, showFlags } = this.options;
2389
2154
  if (allowDropdown || showFlags || separateDialCode) {
2390
2155
  this.countryContainer = createEl(
2391
2156
  "div",
@@ -2393,11 +2158,6 @@ var Iti = class _Iti {
2393
2158
  { class: "iti__country-container iti__v-hide" },
2394
2159
  wrapper
2395
2160
  );
2396
- if (this.showSelectedCountryOnLeft) {
2397
- this.countryContainer.style.left = "0px";
2398
- } else {
2399
- this.countryContainer.style.right = "0px";
2400
- }
2401
2161
  if (allowDropdown) {
2402
2162
  this.selectedCountry = createEl(
2403
2163
  "button",
@@ -2441,7 +2201,7 @@ var Iti = class _Iti {
2441
2201
  if (separateDialCode) {
2442
2202
  this.selectedDialCode = createEl(
2443
2203
  "div",
2444
- { class: "iti__selected-dial-code", dir: "ltr" },
2204
+ { class: "iti__selected-dial-code" },
2445
2205
  this.selectedCountry
2446
2206
  );
2447
2207
  }
@@ -2466,6 +2226,9 @@ var Iti = class _Iti {
2466
2226
  role: "dialog",
2467
2227
  "aria-modal": "true"
2468
2228
  });
2229
+ if (this.isRTL) {
2230
+ this.dropdownContent.setAttribute("dir", "rtl");
2231
+ }
2469
2232
  if (countrySearch) {
2470
2233
  this._buildSearchUI();
2471
2234
  }
@@ -2480,12 +2243,12 @@ var Iti = class _Iti {
2480
2243
  this.dropdownContent
2481
2244
  );
2482
2245
  this._appendListItems();
2483
- if (countrySearch) {
2484
- this._updateSearchResultsA11yText();
2246
+ if (this.options.countrySearch) {
2247
+ this.updateSearchResultsA11yText();
2485
2248
  }
2486
2249
  if (dropdownContainer) {
2487
- const dropdownClasses = _Iti._buildClassNames({
2488
- "iti": true,
2250
+ const dropdownClasses = buildClassNames({
2251
+ iti: true,
2489
2252
  "iti--container": true,
2490
2253
  "iti--fullscreen-popup": useFullscreenPopup,
2491
2254
  "iti--inline-dropdown": !useFullscreenPopup,
@@ -2531,7 +2294,7 @@ var Iti = class _Iti {
2531
2294
  "aria-label": i18n.searchPlaceholder,
2532
2295
  "aria-controls": `iti-${this.id}__country-listbox`,
2533
2296
  "aria-autocomplete": "list",
2534
- "autocomplete": "off"
2297
+ autocomplete: "off"
2535
2298
  },
2536
2299
  searchWrapper
2537
2300
  );
@@ -2568,80 +2331,478 @@ var Iti = class _Iti {
2568
2331
  },
2569
2332
  this.dropdownContent
2570
2333
  );
2571
- this.searchNoResults.textContent = i18n.zeroSearchResults;
2334
+ this.searchNoResults.textContent = i18n.zeroSearchResults;
2335
+ }
2336
+ _maybeUpdateInputPaddingAndReveal() {
2337
+ if (this.countryContainer) {
2338
+ this.updateInputPadding();
2339
+ this.countryContainer.classList.remove("iti__v-hide");
2340
+ }
2341
+ }
2342
+ _maybeBuildHiddenInputs(wrapper) {
2343
+ const { hiddenInput } = this.options;
2344
+ if (hiddenInput) {
2345
+ const telInputName = this.telInput.getAttribute("name") || "";
2346
+ const names = hiddenInput(telInputName);
2347
+ if (names.phone) {
2348
+ const existingInput = this.telInput.form?.querySelector(
2349
+ `input[name="${names.phone}"]`
2350
+ );
2351
+ if (existingInput) {
2352
+ this.hiddenInput = existingInput;
2353
+ } else {
2354
+ this.hiddenInput = createEl("input", {
2355
+ type: "hidden",
2356
+ name: names.phone
2357
+ });
2358
+ wrapper.appendChild(this.hiddenInput);
2359
+ }
2360
+ }
2361
+ if (names.country) {
2362
+ const existingInput = this.telInput.form?.querySelector(
2363
+ `input[name="${names.country}"]`
2364
+ );
2365
+ if (existingInput) {
2366
+ this.hiddenInputCountry = existingInput;
2367
+ } else {
2368
+ this.hiddenInputCountry = createEl("input", {
2369
+ type: "hidden",
2370
+ name: names.country
2371
+ });
2372
+ wrapper.appendChild(this.hiddenInputCountry);
2373
+ }
2374
+ }
2375
+ }
2376
+ }
2377
+ //* For each country: add a country list item <li> to the countryList <ul> container.
2378
+ _appendListItems() {
2379
+ const frag = document.createDocumentFragment();
2380
+ for (let i = 0; i < this.countries.length; i++) {
2381
+ const c = this.countries[i];
2382
+ const liClass = buildClassNames({
2383
+ iti__country: true,
2384
+ iti__highlight: i === 0
2385
+ });
2386
+ const listItem = createEl("li", {
2387
+ id: `iti-${this.id}__item-${c.iso2}`,
2388
+ class: liClass,
2389
+ tabindex: "-1",
2390
+ role: "option",
2391
+ "aria-selected": "false"
2392
+ });
2393
+ listItem.dataset.dialCode = c.dialCode;
2394
+ listItem.dataset.countryCode = c.iso2;
2395
+ c.nodeById[this.id] = listItem;
2396
+ if (this.options.showFlags) {
2397
+ createEl("div", { class: `iti__flag iti__${c.iso2}` }, listItem);
2398
+ }
2399
+ const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
2400
+ nameEl.textContent = c.name;
2401
+ const dialEl = createEl("span", { class: "iti__dial-code" }, listItem);
2402
+ if (this.isRTL) {
2403
+ dialEl.setAttribute("dir", "ltr");
2404
+ }
2405
+ dialEl.textContent = `+${c.dialCode}`;
2406
+ frag.appendChild(listItem);
2407
+ }
2408
+ this.countryList.appendChild(frag);
2409
+ }
2410
+ //* Update the input padding to make space for the selected country/dial code.
2411
+ updateInputPadding() {
2412
+ if (this.selectedCountry) {
2413
+ const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
2414
+ const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
2415
+ const inputPadding = selectedCountryWidth + 6;
2416
+ this.telInput.style.paddingLeft = `${inputPadding}px`;
2417
+ }
2418
+ }
2419
+ //* When input is in a hidden container during init, we cannot calculate the selected country width.
2420
+ //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2421
+ //* To get the right styling to apply, all we need is a shallow clone of the container,
2422
+ //* and then to inject a deep clone of the selectedCountry element.
2423
+ _getHiddenSelectedCountryWidth() {
2424
+ if (this.telInput.parentNode) {
2425
+ let body;
2426
+ try {
2427
+ body = window.top.document.body;
2428
+ } catch (e) {
2429
+ body = document.body;
2430
+ }
2431
+ const containerClone = this.telInput.parentNode.cloneNode(
2432
+ false
2433
+ );
2434
+ containerClone.style.visibility = "hidden";
2435
+ body.appendChild(containerClone);
2436
+ const countryContainerClone = this.countryContainer.cloneNode();
2437
+ containerClone.appendChild(countryContainerClone);
2438
+ const selectedCountryClone = this.selectedCountry.cloneNode(
2439
+ true
2440
+ );
2441
+ countryContainerClone.appendChild(selectedCountryClone);
2442
+ const width = selectedCountryClone.offsetWidth;
2443
+ body.removeChild(containerClone);
2444
+ return width;
2445
+ }
2446
+ return 0;
2447
+ }
2448
+ //* Update search results text (for a11y).
2449
+ updateSearchResultsA11yText() {
2450
+ const { i18n } = this.options;
2451
+ const count = this.countryList.childElementCount;
2452
+ let searchText;
2453
+ if (count === 0) {
2454
+ searchText = i18n.zeroSearchResults;
2455
+ } else {
2456
+ if (i18n.searchResultsText) {
2457
+ searchText = i18n.searchResultsText(count);
2458
+ } else if (count === 1) {
2459
+ searchText = i18n.oneSearchResult;
2460
+ } else {
2461
+ searchText = i18n.multipleSearchResults.replace(
2462
+ "${count}",
2463
+ count.toString()
2464
+ );
2465
+ }
2466
+ }
2467
+ this.searchResultsA11yText.textContent = searchText;
2468
+ }
2469
+ //* Check if an element is visible within it's container, else scroll until it is.
2470
+ scrollTo(element) {
2471
+ const container = this.countryList;
2472
+ const scrollTop = document.documentElement.scrollTop;
2473
+ const containerHeight = container.offsetHeight;
2474
+ const containerTop = container.getBoundingClientRect().top + scrollTop;
2475
+ const containerBottom = containerTop + containerHeight;
2476
+ const elementHeight = element.offsetHeight;
2477
+ const elementTop = element.getBoundingClientRect().top + scrollTop;
2478
+ const elementBottom = elementTop + elementHeight;
2479
+ const newScrollTop = elementTop - containerTop + container.scrollTop;
2480
+ if (elementTop < containerTop) {
2481
+ container.scrollTop = newScrollTop;
2482
+ } else if (elementBottom > containerBottom) {
2483
+ const heightDifference = containerHeight - elementHeight;
2484
+ container.scrollTop = newScrollTop - heightDifference;
2485
+ }
2486
+ }
2487
+ //* Remove highlighting from other list items and highlight the given item.
2488
+ highlightListItem(listItem, shouldFocus) {
2489
+ const prevItem = this.highlightedItem;
2490
+ if (prevItem) {
2491
+ prevItem.classList.remove("iti__highlight");
2492
+ prevItem.setAttribute("aria-selected", "false");
2493
+ }
2494
+ this.highlightedItem = listItem;
2495
+ if (this.highlightedItem) {
2496
+ this.highlightedItem.classList.add("iti__highlight");
2497
+ this.highlightedItem.setAttribute("aria-selected", "true");
2498
+ if (this.options.countrySearch) {
2499
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2500
+ this.searchInput.setAttribute(
2501
+ "aria-activedescendant",
2502
+ activeDescendant
2503
+ );
2504
+ }
2505
+ }
2506
+ if (shouldFocus) {
2507
+ this.highlightedItem.focus();
2508
+ }
2509
+ }
2510
+ //* Country search: Filter the country list to the given array of countries.
2511
+ filterCountries(matchedCountries) {
2512
+ this.countryList.innerHTML = "";
2513
+ let noCountriesAddedYet = true;
2514
+ for (const c of matchedCountries) {
2515
+ const listItem = c.nodeById[this.id];
2516
+ if (listItem) {
2517
+ this.countryList.appendChild(listItem);
2518
+ if (noCountriesAddedYet) {
2519
+ this.highlightListItem(listItem, false);
2520
+ noCountriesAddedYet = false;
2521
+ }
2522
+ }
2523
+ }
2524
+ if (noCountriesAddedYet) {
2525
+ this.highlightListItem(null, false);
2526
+ if (this.searchNoResults) {
2527
+ this.searchNoResults.classList.remove("iti__hide");
2528
+ }
2529
+ } else if (this.searchNoResults) {
2530
+ this.searchNoResults.classList.add("iti__hide");
2531
+ }
2532
+ this.countryList.scrollTop = 0;
2533
+ this.updateSearchResultsA11yText();
2534
+ }
2535
+ destroy() {
2536
+ this.telInput.iti = void 0;
2537
+ delete this.telInput.dataset.intlTelInputId;
2538
+ if (this.options.separateDialCode) {
2539
+ this.telInput.style.paddingLeft = this.originalPaddingLeft;
2540
+ }
2541
+ const wrapper = this.telInput.parentNode;
2542
+ wrapper.before(this.telInput);
2543
+ wrapper.remove();
2544
+ this.telInput = null;
2545
+ this.countryContainer = null;
2546
+ this.selectedCountry = null;
2547
+ this.selectedCountryInner = null;
2548
+ this.selectedDialCode = null;
2549
+ this.dropdownArrow = null;
2550
+ this.dropdownContent = null;
2551
+ this.searchInput = null;
2552
+ this.searchIcon = null;
2553
+ this.searchClearButton = null;
2554
+ this.searchNoResults = null;
2555
+ this.searchResultsA11yText = null;
2556
+ this.countryList = null;
2557
+ this.dropdown = null;
2558
+ this.hiddenInput = null;
2559
+ this.hiddenInputCountry = null;
2560
+ this.highlightedItem = null;
2561
+ for (const c of this.countries) {
2562
+ delete c.nodeById[this.id];
2563
+ }
2564
+ this.countries = null;
2565
+ }
2566
+ };
2567
+
2568
+ // src/js/modules/data/country-data.ts
2569
+ function processAllCountries(options) {
2570
+ const { onlyCountries, excludeCountries } = options;
2571
+ if (onlyCountries.length) {
2572
+ const lowerCaseOnlyCountries = onlyCountries.map((country) => country.toLowerCase());
2573
+ return data_default.filter((country) => lowerCaseOnlyCountries.includes(country.iso2));
2574
+ } else if (excludeCountries.length) {
2575
+ const lowerCaseExcludeCountries = excludeCountries.map((country) => country.toLowerCase());
2576
+ return data_default.filter((country) => !lowerCaseExcludeCountries.includes(country.iso2));
2577
+ }
2578
+ return data_default;
2579
+ }
2580
+ function translateCountryNames(countries, options) {
2581
+ for (const c of countries) {
2582
+ const iso2 = c.iso2.toLowerCase();
2583
+ if (options.i18n[iso2]) {
2584
+ c.name = options.i18n[iso2];
2585
+ }
2586
+ }
2587
+ }
2588
+ function processDialCodes(countries, options) {
2589
+ const dialCodes = /* @__PURE__ */ new Set();
2590
+ let dialCodeMaxLen = 0;
2591
+ const dialCodeToIso2Map = {};
2592
+ const _addToDialCodeMap = (iso2, dialCode, priority) => {
2593
+ if (!iso2 || !dialCode) {
2594
+ return;
2595
+ }
2596
+ if (dialCode.length > dialCodeMaxLen) {
2597
+ dialCodeMaxLen = dialCode.length;
2598
+ }
2599
+ if (!dialCodeToIso2Map.hasOwnProperty(dialCode)) {
2600
+ dialCodeToIso2Map[dialCode] = [];
2601
+ }
2602
+ const iso2List = dialCodeToIso2Map[dialCode];
2603
+ if (iso2List.includes(iso2)) {
2604
+ return;
2605
+ }
2606
+ const index = priority !== void 0 ? priority : iso2List.length;
2607
+ iso2List[index] = iso2;
2608
+ };
2609
+ for (const c of countries) {
2610
+ if (!dialCodes.has(c.dialCode)) {
2611
+ dialCodes.add(c.dialCode);
2612
+ }
2613
+ for (let k = 1; k < c.dialCode.length; k++) {
2614
+ const partialDialCode = c.dialCode.substring(0, k);
2615
+ _addToDialCodeMap(c.iso2, partialDialCode);
2616
+ }
2617
+ _addToDialCodeMap(c.iso2, c.dialCode, c.priority);
2618
+ }
2619
+ if (options.onlyCountries.length || options.excludeCountries.length) {
2620
+ dialCodes.forEach((dialCode) => {
2621
+ dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
2622
+ });
2623
+ }
2624
+ for (const c of countries) {
2625
+ if (c.areaCodes) {
2626
+ const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
2627
+ for (const areaCode of c.areaCodes) {
2628
+ for (let k = 1; k < areaCode.length; k++) {
2629
+ const partialAreaCode = areaCode.substring(0, k);
2630
+ const partialDialCode = c.dialCode + partialAreaCode;
2631
+ _addToDialCodeMap(rootIso2Code, partialDialCode);
2632
+ _addToDialCodeMap(c.iso2, partialDialCode);
2633
+ }
2634
+ _addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2635
+ }
2636
+ }
2637
+ }
2638
+ return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
2639
+ }
2640
+ function sortCountries(countries, options) {
2641
+ if (options.countryOrder) {
2642
+ options.countryOrder = options.countryOrder.map((iso2) => iso2.toLowerCase());
2643
+ }
2644
+ countries.sort((a, b) => {
2645
+ const { countryOrder } = options;
2646
+ if (countryOrder) {
2647
+ const aIndex = countryOrder.indexOf(a.iso2);
2648
+ const bIndex = countryOrder.indexOf(b.iso2);
2649
+ const aIndexExists = aIndex > -1;
2650
+ const bIndexExists = bIndex > -1;
2651
+ if (aIndexExists || bIndexExists) {
2652
+ if (aIndexExists && bIndexExists) {
2653
+ return aIndex - bIndex;
2654
+ }
2655
+ return aIndexExists ? -1 : 1;
2656
+ }
2657
+ }
2658
+ return a.name.localeCompare(b.name);
2659
+ });
2660
+ }
2661
+ function cacheSearchTokens(countries) {
2662
+ for (const c of countries) {
2663
+ c.normalisedName = normaliseString(c.name);
2664
+ c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2665
+ c.dialCodePlus = `+${c.dialCode}`;
2666
+ }
2667
+ }
2668
+
2669
+ // src/js/modules/format/formatting.ts
2670
+ function beforeSetNumber(fullNumber, dialCode, separateDialCode, selectedCountryData) {
2671
+ let number = fullNumber;
2672
+ if (separateDialCode) {
2673
+ if (dialCode) {
2674
+ dialCode = `+${selectedCountryData.dialCode}`;
2675
+ const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2676
+ number = number.substring(start);
2677
+ }
2678
+ }
2679
+ return number;
2680
+ }
2681
+ function formatNumberAsYouType(fullNumber, telInputValue, utils2, selectedCountryData, separateDialCode) {
2682
+ const result = utils2 ? utils2.formatNumberAsYouType(fullNumber, selectedCountryData.iso2) : fullNumber;
2683
+ const { dialCode } = selectedCountryData;
2684
+ if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2685
+ const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2686
+ return afterDialCode.trim();
2687
+ }
2688
+ return result;
2689
+ }
2690
+
2691
+ // src/js/modules/format/caret.ts
2692
+ function translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {
2693
+ if (prevCaretPos === 0 && !isDeleteForwards) {
2694
+ return 0;
2695
+ }
2696
+ let relevantCharCount = 0;
2697
+ for (let i = 0; i < formattedValue.length; i++) {
2698
+ if (/[+0-9]/.test(formattedValue[i])) {
2699
+ relevantCharCount++;
2700
+ }
2701
+ if (relevantCharCount === relevantChars && !isDeleteForwards) {
2702
+ return i + 1;
2703
+ }
2704
+ if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
2705
+ return i;
2706
+ }
2707
+ }
2708
+ return formattedValue.length;
2709
+ }
2710
+
2711
+ // src/js/modules/data/nanp-regionless.ts
2712
+ var regionlessNanpNumbers = [
2713
+ "800",
2714
+ "822",
2715
+ "833",
2716
+ "844",
2717
+ "855",
2718
+ "866",
2719
+ "877",
2720
+ "880",
2721
+ "881",
2722
+ "882",
2723
+ "883",
2724
+ "884",
2725
+ "885",
2726
+ "886",
2727
+ "887",
2728
+ "888",
2729
+ "889"
2730
+ ];
2731
+ var isRegionlessNanp = (number) => {
2732
+ const numeric = getNumeric(number);
2733
+ if (numeric.charAt(0) === "1") {
2734
+ const areaCode = numeric.substring(1, 4);
2735
+ return regionlessNanpNumbers.includes(areaCode);
2736
+ }
2737
+ return false;
2738
+ };
2739
+
2740
+ // src/js/intl-tel-input.ts
2741
+ for (const c of data_default) {
2742
+ c.name = countries_default[c.iso2];
2743
+ }
2744
+ var id = 0;
2745
+ var iso2Set = new Set(data_default.map((c) => c.iso2));
2746
+ var isIso2 = (val) => iso2Set.has(val);
2747
+ var Iti = class _Iti {
2748
+ constructor(input, customOptions = {}) {
2749
+ this.id = id++;
2750
+ this.options = { ...defaults, ...customOptions };
2751
+ applyOptionSideEffects(this.options);
2752
+ this.ui = new UI(input, this.options, this.id);
2753
+ this.isAndroid = _Iti._getIsAndroid();
2754
+ this.promise = this._createInitPromises();
2755
+ this.countries = processAllCountries(this.options);
2756
+ const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(
2757
+ this.countries,
2758
+ this.options
2759
+ );
2760
+ this.dialCodes = dialCodes;
2761
+ this.dialCodeMaxLen = dialCodeMaxLen;
2762
+ this.dialCodeToIso2Map = dialCodeToIso2Map;
2763
+ this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
2764
+ this._init();
2572
2765
  }
2573
- _maybeUpdateInputPaddingAndReveal() {
2574
- if (this.countryContainer) {
2575
- this._updateInputPadding();
2576
- this.countryContainer.classList.remove("iti__v-hide");
2577
- }
2766
+ static _getIsAndroid() {
2767
+ return typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
2578
2768
  }
2579
- _maybeBuildHiddenInputs(wrapper) {
2580
- const { hiddenInput } = this.options;
2581
- if (hiddenInput) {
2582
- const telInputName = this.telInput.getAttribute("name") || "";
2583
- const names = hiddenInput(telInputName);
2584
- if (names.phone) {
2585
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
2586
- if (existingInput) {
2587
- this.hiddenInput = existingInput;
2588
- } else {
2589
- this.hiddenInput = createEl("input", {
2590
- type: "hidden",
2591
- name: names.phone
2592
- });
2593
- wrapper.appendChild(this.hiddenInput);
2594
- }
2595
- }
2596
- if (names.country) {
2597
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
2598
- if (existingInput) {
2599
- this.hiddenInputCountry = existingInput;
2600
- } else {
2601
- this.hiddenInputCountry = createEl("input", {
2602
- type: "hidden",
2603
- name: names.country
2604
- });
2605
- wrapper.appendChild(this.hiddenInputCountry);
2606
- }
2607
- }
2608
- }
2769
+ _createInitPromises() {
2770
+ const autoCountryPromise = new Promise((resolve, reject) => {
2771
+ this.resolveAutoCountryPromise = resolve;
2772
+ this.rejectAutoCountryPromise = reject;
2773
+ });
2774
+ const utilsScriptPromise = new Promise((resolve, reject) => {
2775
+ this.resolveUtilsScriptPromise = resolve;
2776
+ this.rejectUtilsScriptPromise = reject;
2777
+ });
2778
+ return Promise.all([autoCountryPromise, utilsScriptPromise]);
2609
2779
  }
2610
- //* For each country: add a country list item <li> to the countryList <ul> container.
2611
- _appendListItems() {
2612
- for (let i = 0; i < this.countries.length; i++) {
2613
- const c = this.countries[i];
2614
- const extraClass = i === 0 ? "iti__highlight" : "";
2615
- const listItem = createEl(
2616
- "li",
2617
- {
2618
- id: `iti-${this.id}__item-${c.iso2}`,
2619
- class: `iti__country ${extraClass}`,
2620
- tabindex: "-1",
2621
- role: "option",
2622
- "data-dial-code": c.dialCode,
2623
- "data-country-code": c.iso2,
2624
- "aria-selected": "false"
2625
- },
2626
- this.countryList
2627
- );
2628
- c.nodeById[this.id] = listItem;
2629
- let content = "";
2630
- if (this.options.showFlags) {
2631
- content += `<div class='iti__flag iti__${c.iso2}'></div>`;
2632
- }
2633
- content += `<span class='iti__country-name'>${c.name}</span>`;
2634
- content += `<span class='iti__dial-code' dir='ltr'>+${c.dialCode}</span>`;
2635
- listItem.insertAdjacentHTML("beforeend", content);
2636
- }
2780
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
2781
+ _init() {
2782
+ this.selectedCountryData = {};
2783
+ this.abortController = new AbortController();
2784
+ this._processCountryData();
2785
+ this.ui.generateMarkup(this.countries);
2786
+ this._setInitialState();
2787
+ this._initListeners();
2788
+ this._initRequests();
2789
+ }
2790
+ //********************
2791
+ //* PRIVATE METHODS
2792
+ //********************
2793
+ //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2794
+ _processCountryData() {
2795
+ translateCountryNames(this.countries, this.options);
2796
+ sortCountries(this.countries, this.options);
2797
+ cacheSearchTokens(this.countries);
2637
2798
  }
2638
2799
  //* Set the initial state of the input value and the selected country by:
2639
2800
  //* 1. Extracting a dial code from the given number
2640
2801
  //* 2. Using explicit initialCountry
2641
2802
  _setInitialState(overrideAutoCountry = false) {
2642
- const attributeValue = this.telInput.getAttribute("value");
2643
- const inputValue = this.telInput.value;
2644
- const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
2803
+ const attributeValue = this.ui.telInput.getAttribute("value");
2804
+ const inputValue = this.ui.telInput.value;
2805
+ const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
2645
2806
  const val = useAttribute ? attributeValue : inputValue;
2646
2807
  const dialCode = this._getDialCode(val);
2647
2808
  const isRegionlessNanpNumber = isRegionlessNanp(val);
@@ -2671,47 +2832,49 @@ var Iti = class _Iti {
2671
2832
  if (this.options.allowDropdown) {
2672
2833
  this._initDropdownListeners();
2673
2834
  }
2674
- if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
2835
+ if ((this.ui.hiddenInput || this.ui.hiddenInputCountry) && this.ui.telInput.form) {
2675
2836
  this._initHiddenInputListener();
2676
2837
  }
2677
2838
  }
2678
2839
  //* Update hidden input on form submit.
2679
2840
  _initHiddenInputListener() {
2680
- this._handleHiddenInputSubmit = () => {
2681
- if (this.hiddenInput) {
2682
- this.hiddenInput.value = this.getNumber();
2841
+ const handleHiddenInputSubmit = () => {
2842
+ if (this.ui.hiddenInput) {
2843
+ this.ui.hiddenInput.value = this.getNumber();
2683
2844
  }
2684
- if (this.hiddenInputCountry) {
2685
- this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "";
2845
+ if (this.ui.hiddenInputCountry) {
2846
+ this.ui.hiddenInputCountry.value = this.selectedCountryData.iso2 || "";
2686
2847
  }
2687
2848
  };
2688
- this.telInput.form?.addEventListener(
2689
- "submit",
2690
- this._handleHiddenInputSubmit
2691
- );
2849
+ this.ui.telInput.form?.addEventListener("submit", handleHiddenInputSubmit, {
2850
+ signal: this.abortController.signal
2851
+ });
2692
2852
  }
2693
2853
  //* initialise the dropdown listeners.
2694
2854
  _initDropdownListeners() {
2695
- this._handleLabelClick = (e) => {
2696
- if (this.dropdownContent.classList.contains("iti__hide")) {
2697
- this.telInput.focus();
2855
+ const signal = this.abortController.signal;
2856
+ const handleLabelClick = (e) => {
2857
+ if (this.ui.dropdownContent.classList.contains("iti__hide")) {
2858
+ this.ui.telInput.focus();
2698
2859
  } else {
2699
2860
  e.preventDefault();
2700
2861
  }
2701
2862
  };
2702
- const label = this.telInput.closest("label");
2863
+ const label = this.ui.telInput.closest("label");
2703
2864
  if (label) {
2704
- label.addEventListener("click", this._handleLabelClick);
2865
+ label.addEventListener("click", handleLabelClick, { signal });
2705
2866
  }
2706
- this._handleClickSelectedCountry = () => {
2707
- const dropdownClosed = this.dropdownContent.classList.contains("iti__hide");
2708
- if (dropdownClosed && !this.telInput.disabled && !this.telInput.readOnly) {
2867
+ const handleClickSelectedCountry = () => {
2868
+ const dropdownClosed = this.ui.dropdownContent.classList.contains("iti__hide");
2869
+ if (dropdownClosed && !this.ui.telInput.disabled && !this.ui.telInput.readOnly) {
2709
2870
  this._openDropdown();
2710
2871
  }
2711
2872
  };
2712
- this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry);
2713
- this._handleCountryContainerKeydown = (e) => {
2714
- const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide");
2873
+ this.ui.selectedCountry.addEventListener("click", handleClickSelectedCountry, {
2874
+ signal
2875
+ });
2876
+ const handleCountryContainerKeydown = (e) => {
2877
+ const isDropdownHidden = this.ui.dropdownContent.classList.contains("iti__hide");
2715
2878
  if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
2716
2879
  e.preventDefault();
2717
2880
  e.stopPropagation();
@@ -2721,26 +2884,29 @@ var Iti = class _Iti {
2721
2884
  this._closeDropdown();
2722
2885
  }
2723
2886
  };
2724
- this.countryContainer.addEventListener(
2887
+ this.ui.countryContainer.addEventListener(
2725
2888
  "keydown",
2726
- this._handleCountryContainerKeydown
2889
+ handleCountryContainerKeydown,
2890
+ { signal }
2727
2891
  );
2728
2892
  }
2729
2893
  //* Init many requests: utils script / geo ip lookup.
2730
2894
  _initRequests() {
2731
- let { loadUtils, initialCountry, geoIpLookup } = this.options;
2895
+ const { loadUtils, initialCountry, geoIpLookup } = this.options;
2732
2896
  if (loadUtils && !intlTelInput.utils) {
2733
- this._doAttachUtils = () => {
2897
+ const doAttachUtils = () => {
2734
2898
  intlTelInput.attachUtils(loadUtils)?.catch(() => {
2735
2899
  });
2736
2900
  };
2737
2901
  if (intlTelInput.documentReady()) {
2738
- this._doAttachUtils();
2902
+ doAttachUtils();
2739
2903
  } else {
2740
- this._handlePageLoad = () => {
2741
- this._doAttachUtils();
2904
+ const handlePageLoad = () => {
2905
+ doAttachUtils();
2742
2906
  };
2743
- window.addEventListener("load", this._handlePageLoad);
2907
+ window.addEventListener("load", handlePageLoad, {
2908
+ signal: this.abortController.signal
2909
+ });
2744
2910
  }
2745
2911
  } else {
2746
2912
  this.resolveUtilsScriptPromise();
@@ -2780,8 +2946,8 @@ var Iti = class _Iti {
2780
2946
  }
2781
2947
  _openDropdownWithPlus() {
2782
2948
  this._openDropdown();
2783
- this.searchInput.value = "+";
2784
- this._filterCountries("");
2949
+ this.ui.searchInput.value = "+";
2950
+ this._filterCountriesByQuery("");
2785
2951
  }
2786
2952
  //* Initialize the tel input listeners.
2787
2953
  _initTelInputListeners() {
@@ -2790,55 +2956,77 @@ var Iti = class _Iti {
2790
2956
  this._maybeBindPasteListener();
2791
2957
  }
2792
2958
  _bindInputListener() {
2793
- const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = this.options;
2959
+ const {
2960
+ strictMode,
2961
+ formatAsYouType,
2962
+ separateDialCode,
2963
+ allowDropdown,
2964
+ countrySearch
2965
+ } = this.options;
2794
2966
  let userOverrideFormatting = false;
2795
- if (/\p{L}/u.test(this.telInput.value)) {
2967
+ if (/\p{L}/u.test(this.ui.telInput.value)) {
2796
2968
  userOverrideFormatting = true;
2797
2969
  }
2798
- this._handleInputEvent = (e) => {
2970
+ const handleInputEvent = (e) => {
2799
2971
  if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
2800
- const currentCaretPos = this.telInput.selectionStart || 0;
2801
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
2802
- const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
2803
- this.telInput.value = valueBeforeCaret + valueAfterCaret;
2972
+ const currentCaretPos = this.ui.telInput.selectionStart || 0;
2973
+ const valueBeforeCaret = this.ui.telInput.value.substring(
2974
+ 0,
2975
+ currentCaretPos - 1
2976
+ );
2977
+ const valueAfterCaret = this.ui.telInput.value.substring(currentCaretPos);
2978
+ this.ui.telInput.value = valueBeforeCaret + valueAfterCaret;
2804
2979
  this._openDropdownWithPlus();
2805
2980
  return;
2806
2981
  }
2807
- if (this._updateCountryFromNumber(this.telInput.value)) {
2982
+ if (this._updateCountryFromNumber(this.ui.telInput.value)) {
2808
2983
  this._triggerCountryChange();
2809
2984
  }
2810
2985
  const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2811
- const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2986
+ const isPaste = e?.inputType === "insertFromPaste" && this.ui.telInput.value;
2812
2987
  if (isFormattingChar || isPaste && !strictMode) {
2813
2988
  userOverrideFormatting = true;
2814
- } else if (!/[^+0-9]/.test(this.telInput.value)) {
2989
+ } else if (!/[^+0-9]/.test(this.ui.telInput.value)) {
2815
2990
  userOverrideFormatting = false;
2816
2991
  }
2817
2992
  const isSetNumber = e?.detail && e.detail["isSetNumber"];
2818
2993
  if (formatAsYouType && !userOverrideFormatting && !isSetNumber) {
2819
- const currentCaretPos = this.telInput.selectionStart || 0;
2820
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2821
- const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2994
+ const currentCaretPos = this.ui.telInput.selectionStart || 0;
2995
+ const valueBeforeCaret = this.ui.telInput.value.substring(
2996
+ 0,
2997
+ currentCaretPos
2998
+ );
2999
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(
3000
+ /[^+0-9]/g,
3001
+ ""
3002
+ ).length;
2822
3003
  const isDeleteForwards = e?.inputType === "deleteContentForward";
2823
3004
  const fullNumber = this._getFullNumber();
2824
3005
  const formattedValue = formatNumberAsYouType(
2825
3006
  fullNumber,
2826
- this.telInput.value,
3007
+ this.ui.telInput.value,
2827
3008
  intlTelInput.utils,
2828
3009
  this.selectedCountryData,
2829
3010
  this.options.separateDialCode
2830
3011
  );
2831
- const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2832
- this.telInput.value = formattedValue;
2833
- this.telInput.setSelectionRange(newCaretPos, newCaretPos);
3012
+ const newCaretPos = translateCursorPosition(
3013
+ relevantCharsBeforeCaret,
3014
+ formattedValue,
3015
+ currentCaretPos,
3016
+ isDeleteForwards
3017
+ );
3018
+ this.ui.telInput.value = formattedValue;
3019
+ this.ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
2834
3020
  }
2835
3021
  };
2836
- this.telInput.addEventListener("input", this._handleInputEvent);
3022
+ this.ui.telInput.addEventListener("input", handleInputEvent, {
3023
+ signal: this.abortController.signal
3024
+ });
2837
3025
  }
2838
3026
  _maybeBindKeydownListener() {
2839
3027
  const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.options;
2840
3028
  if (strictMode || separateDialCode) {
2841
- this._handleKeydownEvent = (e) => {
3029
+ const handleKeydownEvent = (e) => {
2842
3030
  if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
2843
3031
  if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
2844
3032
  e.preventDefault();
@@ -2846,14 +3034,17 @@ var Iti = class _Iti {
2846
3034
  return;
2847
3035
  }
2848
3036
  if (strictMode) {
2849
- const value = this.telInput.value;
2850
- const alreadyHasPlus = value.charAt(0) === "+";
2851
- const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
3037
+ const value = this.ui.telInput.value;
3038
+ const alreadyHasPlus = value.startsWith("+");
3039
+ const isInitialPlus = !alreadyHasPlus && this.ui.telInput.selectionStart === 0 && e.key === "+";
2852
3040
  const isNumeric = /^[0-9]$/.test(e.key);
2853
3041
  const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
2854
- const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
3042
+ const newValue = value.slice(0, this.ui.telInput.selectionStart) + e.key + value.slice(this.ui.telInput.selectionEnd);
2855
3043
  const newFullNumber = this._getFullNumber(newValue);
2856
- const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
3044
+ const coreNumber = intlTelInput.utils.getCoreNumber(
3045
+ newFullNumber,
3046
+ this.selectedCountryData.iso2
3047
+ );
2857
3048
  const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
2858
3049
  const newCountry = this._getNewCountryFromNumber(newFullNumber);
2859
3050
  const isChangingDialCode = newCountry !== null;
@@ -2863,14 +3054,16 @@ var Iti = class _Iti {
2863
3054
  }
2864
3055
  }
2865
3056
  };
2866
- this.telInput.addEventListener("keydown", this._handleKeydownEvent);
3057
+ this.ui.telInput.addEventListener("keydown", handleKeydownEvent, {
3058
+ signal: this.abortController.signal
3059
+ });
2867
3060
  }
2868
3061
  }
2869
3062
  _maybeBindPasteListener() {
2870
3063
  if (this.options.strictMode) {
2871
- this._handlePasteEvent = (e) => {
3064
+ const handlePasteEvent = (e) => {
2872
3065
  e.preventDefault();
2873
- const input = this.telInput;
3066
+ const input = this.ui.telInput;
2874
3067
  const selStart = input.selectionStart;
2875
3068
  const selEnd = input.selectionEnd;
2876
3069
  const before = input.value.slice(0, selStart);
@@ -2905,82 +3098,95 @@ var Iti = class _Iti {
2905
3098
  input.setSelectionRange(caretPos, caretPos);
2906
3099
  input.dispatchEvent(new InputEvent("input", { bubbles: true }));
2907
3100
  };
2908
- this.telInput.addEventListener("paste", this._handlePasteEvent);
3101
+ this.ui.telInput.addEventListener("paste", handlePasteEvent, {
3102
+ signal: this.abortController.signal
3103
+ });
2909
3104
  }
2910
3105
  }
2911
3106
  //* Adhere to the input's maxlength attr.
2912
3107
  _cap(number) {
2913
- const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
3108
+ const max = Number(this.ui.telInput.getAttribute("maxlength"));
2914
3109
  return max && number.length > max ? number.substring(0, max) : number;
2915
3110
  }
2916
- //* Trigger a custom event on the input.
3111
+ //* Trigger a custom event on the input (typed via ItiEventMap).
2917
3112
  _trigger(name, detailProps = {}) {
2918
3113
  const e = new CustomEvent(name, {
2919
3114
  bubbles: true,
2920
3115
  cancelable: true,
2921
3116
  detail: detailProps
2922
3117
  });
2923
- this.telInput.dispatchEvent(e);
3118
+ this.ui.telInput.dispatchEvent(e);
2924
3119
  }
2925
3120
  //* Open the dropdown.
2926
3121
  _openDropdown() {
2927
3122
  const { fixDropdownWidth, countrySearch } = this.options;
3123
+ this.dropdownAbortController = new AbortController();
2928
3124
  if (fixDropdownWidth) {
2929
- this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
3125
+ this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`;
2930
3126
  }
2931
- this.dropdownContent.classList.remove("iti__hide");
2932
- this.selectedCountry.setAttribute("aria-expanded", "true");
3127
+ this.ui.dropdownContent.classList.remove("iti__hide");
3128
+ this.ui.selectedCountry.setAttribute("aria-expanded", "true");
2933
3129
  this._setDropdownPosition();
2934
3130
  if (countrySearch) {
2935
- const firstCountryItem = this.countryList.firstElementChild;
3131
+ const firstCountryItem = this.ui.countryList.firstElementChild;
2936
3132
  if (firstCountryItem) {
2937
- this._highlightListItem(firstCountryItem, false);
2938
- this.countryList.scrollTop = 0;
3133
+ this.ui.highlightListItem(firstCountryItem, false);
3134
+ this.ui.countryList.scrollTop = 0;
2939
3135
  }
2940
- this.searchInput.focus();
3136
+ this.ui.searchInput.focus();
2941
3137
  }
2942
3138
  this._bindDropdownListeners();
2943
- this.dropdownArrow.classList.add("iti__arrow--up");
3139
+ this.ui.dropdownArrow.classList.add("iti__arrow--up");
2944
3140
  this._trigger("open:countrydropdown");
2945
3141
  }
2946
3142
  //* Set the dropdown position
2947
3143
  _setDropdownPosition() {
2948
3144
  if (this.options.dropdownContainer) {
2949
- this.options.dropdownContainer.appendChild(this.dropdown);
3145
+ this.options.dropdownContainer.appendChild(this.ui.dropdown);
2950
3146
  }
2951
3147
  if (!this.options.useFullscreenPopup) {
2952
- const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
2953
- const inputHeight = this.telInput.offsetHeight;
3148
+ const inputPosRelativeToVP = this.ui.telInput.getBoundingClientRect();
3149
+ const inputHeight = this.ui.telInput.offsetHeight;
2954
3150
  if (this.options.dropdownContainer) {
2955
- this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
2956
- this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
2957
- this._handleWindowScroll = () => this._closeDropdown();
2958
- window.addEventListener("scroll", this._handleWindowScroll);
3151
+ this.ui.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
3152
+ this.ui.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
3153
+ const handleWindowScroll = () => this._closeDropdown();
3154
+ window.addEventListener("scroll", handleWindowScroll, {
3155
+ signal: this.dropdownAbortController.signal
3156
+ });
2959
3157
  }
2960
3158
  }
2961
3159
  }
2962
3160
  //* We only bind dropdown listeners when the dropdown is open.
2963
3161
  _bindDropdownListeners() {
2964
- this._handleMouseoverCountryList = (e) => {
2965
- const listItem = e.target?.closest(".iti__country");
3162
+ const signal = this.dropdownAbortController.signal;
3163
+ const handleMouseoverCountryList = (e) => {
3164
+ const listItem = e.target?.closest(
3165
+ ".iti__country"
3166
+ );
2966
3167
  if (listItem) {
2967
- this._highlightListItem(listItem, false);
3168
+ this.ui.highlightListItem(listItem, false);
2968
3169
  }
2969
3170
  };
2970
- this.countryList.addEventListener(
2971
- "mouseover",
2972
- this._handleMouseoverCountryList
2973
- );
2974
- this._handleClickCountryList = (e) => {
2975
- const listItem = e.target?.closest(".iti__country");
3171
+ this.ui.countryList.addEventListener("mouseover", handleMouseoverCountryList, {
3172
+ signal
3173
+ });
3174
+ const handleClickCountryList = (e) => {
3175
+ const listItem = e.target?.closest(
3176
+ ".iti__country"
3177
+ );
2976
3178
  if (listItem) {
2977
3179
  this._selectListItem(listItem);
2978
3180
  }
2979
3181
  };
2980
- this.countryList.addEventListener("click", this._handleClickCountryList);
2981
- this._handleClickOffToClose = (e) => {
3182
+ this.ui.countryList.addEventListener("click", handleClickCountryList, {
3183
+ signal
3184
+ });
3185
+ const handleClickOffToClose = (e) => {
2982
3186
  const target = e.target;
2983
- const clickedInsideDropdown = !!target.closest(`#iti-${this.id}__dropdown-content`);
3187
+ const clickedInsideDropdown = !!target.closest(
3188
+ `#iti-${this.id}__dropdown-content`
3189
+ );
2984
3190
  if (!clickedInsideDropdown) {
2985
3191
  this._closeDropdown();
2986
3192
  }
@@ -2988,12 +3194,13 @@ var Iti = class _Iti {
2988
3194
  setTimeout(() => {
2989
3195
  document.documentElement.addEventListener(
2990
3196
  "click",
2991
- this._handleClickOffToClose
3197
+ handleClickOffToClose,
3198
+ { signal }
2992
3199
  );
2993
3200
  }, 0);
2994
3201
  let query = "";
2995
3202
  let queryTimer = null;
2996
- this._handleKeydownOnDropdown = (e) => {
3203
+ const handleKeydownOnDropdown = (e) => {
2997
3204
  if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
2998
3205
  e.preventDefault();
2999
3206
  e.stopPropagation();
@@ -3017,19 +3224,19 @@ var Iti = class _Iti {
3017
3224
  }, 1e3);
3018
3225
  }
3019
3226
  };
3020
- document.addEventListener("keydown", this._handleKeydownOnDropdown);
3227
+ document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
3021
3228
  if (this.options.countrySearch) {
3022
3229
  const doFilter = () => {
3023
- const inputQuery = this.searchInput.value.trim();
3024
- this._filterCountries(inputQuery);
3025
- if (this.searchInput.value) {
3026
- this.searchClearButton.classList.remove("iti__hide");
3230
+ const inputQuery = this.ui.searchInput.value.trim();
3231
+ this._filterCountriesByQuery(inputQuery);
3232
+ if (this.ui.searchInput.value) {
3233
+ this.ui.searchClearButton.classList.remove("iti__hide");
3027
3234
  } else {
3028
- this.searchClearButton.classList.add("iti__hide");
3235
+ this.ui.searchClearButton.classList.add("iti__hide");
3029
3236
  }
3030
3237
  };
3031
3238
  let keyupTimer = null;
3032
- this._handleSearchChange = () => {
3239
+ const handleSearchChange = () => {
3033
3240
  if (keyupTimer) {
3034
3241
  clearTimeout(keyupTimer);
3035
3242
  }
@@ -3038,13 +3245,17 @@ var Iti = class _Iti {
3038
3245
  keyupTimer = null;
3039
3246
  }, 100);
3040
3247
  };
3041
- this.searchInput.addEventListener("input", this._handleSearchChange);
3042
- this._handleSearchClear = () => {
3043
- this.searchInput.value = "";
3044
- this.searchInput.focus();
3248
+ this.ui.searchInput.addEventListener("input", handleSearchChange, {
3249
+ signal
3250
+ });
3251
+ const handleSearchClear = () => {
3252
+ this.ui.searchInput.value = "";
3253
+ this.ui.searchInput.focus();
3045
3254
  doFilter();
3046
3255
  };
3047
- this.searchClearButton.addEventListener("click", this._handleSearchClear);
3256
+ this.ui.searchClearButton.addEventListener("click", handleSearchClear, {
3257
+ signal
3258
+ });
3048
3259
  }
3049
3260
  }
3050
3261
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
@@ -3053,42 +3264,21 @@ var Iti = class _Iti {
3053
3264
  const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
3054
3265
  if (startsWith) {
3055
3266
  const listItem = c.nodeById[this.id];
3056
- this._highlightListItem(listItem, false);
3057
- this._scrollTo(listItem);
3267
+ this.ui.highlightListItem(listItem, false);
3268
+ this.ui.scrollTo(listItem);
3058
3269
  break;
3059
3270
  }
3060
3271
  }
3061
3272
  }
3062
- //* Country search enabled: Filter the countries according to the search query.
3063
- _filterCountries(query) {
3064
- this.countryList.innerHTML = "";
3273
+ //* Country search: Filter the countries according to the search query.
3274
+ _filterCountriesByQuery(query) {
3065
3275
  let matchedCountries;
3066
3276
  if (query === "") {
3067
3277
  matchedCountries = this.countries;
3068
3278
  } else {
3069
3279
  matchedCountries = this._getMatchedCountries(query);
3070
3280
  }
3071
- let noCountriesAddedYet = true;
3072
- for (const c of matchedCountries) {
3073
- const listItem = c.nodeById[this.id];
3074
- if (listItem) {
3075
- this.countryList.appendChild(listItem);
3076
- if (noCountriesAddedYet) {
3077
- this._highlightListItem(listItem, false);
3078
- noCountriesAddedYet = false;
3079
- }
3080
- }
3081
- }
3082
- if (noCountriesAddedYet) {
3083
- this._highlightListItem(null, false);
3084
- if (this.searchNoResults) {
3085
- this.searchNoResults.classList.remove("iti__hide");
3086
- }
3087
- } else if (this.searchNoResults) {
3088
- this.searchNoResults.classList.add("iti__hide");
3089
- }
3090
- this.countryList.scrollTop = 0;
3091
- this._updateSearchResultsA11yText();
3281
+ this.ui.filterCountries(matchedCountries);
3092
3282
  }
3093
3283
  _getMatchedCountries(query) {
3094
3284
  const normalisedQuery = normaliseString(query);
@@ -3122,39 +3312,21 @@ var Iti = class _Iti {
3122
3312
  ...initialsMatches.sort((a, b) => a.priority - b.priority)
3123
3313
  ];
3124
3314
  }
3125
- //* Update search results text (for a11y).
3126
- _updateSearchResultsA11yText() {
3127
- const { i18n } = this.options;
3128
- const count = this.countryList.childElementCount;
3129
- let searchText;
3130
- if (count === 0) {
3131
- searchText = i18n.zeroSearchResults;
3132
- } else {
3133
- if (i18n.searchResultsText) {
3134
- searchText = i18n.searchResultsText(count);
3135
- } else if (count === 1) {
3136
- searchText = i18n.oneSearchResult;
3137
- } else {
3138
- searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
3139
- }
3140
- }
3141
- this.searchResultsA11yText.textContent = searchText;
3142
- }
3143
3315
  //* Highlight the next/prev item in the list (and ensure it is visible).
3144
3316
  _handleUpDownKey(key) {
3145
- let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
3146
- if (!next && this.countryList.childElementCount > 1) {
3147
- next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
3317
+ let next = key === "ArrowUp" ? this.ui.highlightedItem?.previousElementSibling : this.ui.highlightedItem?.nextElementSibling;
3318
+ if (!next && this.ui.countryList.childElementCount > 1) {
3319
+ next = key === "ArrowUp" ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild;
3148
3320
  }
3149
3321
  if (next) {
3150
- this._scrollTo(next);
3151
- this._highlightListItem(next, false);
3322
+ this.ui.scrollTo(next);
3323
+ this.ui.highlightListItem(next, false);
3152
3324
  }
3153
3325
  }
3154
3326
  //* Select the currently highlighted item.
3155
3327
  _handleEnterKey() {
3156
- if (this.highlightedItem) {
3157
- this._selectListItem(this.highlightedItem);
3328
+ if (this.ui.highlightedItem) {
3329
+ this._selectListItem(this.ui.highlightedItem);
3158
3330
  }
3159
3331
  }
3160
3332
  //* Update the input's value to the given val (format first if possible)
@@ -3162,7 +3334,7 @@ var Iti = class _Iti {
3162
3334
  _updateValFromNumber(fullNumber) {
3163
3335
  let number = fullNumber;
3164
3336
  if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
3165
- const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode;
3337
+ const useNational = this.options.nationalMode || !number.startsWith("+") && !this.options.separateDialCode;
3166
3338
  const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
3167
3339
  const format = useNational ? NATIONAL : INTERNATIONAL;
3168
3340
  number = intlTelInput.utils.formatNumber(
@@ -3172,7 +3344,7 @@ var Iti = class _Iti {
3172
3344
  );
3173
3345
  }
3174
3346
  number = this._beforeSetNumber(number);
3175
- this.telInput.value = number;
3347
+ this.ui.telInput.value = number;
3176
3348
  }
3177
3349
  //* Check if need to select a new country based on the given number
3178
3350
  //* Note: called from _setInitialState, keyup handler, setNumber.
@@ -3186,11 +3358,11 @@ var Iti = class _Iti {
3186
3358
  // if there is a selected country, and the number doesn't start with a dial code, then add it
3187
3359
  _ensureHasDialCode(number) {
3188
3360
  const { dialCode, nationalPrefix } = this.selectedCountryData;
3189
- const alreadyHasPlus = number.charAt(0) === "+";
3361
+ const alreadyHasPlus = number.startsWith("+");
3190
3362
  if (alreadyHasPlus || !dialCode) {
3191
3363
  return number;
3192
3364
  }
3193
- const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
3365
+ const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.options.separateDialCode;
3194
3366
  const cleanNumber = hasPrefix ? number.substring(1) : number;
3195
3367
  return `+${dialCode}${cleanNumber}`;
3196
3368
  }
@@ -3223,7 +3395,9 @@ var Iti = class _Iti {
3223
3395
  }
3224
3396
  const { areaCodes, priority } = this.selectedCountryData;
3225
3397
  if (areaCodes) {
3226
- const dialCodeAreaCodes = areaCodes.map((areaCode) => `${selectedDialCode}${areaCode}`);
3398
+ const dialCodeAreaCodes = areaCodes.map(
3399
+ (areaCode) => `${selectedDialCode}${areaCode}`
3400
+ );
3227
3401
  for (const dialCodeAreaCode of dialCodeAreaCodes) {
3228
3402
  if (numeric.startsWith(dialCodeAreaCode)) {
3229
3403
  return null;
@@ -3237,33 +3411,13 @@ var Iti = class _Iti {
3237
3411
  if (!isValidSelection && !alreadySelected) {
3238
3412
  return iso2Codes[0];
3239
3413
  }
3240
- } else if (number.charAt(0) === "+" && numeric.length) {
3414
+ } else if (number.startsWith("+") && numeric.length) {
3241
3415
  return "";
3242
3416
  } else if ((!number || number === "+") && !selectedIso2) {
3243
3417
  return this.defaultCountry;
3244
3418
  }
3245
3419
  return null;
3246
3420
  }
3247
- //* Remove highlighting from other list items and highlight the given item.
3248
- _highlightListItem(listItem, shouldFocus) {
3249
- const prevItem = this.highlightedItem;
3250
- if (prevItem) {
3251
- prevItem.classList.remove("iti__highlight");
3252
- prevItem.setAttribute("aria-selected", "false");
3253
- }
3254
- this.highlightedItem = listItem;
3255
- if (this.highlightedItem) {
3256
- this.highlightedItem.classList.add("iti__highlight");
3257
- this.highlightedItem.setAttribute("aria-selected", "true");
3258
- if (this.options.countrySearch) {
3259
- const activeDescendant = this.highlightedItem.getAttribute("id") || "";
3260
- this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
3261
- }
3262
- }
3263
- if (shouldFocus) {
3264
- this.highlightedItem.focus();
3265
- }
3266
- }
3267
3421
  //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
3268
3422
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
3269
3423
  _setCountry(iso2) {
@@ -3273,7 +3427,7 @@ var Iti = class _Iti {
3273
3427
  if (this.selectedCountryData.iso2) {
3274
3428
  this.defaultCountry = this.selectedCountryData.iso2;
3275
3429
  }
3276
- if (this.selectedCountry) {
3430
+ if (this.ui.selectedCountry) {
3277
3431
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
3278
3432
  let ariaLabel, title;
3279
3433
  if (iso2) {
@@ -3284,32 +3438,19 @@ var Iti = class _Iti {
3284
3438
  title = i18n.noCountrySelected;
3285
3439
  ariaLabel = i18n.noCountrySelected;
3286
3440
  }
3287
- this.selectedCountryInner.className = flagClass;
3288
- this.selectedCountry.setAttribute("title", title);
3289
- this.selectedCountry.setAttribute("aria-label", ariaLabel);
3441
+ this.ui.selectedCountryInner.className = flagClass;
3442
+ this.ui.selectedCountry.setAttribute("title", title);
3443
+ this.ui.selectedCountry.setAttribute("aria-label", ariaLabel);
3290
3444
  }
3291
3445
  if (separateDialCode) {
3292
3446
  const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
3293
- this.selectedDialCode.innerHTML = dialCode;
3294
- this._updateInputPadding();
3447
+ this.ui.selectedDialCode.textContent = dialCode;
3448
+ this.ui.updateInputPadding();
3295
3449
  }
3296
3450
  this._updatePlaceholder();
3297
3451
  this._updateMaxLength();
3298
3452
  return prevIso2 !== iso2;
3299
3453
  }
3300
- //* Update the input padding to make space for the selected country/dial code.
3301
- _updateInputPadding() {
3302
- if (this.selectedCountry) {
3303
- const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
3304
- const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
3305
- const inputPadding = selectedCountryWidth + 6;
3306
- if (this.showSelectedCountryOnLeft) {
3307
- this.telInput.style.paddingLeft = `${inputPadding}px`;
3308
- } else {
3309
- this.telInput.style.paddingRight = `${inputPadding}px`;
3310
- }
3311
- }
3312
- }
3313
3454
  //* Update the maximum valid number length for the currently selected country.
3314
3455
  _updateMaxLength() {
3315
3456
  const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
@@ -3324,7 +3465,11 @@ var Iti = class _Iti {
3324
3465
  true
3325
3466
  );
3326
3467
  let validNumber = exampleNumber;
3327
- while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
3468
+ while (intlTelInput.utils.isPossibleNumber(
3469
+ exampleNumber,
3470
+ iso2,
3471
+ validationNumberTypes
3472
+ )) {
3328
3473
  validNumber = exampleNumber;
3329
3474
  exampleNumber += "0";
3330
3475
  }
@@ -3338,31 +3483,6 @@ var Iti = class _Iti {
3338
3483
  }
3339
3484
  }
3340
3485
  }
3341
- //* When input is in a hidden container during init, we cannot calculate the selected country width.
3342
- //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
3343
- //* To get the right styling to apply, all we need is a shallow clone of the container,
3344
- //* and then to inject a deep clone of the selectedCountry element.
3345
- _getHiddenSelectedCountryWidth() {
3346
- if (this.telInput.parentNode) {
3347
- let body;
3348
- try {
3349
- body = window.top.document.body;
3350
- } catch (e) {
3351
- body = document.body;
3352
- }
3353
- const containerClone = this.telInput.parentNode.cloneNode(false);
3354
- containerClone.style.visibility = "hidden";
3355
- body.appendChild(containerClone);
3356
- const countryContainerClone = this.countryContainer.cloneNode();
3357
- containerClone.appendChild(countryContainerClone);
3358
- const selectedCountryClone = this.selectedCountry.cloneNode(true);
3359
- countryContainerClone.appendChild(selectedCountryClone);
3360
- const width = selectedCountryClone.offsetWidth;
3361
- body.removeChild(containerClone);
3362
- return width;
3363
- }
3364
- return 0;
3365
- }
3366
3486
  //* Update the input placeholder to an example number from the currently selected country.
3367
3487
  _updatePlaceholder() {
3368
3488
  const {
@@ -3371,7 +3491,7 @@ var Iti = class _Iti {
3371
3491
  nationalMode,
3372
3492
  customPlaceholder
3373
3493
  } = this.options;
3374
- const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
3494
+ const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.ui.hadInitialPlaceholder && autoPlaceholder === "polite";
3375
3495
  if (intlTelInput.utils && shouldSetPlaceholder) {
3376
3496
  const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3377
3497
  let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
@@ -3383,98 +3503,66 @@ var Iti = class _Iti {
3383
3503
  if (typeof customPlaceholder === "function") {
3384
3504
  placeholder = customPlaceholder(placeholder, this.selectedCountryData);
3385
3505
  }
3386
- this.telInput.setAttribute("placeholder", placeholder);
3506
+ this.ui.telInput.setAttribute("placeholder", placeholder);
3387
3507
  }
3388
3508
  }
3389
3509
  //* Called when the user selects a list item from the dropdown.
3390
3510
  _selectListItem(listItem) {
3391
- const iso2 = listItem.getAttribute("data-country-code");
3511
+ const iso2 = listItem.dataset.countryCode;
3392
3512
  const countryChanged = this._setCountry(iso2);
3393
3513
  this._closeDropdown();
3394
- const dialCode = listItem.getAttribute("data-dial-code");
3514
+ const dialCode = listItem.dataset.dialCode;
3395
3515
  this._updateDialCode(dialCode);
3396
3516
  if (this.options.formatOnDisplay) {
3397
- this._updateValFromNumber(this.telInput.value);
3517
+ this._updateValFromNumber(this.ui.telInput.value);
3398
3518
  }
3399
- this.telInput.focus();
3519
+ this.ui.telInput.focus();
3400
3520
  if (countryChanged) {
3401
3521
  this._triggerCountryChange();
3402
3522
  }
3403
3523
  }
3404
3524
  //* Close the dropdown and unbind any listeners.
3405
3525
  _closeDropdown() {
3406
- this.dropdownContent.classList.add("iti__hide");
3407
- this.selectedCountry.setAttribute("aria-expanded", "false");
3408
- if (this.highlightedItem) {
3409
- this.highlightedItem.setAttribute("aria-selected", "false");
3526
+ if (this.ui.dropdownContent.classList.contains("iti__hide")) {
3527
+ return;
3410
3528
  }
3411
- if (this.options.countrySearch) {
3412
- this.searchInput.removeAttribute("aria-activedescendant");
3529
+ this.ui.dropdownContent.classList.add("iti__hide");
3530
+ this.ui.selectedCountry.setAttribute("aria-expanded", "false");
3531
+ if (this.ui.highlightedItem) {
3532
+ this.ui.highlightedItem.setAttribute("aria-selected", "false");
3413
3533
  }
3414
- this.dropdownArrow.classList.remove("iti__arrow--up");
3415
3534
  if (this.options.countrySearch) {
3416
- this.searchInput.removeEventListener("input", this._handleSearchChange);
3417
- this.searchClearButton.removeEventListener("click", this._handleSearchClear);
3535
+ this.ui.searchInput.removeAttribute("aria-activedescendant");
3418
3536
  }
3419
- document.removeEventListener("keydown", this._handleKeydownOnDropdown);
3420
- document.documentElement.removeEventListener(
3421
- "click",
3422
- this._handleClickOffToClose
3423
- );
3424
- this.countryList.removeEventListener(
3425
- "mouseover",
3426
- this._handleMouseoverCountryList
3427
- );
3428
- this.countryList.removeEventListener("click", this._handleClickCountryList);
3537
+ this.ui.dropdownArrow.classList.remove("iti__arrow--up");
3538
+ this.dropdownAbortController.abort();
3539
+ this.dropdownAbortController = null;
3429
3540
  if (this.options.dropdownContainer) {
3430
- if (!this.options.useFullscreenPopup) {
3431
- window.removeEventListener("scroll", this._handleWindowScroll);
3432
- }
3433
- if (this.dropdown.parentNode) {
3434
- this.dropdown.parentNode.removeChild(this.dropdown);
3435
- }
3541
+ this.ui.dropdown.remove();
3436
3542
  }
3437
3543
  this._trigger("close:countrydropdown");
3438
3544
  }
3439
- //* Check if an element is visible within it's container, else scroll until it is.
3440
- _scrollTo(element) {
3441
- const container = this.countryList;
3442
- const scrollTop = document.documentElement.scrollTop;
3443
- const containerHeight = container.offsetHeight;
3444
- const containerTop = container.getBoundingClientRect().top + scrollTop;
3445
- const containerBottom = containerTop + containerHeight;
3446
- const elementHeight = element.offsetHeight;
3447
- const elementTop = element.getBoundingClientRect().top + scrollTop;
3448
- const elementBottom = elementTop + elementHeight;
3449
- const newScrollTop = elementTop - containerTop + container.scrollTop;
3450
- if (elementTop < containerTop) {
3451
- container.scrollTop = newScrollTop;
3452
- } else if (elementBottom > containerBottom) {
3453
- const heightDifference = containerHeight - elementHeight;
3454
- container.scrollTop = newScrollTop - heightDifference;
3455
- }
3456
- }
3457
3545
  //* Replace any existing dial code with the new one
3458
3546
  //* Note: called from _selectListItem and setCountry
3459
3547
  _updateDialCode(newDialCodeBare) {
3460
- const inputVal = this.telInput.value;
3548
+ const inputVal = this.ui.telInput.value;
3461
3549
  const newDialCode = `+${newDialCodeBare}`;
3462
3550
  let newNumber;
3463
- if (inputVal.charAt(0) === "+") {
3551
+ if (inputVal.startsWith("+")) {
3464
3552
  const prevDialCode = this._getDialCode(inputVal);
3465
3553
  if (prevDialCode) {
3466
3554
  newNumber = inputVal.replace(prevDialCode, newDialCode);
3467
3555
  } else {
3468
3556
  newNumber = newDialCode;
3469
3557
  }
3470
- this.telInput.value = newNumber;
3558
+ this.ui.telInput.value = newNumber;
3471
3559
  }
3472
3560
  }
3473
3561
  //* Try and extract a valid international dial code from a full telephone number.
3474
3562
  //* Note: returns the raw string inc plus character and any whitespace/dots etc.
3475
3563
  _getDialCode(number, includeAreaCode) {
3476
3564
  let dialCode = "";
3477
- if (number.charAt(0) === "+") {
3565
+ if (number.startsWith("+")) {
3478
3566
  let numericChars = "";
3479
3567
  for (let i = 0; i < number.length; i++) {
3480
3568
  const c = number.charAt(i);
@@ -3500,11 +3588,11 @@ var Iti = class _Iti {
3500
3588
  }
3501
3589
  //* Get the input val, adding the dial code if separateDialCode is enabled.
3502
3590
  _getFullNumber(overrideVal) {
3503
- const val = overrideVal || this.telInput.value.trim();
3591
+ const val = overrideVal || this.ui.telInput.value.trim();
3504
3592
  const { dialCode } = this.selectedCountryData;
3505
3593
  let prefix;
3506
3594
  const numericVal = getNumeric(val);
3507
- if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
3595
+ if (this.options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
3508
3596
  prefix = `+${dialCode}`;
3509
3597
  } else {
3510
3598
  prefix = "";
@@ -3533,7 +3621,7 @@ var Iti = class _Iti {
3533
3621
  handleAutoCountry() {
3534
3622
  if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
3535
3623
  this.defaultCountry = intlTelInput.autoCountry;
3536
- const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
3624
+ const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains("iti__globe");
3537
3625
  if (!hasSelectedCountryOrGlobe) {
3538
3626
  this.setCountry(this.defaultCountry);
3539
3627
  }
@@ -3543,8 +3631,8 @@ var Iti = class _Iti {
3543
3631
  //* This is called when the utils request completes.
3544
3632
  handleUtils() {
3545
3633
  if (intlTelInput.utils) {
3546
- if (this.telInput.value) {
3547
- this._updateValFromNumber(this.telInput.value);
3634
+ if (this.ui.telInput.value) {
3635
+ this._updateValFromNumber(this.ui.telInput.value);
3548
3636
  }
3549
3637
  if (this.selectedCountryData.iso2) {
3550
3638
  this._updatePlaceholder();
@@ -3558,49 +3646,20 @@ var Iti = class _Iti {
3558
3646
  //********************
3559
3647
  //* Remove plugin.
3560
3648
  destroy() {
3561
- this.telInput.iti = void 0;
3562
- const { allowDropdown, separateDialCode } = this.options;
3563
- if (allowDropdown) {
3564
- this._closeDropdown();
3565
- this.selectedCountry.removeEventListener(
3566
- "click",
3567
- this._handleClickSelectedCountry
3568
- );
3569
- this.countryContainer.removeEventListener(
3570
- "keydown",
3571
- this._handleCountryContainerKeydown
3572
- );
3573
- const label = this.telInput.closest("label");
3574
- if (label) {
3575
- label.removeEventListener("click", this._handleLabelClick);
3576
- }
3577
- }
3578
- const { form } = this.telInput;
3579
- if (this._handleHiddenInputSubmit && form) {
3580
- form.removeEventListener("submit", this._handleHiddenInputSubmit);
3581
- }
3582
- this.telInput.removeEventListener("input", this._handleInputEvent);
3583
- if (this._handleKeydownEvent) {
3584
- this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
3585
- }
3586
- if (this._handlePasteEvent) {
3587
- this.telInput.removeEventListener("paste", this._handlePasteEvent);
3649
+ if (!this.ui.telInput) {
3650
+ return;
3588
3651
  }
3589
- if (this._handlePageLoad) {
3590
- window.removeEventListener("load", this._handlePageLoad);
3652
+ if (this.options.allowDropdown) {
3653
+ this._closeDropdown();
3591
3654
  }
3592
- this.telInput.removeAttribute("data-intl-tel-input-id");
3593
- if (separateDialCode) {
3594
- if (this.isRTL) {
3595
- this.telInput.style.paddingRight = this.originalPaddingRight;
3596
- } else {
3597
- this.telInput.style.paddingLeft = this.originalPaddingLeft;
3598
- }
3655
+ this.abortController.abort();
3656
+ this.abortController = null;
3657
+ this.ui.destroy();
3658
+ if (intlTelInput.instances instanceof Map) {
3659
+ intlTelInput.instances.delete(this.id);
3660
+ } else {
3661
+ delete intlTelInput.instances[this.id];
3599
3662
  }
3600
- const wrapper = this.telInput.parentNode;
3601
- wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
3602
- wrapper?.parentNode?.removeChild(wrapper);
3603
- delete intlTelInput.instances[this.id];
3604
3663
  }
3605
3664
  //* Get the extension from the current number.
3606
3665
  getExtension() {
@@ -3646,19 +3705,34 @@ var Iti = class _Iti {
3646
3705
  }
3647
3706
  return -99;
3648
3707
  }
3649
- //* Validate the input val (with precise=false)
3708
+ //* Validate the input val using number length only
3650
3709
  isValidNumber() {
3710
+ const { dialCode, iso2 } = this.selectedCountryData;
3711
+ if (dialCode === "44" && intlTelInput.utils) {
3712
+ const number = this._getFullNumber();
3713
+ const coreNumber = intlTelInput.utils.getCoreNumber(number, iso2);
3714
+ if (coreNumber[0] === "7" && coreNumber.length !== 10) {
3715
+ return false;
3716
+ }
3717
+ }
3651
3718
  return this._validateNumber(false);
3652
3719
  }
3653
- //* Validate the input val (with precise=true)
3720
+ //* Validate the input val with precise validation
3654
3721
  isValidNumberPrecise() {
3655
3722
  return this._validateNumber(true);
3656
3723
  }
3657
3724
  _utilsIsPossibleNumber(val) {
3658
- return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3725
+ return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(
3726
+ val,
3727
+ this.selectedCountryData.iso2,
3728
+ this.options.validationNumberTypes
3729
+ ) : null;
3659
3730
  }
3660
3731
  //* Shared internal validation logic to handle alpha character extension rules.
3661
3732
  _validateNumber(precise) {
3733
+ if (!intlTelInput.utils) {
3734
+ return null;
3735
+ }
3662
3736
  if (!this.selectedCountryData.iso2) {
3663
3737
  return false;
3664
3738
  }
@@ -3675,7 +3749,11 @@ var Iti = class _Iti {
3675
3749
  return testValidity(val);
3676
3750
  }
3677
3751
  _utilsIsValidNumber(val) {
3678
- return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3752
+ return intlTelInput.utils ? intlTelInput.utils.isValidNumber(
3753
+ val,
3754
+ this.selectedCountryData.iso2,
3755
+ this.options.validationNumberTypes
3756
+ ) : null;
3679
3757
  }
3680
3758
  //* Update the selected country, and update the input val accordingly.
3681
3759
  setCountry(iso2) {
@@ -3689,7 +3767,7 @@ var Iti = class _Iti {
3689
3767
  this._setCountry(iso2Lower);
3690
3768
  this._updateDialCode(this.selectedCountryData.dialCode);
3691
3769
  if (this.options.formatOnDisplay) {
3692
- this._updateValFromNumber(this.telInput.value);
3770
+ this._updateValFromNumber(this.ui.telInput.value);
3693
3771
  }
3694
3772
  this._triggerCountryChange();
3695
3773
  }
@@ -3709,11 +3787,11 @@ var Iti = class _Iti {
3709
3787
  this._updatePlaceholder();
3710
3788
  }
3711
3789
  setDisabled(disabled) {
3712
- this.telInput.disabled = disabled;
3790
+ this.ui.telInput.disabled = disabled;
3713
3791
  if (disabled) {
3714
- this.selectedCountry.setAttribute("disabled", "true");
3792
+ this.ui.selectedCountry.setAttribute("disabled", "true");
3715
3793
  } else {
3716
- this.selectedCountry.removeAttribute("disabled");
3794
+ this.ui.selectedCountry.removeAttribute("disabled");
3717
3795
  }
3718
3796
  }
3719
3797
  };
@@ -3727,13 +3805,19 @@ var attachUtils = (source) => {
3727
3805
  return Promise.reject(error);
3728
3806
  }
3729
3807
  } else {
3730
- return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`));
3808
+ return Promise.reject(
3809
+ new TypeError(
3810
+ `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
3811
+ )
3812
+ );
3731
3813
  }
3732
3814
  intlTelInput.startedLoadingUtilsScript = true;
3733
3815
  return loadCall.then((module2) => {
3734
3816
  const utils2 = module2?.default;
3735
3817
  if (!utils2 || typeof utils2 !== "object") {
3736
- throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
3818
+ throw new TypeError(
3819
+ "The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
3820
+ );
3737
3821
  }
3738
3822
  intlTelInput.utils = utils2;
3739
3823
  forEachInstance("handleUtils");
@@ -3745,11 +3829,17 @@ var attachUtils = (source) => {
3745
3829
  }
3746
3830
  return null;
3747
3831
  };
3832
+ var forEachInstance = (method, ...args) => {
3833
+ Object.values(intlTelInput.instances).forEach((instance) => {
3834
+ const fn = instance[method];
3835
+ if (typeof fn === "function") {
3836
+ fn.apply(instance, args);
3837
+ }
3838
+ });
3839
+ };
3748
3840
  var intlTelInput = Object.assign(
3749
3841
  (input, options) => {
3750
3842
  const iti = new Iti(input, options);
3751
- iti._init();
3752
- input.setAttribute("data-intl-tel-input-id", iti.id.toString());
3753
3843
  intlTelInput.instances[iti.id] = iti;
3754
3844
  input.iti = iti;
3755
3845
  return iti;
@@ -3762,7 +3852,7 @@ var intlTelInput = Object.assign(
3762
3852
  getCountryData: () => data_default,
3763
3853
  //* A getter for the plugin instance.
3764
3854
  getInstance: (input) => {
3765
- const id2 = input.getAttribute("data-intl-tel-input-id");
3855
+ const id2 = input.dataset.intlTelInputId;
3766
3856
  return id2 ? intlTelInput.instances[id2] : null;
3767
3857
  },
3768
3858
  //* A map from instance ID to instance object.
@@ -3770,7 +3860,7 @@ var intlTelInput = Object.assign(
3770
3860
  attachUtils,
3771
3861
  startedLoadingUtilsScript: false,
3772
3862
  startedLoadingAutoCountry: false,
3773
- version: "25.10.11"
3863
+ version: "25.11.0"
3774
3864
  }
3775
3865
  );
3776
3866
  var intl_tel_input_default = intlTelInput;
@@ -6880,7 +6970,7 @@ var intl_tel_input_default = intlTelInput;
6880
6970
  ,
6881
6971
  ,
6882
6972
  [7, 8, 9]
6883
- ], [, , "(?:1(?:0[0-8]|1[0-7]|2[014]|30)|7\\d\\d)\\d{6}", , , , "712123456", , , [9]], [, , "800[02-8]\\d{5,6}", , , , "800223456", , , [9, 10]], [, , "900[02-9]\\d{5}", , , , "900223456", , , [9]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "KE", 254, "000", "0", , , "0", , , , [[, "(\\d{2})(\\d{5,7})", "$1 $2", ["[24-6]"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[17]"], "0$1"], [, "(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
6973
+ ], [, , "(?:1(?:0[0-8]|1\\d|2[014]|[34]0)|7\\d\\d)\\d{6}", , , , "712123456", , , [9]], [, , "800[02-8]\\d{5,6}", , , , "800223456", , , [9, 10]], [, , "900[02-9]\\d{5}", , , , "900223456", , , [9]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "KE", 254, "000", "0", , , "0", , , , [[, "(\\d{2})(\\d{5,7})", "$1 $2", ["[24-6]"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[17]"], "0$1"], [, "(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
6884
6974
  KG: [, [
6885
6975
  ,
6886
6976
  ,
@@ -8936,7 +9026,7 @@ var intl_tel_input_default = intlTelInput;
8936
9026
  ,
8937
9027
  ,
8938
9028
  [5, 6, 7]
8939
- ], [, , "72[48]0\\d{5}|7(?:[014-8]\\d|2[067]|36|9[0189])\\d{6}", , , , "712345678"], [, , "800[1-3]\\d{5}", , , , "800123456"], [, , "90[1-3]\\d{6}", , , , "901123456"], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "UG", 256, "00[057]", "0", , , "0", , , , [[, "(\\d{4})(\\d{5})", "$1 $2", ["202", "2024"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[27-9]|4(?:6[45]|[7-9])"], "0$1"], [, "(\\d{2})(\\d{7})", "$1 $2", ["[34]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
9029
+ ], [, , "72[48]0\\d{5}|7(?:[014-8]\\d|2[067]|36|9[0-289])\\d{6}", , , , "712345678"], [, , "800[1-3]\\d{5}", , , , "800123456"], [, , "90[1-3]\\d{6}", , , , "901123456"], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "UG", 256, "00[057]", "0", , , "0", , , , [[, "(\\d{4})(\\d{5})", "$1 $2", ["202", "2024"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[27-9]|4(?:6[45]|[7-9])"], "0$1"], [, "(\\d{2})(\\d{7})", "$1 $2", ["[34]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
8940
9030
  US: [, [
8941
9031
  ,
8942
9032
  ,
@@ -8952,7 +9042,7 @@ var intl_tel_input_default = intlTelInput;
8952
9042
  ], [
8953
9043
  ,
8954
9044
  ,
8955
- "(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-68]))\\d{4}|(?:2742|305[3-9]|(?:472|983)[2-47-9]|505[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
9045
+ "3052(?:0[0-8]|[1-9]\\d)\\d{4}|(?:2742|305[3-9])\\d{6}|(?:472|983)[2-47-9]\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
8956
9046
  ,
8957
9047
  ,
8958
9048
  ,
@@ -8964,7 +9054,7 @@ var intl_tel_input_default = intlTelInput;
8964
9054
  ], [
8965
9055
  ,
8966
9056
  ,
8967
- "(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-68]))\\d{4}|(?:2742|305[3-9]|(?:472|983)[2-47-9]|505[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
9057
+ "3052(?:0[0-8]|[1-9]\\d)\\d{4}|(?:2742|305[3-9])\\d{6}|(?:472|983)[2-47-9]\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
8968
9058
  ,
8969
9059
  ,
8970
9060
  ,