intl-tel-input 28.1.0 → 29.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 +20 -11
- package/dist/css/intlTelInput-no-assets.min.css +1 -1
- package/dist/css/intlTelInput.css +20 -11
- package/dist/css/intlTelInput.min.css +1 -1
- package/dist/js/data.js +1 -1
- package/dist/js/data.min.js +1 -1
- package/dist/js/intlTelInput.d.ts +38 -23
- package/dist/js/intlTelInput.js +362 -300
- package/dist/js/intlTelInput.min.js +2 -2
- package/dist/js/intlTelInput.mjs +361 -299
- package/dist/js/intlTelInputWithUtils.js +650 -590
- package/dist/js/intlTelInputWithUtils.min.js +2 -2
- package/dist/js/intlTelInputWithUtils.mjs +649 -589
- package/dist/js/locale.d.ts +124 -0
- package/dist/js/utils.js +51 -51
- package/package.json +7 -7
- package/dist/js/i18n.d.ts +0 -124
- /package/dist/js/{i18n → locale}/ar.js +0 -0
- /package/dist/js/{i18n → locale}/bg.js +0 -0
- /package/dist/js/{i18n → locale}/bn.js +0 -0
- /package/dist/js/{i18n → locale}/bs.js +0 -0
- /package/dist/js/{i18n → locale}/ca.js +0 -0
- /package/dist/js/{i18n → locale}/cs.js +0 -0
- /package/dist/js/{i18n → locale}/da.js +0 -0
- /package/dist/js/{i18n → locale}/de.js +0 -0
- /package/dist/js/{i18n → locale}/el.js +0 -0
- /package/dist/js/{i18n → locale}/en.js +0 -0
- /package/dist/js/{i18n → locale}/es.js +0 -0
- /package/dist/js/{i18n → locale}/et.js +0 -0
- /package/dist/js/{i18n → locale}/fa.js +0 -0
- /package/dist/js/{i18n → locale}/fi.js +0 -0
- /package/dist/js/{i18n → locale}/fil.js +0 -0
- /package/dist/js/{i18n → locale}/fr.js +0 -0
- /package/dist/js/{i18n → locale}/he.js +0 -0
- /package/dist/js/{i18n → locale}/hi.js +0 -0
- /package/dist/js/{i18n → locale}/hr.js +0 -0
- /package/dist/js/{i18n → locale}/hu.js +0 -0
- /package/dist/js/{i18n → locale}/hy.js +0 -0
- /package/dist/js/{i18n → locale}/id.js +0 -0
- /package/dist/js/{i18n → locale}/index.js +0 -0
- /package/dist/js/{i18n → locale}/is.js +0 -0
- /package/dist/js/{i18n → locale}/it.js +0 -0
- /package/dist/js/{i18n → locale}/ja.js +0 -0
- /package/dist/js/{i18n → locale}/kn.js +0 -0
- /package/dist/js/{i18n → locale}/ko.js +0 -0
- /package/dist/js/{i18n → locale}/lt.js +0 -0
- /package/dist/js/{i18n → locale}/lv.js +0 -0
- /package/dist/js/{i18n → locale}/mk.js +0 -0
- /package/dist/js/{i18n → locale}/mr.js +0 -0
- /package/dist/js/{i18n → locale}/ms.js +0 -0
- /package/dist/js/{i18n → locale}/nl.js +0 -0
- /package/dist/js/{i18n → locale}/no.js +0 -0
- /package/dist/js/{i18n → locale}/pl.js +0 -0
- /package/dist/js/{i18n → locale}/pt.js +0 -0
- /package/dist/js/{i18n → locale}/ro.js +0 -0
- /package/dist/js/{i18n → locale}/ru.js +0 -0
- /package/dist/js/{i18n → locale}/sk.js +0 -0
- /package/dist/js/{i18n → locale}/sl.js +0 -0
- /package/dist/js/{i18n → locale}/sq.js +0 -0
- /package/dist/js/{i18n → locale}/sr.js +0 -0
- /package/dist/js/{i18n → locale}/sv.js +0 -0
- /package/dist/js/{i18n → locale}/sw.js +0 -0
- /package/dist/js/{i18n → locale}/ta.js +0 -0
- /package/dist/js/{i18n → locale}/te.js +0 -0
- /package/dist/js/{i18n → locale}/th.js +0 -0
- /package/dist/js/{i18n → locale}/tr.js +0 -0
- /package/dist/js/{i18n → locale}/types.js +0 -0
- /package/dist/js/{i18n → locale}/uk.js +0 -0
- /package/dist/js/{i18n → locale}/ur.js +0 -0
- /package/dist/js/{i18n → locale}/uz.js +0 -0
- /package/dist/js/{i18n → locale}/vi.js +0 -0
- /package/dist/js/{i18n → locale}/zh-hk.js +0 -0
- /package/dist/js/{i18n → locale}/zh.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input
|
|
2
|
+
* International Telephone Input v29.0.0
|
|
3
3
|
* git+https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -1783,8 +1783,8 @@ var _factory = (() => {
|
|
|
1783
1783
|
|
|
1784
1784
|
// packages/core/src/js/constants.ts
|
|
1785
1785
|
var EVENTS = {
|
|
1786
|
-
|
|
1787
|
-
|
|
1786
|
+
OPEN_COUNTRY_SELECTOR: "open:countryselector",
|
|
1787
|
+
CLOSE_COUNTRY_SELECTOR: "close:countryselector",
|
|
1788
1788
|
COUNTRY_CHANGE: "countrychange",
|
|
1789
1789
|
INPUT: "input",
|
|
1790
1790
|
// used for synthetic input trigger
|
|
@@ -1831,9 +1831,9 @@ var _factory = (() => {
|
|
|
1831
1831
|
var LAYOUT = {
|
|
1832
1832
|
NARROW_VIEWPORT_WIDTH: 500,
|
|
1833
1833
|
// keep in sync with .iti__country-list CSS media query
|
|
1834
|
-
|
|
1834
|
+
FALLBACK_SELECTED_COUNTRY_WITH_DIAL_WIDTH: 78,
|
|
1835
1835
|
// px width fallback when separateDialCode enabled
|
|
1836
|
-
|
|
1836
|
+
FALLBACK_SELECTED_COUNTRY_NO_DIAL_WIDTH: 42,
|
|
1837
1837
|
// px width fallback when no separate dial code
|
|
1838
1838
|
INPUT_PADDING_EXTRA_LEFT: 6,
|
|
1839
1839
|
// px gap between selected country container and input text
|
|
@@ -1861,14 +1861,17 @@ var _factory = (() => {
|
|
|
1861
1861
|
DIAL_CODE: "1"
|
|
1862
1862
|
// +1 United States
|
|
1863
1863
|
};
|
|
1864
|
-
var
|
|
1865
|
-
AGGRESSIVE: "
|
|
1866
|
-
POLITE: "
|
|
1867
|
-
OFF: "
|
|
1868
|
-
};
|
|
1869
|
-
var INITIAL_COUNTRY = {
|
|
1870
|
-
AUTO: "auto"
|
|
1864
|
+
var PLACEHOLDER_POLICY = {
|
|
1865
|
+
AGGRESSIVE: "AGGRESSIVE",
|
|
1866
|
+
POLITE: "POLITE",
|
|
1867
|
+
OFF: "OFF"
|
|
1871
1868
|
};
|
|
1869
|
+
var COUNTRY_SELECTOR_MODES = [
|
|
1870
|
+
"OFF",
|
|
1871
|
+
"DROPDOWN",
|
|
1872
|
+
"FULLSCREEN",
|
|
1873
|
+
"AUTO"
|
|
1874
|
+
];
|
|
1872
1875
|
var NUMBER_FORMATS = [
|
|
1873
1876
|
"E164",
|
|
1874
1877
|
"INTERNATIONAL",
|
|
@@ -1901,8 +1904,9 @@ var _factory = (() => {
|
|
|
1901
1904
|
var NUMBER_FORMAT = toEnumObject(NUMBER_FORMATS);
|
|
1902
1905
|
var NUMBER_TYPE = toEnumObject(NUMBER_TYPES);
|
|
1903
1906
|
var VALIDATION_ERROR = toEnumObject(VALIDATION_ERRORS);
|
|
1907
|
+
var COUNTRY_SELECTOR_MODE = toEnumObject(COUNTRY_SELECTOR_MODES);
|
|
1904
1908
|
var DATA_KEYS = {
|
|
1905
|
-
// e.g. <li data-iso2="us"> for country items in
|
|
1909
|
+
// e.g. <li data-iso2="us"> for country items in the country list
|
|
1906
1910
|
ISO2: "iso2",
|
|
1907
1911
|
DIAL_CODE: "dialCode",
|
|
1908
1912
|
// e.g. <input data-intl-tel-input-id="0"> on the input element
|
|
@@ -1920,7 +1924,7 @@ var _factory = (() => {
|
|
|
1920
1924
|
MODAL: "aria-modal"
|
|
1921
1925
|
};
|
|
1922
1926
|
|
|
1923
|
-
// packages/core/src/js/
|
|
1927
|
+
// packages/core/src/js/locale/en.ts
|
|
1924
1928
|
var interfaceTranslations = {
|
|
1925
1929
|
selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
|
|
1926
1930
|
noCountrySelected: "Select country for phone number",
|
|
@@ -1943,63 +1947,63 @@ var _factory = (() => {
|
|
|
1943
1947
|
// packages/core/src/js/core/options.ts
|
|
1944
1948
|
var mediaQuery = (q) => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
|
|
1945
1949
|
var isNarrowViewport = () => mediaQuery(`(max-width: ${LAYOUT.NARROW_VIEWPORT_WIDTH}px)`);
|
|
1946
|
-
var
|
|
1950
|
+
var resolveAutoCountrySelectorMode = () => {
|
|
1947
1951
|
if (typeof navigator !== "undefined" && typeof window !== "undefined") {
|
|
1948
1952
|
const isShortViewport = mediaQuery("(max-height: 600px)");
|
|
1949
1953
|
const isCoarsePointer = mediaQuery("(pointer: coarse)");
|
|
1950
|
-
|
|
1954
|
+
if (isNarrowViewport() || isCoarsePointer && isShortViewport) {
|
|
1955
|
+
return COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
1956
|
+
}
|
|
1951
1957
|
}
|
|
1952
|
-
return
|
|
1958
|
+
return COUNTRY_SELECTOR_MODE.DROPDOWN;
|
|
1953
1959
|
};
|
|
1954
1960
|
var defaults = {
|
|
1955
|
-
//*
|
|
1956
|
-
|
|
1961
|
+
//* How the country selector is displayed. "DROPDOWN" vs "FULLSCREEN", or "AUTO" to decide itself, or "OFF".
|
|
1962
|
+
countrySelectorMode: COUNTRY_SELECTOR_MODE.AUTO,
|
|
1957
1963
|
//* The number type to enforce during validation.
|
|
1958
1964
|
allowedNumberTypes: [NUMBER_TYPE.MOBILE, NUMBER_TYPE.FIXED_LINE],
|
|
1959
1965
|
//* Whether or not to allow extensions after the main number.
|
|
1960
1966
|
allowNumberExtensions: false,
|
|
1961
1967
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1962
1968
|
allowPhonewords: false,
|
|
1963
|
-
//* Add a placeholder in the input with an example number for the selected country.
|
|
1964
|
-
autoPlaceholder: PLACEHOLDER_MODES.POLITE,
|
|
1965
1969
|
//* Add a custom class to the (injected) container element.
|
|
1966
1970
|
containerClass: "",
|
|
1967
1971
|
//* Locale for localising country names via Intl.DisplayNames.
|
|
1968
1972
|
countryNameLocale: "en",
|
|
1969
1973
|
//* Override individual country names by iso2 code.
|
|
1970
1974
|
countryNameOverrides: {},
|
|
1971
|
-
//* The order of the countries in the
|
|
1975
|
+
//* The order of the countries in the country list. Defaults to alphabetical.
|
|
1972
1976
|
countryOrder: null,
|
|
1973
|
-
//* Add a country search input at the top of the
|
|
1977
|
+
//* Add a country search input at the top of the country selector.
|
|
1974
1978
|
countrySearch: true,
|
|
1975
1979
|
//* Modify the auto placeholder.
|
|
1976
1980
|
customPlaceholder: null,
|
|
1977
1981
|
//* Always show the dropdown
|
|
1978
1982
|
dropdownAlwaysOpen: false,
|
|
1979
|
-
//*
|
|
1980
|
-
|
|
1983
|
+
//* Optional DOM element to append the dropdown to (used to escape ancestors with overflow:hidden, or to mount in a custom container). Only consulted in dropdown rendering; ignored when the country selector renders as a fullscreen popup.
|
|
1984
|
+
dropdownParent: null,
|
|
1981
1985
|
//* Don't display these countries.
|
|
1982
1986
|
excludeCountries: null,
|
|
1983
1987
|
//* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
|
|
1984
|
-
|
|
1988
|
+
matchDropdownWidth: true,
|
|
1985
1989
|
//* Format the number as the user types
|
|
1986
1990
|
formatAsYouType: true,
|
|
1987
|
-
//*
|
|
1988
|
-
|
|
1989
|
-
//*
|
|
1990
|
-
|
|
1991
|
-
//* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
|
|
1992
|
-
hiddenInput: null,
|
|
1993
|
-
//* Internationalise the core library text e.g. search input placeholder, country names.
|
|
1994
|
-
i18n: {},
|
|
1991
|
+
//* Inject hidden inputs with the names returned from this function, and on submit, populate them with the full number and selected country iso2.
|
|
1992
|
+
hiddenInputs: null,
|
|
1993
|
+
//* Translations for the core library UI strings e.g. search input placeholder, country names.
|
|
1994
|
+
uiTranslations: {},
|
|
1995
1995
|
//* Initial country.
|
|
1996
1996
|
initialCountry: "",
|
|
1997
|
+
//* Async lookup function used to determine the initial country (e.g. via IP). Ignored if initialCountry is set.
|
|
1998
|
+
initialCountryLookup: null,
|
|
1997
1999
|
//* A function to load the utils script.
|
|
1998
2000
|
loadUtils: null,
|
|
1999
|
-
//*
|
|
2000
|
-
|
|
2001
|
+
//* Format used when displaying numbers (placeholder examples and stored values). One of "E164", "INTERNATIONAL", "NATIONAL".
|
|
2002
|
+
numberDisplayFormat: NUMBER_FORMAT.INTERNATIONAL,
|
|
2001
2003
|
//* Display only these countries.
|
|
2002
2004
|
onlyCountries: null,
|
|
2005
|
+
//* When to set the placeholder to an example number for the selected country: "POLITE" only when the input has no manually-set placeholder, "AGGRESSIVE" always, "OFF" never.
|
|
2006
|
+
placeholderNumberPolicy: PLACEHOLDER_POLICY.POLITE,
|
|
2003
2007
|
//* Number type to use for placeholders.
|
|
2004
2008
|
placeholderNumberType: NUMBER_TYPE.MOBILE,
|
|
2005
2009
|
//* Add custom classes to the search input element.
|
|
@@ -2008,12 +2012,10 @@ var _factory = (() => {
|
|
|
2008
2012
|
separateDialCode: true,
|
|
2009
2013
|
//* When strictMode rejects a key (etc), play a short feedback animation
|
|
2010
2014
|
strictRejectAnimation: true,
|
|
2011
|
-
//* Show flags - for both the selected country, and in the country
|
|
2015
|
+
//* Show flags - for both the selected country, and in the country list
|
|
2012
2016
|
showFlags: true,
|
|
2013
2017
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
2014
|
-
strictMode: true
|
|
2015
|
-
//* Use full screen popup instead of dropdown for country list.
|
|
2016
|
-
useFullscreenPopup: computeDefaultUseFullscreenPopup()
|
|
2018
|
+
strictMode: true
|
|
2017
2019
|
};
|
|
2018
2020
|
var toString = (val) => JSON.stringify(val);
|
|
2019
2021
|
var isPlainObject = (val) => Boolean(val) && typeof val === "object" && !Array.isArray(val);
|
|
@@ -2025,7 +2027,7 @@ var _factory = (() => {
|
|
|
2025
2027
|
const v = val;
|
|
2026
2028
|
return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
|
|
2027
2029
|
};
|
|
2028
|
-
var
|
|
2030
|
+
var placeholderPolicySet = new Set(Object.values(PLACEHOLDER_POLICY));
|
|
2029
2031
|
var warn = (message) => {
|
|
2030
2032
|
console.warn(`[intl-tel-input] ${message}`);
|
|
2031
2033
|
};
|
|
@@ -2071,30 +2073,48 @@ var _factory = (() => {
|
|
|
2071
2073
|
continue;
|
|
2072
2074
|
}
|
|
2073
2075
|
switch (key) {
|
|
2074
|
-
case "allowDropdown":
|
|
2075
2076
|
case "allowNumberExtensions":
|
|
2076
2077
|
case "allowPhonewords":
|
|
2077
2078
|
case "countrySearch":
|
|
2078
2079
|
case "dropdownAlwaysOpen":
|
|
2079
|
-
case "
|
|
2080
|
+
case "matchDropdownWidth":
|
|
2080
2081
|
case "formatAsYouType":
|
|
2081
|
-
case "formatOnDisplay":
|
|
2082
|
-
case "nationalMode":
|
|
2083
2082
|
case "showFlags":
|
|
2084
2083
|
case "separateDialCode":
|
|
2085
2084
|
case "strictMode":
|
|
2086
2085
|
case "strictRejectAnimation":
|
|
2087
|
-
case "useFullscreenPopup":
|
|
2088
2086
|
if (typeof value !== "boolean") {
|
|
2089
2087
|
warnOption(key, "a boolean", value);
|
|
2090
2088
|
break;
|
|
2091
2089
|
}
|
|
2092
2090
|
validatedOptions[key] = value;
|
|
2093
2091
|
break;
|
|
2094
|
-
case "
|
|
2095
|
-
if (typeof value !== "string" || !
|
|
2096
|
-
|
|
2097
|
-
|
|
2092
|
+
case "countrySelectorMode":
|
|
2093
|
+
if (typeof value !== "string" || !COUNTRY_SELECTOR_MODES.includes(value)) {
|
|
2094
|
+
warnOption(
|
|
2095
|
+
"countrySelectorMode",
|
|
2096
|
+
`one of ${COUNTRY_SELECTOR_MODES.map((m) => `"${m}"`).join(", ")}`,
|
|
2097
|
+
value
|
|
2098
|
+
);
|
|
2099
|
+
break;
|
|
2100
|
+
}
|
|
2101
|
+
validatedOptions[key] = value;
|
|
2102
|
+
break;
|
|
2103
|
+
case "numberDisplayFormat":
|
|
2104
|
+
if (typeof value !== "string" || value === NUMBER_FORMAT.RFC3966 || !(value === NUMBER_FORMAT.E164 || value === NUMBER_FORMAT.INTERNATIONAL || value === NUMBER_FORMAT.NATIONAL)) {
|
|
2105
|
+
warnOption(
|
|
2106
|
+
"numberDisplayFormat",
|
|
2107
|
+
'one of "E164", "INTERNATIONAL", "NATIONAL"',
|
|
2108
|
+
value
|
|
2109
|
+
);
|
|
2110
|
+
break;
|
|
2111
|
+
}
|
|
2112
|
+
validatedOptions[key] = value;
|
|
2113
|
+
break;
|
|
2114
|
+
case "placeholderNumberPolicy":
|
|
2115
|
+
if (typeof value !== "string" || !placeholderPolicySet.has(value)) {
|
|
2116
|
+
const validPolicies = Array.from(placeholderPolicySet).join(", ");
|
|
2117
|
+
warnOption("placeholderNumberPolicy", `one of ${validPolicies}`, value);
|
|
2098
2118
|
break;
|
|
2099
2119
|
}
|
|
2100
2120
|
validatedOptions[key] = value;
|
|
@@ -2120,8 +2140,8 @@ var _factory = (() => {
|
|
|
2120
2140
|
break;
|
|
2121
2141
|
}
|
|
2122
2142
|
case "customPlaceholder":
|
|
2123
|
-
case "
|
|
2124
|
-
case "
|
|
2143
|
+
case "hiddenInputs":
|
|
2144
|
+
case "initialCountryLookup":
|
|
2125
2145
|
case "loadUtils":
|
|
2126
2146
|
if (value !== null && !isFunction(value)) {
|
|
2127
2147
|
warnOption(key, "a function or null", value);
|
|
@@ -2129,9 +2149,9 @@ var _factory = (() => {
|
|
|
2129
2149
|
}
|
|
2130
2150
|
validatedOptions[key] = value;
|
|
2131
2151
|
break;
|
|
2132
|
-
case "
|
|
2152
|
+
case "dropdownParent":
|
|
2133
2153
|
if (value !== null && !isElLike(value)) {
|
|
2134
|
-
warnOption("
|
|
2154
|
+
warnOption("dropdownParent", "an HTMLElement or null", value);
|
|
2135
2155
|
break;
|
|
2136
2156
|
}
|
|
2137
2157
|
validatedOptions[key] = value;
|
|
@@ -2148,9 +2168,9 @@ var _factory = (() => {
|
|
|
2148
2168
|
}
|
|
2149
2169
|
break;
|
|
2150
2170
|
}
|
|
2151
|
-
case "
|
|
2171
|
+
case "uiTranslations":
|
|
2152
2172
|
if (value && !isPlainObject(value)) {
|
|
2153
|
-
warnOption("
|
|
2173
|
+
warnOption("uiTranslations", "an object", value);
|
|
2154
2174
|
break;
|
|
2155
2175
|
}
|
|
2156
2176
|
validatedOptions[key] = value;
|
|
@@ -2168,12 +2188,8 @@ var _factory = (() => {
|
|
|
2168
2188
|
break;
|
|
2169
2189
|
}
|
|
2170
2190
|
const lower = value.toLowerCase();
|
|
2171
|
-
if (lower &&
|
|
2172
|
-
warnOption(
|
|
2173
|
-
"initialCountry",
|
|
2174
|
-
"a valid iso2 country code or 'auto'",
|
|
2175
|
-
value
|
|
2176
|
-
);
|
|
2191
|
+
if (lower && !isIso2(lower)) {
|
|
2192
|
+
warnOption("initialCountry", "a valid iso2 country code", value);
|
|
2177
2193
|
break;
|
|
2178
2194
|
}
|
|
2179
2195
|
validatedOptions[key] = value;
|
|
@@ -2236,30 +2252,29 @@ var _factory = (() => {
|
|
|
2236
2252
|
}
|
|
2237
2253
|
};
|
|
2238
2254
|
var applyOptionSideEffects = (o) => {
|
|
2255
|
+
if (o.countrySelectorMode === COUNTRY_SELECTOR_MODE.AUTO) {
|
|
2256
|
+
o.countrySelectorMode = resolveAutoCountrySelectorMode();
|
|
2257
|
+
}
|
|
2239
2258
|
if (o.dropdownAlwaysOpen) {
|
|
2240
|
-
o.
|
|
2241
|
-
o.allowDropdown = true;
|
|
2259
|
+
o.countrySelectorMode = COUNTRY_SELECTOR_MODE.DROPDOWN;
|
|
2242
2260
|
}
|
|
2243
|
-
if (o.
|
|
2244
|
-
o.
|
|
2261
|
+
if (o.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN) {
|
|
2262
|
+
o.matchDropdownWidth = false;
|
|
2245
2263
|
} else {
|
|
2246
2264
|
if (isNarrowViewport()) {
|
|
2247
|
-
o.
|
|
2265
|
+
o.matchDropdownWidth = true;
|
|
2248
2266
|
}
|
|
2249
2267
|
}
|
|
2250
2268
|
if (o.onlyCountries?.length === 1) {
|
|
2251
2269
|
o.initialCountry = o.onlyCountries[0];
|
|
2252
2270
|
}
|
|
2253
|
-
if (o.separateDialCode) {
|
|
2254
|
-
o.
|
|
2255
|
-
}
|
|
2256
|
-
if (o.allowDropdown && !o.showFlags && !o.separateDialCode) {
|
|
2257
|
-
o.nationalMode = false;
|
|
2271
|
+
if (o.separateDialCode && o.numberDisplayFormat === NUMBER_FORMAT.NATIONAL) {
|
|
2272
|
+
o.numberDisplayFormat = NUMBER_FORMAT.INTERNATIONAL;
|
|
2258
2273
|
}
|
|
2259
|
-
if (o.
|
|
2260
|
-
o.
|
|
2274
|
+
if (o.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && !o.showFlags && !o.separateDialCode && o.numberDisplayFormat === NUMBER_FORMAT.NATIONAL) {
|
|
2275
|
+
o.numberDisplayFormat = NUMBER_FORMAT.INTERNATIONAL;
|
|
2261
2276
|
}
|
|
2262
|
-
o.
|
|
2277
|
+
o.uiTranslations = { ...en_default, ...o.uiTranslations };
|
|
2263
2278
|
};
|
|
2264
2279
|
|
|
2265
2280
|
// packages/core/src/js/helpers/string.ts
|
|
@@ -2470,6 +2485,7 @@ var _factory = (() => {
|
|
|
2470
2485
|
};
|
|
2471
2486
|
|
|
2472
2487
|
// packages/core/src/js/core/ui.ts
|
|
2488
|
+
var supportsCssAnchor = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name: --x");
|
|
2473
2489
|
var UI = class _UI {
|
|
2474
2490
|
// private
|
|
2475
2491
|
#options;
|
|
@@ -2484,8 +2500,8 @@ var _factory = (() => {
|
|
|
2484
2500
|
#selectedCountryEl;
|
|
2485
2501
|
#selectedFlagEl;
|
|
2486
2502
|
#selectedDialCodeEl;
|
|
2487
|
-
#
|
|
2488
|
-
#
|
|
2503
|
+
#arrowEl;
|
|
2504
|
+
#countrySelectorEl;
|
|
2489
2505
|
#searchIconEl;
|
|
2490
2506
|
#searchInputEl;
|
|
2491
2507
|
#searchClearButtonEl;
|
|
@@ -2494,11 +2510,11 @@ var _factory = (() => {
|
|
|
2494
2510
|
#hiddenInputCountryEl;
|
|
2495
2511
|
#noResultsMessageEl;
|
|
2496
2512
|
#searchResultsLiveRegionEl;
|
|
2497
|
-
#
|
|
2513
|
+
#detachedCountrySelectorEl;
|
|
2498
2514
|
#selectedListItemEl = null;
|
|
2499
2515
|
#highlightedListItemEl = null;
|
|
2500
2516
|
#listItemByIso2 = /* @__PURE__ */ new Map();
|
|
2501
|
-
#
|
|
2517
|
+
#countrySelectorAbortController = null;
|
|
2502
2518
|
#resizeObserver;
|
|
2503
2519
|
// public
|
|
2504
2520
|
telInputEl;
|
|
@@ -2523,7 +2539,7 @@ var _factory = (() => {
|
|
|
2523
2539
|
);
|
|
2524
2540
|
}
|
|
2525
2541
|
}
|
|
2526
|
-
//* Generate all of the markup for the core library: the selected country overlay, and the
|
|
2542
|
+
//* Generate all of the markup for the core library: the selected country overlay, and the country selector.
|
|
2527
2543
|
buildMarkup(countries, searchTokens) {
|
|
2528
2544
|
this.#countries = countries;
|
|
2529
2545
|
this.#searchTokens = searchTokens;
|
|
@@ -2546,13 +2562,13 @@ var _factory = (() => {
|
|
|
2546
2562
|
this.ensureDropdownWidthSet();
|
|
2547
2563
|
}
|
|
2548
2564
|
#createWrapperAndInsert() {
|
|
2549
|
-
const {
|
|
2565
|
+
const { countrySelectorMode, showFlags, containerClass } = this.#options;
|
|
2550
2566
|
const parentClasses = buildClassNames({
|
|
2551
2567
|
iti: true,
|
|
2552
2568
|
"iti--input-container": true,
|
|
2553
|
-
"iti--
|
|
2569
|
+
"iti--has-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF,
|
|
2554
2570
|
"iti--show-flags": showFlags,
|
|
2555
|
-
"iti--inline-
|
|
2571
|
+
"iti--inline-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.FULLSCREEN,
|
|
2556
2572
|
[containerClass]: Boolean(containerClass)
|
|
2557
2573
|
});
|
|
2558
2574
|
const wrapper = createEl("div", { class: parentClasses });
|
|
@@ -2563,8 +2579,9 @@ var _factory = (() => {
|
|
|
2563
2579
|
return wrapper;
|
|
2564
2580
|
}
|
|
2565
2581
|
#buildCountryContainer(wrapper) {
|
|
2566
|
-
const {
|
|
2567
|
-
|
|
2582
|
+
const { countrySelectorMode, separateDialCode, showFlags } = this.#options;
|
|
2583
|
+
const enableCountrySelector = countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF;
|
|
2584
|
+
if (!enableCountrySelector && !showFlags && !separateDialCode) {
|
|
2568
2585
|
return;
|
|
2569
2586
|
}
|
|
2570
2587
|
this.#countryContainerEl = createEl(
|
|
@@ -2573,16 +2590,16 @@ var _factory = (() => {
|
|
|
2573
2590
|
{ class: `iti__country-container ${CLASSES.V_HIDE}` },
|
|
2574
2591
|
wrapper
|
|
2575
2592
|
);
|
|
2576
|
-
if (
|
|
2593
|
+
if (enableCountrySelector) {
|
|
2577
2594
|
this.#selectedCountryEl = createEl(
|
|
2578
2595
|
"button",
|
|
2579
2596
|
{
|
|
2580
2597
|
type: "button",
|
|
2581
2598
|
class: "iti__selected-country",
|
|
2582
2599
|
[ARIA.EXPANDED]: "false",
|
|
2583
|
-
[ARIA.LABEL]: this.#options.
|
|
2600
|
+
[ARIA.LABEL]: this.#options.uiTranslations.noCountrySelected,
|
|
2584
2601
|
[ARIA.HASPOPUP]: "dialog",
|
|
2585
|
-
[ARIA.CONTROLS]: `iti-${this.#id}
|
|
2602
|
+
[ARIA.CONTROLS]: `iti-${this.#id}__country-selector`
|
|
2586
2603
|
},
|
|
2587
2604
|
this.#countryContainerEl
|
|
2588
2605
|
);
|
|
@@ -2606,8 +2623,8 @@ var _factory = (() => {
|
|
|
2606
2623
|
{ class: CLASSES.FLAG },
|
|
2607
2624
|
selectedCountryPrimary
|
|
2608
2625
|
);
|
|
2609
|
-
if (
|
|
2610
|
-
this.#
|
|
2626
|
+
if (enableCountrySelector) {
|
|
2627
|
+
this.#arrowEl = createEl(
|
|
2611
2628
|
"div",
|
|
2612
2629
|
{ class: "iti__arrow", [ARIA.HIDDEN]: "true" },
|
|
2613
2630
|
selectedCountryPrimary
|
|
@@ -2620,38 +2637,39 @@ var _factory = (() => {
|
|
|
2620
2637
|
this.#selectedCountryEl
|
|
2621
2638
|
);
|
|
2622
2639
|
}
|
|
2623
|
-
if (
|
|
2624
|
-
this.#
|
|
2640
|
+
if (enableCountrySelector) {
|
|
2641
|
+
this.#buildCountrySelector();
|
|
2625
2642
|
}
|
|
2626
2643
|
}
|
|
2627
2644
|
ensureDropdownWidthSet() {
|
|
2628
|
-
const {
|
|
2629
|
-
if (
|
|
2645
|
+
const { matchDropdownWidth, countrySelectorMode } = this.#options;
|
|
2646
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.OFF || !matchDropdownWidth || this.#countrySelectorEl.style.width) {
|
|
2630
2647
|
return;
|
|
2631
2648
|
}
|
|
2632
2649
|
const inputWidth = this.telInputEl.offsetWidth;
|
|
2633
2650
|
if (inputWidth > 0) {
|
|
2634
|
-
this.#
|
|
2651
|
+
this.#countrySelectorEl.style.width = `${inputWidth}px`;
|
|
2635
2652
|
}
|
|
2636
2653
|
}
|
|
2637
|
-
#
|
|
2654
|
+
#buildCountrySelector() {
|
|
2638
2655
|
const {
|
|
2639
|
-
|
|
2640
|
-
|
|
2656
|
+
matchDropdownWidth,
|
|
2657
|
+
countrySelectorMode,
|
|
2641
2658
|
countrySearch,
|
|
2642
|
-
|
|
2643
|
-
dropdownContainer,
|
|
2659
|
+
uiTranslations,
|
|
2644
2660
|
containerClass
|
|
2645
2661
|
} = this.#options;
|
|
2646
|
-
const
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2662
|
+
const isFullscreen = countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
2663
|
+
const detachedParent = this.#getDetachedParent();
|
|
2664
|
+
const extraClasses = matchDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2665
|
+
this.#countrySelectorEl = createEl("div", {
|
|
2666
|
+
id: `iti-${this.#id}__country-selector`,
|
|
2667
|
+
class: `iti__country-selector ${CLASSES.HIDE} ${extraClasses}`,
|
|
2650
2668
|
role: "dialog",
|
|
2651
2669
|
[ARIA.MODAL]: "true"
|
|
2652
2670
|
});
|
|
2653
2671
|
if (this.#isRTL) {
|
|
2654
|
-
this.#
|
|
2672
|
+
this.#countrySelectorEl.setAttribute("dir", "rtl");
|
|
2655
2673
|
}
|
|
2656
2674
|
if (countrySearch) {
|
|
2657
2675
|
this.#buildSearchUI();
|
|
@@ -2662,40 +2680,54 @@ var _factory = (() => {
|
|
|
2662
2680
|
class: "iti__country-list",
|
|
2663
2681
|
id: `iti-${this.#id}__country-listbox`,
|
|
2664
2682
|
role: "listbox",
|
|
2665
|
-
[ARIA.LABEL]:
|
|
2683
|
+
[ARIA.LABEL]: uiTranslations.countryListAriaLabel
|
|
2666
2684
|
},
|
|
2667
|
-
this.#
|
|
2685
|
+
this.#countrySelectorEl
|
|
2668
2686
|
);
|
|
2669
2687
|
this.#appendListItems();
|
|
2670
2688
|
if (countrySearch) {
|
|
2671
2689
|
this.#updateSearchResultsA11yText();
|
|
2672
2690
|
}
|
|
2673
|
-
if (!
|
|
2691
|
+
if (!isFullscreen) {
|
|
2674
2692
|
this.#inlineDropdownHeight = this.#getHiddenInlineDropdownHeight();
|
|
2675
2693
|
if (countrySearch) {
|
|
2676
|
-
this.#
|
|
2694
|
+
this.#countrySelectorEl.style.height = `${this.#inlineDropdownHeight}px`;
|
|
2677
2695
|
}
|
|
2678
2696
|
}
|
|
2679
|
-
if (
|
|
2680
|
-
const
|
|
2697
|
+
if (detachedParent) {
|
|
2698
|
+
const wrapperClasses = buildClassNames({
|
|
2681
2699
|
iti: true,
|
|
2682
|
-
"iti--
|
|
2683
|
-
"iti--fullscreen-popup":
|
|
2684
|
-
"iti--inline-
|
|
2700
|
+
"iti--detached-country-selector": true,
|
|
2701
|
+
"iti--fullscreen-popup": isFullscreen,
|
|
2702
|
+
"iti--inline-country-selector": !isFullscreen,
|
|
2685
2703
|
[containerClass]: Boolean(containerClass)
|
|
2686
2704
|
});
|
|
2687
|
-
this.#
|
|
2688
|
-
this.#
|
|
2705
|
+
this.#detachedCountrySelectorEl = createEl("div", { class: wrapperClasses });
|
|
2706
|
+
this.#detachedCountrySelectorEl.appendChild(this.#countrySelectorEl);
|
|
2707
|
+
if (!isFullscreen) {
|
|
2708
|
+
this.#setupCssAnchorPositioning();
|
|
2709
|
+
}
|
|
2689
2710
|
} else {
|
|
2690
|
-
this.#countryContainerEl.appendChild(this.#
|
|
2711
|
+
this.#countryContainerEl.appendChild(this.#countrySelectorEl);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
//* Resolve the DOM element to attach the country selector to. Fullscreen always uses document.body; dropdown uses the consumer-supplied dropdownParent (if any); otherwise the country selector renders inline within the input wrapper (no detached element).
|
|
2715
|
+
#getDetachedParent() {
|
|
2716
|
+
const { countrySelectorMode, dropdownParent } = this.#options;
|
|
2717
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN) {
|
|
2718
|
+
return document.body;
|
|
2691
2719
|
}
|
|
2720
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.DROPDOWN) {
|
|
2721
|
+
return dropdownParent;
|
|
2722
|
+
}
|
|
2723
|
+
return null;
|
|
2692
2724
|
}
|
|
2693
2725
|
#buildSearchUI() {
|
|
2694
|
-
const {
|
|
2726
|
+
const { uiTranslations, searchInputClass } = this.#options;
|
|
2695
2727
|
const searchWrapper = createEl(
|
|
2696
2728
|
"div",
|
|
2697
2729
|
{ class: "iti__search-input-wrapper" },
|
|
2698
|
-
this.#
|
|
2730
|
+
this.#countrySelectorEl
|
|
2699
2731
|
);
|
|
2700
2732
|
this.#searchIconEl = createEl(
|
|
2701
2733
|
"span",
|
|
@@ -2713,11 +2745,11 @@ var _factory = (() => {
|
|
|
2713
2745
|
// Chrome says inputs need either a name or an id
|
|
2714
2746
|
type: "search",
|
|
2715
2747
|
class: `iti__search-input ${searchInputClass}`,
|
|
2716
|
-
placeholder:
|
|
2748
|
+
placeholder: uiTranslations.searchPlaceholder,
|
|
2717
2749
|
// role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
|
|
2718
2750
|
role: "combobox",
|
|
2719
2751
|
[ARIA.EXPANDED]: "true",
|
|
2720
|
-
[ARIA.LABEL]:
|
|
2752
|
+
[ARIA.LABEL]: uiTranslations.searchPlaceholder,
|
|
2721
2753
|
[ARIA.CONTROLS]: `iti-${this.#id}__country-listbox`,
|
|
2722
2754
|
[ARIA.AUTOCOMPLETE]: "list",
|
|
2723
2755
|
autocomplete: "off"
|
|
@@ -2729,7 +2761,7 @@ var _factory = (() => {
|
|
|
2729
2761
|
{
|
|
2730
2762
|
type: "button",
|
|
2731
2763
|
class: `iti__search-clear ${CLASSES.HIDE}`,
|
|
2732
|
-
[ARIA.LABEL]:
|
|
2764
|
+
[ARIA.LABEL]: uiTranslations.clearSearchAriaLabel,
|
|
2733
2765
|
tabindex: "-1"
|
|
2734
2766
|
},
|
|
2735
2767
|
searchWrapper
|
|
@@ -2738,7 +2770,7 @@ var _factory = (() => {
|
|
|
2738
2770
|
this.#searchResultsLiveRegionEl = createEl(
|
|
2739
2771
|
"span",
|
|
2740
2772
|
{ class: "iti__a11y-text" },
|
|
2741
|
-
this.#
|
|
2773
|
+
this.#countrySelectorEl
|
|
2742
2774
|
);
|
|
2743
2775
|
this.#noResultsMessageEl = createEl(
|
|
2744
2776
|
"div",
|
|
@@ -2747,9 +2779,9 @@ var _factory = (() => {
|
|
|
2747
2779
|
[ARIA.HIDDEN]: "true"
|
|
2748
2780
|
// all a11y messaging happens in this.#searchResultsLiveRegionEl
|
|
2749
2781
|
},
|
|
2750
|
-
this.#
|
|
2782
|
+
this.#countrySelectorEl
|
|
2751
2783
|
);
|
|
2752
|
-
this.#noResultsMessageEl.textContent =
|
|
2784
|
+
this.#noResultsMessageEl.textContent = uiTranslations.searchEmptyState ?? null;
|
|
2753
2785
|
}
|
|
2754
2786
|
#updateInputPaddingAndReveal() {
|
|
2755
2787
|
if (!this.#countryContainerEl) {
|
|
@@ -2759,12 +2791,12 @@ var _factory = (() => {
|
|
|
2759
2791
|
this.#countryContainerEl.classList.remove(CLASSES.V_HIDE);
|
|
2760
2792
|
}
|
|
2761
2793
|
#buildHiddenInputs(wrapper) {
|
|
2762
|
-
const {
|
|
2763
|
-
if (!
|
|
2794
|
+
const { hiddenInputs } = this.#options;
|
|
2795
|
+
if (!hiddenInputs) {
|
|
2764
2796
|
return;
|
|
2765
2797
|
}
|
|
2766
2798
|
const telInputName = this.telInputEl.getAttribute("name") || "";
|
|
2767
|
-
const names =
|
|
2799
|
+
const names = hiddenInputs(telInputName);
|
|
2768
2800
|
if (names.phone) {
|
|
2769
2801
|
const existingInput = this.telInputEl.form?.querySelector(
|
|
2770
2802
|
`input[name="${names.phone}"]`
|
|
@@ -2829,7 +2861,7 @@ var _factory = (() => {
|
|
|
2829
2861
|
//* Update the input padding to make space for (1) the selected country/globe, (2) the arrow, and (3) the separate dial code, all of which are optional, hence handling this in the JS rather than CSS.
|
|
2830
2862
|
#updateInputPadding() {
|
|
2831
2863
|
if (this.#selectedCountryEl) {
|
|
2832
|
-
const fallbackWidth = this.#options.separateDialCode ? LAYOUT.
|
|
2864
|
+
const fallbackWidth = this.#options.separateDialCode ? LAYOUT.FALLBACK_SELECTED_COUNTRY_WITH_DIAL_WIDTH : LAYOUT.FALLBACK_SELECTED_COUNTRY_NO_DIAL_WIDTH;
|
|
2833
2865
|
const selectedCountryWidth = this.#selectedCountryEl.offsetWidth || this.#getHiddenSelectedCountryWidth() || fallbackWidth;
|
|
2834
2866
|
const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
|
|
2835
2867
|
this.telInputEl.style.paddingLeft = `${inputPadding}px`;
|
|
@@ -2883,24 +2915,24 @@ var _factory = (() => {
|
|
|
2883
2915
|
// Get the dropdown height (before it is added to the DOM)
|
|
2884
2916
|
#getHiddenInlineDropdownHeight() {
|
|
2885
2917
|
const body = _UI.#getBody();
|
|
2886
|
-
this.#
|
|
2918
|
+
this.#countrySelectorEl.classList.remove(CLASSES.HIDE);
|
|
2887
2919
|
const tempContainer = createEl("div", {
|
|
2888
|
-
class: "iti iti--inline-
|
|
2920
|
+
class: "iti iti--inline-country-selector"
|
|
2889
2921
|
});
|
|
2890
|
-
tempContainer.appendChild(this.#
|
|
2922
|
+
tempContainer.appendChild(this.#countrySelectorEl);
|
|
2891
2923
|
tempContainer.style.visibility = "hidden";
|
|
2892
2924
|
body.appendChild(tempContainer);
|
|
2893
|
-
const height = this.#
|
|
2925
|
+
const height = this.#countrySelectorEl.offsetHeight;
|
|
2894
2926
|
body.removeChild(tempContainer);
|
|
2895
2927
|
tempContainer.style.visibility = "";
|
|
2896
|
-
this.#
|
|
2928
|
+
this.#countrySelectorEl.classList.add(CLASSES.HIDE);
|
|
2897
2929
|
return height > 0 ? height : LAYOUT.FALLBACK_DROPDOWN_HEIGHT;
|
|
2898
2930
|
}
|
|
2899
2931
|
//* Update search results text (for a11y).
|
|
2900
2932
|
#updateSearchResultsA11yText() {
|
|
2901
|
-
const {
|
|
2933
|
+
const { uiTranslations } = this.#options;
|
|
2902
2934
|
const count = this.#countryListEl.childElementCount;
|
|
2903
|
-
this.#searchResultsLiveRegionEl.textContent =
|
|
2935
|
+
this.#searchResultsLiveRegionEl.textContent = uiTranslations.searchSummaryAria(count);
|
|
2904
2936
|
}
|
|
2905
2937
|
//* Country search: Filter the countries according to the search query.
|
|
2906
2938
|
#filterCountriesByQuery(query) {
|
|
@@ -2918,8 +2950,8 @@ var _factory = (() => {
|
|
|
2918
2950
|
this.#showFilteredCountries(matchedCountries);
|
|
2919
2951
|
}
|
|
2920
2952
|
//* Pre-fill the search input with "+" and show all countries
|
|
2921
|
-
//* (used when user types "+" in the phone input to open the
|
|
2922
|
-
//* Explicitly focus the search input (
|
|
2953
|
+
//* (used when user types "+" in the phone input to open the country selector).
|
|
2954
|
+
//* Explicitly focus the search input (openCountrySelector skips this when
|
|
2923
2955
|
//* dropdownAlwaysOpen, but here we need focus to redirect subsequent keystrokes).
|
|
2924
2956
|
prefillSearchWithPlus() {
|
|
2925
2957
|
this.#searchInputEl.value = "+";
|
|
@@ -3002,15 +3034,15 @@ var _factory = (() => {
|
|
|
3002
3034
|
{ signal }
|
|
3003
3035
|
);
|
|
3004
3036
|
}
|
|
3005
|
-
//* Wire up triggers that open/close the
|
|
3037
|
+
//* Wire up triggers that open/close the country selector: label click (focus input or swallow repeat click),
|
|
3006
3038
|
//* selected-country click (open), and keydown on countryContainer (open on arrow/space/enter, close on tab).
|
|
3007
|
-
|
|
3039
|
+
bindAllInitialCountrySelectorListeners(signal, onOpen, onClose) {
|
|
3008
3040
|
const label = this.telInputEl.closest("label");
|
|
3009
3041
|
if (label) {
|
|
3010
3042
|
label.addEventListener(
|
|
3011
3043
|
"click",
|
|
3012
3044
|
(e) => {
|
|
3013
|
-
if (!this.
|
|
3045
|
+
if (!this.isCountrySelectorOpen()) {
|
|
3014
3046
|
this.telInputEl.focus();
|
|
3015
3047
|
} else {
|
|
3016
3048
|
e.preventDefault();
|
|
@@ -3022,7 +3054,7 @@ var _factory = (() => {
|
|
|
3022
3054
|
this.#selectedCountryEl.addEventListener(
|
|
3023
3055
|
"click",
|
|
3024
3056
|
() => {
|
|
3025
|
-
if (!this.
|
|
3057
|
+
if (!this.isCountrySelectorOpen() && !this.telInputEl.disabled && !this.telInputEl.readOnly) {
|
|
3026
3058
|
onOpen();
|
|
3027
3059
|
}
|
|
3028
3060
|
},
|
|
@@ -3037,7 +3069,7 @@ var _factory = (() => {
|
|
|
3037
3069
|
KEYS.SPACE,
|
|
3038
3070
|
KEYS.ENTER
|
|
3039
3071
|
];
|
|
3040
|
-
if (!this.
|
|
3072
|
+
if (!this.isCountrySelectorOpen() && openKeys.includes(e.key)) {
|
|
3041
3073
|
e.preventDefault();
|
|
3042
3074
|
e.stopPropagation();
|
|
3043
3075
|
onOpen();
|
|
@@ -3049,24 +3081,24 @@ var _factory = (() => {
|
|
|
3049
3081
|
{ signal }
|
|
3050
3082
|
);
|
|
3051
3083
|
}
|
|
3052
|
-
//* Open the
|
|
3053
|
-
//*
|
|
3054
|
-
|
|
3055
|
-
const { countrySearch, dropdownAlwaysOpen
|
|
3056
|
-
this.#
|
|
3084
|
+
//* Open the country selector: create a fresh AbortController, do the DOM work, and wire up all
|
|
3085
|
+
//* open-state listeners (which invoke the caller's onSelect / onClose callbacks).
|
|
3086
|
+
openCountrySelector(onSelect, onClose) {
|
|
3087
|
+
const { countrySearch, dropdownAlwaysOpen } = this.#options;
|
|
3088
|
+
this.#countrySelectorAbortController = new AbortController();
|
|
3057
3089
|
this.ensureDropdownWidthSet();
|
|
3058
|
-
if (
|
|
3059
|
-
this.#
|
|
3090
|
+
if (this.#detachedCountrySelectorEl) {
|
|
3091
|
+
this.#injectAndPositionDetachedCountrySelector();
|
|
3060
3092
|
} else {
|
|
3061
|
-
const positionBelow = this.#
|
|
3093
|
+
const positionBelow = this.#shouldPositionDropdownBelowInput();
|
|
3062
3094
|
const distance = this.telInputEl.offsetHeight + LAYOUT.DROPDOWN_MARGIN;
|
|
3063
3095
|
if (positionBelow) {
|
|
3064
|
-
this.#
|
|
3096
|
+
this.#countrySelectorEl.style.top = `${distance}px`;
|
|
3065
3097
|
} else {
|
|
3066
|
-
this.#
|
|
3098
|
+
this.#countrySelectorEl.style.bottom = `${distance}px`;
|
|
3067
3099
|
}
|
|
3068
3100
|
}
|
|
3069
|
-
this.#
|
|
3101
|
+
this.#countrySelectorEl.classList.remove(CLASSES.HIDE);
|
|
3070
3102
|
this.#selectedCountryEl.setAttribute(ARIA.EXPANDED, "true");
|
|
3071
3103
|
const itemToHighlight = this.#selectedListItemEl ?? this.#countryListEl.firstElementChild;
|
|
3072
3104
|
if (itemToHighlight) {
|
|
@@ -3075,7 +3107,7 @@ var _factory = (() => {
|
|
|
3075
3107
|
if (countrySearch && !dropdownAlwaysOpen) {
|
|
3076
3108
|
this.#searchInputEl.focus();
|
|
3077
3109
|
}
|
|
3078
|
-
if (this.#options.
|
|
3110
|
+
if (this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN && this.#detachedCountrySelectorEl && window.visualViewport) {
|
|
3079
3111
|
window.visualViewport.addEventListener(
|
|
3080
3112
|
"resize",
|
|
3081
3113
|
() => {
|
|
@@ -3084,29 +3116,29 @@ var _factory = (() => {
|
|
|
3084
3116
|
this.#scrollCountryListToItem(this.#highlightedListItemEl);
|
|
3085
3117
|
}
|
|
3086
3118
|
},
|
|
3087
|
-
{ signal: this.#
|
|
3119
|
+
{ signal: this.#countrySelectorAbortController.signal }
|
|
3088
3120
|
);
|
|
3089
3121
|
}
|
|
3090
|
-
this.#
|
|
3091
|
-
this.#
|
|
3122
|
+
this.#arrowEl.classList.add(CLASSES.ARROW_UP);
|
|
3123
|
+
this.#bindCountrySelectorOpenListeners(onSelect, onClose);
|
|
3092
3124
|
}
|
|
3093
|
-
//* Wire up all listeners needed while the
|
|
3125
|
+
//* Wire up all listeners needed while the country selector is open: list-item hover (highlight),
|
|
3094
3126
|
//* list-item click & enter key (select), click-off & escape (close), search input (filter),
|
|
3095
|
-
//* (when countrySearch disabled) typed-char hidden search, and (when
|
|
3096
|
-
//* container)
|
|
3097
|
-
#
|
|
3098
|
-
const signal = this.#
|
|
3127
|
+
//* (when countrySearch disabled) typed-char hidden search, and (when the country selector is in an
|
|
3128
|
+
//* external container) update (fixed) position on scroll/resize.
|
|
3129
|
+
#bindCountrySelectorOpenListeners(onSelect, onClose) {
|
|
3130
|
+
const signal = this.#countrySelectorAbortController.signal;
|
|
3099
3131
|
this.#bindListItemHover(signal);
|
|
3100
3132
|
this.#bindListItemClick(signal, onSelect);
|
|
3101
3133
|
if (!this.#options.dropdownAlwaysOpen) {
|
|
3102
3134
|
this.#bindOutsideClickToClose(signal, onClose);
|
|
3103
3135
|
}
|
|
3104
|
-
this.#
|
|
3136
|
+
this.#bindCountrySelectorKeydownListener(signal, onSelect, onClose);
|
|
3105
3137
|
if (this.#options.countrySearch) {
|
|
3106
3138
|
this.#bindSearchInputListener(signal);
|
|
3107
3139
|
}
|
|
3108
|
-
if (
|
|
3109
|
-
|
|
3140
|
+
if (this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.DROPDOWN && this.#options.dropdownParent && !supportsCssAnchor) {
|
|
3141
|
+
document.addEventListener("scroll", onClose, { signal, capture: true, passive: true });
|
|
3110
3142
|
}
|
|
3111
3143
|
}
|
|
3112
3144
|
//* When mouse over a list item, just highlight that one (so if they hit "enter" we know which to select).
|
|
@@ -3139,13 +3171,13 @@ var _factory = (() => {
|
|
|
3139
3171
|
{ signal }
|
|
3140
3172
|
);
|
|
3141
3173
|
}
|
|
3142
|
-
//* Invoke onClickOff when the user clicks anywhere outside the
|
|
3174
|
+
//* Invoke onClickOff when the user clicks anywhere outside the country selector.
|
|
3143
3175
|
#bindOutsideClickToClose(signal, onClickOff) {
|
|
3144
3176
|
setTimeout(() => {
|
|
3145
3177
|
document.documentElement.addEventListener(
|
|
3146
3178
|
"click",
|
|
3147
3179
|
(e) => {
|
|
3148
|
-
if (!this.#
|
|
3180
|
+
if (!this.#countrySelectorEl.contains(e.target)) {
|
|
3149
3181
|
onClickOff();
|
|
3150
3182
|
}
|
|
3151
3183
|
},
|
|
@@ -3153,10 +3185,10 @@ var _factory = (() => {
|
|
|
3153
3185
|
);
|
|
3154
3186
|
}, 0);
|
|
3155
3187
|
}
|
|
3156
|
-
//* Keyboard navigation while the
|
|
3157
|
-
//* and enter/escape invoke the caller's callbacks (which handle country selection /
|
|
3188
|
+
//* Keyboard navigation while the country selector is open: arrow keys navigate, hidden-search keys filter,
|
|
3189
|
+
//* and enter/escape invoke the caller's callbacks (which handle country selection / close).
|
|
3158
3190
|
//* Uses keydown rather than keypress so non-char keys (arrow, esc) fire and so holding a key repeats.
|
|
3159
|
-
#
|
|
3191
|
+
#bindCountrySelectorKeydownListener(signal, onEnter, onEscape) {
|
|
3160
3192
|
let query = "";
|
|
3161
3193
|
let queryTimer = null;
|
|
3162
3194
|
const handleKeydown = (e) => {
|
|
@@ -3191,7 +3223,7 @@ var _factory = (() => {
|
|
|
3191
3223
|
}
|
|
3192
3224
|
};
|
|
3193
3225
|
this.#selectedCountryEl?.addEventListener("keydown", handleKeydown, { signal });
|
|
3194
|
-
this.#
|
|
3226
|
+
this.#countrySelectorEl?.addEventListener("keydown", handleKeydown, { signal });
|
|
3195
3227
|
}
|
|
3196
3228
|
//* Wire up country search input listener: typing filters the list, the clear button resets it.
|
|
3197
3229
|
#bindSearchInputListener(signal) {
|
|
@@ -3228,7 +3260,7 @@ var _factory = (() => {
|
|
|
3228
3260
|
this.#highlightListItem(next);
|
|
3229
3261
|
}
|
|
3230
3262
|
}
|
|
3231
|
-
// Update the selected list item in the
|
|
3263
|
+
// Update the selected list item in the country list
|
|
3232
3264
|
#updateSelectedListItem(iso2) {
|
|
3233
3265
|
if (this.#selectedListItemEl && this.#selectedListItemEl.dataset[DATA_KEYS.ISO2] !== iso2) {
|
|
3234
3266
|
this.#selectedListItemEl.setAttribute(ARIA.SELECTED, "false");
|
|
@@ -3279,12 +3311,12 @@ var _factory = (() => {
|
|
|
3279
3311
|
this.#countryListEl.scrollTop = 0;
|
|
3280
3312
|
this.#updateSearchResultsA11yText();
|
|
3281
3313
|
}
|
|
3282
|
-
// UI: Close the
|
|
3283
|
-
|
|
3284
|
-
const { countrySearch
|
|
3285
|
-
this.#
|
|
3286
|
-
this.#
|
|
3287
|
-
this.#
|
|
3314
|
+
// UI: Close the country selector (DOM + abort scoped listeners).
|
|
3315
|
+
closeCountrySelector() {
|
|
3316
|
+
const { countrySearch } = this.#options;
|
|
3317
|
+
this.#countrySelectorAbortController.abort();
|
|
3318
|
+
this.#countrySelectorAbortController = null;
|
|
3319
|
+
this.#countrySelectorEl.classList.add(CLASSES.HIDE);
|
|
3288
3320
|
this.#selectedCountryEl.setAttribute(ARIA.EXPANDED, "false");
|
|
3289
3321
|
if (countrySearch) {
|
|
3290
3322
|
this.#searchInputEl.removeAttribute(ARIA.ACTIVE_DESCENDANT);
|
|
@@ -3295,19 +3327,19 @@ var _factory = (() => {
|
|
|
3295
3327
|
this.#highlightedListItemEl = null;
|
|
3296
3328
|
}
|
|
3297
3329
|
}
|
|
3298
|
-
this.#
|
|
3299
|
-
if (
|
|
3300
|
-
this.#
|
|
3301
|
-
this.#
|
|
3302
|
-
this.#
|
|
3303
|
-
this.#
|
|
3304
|
-
this.#
|
|
3330
|
+
this.#arrowEl.classList.remove(CLASSES.ARROW_UP);
|
|
3331
|
+
if (this.#detachedCountrySelectorEl) {
|
|
3332
|
+
this.#detachedCountrySelectorEl.remove();
|
|
3333
|
+
this.#detachedCountrySelectorEl.style.top = "";
|
|
3334
|
+
this.#detachedCountrySelectorEl.style.bottom = "";
|
|
3335
|
+
this.#detachedCountrySelectorEl.style.paddingLeft = "";
|
|
3336
|
+
this.#detachedCountrySelectorEl.style.paddingRight = "";
|
|
3305
3337
|
} else {
|
|
3306
|
-
this.#
|
|
3307
|
-
this.#
|
|
3338
|
+
this.#countrySelectorEl.style.top = "";
|
|
3339
|
+
this.#countrySelectorEl.style.bottom = "";
|
|
3308
3340
|
}
|
|
3309
3341
|
}
|
|
3310
|
-
#
|
|
3342
|
+
#shouldPositionDropdownBelowInput() {
|
|
3311
3343
|
if (this.#options.dropdownAlwaysOpen) {
|
|
3312
3344
|
return true;
|
|
3313
3345
|
}
|
|
@@ -3316,41 +3348,54 @@ var _factory = (() => {
|
|
|
3316
3348
|
const spaceBelow = window.innerHeight - inputPos.bottom;
|
|
3317
3349
|
return spaceBelow >= this.#inlineDropdownHeight || spaceBelow >= spaceAbove;
|
|
3318
3350
|
}
|
|
3319
|
-
// inject
|
|
3320
|
-
#
|
|
3321
|
-
const
|
|
3322
|
-
|
|
3351
|
+
// inject the country selector into its detached wrapper and apply positioning styles
|
|
3352
|
+
#injectAndPositionDetachedCountrySelector() {
|
|
3353
|
+
const isFullscreen = this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
3354
|
+
const detachedParent = this.#getDetachedParent();
|
|
3355
|
+
if (isFullscreen) {
|
|
3323
3356
|
if (window.innerWidth >= LAYOUT.NARROW_VIEWPORT_WIDTH) {
|
|
3324
3357
|
const inputPos = this.telInputEl.getBoundingClientRect();
|
|
3325
|
-
this.#
|
|
3326
|
-
this.#
|
|
3358
|
+
this.#detachedCountrySelectorEl.style.paddingLeft = `${inputPos.left}px`;
|
|
3359
|
+
this.#detachedCountrySelectorEl.style.paddingRight = `${window.innerWidth - inputPos.right}px`;
|
|
3327
3360
|
}
|
|
3328
|
-
} else {
|
|
3361
|
+
} else if (!supportsCssAnchor) {
|
|
3329
3362
|
const inputPos = this.telInputEl.getBoundingClientRect();
|
|
3330
|
-
this.#
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
this.#detachedDropdownEl.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3363
|
+
this.#detachedCountrySelectorEl.style.left = `${inputPos.left}px`;
|
|
3364
|
+
if (this.#shouldPositionDropdownBelowInput()) {
|
|
3365
|
+
this.#detachedCountrySelectorEl.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3334
3366
|
} else {
|
|
3335
|
-
this.#
|
|
3336
|
-
this.#
|
|
3367
|
+
this.#detachedCountrySelectorEl.style.top = "unset";
|
|
3368
|
+
this.#detachedCountrySelectorEl.style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3337
3369
|
}
|
|
3338
3370
|
}
|
|
3339
|
-
|
|
3371
|
+
detachedParent.appendChild(this.#detachedCountrySelectorEl);
|
|
3372
|
+
}
|
|
3373
|
+
//* Wire up CSS Anchor Positioning between the input and the detached country selector using a
|
|
3374
|
+
//* unique anchor name per instance. Called once at build time — the matching styles in
|
|
3375
|
+
//* intlTelInput.css only take effect in browsers that support anchor(); elsewhere these
|
|
3376
|
+
//* properties are inert. We append our name to any existing anchor-name (read via
|
|
3377
|
+
//* getComputedStyle so we pick up CSS-defined values), so consumer-set anchors on the input
|
|
3378
|
+
//* are preserved. Caveat: this snapshots the consumer's value once — if they later change
|
|
3379
|
+
//* anchor-name via CSS (e.g. a class swap), our inline write will shadow the change.
|
|
3380
|
+
#setupCssAnchorPositioning() {
|
|
3381
|
+
const anchorName = `--iti-anchor-${this.#id}`;
|
|
3382
|
+
const existing = getComputedStyle(this.telInputEl).anchorName;
|
|
3383
|
+
this.telInputEl.style.anchorName = existing && existing !== "none" ? `${existing}, ${anchorName}` : anchorName;
|
|
3384
|
+
this.#detachedCountrySelectorEl.style.positionAnchor = anchorName;
|
|
3340
3385
|
}
|
|
3341
3386
|
// Adjust the fullscreen popup dimensions to match the visual viewport,
|
|
3342
3387
|
// so it stays above the virtual keyboard on mobile devices.
|
|
3343
3388
|
#adjustFullscreenPopupToViewport() {
|
|
3344
3389
|
const vv = window.visualViewport;
|
|
3345
|
-
if (!vv || !this.#
|
|
3390
|
+
if (!vv || !this.#detachedCountrySelectorEl) {
|
|
3346
3391
|
return;
|
|
3347
3392
|
}
|
|
3348
3393
|
const virtualKeyboardHeight = window.innerHeight - vv.height;
|
|
3349
|
-
this.#
|
|
3394
|
+
this.#detachedCountrySelectorEl.style.bottom = `${virtualKeyboardHeight}px`;
|
|
3350
3395
|
}
|
|
3351
|
-
// UI: Whether the
|
|
3352
|
-
|
|
3353
|
-
return !this.#
|
|
3396
|
+
// UI: Whether the country selector is currently open (visible).
|
|
3397
|
+
isCountrySelectorOpen() {
|
|
3398
|
+
return !this.#countrySelectorEl.classList.contains(CLASSES.HIDE);
|
|
3354
3399
|
}
|
|
3355
3400
|
// Toggle the loading spinner on the selected flag (used during auto-country geoIP lookup).
|
|
3356
3401
|
setLoading(isLoading) {
|
|
@@ -3379,7 +3424,7 @@ var _factory = (() => {
|
|
|
3379
3424
|
isLoading() {
|
|
3380
3425
|
return this.#selectedFlagEl.classList.contains(CLASSES.LOADING);
|
|
3381
3426
|
}
|
|
3382
|
-
// Set the disabled state of the input and
|
|
3427
|
+
// Set the disabled state of the input and country selector.
|
|
3383
3428
|
setDisabled(disabled) {
|
|
3384
3429
|
this.telInputEl.disabled = disabled;
|
|
3385
3430
|
if (this.#selectedCountryEl) {
|
|
@@ -3390,7 +3435,7 @@ var _factory = (() => {
|
|
|
3390
3435
|
}
|
|
3391
3436
|
}
|
|
3392
3437
|
}
|
|
3393
|
-
// Set the readonly state of the input and
|
|
3438
|
+
// Set the readonly state of the input and country selector.
|
|
3394
3439
|
setReadonly(readonly) {
|
|
3395
3440
|
this.telInputEl.readOnly = readonly;
|
|
3396
3441
|
if (this.#selectedCountryEl) {
|
|
@@ -3401,12 +3446,12 @@ var _factory = (() => {
|
|
|
3401
3446
|
}
|
|
3402
3447
|
}
|
|
3403
3448
|
}
|
|
3404
|
-
|
|
3405
|
-
const {
|
|
3406
|
-
const name =
|
|
3407
|
-
const dialCode =
|
|
3408
|
-
const iso2 =
|
|
3409
|
-
if (
|
|
3449
|
+
setSelectedCountry(selectedCountry) {
|
|
3450
|
+
const { countrySelectorMode, showFlags, separateDialCode, uiTranslations } = this.#options;
|
|
3451
|
+
const name = selectedCountry?.name;
|
|
3452
|
+
const dialCode = selectedCountry?.dialCode;
|
|
3453
|
+
const iso2 = selectedCountry?.iso2 ?? "";
|
|
3454
|
+
if (countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
3410
3455
|
this.#updateSelectedListItem(iso2);
|
|
3411
3456
|
}
|
|
3412
3457
|
if (this.#selectedCountryEl) {
|
|
@@ -3415,13 +3460,13 @@ var _factory = (() => {
|
|
|
3415
3460
|
let flagContent = null;
|
|
3416
3461
|
if (iso2) {
|
|
3417
3462
|
title = name;
|
|
3418
|
-
ariaLabel =
|
|
3463
|
+
ariaLabel = uiTranslations.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
|
|
3419
3464
|
if (!showFlags) {
|
|
3420
3465
|
flagContent = buildGlobeIcon();
|
|
3421
3466
|
}
|
|
3422
3467
|
} else {
|
|
3423
|
-
title =
|
|
3424
|
-
ariaLabel =
|
|
3468
|
+
title = uiTranslations.noCountrySelected;
|
|
3469
|
+
ariaLabel = uiTranslations.noCountrySelected;
|
|
3425
3470
|
flagContent = buildGlobeIcon();
|
|
3426
3471
|
}
|
|
3427
3472
|
this.#selectedFlagEl.className = flagClass;
|
|
@@ -3570,17 +3615,17 @@ var _factory = (() => {
|
|
|
3570
3615
|
};
|
|
3571
3616
|
|
|
3572
3617
|
// packages/core/src/js/format/formatting.ts
|
|
3573
|
-
var stripSeparateDialCode = (fullNumber, hasValidDialCode, separateDialCode,
|
|
3618
|
+
var stripSeparateDialCode = (fullNumber, hasValidDialCode, separateDialCode, selectedCountry) => {
|
|
3574
3619
|
if (!separateDialCode || !hasValidDialCode) {
|
|
3575
3620
|
return fullNumber;
|
|
3576
3621
|
}
|
|
3577
|
-
const dialCode = `+${
|
|
3622
|
+
const dialCode = `+${selectedCountry.dialCode}`;
|
|
3578
3623
|
const start = fullNumber[dialCode.length] === " " || fullNumber[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
|
|
3579
3624
|
return fullNumber.substring(start);
|
|
3580
3625
|
};
|
|
3581
|
-
var formatNumberAsYouType = (fullNumber, telInputValue, utils,
|
|
3582
|
-
const result = utils ? utils.formatNumberAsYouType(fullNumber,
|
|
3583
|
-
const dialCode =
|
|
3626
|
+
var formatNumberAsYouType = (fullNumber, telInputValue, utils, selectedCountry, separateDialCode) => {
|
|
3627
|
+
const result = utils ? utils.formatNumberAsYouType(fullNumber, selectedCountry?.iso2) : fullNumber;
|
|
3628
|
+
const dialCode = selectedCountry?.dialCode;
|
|
3584
3629
|
if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
|
|
3585
3630
|
const afterDialCode = result.split(`+${dialCode}`)[1] || "";
|
|
3586
3631
|
return afterDialCode.trim();
|
|
@@ -3711,8 +3756,8 @@ var _factory = (() => {
|
|
|
3711
3756
|
this.#ui.telInputEl.value = this.#numerals.denormalise(asciiValue);
|
|
3712
3757
|
}
|
|
3713
3758
|
#createInitPromise(options) {
|
|
3714
|
-
const { initialCountry,
|
|
3715
|
-
const needsAutoCountryDeferred = initialCountry
|
|
3759
|
+
const { initialCountry, initialCountryLookup, loadUtils } = options;
|
|
3760
|
+
const needsAutoCountryDeferred = !initialCountry && Boolean(initialCountryLookup);
|
|
3716
3761
|
const needsUtilsDeferred = Boolean(loadUtils) && !intlTelInput.utils;
|
|
3717
3762
|
if (needsAutoCountryDeferred) {
|
|
3718
3763
|
this.#autoCountryDeferred = createDeferred();
|
|
@@ -3734,7 +3779,7 @@ var _factory = (() => {
|
|
|
3734
3779
|
this.#initListeners();
|
|
3735
3780
|
this.#startAsyncLoads();
|
|
3736
3781
|
if (this.#options.dropdownAlwaysOpen) {
|
|
3737
|
-
this
|
|
3782
|
+
this.openCountrySelector();
|
|
3738
3783
|
}
|
|
3739
3784
|
}
|
|
3740
3785
|
//********************
|
|
@@ -3757,8 +3802,8 @@ var _factory = (() => {
|
|
|
3757
3802
|
const value = useAttribute ? attributeValue : inputValue;
|
|
3758
3803
|
const dialCode = this.#getDialCode(value);
|
|
3759
3804
|
const isRegionlessNanpNumber = isRegionlessNanp(value);
|
|
3760
|
-
const { initialCountry,
|
|
3761
|
-
const isAutoCountry = initialCountry
|
|
3805
|
+
const { initialCountry, initialCountryLookup } = this.#options;
|
|
3806
|
+
const isAutoCountry = !initialCountry && Boolean(initialCountryLookup);
|
|
3762
3807
|
const resolvedInitialCountry = isAutoCountry && intlTelInput.autoCountry ? intlTelInput.autoCountry : initialCountry;
|
|
3763
3808
|
const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry && !intlTelInput.autoCountry;
|
|
3764
3809
|
const isValidInitialCountry = isIso2(resolvedInitialCountry);
|
|
@@ -3787,11 +3832,11 @@ var _factory = (() => {
|
|
|
3787
3832
|
//* Initialise the main event listeners: input keyup, and click selected country.
|
|
3788
3833
|
#initListeners() {
|
|
3789
3834
|
this.#bindAllTelInputListeners();
|
|
3790
|
-
if (this.#options.
|
|
3791
|
-
this.#ui.
|
|
3835
|
+
if (this.#options.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
3836
|
+
this.#ui.bindAllInitialCountrySelectorListeners(
|
|
3792
3837
|
this.#abortController.signal,
|
|
3793
|
-
() => this
|
|
3794
|
-
() => this.#
|
|
3838
|
+
() => this.openCountrySelector(),
|
|
3839
|
+
() => this.#closeCountrySelectorInternal()
|
|
3795
3840
|
);
|
|
3796
3841
|
}
|
|
3797
3842
|
this.#ui.bindHiddenInputSubmitListener(
|
|
@@ -3800,7 +3845,7 @@ var _factory = (() => {
|
|
|
3800
3845
|
() => this.#selectedCountry?.iso2 || ""
|
|
3801
3846
|
);
|
|
3802
3847
|
}
|
|
3803
|
-
//* Init requests: utils script /
|
|
3848
|
+
//* Init requests: utils script / initial country lookup.
|
|
3804
3849
|
#startAsyncLoads() {
|
|
3805
3850
|
if (this.#utilsDeferred) {
|
|
3806
3851
|
const { loadUtils } = this.#options;
|
|
@@ -3824,7 +3869,7 @@ var _factory = (() => {
|
|
|
3824
3869
|
}
|
|
3825
3870
|
}
|
|
3826
3871
|
}
|
|
3827
|
-
//* Perform the
|
|
3872
|
+
//* Perform the initial country lookup.
|
|
3828
3873
|
async #loadAutoCountry() {
|
|
3829
3874
|
if (intlTelInput.autoCountry) {
|
|
3830
3875
|
this.#handleAutoCountryLoaded();
|
|
@@ -3835,14 +3880,14 @@ var _factory = (() => {
|
|
|
3835
3880
|
return;
|
|
3836
3881
|
}
|
|
3837
3882
|
intlTelInput.startedLoadingAutoCountry = true;
|
|
3838
|
-
if (typeof this.#options.
|
|
3883
|
+
if (typeof this.#options.initialCountryLookup === "function") {
|
|
3839
3884
|
let timeoutId;
|
|
3840
3885
|
try {
|
|
3841
3886
|
const iso2 = await Promise.race([
|
|
3842
|
-
this.#options.
|
|
3887
|
+
this.#options.initialCountryLookup(),
|
|
3843
3888
|
new Promise((_, reject) => {
|
|
3844
3889
|
timeoutId = setTimeout(
|
|
3845
|
-
() => reject(new Error("intl-tel-input:
|
|
3890
|
+
() => reject(new Error("intl-tel-input: initialCountryLookup timed out after 10s")),
|
|
3846
3891
|
1e4
|
|
3847
3892
|
);
|
|
3848
3893
|
})
|
|
@@ -3865,8 +3910,8 @@ var _factory = (() => {
|
|
|
3865
3910
|
}
|
|
3866
3911
|
}
|
|
3867
3912
|
}
|
|
3868
|
-
#
|
|
3869
|
-
this
|
|
3913
|
+
#openCountrySelectorWithPlus() {
|
|
3914
|
+
this.openCountrySelector();
|
|
3870
3915
|
this.#ui.prefillSearchWithPlus();
|
|
3871
3916
|
}
|
|
3872
3917
|
//* Delete the character just typed (the one immediately before the caret). Used by Android workarounds where we can't preventDefault on keydown.
|
|
@@ -3886,7 +3931,7 @@ var _factory = (() => {
|
|
|
3886
3931
|
//* Android workaround for handling plus when separateDialCode enabled (as impossible to handle with keydown/keyup, for which e.key always returns "Unidentified", see https://stackoverflow.com/q/59584061/217866)
|
|
3887
3932
|
#handleAndroidPlusKey(inputValue) {
|
|
3888
3933
|
this.#removeJustTypedChar(inputValue);
|
|
3889
|
-
this.#
|
|
3934
|
+
this.#openCountrySelectorWithPlus();
|
|
3890
3935
|
}
|
|
3891
3936
|
//* Android strictMode workaround: the keydown-based filter can't block these because e.key is "Unidentified" on Android virtual keyboards, so strip them here on input.
|
|
3892
3937
|
#handleAndroidStrictReject(inputValue, rejectedInput) {
|
|
@@ -3956,7 +4001,7 @@ var _factory = (() => {
|
|
|
3956
4001
|
strictMode,
|
|
3957
4002
|
formatAsYouType,
|
|
3958
4003
|
separateDialCode,
|
|
3959
|
-
|
|
4004
|
+
countrySelectorMode,
|
|
3960
4005
|
countrySearch
|
|
3961
4006
|
} = this.#options;
|
|
3962
4007
|
const detail = e?.detail;
|
|
@@ -3966,7 +4011,7 @@ var _factory = (() => {
|
|
|
3966
4011
|
let inputValue = this.#getTelInputValue();
|
|
3967
4012
|
const isPaste = e?.inputType === INPUT_TYPES.PASTE;
|
|
3968
4013
|
const isStrictPaste = strictMode && isPaste;
|
|
3969
|
-
if (this.#isAndroid && !isPaste && e?.data === "+" && separateDialCode &&
|
|
4014
|
+
if (this.#isAndroid && !isPaste && e?.data === "+" && separateDialCode && countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && countrySearch) {
|
|
3970
4015
|
this.#handleAndroidPlusKey(inputValue);
|
|
3971
4016
|
return;
|
|
3972
4017
|
}
|
|
@@ -4013,13 +4058,13 @@ var _factory = (() => {
|
|
|
4013
4058
|
//* On keydown event: (1) if strictMode then prevent invalid characters, (2) if separateDialCode then handle plus key
|
|
4014
4059
|
//* Note that this fires BEFORE the input is updated.
|
|
4015
4060
|
#handleKeydownEvent = (e) => {
|
|
4016
|
-
const { strictMode, separateDialCode,
|
|
4061
|
+
const { strictMode, separateDialCode, countrySelectorMode, countrySearch } = this.#options;
|
|
4017
4062
|
if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) {
|
|
4018
4063
|
return;
|
|
4019
4064
|
}
|
|
4020
|
-
if (separateDialCode &&
|
|
4065
|
+
if (separateDialCode && countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && countrySearch && e.key === "+") {
|
|
4021
4066
|
e.preventDefault();
|
|
4022
|
-
this.#
|
|
4067
|
+
this.#openCountrySelectorWithPlus();
|
|
4023
4068
|
return;
|
|
4024
4069
|
}
|
|
4025
4070
|
if (!strictMode) {
|
|
@@ -4182,27 +4227,36 @@ var _factory = (() => {
|
|
|
4182
4227
|
});
|
|
4183
4228
|
this.#ui.telInputEl.dispatchEvent(e);
|
|
4184
4229
|
}
|
|
4185
|
-
//* Open the
|
|
4186
|
-
//* and its listeners leak. Reachable via
|
|
4187
|
-
|
|
4188
|
-
|
|
4230
|
+
//* Open the country selector. Bail if already open — otherwise the existing AbortController gets overwritten
|
|
4231
|
+
//* and its listeners leak. Reachable via openCountrySelectorWithPlus when dropdownAlwaysOpen is set.
|
|
4232
|
+
//* Public so consumers can programmatically open the country selector.
|
|
4233
|
+
openCountrySelector() {
|
|
4234
|
+
if (this.#ui.isCountrySelectorOpen()) {
|
|
4189
4235
|
return;
|
|
4190
4236
|
}
|
|
4191
|
-
this.#ui.
|
|
4237
|
+
this.#ui.openCountrySelector(
|
|
4192
4238
|
(li) => this.#selectListItem(li),
|
|
4193
|
-
() => this.#
|
|
4239
|
+
() => this.#closeCountrySelectorInternal()
|
|
4194
4240
|
);
|
|
4195
|
-
this.#dispatchEvent(EVENTS.
|
|
4241
|
+
this.#dispatchEvent(EVENTS.OPEN_COUNTRY_SELECTOR);
|
|
4196
4242
|
}
|
|
4197
4243
|
//* Update the input's value to the given number (format first if possible)
|
|
4198
4244
|
//* NOTE: this is called from setInitialState, handleUtilsLoaded and setNumber.
|
|
4199
4245
|
#updateValueFromNumber(fullNumber) {
|
|
4200
|
-
const {
|
|
4246
|
+
const { numberDisplayFormat, separateDialCode } = this.#options;
|
|
4201
4247
|
let number = fullNumber;
|
|
4202
|
-
if (
|
|
4248
|
+
if (intlTelInput.utils && this.#selectedCountry) {
|
|
4203
4249
|
const isRegionless = hasRegionlessDialCode(fullNumber);
|
|
4204
|
-
const
|
|
4205
|
-
const
|
|
4250
|
+
const preserveUserNational = !number.startsWith("+") && !separateDialCode;
|
|
4251
|
+
const useNational = numberDisplayFormat === NUMBER_FORMAT.NATIONAL && !isRegionless || preserveUserNational;
|
|
4252
|
+
let format;
|
|
4253
|
+
if (useNational) {
|
|
4254
|
+
format = NUMBER_FORMAT.NATIONAL;
|
|
4255
|
+
} else if (numberDisplayFormat === NUMBER_FORMAT.E164 && !isRegionless) {
|
|
4256
|
+
format = NUMBER_FORMAT.E164;
|
|
4257
|
+
} else {
|
|
4258
|
+
format = NUMBER_FORMAT.INTERNATIONAL;
|
|
4259
|
+
}
|
|
4206
4260
|
number = intlTelInput.utils.formatNumber(
|
|
4207
4261
|
number,
|
|
4208
4262
|
this.#selectedCountry?.iso2,
|
|
@@ -4299,14 +4353,14 @@ var _factory = (() => {
|
|
|
4299
4353
|
return null;
|
|
4300
4354
|
}
|
|
4301
4355
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
4302
|
-
//* Note: called from setInitialState, updateCountryFromNumber, selectListItem,
|
|
4356
|
+
//* Note: called from setInitialState, updateCountryFromNumber, selectListItem, setSelectedCountry.
|
|
4303
4357
|
#updateSelectedCountry(iso2) {
|
|
4304
4358
|
const prevIso2 = this.#selectedCountry?.iso2 || "";
|
|
4305
4359
|
this.#selectedCountry = iso2 ? this.#countryByIso2.get(iso2) : null;
|
|
4306
4360
|
if (this.#selectedCountry) {
|
|
4307
4361
|
this.#fallbackCountryIso2 = this.#selectedCountry.iso2;
|
|
4308
4362
|
}
|
|
4309
|
-
this.#ui.
|
|
4363
|
+
this.#ui.setSelectedCountry(this.#selectedCountry);
|
|
4310
4364
|
this.#updatePlaceholder();
|
|
4311
4365
|
this.#updateMaxCoreNumberLength();
|
|
4312
4366
|
return prevIso2 !== iso2;
|
|
@@ -4324,12 +4378,11 @@ var _factory = (() => {
|
|
|
4324
4378
|
}
|
|
4325
4379
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
4326
4380
|
iso2,
|
|
4327
|
-
false,
|
|
4328
4381
|
placeholderNumberType,
|
|
4329
|
-
|
|
4382
|
+
NUMBER_FORMAT.E164
|
|
4330
4383
|
);
|
|
4331
4384
|
let validNumber = exampleNumber;
|
|
4332
|
-
while (intlTelInput.utils.
|
|
4385
|
+
while (intlTelInput.utils.isValidNumber(
|
|
4333
4386
|
exampleNumber,
|
|
4334
4387
|
iso2,
|
|
4335
4388
|
allowedNumberTypes
|
|
@@ -4346,19 +4399,19 @@ var _factory = (() => {
|
|
|
4346
4399
|
//* Update the input placeholder to an example number from the currently selected country.
|
|
4347
4400
|
#updatePlaceholder() {
|
|
4348
4401
|
const {
|
|
4349
|
-
|
|
4402
|
+
placeholderNumberPolicy,
|
|
4350
4403
|
placeholderNumberType,
|
|
4351
|
-
|
|
4404
|
+
numberDisplayFormat,
|
|
4352
4405
|
customPlaceholder
|
|
4353
4406
|
} = this.#options;
|
|
4354
|
-
const shouldSetPlaceholder =
|
|
4407
|
+
const shouldSetPlaceholder = placeholderNumberPolicy === PLACEHOLDER_POLICY.AGGRESSIVE || !this.#ui.hadInitialPlaceholder && placeholderNumberPolicy === PLACEHOLDER_POLICY.POLITE;
|
|
4355
4408
|
if (!intlTelInput.utils || !shouldSetPlaceholder) {
|
|
4356
4409
|
return;
|
|
4357
4410
|
}
|
|
4358
4411
|
let placeholder = this.#selectedCountry ? intlTelInput.utils.getExampleNumber(
|
|
4359
4412
|
this.#selectedCountry.iso2,
|
|
4360
|
-
|
|
4361
|
-
|
|
4413
|
+
placeholderNumberType,
|
|
4414
|
+
numberDisplayFormat
|
|
4362
4415
|
) : "";
|
|
4363
4416
|
placeholder = this.#prepareNumberForInput(placeholder);
|
|
4364
4417
|
if (typeof customPlaceholder === "function") {
|
|
@@ -4366,36 +4419,40 @@ var _factory = (() => {
|
|
|
4366
4419
|
}
|
|
4367
4420
|
this.#ui.telInputEl.setAttribute("placeholder", placeholder);
|
|
4368
4421
|
}
|
|
4369
|
-
//* Called when the user selects a list item from the
|
|
4422
|
+
//* Called when the user selects a list item from the country list (no-op if listItem is null).
|
|
4370
4423
|
#selectListItem(listItem) {
|
|
4371
4424
|
if (!listItem) {
|
|
4372
4425
|
return;
|
|
4373
4426
|
}
|
|
4374
4427
|
const iso2 = listItem.dataset[DATA_KEYS.ISO2];
|
|
4375
4428
|
const countryChanged = this.#updateSelectedCountry(iso2);
|
|
4376
|
-
this.#
|
|
4429
|
+
this.#closeCountrySelectorInternal();
|
|
4377
4430
|
const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
|
|
4378
4431
|
this.#updateDialCode(dialCode);
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
this.#updateValueFromNumber(inputValue);
|
|
4382
|
-
}
|
|
4432
|
+
const inputValue = this.#getTelInputValue();
|
|
4433
|
+
this.#updateValueFromNumber(inputValue);
|
|
4383
4434
|
this.#ui.telInputEl.focus();
|
|
4384
4435
|
if (countryChanged) {
|
|
4385
4436
|
this.#dispatchCountryChangeEvent();
|
|
4386
4437
|
this.#dispatchEvent(EVENTS.INPUT, { isCountryChange: true });
|
|
4387
4438
|
}
|
|
4388
4439
|
}
|
|
4389
|
-
//*
|
|
4390
|
-
|
|
4391
|
-
|
|
4440
|
+
//* Public: close the country selector (consumer-callable; delegates to the internal helper
|
|
4441
|
+
//* without the destroy-specific path).
|
|
4442
|
+
closeCountrySelector() {
|
|
4443
|
+
this.#closeCountrySelectorInternal();
|
|
4444
|
+
}
|
|
4445
|
+
//* Close the country selector and unbind any listeners. The isDestroy flag forces close even
|
|
4446
|
+
//* when dropdownAlwaysOpen is set, so destroy() can fully tear down.
|
|
4447
|
+
#closeCountrySelectorInternal(isDestroy) {
|
|
4448
|
+
if (!this.#ui.isCountrySelectorOpen() || this.#options.dropdownAlwaysOpen && !isDestroy) {
|
|
4392
4449
|
return;
|
|
4393
4450
|
}
|
|
4394
|
-
this.#ui.
|
|
4395
|
-
this.#dispatchEvent(EVENTS.
|
|
4451
|
+
this.#ui.closeCountrySelector();
|
|
4452
|
+
this.#dispatchEvent(EVENTS.CLOSE_COUNTRY_SELECTOR);
|
|
4396
4453
|
}
|
|
4397
4454
|
//* Replace any existing dial code with the new one
|
|
4398
|
-
//* Note: called from selectListItem and
|
|
4455
|
+
//* Note: called from selectListItem and setSelectedCountry
|
|
4399
4456
|
#updateDialCode(newDialCodeDigits) {
|
|
4400
4457
|
const inputValue = this.#getTelInputValue();
|
|
4401
4458
|
if (!inputValue.startsWith("+")) {
|
|
@@ -4475,7 +4532,7 @@ var _factory = (() => {
|
|
|
4475
4532
|
//**************************
|
|
4476
4533
|
//* INTERNAL METHODS
|
|
4477
4534
|
//**************************
|
|
4478
|
-
//* Called when the
|
|
4535
|
+
//* Called when the initial country lookup returns.
|
|
4479
4536
|
#handleAutoCountryLoaded() {
|
|
4480
4537
|
if (!this.#autoCountryDeferred || !intlTelInput.autoCountry) {
|
|
4481
4538
|
return;
|
|
@@ -4484,15 +4541,17 @@ var _factory = (() => {
|
|
|
4484
4541
|
this.#autoCountryDeferred.resolve();
|
|
4485
4542
|
return;
|
|
4486
4543
|
}
|
|
4487
|
-
|
|
4488
|
-
|
|
4544
|
+
const isFocused = document.activeElement === this.#ui.telInputEl;
|
|
4545
|
+
const hasTypedValue = Boolean(this.#getTelInputValue());
|
|
4546
|
+
if (this.#ui.isLoading() && !(isFocused && hasTypedValue)) {
|
|
4547
|
+
this.setSelectedCountry(intlTelInput.autoCountry);
|
|
4489
4548
|
} else {
|
|
4490
4549
|
this.#fallbackCountryIso2 = intlTelInput.autoCountry;
|
|
4491
4550
|
}
|
|
4492
4551
|
this.#ui.setLoading(false);
|
|
4493
4552
|
this.#autoCountryDeferred.resolve();
|
|
4494
4553
|
}
|
|
4495
|
-
//* Called when the
|
|
4554
|
+
//* Called when the initial country lookup fails or times out.
|
|
4496
4555
|
#handleAutoCountryFailure() {
|
|
4497
4556
|
if (!this.#isActive) {
|
|
4498
4557
|
this.#autoCountryDeferred?.reject();
|
|
@@ -4513,7 +4572,8 @@ var _factory = (() => {
|
|
|
4513
4572
|
return;
|
|
4514
4573
|
}
|
|
4515
4574
|
const inputValue = this.#getTelInputValue();
|
|
4516
|
-
|
|
4575
|
+
const isFocused = document.activeElement === this.#ui.telInputEl;
|
|
4576
|
+
if (inputValue && !isFocused) {
|
|
4517
4577
|
this.#updateValueFromNumber(inputValue);
|
|
4518
4578
|
}
|
|
4519
4579
|
if (this.#selectedCountry) {
|
|
@@ -4539,8 +4599,8 @@ var _factory = (() => {
|
|
|
4539
4599
|
return;
|
|
4540
4600
|
}
|
|
4541
4601
|
this.#isActive = false;
|
|
4542
|
-
if (this.#options.
|
|
4543
|
-
this.#
|
|
4602
|
+
if (this.#options.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
4603
|
+
this.#closeCountrySelectorInternal(true);
|
|
4544
4604
|
}
|
|
4545
4605
|
this.#abortController.abort();
|
|
4546
4606
|
this.#ui.destroy();
|
|
@@ -4588,7 +4648,7 @@ var _factory = (() => {
|
|
|
4588
4648
|
);
|
|
4589
4649
|
}
|
|
4590
4650
|
//* Get the country data for the currently selected country.
|
|
4591
|
-
|
|
4651
|
+
getSelectedCountry() {
|
|
4592
4652
|
return this.#selectedCountry ?? null;
|
|
4593
4653
|
}
|
|
4594
4654
|
//* Get the validation error e.g. "TOO_SHORT" / "TOO_LONG", or null if it can't be determined / instance is destroyed.
|
|
@@ -4643,7 +4703,7 @@ var _factory = (() => {
|
|
|
4643
4703
|
if (!this.#selectedCountry && !hasRegionlessDialCode(value)) {
|
|
4644
4704
|
return false;
|
|
4645
4705
|
}
|
|
4646
|
-
const check = mode === "precise" ? intlTelInput.utils.
|
|
4706
|
+
const check = mode === "precise" ? intlTelInput.utils.isValidNumberPrecise : intlTelInput.utils.isValidNumber;
|
|
4647
4707
|
if (!check(value, iso2, allowedNumberTypes)) {
|
|
4648
4708
|
return false;
|
|
4649
4709
|
}
|
|
@@ -4656,7 +4716,7 @@ var _factory = (() => {
|
|
|
4656
4716
|
return true;
|
|
4657
4717
|
}
|
|
4658
4718
|
//* Update the selected country, and update the input value accordingly.
|
|
4659
|
-
|
|
4719
|
+
setSelectedCountry(iso2) {
|
|
4660
4720
|
if (!this.#isActive) {
|
|
4661
4721
|
return;
|
|
4662
4722
|
}
|
|
@@ -4671,10 +4731,8 @@ var _factory = (() => {
|
|
|
4671
4731
|
}
|
|
4672
4732
|
this.#updateSelectedCountry(iso2Lower);
|
|
4673
4733
|
this.#updateDialCode(this.#selectedCountry?.dialCode || "");
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
this.#updateValueFromNumber(inputValue);
|
|
4677
|
-
}
|
|
4734
|
+
const inputValue = this.#getTelInputValue();
|
|
4735
|
+
this.#updateValueFromNumber(inputValue);
|
|
4678
4736
|
this.#dispatchCountryChangeEvent();
|
|
4679
4737
|
this.#dispatchEvent(EVENTS.INPUT, { isCountryChange: true });
|
|
4680
4738
|
}
|
|
@@ -4699,14 +4757,14 @@ var _factory = (() => {
|
|
|
4699
4757
|
this.#options.placeholderNumberType = type;
|
|
4700
4758
|
this.#updatePlaceholder();
|
|
4701
4759
|
}
|
|
4702
|
-
// Set the disabled state of the input and
|
|
4760
|
+
// Set the disabled state of the input and country selector.
|
|
4703
4761
|
setDisabled(disabled) {
|
|
4704
4762
|
if (!this.#isActive) {
|
|
4705
4763
|
return;
|
|
4706
4764
|
}
|
|
4707
4765
|
this.#ui.setDisabled(disabled);
|
|
4708
4766
|
}
|
|
4709
|
-
// Set the readonly state of the input and
|
|
4767
|
+
// Set the readonly state of the input and country selector.
|
|
4710
4768
|
setReadonly(readonly) {
|
|
4711
4769
|
if (!this.#isActive) {
|
|
4712
4770
|
return;
|
|
@@ -4716,7 +4774,7 @@ var _factory = (() => {
|
|
|
4716
4774
|
//********************
|
|
4717
4775
|
//* STATIC METHODS
|
|
4718
4776
|
//********************
|
|
4719
|
-
// Internal instance notification used by utils/
|
|
4777
|
+
// Internal instance notification used by utils/initial-country loaders.
|
|
4720
4778
|
// Kept public so module-level helpers (e.g. attachUtils) can call it, while still allowing
|
|
4721
4779
|
// access to private instance methods.
|
|
4722
4780
|
static forEachInstance(method, ...args) {
|
|
@@ -4780,8 +4838,8 @@ var _factory = (() => {
|
|
|
4780
4838
|
defaults,
|
|
4781
4839
|
//* Using a static var like this allows us to mock it in the tests.
|
|
4782
4840
|
documentReady: () => document.readyState === "complete",
|
|
4783
|
-
//* Get the
|
|
4784
|
-
|
|
4841
|
+
//* Get the full list of all countries the library knows about.
|
|
4842
|
+
getAllCountries: () => data_default,
|
|
4785
4843
|
//* A getter for the core library instance.
|
|
4786
4844
|
getInstance: (input) => {
|
|
4787
4845
|
const id = input.dataset[DATA_KEYS.INSTANCE_ID];
|
|
@@ -4792,10 +4850,12 @@ var _factory = (() => {
|
|
|
4792
4850
|
attachUtils,
|
|
4793
4851
|
startedLoadingUtils: false,
|
|
4794
4852
|
startedLoadingAutoCountry: false,
|
|
4795
|
-
version: "
|
|
4853
|
+
version: "29.0.0",
|
|
4796
4854
|
NUMBER_FORMAT,
|
|
4797
4855
|
NUMBER_TYPE,
|
|
4798
|
-
VALIDATION_ERROR
|
|
4856
|
+
VALIDATION_ERROR,
|
|
4857
|
+
PLACEHOLDER_POLICY,
|
|
4858
|
+
COUNTRY_SELECTOR_MODE
|
|
4799
4859
|
}
|
|
4800
4860
|
);
|
|
4801
4861
|
var intlTelInput_default = intlTelInput;
|
|
@@ -4803,14 +4863,14 @@ var _factory = (() => {
|
|
|
4803
4863
|
// packages/core/dist/js/utils.js
|
|
4804
4864
|
var _scope = {};
|
|
4805
4865
|
(function() {
|
|
4806
|
-
var
|
|
4807
|
-
function
|
|
4866
|
+
var k = this || self;
|
|
4867
|
+
function m(a, b) {
|
|
4808
4868
|
a = a.split(".");
|
|
4809
|
-
var c =
|
|
4869
|
+
var c = k;
|
|
4810
4870
|
a[0] in c || typeof c.execScript == "undefined" || c.execScript("var " + a[0]);
|
|
4811
4871
|
for (var d; a.length && (d = a.shift()); ) a.length || b === void 0 ? c[d] && c[d] !== Object.prototype[d] ? c = c[d] : c = c[d] = {} : c[d] = b;
|
|
4812
4872
|
}
|
|
4813
|
-
function
|
|
4873
|
+
function n(a, b) {
|
|
4814
4874
|
function c() {
|
|
4815
4875
|
}
|
|
4816
4876
|
c.prototype = b.prototype;
|
|
@@ -4823,24 +4883,24 @@ var _factory = (() => {
|
|
|
4823
4883
|
};
|
|
4824
4884
|
}
|
|
4825
4885
|
;
|
|
4826
|
-
function
|
|
4886
|
+
function aa(a) {
|
|
4827
4887
|
const b = [];
|
|
4828
4888
|
let c = 0;
|
|
4829
4889
|
for (const d in a) b[c++] = a[d];
|
|
4830
4890
|
return b;
|
|
4831
4891
|
}
|
|
4832
4892
|
;
|
|
4833
|
-
var
|
|
4893
|
+
var ca = class {
|
|
4834
4894
|
constructor(a) {
|
|
4835
|
-
if (
|
|
4895
|
+
if (ba !== ba) throw Error("SafeUrl is not meant to be built directly");
|
|
4836
4896
|
this.g = a;
|
|
4837
4897
|
}
|
|
4838
4898
|
toString() {
|
|
4839
4899
|
return this.g.toString();
|
|
4840
4900
|
}
|
|
4841
|
-
},
|
|
4842
|
-
new
|
|
4843
|
-
new
|
|
4901
|
+
}, ba = {};
|
|
4902
|
+
new ca("about:invalid#zClosurez");
|
|
4903
|
+
new ca("about:blank");
|
|
4844
4904
|
const ea = {};
|
|
4845
4905
|
class fa {
|
|
4846
4906
|
constructor() {
|
|
@@ -4864,7 +4924,7 @@ var _factory = (() => {
|
|
|
4864
4924
|
const ja = {};
|
|
4865
4925
|
class ka {
|
|
4866
4926
|
constructor() {
|
|
4867
|
-
var a =
|
|
4927
|
+
var a = k.trustedTypes && k.trustedTypes.emptyHTML || "";
|
|
4868
4928
|
if (ja !== ja) throw Error("SafeHtml is not meant to be built directly");
|
|
4869
4929
|
this.g = a;
|
|
4870
4930
|
}
|
|
@@ -4901,38 +4961,38 @@ var _factory = (() => {
|
|
|
4901
4961
|
}
|
|
4902
4962
|
}
|
|
4903
4963
|
function ua(a) {
|
|
4904
|
-
a =
|
|
4964
|
+
a = aa(a.g);
|
|
4905
4965
|
a.sort(function(b, c) {
|
|
4906
4966
|
return b.g - c.g;
|
|
4907
4967
|
});
|
|
4908
4968
|
return a;
|
|
4909
4969
|
}
|
|
4910
4970
|
;
|
|
4911
|
-
function
|
|
4971
|
+
function p() {
|
|
4912
4972
|
this.h = {};
|
|
4913
4973
|
this.j = this.m().g;
|
|
4914
4974
|
this.g = this.l = null;
|
|
4915
4975
|
}
|
|
4916
|
-
|
|
4917
|
-
return
|
|
4976
|
+
p.prototype.has = function(a) {
|
|
4977
|
+
return q(this, a.g);
|
|
4918
4978
|
};
|
|
4919
|
-
|
|
4920
|
-
return
|
|
4979
|
+
p.prototype.get = function(a, b) {
|
|
4980
|
+
return r(this, a.g, b);
|
|
4921
4981
|
};
|
|
4922
|
-
|
|
4923
|
-
|
|
4982
|
+
p.prototype.set = function(a, b) {
|
|
4983
|
+
t(this, a.g, b);
|
|
4924
4984
|
};
|
|
4925
|
-
|
|
4985
|
+
p.prototype.add = function(a, b) {
|
|
4926
4986
|
va(this, a.g, b);
|
|
4927
4987
|
};
|
|
4928
|
-
|
|
4988
|
+
p.prototype.equals = function(a) {
|
|
4929
4989
|
if (!a || this.constructor != a.constructor) return false;
|
|
4930
4990
|
for (var b = ua(this.m()), c = 0; c < b.length; c++) {
|
|
4931
4991
|
var d = b[c], e = d.g;
|
|
4932
|
-
if (
|
|
4933
|
-
if (
|
|
4934
|
-
var f = d.h == 11 || d.h == 10, g =
|
|
4935
|
-
e =
|
|
4992
|
+
if (q(this, e) != q(a, e)) return false;
|
|
4993
|
+
if (q(this, e)) {
|
|
4994
|
+
var f = d.h == 11 || d.h == 10, g = u(this, e);
|
|
4995
|
+
e = u(a, e);
|
|
4936
4996
|
if (d.l) {
|
|
4937
4997
|
if (g.length != e.length) return false;
|
|
4938
4998
|
for (d = 0; d < g.length; d++) {
|
|
@@ -4947,25 +5007,25 @@ var _factory = (() => {
|
|
|
4947
5007
|
function wa(a, b) {
|
|
4948
5008
|
for (var c = ua(a.m()), d = 0; d < c.length; d++) {
|
|
4949
5009
|
var e = c[d], f = e.g;
|
|
4950
|
-
if (
|
|
5010
|
+
if (q(b, f)) {
|
|
4951
5011
|
a.g && delete a.g[e.g];
|
|
4952
5012
|
var g = e.h == 11 || e.h == 10;
|
|
4953
5013
|
if (e.l) {
|
|
4954
|
-
e =
|
|
5014
|
+
e = u(b, f) || [];
|
|
4955
5015
|
for (var h = 0; h < e.length; h++) va(a, f, g ? e[h].clone() : e[h]);
|
|
4956
|
-
} else e =
|
|
5016
|
+
} else e = u(b, f), g ? (g = u(a, f)) ? wa(g, e) : t(a, f, e.clone()) : t(a, f, e);
|
|
4957
5017
|
}
|
|
4958
5018
|
}
|
|
4959
5019
|
}
|
|
4960
|
-
|
|
5020
|
+
p.prototype.clone = function() {
|
|
4961
5021
|
var a = new this.constructor();
|
|
4962
5022
|
a != this && (a.h = {}, a.g && (a.g = {}), wa(a, this));
|
|
4963
5023
|
return a;
|
|
4964
5024
|
};
|
|
4965
|
-
function
|
|
5025
|
+
function q(a, b) {
|
|
4966
5026
|
return a.h[b] != null;
|
|
4967
5027
|
}
|
|
4968
|
-
function
|
|
5028
|
+
function u(a, b) {
|
|
4969
5029
|
var c = a.h[b];
|
|
4970
5030
|
if (c == null) return null;
|
|
4971
5031
|
if (a.l) {
|
|
@@ -4981,12 +5041,12 @@ var _factory = (() => {
|
|
|
4981
5041
|
}
|
|
4982
5042
|
return c;
|
|
4983
5043
|
}
|
|
4984
|
-
function
|
|
4985
|
-
var d =
|
|
5044
|
+
function r(a, b, c) {
|
|
5045
|
+
var d = u(a, b);
|
|
4986
5046
|
return a.j[b].l ? d[c || 0] : d;
|
|
4987
5047
|
}
|
|
4988
|
-
function
|
|
4989
|
-
if (
|
|
5048
|
+
function v(a, b) {
|
|
5049
|
+
if (q(a, b)) a = r(a, b);
|
|
4990
5050
|
else a: {
|
|
4991
5051
|
a = a.j[b];
|
|
4992
5052
|
if (a.j === void 0) if (b = a.u, b === Boolean) a.j = false;
|
|
@@ -5000,10 +5060,10 @@ var _factory = (() => {
|
|
|
5000
5060
|
}
|
|
5001
5061
|
return a;
|
|
5002
5062
|
}
|
|
5003
|
-
function
|
|
5004
|
-
return a.j[b].l ?
|
|
5063
|
+
function w(a, b) {
|
|
5064
|
+
return a.j[b].l ? q(a, b) ? a.h[b].length : 0 : q(a, b) ? 1 : 0;
|
|
5005
5065
|
}
|
|
5006
|
-
function
|
|
5066
|
+
function t(a, b, c) {
|
|
5007
5067
|
a.h[b] = c;
|
|
5008
5068
|
a.g && (a.g[b] = c);
|
|
5009
5069
|
}
|
|
@@ -5012,20 +5072,20 @@ var _factory = (() => {
|
|
|
5012
5072
|
a.h[b].push(c);
|
|
5013
5073
|
a.g && delete a.g[b];
|
|
5014
5074
|
}
|
|
5015
|
-
function
|
|
5075
|
+
function x(a, b) {
|
|
5016
5076
|
var c = [], d;
|
|
5017
5077
|
for (d in b) d != 0 && c.push(new la(d, b[d]));
|
|
5018
5078
|
return new ta(a, c);
|
|
5019
5079
|
}
|
|
5020
5080
|
;
|
|
5021
|
-
function
|
|
5081
|
+
function y() {
|
|
5022
5082
|
}
|
|
5023
|
-
|
|
5083
|
+
y.prototype.g = function(a) {
|
|
5024
5084
|
new a.h();
|
|
5025
5085
|
throw Error("Unimplemented");
|
|
5026
5086
|
};
|
|
5027
|
-
|
|
5028
|
-
if (a.h == 11 || a.h == 10) return b instanceof
|
|
5087
|
+
y.prototype.h = function(a, b) {
|
|
5088
|
+
if (a.h == 11 || a.h == 10) return b instanceof p ? b : this.g(a.u.prototype.m(), b);
|
|
5029
5089
|
if (a.h == 14) return typeof b === "string" && xa.test(b) && (a = Number(b), a > 0) ? a : b;
|
|
5030
5090
|
if (!a.o) return b;
|
|
5031
5091
|
a = a.u;
|
|
@@ -5037,7 +5097,7 @@ var _factory = (() => {
|
|
|
5037
5097
|
var xa = /^-?[0-9]+$/;
|
|
5038
5098
|
function ya() {
|
|
5039
5099
|
}
|
|
5040
|
-
|
|
5100
|
+
n(ya, y);
|
|
5041
5101
|
ya.prototype.g = function(a, b) {
|
|
5042
5102
|
a = new a.h();
|
|
5043
5103
|
a.l = this;
|
|
@@ -5047,82 +5107,82 @@ var _factory = (() => {
|
|
|
5047
5107
|
};
|
|
5048
5108
|
function z() {
|
|
5049
5109
|
}
|
|
5050
|
-
|
|
5110
|
+
n(z, ya);
|
|
5051
5111
|
z.prototype.h = function(a, b) {
|
|
5052
|
-
return a.h == 8 ? !!b :
|
|
5112
|
+
return a.h == 8 ? !!b : y.prototype.h.apply(this, arguments);
|
|
5053
5113
|
};
|
|
5054
5114
|
z.prototype.g = function(a, b) {
|
|
5055
5115
|
return z.na.g.call(this, a, b);
|
|
5056
5116
|
};
|
|
5057
|
-
function
|
|
5117
|
+
function B(a, b) {
|
|
5058
5118
|
a != null && this.g.apply(this, arguments);
|
|
5059
5119
|
}
|
|
5060
|
-
|
|
5061
|
-
|
|
5120
|
+
B.prototype.h = "";
|
|
5121
|
+
B.prototype.set = function(a) {
|
|
5062
5122
|
this.h = "" + a;
|
|
5063
5123
|
};
|
|
5064
|
-
|
|
5124
|
+
B.prototype.g = function(a, b, c) {
|
|
5065
5125
|
this.h += String(a);
|
|
5066
5126
|
if (b != null) for (let d = 1; d < arguments.length; d++) this.h += arguments[d];
|
|
5067
5127
|
return this;
|
|
5068
5128
|
};
|
|
5069
|
-
function
|
|
5129
|
+
function C(a) {
|
|
5070
5130
|
a.h = "";
|
|
5071
5131
|
}
|
|
5072
|
-
|
|
5132
|
+
B.prototype.toString = function() {
|
|
5073
5133
|
return this.h;
|
|
5074
5134
|
};
|
|
5075
|
-
function
|
|
5076
|
-
|
|
5135
|
+
function D() {
|
|
5136
|
+
p.call(this);
|
|
5077
5137
|
}
|
|
5078
|
-
|
|
5138
|
+
n(D, p);
|
|
5079
5139
|
var za = null;
|
|
5080
|
-
function
|
|
5081
|
-
|
|
5140
|
+
function E() {
|
|
5141
|
+
p.call(this);
|
|
5082
5142
|
}
|
|
5083
|
-
|
|
5143
|
+
n(E, p);
|
|
5084
5144
|
var Aa = null;
|
|
5085
|
-
function
|
|
5086
|
-
return
|
|
5145
|
+
function F(a) {
|
|
5146
|
+
return u(a, 9) || [];
|
|
5087
5147
|
}
|
|
5088
|
-
function
|
|
5089
|
-
|
|
5148
|
+
function G() {
|
|
5149
|
+
p.call(this);
|
|
5090
5150
|
}
|
|
5091
|
-
|
|
5151
|
+
n(G, p);
|
|
5092
5152
|
var Ba = null;
|
|
5093
|
-
|
|
5153
|
+
D.prototype.m = function() {
|
|
5094
5154
|
var a = za;
|
|
5095
|
-
a || (za = a =
|
|
5155
|
+
a || (za = a = x(D, { 0: { name: "NumberFormat", ja: "i18n.phonenumbers.NumberFormat" }, 1: { name: "pattern", required: true, i: 9, type: String }, 2: { name: "format", required: true, i: 9, type: String }, 3: { name: "leading_digits_pattern", ca: true, i: 9, type: String }, 4: { name: "national_prefix_formatting_rule", i: 9, type: String }, 6: { name: "national_prefix_optional_when_formatting", i: 8, defaultValue: false, type: Boolean }, 5: { name: "domestic_carrier_code_formatting_rule", i: 9, type: String } }));
|
|
5096
5156
|
return a;
|
|
5097
5157
|
};
|
|
5098
|
-
|
|
5099
|
-
|
|
5158
|
+
D.m = D.prototype.m;
|
|
5159
|
+
E.prototype.m = function() {
|
|
5100
5160
|
var a = Aa;
|
|
5101
|
-
a || (Aa = a =
|
|
5161
|
+
a || (Aa = a = x(E, { 0: { name: "PhoneNumberDesc", ja: "i18n.phonenumbers.PhoneNumberDesc" }, 2: { name: "national_number_pattern", i: 9, type: String }, 9: { name: "possible_length", ca: true, i: 5, type: Number }, 10: { name: "possible_length_local_only", ca: true, i: 5, type: Number }, 6: { name: "example_number", i: 9, type: String } }));
|
|
5102
5162
|
return a;
|
|
5103
5163
|
};
|
|
5104
|
-
|
|
5105
|
-
|
|
5164
|
+
E.m = E.prototype.m;
|
|
5165
|
+
G.prototype.m = function() {
|
|
5106
5166
|
var a = Ba;
|
|
5107
|
-
a || (Ba = a =
|
|
5167
|
+
a || (Ba = a = x(G, {
|
|
5108
5168
|
0: { name: "PhoneMetadata", ja: "i18n.phonenumbers.PhoneMetadata" },
|
|
5109
|
-
1: { name: "general_desc", i: 11, type:
|
|
5110
|
-
2: { name: "fixed_line", i: 11, type:
|
|
5111
|
-
3: { name: "mobile", i: 11, type:
|
|
5112
|
-
4: { name: "toll_free", i: 11, type:
|
|
5113
|
-
5: { name: "premium_rate", i: 11, type:
|
|
5114
|
-
6: { name: "shared_cost", i: 11, type:
|
|
5115
|
-
7: { name: "personal_number", i: 11, type:
|
|
5116
|
-
8: { name: "voip", i: 11, type:
|
|
5117
|
-
21: { name: "pager", i: 11, type:
|
|
5118
|
-
25: { name: "uan", i: 11, type:
|
|
5119
|
-
27: { name: "emergency", i: 11, type:
|
|
5120
|
-
28: { name: "voicemail", i: 11, type:
|
|
5121
|
-
29: { name: "short_code", i: 11, type:
|
|
5122
|
-
30: { name: "standard_rate", i: 11, type:
|
|
5123
|
-
31: { name: "carrier_specific", i: 11, type:
|
|
5124
|
-
33: { name: "sms_services", i: 11, type:
|
|
5125
|
-
24: { name: "no_international_dialling", i: 11, type:
|
|
5169
|
+
1: { name: "general_desc", i: 11, type: E },
|
|
5170
|
+
2: { name: "fixed_line", i: 11, type: E },
|
|
5171
|
+
3: { name: "mobile", i: 11, type: E },
|
|
5172
|
+
4: { name: "toll_free", i: 11, type: E },
|
|
5173
|
+
5: { name: "premium_rate", i: 11, type: E },
|
|
5174
|
+
6: { name: "shared_cost", i: 11, type: E },
|
|
5175
|
+
7: { name: "personal_number", i: 11, type: E },
|
|
5176
|
+
8: { name: "voip", i: 11, type: E },
|
|
5177
|
+
21: { name: "pager", i: 11, type: E },
|
|
5178
|
+
25: { name: "uan", i: 11, type: E },
|
|
5179
|
+
27: { name: "emergency", i: 11, type: E },
|
|
5180
|
+
28: { name: "voicemail", i: 11, type: E },
|
|
5181
|
+
29: { name: "short_code", i: 11, type: E },
|
|
5182
|
+
30: { name: "standard_rate", i: 11, type: E },
|
|
5183
|
+
31: { name: "carrier_specific", i: 11, type: E },
|
|
5184
|
+
33: { name: "sms_services", i: 11, type: E },
|
|
5185
|
+
24: { name: "no_international_dialling", i: 11, type: E },
|
|
5126
5186
|
9: { name: "id", required: true, i: 9, type: String },
|
|
5127
5187
|
10: { name: "country_code", i: 5, type: Number },
|
|
5128
5188
|
11: { name: "international_prefix", i: 9, type: String },
|
|
@@ -5136,31 +5196,31 @@ var _factory = (() => {
|
|
|
5136
5196
|
},
|
|
5137
5197
|
16: { name: "national_prefix_transform_rule", i: 9, type: String },
|
|
5138
5198
|
18: { name: "same_mobile_and_fixed_line_pattern", i: 8, defaultValue: false, type: Boolean },
|
|
5139
|
-
19: { name: "number_format", ca: true, i: 11, type:
|
|
5140
|
-
20: { name: "intl_number_format", ca: true, i: 11, type:
|
|
5199
|
+
19: { name: "number_format", ca: true, i: 11, type: D },
|
|
5200
|
+
20: { name: "intl_number_format", ca: true, i: 11, type: D },
|
|
5141
5201
|
22: { name: "main_country_for_code", i: 8, defaultValue: false, type: Boolean },
|
|
5142
5202
|
23: { name: "leading_digits", i: 9, type: String }
|
|
5143
5203
|
}));
|
|
5144
5204
|
return a;
|
|
5145
5205
|
};
|
|
5146
|
-
|
|
5147
|
-
function
|
|
5148
|
-
|
|
5206
|
+
G.m = G.prototype.m;
|
|
5207
|
+
function H() {
|
|
5208
|
+
p.call(this);
|
|
5149
5209
|
}
|
|
5150
|
-
|
|
5210
|
+
n(H, p);
|
|
5151
5211
|
var Ca = null, Da = { sa: 0, ra: 1, qa: 5, pa: 10, oa: 20 };
|
|
5152
|
-
|
|
5212
|
+
H.prototype.m = function() {
|
|
5153
5213
|
var a = Ca;
|
|
5154
|
-
a || (Ca = a =
|
|
5214
|
+
a || (Ca = a = x(H, { 0: { name: "PhoneNumber", ja: "i18n.phonenumbers.PhoneNumber" }, 1: { name: "country_code", required: true, i: 5, type: Number }, 2: { name: "national_number", required: true, i: 4, type: Number }, 3: { name: "extension", i: 9, type: String }, 4: { name: "italian_leading_zero", i: 8, type: Boolean }, 8: { name: "number_of_leading_zeros", i: 5, defaultValue: 1, type: Number }, 5: { name: "raw_input", i: 9, type: String }, 6: { name: "country_code_source", i: 14, defaultValue: 0, type: Da }, 7: {
|
|
5155
5215
|
name: "preferred_domestic_carrier_code",
|
|
5156
5216
|
i: 9,
|
|
5157
5217
|
type: String
|
|
5158
5218
|
} }));
|
|
5159
5219
|
return a;
|
|
5160
5220
|
};
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
var
|
|
5221
|
+
H.ctor = H;
|
|
5222
|
+
H.ctor.m = H.prototype.m;
|
|
5223
|
+
var I = {
|
|
5164
5224
|
1: "US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" "),
|
|
5165
5225
|
7: ["RU", "KZ"],
|
|
5166
5226
|
20: ["EG"],
|
|
@@ -10427,12 +10487,12 @@ var _factory = (() => {
|
|
|
10427
10487
|
], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "001", 888, , , , , , , , 1, [[, "(\\d{3})(\\d{3})(\\d{5})", "$1 $2 $3"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , "\\d{11}", , , , "12345678901"], , , [, , , , , , , , , [-1]]],
|
|
10428
10488
|
979: [, [, , "[1359]\\d{8}", , , , , , , [9], [8]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , "[1359]\\d{8}", , , , "123456789", , , , [8]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "001", 979, , , , , , , , 1, [[, "(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[1359]"]]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]]
|
|
10429
10489
|
};
|
|
10430
|
-
function
|
|
10490
|
+
function J() {
|
|
10431
10491
|
this.g = {};
|
|
10432
10492
|
}
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
return
|
|
10493
|
+
J.h = void 0;
|
|
10494
|
+
J.g = function() {
|
|
10495
|
+
return J.h ? J.h : J.h = new J();
|
|
10436
10496
|
};
|
|
10437
10497
|
var Fa = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", "\uFF10": "0", "\uFF11": "1", "\uFF12": "2", "\uFF13": "3", "\uFF14": "4", "\uFF15": "5", "\uFF16": "6", "\uFF17": "7", "\uFF18": "8", "\uFF19": "9", "\u0660": "0", "\u0661": "1", "\u0662": "2", "\u0663": "3", "\u0664": "4", "\u0665": "5", "\u0666": "6", "\u0667": "7", "\u0668": "8", "\u0669": "9", "\u06F0": "0", "\u06F1": "1", "\u06F2": "2", "\u06F3": "3", "\u06F4": "4", "\u06F5": "5", "\u06F6": "6", "\u06F7": "7", "\u06F8": "8", "\u06F9": "9" }, Ga = {
|
|
10438
10498
|
0: "0",
|
|
@@ -10515,56 +10575,56 @@ var _factory = (() => {
|
|
|
10515
10575
|
X: "9",
|
|
10516
10576
|
Y: "9",
|
|
10517
10577
|
Z: "9"
|
|
10518
|
-
}, Ia = RegExp("[+\uFF0B]+"),
|
|
10519
|
-
function
|
|
10578
|
+
}, Ia = RegExp("[+\uFF0B]+"), K = RegExp("^[+\uFF0B]+"), Ja = RegExp("([0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9])"), Ka = RegExp("[+\uFF0B0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]"), La = /[\\\/] *x/, Ma = RegExp("[^0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9A-Za-z#]+$"), Na = /(?:.*?[A-Za-z]){3}.*/, Oa = RegExp("^\\+([0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]|[\\-\\.\\(\\)]?)*[0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]([0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]|[\\-\\.\\(\\)]?)*$"), Pa = RegExp("^([A-Za-z0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]+((\\-)*[A-Za-z0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9])*\\.)*[A-Za-z]+((\\-)*[A-Za-z0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9])*\\.?$");
|
|
10579
|
+
function L(a) {
|
|
10520
10580
|
return "([0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]{1," + a + "})";
|
|
10521
10581
|
}
|
|
10522
10582
|
function Qa() {
|
|
10523
|
-
return ";ext=" +
|
|
10583
|
+
return ";ext=" + L("20") + "|[ \xA0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)[:\\.\uFF0E]?[ \xA0\\t,-]*" + (L("20") + "#?|[ \xA0\\t,]*(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)[:\\.\uFF0E]?[ \xA0\\t,-]*") + (L("9") + "#?|[- ]+") + (L("6") + "#|[ \xA0\\t]*(?:,{2}|;)[:\\.\uFF0E]?[ \xA0\\t,-]*") + (L("15") + "#?|[ \xA0\\t]*(?:,)+[:\\.\uFF0E]?[ \xA0\\t,-]*") + (L("9") + "#?");
|
|
10524
10584
|
}
|
|
10525
10585
|
var Ra = new RegExp("(?:" + Qa() + ")$", "i"), Sa = new RegExp("^[0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]{2}$|^[+\uFF0B]*(?:[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E*]*[0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]){3,}[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E*A-Za-z0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]*(?:" + Qa() + ")?$", "i"), Ta = /(\$\d)/, Ua = /^\(?\$1\)?$/;
|
|
10526
10586
|
function Va(a) {
|
|
10527
|
-
return a.length < 2 ? false :
|
|
10587
|
+
return a.length < 2 ? false : M(Sa, a);
|
|
10528
10588
|
}
|
|
10529
10589
|
function Wa(a) {
|
|
10530
|
-
return
|
|
10590
|
+
return M(Na, a) ? N(a, Ha) : N(a, Fa);
|
|
10531
10591
|
}
|
|
10532
10592
|
function Xa(a) {
|
|
10533
10593
|
var b = Wa(a.toString());
|
|
10534
|
-
|
|
10594
|
+
C(a);
|
|
10535
10595
|
a.g(b);
|
|
10536
10596
|
}
|
|
10537
10597
|
function Ya(a) {
|
|
10538
|
-
return a != null && (
|
|
10598
|
+
return a != null && (w(a, 9) != 1 || F(a)[0] != -1);
|
|
10539
10599
|
}
|
|
10540
|
-
function
|
|
10541
|
-
for (var c = new
|
|
10600
|
+
function N(a, b) {
|
|
10601
|
+
for (var c = new B(), d, e = a.length, f = 0; f < e; ++f) d = a.charAt(f), d = b[d.toUpperCase()], d != null && c.g(d);
|
|
10542
10602
|
return c.toString();
|
|
10543
10603
|
}
|
|
10544
10604
|
function Za(a) {
|
|
10545
10605
|
return a.length == 0 || Ua.test(a);
|
|
10546
10606
|
}
|
|
10547
|
-
function
|
|
10607
|
+
function O(a) {
|
|
10548
10608
|
return a != null && isNaN(a) && a.toUpperCase() in Ea;
|
|
10549
10609
|
}
|
|
10550
|
-
|
|
10551
|
-
if (
|
|
10552
|
-
var c =
|
|
10610
|
+
J.prototype.format = function(a, b) {
|
|
10611
|
+
if (r(a, 2) == 0 && q(a, 5)) {
|
|
10612
|
+
var c = v(a, 5);
|
|
10553
10613
|
if (c.length > 0) return c;
|
|
10554
10614
|
}
|
|
10555
|
-
c =
|
|
10556
|
-
var d =
|
|
10615
|
+
c = v(a, 1);
|
|
10616
|
+
var d = P(a);
|
|
10557
10617
|
if (b == 0) return $a(c, 0, d, "");
|
|
10558
|
-
if (!(c in
|
|
10559
|
-
var e =
|
|
10560
|
-
a =
|
|
10618
|
+
if (!(c in I)) return d;
|
|
10619
|
+
var e = Q(this, c, R(c));
|
|
10620
|
+
a = q(a, 3) && r(a, 3).length != 0 ? b == 3 ? ";ext=" + r(a, 3) : q(e, 13) ? r(e, 13) + v(a, 3) : " ext. " + v(a, 3) : "";
|
|
10561
10621
|
a: {
|
|
10562
|
-
e = (
|
|
10622
|
+
e = (u(e, 20) || []).length == 0 || b == 2 ? u(e, 19) || [] : u(e, 20) || [];
|
|
10563
10623
|
for (var f, g = e.length, h = 0; h < g; ++h) {
|
|
10564
10624
|
f = e[h];
|
|
10565
|
-
var l =
|
|
10566
|
-
if (l == 0 || d.search(
|
|
10567
|
-
if (l = new RegExp(
|
|
10625
|
+
var l = w(f, 3);
|
|
10626
|
+
if (l == 0 || d.search(r(f, 3, l - 1)) == 0) {
|
|
10627
|
+
if (l = new RegExp(r(f, 1)), M(l, d)) {
|
|
10568
10628
|
e = f;
|
|
10569
10629
|
break a;
|
|
10570
10630
|
}
|
|
@@ -10572,19 +10632,19 @@ var _factory = (() => {
|
|
|
10572
10632
|
}
|
|
10573
10633
|
e = null;
|
|
10574
10634
|
}
|
|
10575
|
-
e != null && (g = e, e =
|
|
10635
|
+
e != null && (g = e, e = v(g, 2), f = new RegExp(r(
|
|
10576
10636
|
g,
|
|
10577
10637
|
1
|
|
10578
|
-
)),
|
|
10638
|
+
)), v(g, 5), g = v(g, 4), d = b == 2 && g != null && g.length > 0 ? d.replace(f, e.replace(Ta, g)) : d.replace(f, e), b == 3 && (d = d.replace(RegExp("^[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E]+"), ""), d = d.replace(RegExp("[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E]+", "g"), "-")));
|
|
10579
10639
|
return $a(c, b, d, a);
|
|
10580
10640
|
};
|
|
10581
|
-
function
|
|
10582
|
-
return "001" == c ?
|
|
10641
|
+
function Q(a, b, c) {
|
|
10642
|
+
return "001" == c ? S(a, "" + b) : S(a, c);
|
|
10583
10643
|
}
|
|
10584
|
-
function
|
|
10585
|
-
if (!
|
|
10586
|
-
var b = "" +
|
|
10587
|
-
return
|
|
10644
|
+
function P(a) {
|
|
10645
|
+
if (!q(a, 2)) return "";
|
|
10646
|
+
var b = "" + r(a, 2);
|
|
10647
|
+
return q(a, 4) && r(a, 4) && v(a, 8) > 0 ? Array(v(a, 8) + 1).join("0") + b : b;
|
|
10588
10648
|
}
|
|
10589
10649
|
function $a(a, b, c, d) {
|
|
10590
10650
|
switch (b) {
|
|
@@ -10598,79 +10658,79 @@ var _factory = (() => {
|
|
|
10598
10658
|
return c + d;
|
|
10599
10659
|
}
|
|
10600
10660
|
}
|
|
10601
|
-
function
|
|
10661
|
+
function T(a, b) {
|
|
10602
10662
|
switch (b) {
|
|
10603
10663
|
case 4:
|
|
10604
|
-
return
|
|
10664
|
+
return r(a, 5);
|
|
10605
10665
|
case 3:
|
|
10606
|
-
return
|
|
10666
|
+
return r(a, 4);
|
|
10607
10667
|
case 1:
|
|
10608
|
-
return
|
|
10668
|
+
return r(a, 3);
|
|
10609
10669
|
case 0:
|
|
10610
10670
|
case 2:
|
|
10611
|
-
return
|
|
10671
|
+
return r(a, 2);
|
|
10612
10672
|
case 5:
|
|
10613
|
-
return
|
|
10673
|
+
return r(a, 6);
|
|
10614
10674
|
case 6:
|
|
10615
|
-
return
|
|
10675
|
+
return r(a, 8);
|
|
10616
10676
|
case 7:
|
|
10617
|
-
return
|
|
10677
|
+
return r(a, 7);
|
|
10618
10678
|
case 8:
|
|
10619
|
-
return
|
|
10679
|
+
return r(a, 21);
|
|
10620
10680
|
case 9:
|
|
10621
|
-
return
|
|
10681
|
+
return r(a, 25);
|
|
10622
10682
|
case 10:
|
|
10623
|
-
return
|
|
10683
|
+
return r(a, 28);
|
|
10624
10684
|
default:
|
|
10625
|
-
return
|
|
10685
|
+
return r(a, 1);
|
|
10626
10686
|
}
|
|
10627
10687
|
}
|
|
10628
10688
|
function ab(a, b) {
|
|
10629
10689
|
var c = bb(a, b);
|
|
10630
|
-
a =
|
|
10690
|
+
a = Q(a, v(b, 1), c);
|
|
10631
10691
|
if (a == null) return -1;
|
|
10632
|
-
b =
|
|
10692
|
+
b = P(b);
|
|
10633
10693
|
return cb(b, a);
|
|
10634
10694
|
}
|
|
10635
10695
|
function cb(a, b) {
|
|
10636
|
-
return
|
|
10696
|
+
return U(a, r(b, 1)) ? U(a, r(b, 5)) ? 4 : U(a, r(b, 4)) ? 3 : U(a, r(b, 6)) ? 5 : U(a, r(b, 8)) ? 6 : U(a, r(b, 7)) ? 7 : U(a, r(b, 21)) ? 8 : U(a, r(b, 25)) ? 9 : U(a, r(b, 28)) ? 10 : U(a, r(b, 2)) ? r(b, 18) || U(a, r(b, 3)) ? 2 : 0 : !r(b, 18) && U(a, r(b, 3)) ? 1 : -1 : -1;
|
|
10637
10697
|
}
|
|
10638
|
-
function
|
|
10698
|
+
function S(a, b) {
|
|
10639
10699
|
if (b == null) return null;
|
|
10640
10700
|
b = b.toUpperCase();
|
|
10641
10701
|
var c = a.g[b];
|
|
10642
10702
|
if (c == null) {
|
|
10643
10703
|
c = Ea[b];
|
|
10644
10704
|
if (c == null) return null;
|
|
10645
|
-
c = new z().g(
|
|
10705
|
+
c = new z().g(G.m(), c);
|
|
10646
10706
|
a.g[b] = c;
|
|
10647
10707
|
}
|
|
10648
10708
|
return c;
|
|
10649
10709
|
}
|
|
10650
|
-
function
|
|
10710
|
+
function U(a, b) {
|
|
10651
10711
|
var c = a.length;
|
|
10652
|
-
return
|
|
10712
|
+
return w(b, 9) > 0 && F(b).indexOf(c) == -1 ? false : M(v(b, 2), a);
|
|
10653
10713
|
}
|
|
10654
10714
|
function db(a, b) {
|
|
10655
10715
|
var c = bb(a, b);
|
|
10656
|
-
var d =
|
|
10657
|
-
var e =
|
|
10658
|
-
e == null || "001" != c && d != eb(a, c) ? e = false : (a =
|
|
10716
|
+
var d = v(b, 1);
|
|
10717
|
+
var e = Q(a, d, c);
|
|
10718
|
+
e == null || "001" != c && d != eb(a, c) ? e = false : (a = P(b), e = cb(a, e) != -1);
|
|
10659
10719
|
return e;
|
|
10660
10720
|
}
|
|
10661
10721
|
function bb(a, b) {
|
|
10662
10722
|
if (b == null) return null;
|
|
10663
|
-
var c =
|
|
10664
|
-
c =
|
|
10723
|
+
var c = v(b, 1);
|
|
10724
|
+
c = I[c];
|
|
10665
10725
|
if (c == null) a = null;
|
|
10666
10726
|
else if (c.length == 1) a = c[0];
|
|
10667
10727
|
else a: {
|
|
10668
|
-
b =
|
|
10728
|
+
b = P(b);
|
|
10669
10729
|
for (var d, e = c.length, f = 0; f < e; f++) {
|
|
10670
10730
|
d = c[f];
|
|
10671
|
-
var g =
|
|
10672
|
-
if (
|
|
10673
|
-
if (b.search(
|
|
10731
|
+
var g = S(a, d);
|
|
10732
|
+
if (q(g, 23)) {
|
|
10733
|
+
if (b.search(r(g, 23)) == 0) {
|
|
10674
10734
|
a = d;
|
|
10675
10735
|
break a;
|
|
10676
10736
|
}
|
|
@@ -10683,48 +10743,48 @@ var _factory = (() => {
|
|
|
10683
10743
|
}
|
|
10684
10744
|
return a;
|
|
10685
10745
|
}
|
|
10686
|
-
function
|
|
10687
|
-
a =
|
|
10746
|
+
function R(a) {
|
|
10747
|
+
a = I[a];
|
|
10688
10748
|
return a == null ? "ZZ" : a[0];
|
|
10689
10749
|
}
|
|
10690
10750
|
function eb(a, b) {
|
|
10691
|
-
a =
|
|
10751
|
+
a = S(a, b);
|
|
10692
10752
|
if (a == null) throw Error("Invalid region code: " + b);
|
|
10693
|
-
return
|
|
10753
|
+
return v(a, 10);
|
|
10694
10754
|
}
|
|
10695
|
-
function
|
|
10696
|
-
var e =
|
|
10697
|
-
e =
|
|
10698
|
-
if (d == 2) if (Ya(
|
|
10699
|
-
else return
|
|
10755
|
+
function V(a, b, c, d) {
|
|
10756
|
+
var e = T(c, d), f = w(e, 9) == 0 ? F(r(c, 1)) : F(e);
|
|
10757
|
+
e = u(e, 10) || [];
|
|
10758
|
+
if (d == 2) if (Ya(T(c, 0))) a = T(c, 1), Ya(a) && (f = f.concat(w(a, 9) == 0 ? F(r(c, 1)) : F(a)), f.sort(), e.length == 0 ? e = u(a, 10) || [] : (e = e.concat(u(a, 10) || []), e.sort()));
|
|
10759
|
+
else return V(a, b, c, 1);
|
|
10700
10760
|
if (f[0] == -1) return 5;
|
|
10701
10761
|
b = b.length;
|
|
10702
10762
|
if (e.indexOf(b) > -1) return 4;
|
|
10703
10763
|
c = f[0];
|
|
10704
10764
|
return c == b ? 0 : c > b ? 2 : f[f.length - 1] < b ? 3 : f.indexOf(b, 1) > -1 ? 0 : 5;
|
|
10705
10765
|
}
|
|
10706
|
-
function
|
|
10707
|
-
var d =
|
|
10708
|
-
b =
|
|
10709
|
-
if (!(b in
|
|
10710
|
-
b =
|
|
10711
|
-
return
|
|
10766
|
+
function W(a, b, c) {
|
|
10767
|
+
var d = P(b);
|
|
10768
|
+
b = v(b, 1);
|
|
10769
|
+
if (!(b in I)) return 1;
|
|
10770
|
+
b = Q(a, b, R(b));
|
|
10771
|
+
return V(a, d, b, c);
|
|
10712
10772
|
}
|
|
10713
10773
|
function fb(a, b) {
|
|
10714
10774
|
a = a.toString();
|
|
10715
10775
|
if (a.length == 0 || a.charAt(0) == "0") return 0;
|
|
10716
|
-
for (var c, d = a.length, e = 1; e <= 3 && e <= d; ++e) if (c = parseInt(a.substring(0, e), 10), c in
|
|
10776
|
+
for (var c, d = a.length, e = 1; e <= 3 && e <= d; ++e) if (c = parseInt(a.substring(0, e), 10), c in I) return b.g(a.substring(e)), c;
|
|
10717
10777
|
return 0;
|
|
10718
10778
|
}
|
|
10719
10779
|
function gb(a, b, c, d, e, f) {
|
|
10720
10780
|
if (b.length == 0) return 0;
|
|
10721
|
-
b = new
|
|
10781
|
+
b = new B(b);
|
|
10722
10782
|
var g;
|
|
10723
|
-
c != null && (g =
|
|
10783
|
+
c != null && (g = r(c, 11));
|
|
10724
10784
|
g == null && (g = "NonMatch");
|
|
10725
10785
|
var h = b.toString();
|
|
10726
10786
|
if (h.length == 0) g = 20;
|
|
10727
|
-
else if (
|
|
10787
|
+
else if (K.test(h)) h = h.replace(K, ""), C(b), b.g(Wa(h)), g = 1;
|
|
10728
10788
|
else {
|
|
10729
10789
|
h = new RegExp(g);
|
|
10730
10790
|
Xa(b);
|
|
@@ -10732,44 +10792,44 @@ var _factory = (() => {
|
|
|
10732
10792
|
if (g.search(h) == 0) {
|
|
10733
10793
|
h = g.match(h)[0].length;
|
|
10734
10794
|
var l = g.substring(h).match(Ja);
|
|
10735
|
-
l && l[1] != null && l[1].length > 0 &&
|
|
10795
|
+
l && l[1] != null && l[1].length > 0 && N(l[1], Fa) == "0" ? g = false : (C(b), b.g(g.substring(h)), g = true);
|
|
10736
10796
|
} else g = false;
|
|
10737
10797
|
g = g ? 5 : 20;
|
|
10738
10798
|
}
|
|
10739
|
-
e &&
|
|
10799
|
+
e && t(f, 6, g);
|
|
10740
10800
|
if (g != 20) {
|
|
10741
10801
|
if (b.h.length <= 2) throw Error("Phone number too short after IDD");
|
|
10742
10802
|
a = fb(b, d);
|
|
10743
|
-
if (a != 0) return
|
|
10803
|
+
if (a != 0) return t(f, 1, a), a;
|
|
10744
10804
|
throw Error("Invalid country calling code");
|
|
10745
10805
|
}
|
|
10746
|
-
if (c != null && (g =
|
|
10747
|
-
|
|
10806
|
+
if (c != null && (g = v(c, 10), h = "" + g, l = b.toString(), l.lastIndexOf(h, 0) == 0 && (h = new B(l.substring(h.length)), l = r(c, 1), l = new RegExp(v(l, 2)), hb(h, c, null), h = h.toString(), !M(l, b.toString()) && M(l, h) || V(a, b.toString(), c, -1) == 3))) return d.g(h), e && t(f, 6, 10), t(f, 1, g), g;
|
|
10807
|
+
t(f, 1, 0);
|
|
10748
10808
|
return 0;
|
|
10749
10809
|
}
|
|
10750
10810
|
function hb(a, b, c) {
|
|
10751
|
-
var d = a.toString(), e = d.length, f =
|
|
10811
|
+
var d = a.toString(), e = d.length, f = r(b, 15);
|
|
10752
10812
|
if (e != 0 && f != null && f.length != 0 && (f = new RegExp("^(?:" + f + ")"), e = f.exec(d))) {
|
|
10753
10813
|
var g = RegExp;
|
|
10754
|
-
var h =
|
|
10755
|
-
h =
|
|
10814
|
+
var h = r(b, 1);
|
|
10815
|
+
h = v(h, 2);
|
|
10756
10816
|
g = new g(h);
|
|
10757
|
-
h =
|
|
10817
|
+
h = M(g, d);
|
|
10758
10818
|
var l = e.length - 1;
|
|
10759
|
-
b =
|
|
10819
|
+
b = r(b, 16);
|
|
10760
10820
|
if (b == null || b.length == 0 || e[l] == null || e[l].length == 0) {
|
|
10761
|
-
if (!h ||
|
|
10762
|
-
} else if (d = d.replace(f, b), !h ||
|
|
10821
|
+
if (!h || M(g, d.substring(e[0].length))) c != null && l > 0 && e[l] != null && c.g(e[1]), a.set(d.substring(e[0].length));
|
|
10822
|
+
} else if (d = d.replace(f, b), !h || M(g, d)) c != null && l > 0 && c.g(e[1]), a.set(d);
|
|
10763
10823
|
}
|
|
10764
10824
|
}
|
|
10765
|
-
function
|
|
10766
|
-
if (!
|
|
10825
|
+
function X(a, b, c) {
|
|
10826
|
+
if (!O(c) && b.length > 0 && b.charAt(0) != "+") throw Error("Invalid country calling code");
|
|
10767
10827
|
return ib(a, b, c, true);
|
|
10768
10828
|
}
|
|
10769
10829
|
function ib(a, b, c, d) {
|
|
10770
10830
|
if (b == null) throw Error("The string supplied did not seem to be a phone number");
|
|
10771
10831
|
if (b.length > 250) throw Error("The string supplied is too long to be a phone number");
|
|
10772
|
-
var e = new
|
|
10832
|
+
var e = new B();
|
|
10773
10833
|
var f = b.indexOf(";phone-context=");
|
|
10774
10834
|
if (f === -1) f = null;
|
|
10775
10835
|
else if (f += 15, f >= b.length) f = "";
|
|
@@ -10783,109 +10843,109 @@ var _factory = (() => {
|
|
|
10783
10843
|
f != null ? (f.charAt(0) === "+" && e.g(f), f = b.indexOf("tel:"), e.g(b.substring(f >= 0 ? f + 4 : 0, b.indexOf(";phone-context=")))) : (f = e.g, g = b ?? "", h = g.search(Ka), h >= 0 ? (g = g.substring(h), g = g.replace(Ma, ""), h = g.search(La), h >= 0 && (g = g.substring(0, h))) : g = "", f.call(e, g));
|
|
10784
10844
|
f = e.toString();
|
|
10785
10845
|
g = f.indexOf(";isub=");
|
|
10786
|
-
g > 0 && (
|
|
10846
|
+
g > 0 && (C(e), e.g(f.substring(0, g)));
|
|
10787
10847
|
if (!Va(e.toString())) throw Error("The string supplied did not seem to be a phone number");
|
|
10788
10848
|
f = e.toString();
|
|
10789
|
-
if (!(
|
|
10790
|
-
f = new
|
|
10791
|
-
d &&
|
|
10849
|
+
if (!(O(c) || f != null && f.length > 0 && K.test(f))) throw Error("Invalid country calling code");
|
|
10850
|
+
f = new H();
|
|
10851
|
+
d && t(f, 5, b);
|
|
10792
10852
|
a: {
|
|
10793
10853
|
b = e.toString();
|
|
10794
10854
|
g = b.search(Ra);
|
|
10795
10855
|
if (g >= 0 && Va(b.substring(0, g))) {
|
|
10796
10856
|
h = b.match(Ra);
|
|
10797
|
-
for (var l = h.length,
|
|
10798
|
-
|
|
10857
|
+
for (var l = h.length, A = 1; A < l; ++A) if (h[A] != null && h[A].length > 0) {
|
|
10858
|
+
C(e);
|
|
10799
10859
|
e.g(b.substring(0, g));
|
|
10800
|
-
b = h[
|
|
10860
|
+
b = h[A];
|
|
10801
10861
|
break a;
|
|
10802
10862
|
}
|
|
10803
10863
|
}
|
|
10804
10864
|
b = "";
|
|
10805
10865
|
}
|
|
10806
|
-
b.length > 0 &&
|
|
10807
|
-
g =
|
|
10808
|
-
b = new
|
|
10866
|
+
b.length > 0 && t(f, 3, b);
|
|
10867
|
+
g = S(a, c);
|
|
10868
|
+
b = new B();
|
|
10809
10869
|
h = 0;
|
|
10810
10870
|
l = e.toString();
|
|
10811
10871
|
try {
|
|
10812
10872
|
h = gb(a, l, g, b, d, f);
|
|
10813
|
-
} catch (
|
|
10814
|
-
if (
|
|
10815
|
-
if (l = l.replace(
|
|
10816
|
-
} else throw
|
|
10873
|
+
} catch (da) {
|
|
10874
|
+
if (da.message == "Invalid country calling code" && K.test(l)) {
|
|
10875
|
+
if (l = l.replace(K, ""), h = gb(a, l, g, b, d, f), h == 0) throw da;
|
|
10876
|
+
} else throw da;
|
|
10817
10877
|
}
|
|
10818
|
-
h != 0 ? (e =
|
|
10878
|
+
h != 0 ? (e = R(h), e != c && (g = Q(a, h, e))) : (Xa(e), b.g(e.toString()), c != null ? (h = v(g, 10), t(
|
|
10819
10879
|
f,
|
|
10820
10880
|
1,
|
|
10821
10881
|
h
|
|
10822
10882
|
)) : d && (delete f.h[6], f.g && delete f.g[6]));
|
|
10823
10883
|
if (b.h.length < 2) throw Error("The string supplied is too short to be a phone number");
|
|
10824
|
-
g != null && (c = new
|
|
10884
|
+
g != null && (c = new B(), e = new B(b.toString()), hb(e, g, c), a = V(a, e.toString(), g, -1), a != 2 && a != 4 && a != 5 && (b = e, d && c.toString().length > 0 && t(f, 7, c.toString())));
|
|
10825
10885
|
d = b.toString();
|
|
10826
10886
|
a = d.length;
|
|
10827
10887
|
if (a < 2) throw Error("The string supplied is too short to be a phone number");
|
|
10828
10888
|
if (a > 17) throw Error("The string supplied is too long to be a phone number");
|
|
10829
10889
|
if (d.length > 1 && d.charAt(0) == "0") {
|
|
10830
|
-
|
|
10890
|
+
t(f, 4, true);
|
|
10831
10891
|
for (a = 1; a < d.length - 1 && d.charAt(a) == "0"; ) a++;
|
|
10832
|
-
a != 1 &&
|
|
10892
|
+
a != 1 && t(f, 8, a);
|
|
10833
10893
|
}
|
|
10834
|
-
|
|
10894
|
+
t(f, 2, parseInt(d, 10));
|
|
10835
10895
|
return f;
|
|
10836
10896
|
}
|
|
10837
|
-
function
|
|
10897
|
+
function M(a, b) {
|
|
10838
10898
|
return (a = b.match(new RegExp("^(?:" + (typeof a == "string" ? a : a.source) + ")$", "i"))) && a[0].length == b.length ? true : false;
|
|
10839
10899
|
}
|
|
10840
10900
|
;
|
|
10841
10901
|
function jb(a) {
|
|
10842
10902
|
this.ga = RegExp("\u2008");
|
|
10843
10903
|
this.ka = "";
|
|
10844
|
-
this.$ = new
|
|
10904
|
+
this.$ = new B();
|
|
10845
10905
|
this.ea = "";
|
|
10846
|
-
this.u = new
|
|
10847
|
-
this.da = new
|
|
10906
|
+
this.u = new B();
|
|
10907
|
+
this.da = new B();
|
|
10848
10908
|
this.v = true;
|
|
10849
10909
|
this.fa = this.aa = this.ma = false;
|
|
10850
|
-
this.ha =
|
|
10910
|
+
this.ha = J.g();
|
|
10851
10911
|
this.ba = 0;
|
|
10852
|
-
this.h = new
|
|
10912
|
+
this.h = new B();
|
|
10853
10913
|
this.ia = false;
|
|
10854
10914
|
this.o = "";
|
|
10855
|
-
this.g = new
|
|
10915
|
+
this.g = new B();
|
|
10856
10916
|
this.j = [];
|
|
10857
10917
|
this.la = a;
|
|
10858
10918
|
this.l = kb(this, this.la);
|
|
10859
10919
|
}
|
|
10860
|
-
var lb = new
|
|
10861
|
-
|
|
10920
|
+
var lb = new G();
|
|
10921
|
+
t(lb, 11, "NA");
|
|
10862
10922
|
var mb = RegExp("^[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E]*\\$1[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E]*(\\$\\d[-x\u2010-\u2015\u2212\u30FC\uFF0D-\uFF0F \xA0\xAD\u200B\u2060\u3000()\uFF08\uFF09\uFF3B\uFF3D.\\[\\]/~\u2053\u223C\uFF5E]*)*$"), nb = /[- ]/;
|
|
10863
10923
|
function kb(a, b) {
|
|
10864
10924
|
var c = a.ha;
|
|
10865
|
-
b =
|
|
10866
|
-
a =
|
|
10925
|
+
b = O(b) ? eb(c, b) : 0;
|
|
10926
|
+
a = S(a.ha, R(b));
|
|
10867
10927
|
return a != null ? a : lb;
|
|
10868
10928
|
}
|
|
10869
10929
|
function ob(a) {
|
|
10870
10930
|
for (var b = a.j.length, c = 0; c < b; ++c) {
|
|
10871
|
-
var d = a.j[c], e =
|
|
10931
|
+
var d = a.j[c], e = v(d, 1);
|
|
10872
10932
|
if (a.ea == e) return false;
|
|
10873
10933
|
var f = a;
|
|
10874
|
-
var g = d, h =
|
|
10875
|
-
|
|
10934
|
+
var g = d, h = v(g, 1);
|
|
10935
|
+
C(f.$);
|
|
10876
10936
|
var l = f;
|
|
10877
|
-
g =
|
|
10878
|
-
var
|
|
10879
|
-
|
|
10937
|
+
g = v(g, 2);
|
|
10938
|
+
var A = "999999999999999".match(h)[0];
|
|
10939
|
+
A.length < l.g.h.length ? l = "" : (l = A.replace(new RegExp(h, "g"), g), l = l.replace(RegExp("9", "g"), "\u2008"));
|
|
10880
10940
|
l.length > 0 ? (f.$.g(l), f = true) : f = false;
|
|
10881
|
-
if (f) return a.ea = e, a.ia = nb.test(
|
|
10941
|
+
if (f) return a.ea = e, a.ia = nb.test(r(d, 4)), a.ba = 0, true;
|
|
10882
10942
|
}
|
|
10883
10943
|
return a.v = false;
|
|
10884
10944
|
}
|
|
10885
10945
|
function pb(a, b) {
|
|
10886
10946
|
for (var c = [], d = b.length - 3, e = a.j.length, f = 0; f < e; ++f) {
|
|
10887
10947
|
var g = a.j[f];
|
|
10888
|
-
|
|
10948
|
+
w(g, 3) == 0 ? c.push(a.j[f]) : (g = r(g, 3, Math.min(d, w(g, 3) - 1)), b.search(g) == 0 && c.push(a.j[f]));
|
|
10889
10949
|
}
|
|
10890
10950
|
a.j = c;
|
|
10891
10951
|
}
|
|
@@ -10897,7 +10957,7 @@ var _factory = (() => {
|
|
|
10897
10957
|
if (!a.ma) {
|
|
10898
10958
|
if (rb(a)) {
|
|
10899
10959
|
if (sb(a)) return tb(a);
|
|
10900
|
-
} else if (a.o.length > 0 && (b = a.g.toString(),
|
|
10960
|
+
} else if (a.o.length > 0 && (b = a.g.toString(), C(a.g), a.g.g(a.o), a.g.g(b), b = a.h.toString(), c = b.lastIndexOf(a.o), C(a.h), a.h.g(b.substring(0, c))), a.o != ub(a)) return a.h.g(" "), tb(a);
|
|
10901
10961
|
}
|
|
10902
10962
|
return a.u.toString();
|
|
10903
10963
|
}
|
|
@@ -10916,7 +10976,7 @@ var _factory = (() => {
|
|
|
10916
10976
|
c = xb(a);
|
|
10917
10977
|
if (c.length > 0) return c;
|
|
10918
10978
|
pb(a, a.g.toString());
|
|
10919
|
-
return ob(a) ? yb(a) : a.v ?
|
|
10979
|
+
return ob(a) ? yb(a) : a.v ? Y(a, b) : a.u.toString();
|
|
10920
10980
|
}
|
|
10921
10981
|
return vb(a);
|
|
10922
10982
|
}
|
|
@@ -10926,64 +10986,64 @@ var _factory = (() => {
|
|
|
10926
10986
|
a.fa = false;
|
|
10927
10987
|
a.j = [];
|
|
10928
10988
|
a.ba = 0;
|
|
10929
|
-
|
|
10989
|
+
C(a.$);
|
|
10930
10990
|
a.ea = "";
|
|
10931
10991
|
return vb(a);
|
|
10932
10992
|
}
|
|
10933
10993
|
function xb(a) {
|
|
10934
10994
|
for (var b = a.g.toString(), c = a.j.length, d = 0; d < c; ++d) {
|
|
10935
|
-
var e = a.j[d], f =
|
|
10936
|
-
if (new RegExp("^(?:" + f + ")$").test(b) && (a.ia = nb.test(
|
|
10995
|
+
var e = a.j[d], f = v(e, 1);
|
|
10996
|
+
if (new RegExp("^(?:" + f + ")$").test(b) && (a.ia = nb.test(r(e, 4)), e = b.replace(new RegExp(f, "g"), r(e, 2)), e = Y(a, e), N(e, Ga) == a.da)) return e;
|
|
10937
10997
|
}
|
|
10938
10998
|
return "";
|
|
10939
10999
|
}
|
|
10940
|
-
function
|
|
11000
|
+
function Y(a, b) {
|
|
10941
11001
|
var c = a.h.h.length;
|
|
10942
11002
|
return a.ia && c > 0 && a.h.toString().charAt(c - 1) != " " ? a.h + " " + b : a.h + b;
|
|
10943
11003
|
}
|
|
10944
11004
|
function vb(a) {
|
|
10945
11005
|
var b = a.g.toString();
|
|
10946
11006
|
if (b.length >= 3) {
|
|
10947
|
-
for (var c = a.aa && a.o.length == 0 &&
|
|
11007
|
+
for (var c = a.aa && a.o.length == 0 && w(a.l, 20) > 0 ? u(a.l, 20) || [] : u(a.l, 19) || [], d = c.length, e = 0; e < d; ++e) {
|
|
10948
11008
|
var f = c[e];
|
|
10949
|
-
a.o.length > 0 && Za(
|
|
11009
|
+
a.o.length > 0 && Za(v(f, 4)) && !r(f, 6) && !q(f, 5) || (a.o.length != 0 || a.aa || Za(v(f, 4)) || r(f, 6)) && mb.test(v(f, 2)) && a.j.push(f);
|
|
10950
11010
|
}
|
|
10951
11011
|
pb(a, b);
|
|
10952
11012
|
b = xb(a);
|
|
10953
11013
|
return b.length > 0 ? b : ob(a) ? yb(a) : a.u.toString();
|
|
10954
11014
|
}
|
|
10955
|
-
return
|
|
11015
|
+
return Y(a, b);
|
|
10956
11016
|
}
|
|
10957
11017
|
function yb(a) {
|
|
10958
11018
|
var b = a.g.toString(), c = b.length;
|
|
10959
11019
|
if (c > 0) {
|
|
10960
11020
|
for (var d = "", e = 0; e < c; e++) d = wb(a, b.charAt(e));
|
|
10961
|
-
return a.v ?
|
|
11021
|
+
return a.v ? Y(a, d) : a.u.toString();
|
|
10962
11022
|
}
|
|
10963
11023
|
return a.h.toString();
|
|
10964
11024
|
}
|
|
10965
11025
|
function ub(a) {
|
|
10966
11026
|
var b = a.g.toString(), c = 0;
|
|
10967
|
-
if (
|
|
11027
|
+
if (r(a.l, 10) != 1) var d = false;
|
|
10968
11028
|
else d = a.g.toString(), d = d.charAt(0) == "1" && d.charAt(1) != "0" && d.charAt(1) != "1";
|
|
10969
|
-
d ? (c = 1, a.h.g("1").g(" "), a.aa = true) :
|
|
10970
|
-
|
|
11029
|
+
d ? (c = 1, a.h.g("1").g(" "), a.aa = true) : q(a.l, 15) && (d = new RegExp("^(?:" + r(a.l, 15) + ")"), d = b.match(d), d != null && d[0] != null && d[0].length > 0 && (a.aa = true, c = d[0].length, a.h.g(b.substring(0, c))));
|
|
11030
|
+
C(a.g);
|
|
10971
11031
|
a.g.g(b.substring(c));
|
|
10972
11032
|
return b.substring(0, c);
|
|
10973
11033
|
}
|
|
10974
11034
|
function rb(a) {
|
|
10975
|
-
var b = a.da.toString(), c = new RegExp("^(?:\\+|" +
|
|
11035
|
+
var b = a.da.toString(), c = new RegExp("^(?:\\+|" + r(a.l, 11) + ")");
|
|
10976
11036
|
c = b.match(c);
|
|
10977
|
-
return c != null && c[0] != null && c[0].length > 0 ? (a.aa = true, c = c[0].length,
|
|
11037
|
+
return c != null && c[0] != null && c[0].length > 0 ? (a.aa = true, c = c[0].length, C(a.g), a.g.g(b.substring(c)), C(a.h), a.h.g(b.substring(0, c)), b.charAt(0) != "+" && a.h.g(" "), true) : false;
|
|
10978
11038
|
}
|
|
10979
11039
|
function sb(a) {
|
|
10980
11040
|
if (a.g.h.length == 0) return false;
|
|
10981
|
-
var b = new
|
|
11041
|
+
var b = new B(), c = fb(a.g, b);
|
|
10982
11042
|
if (c == 0) return false;
|
|
10983
|
-
|
|
11043
|
+
C(a.g);
|
|
10984
11044
|
a.g.g(b.toString());
|
|
10985
|
-
b =
|
|
10986
|
-
"001" == b ? a.l =
|
|
11045
|
+
b = R(c);
|
|
11046
|
+
"001" == b ? a.l = S(a.ha, "" + c) : b != a.la && (a.l = kb(a, b));
|
|
10987
11047
|
a.h.g("" + c).g(" ");
|
|
10988
11048
|
a.o = "";
|
|
10989
11049
|
return true;
|
|
@@ -10993,7 +11053,7 @@ var _factory = (() => {
|
|
|
10993
11053
|
if (c.substring(a.ba).search(a.ga) >= 0) {
|
|
10994
11054
|
var d = c.search(a.ga);
|
|
10995
11055
|
b = c.replace(a.ga, b);
|
|
10996
|
-
|
|
11056
|
+
C(a.$);
|
|
10997
11057
|
a.$.g(b);
|
|
10998
11058
|
a.ba = d;
|
|
10999
11059
|
return b.substring(0, a.ba + 1);
|
|
@@ -11029,8 +11089,8 @@ var _factory = (() => {
|
|
|
11029
11089
|
a.includes("FIXED_LINE_OR_MOBILE") ? (a.includes("MOBILE") || b.push("MOBILE"), a.includes("FIXED_LINE") || b.push("FIXED_LINE")) : (a.includes("MOBILE") || a.includes("FIXED_LINE")) && b.push("FIXED_LINE_OR_MOBILE");
|
|
11030
11090
|
return a.concat(b);
|
|
11031
11091
|
};
|
|
11032
|
-
|
|
11033
|
-
|
|
11092
|
+
m("utils", {});
|
|
11093
|
+
m("utils.formatNumberAsYouType", (a, b) => {
|
|
11034
11094
|
try {
|
|
11035
11095
|
const c = a.replace(/[^+0-9]/g, ""), d = new jb(b);
|
|
11036
11096
|
b = "";
|
|
@@ -11040,92 +11100,92 @@ var _factory = (() => {
|
|
|
11040
11100
|
return a;
|
|
11041
11101
|
}
|
|
11042
11102
|
});
|
|
11043
|
-
|
|
11103
|
+
m("utils.formatNumber", (a, b, c) => {
|
|
11044
11104
|
try {
|
|
11045
|
-
const e =
|
|
11046
|
-
var d =
|
|
11105
|
+
const e = J.g(), f = X(e, a, b);
|
|
11106
|
+
var d = W(e, f, -1);
|
|
11047
11107
|
return d == 0 || d == 4 ? e.format(f, typeof c === "undefined" ? 0 : zb[c]) : a;
|
|
11048
11108
|
} catch {
|
|
11049
11109
|
return a;
|
|
11050
11110
|
}
|
|
11051
11111
|
});
|
|
11052
|
-
|
|
11112
|
+
m("utils.getExampleNumber", (a, b, c) => {
|
|
11053
11113
|
try {
|
|
11054
|
-
const
|
|
11114
|
+
const l = J.g();
|
|
11055
11115
|
a: {
|
|
11056
|
-
var
|
|
11057
|
-
if (
|
|
11058
|
-
var
|
|
11116
|
+
var d = l, e = Z[b];
|
|
11117
|
+
if (O(a)) {
|
|
11118
|
+
var f = T(S(d, a), e);
|
|
11059
11119
|
try {
|
|
11060
|
-
if (
|
|
11061
|
-
var
|
|
11062
|
-
var
|
|
11120
|
+
if (q(f, 6)) {
|
|
11121
|
+
var g = r(f, 6);
|
|
11122
|
+
var h = ib(d, g, a, false);
|
|
11063
11123
|
break a;
|
|
11064
11124
|
}
|
|
11065
|
-
} catch (
|
|
11125
|
+
} catch (A) {
|
|
11066
11126
|
}
|
|
11067
11127
|
}
|
|
11068
|
-
|
|
11128
|
+
h = null;
|
|
11069
11129
|
}
|
|
11070
|
-
return
|
|
11130
|
+
return l.format(h, zb[c]);
|
|
11071
11131
|
} catch {
|
|
11072
11132
|
return "";
|
|
11073
11133
|
}
|
|
11074
11134
|
});
|
|
11075
|
-
|
|
11135
|
+
m("utils.getExtension", (a, b) => {
|
|
11076
11136
|
try {
|
|
11077
|
-
var c =
|
|
11078
|
-
return
|
|
11137
|
+
var c = X(J.g(), a, b);
|
|
11138
|
+
return r(c, 3);
|
|
11079
11139
|
} catch {
|
|
11080
11140
|
return "";
|
|
11081
11141
|
}
|
|
11082
11142
|
});
|
|
11083
|
-
|
|
11143
|
+
m("utils.getNumberType", (a, b) => {
|
|
11084
11144
|
try {
|
|
11085
|
-
const c =
|
|
11145
|
+
const c = J.g(), d = X(c, a, b), e = ab(c, d);
|
|
11086
11146
|
return Bb[e] || null;
|
|
11087
11147
|
} catch {
|
|
11088
11148
|
return null;
|
|
11089
11149
|
}
|
|
11090
11150
|
});
|
|
11091
|
-
|
|
11151
|
+
m("utils.getValidationError", (a, b) => {
|
|
11092
11152
|
if (!b) return "INVALID_COUNTRY_CODE";
|
|
11093
11153
|
try {
|
|
11094
|
-
const c =
|
|
11154
|
+
const c = J.g(), d = X(c, a, b), e = W(c, d, -1);
|
|
11095
11155
|
return Cb[e] || null;
|
|
11096
11156
|
} catch (c) {
|
|
11097
11157
|
return c.message === "Invalid country calling code" ? "INVALID_COUNTRY_CODE" : a.length <= 3 || c.message === "Phone number too short after IDD" || c.message === "The string supplied is too short to be a phone number" ? "TOO_SHORT" : c.message === "The string supplied is too long to be a phone number" ? "TOO_LONG" : null;
|
|
11098
11158
|
}
|
|
11099
11159
|
});
|
|
11100
|
-
|
|
11160
|
+
m("utils.isValidNumber", (a, b, c) => {
|
|
11101
11161
|
try {
|
|
11102
|
-
const d =
|
|
11162
|
+
const d = J.g(), e = X(d, a, b);
|
|
11103
11163
|
if (c) {
|
|
11104
|
-
const
|
|
11105
|
-
|
|
11164
|
+
const f = Db(c);
|
|
11165
|
+
for (let g of f) if (W(d, e, Z[g]) === 0) return true;
|
|
11166
|
+
return false;
|
|
11106
11167
|
}
|
|
11107
|
-
return
|
|
11168
|
+
return W(d, e, -1) === 0;
|
|
11108
11169
|
} catch {
|
|
11109
11170
|
return false;
|
|
11110
11171
|
}
|
|
11111
11172
|
});
|
|
11112
|
-
|
|
11173
|
+
m("utils.isValidNumberPrecise", (a, b, c) => {
|
|
11113
11174
|
try {
|
|
11114
|
-
const d =
|
|
11175
|
+
const d = J.g(), e = X(d, a, b), f = db(d, e);
|
|
11115
11176
|
if (c) {
|
|
11116
|
-
const
|
|
11117
|
-
|
|
11118
|
-
return false;
|
|
11177
|
+
const g = Db(c).map((h) => Z[h]);
|
|
11178
|
+
return f && g.includes(ab(d, e));
|
|
11119
11179
|
}
|
|
11120
|
-
return
|
|
11180
|
+
return f;
|
|
11121
11181
|
} catch {
|
|
11122
11182
|
return false;
|
|
11123
11183
|
}
|
|
11124
11184
|
});
|
|
11125
|
-
|
|
11185
|
+
m("utils.getCoreNumber", (a, b) => {
|
|
11126
11186
|
try {
|
|
11127
|
-
var c =
|
|
11128
|
-
return
|
|
11187
|
+
var c = X(J.g(), a, b);
|
|
11188
|
+
return r(c, 2).toString();
|
|
11129
11189
|
} catch {
|
|
11130
11190
|
return "";
|
|
11131
11191
|
}
|