intl-tel-input 25.14.1 → 26.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -43
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +78 -324
- package/angular/build/IntlTelInputWithUtils.js +78 -324
- package/angular/build/types/intl-tel-input/i18n/ar/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/bg/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/bn/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/bs/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ca/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/cs/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/da/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/de/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ee/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/el/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/en/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/es/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/fa/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/fi/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/fr/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/hi/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/hr/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/hu/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/id/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/index.d.ts +43 -43
- package/angular/build/types/intl-tel-input/i18n/it/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ja/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ko/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/lt/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/mr/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/nl/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/no/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/pl/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/pt/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ro/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ru/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/sk/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/sl/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/sq/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/sr/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/sv/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/te/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/th/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/tr/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +2 -4
- package/angular/build/types/intl-tel-input/i18n/uk/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/ur/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/uz/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/vi/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input/i18n/zh/index.d.ts +3 -6
- package/angular/build/types/intl-tel-input.d.ts +1 -1
- package/angular/build/types/modules/constants.d.ts +1 -1
- package/angular/build/types/modules/core/icons.d.ts +2 -0
- package/angular/build/types/modules/core/options.d.ts +1 -2
- package/angular/build/types/modules/core/ui.d.ts +2 -3
- package/angular/build/types/modules/data/country-data.d.ts +2 -2
- package/angular/build/types/modules/format/formatting.d.ts +2 -2
- package/angular/build/types/modules/types/public-api.d.ts +3 -1
- package/build/css/demo.css +1 -3
- package/build/css/intlTelInput-no-assets.css +1257 -0
- package/build/css/intlTelInput-no-assets.min.css +1 -0
- package/build/css/intlTelInput.css +21 -22
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/i18n/ar/index.js +23 -5
- package/build/js/i18n/bg/index.js +17 -5
- package/build/js/i18n/bn/index.js +17 -5
- package/build/js/i18n/bs/index.js +23 -5
- package/build/js/i18n/ca/index.js +17 -5
- package/build/js/i18n/cs/index.js +20 -5
- package/build/js/i18n/da/index.js +17 -5
- package/build/js/i18n/de/index.js +17 -5
- package/build/js/i18n/ee/index.js +17 -5
- package/build/js/i18n/el/index.js +17 -5
- package/build/js/i18n/en/index.js +18 -5
- package/build/js/i18n/es/index.js +17 -5
- package/build/js/i18n/fa/index.js +17 -5
- package/build/js/i18n/fi/index.js +17 -5
- package/build/js/i18n/fr/index.js +17 -5
- package/build/js/i18n/hi/index.js +17 -5
- package/build/js/i18n/hr/index.js +23 -5
- package/build/js/i18n/hu/index.js +17 -5
- package/build/js/i18n/id/index.js +17 -5
- package/build/js/i18n/index.js +43 -43
- package/build/js/i18n/it/index.js +17 -5
- package/build/js/i18n/ja/index.js +17 -5
- package/build/js/i18n/ko/index.js +17 -5
- package/build/js/i18n/lt/index.js +26 -5
- package/build/js/i18n/mr/index.js +17 -5
- package/build/js/i18n/nl/index.js +17 -5
- package/build/js/i18n/no/index.js +17 -5
- package/build/js/i18n/pl/index.js +21 -5
- package/build/js/i18n/pt/index.js +17 -5
- package/build/js/i18n/ro/index.js +21 -5
- package/build/js/i18n/ru/index.js +23 -5
- package/build/js/i18n/sk/index.js +23 -5
- package/build/js/i18n/sl/index.js +25 -5
- package/build/js/i18n/sq/index.js +18 -5
- package/build/js/i18n/sr/index.js +24 -5
- package/build/js/i18n/sv/index.js +17 -5
- package/build/js/i18n/te/index.js +17 -5
- package/build/js/i18n/th/index.js +17 -5
- package/build/js/i18n/tr/index.js +17 -5
- package/build/js/i18n/uk/index.js +23 -5
- package/build/js/i18n/ur/index.js +17 -5
- package/build/js/i18n/uz/index.js +17 -5
- package/build/js/i18n/vi/index.js +17 -5
- package/build/js/i18n/zh/index.js +17 -5
- package/build/js/intlTelInput.d.ts +118 -677
- package/build/js/intlTelInput.js +79 -329
- package/build/js/intlTelInput.min.js +8 -4
- package/build/js/intlTelInputWithUtils.js +79 -329
- package/build/js/intlTelInputWithUtils.min.js +7 -3
- package/package.json +10 -4
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +78 -328
- package/react/build/IntlTelInput.d.ts +118 -677
- package/react/build/IntlTelInput.js +78 -328
- package/react/build/IntlTelInputWithUtils.cjs +78 -328
- package/react/build/IntlTelInputWithUtils.js +78 -328
- package/svelte/README.md +1 -1
- package/svelte/build/IntlTelInput.mjs +1170 -1413
- package/svelte/build/IntlTelInputWithUtils.mjs +935 -1178
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.vue.d.ts +34 -0
- package/vue/build/IntlTelInputWithUtils.vue.d.ts +34 -0
- package/vue/build/exports/IntlTelInput.d.ts +3 -0
- package/vue/build/exports/IntlTelInput.mjs +66 -0
- package/vue/build/exports/IntlTelInputWithUtils.d.ts +3 -0
- package/vue/build/{IntlTelInputWithUtils.mjs → exports/IntlTelInputWithUtils.mjs} +533 -3866
- package/vue/build/{IntlTelInput.mjs → intl-tel-input-BY4WpieT.mjs} +403 -720
- package/vue/build/intl-tel-input.d.ts +97 -0
- package/vue/build/modules/constants.d.ts +85 -0
- package/vue/build/modules/core/countrySearch.d.ts +17 -0
- package/vue/build/modules/core/icons.d.ts +9 -0
- package/vue/build/modules/core/options.d.ts +3 -0
- package/vue/build/modules/core/ui.d.ts +45 -0
- package/vue/build/modules/data/country-data.d.ts +12 -0
- package/vue/build/modules/data/nanp-regionless.d.ts +2 -0
- package/vue/build/modules/format/caret.d.ts +1 -0
- package/vue/build/modules/format/formatting.d.ts +3 -0
- package/vue/build/modules/types/events.d.ts +9 -0
- package/vue/build/modules/types/public-api.d.ts +79 -0
- package/vue/build/modules/utils/dom.d.ts +6 -0
- package/vue/build/modules/utils/string.d.ts +2 -0
- package/build/js/i18n/ar/countries.js +0 -245
- package/build/js/i18n/ar/interface.js +0 -23
- package/build/js/i18n/bg/countries.js +0 -245
- package/build/js/i18n/bg/interface.js +0 -13
- package/build/js/i18n/bn/countries.js +0 -245
- package/build/js/i18n/bn/interface.js +0 -13
- package/build/js/i18n/bs/countries.js +0 -245
- package/build/js/i18n/bs/interface.js +0 -20
- package/build/js/i18n/ca/countries.js +0 -245
- package/build/js/i18n/ca/interface.js +0 -13
- package/build/js/i18n/cs/countries.js +0 -245
- package/build/js/i18n/cs/interface.js +0 -20
- package/build/js/i18n/da/countries.js +0 -245
- package/build/js/i18n/da/interface.js +0 -13
- package/build/js/i18n/de/countries.js +0 -245
- package/build/js/i18n/de/interface.js +0 -13
- package/build/js/i18n/ee/countries.js +0 -245
- package/build/js/i18n/ee/interface.js +0 -13
- package/build/js/i18n/el/countries.js +0 -245
- package/build/js/i18n/el/interface.js +0 -13
- package/build/js/i18n/en/countries.js +0 -245
- package/build/js/i18n/en/interface.js +0 -14
- package/build/js/i18n/es/countries.js +0 -245
- package/build/js/i18n/es/interface.js +0 -13
- package/build/js/i18n/fa/countries.js +0 -245
- package/build/js/i18n/fa/interface.js +0 -13
- package/build/js/i18n/fi/countries.js +0 -245
- package/build/js/i18n/fi/interface.js +0 -13
- package/build/js/i18n/fr/countries.js +0 -245
- package/build/js/i18n/fr/interface.js +0 -13
- package/build/js/i18n/hi/countries.js +0 -245
- package/build/js/i18n/hi/interface.js +0 -13
- package/build/js/i18n/hr/countries.js +0 -245
- package/build/js/i18n/hr/interface.js +0 -20
- package/build/js/i18n/hu/countries.js +0 -245
- package/build/js/i18n/hu/interface.js +0 -13
- package/build/js/i18n/id/countries.js +0 -245
- package/build/js/i18n/id/interface.js +0 -13
- package/build/js/i18n/it/countries.js +0 -245
- package/build/js/i18n/it/interface.js +0 -13
- package/build/js/i18n/ja/countries.js +0 -245
- package/build/js/i18n/ja/interface.js +0 -13
- package/build/js/i18n/ko/countries.js +0 -245
- package/build/js/i18n/ko/interface.js +0 -13
- package/build/js/i18n/lt/countries.js +0 -245
- package/build/js/i18n/lt/interface.js +0 -26
- package/build/js/i18n/mr/countries.js +0 -245
- package/build/js/i18n/mr/interface.js +0 -13
- package/build/js/i18n/nl/countries.js +0 -245
- package/build/js/i18n/nl/interface.js +0 -13
- package/build/js/i18n/no/countries.js +0 -245
- package/build/js/i18n/no/interface.js +0 -13
- package/build/js/i18n/pl/countries.js +0 -245
- package/build/js/i18n/pl/interface.js +0 -19
- package/build/js/i18n/pt/countries.js +0 -245
- package/build/js/i18n/pt/interface.js +0 -13
- package/build/js/i18n/ro/countries.js +0 -245
- package/build/js/i18n/ro/interface.js +0 -18
- package/build/js/i18n/ru/countries.js +0 -245
- package/build/js/i18n/ru/interface.js +0 -20
- package/build/js/i18n/sk/countries.js +0 -245
- package/build/js/i18n/sk/interface.js +0 -20
- package/build/js/i18n/sl/countries.js +0 -245
- package/build/js/i18n/sl/interface.js +0 -25
- package/build/js/i18n/sq/countries.js +0 -245
- package/build/js/i18n/sq/interface.js +0 -14
- package/build/js/i18n/sr/countries.js +0 -245
- package/build/js/i18n/sr/interface.js +0 -21
- package/build/js/i18n/sv/countries.js +0 -245
- package/build/js/i18n/sv/interface.js +0 -13
- package/build/js/i18n/te/countries.js +0 -245
- package/build/js/i18n/te/interface.js +0 -13
- package/build/js/i18n/th/countries.js +0 -245
- package/build/js/i18n/th/interface.js +0 -13
- package/build/js/i18n/tr/countries.js +0 -245
- package/build/js/i18n/tr/interface.js +0 -13
- package/build/js/i18n/uk/countries.js +0 -245
- package/build/js/i18n/uk/interface.js +0 -20
- package/build/js/i18n/ur/countries.js +0 -245
- package/build/js/i18n/ur/interface.js +0 -13
- package/build/js/i18n/uz/countries.js +0 -245
- package/build/js/i18n/uz/interface.js +0 -13
- package/build/js/i18n/vi/countries.js +0 -245
- package/build/js/i18n/vi/interface.js +0 -13
- package/build/js/i18n/zh/countries.js +0 -245
- package/build/js/i18n/zh/interface.js +0 -13
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const rt = [
|
|
1
|
+
const q = [
|
|
3
2
|
[
|
|
4
3
|
"af",
|
|
5
4
|
// Afghanistan
|
|
@@ -1677,7 +1676,7 @@ const rt = [
|
|
|
1677
1676
|
"0"
|
|
1678
1677
|
]
|
|
1679
1678
|
], A = [];
|
|
1680
|
-
for (const l of
|
|
1679
|
+
for (const l of q)
|
|
1681
1680
|
A.push({
|
|
1682
1681
|
name: "",
|
|
1683
1682
|
// populated in the plugin
|
|
@@ -1695,262 +1694,7 @@ for (const l of rt)
|
|
|
1695
1694
|
dialCodePlus: ""
|
|
1696
1695
|
// populated in the plugin
|
|
1697
1696
|
});
|
|
1698
|
-
const
|
|
1699
|
-
ad: "Andorra",
|
|
1700
|
-
ae: "United Arab Emirates",
|
|
1701
|
-
af: "Afghanistan",
|
|
1702
|
-
ag: "Antigua & Barbuda",
|
|
1703
|
-
ai: "Anguilla",
|
|
1704
|
-
al: "Albania",
|
|
1705
|
-
am: "Armenia",
|
|
1706
|
-
ao: "Angola",
|
|
1707
|
-
ar: "Argentina",
|
|
1708
|
-
as: "American Samoa",
|
|
1709
|
-
at: "Austria",
|
|
1710
|
-
au: "Australia",
|
|
1711
|
-
aw: "Aruba",
|
|
1712
|
-
ax: "Åland Islands",
|
|
1713
|
-
az: "Azerbaijan",
|
|
1714
|
-
ba: "Bosnia & Herzegovina",
|
|
1715
|
-
bb: "Barbados",
|
|
1716
|
-
bd: "Bangladesh",
|
|
1717
|
-
be: "Belgium",
|
|
1718
|
-
bf: "Burkina Faso",
|
|
1719
|
-
bg: "Bulgaria",
|
|
1720
|
-
bh: "Bahrain",
|
|
1721
|
-
bi: "Burundi",
|
|
1722
|
-
bj: "Benin",
|
|
1723
|
-
bl: "St. Barthélemy",
|
|
1724
|
-
bm: "Bermuda",
|
|
1725
|
-
bn: "Brunei",
|
|
1726
|
-
bo: "Bolivia",
|
|
1727
|
-
bq: "Caribbean Netherlands",
|
|
1728
|
-
br: "Brazil",
|
|
1729
|
-
bs: "Bahamas",
|
|
1730
|
-
bt: "Bhutan",
|
|
1731
|
-
bw: "Botswana",
|
|
1732
|
-
by: "Belarus",
|
|
1733
|
-
bz: "Belize",
|
|
1734
|
-
ca: "Canada",
|
|
1735
|
-
cc: "Cocos (Keeling) Islands",
|
|
1736
|
-
cd: "Congo - Kinshasa",
|
|
1737
|
-
cf: "Central African Republic",
|
|
1738
|
-
cg: "Congo - Brazzaville",
|
|
1739
|
-
ch: "Switzerland",
|
|
1740
|
-
ci: "Côte d’Ivoire",
|
|
1741
|
-
ck: "Cook Islands",
|
|
1742
|
-
cl: "Chile",
|
|
1743
|
-
cm: "Cameroon",
|
|
1744
|
-
cn: "China",
|
|
1745
|
-
co: "Colombia",
|
|
1746
|
-
cr: "Costa Rica",
|
|
1747
|
-
cu: "Cuba",
|
|
1748
|
-
cv: "Cape Verde",
|
|
1749
|
-
cw: "Curaçao",
|
|
1750
|
-
cx: "Christmas Island",
|
|
1751
|
-
cy: "Cyprus",
|
|
1752
|
-
cz: "Czechia",
|
|
1753
|
-
de: "Germany",
|
|
1754
|
-
dj: "Djibouti",
|
|
1755
|
-
dk: "Denmark",
|
|
1756
|
-
dm: "Dominica",
|
|
1757
|
-
do: "Dominican Republic",
|
|
1758
|
-
dz: "Algeria",
|
|
1759
|
-
ec: "Ecuador",
|
|
1760
|
-
ee: "Estonia",
|
|
1761
|
-
eg: "Egypt",
|
|
1762
|
-
eh: "Western Sahara",
|
|
1763
|
-
er: "Eritrea",
|
|
1764
|
-
es: "Spain",
|
|
1765
|
-
et: "Ethiopia",
|
|
1766
|
-
fi: "Finland",
|
|
1767
|
-
fj: "Fiji",
|
|
1768
|
-
fk: "Falkland Islands",
|
|
1769
|
-
fm: "Micronesia",
|
|
1770
|
-
fo: "Faroe Islands",
|
|
1771
|
-
fr: "France",
|
|
1772
|
-
ga: "Gabon",
|
|
1773
|
-
gb: "United Kingdom",
|
|
1774
|
-
gd: "Grenada",
|
|
1775
|
-
ge: "Georgia",
|
|
1776
|
-
gf: "French Guiana",
|
|
1777
|
-
gg: "Guernsey",
|
|
1778
|
-
gh: "Ghana",
|
|
1779
|
-
gi: "Gibraltar",
|
|
1780
|
-
gl: "Greenland",
|
|
1781
|
-
gm: "Gambia",
|
|
1782
|
-
gn: "Guinea",
|
|
1783
|
-
gp: "Guadeloupe",
|
|
1784
|
-
gq: "Equatorial Guinea",
|
|
1785
|
-
gr: "Greece",
|
|
1786
|
-
gt: "Guatemala",
|
|
1787
|
-
gu: "Guam",
|
|
1788
|
-
gw: "Guinea-Bissau",
|
|
1789
|
-
gy: "Guyana",
|
|
1790
|
-
hk: "Hong Kong SAR China",
|
|
1791
|
-
hn: "Honduras",
|
|
1792
|
-
hr: "Croatia",
|
|
1793
|
-
ht: "Haiti",
|
|
1794
|
-
hu: "Hungary",
|
|
1795
|
-
id: "Indonesia",
|
|
1796
|
-
ie: "Ireland",
|
|
1797
|
-
il: "Israel",
|
|
1798
|
-
im: "Isle of Man",
|
|
1799
|
-
in: "India",
|
|
1800
|
-
io: "British Indian Ocean Territory",
|
|
1801
|
-
iq: "Iraq",
|
|
1802
|
-
ir: "Iran",
|
|
1803
|
-
is: "Iceland",
|
|
1804
|
-
it: "Italy",
|
|
1805
|
-
je: "Jersey",
|
|
1806
|
-
jm: "Jamaica",
|
|
1807
|
-
jo: "Jordan",
|
|
1808
|
-
jp: "Japan",
|
|
1809
|
-
ke: "Kenya",
|
|
1810
|
-
kg: "Kyrgyzstan",
|
|
1811
|
-
kh: "Cambodia",
|
|
1812
|
-
ki: "Kiribati",
|
|
1813
|
-
km: "Comoros",
|
|
1814
|
-
kn: "St. Kitts & Nevis",
|
|
1815
|
-
kp: "North Korea",
|
|
1816
|
-
kr: "South Korea",
|
|
1817
|
-
kw: "Kuwait",
|
|
1818
|
-
ky: "Cayman Islands",
|
|
1819
|
-
kz: "Kazakhstan",
|
|
1820
|
-
la: "Laos",
|
|
1821
|
-
lb: "Lebanon",
|
|
1822
|
-
lc: "St. Lucia",
|
|
1823
|
-
li: "Liechtenstein",
|
|
1824
|
-
lk: "Sri Lanka",
|
|
1825
|
-
lr: "Liberia",
|
|
1826
|
-
ls: "Lesotho",
|
|
1827
|
-
lt: "Lithuania",
|
|
1828
|
-
lu: "Luxembourg",
|
|
1829
|
-
lv: "Latvia",
|
|
1830
|
-
ly: "Libya",
|
|
1831
|
-
ma: "Morocco",
|
|
1832
|
-
mc: "Monaco",
|
|
1833
|
-
md: "Moldova",
|
|
1834
|
-
me: "Montenegro",
|
|
1835
|
-
mf: "St. Martin",
|
|
1836
|
-
mg: "Madagascar",
|
|
1837
|
-
mh: "Marshall Islands",
|
|
1838
|
-
mk: "North Macedonia",
|
|
1839
|
-
ml: "Mali",
|
|
1840
|
-
mm: "Myanmar (Burma)",
|
|
1841
|
-
mn: "Mongolia",
|
|
1842
|
-
mo: "Macao SAR China",
|
|
1843
|
-
mp: "Northern Mariana Islands",
|
|
1844
|
-
mq: "Martinique",
|
|
1845
|
-
mr: "Mauritania",
|
|
1846
|
-
ms: "Montserrat",
|
|
1847
|
-
mt: "Malta",
|
|
1848
|
-
mu: "Mauritius",
|
|
1849
|
-
mv: "Maldives",
|
|
1850
|
-
mw: "Malawi",
|
|
1851
|
-
mx: "Mexico",
|
|
1852
|
-
my: "Malaysia",
|
|
1853
|
-
mz: "Mozambique",
|
|
1854
|
-
na: "Namibia",
|
|
1855
|
-
nc: "New Caledonia",
|
|
1856
|
-
ne: "Niger",
|
|
1857
|
-
nf: "Norfolk Island",
|
|
1858
|
-
ng: "Nigeria",
|
|
1859
|
-
ni: "Nicaragua",
|
|
1860
|
-
nl: "Netherlands",
|
|
1861
|
-
no: "Norway",
|
|
1862
|
-
np: "Nepal",
|
|
1863
|
-
nr: "Nauru",
|
|
1864
|
-
nu: "Niue",
|
|
1865
|
-
nz: "New Zealand",
|
|
1866
|
-
om: "Oman",
|
|
1867
|
-
pa: "Panama",
|
|
1868
|
-
pe: "Peru",
|
|
1869
|
-
pf: "French Polynesia",
|
|
1870
|
-
pg: "Papua New Guinea",
|
|
1871
|
-
ph: "Philippines",
|
|
1872
|
-
pk: "Pakistan",
|
|
1873
|
-
pl: "Poland",
|
|
1874
|
-
pm: "St. Pierre & Miquelon",
|
|
1875
|
-
pr: "Puerto Rico",
|
|
1876
|
-
ps: "Palestinian Territories",
|
|
1877
|
-
pt: "Portugal",
|
|
1878
|
-
pw: "Palau",
|
|
1879
|
-
py: "Paraguay",
|
|
1880
|
-
qa: "Qatar",
|
|
1881
|
-
re: "Réunion",
|
|
1882
|
-
ro: "Romania",
|
|
1883
|
-
rs: "Serbia",
|
|
1884
|
-
ru: "Russia",
|
|
1885
|
-
rw: "Rwanda",
|
|
1886
|
-
sa: "Saudi Arabia",
|
|
1887
|
-
sb: "Solomon Islands",
|
|
1888
|
-
sc: "Seychelles",
|
|
1889
|
-
sd: "Sudan",
|
|
1890
|
-
se: "Sweden",
|
|
1891
|
-
sg: "Singapore",
|
|
1892
|
-
sh: "St. Helena",
|
|
1893
|
-
si: "Slovenia",
|
|
1894
|
-
sj: "Svalbard & Jan Mayen",
|
|
1895
|
-
sk: "Slovakia",
|
|
1896
|
-
sl: "Sierra Leone",
|
|
1897
|
-
sm: "San Marino",
|
|
1898
|
-
sn: "Senegal",
|
|
1899
|
-
so: "Somalia",
|
|
1900
|
-
sr: "Suriname",
|
|
1901
|
-
ss: "South Sudan",
|
|
1902
|
-
st: "São Tomé & Príncipe",
|
|
1903
|
-
sv: "El Salvador",
|
|
1904
|
-
sx: "Sint Maarten",
|
|
1905
|
-
sy: "Syria",
|
|
1906
|
-
sz: "Eswatini",
|
|
1907
|
-
tc: "Turks & Caicos Islands",
|
|
1908
|
-
td: "Chad",
|
|
1909
|
-
tg: "Togo",
|
|
1910
|
-
th: "Thailand",
|
|
1911
|
-
tj: "Tajikistan",
|
|
1912
|
-
tk: "Tokelau",
|
|
1913
|
-
tl: "Timor-Leste",
|
|
1914
|
-
tm: "Turkmenistan",
|
|
1915
|
-
tn: "Tunisia",
|
|
1916
|
-
to: "Tonga",
|
|
1917
|
-
tr: "Turkey",
|
|
1918
|
-
tt: "Trinidad & Tobago",
|
|
1919
|
-
tv: "Tuvalu",
|
|
1920
|
-
tw: "Taiwan",
|
|
1921
|
-
tz: "Tanzania",
|
|
1922
|
-
ua: "Ukraine",
|
|
1923
|
-
ug: "Uganda",
|
|
1924
|
-
us: "United States",
|
|
1925
|
-
uy: "Uruguay",
|
|
1926
|
-
uz: "Uzbekistan",
|
|
1927
|
-
va: "Vatican City",
|
|
1928
|
-
vc: "St. Vincent & Grenadines",
|
|
1929
|
-
ve: "Venezuela",
|
|
1930
|
-
vg: "British Virgin Islands",
|
|
1931
|
-
vi: "U.S. Virgin Islands",
|
|
1932
|
-
vn: "Vietnam",
|
|
1933
|
-
vu: "Vanuatu",
|
|
1934
|
-
wf: "Wallis & Futuna",
|
|
1935
|
-
ws: "Samoa",
|
|
1936
|
-
ye: "Yemen",
|
|
1937
|
-
yt: "Mayotte",
|
|
1938
|
-
za: "South Africa",
|
|
1939
|
-
zm: "Zambia",
|
|
1940
|
-
zw: "Zimbabwe"
|
|
1941
|
-
}, at = {
|
|
1942
|
-
selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
|
|
1943
|
-
noCountrySelected: "Select country",
|
|
1944
|
-
countryListAriaLabel: "List of countries",
|
|
1945
|
-
searchPlaceholder: "Search",
|
|
1946
|
-
clearSearchAriaLabel: "Clear search",
|
|
1947
|
-
zeroSearchResults: "No results found",
|
|
1948
|
-
oneSearchResult: "1 result found",
|
|
1949
|
-
multipleSearchResults: "${count} results found",
|
|
1950
|
-
// additional countries (not supported by country-list library)
|
|
1951
|
-
ac: "Ascension Island",
|
|
1952
|
-
xk: "Kosovo"
|
|
1953
|
-
}, j = { ...lt, ...at }, T = {
|
|
1697
|
+
const S = {
|
|
1954
1698
|
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
1955
1699
|
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
|
|
1956
1700
|
COUNTRY_CHANGE: "countrychange",
|
|
@@ -1964,17 +1708,17 @@ const lt = {
|
|
|
1964
1708
|
FLAG: "iti__flag",
|
|
1965
1709
|
COUNTRY_ITEM: "iti__country",
|
|
1966
1710
|
HIGHLIGHT: "iti__highlight"
|
|
1967
|
-
},
|
|
1711
|
+
}, y = {
|
|
1968
1712
|
ARROW_UP: "ArrowUp",
|
|
1969
1713
|
ARROW_DOWN: "ArrowDown",
|
|
1970
1714
|
SPACE: " ",
|
|
1971
1715
|
ENTER: "Enter",
|
|
1972
1716
|
ESC: "Escape",
|
|
1973
1717
|
TAB: "Tab"
|
|
1974
|
-
},
|
|
1718
|
+
}, B = {
|
|
1975
1719
|
PASTE: "insertFromPaste",
|
|
1976
1720
|
DELETE_FWD: "deleteContentForward"
|
|
1977
|
-
},
|
|
1721
|
+
}, L = {
|
|
1978
1722
|
ALPHA_UNICODE: new RegExp("\\p{L}", "u"),
|
|
1979
1723
|
// any kind of letter from any language
|
|
1980
1724
|
NON_PLUS_NUMERIC: /[^+0-9]/,
|
|
@@ -1983,39 +1727,39 @@ const lt = {
|
|
|
1983
1727
|
// chars that are NOT + or digit (global)
|
|
1984
1728
|
HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
|
|
1985
1729
|
// single acceptable hidden-search char
|
|
1986
|
-
},
|
|
1730
|
+
}, X = {
|
|
1987
1731
|
HIDDEN_SEARCH_RESET_MS: 1e3
|
|
1988
|
-
},
|
|
1732
|
+
}, F = {
|
|
1989
1733
|
UNKNOWN_NUMBER_TYPE: -99,
|
|
1990
1734
|
UNKNOWN_VALIDATION_ERROR: -99
|
|
1991
|
-
},
|
|
1735
|
+
}, v = {
|
|
1992
1736
|
SANE_SELECTED_WITH_DIAL_WIDTH: 78,
|
|
1993
1737
|
// px width fallback when separateDialCode enabled
|
|
1994
1738
|
SANE_SELECTED_NO_DIAL_WIDTH: 42,
|
|
1995
1739
|
// px width fallback when no separate dial code
|
|
1996
1740
|
INPUT_PADDING_EXTRA_LEFT: 6
|
|
1997
1741
|
// px gap between selected country container and input text
|
|
1998
|
-
},
|
|
1742
|
+
}, j = {
|
|
1999
1743
|
NANP: "1"
|
|
2000
1744
|
// North American Numbering Plan
|
|
2001
|
-
},
|
|
1745
|
+
}, R = {
|
|
2002
1746
|
DIAL_CODE: "44",
|
|
2003
1747
|
// +44 United Kingdom
|
|
2004
1748
|
MOBILE_PREFIX: "7",
|
|
2005
1749
|
// UK mobile numbers start with 7 after national trunk (0) or core section
|
|
2006
1750
|
MOBILE_CORE_LENGTH: 10
|
|
2007
1751
|
// core number length (excluding dial code / national prefix) for mobiles
|
|
2008
|
-
},
|
|
1752
|
+
}, Q = {
|
|
2009
1753
|
ISO2: "us"
|
|
2010
|
-
},
|
|
1754
|
+
}, M = {
|
|
2011
1755
|
AGGRESSIVE: "aggressive",
|
|
2012
1756
|
POLITE: "polite"
|
|
2013
|
-
},
|
|
1757
|
+
}, x = {
|
|
2014
1758
|
AUTO: "auto"
|
|
2015
|
-
},
|
|
1759
|
+
}, V = {
|
|
2016
1760
|
COUNTRY_CODE: "countryCode",
|
|
2017
1761
|
DIAL_CODE: "dialCode"
|
|
2018
|
-
},
|
|
1762
|
+
}, p = {
|
|
2019
1763
|
EXPANDED: "aria-expanded",
|
|
2020
1764
|
LABEL: "aria-label",
|
|
2021
1765
|
SELECTED: "aria-selected",
|
|
@@ -2025,23 +1769,35 @@ const lt = {
|
|
|
2025
1769
|
HIDDEN: "aria-hidden",
|
|
2026
1770
|
AUTOCOMPLETE: "aria-autocomplete",
|
|
2027
1771
|
MODAL: "aria-modal"
|
|
2028
|
-
},
|
|
1772
|
+
}, Z = {
|
|
1773
|
+
selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
|
|
1774
|
+
noCountrySelected: "Select country",
|
|
1775
|
+
countryListAriaLabel: "List of countries",
|
|
1776
|
+
searchPlaceholder: "Search",
|
|
1777
|
+
clearSearchAriaLabel: "Clear search",
|
|
1778
|
+
searchEmptyState: "No results found",
|
|
1779
|
+
searchSummaryAria(l) {
|
|
1780
|
+
return l === 0 ? "No results found" : l === 1 ? "1 result found" : `${l} results found`;
|
|
1781
|
+
}
|
|
1782
|
+
}, U = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, J = () => {
|
|
2029
1783
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
2030
|
-
const l =
|
|
2031
|
-
|
|
2032
|
-
), t = x("(max-width: 500px)"), e = x("(max-height: 600px)"), i = x("(pointer: coarse)");
|
|
2033
|
-
return l || t || i && e;
|
|
1784
|
+
const l = U("(max-width: 500px)"), t = U("(max-height: 600px)"), e = U("(pointer: coarse)");
|
|
1785
|
+
return l || e && t;
|
|
2034
1786
|
}
|
|
2035
1787
|
return !1;
|
|
2036
|
-
},
|
|
2037
|
-
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
2038
|
-
allowPhonewords: !1,
|
|
1788
|
+
}, K = {
|
|
2039
1789
|
//* Whether or not to allow the dropdown.
|
|
2040
1790
|
allowDropdown: !0,
|
|
1791
|
+
//* Whether or not to allow extensions after the main number.
|
|
1792
|
+
allowNumberExtensions: !1,
|
|
1793
|
+
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1794
|
+
allowPhonewords: !1,
|
|
2041
1795
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
2042
|
-
autoPlaceholder:
|
|
1796
|
+
autoPlaceholder: M.POLITE,
|
|
2043
1797
|
//* Modify the parentClass.
|
|
2044
1798
|
containerClass: "",
|
|
1799
|
+
//* Locale for localising country names via Intl.DisplayNames.
|
|
1800
|
+
countryNameLocale: "en",
|
|
2045
1801
|
//* The order of the countries in the dropdown. Defaults to alphabetical.
|
|
2046
1802
|
countryOrder: null,
|
|
2047
1803
|
//* Add a country search input at the top of the dropdown.
|
|
@@ -2081,112 +1837,112 @@ const lt = {
|
|
|
2081
1837
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
2082
1838
|
strictMode: !1,
|
|
2083
1839
|
//* Use full screen popup instead of dropdown for country list.
|
|
2084
|
-
useFullscreenPopup:
|
|
1840
|
+
useFullscreenPopup: J(),
|
|
2085
1841
|
//* The number type to enforce during validation.
|
|
2086
|
-
|
|
2087
|
-
},
|
|
2088
|
-
l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...
|
|
2089
|
-
},
|
|
2090
|
-
const e =
|
|
1842
|
+
allowedNumberTypes: ["MOBILE", "FIXED_LINE"]
|
|
1843
|
+
}, tt = (l) => {
|
|
1844
|
+
l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...Z, ...l.i18n };
|
|
1845
|
+
}, P = (l) => l.replace(/\D/g, ""), Y = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), et = (l, t) => {
|
|
1846
|
+
const e = Y(t), s = [], i = [], o = [], n = [], r = [], a = [];
|
|
2091
1847
|
for (const c of l)
|
|
2092
|
-
c.iso2 === e ?
|
|
2093
|
-
const d = (c,
|
|
1848
|
+
c.iso2 === e ? s.push(c) : c.normalisedName.startsWith(e) ? i.push(c) : c.normalisedName.includes(e) ? o.push(c) : e === c.dialCode || e === c.dialCodePlus ? n.push(c) : c.dialCodePlus.includes(e) ? r.push(c) : c.initials.includes(e) && a.push(c);
|
|
1849
|
+
const d = (c, m) => c.priority - m.priority;
|
|
2094
1850
|
return [
|
|
2095
|
-
...i.sort(d),
|
|
2096
1851
|
...s.sort(d),
|
|
1852
|
+
...i.sort(d),
|
|
2097
1853
|
...o.sort(d),
|
|
2098
1854
|
...n.sort(d),
|
|
2099
1855
|
...r.sort(d),
|
|
2100
1856
|
...a.sort(d)
|
|
2101
1857
|
];
|
|
2102
|
-
},
|
|
1858
|
+
}, st = (l, t) => {
|
|
2103
1859
|
const e = t.toLowerCase();
|
|
2104
|
-
for (const
|
|
2105
|
-
if (
|
|
2106
|
-
return
|
|
1860
|
+
for (const s of l)
|
|
1861
|
+
if (s.name.toLowerCase().startsWith(e))
|
|
1862
|
+
return s;
|
|
2107
1863
|
return null;
|
|
2108
|
-
},
|
|
2109
|
-
const
|
|
1864
|
+
}, H = (l) => Object.keys(l).filter((t) => !!l[t]).join(" "), C = (l, t, e) => {
|
|
1865
|
+
const s = document.createElement(l);
|
|
2110
1866
|
return t && Object.entries(t).forEach(
|
|
2111
|
-
([
|
|
2112
|
-
), e && e.appendChild(
|
|
2113
|
-
},
|
|
2114
|
-
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${
|
|
1867
|
+
([i, o]) => s.setAttribute(i, o)
|
|
1868
|
+
), e && e.appendChild(s), s;
|
|
1869
|
+
}, it = () => `
|
|
1870
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${p.HIDDEN}="true">
|
|
2115
1871
|
<circle cx="11" cy="11" r="7" />
|
|
2116
1872
|
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2117
|
-
</svg>`,
|
|
1873
|
+
</svg>`, nt = (l) => {
|
|
2118
1874
|
const t = `iti-${l}-clear-mask`;
|
|
2119
1875
|
return `
|
|
2120
|
-
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${
|
|
1876
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${p.HIDDEN}="true" focusable="false">
|
|
2121
1877
|
<mask id="${t}" maskUnits="userSpaceOnUse">
|
|
2122
1878
|
<rect width="16" height="16" fill="white" />
|
|
2123
1879
|
<path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
|
|
2124
1880
|
</mask>
|
|
2125
1881
|
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${t})" />
|
|
2126
1882
|
</svg>`;
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
1883
|
+
}, ot = () => `
|
|
1884
|
+
<svg width="256" height="256" viewBox="0 0 512 512" class="iti__globe-svg">
|
|
1885
|
+
<path d="M508 213a240 240 0 0 0-449-87l-2 5-2 5c-8 14-13 30-17 46a65 65 0 0 1 56 4c16-10 35-19 56-27l9-3c-6 23-10 48-10 74h-16l4 6c3 4 5 8 6 13h6c0 22 3 44 8 65l2 10-25-10-4 5 12 18 9 3 6 2 8 3 9 26 1 2 16-7h1l-5-13-1-2c24 6 49 9 75 10v26l11 10 7 7v-30l1-13c22 0 44-3 65-8l10-2-21 48-1 1a317 317 0 0 1-14 23l-21 5h-2c6 16 7 33 1 50a240 240 0 0 0 211-265m-401-56-11 6c19-44 54-79 98-98-11 20-21 44-29 69-21 6-40 15-58 23m154 182v4c-29-1-57-6-81-13-7-25-12-52-13-81h94zm0-109h-94c1-29 6-56 13-81 24-7 52-12 81-13zm0-112c-22 1-44 4-65 8l-10 2 12-30 9-17 1-2a332 332 0 0 1 13-23c13-4 26-6 40-7zm187 69 6 4c4 12 6 25 6 38v1h-68c-1-26-4-51-10-74l48 20 1 1 14 8zm-14-44 10 20c-20-11-43-21-68-29-8-25-18-49-29-69 37 16 67 44 87 78M279 49h1c13 1 27 3 39 7l14 23 1 2a343 343 0 0 1 12 26l2 5 6 16c-23-6-48-9-74-10h-1zm0 87h1c29 1 56 6 81 13 7 24 12 51 12 80v1h-94zm2 207h-2v-94h95c-1 29-6 56-13 81-24 7-51 12-80 13m86 60-20 10c11-20 21-43 29-68 25-8 48-18 68-29-16 37-43 67-77 87m87-115-7 5-16 9-2 1a337 337 0 0 1-47 21c6-24 9-49 10-75h68c0 13-2 27-6 39"/>
|
|
1886
|
+
<path d="m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40"/>
|
|
1887
|
+
</svg>`;
|
|
1888
|
+
class lt {
|
|
1889
|
+
constructor(t, e, s) {
|
|
1890
|
+
this.highlightedItem = null, this.selectedItem = null, t.dataset.intlTelInputId = s.toString(), this.telInput = t, this.options = e, this.id = s, this.hadInitialPlaceholder = !!t.getAttribute("placeholder"), this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.originalPaddingLeft = this.telInput.style.paddingLeft);
|
|
2131
1891
|
}
|
|
2132
1892
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
2133
1893
|
generateMarkup(t) {
|
|
2134
|
-
this.countries = t, this.
|
|
1894
|
+
this.countries = t, this.telInput.classList.add("iti__tel-input");
|
|
2135
1895
|
const e = this._createWrapperAndInsert();
|
|
2136
1896
|
this._maybeBuildCountryContainer(e), e.appendChild(this.telInput), this._maybeUpdateInputPaddingAndReveal(), this._maybeBuildHiddenInputs(e);
|
|
2137
1897
|
}
|
|
2138
|
-
_prepareTelInput() {
|
|
2139
|
-
var t;
|
|
2140
|
-
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !((t = this.telInput.form) != null && t.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
2141
|
-
}
|
|
2142
1898
|
_createWrapperAndInsert() {
|
|
2143
|
-
const { allowDropdown: t, showFlags: e, containerClass:
|
|
1899
|
+
const { allowDropdown: t, showFlags: e, containerClass: s, useFullscreenPopup: i } = this.options, o = H({
|
|
2144
1900
|
iti: !0,
|
|
2145
1901
|
"iti--allow-dropdown": t,
|
|
2146
1902
|
"iti--show-flags": e,
|
|
2147
|
-
"iti--inline-dropdown": !
|
|
2148
|
-
[
|
|
2149
|
-
}), n =
|
|
1903
|
+
"iti--inline-dropdown": !i,
|
|
1904
|
+
[s]: !!s
|
|
1905
|
+
}), n = C("div", { class: o });
|
|
2150
1906
|
return this.isRTL && n.setAttribute("dir", "ltr"), this.telInput.before(n), n;
|
|
2151
1907
|
}
|
|
2152
1908
|
_maybeBuildCountryContainer(t) {
|
|
2153
|
-
const { allowDropdown: e, separateDialCode:
|
|
2154
|
-
if (e ||
|
|
2155
|
-
this.countryContainer =
|
|
1909
|
+
const { allowDropdown: e, separateDialCode: s, showFlags: i } = this.options;
|
|
1910
|
+
if (e || i || s) {
|
|
1911
|
+
this.countryContainer = C(
|
|
2156
1912
|
"div",
|
|
2157
1913
|
// visibly hidden until we measure it's width to set the input padding correctly
|
|
2158
1914
|
{ class: `iti__country-container ${h.V_HIDE}` },
|
|
2159
1915
|
t
|
|
2160
|
-
), e ? (this.selectedCountry =
|
|
1916
|
+
), e ? (this.selectedCountry = C(
|
|
2161
1917
|
"button",
|
|
2162
1918
|
{
|
|
2163
1919
|
type: "button",
|
|
2164
1920
|
class: "iti__selected-country",
|
|
2165
|
-
[
|
|
2166
|
-
[
|
|
2167
|
-
[
|
|
2168
|
-
[
|
|
1921
|
+
[p.EXPANDED]: "false",
|
|
1922
|
+
[p.LABEL]: this.options.i18n.noCountrySelected,
|
|
1923
|
+
[p.HASPOPUP]: "dialog",
|
|
1924
|
+
[p.CONTROLS]: `iti-${this.id}__dropdown-content`
|
|
2169
1925
|
},
|
|
2170
1926
|
this.countryContainer
|
|
2171
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
1927
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = C(
|
|
2172
1928
|
"div",
|
|
2173
1929
|
{ class: "iti__selected-country" },
|
|
2174
1930
|
this.countryContainer
|
|
2175
1931
|
);
|
|
2176
|
-
const o =
|
|
1932
|
+
const o = C(
|
|
2177
1933
|
"div",
|
|
2178
1934
|
{ class: "iti__selected-country-primary" },
|
|
2179
1935
|
this.selectedCountry
|
|
2180
1936
|
);
|
|
2181
|
-
this.selectedCountryInner =
|
|
1937
|
+
this.selectedCountryInner = C(
|
|
2182
1938
|
"div",
|
|
2183
1939
|
{ class: h.FLAG },
|
|
2184
1940
|
o
|
|
2185
|
-
), e && (this.dropdownArrow =
|
|
1941
|
+
), e && (this.dropdownArrow = C(
|
|
2186
1942
|
"div",
|
|
2187
|
-
{ class: "iti__arrow", [
|
|
1943
|
+
{ class: "iti__arrow", [p.HIDDEN]: "true" },
|
|
2188
1944
|
o
|
|
2189
|
-
)),
|
|
1945
|
+
)), s && (this.selectedDialCode = C(
|
|
2190
1946
|
"div",
|
|
2191
1947
|
{ class: "iti__selected-dial-code" },
|
|
2192
1948
|
this.selectedCountry
|
|
@@ -2197,51 +1953,51 @@ class yt {
|
|
|
2197
1953
|
const {
|
|
2198
1954
|
fixDropdownWidth: t,
|
|
2199
1955
|
useFullscreenPopup: e,
|
|
2200
|
-
countrySearch:
|
|
2201
|
-
i18n:
|
|
1956
|
+
countrySearch: s,
|
|
1957
|
+
i18n: i,
|
|
2202
1958
|
dropdownContainer: o,
|
|
2203
1959
|
containerClass: n
|
|
2204
1960
|
} = this.options, r = t ? "" : "iti--flexible-dropdown-width";
|
|
2205
|
-
if (this.dropdownContent =
|
|
1961
|
+
if (this.dropdownContent = C("div", {
|
|
2206
1962
|
id: `iti-${this.id}__dropdown-content`,
|
|
2207
1963
|
class: `iti__dropdown-content ${h.HIDE} ${r}`,
|
|
2208
1964
|
role: "dialog",
|
|
2209
|
-
[
|
|
2210
|
-
}), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"),
|
|
1965
|
+
[p.MODAL]: "true"
|
|
1966
|
+
}), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), s && this._buildSearchUI(), this.countryList = C(
|
|
2211
1967
|
"ul",
|
|
2212
1968
|
{
|
|
2213
1969
|
class: "iti__country-list",
|
|
2214
1970
|
id: `iti-${this.id}__country-listbox`,
|
|
2215
1971
|
role: "listbox",
|
|
2216
|
-
[
|
|
1972
|
+
[p.LABEL]: i.countryListAriaLabel
|
|
2217
1973
|
},
|
|
2218
1974
|
this.dropdownContent
|
|
2219
|
-
), this._appendListItems(),
|
|
2220
|
-
const a =
|
|
1975
|
+
), this._appendListItems(), s && this.updateSearchResultsA11yText(), o) {
|
|
1976
|
+
const a = H({
|
|
2221
1977
|
iti: !0,
|
|
2222
1978
|
"iti--container": !0,
|
|
2223
1979
|
"iti--fullscreen-popup": e,
|
|
2224
1980
|
"iti--inline-dropdown": !e,
|
|
2225
1981
|
[n]: !!n
|
|
2226
1982
|
});
|
|
2227
|
-
this.dropdown =
|
|
1983
|
+
this.dropdown = C("div", { class: a }), this.dropdown.appendChild(this.dropdownContent);
|
|
2228
1984
|
} else
|
|
2229
1985
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
2230
1986
|
}
|
|
2231
1987
|
_buildSearchUI() {
|
|
2232
|
-
const { i18n: t } = this.options, e =
|
|
1988
|
+
const { i18n: t } = this.options, e = C(
|
|
2233
1989
|
"div",
|
|
2234
1990
|
{ class: "iti__search-input-wrapper" },
|
|
2235
1991
|
this.dropdownContent
|
|
2236
1992
|
);
|
|
2237
|
-
this.searchIcon =
|
|
1993
|
+
this.searchIcon = C(
|
|
2238
1994
|
"span",
|
|
2239
1995
|
{
|
|
2240
1996
|
class: "iti__search-icon",
|
|
2241
|
-
[
|
|
1997
|
+
[p.HIDDEN]: "true"
|
|
2242
1998
|
},
|
|
2243
1999
|
e
|
|
2244
|
-
), this.searchIcon.innerHTML =
|
|
2000
|
+
), this.searchIcon.innerHTML = it(), this.searchInput = C(
|
|
2245
2001
|
"input",
|
|
2246
2002
|
{
|
|
2247
2003
|
id: `iti-${this.id}__search-input`,
|
|
@@ -2251,58 +2007,58 @@ class yt {
|
|
|
2251
2007
|
placeholder: t.searchPlaceholder,
|
|
2252
2008
|
// 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
|
|
2253
2009
|
role: "combobox",
|
|
2254
|
-
[
|
|
2255
|
-
[
|
|
2256
|
-
[
|
|
2257
|
-
[
|
|
2010
|
+
[p.EXPANDED]: "true",
|
|
2011
|
+
[p.LABEL]: t.searchPlaceholder,
|
|
2012
|
+
[p.CONTROLS]: `iti-${this.id}__country-listbox`,
|
|
2013
|
+
[p.AUTOCOMPLETE]: "list",
|
|
2258
2014
|
autocomplete: "off"
|
|
2259
2015
|
},
|
|
2260
2016
|
e
|
|
2261
|
-
), this.searchClearButton =
|
|
2017
|
+
), this.searchClearButton = C(
|
|
2262
2018
|
"button",
|
|
2263
2019
|
{
|
|
2264
2020
|
type: "button",
|
|
2265
2021
|
class: `iti__search-clear ${h.HIDE}`,
|
|
2266
|
-
[
|
|
2022
|
+
[p.LABEL]: t.clearSearchAriaLabel,
|
|
2267
2023
|
tabindex: "-1"
|
|
2268
2024
|
},
|
|
2269
2025
|
e
|
|
2270
|
-
), this.searchClearButton.innerHTML =
|
|
2026
|
+
), this.searchClearButton.innerHTML = nt(this.id), this.searchResultsA11yText = C(
|
|
2271
2027
|
"span",
|
|
2272
2028
|
{ class: "iti__a11y-text" },
|
|
2273
2029
|
this.dropdownContent
|
|
2274
|
-
), this.searchNoResults =
|
|
2030
|
+
), this.searchNoResults = C(
|
|
2275
2031
|
"div",
|
|
2276
2032
|
{
|
|
2277
2033
|
class: `iti__no-results ${h.HIDE}`,
|
|
2278
|
-
[
|
|
2034
|
+
[p.HIDDEN]: "true"
|
|
2279
2035
|
// all a11y messaging happens in this.searchResultsA11yText
|
|
2280
2036
|
},
|
|
2281
2037
|
this.dropdownContent
|
|
2282
|
-
), this.searchNoResults.textContent = t.
|
|
2038
|
+
), this.searchNoResults.textContent = t.searchEmptyState;
|
|
2283
2039
|
}
|
|
2284
2040
|
_maybeUpdateInputPaddingAndReveal() {
|
|
2285
2041
|
this.countryContainer && (this.updateInputPadding(), this.countryContainer.classList.remove(h.V_HIDE));
|
|
2286
2042
|
}
|
|
2287
2043
|
_maybeBuildHiddenInputs(t) {
|
|
2288
|
-
var
|
|
2044
|
+
var s, i;
|
|
2289
2045
|
const { hiddenInput: e } = this.options;
|
|
2290
2046
|
if (e) {
|
|
2291
2047
|
const o = this.telInput.getAttribute("name") || "", n = e(o);
|
|
2292
2048
|
if (n.phone) {
|
|
2293
|
-
const r = (
|
|
2049
|
+
const r = (s = this.telInput.form) == null ? void 0 : s.querySelector(
|
|
2294
2050
|
`input[name="${n.phone}"]`
|
|
2295
2051
|
);
|
|
2296
|
-
r ? this.hiddenInput = r : (this.hiddenInput =
|
|
2052
|
+
r ? this.hiddenInput = r : (this.hiddenInput = C("input", {
|
|
2297
2053
|
type: "hidden",
|
|
2298
2054
|
name: n.phone
|
|
2299
2055
|
}), t.appendChild(this.hiddenInput));
|
|
2300
2056
|
}
|
|
2301
2057
|
if (n.country) {
|
|
2302
|
-
const r = (
|
|
2058
|
+
const r = (i = this.telInput.form) == null ? void 0 : i.querySelector(
|
|
2303
2059
|
`input[name="${n.country}"]`
|
|
2304
2060
|
);
|
|
2305
|
-
r ? this.hiddenInputCountry = r : (this.hiddenInputCountry =
|
|
2061
|
+
r ? this.hiddenInputCountry = r : (this.hiddenInputCountry = C("input", {
|
|
2306
2062
|
type: "hidden",
|
|
2307
2063
|
name: n.country
|
|
2308
2064
|
}), t.appendChild(this.hiddenInputCountry));
|
|
@@ -2313,28 +2069,28 @@ class yt {
|
|
|
2313
2069
|
_appendListItems() {
|
|
2314
2070
|
const t = document.createDocumentFragment();
|
|
2315
2071
|
for (let e = 0; e < this.countries.length; e++) {
|
|
2316
|
-
const
|
|
2072
|
+
const s = this.countries[e], i = H({
|
|
2317
2073
|
[h.COUNTRY_ITEM]: !0
|
|
2318
|
-
}), o =
|
|
2319
|
-
id: `iti-${this.id}__item-${
|
|
2320
|
-
class:
|
|
2074
|
+
}), o = C("li", {
|
|
2075
|
+
id: `iti-${this.id}__item-${s.iso2}`,
|
|
2076
|
+
class: i,
|
|
2321
2077
|
tabindex: "-1",
|
|
2322
2078
|
role: "option",
|
|
2323
|
-
[
|
|
2079
|
+
[p.SELECTED]: "false"
|
|
2324
2080
|
});
|
|
2325
|
-
o.dataset.dialCode =
|
|
2326
|
-
const n =
|
|
2327
|
-
n.textContent =
|
|
2328
|
-
const r =
|
|
2329
|
-
this.isRTL && r.setAttribute("dir", "ltr"), r.textContent = `+${
|
|
2081
|
+
o.dataset.dialCode = s.dialCode, o.dataset.countryCode = s.iso2, s.nodeById[this.id] = o, this.options.showFlags && C("div", { class: `${h.FLAG} iti__${s.iso2}` }, o);
|
|
2082
|
+
const n = C("span", { class: "iti__country-name" }, o);
|
|
2083
|
+
n.textContent = s.name;
|
|
2084
|
+
const r = C("span", { class: "iti__dial-code" }, o);
|
|
2085
|
+
this.isRTL && r.setAttribute("dir", "ltr"), r.textContent = `+${s.dialCode}`, t.appendChild(o);
|
|
2330
2086
|
}
|
|
2331
2087
|
this.countryList.appendChild(t);
|
|
2332
2088
|
}
|
|
2333
2089
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2334
2090
|
updateInputPadding() {
|
|
2335
2091
|
if (this.selectedCountry) {
|
|
2336
|
-
const t = this.options.separateDialCode ?
|
|
2337
|
-
this.telInput.style.paddingLeft = `${
|
|
2092
|
+
const t = this.options.separateDialCode ? v.SANE_SELECTED_WITH_DIAL_WIDTH : v.SANE_SELECTED_NO_DIAL_WIDTH, s = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + v.INPUT_PADDING_EXTRA_LEFT;
|
|
2093
|
+
this.telInput.style.paddingLeft = `${s}px`;
|
|
2338
2094
|
}
|
|
2339
2095
|
}
|
|
2340
2096
|
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
@@ -2353,13 +2109,13 @@ class yt {
|
|
|
2353
2109
|
!1
|
|
2354
2110
|
);
|
|
2355
2111
|
e.style.visibility = "hidden", t.appendChild(e);
|
|
2356
|
-
const
|
|
2357
|
-
e.appendChild(
|
|
2358
|
-
const
|
|
2112
|
+
const s = this.countryContainer.cloneNode();
|
|
2113
|
+
e.appendChild(s);
|
|
2114
|
+
const i = this.selectedCountry.cloneNode(
|
|
2359
2115
|
!0
|
|
2360
2116
|
);
|
|
2361
|
-
|
|
2362
|
-
const o =
|
|
2117
|
+
s.appendChild(i);
|
|
2118
|
+
const o = i.offsetWidth;
|
|
2363
2119
|
return t.removeChild(e), o;
|
|
2364
2120
|
}
|
|
2365
2121
|
return 0;
|
|
@@ -2367,46 +2123,42 @@ class yt {
|
|
|
2367
2123
|
//* Update search results text (for a11y).
|
|
2368
2124
|
updateSearchResultsA11yText() {
|
|
2369
2125
|
const { i18n: t } = this.options, e = this.countryList.childElementCount;
|
|
2370
|
-
|
|
2371
|
-
e === 0 ? i = t.zeroSearchResults : t.searchResultsText ? i = t.searchResultsText(e) : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace(
|
|
2372
|
-
"${count}",
|
|
2373
|
-
e.toString()
|
|
2374
|
-
), this.searchResultsA11yText.textContent = i;
|
|
2126
|
+
this.searchResultsA11yText.textContent = t.searchSummaryAria(e);
|
|
2375
2127
|
}
|
|
2376
2128
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2377
2129
|
scrollTo(t) {
|
|
2378
|
-
const e = this.countryList,
|
|
2130
|
+
const e = this.countryList, s = document.documentElement.scrollTop, i = e.offsetHeight, o = e.getBoundingClientRect().top + s, n = o + i, r = t.offsetHeight, a = t.getBoundingClientRect().top + s, d = a + r, c = a - o + e.scrollTop;
|
|
2379
2131
|
if (a < o)
|
|
2380
2132
|
e.scrollTop = c;
|
|
2381
2133
|
else if (d > n) {
|
|
2382
|
-
const
|
|
2383
|
-
e.scrollTop = c -
|
|
2134
|
+
const m = i - r;
|
|
2135
|
+
e.scrollTop = c - m;
|
|
2384
2136
|
}
|
|
2385
2137
|
}
|
|
2386
2138
|
//* Remove highlighting from the previous list item and highlight the new one.
|
|
2387
2139
|
highlightListItem(t, e) {
|
|
2388
|
-
const
|
|
2389
|
-
if (
|
|
2390
|
-
const
|
|
2391
|
-
this.searchInput.setAttribute(
|
|
2140
|
+
const s = this.highlightedItem;
|
|
2141
|
+
if (s && s.classList.remove(h.HIGHLIGHT), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add(h.HIGHLIGHT), this.options.countrySearch)) {
|
|
2142
|
+
const i = this.highlightedItem.getAttribute("id") || "";
|
|
2143
|
+
this.searchInput.setAttribute(p.ACTIVE_DESCENDANT, i);
|
|
2392
2144
|
}
|
|
2393
2145
|
e && this.highlightedItem.focus();
|
|
2394
2146
|
}
|
|
2395
2147
|
updateSelectedItem(t) {
|
|
2396
|
-
if (this.selectedItem && this.selectedItem.dataset.countryCode !== t && (this.selectedItem.setAttribute(
|
|
2148
|
+
if (this.selectedItem && this.selectedItem.dataset.countryCode !== t && (this.selectedItem.setAttribute(p.SELECTED, "false"), this.selectedItem = null), t && !this.selectedItem) {
|
|
2397
2149
|
const e = this.countryList.querySelector(
|
|
2398
2150
|
`[data-country-code="${t}"]`
|
|
2399
2151
|
);
|
|
2400
|
-
e && (e.setAttribute(
|
|
2152
|
+
e && (e.setAttribute(p.SELECTED, "true"), this.selectedItem = e);
|
|
2401
2153
|
}
|
|
2402
2154
|
}
|
|
2403
2155
|
//* Country search: Filter the country list to the given array of countries.
|
|
2404
2156
|
filterCountries(t) {
|
|
2405
2157
|
this.countryList.innerHTML = "";
|
|
2406
2158
|
let e = !0;
|
|
2407
|
-
for (const
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2159
|
+
for (const s of t) {
|
|
2160
|
+
const i = s.nodeById[this.id];
|
|
2161
|
+
i && (this.countryList.appendChild(i), e && (this.highlightListItem(i, !1), e = !1));
|
|
2410
2162
|
}
|
|
2411
2163
|
e ? (this.highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove(h.HIDE)) : this.searchNoResults && this.searchNoResults.classList.add(h.HIDE), this.countryList.scrollTop = 0, this.updateSearchResultsA11yText();
|
|
2412
2164
|
}
|
|
@@ -2419,95 +2171,95 @@ class yt {
|
|
|
2419
2171
|
this.countries = null;
|
|
2420
2172
|
}
|
|
2421
2173
|
}
|
|
2422
|
-
const
|
|
2174
|
+
const rt = (l) => {
|
|
2423
2175
|
const { onlyCountries: t, excludeCountries: e } = l;
|
|
2424
2176
|
if (t.length) {
|
|
2425
|
-
const
|
|
2426
|
-
(
|
|
2177
|
+
const s = t.map(
|
|
2178
|
+
(i) => i.toLowerCase()
|
|
2427
2179
|
);
|
|
2428
2180
|
return A.filter(
|
|
2429
|
-
(
|
|
2181
|
+
(i) => s.includes(i.iso2)
|
|
2430
2182
|
);
|
|
2431
2183
|
} else if (e.length) {
|
|
2432
|
-
const
|
|
2433
|
-
(
|
|
2184
|
+
const s = e.map(
|
|
2185
|
+
(i) => i.toLowerCase()
|
|
2434
2186
|
);
|
|
2435
2187
|
return A.filter(
|
|
2436
|
-
(
|
|
2188
|
+
(i) => !s.includes(i.iso2)
|
|
2437
2189
|
);
|
|
2438
2190
|
}
|
|
2439
2191
|
return A;
|
|
2440
|
-
},
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2192
|
+
}, at = (l, t) => {
|
|
2193
|
+
const { countryNameLocale: e, i18n: s } = t, o = typeof Intl < "u" && typeof Intl.DisplayNames == "function" ? new Intl.DisplayNames(e, {
|
|
2194
|
+
type: "region"
|
|
2195
|
+
}) : null;
|
|
2196
|
+
for (const n of l)
|
|
2197
|
+
n.name = s[n.iso2] || (o == null ? void 0 : o.of(n.iso2.toUpperCase()));
|
|
2198
|
+
}, ut = (l) => {
|
|
2446
2199
|
const t = /* @__PURE__ */ new Set();
|
|
2447
2200
|
let e = 0;
|
|
2448
|
-
const
|
|
2201
|
+
const s = {}, i = (n, r) => {
|
|
2449
2202
|
if (!n || !r)
|
|
2450
2203
|
return;
|
|
2451
|
-
r.length > e && (e = r.length),
|
|
2452
|
-
const a =
|
|
2204
|
+
r.length > e && (e = r.length), s.hasOwnProperty(r) || (s[r] = []);
|
|
2205
|
+
const a = s[r];
|
|
2453
2206
|
a.includes(n) || a.push(n);
|
|
2454
2207
|
}, o = [...l].sort((n, r) => n.priority - r.priority);
|
|
2455
2208
|
for (const n of o) {
|
|
2456
2209
|
t.has(n.dialCode) || t.add(n.dialCode);
|
|
2457
2210
|
for (let r = 1; r < n.dialCode.length; r++) {
|
|
2458
2211
|
const a = n.dialCode.substring(0, r);
|
|
2459
|
-
|
|
2212
|
+
i(n.iso2, a);
|
|
2460
2213
|
}
|
|
2461
|
-
if (
|
|
2462
|
-
const r =
|
|
2214
|
+
if (i(n.iso2, n.dialCode), n.areaCodes) {
|
|
2215
|
+
const r = s[n.dialCode][0];
|
|
2463
2216
|
for (const a of n.areaCodes) {
|
|
2464
2217
|
for (let d = 1; d < a.length; d++) {
|
|
2465
|
-
const c = a.substring(0, d),
|
|
2466
|
-
|
|
2218
|
+
const c = a.substring(0, d), m = n.dialCode + c;
|
|
2219
|
+
i(r, m), i(n.iso2, m);
|
|
2467
2220
|
}
|
|
2468
|
-
|
|
2221
|
+
i(n.iso2, n.dialCode + a);
|
|
2469
2222
|
}
|
|
2470
2223
|
}
|
|
2471
2224
|
}
|
|
2472
|
-
return { dialCodes: t, dialCodeMaxLen: e, dialCodeToIso2Map:
|
|
2473
|
-
},
|
|
2225
|
+
return { dialCodes: t, dialCodeMaxLen: e, dialCodeToIso2Map: s };
|
|
2226
|
+
}, dt = (l, t) => {
|
|
2474
2227
|
t.countryOrder && (t.countryOrder = t.countryOrder.map(
|
|
2475
2228
|
(e) => e.toLowerCase()
|
|
2476
|
-
)), l.sort((e,
|
|
2477
|
-
const { countryOrder:
|
|
2478
|
-
if (
|
|
2479
|
-
const o =
|
|
2229
|
+
)), l.sort((e, s) => {
|
|
2230
|
+
const { countryOrder: i } = t;
|
|
2231
|
+
if (i) {
|
|
2232
|
+
const o = i.indexOf(e.iso2), n = i.indexOf(s.iso2), r = o > -1, a = n > -1;
|
|
2480
2233
|
if (r || a)
|
|
2481
2234
|
return r && a ? o - n : r ? -1 : 1;
|
|
2482
2235
|
}
|
|
2483
|
-
return e.name.localeCompare(
|
|
2236
|
+
return e.name.localeCompare(s.name);
|
|
2484
2237
|
});
|
|
2485
|
-
},
|
|
2238
|
+
}, ct = (l) => {
|
|
2486
2239
|
for (const t of l)
|
|
2487
|
-
t.normalisedName =
|
|
2488
|
-
},
|
|
2489
|
-
let
|
|
2240
|
+
t.normalisedName = Y(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
|
|
2241
|
+
}, $ = (l, t, e, s) => {
|
|
2242
|
+
let i = l;
|
|
2490
2243
|
if (e && t) {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
if (e === 0 && !i)
|
|
2244
|
+
const o = `+${s.dialCode}`, n = i[o.length] === " " || i[o.length] === "-" ? o.length + 1 : o.length;
|
|
2245
|
+
i = i.substring(n);
|
|
2246
|
+
}
|
|
2247
|
+
return i;
|
|
2248
|
+
}, ht = (l, t, e, s, i) => {
|
|
2249
|
+
const o = e ? e.formatNumberAsYouType(l, s.iso2) : l, { dialCode: n } = s;
|
|
2250
|
+
return i && t.charAt(0) !== "+" && o.includes(`+${n}`) ? (o.split(`+${n}`)[1] || "").trim() : o;
|
|
2251
|
+
}, pt = (l, t, e, s) => {
|
|
2252
|
+
if (e === 0 && !s)
|
|
2501
2253
|
return 0;
|
|
2502
|
-
let
|
|
2254
|
+
let i = 0;
|
|
2503
2255
|
for (let o = 0; o < t.length; o++) {
|
|
2504
|
-
if (/[+0-9]/.test(t[o]) &&
|
|
2256
|
+
if (/[+0-9]/.test(t[o]) && i++, i === l && !s)
|
|
2505
2257
|
return o + 1;
|
|
2506
|
-
if (
|
|
2258
|
+
if (s && i === l + 1)
|
|
2507
2259
|
return o;
|
|
2508
2260
|
}
|
|
2509
2261
|
return t.length;
|
|
2510
|
-
},
|
|
2262
|
+
}, Ct = [
|
|
2511
2263
|
"800",
|
|
2512
2264
|
"822",
|
|
2513
2265
|
"833",
|
|
@@ -2525,25 +2277,23 @@ const gt = (l) => {
|
|
|
2525
2277
|
"887",
|
|
2526
2278
|
"888",
|
|
2527
2279
|
"889"
|
|
2528
|
-
],
|
|
2529
|
-
const t =
|
|
2530
|
-
if (t.startsWith(
|
|
2280
|
+
], G = (l) => {
|
|
2281
|
+
const t = P(l);
|
|
2282
|
+
if (t.startsWith(j.NANP) && t.length >= 4) {
|
|
2531
2283
|
const e = t.substring(1, 4);
|
|
2532
|
-
return
|
|
2284
|
+
return Ct.includes(e);
|
|
2533
2285
|
}
|
|
2534
2286
|
return !1;
|
|
2535
2287
|
};
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
const St = new Set(A.map((l) => l.iso2)), B = (l) => St.has(l);
|
|
2540
|
-
class V {
|
|
2288
|
+
let mt = 0;
|
|
2289
|
+
const ft = new Set(A.map((l) => l.iso2)), k = (l) => ft.has(l);
|
|
2290
|
+
class W {
|
|
2541
2291
|
constructor(t, e = {}) {
|
|
2542
|
-
this.id =
|
|
2543
|
-
const { dialCodes:
|
|
2292
|
+
this.id = mt++, this.options = { ...K, ...e }, tt(this.options), this.ui = new lt(t, this.options, this.id), this.isAndroid = W._getIsAndroid(), this.promise = this._createInitPromises(), this.countries = rt(this.options);
|
|
2293
|
+
const { dialCodes: s, dialCodeMaxLen: i, dialCodeToIso2Map: o } = ut(
|
|
2544
2294
|
this.countries
|
|
2545
2295
|
);
|
|
2546
|
-
this.dialCodes =
|
|
2296
|
+
this.dialCodes = s, this.dialCodeMaxLen = i, this.dialCodeToIso2Map = o, this.countryByIso2 = new Map(this.countries.map((n) => [n.iso2, n])), this._init();
|
|
2547
2297
|
}
|
|
2548
2298
|
static _getIsAndroid() {
|
|
2549
2299
|
return typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1;
|
|
@@ -2555,7 +2305,7 @@ class V {
|
|
|
2555
2305
|
if (this.userNumeralSet || this._updateNumeralSet(this.ui.telInput.value), this.userNumeralSet === "ascii")
|
|
2556
2306
|
return t;
|
|
2557
2307
|
const e = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2558
|
-
return t.replace(/[0-9]/g, (
|
|
2308
|
+
return t.replace(/[0-9]/g, (s) => String.fromCharCode(e + Number(s)));
|
|
2559
2309
|
}
|
|
2560
2310
|
// Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
|
|
2561
2311
|
_normaliseNumerals(t) {
|
|
@@ -2563,8 +2313,8 @@ class V {
|
|
|
2563
2313
|
return "";
|
|
2564
2314
|
if (this._updateNumeralSet(t), this.userNumeralSet === "ascii")
|
|
2565
2315
|
return t;
|
|
2566
|
-
const e = this.userNumeralSet === "arabic-indic" ? 1632 : 1776,
|
|
2567
|
-
return t.replace(
|
|
2316
|
+
const e = this.userNumeralSet === "arabic-indic" ? 1632 : 1776, s = this.userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
2317
|
+
return t.replace(s, (i) => String.fromCharCode(48 + (i.charCodeAt(0) - e)));
|
|
2568
2318
|
}
|
|
2569
2319
|
_getTelInputValue() {
|
|
2570
2320
|
const t = this.ui.telInput.value.trim();
|
|
@@ -2574,10 +2324,10 @@ class V {
|
|
|
2574
2324
|
this.ui.telInput.value = this._mapAsciiToUserNumerals(t);
|
|
2575
2325
|
}
|
|
2576
2326
|
_createInitPromises() {
|
|
2577
|
-
const t = new Promise((
|
|
2578
|
-
this.resolveAutoCountryPromise =
|
|
2579
|
-
}), e = new Promise((
|
|
2580
|
-
this.resolveUtilsScriptPromise =
|
|
2327
|
+
const t = new Promise((s, i) => {
|
|
2328
|
+
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = i;
|
|
2329
|
+
}), e = new Promise((s, i) => {
|
|
2330
|
+
this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = i;
|
|
2581
2331
|
});
|
|
2582
2332
|
return Promise.all([t, e]);
|
|
2583
2333
|
}
|
|
@@ -2590,18 +2340,18 @@ class V {
|
|
|
2590
2340
|
//********************
|
|
2591
2341
|
//* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
|
|
2592
2342
|
_processCountryData() {
|
|
2593
|
-
|
|
2343
|
+
at(this.countries, this.options), dt(this.countries, this.options), ct(this.countries);
|
|
2594
2344
|
}
|
|
2595
2345
|
//* Set the initial state of the input value and the selected country by:
|
|
2596
2346
|
//* 1. Extracting a dial code from the given number
|
|
2597
2347
|
//* 2. Using explicit initialCountry
|
|
2598
2348
|
_setInitialState(t = !1) {
|
|
2599
|
-
const e = this.ui.telInput.getAttribute("value"),
|
|
2349
|
+
const e = this.ui.telInput.getAttribute("value"), s = this._normaliseNumerals(e), i = this._getTelInputValue(), n = s && s.startsWith("+") && (!i || !i.startsWith("+")) ? s : i, r = this._getDialCode(n), a = G(n), { initialCountry: d, geoIpLookup: c } = this.options, m = d === x.AUTO && c;
|
|
2600
2350
|
if (r && !a)
|
|
2601
2351
|
this._updateCountryFromNumber(n);
|
|
2602
|
-
else if (!
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2352
|
+
else if (!m || t) {
|
|
2353
|
+
const g = d ? d.toLowerCase() : "";
|
|
2354
|
+
k(g) ? this._setCountry(g) : r && a ? this._setCountry(Q.ISO2) : this._setCountry("");
|
|
2605
2355
|
}
|
|
2606
2356
|
n && this._updateValFromNumber(n);
|
|
2607
2357
|
}
|
|
@@ -2623,16 +2373,16 @@ class V {
|
|
|
2623
2373
|
_initDropdownListeners() {
|
|
2624
2374
|
const t = this.abortController.signal, e = (n) => {
|
|
2625
2375
|
this.ui.dropdownContent.classList.contains(h.HIDE) ? this.ui.telInput.focus() : n.preventDefault();
|
|
2626
|
-
},
|
|
2627
|
-
|
|
2628
|
-
const
|
|
2376
|
+
}, s = this.ui.telInput.closest("label");
|
|
2377
|
+
s && s.addEventListener("click", e, { signal: t });
|
|
2378
|
+
const i = () => {
|
|
2629
2379
|
this.ui.dropdownContent.classList.contains(
|
|
2630
2380
|
h.HIDE
|
|
2631
2381
|
) && !this.ui.telInput.disabled && !this.ui.telInput.readOnly && this._openDropdown();
|
|
2632
2382
|
};
|
|
2633
2383
|
this.ui.selectedCountry.addEventListener(
|
|
2634
2384
|
"click",
|
|
2635
|
-
|
|
2385
|
+
i,
|
|
2636
2386
|
{
|
|
2637
2387
|
signal: t
|
|
2638
2388
|
}
|
|
@@ -2640,7 +2390,7 @@ class V {
|
|
|
2640
2390
|
const o = (n) => {
|
|
2641
2391
|
this.ui.dropdownContent.classList.contains(
|
|
2642
2392
|
h.HIDE
|
|
2643
|
-
) && [
|
|
2393
|
+
) && [y.ARROW_UP, y.ARROW_DOWN, y.SPACE, y.ENTER].includes(n.key) && (n.preventDefault(), n.stopPropagation(), this._openDropdown()), n.key === y.TAB && this._closeDropdown();
|
|
2644
2394
|
};
|
|
2645
2395
|
this.ui.countryContainer.addEventListener(
|
|
2646
2396
|
"keydown",
|
|
@@ -2650,7 +2400,7 @@ class V {
|
|
|
2650
2400
|
}
|
|
2651
2401
|
//* Init many requests: utils script / geo ip lookup.
|
|
2652
2402
|
_initRequests() {
|
|
2653
|
-
const { loadUtils: t, initialCountry: e, geoIpLookup:
|
|
2403
|
+
const { loadUtils: t, initialCountry: e, geoIpLookup: s } = this.options;
|
|
2654
2404
|
if (t && !u.utils) {
|
|
2655
2405
|
const o = () => {
|
|
2656
2406
|
var n;
|
|
@@ -2669,17 +2419,17 @@ class V {
|
|
|
2669
2419
|
}
|
|
2670
2420
|
} else
|
|
2671
2421
|
this.resolveUtilsScriptPromise();
|
|
2672
|
-
e ===
|
|
2422
|
+
e === x.AUTO && s && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
2673
2423
|
}
|
|
2674
2424
|
//* Perform the geo ip lookup.
|
|
2675
2425
|
_loadAutoCountry() {
|
|
2676
2426
|
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
2677
2427
|
(t = "") => {
|
|
2678
2428
|
const e = t.toLowerCase();
|
|
2679
|
-
|
|
2429
|
+
k(e) ? (u.autoCountry = e, setTimeout(() => T("handleAutoCountry"))) : (this._setInitialState(!0), T("rejectAutoCountryPromise"));
|
|
2680
2430
|
},
|
|
2681
2431
|
() => {
|
|
2682
|
-
this._setInitialState(!0),
|
|
2432
|
+
this._setInitialState(!0), T("rejectAutoCountryPromise");
|
|
2683
2433
|
}
|
|
2684
2434
|
));
|
|
2685
2435
|
}
|
|
@@ -2694,43 +2444,47 @@ class V {
|
|
|
2694
2444
|
const {
|
|
2695
2445
|
strictMode: t,
|
|
2696
2446
|
formatAsYouType: e,
|
|
2697
|
-
separateDialCode:
|
|
2698
|
-
allowDropdown:
|
|
2447
|
+
separateDialCode: s,
|
|
2448
|
+
allowDropdown: i,
|
|
2699
2449
|
countrySearch: o
|
|
2700
2450
|
} = this.options;
|
|
2701
2451
|
let n = !1;
|
|
2702
|
-
|
|
2452
|
+
L.ALPHA_UNICODE.test(this._getTelInputValue()) && (n = !0);
|
|
2703
2453
|
const r = (a) => {
|
|
2704
2454
|
const d = this._getTelInputValue();
|
|
2705
|
-
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" &&
|
|
2706
|
-
const
|
|
2707
|
-
this._setTelInputValue(
|
|
2455
|
+
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && s && i && o) {
|
|
2456
|
+
const _ = this.ui.telInput.selectionStart || 0, N = d.substring(0, _ - 1), I = d.substring(_);
|
|
2457
|
+
this._setTelInputValue(N + I), this._openDropdownWithPlus();
|
|
2708
2458
|
return;
|
|
2709
2459
|
}
|
|
2710
2460
|
this._updateCountryFromNumber(d) && this._triggerCountryChange();
|
|
2711
|
-
const c = (a == null ? void 0 : a.data) &&
|
|
2712
|
-
c ||
|
|
2713
|
-
const
|
|
2714
|
-
if (e && !n && !
|
|
2715
|
-
const
|
|
2461
|
+
const c = (a == null ? void 0 : a.data) && L.NON_PLUS_NUMERIC.test(a.data), m = (a == null ? void 0 : a.inputType) === B.PASTE && d;
|
|
2462
|
+
c || m && !t ? n = !0 : L.NON_PLUS_NUMERIC.test(d) || (n = !1);
|
|
2463
|
+
const g = (a == null ? void 0 : a.detail) && a.detail.isSetNumber, E = this.userNumeralSet === "ascii";
|
|
2464
|
+
if (e && !n && !g && E) {
|
|
2465
|
+
const _ = this.ui.telInput.selectionStart || 0, I = d.substring(
|
|
2716
2466
|
0,
|
|
2717
|
-
|
|
2467
|
+
_
|
|
2718
2468
|
).replace(
|
|
2719
|
-
|
|
2469
|
+
L.NON_PLUS_NUMERIC_GLOBAL,
|
|
2720
2470
|
""
|
|
2721
|
-
).length, D = (a == null ? void 0 : a.inputType) ===
|
|
2722
|
-
|
|
2471
|
+
).length, D = (a == null ? void 0 : a.inputType) === B.DELETE_FWD, f = this._getFullNumber(), w = ht(
|
|
2472
|
+
f,
|
|
2723
2473
|
d,
|
|
2724
2474
|
u.utils,
|
|
2725
2475
|
this.selectedCountryData,
|
|
2726
|
-
|
|
2727
|
-
),
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2476
|
+
s
|
|
2477
|
+
), b = pt(
|
|
2478
|
+
I,
|
|
2479
|
+
w,
|
|
2480
|
+
_,
|
|
2731
2481
|
D
|
|
2732
2482
|
);
|
|
2733
|
-
this._setTelInputValue(
|
|
2483
|
+
this._setTelInputValue(w), this.ui.telInput.setSelectionRange(b, b);
|
|
2484
|
+
}
|
|
2485
|
+
if (s && d.startsWith("+") && this.selectedCountryData.dialCode) {
|
|
2486
|
+
const _ = $(d, !0, s, this.selectedCountryData);
|
|
2487
|
+
this._setTelInputValue(_);
|
|
2734
2488
|
}
|
|
2735
2489
|
};
|
|
2736
2490
|
this.ui.telInput.addEventListener(
|
|
@@ -2742,20 +2496,20 @@ class V {
|
|
|
2742
2496
|
);
|
|
2743
2497
|
}
|
|
2744
2498
|
_maybeBindKeydownListener() {
|
|
2745
|
-
const { strictMode: t, separateDialCode: e, allowDropdown:
|
|
2499
|
+
const { strictMode: t, separateDialCode: e, allowDropdown: s, countrySearch: i } = this.options;
|
|
2746
2500
|
if (t || e) {
|
|
2747
2501
|
const o = (n) => {
|
|
2748
2502
|
if (n.key && n.key.length === 1 && !n.altKey && !n.ctrlKey && !n.metaKey) {
|
|
2749
|
-
if (e &&
|
|
2503
|
+
if (e && s && i && n.key === "+") {
|
|
2750
2504
|
n.preventDefault(), this._openDropdownWithPlus();
|
|
2751
2505
|
return;
|
|
2752
2506
|
}
|
|
2753
2507
|
if (t) {
|
|
2754
|
-
const r = this._getTelInputValue(), d = !r.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = this._normaliseNumerals(n.key),
|
|
2755
|
-
|
|
2508
|
+
const r = this._getTelInputValue(), d = !r.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = this._normaliseNumerals(n.key), m = /^[0-9]$/.test(c), g = e ? m : d || m, E = this.ui.telInput, _ = E.selectionStart, N = E.selectionEnd, I = r.slice(0, _), D = r.slice(N), f = I + n.key + D, w = this._getFullNumber(f), b = u.utils.getCoreNumber(
|
|
2509
|
+
w,
|
|
2756
2510
|
this.selectedCountryData.iso2
|
|
2757
|
-
),
|
|
2758
|
-
(!
|
|
2511
|
+
), O = this.maxCoreNumberLength && b.length > this.maxCoreNumberLength, z = this._getNewCountryFromNumber(w) !== null;
|
|
2512
|
+
(!g || O && !z && !d) && n.preventDefault();
|
|
2759
2513
|
}
|
|
2760
2514
|
}
|
|
2761
2515
|
};
|
|
@@ -2768,24 +2522,24 @@ class V {
|
|
|
2768
2522
|
if (this.options.strictMode) {
|
|
2769
2523
|
const t = (e) => {
|
|
2770
2524
|
e.preventDefault();
|
|
2771
|
-
const
|
|
2772
|
-
let
|
|
2773
|
-
if (
|
|
2774
|
-
let
|
|
2775
|
-
for (;
|
|
2776
|
-
|
|
2777
|
-
if (!
|
|
2525
|
+
const s = this.ui.telInput, i = s.selectionStart, o = s.selectionEnd, n = this._getTelInputValue(), r = n.slice(0, i), a = n.slice(o), d = this.selectedCountryData.iso2, c = e.clipboardData.getData("text"), m = this._normaliseNumerals(c), g = i === 0 && o > 0, E = !n.startsWith("+") || g, _ = m.replace(L.NON_PLUS_NUMERIC_GLOBAL, ""), N = _.startsWith("+"), I = _.replace(/\+/g, ""), D = N && E ? `+${I}` : I;
|
|
2526
|
+
let f = r + D + a;
|
|
2527
|
+
if (f.length > 5) {
|
|
2528
|
+
let b = u.utils.getCoreNumber(f, d);
|
|
2529
|
+
for (; b.length === 0 && f.length > 0; )
|
|
2530
|
+
f = f.slice(0, -1), b = u.utils.getCoreNumber(f, d);
|
|
2531
|
+
if (!b)
|
|
2778
2532
|
return;
|
|
2779
|
-
if (this.maxCoreNumberLength &&
|
|
2780
|
-
if (
|
|
2781
|
-
const
|
|
2782
|
-
|
|
2533
|
+
if (this.maxCoreNumberLength && b.length > this.maxCoreNumberLength)
|
|
2534
|
+
if (s.selectionEnd === n.length) {
|
|
2535
|
+
const O = b.length - this.maxCoreNumberLength;
|
|
2536
|
+
f = f.slice(0, f.length - O);
|
|
2783
2537
|
} else
|
|
2784
2538
|
return;
|
|
2785
2539
|
}
|
|
2786
|
-
this._setTelInputValue(
|
|
2787
|
-
const
|
|
2788
|
-
|
|
2540
|
+
this._setTelInputValue(f);
|
|
2541
|
+
const w = i + D.length;
|
|
2542
|
+
s.setSelectionRange(w, w), s.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
|
|
2789
2543
|
};
|
|
2790
2544
|
this.ui.telInput.addEventListener("paste", t, {
|
|
2791
2545
|
signal: this.abortController.signal
|
|
@@ -2799,21 +2553,21 @@ class V {
|
|
|
2799
2553
|
}
|
|
2800
2554
|
//* Trigger a custom event on the input (typed via ItiEventMap).
|
|
2801
2555
|
_trigger(t, e = {}) {
|
|
2802
|
-
const
|
|
2556
|
+
const s = new CustomEvent(t, {
|
|
2803
2557
|
bubbles: !0,
|
|
2804
2558
|
cancelable: !0,
|
|
2805
2559
|
detail: e
|
|
2806
2560
|
});
|
|
2807
|
-
this.ui.telInput.dispatchEvent(
|
|
2561
|
+
this.ui.telInput.dispatchEvent(s);
|
|
2808
2562
|
}
|
|
2809
2563
|
//* Open the dropdown.
|
|
2810
2564
|
_openDropdown() {
|
|
2811
2565
|
const { fixDropdownWidth: t, countrySearch: e } = this.options;
|
|
2812
|
-
if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove(h.HIDE), this.ui.selectedCountry.setAttribute(
|
|
2813
|
-
const
|
|
2814
|
-
|
|
2566
|
+
if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove(h.HIDE), this.ui.selectedCountry.setAttribute(p.EXPANDED, "true"), this._setDropdownPosition(), e) {
|
|
2567
|
+
const s = this.ui.countryList.firstElementChild;
|
|
2568
|
+
s && (this.ui.highlightListItem(s, !1), this.ui.countryList.scrollTop = 0), this.ui.searchInput.focus();
|
|
2815
2569
|
}
|
|
2816
|
-
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(
|
|
2570
|
+
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(S.OPEN_COUNTRY_DROPDOWN);
|
|
2817
2571
|
}
|
|
2818
2572
|
//* Set the dropdown position
|
|
2819
2573
|
_setDropdownPosition() {
|
|
@@ -2821,8 +2575,8 @@ class V {
|
|
|
2821
2575
|
const t = this.ui.telInput.getBoundingClientRect(), e = this.ui.telInput.offsetHeight;
|
|
2822
2576
|
if (this.options.dropdownContainer) {
|
|
2823
2577
|
this.ui.dropdown.style.top = `${t.top + e}px`, this.ui.dropdown.style.left = `${t.left}px`;
|
|
2824
|
-
const
|
|
2825
|
-
window.addEventListener("scroll",
|
|
2578
|
+
const s = () => this._closeDropdown();
|
|
2579
|
+
window.addEventListener("scroll", s, {
|
|
2826
2580
|
signal: this.dropdownAbortController.signal
|
|
2827
2581
|
});
|
|
2828
2582
|
}
|
|
@@ -2836,12 +2590,12 @@ class V {
|
|
|
2836
2590
|
//* When mouse over a list item, just highlight that one
|
|
2837
2591
|
//* we add the class "highlight", so if they hit "enter" we know which one to select.
|
|
2838
2592
|
_bindDropdownMouseoverListener(t) {
|
|
2839
|
-
const e = (
|
|
2593
|
+
const e = (s) => {
|
|
2840
2594
|
var o;
|
|
2841
|
-
const
|
|
2595
|
+
const i = (o = s.target) == null ? void 0 : o.closest(
|
|
2842
2596
|
`.${h.COUNTRY_ITEM}`
|
|
2843
2597
|
);
|
|
2844
|
-
|
|
2598
|
+
i && this.ui.highlightListItem(i, !1);
|
|
2845
2599
|
};
|
|
2846
2600
|
this.ui.countryList.addEventListener(
|
|
2847
2601
|
"mouseover",
|
|
@@ -2853,12 +2607,12 @@ class V {
|
|
|
2853
2607
|
}
|
|
2854
2608
|
//* Listen for country selection.
|
|
2855
2609
|
_bindDropdownCountryClickListener(t) {
|
|
2856
|
-
const e = (
|
|
2610
|
+
const e = (s) => {
|
|
2857
2611
|
var o;
|
|
2858
|
-
const
|
|
2612
|
+
const i = (o = s.target) == null ? void 0 : o.closest(
|
|
2859
2613
|
`.${h.COUNTRY_ITEM}`
|
|
2860
2614
|
);
|
|
2861
|
-
|
|
2615
|
+
i && this._selectListItem(i);
|
|
2862
2616
|
};
|
|
2863
2617
|
this.ui.countryList.addEventListener("click", e, {
|
|
2864
2618
|
signal: t
|
|
@@ -2867,8 +2621,8 @@ class V {
|
|
|
2867
2621
|
//* Click off to close (except when this initial opening click is bubbling up).
|
|
2868
2622
|
//* We cannot just stopPropagation as it may be needed to close another instance.
|
|
2869
2623
|
_bindDropdownClickOffListener(t) {
|
|
2870
|
-
const e = (
|
|
2871
|
-
!!
|
|
2624
|
+
const e = (s) => {
|
|
2625
|
+
!!s.target.closest(
|
|
2872
2626
|
`#iti-${this.id}__dropdown-content`
|
|
2873
2627
|
) || this._closeDropdown();
|
|
2874
2628
|
};
|
|
@@ -2885,18 +2639,18 @@ class V {
|
|
|
2885
2639
|
//* just hit down and hold it to scroll down (no keyup event).
|
|
2886
2640
|
//* Listen on the document because that's where key events are triggered if no input has focus.
|
|
2887
2641
|
_bindDropdownKeydownListener(t) {
|
|
2888
|
-
let e = "",
|
|
2889
|
-
const
|
|
2642
|
+
let e = "", s = null;
|
|
2643
|
+
const i = (o) => {
|
|
2890
2644
|
[
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key ===
|
|
2645
|
+
y.ARROW_UP,
|
|
2646
|
+
y.ARROW_DOWN,
|
|
2647
|
+
y.ENTER,
|
|
2648
|
+
y.ESC
|
|
2649
|
+
].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key === y.ARROW_UP || o.key === y.ARROW_DOWN ? this._handleUpDownKey(o.key) : o.key === y.ENTER ? this._handleEnterKey() : o.key === y.ESC && (this._closeDropdown(), this.ui.selectedCountry.focus())), !this.options.countrySearch && L.HIDDEN_SEARCH_CHAR.test(o.key) && (o.stopPropagation(), s && clearTimeout(s), e += o.key.toLowerCase(), this._searchForCountry(e), s = setTimeout(() => {
|
|
2896
2650
|
e = "";
|
|
2897
|
-
},
|
|
2651
|
+
}, X.HIDDEN_SEARCH_RESET_MS));
|
|
2898
2652
|
};
|
|
2899
|
-
document.addEventListener("keydown",
|
|
2653
|
+
document.addEventListener("keydown", i, { signal: t });
|
|
2900
2654
|
}
|
|
2901
2655
|
//* Search input listeners when countrySearch enabled.
|
|
2902
2656
|
_bindDropdownSearchListeners(t) {
|
|
@@ -2904,13 +2658,13 @@ class V {
|
|
|
2904
2658
|
const n = this.ui.searchInput.value.trim();
|
|
2905
2659
|
this._filterCountriesByQuery(n), this.ui.searchInput.value ? this.ui.searchClearButton.classList.remove(h.HIDE) : this.ui.searchClearButton.classList.add(h.HIDE);
|
|
2906
2660
|
};
|
|
2907
|
-
let
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2910
|
-
e(),
|
|
2661
|
+
let s = null;
|
|
2662
|
+
const i = () => {
|
|
2663
|
+
s && clearTimeout(s), s = setTimeout(() => {
|
|
2664
|
+
e(), s = null;
|
|
2911
2665
|
}, 100);
|
|
2912
2666
|
};
|
|
2913
|
-
this.ui.searchInput.addEventListener("input",
|
|
2667
|
+
this.ui.searchInput.addEventListener("input", i, {
|
|
2914
2668
|
signal: t
|
|
2915
2669
|
});
|
|
2916
2670
|
const o = () => {
|
|
@@ -2922,22 +2676,22 @@ class V {
|
|
|
2922
2676
|
}
|
|
2923
2677
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2924
2678
|
_searchForCountry(t) {
|
|
2925
|
-
const e =
|
|
2679
|
+
const e = st(this.countries, t);
|
|
2926
2680
|
if (e) {
|
|
2927
|
-
const
|
|
2928
|
-
this.ui.highlightListItem(
|
|
2681
|
+
const s = e.nodeById[this.id];
|
|
2682
|
+
this.ui.highlightListItem(s, !1), this.ui.scrollTo(s);
|
|
2929
2683
|
}
|
|
2930
2684
|
}
|
|
2931
2685
|
//* Country search: Filter the countries according to the search query.
|
|
2932
2686
|
_filterCountriesByQuery(t) {
|
|
2933
2687
|
let e;
|
|
2934
|
-
t === "" ? e = this.countries : e =
|
|
2688
|
+
t === "" ? e = this.countries : e = et(this.countries, t), this.ui.filterCountries(e);
|
|
2935
2689
|
}
|
|
2936
2690
|
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2937
2691
|
_handleUpDownKey(t) {
|
|
2938
|
-
var
|
|
2939
|
-
let e = t ===
|
|
2940
|
-
!e && this.ui.countryList.childElementCount > 1 && (e = t ===
|
|
2692
|
+
var s, i;
|
|
2693
|
+
let e = t === y.ARROW_UP ? (s = this.ui.highlightedItem) == null ? void 0 : s.previousElementSibling : (i = this.ui.highlightedItem) == null ? void 0 : i.nextElementSibling;
|
|
2694
|
+
!e && this.ui.countryList.childElementCount > 1 && (e = t === y.ARROW_UP ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild), e && (this.ui.scrollTo(e), this.ui.highlightListItem(e, !1));
|
|
2941
2695
|
}
|
|
2942
2696
|
//* Select the currently highlighted item.
|
|
2943
2697
|
_handleEnterKey() {
|
|
@@ -2948,7 +2702,7 @@ class V {
|
|
|
2948
2702
|
_updateValFromNumber(t) {
|
|
2949
2703
|
let e = t;
|
|
2950
2704
|
if (this.options.formatOnDisplay && u.utils && this.selectedCountryData) {
|
|
2951
|
-
const
|
|
2705
|
+
const s = this.options.nationalMode || !e.startsWith("+") && !this.options.separateDialCode, { NATIONAL: i, INTERNATIONAL: o } = u.utils.numberFormat, n = s ? i : o;
|
|
2952
2706
|
e = u.utils.formatNumber(
|
|
2953
2707
|
e,
|
|
2954
2708
|
this.selectedCountryData.iso2,
|
|
@@ -2965,10 +2719,10 @@ class V {
|
|
|
2965
2719
|
}
|
|
2966
2720
|
// if there is a selected country, and the number doesn't start with a dial code, then add it
|
|
2967
2721
|
_ensureHasDialCode(t) {
|
|
2968
|
-
const { dialCode: e, nationalPrefix:
|
|
2722
|
+
const { dialCode: e, nationalPrefix: s } = this.selectedCountryData;
|
|
2969
2723
|
if (t.startsWith("+") || !e)
|
|
2970
2724
|
return t;
|
|
2971
|
-
const n =
|
|
2725
|
+
const n = s && t.startsWith(s) && !this.options.separateDialCode ? t.substring(1) : t;
|
|
2972
2726
|
return `+${e}${n}`;
|
|
2973
2727
|
}
|
|
2974
2728
|
// Get the country ISO2 code from the given number
|
|
@@ -2976,50 +2730,50 @@ class V {
|
|
|
2976
2730
|
// NOTE: consider refactoring this to be more clear
|
|
2977
2731
|
_getNewCountryFromNumber(t) {
|
|
2978
2732
|
const e = t.indexOf("+");
|
|
2979
|
-
let
|
|
2980
|
-
const
|
|
2981
|
-
|
|
2982
|
-
const n = this._getDialCode(
|
|
2733
|
+
let s = e ? t.substring(e) : t;
|
|
2734
|
+
const i = this.selectedCountryData.iso2, o = this.selectedCountryData.dialCode;
|
|
2735
|
+
s = this._ensureHasDialCode(s);
|
|
2736
|
+
const n = this._getDialCode(s, !0), r = P(s);
|
|
2983
2737
|
if (n) {
|
|
2984
|
-
const a =
|
|
2738
|
+
const a = P(n), d = this.dialCodeToIso2Map[a];
|
|
2985
2739
|
if (d.length === 1)
|
|
2986
|
-
return d[0] ===
|
|
2987
|
-
if (!
|
|
2740
|
+
return d[0] === i ? null : d[0];
|
|
2741
|
+
if (!i && this.defaultCountry && d.includes(this.defaultCountry))
|
|
2988
2742
|
return this.defaultCountry;
|
|
2989
|
-
if (o ===
|
|
2743
|
+
if (o === j.NANP && G(r))
|
|
2990
2744
|
return null;
|
|
2991
|
-
const { areaCodes:
|
|
2992
|
-
if (
|
|
2993
|
-
const D =
|
|
2994
|
-
(
|
|
2745
|
+
const { areaCodes: m, priority: g } = this.selectedCountryData;
|
|
2746
|
+
if (m) {
|
|
2747
|
+
const D = m.map(
|
|
2748
|
+
(f) => `${o}${f}`
|
|
2995
2749
|
);
|
|
2996
|
-
for (const
|
|
2997
|
-
if (r.startsWith(
|
|
2750
|
+
for (const f of D)
|
|
2751
|
+
if (r.startsWith(f))
|
|
2998
2752
|
return null;
|
|
2999
2753
|
}
|
|
3000
|
-
const
|
|
3001
|
-
if (!
|
|
2754
|
+
const _ = m && !(g === 0) && r.length > a.length, N = i && d.includes(i) && !_, I = i === d[0];
|
|
2755
|
+
if (!N && !I)
|
|
3002
2756
|
return d[0];
|
|
3003
|
-
} else if (
|
|
2757
|
+
} else if (s.startsWith("+") && r.length) {
|
|
3004
2758
|
const a = this.selectedCountryData.dialCode || "";
|
|
3005
2759
|
return a && a.startsWith(r) ? null : "";
|
|
3006
|
-
} else if ((!
|
|
2760
|
+
} else if ((!s || s === "+") && !i)
|
|
3007
2761
|
return this.defaultCountry;
|
|
3008
2762
|
return null;
|
|
3009
2763
|
}
|
|
3010
2764
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
3011
2765
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3012
2766
|
_setCountry(t) {
|
|
3013
|
-
const { separateDialCode: e, showFlags:
|
|
2767
|
+
const { separateDialCode: e, showFlags: s, i18n: i, allowDropdown: o } = this.options, n = this.selectedCountryData.iso2 || "";
|
|
3014
2768
|
if (o && this.ui.updateSelectedItem(t), this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
|
|
3015
|
-
const r = t &&
|
|
3016
|
-
let a, d;
|
|
2769
|
+
const r = t && s ? `${h.FLAG} iti__${t}` : `${h.FLAG} ${h.GLOBE}`;
|
|
2770
|
+
let a, d, c;
|
|
3017
2771
|
if (t) {
|
|
3018
|
-
const { name:
|
|
3019
|
-
d =
|
|
2772
|
+
const { name: m, dialCode: g } = this.selectedCountryData;
|
|
2773
|
+
d = m, a = i.selectedCountryAriaLabel.replace("${countryName}", m).replace("${dialCode}", `+${g}`), c = "";
|
|
3020
2774
|
} else
|
|
3021
|
-
d =
|
|
3022
|
-
this.ui.selectedCountryInner.className = r, this.ui.selectedCountry.setAttribute("title", d), this.ui.selectedCountry.setAttribute(
|
|
2775
|
+
d = i.noCountrySelected, a = i.noCountrySelected, c = ot();
|
|
2776
|
+
this.ui.selectedCountryInner.className = r, this.ui.selectedCountry.setAttribute("title", d), this.ui.selectedCountry.setAttribute(p.LABEL, a), this.ui.selectedCountryInner.innerHTML = c;
|
|
3023
2777
|
}
|
|
3024
2778
|
if (e) {
|
|
3025
2779
|
const r = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
@@ -3029,24 +2783,24 @@ class V {
|
|
|
3029
2783
|
}
|
|
3030
2784
|
//* Update the maximum valid number length for the currently selected country.
|
|
3031
2785
|
_updateMaxLength() {
|
|
3032
|
-
const { strictMode: t, placeholderNumberType: e,
|
|
2786
|
+
const { strictMode: t, placeholderNumberType: e, allowedNumberTypes: s } = this.options, { iso2: i } = this.selectedCountryData;
|
|
3033
2787
|
if (t && u.utils)
|
|
3034
|
-
if (
|
|
2788
|
+
if (i) {
|
|
3035
2789
|
const o = u.utils.numberType[e];
|
|
3036
2790
|
let n = u.utils.getExampleNumber(
|
|
3037
|
-
|
|
2791
|
+
i,
|
|
3038
2792
|
!1,
|
|
3039
2793
|
o,
|
|
3040
2794
|
!0
|
|
3041
2795
|
), r = n;
|
|
3042
2796
|
for (; u.utils.isPossibleNumber(
|
|
3043
2797
|
n,
|
|
3044
|
-
|
|
3045
|
-
|
|
2798
|
+
i,
|
|
2799
|
+
s
|
|
3046
2800
|
); )
|
|
3047
2801
|
r = n, n += "0";
|
|
3048
|
-
const a = u.utils.getCoreNumber(r,
|
|
3049
|
-
this.maxCoreNumberLength = a.length,
|
|
2802
|
+
const a = u.utils.getCoreNumber(r, i);
|
|
2803
|
+
this.maxCoreNumberLength = a.length, i === "by" && (this.maxCoreNumberLength = a.length + 1);
|
|
3050
2804
|
} else
|
|
3051
2805
|
this.maxCoreNumberLength = null;
|
|
3052
2806
|
}
|
|
@@ -3055,93 +2809,93 @@ class V {
|
|
|
3055
2809
|
const {
|
|
3056
2810
|
autoPlaceholder: t,
|
|
3057
2811
|
placeholderNumberType: e,
|
|
3058
|
-
nationalMode:
|
|
3059
|
-
customPlaceholder:
|
|
3060
|
-
} = this.options, o = t ===
|
|
2812
|
+
nationalMode: s,
|
|
2813
|
+
customPlaceholder: i
|
|
2814
|
+
} = this.options, o = t === M.AGGRESSIVE || !this.ui.hadInitialPlaceholder && t === M.POLITE;
|
|
3061
2815
|
if (u.utils && o) {
|
|
3062
2816
|
const n = u.utils.numberType[e];
|
|
3063
2817
|
let r = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
3064
2818
|
this.selectedCountryData.iso2,
|
|
3065
|
-
|
|
2819
|
+
s,
|
|
3066
2820
|
n
|
|
3067
2821
|
) : "";
|
|
3068
|
-
r = this._beforeSetNumber(r), typeof
|
|
2822
|
+
r = this._beforeSetNumber(r), typeof i == "function" && (r = i(r, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", r);
|
|
3069
2823
|
}
|
|
3070
2824
|
}
|
|
3071
2825
|
//* Called when the user selects a list item from the dropdown.
|
|
3072
2826
|
_selectListItem(t) {
|
|
3073
|
-
const e = t.dataset[
|
|
2827
|
+
const e = t.dataset[V.COUNTRY_CODE], s = this._setCountry(e);
|
|
3074
2828
|
this._closeDropdown();
|
|
3075
|
-
const
|
|
3076
|
-
if (this._updateDialCode(
|
|
2829
|
+
const i = t.dataset[V.DIAL_CODE];
|
|
2830
|
+
if (this._updateDialCode(i), this.options.formatOnDisplay) {
|
|
3077
2831
|
const o = this._getTelInputValue();
|
|
3078
2832
|
this._updateValFromNumber(o);
|
|
3079
2833
|
}
|
|
3080
|
-
this.ui.telInput.focus(),
|
|
2834
|
+
this.ui.telInput.focus(), s && this._triggerCountryChange();
|
|
3081
2835
|
}
|
|
3082
2836
|
//* Close the dropdown and unbind any listeners.
|
|
3083
2837
|
_closeDropdown() {
|
|
3084
|
-
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(
|
|
2838
|
+
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(p.EXPANDED, "false"), this.options.countrySearch && (this.ui.searchInput.removeAttribute(p.ACTIVE_DESCENDANT), this.ui.highlightedItem && (this.ui.highlightedItem.classList.remove(h.HIGHLIGHT), this.ui.highlightedItem = null)), this.ui.dropdownArrow.classList.remove(h.ARROW_UP), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger(S.CLOSE_COUNTRY_DROPDOWN));
|
|
3085
2839
|
}
|
|
3086
2840
|
//* Replace any existing dial code with the new one
|
|
3087
2841
|
//* Note: called from _selectListItem and setCountry
|
|
3088
2842
|
_updateDialCode(t) {
|
|
3089
|
-
const e = this._getTelInputValue(),
|
|
3090
|
-
let
|
|
2843
|
+
const e = this._getTelInputValue(), s = `+${t}`;
|
|
2844
|
+
let i;
|
|
3091
2845
|
if (e.startsWith("+")) {
|
|
3092
2846
|
const o = this._getDialCode(e);
|
|
3093
|
-
o ?
|
|
2847
|
+
o ? i = e.replace(o, s) : i = s, this._setTelInputValue(i);
|
|
3094
2848
|
}
|
|
3095
2849
|
}
|
|
3096
2850
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
3097
2851
|
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
3098
2852
|
_getDialCode(t, e) {
|
|
3099
|
-
let
|
|
2853
|
+
let s = "";
|
|
3100
2854
|
if (t.startsWith("+")) {
|
|
3101
|
-
let
|
|
2855
|
+
let i = "", o = !1;
|
|
3102
2856
|
for (let n = 0; n < t.length; n++) {
|
|
3103
2857
|
const r = t.charAt(n);
|
|
3104
2858
|
if (/[0-9]/.test(r)) {
|
|
3105
|
-
if (
|
|
2859
|
+
if (i += r, !!!this.dialCodeToIso2Map[i])
|
|
3106
2860
|
break;
|
|
3107
|
-
if (this.dialCodes.has(
|
|
3108
|
-
if (
|
|
2861
|
+
if (this.dialCodes.has(i)) {
|
|
2862
|
+
if (s = t.substring(0, n + 1), o = !0, !e)
|
|
3109
2863
|
break;
|
|
3110
|
-
} else e && o && (
|
|
3111
|
-
if (
|
|
2864
|
+
} else e && o && (s = t.substring(0, n + 1));
|
|
2865
|
+
if (i.length === this.dialCodeMaxLen)
|
|
3112
2866
|
break;
|
|
3113
2867
|
}
|
|
3114
2868
|
}
|
|
3115
2869
|
}
|
|
3116
|
-
return
|
|
2870
|
+
return s;
|
|
3117
2871
|
}
|
|
3118
2872
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3119
2873
|
_getFullNumber(t) {
|
|
3120
|
-
const e = t ? this._normaliseNumerals(t) : this._getTelInputValue(), { dialCode:
|
|
3121
|
-
let
|
|
3122
|
-
const o =
|
|
3123
|
-
return this.options.separateDialCode && !e.startsWith("+") &&
|
|
2874
|
+
const e = t ? this._normaliseNumerals(t) : this._getTelInputValue(), { dialCode: s } = this.selectedCountryData;
|
|
2875
|
+
let i;
|
|
2876
|
+
const o = P(e);
|
|
2877
|
+
return this.options.separateDialCode && !e.startsWith("+") && s && o ? i = `+${s}` : i = "", i + e;
|
|
3124
2878
|
}
|
|
3125
2879
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
3126
2880
|
_beforeSetNumber(t) {
|
|
3127
|
-
const e = this._getDialCode(t),
|
|
2881
|
+
const e = !!this._getDialCode(t), s = $(
|
|
3128
2882
|
t,
|
|
3129
2883
|
e,
|
|
3130
2884
|
this.options.separateDialCode,
|
|
3131
2885
|
this.selectedCountryData
|
|
3132
2886
|
);
|
|
3133
|
-
return this._cap(
|
|
2887
|
+
return this._cap(s);
|
|
3134
2888
|
}
|
|
3135
2889
|
//* Trigger the 'countrychange' event.
|
|
3136
2890
|
_triggerCountryChange() {
|
|
3137
|
-
this._trigger(
|
|
2891
|
+
this._trigger(S.COUNTRY_CHANGE);
|
|
3138
2892
|
}
|
|
3139
2893
|
//**************************
|
|
3140
2894
|
//* SECRET PUBLIC METHODS
|
|
3141
2895
|
//**************************
|
|
3142
2896
|
//* This is called when the geoip call returns.
|
|
3143
2897
|
handleAutoCountry() {
|
|
3144
|
-
this.options.initialCountry ===
|
|
2898
|
+
this.options.initialCountry === x.AUTO && u.autoCountry && (this.defaultCountry = u.autoCountry, this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains(h.GLOBE) || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
|
|
3145
2899
|
}
|
|
3146
2900
|
//* This is called when the utils request completes.
|
|
3147
2901
|
handleUtils() {
|
|
@@ -3168,12 +2922,12 @@ class V {
|
|
|
3168
2922
|
//* Format the number to the given format.
|
|
3169
2923
|
getNumber(t) {
|
|
3170
2924
|
if (u.utils) {
|
|
3171
|
-
const { iso2: e } = this.selectedCountryData,
|
|
3172
|
-
|
|
2925
|
+
const { iso2: e } = this.selectedCountryData, s = this._getFullNumber(), i = u.utils.formatNumber(
|
|
2926
|
+
s,
|
|
3173
2927
|
e,
|
|
3174
2928
|
t
|
|
3175
2929
|
);
|
|
3176
|
-
return this._mapAsciiToUserNumerals(
|
|
2930
|
+
return this._mapAsciiToUserNumerals(i);
|
|
3177
2931
|
}
|
|
3178
2932
|
return "";
|
|
3179
2933
|
}
|
|
@@ -3182,7 +2936,7 @@ class V {
|
|
|
3182
2936
|
return u.utils ? u.utils.getNumberType(
|
|
3183
2937
|
this._getFullNumber(),
|
|
3184
2938
|
this.selectedCountryData.iso2
|
|
3185
|
-
) :
|
|
2939
|
+
) : F.UNKNOWN_NUMBER_TYPE;
|
|
3186
2940
|
}
|
|
3187
2941
|
//* Get the country data for the currently selected country.
|
|
3188
2942
|
getSelectedCountryData() {
|
|
@@ -3194,14 +2948,14 @@ class V {
|
|
|
3194
2948
|
const { iso2: t } = this.selectedCountryData;
|
|
3195
2949
|
return u.utils.getValidationError(this._getFullNumber(), t);
|
|
3196
2950
|
}
|
|
3197
|
-
return
|
|
2951
|
+
return F.UNKNOWN_VALIDATION_ERROR;
|
|
3198
2952
|
}
|
|
3199
2953
|
//* Validate the input val using number length only
|
|
3200
2954
|
isValidNumber() {
|
|
3201
2955
|
const { dialCode: t, iso2: e } = this.selectedCountryData;
|
|
3202
|
-
if (t ===
|
|
3203
|
-
const
|
|
3204
|
-
if (
|
|
2956
|
+
if (t === R.DIAL_CODE && u.utils) {
|
|
2957
|
+
const s = this._getFullNumber(), i = u.utils.getCoreNumber(s, e);
|
|
2958
|
+
if (i[0] === R.MOBILE_PREFIX && i.length !== R.MOBILE_CORE_LENGTH)
|
|
3205
2959
|
return !1;
|
|
3206
2960
|
}
|
|
3207
2961
|
return this._validateNumber(!1);
|
|
@@ -3214,7 +2968,7 @@ class V {
|
|
|
3214
2968
|
return u.utils ? u.utils.isPossibleNumber(
|
|
3215
2969
|
t,
|
|
3216
2970
|
this.selectedCountryData.iso2,
|
|
3217
|
-
this.options.
|
|
2971
|
+
this.options.allowedNumberTypes
|
|
3218
2972
|
) : null;
|
|
3219
2973
|
}
|
|
3220
2974
|
//* Shared internal validation logic to handle alpha character extension rules.
|
|
@@ -3223,27 +2977,29 @@ class V {
|
|
|
3223
2977
|
return null;
|
|
3224
2978
|
if (!this.selectedCountryData.iso2)
|
|
3225
2979
|
return !1;
|
|
3226
|
-
const e = (
|
|
3227
|
-
if (
|
|
3228
|
-
|
|
3229
|
-
|
|
2980
|
+
const { allowNumberExtensions: e, allowPhonewords: s } = this.options, i = (a) => t ? this._utilsIsValidNumber(a) : this._utilsIsPossibleNumber(a), o = this._getFullNumber();
|
|
2981
|
+
if (!i(o))
|
|
2982
|
+
return !1;
|
|
2983
|
+
if (o.search(L.ALPHA_UNICODE) > -1) {
|
|
2984
|
+
const a = this.selectedCountryData.iso2;
|
|
2985
|
+
return u.utils.getExtension(o, a) ? e : s;
|
|
3230
2986
|
}
|
|
3231
|
-
return
|
|
2987
|
+
return !0;
|
|
3232
2988
|
}
|
|
3233
2989
|
_utilsIsValidNumber(t) {
|
|
3234
2990
|
return u.utils ? u.utils.isValidNumber(
|
|
3235
2991
|
t,
|
|
3236
2992
|
this.selectedCountryData.iso2,
|
|
3237
|
-
this.options.
|
|
2993
|
+
this.options.allowedNumberTypes
|
|
3238
2994
|
) : null;
|
|
3239
2995
|
}
|
|
3240
2996
|
//* Update the selected country, and update the input val accordingly.
|
|
3241
2997
|
setCountry(t) {
|
|
3242
2998
|
const e = t == null ? void 0 : t.toLowerCase();
|
|
3243
|
-
if (!
|
|
2999
|
+
if (!k(e))
|
|
3244
3000
|
throw new Error(`Invalid country code: '${e}'`);
|
|
3245
|
-
const
|
|
3246
|
-
if (t && e !==
|
|
3001
|
+
const s = this.selectedCountryData.iso2;
|
|
3002
|
+
if (t && e !== s || !t && s) {
|
|
3247
3003
|
if (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay) {
|
|
3248
3004
|
const o = this._getTelInputValue();
|
|
3249
3005
|
this._updateValFromNumber(o);
|
|
@@ -3253,8 +3009,8 @@ class V {
|
|
|
3253
3009
|
}
|
|
3254
3010
|
//* Set the input value and update the country.
|
|
3255
3011
|
setNumber(t) {
|
|
3256
|
-
const e = this._normaliseNumerals(t),
|
|
3257
|
-
this._updateValFromNumber(e),
|
|
3012
|
+
const e = this._normaliseNumerals(t), s = this._updateCountryFromNumber(e);
|
|
3013
|
+
this._updateValFromNumber(e), s && this._triggerCountryChange(), this._trigger(S.INPUT, { isSetNumber: !0 });
|
|
3258
3014
|
}
|
|
3259
3015
|
//* Set the placeholder number typ
|
|
3260
3016
|
setPlaceholderNumberType(t) {
|
|
@@ -3264,7 +3020,7 @@ class V {
|
|
|
3264
3020
|
this.ui.telInput.disabled = t, t ? this.ui.selectedCountry.setAttribute("disabled", "true") : this.ui.selectedCountry.removeAttribute("disabled");
|
|
3265
3021
|
}
|
|
3266
3022
|
}
|
|
3267
|
-
const
|
|
3023
|
+
const yt = (l) => {
|
|
3268
3024
|
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
3269
3025
|
let t;
|
|
3270
3026
|
if (typeof l == "function")
|
|
@@ -3280,29 +3036,29 @@ const Tt = (l) => {
|
|
|
3280
3036
|
)
|
|
3281
3037
|
);
|
|
3282
3038
|
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
3283
|
-
const
|
|
3284
|
-
if (!
|
|
3039
|
+
const s = e == null ? void 0 : e.default;
|
|
3040
|
+
if (!s || typeof s != "object")
|
|
3285
3041
|
throw new TypeError(
|
|
3286
3042
|
"The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
|
|
3287
3043
|
);
|
|
3288
|
-
return u.utils =
|
|
3044
|
+
return u.utils = s, T("handleUtils"), !0;
|
|
3289
3045
|
}).catch((e) => {
|
|
3290
|
-
throw
|
|
3046
|
+
throw T("rejectUtilsScriptPromise", e), e;
|
|
3291
3047
|
});
|
|
3292
3048
|
}
|
|
3293
3049
|
return null;
|
|
3294
|
-
},
|
|
3050
|
+
}, T = (l, ...t) => {
|
|
3295
3051
|
Object.values(u.instances).forEach((e) => {
|
|
3296
|
-
const
|
|
3297
|
-
typeof
|
|
3052
|
+
const s = e[l];
|
|
3053
|
+
typeof s == "function" && s.apply(e, t);
|
|
3298
3054
|
});
|
|
3299
3055
|
}, u = Object.assign(
|
|
3300
3056
|
(l, t) => {
|
|
3301
|
-
const e = new
|
|
3057
|
+
const e = new W(l, t);
|
|
3302
3058
|
return u.instances[e.id] = e, l.iti = e, e;
|
|
3303
3059
|
},
|
|
3304
3060
|
{
|
|
3305
|
-
defaults:
|
|
3061
|
+
defaults: K,
|
|
3306
3062
|
//* Using a static var like this allows us to mock it in the tests.
|
|
3307
3063
|
documentReady: () => document.readyState === "complete",
|
|
3308
3064
|
//* Get the country data object.
|
|
@@ -3314,85 +3070,12 @@ const Tt = (l) => {
|
|
|
3314
3070
|
},
|
|
3315
3071
|
//* A map from instance ID to instance object.
|
|
3316
3072
|
instances: {},
|
|
3317
|
-
attachUtils:
|
|
3073
|
+
attachUtils: yt,
|
|
3318
3074
|
startedLoadingUtilsScript: !1,
|
|
3319
3075
|
startedLoadingAutoCountry: !1,
|
|
3320
|
-
version: "
|
|
3321
|
-
}
|
|
3322
|
-
), Ot = {
|
|
3323
|
-
__name: "IntlTelInput",
|
|
3324
|
-
props: /* @__PURE__ */ W({
|
|
3325
|
-
disabled: {
|
|
3326
|
-
type: Boolean,
|
|
3327
|
-
default: !1
|
|
3328
|
-
},
|
|
3329
|
-
inputProps: {
|
|
3330
|
-
type: Object,
|
|
3331
|
-
default: () => ({})
|
|
3332
|
-
},
|
|
3333
|
-
options: {
|
|
3334
|
-
type: Object,
|
|
3335
|
-
default: () => ({})
|
|
3336
|
-
},
|
|
3337
|
-
value: {
|
|
3338
|
-
type: String,
|
|
3339
|
-
default: ""
|
|
3340
|
-
}
|
|
3341
|
-
}, {
|
|
3342
|
-
modelValue: {
|
|
3343
|
-
type: String,
|
|
3344
|
-
default: ""
|
|
3345
|
-
},
|
|
3346
|
-
modelModifiers: {}
|
|
3347
|
-
}),
|
|
3348
|
-
emits: /* @__PURE__ */ W([
|
|
3349
|
-
"changeNumber",
|
|
3350
|
-
"changeCountry",
|
|
3351
|
-
"changeValidity",
|
|
3352
|
-
"changeErrorCode"
|
|
3353
|
-
], ["update:modelValue"]),
|
|
3354
|
-
setup(l, { expose: t, emit: e }) {
|
|
3355
|
-
const i = Q(l, "modelValue"), s = l, o = e, n = O(), r = O(), a = O(!1), d = () => r.value ? s.options.strictMode ? r.value.isValidNumberPrecise() : r.value.isValidNumber() : null, c = () => {
|
|
3356
|
-
let C = d();
|
|
3357
|
-
a.value !== C && (a.value = C, o("changeValidity", !!C), o(
|
|
3358
|
-
"changeErrorCode",
|
|
3359
|
-
C ? null : r.value.getValidationError()
|
|
3360
|
-
));
|
|
3361
|
-
}, p = () => {
|
|
3362
|
-
var C;
|
|
3363
|
-
o("changeNumber", ((C = r.value) == null ? void 0 : C.getNumber()) ?? ""), c();
|
|
3364
|
-
}, b = () => {
|
|
3365
|
-
var C;
|
|
3366
|
-
o("changeCountry", ((C = r.value) == null ? void 0 : C.getSelectedCountryData().iso2) ?? ""), p(), c();
|
|
3367
|
-
};
|
|
3368
|
-
return J(() => {
|
|
3369
|
-
n.value && (r.value = u(n.value, s.options), s.value && r.value.setNumber(s.value), s.disabled && r.value.setDisabled(s.disabled), a.value = d());
|
|
3370
|
-
}), Z(
|
|
3371
|
-
() => s.disabled,
|
|
3372
|
-
(C) => {
|
|
3373
|
-
var y;
|
|
3374
|
-
return (y = r.value) == null ? void 0 : y.setDisabled(C);
|
|
3375
|
-
}
|
|
3376
|
-
), tt(() => {
|
|
3377
|
-
var C;
|
|
3378
|
-
return (C = r.value) == null ? void 0 : C.destroy();
|
|
3379
|
-
}), t({ instance: r, input: n }), (C, y) => et((st(), it("input", nt({
|
|
3380
|
-
ref_key: "input",
|
|
3381
|
-
ref: n,
|
|
3382
|
-
"onUpdate:modelValue": y[0] || (y[0] = (I) => i.value = I),
|
|
3383
|
-
type: "tel",
|
|
3384
|
-
onCountrychange: b,
|
|
3385
|
-
onInput: p
|
|
3386
|
-
}, l.inputProps), null, 16)), [
|
|
3387
|
-
[
|
|
3388
|
-
ot,
|
|
3389
|
-
i.value,
|
|
3390
|
-
void 0,
|
|
3391
|
-
{ lazy: !0 }
|
|
3392
|
-
]
|
|
3393
|
-
]);
|
|
3076
|
+
version: "26.0.0-beta.0"
|
|
3394
3077
|
}
|
|
3395
|
-
|
|
3078
|
+
);
|
|
3396
3079
|
export {
|
|
3397
|
-
|
|
3080
|
+
u as i
|
|
3398
3081
|
};
|