intl-tel-input 28.0.9 → 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 +392 -324
- package/dist/js/intlTelInput.min.js +2 -2
- package/dist/js/intlTelInput.mjs +391 -323
- package/dist/js/intlTelInputWithUtils.js +680 -614
- package/dist/js/intlTelInputWithUtils.min.js +2 -2
- package/dist/js/intlTelInputWithUtils.mjs +679 -613
- package/dist/js/{i18n → locale}/ar.js +3 -3
- package/dist/js/{i18n → locale}/bg.js +2 -2
- package/dist/js/{i18n → locale}/bn.js +2 -2
- package/dist/js/{i18n → locale}/bs.js +2 -2
- package/dist/js/{i18n → locale}/ca.js +2 -2
- package/dist/js/{i18n → locale}/cs.js +2 -2
- package/dist/js/{i18n → locale}/da.js +2 -2
- package/dist/js/{i18n → locale}/de.js +2 -2
- package/dist/js/{i18n → locale}/el.js +2 -2
- package/dist/js/{i18n → locale}/es.js +2 -2
- package/dist/js/{i18n → locale}/et.js +2 -2
- package/dist/js/{i18n → locale}/fa.js +2 -5
- package/dist/js/{i18n → locale}/fi.js +2 -2
- package/dist/js/locale/fil.js +16 -0
- package/dist/js/{i18n → locale}/fr.js +2 -2
- package/dist/js/locale/he.js +19 -0
- package/dist/js/{i18n → locale}/hi.js +2 -2
- package/dist/js/{i18n → locale}/hr.js +2 -2
- package/dist/js/{i18n → locale}/hu.js +2 -5
- package/dist/js/locale/hy.js +19 -0
- package/dist/js/{i18n → locale}/id.js +2 -5
- package/dist/js/{i18n → locale}/index.js +9 -0
- package/dist/js/locale/is.js +21 -0
- package/dist/js/{i18n → locale}/it.js +2 -2
- package/dist/js/{i18n → locale}/ja.js +2 -5
- package/dist/js/{i18n → locale}/kn.js +2 -2
- package/dist/js/{i18n → locale}/ko.js +2 -5
- package/dist/js/{i18n → locale}/lt.js +2 -2
- package/dist/js/locale/lv.js +24 -0
- package/dist/js/locale/mk.js +21 -0
- package/dist/js/{i18n → locale}/mr.js +2 -2
- package/dist/js/locale/ms.js +16 -0
- package/dist/js/{i18n → locale}/nl.js +2 -2
- package/dist/js/{i18n → locale}/no.js +2 -2
- package/dist/js/{i18n → locale}/pl.js +2 -2
- package/dist/js/{i18n → locale}/pt.js +2 -2
- package/dist/js/{i18n → locale}/ro.js +4 -4
- package/dist/js/{i18n → locale}/ru.js +2 -2
- package/dist/js/{i18n → locale}/sk.js +5 -8
- package/dist/js/{i18n → locale}/sl.js +2 -2
- package/dist/js/{i18n → locale}/sq.js +2 -2
- package/dist/js/{i18n → locale}/sr.js +2 -2
- package/dist/js/{i18n → locale}/sv.js +2 -5
- package/dist/js/locale/sw.js +19 -0
- package/dist/js/locale/ta.js +19 -0
- package/dist/js/{i18n → locale}/te.js +2 -2
- package/dist/js/{i18n → locale}/th.js +2 -5
- package/dist/js/{i18n → locale}/tr.js +2 -5
- package/dist/js/{i18n → locale}/uk.js +2 -2
- package/dist/js/{i18n → locale}/ur.js +2 -2
- package/dist/js/{i18n → locale}/uz.js +2 -5
- package/dist/js/{i18n → locale}/vi.js +2 -5
- package/dist/js/{i18n → locale}/zh-hk.js +2 -5
- package/dist/js/{i18n → locale}/zh.js +2 -5
- 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 -106
- /package/dist/js/{i18n → locale}/en.js +0 -0
- /package/dist/js/{i18n → locale}/types.js +0 -0
|
@@ -1752,8 +1752,8 @@ var data_default = allCountries;
|
|
|
1752
1752
|
|
|
1753
1753
|
// packages/core/src/js/constants.ts
|
|
1754
1754
|
var EVENTS = {
|
|
1755
|
-
|
|
1756
|
-
|
|
1755
|
+
OPEN_COUNTRY_SELECTOR: "open:countryselector",
|
|
1756
|
+
CLOSE_COUNTRY_SELECTOR: "close:countryselector",
|
|
1757
1757
|
COUNTRY_CHANGE: "countrychange",
|
|
1758
1758
|
INPUT: "input",
|
|
1759
1759
|
// used for synthetic input trigger
|
|
@@ -1767,7 +1767,8 @@ var CLASSES = {
|
|
|
1767
1767
|
FLAG: "iti__flag",
|
|
1768
1768
|
LOADING: "iti__loading",
|
|
1769
1769
|
COUNTRY_ITEM: "iti__country",
|
|
1770
|
-
HIGHLIGHT: "iti__highlight"
|
|
1770
|
+
HIGHLIGHT: "iti__highlight",
|
|
1771
|
+
STRICT_REJECT_ANIMATION: "iti__strict-reject-animation"
|
|
1771
1772
|
};
|
|
1772
1773
|
var KEYS = {
|
|
1773
1774
|
ARROW_UP: "ArrowUp",
|
|
@@ -1799,9 +1800,9 @@ var TIMINGS = {
|
|
|
1799
1800
|
var LAYOUT = {
|
|
1800
1801
|
NARROW_VIEWPORT_WIDTH: 500,
|
|
1801
1802
|
// keep in sync with .iti__country-list CSS media query
|
|
1802
|
-
|
|
1803
|
+
FALLBACK_SELECTED_COUNTRY_WITH_DIAL_WIDTH: 78,
|
|
1803
1804
|
// px width fallback when separateDialCode enabled
|
|
1804
|
-
|
|
1805
|
+
FALLBACK_SELECTED_COUNTRY_NO_DIAL_WIDTH: 42,
|
|
1805
1806
|
// px width fallback when no separate dial code
|
|
1806
1807
|
INPUT_PADDING_EXTRA_LEFT: 6,
|
|
1807
1808
|
// px gap between selected country container and input text
|
|
@@ -1829,14 +1830,17 @@ var US = {
|
|
|
1829
1830
|
DIAL_CODE: "1"
|
|
1830
1831
|
// +1 United States
|
|
1831
1832
|
};
|
|
1832
|
-
var
|
|
1833
|
-
AGGRESSIVE: "
|
|
1834
|
-
POLITE: "
|
|
1835
|
-
OFF: "
|
|
1836
|
-
};
|
|
1837
|
-
var INITIAL_COUNTRY = {
|
|
1838
|
-
AUTO: "auto"
|
|
1833
|
+
var PLACEHOLDER_POLICY = {
|
|
1834
|
+
AGGRESSIVE: "AGGRESSIVE",
|
|
1835
|
+
POLITE: "POLITE",
|
|
1836
|
+
OFF: "OFF"
|
|
1839
1837
|
};
|
|
1838
|
+
var COUNTRY_SELECTOR_MODES = [
|
|
1839
|
+
"OFF",
|
|
1840
|
+
"DROPDOWN",
|
|
1841
|
+
"FULLSCREEN",
|
|
1842
|
+
"AUTO"
|
|
1843
|
+
];
|
|
1840
1844
|
var NUMBER_FORMATS = [
|
|
1841
1845
|
"E164",
|
|
1842
1846
|
"INTERNATIONAL",
|
|
@@ -1869,8 +1873,9 @@ var toEnumObject = (arr) => Object.fromEntries(arr.map((v) => [v, v]));
|
|
|
1869
1873
|
var NUMBER_FORMAT = toEnumObject(NUMBER_FORMATS);
|
|
1870
1874
|
var NUMBER_TYPE = toEnumObject(NUMBER_TYPES);
|
|
1871
1875
|
var VALIDATION_ERROR = toEnumObject(VALIDATION_ERRORS);
|
|
1876
|
+
var COUNTRY_SELECTOR_MODE = toEnumObject(COUNTRY_SELECTOR_MODES);
|
|
1872
1877
|
var DATA_KEYS = {
|
|
1873
|
-
// e.g. <li data-iso2="us"> for country items in
|
|
1878
|
+
// e.g. <li data-iso2="us"> for country items in the country list
|
|
1874
1879
|
ISO2: "iso2",
|
|
1875
1880
|
DIAL_CODE: "dialCode",
|
|
1876
1881
|
// e.g. <input data-intl-tel-input-id="0"> on the input element
|
|
@@ -1888,7 +1893,7 @@ var ARIA = {
|
|
|
1888
1893
|
MODAL: "aria-modal"
|
|
1889
1894
|
};
|
|
1890
1895
|
|
|
1891
|
-
// packages/core/src/js/
|
|
1896
|
+
// packages/core/src/js/locale/en.ts
|
|
1892
1897
|
var interfaceTranslations = {
|
|
1893
1898
|
selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
|
|
1894
1899
|
noCountrySelected: "Select country for phone number",
|
|
@@ -1911,63 +1916,63 @@ var en_default = interfaceTranslations;
|
|
|
1911
1916
|
// packages/core/src/js/core/options.ts
|
|
1912
1917
|
var mediaQuery = (q) => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
|
|
1913
1918
|
var isNarrowViewport = () => mediaQuery(`(max-width: ${LAYOUT.NARROW_VIEWPORT_WIDTH}px)`);
|
|
1914
|
-
var
|
|
1919
|
+
var resolveAutoCountrySelectorMode = () => {
|
|
1915
1920
|
if (typeof navigator !== "undefined" && typeof window !== "undefined") {
|
|
1916
1921
|
const isShortViewport = mediaQuery("(max-height: 600px)");
|
|
1917
1922
|
const isCoarsePointer = mediaQuery("(pointer: coarse)");
|
|
1918
|
-
|
|
1923
|
+
if (isNarrowViewport() || isCoarsePointer && isShortViewport) {
|
|
1924
|
+
return COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
1925
|
+
}
|
|
1919
1926
|
}
|
|
1920
|
-
return
|
|
1927
|
+
return COUNTRY_SELECTOR_MODE.DROPDOWN;
|
|
1921
1928
|
};
|
|
1922
1929
|
var defaults = {
|
|
1923
|
-
//*
|
|
1924
|
-
|
|
1930
|
+
//* How the country selector is displayed. "DROPDOWN" vs "FULLSCREEN", or "AUTO" to decide itself, or "OFF".
|
|
1931
|
+
countrySelectorMode: COUNTRY_SELECTOR_MODE.AUTO,
|
|
1925
1932
|
//* The number type to enforce during validation.
|
|
1926
1933
|
allowedNumberTypes: [NUMBER_TYPE.MOBILE, NUMBER_TYPE.FIXED_LINE],
|
|
1927
1934
|
//* Whether or not to allow extensions after the main number.
|
|
1928
1935
|
allowNumberExtensions: false,
|
|
1929
1936
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1930
1937
|
allowPhonewords: false,
|
|
1931
|
-
//* Add a placeholder in the input with an example number for the selected country.
|
|
1932
|
-
autoPlaceholder: PLACEHOLDER_MODES.POLITE,
|
|
1933
1938
|
//* Add a custom class to the (injected) container element.
|
|
1934
1939
|
containerClass: "",
|
|
1935
1940
|
//* Locale for localising country names via Intl.DisplayNames.
|
|
1936
1941
|
countryNameLocale: "en",
|
|
1937
1942
|
//* Override individual country names by iso2 code.
|
|
1938
1943
|
countryNameOverrides: {},
|
|
1939
|
-
//* The order of the countries in the
|
|
1944
|
+
//* The order of the countries in the country list. Defaults to alphabetical.
|
|
1940
1945
|
countryOrder: null,
|
|
1941
|
-
//* Add a country search input at the top of the
|
|
1946
|
+
//* Add a country search input at the top of the country selector.
|
|
1942
1947
|
countrySearch: true,
|
|
1943
1948
|
//* Modify the auto placeholder.
|
|
1944
1949
|
customPlaceholder: null,
|
|
1945
1950
|
//* Always show the dropdown
|
|
1946
1951
|
dropdownAlwaysOpen: false,
|
|
1947
|
-
//*
|
|
1948
|
-
|
|
1952
|
+
//* 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.
|
|
1953
|
+
dropdownParent: null,
|
|
1949
1954
|
//* Don't display these countries.
|
|
1950
1955
|
excludeCountries: null,
|
|
1951
1956
|
//* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
|
|
1952
|
-
|
|
1957
|
+
matchDropdownWidth: true,
|
|
1953
1958
|
//* Format the number as the user types
|
|
1954
1959
|
formatAsYouType: true,
|
|
1955
|
-
//*
|
|
1956
|
-
|
|
1957
|
-
//*
|
|
1958
|
-
|
|
1959
|
-
//* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
|
|
1960
|
-
hiddenInput: null,
|
|
1961
|
-
//* Internationalise the core library text e.g. search input placeholder, country names.
|
|
1962
|
-
i18n: {},
|
|
1960
|
+
//* Inject hidden inputs with the names returned from this function, and on submit, populate them with the full number and selected country iso2.
|
|
1961
|
+
hiddenInputs: null,
|
|
1962
|
+
//* Translations for the core library UI strings e.g. search input placeholder, country names.
|
|
1963
|
+
uiTranslations: {},
|
|
1963
1964
|
//* Initial country.
|
|
1964
1965
|
initialCountry: "",
|
|
1966
|
+
//* Async lookup function used to determine the initial country (e.g. via IP). Ignored if initialCountry is set.
|
|
1967
|
+
initialCountryLookup: null,
|
|
1965
1968
|
//* A function to load the utils script.
|
|
1966
1969
|
loadUtils: null,
|
|
1967
|
-
//*
|
|
1968
|
-
|
|
1970
|
+
//* Format used when displaying numbers (placeholder examples and stored values). One of "E164", "INTERNATIONAL", "NATIONAL".
|
|
1971
|
+
numberDisplayFormat: NUMBER_FORMAT.INTERNATIONAL,
|
|
1969
1972
|
//* Display only these countries.
|
|
1970
1973
|
onlyCountries: null,
|
|
1974
|
+
//* 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.
|
|
1975
|
+
placeholderNumberPolicy: PLACEHOLDER_POLICY.POLITE,
|
|
1971
1976
|
//* Number type to use for placeholders.
|
|
1972
1977
|
placeholderNumberType: NUMBER_TYPE.MOBILE,
|
|
1973
1978
|
//* Add custom classes to the search input element.
|
|
@@ -1976,12 +1981,10 @@ var defaults = {
|
|
|
1976
1981
|
separateDialCode: true,
|
|
1977
1982
|
//* When strictMode rejects a key (etc), play a short feedback animation
|
|
1978
1983
|
strictRejectAnimation: true,
|
|
1979
|
-
//* Show flags - for both the selected country, and in the country
|
|
1984
|
+
//* Show flags - for both the selected country, and in the country list
|
|
1980
1985
|
showFlags: true,
|
|
1981
1986
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1982
|
-
strictMode: true
|
|
1983
|
-
//* Use full screen popup instead of dropdown for country list.
|
|
1984
|
-
useFullscreenPopup: computeDefaultUseFullscreenPopup()
|
|
1987
|
+
strictMode: true
|
|
1985
1988
|
};
|
|
1986
1989
|
var toString = (val) => JSON.stringify(val);
|
|
1987
1990
|
var isPlainObject = (val) => Boolean(val) && typeof val === "object" && !Array.isArray(val);
|
|
@@ -1993,7 +1996,7 @@ var isElLike = (val) => {
|
|
|
1993
1996
|
const v = val;
|
|
1994
1997
|
return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
|
|
1995
1998
|
};
|
|
1996
|
-
var
|
|
1999
|
+
var placeholderPolicySet = new Set(Object.values(PLACEHOLDER_POLICY));
|
|
1997
2000
|
var warn = (message) => {
|
|
1998
2001
|
console.warn(`[intl-tel-input] ${message}`);
|
|
1999
2002
|
};
|
|
@@ -2039,30 +2042,48 @@ var validateOptions = (customOptions) => {
|
|
|
2039
2042
|
continue;
|
|
2040
2043
|
}
|
|
2041
2044
|
switch (key) {
|
|
2042
|
-
case "allowDropdown":
|
|
2043
2045
|
case "allowNumberExtensions":
|
|
2044
2046
|
case "allowPhonewords":
|
|
2045
2047
|
case "countrySearch":
|
|
2046
2048
|
case "dropdownAlwaysOpen":
|
|
2047
|
-
case "
|
|
2049
|
+
case "matchDropdownWidth":
|
|
2048
2050
|
case "formatAsYouType":
|
|
2049
|
-
case "formatOnDisplay":
|
|
2050
|
-
case "nationalMode":
|
|
2051
2051
|
case "showFlags":
|
|
2052
2052
|
case "separateDialCode":
|
|
2053
2053
|
case "strictMode":
|
|
2054
2054
|
case "strictRejectAnimation":
|
|
2055
|
-
case "useFullscreenPopup":
|
|
2056
2055
|
if (typeof value !== "boolean") {
|
|
2057
2056
|
warnOption(key, "a boolean", value);
|
|
2058
2057
|
break;
|
|
2059
2058
|
}
|
|
2060
2059
|
validatedOptions[key] = value;
|
|
2061
2060
|
break;
|
|
2062
|
-
case "
|
|
2063
|
-
if (typeof value !== "string" || !
|
|
2064
|
-
|
|
2065
|
-
|
|
2061
|
+
case "countrySelectorMode":
|
|
2062
|
+
if (typeof value !== "string" || !COUNTRY_SELECTOR_MODES.includes(value)) {
|
|
2063
|
+
warnOption(
|
|
2064
|
+
"countrySelectorMode",
|
|
2065
|
+
`one of ${COUNTRY_SELECTOR_MODES.map((m) => `"${m}"`).join(", ")}`,
|
|
2066
|
+
value
|
|
2067
|
+
);
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
validatedOptions[key] = value;
|
|
2071
|
+
break;
|
|
2072
|
+
case "numberDisplayFormat":
|
|
2073
|
+
if (typeof value !== "string" || value === NUMBER_FORMAT.RFC3966 || !(value === NUMBER_FORMAT.E164 || value === NUMBER_FORMAT.INTERNATIONAL || value === NUMBER_FORMAT.NATIONAL)) {
|
|
2074
|
+
warnOption(
|
|
2075
|
+
"numberDisplayFormat",
|
|
2076
|
+
'one of "E164", "INTERNATIONAL", "NATIONAL"',
|
|
2077
|
+
value
|
|
2078
|
+
);
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
validatedOptions[key] = value;
|
|
2082
|
+
break;
|
|
2083
|
+
case "placeholderNumberPolicy":
|
|
2084
|
+
if (typeof value !== "string" || !placeholderPolicySet.has(value)) {
|
|
2085
|
+
const validPolicies = Array.from(placeholderPolicySet).join(", ");
|
|
2086
|
+
warnOption("placeholderNumberPolicy", `one of ${validPolicies}`, value);
|
|
2066
2087
|
break;
|
|
2067
2088
|
}
|
|
2068
2089
|
validatedOptions[key] = value;
|
|
@@ -2088,8 +2109,8 @@ var validateOptions = (customOptions) => {
|
|
|
2088
2109
|
break;
|
|
2089
2110
|
}
|
|
2090
2111
|
case "customPlaceholder":
|
|
2091
|
-
case "
|
|
2092
|
-
case "
|
|
2112
|
+
case "hiddenInputs":
|
|
2113
|
+
case "initialCountryLookup":
|
|
2093
2114
|
case "loadUtils":
|
|
2094
2115
|
if (value !== null && !isFunction(value)) {
|
|
2095
2116
|
warnOption(key, "a function or null", value);
|
|
@@ -2097,9 +2118,9 @@ var validateOptions = (customOptions) => {
|
|
|
2097
2118
|
}
|
|
2098
2119
|
validatedOptions[key] = value;
|
|
2099
2120
|
break;
|
|
2100
|
-
case "
|
|
2121
|
+
case "dropdownParent":
|
|
2101
2122
|
if (value !== null && !isElLike(value)) {
|
|
2102
|
-
warnOption("
|
|
2123
|
+
warnOption("dropdownParent", "an HTMLElement or null", value);
|
|
2103
2124
|
break;
|
|
2104
2125
|
}
|
|
2105
2126
|
validatedOptions[key] = value;
|
|
@@ -2116,9 +2137,9 @@ var validateOptions = (customOptions) => {
|
|
|
2116
2137
|
}
|
|
2117
2138
|
break;
|
|
2118
2139
|
}
|
|
2119
|
-
case "
|
|
2140
|
+
case "uiTranslations":
|
|
2120
2141
|
if (value && !isPlainObject(value)) {
|
|
2121
|
-
warnOption("
|
|
2142
|
+
warnOption("uiTranslations", "an object", value);
|
|
2122
2143
|
break;
|
|
2123
2144
|
}
|
|
2124
2145
|
validatedOptions[key] = value;
|
|
@@ -2136,12 +2157,8 @@ var validateOptions = (customOptions) => {
|
|
|
2136
2157
|
break;
|
|
2137
2158
|
}
|
|
2138
2159
|
const lower = value.toLowerCase();
|
|
2139
|
-
if (lower &&
|
|
2140
|
-
warnOption(
|
|
2141
|
-
"initialCountry",
|
|
2142
|
-
"a valid iso2 country code or 'auto'",
|
|
2143
|
-
value
|
|
2144
|
-
);
|
|
2160
|
+
if (lower && !isIso2(lower)) {
|
|
2161
|
+
warnOption("initialCountry", "a valid iso2 country code", value);
|
|
2145
2162
|
break;
|
|
2146
2163
|
}
|
|
2147
2164
|
validatedOptions[key] = value;
|
|
@@ -2204,30 +2221,29 @@ var normaliseOptions = (o) => {
|
|
|
2204
2221
|
}
|
|
2205
2222
|
};
|
|
2206
2223
|
var applyOptionSideEffects = (o) => {
|
|
2224
|
+
if (o.countrySelectorMode === COUNTRY_SELECTOR_MODE.AUTO) {
|
|
2225
|
+
o.countrySelectorMode = resolveAutoCountrySelectorMode();
|
|
2226
|
+
}
|
|
2207
2227
|
if (o.dropdownAlwaysOpen) {
|
|
2208
|
-
o.
|
|
2209
|
-
o.allowDropdown = true;
|
|
2228
|
+
o.countrySelectorMode = COUNTRY_SELECTOR_MODE.DROPDOWN;
|
|
2210
2229
|
}
|
|
2211
|
-
if (o.
|
|
2212
|
-
o.
|
|
2230
|
+
if (o.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN) {
|
|
2231
|
+
o.matchDropdownWidth = false;
|
|
2213
2232
|
} else {
|
|
2214
2233
|
if (isNarrowViewport()) {
|
|
2215
|
-
o.
|
|
2234
|
+
o.matchDropdownWidth = true;
|
|
2216
2235
|
}
|
|
2217
2236
|
}
|
|
2218
2237
|
if (o.onlyCountries?.length === 1) {
|
|
2219
2238
|
o.initialCountry = o.onlyCountries[0];
|
|
2220
2239
|
}
|
|
2221
|
-
if (o.separateDialCode) {
|
|
2222
|
-
o.
|
|
2223
|
-
}
|
|
2224
|
-
if (o.allowDropdown && !o.showFlags && !o.separateDialCode) {
|
|
2225
|
-
o.nationalMode = false;
|
|
2240
|
+
if (o.separateDialCode && o.numberDisplayFormat === NUMBER_FORMAT.NATIONAL) {
|
|
2241
|
+
o.numberDisplayFormat = NUMBER_FORMAT.INTERNATIONAL;
|
|
2226
2242
|
}
|
|
2227
|
-
if (o.
|
|
2228
|
-
o.
|
|
2243
|
+
if (o.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && !o.showFlags && !o.separateDialCode && o.numberDisplayFormat === NUMBER_FORMAT.NATIONAL) {
|
|
2244
|
+
o.numberDisplayFormat = NUMBER_FORMAT.INTERNATIONAL;
|
|
2229
2245
|
}
|
|
2230
|
-
o.
|
|
2246
|
+
o.uiTranslations = { ...en_default, ...o.uiTranslations };
|
|
2231
2247
|
};
|
|
2232
2248
|
|
|
2233
2249
|
// packages/core/src/js/helpers/string.ts
|
|
@@ -2438,6 +2454,7 @@ var Numerals = class _Numerals {
|
|
|
2438
2454
|
};
|
|
2439
2455
|
|
|
2440
2456
|
// packages/core/src/js/core/ui.ts
|
|
2457
|
+
var supportsCssAnchor = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name: --x");
|
|
2441
2458
|
var UI = class _UI {
|
|
2442
2459
|
// private
|
|
2443
2460
|
#options;
|
|
@@ -2452,8 +2469,8 @@ var UI = class _UI {
|
|
|
2452
2469
|
#selectedCountryEl;
|
|
2453
2470
|
#selectedFlagEl;
|
|
2454
2471
|
#selectedDialCodeEl;
|
|
2455
|
-
#
|
|
2456
|
-
#
|
|
2472
|
+
#arrowEl;
|
|
2473
|
+
#countrySelectorEl;
|
|
2457
2474
|
#searchIconEl;
|
|
2458
2475
|
#searchInputEl;
|
|
2459
2476
|
#searchClearButtonEl;
|
|
@@ -2462,11 +2479,11 @@ var UI = class _UI {
|
|
|
2462
2479
|
#hiddenInputCountryEl;
|
|
2463
2480
|
#noResultsMessageEl;
|
|
2464
2481
|
#searchResultsLiveRegionEl;
|
|
2465
|
-
#
|
|
2482
|
+
#detachedCountrySelectorEl;
|
|
2466
2483
|
#selectedListItemEl = null;
|
|
2467
2484
|
#highlightedListItemEl = null;
|
|
2468
2485
|
#listItemByIso2 = /* @__PURE__ */ new Map();
|
|
2469
|
-
#
|
|
2486
|
+
#countrySelectorAbortController = null;
|
|
2470
2487
|
#resizeObserver;
|
|
2471
2488
|
// public
|
|
2472
2489
|
telInputEl;
|
|
@@ -2491,7 +2508,7 @@ var UI = class _UI {
|
|
|
2491
2508
|
);
|
|
2492
2509
|
}
|
|
2493
2510
|
}
|
|
2494
|
-
//* Generate all of the markup for the core library: the selected country overlay, and the
|
|
2511
|
+
//* Generate all of the markup for the core library: the selected country overlay, and the country selector.
|
|
2495
2512
|
buildMarkup(countries, searchTokens) {
|
|
2496
2513
|
this.#countries = countries;
|
|
2497
2514
|
this.#searchTokens = searchTokens;
|
|
@@ -2514,13 +2531,13 @@ var UI = class _UI {
|
|
|
2514
2531
|
this.ensureDropdownWidthSet();
|
|
2515
2532
|
}
|
|
2516
2533
|
#createWrapperAndInsert() {
|
|
2517
|
-
const {
|
|
2534
|
+
const { countrySelectorMode, showFlags, containerClass } = this.#options;
|
|
2518
2535
|
const parentClasses = buildClassNames({
|
|
2519
2536
|
iti: true,
|
|
2520
2537
|
"iti--input-container": true,
|
|
2521
|
-
"iti--
|
|
2538
|
+
"iti--has-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF,
|
|
2522
2539
|
"iti--show-flags": showFlags,
|
|
2523
|
-
"iti--inline-
|
|
2540
|
+
"iti--inline-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.FULLSCREEN,
|
|
2524
2541
|
[containerClass]: Boolean(containerClass)
|
|
2525
2542
|
});
|
|
2526
2543
|
const wrapper = createEl("div", { class: parentClasses });
|
|
@@ -2531,8 +2548,9 @@ var UI = class _UI {
|
|
|
2531
2548
|
return wrapper;
|
|
2532
2549
|
}
|
|
2533
2550
|
#buildCountryContainer(wrapper) {
|
|
2534
|
-
const {
|
|
2535
|
-
|
|
2551
|
+
const { countrySelectorMode, separateDialCode, showFlags } = this.#options;
|
|
2552
|
+
const enableCountrySelector = countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF;
|
|
2553
|
+
if (!enableCountrySelector && !showFlags && !separateDialCode) {
|
|
2536
2554
|
return;
|
|
2537
2555
|
}
|
|
2538
2556
|
this.#countryContainerEl = createEl(
|
|
@@ -2541,16 +2559,16 @@ var UI = class _UI {
|
|
|
2541
2559
|
{ class: `iti__country-container ${CLASSES.V_HIDE}` },
|
|
2542
2560
|
wrapper
|
|
2543
2561
|
);
|
|
2544
|
-
if (
|
|
2562
|
+
if (enableCountrySelector) {
|
|
2545
2563
|
this.#selectedCountryEl = createEl(
|
|
2546
2564
|
"button",
|
|
2547
2565
|
{
|
|
2548
2566
|
type: "button",
|
|
2549
2567
|
class: "iti__selected-country",
|
|
2550
2568
|
[ARIA.EXPANDED]: "false",
|
|
2551
|
-
[ARIA.LABEL]: this.#options.
|
|
2569
|
+
[ARIA.LABEL]: this.#options.uiTranslations.noCountrySelected,
|
|
2552
2570
|
[ARIA.HASPOPUP]: "dialog",
|
|
2553
|
-
[ARIA.CONTROLS]: `iti-${this.#id}
|
|
2571
|
+
[ARIA.CONTROLS]: `iti-${this.#id}__country-selector`
|
|
2554
2572
|
},
|
|
2555
2573
|
this.#countryContainerEl
|
|
2556
2574
|
);
|
|
@@ -2574,8 +2592,8 @@ var UI = class _UI {
|
|
|
2574
2592
|
{ class: CLASSES.FLAG },
|
|
2575
2593
|
selectedCountryPrimary
|
|
2576
2594
|
);
|
|
2577
|
-
if (
|
|
2578
|
-
this.#
|
|
2595
|
+
if (enableCountrySelector) {
|
|
2596
|
+
this.#arrowEl = createEl(
|
|
2579
2597
|
"div",
|
|
2580
2598
|
{ class: "iti__arrow", [ARIA.HIDDEN]: "true" },
|
|
2581
2599
|
selectedCountryPrimary
|
|
@@ -2588,38 +2606,39 @@ var UI = class _UI {
|
|
|
2588
2606
|
this.#selectedCountryEl
|
|
2589
2607
|
);
|
|
2590
2608
|
}
|
|
2591
|
-
if (
|
|
2592
|
-
this.#
|
|
2609
|
+
if (enableCountrySelector) {
|
|
2610
|
+
this.#buildCountrySelector();
|
|
2593
2611
|
}
|
|
2594
2612
|
}
|
|
2595
2613
|
ensureDropdownWidthSet() {
|
|
2596
|
-
const {
|
|
2597
|
-
if (
|
|
2614
|
+
const { matchDropdownWidth, countrySelectorMode } = this.#options;
|
|
2615
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.OFF || !matchDropdownWidth || this.#countrySelectorEl.style.width) {
|
|
2598
2616
|
return;
|
|
2599
2617
|
}
|
|
2600
2618
|
const inputWidth = this.telInputEl.offsetWidth;
|
|
2601
2619
|
if (inputWidth > 0) {
|
|
2602
|
-
this.#
|
|
2620
|
+
this.#countrySelectorEl.style.width = `${inputWidth}px`;
|
|
2603
2621
|
}
|
|
2604
2622
|
}
|
|
2605
|
-
#
|
|
2623
|
+
#buildCountrySelector() {
|
|
2606
2624
|
const {
|
|
2607
|
-
|
|
2608
|
-
|
|
2625
|
+
matchDropdownWidth,
|
|
2626
|
+
countrySelectorMode,
|
|
2609
2627
|
countrySearch,
|
|
2610
|
-
|
|
2611
|
-
dropdownContainer,
|
|
2628
|
+
uiTranslations,
|
|
2612
2629
|
containerClass
|
|
2613
2630
|
} = this.#options;
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2631
|
+
const isFullscreen = countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
2632
|
+
const detachedParent = this.#getDetachedParent();
|
|
2633
|
+
const extraClasses = matchDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2634
|
+
this.#countrySelectorEl = createEl("div", {
|
|
2635
|
+
id: `iti-${this.#id}__country-selector`,
|
|
2636
|
+
class: `iti__country-selector ${CLASSES.HIDE} ${extraClasses}`,
|
|
2618
2637
|
role: "dialog",
|
|
2619
2638
|
[ARIA.MODAL]: "true"
|
|
2620
2639
|
});
|
|
2621
2640
|
if (this.#isRTL) {
|
|
2622
|
-
this.#
|
|
2641
|
+
this.#countrySelectorEl.setAttribute("dir", "rtl");
|
|
2623
2642
|
}
|
|
2624
2643
|
if (countrySearch) {
|
|
2625
2644
|
this.#buildSearchUI();
|
|
@@ -2630,40 +2649,54 @@ var UI = class _UI {
|
|
|
2630
2649
|
class: "iti__country-list",
|
|
2631
2650
|
id: `iti-${this.#id}__country-listbox`,
|
|
2632
2651
|
role: "listbox",
|
|
2633
|
-
[ARIA.LABEL]:
|
|
2652
|
+
[ARIA.LABEL]: uiTranslations.countryListAriaLabel
|
|
2634
2653
|
},
|
|
2635
|
-
this.#
|
|
2654
|
+
this.#countrySelectorEl
|
|
2636
2655
|
);
|
|
2637
2656
|
this.#appendListItems();
|
|
2638
2657
|
if (countrySearch) {
|
|
2639
2658
|
this.#updateSearchResultsA11yText();
|
|
2640
2659
|
}
|
|
2641
|
-
if (!
|
|
2660
|
+
if (!isFullscreen) {
|
|
2642
2661
|
this.#inlineDropdownHeight = this.#getHiddenInlineDropdownHeight();
|
|
2643
2662
|
if (countrySearch) {
|
|
2644
|
-
this.#
|
|
2663
|
+
this.#countrySelectorEl.style.height = `${this.#inlineDropdownHeight}px`;
|
|
2645
2664
|
}
|
|
2646
2665
|
}
|
|
2647
|
-
if (
|
|
2648
|
-
const
|
|
2666
|
+
if (detachedParent) {
|
|
2667
|
+
const wrapperClasses = buildClassNames({
|
|
2649
2668
|
iti: true,
|
|
2650
|
-
"iti--
|
|
2651
|
-
"iti--fullscreen-popup":
|
|
2652
|
-
"iti--inline-
|
|
2669
|
+
"iti--detached-country-selector": true,
|
|
2670
|
+
"iti--fullscreen-popup": isFullscreen,
|
|
2671
|
+
"iti--inline-country-selector": !isFullscreen,
|
|
2653
2672
|
[containerClass]: Boolean(containerClass)
|
|
2654
2673
|
});
|
|
2655
|
-
this.#
|
|
2656
|
-
this.#
|
|
2674
|
+
this.#detachedCountrySelectorEl = createEl("div", { class: wrapperClasses });
|
|
2675
|
+
this.#detachedCountrySelectorEl.appendChild(this.#countrySelectorEl);
|
|
2676
|
+
if (!isFullscreen) {
|
|
2677
|
+
this.#setupCssAnchorPositioning();
|
|
2678
|
+
}
|
|
2657
2679
|
} else {
|
|
2658
|
-
this.#countryContainerEl.appendChild(this.#
|
|
2680
|
+
this.#countryContainerEl.appendChild(this.#countrySelectorEl);
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
//* 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).
|
|
2684
|
+
#getDetachedParent() {
|
|
2685
|
+
const { countrySelectorMode, dropdownParent } = this.#options;
|
|
2686
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN) {
|
|
2687
|
+
return document.body;
|
|
2659
2688
|
}
|
|
2689
|
+
if (countrySelectorMode === COUNTRY_SELECTOR_MODE.DROPDOWN) {
|
|
2690
|
+
return dropdownParent;
|
|
2691
|
+
}
|
|
2692
|
+
return null;
|
|
2660
2693
|
}
|
|
2661
2694
|
#buildSearchUI() {
|
|
2662
|
-
const {
|
|
2695
|
+
const { uiTranslations, searchInputClass } = this.#options;
|
|
2663
2696
|
const searchWrapper = createEl(
|
|
2664
2697
|
"div",
|
|
2665
2698
|
{ class: "iti__search-input-wrapper" },
|
|
2666
|
-
this.#
|
|
2699
|
+
this.#countrySelectorEl
|
|
2667
2700
|
);
|
|
2668
2701
|
this.#searchIconEl = createEl(
|
|
2669
2702
|
"span",
|
|
@@ -2681,11 +2714,11 @@ var UI = class _UI {
|
|
|
2681
2714
|
// Chrome says inputs need either a name or an id
|
|
2682
2715
|
type: "search",
|
|
2683
2716
|
class: `iti__search-input ${searchInputClass}`,
|
|
2684
|
-
placeholder:
|
|
2717
|
+
placeholder: uiTranslations.searchPlaceholder,
|
|
2685
2718
|
// 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
|
|
2686
2719
|
role: "combobox",
|
|
2687
2720
|
[ARIA.EXPANDED]: "true",
|
|
2688
|
-
[ARIA.LABEL]:
|
|
2721
|
+
[ARIA.LABEL]: uiTranslations.searchPlaceholder,
|
|
2689
2722
|
[ARIA.CONTROLS]: `iti-${this.#id}__country-listbox`,
|
|
2690
2723
|
[ARIA.AUTOCOMPLETE]: "list",
|
|
2691
2724
|
autocomplete: "off"
|
|
@@ -2697,7 +2730,7 @@ var UI = class _UI {
|
|
|
2697
2730
|
{
|
|
2698
2731
|
type: "button",
|
|
2699
2732
|
class: `iti__search-clear ${CLASSES.HIDE}`,
|
|
2700
|
-
[ARIA.LABEL]:
|
|
2733
|
+
[ARIA.LABEL]: uiTranslations.clearSearchAriaLabel,
|
|
2701
2734
|
tabindex: "-1"
|
|
2702
2735
|
},
|
|
2703
2736
|
searchWrapper
|
|
@@ -2706,7 +2739,7 @@ var UI = class _UI {
|
|
|
2706
2739
|
this.#searchResultsLiveRegionEl = createEl(
|
|
2707
2740
|
"span",
|
|
2708
2741
|
{ class: "iti__a11y-text" },
|
|
2709
|
-
this.#
|
|
2742
|
+
this.#countrySelectorEl
|
|
2710
2743
|
);
|
|
2711
2744
|
this.#noResultsMessageEl = createEl(
|
|
2712
2745
|
"div",
|
|
@@ -2715,9 +2748,9 @@ var UI = class _UI {
|
|
|
2715
2748
|
[ARIA.HIDDEN]: "true"
|
|
2716
2749
|
// all a11y messaging happens in this.#searchResultsLiveRegionEl
|
|
2717
2750
|
},
|
|
2718
|
-
this.#
|
|
2751
|
+
this.#countrySelectorEl
|
|
2719
2752
|
);
|
|
2720
|
-
this.#noResultsMessageEl.textContent =
|
|
2753
|
+
this.#noResultsMessageEl.textContent = uiTranslations.searchEmptyState ?? null;
|
|
2721
2754
|
}
|
|
2722
2755
|
#updateInputPaddingAndReveal() {
|
|
2723
2756
|
if (!this.#countryContainerEl) {
|
|
@@ -2727,12 +2760,12 @@ var UI = class _UI {
|
|
|
2727
2760
|
this.#countryContainerEl.classList.remove(CLASSES.V_HIDE);
|
|
2728
2761
|
}
|
|
2729
2762
|
#buildHiddenInputs(wrapper) {
|
|
2730
|
-
const {
|
|
2731
|
-
if (!
|
|
2763
|
+
const { hiddenInputs } = this.#options;
|
|
2764
|
+
if (!hiddenInputs) {
|
|
2732
2765
|
return;
|
|
2733
2766
|
}
|
|
2734
2767
|
const telInputName = this.telInputEl.getAttribute("name") || "";
|
|
2735
|
-
const names =
|
|
2768
|
+
const names = hiddenInputs(telInputName);
|
|
2736
2769
|
if (names.phone) {
|
|
2737
2770
|
const existingInput = this.telInputEl.form?.querySelector(
|
|
2738
2771
|
`input[name="${names.phone}"]`
|
|
@@ -2797,7 +2830,7 @@ var UI = class _UI {
|
|
|
2797
2830
|
//* 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.
|
|
2798
2831
|
#updateInputPadding() {
|
|
2799
2832
|
if (this.#selectedCountryEl) {
|
|
2800
|
-
const fallbackWidth = this.#options.separateDialCode ? LAYOUT.
|
|
2833
|
+
const fallbackWidth = this.#options.separateDialCode ? LAYOUT.FALLBACK_SELECTED_COUNTRY_WITH_DIAL_WIDTH : LAYOUT.FALLBACK_SELECTED_COUNTRY_NO_DIAL_WIDTH;
|
|
2801
2834
|
const selectedCountryWidth = this.#selectedCountryEl.offsetWidth || this.#getHiddenSelectedCountryWidth() || fallbackWidth;
|
|
2802
2835
|
const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
|
|
2803
2836
|
this.telInputEl.style.paddingLeft = `${inputPadding}px`;
|
|
@@ -2851,24 +2884,24 @@ var UI = class _UI {
|
|
|
2851
2884
|
// Get the dropdown height (before it is added to the DOM)
|
|
2852
2885
|
#getHiddenInlineDropdownHeight() {
|
|
2853
2886
|
const body = _UI.#getBody();
|
|
2854
|
-
this.#
|
|
2887
|
+
this.#countrySelectorEl.classList.remove(CLASSES.HIDE);
|
|
2855
2888
|
const tempContainer = createEl("div", {
|
|
2856
|
-
class: "iti iti--inline-
|
|
2889
|
+
class: "iti iti--inline-country-selector"
|
|
2857
2890
|
});
|
|
2858
|
-
tempContainer.appendChild(this.#
|
|
2891
|
+
tempContainer.appendChild(this.#countrySelectorEl);
|
|
2859
2892
|
tempContainer.style.visibility = "hidden";
|
|
2860
2893
|
body.appendChild(tempContainer);
|
|
2861
|
-
const height = this.#
|
|
2894
|
+
const height = this.#countrySelectorEl.offsetHeight;
|
|
2862
2895
|
body.removeChild(tempContainer);
|
|
2863
2896
|
tempContainer.style.visibility = "";
|
|
2864
|
-
this.#
|
|
2897
|
+
this.#countrySelectorEl.classList.add(CLASSES.HIDE);
|
|
2865
2898
|
return height > 0 ? height : LAYOUT.FALLBACK_DROPDOWN_HEIGHT;
|
|
2866
2899
|
}
|
|
2867
2900
|
//* Update search results text (for a11y).
|
|
2868
2901
|
#updateSearchResultsA11yText() {
|
|
2869
|
-
const {
|
|
2902
|
+
const { uiTranslations } = this.#options;
|
|
2870
2903
|
const count = this.#countryListEl.childElementCount;
|
|
2871
|
-
this.#searchResultsLiveRegionEl.textContent =
|
|
2904
|
+
this.#searchResultsLiveRegionEl.textContent = uiTranslations.searchSummaryAria(count);
|
|
2872
2905
|
}
|
|
2873
2906
|
//* Country search: Filter the countries according to the search query.
|
|
2874
2907
|
#filterCountriesByQuery(query) {
|
|
@@ -2886,8 +2919,8 @@ var UI = class _UI {
|
|
|
2886
2919
|
this.#showFilteredCountries(matchedCountries);
|
|
2887
2920
|
}
|
|
2888
2921
|
//* Pre-fill the search input with "+" and show all countries
|
|
2889
|
-
//* (used when user types "+" in the phone input to open the
|
|
2890
|
-
//* Explicitly focus the search input (
|
|
2922
|
+
//* (used when user types "+" in the phone input to open the country selector).
|
|
2923
|
+
//* Explicitly focus the search input (openCountrySelector skips this when
|
|
2891
2924
|
//* dropdownAlwaysOpen, but here we need focus to redirect subsequent keystrokes).
|
|
2892
2925
|
prefillSearchWithPlus() {
|
|
2893
2926
|
this.#searchInputEl.value = "+";
|
|
@@ -2970,15 +3003,15 @@ var UI = class _UI {
|
|
|
2970
3003
|
{ signal }
|
|
2971
3004
|
);
|
|
2972
3005
|
}
|
|
2973
|
-
//* Wire up triggers that open/close the
|
|
3006
|
+
//* Wire up triggers that open/close the country selector: label click (focus input or swallow repeat click),
|
|
2974
3007
|
//* selected-country click (open), and keydown on countryContainer (open on arrow/space/enter, close on tab).
|
|
2975
|
-
|
|
3008
|
+
bindAllInitialCountrySelectorListeners(signal, onOpen, onClose) {
|
|
2976
3009
|
const label = this.telInputEl.closest("label");
|
|
2977
3010
|
if (label) {
|
|
2978
3011
|
label.addEventListener(
|
|
2979
3012
|
"click",
|
|
2980
3013
|
(e) => {
|
|
2981
|
-
if (!this.
|
|
3014
|
+
if (!this.isCountrySelectorOpen()) {
|
|
2982
3015
|
this.telInputEl.focus();
|
|
2983
3016
|
} else {
|
|
2984
3017
|
e.preventDefault();
|
|
@@ -2990,7 +3023,7 @@ var UI = class _UI {
|
|
|
2990
3023
|
this.#selectedCountryEl.addEventListener(
|
|
2991
3024
|
"click",
|
|
2992
3025
|
() => {
|
|
2993
|
-
if (!this.
|
|
3026
|
+
if (!this.isCountrySelectorOpen() && !this.telInputEl.disabled && !this.telInputEl.readOnly) {
|
|
2994
3027
|
onOpen();
|
|
2995
3028
|
}
|
|
2996
3029
|
},
|
|
@@ -3005,7 +3038,7 @@ var UI = class _UI {
|
|
|
3005
3038
|
KEYS.SPACE,
|
|
3006
3039
|
KEYS.ENTER
|
|
3007
3040
|
];
|
|
3008
|
-
if (!this.
|
|
3041
|
+
if (!this.isCountrySelectorOpen() && openKeys.includes(e.key)) {
|
|
3009
3042
|
e.preventDefault();
|
|
3010
3043
|
e.stopPropagation();
|
|
3011
3044
|
onOpen();
|
|
@@ -3017,24 +3050,24 @@ var UI = class _UI {
|
|
|
3017
3050
|
{ signal }
|
|
3018
3051
|
);
|
|
3019
3052
|
}
|
|
3020
|
-
//* Open the
|
|
3021
|
-
//*
|
|
3022
|
-
|
|
3023
|
-
const { countrySearch, dropdownAlwaysOpen
|
|
3024
|
-
this.#
|
|
3053
|
+
//* Open the country selector: create a fresh AbortController, do the DOM work, and wire up all
|
|
3054
|
+
//* open-state listeners (which invoke the caller's onSelect / onClose callbacks).
|
|
3055
|
+
openCountrySelector(onSelect, onClose) {
|
|
3056
|
+
const { countrySearch, dropdownAlwaysOpen } = this.#options;
|
|
3057
|
+
this.#countrySelectorAbortController = new AbortController();
|
|
3025
3058
|
this.ensureDropdownWidthSet();
|
|
3026
|
-
if (
|
|
3027
|
-
this.#
|
|
3059
|
+
if (this.#detachedCountrySelectorEl) {
|
|
3060
|
+
this.#injectAndPositionDetachedCountrySelector();
|
|
3028
3061
|
} else {
|
|
3029
|
-
const positionBelow = this.#
|
|
3062
|
+
const positionBelow = this.#shouldPositionDropdownBelowInput();
|
|
3030
3063
|
const distance = this.telInputEl.offsetHeight + LAYOUT.DROPDOWN_MARGIN;
|
|
3031
3064
|
if (positionBelow) {
|
|
3032
|
-
this.#
|
|
3065
|
+
this.#countrySelectorEl.style.top = `${distance}px`;
|
|
3033
3066
|
} else {
|
|
3034
|
-
this.#
|
|
3067
|
+
this.#countrySelectorEl.style.bottom = `${distance}px`;
|
|
3035
3068
|
}
|
|
3036
3069
|
}
|
|
3037
|
-
this.#
|
|
3070
|
+
this.#countrySelectorEl.classList.remove(CLASSES.HIDE);
|
|
3038
3071
|
this.#selectedCountryEl.setAttribute(ARIA.EXPANDED, "true");
|
|
3039
3072
|
const itemToHighlight = this.#selectedListItemEl ?? this.#countryListEl.firstElementChild;
|
|
3040
3073
|
if (itemToHighlight) {
|
|
@@ -3043,7 +3076,7 @@ var UI = class _UI {
|
|
|
3043
3076
|
if (countrySearch && !dropdownAlwaysOpen) {
|
|
3044
3077
|
this.#searchInputEl.focus();
|
|
3045
3078
|
}
|
|
3046
|
-
if (this.#options.
|
|
3079
|
+
if (this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN && this.#detachedCountrySelectorEl && window.visualViewport) {
|
|
3047
3080
|
window.visualViewport.addEventListener(
|
|
3048
3081
|
"resize",
|
|
3049
3082
|
() => {
|
|
@@ -3052,29 +3085,29 @@ var UI = class _UI {
|
|
|
3052
3085
|
this.#scrollCountryListToItem(this.#highlightedListItemEl);
|
|
3053
3086
|
}
|
|
3054
3087
|
},
|
|
3055
|
-
{ signal: this.#
|
|
3088
|
+
{ signal: this.#countrySelectorAbortController.signal }
|
|
3056
3089
|
);
|
|
3057
3090
|
}
|
|
3058
|
-
this.#
|
|
3059
|
-
this.#
|
|
3091
|
+
this.#arrowEl.classList.add(CLASSES.ARROW_UP);
|
|
3092
|
+
this.#bindCountrySelectorOpenListeners(onSelect, onClose);
|
|
3060
3093
|
}
|
|
3061
|
-
//* Wire up all listeners needed while the
|
|
3094
|
+
//* Wire up all listeners needed while the country selector is open: list-item hover (highlight),
|
|
3062
3095
|
//* list-item click & enter key (select), click-off & escape (close), search input (filter),
|
|
3063
|
-
//* (when countrySearch disabled) typed-char hidden search, and (when
|
|
3064
|
-
//* container)
|
|
3065
|
-
#
|
|
3066
|
-
const signal = this.#
|
|
3096
|
+
//* (when countrySearch disabled) typed-char hidden search, and (when the country selector is in an
|
|
3097
|
+
//* external container) update (fixed) position on scroll/resize.
|
|
3098
|
+
#bindCountrySelectorOpenListeners(onSelect, onClose) {
|
|
3099
|
+
const signal = this.#countrySelectorAbortController.signal;
|
|
3067
3100
|
this.#bindListItemHover(signal);
|
|
3068
3101
|
this.#bindListItemClick(signal, onSelect);
|
|
3069
3102
|
if (!this.#options.dropdownAlwaysOpen) {
|
|
3070
3103
|
this.#bindOutsideClickToClose(signal, onClose);
|
|
3071
3104
|
}
|
|
3072
|
-
this.#
|
|
3105
|
+
this.#bindCountrySelectorKeydownListener(signal, onSelect, onClose);
|
|
3073
3106
|
if (this.#options.countrySearch) {
|
|
3074
3107
|
this.#bindSearchInputListener(signal);
|
|
3075
3108
|
}
|
|
3076
|
-
if (
|
|
3077
|
-
|
|
3109
|
+
if (this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.DROPDOWN && this.#options.dropdownParent && !supportsCssAnchor) {
|
|
3110
|
+
document.addEventListener("scroll", onClose, { signal, capture: true, passive: true });
|
|
3078
3111
|
}
|
|
3079
3112
|
}
|
|
3080
3113
|
//* When mouse over a list item, just highlight that one (so if they hit "enter" we know which to select).
|
|
@@ -3107,13 +3140,13 @@ var UI = class _UI {
|
|
|
3107
3140
|
{ signal }
|
|
3108
3141
|
);
|
|
3109
3142
|
}
|
|
3110
|
-
//* Invoke onClickOff when the user clicks anywhere outside the
|
|
3143
|
+
//* Invoke onClickOff when the user clicks anywhere outside the country selector.
|
|
3111
3144
|
#bindOutsideClickToClose(signal, onClickOff) {
|
|
3112
3145
|
setTimeout(() => {
|
|
3113
3146
|
document.documentElement.addEventListener(
|
|
3114
3147
|
"click",
|
|
3115
3148
|
(e) => {
|
|
3116
|
-
if (!this.#
|
|
3149
|
+
if (!this.#countrySelectorEl.contains(e.target)) {
|
|
3117
3150
|
onClickOff();
|
|
3118
3151
|
}
|
|
3119
3152
|
},
|
|
@@ -3121,11 +3154,10 @@ var UI = class _UI {
|
|
|
3121
3154
|
);
|
|
3122
3155
|
}, 0);
|
|
3123
3156
|
}
|
|
3124
|
-
//* Keyboard navigation while the
|
|
3125
|
-
//* and enter/escape invoke the caller's callbacks (which handle country selection /
|
|
3126
|
-
//* Listens on document because key events go there when no input has focus.
|
|
3157
|
+
//* Keyboard navigation while the country selector is open: arrow keys navigate, hidden-search keys filter,
|
|
3158
|
+
//* and enter/escape invoke the caller's callbacks (which handle country selection / close).
|
|
3127
3159
|
//* Uses keydown rather than keypress so non-char keys (arrow, esc) fire and so holding a key repeats.
|
|
3128
|
-
#
|
|
3160
|
+
#bindCountrySelectorKeydownListener(signal, onEnter, onEscape) {
|
|
3129
3161
|
let query = "";
|
|
3130
3162
|
let queryTimer = null;
|
|
3131
3163
|
const handleKeydown = (e) => {
|
|
@@ -3147,7 +3179,7 @@ var UI = class _UI {
|
|
|
3147
3179
|
this.#selectedCountryEl.focus();
|
|
3148
3180
|
}
|
|
3149
3181
|
}
|
|
3150
|
-
if (!this.#options.countrySearch &&
|
|
3182
|
+
if (!this.#options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
|
|
3151
3183
|
e.stopPropagation();
|
|
3152
3184
|
if (queryTimer) {
|
|
3153
3185
|
clearTimeout(queryTimer);
|
|
@@ -3159,7 +3191,8 @@ var UI = class _UI {
|
|
|
3159
3191
|
}, TIMINGS.HIDDEN_SEARCH_RESET_MS);
|
|
3160
3192
|
}
|
|
3161
3193
|
};
|
|
3162
|
-
|
|
3194
|
+
this.#selectedCountryEl?.addEventListener("keydown", handleKeydown, { signal });
|
|
3195
|
+
this.#countrySelectorEl?.addEventListener("keydown", handleKeydown, { signal });
|
|
3163
3196
|
}
|
|
3164
3197
|
//* Wire up country search input listener: typing filters the list, the clear button resets it.
|
|
3165
3198
|
#bindSearchInputListener(signal) {
|
|
@@ -3196,7 +3229,7 @@ var UI = class _UI {
|
|
|
3196
3229
|
this.#highlightListItem(next);
|
|
3197
3230
|
}
|
|
3198
3231
|
}
|
|
3199
|
-
// Update the selected list item in the
|
|
3232
|
+
// Update the selected list item in the country list
|
|
3200
3233
|
#updateSelectedListItem(iso2) {
|
|
3201
3234
|
if (this.#selectedListItemEl && this.#selectedListItemEl.dataset[DATA_KEYS.ISO2] !== iso2) {
|
|
3202
3235
|
this.#selectedListItemEl.setAttribute(ARIA.SELECTED, "false");
|
|
@@ -3247,12 +3280,12 @@ var UI = class _UI {
|
|
|
3247
3280
|
this.#countryListEl.scrollTop = 0;
|
|
3248
3281
|
this.#updateSearchResultsA11yText();
|
|
3249
3282
|
}
|
|
3250
|
-
// UI: Close the
|
|
3251
|
-
|
|
3252
|
-
const { countrySearch
|
|
3253
|
-
this.#
|
|
3254
|
-
this.#
|
|
3255
|
-
this.#
|
|
3283
|
+
// UI: Close the country selector (DOM + abort scoped listeners).
|
|
3284
|
+
closeCountrySelector() {
|
|
3285
|
+
const { countrySearch } = this.#options;
|
|
3286
|
+
this.#countrySelectorAbortController.abort();
|
|
3287
|
+
this.#countrySelectorAbortController = null;
|
|
3288
|
+
this.#countrySelectorEl.classList.add(CLASSES.HIDE);
|
|
3256
3289
|
this.#selectedCountryEl.setAttribute(ARIA.EXPANDED, "false");
|
|
3257
3290
|
if (countrySearch) {
|
|
3258
3291
|
this.#searchInputEl.removeAttribute(ARIA.ACTIVE_DESCENDANT);
|
|
@@ -3263,19 +3296,19 @@ var UI = class _UI {
|
|
|
3263
3296
|
this.#highlightedListItemEl = null;
|
|
3264
3297
|
}
|
|
3265
3298
|
}
|
|
3266
|
-
this.#
|
|
3267
|
-
if (
|
|
3268
|
-
this.#
|
|
3269
|
-
this.#
|
|
3270
|
-
this.#
|
|
3271
|
-
this.#
|
|
3272
|
-
this.#
|
|
3299
|
+
this.#arrowEl.classList.remove(CLASSES.ARROW_UP);
|
|
3300
|
+
if (this.#detachedCountrySelectorEl) {
|
|
3301
|
+
this.#detachedCountrySelectorEl.remove();
|
|
3302
|
+
this.#detachedCountrySelectorEl.style.top = "";
|
|
3303
|
+
this.#detachedCountrySelectorEl.style.bottom = "";
|
|
3304
|
+
this.#detachedCountrySelectorEl.style.paddingLeft = "";
|
|
3305
|
+
this.#detachedCountrySelectorEl.style.paddingRight = "";
|
|
3273
3306
|
} else {
|
|
3274
|
-
this.#
|
|
3275
|
-
this.#
|
|
3307
|
+
this.#countrySelectorEl.style.top = "";
|
|
3308
|
+
this.#countrySelectorEl.style.bottom = "";
|
|
3276
3309
|
}
|
|
3277
3310
|
}
|
|
3278
|
-
#
|
|
3311
|
+
#shouldPositionDropdownBelowInput() {
|
|
3279
3312
|
if (this.#options.dropdownAlwaysOpen) {
|
|
3280
3313
|
return true;
|
|
3281
3314
|
}
|
|
@@ -3284,50 +3317,83 @@ var UI = class _UI {
|
|
|
3284
3317
|
const spaceBelow = window.innerHeight - inputPos.bottom;
|
|
3285
3318
|
return spaceBelow >= this.#inlineDropdownHeight || spaceBelow >= spaceAbove;
|
|
3286
3319
|
}
|
|
3287
|
-
// inject
|
|
3288
|
-
#
|
|
3289
|
-
const
|
|
3290
|
-
|
|
3320
|
+
// inject the country selector into its detached wrapper and apply positioning styles
|
|
3321
|
+
#injectAndPositionDetachedCountrySelector() {
|
|
3322
|
+
const isFullscreen = this.#options.countrySelectorMode === COUNTRY_SELECTOR_MODE.FULLSCREEN;
|
|
3323
|
+
const detachedParent = this.#getDetachedParent();
|
|
3324
|
+
if (isFullscreen) {
|
|
3291
3325
|
if (window.innerWidth >= LAYOUT.NARROW_VIEWPORT_WIDTH) {
|
|
3292
3326
|
const inputPos = this.telInputEl.getBoundingClientRect();
|
|
3293
|
-
this.#
|
|
3294
|
-
this.#
|
|
3327
|
+
this.#detachedCountrySelectorEl.style.paddingLeft = `${inputPos.left}px`;
|
|
3328
|
+
this.#detachedCountrySelectorEl.style.paddingRight = `${window.innerWidth - inputPos.right}px`;
|
|
3295
3329
|
}
|
|
3296
|
-
} else {
|
|
3330
|
+
} else if (!supportsCssAnchor) {
|
|
3297
3331
|
const inputPos = this.telInputEl.getBoundingClientRect();
|
|
3298
|
-
this.#
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
this.#detachedDropdownEl.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3332
|
+
this.#detachedCountrySelectorEl.style.left = `${inputPos.left}px`;
|
|
3333
|
+
if (this.#shouldPositionDropdownBelowInput()) {
|
|
3334
|
+
this.#detachedCountrySelectorEl.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3302
3335
|
} else {
|
|
3303
|
-
this.#
|
|
3304
|
-
this.#
|
|
3336
|
+
this.#detachedCountrySelectorEl.style.top = "unset";
|
|
3337
|
+
this.#detachedCountrySelectorEl.style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
3305
3338
|
}
|
|
3306
3339
|
}
|
|
3307
|
-
|
|
3340
|
+
detachedParent.appendChild(this.#detachedCountrySelectorEl);
|
|
3341
|
+
}
|
|
3342
|
+
//* Wire up CSS Anchor Positioning between the input and the detached country selector using a
|
|
3343
|
+
//* unique anchor name per instance. Called once at build time — the matching styles in
|
|
3344
|
+
//* intlTelInput.css only take effect in browsers that support anchor(); elsewhere these
|
|
3345
|
+
//* properties are inert. We append our name to any existing anchor-name (read via
|
|
3346
|
+
//* getComputedStyle so we pick up CSS-defined values), so consumer-set anchors on the input
|
|
3347
|
+
//* are preserved. Caveat: this snapshots the consumer's value once — if they later change
|
|
3348
|
+
//* anchor-name via CSS (e.g. a class swap), our inline write will shadow the change.
|
|
3349
|
+
#setupCssAnchorPositioning() {
|
|
3350
|
+
const anchorName = `--iti-anchor-${this.#id}`;
|
|
3351
|
+
const existing = getComputedStyle(this.telInputEl).anchorName;
|
|
3352
|
+
this.telInputEl.style.anchorName = existing && existing !== "none" ? `${existing}, ${anchorName}` : anchorName;
|
|
3353
|
+
this.#detachedCountrySelectorEl.style.positionAnchor = anchorName;
|
|
3308
3354
|
}
|
|
3309
3355
|
// Adjust the fullscreen popup dimensions to match the visual viewport,
|
|
3310
3356
|
// so it stays above the virtual keyboard on mobile devices.
|
|
3311
3357
|
#adjustFullscreenPopupToViewport() {
|
|
3312
3358
|
const vv = window.visualViewport;
|
|
3313
|
-
if (!vv || !this.#
|
|
3359
|
+
if (!vv || !this.#detachedCountrySelectorEl) {
|
|
3314
3360
|
return;
|
|
3315
3361
|
}
|
|
3316
3362
|
const virtualKeyboardHeight = window.innerHeight - vv.height;
|
|
3317
|
-
this.#
|
|
3363
|
+
this.#detachedCountrySelectorEl.style.bottom = `${virtualKeyboardHeight}px`;
|
|
3318
3364
|
}
|
|
3319
|
-
// UI: Whether the
|
|
3320
|
-
|
|
3321
|
-
return !this.#
|
|
3365
|
+
// UI: Whether the country selector is currently open (visible).
|
|
3366
|
+
isCountrySelectorOpen() {
|
|
3367
|
+
return !this.#countrySelectorEl.classList.contains(CLASSES.HIDE);
|
|
3322
3368
|
}
|
|
3323
3369
|
// Toggle the loading spinner on the selected flag (used during auto-country geoIP lookup).
|
|
3324
3370
|
setLoading(isLoading) {
|
|
3325
3371
|
this.#selectedFlagEl.classList.toggle(CLASSES.LOADING, isLoading);
|
|
3326
3372
|
}
|
|
3373
|
+
//* Play the strict-reject animation (shake, or background-colour flash under prefers-reduced-motion) on the wrapper.
|
|
3374
|
+
//* Called when strictMode rejects the whole input (keystroke, or whole paste).
|
|
3375
|
+
//* Uses the wrapper (not the input) so any separateDialCode / country button move together with the input.
|
|
3376
|
+
playStrictRejectAnimation() {
|
|
3377
|
+
if (!this.#options.strictRejectAnimation) {
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
const wrapperEl = this.telInputEl.parentElement;
|
|
3381
|
+
if (!wrapperEl) {
|
|
3382
|
+
return;
|
|
3383
|
+
}
|
|
3384
|
+
wrapperEl.classList.remove(CLASSES.STRICT_REJECT_ANIMATION);
|
|
3385
|
+
void wrapperEl.offsetWidth;
|
|
3386
|
+
wrapperEl.classList.add(CLASSES.STRICT_REJECT_ANIMATION);
|
|
3387
|
+
wrapperEl.addEventListener(
|
|
3388
|
+
"animationend",
|
|
3389
|
+
() => wrapperEl.classList.remove(CLASSES.STRICT_REJECT_ANIMATION),
|
|
3390
|
+
{ once: true }
|
|
3391
|
+
);
|
|
3392
|
+
}
|
|
3327
3393
|
isLoading() {
|
|
3328
3394
|
return this.#selectedFlagEl.classList.contains(CLASSES.LOADING);
|
|
3329
3395
|
}
|
|
3330
|
-
// Set the disabled state of the input and
|
|
3396
|
+
// Set the disabled state of the input and country selector.
|
|
3331
3397
|
setDisabled(disabled) {
|
|
3332
3398
|
this.telInputEl.disabled = disabled;
|
|
3333
3399
|
if (this.#selectedCountryEl) {
|
|
@@ -3338,7 +3404,7 @@ var UI = class _UI {
|
|
|
3338
3404
|
}
|
|
3339
3405
|
}
|
|
3340
3406
|
}
|
|
3341
|
-
// Set the readonly state of the input and
|
|
3407
|
+
// Set the readonly state of the input and country selector.
|
|
3342
3408
|
setReadonly(readonly) {
|
|
3343
3409
|
this.telInputEl.readOnly = readonly;
|
|
3344
3410
|
if (this.#selectedCountryEl) {
|
|
@@ -3349,12 +3415,12 @@ var UI = class _UI {
|
|
|
3349
3415
|
}
|
|
3350
3416
|
}
|
|
3351
3417
|
}
|
|
3352
|
-
|
|
3353
|
-
const {
|
|
3354
|
-
const name =
|
|
3355
|
-
const dialCode =
|
|
3356
|
-
const iso2 =
|
|
3357
|
-
if (
|
|
3418
|
+
setSelectedCountry(selectedCountry) {
|
|
3419
|
+
const { countrySelectorMode, showFlags, separateDialCode, uiTranslations } = this.#options;
|
|
3420
|
+
const name = selectedCountry?.name;
|
|
3421
|
+
const dialCode = selectedCountry?.dialCode;
|
|
3422
|
+
const iso2 = selectedCountry?.iso2 ?? "";
|
|
3423
|
+
if (countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
3358
3424
|
this.#updateSelectedListItem(iso2);
|
|
3359
3425
|
}
|
|
3360
3426
|
if (this.#selectedCountryEl) {
|
|
@@ -3363,13 +3429,13 @@ var UI = class _UI {
|
|
|
3363
3429
|
let flagContent = null;
|
|
3364
3430
|
if (iso2) {
|
|
3365
3431
|
title = name;
|
|
3366
|
-
ariaLabel =
|
|
3432
|
+
ariaLabel = uiTranslations.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
|
|
3367
3433
|
if (!showFlags) {
|
|
3368
3434
|
flagContent = buildGlobeIcon();
|
|
3369
3435
|
}
|
|
3370
3436
|
} else {
|
|
3371
|
-
title =
|
|
3372
|
-
ariaLabel =
|
|
3437
|
+
title = uiTranslations.noCountrySelected;
|
|
3438
|
+
ariaLabel = uiTranslations.noCountrySelected;
|
|
3373
3439
|
flagContent = buildGlobeIcon();
|
|
3374
3440
|
}
|
|
3375
3441
|
this.#selectedFlagEl.className = flagClass;
|
|
@@ -3518,17 +3584,17 @@ var hasRegionlessDialCode = (number) => {
|
|
|
3518
3584
|
};
|
|
3519
3585
|
|
|
3520
3586
|
// packages/core/src/js/format/formatting.ts
|
|
3521
|
-
var stripSeparateDialCode = (fullNumber, hasValidDialCode, separateDialCode,
|
|
3587
|
+
var stripSeparateDialCode = (fullNumber, hasValidDialCode, separateDialCode, selectedCountry) => {
|
|
3522
3588
|
if (!separateDialCode || !hasValidDialCode) {
|
|
3523
3589
|
return fullNumber;
|
|
3524
3590
|
}
|
|
3525
|
-
const dialCode = `+${
|
|
3591
|
+
const dialCode = `+${selectedCountry.dialCode}`;
|
|
3526
3592
|
const start = fullNumber[dialCode.length] === " " || fullNumber[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
|
|
3527
3593
|
return fullNumber.substring(start);
|
|
3528
3594
|
};
|
|
3529
|
-
var formatNumberAsYouType = (fullNumber, telInputValue, utils,
|
|
3530
|
-
const result = utils ? utils.formatNumberAsYouType(fullNumber,
|
|
3531
|
-
const dialCode =
|
|
3595
|
+
var formatNumberAsYouType = (fullNumber, telInputValue, utils, selectedCountry, separateDialCode) => {
|
|
3596
|
+
const result = utils ? utils.formatNumberAsYouType(fullNumber, selectedCountry?.iso2) : fullNumber;
|
|
3597
|
+
const dialCode = selectedCountry?.dialCode;
|
|
3532
3598
|
if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
|
|
3533
3599
|
const afterDialCode = result.split(`+${dialCode}`)[1] || "";
|
|
3534
3600
|
return afterDialCode.trim();
|
|
@@ -3659,8 +3725,8 @@ var Iti = class _Iti {
|
|
|
3659
3725
|
this.#ui.telInputEl.value = this.#numerals.denormalise(asciiValue);
|
|
3660
3726
|
}
|
|
3661
3727
|
#createInitPromise(options) {
|
|
3662
|
-
const { initialCountry,
|
|
3663
|
-
const needsAutoCountryDeferred = initialCountry
|
|
3728
|
+
const { initialCountry, initialCountryLookup, loadUtils } = options;
|
|
3729
|
+
const needsAutoCountryDeferred = !initialCountry && Boolean(initialCountryLookup);
|
|
3664
3730
|
const needsUtilsDeferred = Boolean(loadUtils) && !intlTelInput.utils;
|
|
3665
3731
|
if (needsAutoCountryDeferred) {
|
|
3666
3732
|
this.#autoCountryDeferred = createDeferred();
|
|
@@ -3682,7 +3748,7 @@ var Iti = class _Iti {
|
|
|
3682
3748
|
this.#initListeners();
|
|
3683
3749
|
this.#startAsyncLoads();
|
|
3684
3750
|
if (this.#options.dropdownAlwaysOpen) {
|
|
3685
|
-
this
|
|
3751
|
+
this.openCountrySelector();
|
|
3686
3752
|
}
|
|
3687
3753
|
}
|
|
3688
3754
|
//********************
|
|
@@ -3705,8 +3771,8 @@ var Iti = class _Iti {
|
|
|
3705
3771
|
const value = useAttribute ? attributeValue : inputValue;
|
|
3706
3772
|
const dialCode = this.#getDialCode(value);
|
|
3707
3773
|
const isRegionlessNanpNumber = isRegionlessNanp(value);
|
|
3708
|
-
const { initialCountry,
|
|
3709
|
-
const isAutoCountry = initialCountry
|
|
3774
|
+
const { initialCountry, initialCountryLookup } = this.#options;
|
|
3775
|
+
const isAutoCountry = !initialCountry && Boolean(initialCountryLookup);
|
|
3710
3776
|
const resolvedInitialCountry = isAutoCountry && intlTelInput.autoCountry ? intlTelInput.autoCountry : initialCountry;
|
|
3711
3777
|
const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry && !intlTelInput.autoCountry;
|
|
3712
3778
|
const isValidInitialCountry = isIso2(resolvedInitialCountry);
|
|
@@ -3735,11 +3801,11 @@ var Iti = class _Iti {
|
|
|
3735
3801
|
//* Initialise the main event listeners: input keyup, and click selected country.
|
|
3736
3802
|
#initListeners() {
|
|
3737
3803
|
this.#bindAllTelInputListeners();
|
|
3738
|
-
if (this.#options.
|
|
3739
|
-
this.#ui.
|
|
3804
|
+
if (this.#options.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
3805
|
+
this.#ui.bindAllInitialCountrySelectorListeners(
|
|
3740
3806
|
this.#abortController.signal,
|
|
3741
|
-
() => this
|
|
3742
|
-
() => this.#
|
|
3807
|
+
() => this.openCountrySelector(),
|
|
3808
|
+
() => this.#closeCountrySelectorInternal()
|
|
3743
3809
|
);
|
|
3744
3810
|
}
|
|
3745
3811
|
this.#ui.bindHiddenInputSubmitListener(
|
|
@@ -3748,7 +3814,7 @@ var Iti = class _Iti {
|
|
|
3748
3814
|
() => this.#selectedCountry?.iso2 || ""
|
|
3749
3815
|
);
|
|
3750
3816
|
}
|
|
3751
|
-
//* Init requests: utils script /
|
|
3817
|
+
//* Init requests: utils script / initial country lookup.
|
|
3752
3818
|
#startAsyncLoads() {
|
|
3753
3819
|
if (this.#utilsDeferred) {
|
|
3754
3820
|
const { loadUtils } = this.#options;
|
|
@@ -3772,7 +3838,7 @@ var Iti = class _Iti {
|
|
|
3772
3838
|
}
|
|
3773
3839
|
}
|
|
3774
3840
|
}
|
|
3775
|
-
//* Perform the
|
|
3841
|
+
//* Perform the initial country lookup.
|
|
3776
3842
|
async #loadAutoCountry() {
|
|
3777
3843
|
if (intlTelInput.autoCountry) {
|
|
3778
3844
|
this.#handleAutoCountryLoaded();
|
|
@@ -3783,14 +3849,14 @@ var Iti = class _Iti {
|
|
|
3783
3849
|
return;
|
|
3784
3850
|
}
|
|
3785
3851
|
intlTelInput.startedLoadingAutoCountry = true;
|
|
3786
|
-
if (typeof this.#options.
|
|
3852
|
+
if (typeof this.#options.initialCountryLookup === "function") {
|
|
3787
3853
|
let timeoutId;
|
|
3788
3854
|
try {
|
|
3789
3855
|
const iso2 = await Promise.race([
|
|
3790
|
-
this.#options.
|
|
3856
|
+
this.#options.initialCountryLookup(),
|
|
3791
3857
|
new Promise((_, reject) => {
|
|
3792
3858
|
timeoutId = setTimeout(
|
|
3793
|
-
() => reject(new Error("intl-tel-input:
|
|
3859
|
+
() => reject(new Error("intl-tel-input: initialCountryLookup timed out after 10s")),
|
|
3794
3860
|
1e4
|
|
3795
3861
|
);
|
|
3796
3862
|
})
|
|
@@ -3813,8 +3879,8 @@ var Iti = class _Iti {
|
|
|
3813
3879
|
}
|
|
3814
3880
|
}
|
|
3815
3881
|
}
|
|
3816
|
-
#
|
|
3817
|
-
this
|
|
3882
|
+
#openCountrySelectorWithPlus() {
|
|
3883
|
+
this.openCountrySelector();
|
|
3818
3884
|
this.#ui.prefillSearchWithPlus();
|
|
3819
3885
|
}
|
|
3820
3886
|
//* Delete the character just typed (the one immediately before the caret). Used by Android workarounds where we can't preventDefault on keydown.
|
|
@@ -3834,13 +3900,13 @@ var Iti = class _Iti {
|
|
|
3834
3900
|
//* 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)
|
|
3835
3901
|
#handleAndroidPlusKey(inputValue) {
|
|
3836
3902
|
this.#removeJustTypedChar(inputValue);
|
|
3837
|
-
this.#
|
|
3903
|
+
this.#openCountrySelectorWithPlus();
|
|
3838
3904
|
}
|
|
3839
3905
|
//* 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.
|
|
3840
3906
|
#handleAndroidStrictReject(inputValue, rejectedInput) {
|
|
3841
3907
|
const newCaretPos = this.#removeJustTypedChar(inputValue);
|
|
3842
3908
|
this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
|
|
3843
|
-
this.#playStrictRejectAnimation();
|
|
3909
|
+
this.#ui.playStrictRejectAnimation();
|
|
3844
3910
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
3845
3911
|
source: "key",
|
|
3846
3912
|
rejectedInput,
|
|
@@ -3904,7 +3970,7 @@ var Iti = class _Iti {
|
|
|
3904
3970
|
strictMode,
|
|
3905
3971
|
formatAsYouType,
|
|
3906
3972
|
separateDialCode,
|
|
3907
|
-
|
|
3973
|
+
countrySelectorMode,
|
|
3908
3974
|
countrySearch
|
|
3909
3975
|
} = this.#options;
|
|
3910
3976
|
const detail = e?.detail;
|
|
@@ -3914,7 +3980,7 @@ var Iti = class _Iti {
|
|
|
3914
3980
|
let inputValue = this.#getTelInputValue();
|
|
3915
3981
|
const isPaste = e?.inputType === INPUT_TYPES.PASTE;
|
|
3916
3982
|
const isStrictPaste = strictMode && isPaste;
|
|
3917
|
-
if (this.#isAndroid && !isPaste && e?.data === "+" && separateDialCode &&
|
|
3983
|
+
if (this.#isAndroid && !isPaste && e?.data === "+" && separateDialCode && countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && countrySearch) {
|
|
3918
3984
|
this.#handleAndroidPlusKey(inputValue);
|
|
3919
3985
|
return;
|
|
3920
3986
|
}
|
|
@@ -3961,13 +4027,13 @@ var Iti = class _Iti {
|
|
|
3961
4027
|
//* On keydown event: (1) if strictMode then prevent invalid characters, (2) if separateDialCode then handle plus key
|
|
3962
4028
|
//* Note that this fires BEFORE the input is updated.
|
|
3963
4029
|
#handleKeydownEvent = (e) => {
|
|
3964
|
-
const { strictMode, separateDialCode,
|
|
4030
|
+
const { strictMode, separateDialCode, countrySelectorMode, countrySearch } = this.#options;
|
|
3965
4031
|
if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) {
|
|
3966
4032
|
return;
|
|
3967
4033
|
}
|
|
3968
|
-
if (separateDialCode &&
|
|
4034
|
+
if (separateDialCode && countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF && countrySearch && e.key === "+") {
|
|
3969
4035
|
e.preventDefault();
|
|
3970
|
-
this.#
|
|
4036
|
+
this.#openCountrySelectorWithPlus();
|
|
3971
4037
|
return;
|
|
3972
4038
|
}
|
|
3973
4039
|
if (!strictMode) {
|
|
@@ -3997,7 +4063,7 @@ var Iti = class _Iti {
|
|
|
3997
4063
|
const newCountry = this.#resolveCountryChangeFromNumber(newFullNumber);
|
|
3998
4064
|
const isChangingDialCode = newCountry !== null;
|
|
3999
4065
|
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
4000
|
-
this.#playStrictRejectAnimation();
|
|
4066
|
+
this.#ui.playStrictRejectAnimation();
|
|
4001
4067
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4002
4068
|
source: "key",
|
|
4003
4069
|
rejectedInput: e.key,
|
|
@@ -4052,7 +4118,7 @@ var Iti = class _Iti {
|
|
|
4052
4118
|
let newValue = before + sanitised + after;
|
|
4053
4119
|
let rejectReason = sanitised !== pasted ? "invalid" : null;
|
|
4054
4120
|
if (newValue.length > 30) {
|
|
4055
|
-
this.#playStrictRejectAnimation();
|
|
4121
|
+
this.#ui.playStrictRejectAnimation();
|
|
4056
4122
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4057
4123
|
source: "paste",
|
|
4058
4124
|
rejectedInput: pastedRaw,
|
|
@@ -4068,7 +4134,7 @@ var Iti = class _Iti {
|
|
|
4068
4134
|
coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
|
|
4069
4135
|
}
|
|
4070
4136
|
if (!coreNumber) {
|
|
4071
|
-
this.#playStrictRejectAnimation();
|
|
4137
|
+
this.#ui.playStrictRejectAnimation();
|
|
4072
4138
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4073
4139
|
source: "paste",
|
|
4074
4140
|
rejectedInput: pastedRaw,
|
|
@@ -4083,7 +4149,7 @@ var Iti = class _Iti {
|
|
|
4083
4149
|
newValue = newValue.slice(0, newValue.length - trimLength);
|
|
4084
4150
|
rejectReason = "max-length";
|
|
4085
4151
|
} else {
|
|
4086
|
-
this.#playStrictRejectAnimation();
|
|
4152
|
+
this.#ui.playStrictRejectAnimation();
|
|
4087
4153
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4088
4154
|
source: "paste",
|
|
4089
4155
|
rejectedInput: pastedRaw,
|
|
@@ -4099,7 +4165,7 @@ var Iti = class _Iti {
|
|
|
4099
4165
|
input.setSelectionRange(caretPos, caretPos);
|
|
4100
4166
|
if (rejectReason) {
|
|
4101
4167
|
if (pasted.length > 0 && sanitised.length === 0) {
|
|
4102
|
-
this.#playStrictRejectAnimation();
|
|
4168
|
+
this.#ui.playStrictRejectAnimation();
|
|
4103
4169
|
}
|
|
4104
4170
|
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4105
4171
|
source: "paste",
|
|
@@ -4121,21 +4187,6 @@ var Iti = class _Iti {
|
|
|
4121
4187
|
const max = Number(this.#ui.telInputEl.getAttribute("maxlength"));
|
|
4122
4188
|
return max && number.length > max ? number.substring(0, max) : number;
|
|
4123
4189
|
}
|
|
4124
|
-
//* Play the strict-reject animation (shake, or background-colour flash under prefers-reduced-motion) on the wrapper.
|
|
4125
|
-
//* Called when strictMode rejects the whole input (keystroke, or whole paste).
|
|
4126
|
-
//* Uses the wrapper (not the input) so any separateDialCode / country button move together with the input.
|
|
4127
|
-
#playStrictRejectAnimation() {
|
|
4128
|
-
if (!this.#options.strictRejectAnimation) {
|
|
4129
|
-
return;
|
|
4130
|
-
}
|
|
4131
|
-
const wrapperEl = this.#ui.telInputEl.parentElement;
|
|
4132
|
-
if (!wrapperEl) {
|
|
4133
|
-
return;
|
|
4134
|
-
}
|
|
4135
|
-
wrapperEl.classList.remove("iti__strict-reject-animation");
|
|
4136
|
-
void wrapperEl.offsetWidth;
|
|
4137
|
-
wrapperEl.classList.add("iti__strict-reject-animation");
|
|
4138
|
-
}
|
|
4139
4190
|
//* Trigger a custom event on the input (typed via ItiEventMap).
|
|
4140
4191
|
#dispatchEvent(name, detailProps = {}) {
|
|
4141
4192
|
const e = new CustomEvent(name, {
|
|
@@ -4145,27 +4196,36 @@ var Iti = class _Iti {
|
|
|
4145
4196
|
});
|
|
4146
4197
|
this.#ui.telInputEl.dispatchEvent(e);
|
|
4147
4198
|
}
|
|
4148
|
-
//* Open the
|
|
4149
|
-
//* and its listeners leak. Reachable via
|
|
4150
|
-
|
|
4151
|
-
|
|
4199
|
+
//* Open the country selector. Bail if already open — otherwise the existing AbortController gets overwritten
|
|
4200
|
+
//* and its listeners leak. Reachable via openCountrySelectorWithPlus when dropdownAlwaysOpen is set.
|
|
4201
|
+
//* Public so consumers can programmatically open the country selector.
|
|
4202
|
+
openCountrySelector() {
|
|
4203
|
+
if (this.#ui.isCountrySelectorOpen()) {
|
|
4152
4204
|
return;
|
|
4153
4205
|
}
|
|
4154
|
-
this.#ui.
|
|
4206
|
+
this.#ui.openCountrySelector(
|
|
4155
4207
|
(li) => this.#selectListItem(li),
|
|
4156
|
-
() => this.#
|
|
4208
|
+
() => this.#closeCountrySelectorInternal()
|
|
4157
4209
|
);
|
|
4158
|
-
this.#dispatchEvent(EVENTS.
|
|
4210
|
+
this.#dispatchEvent(EVENTS.OPEN_COUNTRY_SELECTOR);
|
|
4159
4211
|
}
|
|
4160
4212
|
//* Update the input's value to the given number (format first if possible)
|
|
4161
4213
|
//* NOTE: this is called from setInitialState, handleUtilsLoaded and setNumber.
|
|
4162
4214
|
#updateValueFromNumber(fullNumber) {
|
|
4163
|
-
const {
|
|
4215
|
+
const { numberDisplayFormat, separateDialCode } = this.#options;
|
|
4164
4216
|
let number = fullNumber;
|
|
4165
|
-
if (
|
|
4217
|
+
if (intlTelInput.utils && this.#selectedCountry) {
|
|
4166
4218
|
const isRegionless = hasRegionlessDialCode(fullNumber);
|
|
4167
|
-
const
|
|
4168
|
-
const
|
|
4219
|
+
const preserveUserNational = !number.startsWith("+") && !separateDialCode;
|
|
4220
|
+
const useNational = numberDisplayFormat === NUMBER_FORMAT.NATIONAL && !isRegionless || preserveUserNational;
|
|
4221
|
+
let format;
|
|
4222
|
+
if (useNational) {
|
|
4223
|
+
format = NUMBER_FORMAT.NATIONAL;
|
|
4224
|
+
} else if (numberDisplayFormat === NUMBER_FORMAT.E164 && !isRegionless) {
|
|
4225
|
+
format = NUMBER_FORMAT.E164;
|
|
4226
|
+
} else {
|
|
4227
|
+
format = NUMBER_FORMAT.INTERNATIONAL;
|
|
4228
|
+
}
|
|
4169
4229
|
number = intlTelInput.utils.formatNumber(
|
|
4170
4230
|
number,
|
|
4171
4231
|
this.#selectedCountry?.iso2,
|
|
@@ -4262,14 +4322,14 @@ var Iti = class _Iti {
|
|
|
4262
4322
|
return null;
|
|
4263
4323
|
}
|
|
4264
4324
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
4265
|
-
//* Note: called from setInitialState, updateCountryFromNumber, selectListItem,
|
|
4325
|
+
//* Note: called from setInitialState, updateCountryFromNumber, selectListItem, setSelectedCountry.
|
|
4266
4326
|
#updateSelectedCountry(iso2) {
|
|
4267
4327
|
const prevIso2 = this.#selectedCountry?.iso2 || "";
|
|
4268
4328
|
this.#selectedCountry = iso2 ? this.#countryByIso2.get(iso2) : null;
|
|
4269
4329
|
if (this.#selectedCountry) {
|
|
4270
4330
|
this.#fallbackCountryIso2 = this.#selectedCountry.iso2;
|
|
4271
4331
|
}
|
|
4272
|
-
this.#ui.
|
|
4332
|
+
this.#ui.setSelectedCountry(this.#selectedCountry);
|
|
4273
4333
|
this.#updatePlaceholder();
|
|
4274
4334
|
this.#updateMaxCoreNumberLength();
|
|
4275
4335
|
return prevIso2 !== iso2;
|
|
@@ -4287,12 +4347,11 @@ var Iti = class _Iti {
|
|
|
4287
4347
|
}
|
|
4288
4348
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
4289
4349
|
iso2,
|
|
4290
|
-
false,
|
|
4291
4350
|
placeholderNumberType,
|
|
4292
|
-
|
|
4351
|
+
NUMBER_FORMAT.E164
|
|
4293
4352
|
);
|
|
4294
4353
|
let validNumber = exampleNumber;
|
|
4295
|
-
while (intlTelInput.utils.
|
|
4354
|
+
while (intlTelInput.utils.isValidNumber(
|
|
4296
4355
|
exampleNumber,
|
|
4297
4356
|
iso2,
|
|
4298
4357
|
allowedNumberTypes
|
|
@@ -4309,19 +4368,19 @@ var Iti = class _Iti {
|
|
|
4309
4368
|
//* Update the input placeholder to an example number from the currently selected country.
|
|
4310
4369
|
#updatePlaceholder() {
|
|
4311
4370
|
const {
|
|
4312
|
-
|
|
4371
|
+
placeholderNumberPolicy,
|
|
4313
4372
|
placeholderNumberType,
|
|
4314
|
-
|
|
4373
|
+
numberDisplayFormat,
|
|
4315
4374
|
customPlaceholder
|
|
4316
4375
|
} = this.#options;
|
|
4317
|
-
const shouldSetPlaceholder =
|
|
4376
|
+
const shouldSetPlaceholder = placeholderNumberPolicy === PLACEHOLDER_POLICY.AGGRESSIVE || !this.#ui.hadInitialPlaceholder && placeholderNumberPolicy === PLACEHOLDER_POLICY.POLITE;
|
|
4318
4377
|
if (!intlTelInput.utils || !shouldSetPlaceholder) {
|
|
4319
4378
|
return;
|
|
4320
4379
|
}
|
|
4321
4380
|
let placeholder = this.#selectedCountry ? intlTelInput.utils.getExampleNumber(
|
|
4322
4381
|
this.#selectedCountry.iso2,
|
|
4323
|
-
|
|
4324
|
-
|
|
4382
|
+
placeholderNumberType,
|
|
4383
|
+
numberDisplayFormat
|
|
4325
4384
|
) : "";
|
|
4326
4385
|
placeholder = this.#prepareNumberForInput(placeholder);
|
|
4327
4386
|
if (typeof customPlaceholder === "function") {
|
|
@@ -4329,36 +4388,40 @@ var Iti = class _Iti {
|
|
|
4329
4388
|
}
|
|
4330
4389
|
this.#ui.telInputEl.setAttribute("placeholder", placeholder);
|
|
4331
4390
|
}
|
|
4332
|
-
//* Called when the user selects a list item from the
|
|
4391
|
+
//* Called when the user selects a list item from the country list (no-op if listItem is null).
|
|
4333
4392
|
#selectListItem(listItem) {
|
|
4334
4393
|
if (!listItem) {
|
|
4335
4394
|
return;
|
|
4336
4395
|
}
|
|
4337
4396
|
const iso2 = listItem.dataset[DATA_KEYS.ISO2];
|
|
4338
4397
|
const countryChanged = this.#updateSelectedCountry(iso2);
|
|
4339
|
-
this.#
|
|
4398
|
+
this.#closeCountrySelectorInternal();
|
|
4340
4399
|
const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
|
|
4341
4400
|
this.#updateDialCode(dialCode);
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
this.#updateValueFromNumber(inputValue);
|
|
4345
|
-
}
|
|
4401
|
+
const inputValue = this.#getTelInputValue();
|
|
4402
|
+
this.#updateValueFromNumber(inputValue);
|
|
4346
4403
|
this.#ui.telInputEl.focus();
|
|
4347
4404
|
if (countryChanged) {
|
|
4348
4405
|
this.#dispatchCountryChangeEvent();
|
|
4349
4406
|
this.#dispatchEvent(EVENTS.INPUT, { isCountryChange: true });
|
|
4350
4407
|
}
|
|
4351
4408
|
}
|
|
4352
|
-
//*
|
|
4353
|
-
|
|
4354
|
-
|
|
4409
|
+
//* Public: close the country selector (consumer-callable; delegates to the internal helper
|
|
4410
|
+
//* without the destroy-specific path).
|
|
4411
|
+
closeCountrySelector() {
|
|
4412
|
+
this.#closeCountrySelectorInternal();
|
|
4413
|
+
}
|
|
4414
|
+
//* Close the country selector and unbind any listeners. The isDestroy flag forces close even
|
|
4415
|
+
//* when dropdownAlwaysOpen is set, so destroy() can fully tear down.
|
|
4416
|
+
#closeCountrySelectorInternal(isDestroy) {
|
|
4417
|
+
if (!this.#ui.isCountrySelectorOpen() || this.#options.dropdownAlwaysOpen && !isDestroy) {
|
|
4355
4418
|
return;
|
|
4356
4419
|
}
|
|
4357
|
-
this.#ui.
|
|
4358
|
-
this.#dispatchEvent(EVENTS.
|
|
4420
|
+
this.#ui.closeCountrySelector();
|
|
4421
|
+
this.#dispatchEvent(EVENTS.CLOSE_COUNTRY_SELECTOR);
|
|
4359
4422
|
}
|
|
4360
4423
|
//* Replace any existing dial code with the new one
|
|
4361
|
-
//* Note: called from selectListItem and
|
|
4424
|
+
//* Note: called from selectListItem and setSelectedCountry
|
|
4362
4425
|
#updateDialCode(newDialCodeDigits) {
|
|
4363
4426
|
const inputValue = this.#getTelInputValue();
|
|
4364
4427
|
if (!inputValue.startsWith("+")) {
|
|
@@ -4438,7 +4501,7 @@ var Iti = class _Iti {
|
|
|
4438
4501
|
//**************************
|
|
4439
4502
|
//* INTERNAL METHODS
|
|
4440
4503
|
//**************************
|
|
4441
|
-
//* Called when the
|
|
4504
|
+
//* Called when the initial country lookup returns.
|
|
4442
4505
|
#handleAutoCountryLoaded() {
|
|
4443
4506
|
if (!this.#autoCountryDeferred || !intlTelInput.autoCountry) {
|
|
4444
4507
|
return;
|
|
@@ -4447,15 +4510,17 @@ var Iti = class _Iti {
|
|
|
4447
4510
|
this.#autoCountryDeferred.resolve();
|
|
4448
4511
|
return;
|
|
4449
4512
|
}
|
|
4450
|
-
|
|
4451
|
-
|
|
4513
|
+
const isFocused = document.activeElement === this.#ui.telInputEl;
|
|
4514
|
+
const hasTypedValue = Boolean(this.#getTelInputValue());
|
|
4515
|
+
if (this.#ui.isLoading() && !(isFocused && hasTypedValue)) {
|
|
4516
|
+
this.setSelectedCountry(intlTelInput.autoCountry);
|
|
4452
4517
|
} else {
|
|
4453
4518
|
this.#fallbackCountryIso2 = intlTelInput.autoCountry;
|
|
4454
4519
|
}
|
|
4455
4520
|
this.#ui.setLoading(false);
|
|
4456
4521
|
this.#autoCountryDeferred.resolve();
|
|
4457
4522
|
}
|
|
4458
|
-
//* Called when the
|
|
4523
|
+
//* Called when the initial country lookup fails or times out.
|
|
4459
4524
|
#handleAutoCountryFailure() {
|
|
4460
4525
|
if (!this.#isActive) {
|
|
4461
4526
|
this.#autoCountryDeferred?.reject();
|
|
@@ -4476,7 +4541,8 @@ var Iti = class _Iti {
|
|
|
4476
4541
|
return;
|
|
4477
4542
|
}
|
|
4478
4543
|
const inputValue = this.#getTelInputValue();
|
|
4479
|
-
|
|
4544
|
+
const isFocused = document.activeElement === this.#ui.telInputEl;
|
|
4545
|
+
if (inputValue && !isFocused) {
|
|
4480
4546
|
this.#updateValueFromNumber(inputValue);
|
|
4481
4547
|
}
|
|
4482
4548
|
if (this.#selectedCountry) {
|
|
@@ -4502,8 +4568,8 @@ var Iti = class _Iti {
|
|
|
4502
4568
|
return;
|
|
4503
4569
|
}
|
|
4504
4570
|
this.#isActive = false;
|
|
4505
|
-
if (this.#options.
|
|
4506
|
-
this.#
|
|
4571
|
+
if (this.#options.countrySelectorMode !== COUNTRY_SELECTOR_MODE.OFF) {
|
|
4572
|
+
this.#closeCountrySelectorInternal(true);
|
|
4507
4573
|
}
|
|
4508
4574
|
this.#abortController.abort();
|
|
4509
4575
|
this.#ui.destroy();
|
|
@@ -4551,7 +4617,7 @@ var Iti = class _Iti {
|
|
|
4551
4617
|
);
|
|
4552
4618
|
}
|
|
4553
4619
|
//* Get the country data for the currently selected country.
|
|
4554
|
-
|
|
4620
|
+
getSelectedCountry() {
|
|
4555
4621
|
return this.#selectedCountry ?? null;
|
|
4556
4622
|
}
|
|
4557
4623
|
//* Get the validation error e.g. "TOO_SHORT" / "TOO_LONG", or null if it can't be determined / instance is destroyed.
|
|
@@ -4606,7 +4672,7 @@ var Iti = class _Iti {
|
|
|
4606
4672
|
if (!this.#selectedCountry && !hasRegionlessDialCode(value)) {
|
|
4607
4673
|
return false;
|
|
4608
4674
|
}
|
|
4609
|
-
const check = mode === "precise" ? intlTelInput.utils.
|
|
4675
|
+
const check = mode === "precise" ? intlTelInput.utils.isValidNumberPrecise : intlTelInput.utils.isValidNumber;
|
|
4610
4676
|
if (!check(value, iso2, allowedNumberTypes)) {
|
|
4611
4677
|
return false;
|
|
4612
4678
|
}
|
|
@@ -4619,7 +4685,7 @@ var Iti = class _Iti {
|
|
|
4619
4685
|
return true;
|
|
4620
4686
|
}
|
|
4621
4687
|
//* Update the selected country, and update the input value accordingly.
|
|
4622
|
-
|
|
4688
|
+
setSelectedCountry(iso2) {
|
|
4623
4689
|
if (!this.#isActive) {
|
|
4624
4690
|
return;
|
|
4625
4691
|
}
|
|
@@ -4634,10 +4700,8 @@ var Iti = class _Iti {
|
|
|
4634
4700
|
}
|
|
4635
4701
|
this.#updateSelectedCountry(iso2Lower);
|
|
4636
4702
|
this.#updateDialCode(this.#selectedCountry?.dialCode || "");
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
this.#updateValueFromNumber(inputValue);
|
|
4640
|
-
}
|
|
4703
|
+
const inputValue = this.#getTelInputValue();
|
|
4704
|
+
this.#updateValueFromNumber(inputValue);
|
|
4641
4705
|
this.#dispatchCountryChangeEvent();
|
|
4642
4706
|
this.#dispatchEvent(EVENTS.INPUT, { isCountryChange: true });
|
|
4643
4707
|
}
|
|
@@ -4662,14 +4726,14 @@ var Iti = class _Iti {
|
|
|
4662
4726
|
this.#options.placeholderNumberType = type;
|
|
4663
4727
|
this.#updatePlaceholder();
|
|
4664
4728
|
}
|
|
4665
|
-
// Set the disabled state of the input and
|
|
4729
|
+
// Set the disabled state of the input and country selector.
|
|
4666
4730
|
setDisabled(disabled) {
|
|
4667
4731
|
if (!this.#isActive) {
|
|
4668
4732
|
return;
|
|
4669
4733
|
}
|
|
4670
4734
|
this.#ui.setDisabled(disabled);
|
|
4671
4735
|
}
|
|
4672
|
-
// Set the readonly state of the input and
|
|
4736
|
+
// Set the readonly state of the input and country selector.
|
|
4673
4737
|
setReadonly(readonly) {
|
|
4674
4738
|
if (!this.#isActive) {
|
|
4675
4739
|
return;
|
|
@@ -4679,7 +4743,7 @@ var Iti = class _Iti {
|
|
|
4679
4743
|
//********************
|
|
4680
4744
|
//* STATIC METHODS
|
|
4681
4745
|
//********************
|
|
4682
|
-
// Internal instance notification used by utils/
|
|
4746
|
+
// Internal instance notification used by utils/initial-country loaders.
|
|
4683
4747
|
// Kept public so module-level helpers (e.g. attachUtils) can call it, while still allowing
|
|
4684
4748
|
// access to private instance methods.
|
|
4685
4749
|
static forEachInstance(method, ...args) {
|
|
@@ -4743,8 +4807,8 @@ var intlTelInput = Object.assign(
|
|
|
4743
4807
|
defaults,
|
|
4744
4808
|
//* Using a static var like this allows us to mock it in the tests.
|
|
4745
4809
|
documentReady: () => document.readyState === "complete",
|
|
4746
|
-
//* Get the
|
|
4747
|
-
|
|
4810
|
+
//* Get the full list of all countries the library knows about.
|
|
4811
|
+
getAllCountries: () => data_default,
|
|
4748
4812
|
//* A getter for the core library instance.
|
|
4749
4813
|
getInstance: (input) => {
|
|
4750
4814
|
const id = input.dataset[DATA_KEYS.INSTANCE_ID];
|
|
@@ -4755,10 +4819,12 @@ var intlTelInput = Object.assign(
|
|
|
4755
4819
|
attachUtils,
|
|
4756
4820
|
startedLoadingUtils: false,
|
|
4757
4821
|
startedLoadingAutoCountry: false,
|
|
4758
|
-
version: "
|
|
4822
|
+
version: "29.0.0",
|
|
4759
4823
|
NUMBER_FORMAT,
|
|
4760
4824
|
NUMBER_TYPE,
|
|
4761
|
-
VALIDATION_ERROR
|
|
4825
|
+
VALIDATION_ERROR,
|
|
4826
|
+
PLACEHOLDER_POLICY,
|
|
4827
|
+
COUNTRY_SELECTOR_MODE
|
|
4762
4828
|
}
|
|
4763
4829
|
);
|
|
4764
4830
|
var intlTelInput_default = intlTelInput;
|
|
@@ -4766,14 +4832,14 @@ var intlTelInput_default = intlTelInput;
|
|
|
4766
4832
|
// packages/core/dist/js/utils.js
|
|
4767
4833
|
var _scope = {};
|
|
4768
4834
|
(function() {
|
|
4769
|
-
var
|
|
4770
|
-
function
|
|
4835
|
+
var k = this || self;
|
|
4836
|
+
function m(a, b) {
|
|
4771
4837
|
a = a.split(".");
|
|
4772
|
-
var c =
|
|
4838
|
+
var c = k;
|
|
4773
4839
|
a[0] in c || typeof c.execScript == "undefined" || c.execScript("var " + a[0]);
|
|
4774
4840
|
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;
|
|
4775
4841
|
}
|
|
4776
|
-
function
|
|
4842
|
+
function n(a, b) {
|
|
4777
4843
|
function c() {
|
|
4778
4844
|
}
|
|
4779
4845
|
c.prototype = b.prototype;
|
|
@@ -4786,24 +4852,24 @@ var _scope = {};
|
|
|
4786
4852
|
};
|
|
4787
4853
|
}
|
|
4788
4854
|
;
|
|
4789
|
-
function
|
|
4855
|
+
function aa(a) {
|
|
4790
4856
|
const b = [];
|
|
4791
4857
|
let c = 0;
|
|
4792
4858
|
for (const d in a) b[c++] = a[d];
|
|
4793
4859
|
return b;
|
|
4794
4860
|
}
|
|
4795
4861
|
;
|
|
4796
|
-
var
|
|
4862
|
+
var ca = class {
|
|
4797
4863
|
constructor(a) {
|
|
4798
|
-
if (
|
|
4864
|
+
if (ba !== ba) throw Error("SafeUrl is not meant to be built directly");
|
|
4799
4865
|
this.g = a;
|
|
4800
4866
|
}
|
|
4801
4867
|
toString() {
|
|
4802
4868
|
return this.g.toString();
|
|
4803
4869
|
}
|
|
4804
|
-
},
|
|
4805
|
-
new
|
|
4806
|
-
new
|
|
4870
|
+
}, ba = {};
|
|
4871
|
+
new ca("about:invalid#zClosurez");
|
|
4872
|
+
new ca("about:blank");
|
|
4807
4873
|
const ea = {};
|
|
4808
4874
|
class fa {
|
|
4809
4875
|
constructor() {
|
|
@@ -4827,7 +4893,7 @@ var _scope = {};
|
|
|
4827
4893
|
const ja = {};
|
|
4828
4894
|
class ka {
|
|
4829
4895
|
constructor() {
|
|
4830
|
-
var a =
|
|
4896
|
+
var a = k.trustedTypes && k.trustedTypes.emptyHTML || "";
|
|
4831
4897
|
if (ja !== ja) throw Error("SafeHtml is not meant to be built directly");
|
|
4832
4898
|
this.g = a;
|
|
4833
4899
|
}
|
|
@@ -4864,38 +4930,38 @@ var _scope = {};
|
|
|
4864
4930
|
}
|
|
4865
4931
|
}
|
|
4866
4932
|
function ua(a) {
|
|
4867
|
-
a =
|
|
4933
|
+
a = aa(a.g);
|
|
4868
4934
|
a.sort(function(b, c) {
|
|
4869
4935
|
return b.g - c.g;
|
|
4870
4936
|
});
|
|
4871
4937
|
return a;
|
|
4872
4938
|
}
|
|
4873
4939
|
;
|
|
4874
|
-
function
|
|
4940
|
+
function p() {
|
|
4875
4941
|
this.h = {};
|
|
4876
4942
|
this.j = this.m().g;
|
|
4877
4943
|
this.g = this.l = null;
|
|
4878
4944
|
}
|
|
4879
|
-
|
|
4880
|
-
return
|
|
4945
|
+
p.prototype.has = function(a) {
|
|
4946
|
+
return q(this, a.g);
|
|
4881
4947
|
};
|
|
4882
|
-
|
|
4883
|
-
return
|
|
4948
|
+
p.prototype.get = function(a, b) {
|
|
4949
|
+
return r(this, a.g, b);
|
|
4884
4950
|
};
|
|
4885
|
-
|
|
4886
|
-
|
|
4951
|
+
p.prototype.set = function(a, b) {
|
|
4952
|
+
t(this, a.g, b);
|
|
4887
4953
|
};
|
|
4888
|
-
|
|
4954
|
+
p.prototype.add = function(a, b) {
|
|
4889
4955
|
va(this, a.g, b);
|
|
4890
4956
|
};
|
|
4891
|
-
|
|
4957
|
+
p.prototype.equals = function(a) {
|
|
4892
4958
|
if (!a || this.constructor != a.constructor) return false;
|
|
4893
4959
|
for (var b = ua(this.m()), c = 0; c < b.length; c++) {
|
|
4894
4960
|
var d = b[c], e = d.g;
|
|
4895
|
-
if (
|
|
4896
|
-
if (
|
|
4897
|
-
var f = d.h == 11 || d.h == 10, g =
|
|
4898
|
-
e =
|
|
4961
|
+
if (q(this, e) != q(a, e)) return false;
|
|
4962
|
+
if (q(this, e)) {
|
|
4963
|
+
var f = d.h == 11 || d.h == 10, g = u(this, e);
|
|
4964
|
+
e = u(a, e);
|
|
4899
4965
|
if (d.l) {
|
|
4900
4966
|
if (g.length != e.length) return false;
|
|
4901
4967
|
for (d = 0; d < g.length; d++) {
|
|
@@ -4910,25 +4976,25 @@ var _scope = {};
|
|
|
4910
4976
|
function wa(a, b) {
|
|
4911
4977
|
for (var c = ua(a.m()), d = 0; d < c.length; d++) {
|
|
4912
4978
|
var e = c[d], f = e.g;
|
|
4913
|
-
if (
|
|
4979
|
+
if (q(b, f)) {
|
|
4914
4980
|
a.g && delete a.g[e.g];
|
|
4915
4981
|
var g = e.h == 11 || e.h == 10;
|
|
4916
4982
|
if (e.l) {
|
|
4917
|
-
e =
|
|
4983
|
+
e = u(b, f) || [];
|
|
4918
4984
|
for (var h = 0; h < e.length; h++) va(a, f, g ? e[h].clone() : e[h]);
|
|
4919
|
-
} else e =
|
|
4985
|
+
} else e = u(b, f), g ? (g = u(a, f)) ? wa(g, e) : t(a, f, e.clone()) : t(a, f, e);
|
|
4920
4986
|
}
|
|
4921
4987
|
}
|
|
4922
4988
|
}
|
|
4923
|
-
|
|
4989
|
+
p.prototype.clone = function() {
|
|
4924
4990
|
var a = new this.constructor();
|
|
4925
4991
|
a != this && (a.h = {}, a.g && (a.g = {}), wa(a, this));
|
|
4926
4992
|
return a;
|
|
4927
4993
|
};
|
|
4928
|
-
function
|
|
4994
|
+
function q(a, b) {
|
|
4929
4995
|
return a.h[b] != null;
|
|
4930
4996
|
}
|
|
4931
|
-
function
|
|
4997
|
+
function u(a, b) {
|
|
4932
4998
|
var c = a.h[b];
|
|
4933
4999
|
if (c == null) return null;
|
|
4934
5000
|
if (a.l) {
|
|
@@ -4944,12 +5010,12 @@ var _scope = {};
|
|
|
4944
5010
|
}
|
|
4945
5011
|
return c;
|
|
4946
5012
|
}
|
|
4947
|
-
function
|
|
4948
|
-
var d =
|
|
5013
|
+
function r(a, b, c) {
|
|
5014
|
+
var d = u(a, b);
|
|
4949
5015
|
return a.j[b].l ? d[c || 0] : d;
|
|
4950
5016
|
}
|
|
4951
|
-
function
|
|
4952
|
-
if (
|
|
5017
|
+
function v(a, b) {
|
|
5018
|
+
if (q(a, b)) a = r(a, b);
|
|
4953
5019
|
else a: {
|
|
4954
5020
|
a = a.j[b];
|
|
4955
5021
|
if (a.j === void 0) if (b = a.u, b === Boolean) a.j = false;
|
|
@@ -4963,10 +5029,10 @@ var _scope = {};
|
|
|
4963
5029
|
}
|
|
4964
5030
|
return a;
|
|
4965
5031
|
}
|
|
4966
|
-
function
|
|
4967
|
-
return a.j[b].l ?
|
|
5032
|
+
function w(a, b) {
|
|
5033
|
+
return a.j[b].l ? q(a, b) ? a.h[b].length : 0 : q(a, b) ? 1 : 0;
|
|
4968
5034
|
}
|
|
4969
|
-
function
|
|
5035
|
+
function t(a, b, c) {
|
|
4970
5036
|
a.h[b] = c;
|
|
4971
5037
|
a.g && (a.g[b] = c);
|
|
4972
5038
|
}
|
|
@@ -4975,20 +5041,20 @@ var _scope = {};
|
|
|
4975
5041
|
a.h[b].push(c);
|
|
4976
5042
|
a.g && delete a.g[b];
|
|
4977
5043
|
}
|
|
4978
|
-
function
|
|
5044
|
+
function x(a, b) {
|
|
4979
5045
|
var c = [], d;
|
|
4980
5046
|
for (d in b) d != 0 && c.push(new la(d, b[d]));
|
|
4981
5047
|
return new ta(a, c);
|
|
4982
5048
|
}
|
|
4983
5049
|
;
|
|
4984
|
-
function
|
|
5050
|
+
function y() {
|
|
4985
5051
|
}
|
|
4986
|
-
|
|
5052
|
+
y.prototype.g = function(a) {
|
|
4987
5053
|
new a.h();
|
|
4988
5054
|
throw Error("Unimplemented");
|
|
4989
5055
|
};
|
|
4990
|
-
|
|
4991
|
-
if (a.h == 11 || a.h == 10) return b instanceof
|
|
5056
|
+
y.prototype.h = function(a, b) {
|
|
5057
|
+
if (a.h == 11 || a.h == 10) return b instanceof p ? b : this.g(a.u.prototype.m(), b);
|
|
4992
5058
|
if (a.h == 14) return typeof b === "string" && xa.test(b) && (a = Number(b), a > 0) ? a : b;
|
|
4993
5059
|
if (!a.o) return b;
|
|
4994
5060
|
a = a.u;
|
|
@@ -5000,7 +5066,7 @@ var _scope = {};
|
|
|
5000
5066
|
var xa = /^-?[0-9]+$/;
|
|
5001
5067
|
function ya() {
|
|
5002
5068
|
}
|
|
5003
|
-
|
|
5069
|
+
n(ya, y);
|
|
5004
5070
|
ya.prototype.g = function(a, b) {
|
|
5005
5071
|
a = new a.h();
|
|
5006
5072
|
a.l = this;
|
|
@@ -5010,82 +5076,82 @@ var _scope = {};
|
|
|
5010
5076
|
};
|
|
5011
5077
|
function z() {
|
|
5012
5078
|
}
|
|
5013
|
-
|
|
5079
|
+
n(z, ya);
|
|
5014
5080
|
z.prototype.h = function(a, b) {
|
|
5015
|
-
return a.h == 8 ? !!b :
|
|
5081
|
+
return a.h == 8 ? !!b : y.prototype.h.apply(this, arguments);
|
|
5016
5082
|
};
|
|
5017
5083
|
z.prototype.g = function(a, b) {
|
|
5018
5084
|
return z.na.g.call(this, a, b);
|
|
5019
5085
|
};
|
|
5020
|
-
function
|
|
5086
|
+
function B(a, b) {
|
|
5021
5087
|
a != null && this.g.apply(this, arguments);
|
|
5022
5088
|
}
|
|
5023
|
-
|
|
5024
|
-
|
|
5089
|
+
B.prototype.h = "";
|
|
5090
|
+
B.prototype.set = function(a) {
|
|
5025
5091
|
this.h = "" + a;
|
|
5026
5092
|
};
|
|
5027
|
-
|
|
5093
|
+
B.prototype.g = function(a, b, c) {
|
|
5028
5094
|
this.h += String(a);
|
|
5029
5095
|
if (b != null) for (let d = 1; d < arguments.length; d++) this.h += arguments[d];
|
|
5030
5096
|
return this;
|
|
5031
5097
|
};
|
|
5032
|
-
function
|
|
5098
|
+
function C(a) {
|
|
5033
5099
|
a.h = "";
|
|
5034
5100
|
}
|
|
5035
|
-
|
|
5101
|
+
B.prototype.toString = function() {
|
|
5036
5102
|
return this.h;
|
|
5037
5103
|
};
|
|
5038
|
-
function
|
|
5039
|
-
|
|
5104
|
+
function D() {
|
|
5105
|
+
p.call(this);
|
|
5040
5106
|
}
|
|
5041
|
-
|
|
5107
|
+
n(D, p);
|
|
5042
5108
|
var za = null;
|
|
5043
|
-
function
|
|
5044
|
-
|
|
5109
|
+
function E() {
|
|
5110
|
+
p.call(this);
|
|
5045
5111
|
}
|
|
5046
|
-
|
|
5112
|
+
n(E, p);
|
|
5047
5113
|
var Aa = null;
|
|
5048
|
-
function
|
|
5049
|
-
return
|
|
5114
|
+
function F(a) {
|
|
5115
|
+
return u(a, 9) || [];
|
|
5050
5116
|
}
|
|
5051
|
-
function
|
|
5052
|
-
|
|
5117
|
+
function G() {
|
|
5118
|
+
p.call(this);
|
|
5053
5119
|
}
|
|
5054
|
-
|
|
5120
|
+
n(G, p);
|
|
5055
5121
|
var Ba = null;
|
|
5056
|
-
|
|
5122
|
+
D.prototype.m = function() {
|
|
5057
5123
|
var a = za;
|
|
5058
|
-
a || (za = a =
|
|
5124
|
+
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 } }));
|
|
5059
5125
|
return a;
|
|
5060
5126
|
};
|
|
5061
|
-
|
|
5062
|
-
|
|
5127
|
+
D.m = D.prototype.m;
|
|
5128
|
+
E.prototype.m = function() {
|
|
5063
5129
|
var a = Aa;
|
|
5064
|
-
a || (Aa = a =
|
|
5130
|
+
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 } }));
|
|
5065
5131
|
return a;
|
|
5066
5132
|
};
|
|
5067
|
-
|
|
5068
|
-
|
|
5133
|
+
E.m = E.prototype.m;
|
|
5134
|
+
G.prototype.m = function() {
|
|
5069
5135
|
var a = Ba;
|
|
5070
|
-
a || (Ba = a =
|
|
5136
|
+
a || (Ba = a = x(G, {
|
|
5071
5137
|
0: { name: "PhoneMetadata", ja: "i18n.phonenumbers.PhoneMetadata" },
|
|
5072
|
-
1: { name: "general_desc", i: 11, type:
|
|
5073
|
-
2: { name: "fixed_line", i: 11, type:
|
|
5074
|
-
3: { name: "mobile", i: 11, type:
|
|
5075
|
-
4: { name: "toll_free", i: 11, type:
|
|
5076
|
-
5: { name: "premium_rate", i: 11, type:
|
|
5077
|
-
6: { name: "shared_cost", i: 11, type:
|
|
5078
|
-
7: { name: "personal_number", i: 11, type:
|
|
5079
|
-
8: { name: "voip", i: 11, type:
|
|
5080
|
-
21: { name: "pager", i: 11, type:
|
|
5081
|
-
25: { name: "uan", i: 11, type:
|
|
5082
|
-
27: { name: "emergency", i: 11, type:
|
|
5083
|
-
28: { name: "voicemail", i: 11, type:
|
|
5084
|
-
29: { name: "short_code", i: 11, type:
|
|
5085
|
-
30: { name: "standard_rate", i: 11, type:
|
|
5086
|
-
31: { name: "carrier_specific", i: 11, type:
|
|
5087
|
-
33: { name: "sms_services", i: 11, type:
|
|
5088
|
-
24: { name: "no_international_dialling", i: 11, type:
|
|
5138
|
+
1: { name: "general_desc", i: 11, type: E },
|
|
5139
|
+
2: { name: "fixed_line", i: 11, type: E },
|
|
5140
|
+
3: { name: "mobile", i: 11, type: E },
|
|
5141
|
+
4: { name: "toll_free", i: 11, type: E },
|
|
5142
|
+
5: { name: "premium_rate", i: 11, type: E },
|
|
5143
|
+
6: { name: "shared_cost", i: 11, type: E },
|
|
5144
|
+
7: { name: "personal_number", i: 11, type: E },
|
|
5145
|
+
8: { name: "voip", i: 11, type: E },
|
|
5146
|
+
21: { name: "pager", i: 11, type: E },
|
|
5147
|
+
25: { name: "uan", i: 11, type: E },
|
|
5148
|
+
27: { name: "emergency", i: 11, type: E },
|
|
5149
|
+
28: { name: "voicemail", i: 11, type: E },
|
|
5150
|
+
29: { name: "short_code", i: 11, type: E },
|
|
5151
|
+
30: { name: "standard_rate", i: 11, type: E },
|
|
5152
|
+
31: { name: "carrier_specific", i: 11, type: E },
|
|
5153
|
+
33: { name: "sms_services", i: 11, type: E },
|
|
5154
|
+
24: { name: "no_international_dialling", i: 11, type: E },
|
|
5089
5155
|
9: { name: "id", required: true, i: 9, type: String },
|
|
5090
5156
|
10: { name: "country_code", i: 5, type: Number },
|
|
5091
5157
|
11: { name: "international_prefix", i: 9, type: String },
|
|
@@ -5099,31 +5165,31 @@ var _scope = {};
|
|
|
5099
5165
|
},
|
|
5100
5166
|
16: { name: "national_prefix_transform_rule", i: 9, type: String },
|
|
5101
5167
|
18: { name: "same_mobile_and_fixed_line_pattern", i: 8, defaultValue: false, type: Boolean },
|
|
5102
|
-
19: { name: "number_format", ca: true, i: 11, type:
|
|
5103
|
-
20: { name: "intl_number_format", ca: true, i: 11, type:
|
|
5168
|
+
19: { name: "number_format", ca: true, i: 11, type: D },
|
|
5169
|
+
20: { name: "intl_number_format", ca: true, i: 11, type: D },
|
|
5104
5170
|
22: { name: "main_country_for_code", i: 8, defaultValue: false, type: Boolean },
|
|
5105
5171
|
23: { name: "leading_digits", i: 9, type: String }
|
|
5106
5172
|
}));
|
|
5107
5173
|
return a;
|
|
5108
5174
|
};
|
|
5109
|
-
|
|
5110
|
-
function
|
|
5111
|
-
|
|
5175
|
+
G.m = G.prototype.m;
|
|
5176
|
+
function H() {
|
|
5177
|
+
p.call(this);
|
|
5112
5178
|
}
|
|
5113
|
-
|
|
5179
|
+
n(H, p);
|
|
5114
5180
|
var Ca = null, Da = { sa: 0, ra: 1, qa: 5, pa: 10, oa: 20 };
|
|
5115
|
-
|
|
5181
|
+
H.prototype.m = function() {
|
|
5116
5182
|
var a = Ca;
|
|
5117
|
-
a || (Ca = a =
|
|
5183
|
+
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: {
|
|
5118
5184
|
name: "preferred_domestic_carrier_code",
|
|
5119
5185
|
i: 9,
|
|
5120
5186
|
type: String
|
|
5121
5187
|
} }));
|
|
5122
5188
|
return a;
|
|
5123
5189
|
};
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
var
|
|
5190
|
+
H.ctor = H;
|
|
5191
|
+
H.ctor.m = H.prototype.m;
|
|
5192
|
+
var I = {
|
|
5127
5193
|
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(" "),
|
|
5128
5194
|
7: ["RU", "KZ"],
|
|
5129
5195
|
20: ["EG"],
|
|
@@ -10390,12 +10456,12 @@ var _scope = {};
|
|
|
10390
10456
|
], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "001", 888, , , , , , , , 1, [[, "(\\d{3})(\\d{3})(\\d{5})", "$1 $2 $3"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , "\\d{11}", , , , "12345678901"], , , [, , , , , , , , , [-1]]],
|
|
10391
10457
|
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]]]
|
|
10392
10458
|
};
|
|
10393
|
-
function
|
|
10459
|
+
function J() {
|
|
10394
10460
|
this.g = {};
|
|
10395
10461
|
}
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
return
|
|
10462
|
+
J.h = void 0;
|
|
10463
|
+
J.g = function() {
|
|
10464
|
+
return J.h ? J.h : J.h = new J();
|
|
10399
10465
|
};
|
|
10400
10466
|
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 = {
|
|
10401
10467
|
0: "0",
|
|
@@ -10478,56 +10544,56 @@ var _scope = {};
|
|
|
10478
10544
|
X: "9",
|
|
10479
10545
|
Y: "9",
|
|
10480
10546
|
Z: "9"
|
|
10481
|
-
}, Ia = RegExp("[+\uFF0B]+"),
|
|
10482
|
-
function
|
|
10547
|
+
}, 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])*\\.?$");
|
|
10548
|
+
function L(a) {
|
|
10483
10549
|
return "([0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]{1," + a + "})";
|
|
10484
10550
|
}
|
|
10485
10551
|
function Qa() {
|
|
10486
|
-
return ";ext=" +
|
|
10552
|
+
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") + "#?");
|
|
10487
10553
|
}
|
|
10488
10554
|
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\)?$/;
|
|
10489
10555
|
function Va(a) {
|
|
10490
|
-
return a.length < 2 ? false :
|
|
10556
|
+
return a.length < 2 ? false : M(Sa, a);
|
|
10491
10557
|
}
|
|
10492
10558
|
function Wa(a) {
|
|
10493
|
-
return
|
|
10559
|
+
return M(Na, a) ? N(a, Ha) : N(a, Fa);
|
|
10494
10560
|
}
|
|
10495
10561
|
function Xa(a) {
|
|
10496
10562
|
var b = Wa(a.toString());
|
|
10497
|
-
|
|
10563
|
+
C(a);
|
|
10498
10564
|
a.g(b);
|
|
10499
10565
|
}
|
|
10500
10566
|
function Ya(a) {
|
|
10501
|
-
return a != null && (
|
|
10567
|
+
return a != null && (w(a, 9) != 1 || F(a)[0] != -1);
|
|
10502
10568
|
}
|
|
10503
|
-
function
|
|
10504
|
-
for (var c = new
|
|
10569
|
+
function N(a, b) {
|
|
10570
|
+
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);
|
|
10505
10571
|
return c.toString();
|
|
10506
10572
|
}
|
|
10507
10573
|
function Za(a) {
|
|
10508
10574
|
return a.length == 0 || Ua.test(a);
|
|
10509
10575
|
}
|
|
10510
|
-
function
|
|
10576
|
+
function O(a) {
|
|
10511
10577
|
return a != null && isNaN(a) && a.toUpperCase() in Ea;
|
|
10512
10578
|
}
|
|
10513
|
-
|
|
10514
|
-
if (
|
|
10515
|
-
var c =
|
|
10579
|
+
J.prototype.format = function(a, b) {
|
|
10580
|
+
if (r(a, 2) == 0 && q(a, 5)) {
|
|
10581
|
+
var c = v(a, 5);
|
|
10516
10582
|
if (c.length > 0) return c;
|
|
10517
10583
|
}
|
|
10518
|
-
c =
|
|
10519
|
-
var d =
|
|
10584
|
+
c = v(a, 1);
|
|
10585
|
+
var d = P(a);
|
|
10520
10586
|
if (b == 0) return $a(c, 0, d, "");
|
|
10521
|
-
if (!(c in
|
|
10522
|
-
var e =
|
|
10523
|
-
a =
|
|
10587
|
+
if (!(c in I)) return d;
|
|
10588
|
+
var e = Q(this, c, R(c));
|
|
10589
|
+
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) : "";
|
|
10524
10590
|
a: {
|
|
10525
|
-
e = (
|
|
10591
|
+
e = (u(e, 20) || []).length == 0 || b == 2 ? u(e, 19) || [] : u(e, 20) || [];
|
|
10526
10592
|
for (var f, g = e.length, h = 0; h < g; ++h) {
|
|
10527
10593
|
f = e[h];
|
|
10528
|
-
var l =
|
|
10529
|
-
if (l == 0 || d.search(
|
|
10530
|
-
if (l = new RegExp(
|
|
10594
|
+
var l = w(f, 3);
|
|
10595
|
+
if (l == 0 || d.search(r(f, 3, l - 1)) == 0) {
|
|
10596
|
+
if (l = new RegExp(r(f, 1)), M(l, d)) {
|
|
10531
10597
|
e = f;
|
|
10532
10598
|
break a;
|
|
10533
10599
|
}
|
|
@@ -10535,19 +10601,19 @@ var _scope = {};
|
|
|
10535
10601
|
}
|
|
10536
10602
|
e = null;
|
|
10537
10603
|
}
|
|
10538
|
-
e != null && (g = e, e =
|
|
10604
|
+
e != null && (g = e, e = v(g, 2), f = new RegExp(r(
|
|
10539
10605
|
g,
|
|
10540
10606
|
1
|
|
10541
|
-
)),
|
|
10607
|
+
)), 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"), "-")));
|
|
10542
10608
|
return $a(c, b, d, a);
|
|
10543
10609
|
};
|
|
10544
|
-
function
|
|
10545
|
-
return "001" == c ?
|
|
10610
|
+
function Q(a, b, c) {
|
|
10611
|
+
return "001" == c ? S(a, "" + b) : S(a, c);
|
|
10546
10612
|
}
|
|
10547
|
-
function
|
|
10548
|
-
if (!
|
|
10549
|
-
var b = "" +
|
|
10550
|
-
return
|
|
10613
|
+
function P(a) {
|
|
10614
|
+
if (!q(a, 2)) return "";
|
|
10615
|
+
var b = "" + r(a, 2);
|
|
10616
|
+
return q(a, 4) && r(a, 4) && v(a, 8) > 0 ? Array(v(a, 8) + 1).join("0") + b : b;
|
|
10551
10617
|
}
|
|
10552
10618
|
function $a(a, b, c, d) {
|
|
10553
10619
|
switch (b) {
|
|
@@ -10561,79 +10627,79 @@ var _scope = {};
|
|
|
10561
10627
|
return c + d;
|
|
10562
10628
|
}
|
|
10563
10629
|
}
|
|
10564
|
-
function
|
|
10630
|
+
function T(a, b) {
|
|
10565
10631
|
switch (b) {
|
|
10566
10632
|
case 4:
|
|
10567
|
-
return
|
|
10633
|
+
return r(a, 5);
|
|
10568
10634
|
case 3:
|
|
10569
|
-
return
|
|
10635
|
+
return r(a, 4);
|
|
10570
10636
|
case 1:
|
|
10571
|
-
return
|
|
10637
|
+
return r(a, 3);
|
|
10572
10638
|
case 0:
|
|
10573
10639
|
case 2:
|
|
10574
|
-
return
|
|
10640
|
+
return r(a, 2);
|
|
10575
10641
|
case 5:
|
|
10576
|
-
return
|
|
10642
|
+
return r(a, 6);
|
|
10577
10643
|
case 6:
|
|
10578
|
-
return
|
|
10644
|
+
return r(a, 8);
|
|
10579
10645
|
case 7:
|
|
10580
|
-
return
|
|
10646
|
+
return r(a, 7);
|
|
10581
10647
|
case 8:
|
|
10582
|
-
return
|
|
10648
|
+
return r(a, 21);
|
|
10583
10649
|
case 9:
|
|
10584
|
-
return
|
|
10650
|
+
return r(a, 25);
|
|
10585
10651
|
case 10:
|
|
10586
|
-
return
|
|
10652
|
+
return r(a, 28);
|
|
10587
10653
|
default:
|
|
10588
|
-
return
|
|
10654
|
+
return r(a, 1);
|
|
10589
10655
|
}
|
|
10590
10656
|
}
|
|
10591
10657
|
function ab(a, b) {
|
|
10592
10658
|
var c = bb(a, b);
|
|
10593
|
-
a =
|
|
10659
|
+
a = Q(a, v(b, 1), c);
|
|
10594
10660
|
if (a == null) return -1;
|
|
10595
|
-
b =
|
|
10661
|
+
b = P(b);
|
|
10596
10662
|
return cb(b, a);
|
|
10597
10663
|
}
|
|
10598
10664
|
function cb(a, b) {
|
|
10599
|
-
return
|
|
10665
|
+
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;
|
|
10600
10666
|
}
|
|
10601
|
-
function
|
|
10667
|
+
function S(a, b) {
|
|
10602
10668
|
if (b == null) return null;
|
|
10603
10669
|
b = b.toUpperCase();
|
|
10604
10670
|
var c = a.g[b];
|
|
10605
10671
|
if (c == null) {
|
|
10606
10672
|
c = Ea[b];
|
|
10607
10673
|
if (c == null) return null;
|
|
10608
|
-
c = new z().g(
|
|
10674
|
+
c = new z().g(G.m(), c);
|
|
10609
10675
|
a.g[b] = c;
|
|
10610
10676
|
}
|
|
10611
10677
|
return c;
|
|
10612
10678
|
}
|
|
10613
|
-
function
|
|
10679
|
+
function U(a, b) {
|
|
10614
10680
|
var c = a.length;
|
|
10615
|
-
return
|
|
10681
|
+
return w(b, 9) > 0 && F(b).indexOf(c) == -1 ? false : M(v(b, 2), a);
|
|
10616
10682
|
}
|
|
10617
10683
|
function db(a, b) {
|
|
10618
10684
|
var c = bb(a, b);
|
|
10619
|
-
var d =
|
|
10620
|
-
var e =
|
|
10621
|
-
e == null || "001" != c && d != eb(a, c) ? e = false : (a =
|
|
10685
|
+
var d = v(b, 1);
|
|
10686
|
+
var e = Q(a, d, c);
|
|
10687
|
+
e == null || "001" != c && d != eb(a, c) ? e = false : (a = P(b), e = cb(a, e) != -1);
|
|
10622
10688
|
return e;
|
|
10623
10689
|
}
|
|
10624
10690
|
function bb(a, b) {
|
|
10625
10691
|
if (b == null) return null;
|
|
10626
|
-
var c =
|
|
10627
|
-
c =
|
|
10692
|
+
var c = v(b, 1);
|
|
10693
|
+
c = I[c];
|
|
10628
10694
|
if (c == null) a = null;
|
|
10629
10695
|
else if (c.length == 1) a = c[0];
|
|
10630
10696
|
else a: {
|
|
10631
|
-
b =
|
|
10697
|
+
b = P(b);
|
|
10632
10698
|
for (var d, e = c.length, f = 0; f < e; f++) {
|
|
10633
10699
|
d = c[f];
|
|
10634
|
-
var g =
|
|
10635
|
-
if (
|
|
10636
|
-
if (b.search(
|
|
10700
|
+
var g = S(a, d);
|
|
10701
|
+
if (q(g, 23)) {
|
|
10702
|
+
if (b.search(r(g, 23)) == 0) {
|
|
10637
10703
|
a = d;
|
|
10638
10704
|
break a;
|
|
10639
10705
|
}
|
|
@@ -10646,48 +10712,48 @@ var _scope = {};
|
|
|
10646
10712
|
}
|
|
10647
10713
|
return a;
|
|
10648
10714
|
}
|
|
10649
|
-
function
|
|
10650
|
-
a =
|
|
10715
|
+
function R(a) {
|
|
10716
|
+
a = I[a];
|
|
10651
10717
|
return a == null ? "ZZ" : a[0];
|
|
10652
10718
|
}
|
|
10653
10719
|
function eb(a, b) {
|
|
10654
|
-
a =
|
|
10720
|
+
a = S(a, b);
|
|
10655
10721
|
if (a == null) throw Error("Invalid region code: " + b);
|
|
10656
|
-
return
|
|
10722
|
+
return v(a, 10);
|
|
10657
10723
|
}
|
|
10658
|
-
function
|
|
10659
|
-
var e =
|
|
10660
|
-
e =
|
|
10661
|
-
if (d == 2) if (Ya(
|
|
10662
|
-
else return
|
|
10724
|
+
function V(a, b, c, d) {
|
|
10725
|
+
var e = T(c, d), f = w(e, 9) == 0 ? F(r(c, 1)) : F(e);
|
|
10726
|
+
e = u(e, 10) || [];
|
|
10727
|
+
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()));
|
|
10728
|
+
else return V(a, b, c, 1);
|
|
10663
10729
|
if (f[0] == -1) return 5;
|
|
10664
10730
|
b = b.length;
|
|
10665
10731
|
if (e.indexOf(b) > -1) return 4;
|
|
10666
10732
|
c = f[0];
|
|
10667
10733
|
return c == b ? 0 : c > b ? 2 : f[f.length - 1] < b ? 3 : f.indexOf(b, 1) > -1 ? 0 : 5;
|
|
10668
10734
|
}
|
|
10669
|
-
function
|
|
10670
|
-
var d =
|
|
10671
|
-
b =
|
|
10672
|
-
if (!(b in
|
|
10673
|
-
b =
|
|
10674
|
-
return
|
|
10735
|
+
function W(a, b, c) {
|
|
10736
|
+
var d = P(b);
|
|
10737
|
+
b = v(b, 1);
|
|
10738
|
+
if (!(b in I)) return 1;
|
|
10739
|
+
b = Q(a, b, R(b));
|
|
10740
|
+
return V(a, d, b, c);
|
|
10675
10741
|
}
|
|
10676
10742
|
function fb(a, b) {
|
|
10677
10743
|
a = a.toString();
|
|
10678
10744
|
if (a.length == 0 || a.charAt(0) == "0") return 0;
|
|
10679
|
-
for (var c, d = a.length, e = 1; e <= 3 && e <= d; ++e) if (c = parseInt(a.substring(0, e), 10), c in
|
|
10745
|
+
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;
|
|
10680
10746
|
return 0;
|
|
10681
10747
|
}
|
|
10682
10748
|
function gb(a, b, c, d, e, f) {
|
|
10683
10749
|
if (b.length == 0) return 0;
|
|
10684
|
-
b = new
|
|
10750
|
+
b = new B(b);
|
|
10685
10751
|
var g;
|
|
10686
|
-
c != null && (g =
|
|
10752
|
+
c != null && (g = r(c, 11));
|
|
10687
10753
|
g == null && (g = "NonMatch");
|
|
10688
10754
|
var h = b.toString();
|
|
10689
10755
|
if (h.length == 0) g = 20;
|
|
10690
|
-
else if (
|
|
10756
|
+
else if (K.test(h)) h = h.replace(K, ""), C(b), b.g(Wa(h)), g = 1;
|
|
10691
10757
|
else {
|
|
10692
10758
|
h = new RegExp(g);
|
|
10693
10759
|
Xa(b);
|
|
@@ -10695,44 +10761,44 @@ var _scope = {};
|
|
|
10695
10761
|
if (g.search(h) == 0) {
|
|
10696
10762
|
h = g.match(h)[0].length;
|
|
10697
10763
|
var l = g.substring(h).match(Ja);
|
|
10698
|
-
l && l[1] != null && l[1].length > 0 &&
|
|
10764
|
+
l && l[1] != null && l[1].length > 0 && N(l[1], Fa) == "0" ? g = false : (C(b), b.g(g.substring(h)), g = true);
|
|
10699
10765
|
} else g = false;
|
|
10700
10766
|
g = g ? 5 : 20;
|
|
10701
10767
|
}
|
|
10702
|
-
e &&
|
|
10768
|
+
e && t(f, 6, g);
|
|
10703
10769
|
if (g != 20) {
|
|
10704
10770
|
if (b.h.length <= 2) throw Error("Phone number too short after IDD");
|
|
10705
10771
|
a = fb(b, d);
|
|
10706
|
-
if (a != 0) return
|
|
10772
|
+
if (a != 0) return t(f, 1, a), a;
|
|
10707
10773
|
throw Error("Invalid country calling code");
|
|
10708
10774
|
}
|
|
10709
|
-
if (c != null && (g =
|
|
10710
|
-
|
|
10775
|
+
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;
|
|
10776
|
+
t(f, 1, 0);
|
|
10711
10777
|
return 0;
|
|
10712
10778
|
}
|
|
10713
10779
|
function hb(a, b, c) {
|
|
10714
|
-
var d = a.toString(), e = d.length, f =
|
|
10780
|
+
var d = a.toString(), e = d.length, f = r(b, 15);
|
|
10715
10781
|
if (e != 0 && f != null && f.length != 0 && (f = new RegExp("^(?:" + f + ")"), e = f.exec(d))) {
|
|
10716
10782
|
var g = RegExp;
|
|
10717
|
-
var h =
|
|
10718
|
-
h =
|
|
10783
|
+
var h = r(b, 1);
|
|
10784
|
+
h = v(h, 2);
|
|
10719
10785
|
g = new g(h);
|
|
10720
|
-
h =
|
|
10786
|
+
h = M(g, d);
|
|
10721
10787
|
var l = e.length - 1;
|
|
10722
|
-
b =
|
|
10788
|
+
b = r(b, 16);
|
|
10723
10789
|
if (b == null || b.length == 0 || e[l] == null || e[l].length == 0) {
|
|
10724
|
-
if (!h ||
|
|
10725
|
-
} else if (d = d.replace(f, b), !h ||
|
|
10790
|
+
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));
|
|
10791
|
+
} else if (d = d.replace(f, b), !h || M(g, d)) c != null && l > 0 && c.g(e[1]), a.set(d);
|
|
10726
10792
|
}
|
|
10727
10793
|
}
|
|
10728
|
-
function
|
|
10729
|
-
if (!
|
|
10794
|
+
function X(a, b, c) {
|
|
10795
|
+
if (!O(c) && b.length > 0 && b.charAt(0) != "+") throw Error("Invalid country calling code");
|
|
10730
10796
|
return ib(a, b, c, true);
|
|
10731
10797
|
}
|
|
10732
10798
|
function ib(a, b, c, d) {
|
|
10733
10799
|
if (b == null) throw Error("The string supplied did not seem to be a phone number");
|
|
10734
10800
|
if (b.length > 250) throw Error("The string supplied is too long to be a phone number");
|
|
10735
|
-
var e = new
|
|
10801
|
+
var e = new B();
|
|
10736
10802
|
var f = b.indexOf(";phone-context=");
|
|
10737
10803
|
if (f === -1) f = null;
|
|
10738
10804
|
else if (f += 15, f >= b.length) f = "";
|
|
@@ -10746,109 +10812,109 @@ var _scope = {};
|
|
|
10746
10812
|
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));
|
|
10747
10813
|
f = e.toString();
|
|
10748
10814
|
g = f.indexOf(";isub=");
|
|
10749
|
-
g > 0 && (
|
|
10815
|
+
g > 0 && (C(e), e.g(f.substring(0, g)));
|
|
10750
10816
|
if (!Va(e.toString())) throw Error("The string supplied did not seem to be a phone number");
|
|
10751
10817
|
f = e.toString();
|
|
10752
|
-
if (!(
|
|
10753
|
-
f = new
|
|
10754
|
-
d &&
|
|
10818
|
+
if (!(O(c) || f != null && f.length > 0 && K.test(f))) throw Error("Invalid country calling code");
|
|
10819
|
+
f = new H();
|
|
10820
|
+
d && t(f, 5, b);
|
|
10755
10821
|
a: {
|
|
10756
10822
|
b = e.toString();
|
|
10757
10823
|
g = b.search(Ra);
|
|
10758
10824
|
if (g >= 0 && Va(b.substring(0, g))) {
|
|
10759
10825
|
h = b.match(Ra);
|
|
10760
|
-
for (var l = h.length,
|
|
10761
|
-
|
|
10826
|
+
for (var l = h.length, A = 1; A < l; ++A) if (h[A] != null && h[A].length > 0) {
|
|
10827
|
+
C(e);
|
|
10762
10828
|
e.g(b.substring(0, g));
|
|
10763
|
-
b = h[
|
|
10829
|
+
b = h[A];
|
|
10764
10830
|
break a;
|
|
10765
10831
|
}
|
|
10766
10832
|
}
|
|
10767
10833
|
b = "";
|
|
10768
10834
|
}
|
|
10769
|
-
b.length > 0 &&
|
|
10770
|
-
g =
|
|
10771
|
-
b = new
|
|
10835
|
+
b.length > 0 && t(f, 3, b);
|
|
10836
|
+
g = S(a, c);
|
|
10837
|
+
b = new B();
|
|
10772
10838
|
h = 0;
|
|
10773
10839
|
l = e.toString();
|
|
10774
10840
|
try {
|
|
10775
10841
|
h = gb(a, l, g, b, d, f);
|
|
10776
|
-
} catch (
|
|
10777
|
-
if (
|
|
10778
|
-
if (l = l.replace(
|
|
10779
|
-
} else throw
|
|
10842
|
+
} catch (da) {
|
|
10843
|
+
if (da.message == "Invalid country calling code" && K.test(l)) {
|
|
10844
|
+
if (l = l.replace(K, ""), h = gb(a, l, g, b, d, f), h == 0) throw da;
|
|
10845
|
+
} else throw da;
|
|
10780
10846
|
}
|
|
10781
|
-
h != 0 ? (e =
|
|
10847
|
+
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(
|
|
10782
10848
|
f,
|
|
10783
10849
|
1,
|
|
10784
10850
|
h
|
|
10785
10851
|
)) : d && (delete f.h[6], f.g && delete f.g[6]));
|
|
10786
10852
|
if (b.h.length < 2) throw Error("The string supplied is too short to be a phone number");
|
|
10787
|
-
g != null && (c = new
|
|
10853
|
+
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())));
|
|
10788
10854
|
d = b.toString();
|
|
10789
10855
|
a = d.length;
|
|
10790
10856
|
if (a < 2) throw Error("The string supplied is too short to be a phone number");
|
|
10791
10857
|
if (a > 17) throw Error("The string supplied is too long to be a phone number");
|
|
10792
10858
|
if (d.length > 1 && d.charAt(0) == "0") {
|
|
10793
|
-
|
|
10859
|
+
t(f, 4, true);
|
|
10794
10860
|
for (a = 1; a < d.length - 1 && d.charAt(a) == "0"; ) a++;
|
|
10795
|
-
a != 1 &&
|
|
10861
|
+
a != 1 && t(f, 8, a);
|
|
10796
10862
|
}
|
|
10797
|
-
|
|
10863
|
+
t(f, 2, parseInt(d, 10));
|
|
10798
10864
|
return f;
|
|
10799
10865
|
}
|
|
10800
|
-
function
|
|
10866
|
+
function M(a, b) {
|
|
10801
10867
|
return (a = b.match(new RegExp("^(?:" + (typeof a == "string" ? a : a.source) + ")$", "i"))) && a[0].length == b.length ? true : false;
|
|
10802
10868
|
}
|
|
10803
10869
|
;
|
|
10804
10870
|
function jb(a) {
|
|
10805
10871
|
this.ga = RegExp("\u2008");
|
|
10806
10872
|
this.ka = "";
|
|
10807
|
-
this.$ = new
|
|
10873
|
+
this.$ = new B();
|
|
10808
10874
|
this.ea = "";
|
|
10809
|
-
this.u = new
|
|
10810
|
-
this.da = new
|
|
10875
|
+
this.u = new B();
|
|
10876
|
+
this.da = new B();
|
|
10811
10877
|
this.v = true;
|
|
10812
10878
|
this.fa = this.aa = this.ma = false;
|
|
10813
|
-
this.ha =
|
|
10879
|
+
this.ha = J.g();
|
|
10814
10880
|
this.ba = 0;
|
|
10815
|
-
this.h = new
|
|
10881
|
+
this.h = new B();
|
|
10816
10882
|
this.ia = false;
|
|
10817
10883
|
this.o = "";
|
|
10818
|
-
this.g = new
|
|
10884
|
+
this.g = new B();
|
|
10819
10885
|
this.j = [];
|
|
10820
10886
|
this.la = a;
|
|
10821
10887
|
this.l = kb(this, this.la);
|
|
10822
10888
|
}
|
|
10823
|
-
var lb = new
|
|
10824
|
-
|
|
10889
|
+
var lb = new G();
|
|
10890
|
+
t(lb, 11, "NA");
|
|
10825
10891
|
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 = /[- ]/;
|
|
10826
10892
|
function kb(a, b) {
|
|
10827
10893
|
var c = a.ha;
|
|
10828
|
-
b =
|
|
10829
|
-
a =
|
|
10894
|
+
b = O(b) ? eb(c, b) : 0;
|
|
10895
|
+
a = S(a.ha, R(b));
|
|
10830
10896
|
return a != null ? a : lb;
|
|
10831
10897
|
}
|
|
10832
10898
|
function ob(a) {
|
|
10833
10899
|
for (var b = a.j.length, c = 0; c < b; ++c) {
|
|
10834
|
-
var d = a.j[c], e =
|
|
10900
|
+
var d = a.j[c], e = v(d, 1);
|
|
10835
10901
|
if (a.ea == e) return false;
|
|
10836
10902
|
var f = a;
|
|
10837
|
-
var g = d, h =
|
|
10838
|
-
|
|
10903
|
+
var g = d, h = v(g, 1);
|
|
10904
|
+
C(f.$);
|
|
10839
10905
|
var l = f;
|
|
10840
|
-
g =
|
|
10841
|
-
var
|
|
10842
|
-
|
|
10906
|
+
g = v(g, 2);
|
|
10907
|
+
var A = "999999999999999".match(h)[0];
|
|
10908
|
+
A.length < l.g.h.length ? l = "" : (l = A.replace(new RegExp(h, "g"), g), l = l.replace(RegExp("9", "g"), "\u2008"));
|
|
10843
10909
|
l.length > 0 ? (f.$.g(l), f = true) : f = false;
|
|
10844
|
-
if (f) return a.ea = e, a.ia = nb.test(
|
|
10910
|
+
if (f) return a.ea = e, a.ia = nb.test(r(d, 4)), a.ba = 0, true;
|
|
10845
10911
|
}
|
|
10846
10912
|
return a.v = false;
|
|
10847
10913
|
}
|
|
10848
10914
|
function pb(a, b) {
|
|
10849
10915
|
for (var c = [], d = b.length - 3, e = a.j.length, f = 0; f < e; ++f) {
|
|
10850
10916
|
var g = a.j[f];
|
|
10851
|
-
|
|
10917
|
+
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]));
|
|
10852
10918
|
}
|
|
10853
10919
|
a.j = c;
|
|
10854
10920
|
}
|
|
@@ -10860,7 +10926,7 @@ var _scope = {};
|
|
|
10860
10926
|
if (!a.ma) {
|
|
10861
10927
|
if (rb(a)) {
|
|
10862
10928
|
if (sb(a)) return tb(a);
|
|
10863
|
-
} else if (a.o.length > 0 && (b = a.g.toString(),
|
|
10929
|
+
} 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);
|
|
10864
10930
|
}
|
|
10865
10931
|
return a.u.toString();
|
|
10866
10932
|
}
|
|
@@ -10879,7 +10945,7 @@ var _scope = {};
|
|
|
10879
10945
|
c = xb(a);
|
|
10880
10946
|
if (c.length > 0) return c;
|
|
10881
10947
|
pb(a, a.g.toString());
|
|
10882
|
-
return ob(a) ? yb(a) : a.v ?
|
|
10948
|
+
return ob(a) ? yb(a) : a.v ? Y(a, b) : a.u.toString();
|
|
10883
10949
|
}
|
|
10884
10950
|
return vb(a);
|
|
10885
10951
|
}
|
|
@@ -10889,64 +10955,64 @@ var _scope = {};
|
|
|
10889
10955
|
a.fa = false;
|
|
10890
10956
|
a.j = [];
|
|
10891
10957
|
a.ba = 0;
|
|
10892
|
-
|
|
10958
|
+
C(a.$);
|
|
10893
10959
|
a.ea = "";
|
|
10894
10960
|
return vb(a);
|
|
10895
10961
|
}
|
|
10896
10962
|
function xb(a) {
|
|
10897
10963
|
for (var b = a.g.toString(), c = a.j.length, d = 0; d < c; ++d) {
|
|
10898
|
-
var e = a.j[d], f =
|
|
10899
|
-
if (new RegExp("^(?:" + f + ")$").test(b) && (a.ia = nb.test(
|
|
10964
|
+
var e = a.j[d], f = v(e, 1);
|
|
10965
|
+
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;
|
|
10900
10966
|
}
|
|
10901
10967
|
return "";
|
|
10902
10968
|
}
|
|
10903
|
-
function
|
|
10969
|
+
function Y(a, b) {
|
|
10904
10970
|
var c = a.h.h.length;
|
|
10905
10971
|
return a.ia && c > 0 && a.h.toString().charAt(c - 1) != " " ? a.h + " " + b : a.h + b;
|
|
10906
10972
|
}
|
|
10907
10973
|
function vb(a) {
|
|
10908
10974
|
var b = a.g.toString();
|
|
10909
10975
|
if (b.length >= 3) {
|
|
10910
|
-
for (var c = a.aa && a.o.length == 0 &&
|
|
10976
|
+
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) {
|
|
10911
10977
|
var f = c[e];
|
|
10912
|
-
a.o.length > 0 && Za(
|
|
10978
|
+
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);
|
|
10913
10979
|
}
|
|
10914
10980
|
pb(a, b);
|
|
10915
10981
|
b = xb(a);
|
|
10916
10982
|
return b.length > 0 ? b : ob(a) ? yb(a) : a.u.toString();
|
|
10917
10983
|
}
|
|
10918
|
-
return
|
|
10984
|
+
return Y(a, b);
|
|
10919
10985
|
}
|
|
10920
10986
|
function yb(a) {
|
|
10921
10987
|
var b = a.g.toString(), c = b.length;
|
|
10922
10988
|
if (c > 0) {
|
|
10923
10989
|
for (var d = "", e = 0; e < c; e++) d = wb(a, b.charAt(e));
|
|
10924
|
-
return a.v ?
|
|
10990
|
+
return a.v ? Y(a, d) : a.u.toString();
|
|
10925
10991
|
}
|
|
10926
10992
|
return a.h.toString();
|
|
10927
10993
|
}
|
|
10928
10994
|
function ub(a) {
|
|
10929
10995
|
var b = a.g.toString(), c = 0;
|
|
10930
|
-
if (
|
|
10996
|
+
if (r(a.l, 10) != 1) var d = false;
|
|
10931
10997
|
else d = a.g.toString(), d = d.charAt(0) == "1" && d.charAt(1) != "0" && d.charAt(1) != "1";
|
|
10932
|
-
d ? (c = 1, a.h.g("1").g(" "), a.aa = true) :
|
|
10933
|
-
|
|
10998
|
+
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))));
|
|
10999
|
+
C(a.g);
|
|
10934
11000
|
a.g.g(b.substring(c));
|
|
10935
11001
|
return b.substring(0, c);
|
|
10936
11002
|
}
|
|
10937
11003
|
function rb(a) {
|
|
10938
|
-
var b = a.da.toString(), c = new RegExp("^(?:\\+|" +
|
|
11004
|
+
var b = a.da.toString(), c = new RegExp("^(?:\\+|" + r(a.l, 11) + ")");
|
|
10939
11005
|
c = b.match(c);
|
|
10940
|
-
return c != null && c[0] != null && c[0].length > 0 ? (a.aa = true, c = c[0].length,
|
|
11006
|
+
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;
|
|
10941
11007
|
}
|
|
10942
11008
|
function sb(a) {
|
|
10943
11009
|
if (a.g.h.length == 0) return false;
|
|
10944
|
-
var b = new
|
|
11010
|
+
var b = new B(), c = fb(a.g, b);
|
|
10945
11011
|
if (c == 0) return false;
|
|
10946
|
-
|
|
11012
|
+
C(a.g);
|
|
10947
11013
|
a.g.g(b.toString());
|
|
10948
|
-
b =
|
|
10949
|
-
"001" == b ? a.l =
|
|
11014
|
+
b = R(c);
|
|
11015
|
+
"001" == b ? a.l = S(a.ha, "" + c) : b != a.la && (a.l = kb(a, b));
|
|
10950
11016
|
a.h.g("" + c).g(" ");
|
|
10951
11017
|
a.o = "";
|
|
10952
11018
|
return true;
|
|
@@ -10956,7 +11022,7 @@ var _scope = {};
|
|
|
10956
11022
|
if (c.substring(a.ba).search(a.ga) >= 0) {
|
|
10957
11023
|
var d = c.search(a.ga);
|
|
10958
11024
|
b = c.replace(a.ga, b);
|
|
10959
|
-
|
|
11025
|
+
C(a.$);
|
|
10960
11026
|
a.$.g(b);
|
|
10961
11027
|
a.ba = d;
|
|
10962
11028
|
return b.substring(0, a.ba + 1);
|
|
@@ -10992,8 +11058,8 @@ var _scope = {};
|
|
|
10992
11058
|
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");
|
|
10993
11059
|
return a.concat(b);
|
|
10994
11060
|
};
|
|
10995
|
-
|
|
10996
|
-
|
|
11061
|
+
m("utils", {});
|
|
11062
|
+
m("utils.formatNumberAsYouType", (a, b) => {
|
|
10997
11063
|
try {
|
|
10998
11064
|
const c = a.replace(/[^+0-9]/g, ""), d = new jb(b);
|
|
10999
11065
|
b = "";
|
|
@@ -11003,92 +11069,92 @@ var _scope = {};
|
|
|
11003
11069
|
return a;
|
|
11004
11070
|
}
|
|
11005
11071
|
});
|
|
11006
|
-
|
|
11072
|
+
m("utils.formatNumber", (a, b, c) => {
|
|
11007
11073
|
try {
|
|
11008
|
-
const e =
|
|
11009
|
-
var d =
|
|
11074
|
+
const e = J.g(), f = X(e, a, b);
|
|
11075
|
+
var d = W(e, f, -1);
|
|
11010
11076
|
return d == 0 || d == 4 ? e.format(f, typeof c === "undefined" ? 0 : zb[c]) : a;
|
|
11011
11077
|
} catch {
|
|
11012
11078
|
return a;
|
|
11013
11079
|
}
|
|
11014
11080
|
});
|
|
11015
|
-
|
|
11081
|
+
m("utils.getExampleNumber", (a, b, c) => {
|
|
11016
11082
|
try {
|
|
11017
|
-
const
|
|
11083
|
+
const l = J.g();
|
|
11018
11084
|
a: {
|
|
11019
|
-
var
|
|
11020
|
-
if (
|
|
11021
|
-
var
|
|
11085
|
+
var d = l, e = Z[b];
|
|
11086
|
+
if (O(a)) {
|
|
11087
|
+
var f = T(S(d, a), e);
|
|
11022
11088
|
try {
|
|
11023
|
-
if (
|
|
11024
|
-
var
|
|
11025
|
-
var
|
|
11089
|
+
if (q(f, 6)) {
|
|
11090
|
+
var g = r(f, 6);
|
|
11091
|
+
var h = ib(d, g, a, false);
|
|
11026
11092
|
break a;
|
|
11027
11093
|
}
|
|
11028
|
-
} catch (
|
|
11094
|
+
} catch (A) {
|
|
11029
11095
|
}
|
|
11030
11096
|
}
|
|
11031
|
-
|
|
11097
|
+
h = null;
|
|
11032
11098
|
}
|
|
11033
|
-
return
|
|
11099
|
+
return l.format(h, zb[c]);
|
|
11034
11100
|
} catch {
|
|
11035
11101
|
return "";
|
|
11036
11102
|
}
|
|
11037
11103
|
});
|
|
11038
|
-
|
|
11104
|
+
m("utils.getExtension", (a, b) => {
|
|
11039
11105
|
try {
|
|
11040
|
-
var c =
|
|
11041
|
-
return
|
|
11106
|
+
var c = X(J.g(), a, b);
|
|
11107
|
+
return r(c, 3);
|
|
11042
11108
|
} catch {
|
|
11043
11109
|
return "";
|
|
11044
11110
|
}
|
|
11045
11111
|
});
|
|
11046
|
-
|
|
11112
|
+
m("utils.getNumberType", (a, b) => {
|
|
11047
11113
|
try {
|
|
11048
|
-
const c =
|
|
11114
|
+
const c = J.g(), d = X(c, a, b), e = ab(c, d);
|
|
11049
11115
|
return Bb[e] || null;
|
|
11050
11116
|
} catch {
|
|
11051
11117
|
return null;
|
|
11052
11118
|
}
|
|
11053
11119
|
});
|
|
11054
|
-
|
|
11120
|
+
m("utils.getValidationError", (a, b) => {
|
|
11055
11121
|
if (!b) return "INVALID_COUNTRY_CODE";
|
|
11056
11122
|
try {
|
|
11057
|
-
const c =
|
|
11123
|
+
const c = J.g(), d = X(c, a, b), e = W(c, d, -1);
|
|
11058
11124
|
return Cb[e] || null;
|
|
11059
11125
|
} catch (c) {
|
|
11060
11126
|
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;
|
|
11061
11127
|
}
|
|
11062
11128
|
});
|
|
11063
|
-
|
|
11129
|
+
m("utils.isValidNumber", (a, b, c) => {
|
|
11064
11130
|
try {
|
|
11065
|
-
const d =
|
|
11131
|
+
const d = J.g(), e = X(d, a, b);
|
|
11066
11132
|
if (c) {
|
|
11067
|
-
const
|
|
11068
|
-
|
|
11133
|
+
const f = Db(c);
|
|
11134
|
+
for (let g of f) if (W(d, e, Z[g]) === 0) return true;
|
|
11135
|
+
return false;
|
|
11069
11136
|
}
|
|
11070
|
-
return
|
|
11137
|
+
return W(d, e, -1) === 0;
|
|
11071
11138
|
} catch {
|
|
11072
11139
|
return false;
|
|
11073
11140
|
}
|
|
11074
11141
|
});
|
|
11075
|
-
|
|
11142
|
+
m("utils.isValidNumberPrecise", (a, b, c) => {
|
|
11076
11143
|
try {
|
|
11077
|
-
const d =
|
|
11144
|
+
const d = J.g(), e = X(d, a, b), f = db(d, e);
|
|
11078
11145
|
if (c) {
|
|
11079
|
-
const
|
|
11080
|
-
|
|
11081
|
-
return false;
|
|
11146
|
+
const g = Db(c).map((h) => Z[h]);
|
|
11147
|
+
return f && g.includes(ab(d, e));
|
|
11082
11148
|
}
|
|
11083
|
-
return
|
|
11149
|
+
return f;
|
|
11084
11150
|
} catch {
|
|
11085
11151
|
return false;
|
|
11086
11152
|
}
|
|
11087
11153
|
});
|
|
11088
|
-
|
|
11154
|
+
m("utils.getCoreNumber", (a, b) => {
|
|
11089
11155
|
try {
|
|
11090
|
-
var c =
|
|
11091
|
-
return
|
|
11156
|
+
var c = X(J.g(), a, b);
|
|
11157
|
+
return r(c, 2).toString();
|
|
11092
11158
|
} catch {
|
|
11093
11159
|
return "";
|
|
11094
11160
|
}
|