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