intl-tel-input 26.9.2 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular/README.md +1 -1
- package/angular/dist/IntlTelInput.d.ts +97 -0
- package/angular/dist/IntlTelInput.js +4812 -0
- package/angular/dist/IntlTelInputWithUtils.d.ts +3 -0
- package/angular/{build → dist}/IntlTelInputWithUtils.js +2342 -2096
- package/{build → dist}/css/demo.css +1 -1
- package/dist/css/intlTelInput-no-assets.css +1 -0
- package/dist/css/intlTelInput-no-assets.min.css +1 -0
- package/dist/css/intlTelInput.css +1 -0
- package/dist/css/intlTelInput.min.css +1 -0
- package/dist/img/flags.png +0 -0
- package/dist/img/flags.webp +0 -0
- package/dist/img/flags@2x.png +0 -0
- package/dist/img/flags@2x.webp +0 -0
- package/dist/js/data.d.ts +1616 -0
- package/{build → dist}/js/data.js +5 -17
- package/dist/js/data.min.js +7 -0
- package/dist/js/data.mjs +1708 -0
- package/{build/js/i18n/ar/index.js → dist/js/i18n/ar.js} +1 -0
- package/{build/js/i18n/bg/index.js → dist/js/i18n/bg.js} +1 -0
- package/{build/js/i18n/bn/index.js → dist/js/i18n/bn.js} +1 -0
- package/{build/js/i18n/bs/index.js → dist/js/i18n/bs.js} +1 -0
- package/{build/js/i18n/ca/index.js → dist/js/i18n/ca.js} +1 -0
- package/{build/js/i18n/cs/index.js → dist/js/i18n/cs.js} +1 -0
- package/{build/js/i18n/da/index.js → dist/js/i18n/da.js} +1 -0
- package/{build/js/i18n/de/index.js → dist/js/i18n/de.js} +1 -0
- package/{build/js/i18n/el/index.js → dist/js/i18n/el.js} +1 -0
- package/{build/js/i18n/en/index.js → dist/js/i18n/en.js} +3 -2
- package/{build/js/i18n/es/index.js → dist/js/i18n/es.js} +1 -0
- package/{build/js/i18n/et/index.js → dist/js/i18n/et.js} +1 -0
- package/{build/js/i18n/fa/index.js → dist/js/i18n/fa.js} +1 -0
- package/{build/js/i18n/fi/index.js → dist/js/i18n/fi.js} +1 -0
- package/{build/js/i18n/fr/index.js → dist/js/i18n/fr.js} +1 -0
- package/{build/js/i18n/hi/index.js → dist/js/i18n/hi.js} +1 -0
- package/{build/js/i18n/hr/index.js → dist/js/i18n/hr.js} +1 -0
- package/{build/js/i18n/hu/index.js → dist/js/i18n/hu.js} +1 -0
- package/{build/js/i18n/id/index.js → dist/js/i18n/id.js} +1 -0
- package/{build → dist}/js/i18n/index.js +1 -0
- package/{build/js/i18n/it/index.js → dist/js/i18n/it.js} +1 -0
- package/{build/js/i18n/ja/index.js → dist/js/i18n/ja.js} +1 -0
- package/{build/js/i18n/kn/index.js → dist/js/i18n/kn.js} +1 -0
- package/{build/js/i18n/ko/index.js → dist/js/i18n/ko.js} +1 -0
- package/{build/js/i18n/lt/index.js → dist/js/i18n/lt.js} +1 -0
- package/{build/js/i18n/mr/index.js → dist/js/i18n/mr.js} +1 -0
- package/{build/js/i18n/nl/index.js → dist/js/i18n/nl.js} +1 -0
- package/{build/js/i18n/no/index.js → dist/js/i18n/no.js} +1 -0
- package/{build/js/i18n/pl/index.js → dist/js/i18n/pl.js} +1 -0
- package/{build/js/i18n/pt/index.js → dist/js/i18n/pt.js} +1 -0
- package/{build/js/i18n/ro/index.js → dist/js/i18n/ro.js} +1 -0
- package/{build/js/i18n/ru/index.js → dist/js/i18n/ru.js} +1 -0
- package/{build/js/i18n/sk/index.js → dist/js/i18n/sk.js} +1 -0
- package/{build/js/i18n/sl/index.js → dist/js/i18n/sl.js} +1 -0
- package/{build/js/i18n/sq/index.js → dist/js/i18n/sq.js} +1 -0
- package/{build/js/i18n/sr/index.js → dist/js/i18n/sr.js} +1 -0
- package/{build/js/i18n/sv/index.js → dist/js/i18n/sv.js} +1 -0
- package/{build/js/i18n/te/index.js → dist/js/i18n/te.js} +1 -0
- package/{build/js/i18n/th/index.js → dist/js/i18n/th.js} +1 -0
- package/{build/js/i18n/tr/index.js → dist/js/i18n/tr.js} +1 -0
- package/dist/js/i18n/types.js +1 -0
- package/{build/js/i18n/uk/index.js → dist/js/i18n/uk.js} +1 -0
- package/{build/js/i18n/ur/index.js → dist/js/i18n/ur.js} +1 -0
- package/{build/js/i18n/uz/index.js → dist/js/i18n/uz.js} +1 -0
- package/{build/js/i18n/vi/index.js → dist/js/i18n/vi.js} +1 -0
- package/{build/js/i18n/zh-hk/index.js → dist/js/i18n/zh-hk.js} +1 -0
- package/{build/js/i18n/zh/index.js → dist/js/i18n/zh.js} +1 -0
- package/dist/js/i18n.d.ts +1697 -0
- package/dist/js/intlTelInput.d.ts +1773 -0
- package/{build → dist}/js/intlTelInput.js +228 -215
- package/dist/js/intlTelInput.min.js +25 -0
- package/{react/build/IntlTelInput.cjs → dist/js/intlTelInput.mjs} +230 -340
- package/{build → dist}/js/intlTelInputWithUtils.js +531 -498
- package/dist/js/intlTelInputWithUtils.min.js +25 -0
- package/{react/build/IntlTelInputWithUtils.cjs → dist/js/intlTelInputWithUtils.mjs} +530 -621
- package/{build → dist}/js/utils.js +46 -47
- package/package.json +122 -122
- package/react/README.md +1 -1
- package/react/dist/IntlTelInput.d.ts +20 -0
- package/react/{build → dist}/IntlTelInput.js +274 -255
- package/react/dist/IntlTelInputWithUtils.d.ts +4 -0
- package/react/{build → dist}/IntlTelInputWithUtils.js +580 -542
- package/svelte/README.md +1 -1
- package/svelte/src/IntlTelInput.svelte +199 -0
- package/svelte/src/IntlTelInputWithUtils.svelte +15 -0
- package/svelte/src/shims.d.ts +4 -0
- package/vue/README.md +1 -1
- package/vue/dist/IntlTelInput-D7r449B2.js +2577 -0
- package/vue/dist/IntlTelInput.js +5 -0
- package/vue/dist/IntlTelInputWithUtils.js +49385 -0
- package/vue/dist/src/IntlTelInput.vue.d.ts +35 -0
- package/vue/dist/src/index.d.ts +4 -0
- package/vue/dist/src/indexWithUtils.d.ts +3 -0
- package/angular/build/IntlTelInput.js +0 -4501
- package/angular/build/types/intl-tel-input/angular.d.ts +0 -65
- package/angular/build/types/intl-tel-input/angularWithUtils.d.ts +0 -65
- package/angular/build/types/intl-tel-input/data.d.ts +0 -20
- package/angular/build/types/intl-tel-input/i18n/ar/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bg/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bn/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bs/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ca/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/cs/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/da/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/de/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/el/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/en/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/es/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/et/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fa/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hu/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/id/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/index.d.ts +0 -45
- package/angular/build/types/intl-tel-input/i18n/it/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ja/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/kn/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ko/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/lt/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/mr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/nl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/no/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/pl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/pt/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ro/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ru/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sq/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sv/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/te/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/th/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/tr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +0 -10
- package/angular/build/types/intl-tel-input/i18n/uk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ur/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/uz/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/vi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/zh/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
- package/angular/build/types/intl-tel-input/utils.d.ts +0 -2
- package/angular/build/types/intl-tel-input.d.ts +0 -46
- package/angular/build/types/modules/constants.d.ts +0 -94
- package/angular/build/types/modules/core/countrySearch.d.ts +0 -17
- package/angular/build/types/modules/core/icons.d.ts +0 -11
- package/angular/build/types/modules/core/numerals.d.ts +0 -7
- package/angular/build/types/modules/core/options.d.ts +0 -8
- package/angular/build/types/modules/core/ui.d.ts +0 -30
- package/angular/build/types/modules/data/country-data.d.ts +0 -12
- package/angular/build/types/modules/data/intl-regionless.d.ts +0 -2
- package/angular/build/types/modules/data/nanp-regionless.d.ts +0 -2
- package/angular/build/types/modules/format/caret.d.ts +0 -1
- package/angular/build/types/modules/format/formatting.d.ts +0 -3
- package/angular/build/types/modules/types/events.d.ts +0 -10
- package/angular/build/types/modules/types/forEachInstanceArgsMap.d.ts +0 -6
- package/angular/build/types/modules/types/public-api.d.ts +0 -65
- package/angular/build/types/modules/utils/dom.d.ts +0 -6
- package/angular/build/types/modules/utils/isAndroid.d.ts +0 -1
- package/angular/build/types/modules/utils/string.d.ts +0 -2
- package/build/css/intlTelInput-no-assets.css +0 -1323
- package/build/css/intlTelInput-no-assets.min.css +0 -1
- package/build/css/intlTelInput.css +0 -1327
- package/build/css/intlTelInput.min.css +0 -1
- package/build/img/flags.png +0 -0
- package/build/img/flags.webp +0 -0
- package/build/img/flags@2x.png +0 -0
- package/build/img/flags@2x.webp +0 -0
- package/build/js/data.min.js +0 -20
- package/build/js/i18n/types.js +0 -0
- package/build/js/intlTelInput.d.ts +0 -671
- package/build/js/intlTelInput.min.js +0 -38
- package/build/js/intlTelInputWithUtils.min.js +0 -38
- package/index.js +0 -1
- package/react/build/IntlTelInput.d.ts +0 -721
- package/svelte/build/IntlTelInput.mjs +0 -5294
- package/svelte/build/IntlTelInputWithUtils.mjs +0 -11381
- package/vue/build/IntlTelInput.vue.d.ts +0 -34
- package/vue/build/IntlTelInputWithUtils.vue.d.ts +0 -34
- package/vue/build/exports/IntlTelInput.d.ts +0 -3
- package/vue/build/exports/IntlTelInput.mjs +0 -86
- package/vue/build/exports/IntlTelInputWithUtils.d.ts +0 -3
- package/vue/build/exports/IntlTelInputWithUtils.mjs +0 -6173
- package/vue/build/intl-tel-input/data.d.ts +0 -20
- package/vue/build/intl-tel-input/i18n/ar/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bg/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bn/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bs/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ca/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/cs/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/da/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/de/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/el/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/en/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/es/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/et/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fa/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hu/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/id/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/index.d.ts +0 -45
- package/vue/build/intl-tel-input/i18n/it/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ja/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/kn/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ko/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/lt/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/mr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/nl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/no/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/pl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/pt/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ro/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ru/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sq/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sv/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/te/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/th/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/tr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/types.d.ts +0 -10
- package/vue/build/intl-tel-input/i18n/uk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ur/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/uz/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/vi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/zh/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
- package/vue/build/intl-tel-input-MeSkUgHd.mjs +0 -3438
- package/vue/build/intl-tel-input.d.ts +0 -46
- package/vue/build/modules/constants.d.ts +0 -94
- package/vue/build/modules/core/countrySearch.d.ts +0 -17
- package/vue/build/modules/core/icons.d.ts +0 -11
- package/vue/build/modules/core/numerals.d.ts +0 -7
- package/vue/build/modules/core/options.d.ts +0 -8
- package/vue/build/modules/core/ui.d.ts +0 -30
- package/vue/build/modules/data/country-data.d.ts +0 -12
- package/vue/build/modules/data/intl-regionless.d.ts +0 -2
- package/vue/build/modules/data/nanp-regionless.d.ts +0 -2
- package/vue/build/modules/format/caret.d.ts +0 -1
- package/vue/build/modules/format/formatting.d.ts +0 -3
- package/vue/build/modules/types/events.d.ts +0 -10
- package/vue/build/modules/types/forEachInstanceArgsMap.d.ts +0 -6
- package/vue/build/modules/types/public-api.d.ts +0 -65
- package/vue/build/modules/utils/dom.d.ts +0 -6
- package/vue/build/modules/utils/isAndroid.d.ts +0 -1
- package/vue/build/modules/utils/string.d.ts +0 -2
|
@@ -0,0 +1,4812 @@
|
|
|
1
|
+
// dist/js/intlTelInput.mjs
|
|
2
|
+
var rawCountryData = [
|
|
3
|
+
[
|
|
4
|
+
"af",
|
|
5
|
+
// Afghanistan
|
|
6
|
+
"93",
|
|
7
|
+
0,
|
|
8
|
+
null,
|
|
9
|
+
"0"
|
|
10
|
+
],
|
|
11
|
+
[
|
|
12
|
+
"ax",
|
|
13
|
+
// Åland Islands
|
|
14
|
+
"358",
|
|
15
|
+
1,
|
|
16
|
+
["18", "4"],
|
|
17
|
+
// (4 is a mobile range shared with FI)
|
|
18
|
+
"0"
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"al",
|
|
22
|
+
// Albania
|
|
23
|
+
"355",
|
|
24
|
+
0,
|
|
25
|
+
null,
|
|
26
|
+
"0"
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
"dz",
|
|
30
|
+
// Algeria
|
|
31
|
+
"213",
|
|
32
|
+
0,
|
|
33
|
+
null,
|
|
34
|
+
"0"
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"as",
|
|
38
|
+
// American Samoa
|
|
39
|
+
"1",
|
|
40
|
+
5,
|
|
41
|
+
["684"],
|
|
42
|
+
"1"
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"ad",
|
|
46
|
+
// Andorra
|
|
47
|
+
"376"
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"ao",
|
|
51
|
+
// Angola
|
|
52
|
+
"244"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"ai",
|
|
56
|
+
// Anguilla
|
|
57
|
+
"1",
|
|
58
|
+
6,
|
|
59
|
+
["264"],
|
|
60
|
+
"1"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"ag",
|
|
64
|
+
// Antigua and Barbuda
|
|
65
|
+
"1",
|
|
66
|
+
7,
|
|
67
|
+
["268"],
|
|
68
|
+
"1"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"ar",
|
|
72
|
+
// Argentina
|
|
73
|
+
"54",
|
|
74
|
+
0,
|
|
75
|
+
null,
|
|
76
|
+
"0"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"am",
|
|
80
|
+
// Armenia
|
|
81
|
+
"374",
|
|
82
|
+
0,
|
|
83
|
+
null,
|
|
84
|
+
"0"
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"aw",
|
|
88
|
+
// Aruba
|
|
89
|
+
"297"
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
"ac",
|
|
93
|
+
// Ascension Island
|
|
94
|
+
"247"
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"au",
|
|
98
|
+
// Australia
|
|
99
|
+
"61",
|
|
100
|
+
0,
|
|
101
|
+
["4"],
|
|
102
|
+
// (mobile range shared with CX and CC)
|
|
103
|
+
"0"
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"at",
|
|
107
|
+
// Austria
|
|
108
|
+
"43",
|
|
109
|
+
0,
|
|
110
|
+
null,
|
|
111
|
+
"0"
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"az",
|
|
115
|
+
// Azerbaijan
|
|
116
|
+
"994",
|
|
117
|
+
0,
|
|
118
|
+
null,
|
|
119
|
+
"0"
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"bs",
|
|
123
|
+
// Bahamas
|
|
124
|
+
"1",
|
|
125
|
+
8,
|
|
126
|
+
["242"],
|
|
127
|
+
"1"
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
"bh",
|
|
131
|
+
// Bahrain
|
|
132
|
+
"973"
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
"bd",
|
|
136
|
+
// Bangladesh
|
|
137
|
+
"880",
|
|
138
|
+
0,
|
|
139
|
+
null,
|
|
140
|
+
"0"
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
"bb",
|
|
144
|
+
// Barbados
|
|
145
|
+
"1",
|
|
146
|
+
9,
|
|
147
|
+
["246"],
|
|
148
|
+
"1"
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
"by",
|
|
152
|
+
// Belarus
|
|
153
|
+
"375",
|
|
154
|
+
0,
|
|
155
|
+
null,
|
|
156
|
+
"8"
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
"be",
|
|
160
|
+
// Belgium
|
|
161
|
+
"32",
|
|
162
|
+
0,
|
|
163
|
+
null,
|
|
164
|
+
"0"
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
"bz",
|
|
168
|
+
// Belize
|
|
169
|
+
"501"
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
"bj",
|
|
173
|
+
// Benin
|
|
174
|
+
"229"
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"bm",
|
|
178
|
+
// Bermuda
|
|
179
|
+
"1",
|
|
180
|
+
10,
|
|
181
|
+
["441"],
|
|
182
|
+
"1"
|
|
183
|
+
],
|
|
184
|
+
[
|
|
185
|
+
"bt",
|
|
186
|
+
// Bhutan
|
|
187
|
+
"975"
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
"bo",
|
|
191
|
+
// Bolivia
|
|
192
|
+
"591",
|
|
193
|
+
0,
|
|
194
|
+
null,
|
|
195
|
+
"0"
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"ba",
|
|
199
|
+
// Bosnia and Herzegovina
|
|
200
|
+
"387",
|
|
201
|
+
0,
|
|
202
|
+
null,
|
|
203
|
+
"0"
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
"bw",
|
|
207
|
+
// Botswana
|
|
208
|
+
"267"
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
"br",
|
|
212
|
+
// Brazil
|
|
213
|
+
"55",
|
|
214
|
+
0,
|
|
215
|
+
null,
|
|
216
|
+
"0"
|
|
217
|
+
],
|
|
218
|
+
[
|
|
219
|
+
"io",
|
|
220
|
+
// British Indian Ocean Territory
|
|
221
|
+
"246"
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
"vg",
|
|
225
|
+
// British Virgin Islands
|
|
226
|
+
"1",
|
|
227
|
+
11,
|
|
228
|
+
["284"],
|
|
229
|
+
"1"
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
"bn",
|
|
233
|
+
// Brunei
|
|
234
|
+
"673"
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
"bg",
|
|
238
|
+
// Bulgaria
|
|
239
|
+
"359",
|
|
240
|
+
0,
|
|
241
|
+
null,
|
|
242
|
+
"0"
|
|
243
|
+
],
|
|
244
|
+
[
|
|
245
|
+
"bf",
|
|
246
|
+
// Burkina Faso
|
|
247
|
+
"226"
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
"bi",
|
|
251
|
+
// Burundi
|
|
252
|
+
"257"
|
|
253
|
+
],
|
|
254
|
+
[
|
|
255
|
+
"kh",
|
|
256
|
+
// Cambodia
|
|
257
|
+
"855",
|
|
258
|
+
0,
|
|
259
|
+
null,
|
|
260
|
+
"0"
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
"cm",
|
|
264
|
+
// Cameroon
|
|
265
|
+
"237"
|
|
266
|
+
],
|
|
267
|
+
[
|
|
268
|
+
"ca",
|
|
269
|
+
// Canada
|
|
270
|
+
"1",
|
|
271
|
+
1,
|
|
272
|
+
["204", "226", "236", "249", "250", "257", "263", "289", "306", "343", "354", "365", "367", "368", "382", "403", "416", "418", "428", "431", "437", "438", "450", "468", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "683", "705", "709", "742", "753", "778", "780", "782", "807", "819", "825", "867", "873", "879", "902", "905", "942"],
|
|
273
|
+
"1"
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
"cv",
|
|
277
|
+
// Cape Verde
|
|
278
|
+
"238"
|
|
279
|
+
],
|
|
280
|
+
[
|
|
281
|
+
"bq",
|
|
282
|
+
// Caribbean Netherlands
|
|
283
|
+
"599",
|
|
284
|
+
1,
|
|
285
|
+
["3", "4", "7"]
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
"ky",
|
|
289
|
+
// Cayman Islands
|
|
290
|
+
"1",
|
|
291
|
+
12,
|
|
292
|
+
["345"],
|
|
293
|
+
"1"
|
|
294
|
+
],
|
|
295
|
+
[
|
|
296
|
+
"cf",
|
|
297
|
+
// Central African Republic
|
|
298
|
+
"236"
|
|
299
|
+
],
|
|
300
|
+
[
|
|
301
|
+
"td",
|
|
302
|
+
// Chad
|
|
303
|
+
"235"
|
|
304
|
+
],
|
|
305
|
+
[
|
|
306
|
+
"cl",
|
|
307
|
+
// Chile
|
|
308
|
+
"56"
|
|
309
|
+
],
|
|
310
|
+
[
|
|
311
|
+
"cn",
|
|
312
|
+
// China
|
|
313
|
+
"86",
|
|
314
|
+
0,
|
|
315
|
+
null,
|
|
316
|
+
"0"
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
"cx",
|
|
320
|
+
// Christmas Island
|
|
321
|
+
"61",
|
|
322
|
+
2,
|
|
323
|
+
["4", "89164"],
|
|
324
|
+
// (4 is a mobile range shared with AU and CC)
|
|
325
|
+
"0"
|
|
326
|
+
],
|
|
327
|
+
[
|
|
328
|
+
"cc",
|
|
329
|
+
// Cocos (Keeling) Islands
|
|
330
|
+
"61",
|
|
331
|
+
1,
|
|
332
|
+
["4", "89162"],
|
|
333
|
+
// (4 is a mobile range shared with AU and CX)
|
|
334
|
+
"0"
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
"co",
|
|
338
|
+
// Colombia
|
|
339
|
+
"57",
|
|
340
|
+
0,
|
|
341
|
+
null,
|
|
342
|
+
"0"
|
|
343
|
+
],
|
|
344
|
+
[
|
|
345
|
+
"km",
|
|
346
|
+
// Comoros
|
|
347
|
+
"269"
|
|
348
|
+
],
|
|
349
|
+
[
|
|
350
|
+
"cg",
|
|
351
|
+
// Congo (Brazzaville)
|
|
352
|
+
"242"
|
|
353
|
+
],
|
|
354
|
+
[
|
|
355
|
+
"cd",
|
|
356
|
+
// Congo (Kinshasa)
|
|
357
|
+
"243",
|
|
358
|
+
0,
|
|
359
|
+
null,
|
|
360
|
+
"0"
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
"ck",
|
|
364
|
+
// Cook Islands
|
|
365
|
+
"682"
|
|
366
|
+
],
|
|
367
|
+
[
|
|
368
|
+
"cr",
|
|
369
|
+
// Costa Rica
|
|
370
|
+
"506"
|
|
371
|
+
],
|
|
372
|
+
[
|
|
373
|
+
"ci",
|
|
374
|
+
// Côte d'Ivoire
|
|
375
|
+
"225"
|
|
376
|
+
],
|
|
377
|
+
[
|
|
378
|
+
"hr",
|
|
379
|
+
// Croatia
|
|
380
|
+
"385",
|
|
381
|
+
0,
|
|
382
|
+
null,
|
|
383
|
+
"0"
|
|
384
|
+
],
|
|
385
|
+
[
|
|
386
|
+
"cu",
|
|
387
|
+
// Cuba
|
|
388
|
+
"53",
|
|
389
|
+
0,
|
|
390
|
+
null,
|
|
391
|
+
"0"
|
|
392
|
+
],
|
|
393
|
+
[
|
|
394
|
+
"cw",
|
|
395
|
+
// Curaçao
|
|
396
|
+
"599",
|
|
397
|
+
0
|
|
398
|
+
],
|
|
399
|
+
[
|
|
400
|
+
"cy",
|
|
401
|
+
// Cyprus
|
|
402
|
+
"357"
|
|
403
|
+
],
|
|
404
|
+
[
|
|
405
|
+
"cz",
|
|
406
|
+
// Czech Republic
|
|
407
|
+
"420"
|
|
408
|
+
],
|
|
409
|
+
[
|
|
410
|
+
"dk",
|
|
411
|
+
// Denmark
|
|
412
|
+
"45"
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
"dj",
|
|
416
|
+
// Djibouti
|
|
417
|
+
"253"
|
|
418
|
+
],
|
|
419
|
+
[
|
|
420
|
+
"dm",
|
|
421
|
+
// Dominica
|
|
422
|
+
"1",
|
|
423
|
+
13,
|
|
424
|
+
["767"],
|
|
425
|
+
"1"
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
"do",
|
|
429
|
+
// Dominican Republic
|
|
430
|
+
"1",
|
|
431
|
+
2,
|
|
432
|
+
["809", "829", "849"],
|
|
433
|
+
"1"
|
|
434
|
+
],
|
|
435
|
+
[
|
|
436
|
+
"ec",
|
|
437
|
+
// Ecuador
|
|
438
|
+
"593",
|
|
439
|
+
0,
|
|
440
|
+
null,
|
|
441
|
+
"0"
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
"eg",
|
|
445
|
+
// Egypt
|
|
446
|
+
"20",
|
|
447
|
+
0,
|
|
448
|
+
null,
|
|
449
|
+
"0"
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
"sv",
|
|
453
|
+
// El Salvador
|
|
454
|
+
"503"
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
"gq",
|
|
458
|
+
// Equatorial Guinea
|
|
459
|
+
"240"
|
|
460
|
+
],
|
|
461
|
+
[
|
|
462
|
+
"er",
|
|
463
|
+
// Eritrea
|
|
464
|
+
"291",
|
|
465
|
+
0,
|
|
466
|
+
null,
|
|
467
|
+
"0"
|
|
468
|
+
],
|
|
469
|
+
[
|
|
470
|
+
"ee",
|
|
471
|
+
// Estonia
|
|
472
|
+
"372"
|
|
473
|
+
],
|
|
474
|
+
[
|
|
475
|
+
"sz",
|
|
476
|
+
// Eswatini
|
|
477
|
+
"268"
|
|
478
|
+
],
|
|
479
|
+
[
|
|
480
|
+
"et",
|
|
481
|
+
// Ethiopia
|
|
482
|
+
"251",
|
|
483
|
+
0,
|
|
484
|
+
null,
|
|
485
|
+
"0"
|
|
486
|
+
],
|
|
487
|
+
[
|
|
488
|
+
"fk",
|
|
489
|
+
// Falkland Islands (Malvinas)
|
|
490
|
+
"500"
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
"fo",
|
|
494
|
+
// Faroe Islands
|
|
495
|
+
"298"
|
|
496
|
+
],
|
|
497
|
+
[
|
|
498
|
+
"fj",
|
|
499
|
+
// Fiji
|
|
500
|
+
"679"
|
|
501
|
+
],
|
|
502
|
+
[
|
|
503
|
+
"fi",
|
|
504
|
+
// Finland
|
|
505
|
+
"358",
|
|
506
|
+
0,
|
|
507
|
+
["4"],
|
|
508
|
+
// (mobile range shared with AX)
|
|
509
|
+
"0"
|
|
510
|
+
],
|
|
511
|
+
[
|
|
512
|
+
"fr",
|
|
513
|
+
// France
|
|
514
|
+
"33",
|
|
515
|
+
0,
|
|
516
|
+
null,
|
|
517
|
+
"0"
|
|
518
|
+
],
|
|
519
|
+
[
|
|
520
|
+
"gf",
|
|
521
|
+
// French Guiana
|
|
522
|
+
"594",
|
|
523
|
+
0,
|
|
524
|
+
null,
|
|
525
|
+
"0"
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
"pf",
|
|
529
|
+
// French Polynesia
|
|
530
|
+
"689"
|
|
531
|
+
],
|
|
532
|
+
[
|
|
533
|
+
"ga",
|
|
534
|
+
// Gabon
|
|
535
|
+
"241"
|
|
536
|
+
],
|
|
537
|
+
[
|
|
538
|
+
"gm",
|
|
539
|
+
// Gambia
|
|
540
|
+
"220"
|
|
541
|
+
],
|
|
542
|
+
[
|
|
543
|
+
"ge",
|
|
544
|
+
// Georgia
|
|
545
|
+
"995",
|
|
546
|
+
0,
|
|
547
|
+
null,
|
|
548
|
+
"0"
|
|
549
|
+
],
|
|
550
|
+
[
|
|
551
|
+
"de",
|
|
552
|
+
// Germany
|
|
553
|
+
"49",
|
|
554
|
+
0,
|
|
555
|
+
null,
|
|
556
|
+
"0"
|
|
557
|
+
],
|
|
558
|
+
[
|
|
559
|
+
"gh",
|
|
560
|
+
// Ghana
|
|
561
|
+
"233",
|
|
562
|
+
0,
|
|
563
|
+
null,
|
|
564
|
+
"0"
|
|
565
|
+
],
|
|
566
|
+
[
|
|
567
|
+
"gi",
|
|
568
|
+
// Gibraltar
|
|
569
|
+
"350"
|
|
570
|
+
],
|
|
571
|
+
[
|
|
572
|
+
"gr",
|
|
573
|
+
// Greece
|
|
574
|
+
"30"
|
|
575
|
+
],
|
|
576
|
+
[
|
|
577
|
+
"gl",
|
|
578
|
+
// Greenland
|
|
579
|
+
"299"
|
|
580
|
+
],
|
|
581
|
+
[
|
|
582
|
+
"gd",
|
|
583
|
+
// Grenada
|
|
584
|
+
"1",
|
|
585
|
+
14,
|
|
586
|
+
["473"],
|
|
587
|
+
"1"
|
|
588
|
+
],
|
|
589
|
+
[
|
|
590
|
+
"gp",
|
|
591
|
+
// Guadeloupe
|
|
592
|
+
"590",
|
|
593
|
+
0,
|
|
594
|
+
null,
|
|
595
|
+
"0"
|
|
596
|
+
],
|
|
597
|
+
[
|
|
598
|
+
"gu",
|
|
599
|
+
// Guam
|
|
600
|
+
"1",
|
|
601
|
+
15,
|
|
602
|
+
["671"],
|
|
603
|
+
"1"
|
|
604
|
+
],
|
|
605
|
+
[
|
|
606
|
+
"gt",
|
|
607
|
+
// Guatemala
|
|
608
|
+
"502"
|
|
609
|
+
],
|
|
610
|
+
[
|
|
611
|
+
"gg",
|
|
612
|
+
// Guernsey
|
|
613
|
+
"44",
|
|
614
|
+
1,
|
|
615
|
+
["1481", "7781", "7839", "7911"],
|
|
616
|
+
"0"
|
|
617
|
+
],
|
|
618
|
+
[
|
|
619
|
+
"gn",
|
|
620
|
+
// Guinea
|
|
621
|
+
"224"
|
|
622
|
+
],
|
|
623
|
+
[
|
|
624
|
+
"gw",
|
|
625
|
+
// Guinea-Bissau
|
|
626
|
+
"245"
|
|
627
|
+
],
|
|
628
|
+
[
|
|
629
|
+
"gy",
|
|
630
|
+
// Guyana
|
|
631
|
+
"592"
|
|
632
|
+
],
|
|
633
|
+
[
|
|
634
|
+
"ht",
|
|
635
|
+
// Haiti
|
|
636
|
+
"509"
|
|
637
|
+
],
|
|
638
|
+
[
|
|
639
|
+
"hn",
|
|
640
|
+
// Honduras
|
|
641
|
+
"504"
|
|
642
|
+
],
|
|
643
|
+
[
|
|
644
|
+
"hk",
|
|
645
|
+
// Hong Kong SAR China
|
|
646
|
+
"852"
|
|
647
|
+
],
|
|
648
|
+
[
|
|
649
|
+
"hu",
|
|
650
|
+
// Hungary
|
|
651
|
+
"36",
|
|
652
|
+
0,
|
|
653
|
+
null,
|
|
654
|
+
"06"
|
|
655
|
+
],
|
|
656
|
+
[
|
|
657
|
+
"is",
|
|
658
|
+
// Iceland
|
|
659
|
+
"354"
|
|
660
|
+
],
|
|
661
|
+
[
|
|
662
|
+
"in",
|
|
663
|
+
// India
|
|
664
|
+
"91",
|
|
665
|
+
0,
|
|
666
|
+
null,
|
|
667
|
+
"0"
|
|
668
|
+
],
|
|
669
|
+
[
|
|
670
|
+
"id",
|
|
671
|
+
// Indonesia
|
|
672
|
+
"62",
|
|
673
|
+
0,
|
|
674
|
+
null,
|
|
675
|
+
"0"
|
|
676
|
+
],
|
|
677
|
+
[
|
|
678
|
+
"ir",
|
|
679
|
+
// Iran
|
|
680
|
+
"98",
|
|
681
|
+
0,
|
|
682
|
+
null,
|
|
683
|
+
"0"
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
"iq",
|
|
687
|
+
// Iraq
|
|
688
|
+
"964",
|
|
689
|
+
0,
|
|
690
|
+
null,
|
|
691
|
+
"0"
|
|
692
|
+
],
|
|
693
|
+
[
|
|
694
|
+
"ie",
|
|
695
|
+
// Ireland
|
|
696
|
+
"353",
|
|
697
|
+
0,
|
|
698
|
+
null,
|
|
699
|
+
"0"
|
|
700
|
+
],
|
|
701
|
+
[
|
|
702
|
+
"im",
|
|
703
|
+
// Isle of Man
|
|
704
|
+
"44",
|
|
705
|
+
2,
|
|
706
|
+
["1624", "74576", "7524", "7624", "7924"],
|
|
707
|
+
"0"
|
|
708
|
+
],
|
|
709
|
+
[
|
|
710
|
+
"il",
|
|
711
|
+
// Israel
|
|
712
|
+
"972",
|
|
713
|
+
0,
|
|
714
|
+
null,
|
|
715
|
+
"0"
|
|
716
|
+
],
|
|
717
|
+
[
|
|
718
|
+
"it",
|
|
719
|
+
// Italy
|
|
720
|
+
"39",
|
|
721
|
+
0,
|
|
722
|
+
["3"]
|
|
723
|
+
// (mobile range shared with VA)
|
|
724
|
+
],
|
|
725
|
+
[
|
|
726
|
+
"jm",
|
|
727
|
+
// Jamaica
|
|
728
|
+
"1",
|
|
729
|
+
4,
|
|
730
|
+
["658", "876"],
|
|
731
|
+
"1"
|
|
732
|
+
],
|
|
733
|
+
[
|
|
734
|
+
"jp",
|
|
735
|
+
// Japan
|
|
736
|
+
"81",
|
|
737
|
+
0,
|
|
738
|
+
null,
|
|
739
|
+
"0"
|
|
740
|
+
],
|
|
741
|
+
[
|
|
742
|
+
"je",
|
|
743
|
+
// Jersey
|
|
744
|
+
"44",
|
|
745
|
+
3,
|
|
746
|
+
["1534", "7509", "7700", "7797", "7829", "7937"],
|
|
747
|
+
"0"
|
|
748
|
+
],
|
|
749
|
+
[
|
|
750
|
+
"jo",
|
|
751
|
+
// Jordan
|
|
752
|
+
"962",
|
|
753
|
+
0,
|
|
754
|
+
null,
|
|
755
|
+
"0"
|
|
756
|
+
],
|
|
757
|
+
[
|
|
758
|
+
"kz",
|
|
759
|
+
// Kazakhstan
|
|
760
|
+
"7",
|
|
761
|
+
1,
|
|
762
|
+
["33", "7"],
|
|
763
|
+
// (33 is shared with RU)
|
|
764
|
+
"8"
|
|
765
|
+
],
|
|
766
|
+
[
|
|
767
|
+
"ke",
|
|
768
|
+
// Kenya
|
|
769
|
+
"254",
|
|
770
|
+
0,
|
|
771
|
+
null,
|
|
772
|
+
"0"
|
|
773
|
+
],
|
|
774
|
+
[
|
|
775
|
+
"ki",
|
|
776
|
+
// Kiribati
|
|
777
|
+
"686",
|
|
778
|
+
0,
|
|
779
|
+
null,
|
|
780
|
+
"0"
|
|
781
|
+
],
|
|
782
|
+
[
|
|
783
|
+
"xk",
|
|
784
|
+
// Kosovo
|
|
785
|
+
"383",
|
|
786
|
+
0,
|
|
787
|
+
null,
|
|
788
|
+
"0"
|
|
789
|
+
],
|
|
790
|
+
[
|
|
791
|
+
"kw",
|
|
792
|
+
// Kuwait
|
|
793
|
+
"965"
|
|
794
|
+
],
|
|
795
|
+
[
|
|
796
|
+
"kg",
|
|
797
|
+
// Kyrgyzstan
|
|
798
|
+
"996",
|
|
799
|
+
0,
|
|
800
|
+
null,
|
|
801
|
+
"0"
|
|
802
|
+
],
|
|
803
|
+
[
|
|
804
|
+
"la",
|
|
805
|
+
// Laos
|
|
806
|
+
"856",
|
|
807
|
+
0,
|
|
808
|
+
null,
|
|
809
|
+
"0"
|
|
810
|
+
],
|
|
811
|
+
[
|
|
812
|
+
"lv",
|
|
813
|
+
// Latvia
|
|
814
|
+
"371"
|
|
815
|
+
],
|
|
816
|
+
[
|
|
817
|
+
"lb",
|
|
818
|
+
// Lebanon
|
|
819
|
+
"961",
|
|
820
|
+
0,
|
|
821
|
+
null,
|
|
822
|
+
"0"
|
|
823
|
+
],
|
|
824
|
+
[
|
|
825
|
+
"ls",
|
|
826
|
+
// Lesotho
|
|
827
|
+
"266"
|
|
828
|
+
],
|
|
829
|
+
[
|
|
830
|
+
"lr",
|
|
831
|
+
// Liberia
|
|
832
|
+
"231",
|
|
833
|
+
0,
|
|
834
|
+
null,
|
|
835
|
+
"0"
|
|
836
|
+
],
|
|
837
|
+
[
|
|
838
|
+
"ly",
|
|
839
|
+
// Libya
|
|
840
|
+
"218",
|
|
841
|
+
0,
|
|
842
|
+
null,
|
|
843
|
+
"0"
|
|
844
|
+
],
|
|
845
|
+
[
|
|
846
|
+
"li",
|
|
847
|
+
// Liechtenstein
|
|
848
|
+
"423",
|
|
849
|
+
0,
|
|
850
|
+
null,
|
|
851
|
+
"0"
|
|
852
|
+
],
|
|
853
|
+
[
|
|
854
|
+
"lt",
|
|
855
|
+
// Lithuania
|
|
856
|
+
"370",
|
|
857
|
+
0,
|
|
858
|
+
null,
|
|
859
|
+
"0"
|
|
860
|
+
],
|
|
861
|
+
[
|
|
862
|
+
"lu",
|
|
863
|
+
// Luxembourg
|
|
864
|
+
"352"
|
|
865
|
+
],
|
|
866
|
+
[
|
|
867
|
+
"mo",
|
|
868
|
+
// Macao SAR China
|
|
869
|
+
"853"
|
|
870
|
+
],
|
|
871
|
+
[
|
|
872
|
+
"mg",
|
|
873
|
+
// Madagascar
|
|
874
|
+
"261",
|
|
875
|
+
0,
|
|
876
|
+
null,
|
|
877
|
+
"0"
|
|
878
|
+
],
|
|
879
|
+
[
|
|
880
|
+
"mw",
|
|
881
|
+
// Malawi
|
|
882
|
+
"265",
|
|
883
|
+
0,
|
|
884
|
+
null,
|
|
885
|
+
"0"
|
|
886
|
+
],
|
|
887
|
+
[
|
|
888
|
+
"my",
|
|
889
|
+
// Malaysia
|
|
890
|
+
"60",
|
|
891
|
+
0,
|
|
892
|
+
null,
|
|
893
|
+
"0"
|
|
894
|
+
],
|
|
895
|
+
[
|
|
896
|
+
"mv",
|
|
897
|
+
// Maldives
|
|
898
|
+
"960"
|
|
899
|
+
],
|
|
900
|
+
[
|
|
901
|
+
"ml",
|
|
902
|
+
// Mali
|
|
903
|
+
"223"
|
|
904
|
+
],
|
|
905
|
+
[
|
|
906
|
+
"mt",
|
|
907
|
+
// Malta
|
|
908
|
+
"356"
|
|
909
|
+
],
|
|
910
|
+
[
|
|
911
|
+
"mh",
|
|
912
|
+
// Marshall Islands
|
|
913
|
+
"692",
|
|
914
|
+
0,
|
|
915
|
+
null,
|
|
916
|
+
"1"
|
|
917
|
+
],
|
|
918
|
+
[
|
|
919
|
+
"mq",
|
|
920
|
+
// Martinique
|
|
921
|
+
"596",
|
|
922
|
+
0,
|
|
923
|
+
null,
|
|
924
|
+
"0"
|
|
925
|
+
],
|
|
926
|
+
[
|
|
927
|
+
"mr",
|
|
928
|
+
// Mauritania
|
|
929
|
+
"222"
|
|
930
|
+
],
|
|
931
|
+
[
|
|
932
|
+
"mu",
|
|
933
|
+
// Mauritius
|
|
934
|
+
"230"
|
|
935
|
+
],
|
|
936
|
+
[
|
|
937
|
+
"yt",
|
|
938
|
+
// Mayotte
|
|
939
|
+
"262",
|
|
940
|
+
1,
|
|
941
|
+
["269", "639"],
|
|
942
|
+
"0"
|
|
943
|
+
],
|
|
944
|
+
[
|
|
945
|
+
"mx",
|
|
946
|
+
// Mexico
|
|
947
|
+
"52"
|
|
948
|
+
],
|
|
949
|
+
[
|
|
950
|
+
"fm",
|
|
951
|
+
// Micronesia
|
|
952
|
+
"691"
|
|
953
|
+
],
|
|
954
|
+
[
|
|
955
|
+
"md",
|
|
956
|
+
// Moldova
|
|
957
|
+
"373",
|
|
958
|
+
0,
|
|
959
|
+
null,
|
|
960
|
+
"0"
|
|
961
|
+
],
|
|
962
|
+
[
|
|
963
|
+
"mc",
|
|
964
|
+
// Monaco
|
|
965
|
+
"377",
|
|
966
|
+
0,
|
|
967
|
+
null,
|
|
968
|
+
"0"
|
|
969
|
+
],
|
|
970
|
+
[
|
|
971
|
+
"mn",
|
|
972
|
+
// Mongolia
|
|
973
|
+
"976",
|
|
974
|
+
0,
|
|
975
|
+
null,
|
|
976
|
+
"0"
|
|
977
|
+
],
|
|
978
|
+
[
|
|
979
|
+
"me",
|
|
980
|
+
// Montenegro
|
|
981
|
+
"382",
|
|
982
|
+
0,
|
|
983
|
+
null,
|
|
984
|
+
"0"
|
|
985
|
+
],
|
|
986
|
+
[
|
|
987
|
+
"ms",
|
|
988
|
+
// Montserrat
|
|
989
|
+
"1",
|
|
990
|
+
16,
|
|
991
|
+
["664"],
|
|
992
|
+
"1"
|
|
993
|
+
],
|
|
994
|
+
[
|
|
995
|
+
"ma",
|
|
996
|
+
// Morocco
|
|
997
|
+
"212",
|
|
998
|
+
0,
|
|
999
|
+
["6", "7"],
|
|
1000
|
+
// (mobile ranges shared with EH)
|
|
1001
|
+
"0"
|
|
1002
|
+
],
|
|
1003
|
+
[
|
|
1004
|
+
"mz",
|
|
1005
|
+
// Mozambique
|
|
1006
|
+
"258"
|
|
1007
|
+
],
|
|
1008
|
+
[
|
|
1009
|
+
"mm",
|
|
1010
|
+
// Myanmar (Burma)
|
|
1011
|
+
"95",
|
|
1012
|
+
0,
|
|
1013
|
+
null,
|
|
1014
|
+
"0"
|
|
1015
|
+
],
|
|
1016
|
+
[
|
|
1017
|
+
"na",
|
|
1018
|
+
// Namibia
|
|
1019
|
+
"264",
|
|
1020
|
+
0,
|
|
1021
|
+
null,
|
|
1022
|
+
"0"
|
|
1023
|
+
],
|
|
1024
|
+
[
|
|
1025
|
+
"nr",
|
|
1026
|
+
// Nauru
|
|
1027
|
+
"674"
|
|
1028
|
+
],
|
|
1029
|
+
[
|
|
1030
|
+
"np",
|
|
1031
|
+
// Nepal
|
|
1032
|
+
"977",
|
|
1033
|
+
0,
|
|
1034
|
+
null,
|
|
1035
|
+
"0"
|
|
1036
|
+
],
|
|
1037
|
+
[
|
|
1038
|
+
"nl",
|
|
1039
|
+
// Netherlands
|
|
1040
|
+
"31",
|
|
1041
|
+
0,
|
|
1042
|
+
null,
|
|
1043
|
+
"0"
|
|
1044
|
+
],
|
|
1045
|
+
[
|
|
1046
|
+
"nc",
|
|
1047
|
+
// New Caledonia
|
|
1048
|
+
"687"
|
|
1049
|
+
],
|
|
1050
|
+
[
|
|
1051
|
+
"nz",
|
|
1052
|
+
// New Zealand
|
|
1053
|
+
"64",
|
|
1054
|
+
0,
|
|
1055
|
+
null,
|
|
1056
|
+
"0"
|
|
1057
|
+
],
|
|
1058
|
+
[
|
|
1059
|
+
"ni",
|
|
1060
|
+
// Nicaragua
|
|
1061
|
+
"505"
|
|
1062
|
+
],
|
|
1063
|
+
[
|
|
1064
|
+
"ne",
|
|
1065
|
+
// Niger
|
|
1066
|
+
"227"
|
|
1067
|
+
],
|
|
1068
|
+
[
|
|
1069
|
+
"ng",
|
|
1070
|
+
// Nigeria
|
|
1071
|
+
"234",
|
|
1072
|
+
0,
|
|
1073
|
+
null,
|
|
1074
|
+
"0"
|
|
1075
|
+
],
|
|
1076
|
+
[
|
|
1077
|
+
"nu",
|
|
1078
|
+
// Niue
|
|
1079
|
+
"683"
|
|
1080
|
+
],
|
|
1081
|
+
[
|
|
1082
|
+
"nf",
|
|
1083
|
+
// Norfolk Island
|
|
1084
|
+
"672"
|
|
1085
|
+
],
|
|
1086
|
+
[
|
|
1087
|
+
"kp",
|
|
1088
|
+
// North Korea
|
|
1089
|
+
"850",
|
|
1090
|
+
0,
|
|
1091
|
+
null,
|
|
1092
|
+
"0"
|
|
1093
|
+
],
|
|
1094
|
+
[
|
|
1095
|
+
"mk",
|
|
1096
|
+
// North Macedonia
|
|
1097
|
+
"389",
|
|
1098
|
+
0,
|
|
1099
|
+
null,
|
|
1100
|
+
"0"
|
|
1101
|
+
],
|
|
1102
|
+
[
|
|
1103
|
+
"mp",
|
|
1104
|
+
// Northern Mariana Islands
|
|
1105
|
+
"1",
|
|
1106
|
+
17,
|
|
1107
|
+
["670"],
|
|
1108
|
+
"1"
|
|
1109
|
+
],
|
|
1110
|
+
[
|
|
1111
|
+
"no",
|
|
1112
|
+
// Norway
|
|
1113
|
+
"47",
|
|
1114
|
+
0,
|
|
1115
|
+
["4", "9"]
|
|
1116
|
+
// (mobile ranges shared with SJ)
|
|
1117
|
+
],
|
|
1118
|
+
[
|
|
1119
|
+
"om",
|
|
1120
|
+
// Oman
|
|
1121
|
+
"968"
|
|
1122
|
+
],
|
|
1123
|
+
[
|
|
1124
|
+
"pk",
|
|
1125
|
+
// Pakistan
|
|
1126
|
+
"92",
|
|
1127
|
+
0,
|
|
1128
|
+
null,
|
|
1129
|
+
"0"
|
|
1130
|
+
],
|
|
1131
|
+
[
|
|
1132
|
+
"pw",
|
|
1133
|
+
// Palau
|
|
1134
|
+
"680"
|
|
1135
|
+
],
|
|
1136
|
+
[
|
|
1137
|
+
"ps",
|
|
1138
|
+
// Palestinian Territories
|
|
1139
|
+
"970",
|
|
1140
|
+
0,
|
|
1141
|
+
null,
|
|
1142
|
+
"0"
|
|
1143
|
+
],
|
|
1144
|
+
[
|
|
1145
|
+
"pa",
|
|
1146
|
+
// Panama
|
|
1147
|
+
"507"
|
|
1148
|
+
],
|
|
1149
|
+
[
|
|
1150
|
+
"pg",
|
|
1151
|
+
// Papua New Guinea
|
|
1152
|
+
"675"
|
|
1153
|
+
],
|
|
1154
|
+
[
|
|
1155
|
+
"py",
|
|
1156
|
+
// Paraguay
|
|
1157
|
+
"595",
|
|
1158
|
+
0,
|
|
1159
|
+
null,
|
|
1160
|
+
"0"
|
|
1161
|
+
],
|
|
1162
|
+
[
|
|
1163
|
+
"pe",
|
|
1164
|
+
// Peru
|
|
1165
|
+
"51",
|
|
1166
|
+
0,
|
|
1167
|
+
null,
|
|
1168
|
+
"0"
|
|
1169
|
+
],
|
|
1170
|
+
[
|
|
1171
|
+
"ph",
|
|
1172
|
+
// Philippines
|
|
1173
|
+
"63",
|
|
1174
|
+
0,
|
|
1175
|
+
null,
|
|
1176
|
+
"0"
|
|
1177
|
+
],
|
|
1178
|
+
[
|
|
1179
|
+
"pl",
|
|
1180
|
+
// Poland
|
|
1181
|
+
"48"
|
|
1182
|
+
],
|
|
1183
|
+
[
|
|
1184
|
+
"pt",
|
|
1185
|
+
// Portugal
|
|
1186
|
+
"351"
|
|
1187
|
+
],
|
|
1188
|
+
[
|
|
1189
|
+
"pr",
|
|
1190
|
+
// Puerto Rico
|
|
1191
|
+
"1",
|
|
1192
|
+
3,
|
|
1193
|
+
["787", "939"],
|
|
1194
|
+
"1"
|
|
1195
|
+
],
|
|
1196
|
+
[
|
|
1197
|
+
"qa",
|
|
1198
|
+
// Qatar
|
|
1199
|
+
"974"
|
|
1200
|
+
],
|
|
1201
|
+
[
|
|
1202
|
+
"re",
|
|
1203
|
+
// Réunion
|
|
1204
|
+
"262",
|
|
1205
|
+
0,
|
|
1206
|
+
null,
|
|
1207
|
+
"0"
|
|
1208
|
+
],
|
|
1209
|
+
[
|
|
1210
|
+
"ro",
|
|
1211
|
+
// Romania
|
|
1212
|
+
"40",
|
|
1213
|
+
0,
|
|
1214
|
+
null,
|
|
1215
|
+
"0"
|
|
1216
|
+
],
|
|
1217
|
+
[
|
|
1218
|
+
"ru",
|
|
1219
|
+
// Russia
|
|
1220
|
+
"7",
|
|
1221
|
+
0,
|
|
1222
|
+
["33"],
|
|
1223
|
+
// (shared with KZ)
|
|
1224
|
+
"8"
|
|
1225
|
+
],
|
|
1226
|
+
[
|
|
1227
|
+
"rw",
|
|
1228
|
+
// Rwanda
|
|
1229
|
+
"250",
|
|
1230
|
+
0,
|
|
1231
|
+
null,
|
|
1232
|
+
"0"
|
|
1233
|
+
],
|
|
1234
|
+
[
|
|
1235
|
+
"ws",
|
|
1236
|
+
// Samoa
|
|
1237
|
+
"685"
|
|
1238
|
+
],
|
|
1239
|
+
[
|
|
1240
|
+
"sm",
|
|
1241
|
+
// San Marino
|
|
1242
|
+
"378"
|
|
1243
|
+
],
|
|
1244
|
+
[
|
|
1245
|
+
"st",
|
|
1246
|
+
// São Tomé & Príncipe
|
|
1247
|
+
"239"
|
|
1248
|
+
],
|
|
1249
|
+
[
|
|
1250
|
+
"sa",
|
|
1251
|
+
// Saudi Arabia
|
|
1252
|
+
"966",
|
|
1253
|
+
0,
|
|
1254
|
+
null,
|
|
1255
|
+
"0"
|
|
1256
|
+
],
|
|
1257
|
+
[
|
|
1258
|
+
"sn",
|
|
1259
|
+
// Senegal
|
|
1260
|
+
"221"
|
|
1261
|
+
],
|
|
1262
|
+
[
|
|
1263
|
+
"rs",
|
|
1264
|
+
// Serbia
|
|
1265
|
+
"381",
|
|
1266
|
+
0,
|
|
1267
|
+
null,
|
|
1268
|
+
"0"
|
|
1269
|
+
],
|
|
1270
|
+
[
|
|
1271
|
+
"sc",
|
|
1272
|
+
// Seychelles
|
|
1273
|
+
"248"
|
|
1274
|
+
],
|
|
1275
|
+
[
|
|
1276
|
+
"sl",
|
|
1277
|
+
// Sierra Leone
|
|
1278
|
+
"232",
|
|
1279
|
+
0,
|
|
1280
|
+
null,
|
|
1281
|
+
"0"
|
|
1282
|
+
],
|
|
1283
|
+
[
|
|
1284
|
+
"sg",
|
|
1285
|
+
// Singapore
|
|
1286
|
+
"65"
|
|
1287
|
+
],
|
|
1288
|
+
[
|
|
1289
|
+
"sx",
|
|
1290
|
+
// Sint Maarten
|
|
1291
|
+
"1",
|
|
1292
|
+
21,
|
|
1293
|
+
["721"],
|
|
1294
|
+
"1"
|
|
1295
|
+
],
|
|
1296
|
+
[
|
|
1297
|
+
"sk",
|
|
1298
|
+
// Slovakia
|
|
1299
|
+
"421",
|
|
1300
|
+
0,
|
|
1301
|
+
null,
|
|
1302
|
+
"0"
|
|
1303
|
+
],
|
|
1304
|
+
[
|
|
1305
|
+
"si",
|
|
1306
|
+
// Slovenia
|
|
1307
|
+
"386",
|
|
1308
|
+
0,
|
|
1309
|
+
null,
|
|
1310
|
+
"0"
|
|
1311
|
+
],
|
|
1312
|
+
[
|
|
1313
|
+
"sb",
|
|
1314
|
+
// Solomon Islands
|
|
1315
|
+
"677"
|
|
1316
|
+
],
|
|
1317
|
+
[
|
|
1318
|
+
"so",
|
|
1319
|
+
// Somalia
|
|
1320
|
+
"252",
|
|
1321
|
+
0,
|
|
1322
|
+
null,
|
|
1323
|
+
"0"
|
|
1324
|
+
],
|
|
1325
|
+
[
|
|
1326
|
+
"za",
|
|
1327
|
+
// South Africa
|
|
1328
|
+
"27",
|
|
1329
|
+
0,
|
|
1330
|
+
null,
|
|
1331
|
+
"0"
|
|
1332
|
+
],
|
|
1333
|
+
[
|
|
1334
|
+
"kr",
|
|
1335
|
+
// South Korea
|
|
1336
|
+
"82",
|
|
1337
|
+
0,
|
|
1338
|
+
null,
|
|
1339
|
+
"0"
|
|
1340
|
+
],
|
|
1341
|
+
[
|
|
1342
|
+
"ss",
|
|
1343
|
+
// South Sudan
|
|
1344
|
+
"211",
|
|
1345
|
+
0,
|
|
1346
|
+
null,
|
|
1347
|
+
"0"
|
|
1348
|
+
],
|
|
1349
|
+
[
|
|
1350
|
+
"es",
|
|
1351
|
+
// Spain
|
|
1352
|
+
"34"
|
|
1353
|
+
],
|
|
1354
|
+
[
|
|
1355
|
+
"lk",
|
|
1356
|
+
// Sri Lanka
|
|
1357
|
+
"94",
|
|
1358
|
+
0,
|
|
1359
|
+
null,
|
|
1360
|
+
"0"
|
|
1361
|
+
],
|
|
1362
|
+
[
|
|
1363
|
+
"bl",
|
|
1364
|
+
// St. Barthélemy
|
|
1365
|
+
"590",
|
|
1366
|
+
1,
|
|
1367
|
+
null,
|
|
1368
|
+
"0"
|
|
1369
|
+
],
|
|
1370
|
+
[
|
|
1371
|
+
"sh",
|
|
1372
|
+
// St. Helena
|
|
1373
|
+
"290"
|
|
1374
|
+
],
|
|
1375
|
+
[
|
|
1376
|
+
"kn",
|
|
1377
|
+
// St. Kitts & Nevis
|
|
1378
|
+
"1",
|
|
1379
|
+
18,
|
|
1380
|
+
["869"],
|
|
1381
|
+
"1"
|
|
1382
|
+
],
|
|
1383
|
+
[
|
|
1384
|
+
"lc",
|
|
1385
|
+
// St. Lucia
|
|
1386
|
+
"1",
|
|
1387
|
+
19,
|
|
1388
|
+
["758"],
|
|
1389
|
+
"1"
|
|
1390
|
+
],
|
|
1391
|
+
[
|
|
1392
|
+
"mf",
|
|
1393
|
+
// St. Martin
|
|
1394
|
+
"590",
|
|
1395
|
+
2,
|
|
1396
|
+
null,
|
|
1397
|
+
"0"
|
|
1398
|
+
],
|
|
1399
|
+
[
|
|
1400
|
+
"pm",
|
|
1401
|
+
// St. Pierre & Miquelon
|
|
1402
|
+
"508",
|
|
1403
|
+
0,
|
|
1404
|
+
null,
|
|
1405
|
+
"0"
|
|
1406
|
+
],
|
|
1407
|
+
[
|
|
1408
|
+
"vc",
|
|
1409
|
+
// St. Vincent & Grenadines
|
|
1410
|
+
"1",
|
|
1411
|
+
20,
|
|
1412
|
+
["784"],
|
|
1413
|
+
"1"
|
|
1414
|
+
],
|
|
1415
|
+
[
|
|
1416
|
+
"sd",
|
|
1417
|
+
// Sudan
|
|
1418
|
+
"249",
|
|
1419
|
+
0,
|
|
1420
|
+
null,
|
|
1421
|
+
"0"
|
|
1422
|
+
],
|
|
1423
|
+
[
|
|
1424
|
+
"sr",
|
|
1425
|
+
// Suriname
|
|
1426
|
+
"597"
|
|
1427
|
+
],
|
|
1428
|
+
[
|
|
1429
|
+
"sj",
|
|
1430
|
+
// Svalbard & Jan Mayen
|
|
1431
|
+
"47",
|
|
1432
|
+
1,
|
|
1433
|
+
["4", "79", "9"]
|
|
1434
|
+
// (4 and 9 are mobile ranges shared with NO)
|
|
1435
|
+
],
|
|
1436
|
+
[
|
|
1437
|
+
"se",
|
|
1438
|
+
// Sweden
|
|
1439
|
+
"46",
|
|
1440
|
+
0,
|
|
1441
|
+
null,
|
|
1442
|
+
"0"
|
|
1443
|
+
],
|
|
1444
|
+
[
|
|
1445
|
+
"ch",
|
|
1446
|
+
// Switzerland
|
|
1447
|
+
"41",
|
|
1448
|
+
0,
|
|
1449
|
+
null,
|
|
1450
|
+
"0"
|
|
1451
|
+
],
|
|
1452
|
+
[
|
|
1453
|
+
"sy",
|
|
1454
|
+
// Syria
|
|
1455
|
+
"963",
|
|
1456
|
+
0,
|
|
1457
|
+
null,
|
|
1458
|
+
"0"
|
|
1459
|
+
],
|
|
1460
|
+
[
|
|
1461
|
+
"tw",
|
|
1462
|
+
// Taiwan
|
|
1463
|
+
"886",
|
|
1464
|
+
0,
|
|
1465
|
+
null,
|
|
1466
|
+
"0"
|
|
1467
|
+
],
|
|
1468
|
+
[
|
|
1469
|
+
"tj",
|
|
1470
|
+
// Tajikistan
|
|
1471
|
+
"992"
|
|
1472
|
+
],
|
|
1473
|
+
[
|
|
1474
|
+
"tz",
|
|
1475
|
+
// Tanzania
|
|
1476
|
+
"255",
|
|
1477
|
+
0,
|
|
1478
|
+
null,
|
|
1479
|
+
"0"
|
|
1480
|
+
],
|
|
1481
|
+
[
|
|
1482
|
+
"th",
|
|
1483
|
+
// Thailand
|
|
1484
|
+
"66",
|
|
1485
|
+
0,
|
|
1486
|
+
null,
|
|
1487
|
+
"0"
|
|
1488
|
+
],
|
|
1489
|
+
[
|
|
1490
|
+
"tl",
|
|
1491
|
+
// Timor-Leste
|
|
1492
|
+
"670"
|
|
1493
|
+
],
|
|
1494
|
+
[
|
|
1495
|
+
"tg",
|
|
1496
|
+
// Togo
|
|
1497
|
+
"228"
|
|
1498
|
+
],
|
|
1499
|
+
[
|
|
1500
|
+
"tk",
|
|
1501
|
+
// Tokelau
|
|
1502
|
+
"690"
|
|
1503
|
+
],
|
|
1504
|
+
[
|
|
1505
|
+
"to",
|
|
1506
|
+
// Tonga
|
|
1507
|
+
"676"
|
|
1508
|
+
],
|
|
1509
|
+
[
|
|
1510
|
+
"tt",
|
|
1511
|
+
// Trinidad & Tobago
|
|
1512
|
+
"1",
|
|
1513
|
+
22,
|
|
1514
|
+
["868"],
|
|
1515
|
+
"1"
|
|
1516
|
+
],
|
|
1517
|
+
[
|
|
1518
|
+
"tn",
|
|
1519
|
+
// Tunisia
|
|
1520
|
+
"216"
|
|
1521
|
+
],
|
|
1522
|
+
[
|
|
1523
|
+
"tr",
|
|
1524
|
+
// Turkey
|
|
1525
|
+
"90",
|
|
1526
|
+
0,
|
|
1527
|
+
null,
|
|
1528
|
+
"0"
|
|
1529
|
+
],
|
|
1530
|
+
[
|
|
1531
|
+
"tm",
|
|
1532
|
+
// Turkmenistan
|
|
1533
|
+
"993",
|
|
1534
|
+
0,
|
|
1535
|
+
null,
|
|
1536
|
+
"8"
|
|
1537
|
+
],
|
|
1538
|
+
[
|
|
1539
|
+
"tc",
|
|
1540
|
+
// Turks & Caicos Islands
|
|
1541
|
+
"1",
|
|
1542
|
+
23,
|
|
1543
|
+
["649"],
|
|
1544
|
+
"1"
|
|
1545
|
+
],
|
|
1546
|
+
[
|
|
1547
|
+
"tv",
|
|
1548
|
+
// Tuvalu
|
|
1549
|
+
"688"
|
|
1550
|
+
],
|
|
1551
|
+
[
|
|
1552
|
+
"vi",
|
|
1553
|
+
// U.S. Virgin Islands
|
|
1554
|
+
"1",
|
|
1555
|
+
24,
|
|
1556
|
+
["340"],
|
|
1557
|
+
"1"
|
|
1558
|
+
],
|
|
1559
|
+
[
|
|
1560
|
+
"ug",
|
|
1561
|
+
// Uganda
|
|
1562
|
+
"256",
|
|
1563
|
+
0,
|
|
1564
|
+
null,
|
|
1565
|
+
"0"
|
|
1566
|
+
],
|
|
1567
|
+
[
|
|
1568
|
+
"ua",
|
|
1569
|
+
// Ukraine
|
|
1570
|
+
"380",
|
|
1571
|
+
0,
|
|
1572
|
+
null,
|
|
1573
|
+
"0"
|
|
1574
|
+
],
|
|
1575
|
+
[
|
|
1576
|
+
"ae",
|
|
1577
|
+
// United Arab Emirates
|
|
1578
|
+
"971",
|
|
1579
|
+
0,
|
|
1580
|
+
null,
|
|
1581
|
+
"0"
|
|
1582
|
+
],
|
|
1583
|
+
[
|
|
1584
|
+
"gb",
|
|
1585
|
+
// United Kingdom
|
|
1586
|
+
"44",
|
|
1587
|
+
0,
|
|
1588
|
+
null,
|
|
1589
|
+
"0"
|
|
1590
|
+
],
|
|
1591
|
+
[
|
|
1592
|
+
"us",
|
|
1593
|
+
// United States
|
|
1594
|
+
"1",
|
|
1595
|
+
0,
|
|
1596
|
+
null,
|
|
1597
|
+
"1"
|
|
1598
|
+
],
|
|
1599
|
+
[
|
|
1600
|
+
"uy",
|
|
1601
|
+
// Uruguay
|
|
1602
|
+
"598",
|
|
1603
|
+
0,
|
|
1604
|
+
null,
|
|
1605
|
+
"0"
|
|
1606
|
+
],
|
|
1607
|
+
[
|
|
1608
|
+
"uz",
|
|
1609
|
+
// Uzbekistan
|
|
1610
|
+
"998"
|
|
1611
|
+
],
|
|
1612
|
+
[
|
|
1613
|
+
"vu",
|
|
1614
|
+
// Vanuatu
|
|
1615
|
+
"678"
|
|
1616
|
+
],
|
|
1617
|
+
[
|
|
1618
|
+
"va",
|
|
1619
|
+
// Vatican City
|
|
1620
|
+
"39",
|
|
1621
|
+
1,
|
|
1622
|
+
["06698", "3"]
|
|
1623
|
+
// (3 is a mobile range shared with IT)
|
|
1624
|
+
],
|
|
1625
|
+
[
|
|
1626
|
+
"ve",
|
|
1627
|
+
// Venezuela
|
|
1628
|
+
"58",
|
|
1629
|
+
0,
|
|
1630
|
+
null,
|
|
1631
|
+
"0"
|
|
1632
|
+
],
|
|
1633
|
+
[
|
|
1634
|
+
"vn",
|
|
1635
|
+
// Vietnam
|
|
1636
|
+
"84",
|
|
1637
|
+
0,
|
|
1638
|
+
null,
|
|
1639
|
+
"0"
|
|
1640
|
+
],
|
|
1641
|
+
[
|
|
1642
|
+
"wf",
|
|
1643
|
+
// Wallis & Futuna
|
|
1644
|
+
"681"
|
|
1645
|
+
],
|
|
1646
|
+
[
|
|
1647
|
+
"eh",
|
|
1648
|
+
// Western Sahara
|
|
1649
|
+
"212",
|
|
1650
|
+
1,
|
|
1651
|
+
["5288", "5289", "6", "7"],
|
|
1652
|
+
// (6 and 7 are mobile ranges shared with MA)
|
|
1653
|
+
"0"
|
|
1654
|
+
],
|
|
1655
|
+
[
|
|
1656
|
+
"ye",
|
|
1657
|
+
// Yemen
|
|
1658
|
+
"967",
|
|
1659
|
+
0,
|
|
1660
|
+
null,
|
|
1661
|
+
"0"
|
|
1662
|
+
],
|
|
1663
|
+
[
|
|
1664
|
+
"zm",
|
|
1665
|
+
// Zambia
|
|
1666
|
+
"260",
|
|
1667
|
+
0,
|
|
1668
|
+
null,
|
|
1669
|
+
"0"
|
|
1670
|
+
],
|
|
1671
|
+
[
|
|
1672
|
+
"zw",
|
|
1673
|
+
// Zimbabwe
|
|
1674
|
+
"263",
|
|
1675
|
+
0,
|
|
1676
|
+
null,
|
|
1677
|
+
"0"
|
|
1678
|
+
]
|
|
1679
|
+
];
|
|
1680
|
+
var allCountries = [];
|
|
1681
|
+
for (const c of rawCountryData) {
|
|
1682
|
+
allCountries.push({
|
|
1683
|
+
name: "",
|
|
1684
|
+
// populated in the plugin
|
|
1685
|
+
iso2: c[0],
|
|
1686
|
+
dialCode: c[1],
|
|
1687
|
+
priority: c[2] || 0,
|
|
1688
|
+
areaCodes: c[3] || null,
|
|
1689
|
+
nodeById: {},
|
|
1690
|
+
// populated by the plugin
|
|
1691
|
+
nationalPrefix: c[4] || null,
|
|
1692
|
+
normalisedName: "",
|
|
1693
|
+
// populated in the plugin
|
|
1694
|
+
initials: "",
|
|
1695
|
+
// populated in the plugin
|
|
1696
|
+
dialCodePlus: ""
|
|
1697
|
+
// populated in the plugin
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
var iso2Set = new Set(allCountries.map((c) => c.iso2));
|
|
1701
|
+
var isIso2 = (val) => iso2Set.has(val);
|
|
1702
|
+
var data_default = allCountries;
|
|
1703
|
+
var EVENTS = {
|
|
1704
|
+
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
1705
|
+
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
|
|
1706
|
+
COUNTRY_CHANGE: "countrychange",
|
|
1707
|
+
INPUT: "input"
|
|
1708
|
+
// used for synthetic input trigger
|
|
1709
|
+
};
|
|
1710
|
+
var CLASSES = {
|
|
1711
|
+
HIDE: "iti__hide",
|
|
1712
|
+
V_HIDE: "iti__v-hide",
|
|
1713
|
+
ARROW_UP: "iti__arrow--up",
|
|
1714
|
+
GLOBE: "iti__globe",
|
|
1715
|
+
FLAG: "iti__flag",
|
|
1716
|
+
LOADING: "iti__loading",
|
|
1717
|
+
COUNTRY_ITEM: "iti__country",
|
|
1718
|
+
HIGHLIGHT: "iti__highlight"
|
|
1719
|
+
};
|
|
1720
|
+
var KEYS = {
|
|
1721
|
+
ARROW_UP: "ArrowUp",
|
|
1722
|
+
ARROW_DOWN: "ArrowDown",
|
|
1723
|
+
SPACE: " ",
|
|
1724
|
+
ENTER: "Enter",
|
|
1725
|
+
ESC: "Escape",
|
|
1726
|
+
TAB: "Tab"
|
|
1727
|
+
};
|
|
1728
|
+
var INPUT_TYPES = {
|
|
1729
|
+
PASTE: "insertFromPaste",
|
|
1730
|
+
DELETE_FWD: "deleteContentForward"
|
|
1731
|
+
};
|
|
1732
|
+
var REGEX = {
|
|
1733
|
+
ALPHA_UNICODE: /\p{L}/u,
|
|
1734
|
+
// any kind of letter from any language
|
|
1735
|
+
NON_PLUS_NUMERIC: /[^+0-9]/,
|
|
1736
|
+
// chars that are NOT + or digit
|
|
1737
|
+
NON_PLUS_NUMERIC_GLOBAL: /[^+0-9]/g,
|
|
1738
|
+
// chars that are NOT + or digit (global)
|
|
1739
|
+
HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
|
|
1740
|
+
// single acceptable hidden-search char
|
|
1741
|
+
};
|
|
1742
|
+
var TIMINGS = {
|
|
1743
|
+
SEARCH_DEBOUNCE_MS: 100,
|
|
1744
|
+
HIDDEN_SEARCH_RESET_MS: 1e3,
|
|
1745
|
+
NEXT_TICK: 0
|
|
1746
|
+
};
|
|
1747
|
+
var SENTINELS = {
|
|
1748
|
+
UNKNOWN_NUMBER_TYPE: -99,
|
|
1749
|
+
UNKNOWN_VALIDATION_ERROR: -99
|
|
1750
|
+
};
|
|
1751
|
+
var LAYOUT = {
|
|
1752
|
+
NARROW_VIEWPORT_WIDTH: 500,
|
|
1753
|
+
// keep in sync with .iti__country-list CSS media query
|
|
1754
|
+
SANE_SELECTED_WITH_DIAL_WIDTH: 78,
|
|
1755
|
+
// px width fallback when separateDialCode enabled
|
|
1756
|
+
SANE_SELECTED_NO_DIAL_WIDTH: 42,
|
|
1757
|
+
// px width fallback when no separate dial code
|
|
1758
|
+
INPUT_PADDING_EXTRA_LEFT: 6,
|
|
1759
|
+
// px gap between selected country container and input text
|
|
1760
|
+
DROPDOWN_MARGIN: 3,
|
|
1761
|
+
// px margin between dropdown and tel input
|
|
1762
|
+
SANE_DROPDOWN_HEIGHT: 200
|
|
1763
|
+
// px height fallback for dropdown
|
|
1764
|
+
};
|
|
1765
|
+
var DIAL = {
|
|
1766
|
+
PLUS: "+",
|
|
1767
|
+
NANP: "1"
|
|
1768
|
+
// North American Numbering Plan
|
|
1769
|
+
};
|
|
1770
|
+
var UK = {
|
|
1771
|
+
ISO2: "gb",
|
|
1772
|
+
DIAL_CODE: "44",
|
|
1773
|
+
// +44 United Kingdom
|
|
1774
|
+
MOBILE_PREFIX: "7",
|
|
1775
|
+
// UK mobile numbers start with 7 after national trunk (0) or core section
|
|
1776
|
+
MOBILE_CORE_LENGTH: 10
|
|
1777
|
+
// core number length (excluding dial code / national prefix) for mobiles
|
|
1778
|
+
};
|
|
1779
|
+
var US = {
|
|
1780
|
+
ISO2: "us",
|
|
1781
|
+
DIAL_CODE: "1"
|
|
1782
|
+
// +1 United States
|
|
1783
|
+
};
|
|
1784
|
+
var PLACEHOLDER_MODES = {
|
|
1785
|
+
AGGRESSIVE: "aggressive",
|
|
1786
|
+
POLITE: "polite",
|
|
1787
|
+
OFF: "off"
|
|
1788
|
+
};
|
|
1789
|
+
var INITIAL_COUNTRY = {
|
|
1790
|
+
AUTO: "auto"
|
|
1791
|
+
};
|
|
1792
|
+
var NUMBER_TYPES = [
|
|
1793
|
+
"FIXED_LINE",
|
|
1794
|
+
"MOBILE",
|
|
1795
|
+
"FIXED_LINE_OR_MOBILE",
|
|
1796
|
+
"TOLL_FREE",
|
|
1797
|
+
"PREMIUM_RATE",
|
|
1798
|
+
"SHARED_COST",
|
|
1799
|
+
"VOIP",
|
|
1800
|
+
"PERSONAL_NUMBER",
|
|
1801
|
+
"PAGER",
|
|
1802
|
+
"UAN",
|
|
1803
|
+
"VOICEMAIL",
|
|
1804
|
+
"UNKNOWN"
|
|
1805
|
+
];
|
|
1806
|
+
var NUMBER_TYPE_SET = new Set(NUMBER_TYPES);
|
|
1807
|
+
var DATA_KEYS = {
|
|
1808
|
+
COUNTRY_CODE: "countryCode",
|
|
1809
|
+
DIAL_CODE: "dialCode"
|
|
1810
|
+
};
|
|
1811
|
+
var ARIA = {
|
|
1812
|
+
EXPANDED: "aria-expanded",
|
|
1813
|
+
LABEL: "aria-label",
|
|
1814
|
+
SELECTED: "aria-selected",
|
|
1815
|
+
ACTIVE_DESCENDANT: "aria-activedescendant",
|
|
1816
|
+
HASPOPUP: "aria-haspopup",
|
|
1817
|
+
CONTROLS: "aria-controls",
|
|
1818
|
+
HIDDEN: "aria-hidden",
|
|
1819
|
+
AUTOCOMPLETE: "aria-autocomplete",
|
|
1820
|
+
MODAL: "aria-modal"
|
|
1821
|
+
};
|
|
1822
|
+
var interfaceTranslations = {
|
|
1823
|
+
selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
|
|
1824
|
+
noCountrySelected: "Select country for phone number",
|
|
1825
|
+
countryListAriaLabel: "List of countries",
|
|
1826
|
+
searchPlaceholder: "Search",
|
|
1827
|
+
clearSearchAriaLabel: "Clear search",
|
|
1828
|
+
searchEmptyState: "No results found",
|
|
1829
|
+
searchSummaryAria(count) {
|
|
1830
|
+
if (count === 0) {
|
|
1831
|
+
return "No results found";
|
|
1832
|
+
}
|
|
1833
|
+
if (count === 1) {
|
|
1834
|
+
return "1 result found";
|
|
1835
|
+
}
|
|
1836
|
+
return `${count} results found`;
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
var en_default = interfaceTranslations;
|
|
1840
|
+
var mq = (q) => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
|
|
1841
|
+
var isNarrowViewport = () => mq(`(max-width: ${LAYOUT.NARROW_VIEWPORT_WIDTH}px)`);
|
|
1842
|
+
var computeDefaultUseFullscreenPopup = () => {
|
|
1843
|
+
if (typeof navigator !== "undefined" && typeof window !== "undefined") {
|
|
1844
|
+
const isShortViewport = mq("(max-height: 600px)");
|
|
1845
|
+
const isCoarsePointer = mq("(pointer: coarse)");
|
|
1846
|
+
return isNarrowViewport() || isCoarsePointer && isShortViewport;
|
|
1847
|
+
}
|
|
1848
|
+
return false;
|
|
1849
|
+
};
|
|
1850
|
+
var defaults = {
|
|
1851
|
+
//* Whether or not to allow the dropdown.
|
|
1852
|
+
allowDropdown: true,
|
|
1853
|
+
//* The number type to enforce during validation.
|
|
1854
|
+
allowedNumberTypes: ["MOBILE", "FIXED_LINE"],
|
|
1855
|
+
//* Whether or not to allow extensions after the main number.
|
|
1856
|
+
allowNumberExtensions: false,
|
|
1857
|
+
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1858
|
+
allowPhonewords: false,
|
|
1859
|
+
//* Add a placeholder in the input with an example number for the selected country.
|
|
1860
|
+
autoPlaceholder: PLACEHOLDER_MODES.POLITE,
|
|
1861
|
+
//* Add a custom class to the (injected) container element.
|
|
1862
|
+
containerClass: "",
|
|
1863
|
+
//* Locale for localising country names via Intl.DisplayNames.
|
|
1864
|
+
countryNameLocale: "en",
|
|
1865
|
+
//* The order of the countries in the dropdown. Defaults to alphabetical.
|
|
1866
|
+
countryOrder: null,
|
|
1867
|
+
//* Add a country search input at the top of the dropdown.
|
|
1868
|
+
countrySearch: true,
|
|
1869
|
+
//* Modify the auto placeholder.
|
|
1870
|
+
customPlaceholder: null,
|
|
1871
|
+
//* Always show the dropdown
|
|
1872
|
+
dropdownAlwaysOpen: false,
|
|
1873
|
+
//* Append menu to specified element.
|
|
1874
|
+
dropdownContainer: null,
|
|
1875
|
+
//* Don't display these countries.
|
|
1876
|
+
excludeCountries: null,
|
|
1877
|
+
//* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
|
|
1878
|
+
fixDropdownWidth: true,
|
|
1879
|
+
//* Format the number as the user types
|
|
1880
|
+
formatAsYouType: true,
|
|
1881
|
+
//* Format the input value during initialisation and on setNumber.
|
|
1882
|
+
formatOnDisplay: true,
|
|
1883
|
+
//* geoIp lookup function.
|
|
1884
|
+
geoIpLookup: null,
|
|
1885
|
+
//* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
|
|
1886
|
+
hiddenInput: null,
|
|
1887
|
+
//* Internationalise the plugin text e.g. search input placeholder, country names.
|
|
1888
|
+
i18n: {},
|
|
1889
|
+
//* Initial country.
|
|
1890
|
+
initialCountry: "",
|
|
1891
|
+
//* A function to load the utils script.
|
|
1892
|
+
loadUtils: null,
|
|
1893
|
+
//* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
|
|
1894
|
+
nationalMode: true,
|
|
1895
|
+
//* Display only these countries.
|
|
1896
|
+
onlyCountries: null,
|
|
1897
|
+
//* Number type to use for placeholders.
|
|
1898
|
+
placeholderNumberType: "MOBILE",
|
|
1899
|
+
//* Add custom classes to the search input element.
|
|
1900
|
+
searchInputClass: "",
|
|
1901
|
+
//* Display the international dial code next to the selected flag.
|
|
1902
|
+
separateDialCode: false,
|
|
1903
|
+
//* Show flags - for both the selected country, and in the country dropdown
|
|
1904
|
+
showFlags: true,
|
|
1905
|
+
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1906
|
+
strictMode: false,
|
|
1907
|
+
//* Use full screen popup instead of dropdown for country list.
|
|
1908
|
+
useFullscreenPopup: computeDefaultUseFullscreenPopup()
|
|
1909
|
+
};
|
|
1910
|
+
var toString = (val) => JSON.stringify(val);
|
|
1911
|
+
var isPlainObject = (val) => Boolean(val) && typeof val === "object" && !Array.isArray(val);
|
|
1912
|
+
var isFn = (val) => typeof val === "function";
|
|
1913
|
+
var isElLike = (val) => {
|
|
1914
|
+
if (!val || typeof val !== "object") {
|
|
1915
|
+
return false;
|
|
1916
|
+
}
|
|
1917
|
+
const v = val;
|
|
1918
|
+
return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
|
|
1919
|
+
};
|
|
1920
|
+
var placeholderModeSet = new Set(Object.values(PLACEHOLDER_MODES));
|
|
1921
|
+
var warn = (message) => {
|
|
1922
|
+
console.warn(`[intl-tel-input] ${message}`);
|
|
1923
|
+
};
|
|
1924
|
+
var warnOption = (optionName, expectedType, actualValue) => {
|
|
1925
|
+
warn(`Option '${optionName}' must be ${expectedType}; got ${toString(actualValue)}. Ignoring.`);
|
|
1926
|
+
};
|
|
1927
|
+
var hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
1928
|
+
var validateIso2Array = (key, value) => {
|
|
1929
|
+
const expectedType = "an array of ISO2 country code strings";
|
|
1930
|
+
if (!Array.isArray(value)) {
|
|
1931
|
+
warnOption(key, expectedType, value);
|
|
1932
|
+
return false;
|
|
1933
|
+
}
|
|
1934
|
+
const valid = [];
|
|
1935
|
+
for (const v of value) {
|
|
1936
|
+
if (typeof v !== "string") {
|
|
1937
|
+
warnOption(key, expectedType, value);
|
|
1938
|
+
return false;
|
|
1939
|
+
}
|
|
1940
|
+
const lower = v.toLowerCase();
|
|
1941
|
+
if (!isIso2(lower)) {
|
|
1942
|
+
warn(`Invalid country code in '${key}': '${v}'. Skipping.`);
|
|
1943
|
+
} else {
|
|
1944
|
+
valid.push(v);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return valid;
|
|
1948
|
+
};
|
|
1949
|
+
var validateOptions = (customOptions) => {
|
|
1950
|
+
if (customOptions === void 0) {
|
|
1951
|
+
return {};
|
|
1952
|
+
}
|
|
1953
|
+
if (!isPlainObject(customOptions)) {
|
|
1954
|
+
const error = `The second argument must be an options object; got ${toString(customOptions)}. Using defaults.`;
|
|
1955
|
+
warn(error);
|
|
1956
|
+
return {};
|
|
1957
|
+
}
|
|
1958
|
+
const validatedOptions = {};
|
|
1959
|
+
for (const [key, value] of Object.entries(customOptions)) {
|
|
1960
|
+
if (!hasOwn(defaults, key)) {
|
|
1961
|
+
warn(`Unknown option '${key}'. Ignoring.`);
|
|
1962
|
+
continue;
|
|
1963
|
+
}
|
|
1964
|
+
switch (key) {
|
|
1965
|
+
case "allowDropdown":
|
|
1966
|
+
case "allowNumberExtensions":
|
|
1967
|
+
case "allowPhonewords":
|
|
1968
|
+
case "countrySearch":
|
|
1969
|
+
case "dropdownAlwaysOpen":
|
|
1970
|
+
case "fixDropdownWidth":
|
|
1971
|
+
case "formatAsYouType":
|
|
1972
|
+
case "formatOnDisplay":
|
|
1973
|
+
case "nationalMode":
|
|
1974
|
+
case "showFlags":
|
|
1975
|
+
case "separateDialCode":
|
|
1976
|
+
case "strictMode":
|
|
1977
|
+
case "useFullscreenPopup":
|
|
1978
|
+
if (typeof value !== "boolean") {
|
|
1979
|
+
warnOption(key, "a boolean", value);
|
|
1980
|
+
break;
|
|
1981
|
+
}
|
|
1982
|
+
validatedOptions[key] = value;
|
|
1983
|
+
break;
|
|
1984
|
+
case "autoPlaceholder":
|
|
1985
|
+
if (typeof value !== "string" || !placeholderModeSet.has(value)) {
|
|
1986
|
+
const validModes = Array.from(placeholderModeSet).join(", ");
|
|
1987
|
+
warnOption("autoPlaceholder", `one of ${validModes}`, value);
|
|
1988
|
+
break;
|
|
1989
|
+
}
|
|
1990
|
+
validatedOptions[key] = value;
|
|
1991
|
+
break;
|
|
1992
|
+
case "containerClass":
|
|
1993
|
+
case "searchInputClass":
|
|
1994
|
+
case "countryNameLocale":
|
|
1995
|
+
if (typeof value !== "string") {
|
|
1996
|
+
warnOption(key, "a string", value);
|
|
1997
|
+
break;
|
|
1998
|
+
}
|
|
1999
|
+
validatedOptions[key] = value;
|
|
2000
|
+
break;
|
|
2001
|
+
case "countryOrder": {
|
|
2002
|
+
if (value === null) {
|
|
2003
|
+
validatedOptions[key] = value;
|
|
2004
|
+
} else {
|
|
2005
|
+
const filtered = validateIso2Array(key, value);
|
|
2006
|
+
if (filtered !== false) {
|
|
2007
|
+
validatedOptions[key] = filtered;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
break;
|
|
2011
|
+
}
|
|
2012
|
+
case "customPlaceholder":
|
|
2013
|
+
case "geoIpLookup":
|
|
2014
|
+
case "hiddenInput":
|
|
2015
|
+
case "loadUtils":
|
|
2016
|
+
if (value !== null && !isFn(value)) {
|
|
2017
|
+
warnOption(key, "a function or null", value);
|
|
2018
|
+
break;
|
|
2019
|
+
}
|
|
2020
|
+
validatedOptions[key] = value;
|
|
2021
|
+
break;
|
|
2022
|
+
case "dropdownContainer":
|
|
2023
|
+
if (value !== null && !isElLike(value)) {
|
|
2024
|
+
warnOption("dropdownContainer", "an HTMLElement or null", value);
|
|
2025
|
+
break;
|
|
2026
|
+
}
|
|
2027
|
+
validatedOptions[key] = value;
|
|
2028
|
+
break;
|
|
2029
|
+
case "excludeCountries":
|
|
2030
|
+
case "onlyCountries": {
|
|
2031
|
+
if (value === null) {
|
|
2032
|
+
validatedOptions[key] = value;
|
|
2033
|
+
} else {
|
|
2034
|
+
const filtered = validateIso2Array(key, value);
|
|
2035
|
+
if (filtered !== false) {
|
|
2036
|
+
validatedOptions[key] = filtered;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
case "i18n":
|
|
2042
|
+
if (value && !isPlainObject(value)) {
|
|
2043
|
+
warnOption("i18n", "an object", value);
|
|
2044
|
+
break;
|
|
2045
|
+
}
|
|
2046
|
+
validatedOptions[key] = value;
|
|
2047
|
+
break;
|
|
2048
|
+
case "initialCountry": {
|
|
2049
|
+
if (typeof value !== "string") {
|
|
2050
|
+
warnOption("initialCountry", "a string", value);
|
|
2051
|
+
break;
|
|
2052
|
+
}
|
|
2053
|
+
const lower = value.toLowerCase();
|
|
2054
|
+
if (lower && (lower !== INITIAL_COUNTRY.AUTO && !isIso2(lower))) {
|
|
2055
|
+
warnOption("initialCountry", "a valid ISO2 country code or 'auto'", value);
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
validatedOptions[key] = value;
|
|
2059
|
+
break;
|
|
2060
|
+
}
|
|
2061
|
+
case "placeholderNumberType":
|
|
2062
|
+
if (typeof value !== "string" || !NUMBER_TYPE_SET.has(value)) {
|
|
2063
|
+
const validTypes = Array.from(NUMBER_TYPE_SET).join(", ");
|
|
2064
|
+
warnOption("placeholderNumberType", `one of ${validTypes}`, value);
|
|
2065
|
+
break;
|
|
2066
|
+
}
|
|
2067
|
+
validatedOptions[key] = value;
|
|
2068
|
+
break;
|
|
2069
|
+
case "allowedNumberTypes":
|
|
2070
|
+
if (value !== null) {
|
|
2071
|
+
if (!Array.isArray(value)) {
|
|
2072
|
+
warnOption("allowedNumberTypes", "an array of number types or null", value);
|
|
2073
|
+
break;
|
|
2074
|
+
}
|
|
2075
|
+
let allValid = true;
|
|
2076
|
+
for (const v of value) {
|
|
2077
|
+
if (typeof v !== "string" || !NUMBER_TYPE_SET.has(v)) {
|
|
2078
|
+
const validTypes = Array.from(NUMBER_TYPE_SET).join(", ");
|
|
2079
|
+
warnOption("allowedNumberTypes", `an array of valid number types (${validTypes})`, v);
|
|
2080
|
+
allValid = false;
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
if (allValid) {
|
|
2085
|
+
validatedOptions[key] = value;
|
|
2086
|
+
}
|
|
2087
|
+
} else {
|
|
2088
|
+
validatedOptions[key] = null;
|
|
2089
|
+
}
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
return validatedOptions;
|
|
2094
|
+
};
|
|
2095
|
+
var normaliseOptions = (o) => {
|
|
2096
|
+
if (o.initialCountry) {
|
|
2097
|
+
o.initialCountry = o.initialCountry.toLowerCase();
|
|
2098
|
+
}
|
|
2099
|
+
if (o.onlyCountries?.length) {
|
|
2100
|
+
o.onlyCountries = o.onlyCountries.map((c) => c.toLowerCase());
|
|
2101
|
+
}
|
|
2102
|
+
if (o.excludeCountries?.length) {
|
|
2103
|
+
o.excludeCountries = o.excludeCountries.map((c) => c.toLowerCase());
|
|
2104
|
+
}
|
|
2105
|
+
if (o.countryOrder) {
|
|
2106
|
+
o.countryOrder = o.countryOrder.map((c) => c.toLowerCase());
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
var applyOptionSideEffects = (o) => {
|
|
2110
|
+
if (o.dropdownAlwaysOpen) {
|
|
2111
|
+
o.useFullscreenPopup = false;
|
|
2112
|
+
o.allowDropdown = true;
|
|
2113
|
+
}
|
|
2114
|
+
if (o.useFullscreenPopup) {
|
|
2115
|
+
o.fixDropdownWidth = false;
|
|
2116
|
+
} else {
|
|
2117
|
+
if (isNarrowViewport()) {
|
|
2118
|
+
o.fixDropdownWidth = true;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
if (o.onlyCountries?.length === 1) {
|
|
2122
|
+
o.initialCountry = o.onlyCountries[0];
|
|
2123
|
+
}
|
|
2124
|
+
if (o.separateDialCode) {
|
|
2125
|
+
o.nationalMode = false;
|
|
2126
|
+
}
|
|
2127
|
+
if (o.allowDropdown && !o.showFlags && !o.separateDialCode) {
|
|
2128
|
+
o.nationalMode = false;
|
|
2129
|
+
}
|
|
2130
|
+
if (o.useFullscreenPopup && !o.dropdownContainer) {
|
|
2131
|
+
o.dropdownContainer = document.body;
|
|
2132
|
+
}
|
|
2133
|
+
o.i18n = { ...en_default, ...o.i18n };
|
|
2134
|
+
};
|
|
2135
|
+
var getNumeric = (s) => s.replace(/\D/g, "");
|
|
2136
|
+
var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
2137
|
+
var getIsAndroid = () => typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
|
|
2138
|
+
var getMatchedCountries = (countries, query) => {
|
|
2139
|
+
const normalisedQuery = normaliseString(query);
|
|
2140
|
+
const iso2Matches = [];
|
|
2141
|
+
const nameStartWith = [];
|
|
2142
|
+
const nameContains = [];
|
|
2143
|
+
const dialCodeMatches = [];
|
|
2144
|
+
const dialCodeContains = [];
|
|
2145
|
+
const initialsMatches = [];
|
|
2146
|
+
for (const c of countries) {
|
|
2147
|
+
if (c.iso2 === normalisedQuery) {
|
|
2148
|
+
iso2Matches.push(c);
|
|
2149
|
+
} else if (c.normalisedName.startsWith(normalisedQuery)) {
|
|
2150
|
+
nameStartWith.push(c);
|
|
2151
|
+
} else if (c.normalisedName.includes(normalisedQuery)) {
|
|
2152
|
+
nameContains.push(c);
|
|
2153
|
+
} else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
|
|
2154
|
+
dialCodeMatches.push(c);
|
|
2155
|
+
} else if (c.dialCodePlus.includes(normalisedQuery)) {
|
|
2156
|
+
dialCodeContains.push(c);
|
|
2157
|
+
} else if (c.initials.includes(normalisedQuery)) {
|
|
2158
|
+
initialsMatches.push(c);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
const sortByPriority = (a, b) => a.priority - b.priority;
|
|
2162
|
+
return [
|
|
2163
|
+
...iso2Matches,
|
|
2164
|
+
...nameStartWith,
|
|
2165
|
+
...nameContains,
|
|
2166
|
+
// priority sort is only relevant when showing multiple countries with the same dial code (that's what the priority field is used to distinguish between)
|
|
2167
|
+
...dialCodeMatches.sort(sortByPriority),
|
|
2168
|
+
...dialCodeContains.sort(sortByPriority),
|
|
2169
|
+
...initialsMatches
|
|
2170
|
+
];
|
|
2171
|
+
};
|
|
2172
|
+
var findFirstCountryStartingWith = (countries, query) => {
|
|
2173
|
+
const normalisedQuery = normaliseString(query);
|
|
2174
|
+
for (const c of countries) {
|
|
2175
|
+
if (c.normalisedName.startsWith(normalisedQuery)) {
|
|
2176
|
+
return c;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
return null;
|
|
2180
|
+
};
|
|
2181
|
+
var buildClassNames = (flags) => Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
|
|
2182
|
+
var createEl = (tagName, attrs, container) => {
|
|
2183
|
+
const el = document.createElement(tagName);
|
|
2184
|
+
if (attrs) {
|
|
2185
|
+
Object.entries(attrs).forEach(
|
|
2186
|
+
([key, value]) => el.setAttribute(key, value)
|
|
2187
|
+
);
|
|
2188
|
+
}
|
|
2189
|
+
if (container) {
|
|
2190
|
+
container.appendChild(el);
|
|
2191
|
+
}
|
|
2192
|
+
return el;
|
|
2193
|
+
};
|
|
2194
|
+
var buildSearchIcon = () => `
|
|
2195
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${ARIA.HIDDEN}="true">
|
|
2196
|
+
<circle cx="11" cy="11" r="7" />
|
|
2197
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2198
|
+
</svg>`;
|
|
2199
|
+
var buildClearIcon = (id2) => {
|
|
2200
|
+
const maskId = `iti-${id2}-clear-mask`;
|
|
2201
|
+
return `
|
|
2202
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${ARIA.HIDDEN}="true" focusable="false">
|
|
2203
|
+
<mask id="${maskId}" maskUnits="userSpaceOnUse">
|
|
2204
|
+
<rect width="16" height="16" fill="white" />
|
|
2205
|
+
<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" />
|
|
2206
|
+
</mask>
|
|
2207
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
|
|
2208
|
+
</svg>`;
|
|
2209
|
+
};
|
|
2210
|
+
var buildCheckIcon = () => `
|
|
2211
|
+
<svg class="iti__country-check-svg" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" focusable="false" ${ARIA.HIDDEN}="true">
|
|
2212
|
+
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
|
2213
|
+
</svg>`;
|
|
2214
|
+
var buildGlobeIcon = () => `
|
|
2215
|
+
<svg width="256" height="256" viewBox="0 0 512 512" class="iti__globe-svg">
|
|
2216
|
+
<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"/>
|
|
2217
|
+
<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"/>
|
|
2218
|
+
</svg>`;
|
|
2219
|
+
var UI = class _UI {
|
|
2220
|
+
// private
|
|
2221
|
+
#options;
|
|
2222
|
+
#id;
|
|
2223
|
+
#isRTL;
|
|
2224
|
+
#originalPaddingLeft = "";
|
|
2225
|
+
#countries;
|
|
2226
|
+
#searchKeyupTimer = null;
|
|
2227
|
+
#inlineDropdownHeight;
|
|
2228
|
+
#selectedDialCode;
|
|
2229
|
+
#dropdownArrow;
|
|
2230
|
+
#dropdownContent;
|
|
2231
|
+
#searchIcon;
|
|
2232
|
+
#searchNoResults;
|
|
2233
|
+
#searchResultsA11yText;
|
|
2234
|
+
#dropdownForContainer;
|
|
2235
|
+
#selectedItem = null;
|
|
2236
|
+
// public
|
|
2237
|
+
telInput;
|
|
2238
|
+
countryContainer;
|
|
2239
|
+
selectedCountry;
|
|
2240
|
+
selectedCountryInner;
|
|
2241
|
+
searchInput;
|
|
2242
|
+
searchClearButton;
|
|
2243
|
+
countryList;
|
|
2244
|
+
hiddenInputPhone;
|
|
2245
|
+
hiddenInputCountry;
|
|
2246
|
+
highlightedItem = null;
|
|
2247
|
+
hadInitialPlaceholder;
|
|
2248
|
+
constructor(input, options, id2) {
|
|
2249
|
+
input.dataset.intlTelInputId = id2.toString();
|
|
2250
|
+
this.telInput = input;
|
|
2251
|
+
this.#options = options;
|
|
2252
|
+
this.#id = id2;
|
|
2253
|
+
this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
|
|
2254
|
+
this.#isRTL = !!this.telInput.closest("[dir=rtl]");
|
|
2255
|
+
if (this.#options.separateDialCode) {
|
|
2256
|
+
this.#originalPaddingLeft = this.telInput.style.paddingLeft;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
// Validate that the provided element is an HTMLInputElement.
|
|
2260
|
+
static validateInput(input) {
|
|
2261
|
+
const tagName = input?.tagName;
|
|
2262
|
+
const isInputEl = Boolean(input) && typeof input === "object" && tagName === "INPUT" && typeof input.setAttribute === "function";
|
|
2263
|
+
if (!isInputEl) {
|
|
2264
|
+
const type = Object.prototype.toString.call(input);
|
|
2265
|
+
throw new TypeError(
|
|
2266
|
+
`The first argument must be an HTMLInputElement, not ${type}`
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
2271
|
+
generateMarkup(countries) {
|
|
2272
|
+
this.#countries = countries;
|
|
2273
|
+
this.telInput.classList.add("iti__tel-input");
|
|
2274
|
+
if (!this.telInput.hasAttribute("type")) {
|
|
2275
|
+
this.telInput.setAttribute("type", "tel");
|
|
2276
|
+
}
|
|
2277
|
+
if (!this.telInput.hasAttribute("autocomplete")) {
|
|
2278
|
+
this.telInput.setAttribute("autocomplete", "tel");
|
|
2279
|
+
}
|
|
2280
|
+
if (!this.telInput.hasAttribute("inputmode")) {
|
|
2281
|
+
this.telInput.setAttribute("inputmode", "tel");
|
|
2282
|
+
}
|
|
2283
|
+
const wrapper = this.#createWrapperAndInsert();
|
|
2284
|
+
this.#maybeBuildCountryContainer(wrapper);
|
|
2285
|
+
wrapper.appendChild(this.telInput);
|
|
2286
|
+
this.#maybeUpdateInputPaddingAndReveal();
|
|
2287
|
+
this.#maybeBuildHiddenInputs(wrapper);
|
|
2288
|
+
}
|
|
2289
|
+
#createWrapperAndInsert() {
|
|
2290
|
+
const {
|
|
2291
|
+
allowDropdown,
|
|
2292
|
+
showFlags,
|
|
2293
|
+
containerClass,
|
|
2294
|
+
useFullscreenPopup
|
|
2295
|
+
} = this.#options;
|
|
2296
|
+
const parentClasses = buildClassNames({
|
|
2297
|
+
iti: true,
|
|
2298
|
+
"iti--allow-dropdown": allowDropdown,
|
|
2299
|
+
"iti--show-flags": showFlags,
|
|
2300
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
2301
|
+
[containerClass]: Boolean(containerClass)
|
|
2302
|
+
});
|
|
2303
|
+
const wrapper = createEl("div", { class: parentClasses });
|
|
2304
|
+
if (this.#isRTL) {
|
|
2305
|
+
wrapper.setAttribute("dir", "ltr");
|
|
2306
|
+
}
|
|
2307
|
+
this.telInput.before(wrapper);
|
|
2308
|
+
return wrapper;
|
|
2309
|
+
}
|
|
2310
|
+
#maybeBuildCountryContainer(wrapper) {
|
|
2311
|
+
const { allowDropdown, separateDialCode, showFlags } = this.#options;
|
|
2312
|
+
if (allowDropdown || showFlags || separateDialCode) {
|
|
2313
|
+
this.countryContainer = createEl(
|
|
2314
|
+
"div",
|
|
2315
|
+
// visibly hidden until we measure it's width to set the input padding correctly
|
|
2316
|
+
{ class: `iti__country-container ${CLASSES.V_HIDE}` },
|
|
2317
|
+
wrapper
|
|
2318
|
+
);
|
|
2319
|
+
if (allowDropdown) {
|
|
2320
|
+
this.selectedCountry = createEl(
|
|
2321
|
+
"button",
|
|
2322
|
+
{
|
|
2323
|
+
type: "button",
|
|
2324
|
+
class: "iti__selected-country",
|
|
2325
|
+
[ARIA.EXPANDED]: "false",
|
|
2326
|
+
[ARIA.LABEL]: this.#options.i18n.noCountrySelected,
|
|
2327
|
+
[ARIA.HASPOPUP]: "dialog",
|
|
2328
|
+
[ARIA.CONTROLS]: `iti-${this.#id}__dropdown-content`
|
|
2329
|
+
},
|
|
2330
|
+
this.countryContainer
|
|
2331
|
+
);
|
|
2332
|
+
if (this.telInput.disabled) {
|
|
2333
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
2334
|
+
}
|
|
2335
|
+
} else {
|
|
2336
|
+
this.selectedCountry = createEl(
|
|
2337
|
+
"div",
|
|
2338
|
+
{ class: "iti__selected-country" },
|
|
2339
|
+
this.countryContainer
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
const selectedCountryPrimary = createEl(
|
|
2343
|
+
"div",
|
|
2344
|
+
{ class: "iti__selected-country-primary" },
|
|
2345
|
+
this.selectedCountry
|
|
2346
|
+
);
|
|
2347
|
+
this.selectedCountryInner = createEl(
|
|
2348
|
+
"div",
|
|
2349
|
+
{ class: CLASSES.FLAG },
|
|
2350
|
+
selectedCountryPrimary
|
|
2351
|
+
);
|
|
2352
|
+
if (allowDropdown) {
|
|
2353
|
+
this.#dropdownArrow = createEl(
|
|
2354
|
+
"div",
|
|
2355
|
+
{ class: "iti__arrow", [ARIA.HIDDEN]: "true" },
|
|
2356
|
+
selectedCountryPrimary
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
if (separateDialCode) {
|
|
2360
|
+
this.#selectedDialCode = createEl(
|
|
2361
|
+
"div",
|
|
2362
|
+
{ class: "iti__selected-dial-code" },
|
|
2363
|
+
this.selectedCountry
|
|
2364
|
+
);
|
|
2365
|
+
}
|
|
2366
|
+
if (allowDropdown) {
|
|
2367
|
+
this.#buildDropdownContent();
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
#maybeEnsureDropdownWidthSet() {
|
|
2372
|
+
const { fixDropdownWidth } = this.#options;
|
|
2373
|
+
if (fixDropdownWidth && !this.#dropdownContent.style.width) {
|
|
2374
|
+
const inputWidth = this.telInput.offsetWidth;
|
|
2375
|
+
if (inputWidth > 0) {
|
|
2376
|
+
this.#dropdownContent.style.width = `${inputWidth}px`;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
#buildDropdownContent() {
|
|
2381
|
+
const {
|
|
2382
|
+
fixDropdownWidth,
|
|
2383
|
+
useFullscreenPopup,
|
|
2384
|
+
countrySearch,
|
|
2385
|
+
i18n,
|
|
2386
|
+
dropdownContainer,
|
|
2387
|
+
containerClass
|
|
2388
|
+
} = this.#options;
|
|
2389
|
+
const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2390
|
+
this.#dropdownContent = createEl("div", {
|
|
2391
|
+
id: `iti-${this.#id}__dropdown-content`,
|
|
2392
|
+
class: `iti__dropdown-content ${CLASSES.HIDE} ${extraClasses}`,
|
|
2393
|
+
role: "dialog",
|
|
2394
|
+
[ARIA.MODAL]: "true"
|
|
2395
|
+
});
|
|
2396
|
+
if (this.#isRTL) {
|
|
2397
|
+
this.#dropdownContent.setAttribute("dir", "rtl");
|
|
2398
|
+
}
|
|
2399
|
+
if (countrySearch) {
|
|
2400
|
+
this.#buildSearchUI();
|
|
2401
|
+
}
|
|
2402
|
+
this.countryList = createEl(
|
|
2403
|
+
"ul",
|
|
2404
|
+
{
|
|
2405
|
+
class: "iti__country-list",
|
|
2406
|
+
id: `iti-${this.#id}__country-listbox`,
|
|
2407
|
+
role: "listbox",
|
|
2408
|
+
[ARIA.LABEL]: i18n.countryListAriaLabel
|
|
2409
|
+
},
|
|
2410
|
+
this.#dropdownContent
|
|
2411
|
+
);
|
|
2412
|
+
this.#appendListItems();
|
|
2413
|
+
if (countrySearch) {
|
|
2414
|
+
this.#updateSearchResultsA11yText();
|
|
2415
|
+
}
|
|
2416
|
+
if (!useFullscreenPopup) {
|
|
2417
|
+
this.#maybeEnsureDropdownWidthSet();
|
|
2418
|
+
this.#inlineDropdownHeight = this.#getHiddenInlineDropdownHeight();
|
|
2419
|
+
if (countrySearch) {
|
|
2420
|
+
this.#dropdownContent.style.height = `${this.#inlineDropdownHeight}px`;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (dropdownContainer) {
|
|
2424
|
+
const dropdownClasses = buildClassNames({
|
|
2425
|
+
iti: true,
|
|
2426
|
+
"iti--container": true,
|
|
2427
|
+
"iti--fullscreen-popup": useFullscreenPopup,
|
|
2428
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
2429
|
+
[containerClass]: Boolean(containerClass)
|
|
2430
|
+
});
|
|
2431
|
+
this.#dropdownForContainer = createEl("div", { class: dropdownClasses });
|
|
2432
|
+
this.#dropdownForContainer.appendChild(this.#dropdownContent);
|
|
2433
|
+
} else {
|
|
2434
|
+
this.countryContainer.appendChild(this.#dropdownContent);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
#buildSearchUI() {
|
|
2438
|
+
const { i18n, searchInputClass } = this.#options;
|
|
2439
|
+
const searchWrapper = createEl(
|
|
2440
|
+
"div",
|
|
2441
|
+
{ class: "iti__search-input-wrapper" },
|
|
2442
|
+
this.#dropdownContent
|
|
2443
|
+
);
|
|
2444
|
+
this.#searchIcon = createEl(
|
|
2445
|
+
"span",
|
|
2446
|
+
{
|
|
2447
|
+
class: "iti__search-icon",
|
|
2448
|
+
[ARIA.HIDDEN]: "true"
|
|
2449
|
+
},
|
|
2450
|
+
searchWrapper
|
|
2451
|
+
);
|
|
2452
|
+
this.#searchIcon.innerHTML = buildSearchIcon();
|
|
2453
|
+
this.searchInput = createEl(
|
|
2454
|
+
"input",
|
|
2455
|
+
{
|
|
2456
|
+
id: `iti-${this.#id}__search-input`,
|
|
2457
|
+
// Chrome says inputs need either a name or an id
|
|
2458
|
+
type: "search",
|
|
2459
|
+
class: `iti__search-input ${searchInputClass}`,
|
|
2460
|
+
placeholder: i18n.searchPlaceholder,
|
|
2461
|
+
// 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
|
|
2462
|
+
role: "combobox",
|
|
2463
|
+
[ARIA.EXPANDED]: "true",
|
|
2464
|
+
[ARIA.LABEL]: i18n.searchPlaceholder,
|
|
2465
|
+
[ARIA.CONTROLS]: `iti-${this.#id}__country-listbox`,
|
|
2466
|
+
[ARIA.AUTOCOMPLETE]: "list",
|
|
2467
|
+
autocomplete: "off"
|
|
2468
|
+
},
|
|
2469
|
+
searchWrapper
|
|
2470
|
+
);
|
|
2471
|
+
this.searchClearButton = createEl(
|
|
2472
|
+
"button",
|
|
2473
|
+
{
|
|
2474
|
+
type: "button",
|
|
2475
|
+
class: `iti__search-clear ${CLASSES.HIDE}`,
|
|
2476
|
+
[ARIA.LABEL]: i18n.clearSearchAriaLabel,
|
|
2477
|
+
tabindex: "-1"
|
|
2478
|
+
},
|
|
2479
|
+
searchWrapper
|
|
2480
|
+
);
|
|
2481
|
+
this.searchClearButton.innerHTML = buildClearIcon(this.#id);
|
|
2482
|
+
this.#searchResultsA11yText = createEl(
|
|
2483
|
+
"span",
|
|
2484
|
+
{ class: "iti__a11y-text" },
|
|
2485
|
+
this.#dropdownContent
|
|
2486
|
+
);
|
|
2487
|
+
this.#searchNoResults = createEl(
|
|
2488
|
+
"div",
|
|
2489
|
+
{
|
|
2490
|
+
class: `iti__no-results ${CLASSES.HIDE}`,
|
|
2491
|
+
[ARIA.HIDDEN]: "true"
|
|
2492
|
+
// all a11y messaging happens in this.#searchResultsA11yText
|
|
2493
|
+
},
|
|
2494
|
+
this.#dropdownContent
|
|
2495
|
+
);
|
|
2496
|
+
this.#searchNoResults.textContent = i18n.searchEmptyState ?? null;
|
|
2497
|
+
}
|
|
2498
|
+
#maybeUpdateInputPaddingAndReveal() {
|
|
2499
|
+
if (this.countryContainer) {
|
|
2500
|
+
this.#updateInputPadding();
|
|
2501
|
+
this.countryContainer.classList.remove(CLASSES.V_HIDE);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
#maybeBuildHiddenInputs(wrapper) {
|
|
2505
|
+
const { hiddenInput } = this.#options;
|
|
2506
|
+
if (hiddenInput) {
|
|
2507
|
+
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2508
|
+
const names = hiddenInput(telInputName);
|
|
2509
|
+
if (names.phone) {
|
|
2510
|
+
const existingInput = this.telInput.form?.querySelector(
|
|
2511
|
+
`input[name="${names.phone}"]`
|
|
2512
|
+
);
|
|
2513
|
+
if (existingInput) {
|
|
2514
|
+
this.hiddenInputPhone = existingInput;
|
|
2515
|
+
} else {
|
|
2516
|
+
this.hiddenInputPhone = createEl("input", {
|
|
2517
|
+
type: "hidden",
|
|
2518
|
+
name: names.phone
|
|
2519
|
+
});
|
|
2520
|
+
wrapper.appendChild(this.hiddenInputPhone);
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
if (names.country) {
|
|
2524
|
+
const existingInput = this.telInput.form?.querySelector(
|
|
2525
|
+
`input[name="${names.country}"]`
|
|
2526
|
+
);
|
|
2527
|
+
if (existingInput) {
|
|
2528
|
+
this.hiddenInputCountry = existingInput;
|
|
2529
|
+
} else {
|
|
2530
|
+
this.hiddenInputCountry = createEl("input", {
|
|
2531
|
+
type: "hidden",
|
|
2532
|
+
name: names.country
|
|
2533
|
+
});
|
|
2534
|
+
wrapper.appendChild(this.hiddenInputCountry);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
2540
|
+
#appendListItems() {
|
|
2541
|
+
const frag = document.createDocumentFragment();
|
|
2542
|
+
for (let i = 0; i < this.#countries.length; i++) {
|
|
2543
|
+
const c = this.#countries[i];
|
|
2544
|
+
const liClass = buildClassNames({
|
|
2545
|
+
[CLASSES.COUNTRY_ITEM]: true
|
|
2546
|
+
});
|
|
2547
|
+
const listItem = createEl("li", {
|
|
2548
|
+
id: `iti-${this.#id}__item-${c.iso2}`,
|
|
2549
|
+
class: liClass,
|
|
2550
|
+
tabindex: "-1",
|
|
2551
|
+
role: "option",
|
|
2552
|
+
[ARIA.SELECTED]: "false"
|
|
2553
|
+
});
|
|
2554
|
+
listItem.dataset.dialCode = c.dialCode;
|
|
2555
|
+
listItem.dataset.countryCode = c.iso2;
|
|
2556
|
+
c.nodeById[this.#id] = listItem;
|
|
2557
|
+
if (this.#options.showFlags) {
|
|
2558
|
+
createEl("div", { class: `${CLASSES.FLAG} iti__${c.iso2}` }, listItem);
|
|
2559
|
+
}
|
|
2560
|
+
const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
|
|
2561
|
+
nameEl.textContent = `${c.name} `;
|
|
2562
|
+
const dialEl = createEl("span", { class: "iti__dial-code" }, nameEl);
|
|
2563
|
+
if (this.#isRTL) {
|
|
2564
|
+
dialEl.setAttribute("dir", "ltr");
|
|
2565
|
+
}
|
|
2566
|
+
dialEl.textContent = `(+${c.dialCode})`;
|
|
2567
|
+
frag.appendChild(listItem);
|
|
2568
|
+
}
|
|
2569
|
+
this.countryList.appendChild(frag);
|
|
2570
|
+
}
|
|
2571
|
+
//* Update the input padding to make space for the selected country/dial code.
|
|
2572
|
+
#updateInputPadding() {
|
|
2573
|
+
if (this.selectedCountry) {
|
|
2574
|
+
const fallbackWidth = this.#options.separateDialCode ? LAYOUT.SANE_SELECTED_WITH_DIAL_WIDTH : LAYOUT.SANE_SELECTED_NO_DIAL_WIDTH;
|
|
2575
|
+
const selectedCountryWidth = this.selectedCountry.offsetWidth || this.#getHiddenSelectedCountryWidth() || fallbackWidth;
|
|
2576
|
+
const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
|
|
2577
|
+
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
static #getBody() {
|
|
2581
|
+
let body;
|
|
2582
|
+
try {
|
|
2583
|
+
body = window.top.document.body;
|
|
2584
|
+
} catch (e) {
|
|
2585
|
+
body = document.body;
|
|
2586
|
+
}
|
|
2587
|
+
return body;
|
|
2588
|
+
}
|
|
2589
|
+
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
2590
|
+
//* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
|
|
2591
|
+
//* To get the right styling to apply, all we need is a shallow clone of the container,
|
|
2592
|
+
//* and then to inject a deep clone of the selectedCountry element.
|
|
2593
|
+
#getHiddenSelectedCountryWidth() {
|
|
2594
|
+
if (this.telInput.parentNode) {
|
|
2595
|
+
const body = _UI.#getBody();
|
|
2596
|
+
const containerClone = this.telInput.parentNode.cloneNode(
|
|
2597
|
+
false
|
|
2598
|
+
);
|
|
2599
|
+
containerClone.style.visibility = "hidden";
|
|
2600
|
+
body.appendChild(containerClone);
|
|
2601
|
+
const countryContainerClone = this.countryContainer.cloneNode();
|
|
2602
|
+
containerClone.appendChild(countryContainerClone);
|
|
2603
|
+
const selectedCountryClone = this.selectedCountry.cloneNode(
|
|
2604
|
+
true
|
|
2605
|
+
);
|
|
2606
|
+
countryContainerClone.appendChild(selectedCountryClone);
|
|
2607
|
+
const width = selectedCountryClone.offsetWidth;
|
|
2608
|
+
body.removeChild(containerClone);
|
|
2609
|
+
return width;
|
|
2610
|
+
}
|
|
2611
|
+
return 0;
|
|
2612
|
+
}
|
|
2613
|
+
// this is run before we add the dropdown to the DOM
|
|
2614
|
+
#getHiddenInlineDropdownHeight() {
|
|
2615
|
+
const body = _UI.#getBody();
|
|
2616
|
+
this.#dropdownContent.classList.remove(CLASSES.HIDE);
|
|
2617
|
+
const tempContainer = createEl("div", { class: "iti iti--inline-dropdown" });
|
|
2618
|
+
tempContainer.appendChild(this.#dropdownContent);
|
|
2619
|
+
tempContainer.style.visibility = "hidden";
|
|
2620
|
+
body.appendChild(tempContainer);
|
|
2621
|
+
const height = this.#dropdownContent.offsetHeight;
|
|
2622
|
+
body.removeChild(tempContainer);
|
|
2623
|
+
tempContainer.style.visibility = "";
|
|
2624
|
+
this.#dropdownContent.classList.add(CLASSES.HIDE);
|
|
2625
|
+
return height > 0 ? height : LAYOUT.SANE_DROPDOWN_HEIGHT;
|
|
2626
|
+
}
|
|
2627
|
+
//* Update search results text (for a11y).
|
|
2628
|
+
#updateSearchResultsA11yText() {
|
|
2629
|
+
const { i18n } = this.#options;
|
|
2630
|
+
const count = this.countryList.childElementCount;
|
|
2631
|
+
this.#searchResultsA11yText.textContent = i18n.searchSummaryAria(count);
|
|
2632
|
+
}
|
|
2633
|
+
//* Country search: Filter the countries according to the search query.
|
|
2634
|
+
filterCountriesByQuery(query) {
|
|
2635
|
+
let matchedCountries;
|
|
2636
|
+
if (query === "") {
|
|
2637
|
+
matchedCountries = this.#countries;
|
|
2638
|
+
} else {
|
|
2639
|
+
matchedCountries = getMatchedCountries(this.#countries, query);
|
|
2640
|
+
}
|
|
2641
|
+
this.#filterCountries(matchedCountries);
|
|
2642
|
+
}
|
|
2643
|
+
// Search input handlers
|
|
2644
|
+
#doFilter() {
|
|
2645
|
+
const inputQuery = this.searchInput.value.trim();
|
|
2646
|
+
this.filterCountriesByQuery(inputQuery);
|
|
2647
|
+
if (this.searchInput.value) {
|
|
2648
|
+
this.searchClearButton.classList.remove(CLASSES.HIDE);
|
|
2649
|
+
} else {
|
|
2650
|
+
this.searchClearButton.classList.add(CLASSES.HIDE);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
handleSearchChange() {
|
|
2654
|
+
if (this.#searchKeyupTimer) {
|
|
2655
|
+
clearTimeout(this.#searchKeyupTimer);
|
|
2656
|
+
}
|
|
2657
|
+
this.#searchKeyupTimer = setTimeout(() => {
|
|
2658
|
+
this.#doFilter();
|
|
2659
|
+
this.#searchKeyupTimer = null;
|
|
2660
|
+
}, TIMINGS.SEARCH_DEBOUNCE_MS);
|
|
2661
|
+
}
|
|
2662
|
+
handleSearchClear() {
|
|
2663
|
+
this.searchInput.value = "";
|
|
2664
|
+
this.searchInput.focus();
|
|
2665
|
+
this.#doFilter();
|
|
2666
|
+
}
|
|
2667
|
+
//* Check if a country list item element is visible within it's container (the country list), else scroll until it is.
|
|
2668
|
+
scrollCountryListToItem(element) {
|
|
2669
|
+
const container = this.countryList;
|
|
2670
|
+
const containerRect = container.getBoundingClientRect();
|
|
2671
|
+
const elementRect = element.getBoundingClientRect();
|
|
2672
|
+
const offsetTop = elementRect.top - containerRect.top + container.scrollTop;
|
|
2673
|
+
if (elementRect.top < containerRect.top) {
|
|
2674
|
+
container.scrollTop = offsetTop;
|
|
2675
|
+
} else if (elementRect.bottom > containerRect.bottom) {
|
|
2676
|
+
container.scrollTop = offsetTop - containerRect.height + elementRect.height;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
//* Remove highlighting from the previous list item and highlight the new one.
|
|
2680
|
+
highlightListItem(listItem, shouldFocus) {
|
|
2681
|
+
const prevItem = this.highlightedItem;
|
|
2682
|
+
if (prevItem) {
|
|
2683
|
+
prevItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
2684
|
+
}
|
|
2685
|
+
this.highlightedItem = listItem;
|
|
2686
|
+
if (this.highlightedItem) {
|
|
2687
|
+
this.highlightedItem.classList.add(CLASSES.HIGHLIGHT);
|
|
2688
|
+
if (this.#options.countrySearch) {
|
|
2689
|
+
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2690
|
+
this.searchInput.setAttribute(ARIA.ACTIVE_DESCENDANT, activeDescendant);
|
|
2691
|
+
}
|
|
2692
|
+
if (shouldFocus) {
|
|
2693
|
+
this.highlightedItem.focus();
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2698
|
+
handleUpDownKey(key) {
|
|
2699
|
+
let next = key === KEYS.ARROW_UP ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
|
|
2700
|
+
if (!next && this.countryList.childElementCount > 1) {
|
|
2701
|
+
next = key === KEYS.ARROW_UP ? this.countryList.lastElementChild : this.countryList.firstElementChild;
|
|
2702
|
+
}
|
|
2703
|
+
if (next) {
|
|
2704
|
+
this.scrollCountryListToItem(next);
|
|
2705
|
+
this.highlightListItem(next, false);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
// Update the selected list item in the dropdown
|
|
2709
|
+
#updateSelectedItem(iso2) {
|
|
2710
|
+
if (this.#selectedItem && this.#selectedItem.dataset.countryCode !== iso2) {
|
|
2711
|
+
this.#selectedItem.setAttribute(ARIA.SELECTED, "false");
|
|
2712
|
+
this.#selectedItem.querySelector(".iti__country-check")?.remove();
|
|
2713
|
+
this.#selectedItem = null;
|
|
2714
|
+
}
|
|
2715
|
+
if (iso2 && !this.#selectedItem) {
|
|
2716
|
+
const newListItem = this.countryList.querySelector(
|
|
2717
|
+
`[data-country-code="${iso2}"]`
|
|
2718
|
+
);
|
|
2719
|
+
if (newListItem) {
|
|
2720
|
+
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
2721
|
+
const checkIcon = createEl(
|
|
2722
|
+
"span",
|
|
2723
|
+
{ class: "iti__country-check", [ARIA.HIDDEN]: "true" },
|
|
2724
|
+
newListItem
|
|
2725
|
+
);
|
|
2726
|
+
checkIcon.innerHTML = buildCheckIcon();
|
|
2727
|
+
this.#selectedItem = newListItem;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
//* Country search: Filter the country list to the given array of countries.
|
|
2732
|
+
#filterCountries(matchedCountries) {
|
|
2733
|
+
this.countryList.replaceChildren();
|
|
2734
|
+
let noCountriesAddedYet = true;
|
|
2735
|
+
for (const c of matchedCountries) {
|
|
2736
|
+
const listItem = c.nodeById[this.#id];
|
|
2737
|
+
if (listItem) {
|
|
2738
|
+
this.countryList.appendChild(listItem);
|
|
2739
|
+
if (noCountriesAddedYet) {
|
|
2740
|
+
this.highlightListItem(listItem, false);
|
|
2741
|
+
noCountriesAddedYet = false;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
if (noCountriesAddedYet) {
|
|
2746
|
+
this.highlightListItem(null, false);
|
|
2747
|
+
if (this.#searchNoResults) {
|
|
2748
|
+
this.#searchNoResults.classList.remove(CLASSES.HIDE);
|
|
2749
|
+
}
|
|
2750
|
+
} else if (this.#searchNoResults) {
|
|
2751
|
+
this.#searchNoResults.classList.add(CLASSES.HIDE);
|
|
2752
|
+
}
|
|
2753
|
+
this.countryList.scrollTop = 0;
|
|
2754
|
+
this.#updateSearchResultsA11yText();
|
|
2755
|
+
}
|
|
2756
|
+
destroy() {
|
|
2757
|
+
this.telInput.iti = void 0;
|
|
2758
|
+
delete this.telInput.dataset.intlTelInputId;
|
|
2759
|
+
if (this.#options.separateDialCode) {
|
|
2760
|
+
this.telInput.style.paddingLeft = this.#originalPaddingLeft;
|
|
2761
|
+
}
|
|
2762
|
+
const wrapper = this.telInput.parentNode;
|
|
2763
|
+
wrapper.before(this.telInput);
|
|
2764
|
+
wrapper.remove();
|
|
2765
|
+
for (const c of this.#countries) {
|
|
2766
|
+
delete c.nodeById[this.#id];
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
// UI: Open the dropdown (DOM only).
|
|
2770
|
+
openDropdown() {
|
|
2771
|
+
const {
|
|
2772
|
+
countrySearch,
|
|
2773
|
+
dropdownAlwaysOpen,
|
|
2774
|
+
dropdownContainer
|
|
2775
|
+
} = this.#options;
|
|
2776
|
+
this.#maybeEnsureDropdownWidthSet();
|
|
2777
|
+
if (dropdownContainer) {
|
|
2778
|
+
this.#handleDropdownContainer();
|
|
2779
|
+
} else {
|
|
2780
|
+
const positionBelow = this.#shouldPositionInlineDropdownBelowInput();
|
|
2781
|
+
const distance = this.telInput.offsetHeight + LAYOUT.DROPDOWN_MARGIN;
|
|
2782
|
+
if (positionBelow) {
|
|
2783
|
+
this.#dropdownContent.style.top = `${distance}px`;
|
|
2784
|
+
} else {
|
|
2785
|
+
this.#dropdownContent.style.bottom = `${distance}px`;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
this.#dropdownContent.classList.remove(CLASSES.HIDE);
|
|
2789
|
+
this.selectedCountry.setAttribute(ARIA.EXPANDED, "true");
|
|
2790
|
+
if (countrySearch) {
|
|
2791
|
+
const itemToHighlight = this.#selectedItem ?? this.countryList.firstElementChild;
|
|
2792
|
+
if (itemToHighlight) {
|
|
2793
|
+
this.highlightListItem(itemToHighlight, false);
|
|
2794
|
+
this.scrollCountryListToItem(itemToHighlight);
|
|
2795
|
+
}
|
|
2796
|
+
if (!dropdownAlwaysOpen) {
|
|
2797
|
+
this.searchInput.focus();
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
this.#dropdownArrow.classList.add(CLASSES.ARROW_UP);
|
|
2801
|
+
}
|
|
2802
|
+
// UI: Close the dropdown (DOM only).
|
|
2803
|
+
closeDropdown() {
|
|
2804
|
+
const { countrySearch, dropdownContainer } = this.#options;
|
|
2805
|
+
this.#dropdownContent.classList.add(CLASSES.HIDE);
|
|
2806
|
+
this.selectedCountry.setAttribute(ARIA.EXPANDED, "false");
|
|
2807
|
+
if (countrySearch) {
|
|
2808
|
+
this.searchInput.removeAttribute(ARIA.ACTIVE_DESCENDANT);
|
|
2809
|
+
this.searchInput.value = "";
|
|
2810
|
+
this.#doFilter();
|
|
2811
|
+
if (this.highlightedItem) {
|
|
2812
|
+
this.highlightedItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
2813
|
+
this.highlightedItem = null;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
this.#dropdownArrow.classList.remove(CLASSES.ARROW_UP);
|
|
2817
|
+
if (dropdownContainer) {
|
|
2818
|
+
this.#dropdownForContainer.remove();
|
|
2819
|
+
this.#dropdownForContainer.style.top = "";
|
|
2820
|
+
this.#dropdownForContainer.style.bottom = "";
|
|
2821
|
+
this.#dropdownForContainer.style.paddingLeft = "";
|
|
2822
|
+
this.#dropdownForContainer.style.paddingRight = "";
|
|
2823
|
+
} else {
|
|
2824
|
+
this.#dropdownContent.style.top = "";
|
|
2825
|
+
this.#dropdownContent.style.bottom = "";
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
#shouldPositionInlineDropdownBelowInput() {
|
|
2829
|
+
if (this.#options.dropdownAlwaysOpen) {
|
|
2830
|
+
return true;
|
|
2831
|
+
}
|
|
2832
|
+
const inputPos = this.telInput.getBoundingClientRect();
|
|
2833
|
+
const spaceAbove = inputPos.top;
|
|
2834
|
+
const spaceBelow = window.innerHeight - inputPos.bottom;
|
|
2835
|
+
return spaceBelow >= this.#inlineDropdownHeight || spaceBelow >= spaceAbove;
|
|
2836
|
+
}
|
|
2837
|
+
// inject dropdown into container and apply positioning styles
|
|
2838
|
+
#handleDropdownContainer() {
|
|
2839
|
+
const { dropdownContainer, useFullscreenPopup } = this.#options;
|
|
2840
|
+
if (useFullscreenPopup) {
|
|
2841
|
+
if (window.innerWidth >= LAYOUT.NARROW_VIEWPORT_WIDTH) {
|
|
2842
|
+
const inputPos = this.telInput.getBoundingClientRect();
|
|
2843
|
+
this.#dropdownForContainer.style.paddingLeft = `${inputPos.left}px`;
|
|
2844
|
+
this.#dropdownForContainer.style.paddingRight = `${window.innerWidth - inputPos.right}px`;
|
|
2845
|
+
}
|
|
2846
|
+
} else {
|
|
2847
|
+
const inputPos = this.telInput.getBoundingClientRect();
|
|
2848
|
+
this.#dropdownForContainer.style.left = `${inputPos.left}px`;
|
|
2849
|
+
const positionBelow = this.#shouldPositionInlineDropdownBelowInput();
|
|
2850
|
+
if (positionBelow) {
|
|
2851
|
+
this.#dropdownForContainer.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
2852
|
+
} else {
|
|
2853
|
+
this.#dropdownForContainer.style.top = "unset";
|
|
2854
|
+
this.#dropdownForContainer.style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
dropdownContainer.appendChild(this.#dropdownForContainer);
|
|
2858
|
+
}
|
|
2859
|
+
// UI: Whether the dropdown is currently closed (hidden).
|
|
2860
|
+
isDropdownClosed() {
|
|
2861
|
+
return this.#dropdownContent.classList.contains(CLASSES.HIDE);
|
|
2862
|
+
}
|
|
2863
|
+
setCountry(selectedCountryData) {
|
|
2864
|
+
const { allowDropdown, showFlags, separateDialCode, i18n } = this.#options;
|
|
2865
|
+
const name = selectedCountryData?.name;
|
|
2866
|
+
const dialCode = selectedCountryData?.dialCode;
|
|
2867
|
+
const iso2 = selectedCountryData?.iso2 ?? "";
|
|
2868
|
+
if (allowDropdown) {
|
|
2869
|
+
this.#updateSelectedItem(iso2);
|
|
2870
|
+
}
|
|
2871
|
+
if (this.selectedCountry) {
|
|
2872
|
+
const flagClass = iso2 && showFlags ? `${CLASSES.FLAG} iti__${iso2}` : `${CLASSES.FLAG} ${CLASSES.GLOBE}`;
|
|
2873
|
+
let ariaLabel, title, selectedCountryInner;
|
|
2874
|
+
if (iso2) {
|
|
2875
|
+
title = name;
|
|
2876
|
+
ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
|
|
2877
|
+
selectedCountryInner = showFlags ? "" : buildGlobeIcon();
|
|
2878
|
+
} else {
|
|
2879
|
+
title = i18n.noCountrySelected;
|
|
2880
|
+
ariaLabel = i18n.noCountrySelected;
|
|
2881
|
+
selectedCountryInner = buildGlobeIcon();
|
|
2882
|
+
}
|
|
2883
|
+
this.selectedCountryInner.className = flagClass;
|
|
2884
|
+
this.selectedCountry.setAttribute("title", title);
|
|
2885
|
+
this.selectedCountry.setAttribute(ARIA.LABEL, ariaLabel);
|
|
2886
|
+
this.selectedCountryInner.innerHTML = selectedCountryInner;
|
|
2887
|
+
}
|
|
2888
|
+
if (separateDialCode) {
|
|
2889
|
+
const fullDialCode = dialCode ? `+${dialCode}` : "";
|
|
2890
|
+
this.#selectedDialCode.textContent = fullDialCode;
|
|
2891
|
+
this.#updateInputPadding();
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
};
|
|
2895
|
+
var processAllCountries = (options) => {
|
|
2896
|
+
const { onlyCountries, excludeCountries } = options;
|
|
2897
|
+
if (onlyCountries?.length) {
|
|
2898
|
+
return data_default.filter(
|
|
2899
|
+
(country) => onlyCountries.includes(country.iso2)
|
|
2900
|
+
);
|
|
2901
|
+
} else if (excludeCountries?.length) {
|
|
2902
|
+
return data_default.filter(
|
|
2903
|
+
(country) => !excludeCountries.includes(country.iso2)
|
|
2904
|
+
);
|
|
2905
|
+
}
|
|
2906
|
+
return data_default;
|
|
2907
|
+
};
|
|
2908
|
+
var generateCountryNames = (countries, options) => {
|
|
2909
|
+
const { countryNameLocale, i18n } = options;
|
|
2910
|
+
let displayNames;
|
|
2911
|
+
try {
|
|
2912
|
+
const hasDisplayNames = typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function";
|
|
2913
|
+
if (hasDisplayNames) {
|
|
2914
|
+
displayNames = new Intl.DisplayNames(countryNameLocale, {
|
|
2915
|
+
type: "region"
|
|
2916
|
+
});
|
|
2917
|
+
} else {
|
|
2918
|
+
displayNames = null;
|
|
2919
|
+
}
|
|
2920
|
+
} catch (e) {
|
|
2921
|
+
console.error(e);
|
|
2922
|
+
displayNames = null;
|
|
2923
|
+
}
|
|
2924
|
+
for (const c of countries) {
|
|
2925
|
+
c.name = i18n[c.iso2] || displayNames?.of(c.iso2.toUpperCase()) || "";
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
var processDialCodes = (countries) => {
|
|
2929
|
+
const dialCodes = /* @__PURE__ */ new Set();
|
|
2930
|
+
let dialCodeMaxLen = 0;
|
|
2931
|
+
const dialCodeToIso2Map = {};
|
|
2932
|
+
const addToDialCodeMap = (iso2, dialCode) => {
|
|
2933
|
+
if (!iso2 || !dialCode) {
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
if (dialCode.length > dialCodeMaxLen) {
|
|
2937
|
+
dialCodeMaxLen = dialCode.length;
|
|
2938
|
+
}
|
|
2939
|
+
if (!dialCodeToIso2Map.hasOwnProperty(dialCode)) {
|
|
2940
|
+
dialCodeToIso2Map[dialCode] = [];
|
|
2941
|
+
}
|
|
2942
|
+
const iso2List = dialCodeToIso2Map[dialCode];
|
|
2943
|
+
if (iso2List.includes(iso2)) {
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
iso2List.push(iso2);
|
|
2947
|
+
};
|
|
2948
|
+
const countriesSortedByPriority = [...countries].sort((a, b) => a.priority - b.priority);
|
|
2949
|
+
for (const c of countriesSortedByPriority) {
|
|
2950
|
+
if (!dialCodes.has(c.dialCode)) {
|
|
2951
|
+
dialCodes.add(c.dialCode);
|
|
2952
|
+
}
|
|
2953
|
+
for (let k = 1; k < c.dialCode.length; k++) {
|
|
2954
|
+
const partialDialCode = c.dialCode.substring(0, k);
|
|
2955
|
+
addToDialCodeMap(c.iso2, partialDialCode);
|
|
2956
|
+
}
|
|
2957
|
+
addToDialCodeMap(c.iso2, c.dialCode);
|
|
2958
|
+
if (c.areaCodes) {
|
|
2959
|
+
const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
|
|
2960
|
+
for (const areaCode of c.areaCodes) {
|
|
2961
|
+
for (let k = 1; k < areaCode.length; k++) {
|
|
2962
|
+
const partialAreaCode = areaCode.substring(0, k);
|
|
2963
|
+
const partialDialCode = c.dialCode + partialAreaCode;
|
|
2964
|
+
addToDialCodeMap(rootIso2Code, partialDialCode);
|
|
2965
|
+
addToDialCodeMap(c.iso2, partialDialCode);
|
|
2966
|
+
}
|
|
2967
|
+
addToDialCodeMap(c.iso2, c.dialCode + areaCode);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
|
|
2972
|
+
};
|
|
2973
|
+
var sortCountries = (countries, options) => {
|
|
2974
|
+
const { countryOrder } = options;
|
|
2975
|
+
countries.sort((a, b) => {
|
|
2976
|
+
if (countryOrder) {
|
|
2977
|
+
const aIndex = countryOrder.indexOf(a.iso2);
|
|
2978
|
+
const bIndex = countryOrder.indexOf(b.iso2);
|
|
2979
|
+
const aIndexExists = aIndex > -1;
|
|
2980
|
+
const bIndexExists = bIndex > -1;
|
|
2981
|
+
if (aIndexExists || bIndexExists) {
|
|
2982
|
+
if (aIndexExists && bIndexExists) {
|
|
2983
|
+
return aIndex - bIndex;
|
|
2984
|
+
}
|
|
2985
|
+
return aIndexExists ? -1 : 1;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
return a.name.localeCompare(b.name);
|
|
2989
|
+
});
|
|
2990
|
+
};
|
|
2991
|
+
var cacheSearchTokens = (countries) => {
|
|
2992
|
+
for (const c of countries) {
|
|
2993
|
+
c.normalisedName = normaliseString(c.name);
|
|
2994
|
+
c.initials = c.normalisedName.split(/[^a-z]/).map((word) => word[0]).join("");
|
|
2995
|
+
c.dialCodePlus = `+${c.dialCode}`;
|
|
2996
|
+
}
|
|
2997
|
+
};
|
|
2998
|
+
var REGIONLESS_DIAL_CODES = /* @__PURE__ */ new Set([
|
|
2999
|
+
"800",
|
|
3000
|
+
"808",
|
|
3001
|
+
"870",
|
|
3002
|
+
"881",
|
|
3003
|
+
"882",
|
|
3004
|
+
"883",
|
|
3005
|
+
"888",
|
|
3006
|
+
"979"
|
|
3007
|
+
]);
|
|
3008
|
+
var hasRegionlessDialCode = (number) => {
|
|
3009
|
+
const dialCode = getNumeric(number).slice(0, 3);
|
|
3010
|
+
return number.startsWith("+") && REGIONLESS_DIAL_CODES.has(dialCode);
|
|
3011
|
+
};
|
|
3012
|
+
var beforeSetNumber = (fullNumber, hasValidDialCode, separateDialCode, selectedCountryData) => {
|
|
3013
|
+
let number = fullNumber;
|
|
3014
|
+
if (separateDialCode) {
|
|
3015
|
+
if (hasValidDialCode) {
|
|
3016
|
+
const dialCode = `+${selectedCountryData.dialCode}`;
|
|
3017
|
+
const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
|
|
3018
|
+
number = number.substring(start);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
return number;
|
|
3022
|
+
};
|
|
3023
|
+
var formatNumberAsYouType = (fullNumber, telInputValue, utils, selectedCountryData, separateDialCode) => {
|
|
3024
|
+
const result = utils ? utils.formatNumberAsYouType(fullNumber, selectedCountryData?.iso2) : fullNumber;
|
|
3025
|
+
const dialCode = selectedCountryData?.dialCode;
|
|
3026
|
+
if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
|
|
3027
|
+
const afterDialCode = result.split(`+${dialCode}`)[1] || "";
|
|
3028
|
+
return afterDialCode.trim();
|
|
3029
|
+
}
|
|
3030
|
+
return result;
|
|
3031
|
+
};
|
|
3032
|
+
var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => {
|
|
3033
|
+
if (prevCaretPos === 0 && !isDeleteForwards) {
|
|
3034
|
+
return 0;
|
|
3035
|
+
}
|
|
3036
|
+
let relevantCharCount = 0;
|
|
3037
|
+
for (let i = 0; i < formattedValue.length; i++) {
|
|
3038
|
+
if (/[+0-9]/.test(formattedValue[i])) {
|
|
3039
|
+
relevantCharCount++;
|
|
3040
|
+
}
|
|
3041
|
+
if (relevantCharCount === relevantChars && !isDeleteForwards) {
|
|
3042
|
+
return i + 1;
|
|
3043
|
+
}
|
|
3044
|
+
if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
|
|
3045
|
+
return i;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
return formattedValue.length;
|
|
3049
|
+
};
|
|
3050
|
+
var regionlessNanpNumbers = /* @__PURE__ */ new Set([
|
|
3051
|
+
"800",
|
|
3052
|
+
"822",
|
|
3053
|
+
"833",
|
|
3054
|
+
"844",
|
|
3055
|
+
"855",
|
|
3056
|
+
"866",
|
|
3057
|
+
"877",
|
|
3058
|
+
"880",
|
|
3059
|
+
"881",
|
|
3060
|
+
"882",
|
|
3061
|
+
"883",
|
|
3062
|
+
"884",
|
|
3063
|
+
"885",
|
|
3064
|
+
"886",
|
|
3065
|
+
"887",
|
|
3066
|
+
"888",
|
|
3067
|
+
"889"
|
|
3068
|
+
]);
|
|
3069
|
+
var isRegionlessNanp = (number) => {
|
|
3070
|
+
const numeric = getNumeric(number);
|
|
3071
|
+
if (numeric.startsWith(DIAL.NANP) && numeric.length >= 4) {
|
|
3072
|
+
const areaCode = numeric.substring(1, 4);
|
|
3073
|
+
return regionlessNanpNumbers.has(areaCode);
|
|
3074
|
+
}
|
|
3075
|
+
return false;
|
|
3076
|
+
};
|
|
3077
|
+
var Numerals = class {
|
|
3078
|
+
#userNumeralSet;
|
|
3079
|
+
constructor(initialValue) {
|
|
3080
|
+
if (initialValue) {
|
|
3081
|
+
this.#updateNumeralSet(initialValue);
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
// If any Arabic-Indic digits, then label it as that set. Same for Persian. Otherwise assume ASCII.
|
|
3085
|
+
#updateNumeralSet(str) {
|
|
3086
|
+
if (/[\u0660-\u0669]/.test(str)) {
|
|
3087
|
+
this.#userNumeralSet = "arabic-indic";
|
|
3088
|
+
} else if (/[\u06F0-\u06F9]/.test(str)) {
|
|
3089
|
+
this.#userNumeralSet = "persian";
|
|
3090
|
+
} else {
|
|
3091
|
+
this.#userNumeralSet = "ascii";
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
// Denormalise ASCII 0-9 to the user's numeral set. If not yet known, return as-is.
|
|
3095
|
+
// NOTE: normalise is always called before this, so it should be impossible for the numeral set to be unknown at this point.
|
|
3096
|
+
denormalise(str) {
|
|
3097
|
+
if (!this.#userNumeralSet || this.#userNumeralSet === "ascii") {
|
|
3098
|
+
return str;
|
|
3099
|
+
}
|
|
3100
|
+
const base = this.#userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
3101
|
+
return str.replace(/[0-9]/g, (d) => String.fromCharCode(base + Number(d)));
|
|
3102
|
+
}
|
|
3103
|
+
// Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
|
|
3104
|
+
normalise(str) {
|
|
3105
|
+
if (!str) {
|
|
3106
|
+
return "";
|
|
3107
|
+
}
|
|
3108
|
+
this.#updateNumeralSet(str);
|
|
3109
|
+
if (this.#userNumeralSet === "ascii") {
|
|
3110
|
+
return str;
|
|
3111
|
+
}
|
|
3112
|
+
const base = this.#userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
3113
|
+
const regex = this.#userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
3114
|
+
return str.replace(regex, (ch) => String.fromCharCode(48 + (ch.charCodeAt(0) - base)));
|
|
3115
|
+
}
|
|
3116
|
+
isAscii() {
|
|
3117
|
+
return !this.#userNumeralSet || this.#userNumeralSet === "ascii";
|
|
3118
|
+
}
|
|
3119
|
+
};
|
|
3120
|
+
var id = 0;
|
|
3121
|
+
var ensureUtils = (methodName) => {
|
|
3122
|
+
if (!intlTelInput.utils) {
|
|
3123
|
+
throw new Error(`intlTelInput.utils is required for ${methodName}(). See: https://intl-tel-input.com/docs/utils`);
|
|
3124
|
+
}
|
|
3125
|
+
};
|
|
3126
|
+
var createDeferred = () => {
|
|
3127
|
+
let resolve;
|
|
3128
|
+
let reject;
|
|
3129
|
+
const promise = new Promise((res, rej) => {
|
|
3130
|
+
resolve = res;
|
|
3131
|
+
reject = rej;
|
|
3132
|
+
});
|
|
3133
|
+
return { promise, resolve, reject };
|
|
3134
|
+
};
|
|
3135
|
+
var Iti = class _Iti {
|
|
3136
|
+
//* PUBLIC FIELDS - READONLY
|
|
3137
|
+
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
3138
|
+
id;
|
|
3139
|
+
// accessed externally via iti.promise.then(...)
|
|
3140
|
+
promise;
|
|
3141
|
+
//* PRIVATE FIELDS
|
|
3142
|
+
#ui;
|
|
3143
|
+
#options;
|
|
3144
|
+
#isAndroid;
|
|
3145
|
+
// country data
|
|
3146
|
+
#countries;
|
|
3147
|
+
#dialCodeMaxLen;
|
|
3148
|
+
#dialCodeToIso2Map;
|
|
3149
|
+
#dialCodes;
|
|
3150
|
+
#countryByIso2;
|
|
3151
|
+
#selectedCountryData = null;
|
|
3152
|
+
#maxCoreNumberLength = null;
|
|
3153
|
+
#defaultCountry;
|
|
3154
|
+
#destroyed = false;
|
|
3155
|
+
#abortController;
|
|
3156
|
+
#dropdownAbortController = null;
|
|
3157
|
+
#numerals;
|
|
3158
|
+
#autoCountryDeferred;
|
|
3159
|
+
#utilsScriptDeferred;
|
|
3160
|
+
constructor(input, customOptions = {}) {
|
|
3161
|
+
this.id = id++;
|
|
3162
|
+
UI.validateInput(input);
|
|
3163
|
+
const validatedOptions = validateOptions(customOptions);
|
|
3164
|
+
this.#options = { ...defaults, ...validatedOptions };
|
|
3165
|
+
normaliseOptions(this.#options);
|
|
3166
|
+
applyOptionSideEffects(this.#options);
|
|
3167
|
+
this.#ui = new UI(input, this.#options, this.id);
|
|
3168
|
+
this.#isAndroid = getIsAndroid();
|
|
3169
|
+
this.#numerals = new Numerals(input.value);
|
|
3170
|
+
this.promise = this.#createInitPromises(this.#options);
|
|
3171
|
+
this.#countries = processAllCountries(this.#options);
|
|
3172
|
+
const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(
|
|
3173
|
+
this.#countries
|
|
3174
|
+
);
|
|
3175
|
+
this.#dialCodes = dialCodes;
|
|
3176
|
+
this.#dialCodeMaxLen = dialCodeMaxLen;
|
|
3177
|
+
this.#dialCodeToIso2Map = dialCodeToIso2Map;
|
|
3178
|
+
this.#countryByIso2 = new Map(this.#countries.map((c) => [c.iso2, c]));
|
|
3179
|
+
this.#init();
|
|
3180
|
+
}
|
|
3181
|
+
#getTelInputValue() {
|
|
3182
|
+
const inputValue = this.#ui.telInput.value.trim();
|
|
3183
|
+
return this.#numerals.normalise(inputValue);
|
|
3184
|
+
}
|
|
3185
|
+
#setTelInputValue(asciiValue) {
|
|
3186
|
+
this.#ui.telInput.value = this.#numerals.denormalise(asciiValue);
|
|
3187
|
+
}
|
|
3188
|
+
#createInitPromises(options) {
|
|
3189
|
+
const { initialCountry, geoIpLookup, loadUtils } = options;
|
|
3190
|
+
const needsAutoCountryPromise = initialCountry === INITIAL_COUNTRY.AUTO && Boolean(geoIpLookup);
|
|
3191
|
+
const needsUtilsScriptPromise = Boolean(loadUtils) && !intlTelInput.utils;
|
|
3192
|
+
if (needsAutoCountryPromise) {
|
|
3193
|
+
this.#autoCountryDeferred = createDeferred();
|
|
3194
|
+
}
|
|
3195
|
+
if (needsUtilsScriptPromise) {
|
|
3196
|
+
this.#utilsScriptDeferred = createDeferred();
|
|
3197
|
+
}
|
|
3198
|
+
return Promise.all([
|
|
3199
|
+
this.#autoCountryDeferred?.promise,
|
|
3200
|
+
this.#utilsScriptDeferred?.promise
|
|
3201
|
+
]).then(() => {
|
|
3202
|
+
});
|
|
3203
|
+
}
|
|
3204
|
+
#init() {
|
|
3205
|
+
this.#abortController = new AbortController();
|
|
3206
|
+
this.#processCountryData();
|
|
3207
|
+
this.#ui.generateMarkup(this.#countries);
|
|
3208
|
+
this.#setInitialState();
|
|
3209
|
+
this.#initListeners();
|
|
3210
|
+
this.#initRequests();
|
|
3211
|
+
if (this.#options.dropdownAlwaysOpen) {
|
|
3212
|
+
this.#openDropdown();
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
//********************
|
|
3216
|
+
//* PRIVATE METHODS
|
|
3217
|
+
//********************
|
|
3218
|
+
//* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
|
|
3219
|
+
#processCountryData() {
|
|
3220
|
+
generateCountryNames(this.#countries, this.#options);
|
|
3221
|
+
sortCountries(this.#countries, this.#options);
|
|
3222
|
+
cacheSearchTokens(this.#countries);
|
|
3223
|
+
}
|
|
3224
|
+
//* Set the initial state of the input value and the selected country by:
|
|
3225
|
+
//* 1. Extracting a dial code from the given number
|
|
3226
|
+
//* 2. Using explicit initialCountry
|
|
3227
|
+
#setInitialState(overrideAutoCountry = false) {
|
|
3228
|
+
const attributeValueRaw = this.#ui.telInput.getAttribute("value");
|
|
3229
|
+
const attributeValue = this.#numerals.normalise(attributeValueRaw ?? "");
|
|
3230
|
+
const inputValue = this.#getTelInputValue();
|
|
3231
|
+
const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
|
|
3232
|
+
const val = useAttribute ? attributeValue : inputValue;
|
|
3233
|
+
const dialCode = this.#getDialCode(val);
|
|
3234
|
+
const isRegionlessNanpNumber = isRegionlessNanp(val);
|
|
3235
|
+
const { initialCountry, geoIpLookup } = this.#options;
|
|
3236
|
+
const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
|
|
3237
|
+
const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry;
|
|
3238
|
+
const isValidInitialCountry = isIso2(initialCountry);
|
|
3239
|
+
if (dialCode) {
|
|
3240
|
+
if (isRegionlessNanpNumber) {
|
|
3241
|
+
if (isValidInitialCountry) {
|
|
3242
|
+
this.#setCountry(initialCountry);
|
|
3243
|
+
} else if (!doingAutoCountryLookup) {
|
|
3244
|
+
this.#setCountry(US.ISO2);
|
|
3245
|
+
}
|
|
3246
|
+
} else {
|
|
3247
|
+
this.#updateCountryFromNumber(val);
|
|
3248
|
+
}
|
|
3249
|
+
} else if (isValidInitialCountry) {
|
|
3250
|
+
this.#setCountry(initialCountry);
|
|
3251
|
+
} else if (!doingAutoCountryLookup) {
|
|
3252
|
+
this.#setCountry("");
|
|
3253
|
+
}
|
|
3254
|
+
if (val) {
|
|
3255
|
+
this.#updateValFromNumber(val);
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
//* Initialise the main event listeners: input keyup, and click selected country.
|
|
3259
|
+
#initListeners() {
|
|
3260
|
+
this.#initTelInputListeners();
|
|
3261
|
+
if (this.#options.allowDropdown) {
|
|
3262
|
+
this.#initDropdownListeners();
|
|
3263
|
+
}
|
|
3264
|
+
if ((this.#ui.hiddenInputPhone || this.#ui.hiddenInputCountry) && this.#ui.telInput.form) {
|
|
3265
|
+
this.#initHiddenInputListener();
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
//* Update hidden input on form submit.
|
|
3269
|
+
#initHiddenInputListener() {
|
|
3270
|
+
const handleHiddenInputSubmit = () => {
|
|
3271
|
+
if (this.#ui.hiddenInputPhone) {
|
|
3272
|
+
this.#ui.hiddenInputPhone.value = this.getNumber();
|
|
3273
|
+
}
|
|
3274
|
+
if (this.#ui.hiddenInputCountry) {
|
|
3275
|
+
this.#ui.hiddenInputCountry.value = this.#selectedCountryData?.iso2 || "";
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3278
|
+
this.#ui.telInput.form?.addEventListener("submit", handleHiddenInputSubmit, {
|
|
3279
|
+
signal: this.#abortController.signal
|
|
3280
|
+
});
|
|
3281
|
+
}
|
|
3282
|
+
//* initialise the dropdown listeners.
|
|
3283
|
+
#initDropdownListeners() {
|
|
3284
|
+
const signal = this.#abortController.signal;
|
|
3285
|
+
const handleLabelClick = (e) => {
|
|
3286
|
+
if (this.#ui.isDropdownClosed()) {
|
|
3287
|
+
this.#ui.telInput.focus();
|
|
3288
|
+
} else {
|
|
3289
|
+
e.preventDefault();
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
const label = this.#ui.telInput.closest("label");
|
|
3293
|
+
if (label) {
|
|
3294
|
+
label.addEventListener("click", handleLabelClick, { signal });
|
|
3295
|
+
}
|
|
3296
|
+
const handleClickSelectedCountry = () => {
|
|
3297
|
+
if (this.#ui.isDropdownClosed() && !this.#ui.telInput.disabled && !this.#ui.telInput.readOnly) {
|
|
3298
|
+
this.#openDropdown();
|
|
3299
|
+
}
|
|
3300
|
+
};
|
|
3301
|
+
this.#ui.selectedCountry.addEventListener(
|
|
3302
|
+
"click",
|
|
3303
|
+
handleClickSelectedCountry,
|
|
3304
|
+
{
|
|
3305
|
+
signal
|
|
3306
|
+
}
|
|
3307
|
+
);
|
|
3308
|
+
const handleCountryContainerKeydown = (e) => {
|
|
3309
|
+
const allowedKeys = [KEYS.ARROW_UP, KEYS.ARROW_DOWN, KEYS.SPACE, KEYS.ENTER];
|
|
3310
|
+
if (this.#ui.isDropdownClosed() && allowedKeys.includes(e.key)) {
|
|
3311
|
+
e.preventDefault();
|
|
3312
|
+
e.stopPropagation();
|
|
3313
|
+
this.#openDropdown();
|
|
3314
|
+
}
|
|
3315
|
+
if (e.key === KEYS.TAB) {
|
|
3316
|
+
this.#closeDropdown();
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
this.#ui.countryContainer.addEventListener(
|
|
3320
|
+
"keydown",
|
|
3321
|
+
handleCountryContainerKeydown,
|
|
3322
|
+
{ signal }
|
|
3323
|
+
);
|
|
3324
|
+
}
|
|
3325
|
+
//* Init requests: utils script / geo ip lookup.
|
|
3326
|
+
#initRequests() {
|
|
3327
|
+
const { loadUtils, initialCountry, geoIpLookup } = this.#options;
|
|
3328
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
3329
|
+
const doAttachUtils = () => {
|
|
3330
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
3331
|
+
});
|
|
3332
|
+
};
|
|
3333
|
+
if (intlTelInput.documentReady()) {
|
|
3334
|
+
doAttachUtils();
|
|
3335
|
+
} else {
|
|
3336
|
+
window.addEventListener("load", doAttachUtils, {
|
|
3337
|
+
signal: this.#abortController.signal
|
|
3338
|
+
});
|
|
3339
|
+
}
|
|
3340
|
+
} else {
|
|
3341
|
+
this.#utilsScriptDeferred?.resolve();
|
|
3342
|
+
}
|
|
3343
|
+
const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
|
|
3344
|
+
if (isAutoCountry) {
|
|
3345
|
+
if (this.#selectedCountryData) {
|
|
3346
|
+
this.#autoCountryDeferred?.resolve();
|
|
3347
|
+
} else {
|
|
3348
|
+
this.#loadAutoCountry();
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
//* Perform the geo ip lookup.
|
|
3353
|
+
#loadAutoCountry() {
|
|
3354
|
+
if (intlTelInput.autoCountry) {
|
|
3355
|
+
this.#handleAutoCountry();
|
|
3356
|
+
} else {
|
|
3357
|
+
this.#ui.selectedCountryInner.classList.add(CLASSES.LOADING);
|
|
3358
|
+
if (!intlTelInput.startedLoadingAutoCountry) {
|
|
3359
|
+
intlTelInput.startedLoadingAutoCountry = true;
|
|
3360
|
+
if (typeof this.#options.geoIpLookup === "function") {
|
|
3361
|
+
const successCallback = (iso2 = "") => {
|
|
3362
|
+
this.#ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
|
|
3363
|
+
const iso2Lower = iso2.toLowerCase();
|
|
3364
|
+
if (isIso2(iso2Lower)) {
|
|
3365
|
+
intlTelInput.autoCountry = iso2Lower;
|
|
3366
|
+
setTimeout(() => _Iti.forEachInstance("handleAutoCountry"));
|
|
3367
|
+
} else {
|
|
3368
|
+
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
const failureCallback = () => {
|
|
3372
|
+
this.#ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
|
|
3373
|
+
_Iti.forEachInstance("handleAutoCountryFailure");
|
|
3374
|
+
};
|
|
3375
|
+
this.#options.geoIpLookup(successCallback, failureCallback);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
#openDropdownWithPlus() {
|
|
3381
|
+
this.#openDropdown();
|
|
3382
|
+
this.#ui.searchInput.value = "+";
|
|
3383
|
+
this.#ui.filterCountriesByQuery("");
|
|
3384
|
+
}
|
|
3385
|
+
//* Initialize the tel input listeners.
|
|
3386
|
+
#initTelInputListeners() {
|
|
3387
|
+
this.#bindInputListener();
|
|
3388
|
+
this.#maybeBindKeydownListener();
|
|
3389
|
+
this.#maybeBindPasteListener();
|
|
3390
|
+
}
|
|
3391
|
+
#bindInputListener() {
|
|
3392
|
+
const {
|
|
3393
|
+
strictMode,
|
|
3394
|
+
formatAsYouType,
|
|
3395
|
+
separateDialCode,
|
|
3396
|
+
allowDropdown,
|
|
3397
|
+
countrySearch
|
|
3398
|
+
} = this.#options;
|
|
3399
|
+
let userOverrideFormatting = false;
|
|
3400
|
+
if (REGEX.ALPHA_UNICODE.test(this.#getTelInputValue())) {
|
|
3401
|
+
userOverrideFormatting = true;
|
|
3402
|
+
}
|
|
3403
|
+
const handleInputEvent = (e) => {
|
|
3404
|
+
const inputValue = this.#getTelInputValue();
|
|
3405
|
+
if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
|
|
3406
|
+
const currentCaretPos = this.#ui.telInput.selectionStart || 0;
|
|
3407
|
+
const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
|
|
3408
|
+
const valueAfterCaret = inputValue.substring(currentCaretPos);
|
|
3409
|
+
this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
|
|
3410
|
+
this.#openDropdownWithPlus();
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
if (this.#updateCountryFromNumber(inputValue)) {
|
|
3414
|
+
this.#triggerCountryChange();
|
|
3415
|
+
}
|
|
3416
|
+
const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
|
|
3417
|
+
const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
|
|
3418
|
+
if (isFormattingChar || isPaste && !strictMode) {
|
|
3419
|
+
userOverrideFormatting = true;
|
|
3420
|
+
} else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
|
|
3421
|
+
userOverrideFormatting = false;
|
|
3422
|
+
}
|
|
3423
|
+
const isSetNumber = e?.detail && e.detail["isSetNumber"];
|
|
3424
|
+
const isAscii = this.#numerals.isAscii();
|
|
3425
|
+
if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
|
|
3426
|
+
const currentCaretPos = this.#ui.telInput.selectionStart || 0;
|
|
3427
|
+
const valueBeforeCaret = inputValue.substring(
|
|
3428
|
+
0,
|
|
3429
|
+
currentCaretPos
|
|
3430
|
+
);
|
|
3431
|
+
const relevantCharsBeforeCaret = valueBeforeCaret.replace(
|
|
3432
|
+
REGEX.NON_PLUS_NUMERIC_GLOBAL,
|
|
3433
|
+
""
|
|
3434
|
+
).length;
|
|
3435
|
+
const isDeleteForwards = e?.inputType === INPUT_TYPES.DELETE_FWD;
|
|
3436
|
+
const fullNumber = this.#getFullNumber();
|
|
3437
|
+
const formattedValue = formatNumberAsYouType(
|
|
3438
|
+
fullNumber,
|
|
3439
|
+
inputValue,
|
|
3440
|
+
intlTelInput.utils,
|
|
3441
|
+
this.#selectedCountryData,
|
|
3442
|
+
separateDialCode
|
|
3443
|
+
);
|
|
3444
|
+
const newCaretPos = translateCursorPosition(
|
|
3445
|
+
relevantCharsBeforeCaret,
|
|
3446
|
+
formattedValue,
|
|
3447
|
+
currentCaretPos,
|
|
3448
|
+
isDeleteForwards
|
|
3449
|
+
);
|
|
3450
|
+
this.#setTelInputValue(formattedValue);
|
|
3451
|
+
this.#ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
|
|
3452
|
+
}
|
|
3453
|
+
if (separateDialCode && inputValue.startsWith("+") && this.#selectedCountryData?.dialCode) {
|
|
3454
|
+
const cleanNumber = beforeSetNumber(
|
|
3455
|
+
inputValue,
|
|
3456
|
+
true,
|
|
3457
|
+
separateDialCode,
|
|
3458
|
+
this.#selectedCountryData
|
|
3459
|
+
);
|
|
3460
|
+
this.#setTelInputValue(cleanNumber);
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
this.#ui.telInput.addEventListener(
|
|
3464
|
+
"input",
|
|
3465
|
+
handleInputEvent,
|
|
3466
|
+
{
|
|
3467
|
+
signal: this.#abortController.signal
|
|
3468
|
+
}
|
|
3469
|
+
);
|
|
3470
|
+
}
|
|
3471
|
+
#maybeBindKeydownListener() {
|
|
3472
|
+
const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.#options;
|
|
3473
|
+
if (strictMode || separateDialCode) {
|
|
3474
|
+
const handleKeydownEvent = (e) => {
|
|
3475
|
+
if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
3476
|
+
if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
|
|
3477
|
+
e.preventDefault();
|
|
3478
|
+
this.#openDropdownWithPlus();
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
if (strictMode) {
|
|
3482
|
+
const inputValue = this.#getTelInputValue();
|
|
3483
|
+
const alreadyHasPlus = inputValue.startsWith("+");
|
|
3484
|
+
const isInitialPlus = !alreadyHasPlus && this.#ui.telInput.selectionStart === 0 && e.key === "+";
|
|
3485
|
+
const normalisedKey = this.#numerals.normalise(e.key);
|
|
3486
|
+
const isNumeric = /^[0-9]$/.test(normalisedKey);
|
|
3487
|
+
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
3488
|
+
const input = this.#ui.telInput;
|
|
3489
|
+
const selStart = input.selectionStart;
|
|
3490
|
+
const selEnd = input.selectionEnd;
|
|
3491
|
+
const before = inputValue.slice(0, selStart ?? void 0);
|
|
3492
|
+
const after = inputValue.slice(selEnd ?? void 0);
|
|
3493
|
+
const newValue = before + e.key + after;
|
|
3494
|
+
const newFullNumber = this.#getFullNumber(newValue);
|
|
3495
|
+
let hasExceededMaxLength = false;
|
|
3496
|
+
if (intlTelInput.utils && this.#maxCoreNumberLength) {
|
|
3497
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(
|
|
3498
|
+
newFullNumber,
|
|
3499
|
+
this.#selectedCountryData?.iso2
|
|
3500
|
+
);
|
|
3501
|
+
hasExceededMaxLength = coreNumber.length > this.#maxCoreNumberLength;
|
|
3502
|
+
}
|
|
3503
|
+
const newCountry = this.#getNewCountryFromNumber(newFullNumber);
|
|
3504
|
+
const isChangingDialCode = newCountry !== null;
|
|
3505
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
3506
|
+
e.preventDefault();
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
};
|
|
3511
|
+
this.#ui.telInput.addEventListener("keydown", handleKeydownEvent, {
|
|
3512
|
+
signal: this.#abortController.signal
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
#maybeBindPasteListener() {
|
|
3517
|
+
if (this.#options.strictMode) {
|
|
3518
|
+
const handlePasteEvent = (e) => {
|
|
3519
|
+
e.preventDefault();
|
|
3520
|
+
const input = this.#ui.telInput;
|
|
3521
|
+
const selStart = input.selectionStart;
|
|
3522
|
+
const selEnd = input.selectionEnd;
|
|
3523
|
+
const inputValue = this.#getTelInputValue();
|
|
3524
|
+
const before = inputValue.slice(0, selStart ?? void 0);
|
|
3525
|
+
const after = inputValue.slice(selEnd ?? void 0);
|
|
3526
|
+
const iso2 = this.#selectedCountryData?.iso2;
|
|
3527
|
+
const pastedRaw = e.clipboardData.getData("text");
|
|
3528
|
+
const pasted = this.#numerals.normalise(pastedRaw);
|
|
3529
|
+
const initialCharSelected = selStart === 0 && selEnd > 0;
|
|
3530
|
+
const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
|
|
3531
|
+
const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
|
|
3532
|
+
const hasLeadingPlus = allowedChars.startsWith("+");
|
|
3533
|
+
const numerics = allowedChars.replace(/\+/g, "");
|
|
3534
|
+
const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
|
|
3535
|
+
let newVal = before + sanitised + after;
|
|
3536
|
+
if (newVal.length > 5 && intlTelInput.utils) {
|
|
3537
|
+
let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3538
|
+
while (coreNumber.length === 0 && newVal.length > 0) {
|
|
3539
|
+
newVal = newVal.slice(0, -1);
|
|
3540
|
+
coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3541
|
+
}
|
|
3542
|
+
if (!coreNumber) {
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
if (this.#maxCoreNumberLength && coreNumber.length > this.#maxCoreNumberLength) {
|
|
3546
|
+
if (input.selectionEnd === inputValue.length) {
|
|
3547
|
+
const trimLength = coreNumber.length - this.#maxCoreNumberLength;
|
|
3548
|
+
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
3549
|
+
} else {
|
|
3550
|
+
return;
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
this.#setTelInputValue(newVal);
|
|
3555
|
+
const caretPos = selStart + sanitised.length;
|
|
3556
|
+
input.setSelectionRange(caretPos, caretPos);
|
|
3557
|
+
input.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
3558
|
+
};
|
|
3559
|
+
this.#ui.telInput.addEventListener("paste", handlePasteEvent, {
|
|
3560
|
+
signal: this.#abortController.signal
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
//* Adhere to the input's maxlength attr.
|
|
3565
|
+
#cap(number) {
|
|
3566
|
+
const max = Number(this.#ui.telInput.getAttribute("maxlength"));
|
|
3567
|
+
return max && number.length > max ? number.substring(0, max) : number;
|
|
3568
|
+
}
|
|
3569
|
+
//* Trigger a custom event on the input (typed via ItiEventMap).
|
|
3570
|
+
#trigger(name, detailProps = {}) {
|
|
3571
|
+
const e = new CustomEvent(name, {
|
|
3572
|
+
bubbles: true,
|
|
3573
|
+
cancelable: true,
|
|
3574
|
+
detail: detailProps
|
|
3575
|
+
});
|
|
3576
|
+
this.#ui.telInput.dispatchEvent(e);
|
|
3577
|
+
}
|
|
3578
|
+
//* Open the dropdown.
|
|
3579
|
+
#openDropdown() {
|
|
3580
|
+
const { dropdownContainer, useFullscreenPopup } = this.#options;
|
|
3581
|
+
this.#dropdownAbortController = new AbortController();
|
|
3582
|
+
this.#ui.openDropdown();
|
|
3583
|
+
if (!useFullscreenPopup && dropdownContainer) {
|
|
3584
|
+
const handleWindowScroll = () => this.#closeDropdown();
|
|
3585
|
+
window.addEventListener("scroll", handleWindowScroll, {
|
|
3586
|
+
signal: this.#dropdownAbortController.signal
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
this.#bindDropdownListeners();
|
|
3590
|
+
this.#trigger(EVENTS.OPEN_COUNTRY_DROPDOWN);
|
|
3591
|
+
}
|
|
3592
|
+
//* We only bind dropdown listeners when the dropdown is open.
|
|
3593
|
+
#bindDropdownListeners() {
|
|
3594
|
+
const signal = this.#dropdownAbortController.signal;
|
|
3595
|
+
this.#bindDropdownMouseoverListener(signal);
|
|
3596
|
+
this.#bindDropdownCountryClickListener(signal);
|
|
3597
|
+
if (!this.#options.dropdownAlwaysOpen) {
|
|
3598
|
+
this.#bindDropdownClickOffListener(signal);
|
|
3599
|
+
}
|
|
3600
|
+
this.#bindDropdownKeydownListener(signal);
|
|
3601
|
+
if (this.#options.countrySearch) {
|
|
3602
|
+
this.#bindDropdownSearchListeners(signal);
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
//* When mouse over a list item, just highlight that one
|
|
3606
|
+
//* we add the class "highlight", so if they hit "enter" we know which one to select.
|
|
3607
|
+
#bindDropdownMouseoverListener(signal) {
|
|
3608
|
+
const handleMouseoverCountryList = (e) => {
|
|
3609
|
+
const listItem = e.target?.closest(
|
|
3610
|
+
`.${CLASSES.COUNTRY_ITEM}`
|
|
3611
|
+
);
|
|
3612
|
+
if (listItem) {
|
|
3613
|
+
this.#ui.highlightListItem(listItem, false);
|
|
3614
|
+
}
|
|
3615
|
+
};
|
|
3616
|
+
this.#ui.countryList.addEventListener(
|
|
3617
|
+
"mouseover",
|
|
3618
|
+
handleMouseoverCountryList,
|
|
3619
|
+
{
|
|
3620
|
+
signal
|
|
3621
|
+
}
|
|
3622
|
+
);
|
|
3623
|
+
}
|
|
3624
|
+
//* Listen for country selection.
|
|
3625
|
+
#bindDropdownCountryClickListener(signal) {
|
|
3626
|
+
const handleClickCountryList = (e) => {
|
|
3627
|
+
const listItem = e.target?.closest(
|
|
3628
|
+
`.${CLASSES.COUNTRY_ITEM}`
|
|
3629
|
+
);
|
|
3630
|
+
if (listItem) {
|
|
3631
|
+
this.#selectListItem(listItem);
|
|
3632
|
+
}
|
|
3633
|
+
};
|
|
3634
|
+
this.#ui.countryList.addEventListener("click", handleClickCountryList, {
|
|
3635
|
+
signal
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3638
|
+
//* Click off to close (except when this initial opening click is bubbling up).
|
|
3639
|
+
//* We cannot just stopPropagation as it may be needed to close another instance.
|
|
3640
|
+
#bindDropdownClickOffListener(signal) {
|
|
3641
|
+
const handleClickOffToClose = (e) => {
|
|
3642
|
+
const target = e.target;
|
|
3643
|
+
const clickedInsideDropdown = !!target.closest(
|
|
3644
|
+
`#iti-${this.id}__dropdown-content`
|
|
3645
|
+
);
|
|
3646
|
+
if (!clickedInsideDropdown) {
|
|
3647
|
+
this.#closeDropdown();
|
|
3648
|
+
}
|
|
3649
|
+
};
|
|
3650
|
+
setTimeout(() => {
|
|
3651
|
+
document.documentElement.addEventListener(
|
|
3652
|
+
"click",
|
|
3653
|
+
handleClickOffToClose,
|
|
3654
|
+
{ signal }
|
|
3655
|
+
);
|
|
3656
|
+
}, 0);
|
|
3657
|
+
}
|
|
3658
|
+
//* Listen for up/down scrolling, enter to select, or escape to close.
|
|
3659
|
+
//* Use keydown as keypress doesn't fire for non-char keys and we want to catch if they
|
|
3660
|
+
//* just hit down and hold it to scroll down (no keyup event).
|
|
3661
|
+
//* Listen on the document because that's where key events are triggered if no input has focus.
|
|
3662
|
+
#bindDropdownKeydownListener(signal) {
|
|
3663
|
+
let query = "";
|
|
3664
|
+
let queryTimer = null;
|
|
3665
|
+
const handleKeydownOnDropdown = (e) => {
|
|
3666
|
+
const allowedKeys = [
|
|
3667
|
+
KEYS.ARROW_UP,
|
|
3668
|
+
KEYS.ARROW_DOWN,
|
|
3669
|
+
KEYS.ENTER,
|
|
3670
|
+
KEYS.ESC
|
|
3671
|
+
];
|
|
3672
|
+
if (allowedKeys.includes(e.key)) {
|
|
3673
|
+
e.preventDefault();
|
|
3674
|
+
e.stopPropagation();
|
|
3675
|
+
if (e.key === KEYS.ARROW_UP || e.key === KEYS.ARROW_DOWN) {
|
|
3676
|
+
this.#ui.handleUpDownKey(e.key);
|
|
3677
|
+
} else if (e.key === KEYS.ENTER && !e.isComposing) {
|
|
3678
|
+
this.#handleEnterKey();
|
|
3679
|
+
} else if (e.key === KEYS.ESC) {
|
|
3680
|
+
this.#closeDropdown();
|
|
3681
|
+
this.#ui.selectedCountry.focus();
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
if (!this.#options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
|
|
3685
|
+
e.stopPropagation();
|
|
3686
|
+
if (queryTimer) {
|
|
3687
|
+
clearTimeout(queryTimer);
|
|
3688
|
+
}
|
|
3689
|
+
query += e.key.toLowerCase();
|
|
3690
|
+
this.#searchForCountry(query);
|
|
3691
|
+
queryTimer = setTimeout(() => {
|
|
3692
|
+
query = "";
|
|
3693
|
+
}, TIMINGS.HIDDEN_SEARCH_RESET_MS);
|
|
3694
|
+
}
|
|
3695
|
+
};
|
|
3696
|
+
document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
|
|
3697
|
+
}
|
|
3698
|
+
//* Search input listeners when countrySearch enabled.
|
|
3699
|
+
#bindDropdownSearchListeners(signal) {
|
|
3700
|
+
this.#ui.searchInput.addEventListener(
|
|
3701
|
+
"input",
|
|
3702
|
+
() => this.#ui.handleSearchChange(),
|
|
3703
|
+
{ signal }
|
|
3704
|
+
);
|
|
3705
|
+
this.#ui.searchClearButton.addEventListener(
|
|
3706
|
+
"click",
|
|
3707
|
+
() => this.#ui.handleSearchClear(),
|
|
3708
|
+
{ signal }
|
|
3709
|
+
);
|
|
3710
|
+
}
|
|
3711
|
+
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
3712
|
+
#searchForCountry(query) {
|
|
3713
|
+
const match = findFirstCountryStartingWith(this.#countries, query);
|
|
3714
|
+
if (match) {
|
|
3715
|
+
const listItem = match.nodeById[this.id];
|
|
3716
|
+
this.#ui.highlightListItem(listItem, false);
|
|
3717
|
+
this.#ui.scrollCountryListToItem(listItem);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
//* Select the currently highlighted item.
|
|
3721
|
+
#handleEnterKey() {
|
|
3722
|
+
if (this.#ui.highlightedItem) {
|
|
3723
|
+
this.#selectListItem(this.#ui.highlightedItem);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
//* Update the input's value to the given val (format first if possible)
|
|
3727
|
+
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
3728
|
+
#updateValFromNumber(fullNumber) {
|
|
3729
|
+
const { formatOnDisplay, nationalMode, separateDialCode } = this.#options;
|
|
3730
|
+
let number = fullNumber;
|
|
3731
|
+
if (formatOnDisplay && intlTelInput.utils && this.#selectedCountryData) {
|
|
3732
|
+
const isRegionless = hasRegionlessDialCode(fullNumber);
|
|
3733
|
+
const useNational = nationalMode && !isRegionless || !number.startsWith("+") && !separateDialCode;
|
|
3734
|
+
const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
|
|
3735
|
+
const format = useNational ? NATIONAL : INTERNATIONAL;
|
|
3736
|
+
number = intlTelInput.utils.formatNumber(
|
|
3737
|
+
number,
|
|
3738
|
+
this.#selectedCountryData?.iso2,
|
|
3739
|
+
format
|
|
3740
|
+
);
|
|
3741
|
+
}
|
|
3742
|
+
number = this.#beforeSetNumber(number);
|
|
3743
|
+
this.#setTelInputValue(number);
|
|
3744
|
+
}
|
|
3745
|
+
//* Check if need to select a new country based on the given number
|
|
3746
|
+
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
3747
|
+
#updateCountryFromNumber(fullNumber) {
|
|
3748
|
+
const iso2 = this.#getNewCountryFromNumber(fullNumber);
|
|
3749
|
+
if (iso2 !== null) {
|
|
3750
|
+
return this.#setCountry(iso2);
|
|
3751
|
+
}
|
|
3752
|
+
return false;
|
|
3753
|
+
}
|
|
3754
|
+
// if there is a selected country, and the number doesn't start with a dial code, then add it
|
|
3755
|
+
#ensureHasDialCode(number) {
|
|
3756
|
+
const dialCode = this.#selectedCountryData?.dialCode;
|
|
3757
|
+
const nationalPrefix = this.#selectedCountryData?.nationalPrefix;
|
|
3758
|
+
const alreadyHasPlus = number.startsWith("+");
|
|
3759
|
+
if (alreadyHasPlus || !dialCode) {
|
|
3760
|
+
return number;
|
|
3761
|
+
}
|
|
3762
|
+
const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.#options.separateDialCode;
|
|
3763
|
+
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
3764
|
+
return `+${dialCode}${cleanNumber}`;
|
|
3765
|
+
}
|
|
3766
|
+
//* Get the new country based on the input number, or return null if no change, or empty string if should be empty (e.g. if they type an invalid dial code).
|
|
3767
|
+
#getNewCountryFromNumber(fullNumber) {
|
|
3768
|
+
const plusIndex = fullNumber.indexOf("+");
|
|
3769
|
+
let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
|
|
3770
|
+
const selectedIso2 = this.#selectedCountryData?.iso2;
|
|
3771
|
+
const selectedDialCode = this.#selectedCountryData?.dialCode;
|
|
3772
|
+
number = this.#ensureHasDialCode(number);
|
|
3773
|
+
const dialCodeMatch = this.#getDialCode(number, true);
|
|
3774
|
+
const numeric = getNumeric(number);
|
|
3775
|
+
if (dialCodeMatch) {
|
|
3776
|
+
const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
|
|
3777
|
+
const iso2Codes = this.#dialCodeToIso2Map[dialCodeMatchNumeric];
|
|
3778
|
+
if (iso2Codes.length === 1) {
|
|
3779
|
+
if (iso2Codes[0] === selectedIso2) {
|
|
3780
|
+
return null;
|
|
3781
|
+
}
|
|
3782
|
+
return iso2Codes[0];
|
|
3783
|
+
}
|
|
3784
|
+
if (!selectedIso2 && this.#defaultCountry && iso2Codes.includes(this.#defaultCountry)) {
|
|
3785
|
+
return this.#defaultCountry;
|
|
3786
|
+
}
|
|
3787
|
+
const isRegionlessNanpNumber = selectedDialCode === DIAL.NANP && isRegionlessNanp(numeric);
|
|
3788
|
+
if (isRegionlessNanpNumber) {
|
|
3789
|
+
return null;
|
|
3790
|
+
}
|
|
3791
|
+
const areaCodes = this.#selectedCountryData?.areaCodes;
|
|
3792
|
+
const priority = this.#selectedCountryData?.priority;
|
|
3793
|
+
if (areaCodes) {
|
|
3794
|
+
const dialCodeAreaCodes = areaCodes.map(
|
|
3795
|
+
(areaCode) => `${selectedDialCode}${areaCode}`
|
|
3796
|
+
);
|
|
3797
|
+
for (const dialCodeAreaCode of dialCodeAreaCodes) {
|
|
3798
|
+
if (numeric.startsWith(dialCodeAreaCode)) {
|
|
3799
|
+
return null;
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
const isMainCountry = priority === 0;
|
|
3804
|
+
const hasAreaCodesButNoneMatched = areaCodes && !isMainCountry && numeric.length > dialCodeMatchNumeric.length;
|
|
3805
|
+
const isValidSelection = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
3806
|
+
const alreadySelected = selectedIso2 === iso2Codes[0];
|
|
3807
|
+
if (!isValidSelection && !alreadySelected) {
|
|
3808
|
+
return iso2Codes[0];
|
|
3809
|
+
}
|
|
3810
|
+
} else if (number.startsWith("+") && numeric.length) {
|
|
3811
|
+
const currentDial = this.#selectedCountryData?.dialCode || "";
|
|
3812
|
+
if (currentDial && currentDial.startsWith(numeric)) {
|
|
3813
|
+
return null;
|
|
3814
|
+
}
|
|
3815
|
+
return "";
|
|
3816
|
+
} else if ((!number || number === "+") && !selectedIso2 && this.#defaultCountry) {
|
|
3817
|
+
return this.#defaultCountry;
|
|
3818
|
+
}
|
|
3819
|
+
return null;
|
|
3820
|
+
}
|
|
3821
|
+
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
3822
|
+
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3823
|
+
#setCountry(iso2) {
|
|
3824
|
+
const prevIso2 = this.#selectedCountryData?.iso2 || "";
|
|
3825
|
+
this.#selectedCountryData = iso2 ? this.#countryByIso2.get(iso2) : null;
|
|
3826
|
+
if (this.#selectedCountryData) {
|
|
3827
|
+
this.#defaultCountry = this.#selectedCountryData.iso2;
|
|
3828
|
+
}
|
|
3829
|
+
this.#ui.setCountry(this.#selectedCountryData);
|
|
3830
|
+
this.#updatePlaceholder();
|
|
3831
|
+
this.#updateMaxLength();
|
|
3832
|
+
return prevIso2 !== iso2;
|
|
3833
|
+
}
|
|
3834
|
+
//* Update the maximum valid number length for the currently selected country.
|
|
3835
|
+
#updateMaxLength() {
|
|
3836
|
+
const { strictMode, placeholderNumberType, allowedNumberTypes } = this.#options;
|
|
3837
|
+
const iso2 = this.#selectedCountryData?.iso2;
|
|
3838
|
+
if (strictMode && intlTelInput.utils) {
|
|
3839
|
+
if (iso2) {
|
|
3840
|
+
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
3841
|
+
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
3842
|
+
iso2,
|
|
3843
|
+
false,
|
|
3844
|
+
numberType,
|
|
3845
|
+
true
|
|
3846
|
+
);
|
|
3847
|
+
let validNumber = exampleNumber;
|
|
3848
|
+
while (intlTelInput.utils.isPossibleNumber(
|
|
3849
|
+
exampleNumber,
|
|
3850
|
+
iso2,
|
|
3851
|
+
allowedNumberTypes
|
|
3852
|
+
)) {
|
|
3853
|
+
validNumber = exampleNumber;
|
|
3854
|
+
exampleNumber += "0";
|
|
3855
|
+
}
|
|
3856
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
3857
|
+
this.#maxCoreNumberLength = coreNumber.length;
|
|
3858
|
+
if (iso2 === "by") {
|
|
3859
|
+
this.#maxCoreNumberLength = coreNumber.length + 1;
|
|
3860
|
+
}
|
|
3861
|
+
} else {
|
|
3862
|
+
this.#maxCoreNumberLength = null;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
//* Update the input placeholder to an example number from the currently selected country.
|
|
3867
|
+
#updatePlaceholder() {
|
|
3868
|
+
const {
|
|
3869
|
+
autoPlaceholder,
|
|
3870
|
+
placeholderNumberType,
|
|
3871
|
+
nationalMode,
|
|
3872
|
+
customPlaceholder
|
|
3873
|
+
} = this.#options;
|
|
3874
|
+
const shouldSetPlaceholder = autoPlaceholder === PLACEHOLDER_MODES.AGGRESSIVE || !this.#ui.hadInitialPlaceholder && autoPlaceholder === PLACEHOLDER_MODES.POLITE;
|
|
3875
|
+
if (intlTelInput.utils && shouldSetPlaceholder) {
|
|
3876
|
+
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
3877
|
+
let placeholder = this.#selectedCountryData ? intlTelInput.utils.getExampleNumber(
|
|
3878
|
+
this.#selectedCountryData.iso2,
|
|
3879
|
+
nationalMode,
|
|
3880
|
+
numberType
|
|
3881
|
+
) : "";
|
|
3882
|
+
placeholder = this.#beforeSetNumber(placeholder);
|
|
3883
|
+
if (typeof customPlaceholder === "function") {
|
|
3884
|
+
placeholder = customPlaceholder(placeholder, this.#selectedCountryData);
|
|
3885
|
+
}
|
|
3886
|
+
this.#ui.telInput.setAttribute("placeholder", placeholder);
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
//* Called when the user selects a list item from the dropdown.
|
|
3890
|
+
#selectListItem(listItem) {
|
|
3891
|
+
const iso2 = listItem.dataset[DATA_KEYS.COUNTRY_CODE];
|
|
3892
|
+
const countryChanged = this.#setCountry(iso2);
|
|
3893
|
+
this.#closeDropdown();
|
|
3894
|
+
const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
|
|
3895
|
+
this.#updateDialCode(dialCode);
|
|
3896
|
+
if (this.#options.formatOnDisplay) {
|
|
3897
|
+
const inputValue = this.#getTelInputValue();
|
|
3898
|
+
this.#updateValFromNumber(inputValue);
|
|
3899
|
+
}
|
|
3900
|
+
this.#ui.telInput.focus();
|
|
3901
|
+
if (countryChanged) {
|
|
3902
|
+
this.#triggerCountryChange();
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
//* Close the dropdown and unbind any listeners.
|
|
3906
|
+
#closeDropdown(isDestroy) {
|
|
3907
|
+
if (this.#ui.isDropdownClosed() || this.#options.dropdownAlwaysOpen && !isDestroy) {
|
|
3908
|
+
return;
|
|
3909
|
+
}
|
|
3910
|
+
this.#ui.closeDropdown();
|
|
3911
|
+
this.#dropdownAbortController.abort();
|
|
3912
|
+
this.#dropdownAbortController = null;
|
|
3913
|
+
this.#trigger(EVENTS.CLOSE_COUNTRY_DROPDOWN);
|
|
3914
|
+
}
|
|
3915
|
+
//* Replace any existing dial code with the new one
|
|
3916
|
+
//* Note: called from _selectListItem and setCountry
|
|
3917
|
+
#updateDialCode(newDialCodeBare) {
|
|
3918
|
+
const inputVal = this.#getTelInputValue();
|
|
3919
|
+
const newDialCode = `+${newDialCodeBare}`;
|
|
3920
|
+
let newNumber;
|
|
3921
|
+
if (inputVal.startsWith("+")) {
|
|
3922
|
+
const prevDialCode = this.#getDialCode(inputVal);
|
|
3923
|
+
if (prevDialCode) {
|
|
3924
|
+
newNumber = inputVal.replace(prevDialCode, newDialCode);
|
|
3925
|
+
} else {
|
|
3926
|
+
newNumber = newDialCode;
|
|
3927
|
+
}
|
|
3928
|
+
this.#setTelInputValue(newNumber);
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
//* Try and extract a valid international dial code from a full telephone number.
|
|
3932
|
+
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
3933
|
+
#getDialCode(number, includeAreaCode) {
|
|
3934
|
+
let dialCode = "";
|
|
3935
|
+
if (number.startsWith("+")) {
|
|
3936
|
+
let numericChars = "";
|
|
3937
|
+
let foundBaseDialCode = false;
|
|
3938
|
+
for (let i = 0; i < number.length; i++) {
|
|
3939
|
+
const c = number.charAt(i);
|
|
3940
|
+
if (/[0-9]/.test(c)) {
|
|
3941
|
+
numericChars += c;
|
|
3942
|
+
const hasMapEntry = Boolean(this.#dialCodeToIso2Map[numericChars]);
|
|
3943
|
+
if (!hasMapEntry) {
|
|
3944
|
+
break;
|
|
3945
|
+
}
|
|
3946
|
+
if (this.#dialCodes.has(numericChars)) {
|
|
3947
|
+
dialCode = number.substring(0, i + 1);
|
|
3948
|
+
foundBaseDialCode = true;
|
|
3949
|
+
if (!includeAreaCode) {
|
|
3950
|
+
break;
|
|
3951
|
+
}
|
|
3952
|
+
} else if (includeAreaCode && foundBaseDialCode) {
|
|
3953
|
+
dialCode = number.substring(0, i + 1);
|
|
3954
|
+
}
|
|
3955
|
+
if (numericChars.length === this.#dialCodeMaxLen) {
|
|
3956
|
+
break;
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
return dialCode;
|
|
3962
|
+
}
|
|
3963
|
+
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3964
|
+
#getFullNumber(overrideVal) {
|
|
3965
|
+
const val = overrideVal ? this.#numerals.normalise(overrideVal) : this.#getTelInputValue();
|
|
3966
|
+
const dialCode = this.#selectedCountryData?.dialCode;
|
|
3967
|
+
let prefix;
|
|
3968
|
+
const numericVal = getNumeric(val);
|
|
3969
|
+
if (this.#options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
|
|
3970
|
+
prefix = `+${dialCode}`;
|
|
3971
|
+
} else {
|
|
3972
|
+
prefix = "";
|
|
3973
|
+
}
|
|
3974
|
+
return prefix + val;
|
|
3975
|
+
}
|
|
3976
|
+
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
3977
|
+
#beforeSetNumber(fullNumber) {
|
|
3978
|
+
const hasValidDialCode = Boolean(this.#getDialCode(fullNumber));
|
|
3979
|
+
const number = beforeSetNumber(
|
|
3980
|
+
fullNumber,
|
|
3981
|
+
hasValidDialCode,
|
|
3982
|
+
this.#options.separateDialCode,
|
|
3983
|
+
this.#selectedCountryData
|
|
3984
|
+
);
|
|
3985
|
+
return this.#cap(number);
|
|
3986
|
+
}
|
|
3987
|
+
//* Return only the public-facing subset of the selected country data.
|
|
3988
|
+
#getPublicCountryData() {
|
|
3989
|
+
const d = this.#selectedCountryData;
|
|
3990
|
+
if (!d) {
|
|
3991
|
+
return null;
|
|
3992
|
+
}
|
|
3993
|
+
const { iso2, dialCode, name } = d;
|
|
3994
|
+
return { iso2, dialCode, name };
|
|
3995
|
+
}
|
|
3996
|
+
//* Trigger the 'countrychange' event.
|
|
3997
|
+
#triggerCountryChange() {
|
|
3998
|
+
const countryData = this.#getPublicCountryData();
|
|
3999
|
+
this.#trigger(EVENTS.COUNTRY_CHANGE, countryData);
|
|
4000
|
+
}
|
|
4001
|
+
//**************************
|
|
4002
|
+
//* INTERNAL METHODS
|
|
4003
|
+
//**************************
|
|
4004
|
+
//* Called when the geoip call returns.
|
|
4005
|
+
#handleAutoCountry() {
|
|
4006
|
+
if (this.#destroyed) {
|
|
4007
|
+
this.#autoCountryDeferred?.resolve();
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
4010
|
+
if (this.#options.initialCountry === INITIAL_COUNTRY.AUTO && intlTelInput.autoCountry) {
|
|
4011
|
+
this.#defaultCountry = intlTelInput.autoCountry;
|
|
4012
|
+
const hasSelectedCountryOrGlobe = this.#selectedCountryData || this.#ui.selectedCountryInner.classList.contains(CLASSES.GLOBE);
|
|
4013
|
+
if (!hasSelectedCountryOrGlobe) {
|
|
4014
|
+
this.setCountry(this.#defaultCountry);
|
|
4015
|
+
}
|
|
4016
|
+
this.#autoCountryDeferred?.resolve();
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
//* Called when the geoip call fails or times out.
|
|
4020
|
+
#handleAutoCountryFailure() {
|
|
4021
|
+
if (this.#destroyed) {
|
|
4022
|
+
this.#autoCountryDeferred?.reject();
|
|
4023
|
+
return;
|
|
4024
|
+
}
|
|
4025
|
+
this.#setInitialState(true);
|
|
4026
|
+
this.#autoCountryDeferred?.reject();
|
|
4027
|
+
}
|
|
4028
|
+
//* Called when the utils request completes.
|
|
4029
|
+
#handleUtils() {
|
|
4030
|
+
if (this.#destroyed) {
|
|
4031
|
+
this.#utilsScriptDeferred?.resolve();
|
|
4032
|
+
return;
|
|
4033
|
+
}
|
|
4034
|
+
if (intlTelInput.utils) {
|
|
4035
|
+
const inputValue = this.#getTelInputValue();
|
|
4036
|
+
if (inputValue) {
|
|
4037
|
+
this.#updateValFromNumber(inputValue);
|
|
4038
|
+
}
|
|
4039
|
+
if (this.#selectedCountryData) {
|
|
4040
|
+
this.#updatePlaceholder();
|
|
4041
|
+
this.#updateMaxLength();
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
this.#utilsScriptDeferred?.resolve();
|
|
4045
|
+
}
|
|
4046
|
+
//* Called when the utils request fails or times out.
|
|
4047
|
+
#handleUtilsFailure(error) {
|
|
4048
|
+
if (this.#destroyed) {
|
|
4049
|
+
this.#utilsScriptDeferred?.reject(error);
|
|
4050
|
+
return;
|
|
4051
|
+
}
|
|
4052
|
+
this.#utilsScriptDeferred?.reject(error);
|
|
4053
|
+
}
|
|
4054
|
+
//********************
|
|
4055
|
+
//* PUBLIC METHODS
|
|
4056
|
+
//********************
|
|
4057
|
+
//* Remove plugin.
|
|
4058
|
+
destroy() {
|
|
4059
|
+
if (this.#destroyed) {
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
this.#destroyed = true;
|
|
4063
|
+
if (this.#options.allowDropdown) {
|
|
4064
|
+
this.#closeDropdown(true);
|
|
4065
|
+
}
|
|
4066
|
+
this.#abortController.abort();
|
|
4067
|
+
this.#ui.destroy();
|
|
4068
|
+
intlTelInput.instances.delete(String(this.id));
|
|
4069
|
+
}
|
|
4070
|
+
// check if the instance is still valid (not destroyed)
|
|
4071
|
+
isActive() {
|
|
4072
|
+
return !this.#destroyed;
|
|
4073
|
+
}
|
|
4074
|
+
//* Get the extension from the current number.
|
|
4075
|
+
getExtension() {
|
|
4076
|
+
if (this.#destroyed) {
|
|
4077
|
+
return "";
|
|
4078
|
+
}
|
|
4079
|
+
ensureUtils("getExtension");
|
|
4080
|
+
return intlTelInput.utils.getExtension(
|
|
4081
|
+
this.#getFullNumber(),
|
|
4082
|
+
this.#selectedCountryData?.iso2
|
|
4083
|
+
);
|
|
4084
|
+
}
|
|
4085
|
+
//* Format the number to the given format.
|
|
4086
|
+
getNumber(format) {
|
|
4087
|
+
if (this.#destroyed) {
|
|
4088
|
+
return "";
|
|
4089
|
+
}
|
|
4090
|
+
ensureUtils("getNumber");
|
|
4091
|
+
const iso2 = this.#selectedCountryData?.iso2;
|
|
4092
|
+
const fullNumber = this.#getFullNumber();
|
|
4093
|
+
const formattedNumber = intlTelInput.utils.formatNumber(
|
|
4094
|
+
fullNumber,
|
|
4095
|
+
iso2,
|
|
4096
|
+
format
|
|
4097
|
+
);
|
|
4098
|
+
return this.#numerals.denormalise(formattedNumber);
|
|
4099
|
+
}
|
|
4100
|
+
//* Get the type of the entered number e.g. landline/mobile.
|
|
4101
|
+
getNumberType() {
|
|
4102
|
+
if (this.#destroyed) {
|
|
4103
|
+
return SENTINELS.UNKNOWN_NUMBER_TYPE;
|
|
4104
|
+
}
|
|
4105
|
+
ensureUtils("getNumberType");
|
|
4106
|
+
return intlTelInput.utils.getNumberType(
|
|
4107
|
+
this.#getFullNumber(),
|
|
4108
|
+
this.#selectedCountryData?.iso2
|
|
4109
|
+
);
|
|
4110
|
+
}
|
|
4111
|
+
//* Get the country data for the currently selected country.
|
|
4112
|
+
getSelectedCountryData() {
|
|
4113
|
+
return this.#getPublicCountryData();
|
|
4114
|
+
}
|
|
4115
|
+
//* Get the validation error.
|
|
4116
|
+
getValidationError() {
|
|
4117
|
+
if (this.#destroyed) {
|
|
4118
|
+
return SENTINELS.UNKNOWN_VALIDATION_ERROR;
|
|
4119
|
+
}
|
|
4120
|
+
ensureUtils("getValidationError");
|
|
4121
|
+
const iso2 = this.#selectedCountryData?.iso2;
|
|
4122
|
+
return intlTelInput.utils.getValidationError(this.#getFullNumber(), iso2);
|
|
4123
|
+
}
|
|
4124
|
+
//* Validate the input val using number length only
|
|
4125
|
+
isValidNumber() {
|
|
4126
|
+
if (this.#destroyed) {
|
|
4127
|
+
return null;
|
|
4128
|
+
}
|
|
4129
|
+
ensureUtils("isValidNumber");
|
|
4130
|
+
const dialCode = this.#selectedCountryData?.dialCode;
|
|
4131
|
+
const iso2 = this.#selectedCountryData?.iso2;
|
|
4132
|
+
const number = this.#getFullNumber();
|
|
4133
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(number, iso2);
|
|
4134
|
+
if (coreNumber) {
|
|
4135
|
+
if (dialCode === UK.DIAL_CODE) {
|
|
4136
|
+
if (coreNumber[0] === UK.MOBILE_PREFIX && coreNumber.length !== UK.MOBILE_CORE_LENGTH) {
|
|
4137
|
+
return false;
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
const hasAlphaChar = REGEX.ALPHA_UNICODE.test(number);
|
|
4141
|
+
if (!hasAlphaChar && dialCode) {
|
|
4142
|
+
const nationalPortion = number.startsWith("+") ? number.slice(1 + dialCode.length) : number;
|
|
4143
|
+
const nationalDigitCount = getNumeric(nationalPortion).length;
|
|
4144
|
+
if (coreNumber.length > nationalDigitCount) {
|
|
4145
|
+
return false;
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
return this.#validateNumber(false);
|
|
4150
|
+
}
|
|
4151
|
+
//* Validate the input val with precise validation
|
|
4152
|
+
isValidNumberPrecise() {
|
|
4153
|
+
if (this.#destroyed) {
|
|
4154
|
+
return null;
|
|
4155
|
+
}
|
|
4156
|
+
ensureUtils("isValidNumberPrecise");
|
|
4157
|
+
return this.#validateNumber(true);
|
|
4158
|
+
}
|
|
4159
|
+
#utilsIsPossibleNumber(val) {
|
|
4160
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(
|
|
4161
|
+
val,
|
|
4162
|
+
this.#selectedCountryData?.iso2,
|
|
4163
|
+
this.#options.allowedNumberTypes
|
|
4164
|
+
) : null;
|
|
4165
|
+
}
|
|
4166
|
+
//* Shared internal validation logic to handle alpha character extension rules.
|
|
4167
|
+
#validateNumber(precise) {
|
|
4168
|
+
const { allowNumberExtensions, allowPhonewords } = this.#options;
|
|
4169
|
+
const testValidity = (s) => precise ? this.#utilsIsValidNumber(s) : this.#utilsIsPossibleNumber(s);
|
|
4170
|
+
const val = this.#getFullNumber();
|
|
4171
|
+
if (!this.#selectedCountryData) {
|
|
4172
|
+
const isRegionlessDialCode = hasRegionlessDialCode(val);
|
|
4173
|
+
if (!isRegionlessDialCode) {
|
|
4174
|
+
return false;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
if (!testValidity(val)) {
|
|
4178
|
+
return false;
|
|
4179
|
+
}
|
|
4180
|
+
const alphaCharPosition = val.search(REGEX.ALPHA_UNICODE);
|
|
4181
|
+
const hasAlphaChar = alphaCharPosition > -1;
|
|
4182
|
+
if (hasAlphaChar) {
|
|
4183
|
+
const selectedIso2 = this.#selectedCountryData?.iso2;
|
|
4184
|
+
const hasExtension = Boolean(intlTelInput.utils.getExtension(val, selectedIso2));
|
|
4185
|
+
if (hasExtension) {
|
|
4186
|
+
return allowNumberExtensions;
|
|
4187
|
+
}
|
|
4188
|
+
return allowPhonewords;
|
|
4189
|
+
}
|
|
4190
|
+
return true;
|
|
4191
|
+
}
|
|
4192
|
+
#utilsIsValidNumber(val) {
|
|
4193
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(
|
|
4194
|
+
val,
|
|
4195
|
+
this.#selectedCountryData?.iso2,
|
|
4196
|
+
this.#options.allowedNumberTypes
|
|
4197
|
+
) : null;
|
|
4198
|
+
}
|
|
4199
|
+
//* Update the selected country, and update the input val accordingly.
|
|
4200
|
+
setCountry(iso2) {
|
|
4201
|
+
if (this.#destroyed) {
|
|
4202
|
+
return;
|
|
4203
|
+
}
|
|
4204
|
+
const iso2Lower = iso2?.toLowerCase();
|
|
4205
|
+
if (!isIso2(iso2Lower)) {
|
|
4206
|
+
throw new Error(`Invalid country code: '${iso2Lower}'`);
|
|
4207
|
+
}
|
|
4208
|
+
const currentCountry = this.#selectedCountryData?.iso2;
|
|
4209
|
+
const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
|
|
4210
|
+
if (isCountryChange) {
|
|
4211
|
+
this.#setCountry(iso2Lower);
|
|
4212
|
+
this.#updateDialCode(this.#selectedCountryData?.dialCode || "");
|
|
4213
|
+
if (this.#options.formatOnDisplay) {
|
|
4214
|
+
const inputValue = this.#getTelInputValue();
|
|
4215
|
+
this.#updateValFromNumber(inputValue);
|
|
4216
|
+
}
|
|
4217
|
+
this.#triggerCountryChange();
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
//* Set the input value and update the country.
|
|
4221
|
+
setNumber(number) {
|
|
4222
|
+
if (this.#destroyed) {
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
const normalisedNumber = this.#numerals.normalise(number);
|
|
4226
|
+
const countryChanged = this.#updateCountryFromNumber(normalisedNumber);
|
|
4227
|
+
this.#updateValFromNumber(normalisedNumber);
|
|
4228
|
+
if (countryChanged) {
|
|
4229
|
+
this.#triggerCountryChange();
|
|
4230
|
+
}
|
|
4231
|
+
this.#trigger(EVENTS.INPUT, { isSetNumber: true });
|
|
4232
|
+
}
|
|
4233
|
+
//* Set the placeholder number type
|
|
4234
|
+
setPlaceholderNumberType(type) {
|
|
4235
|
+
if (this.#destroyed) {
|
|
4236
|
+
return;
|
|
4237
|
+
}
|
|
4238
|
+
this.#options.placeholderNumberType = type;
|
|
4239
|
+
this.#updatePlaceholder();
|
|
4240
|
+
}
|
|
4241
|
+
// Set the disabled state of the input and dropdown.
|
|
4242
|
+
setDisabled(disabled) {
|
|
4243
|
+
if (this.#destroyed) {
|
|
4244
|
+
return;
|
|
4245
|
+
}
|
|
4246
|
+
this.#ui.telInput.disabled = disabled;
|
|
4247
|
+
if (this.#ui.selectedCountry) {
|
|
4248
|
+
if (disabled) {
|
|
4249
|
+
this.#ui.selectedCountry.setAttribute("disabled", "true");
|
|
4250
|
+
} else {
|
|
4251
|
+
this.#ui.selectedCountry.removeAttribute("disabled");
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
// Set the readonly state of the input and dropdown.
|
|
4256
|
+
setReadonly(readonly) {
|
|
4257
|
+
if (!this.#ui.telInput) {
|
|
4258
|
+
return;
|
|
4259
|
+
}
|
|
4260
|
+
this.#ui.telInput.readOnly = readonly;
|
|
4261
|
+
if (this.#ui.selectedCountry) {
|
|
4262
|
+
if (readonly) {
|
|
4263
|
+
this.#ui.selectedCountry.setAttribute("disabled", "true");
|
|
4264
|
+
} else {
|
|
4265
|
+
this.#ui.selectedCountry.removeAttribute("disabled");
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
//********************
|
|
4270
|
+
//* STATIC METHODS
|
|
4271
|
+
//********************
|
|
4272
|
+
// Internal instance notification used by utils/geoip loaders.
|
|
4273
|
+
// Kept public so module-level helpers (e.g. attachUtils) can call it, while still allowing
|
|
4274
|
+
// access to private instance methods.
|
|
4275
|
+
static forEachInstance(method, ...args) {
|
|
4276
|
+
const values = [...intlTelInput.instances.values()];
|
|
4277
|
+
const arg = args[0];
|
|
4278
|
+
values.forEach((instance) => {
|
|
4279
|
+
if (!(instance instanceof _Iti)) {
|
|
4280
|
+
return;
|
|
4281
|
+
}
|
|
4282
|
+
switch (method) {
|
|
4283
|
+
case "handleUtils":
|
|
4284
|
+
instance.#handleUtils();
|
|
4285
|
+
break;
|
|
4286
|
+
case "handleUtilsFailure":
|
|
4287
|
+
instance.#handleUtilsFailure(arg);
|
|
4288
|
+
break;
|
|
4289
|
+
case "handleAutoCountry":
|
|
4290
|
+
instance.#handleAutoCountry();
|
|
4291
|
+
break;
|
|
4292
|
+
case "handleAutoCountryFailure":
|
|
4293
|
+
instance.#handleAutoCountryFailure();
|
|
4294
|
+
break;
|
|
4295
|
+
}
|
|
4296
|
+
});
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
var attachUtils = (source) => {
|
|
4300
|
+
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
4301
|
+
let loadCall;
|
|
4302
|
+
if (typeof source === "function") {
|
|
4303
|
+
try {
|
|
4304
|
+
loadCall = Promise.resolve(source());
|
|
4305
|
+
} catch (error) {
|
|
4306
|
+
return Promise.reject(error);
|
|
4307
|
+
}
|
|
4308
|
+
} else {
|
|
4309
|
+
return Promise.reject(
|
|
4310
|
+
new TypeError(
|
|
4311
|
+
`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
|
|
4312
|
+
)
|
|
4313
|
+
);
|
|
4314
|
+
}
|
|
4315
|
+
intlTelInput.startedLoadingUtilsScript = true;
|
|
4316
|
+
return loadCall.then((module) => {
|
|
4317
|
+
const utils = module?.default;
|
|
4318
|
+
if (!utils || typeof utils !== "object") {
|
|
4319
|
+
throw new TypeError(
|
|
4320
|
+
"The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
|
|
4321
|
+
);
|
|
4322
|
+
}
|
|
4323
|
+
intlTelInput.utils = utils;
|
|
4324
|
+
Iti.forEachInstance("handleUtils");
|
|
4325
|
+
return true;
|
|
4326
|
+
}).catch((error) => {
|
|
4327
|
+
Iti.forEachInstance("handleUtilsFailure", error);
|
|
4328
|
+
throw error;
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
return null;
|
|
4332
|
+
};
|
|
4333
|
+
var intlTelInput = Object.assign(
|
|
4334
|
+
(input, options) => {
|
|
4335
|
+
const iti = new Iti(input, options);
|
|
4336
|
+
intlTelInput.instances.set(String(iti.id), iti);
|
|
4337
|
+
input.iti = iti;
|
|
4338
|
+
return iti;
|
|
4339
|
+
},
|
|
4340
|
+
{
|
|
4341
|
+
defaults,
|
|
4342
|
+
//* Using a static var like this allows us to mock it in the tests.
|
|
4343
|
+
documentReady: () => document.readyState === "complete",
|
|
4344
|
+
//* Get the country data object.
|
|
4345
|
+
getCountryData: () => data_default,
|
|
4346
|
+
//* A getter for the plugin instance.
|
|
4347
|
+
getInstance: (input) => {
|
|
4348
|
+
const id2 = input.dataset.intlTelInputId;
|
|
4349
|
+
return id2 ? intlTelInput.instances.get(id2) ?? null : null;
|
|
4350
|
+
},
|
|
4351
|
+
//* A map from instance ID to instance object.
|
|
4352
|
+
instances: /* @__PURE__ */ new Map(),
|
|
4353
|
+
attachUtils,
|
|
4354
|
+
startedLoadingUtilsScript: false,
|
|
4355
|
+
startedLoadingAutoCountry: false,
|
|
4356
|
+
version: "27.0.0"
|
|
4357
|
+
}
|
|
4358
|
+
);
|
|
4359
|
+
var intl_tel_input_default = intlTelInput;
|
|
4360
|
+
|
|
4361
|
+
// angular/dist/temp/IntlTelInput.js
|
|
4362
|
+
import { Component, Input, ViewChild, ElementRef, Output, EventEmitter, forwardRef } from "@angular/core";
|
|
4363
|
+
import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from "@angular/forms";
|
|
4364
|
+
import * as i0 from "@angular/core";
|
|
4365
|
+
var _c0 = ["inputRef"];
|
|
4366
|
+
var warnInputAttr = (prop) => {
|
|
4367
|
+
console.warn(`intl-tel-input: ignoring inputAttributes.${prop} - see docs for more info.`);
|
|
4368
|
+
};
|
|
4369
|
+
var IntlTelInput = class _IntlTelInput {
|
|
4370
|
+
inputRef;
|
|
4371
|
+
/** initialValue is only used during initialization — changes after init are ignored. */
|
|
4372
|
+
initialValue;
|
|
4373
|
+
usePreciseValidation = false;
|
|
4374
|
+
inputAttributes = {};
|
|
4375
|
+
disabled = false;
|
|
4376
|
+
readonly = false;
|
|
4377
|
+
// Plugin initialisation options (one @Input per option)
|
|
4378
|
+
allowDropdown;
|
|
4379
|
+
allowedNumberTypes;
|
|
4380
|
+
allowNumberExtensions;
|
|
4381
|
+
allowPhonewords;
|
|
4382
|
+
autoPlaceholder;
|
|
4383
|
+
containerClass;
|
|
4384
|
+
countryNameLocale;
|
|
4385
|
+
countryOrder;
|
|
4386
|
+
countrySearch;
|
|
4387
|
+
customPlaceholder;
|
|
4388
|
+
dropdownAlwaysOpen;
|
|
4389
|
+
dropdownContainer;
|
|
4390
|
+
excludeCountries;
|
|
4391
|
+
fixDropdownWidth;
|
|
4392
|
+
formatAsYouType;
|
|
4393
|
+
formatOnDisplay;
|
|
4394
|
+
geoIpLookup;
|
|
4395
|
+
hiddenInput;
|
|
4396
|
+
i18n;
|
|
4397
|
+
initialCountry;
|
|
4398
|
+
loadUtils;
|
|
4399
|
+
nationalMode;
|
|
4400
|
+
onlyCountries;
|
|
4401
|
+
placeholderNumberType;
|
|
4402
|
+
searchInputClass;
|
|
4403
|
+
separateDialCode;
|
|
4404
|
+
showFlags;
|
|
4405
|
+
strictMode;
|
|
4406
|
+
useFullscreenPopup;
|
|
4407
|
+
numberChange = new EventEmitter();
|
|
4408
|
+
countryChange = new EventEmitter();
|
|
4409
|
+
validityChange = new EventEmitter();
|
|
4410
|
+
errorCodeChange = new EventEmitter();
|
|
4411
|
+
blur = new EventEmitter();
|
|
4412
|
+
focus = new EventEmitter();
|
|
4413
|
+
keydown = new EventEmitter();
|
|
4414
|
+
keyup = new EventEmitter();
|
|
4415
|
+
paste = new EventEmitter();
|
|
4416
|
+
click = new EventEmitter();
|
|
4417
|
+
iti;
|
|
4418
|
+
appliedInputAttrKeys = /* @__PURE__ */ new Set();
|
|
4419
|
+
lastEmittedNumber;
|
|
4420
|
+
lastEmittedCountry;
|
|
4421
|
+
lastEmittedValidity;
|
|
4422
|
+
lastEmittedErrorCode;
|
|
4423
|
+
// writeValue may be called by Angular forms before utils has loaded; queue it until then
|
|
4424
|
+
pendingWriteValue;
|
|
4425
|
+
countryChangeHandler = () => this.handleInput();
|
|
4426
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4427
|
+
onChange = () => {
|
|
4428
|
+
};
|
|
4429
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4430
|
+
onTouched = () => {
|
|
4431
|
+
};
|
|
4432
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4433
|
+
onValidatorChange = () => {
|
|
4434
|
+
};
|
|
4435
|
+
ngAfterViewInit() {
|
|
4436
|
+
this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.buildInitOptions());
|
|
4437
|
+
this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
|
|
4438
|
+
this.applyInputAttrs();
|
|
4439
|
+
if (this.disabled) {
|
|
4440
|
+
this.iti.setDisabled(this.disabled);
|
|
4441
|
+
}
|
|
4442
|
+
if (this.readonly) {
|
|
4443
|
+
this.iti.setReadonly(this.readonly);
|
|
4444
|
+
}
|
|
4445
|
+
this.iti.promise.then(() => {
|
|
4446
|
+
if (!this.iti?.isActive()) {
|
|
4447
|
+
return;
|
|
4448
|
+
}
|
|
4449
|
+
if (this.pendingWriteValue !== void 0) {
|
|
4450
|
+
this.iti.setNumber(this.pendingWriteValue);
|
|
4451
|
+
this.pendingWriteValue = void 0;
|
|
4452
|
+
} else if (this.initialValue) {
|
|
4453
|
+
this.iti.setNumber(this.initialValue);
|
|
4454
|
+
}
|
|
4455
|
+
});
|
|
4456
|
+
}
|
|
4457
|
+
buildInitOptions() {
|
|
4458
|
+
const options = {
|
|
4459
|
+
allowDropdown: this.allowDropdown,
|
|
4460
|
+
allowedNumberTypes: this.allowedNumberTypes,
|
|
4461
|
+
allowNumberExtensions: this.allowNumberExtensions,
|
|
4462
|
+
allowPhonewords: this.allowPhonewords,
|
|
4463
|
+
autoPlaceholder: this.autoPlaceholder,
|
|
4464
|
+
containerClass: this.containerClass,
|
|
4465
|
+
countryNameLocale: this.countryNameLocale,
|
|
4466
|
+
countryOrder: this.countryOrder,
|
|
4467
|
+
countrySearch: this.countrySearch,
|
|
4468
|
+
customPlaceholder: this.customPlaceholder,
|
|
4469
|
+
dropdownAlwaysOpen: this.dropdownAlwaysOpen,
|
|
4470
|
+
dropdownContainer: this.dropdownContainer,
|
|
4471
|
+
excludeCountries: this.excludeCountries,
|
|
4472
|
+
fixDropdownWidth: this.fixDropdownWidth,
|
|
4473
|
+
formatAsYouType: this.formatAsYouType,
|
|
4474
|
+
formatOnDisplay: this.formatOnDisplay,
|
|
4475
|
+
geoIpLookup: this.geoIpLookup,
|
|
4476
|
+
hiddenInput: this.hiddenInput,
|
|
4477
|
+
i18n: this.i18n,
|
|
4478
|
+
initialCountry: this.initialCountry,
|
|
4479
|
+
loadUtils: this.loadUtils,
|
|
4480
|
+
nationalMode: this.nationalMode,
|
|
4481
|
+
onlyCountries: this.onlyCountries,
|
|
4482
|
+
placeholderNumberType: this.placeholderNumberType,
|
|
4483
|
+
searchInputClass: this.searchInputClass,
|
|
4484
|
+
separateDialCode: this.separateDialCode,
|
|
4485
|
+
showFlags: this.showFlags,
|
|
4486
|
+
strictMode: this.strictMode,
|
|
4487
|
+
useFullscreenPopup: this.useFullscreenPopup
|
|
4488
|
+
};
|
|
4489
|
+
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
|
|
4490
|
+
}
|
|
4491
|
+
ngOnChanges(changes) {
|
|
4492
|
+
if (changes["disabled"]) {
|
|
4493
|
+
this.iti?.setDisabled(this.disabled);
|
|
4494
|
+
}
|
|
4495
|
+
if (changes["readonly"]) {
|
|
4496
|
+
this.iti?.setReadonly(this.readonly);
|
|
4497
|
+
}
|
|
4498
|
+
if (changes["inputAttributes"]) {
|
|
4499
|
+
this.applyInputAttrs();
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
handleInput() {
|
|
4503
|
+
if (!this.iti) {
|
|
4504
|
+
return;
|
|
4505
|
+
}
|
|
4506
|
+
const num = this.iti.getNumber() ?? "";
|
|
4507
|
+
const countryIso = this.iti.getSelectedCountryData()?.iso2 ?? "";
|
|
4508
|
+
let hasChanged = false;
|
|
4509
|
+
if (num !== this.lastEmittedNumber) {
|
|
4510
|
+
this.lastEmittedNumber = num;
|
|
4511
|
+
this.numberChange.emit(num);
|
|
4512
|
+
this.onChange(num);
|
|
4513
|
+
hasChanged = true;
|
|
4514
|
+
}
|
|
4515
|
+
if (countryIso !== this.lastEmittedCountry) {
|
|
4516
|
+
this.lastEmittedCountry = countryIso;
|
|
4517
|
+
this.countryChange.emit(countryIso);
|
|
4518
|
+
hasChanged = true;
|
|
4519
|
+
}
|
|
4520
|
+
const isValid = (this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber()) ?? false;
|
|
4521
|
+
const errorCode = isValid ? null : this.iti.getValidationError();
|
|
4522
|
+
if (isValid !== this.lastEmittedValidity) {
|
|
4523
|
+
this.lastEmittedValidity = isValid;
|
|
4524
|
+
this.validityChange.emit(isValid);
|
|
4525
|
+
hasChanged = true;
|
|
4526
|
+
}
|
|
4527
|
+
if (errorCode !== this.lastEmittedErrorCode) {
|
|
4528
|
+
this.lastEmittedErrorCode = errorCode;
|
|
4529
|
+
this.errorCodeChange.emit(errorCode);
|
|
4530
|
+
hasChanged = true;
|
|
4531
|
+
}
|
|
4532
|
+
if (hasChanged) {
|
|
4533
|
+
this.onValidatorChange();
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
handleBlur(event) {
|
|
4537
|
+
this.onTouched();
|
|
4538
|
+
this.blur.emit(event);
|
|
4539
|
+
}
|
|
4540
|
+
handleFocus(event) {
|
|
4541
|
+
this.focus.emit(event);
|
|
4542
|
+
}
|
|
4543
|
+
handleKeyDown(event) {
|
|
4544
|
+
this.keydown.emit(event);
|
|
4545
|
+
}
|
|
4546
|
+
handleKeyUp(event) {
|
|
4547
|
+
this.keyup.emit(event);
|
|
4548
|
+
}
|
|
4549
|
+
handlePaste(event) {
|
|
4550
|
+
this.paste.emit(event);
|
|
4551
|
+
}
|
|
4552
|
+
handleClick(event) {
|
|
4553
|
+
this.click.emit(event);
|
|
4554
|
+
}
|
|
4555
|
+
/**
|
|
4556
|
+
* This method must be called in `ngAfterViewInit` or later lifecycle hooks,
|
|
4557
|
+
* not in `ngOnInit` or the `constructor`, as the component needs to be fully initialized.
|
|
4558
|
+
*/
|
|
4559
|
+
getInstance() {
|
|
4560
|
+
return this.iti;
|
|
4561
|
+
}
|
|
4562
|
+
/**
|
|
4563
|
+
* This method must be called in `ngAfterViewInit` or later lifecycle hooks,
|
|
4564
|
+
* not in `ngOnInit` or the `constructor`, as the component needs to be fully initialized.
|
|
4565
|
+
*/
|
|
4566
|
+
getInput() {
|
|
4567
|
+
return this.inputRef.nativeElement;
|
|
4568
|
+
}
|
|
4569
|
+
ngOnDestroy() {
|
|
4570
|
+
this.iti?.destroy();
|
|
4571
|
+
this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
|
|
4572
|
+
}
|
|
4573
|
+
ignoredInputAttrs = /* @__PURE__ */ new Set([
|
|
4574
|
+
"type",
|
|
4575
|
+
"value",
|
|
4576
|
+
"disabled",
|
|
4577
|
+
"readonly"
|
|
4578
|
+
]);
|
|
4579
|
+
applyInputAttrs() {
|
|
4580
|
+
const currentKeys = /* @__PURE__ */ new Set();
|
|
4581
|
+
Object.entries(this.inputAttributes).forEach(([key, value]) => {
|
|
4582
|
+
if (this.ignoredInputAttrs.has(key)) {
|
|
4583
|
+
warnInputAttr(key);
|
|
4584
|
+
} else {
|
|
4585
|
+
currentKeys.add(key);
|
|
4586
|
+
this.inputRef.nativeElement.setAttribute(key, value);
|
|
4587
|
+
}
|
|
4588
|
+
});
|
|
4589
|
+
this.appliedInputAttrKeys.forEach((key) => {
|
|
4590
|
+
if (!currentKeys.has(key)) {
|
|
4591
|
+
this.inputRef.nativeElement.removeAttribute(key);
|
|
4592
|
+
}
|
|
4593
|
+
});
|
|
4594
|
+
this.appliedInputAttrKeys = currentKeys;
|
|
4595
|
+
}
|
|
4596
|
+
// ============ ControlValueAccessor Implementation ============
|
|
4597
|
+
writeValue(value) {
|
|
4598
|
+
const next = value || "";
|
|
4599
|
+
if (this.iti) {
|
|
4600
|
+
this.iti.promise.then(() => {
|
|
4601
|
+
if (this.iti?.isActive()) {
|
|
4602
|
+
this.iti.setNumber(next);
|
|
4603
|
+
}
|
|
4604
|
+
});
|
|
4605
|
+
} else {
|
|
4606
|
+
this.pendingWriteValue = next;
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
registerOnChange(fn) {
|
|
4610
|
+
this.onChange = fn;
|
|
4611
|
+
}
|
|
4612
|
+
registerOnTouched(fn) {
|
|
4613
|
+
this.onTouched = fn;
|
|
4614
|
+
}
|
|
4615
|
+
setDisabledState(isDisabled) {
|
|
4616
|
+
this.disabled = isDisabled;
|
|
4617
|
+
this.iti?.setDisabled(isDisabled);
|
|
4618
|
+
}
|
|
4619
|
+
// ============ Validator Implementation ============
|
|
4620
|
+
validate(_control) {
|
|
4621
|
+
if (!this.iti || !this.iti.getNumber()) {
|
|
4622
|
+
return null;
|
|
4623
|
+
}
|
|
4624
|
+
const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
|
|
4625
|
+
if (isValid) {
|
|
4626
|
+
return null;
|
|
4627
|
+
}
|
|
4628
|
+
const errorCode = this.iti.getValidationError();
|
|
4629
|
+
return {
|
|
4630
|
+
invalidPhone: errorCode
|
|
4631
|
+
};
|
|
4632
|
+
}
|
|
4633
|
+
registerOnValidatorChange(fn) {
|
|
4634
|
+
this.onValidatorChange = fn;
|
|
4635
|
+
}
|
|
4636
|
+
static \u0275fac = function IntlTelInput_Factory(__ngFactoryType__) {
|
|
4637
|
+
return new (__ngFactoryType__ || _IntlTelInput)();
|
|
4638
|
+
};
|
|
4639
|
+
static \u0275cmp = /* @__PURE__ */ i0.\u0275\u0275defineComponent({ type: _IntlTelInput, selectors: [["intl-tel-input"]], viewQuery: function IntlTelInput_Query(rf, ctx) {
|
|
4640
|
+
if (rf & 1) {
|
|
4641
|
+
i0.\u0275\u0275viewQuery(_c0, 7);
|
|
4642
|
+
}
|
|
4643
|
+
if (rf & 2) {
|
|
4644
|
+
let _t;
|
|
4645
|
+
i0.\u0275\u0275queryRefresh(_t = i0.\u0275\u0275loadQuery()) && (ctx.inputRef = _t.first);
|
|
4646
|
+
}
|
|
4647
|
+
}, inputs: { initialValue: "initialValue", usePreciseValidation: "usePreciseValidation", inputAttributes: "inputAttributes", disabled: "disabled", readonly: "readonly", allowDropdown: "allowDropdown", allowedNumberTypes: "allowedNumberTypes", allowNumberExtensions: "allowNumberExtensions", allowPhonewords: "allowPhonewords", autoPlaceholder: "autoPlaceholder", containerClass: "containerClass", countryNameLocale: "countryNameLocale", countryOrder: "countryOrder", countrySearch: "countrySearch", customPlaceholder: "customPlaceholder", dropdownAlwaysOpen: "dropdownAlwaysOpen", dropdownContainer: "dropdownContainer", excludeCountries: "excludeCountries", fixDropdownWidth: "fixDropdownWidth", formatAsYouType: "formatAsYouType", formatOnDisplay: "formatOnDisplay", geoIpLookup: "geoIpLookup", hiddenInput: "hiddenInput", i18n: "i18n", initialCountry: "initialCountry", loadUtils: "loadUtils", nationalMode: "nationalMode", onlyCountries: "onlyCountries", placeholderNumberType: "placeholderNumberType", searchInputClass: "searchInputClass", separateDialCode: "separateDialCode", showFlags: "showFlags", strictMode: "strictMode", useFullscreenPopup: "useFullscreenPopup" }, outputs: { numberChange: "numberChange", countryChange: "countryChange", validityChange: "validityChange", errorCodeChange: "errorCodeChange", blur: "blur", focus: "focus", keydown: "keydown", keyup: "keyup", paste: "paste", click: "click" }, features: [i0.\u0275\u0275ProvidersFeature([
|
|
4648
|
+
{
|
|
4649
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4650
|
+
useExisting: forwardRef(() => _IntlTelInput),
|
|
4651
|
+
multi: true
|
|
4652
|
+
},
|
|
4653
|
+
{
|
|
4654
|
+
provide: NG_VALIDATORS,
|
|
4655
|
+
useExisting: forwardRef(() => _IntlTelInput),
|
|
4656
|
+
multi: true
|
|
4657
|
+
}
|
|
4658
|
+
]), i0.\u0275\u0275NgOnChangesFeature], decls: 2, vars: 0, consts: [["inputRef", ""], ["type", "tel", 3, "input", "blur", "focus", "keydown", "keyup", "paste", "click"]], template: function IntlTelInput_Template(rf, ctx) {
|
|
4659
|
+
if (rf & 1) {
|
|
4660
|
+
i0.\u0275\u0275domElementStart(0, "input", 1, 0);
|
|
4661
|
+
i0.\u0275\u0275domListener("input", function IntlTelInput_Template_input_input_0_listener() {
|
|
4662
|
+
return ctx.handleInput();
|
|
4663
|
+
})("blur", function IntlTelInput_Template_input_blur_0_listener($event) {
|
|
4664
|
+
return ctx.handleBlur($event);
|
|
4665
|
+
})("focus", function IntlTelInput_Template_input_focus_0_listener($event) {
|
|
4666
|
+
return ctx.handleFocus($event);
|
|
4667
|
+
})("keydown", function IntlTelInput_Template_input_keydown_0_listener($event) {
|
|
4668
|
+
return ctx.handleKeyDown($event);
|
|
4669
|
+
})("keyup", function IntlTelInput_Template_input_keyup_0_listener($event) {
|
|
4670
|
+
return ctx.handleKeyUp($event);
|
|
4671
|
+
})("paste", function IntlTelInput_Template_input_paste_0_listener($event) {
|
|
4672
|
+
return ctx.handlePaste($event);
|
|
4673
|
+
})("click", function IntlTelInput_Template_input_click_0_listener($event) {
|
|
4674
|
+
return ctx.handleClick($event);
|
|
4675
|
+
});
|
|
4676
|
+
i0.\u0275\u0275domElementEnd();
|
|
4677
|
+
}
|
|
4678
|
+
}, encapsulation: 2 });
|
|
4679
|
+
};
|
|
4680
|
+
(() => {
|
|
4681
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassMetadata(IntlTelInput, [{
|
|
4682
|
+
type: Component,
|
|
4683
|
+
args: [{
|
|
4684
|
+
selector: "intl-tel-input",
|
|
4685
|
+
standalone: true,
|
|
4686
|
+
template: `
|
|
4687
|
+
<input
|
|
4688
|
+
type="tel"
|
|
4689
|
+
#inputRef
|
|
4690
|
+
(input)="handleInput()"
|
|
4691
|
+
(blur)="handleBlur($event)"
|
|
4692
|
+
(focus)="handleFocus($event)"
|
|
4693
|
+
(keydown)="handleKeyDown($event)"
|
|
4694
|
+
(keyup)="handleKeyUp($event)"
|
|
4695
|
+
(paste)="handlePaste($event)"
|
|
4696
|
+
(click)="handleClick($event)"
|
|
4697
|
+
/>
|
|
4698
|
+
`,
|
|
4699
|
+
providers: [
|
|
4700
|
+
{
|
|
4701
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4702
|
+
useExisting: forwardRef(() => IntlTelInput),
|
|
4703
|
+
multi: true
|
|
4704
|
+
},
|
|
4705
|
+
{
|
|
4706
|
+
provide: NG_VALIDATORS,
|
|
4707
|
+
useExisting: forwardRef(() => IntlTelInput),
|
|
4708
|
+
multi: true
|
|
4709
|
+
}
|
|
4710
|
+
]
|
|
4711
|
+
}]
|
|
4712
|
+
}], null, { inputRef: [{
|
|
4713
|
+
type: ViewChild,
|
|
4714
|
+
args: ["inputRef", { static: true }]
|
|
4715
|
+
}], initialValue: [{
|
|
4716
|
+
type: Input
|
|
4717
|
+
}], usePreciseValidation: [{
|
|
4718
|
+
type: Input
|
|
4719
|
+
}], inputAttributes: [{
|
|
4720
|
+
type: Input
|
|
4721
|
+
}], disabled: [{
|
|
4722
|
+
type: Input
|
|
4723
|
+
}], readonly: [{
|
|
4724
|
+
type: Input
|
|
4725
|
+
}], allowDropdown: [{
|
|
4726
|
+
type: Input
|
|
4727
|
+
}], allowedNumberTypes: [{
|
|
4728
|
+
type: Input
|
|
4729
|
+
}], allowNumberExtensions: [{
|
|
4730
|
+
type: Input
|
|
4731
|
+
}], allowPhonewords: [{
|
|
4732
|
+
type: Input
|
|
4733
|
+
}], autoPlaceholder: [{
|
|
4734
|
+
type: Input
|
|
4735
|
+
}], containerClass: [{
|
|
4736
|
+
type: Input
|
|
4737
|
+
}], countryNameLocale: [{
|
|
4738
|
+
type: Input
|
|
4739
|
+
}], countryOrder: [{
|
|
4740
|
+
type: Input
|
|
4741
|
+
}], countrySearch: [{
|
|
4742
|
+
type: Input
|
|
4743
|
+
}], customPlaceholder: [{
|
|
4744
|
+
type: Input
|
|
4745
|
+
}], dropdownAlwaysOpen: [{
|
|
4746
|
+
type: Input
|
|
4747
|
+
}], dropdownContainer: [{
|
|
4748
|
+
type: Input
|
|
4749
|
+
}], excludeCountries: [{
|
|
4750
|
+
type: Input
|
|
4751
|
+
}], fixDropdownWidth: [{
|
|
4752
|
+
type: Input
|
|
4753
|
+
}], formatAsYouType: [{
|
|
4754
|
+
type: Input
|
|
4755
|
+
}], formatOnDisplay: [{
|
|
4756
|
+
type: Input
|
|
4757
|
+
}], geoIpLookup: [{
|
|
4758
|
+
type: Input
|
|
4759
|
+
}], hiddenInput: [{
|
|
4760
|
+
type: Input
|
|
4761
|
+
}], i18n: [{
|
|
4762
|
+
type: Input
|
|
4763
|
+
}], initialCountry: [{
|
|
4764
|
+
type: Input
|
|
4765
|
+
}], loadUtils: [{
|
|
4766
|
+
type: Input
|
|
4767
|
+
}], nationalMode: [{
|
|
4768
|
+
type: Input
|
|
4769
|
+
}], onlyCountries: [{
|
|
4770
|
+
type: Input
|
|
4771
|
+
}], placeholderNumberType: [{
|
|
4772
|
+
type: Input
|
|
4773
|
+
}], searchInputClass: [{
|
|
4774
|
+
type: Input
|
|
4775
|
+
}], separateDialCode: [{
|
|
4776
|
+
type: Input
|
|
4777
|
+
}], showFlags: [{
|
|
4778
|
+
type: Input
|
|
4779
|
+
}], strictMode: [{
|
|
4780
|
+
type: Input
|
|
4781
|
+
}], useFullscreenPopup: [{
|
|
4782
|
+
type: Input
|
|
4783
|
+
}], numberChange: [{
|
|
4784
|
+
type: Output
|
|
4785
|
+
}], countryChange: [{
|
|
4786
|
+
type: Output
|
|
4787
|
+
}], validityChange: [{
|
|
4788
|
+
type: Output
|
|
4789
|
+
}], errorCodeChange: [{
|
|
4790
|
+
type: Output
|
|
4791
|
+
}], blur: [{
|
|
4792
|
+
type: Output
|
|
4793
|
+
}], focus: [{
|
|
4794
|
+
type: Output
|
|
4795
|
+
}], keydown: [{
|
|
4796
|
+
type: Output
|
|
4797
|
+
}], keyup: [{
|
|
4798
|
+
type: Output
|
|
4799
|
+
}], paste: [{
|
|
4800
|
+
type: Output
|
|
4801
|
+
}], click: [{
|
|
4802
|
+
type: Output
|
|
4803
|
+
}] });
|
|
4804
|
+
})();
|
|
4805
|
+
(() => {
|
|
4806
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassDebugInfo(IntlTelInput, { className: "IntlTelInput", filePath: "intltelinput.ts", lineNumber: 62 });
|
|
4807
|
+
})();
|
|
4808
|
+
var IntlTelInput_default = IntlTelInput;
|
|
4809
|
+
export {
|
|
4810
|
+
IntlTelInput_default as default,
|
|
4811
|
+
intl_tel_input_default as intlTelInput
|
|
4812
|
+
};
|