intl-tel-input 27.3.1 → 28.0.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/dist/css/intlTelInput-no-assets.css +2 -2
- package/dist/css/intlTelInput.css +3 -3
- package/dist/js/data.js +2 -2
- package/dist/js/data.min.js +1 -1
- package/dist/js/data.mjs +1 -1
- package/dist/js/i18n.d.ts +1 -1592
- package/dist/js/intlTelInput.d.ts +61 -45
- package/dist/js/intlTelInput.js +109 -104
- package/dist/js/intlTelInput.min.js +6 -6
- package/dist/js/intlTelInput.mjs +107 -102
- package/dist/js/intlTelInputWithUtils.js +510 -490
- package/dist/js/intlTelInputWithUtils.min.js +9 -9
- package/dist/js/intlTelInputWithUtils.mjs +508 -488
- package/dist/js/utils.js +56 -55
- package/package.json +14 -181
- package/CHANGELOG.md +0 -33
- package/angular/README.md +0 -13
- package/angular/dist/IntlTelInput.d.ts +0 -110
- package/angular/dist/IntlTelInput.js +0 -5130
- package/angular/dist/IntlTelInputWithUtils.d.ts +0 -3
- package/angular/dist/IntlTelInputWithUtils.js +0 -11469
- package/react/README.md +0 -13
- package/react/dist/IntlTelInput.d.ts +0 -25
- package/react/dist/IntlTelInput.js +0 -4822
- package/react/dist/IntlTelInputWithUtils.d.ts +0 -4
- package/react/dist/IntlTelInputWithUtils.js +0 -11161
- package/svelte/README.md +0 -14
- package/svelte/src/IntlTelInput.svelte +0 -233
- package/svelte/src/IntlTelInput.svelte.d.ts +0 -36
- package/svelte/src/IntlTelInputWithUtils.svelte +0 -24
- package/vue/README.md +0 -14
- package/vue/dist/IntlTelInput-DWpqqgvZ.js +0 -2684
- package/vue/dist/IntlTelInput.js +0 -5
- package/vue/dist/IntlTelInput.vue.d.ts +0 -43
- package/vue/dist/IntlTelInputWithUtils.js +0 -49403
- package/vue/dist/index.d.ts +0 -4
- package/vue/dist/indexWithUtils.d.ts +0 -3
package/dist/js/intlTelInput.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/js/data.ts
|
|
1
|
+
// packages/core/src/js/data.ts
|
|
2
2
|
var rawCountryData = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
@@ -1750,7 +1750,7 @@ var iso2Set = new Set(allCountries.map((c) => c.iso2));
|
|
|
1750
1750
|
var isIso2 = (val) => iso2Set.has(val);
|
|
1751
1751
|
var data_default = allCountries;
|
|
1752
1752
|
|
|
1753
|
-
// src/js/constants.ts
|
|
1753
|
+
// packages/core/src/js/constants.ts
|
|
1754
1754
|
var EVENTS = {
|
|
1755
1755
|
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
1756
1756
|
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
|
|
@@ -1796,10 +1796,6 @@ var TIMINGS = {
|
|
|
1796
1796
|
HIDDEN_SEARCH_RESET_MS: 1e3,
|
|
1797
1797
|
NEXT_TICK: 0
|
|
1798
1798
|
};
|
|
1799
|
-
var SENTINELS = {
|
|
1800
|
-
UNKNOWN_NUMBER_TYPE: -99,
|
|
1801
|
-
UNKNOWN_VALIDATION_ERROR: -99
|
|
1802
|
-
};
|
|
1803
1799
|
var LAYOUT = {
|
|
1804
1800
|
NARROW_VIEWPORT_WIDTH: 500,
|
|
1805
1801
|
// keep in sync with .iti__country-list CSS media query
|
|
@@ -1841,6 +1837,12 @@ var PLACEHOLDER_MODES = {
|
|
|
1841
1837
|
var INITIAL_COUNTRY = {
|
|
1842
1838
|
AUTO: "auto"
|
|
1843
1839
|
};
|
|
1840
|
+
var NUMBER_FORMATS = [
|
|
1841
|
+
"E164",
|
|
1842
|
+
"INTERNATIONAL",
|
|
1843
|
+
"NATIONAL",
|
|
1844
|
+
"RFC3966"
|
|
1845
|
+
];
|
|
1844
1846
|
var NUMBER_TYPES = [
|
|
1845
1847
|
"FIXED_LINE",
|
|
1846
1848
|
"MOBILE",
|
|
@@ -1855,11 +1857,21 @@ var NUMBER_TYPES = [
|
|
|
1855
1857
|
"VOICEMAIL",
|
|
1856
1858
|
"UNKNOWN"
|
|
1857
1859
|
];
|
|
1858
|
-
var
|
|
1860
|
+
var VALIDATION_ERRORS = [
|
|
1861
|
+
"IS_POSSIBLE",
|
|
1862
|
+
"INVALID_COUNTRY_CODE",
|
|
1863
|
+
"TOO_SHORT",
|
|
1864
|
+
"TOO_LONG",
|
|
1865
|
+
"IS_POSSIBLE_LOCAL_ONLY",
|
|
1866
|
+
"INVALID_LENGTH"
|
|
1867
|
+
];
|
|
1868
|
+
var toEnumObject = (arr) => Object.fromEntries(arr.map((v) => [v, v]));
|
|
1869
|
+
var NUMBER_FORMAT = toEnumObject(NUMBER_FORMATS);
|
|
1870
|
+
var NUMBER_TYPE = toEnumObject(NUMBER_TYPES);
|
|
1871
|
+
var VALIDATION_ERROR = toEnumObject(VALIDATION_ERRORS);
|
|
1859
1872
|
var DATA_KEYS = {
|
|
1860
|
-
// e.g. <li data-
|
|
1861
|
-
|
|
1862
|
-
ISO2: "countryCode",
|
|
1873
|
+
// e.g. <li data-iso2="us"> for country items in dropdown
|
|
1874
|
+
ISO2: "iso2",
|
|
1863
1875
|
DIAL_CODE: "dialCode",
|
|
1864
1876
|
// e.g. <input data-intl-tel-input-id="0"> on the input element
|
|
1865
1877
|
INSTANCE_ID: "intlTelInputId"
|
|
@@ -1876,7 +1888,7 @@ var ARIA = {
|
|
|
1876
1888
|
MODAL: "aria-modal"
|
|
1877
1889
|
};
|
|
1878
1890
|
|
|
1879
|
-
// src/js/i18n/en.ts
|
|
1891
|
+
// packages/core/src/js/i18n/en.ts
|
|
1880
1892
|
var interfaceTranslations = {
|
|
1881
1893
|
selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
|
|
1882
1894
|
noCountrySelected: "Select country for phone number",
|
|
@@ -1896,7 +1908,7 @@ var interfaceTranslations = {
|
|
|
1896
1908
|
};
|
|
1897
1909
|
var en_default = interfaceTranslations;
|
|
1898
1910
|
|
|
1899
|
-
// src/js/core/options.ts
|
|
1911
|
+
// packages/core/src/js/core/options.ts
|
|
1900
1912
|
var mediaQuery = (q) => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
|
|
1901
1913
|
var isNarrowViewport = () => mediaQuery(`(max-width: ${LAYOUT.NARROW_VIEWPORT_WIDTH}px)`);
|
|
1902
1914
|
var computeDefaultUseFullscreenPopup = () => {
|
|
@@ -1911,7 +1923,7 @@ var defaults = {
|
|
|
1911
1923
|
//* Whether or not to allow the dropdown.
|
|
1912
1924
|
allowDropdown: true,
|
|
1913
1925
|
//* The number type to enforce during validation.
|
|
1914
|
-
allowedNumberTypes: [
|
|
1926
|
+
allowedNumberTypes: [NUMBER_TYPE.MOBILE, NUMBER_TYPE.FIXED_LINE],
|
|
1915
1927
|
//* Whether or not to allow extensions after the main number.
|
|
1916
1928
|
allowNumberExtensions: false,
|
|
1917
1929
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
@@ -1922,6 +1934,8 @@ var defaults = {
|
|
|
1922
1934
|
containerClass: "",
|
|
1923
1935
|
//* Locale for localising country names via Intl.DisplayNames.
|
|
1924
1936
|
countryNameLocale: "en",
|
|
1937
|
+
//* Override individual country names by iso2 code.
|
|
1938
|
+
countryNameOverrides: {},
|
|
1925
1939
|
//* The order of the countries in the dropdown. Defaults to alphabetical.
|
|
1926
1940
|
countryOrder: null,
|
|
1927
1941
|
//* Add a country search input at the top of the dropdown.
|
|
@@ -1955,17 +1969,17 @@ var defaults = {
|
|
|
1955
1969
|
//* Display only these countries.
|
|
1956
1970
|
onlyCountries: null,
|
|
1957
1971
|
//* Number type to use for placeholders.
|
|
1958
|
-
placeholderNumberType:
|
|
1972
|
+
placeholderNumberType: NUMBER_TYPE.MOBILE,
|
|
1959
1973
|
//* Add custom classes to the search input element.
|
|
1960
1974
|
searchInputClass: "",
|
|
1961
1975
|
//* Display the international dial code next to the selected flag.
|
|
1962
|
-
separateDialCode:
|
|
1976
|
+
separateDialCode: true,
|
|
1963
1977
|
//* When strictMode rejects a key (etc), play a short feedback animation
|
|
1964
|
-
strictRejectAnimation:
|
|
1978
|
+
strictRejectAnimation: true,
|
|
1965
1979
|
//* Show flags - for both the selected country, and in the country dropdown
|
|
1966
1980
|
showFlags: true,
|
|
1967
1981
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1968
|
-
strictMode:
|
|
1982
|
+
strictMode: true,
|
|
1969
1983
|
//* Use full screen popup instead of dropdown for country list.
|
|
1970
1984
|
useFullscreenPopup: computeDefaultUseFullscreenPopup()
|
|
1971
1985
|
};
|
|
@@ -2109,6 +2123,13 @@ var validateOptions = (customOptions) => {
|
|
|
2109
2123
|
}
|
|
2110
2124
|
validatedOptions[key] = value;
|
|
2111
2125
|
break;
|
|
2126
|
+
case "countryNameOverrides":
|
|
2127
|
+
if (value && !isPlainObject(value)) {
|
|
2128
|
+
warnOption("countryNameOverrides", "an object", value);
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
2131
|
+
validatedOptions[key] = value;
|
|
2132
|
+
break;
|
|
2112
2133
|
case "initialCountry": {
|
|
2113
2134
|
if (typeof value !== "string") {
|
|
2114
2135
|
warnOption("initialCountry", "a string", value);
|
|
@@ -2127,8 +2148,8 @@ var validateOptions = (customOptions) => {
|
|
|
2127
2148
|
break;
|
|
2128
2149
|
}
|
|
2129
2150
|
case "placeholderNumberType":
|
|
2130
|
-
if (typeof value !== "string" || !
|
|
2131
|
-
const validTypes =
|
|
2151
|
+
if (typeof value !== "string" || !NUMBER_TYPES.includes(value)) {
|
|
2152
|
+
const validTypes = NUMBER_TYPES.join(", ");
|
|
2132
2153
|
warnOption("placeholderNumberType", `one of ${validTypes}`, value);
|
|
2133
2154
|
break;
|
|
2134
2155
|
}
|
|
@@ -2146,8 +2167,8 @@ var validateOptions = (customOptions) => {
|
|
|
2146
2167
|
}
|
|
2147
2168
|
let allValid = true;
|
|
2148
2169
|
for (const v of value) {
|
|
2149
|
-
if (typeof v !== "string" || !
|
|
2150
|
-
const validTypes =
|
|
2170
|
+
if (typeof v !== "string" || !NUMBER_TYPES.includes(v)) {
|
|
2171
|
+
const validTypes = NUMBER_TYPES.join(", ");
|
|
2151
2172
|
warnOption(
|
|
2152
2173
|
"allowedNumberTypes",
|
|
2153
2174
|
`an array of valid number types (${validTypes})`,
|
|
@@ -2209,11 +2230,11 @@ var applyOptionSideEffects = (o) => {
|
|
|
2209
2230
|
o.i18n = { ...en_default, ...o.i18n };
|
|
2210
2231
|
};
|
|
2211
2232
|
|
|
2212
|
-
// src/js/helpers/string.ts
|
|
2233
|
+
// packages/core/src/js/helpers/string.ts
|
|
2213
2234
|
var getNumeric = (s) => s.replace(/\D/g, "");
|
|
2214
2235
|
var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
2215
2236
|
|
|
2216
|
-
// src/js/helpers/dom.ts
|
|
2237
|
+
// packages/core/src/js/helpers/dom.ts
|
|
2217
2238
|
var buildClassNames = (flags) => Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
|
|
2218
2239
|
var createEl = (tagName, attrs, container) => {
|
|
2219
2240
|
const el = document.createElement(tagName);
|
|
@@ -2228,7 +2249,7 @@ var createEl = (tagName, attrs, container) => {
|
|
|
2228
2249
|
return el;
|
|
2229
2250
|
};
|
|
2230
2251
|
|
|
2231
|
-
// src/js/core/icons.ts
|
|
2252
|
+
// packages/core/src/js/core/icons.ts
|
|
2232
2253
|
var buildSearchIcon = () => `
|
|
2233
2254
|
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${ARIA.HIDDEN}="true">
|
|
2234
2255
|
<circle cx="11" cy="11" r="7" />
|
|
@@ -2255,7 +2276,7 @@ var buildGlobeIcon = () => `
|
|
|
2255
2276
|
<path d="m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40"/>
|
|
2256
2277
|
</svg>`;
|
|
2257
2278
|
|
|
2258
|
-
// src/js/core/countrySearch.ts
|
|
2279
|
+
// packages/core/src/js/core/countrySearch.ts
|
|
2259
2280
|
var buildSearchTokens = (countries) => {
|
|
2260
2281
|
const tokens = /* @__PURE__ */ new Map();
|
|
2261
2282
|
for (const c of countries) {
|
|
@@ -2315,7 +2336,7 @@ var findFirstCountryStartingWith = (countries, searchTokens, query) => {
|
|
|
2315
2336
|
return null;
|
|
2316
2337
|
};
|
|
2317
2338
|
|
|
2318
|
-
// src/js/core/numerals.ts
|
|
2339
|
+
// packages/core/src/js/core/numerals.ts
|
|
2319
2340
|
var Numerals = class _Numerals {
|
|
2320
2341
|
#userNumeralSet;
|
|
2321
2342
|
//* Stateless conversion of any Arabic-Indic / Persian digits to ASCII 0-9.
|
|
@@ -2373,7 +2394,7 @@ var Numerals = class _Numerals {
|
|
|
2373
2394
|
}
|
|
2374
2395
|
};
|
|
2375
2396
|
|
|
2376
|
-
// src/js/core/ui.ts
|
|
2397
|
+
// packages/core/src/js/core/ui.ts
|
|
2377
2398
|
var UI = class _UI {
|
|
2378
2399
|
// private
|
|
2379
2400
|
#options;
|
|
@@ -3126,7 +3147,7 @@ var UI = class _UI {
|
|
|
3126
3147
|
}
|
|
3127
3148
|
if (iso2 && !this.#selectedListItemEl) {
|
|
3128
3149
|
const newListItem = this.#countryListEl.querySelector(
|
|
3129
|
-
`[data-
|
|
3150
|
+
`[data-iso2="${iso2}"]`
|
|
3130
3151
|
);
|
|
3131
3152
|
if (newListItem) {
|
|
3132
3153
|
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
@@ -3314,7 +3335,7 @@ var UI = class _UI {
|
|
|
3314
3335
|
}
|
|
3315
3336
|
};
|
|
3316
3337
|
|
|
3317
|
-
// src/js/data/country-data.ts
|
|
3338
|
+
// packages/core/src/js/data/country-data.ts
|
|
3318
3339
|
var processAllCountries = (options) => {
|
|
3319
3340
|
const { onlyCountries, excludeCountries } = options;
|
|
3320
3341
|
if (onlyCountries?.length) {
|
|
@@ -3329,7 +3350,7 @@ var processAllCountries = (options) => {
|
|
|
3329
3350
|
return [...data_default];
|
|
3330
3351
|
};
|
|
3331
3352
|
var generateCountryNames = (countries, options) => {
|
|
3332
|
-
const { countryNameLocale,
|
|
3353
|
+
const { countryNameLocale, countryNameOverrides } = options;
|
|
3333
3354
|
let displayNames;
|
|
3334
3355
|
try {
|
|
3335
3356
|
const hasDisplayNames = typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function";
|
|
@@ -3345,7 +3366,7 @@ var generateCountryNames = (countries, options) => {
|
|
|
3345
3366
|
displayNames = null;
|
|
3346
3367
|
}
|
|
3347
3368
|
for (const c of countries) {
|
|
3348
|
-
c.name =
|
|
3369
|
+
c.name = countryNameOverrides[c.iso2] || displayNames?.of(c.iso2.toUpperCase()) || "";
|
|
3349
3370
|
}
|
|
3350
3371
|
};
|
|
3351
3372
|
var processDialCodes = (countries) => {
|
|
@@ -3414,7 +3435,7 @@ var sortCountries = (countries, options) => {
|
|
|
3414
3435
|
});
|
|
3415
3436
|
};
|
|
3416
3437
|
|
|
3417
|
-
// src/js/data/intl-regionless.ts
|
|
3438
|
+
// packages/core/src/js/data/intl-regionless.ts
|
|
3418
3439
|
var regionlessDialCodes = /* @__PURE__ */ new Set([
|
|
3419
3440
|
"800",
|
|
3420
3441
|
"808",
|
|
@@ -3430,7 +3451,7 @@ var hasRegionlessDialCode = (number) => {
|
|
|
3430
3451
|
return number.startsWith("+") && regionlessDialCodes.has(dialCode);
|
|
3431
3452
|
};
|
|
3432
3453
|
|
|
3433
|
-
// src/js/format/formatting.ts
|
|
3454
|
+
// packages/core/src/js/format/formatting.ts
|
|
3434
3455
|
var stripSeparateDialCode = (fullNumber, hasValidDialCode, separateDialCode, selectedCountryData) => {
|
|
3435
3456
|
if (!separateDialCode || !hasValidDialCode) {
|
|
3436
3457
|
return fullNumber;
|
|
@@ -3449,7 +3470,7 @@ var formatNumberAsYouType = (fullNumber, telInputValue, utils, selectedCountryDa
|
|
|
3449
3470
|
return result;
|
|
3450
3471
|
};
|
|
3451
3472
|
|
|
3452
|
-
// src/js/format/caret.ts
|
|
3473
|
+
// packages/core/src/js/format/caret.ts
|
|
3453
3474
|
var computeNewCaretPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => {
|
|
3454
3475
|
if (prevCaretPos === 0 && !isDeleteForwards) {
|
|
3455
3476
|
return 0;
|
|
@@ -3469,7 +3490,7 @@ var computeNewCaretPosition = (relevantChars, formattedValue, prevCaretPos, isDe
|
|
|
3469
3490
|
return formattedValue.length;
|
|
3470
3491
|
};
|
|
3471
3492
|
|
|
3472
|
-
// src/js/data/nanp-regionless.ts
|
|
3493
|
+
// packages/core/src/js/data/nanp-regionless.ts
|
|
3473
3494
|
var regionlessNanpAreaCodes = /* @__PURE__ */ new Set([
|
|
3474
3495
|
"800",
|
|
3475
3496
|
"822",
|
|
@@ -3498,7 +3519,7 @@ var isRegionlessNanp = (number) => {
|
|
|
3498
3519
|
return false;
|
|
3499
3520
|
};
|
|
3500
3521
|
|
|
3501
|
-
// src/js/intlTelInput.ts
|
|
3522
|
+
// packages/core/src/js/intlTelInput.ts
|
|
3502
3523
|
var nextId = 0;
|
|
3503
3524
|
var ensureUtils = (methodName) => {
|
|
3504
3525
|
if (!intlTelInput.utils) {
|
|
@@ -3665,7 +3686,7 @@ var Iti = class _Iti {
|
|
|
3665
3686
|
if (this.#utilsDeferred) {
|
|
3666
3687
|
const { loadUtils } = this.#options;
|
|
3667
3688
|
const doAttachUtils = () => {
|
|
3668
|
-
intlTelInput.attachUtils(loadUtils)
|
|
3689
|
+
intlTelInput.attachUtils(loadUtils).catch(() => {
|
|
3669
3690
|
});
|
|
3670
3691
|
};
|
|
3671
3692
|
if (intlTelInput.documentReady()) {
|
|
@@ -3685,7 +3706,7 @@ var Iti = class _Iti {
|
|
|
3685
3706
|
}
|
|
3686
3707
|
}
|
|
3687
3708
|
//* Perform the geo ip lookup.
|
|
3688
|
-
#loadAutoCountry() {
|
|
3709
|
+
async #loadAutoCountry() {
|
|
3689
3710
|
if (intlTelInput.autoCountry) {
|
|
3690
3711
|
this.#handleAutoCountryLoaded();
|
|
3691
3712
|
return;
|
|
@@ -3696,19 +3717,18 @@ var Iti = class _Iti {
|
|
|
3696
3717
|
}
|
|
3697
3718
|
intlTelInput.startedLoadingAutoCountry = true;
|
|
3698
3719
|
if (typeof this.#options.geoIpLookup === "function") {
|
|
3699
|
-
|
|
3700
|
-
const
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
setTimeout(() => _Iti.forEachInstance("handleAutoCountryLoaded"));
|
|
3704
|
-
} else {
|
|
3720
|
+
try {
|
|
3721
|
+
const iso2 = await this.#options.geoIpLookup();
|
|
3722
|
+
const iso2Lower = typeof iso2 === "string" ? iso2.toLowerCase() : "";
|
|
3723
|
+
if (!isIso2(iso2Lower)) {
|
|
3705
3724
|
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3725
|
+
return;
|
|
3706
3726
|
}
|
|
3707
|
-
|
|
3708
|
-
|
|
3727
|
+
intlTelInput.autoCountry = iso2Lower;
|
|
3728
|
+
setTimeout(() => _Iti.forEachInstance("handleAutoCountryLoaded"));
|
|
3729
|
+
} catch {
|
|
3709
3730
|
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3710
|
-
}
|
|
3711
|
-
this.#options.geoIpLookup(successCallback, failureCallback);
|
|
3731
|
+
}
|
|
3712
3732
|
}
|
|
3713
3733
|
}
|
|
3714
3734
|
#openDropdownWithPlus() {
|
|
@@ -4023,8 +4043,7 @@ var Iti = class _Iti {
|
|
|
4023
4043
|
if (formatOnDisplay && intlTelInput.utils && this.#selectedCountry) {
|
|
4024
4044
|
const isRegionless = hasRegionlessDialCode(fullNumber);
|
|
4025
4045
|
const useNational = nationalMode && !isRegionless || !number.startsWith("+") && !separateDialCode;
|
|
4026
|
-
const
|
|
4027
|
-
const format = useNational ? NATIONAL : INTERNATIONAL;
|
|
4046
|
+
const format = useNational ? NUMBER_FORMAT.NATIONAL : NUMBER_FORMAT.INTERNATIONAL;
|
|
4028
4047
|
number = intlTelInput.utils.formatNumber(
|
|
4029
4048
|
number,
|
|
4030
4049
|
this.#selectedCountry?.iso2,
|
|
@@ -4144,11 +4163,10 @@ var Iti = class _Iti {
|
|
|
4144
4163
|
this.#maxCoreNumberLength = null;
|
|
4145
4164
|
return;
|
|
4146
4165
|
}
|
|
4147
|
-
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
4148
4166
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
4149
4167
|
iso2,
|
|
4150
4168
|
false,
|
|
4151
|
-
|
|
4169
|
+
placeholderNumberType,
|
|
4152
4170
|
true
|
|
4153
4171
|
);
|
|
4154
4172
|
let validNumber = exampleNumber;
|
|
@@ -4178,11 +4196,10 @@ var Iti = class _Iti {
|
|
|
4178
4196
|
if (!intlTelInput.utils || !shouldSetPlaceholder) {
|
|
4179
4197
|
return;
|
|
4180
4198
|
}
|
|
4181
|
-
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
4182
4199
|
let placeholder = this.#selectedCountry ? intlTelInput.utils.getExampleNumber(
|
|
4183
4200
|
this.#selectedCountry.iso2,
|
|
4184
4201
|
nationalMode,
|
|
4185
|
-
|
|
4202
|
+
placeholderNumberType
|
|
4186
4203
|
) : "";
|
|
4187
4204
|
placeholder = this.#prepareNumberForInput(placeholder);
|
|
4188
4205
|
if (typeof customPlaceholder === "function") {
|
|
@@ -4292,19 +4309,9 @@ var Iti = class _Iti {
|
|
|
4292
4309
|
);
|
|
4293
4310
|
return this.#truncateToMaxLength(number);
|
|
4294
4311
|
}
|
|
4295
|
-
//* Return only the public-facing subset of the selected country data.
|
|
4296
|
-
#getPublicCountryData() {
|
|
4297
|
-
const d = this.#selectedCountry;
|
|
4298
|
-
if (!d) {
|
|
4299
|
-
return null;
|
|
4300
|
-
}
|
|
4301
|
-
const { iso2, dialCode, name } = d;
|
|
4302
|
-
return { iso2, dialCode, name };
|
|
4303
|
-
}
|
|
4304
4312
|
//* Dispatch the 'countrychange' event.
|
|
4305
4313
|
#dispatchCountryChangeEvent() {
|
|
4306
|
-
|
|
4307
|
-
this.#dispatchEvent(EVENTS.COUNTRY_CHANGE, countryData);
|
|
4314
|
+
this.#dispatchEvent(EVENTS.COUNTRY_CHANGE, this.#selectedCountry ?? null);
|
|
4308
4315
|
}
|
|
4309
4316
|
//**************************
|
|
4310
4317
|
//* INTERNAL METHODS
|
|
@@ -4395,7 +4402,7 @@ var Iti = class _Iti {
|
|
|
4395
4402
|
this.#selectedCountry?.iso2
|
|
4396
4403
|
);
|
|
4397
4404
|
}
|
|
4398
|
-
//* Format the number to the given format.
|
|
4405
|
+
//* Format the number to the given format (defaults to "E164").
|
|
4399
4406
|
getNumber(format) {
|
|
4400
4407
|
if (!this.#isActive) {
|
|
4401
4408
|
return "";
|
|
@@ -4410,10 +4417,10 @@ var Iti = class _Iti {
|
|
|
4410
4417
|
);
|
|
4411
4418
|
return this.#numerals.denormalise(formattedNumber);
|
|
4412
4419
|
}
|
|
4413
|
-
//* Get the type of the entered number e.g.
|
|
4420
|
+
//* Get the type of the entered number e.g. "FIXED_LINE" / "MOBILE", or null if it can't be determined / instance is destroyed.
|
|
4414
4421
|
getNumberType() {
|
|
4415
4422
|
if (!this.#isActive) {
|
|
4416
|
-
return
|
|
4423
|
+
return null;
|
|
4417
4424
|
}
|
|
4418
4425
|
ensureUtils("getNumberType");
|
|
4419
4426
|
return intlTelInput.utils.getNumberType(
|
|
@@ -4423,12 +4430,12 @@ var Iti = class _Iti {
|
|
|
4423
4430
|
}
|
|
4424
4431
|
//* Get the country data for the currently selected country.
|
|
4425
4432
|
getSelectedCountryData() {
|
|
4426
|
-
return this.#
|
|
4433
|
+
return this.#selectedCountry ?? null;
|
|
4427
4434
|
}
|
|
4428
|
-
//* Get the validation error.
|
|
4435
|
+
//* Get the validation error e.g. "TOO_SHORT" / "TOO_LONG", or null if it can't be determined / instance is destroyed.
|
|
4429
4436
|
getValidationError() {
|
|
4430
4437
|
if (!this.#isActive) {
|
|
4431
|
-
return
|
|
4438
|
+
return null;
|
|
4432
4439
|
}
|
|
4433
4440
|
ensureUtils("getValidationError");
|
|
4434
4441
|
const iso2 = this.#selectedCountry?.iso2;
|
|
@@ -4577,39 +4584,31 @@ var Iti = class _Iti {
|
|
|
4577
4584
|
});
|
|
4578
4585
|
}
|
|
4579
4586
|
};
|
|
4580
|
-
var attachUtils = (source) => {
|
|
4581
|
-
if (
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4587
|
+
var attachUtils = async (source) => {
|
|
4588
|
+
if (intlTelInput.utils || intlTelInput.startedLoadingUtils) {
|
|
4589
|
+
return null;
|
|
4590
|
+
}
|
|
4591
|
+
if (typeof source !== "function") {
|
|
4592
|
+
throw new TypeError(
|
|
4593
|
+
`The argument passed to attachUtils must be a function that returns a promise for the utils module, not ${typeof source}`
|
|
4594
|
+
);
|
|
4595
|
+
}
|
|
4596
|
+
intlTelInput.startedLoadingUtils = true;
|
|
4597
|
+
try {
|
|
4598
|
+
const module = await source();
|
|
4599
|
+
const utils = module?.default;
|
|
4600
|
+
if (!utils || typeof utils !== "object") {
|
|
4601
|
+
throw new TypeError(
|
|
4602
|
+
"The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
|
|
4594
4603
|
);
|
|
4595
4604
|
}
|
|
4596
|
-
intlTelInput.
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
);
|
|
4603
|
-
}
|
|
4604
|
-
intlTelInput.utils = utils;
|
|
4605
|
-
Iti.forEachInstance("handleUtilsLoaded");
|
|
4606
|
-
return true;
|
|
4607
|
-
}).catch((error) => {
|
|
4608
|
-
Iti.forEachInstance("handleUtilsFailure", error);
|
|
4609
|
-
throw error;
|
|
4610
|
-
});
|
|
4605
|
+
intlTelInput.utils = utils;
|
|
4606
|
+
Iti.forEachInstance("handleUtilsLoaded");
|
|
4607
|
+
return true;
|
|
4608
|
+
} catch (error) {
|
|
4609
|
+
Iti.forEachInstance("handleUtilsFailure", error);
|
|
4610
|
+
throw error;
|
|
4611
4611
|
}
|
|
4612
|
-
return null;
|
|
4613
4612
|
};
|
|
4614
4613
|
var intlTelInput = Object.assign(
|
|
4615
4614
|
(input, options) => {
|
|
@@ -4634,11 +4633,17 @@ var intlTelInput = Object.assign(
|
|
|
4634
4633
|
attachUtils,
|
|
4635
4634
|
startedLoadingUtils: false,
|
|
4636
4635
|
startedLoadingAutoCountry: false,
|
|
4637
|
-
version: "
|
|
4636
|
+
version: "28.0.0",
|
|
4637
|
+
NUMBER_FORMAT,
|
|
4638
|
+
NUMBER_TYPE,
|
|
4639
|
+
VALIDATION_ERROR
|
|
4638
4640
|
}
|
|
4639
4641
|
);
|
|
4640
4642
|
var intlTelInput_default = intlTelInput;
|
|
4641
4643
|
export {
|
|
4642
4644
|
Iti,
|
|
4645
|
+
NUMBER_FORMAT,
|
|
4646
|
+
NUMBER_TYPE,
|
|
4647
|
+
VALIDATION_ERROR,
|
|
4643
4648
|
intlTelInput_default as default
|
|
4644
4649
|
};
|