intl-tel-input 25.10.12 → 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 +619 -569
- package/angular/build/IntlTelInputWithUtils.js +623 -573
- package/angular/build/types/intl-tel-input.d.ts +17 -69
- 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/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +83 -72
- package/build/js/intlTelInput.js +738 -645
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +742 -649
- 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 +737 -644
- package/react/build/IntlTelInput.d.ts +83 -72
- package/react/build/IntlTelInput.js +737 -644
- package/react/build/IntlTelInputWithUtils.cjs +741 -648
- package/react/build/IntlTelInputWithUtils.js +741 -648
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +818 -714
- package/vue/build/IntlTelInputWithUtils.mjs +1021 -917
|
@@ -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,251 +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
2115
|
if (this.options.separateDialCode) {
|
|
2306
2116
|
this.originalPaddingLeft = this.telInput.style.paddingLeft;
|
|
2307
2117
|
}
|
|
2308
2118
|
}
|
|
2309
|
-
_createInitPromises() {
|
|
2310
|
-
const autoCountryPromise = new Promise((resolve, reject) => {
|
|
2311
|
-
this.resolveAutoCountryPromise = resolve;
|
|
2312
|
-
this.rejectAutoCountryPromise = reject;
|
|
2313
|
-
});
|
|
2314
|
-
const utilsScriptPromise = new Promise((resolve, reject) => {
|
|
2315
|
-
this.resolveUtilsScriptPromise = resolve;
|
|
2316
|
-
this.rejectUtilsScriptPromise = reject;
|
|
2317
|
-
});
|
|
2318
|
-
this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]);
|
|
2319
|
-
}
|
|
2320
|
-
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
2321
|
-
_init() {
|
|
2322
|
-
applyOptionSideEffects(this.options);
|
|
2323
|
-
this._detectEnvironmentAndLayout();
|
|
2324
|
-
this._createInitPromises();
|
|
2325
|
-
this.selectedCountryData = {};
|
|
2326
|
-
this._processCountryData();
|
|
2327
|
-
this._generateMarkup();
|
|
2328
|
-
this._setInitialState();
|
|
2329
|
-
this._initListeners();
|
|
2330
|
-
this._initRequests();
|
|
2331
|
-
}
|
|
2332
|
-
//********************
|
|
2333
|
-
//* PRIVATE METHODS
|
|
2334
|
-
//********************
|
|
2335
|
-
//* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
|
|
2336
|
-
_processCountryData() {
|
|
2337
|
-
this.countries = processAllCountries(this.options);
|
|
2338
|
-
const dialRes = processDialCodes(this.countries, this.options);
|
|
2339
|
-
this.dialCodes = dialRes.dialCodes;
|
|
2340
|
-
this.dialCodeMaxLen = dialRes.dialCodeMaxLen;
|
|
2341
|
-
this.dialCodeToIso2Map = dialRes.dialCodeToIso2Map;
|
|
2342
|
-
translateCountryNames(this.countries, this.options);
|
|
2343
|
-
sortCountries(this.countries, this.options);
|
|
2344
|
-
this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
|
|
2345
|
-
cacheSearchTokens(this.countries);
|
|
2346
|
-
}
|
|
2347
2119
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
2348
|
-
|
|
2120
|
+
generateMarkup(countries) {
|
|
2121
|
+
this.countries = countries;
|
|
2349
2122
|
this._prepareTelInput();
|
|
2350
2123
|
const wrapper = this._createWrapperAndInsert();
|
|
2351
2124
|
this._maybeBuildCountryContainer(wrapper);
|
|
@@ -2355,7 +2128,7 @@ var factoryOutput = (() => {
|
|
|
2355
2128
|
}
|
|
2356
2129
|
_prepareTelInput() {
|
|
2357
2130
|
this.telInput.classList.add("iti__tel-input");
|
|
2358
|
-
if (!this.telInput.hasAttribute("autocomplete") && !
|
|
2131
|
+
if (!this.telInput.hasAttribute("autocomplete") && !this.telInput.form?.hasAttribute("autocomplete")) {
|
|
2359
2132
|
this.telInput.setAttribute("autocomplete", "off");
|
|
2360
2133
|
}
|
|
2361
2134
|
}
|
|
@@ -2366,8 +2139,8 @@ var factoryOutput = (() => {
|
|
|
2366
2139
|
containerClass,
|
|
2367
2140
|
useFullscreenPopup
|
|
2368
2141
|
} = this.options;
|
|
2369
|
-
const parentClasses =
|
|
2370
|
-
|
|
2142
|
+
const parentClasses = buildClassNames({
|
|
2143
|
+
iti: true,
|
|
2371
2144
|
"iti--allow-dropdown": allowDropdown,
|
|
2372
2145
|
"iti--show-flags": showFlags,
|
|
2373
2146
|
"iti--inline-dropdown": !useFullscreenPopup,
|
|
@@ -2377,15 +2150,11 @@ var factoryOutput = (() => {
|
|
|
2377
2150
|
if (this.isRTL) {
|
|
2378
2151
|
wrapper.setAttribute("dir", "ltr");
|
|
2379
2152
|
}
|
|
2380
|
-
this.telInput.
|
|
2153
|
+
this.telInput.before(wrapper);
|
|
2381
2154
|
return wrapper;
|
|
2382
2155
|
}
|
|
2383
2156
|
_maybeBuildCountryContainer(wrapper) {
|
|
2384
|
-
const {
|
|
2385
|
-
allowDropdown,
|
|
2386
|
-
separateDialCode,
|
|
2387
|
-
showFlags
|
|
2388
|
-
} = this.options;
|
|
2157
|
+
const { allowDropdown, separateDialCode, showFlags } = this.options;
|
|
2389
2158
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
2390
2159
|
this.countryContainer = createEl(
|
|
2391
2160
|
"div",
|
|
@@ -2478,12 +2247,12 @@ var factoryOutput = (() => {
|
|
|
2478
2247
|
this.dropdownContent
|
|
2479
2248
|
);
|
|
2480
2249
|
this._appendListItems();
|
|
2481
|
-
if (countrySearch) {
|
|
2482
|
-
this.
|
|
2250
|
+
if (this.options.countrySearch) {
|
|
2251
|
+
this.updateSearchResultsA11yText();
|
|
2483
2252
|
}
|
|
2484
2253
|
if (dropdownContainer) {
|
|
2485
|
-
const dropdownClasses =
|
|
2486
|
-
|
|
2254
|
+
const dropdownClasses = buildClassNames({
|
|
2255
|
+
iti: true,
|
|
2487
2256
|
"iti--container": true,
|
|
2488
2257
|
"iti--fullscreen-popup": useFullscreenPopup,
|
|
2489
2258
|
"iti--inline-dropdown": !useFullscreenPopup,
|
|
@@ -2529,7 +2298,7 @@ var factoryOutput = (() => {
|
|
|
2529
2298
|
"aria-label": i18n.searchPlaceholder,
|
|
2530
2299
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
2531
2300
|
"aria-autocomplete": "list",
|
|
2532
|
-
|
|
2301
|
+
autocomplete: "off"
|
|
2533
2302
|
},
|
|
2534
2303
|
searchWrapper
|
|
2535
2304
|
);
|
|
@@ -2566,80 +2335,478 @@ var factoryOutput = (() => {
|
|
|
2566
2335
|
},
|
|
2567
2336
|
this.dropdownContent
|
|
2568
2337
|
);
|
|
2569
|
-
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();
|
|
2570
2769
|
}
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
this._updateInputPadding();
|
|
2574
|
-
this.countryContainer.classList.remove("iti__v-hide");
|
|
2575
|
-
}
|
|
2770
|
+
static _getIsAndroid() {
|
|
2771
|
+
return typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
|
|
2576
2772
|
}
|
|
2577
|
-
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
this.hiddenInput = createEl("input", {
|
|
2588
|
-
type: "hidden",
|
|
2589
|
-
name: names.phone
|
|
2590
|
-
});
|
|
2591
|
-
wrapper.appendChild(this.hiddenInput);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
if (names.country) {
|
|
2595
|
-
const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
|
|
2596
|
-
if (existingInput) {
|
|
2597
|
-
this.hiddenInputCountry = existingInput;
|
|
2598
|
-
} else {
|
|
2599
|
-
this.hiddenInputCountry = createEl("input", {
|
|
2600
|
-
type: "hidden",
|
|
2601
|
-
name: names.country
|
|
2602
|
-
});
|
|
2603
|
-
wrapper.appendChild(this.hiddenInputCountry);
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
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]);
|
|
2607
2783
|
}
|
|
2608
|
-
//*
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
c.nodeById[this.id] = listItem;
|
|
2627
|
-
let content = "";
|
|
2628
|
-
if (this.options.showFlags) {
|
|
2629
|
-
content += `<div class='iti__flag iti__${c.iso2}'></div>`;
|
|
2630
|
-
}
|
|
2631
|
-
content += `<span class='iti__country-name'>${c.name}</span>`;
|
|
2632
|
-
content += `<span class='iti__dial-code' dir='ltr'>+${c.dialCode}</span>`;
|
|
2633
|
-
listItem.insertAdjacentHTML("beforeend", content);
|
|
2634
|
-
}
|
|
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);
|
|
2635
2802
|
}
|
|
2636
2803
|
//* Set the initial state of the input value and the selected country by:
|
|
2637
2804
|
//* 1. Extracting a dial code from the given number
|
|
2638
2805
|
//* 2. Using explicit initialCountry
|
|
2639
2806
|
_setInitialState(overrideAutoCountry = false) {
|
|
2640
|
-
const attributeValue = this.telInput.getAttribute("value");
|
|
2641
|
-
const inputValue = this.telInput.value;
|
|
2642
|
-
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("+"));
|
|
2643
2810
|
const val = useAttribute ? attributeValue : inputValue;
|
|
2644
2811
|
const dialCode = this._getDialCode(val);
|
|
2645
2812
|
const isRegionlessNanpNumber = isRegionlessNanp(val);
|
|
@@ -2669,47 +2836,49 @@ var factoryOutput = (() => {
|
|
|
2669
2836
|
if (this.options.allowDropdown) {
|
|
2670
2837
|
this._initDropdownListeners();
|
|
2671
2838
|
}
|
|
2672
|
-
if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
|
|
2839
|
+
if ((this.ui.hiddenInput || this.ui.hiddenInputCountry) && this.ui.telInput.form) {
|
|
2673
2840
|
this._initHiddenInputListener();
|
|
2674
2841
|
}
|
|
2675
2842
|
}
|
|
2676
2843
|
//* Update hidden input on form submit.
|
|
2677
2844
|
_initHiddenInputListener() {
|
|
2678
|
-
|
|
2679
|
-
if (this.hiddenInput) {
|
|
2680
|
-
this.hiddenInput.value = this.getNumber();
|
|
2845
|
+
const handleHiddenInputSubmit = () => {
|
|
2846
|
+
if (this.ui.hiddenInput) {
|
|
2847
|
+
this.ui.hiddenInput.value = this.getNumber();
|
|
2681
2848
|
}
|
|
2682
|
-
if (this.hiddenInputCountry) {
|
|
2683
|
-
this.hiddenInputCountry.value = this.
|
|
2849
|
+
if (this.ui.hiddenInputCountry) {
|
|
2850
|
+
this.ui.hiddenInputCountry.value = this.selectedCountryData.iso2 || "";
|
|
2684
2851
|
}
|
|
2685
2852
|
};
|
|
2686
|
-
this.telInput.form?.addEventListener(
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
);
|
|
2853
|
+
this.ui.telInput.form?.addEventListener("submit", handleHiddenInputSubmit, {
|
|
2854
|
+
signal: this.abortController.signal
|
|
2855
|
+
});
|
|
2690
2856
|
}
|
|
2691
2857
|
//* initialise the dropdown listeners.
|
|
2692
2858
|
_initDropdownListeners() {
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2859
|
+
const signal = this.abortController.signal;
|
|
2860
|
+
const handleLabelClick = (e) => {
|
|
2861
|
+
if (this.ui.dropdownContent.classList.contains("iti__hide")) {
|
|
2862
|
+
this.ui.telInput.focus();
|
|
2696
2863
|
} else {
|
|
2697
2864
|
e.preventDefault();
|
|
2698
2865
|
}
|
|
2699
2866
|
};
|
|
2700
|
-
const label = this.telInput.closest("label");
|
|
2867
|
+
const label = this.ui.telInput.closest("label");
|
|
2701
2868
|
if (label) {
|
|
2702
|
-
label.addEventListener("click",
|
|
2869
|
+
label.addEventListener("click", handleLabelClick, { signal });
|
|
2703
2870
|
}
|
|
2704
|
-
|
|
2705
|
-
const dropdownClosed = this.dropdownContent.classList.contains("iti__hide");
|
|
2706
|
-
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) {
|
|
2707
2874
|
this._openDropdown();
|
|
2708
2875
|
}
|
|
2709
2876
|
};
|
|
2710
|
-
this.selectedCountry.addEventListener("click",
|
|
2711
|
-
|
|
2712
|
-
|
|
2877
|
+
this.ui.selectedCountry.addEventListener("click", handleClickSelectedCountry, {
|
|
2878
|
+
signal
|
|
2879
|
+
});
|
|
2880
|
+
const handleCountryContainerKeydown = (e) => {
|
|
2881
|
+
const isDropdownHidden = this.ui.dropdownContent.classList.contains("iti__hide");
|
|
2713
2882
|
if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
|
|
2714
2883
|
e.preventDefault();
|
|
2715
2884
|
e.stopPropagation();
|
|
@@ -2719,26 +2888,29 @@ var factoryOutput = (() => {
|
|
|
2719
2888
|
this._closeDropdown();
|
|
2720
2889
|
}
|
|
2721
2890
|
};
|
|
2722
|
-
this.countryContainer.addEventListener(
|
|
2891
|
+
this.ui.countryContainer.addEventListener(
|
|
2723
2892
|
"keydown",
|
|
2724
|
-
|
|
2893
|
+
handleCountryContainerKeydown,
|
|
2894
|
+
{ signal }
|
|
2725
2895
|
);
|
|
2726
2896
|
}
|
|
2727
2897
|
//* Init many requests: utils script / geo ip lookup.
|
|
2728
2898
|
_initRequests() {
|
|
2729
|
-
|
|
2899
|
+
const { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2730
2900
|
if (loadUtils && !intlTelInput.utils) {
|
|
2731
|
-
|
|
2901
|
+
const doAttachUtils = () => {
|
|
2732
2902
|
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2733
2903
|
});
|
|
2734
2904
|
};
|
|
2735
2905
|
if (intlTelInput.documentReady()) {
|
|
2736
|
-
|
|
2906
|
+
doAttachUtils();
|
|
2737
2907
|
} else {
|
|
2738
|
-
|
|
2739
|
-
|
|
2908
|
+
const handlePageLoad = () => {
|
|
2909
|
+
doAttachUtils();
|
|
2740
2910
|
};
|
|
2741
|
-
window.addEventListener("load",
|
|
2911
|
+
window.addEventListener("load", handlePageLoad, {
|
|
2912
|
+
signal: this.abortController.signal
|
|
2913
|
+
});
|
|
2742
2914
|
}
|
|
2743
2915
|
} else {
|
|
2744
2916
|
this.resolveUtilsScriptPromise();
|
|
@@ -2778,8 +2950,8 @@ var factoryOutput = (() => {
|
|
|
2778
2950
|
}
|
|
2779
2951
|
_openDropdownWithPlus() {
|
|
2780
2952
|
this._openDropdown();
|
|
2781
|
-
this.searchInput.value = "+";
|
|
2782
|
-
this.
|
|
2953
|
+
this.ui.searchInput.value = "+";
|
|
2954
|
+
this._filterCountriesByQuery("");
|
|
2783
2955
|
}
|
|
2784
2956
|
//* Initialize the tel input listeners.
|
|
2785
2957
|
_initTelInputListeners() {
|
|
@@ -2788,55 +2960,77 @@ var factoryOutput = (() => {
|
|
|
2788
2960
|
this._maybeBindPasteListener();
|
|
2789
2961
|
}
|
|
2790
2962
|
_bindInputListener() {
|
|
2791
|
-
const {
|
|
2963
|
+
const {
|
|
2964
|
+
strictMode,
|
|
2965
|
+
formatAsYouType,
|
|
2966
|
+
separateDialCode,
|
|
2967
|
+
allowDropdown,
|
|
2968
|
+
countrySearch
|
|
2969
|
+
} = this.options;
|
|
2792
2970
|
let userOverrideFormatting = false;
|
|
2793
|
-
if (/\p{L}/u.test(this.telInput.value)) {
|
|
2971
|
+
if (/\p{L}/u.test(this.ui.telInput.value)) {
|
|
2794
2972
|
userOverrideFormatting = true;
|
|
2795
2973
|
}
|
|
2796
|
-
|
|
2974
|
+
const handleInputEvent = (e) => {
|
|
2797
2975
|
if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
|
|
2798
|
-
const currentCaretPos = this.telInput.selectionStart || 0;
|
|
2799
|
-
const valueBeforeCaret = this.telInput.value.substring(
|
|
2800
|
-
|
|
2801
|
-
|
|
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;
|
|
2802
2983
|
this._openDropdownWithPlus();
|
|
2803
2984
|
return;
|
|
2804
2985
|
}
|
|
2805
|
-
if (this._updateCountryFromNumber(this.telInput.value)) {
|
|
2986
|
+
if (this._updateCountryFromNumber(this.ui.telInput.value)) {
|
|
2806
2987
|
this._triggerCountryChange();
|
|
2807
2988
|
}
|
|
2808
2989
|
const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
|
|
2809
|
-
const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
|
|
2990
|
+
const isPaste = e?.inputType === "insertFromPaste" && this.ui.telInput.value;
|
|
2810
2991
|
if (isFormattingChar || isPaste && !strictMode) {
|
|
2811
2992
|
userOverrideFormatting = true;
|
|
2812
|
-
} else if (!/[^+0-9]/.test(this.telInput.value)) {
|
|
2993
|
+
} else if (!/[^+0-9]/.test(this.ui.telInput.value)) {
|
|
2813
2994
|
userOverrideFormatting = false;
|
|
2814
2995
|
}
|
|
2815
2996
|
const isSetNumber = e?.detail && e.detail["isSetNumber"];
|
|
2816
2997
|
if (formatAsYouType && !userOverrideFormatting && !isSetNumber) {
|
|
2817
|
-
const currentCaretPos = this.telInput.selectionStart || 0;
|
|
2818
|
-
const valueBeforeCaret = this.telInput.value.substring(
|
|
2819
|
-
|
|
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;
|
|
2820
3007
|
const isDeleteForwards = e?.inputType === "deleteContentForward";
|
|
2821
3008
|
const fullNumber = this._getFullNumber();
|
|
2822
3009
|
const formattedValue = formatNumberAsYouType(
|
|
2823
3010
|
fullNumber,
|
|
2824
|
-
this.telInput.value,
|
|
3011
|
+
this.ui.telInput.value,
|
|
2825
3012
|
intlTelInput.utils,
|
|
2826
3013
|
this.selectedCountryData,
|
|
2827
3014
|
this.options.separateDialCode
|
|
2828
3015
|
);
|
|
2829
|
-
const newCaretPos = translateCursorPosition(
|
|
2830
|
-
|
|
2831
|
-
|
|
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);
|
|
2832
3024
|
}
|
|
2833
3025
|
};
|
|
2834
|
-
this.telInput.addEventListener("input",
|
|
3026
|
+
this.ui.telInput.addEventListener("input", handleInputEvent, {
|
|
3027
|
+
signal: this.abortController.signal
|
|
3028
|
+
});
|
|
2835
3029
|
}
|
|
2836
3030
|
_maybeBindKeydownListener() {
|
|
2837
3031
|
const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.options;
|
|
2838
3032
|
if (strictMode || separateDialCode) {
|
|
2839
|
-
|
|
3033
|
+
const handleKeydownEvent = (e) => {
|
|
2840
3034
|
if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
2841
3035
|
if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
|
|
2842
3036
|
e.preventDefault();
|
|
@@ -2844,14 +3038,17 @@ var factoryOutput = (() => {
|
|
|
2844
3038
|
return;
|
|
2845
3039
|
}
|
|
2846
3040
|
if (strictMode) {
|
|
2847
|
-
const value = this.telInput.value;
|
|
2848
|
-
const alreadyHasPlus = value.
|
|
2849
|
-
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 === "+";
|
|
2850
3044
|
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2851
3045
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2852
|
-
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);
|
|
2853
3047
|
const newFullNumber = this._getFullNumber(newValue);
|
|
2854
|
-
const coreNumber = intlTelInput.utils.getCoreNumber(
|
|
3048
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(
|
|
3049
|
+
newFullNumber,
|
|
3050
|
+
this.selectedCountryData.iso2
|
|
3051
|
+
);
|
|
2855
3052
|
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2856
3053
|
const newCountry = this._getNewCountryFromNumber(newFullNumber);
|
|
2857
3054
|
const isChangingDialCode = newCountry !== null;
|
|
@@ -2861,14 +3058,16 @@ var factoryOutput = (() => {
|
|
|
2861
3058
|
}
|
|
2862
3059
|
}
|
|
2863
3060
|
};
|
|
2864
|
-
this.telInput.addEventListener("keydown",
|
|
3061
|
+
this.ui.telInput.addEventListener("keydown", handleKeydownEvent, {
|
|
3062
|
+
signal: this.abortController.signal
|
|
3063
|
+
});
|
|
2865
3064
|
}
|
|
2866
3065
|
}
|
|
2867
3066
|
_maybeBindPasteListener() {
|
|
2868
3067
|
if (this.options.strictMode) {
|
|
2869
|
-
|
|
3068
|
+
const handlePasteEvent = (e) => {
|
|
2870
3069
|
e.preventDefault();
|
|
2871
|
-
const input = this.telInput;
|
|
3070
|
+
const input = this.ui.telInput;
|
|
2872
3071
|
const selStart = input.selectionStart;
|
|
2873
3072
|
const selEnd = input.selectionEnd;
|
|
2874
3073
|
const before = input.value.slice(0, selStart);
|
|
@@ -2903,82 +3102,95 @@ var factoryOutput = (() => {
|
|
|
2903
3102
|
input.setSelectionRange(caretPos, caretPos);
|
|
2904
3103
|
input.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
2905
3104
|
};
|
|
2906
|
-
this.telInput.addEventListener("paste",
|
|
3105
|
+
this.ui.telInput.addEventListener("paste", handlePasteEvent, {
|
|
3106
|
+
signal: this.abortController.signal
|
|
3107
|
+
});
|
|
2907
3108
|
}
|
|
2908
3109
|
}
|
|
2909
3110
|
//* Adhere to the input's maxlength attr.
|
|
2910
3111
|
_cap(number) {
|
|
2911
|
-
const max =
|
|
3112
|
+
const max = Number(this.ui.telInput.getAttribute("maxlength"));
|
|
2912
3113
|
return max && number.length > max ? number.substring(0, max) : number;
|
|
2913
3114
|
}
|
|
2914
|
-
//* Trigger a custom event on the input.
|
|
3115
|
+
//* Trigger a custom event on the input (typed via ItiEventMap).
|
|
2915
3116
|
_trigger(name, detailProps = {}) {
|
|
2916
3117
|
const e = new CustomEvent(name, {
|
|
2917
3118
|
bubbles: true,
|
|
2918
3119
|
cancelable: true,
|
|
2919
3120
|
detail: detailProps
|
|
2920
3121
|
});
|
|
2921
|
-
this.telInput.dispatchEvent(e);
|
|
3122
|
+
this.ui.telInput.dispatchEvent(e);
|
|
2922
3123
|
}
|
|
2923
3124
|
//* Open the dropdown.
|
|
2924
3125
|
_openDropdown() {
|
|
2925
3126
|
const { fixDropdownWidth, countrySearch } = this.options;
|
|
3127
|
+
this.dropdownAbortController = new AbortController();
|
|
2926
3128
|
if (fixDropdownWidth) {
|
|
2927
|
-
this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
|
|
3129
|
+
this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`;
|
|
2928
3130
|
}
|
|
2929
|
-
this.dropdownContent.classList.remove("iti__hide");
|
|
2930
|
-
this.selectedCountry.setAttribute("aria-expanded", "true");
|
|
3131
|
+
this.ui.dropdownContent.classList.remove("iti__hide");
|
|
3132
|
+
this.ui.selectedCountry.setAttribute("aria-expanded", "true");
|
|
2931
3133
|
this._setDropdownPosition();
|
|
2932
3134
|
if (countrySearch) {
|
|
2933
|
-
const firstCountryItem = this.countryList.firstElementChild;
|
|
3135
|
+
const firstCountryItem = this.ui.countryList.firstElementChild;
|
|
2934
3136
|
if (firstCountryItem) {
|
|
2935
|
-
this.
|
|
2936
|
-
this.countryList.scrollTop = 0;
|
|
3137
|
+
this.ui.highlightListItem(firstCountryItem, false);
|
|
3138
|
+
this.ui.countryList.scrollTop = 0;
|
|
2937
3139
|
}
|
|
2938
|
-
this.searchInput.focus();
|
|
3140
|
+
this.ui.searchInput.focus();
|
|
2939
3141
|
}
|
|
2940
3142
|
this._bindDropdownListeners();
|
|
2941
|
-
this.dropdownArrow.classList.add("iti__arrow--up");
|
|
3143
|
+
this.ui.dropdownArrow.classList.add("iti__arrow--up");
|
|
2942
3144
|
this._trigger("open:countrydropdown");
|
|
2943
3145
|
}
|
|
2944
3146
|
//* Set the dropdown position
|
|
2945
3147
|
_setDropdownPosition() {
|
|
2946
3148
|
if (this.options.dropdownContainer) {
|
|
2947
|
-
this.options.dropdownContainer.appendChild(this.dropdown);
|
|
3149
|
+
this.options.dropdownContainer.appendChild(this.ui.dropdown);
|
|
2948
3150
|
}
|
|
2949
3151
|
if (!this.options.useFullscreenPopup) {
|
|
2950
|
-
const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
|
|
2951
|
-
const inputHeight = this.telInput.offsetHeight;
|
|
3152
|
+
const inputPosRelativeToVP = this.ui.telInput.getBoundingClientRect();
|
|
3153
|
+
const inputHeight = this.ui.telInput.offsetHeight;
|
|
2952
3154
|
if (this.options.dropdownContainer) {
|
|
2953
|
-
this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
|
|
2954
|
-
this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
|
|
2955
|
-
|
|
2956
|
-
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
|
+
});
|
|
2957
3161
|
}
|
|
2958
3162
|
}
|
|
2959
3163
|
}
|
|
2960
3164
|
//* We only bind dropdown listeners when the dropdown is open.
|
|
2961
3165
|
_bindDropdownListeners() {
|
|
2962
|
-
|
|
2963
|
-
|
|
3166
|
+
const signal = this.dropdownAbortController.signal;
|
|
3167
|
+
const handleMouseoverCountryList = (e) => {
|
|
3168
|
+
const listItem = e.target?.closest(
|
|
3169
|
+
".iti__country"
|
|
3170
|
+
);
|
|
2964
3171
|
if (listItem) {
|
|
2965
|
-
this.
|
|
3172
|
+
this.ui.highlightListItem(listItem, false);
|
|
2966
3173
|
}
|
|
2967
3174
|
};
|
|
2968
|
-
this.countryList.addEventListener(
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
)
|
|
2972
|
-
|
|
2973
|
-
|
|
3175
|
+
this.ui.countryList.addEventListener("mouseover", handleMouseoverCountryList, {
|
|
3176
|
+
signal
|
|
3177
|
+
});
|
|
3178
|
+
const handleClickCountryList = (e) => {
|
|
3179
|
+
const listItem = e.target?.closest(
|
|
3180
|
+
".iti__country"
|
|
3181
|
+
);
|
|
2974
3182
|
if (listItem) {
|
|
2975
3183
|
this._selectListItem(listItem);
|
|
2976
3184
|
}
|
|
2977
3185
|
};
|
|
2978
|
-
this.countryList.addEventListener("click",
|
|
2979
|
-
|
|
3186
|
+
this.ui.countryList.addEventListener("click", handleClickCountryList, {
|
|
3187
|
+
signal
|
|
3188
|
+
});
|
|
3189
|
+
const handleClickOffToClose = (e) => {
|
|
2980
3190
|
const target = e.target;
|
|
2981
|
-
const clickedInsideDropdown = !!target.closest(
|
|
3191
|
+
const clickedInsideDropdown = !!target.closest(
|
|
3192
|
+
`#iti-${this.id}__dropdown-content`
|
|
3193
|
+
);
|
|
2982
3194
|
if (!clickedInsideDropdown) {
|
|
2983
3195
|
this._closeDropdown();
|
|
2984
3196
|
}
|
|
@@ -2986,12 +3198,13 @@ var factoryOutput = (() => {
|
|
|
2986
3198
|
setTimeout(() => {
|
|
2987
3199
|
document.documentElement.addEventListener(
|
|
2988
3200
|
"click",
|
|
2989
|
-
|
|
3201
|
+
handleClickOffToClose,
|
|
3202
|
+
{ signal }
|
|
2990
3203
|
);
|
|
2991
3204
|
}, 0);
|
|
2992
3205
|
let query = "";
|
|
2993
3206
|
let queryTimer = null;
|
|
2994
|
-
|
|
3207
|
+
const handleKeydownOnDropdown = (e) => {
|
|
2995
3208
|
if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
|
|
2996
3209
|
e.preventDefault();
|
|
2997
3210
|
e.stopPropagation();
|
|
@@ -3015,19 +3228,19 @@ var factoryOutput = (() => {
|
|
|
3015
3228
|
}, 1e3);
|
|
3016
3229
|
}
|
|
3017
3230
|
};
|
|
3018
|
-
document.addEventListener("keydown",
|
|
3231
|
+
document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
|
|
3019
3232
|
if (this.options.countrySearch) {
|
|
3020
3233
|
const doFilter = () => {
|
|
3021
|
-
const inputQuery = this.searchInput.value.trim();
|
|
3022
|
-
this.
|
|
3023
|
-
if (this.searchInput.value) {
|
|
3024
|
-
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");
|
|
3025
3238
|
} else {
|
|
3026
|
-
this.searchClearButton.classList.add("iti__hide");
|
|
3239
|
+
this.ui.searchClearButton.classList.add("iti__hide");
|
|
3027
3240
|
}
|
|
3028
3241
|
};
|
|
3029
3242
|
let keyupTimer = null;
|
|
3030
|
-
|
|
3243
|
+
const handleSearchChange = () => {
|
|
3031
3244
|
if (keyupTimer) {
|
|
3032
3245
|
clearTimeout(keyupTimer);
|
|
3033
3246
|
}
|
|
@@ -3036,13 +3249,17 @@ var factoryOutput = (() => {
|
|
|
3036
3249
|
keyupTimer = null;
|
|
3037
3250
|
}, 100);
|
|
3038
3251
|
};
|
|
3039
|
-
this.searchInput.addEventListener("input",
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3252
|
+
this.ui.searchInput.addEventListener("input", handleSearchChange, {
|
|
3253
|
+
signal
|
|
3254
|
+
});
|
|
3255
|
+
const handleSearchClear = () => {
|
|
3256
|
+
this.ui.searchInput.value = "";
|
|
3257
|
+
this.ui.searchInput.focus();
|
|
3043
3258
|
doFilter();
|
|
3044
3259
|
};
|
|
3045
|
-
this.searchClearButton.addEventListener("click",
|
|
3260
|
+
this.ui.searchClearButton.addEventListener("click", handleSearchClear, {
|
|
3261
|
+
signal
|
|
3262
|
+
});
|
|
3046
3263
|
}
|
|
3047
3264
|
}
|
|
3048
3265
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
@@ -3051,42 +3268,21 @@ var factoryOutput = (() => {
|
|
|
3051
3268
|
const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
|
|
3052
3269
|
if (startsWith) {
|
|
3053
3270
|
const listItem = c.nodeById[this.id];
|
|
3054
|
-
this.
|
|
3055
|
-
this.
|
|
3271
|
+
this.ui.highlightListItem(listItem, false);
|
|
3272
|
+
this.ui.scrollTo(listItem);
|
|
3056
3273
|
break;
|
|
3057
3274
|
}
|
|
3058
3275
|
}
|
|
3059
3276
|
}
|
|
3060
|
-
//* Country search
|
|
3061
|
-
|
|
3062
|
-
this.countryList.innerHTML = "";
|
|
3277
|
+
//* Country search: Filter the countries according to the search query.
|
|
3278
|
+
_filterCountriesByQuery(query) {
|
|
3063
3279
|
let matchedCountries;
|
|
3064
3280
|
if (query === "") {
|
|
3065
3281
|
matchedCountries = this.countries;
|
|
3066
3282
|
} else {
|
|
3067
3283
|
matchedCountries = this._getMatchedCountries(query);
|
|
3068
3284
|
}
|
|
3069
|
-
|
|
3070
|
-
for (const c of matchedCountries) {
|
|
3071
|
-
const listItem = c.nodeById[this.id];
|
|
3072
|
-
if (listItem) {
|
|
3073
|
-
this.countryList.appendChild(listItem);
|
|
3074
|
-
if (noCountriesAddedYet) {
|
|
3075
|
-
this._highlightListItem(listItem, false);
|
|
3076
|
-
noCountriesAddedYet = false;
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
if (noCountriesAddedYet) {
|
|
3081
|
-
this._highlightListItem(null, false);
|
|
3082
|
-
if (this.searchNoResults) {
|
|
3083
|
-
this.searchNoResults.classList.remove("iti__hide");
|
|
3084
|
-
}
|
|
3085
|
-
} else if (this.searchNoResults) {
|
|
3086
|
-
this.searchNoResults.classList.add("iti__hide");
|
|
3087
|
-
}
|
|
3088
|
-
this.countryList.scrollTop = 0;
|
|
3089
|
-
this._updateSearchResultsA11yText();
|
|
3285
|
+
this.ui.filterCountries(matchedCountries);
|
|
3090
3286
|
}
|
|
3091
3287
|
_getMatchedCountries(query) {
|
|
3092
3288
|
const normalisedQuery = normaliseString(query);
|
|
@@ -3120,39 +3316,21 @@ var factoryOutput = (() => {
|
|
|
3120
3316
|
...initialsMatches.sort((a, b) => a.priority - b.priority)
|
|
3121
3317
|
];
|
|
3122
3318
|
}
|
|
3123
|
-
//* Update search results text (for a11y).
|
|
3124
|
-
_updateSearchResultsA11yText() {
|
|
3125
|
-
const { i18n } = this.options;
|
|
3126
|
-
const count = this.countryList.childElementCount;
|
|
3127
|
-
let searchText;
|
|
3128
|
-
if (count === 0) {
|
|
3129
|
-
searchText = i18n.zeroSearchResults;
|
|
3130
|
-
} else {
|
|
3131
|
-
if (i18n.searchResultsText) {
|
|
3132
|
-
searchText = i18n.searchResultsText(count);
|
|
3133
|
-
} else if (count === 1) {
|
|
3134
|
-
searchText = i18n.oneSearchResult;
|
|
3135
|
-
} else {
|
|
3136
|
-
searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
this.searchResultsA11yText.textContent = searchText;
|
|
3140
|
-
}
|
|
3141
3319
|
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
3142
3320
|
_handleUpDownKey(key) {
|
|
3143
|
-
let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
|
|
3144
|
-
if (!next && this.countryList.childElementCount > 1) {
|
|
3145
|
-
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;
|
|
3146
3324
|
}
|
|
3147
3325
|
if (next) {
|
|
3148
|
-
this.
|
|
3149
|
-
this.
|
|
3326
|
+
this.ui.scrollTo(next);
|
|
3327
|
+
this.ui.highlightListItem(next, false);
|
|
3150
3328
|
}
|
|
3151
3329
|
}
|
|
3152
3330
|
//* Select the currently highlighted item.
|
|
3153
3331
|
_handleEnterKey() {
|
|
3154
|
-
if (this.highlightedItem) {
|
|
3155
|
-
this._selectListItem(this.highlightedItem);
|
|
3332
|
+
if (this.ui.highlightedItem) {
|
|
3333
|
+
this._selectListItem(this.ui.highlightedItem);
|
|
3156
3334
|
}
|
|
3157
3335
|
}
|
|
3158
3336
|
//* Update the input's value to the given val (format first if possible)
|
|
@@ -3160,7 +3338,7 @@ var factoryOutput = (() => {
|
|
|
3160
3338
|
_updateValFromNumber(fullNumber) {
|
|
3161
3339
|
let number = fullNumber;
|
|
3162
3340
|
if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
|
|
3163
|
-
const useNational = this.options.nationalMode || number.
|
|
3341
|
+
const useNational = this.options.nationalMode || !number.startsWith("+") && !this.options.separateDialCode;
|
|
3164
3342
|
const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
|
|
3165
3343
|
const format = useNational ? NATIONAL : INTERNATIONAL;
|
|
3166
3344
|
number = intlTelInput.utils.formatNumber(
|
|
@@ -3170,7 +3348,7 @@ var factoryOutput = (() => {
|
|
|
3170
3348
|
);
|
|
3171
3349
|
}
|
|
3172
3350
|
number = this._beforeSetNumber(number);
|
|
3173
|
-
this.telInput.value = number;
|
|
3351
|
+
this.ui.telInput.value = number;
|
|
3174
3352
|
}
|
|
3175
3353
|
//* Check if need to select a new country based on the given number
|
|
3176
3354
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
@@ -3184,11 +3362,11 @@ var factoryOutput = (() => {
|
|
|
3184
3362
|
// if there is a selected country, and the number doesn't start with a dial code, then add it
|
|
3185
3363
|
_ensureHasDialCode(number) {
|
|
3186
3364
|
const { dialCode, nationalPrefix } = this.selectedCountryData;
|
|
3187
|
-
const alreadyHasPlus = number.
|
|
3365
|
+
const alreadyHasPlus = number.startsWith("+");
|
|
3188
3366
|
if (alreadyHasPlus || !dialCode) {
|
|
3189
3367
|
return number;
|
|
3190
3368
|
}
|
|
3191
|
-
const hasPrefix = nationalPrefix && number.
|
|
3369
|
+
const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.options.separateDialCode;
|
|
3192
3370
|
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
3193
3371
|
return `+${dialCode}${cleanNumber}`;
|
|
3194
3372
|
}
|
|
@@ -3221,7 +3399,9 @@ var factoryOutput = (() => {
|
|
|
3221
3399
|
}
|
|
3222
3400
|
const { areaCodes, priority } = this.selectedCountryData;
|
|
3223
3401
|
if (areaCodes) {
|
|
3224
|
-
const dialCodeAreaCodes = areaCodes.map(
|
|
3402
|
+
const dialCodeAreaCodes = areaCodes.map(
|
|
3403
|
+
(areaCode) => `${selectedDialCode}${areaCode}`
|
|
3404
|
+
);
|
|
3225
3405
|
for (const dialCodeAreaCode of dialCodeAreaCodes) {
|
|
3226
3406
|
if (numeric.startsWith(dialCodeAreaCode)) {
|
|
3227
3407
|
return null;
|
|
@@ -3235,33 +3415,13 @@ var factoryOutput = (() => {
|
|
|
3235
3415
|
if (!isValidSelection && !alreadySelected) {
|
|
3236
3416
|
return iso2Codes[0];
|
|
3237
3417
|
}
|
|
3238
|
-
} else if (number.
|
|
3418
|
+
} else if (number.startsWith("+") && numeric.length) {
|
|
3239
3419
|
return "";
|
|
3240
3420
|
} else if ((!number || number === "+") && !selectedIso2) {
|
|
3241
3421
|
return this.defaultCountry;
|
|
3242
3422
|
}
|
|
3243
3423
|
return null;
|
|
3244
3424
|
}
|
|
3245
|
-
//* Remove highlighting from other list items and highlight the given item.
|
|
3246
|
-
_highlightListItem(listItem, shouldFocus) {
|
|
3247
|
-
const prevItem = this.highlightedItem;
|
|
3248
|
-
if (prevItem) {
|
|
3249
|
-
prevItem.classList.remove("iti__highlight");
|
|
3250
|
-
prevItem.setAttribute("aria-selected", "false");
|
|
3251
|
-
}
|
|
3252
|
-
this.highlightedItem = listItem;
|
|
3253
|
-
if (this.highlightedItem) {
|
|
3254
|
-
this.highlightedItem.classList.add("iti__highlight");
|
|
3255
|
-
this.highlightedItem.setAttribute("aria-selected", "true");
|
|
3256
|
-
if (this.options.countrySearch) {
|
|
3257
|
-
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
3258
|
-
this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
if (shouldFocus) {
|
|
3262
|
-
this.highlightedItem.focus();
|
|
3263
|
-
}
|
|
3264
|
-
}
|
|
3265
3425
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
|
|
3266
3426
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3267
3427
|
_setCountry(iso2) {
|
|
@@ -3271,7 +3431,7 @@ var factoryOutput = (() => {
|
|
|
3271
3431
|
if (this.selectedCountryData.iso2) {
|
|
3272
3432
|
this.defaultCountry = this.selectedCountryData.iso2;
|
|
3273
3433
|
}
|
|
3274
|
-
if (this.selectedCountry) {
|
|
3434
|
+
if (this.ui.selectedCountry) {
|
|
3275
3435
|
const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
|
|
3276
3436
|
let ariaLabel, title;
|
|
3277
3437
|
if (iso2) {
|
|
@@ -3282,28 +3442,19 @@ var factoryOutput = (() => {
|
|
|
3282
3442
|
title = i18n.noCountrySelected;
|
|
3283
3443
|
ariaLabel = i18n.noCountrySelected;
|
|
3284
3444
|
}
|
|
3285
|
-
this.selectedCountryInner.className = flagClass;
|
|
3286
|
-
this.selectedCountry.setAttribute("title", title);
|
|
3287
|
-
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);
|
|
3288
3448
|
}
|
|
3289
3449
|
if (separateDialCode) {
|
|
3290
3450
|
const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
3291
|
-
this.selectedDialCode.
|
|
3292
|
-
this.
|
|
3451
|
+
this.ui.selectedDialCode.textContent = dialCode;
|
|
3452
|
+
this.ui.updateInputPadding();
|
|
3293
3453
|
}
|
|
3294
3454
|
this._updatePlaceholder();
|
|
3295
3455
|
this._updateMaxLength();
|
|
3296
3456
|
return prevIso2 !== iso2;
|
|
3297
3457
|
}
|
|
3298
|
-
//* Update the input padding to make space for the selected country/dial code.
|
|
3299
|
-
_updateInputPadding() {
|
|
3300
|
-
if (this.selectedCountry) {
|
|
3301
|
-
const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
|
|
3302
|
-
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
|
|
3303
|
-
const inputPadding = selectedCountryWidth + 6;
|
|
3304
|
-
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
3458
|
//* Update the maximum valid number length for the currently selected country.
|
|
3308
3459
|
_updateMaxLength() {
|
|
3309
3460
|
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
@@ -3318,7 +3469,11 @@ var factoryOutput = (() => {
|
|
|
3318
3469
|
true
|
|
3319
3470
|
);
|
|
3320
3471
|
let validNumber = exampleNumber;
|
|
3321
|
-
while (intlTelInput.utils.isPossibleNumber(
|
|
3472
|
+
while (intlTelInput.utils.isPossibleNumber(
|
|
3473
|
+
exampleNumber,
|
|
3474
|
+
iso2,
|
|
3475
|
+
validationNumberTypes
|
|
3476
|
+
)) {
|
|
3322
3477
|
validNumber = exampleNumber;
|
|
3323
3478
|
exampleNumber += "0";
|
|
3324
3479
|
}
|
|
@@ -3332,31 +3487,6 @@ var factoryOutput = (() => {
|
|
|
3332
3487
|
}
|
|
3333
3488
|
}
|
|
3334
3489
|
}
|
|
3335
|
-
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
3336
|
-
//* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
|
|
3337
|
-
//* To get the right styling to apply, all we need is a shallow clone of the container,
|
|
3338
|
-
//* and then to inject a deep clone of the selectedCountry element.
|
|
3339
|
-
_getHiddenSelectedCountryWidth() {
|
|
3340
|
-
if (this.telInput.parentNode) {
|
|
3341
|
-
let body;
|
|
3342
|
-
try {
|
|
3343
|
-
body = window.top.document.body;
|
|
3344
|
-
} catch (e) {
|
|
3345
|
-
body = document.body;
|
|
3346
|
-
}
|
|
3347
|
-
const containerClone = this.telInput.parentNode.cloneNode(false);
|
|
3348
|
-
containerClone.style.visibility = "hidden";
|
|
3349
|
-
body.appendChild(containerClone);
|
|
3350
|
-
const countryContainerClone = this.countryContainer.cloneNode();
|
|
3351
|
-
containerClone.appendChild(countryContainerClone);
|
|
3352
|
-
const selectedCountryClone = this.selectedCountry.cloneNode(true);
|
|
3353
|
-
countryContainerClone.appendChild(selectedCountryClone);
|
|
3354
|
-
const width = selectedCountryClone.offsetWidth;
|
|
3355
|
-
body.removeChild(containerClone);
|
|
3356
|
-
return width;
|
|
3357
|
-
}
|
|
3358
|
-
return 0;
|
|
3359
|
-
}
|
|
3360
3490
|
//* Update the input placeholder to an example number from the currently selected country.
|
|
3361
3491
|
_updatePlaceholder() {
|
|
3362
3492
|
const {
|
|
@@ -3365,7 +3495,7 @@ var factoryOutput = (() => {
|
|
|
3365
3495
|
nationalMode,
|
|
3366
3496
|
customPlaceholder
|
|
3367
3497
|
} = this.options;
|
|
3368
|
-
const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
|
|
3498
|
+
const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.ui.hadInitialPlaceholder && autoPlaceholder === "polite";
|
|
3369
3499
|
if (intlTelInput.utils && shouldSetPlaceholder) {
|
|
3370
3500
|
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
3371
3501
|
let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
|
|
@@ -3377,98 +3507,66 @@ var factoryOutput = (() => {
|
|
|
3377
3507
|
if (typeof customPlaceholder === "function") {
|
|
3378
3508
|
placeholder = customPlaceholder(placeholder, this.selectedCountryData);
|
|
3379
3509
|
}
|
|
3380
|
-
this.telInput.setAttribute("placeholder", placeholder);
|
|
3510
|
+
this.ui.telInput.setAttribute("placeholder", placeholder);
|
|
3381
3511
|
}
|
|
3382
3512
|
}
|
|
3383
3513
|
//* Called when the user selects a list item from the dropdown.
|
|
3384
3514
|
_selectListItem(listItem) {
|
|
3385
|
-
const iso2 = listItem.
|
|
3515
|
+
const iso2 = listItem.dataset.countryCode;
|
|
3386
3516
|
const countryChanged = this._setCountry(iso2);
|
|
3387
3517
|
this._closeDropdown();
|
|
3388
|
-
const dialCode = listItem.
|
|
3518
|
+
const dialCode = listItem.dataset.dialCode;
|
|
3389
3519
|
this._updateDialCode(dialCode);
|
|
3390
3520
|
if (this.options.formatOnDisplay) {
|
|
3391
|
-
this._updateValFromNumber(this.telInput.value);
|
|
3521
|
+
this._updateValFromNumber(this.ui.telInput.value);
|
|
3392
3522
|
}
|
|
3393
|
-
this.telInput.focus();
|
|
3523
|
+
this.ui.telInput.focus();
|
|
3394
3524
|
if (countryChanged) {
|
|
3395
3525
|
this._triggerCountryChange();
|
|
3396
3526
|
}
|
|
3397
3527
|
}
|
|
3398
3528
|
//* Close the dropdown and unbind any listeners.
|
|
3399
3529
|
_closeDropdown() {
|
|
3400
|
-
this.dropdownContent.classList.
|
|
3401
|
-
|
|
3402
|
-
if (this.highlightedItem) {
|
|
3403
|
-
this.highlightedItem.setAttribute("aria-selected", "false");
|
|
3530
|
+
if (this.ui.dropdownContent.classList.contains("iti__hide")) {
|
|
3531
|
+
return;
|
|
3404
3532
|
}
|
|
3405
|
-
|
|
3406
|
-
|
|
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");
|
|
3407
3537
|
}
|
|
3408
|
-
this.dropdownArrow.classList.remove("iti__arrow--up");
|
|
3409
3538
|
if (this.options.countrySearch) {
|
|
3410
|
-
this.searchInput.
|
|
3411
|
-
this.searchClearButton.removeEventListener("click", this._handleSearchClear);
|
|
3539
|
+
this.ui.searchInput.removeAttribute("aria-activedescendant");
|
|
3412
3540
|
}
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
this._handleClickOffToClose
|
|
3417
|
-
);
|
|
3418
|
-
this.countryList.removeEventListener(
|
|
3419
|
-
"mouseover",
|
|
3420
|
-
this._handleMouseoverCountryList
|
|
3421
|
-
);
|
|
3422
|
-
this.countryList.removeEventListener("click", this._handleClickCountryList);
|
|
3541
|
+
this.ui.dropdownArrow.classList.remove("iti__arrow--up");
|
|
3542
|
+
this.dropdownAbortController.abort();
|
|
3543
|
+
this.dropdownAbortController = null;
|
|
3423
3544
|
if (this.options.dropdownContainer) {
|
|
3424
|
-
|
|
3425
|
-
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
3426
|
-
}
|
|
3427
|
-
if (this.dropdown.parentNode) {
|
|
3428
|
-
this.dropdown.parentNode.removeChild(this.dropdown);
|
|
3429
|
-
}
|
|
3545
|
+
this.ui.dropdown.remove();
|
|
3430
3546
|
}
|
|
3431
3547
|
this._trigger("close:countrydropdown");
|
|
3432
3548
|
}
|
|
3433
|
-
//* Check if an element is visible within it's container, else scroll until it is.
|
|
3434
|
-
_scrollTo(element) {
|
|
3435
|
-
const container = this.countryList;
|
|
3436
|
-
const scrollTop = document.documentElement.scrollTop;
|
|
3437
|
-
const containerHeight = container.offsetHeight;
|
|
3438
|
-
const containerTop = container.getBoundingClientRect().top + scrollTop;
|
|
3439
|
-
const containerBottom = containerTop + containerHeight;
|
|
3440
|
-
const elementHeight = element.offsetHeight;
|
|
3441
|
-
const elementTop = element.getBoundingClientRect().top + scrollTop;
|
|
3442
|
-
const elementBottom = elementTop + elementHeight;
|
|
3443
|
-
const newScrollTop = elementTop - containerTop + container.scrollTop;
|
|
3444
|
-
if (elementTop < containerTop) {
|
|
3445
|
-
container.scrollTop = newScrollTop;
|
|
3446
|
-
} else if (elementBottom > containerBottom) {
|
|
3447
|
-
const heightDifference = containerHeight - elementHeight;
|
|
3448
|
-
container.scrollTop = newScrollTop - heightDifference;
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
3549
|
//* Replace any existing dial code with the new one
|
|
3452
3550
|
//* Note: called from _selectListItem and setCountry
|
|
3453
3551
|
_updateDialCode(newDialCodeBare) {
|
|
3454
|
-
const inputVal = this.telInput.value;
|
|
3552
|
+
const inputVal = this.ui.telInput.value;
|
|
3455
3553
|
const newDialCode = `+${newDialCodeBare}`;
|
|
3456
3554
|
let newNumber;
|
|
3457
|
-
if (inputVal.
|
|
3555
|
+
if (inputVal.startsWith("+")) {
|
|
3458
3556
|
const prevDialCode = this._getDialCode(inputVal);
|
|
3459
3557
|
if (prevDialCode) {
|
|
3460
3558
|
newNumber = inputVal.replace(prevDialCode, newDialCode);
|
|
3461
3559
|
} else {
|
|
3462
3560
|
newNumber = newDialCode;
|
|
3463
3561
|
}
|
|
3464
|
-
this.telInput.value = newNumber;
|
|
3562
|
+
this.ui.telInput.value = newNumber;
|
|
3465
3563
|
}
|
|
3466
3564
|
}
|
|
3467
3565
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
3468
3566
|
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
3469
3567
|
_getDialCode(number, includeAreaCode) {
|
|
3470
3568
|
let dialCode = "";
|
|
3471
|
-
if (number.
|
|
3569
|
+
if (number.startsWith("+")) {
|
|
3472
3570
|
let numericChars = "";
|
|
3473
3571
|
for (let i = 0; i < number.length; i++) {
|
|
3474
3572
|
const c = number.charAt(i);
|
|
@@ -3494,11 +3592,11 @@ var factoryOutput = (() => {
|
|
|
3494
3592
|
}
|
|
3495
3593
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3496
3594
|
_getFullNumber(overrideVal) {
|
|
3497
|
-
const val = overrideVal || this.telInput.value.trim();
|
|
3595
|
+
const val = overrideVal || this.ui.telInput.value.trim();
|
|
3498
3596
|
const { dialCode } = this.selectedCountryData;
|
|
3499
3597
|
let prefix;
|
|
3500
3598
|
const numericVal = getNumeric(val);
|
|
3501
|
-
if (this.options.separateDialCode && val.
|
|
3599
|
+
if (this.options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
|
|
3502
3600
|
prefix = `+${dialCode}`;
|
|
3503
3601
|
} else {
|
|
3504
3602
|
prefix = "";
|
|
@@ -3527,7 +3625,7 @@ var factoryOutput = (() => {
|
|
|
3527
3625
|
handleAutoCountry() {
|
|
3528
3626
|
if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
|
|
3529
3627
|
this.defaultCountry = intlTelInput.autoCountry;
|
|
3530
|
-
const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
|
|
3628
|
+
const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains("iti__globe");
|
|
3531
3629
|
if (!hasSelectedCountryOrGlobe) {
|
|
3532
3630
|
this.setCountry(this.defaultCountry);
|
|
3533
3631
|
}
|
|
@@ -3537,8 +3635,8 @@ var factoryOutput = (() => {
|
|
|
3537
3635
|
//* This is called when the utils request completes.
|
|
3538
3636
|
handleUtils() {
|
|
3539
3637
|
if (intlTelInput.utils) {
|
|
3540
|
-
if (this.telInput.value) {
|
|
3541
|
-
this._updateValFromNumber(this.telInput.value);
|
|
3638
|
+
if (this.ui.telInput.value) {
|
|
3639
|
+
this._updateValFromNumber(this.ui.telInput.value);
|
|
3542
3640
|
}
|
|
3543
3641
|
if (this.selectedCountryData.iso2) {
|
|
3544
3642
|
this._updatePlaceholder();
|
|
@@ -3552,45 +3650,20 @@ var factoryOutput = (() => {
|
|
|
3552
3650
|
//********************
|
|
3553
3651
|
//* Remove plugin.
|
|
3554
3652
|
destroy() {
|
|
3555
|
-
this.telInput
|
|
3556
|
-
|
|
3557
|
-
if (allowDropdown) {
|
|
3558
|
-
this._closeDropdown();
|
|
3559
|
-
this.selectedCountry.removeEventListener(
|
|
3560
|
-
"click",
|
|
3561
|
-
this._handleClickSelectedCountry
|
|
3562
|
-
);
|
|
3563
|
-
this.countryContainer.removeEventListener(
|
|
3564
|
-
"keydown",
|
|
3565
|
-
this._handleCountryContainerKeydown
|
|
3566
|
-
);
|
|
3567
|
-
const label = this.telInput.closest("label");
|
|
3568
|
-
if (label) {
|
|
3569
|
-
label.removeEventListener("click", this._handleLabelClick);
|
|
3570
|
-
}
|
|
3571
|
-
}
|
|
3572
|
-
const { form } = this.telInput;
|
|
3573
|
-
if (this._handleHiddenInputSubmit && form) {
|
|
3574
|
-
form.removeEventListener("submit", this._handleHiddenInputSubmit);
|
|
3575
|
-
}
|
|
3576
|
-
this.telInput.removeEventListener("input", this._handleInputEvent);
|
|
3577
|
-
if (this._handleKeydownEvent) {
|
|
3578
|
-
this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
|
|
3579
|
-
}
|
|
3580
|
-
if (this._handlePasteEvent) {
|
|
3581
|
-
this.telInput.removeEventListener("paste", this._handlePasteEvent);
|
|
3653
|
+
if (!this.ui.telInput) {
|
|
3654
|
+
return;
|
|
3582
3655
|
}
|
|
3583
|
-
if (this.
|
|
3584
|
-
|
|
3656
|
+
if (this.options.allowDropdown) {
|
|
3657
|
+
this._closeDropdown();
|
|
3585
3658
|
}
|
|
3586
|
-
this.
|
|
3587
|
-
|
|
3588
|
-
|
|
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];
|
|
3589
3666
|
}
|
|
3590
|
-
const wrapper = this.telInput.parentNode;
|
|
3591
|
-
wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
|
|
3592
|
-
wrapper?.parentNode?.removeChild(wrapper);
|
|
3593
|
-
delete intlTelInput.instances[this.id];
|
|
3594
3667
|
}
|
|
3595
3668
|
//* Get the extension from the current number.
|
|
3596
3669
|
getExtension() {
|
|
@@ -3653,7 +3726,11 @@ var factoryOutput = (() => {
|
|
|
3653
3726
|
return this._validateNumber(true);
|
|
3654
3727
|
}
|
|
3655
3728
|
_utilsIsPossibleNumber(val) {
|
|
3656
|
-
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;
|
|
3657
3734
|
}
|
|
3658
3735
|
//* Shared internal validation logic to handle alpha character extension rules.
|
|
3659
3736
|
_validateNumber(precise) {
|
|
@@ -3676,7 +3753,11 @@ var factoryOutput = (() => {
|
|
|
3676
3753
|
return testValidity(val);
|
|
3677
3754
|
}
|
|
3678
3755
|
_utilsIsValidNumber(val) {
|
|
3679
|
-
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;
|
|
3680
3761
|
}
|
|
3681
3762
|
//* Update the selected country, and update the input val accordingly.
|
|
3682
3763
|
setCountry(iso2) {
|
|
@@ -3690,7 +3771,7 @@ var factoryOutput = (() => {
|
|
|
3690
3771
|
this._setCountry(iso2Lower);
|
|
3691
3772
|
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
3692
3773
|
if (this.options.formatOnDisplay) {
|
|
3693
|
-
this._updateValFromNumber(this.telInput.value);
|
|
3774
|
+
this._updateValFromNumber(this.ui.telInput.value);
|
|
3694
3775
|
}
|
|
3695
3776
|
this._triggerCountryChange();
|
|
3696
3777
|
}
|
|
@@ -3710,11 +3791,11 @@ var factoryOutput = (() => {
|
|
|
3710
3791
|
this._updatePlaceholder();
|
|
3711
3792
|
}
|
|
3712
3793
|
setDisabled(disabled) {
|
|
3713
|
-
this.telInput.disabled = disabled;
|
|
3794
|
+
this.ui.telInput.disabled = disabled;
|
|
3714
3795
|
if (disabled) {
|
|
3715
|
-
this.selectedCountry.setAttribute("disabled", "true");
|
|
3796
|
+
this.ui.selectedCountry.setAttribute("disabled", "true");
|
|
3716
3797
|
} else {
|
|
3717
|
-
this.selectedCountry.removeAttribute("disabled");
|
|
3798
|
+
this.ui.selectedCountry.removeAttribute("disabled");
|
|
3718
3799
|
}
|
|
3719
3800
|
}
|
|
3720
3801
|
};
|
|
@@ -3728,13 +3809,19 @@ var factoryOutput = (() => {
|
|
|
3728
3809
|
return Promise.reject(error);
|
|
3729
3810
|
}
|
|
3730
3811
|
} else {
|
|
3731
|
-
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
|
+
);
|
|
3732
3817
|
}
|
|
3733
3818
|
intlTelInput.startedLoadingUtilsScript = true;
|
|
3734
3819
|
return loadCall.then((module) => {
|
|
3735
3820
|
const utils2 = module?.default;
|
|
3736
3821
|
if (!utils2 || typeof utils2 !== "object") {
|
|
3737
|
-
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
|
+
);
|
|
3738
3825
|
}
|
|
3739
3826
|
intlTelInput.utils = utils2;
|
|
3740
3827
|
forEachInstance("handleUtils");
|
|
@@ -3746,11 +3833,17 @@ var factoryOutput = (() => {
|
|
|
3746
3833
|
}
|
|
3747
3834
|
return null;
|
|
3748
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
|
+
};
|
|
3749
3844
|
var intlTelInput = Object.assign(
|
|
3750
3845
|
(input, options) => {
|
|
3751
3846
|
const iti = new Iti(input, options);
|
|
3752
|
-
iti._init();
|
|
3753
|
-
input.setAttribute("data-intl-tel-input-id", iti.id.toString());
|
|
3754
3847
|
intlTelInput.instances[iti.id] = iti;
|
|
3755
3848
|
input.iti = iti;
|
|
3756
3849
|
return iti;
|
|
@@ -3763,7 +3856,7 @@ var factoryOutput = (() => {
|
|
|
3763
3856
|
getCountryData: () => data_default,
|
|
3764
3857
|
//* A getter for the plugin instance.
|
|
3765
3858
|
getInstance: (input) => {
|
|
3766
|
-
const id2 = input.
|
|
3859
|
+
const id2 = input.dataset.intlTelInputId;
|
|
3767
3860
|
return id2 ? intlTelInput.instances[id2] : null;
|
|
3768
3861
|
},
|
|
3769
3862
|
//* A map from instance ID to instance object.
|
|
@@ -3771,7 +3864,7 @@ var factoryOutput = (() => {
|
|
|
3771
3864
|
attachUtils,
|
|
3772
3865
|
startedLoadingUtilsScript: false,
|
|
3773
3866
|
startedLoadingAutoCountry: false,
|
|
3774
|
-
version: "25.
|
|
3867
|
+
version: "25.11.0"
|
|
3775
3868
|
}
|
|
3776
3869
|
);
|
|
3777
3870
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -6881,7 +6974,7 @@ var factoryOutput = (() => {
|
|
|
6881
6974
|
,
|
|
6882
6975
|
,
|
|
6883
6976
|
[7, 8, 9]
|
|
6884
|
-
], [, , "(?: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]]],
|
|
6885
6978
|
KG: [, [
|
|
6886
6979
|
,
|
|
6887
6980
|
,
|
|
@@ -8937,7 +9030,7 @@ var factoryOutput = (() => {
|
|
|
8937
9030
|
,
|
|
8938
9031
|
,
|
|
8939
9032
|
[5, 6, 7]
|
|
8940
|
-
], [, , "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]]],
|
|
8941
9034
|
US: [, [
|
|
8942
9035
|
,
|
|
8943
9036
|
,
|
|
@@ -8953,7 +9046,7 @@ var factoryOutput = (() => {
|
|
|
8953
9046
|
], [
|
|
8954
9047
|
,
|
|
8955
9048
|
,
|
|
8956
|
-
"
|
|
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}",
|
|
8957
9050
|
,
|
|
8958
9051
|
,
|
|
8959
9052
|
,
|
|
@@ -8965,7 +9058,7 @@ var factoryOutput = (() => {
|
|
|
8965
9058
|
], [
|
|
8966
9059
|
,
|
|
8967
9060
|
,
|
|
8968
|
-
"
|
|
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}",
|
|
8969
9062
|
,
|
|
8970
9063
|
,
|
|
8971
9064
|
,
|