intl-tel-input 25.4.8 → 25.5.1

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.
Files changed (146) hide show
  1. package/README.md +5 -5
  2. package/angular/build/IntlTelInput.js +258 -316
  3. package/angular/build/IntlTelInputWithUtils.js +472 -446
  4. package/angular/build/intl-tel-input.js +46 -12
  5. package/build/js/data.js +1 -1
  6. package/build/js/data.min.js +1 -1
  7. package/build/js/intlTelInput.js +38 -9
  8. package/build/js/intlTelInput.min.js +2 -2
  9. package/build/js/intlTelInputWithUtils.js +38 -9
  10. package/build/js/intlTelInputWithUtils.min.js +2 -2
  11. package/package.json +4 -4
  12. package/react/README.md +1 -1
  13. package/react/build/IntlTelInput.cjs +37 -8
  14. package/react/build/IntlTelInput.js +37 -8
  15. package/react/build/IntlTelInputWithUtils.cjs +37 -8
  16. package/react/build/IntlTelInputWithUtils.js +37 -8
  17. package/vue/README.md +1 -1
  18. package/vue/build/IntlTelInput.mjs +144 -135
  19. package/vue/build/IntlTelInputWithUtils.mjs +488 -479
  20. package/angular/build/IntlTelInput.cjs +0 -3358
  21. package/angular/build/IntlTelInput.d.ts +0 -1671
  22. package/angular/build/IntlTelInputWithUtils.cjs +0 -9732
  23. package/angular/build/intl-tel-input/angular.js +0 -205
  24. package/angular/build/intl-tel-input/angularWithUtils.js +0 -206
  25. package/angular/build/intl-tel-input/data.js +0 -1096
  26. package/angular/build/intl-tel-input/i18n/ar/countries.js +0 -245
  27. package/angular/build/intl-tel-input/i18n/ar/index.js +0 -5
  28. package/angular/build/intl-tel-input/i18n/ar/interface.js +0 -13
  29. package/angular/build/intl-tel-input/i18n/bg/countries.js +0 -245
  30. package/angular/build/intl-tel-input/i18n/bg/index.js +0 -5
  31. package/angular/build/intl-tel-input/i18n/bg/interface.js +0 -13
  32. package/angular/build/intl-tel-input/i18n/bn/countries.js +0 -245
  33. package/angular/build/intl-tel-input/i18n/bn/index.js +0 -5
  34. package/angular/build/intl-tel-input/i18n/bn/interface.js +0 -13
  35. package/angular/build/intl-tel-input/i18n/bs/countries.js +0 -245
  36. package/angular/build/intl-tel-input/i18n/bs/index.js +0 -5
  37. package/angular/build/intl-tel-input/i18n/bs/interface.js +0 -13
  38. package/angular/build/intl-tel-input/i18n/ca/countries.js +0 -245
  39. package/angular/build/intl-tel-input/i18n/ca/index.js +0 -5
  40. package/angular/build/intl-tel-input/i18n/ca/interface.js +0 -13
  41. package/angular/build/intl-tel-input/i18n/cs/countries.js +0 -245
  42. package/angular/build/intl-tel-input/i18n/cs/index.js +0 -5
  43. package/angular/build/intl-tel-input/i18n/cs/interface.js +0 -13
  44. package/angular/build/intl-tel-input/i18n/da/countries.js +0 -245
  45. package/angular/build/intl-tel-input/i18n/da/index.js +0 -5
  46. package/angular/build/intl-tel-input/i18n/da/interface.js +0 -13
  47. package/angular/build/intl-tel-input/i18n/de/countries.js +0 -245
  48. package/angular/build/intl-tel-input/i18n/de/index.js +0 -5
  49. package/angular/build/intl-tel-input/i18n/de/interface.js +0 -13
  50. package/angular/build/intl-tel-input/i18n/ee/countries.js +0 -245
  51. package/angular/build/intl-tel-input/i18n/ee/index.js +0 -5
  52. package/angular/build/intl-tel-input/i18n/ee/interface.js +0 -13
  53. package/angular/build/intl-tel-input/i18n/el/countries.js +0 -245
  54. package/angular/build/intl-tel-input/i18n/el/index.js +0 -5
  55. package/angular/build/intl-tel-input/i18n/el/interface.js +0 -13
  56. package/angular/build/intl-tel-input/i18n/en/countries.js +0 -245
  57. package/angular/build/intl-tel-input/i18n/en/index.js +0 -5
  58. package/angular/build/intl-tel-input/i18n/en/interface.js +0 -13
  59. package/angular/build/intl-tel-input/i18n/es/countries.js +0 -245
  60. package/angular/build/intl-tel-input/i18n/es/index.js +0 -5
  61. package/angular/build/intl-tel-input/i18n/es/interface.js +0 -13
  62. package/angular/build/intl-tel-input/i18n/fa/countries.js +0 -245
  63. package/angular/build/intl-tel-input/i18n/fa/index.js +0 -5
  64. package/angular/build/intl-tel-input/i18n/fa/interface.js +0 -13
  65. package/angular/build/intl-tel-input/i18n/fi/countries.js +0 -245
  66. package/angular/build/intl-tel-input/i18n/fi/index.js +0 -5
  67. package/angular/build/intl-tel-input/i18n/fi/interface.js +0 -13
  68. package/angular/build/intl-tel-input/i18n/fr/countries.js +0 -245
  69. package/angular/build/intl-tel-input/i18n/fr/index.js +0 -5
  70. package/angular/build/intl-tel-input/i18n/fr/interface.js +0 -13
  71. package/angular/build/intl-tel-input/i18n/hi/countries.js +0 -245
  72. package/angular/build/intl-tel-input/i18n/hi/index.js +0 -5
  73. package/angular/build/intl-tel-input/i18n/hi/interface.js +0 -13
  74. package/angular/build/intl-tel-input/i18n/hr/countries.js +0 -245
  75. package/angular/build/intl-tel-input/i18n/hr/index.js +0 -5
  76. package/angular/build/intl-tel-input/i18n/hr/interface.js +0 -13
  77. package/angular/build/intl-tel-input/i18n/hu/countries.js +0 -245
  78. package/angular/build/intl-tel-input/i18n/hu/index.js +0 -5
  79. package/angular/build/intl-tel-input/i18n/hu/interface.js +0 -13
  80. package/angular/build/intl-tel-input/i18n/id/countries.js +0 -245
  81. package/angular/build/intl-tel-input/i18n/id/index.js +0 -5
  82. package/angular/build/intl-tel-input/i18n/id/interface.js +0 -13
  83. package/angular/build/intl-tel-input/i18n/index.js +0 -40
  84. package/angular/build/intl-tel-input/i18n/it/countries.js +0 -245
  85. package/angular/build/intl-tel-input/i18n/it/index.js +0 -5
  86. package/angular/build/intl-tel-input/i18n/it/interface.js +0 -13
  87. package/angular/build/intl-tel-input/i18n/ja/countries.js +0 -245
  88. package/angular/build/intl-tel-input/i18n/ja/index.js +0 -5
  89. package/angular/build/intl-tel-input/i18n/ja/interface.js +0 -13
  90. package/angular/build/intl-tel-input/i18n/ko/countries.js +0 -245
  91. package/angular/build/intl-tel-input/i18n/ko/index.js +0 -5
  92. package/angular/build/intl-tel-input/i18n/ko/interface.js +0 -13
  93. package/angular/build/intl-tel-input/i18n/mr/countries.js +0 -245
  94. package/angular/build/intl-tel-input/i18n/mr/index.js +0 -5
  95. package/angular/build/intl-tel-input/i18n/mr/interface.js +0 -13
  96. package/angular/build/intl-tel-input/i18n/nl/countries.js +0 -245
  97. package/angular/build/intl-tel-input/i18n/nl/index.js +0 -5
  98. package/angular/build/intl-tel-input/i18n/nl/interface.js +0 -13
  99. package/angular/build/intl-tel-input/i18n/no/countries.js +0 -245
  100. package/angular/build/intl-tel-input/i18n/no/index.js +0 -5
  101. package/angular/build/intl-tel-input/i18n/no/interface.js +0 -13
  102. package/angular/build/intl-tel-input/i18n/pl/countries.js +0 -245
  103. package/angular/build/intl-tel-input/i18n/pl/index.js +0 -5
  104. package/angular/build/intl-tel-input/i18n/pl/interface.js +0 -24
  105. package/angular/build/intl-tel-input/i18n/pt/countries.js +0 -245
  106. package/angular/build/intl-tel-input/i18n/pt/index.js +0 -5
  107. package/angular/build/intl-tel-input/i18n/pt/interface.js +0 -13
  108. package/angular/build/intl-tel-input/i18n/ro/countries.js +0 -245
  109. package/angular/build/intl-tel-input/i18n/ro/index.js +0 -5
  110. package/angular/build/intl-tel-input/i18n/ro/interface.js +0 -13
  111. package/angular/build/intl-tel-input/i18n/ru/countries.js +0 -245
  112. package/angular/build/intl-tel-input/i18n/ru/index.js +0 -5
  113. package/angular/build/intl-tel-input/i18n/ru/interface.js +0 -13
  114. package/angular/build/intl-tel-input/i18n/sk/countries.js +0 -245
  115. package/angular/build/intl-tel-input/i18n/sk/index.js +0 -5
  116. package/angular/build/intl-tel-input/i18n/sk/interface.js +0 -13
  117. package/angular/build/intl-tel-input/i18n/sv/countries.js +0 -245
  118. package/angular/build/intl-tel-input/i18n/sv/index.js +0 -5
  119. package/angular/build/intl-tel-input/i18n/sv/interface.js +0 -13
  120. package/angular/build/intl-tel-input/i18n/te/countries.js +0 -245
  121. package/angular/build/intl-tel-input/i18n/te/index.js +0 -5
  122. package/angular/build/intl-tel-input/i18n/te/interface.js +0 -13
  123. package/angular/build/intl-tel-input/i18n/th/countries.js +0 -245
  124. package/angular/build/intl-tel-input/i18n/th/index.js +0 -5
  125. package/angular/build/intl-tel-input/i18n/th/interface.js +0 -13
  126. package/angular/build/intl-tel-input/i18n/tr/countries.js +0 -245
  127. package/angular/build/intl-tel-input/i18n/tr/index.js +0 -5
  128. package/angular/build/intl-tel-input/i18n/tr/interface.js +0 -13
  129. package/angular/build/intl-tel-input/i18n/types.js +0 -1
  130. package/angular/build/intl-tel-input/i18n/uk/countries.js +0 -245
  131. package/angular/build/intl-tel-input/i18n/uk/index.js +0 -5
  132. package/angular/build/intl-tel-input/i18n/uk/interface.js +0 -13
  133. package/angular/build/intl-tel-input/i18n/ur/countries.js +0 -245
  134. package/angular/build/intl-tel-input/i18n/ur/index.js +0 -5
  135. package/angular/build/intl-tel-input/i18n/ur/interface.js +0 -13
  136. package/angular/build/intl-tel-input/i18n/uz/countries.js +0 -245
  137. package/angular/build/intl-tel-input/i18n/uz/index.js +0 -5
  138. package/angular/build/intl-tel-input/i18n/uz/interface.js +0 -13
  139. package/angular/build/intl-tel-input/i18n/vi/countries.js +0 -245
  140. package/angular/build/intl-tel-input/i18n/vi/index.js +0 -5
  141. package/angular/build/intl-tel-input/i18n/vi/interface.js +0 -13
  142. package/angular/build/intl-tel-input/i18n/zh/countries.js +0 -245
  143. package/angular/build/intl-tel-input/i18n/zh/index.js +0 -5
  144. package/angular/build/intl-tel-input/i18n/zh/interface.js +0 -13
  145. package/angular/build/intl-tel-input/intlTelInputWithUtils.js +0 -4
  146. package/angular/build/intl-tel-input/utils.js +0 -1341
@@ -1,3358 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __decorateClass = (decorators, target, key, kind) => {
19
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
- if (decorator = decorators[i])
22
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
- if (kind && result) __defProp(target, key, result);
24
- return result;
25
- };
26
-
27
- // angular/src/intl-tel-input/angular.ts
28
- var angular_exports = {};
29
- __export(angular_exports, {
30
- IntlTelInputComponent: () => IntlTelInputComponent,
31
- PHONE_ERROR_MESSAGES: () => PHONE_ERROR_MESSAGES,
32
- intlTelInput: () => intl_tel_input_default
33
- });
34
- module.exports = __toCommonJS(angular_exports);
35
-
36
- // src/js/intl-tel-input/data.ts
37
- var rawCountryData = [
38
- [
39
- "af",
40
- // Afghanistan
41
- "93"
42
- ],
43
- [
44
- "ax",
45
- // Åland Islands
46
- "358",
47
- 1
48
- ],
49
- [
50
- "al",
51
- // Albania
52
- "355"
53
- ],
54
- [
55
- "dz",
56
- // Algeria
57
- "213"
58
- ],
59
- [
60
- "as",
61
- // American Samoa
62
- "1",
63
- 5,
64
- ["684"]
65
- ],
66
- [
67
- "ad",
68
- // Andorra
69
- "376"
70
- ],
71
- [
72
- "ao",
73
- // Angola
74
- "244"
75
- ],
76
- [
77
- "ai",
78
- // Anguilla
79
- "1",
80
- 6,
81
- ["264"]
82
- ],
83
- [
84
- "ag",
85
- // Antigua and Barbuda
86
- "1",
87
- 7,
88
- ["268"]
89
- ],
90
- [
91
- "ar",
92
- // Argentina
93
- "54"
94
- ],
95
- [
96
- "am",
97
- // Armenia
98
- "374"
99
- ],
100
- [
101
- "aw",
102
- // Aruba
103
- "297"
104
- ],
105
- [
106
- "ac",
107
- // Ascension Island
108
- "247"
109
- ],
110
- [
111
- "au",
112
- // Australia
113
- "61",
114
- 0,
115
- null,
116
- "0"
117
- ],
118
- [
119
- "at",
120
- // Austria
121
- "43"
122
- ],
123
- [
124
- "az",
125
- // Azerbaijan
126
- "994"
127
- ],
128
- [
129
- "bs",
130
- // Bahamas
131
- "1",
132
- 8,
133
- ["242"]
134
- ],
135
- [
136
- "bh",
137
- // Bahrain
138
- "973"
139
- ],
140
- [
141
- "bd",
142
- // Bangladesh
143
- "880"
144
- ],
145
- [
146
- "bb",
147
- // Barbados
148
- "1",
149
- 9,
150
- ["246"]
151
- ],
152
- [
153
- "by",
154
- // Belarus
155
- "375"
156
- ],
157
- [
158
- "be",
159
- // Belgium
160
- "32"
161
- ],
162
- [
163
- "bz",
164
- // Belize
165
- "501"
166
- ],
167
- [
168
- "bj",
169
- // Benin
170
- "229"
171
- ],
172
- [
173
- "bm",
174
- // Bermuda
175
- "1",
176
- 10,
177
- ["441"]
178
- ],
179
- [
180
- "bt",
181
- // Bhutan
182
- "975"
183
- ],
184
- [
185
- "bo",
186
- // Bolivia
187
- "591"
188
- ],
189
- [
190
- "ba",
191
- // Bosnia and Herzegovina
192
- "387"
193
- ],
194
- [
195
- "bw",
196
- // Botswana
197
- "267"
198
- ],
199
- [
200
- "br",
201
- // Brazil
202
- "55"
203
- ],
204
- [
205
- "io",
206
- // British Indian Ocean Territory
207
- "246"
208
- ],
209
- [
210
- "vg",
211
- // British Virgin Islands
212
- "1",
213
- 11,
214
- ["284"]
215
- ],
216
- [
217
- "bn",
218
- // Brunei
219
- "673"
220
- ],
221
- [
222
- "bg",
223
- // Bulgaria
224
- "359"
225
- ],
226
- [
227
- "bf",
228
- // Burkina Faso
229
- "226"
230
- ],
231
- [
232
- "bi",
233
- // Burundi
234
- "257"
235
- ],
236
- [
237
- "kh",
238
- // Cambodia
239
- "855"
240
- ],
241
- [
242
- "cm",
243
- // Cameroon
244
- "237"
245
- ],
246
- [
247
- "ca",
248
- // Canada
249
- "1",
250
- 1,
251
- ["204", "226", "236", "249", "250", "263", "289", "306", "343", "354", "365", "367", "368", "382", "387", "403", "416", "418", "428", "431", "437", "438", "450", "584", "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"]
252
- ],
253
- [
254
- "cv",
255
- // Cape Verde
256
- "238"
257
- ],
258
- [
259
- "bq",
260
- // Caribbean Netherlands
261
- "599",
262
- 1,
263
- ["3", "4", "7"]
264
- ],
265
- [
266
- "ky",
267
- // Cayman Islands
268
- "1",
269
- 12,
270
- ["345"]
271
- ],
272
- [
273
- "cf",
274
- // Central African Republic
275
- "236"
276
- ],
277
- [
278
- "td",
279
- // Chad
280
- "235"
281
- ],
282
- [
283
- "cl",
284
- // Chile
285
- "56"
286
- ],
287
- [
288
- "cn",
289
- // China
290
- "86"
291
- ],
292
- [
293
- "cx",
294
- // Christmas Island
295
- "61",
296
- 2,
297
- ["89164"],
298
- "0"
299
- ],
300
- [
301
- "cc",
302
- // Cocos (Keeling) Islands
303
- "61",
304
- 1,
305
- ["89162"],
306
- "0"
307
- ],
308
- [
309
- "co",
310
- // Colombia
311
- "57"
312
- ],
313
- [
314
- "km",
315
- // Comoros
316
- "269"
317
- ],
318
- [
319
- "cg",
320
- // Congo (Brazzaville)
321
- "242"
322
- ],
323
- [
324
- "cd",
325
- // Congo (Kinshasa)
326
- "243"
327
- ],
328
- [
329
- "ck",
330
- // Cook Islands
331
- "682"
332
- ],
333
- [
334
- "cr",
335
- // Costa Rica
336
- "506"
337
- ],
338
- [
339
- "ci",
340
- // Côte d'Ivoire
341
- "225"
342
- ],
343
- [
344
- "hr",
345
- // Croatia
346
- "385"
347
- ],
348
- [
349
- "cu",
350
- // Cuba
351
- "53"
352
- ],
353
- [
354
- "cw",
355
- // Curaçao
356
- "599",
357
- 0
358
- ],
359
- [
360
- "cy",
361
- // Cyprus
362
- "357"
363
- ],
364
- [
365
- "cz",
366
- // Czech Republic
367
- "420"
368
- ],
369
- [
370
- "dk",
371
- // Denmark
372
- "45"
373
- ],
374
- [
375
- "dj",
376
- // Djibouti
377
- "253"
378
- ],
379
- [
380
- "dm",
381
- // Dominica
382
- "1",
383
- 13,
384
- ["767"]
385
- ],
386
- [
387
- "do",
388
- // Dominican Republic
389
- "1",
390
- 2,
391
- ["809", "829", "849"]
392
- ],
393
- [
394
- "ec",
395
- // Ecuador
396
- "593"
397
- ],
398
- [
399
- "eg",
400
- // Egypt
401
- "20"
402
- ],
403
- [
404
- "sv",
405
- // El Salvador
406
- "503"
407
- ],
408
- [
409
- "gq",
410
- // Equatorial Guinea
411
- "240"
412
- ],
413
- [
414
- "er",
415
- // Eritrea
416
- "291"
417
- ],
418
- [
419
- "ee",
420
- // Estonia
421
- "372"
422
- ],
423
- [
424
- "sz",
425
- // Eswatini
426
- "268"
427
- ],
428
- [
429
- "et",
430
- // Ethiopia
431
- "251"
432
- ],
433
- [
434
- "fk",
435
- // Falkland Islands (Malvinas)
436
- "500"
437
- ],
438
- [
439
- "fo",
440
- // Faroe Islands
441
- "298"
442
- ],
443
- [
444
- "fj",
445
- // Fiji
446
- "679"
447
- ],
448
- [
449
- "fi",
450
- // Finland
451
- "358",
452
- 0
453
- ],
454
- [
455
- "fr",
456
- // France
457
- "33"
458
- ],
459
- [
460
- "gf",
461
- // French Guiana
462
- "594"
463
- ],
464
- [
465
- "pf",
466
- // French Polynesia
467
- "689"
468
- ],
469
- [
470
- "ga",
471
- // Gabon
472
- "241"
473
- ],
474
- [
475
- "gm",
476
- // Gambia
477
- "220"
478
- ],
479
- [
480
- "ge",
481
- // Georgia
482
- "995"
483
- ],
484
- [
485
- "de",
486
- // Germany
487
- "49"
488
- ],
489
- [
490
- "gh",
491
- // Ghana
492
- "233"
493
- ],
494
- [
495
- "gi",
496
- // Gibraltar
497
- "350"
498
- ],
499
- [
500
- "gr",
501
- // Greece
502
- "30"
503
- ],
504
- [
505
- "gl",
506
- // Greenland
507
- "299"
508
- ],
509
- [
510
- "gd",
511
- // Grenada
512
- "1",
513
- 14,
514
- ["473"]
515
- ],
516
- [
517
- "gp",
518
- // Guadeloupe
519
- "590",
520
- 0
521
- ],
522
- [
523
- "gu",
524
- // Guam
525
- "1",
526
- 15,
527
- ["671"]
528
- ],
529
- [
530
- "gt",
531
- // Guatemala
532
- "502"
533
- ],
534
- [
535
- "gg",
536
- // Guernsey
537
- "44",
538
- 1,
539
- ["1481", "7781", "7839", "7911"],
540
- "0"
541
- ],
542
- [
543
- "gn",
544
- // Guinea
545
- "224"
546
- ],
547
- [
548
- "gw",
549
- // Guinea-Bissau
550
- "245"
551
- ],
552
- [
553
- "gy",
554
- // Guyana
555
- "592"
556
- ],
557
- [
558
- "ht",
559
- // Haiti
560
- "509"
561
- ],
562
- [
563
- "hn",
564
- // Honduras
565
- "504"
566
- ],
567
- [
568
- "hk",
569
- // Hong Kong SAR China
570
- "852"
571
- ],
572
- [
573
- "hu",
574
- // Hungary
575
- "36"
576
- ],
577
- [
578
- "is",
579
- // Iceland
580
- "354"
581
- ],
582
- [
583
- "in",
584
- // India
585
- "91"
586
- ],
587
- [
588
- "id",
589
- // Indonesia
590
- "62"
591
- ],
592
- [
593
- "ir",
594
- // Iran
595
- "98"
596
- ],
597
- [
598
- "iq",
599
- // Iraq
600
- "964"
601
- ],
602
- [
603
- "ie",
604
- // Ireland
605
- "353"
606
- ],
607
- [
608
- "im",
609
- // Isle of Man
610
- "44",
611
- 2,
612
- ["1624", "74576", "7524", "7924", "7624"],
613
- "0"
614
- ],
615
- [
616
- "il",
617
- // Israel
618
- "972"
619
- ],
620
- [
621
- "it",
622
- // Italy
623
- "39",
624
- 0
625
- ],
626
- [
627
- "jm",
628
- // Jamaica
629
- "1",
630
- 4,
631
- ["876", "658"]
632
- ],
633
- [
634
- "jp",
635
- // Japan
636
- "81"
637
- ],
638
- [
639
- "je",
640
- // Jersey
641
- "44",
642
- 3,
643
- ["1534", "7509", "7700", "7797", "7829", "7937"],
644
- "0"
645
- ],
646
- [
647
- "jo",
648
- // Jordan
649
- "962"
650
- ],
651
- [
652
- "kz",
653
- // Kazakhstan
654
- "7",
655
- 1,
656
- ["33", "7"],
657
- "8"
658
- ],
659
- [
660
- "ke",
661
- // Kenya
662
- "254"
663
- ],
664
- [
665
- "ki",
666
- // Kiribati
667
- "686"
668
- ],
669
- [
670
- "xk",
671
- // Kosovo
672
- "383"
673
- ],
674
- [
675
- "kw",
676
- // Kuwait
677
- "965"
678
- ],
679
- [
680
- "kg",
681
- // Kyrgyzstan
682
- "996"
683
- ],
684
- [
685
- "la",
686
- // Laos
687
- "856"
688
- ],
689
- [
690
- "lv",
691
- // Latvia
692
- "371"
693
- ],
694
- [
695
- "lb",
696
- // Lebanon
697
- "961"
698
- ],
699
- [
700
- "ls",
701
- // Lesotho
702
- "266"
703
- ],
704
- [
705
- "lr",
706
- // Liberia
707
- "231"
708
- ],
709
- [
710
- "ly",
711
- // Libya
712
- "218"
713
- ],
714
- [
715
- "li",
716
- // Liechtenstein
717
- "423"
718
- ],
719
- [
720
- "lt",
721
- // Lithuania
722
- "370"
723
- ],
724
- [
725
- "lu",
726
- // Luxembourg
727
- "352"
728
- ],
729
- [
730
- "mo",
731
- // Macao SAR China
732
- "853"
733
- ],
734
- [
735
- "mg",
736
- // Madagascar
737
- "261"
738
- ],
739
- [
740
- "mw",
741
- // Malawi
742
- "265"
743
- ],
744
- [
745
- "my",
746
- // Malaysia
747
- "60"
748
- ],
749
- [
750
- "mv",
751
- // Maldives
752
- "960"
753
- ],
754
- [
755
- "ml",
756
- // Mali
757
- "223"
758
- ],
759
- [
760
- "mt",
761
- // Malta
762
- "356"
763
- ],
764
- [
765
- "mh",
766
- // Marshall Islands
767
- "692"
768
- ],
769
- [
770
- "mq",
771
- // Martinique
772
- "596"
773
- ],
774
- [
775
- "mr",
776
- // Mauritania
777
- "222"
778
- ],
779
- [
780
- "mu",
781
- // Mauritius
782
- "230"
783
- ],
784
- [
785
- "yt",
786
- // Mayotte
787
- "262",
788
- 1,
789
- ["269", "639"],
790
- "0"
791
- ],
792
- [
793
- "mx",
794
- // Mexico
795
- "52"
796
- ],
797
- [
798
- "fm",
799
- // Micronesia
800
- "691"
801
- ],
802
- [
803
- "md",
804
- // Moldova
805
- "373"
806
- ],
807
- [
808
- "mc",
809
- // Monaco
810
- "377"
811
- ],
812
- [
813
- "mn",
814
- // Mongolia
815
- "976"
816
- ],
817
- [
818
- "me",
819
- // Montenegro
820
- "382"
821
- ],
822
- [
823
- "ms",
824
- // Montserrat
825
- "1",
826
- 16,
827
- ["664"]
828
- ],
829
- [
830
- "ma",
831
- // Morocco
832
- "212",
833
- 0,
834
- null,
835
- "0"
836
- ],
837
- [
838
- "mz",
839
- // Mozambique
840
- "258"
841
- ],
842
- [
843
- "mm",
844
- // Myanmar (Burma)
845
- "95"
846
- ],
847
- [
848
- "na",
849
- // Namibia
850
- "264"
851
- ],
852
- [
853
- "nr",
854
- // Nauru
855
- "674"
856
- ],
857
- [
858
- "np",
859
- // Nepal
860
- "977"
861
- ],
862
- [
863
- "nl",
864
- // Netherlands
865
- "31"
866
- ],
867
- [
868
- "nc",
869
- // New Caledonia
870
- "687"
871
- ],
872
- [
873
- "nz",
874
- // New Zealand
875
- "64"
876
- ],
877
- [
878
- "ni",
879
- // Nicaragua
880
- "505"
881
- ],
882
- [
883
- "ne",
884
- // Niger
885
- "227"
886
- ],
887
- [
888
- "ng",
889
- // Nigeria
890
- "234"
891
- ],
892
- [
893
- "nu",
894
- // Niue
895
- "683"
896
- ],
897
- [
898
- "nf",
899
- // Norfolk Island
900
- "672"
901
- ],
902
- [
903
- "kp",
904
- // North Korea
905
- "850"
906
- ],
907
- [
908
- "mk",
909
- // North Macedonia
910
- "389"
911
- ],
912
- [
913
- "mp",
914
- // Northern Mariana Islands
915
- "1",
916
- 17,
917
- ["670"]
918
- ],
919
- [
920
- "no",
921
- // Norway
922
- "47",
923
- 0
924
- ],
925
- [
926
- "om",
927
- // Oman
928
- "968"
929
- ],
930
- [
931
- "pk",
932
- // Pakistan
933
- "92"
934
- ],
935
- [
936
- "pw",
937
- // Palau
938
- "680"
939
- ],
940
- [
941
- "ps",
942
- // Palestinian Territories
943
- "970"
944
- ],
945
- [
946
- "pa",
947
- // Panama
948
- "507"
949
- ],
950
- [
951
- "pg",
952
- // Papua New Guinea
953
- "675"
954
- ],
955
- [
956
- "py",
957
- // Paraguay
958
- "595"
959
- ],
960
- [
961
- "pe",
962
- // Peru
963
- "51"
964
- ],
965
- [
966
- "ph",
967
- // Philippines
968
- "63"
969
- ],
970
- [
971
- "pl",
972
- // Poland
973
- "48"
974
- ],
975
- [
976
- "pt",
977
- // Portugal
978
- "351"
979
- ],
980
- [
981
- "pr",
982
- // Puerto Rico
983
- "1",
984
- 3,
985
- ["787", "939"]
986
- ],
987
- [
988
- "qa",
989
- // Qatar
990
- "974"
991
- ],
992
- [
993
- "re",
994
- // Réunion
995
- "262",
996
- 0,
997
- null,
998
- "0"
999
- ],
1000
- [
1001
- "ro",
1002
- // Romania
1003
- "40"
1004
- ],
1005
- [
1006
- "ru",
1007
- // Russia
1008
- "7",
1009
- 0,
1010
- null,
1011
- "8"
1012
- ],
1013
- [
1014
- "rw",
1015
- // Rwanda
1016
- "250"
1017
- ],
1018
- [
1019
- "ws",
1020
- // Samoa
1021
- "685"
1022
- ],
1023
- [
1024
- "sm",
1025
- // San Marino
1026
- "378"
1027
- ],
1028
- [
1029
- "st",
1030
- // São Tomé & Príncipe
1031
- "239"
1032
- ],
1033
- [
1034
- "sa",
1035
- // Saudi Arabia
1036
- "966"
1037
- ],
1038
- [
1039
- "sn",
1040
- // Senegal
1041
- "221"
1042
- ],
1043
- [
1044
- "rs",
1045
- // Serbia
1046
- "381"
1047
- ],
1048
- [
1049
- "sc",
1050
- // Seychelles
1051
- "248"
1052
- ],
1053
- [
1054
- "sl",
1055
- // Sierra Leone
1056
- "232"
1057
- ],
1058
- [
1059
- "sg",
1060
- // Singapore
1061
- "65"
1062
- ],
1063
- [
1064
- "sx",
1065
- // Sint Maarten
1066
- "1",
1067
- 21,
1068
- ["721"]
1069
- ],
1070
- [
1071
- "sk",
1072
- // Slovakia
1073
- "421"
1074
- ],
1075
- [
1076
- "si",
1077
- // Slovenia
1078
- "386"
1079
- ],
1080
- [
1081
- "sb",
1082
- // Solomon Islands
1083
- "677"
1084
- ],
1085
- [
1086
- "so",
1087
- // Somalia
1088
- "252"
1089
- ],
1090
- [
1091
- "za",
1092
- // South Africa
1093
- "27"
1094
- ],
1095
- [
1096
- "kr",
1097
- // South Korea
1098
- "82"
1099
- ],
1100
- [
1101
- "ss",
1102
- // South Sudan
1103
- "211"
1104
- ],
1105
- [
1106
- "es",
1107
- // Spain
1108
- "34"
1109
- ],
1110
- [
1111
- "lk",
1112
- // Sri Lanka
1113
- "94"
1114
- ],
1115
- [
1116
- "bl",
1117
- // St. Barthélemy
1118
- "590",
1119
- 1
1120
- ],
1121
- [
1122
- "sh",
1123
- // St. Helena
1124
- "290"
1125
- ],
1126
- [
1127
- "kn",
1128
- // St. Kitts & Nevis
1129
- "1",
1130
- 18,
1131
- ["869"]
1132
- ],
1133
- [
1134
- "lc",
1135
- // St. Lucia
1136
- "1",
1137
- 19,
1138
- ["758"]
1139
- ],
1140
- [
1141
- "mf",
1142
- // St. Martin
1143
- "590",
1144
- 2
1145
- ],
1146
- [
1147
- "pm",
1148
- // St. Pierre & Miquelon
1149
- "508"
1150
- ],
1151
- [
1152
- "vc",
1153
- // St. Vincent & Grenadines
1154
- "1",
1155
- 20,
1156
- ["784"]
1157
- ],
1158
- [
1159
- "sd",
1160
- // Sudan
1161
- "249"
1162
- ],
1163
- [
1164
- "sr",
1165
- // Suriname
1166
- "597"
1167
- ],
1168
- [
1169
- "sj",
1170
- // Svalbard & Jan Mayen
1171
- "47",
1172
- 1,
1173
- ["79"]
1174
- ],
1175
- [
1176
- "se",
1177
- // Sweden
1178
- "46"
1179
- ],
1180
- [
1181
- "ch",
1182
- // Switzerland
1183
- "41"
1184
- ],
1185
- [
1186
- "sy",
1187
- // Syria
1188
- "963"
1189
- ],
1190
- [
1191
- "tw",
1192
- // Taiwan
1193
- "886"
1194
- ],
1195
- [
1196
- "tj",
1197
- // Tajikistan
1198
- "992"
1199
- ],
1200
- [
1201
- "tz",
1202
- // Tanzania
1203
- "255"
1204
- ],
1205
- [
1206
- "th",
1207
- // Thailand
1208
- "66"
1209
- ],
1210
- [
1211
- "tl",
1212
- // Timor-Leste
1213
- "670"
1214
- ],
1215
- [
1216
- "tg",
1217
- // Togo
1218
- "228"
1219
- ],
1220
- [
1221
- "tk",
1222
- // Tokelau
1223
- "690"
1224
- ],
1225
- [
1226
- "to",
1227
- // Tonga
1228
- "676"
1229
- ],
1230
- [
1231
- "tt",
1232
- // Trinidad & Tobago
1233
- "1",
1234
- 22,
1235
- ["868"]
1236
- ],
1237
- [
1238
- "tn",
1239
- // Tunisia
1240
- "216"
1241
- ],
1242
- [
1243
- "tr",
1244
- // Turkey
1245
- "90"
1246
- ],
1247
- [
1248
- "tm",
1249
- // Turkmenistan
1250
- "993"
1251
- ],
1252
- [
1253
- "tc",
1254
- // Turks & Caicos Islands
1255
- "1",
1256
- 23,
1257
- ["649"]
1258
- ],
1259
- [
1260
- "tv",
1261
- // Tuvalu
1262
- "688"
1263
- ],
1264
- [
1265
- "ug",
1266
- // Uganda
1267
- "256"
1268
- ],
1269
- [
1270
- "ua",
1271
- // Ukraine
1272
- "380"
1273
- ],
1274
- [
1275
- "ae",
1276
- // United Arab Emirates
1277
- "971"
1278
- ],
1279
- [
1280
- "gb",
1281
- // United Kingdom
1282
- "44",
1283
- 0,
1284
- null,
1285
- "0"
1286
- ],
1287
- [
1288
- "us",
1289
- // United States
1290
- "1",
1291
- 0
1292
- ],
1293
- [
1294
- "uy",
1295
- // Uruguay
1296
- "598"
1297
- ],
1298
- [
1299
- "vi",
1300
- // U.S. Virgin Islands
1301
- "1",
1302
- 24,
1303
- ["340"]
1304
- ],
1305
- [
1306
- "uz",
1307
- // Uzbekistan
1308
- "998"
1309
- ],
1310
- [
1311
- "vu",
1312
- // Vanuatu
1313
- "678"
1314
- ],
1315
- [
1316
- "va",
1317
- // Vatican City
1318
- "39",
1319
- 1,
1320
- ["06698"]
1321
- ],
1322
- [
1323
- "ve",
1324
- // Venezuela
1325
- "58"
1326
- ],
1327
- [
1328
- "vn",
1329
- // Vietnam
1330
- "84"
1331
- ],
1332
- [
1333
- "wf",
1334
- // Wallis & Futuna
1335
- "681"
1336
- ],
1337
- [
1338
- "eh",
1339
- // Western Sahara
1340
- "212",
1341
- 1,
1342
- ["5288", "5289"],
1343
- "0"
1344
- ],
1345
- [
1346
- "ye",
1347
- // Yemen
1348
- "967"
1349
- ],
1350
- [
1351
- "zm",
1352
- // Zambia
1353
- "260"
1354
- ],
1355
- [
1356
- "zw",
1357
- // Zimbabwe
1358
- "263"
1359
- ]
1360
- ];
1361
- var allCountries = [];
1362
- for (let i = 0; i < rawCountryData.length; i++) {
1363
- const c = rawCountryData[i];
1364
- allCountries[i] = {
1365
- name: "",
1366
- // this is now populated in the plugin
1367
- iso2: c[0],
1368
- dialCode: c[1],
1369
- priority: c[2] || 0,
1370
- areaCodes: c[3] || null,
1371
- nodeById: {},
1372
- nationalPrefix: c[4] || null
1373
- };
1374
- }
1375
- var data_default = allCountries;
1376
-
1377
- // src/js/intl-tel-input/i18n/en/countries.ts
1378
- var countryTranslations = {
1379
- ad: "Andorra",
1380
- ae: "United Arab Emirates",
1381
- af: "Afghanistan",
1382
- ag: "Antigua & Barbuda",
1383
- ai: "Anguilla",
1384
- al: "Albania",
1385
- am: "Armenia",
1386
- ao: "Angola",
1387
- ar: "Argentina",
1388
- as: "American Samoa",
1389
- at: "Austria",
1390
- au: "Australia",
1391
- aw: "Aruba",
1392
- ax: "\xC5land Islands",
1393
- az: "Azerbaijan",
1394
- ba: "Bosnia & Herzegovina",
1395
- bb: "Barbados",
1396
- bd: "Bangladesh",
1397
- be: "Belgium",
1398
- bf: "Burkina Faso",
1399
- bg: "Bulgaria",
1400
- bh: "Bahrain",
1401
- bi: "Burundi",
1402
- bj: "Benin",
1403
- bl: "St. Barth\xE9lemy",
1404
- bm: "Bermuda",
1405
- bn: "Brunei",
1406
- bo: "Bolivia",
1407
- bq: "Caribbean Netherlands",
1408
- br: "Brazil",
1409
- bs: "Bahamas",
1410
- bt: "Bhutan",
1411
- bw: "Botswana",
1412
- by: "Belarus",
1413
- bz: "Belize",
1414
- ca: "Canada",
1415
- cc: "Cocos (Keeling) Islands",
1416
- cd: "Congo - Kinshasa",
1417
- cf: "Central African Republic",
1418
- cg: "Congo - Brazzaville",
1419
- ch: "Switzerland",
1420
- ci: "C\xF4te d\u2019Ivoire",
1421
- ck: "Cook Islands",
1422
- cl: "Chile",
1423
- cm: "Cameroon",
1424
- cn: "China",
1425
- co: "Colombia",
1426
- cr: "Costa Rica",
1427
- cu: "Cuba",
1428
- cv: "Cape Verde",
1429
- cw: "Cura\xE7ao",
1430
- cx: "Christmas Island",
1431
- cy: "Cyprus",
1432
- cz: "Czechia",
1433
- de: "Germany",
1434
- dj: "Djibouti",
1435
- dk: "Denmark",
1436
- dm: "Dominica",
1437
- do: "Dominican Republic",
1438
- dz: "Algeria",
1439
- ec: "Ecuador",
1440
- ee: "Estonia",
1441
- eg: "Egypt",
1442
- eh: "Western Sahara",
1443
- er: "Eritrea",
1444
- es: "Spain",
1445
- et: "Ethiopia",
1446
- fi: "Finland",
1447
- fj: "Fiji",
1448
- fk: "Falkland Islands",
1449
- fm: "Micronesia",
1450
- fo: "Faroe Islands",
1451
- fr: "France",
1452
- ga: "Gabon",
1453
- gb: "United Kingdom",
1454
- gd: "Grenada",
1455
- ge: "Georgia",
1456
- gf: "French Guiana",
1457
- gg: "Guernsey",
1458
- gh: "Ghana",
1459
- gi: "Gibraltar",
1460
- gl: "Greenland",
1461
- gm: "Gambia",
1462
- gn: "Guinea",
1463
- gp: "Guadeloupe",
1464
- gq: "Equatorial Guinea",
1465
- gr: "Greece",
1466
- gt: "Guatemala",
1467
- gu: "Guam",
1468
- gw: "Guinea-Bissau",
1469
- gy: "Guyana",
1470
- hk: "Hong Kong SAR China",
1471
- hn: "Honduras",
1472
- hr: "Croatia",
1473
- ht: "Haiti",
1474
- hu: "Hungary",
1475
- id: "Indonesia",
1476
- ie: "Ireland",
1477
- il: "Israel",
1478
- im: "Isle of Man",
1479
- in: "India",
1480
- io: "British Indian Ocean Territory",
1481
- iq: "Iraq",
1482
- ir: "Iran",
1483
- is: "Iceland",
1484
- it: "Italy",
1485
- je: "Jersey",
1486
- jm: "Jamaica",
1487
- jo: "Jordan",
1488
- jp: "Japan",
1489
- ke: "Kenya",
1490
- kg: "Kyrgyzstan",
1491
- kh: "Cambodia",
1492
- ki: "Kiribati",
1493
- km: "Comoros",
1494
- kn: "St. Kitts & Nevis",
1495
- kp: "North Korea",
1496
- kr: "South Korea",
1497
- kw: "Kuwait",
1498
- ky: "Cayman Islands",
1499
- kz: "Kazakhstan",
1500
- la: "Laos",
1501
- lb: "Lebanon",
1502
- lc: "St. Lucia",
1503
- li: "Liechtenstein",
1504
- lk: "Sri Lanka",
1505
- lr: "Liberia",
1506
- ls: "Lesotho",
1507
- lt: "Lithuania",
1508
- lu: "Luxembourg",
1509
- lv: "Latvia",
1510
- ly: "Libya",
1511
- ma: "Morocco",
1512
- mc: "Monaco",
1513
- md: "Moldova",
1514
- me: "Montenegro",
1515
- mf: "St. Martin",
1516
- mg: "Madagascar",
1517
- mh: "Marshall Islands",
1518
- mk: "North Macedonia",
1519
- ml: "Mali",
1520
- mm: "Myanmar (Burma)",
1521
- mn: "Mongolia",
1522
- mo: "Macao SAR China",
1523
- mp: "Northern Mariana Islands",
1524
- mq: "Martinique",
1525
- mr: "Mauritania",
1526
- ms: "Montserrat",
1527
- mt: "Malta",
1528
- mu: "Mauritius",
1529
- mv: "Maldives",
1530
- mw: "Malawi",
1531
- mx: "Mexico",
1532
- my: "Malaysia",
1533
- mz: "Mozambique",
1534
- na: "Namibia",
1535
- nc: "New Caledonia",
1536
- ne: "Niger",
1537
- nf: "Norfolk Island",
1538
- ng: "Nigeria",
1539
- ni: "Nicaragua",
1540
- nl: "Netherlands",
1541
- no: "Norway",
1542
- np: "Nepal",
1543
- nr: "Nauru",
1544
- nu: "Niue",
1545
- nz: "New Zealand",
1546
- om: "Oman",
1547
- pa: "Panama",
1548
- pe: "Peru",
1549
- pf: "French Polynesia",
1550
- pg: "Papua New Guinea",
1551
- ph: "Philippines",
1552
- pk: "Pakistan",
1553
- pl: "Poland",
1554
- pm: "St. Pierre & Miquelon",
1555
- pr: "Puerto Rico",
1556
- ps: "Palestinian Territories",
1557
- pt: "Portugal",
1558
- pw: "Palau",
1559
- py: "Paraguay",
1560
- qa: "Qatar",
1561
- re: "R\xE9union",
1562
- ro: "Romania",
1563
- rs: "Serbia",
1564
- ru: "Russia",
1565
- rw: "Rwanda",
1566
- sa: "Saudi Arabia",
1567
- sb: "Solomon Islands",
1568
- sc: "Seychelles",
1569
- sd: "Sudan",
1570
- se: "Sweden",
1571
- sg: "Singapore",
1572
- sh: "St. Helena",
1573
- si: "Slovenia",
1574
- sj: "Svalbard & Jan Mayen",
1575
- sk: "Slovakia",
1576
- sl: "Sierra Leone",
1577
- sm: "San Marino",
1578
- sn: "Senegal",
1579
- so: "Somalia",
1580
- sr: "Suriname",
1581
- ss: "South Sudan",
1582
- st: "S\xE3o Tom\xE9 & Pr\xEDncipe",
1583
- sv: "El Salvador",
1584
- sx: "Sint Maarten",
1585
- sy: "Syria",
1586
- sz: "Eswatini",
1587
- tc: "Turks & Caicos Islands",
1588
- td: "Chad",
1589
- tg: "Togo",
1590
- th: "Thailand",
1591
- tj: "Tajikistan",
1592
- tk: "Tokelau",
1593
- tl: "Timor-Leste",
1594
- tm: "Turkmenistan",
1595
- tn: "Tunisia",
1596
- to: "Tonga",
1597
- tr: "Turkey",
1598
- tt: "Trinidad & Tobago",
1599
- tv: "Tuvalu",
1600
- tw: "Taiwan",
1601
- tz: "Tanzania",
1602
- ua: "Ukraine",
1603
- ug: "Uganda",
1604
- us: "United States",
1605
- uy: "Uruguay",
1606
- uz: "Uzbekistan",
1607
- va: "Vatican City",
1608
- vc: "St. Vincent & Grenadines",
1609
- ve: "Venezuela",
1610
- vg: "British Virgin Islands",
1611
- vi: "U.S. Virgin Islands",
1612
- vn: "Vietnam",
1613
- vu: "Vanuatu",
1614
- wf: "Wallis & Futuna",
1615
- ws: "Samoa",
1616
- ye: "Yemen",
1617
- yt: "Mayotte",
1618
- za: "South Africa",
1619
- zm: "Zambia",
1620
- zw: "Zimbabwe"
1621
- };
1622
- var countries_default = countryTranslations;
1623
-
1624
- // src/js/intl-tel-input/i18n/en/interface.ts
1625
- var interfaceTranslations = {
1626
- selectedCountryAriaLabel: "Selected country",
1627
- noCountrySelected: "No country selected",
1628
- countryListAriaLabel: "List of countries",
1629
- searchPlaceholder: "Search",
1630
- zeroSearchResults: "No results found",
1631
- oneSearchResult: "1 result found",
1632
- multipleSearchResults: "${count} results found",
1633
- // additional countries (not supported by country-list library)
1634
- ac: "Ascension Island",
1635
- xk: "Kosovo"
1636
- };
1637
- var interface_default = interfaceTranslations;
1638
-
1639
- // src/js/intl-tel-input/i18n/en/index.ts
1640
- var allTranslations = { ...countries_default, ...interface_default };
1641
- var en_default = allTranslations;
1642
-
1643
- // src/js/intl-tel-input.ts
1644
- for (let i = 0; i < data_default.length; i++) {
1645
- data_default[i].name = en_default[data_default[i].iso2];
1646
- }
1647
- var id = 0;
1648
- var defaults = {
1649
- //* Whether or not to allow the dropdown.
1650
- allowDropdown: true,
1651
- //* Add a placeholder in the input with an example number for the selected country.
1652
- autoPlaceholder: "polite",
1653
- //* Modify the parentClass.
1654
- containerClass: "",
1655
- //* The order of the countries in the dropdown. Defaults to alphabetical.
1656
- countryOrder: null,
1657
- //* Add a country search input at the top of the dropdown.
1658
- countrySearch: true,
1659
- //* Modify the auto placeholder.
1660
- customPlaceholder: null,
1661
- //* Append menu to specified element.
1662
- dropdownContainer: null,
1663
- //* Don't display these countries.
1664
- excludeCountries: [],
1665
- //* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
1666
- fixDropdownWidth: true,
1667
- //* Format the number as the user types
1668
- formatAsYouType: true,
1669
- //* Format the input value during initialisation and on setNumber.
1670
- formatOnDisplay: true,
1671
- //* geoIp lookup function.
1672
- geoIpLookup: null,
1673
- //* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
1674
- hiddenInput: null,
1675
- //* Internationalise the plugin text e.g. search input placeholder, country names.
1676
- i18n: {},
1677
- //* Initial country.
1678
- initialCountry: "",
1679
- //* A function to load the utils script.
1680
- loadUtils: null,
1681
- //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
1682
- nationalMode: true,
1683
- //* Display only these countries.
1684
- onlyCountries: [],
1685
- //* Number type to use for placeholders.
1686
- placeholderNumberType: "MOBILE",
1687
- //* Show flags - for both the selected country, and in the country dropdown
1688
- showFlags: true,
1689
- //* Display the international dial code next to the selected flag.
1690
- separateDialCode: false,
1691
- //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1692
- strictMode: false,
1693
- //* Use full screen popup instead of dropdown for country list.
1694
- useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? (
1695
- //* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
1696
- //* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
1697
- /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1698
- navigator.userAgent
1699
- ) || window.innerWidth <= 500
1700
- ) : false,
1701
- //* The number type to enforce during validation.
1702
- validationNumberTypes: ["MOBILE"]
1703
- };
1704
- var regionlessNanpNumbers = [
1705
- "800",
1706
- "822",
1707
- "833",
1708
- "844",
1709
- "855",
1710
- "866",
1711
- "877",
1712
- "880",
1713
- "881",
1714
- "882",
1715
- "883",
1716
- "884",
1717
- "885",
1718
- "886",
1719
- "887",
1720
- "888",
1721
- "889"
1722
- ];
1723
- var getNumeric = (s) => s.replace(/\D/g, "");
1724
- var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
1725
- var isRegionlessNanp = (number) => {
1726
- const numeric = getNumeric(number);
1727
- if (numeric.charAt(0) === "1") {
1728
- const areaCode = numeric.substr(1, 3);
1729
- return regionlessNanpNumbers.includes(areaCode);
1730
- }
1731
- return false;
1732
- };
1733
- var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => {
1734
- if (prevCaretPos === 0 && !isDeleteForwards) {
1735
- return 0;
1736
- }
1737
- let count = 0;
1738
- for (let i = 0; i < formattedValue.length; i++) {
1739
- if (/[+0-9]/.test(formattedValue[i])) {
1740
- count++;
1741
- }
1742
- if (count === relevantChars && !isDeleteForwards) {
1743
- return i + 1;
1744
- }
1745
- if (isDeleteForwards && count === relevantChars + 1) {
1746
- return i;
1747
- }
1748
- }
1749
- return formattedValue.length;
1750
- };
1751
- var createEl = (name, attrs, container) => {
1752
- const el = document.createElement(name);
1753
- if (attrs) {
1754
- Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
1755
- }
1756
- if (container) {
1757
- container.appendChild(el);
1758
- }
1759
- return el;
1760
- };
1761
- var forEachInstance = (method, ...args) => {
1762
- const { instances } = intlTelInput;
1763
- Object.values(instances).forEach((instance) => instance[method](...args));
1764
- };
1765
- var Iti = class {
1766
- constructor(input, customOptions = {}) {
1767
- this.id = id++;
1768
- this.telInput = input;
1769
- this.highlightedItem = null;
1770
- this.options = Object.assign({}, defaults, customOptions);
1771
- this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
1772
- }
1773
- //* Can't be private as it's called from intlTelInput convenience wrapper.
1774
- _init() {
1775
- if (this.options.useFullscreenPopup) {
1776
- this.options.fixDropdownWidth = false;
1777
- }
1778
- if (this.options.onlyCountries.length === 1) {
1779
- this.options.initialCountry = this.options.onlyCountries[0];
1780
- }
1781
- if (this.options.separateDialCode) {
1782
- this.options.nationalMode = false;
1783
- }
1784
- if (this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode) {
1785
- this.options.nationalMode = false;
1786
- }
1787
- if (this.options.useFullscreenPopup && !this.options.dropdownContainer) {
1788
- this.options.dropdownContainer = document.body;
1789
- }
1790
- this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
1791
- this.isRTL = !!this.telInput.closest("[dir=rtl]");
1792
- const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode;
1793
- this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide;
1794
- if (this.options.separateDialCode) {
1795
- if (this.isRTL) {
1796
- this.originalPaddingRight = this.telInput.style.paddingRight;
1797
- } else {
1798
- this.originalPaddingLeft = this.telInput.style.paddingLeft;
1799
- }
1800
- }
1801
- this.options.i18n = { ...en_default, ...this.options.i18n };
1802
- const autoCountryPromise = new Promise((resolve, reject) => {
1803
- this.resolveAutoCountryPromise = resolve;
1804
- this.rejectAutoCountryPromise = reject;
1805
- });
1806
- const utilsScriptPromise = new Promise((resolve, reject) => {
1807
- this.resolveUtilsScriptPromise = resolve;
1808
- this.rejectUtilsScriptPromise = reject;
1809
- });
1810
- this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]);
1811
- this.selectedCountryData = {};
1812
- this._processCountryData();
1813
- this._generateMarkup();
1814
- this._setInitialState();
1815
- this._initListeners();
1816
- this._initRequests();
1817
- }
1818
- //********************
1819
- //* PRIVATE METHODS
1820
- //********************
1821
- //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
1822
- _processCountryData() {
1823
- this._processAllCountries();
1824
- this._processDialCodes();
1825
- this._translateCountryNames();
1826
- this._sortCountries();
1827
- }
1828
- //* Sort countries by countryOrder option (if present), then name.
1829
- _sortCountries() {
1830
- if (this.options.countryOrder) {
1831
- this.options.countryOrder = this.options.countryOrder.map((country) => country.toLowerCase());
1832
- }
1833
- this.countries.sort((a, b) => {
1834
- const { countryOrder } = this.options;
1835
- if (countryOrder) {
1836
- const aIndex = countryOrder.indexOf(a.iso2);
1837
- const bIndex = countryOrder.indexOf(b.iso2);
1838
- const aIndexExists = aIndex > -1;
1839
- const bIndexExists = bIndex > -1;
1840
- if (aIndexExists || bIndexExists) {
1841
- if (aIndexExists && bIndexExists) {
1842
- return aIndex - bIndex;
1843
- }
1844
- return aIndexExists ? -1 : 1;
1845
- }
1846
- }
1847
- return a.name.localeCompare(b.name);
1848
- });
1849
- }
1850
- //* Add a dial code to this.dialCodeToIso2Map.
1851
- _addToDialCodeMap(iso2, dialCode, priority) {
1852
- if (dialCode.length > this.dialCodeMaxLen) {
1853
- this.dialCodeMaxLen = dialCode.length;
1854
- }
1855
- if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
1856
- this.dialCodeToIso2Map[dialCode] = [];
1857
- }
1858
- for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
1859
- if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
1860
- return;
1861
- }
1862
- }
1863
- const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1864
- this.dialCodeToIso2Map[dialCode][index] = iso2;
1865
- }
1866
- //* Process onlyCountries or excludeCountries array if present.
1867
- _processAllCountries() {
1868
- const { onlyCountries, excludeCountries } = this.options;
1869
- if (onlyCountries.length) {
1870
- const lowerCaseOnlyCountries = onlyCountries.map(
1871
- (country) => country.toLowerCase()
1872
- );
1873
- this.countries = data_default.filter(
1874
- (country) => lowerCaseOnlyCountries.includes(country.iso2)
1875
- );
1876
- } else if (excludeCountries.length) {
1877
- const lowerCaseExcludeCountries = excludeCountries.map(
1878
- (country) => country.toLowerCase()
1879
- );
1880
- this.countries = data_default.filter(
1881
- (country) => !lowerCaseExcludeCountries.includes(country.iso2)
1882
- );
1883
- } else {
1884
- this.countries = data_default;
1885
- }
1886
- }
1887
- //* Translate Countries by object literal provided on config.
1888
- _translateCountryNames() {
1889
- for (let i = 0; i < this.countries.length; i++) {
1890
- const iso2 = this.countries[i].iso2.toLowerCase();
1891
- if (this.options.i18n.hasOwnProperty(iso2)) {
1892
- this.countries[i].name = this.options.i18n[iso2];
1893
- }
1894
- }
1895
- }
1896
- //* Generate this.dialCodes and this.dialCodeToIso2Map.
1897
- _processDialCodes() {
1898
- this.dialCodes = {};
1899
- this.dialCodeMaxLen = 0;
1900
- this.dialCodeToIso2Map = {};
1901
- for (let i = 0; i < this.countries.length; i++) {
1902
- const c = this.countries[i];
1903
- if (!this.dialCodes[c.dialCode]) {
1904
- this.dialCodes[c.dialCode] = true;
1905
- }
1906
- this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1907
- }
1908
- for (let i = 0; i < this.countries.length; i++) {
1909
- const c = this.countries[i];
1910
- if (c.areaCodes) {
1911
- const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
1912
- for (let j = 0; j < c.areaCodes.length; j++) {
1913
- const areaCode = c.areaCodes[j];
1914
- for (let k = 1; k < areaCode.length; k++) {
1915
- const partialAreaCode = areaCode.substr(0, k);
1916
- const partialDialCode = c.dialCode + partialAreaCode;
1917
- this._addToDialCodeMap(rootIso2Code, partialDialCode);
1918
- this._addToDialCodeMap(c.iso2, partialDialCode);
1919
- }
1920
- this._addToDialCodeMap(c.iso2, c.dialCode + areaCode);
1921
- }
1922
- }
1923
- }
1924
- }
1925
- //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
1926
- _generateMarkup() {
1927
- this.telInput.classList.add("iti__tel-input");
1928
- if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
1929
- this.telInput.setAttribute("autocomplete", "off");
1930
- }
1931
- const {
1932
- allowDropdown,
1933
- separateDialCode,
1934
- showFlags,
1935
- containerClass,
1936
- hiddenInput,
1937
- dropdownContainer,
1938
- fixDropdownWidth,
1939
- useFullscreenPopup,
1940
- countrySearch,
1941
- i18n
1942
- } = this.options;
1943
- let parentClass = "iti";
1944
- if (allowDropdown) {
1945
- parentClass += " iti--allow-dropdown";
1946
- }
1947
- if (showFlags) {
1948
- parentClass += " iti--show-flags";
1949
- }
1950
- if (containerClass) {
1951
- parentClass += ` ${containerClass}`;
1952
- }
1953
- if (!useFullscreenPopup) {
1954
- parentClass += " iti--inline-dropdown";
1955
- }
1956
- const wrapper = createEl("div", { class: parentClass });
1957
- this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
1958
- if (allowDropdown || showFlags || separateDialCode) {
1959
- this.countryContainer = createEl(
1960
- "div",
1961
- { class: "iti__country-container" },
1962
- wrapper
1963
- );
1964
- if (this.showSelectedCountryOnLeft) {
1965
- this.countryContainer.style.left = "0px";
1966
- } else {
1967
- this.countryContainer.style.right = "0px";
1968
- }
1969
- if (allowDropdown) {
1970
- this.selectedCountry = createEl(
1971
- "button",
1972
- {
1973
- type: "button",
1974
- class: "iti__selected-country",
1975
- "aria-expanded": "false",
1976
- "aria-label": this.options.i18n.selectedCountryAriaLabel,
1977
- "aria-haspopup": "true",
1978
- "aria-controls": `iti-${this.id}__dropdown-content`,
1979
- "role": "combobox"
1980
- },
1981
- this.countryContainer
1982
- );
1983
- if (this.telInput.disabled) {
1984
- this.selectedCountry.setAttribute("disabled", "true");
1985
- }
1986
- } else {
1987
- this.selectedCountry = createEl(
1988
- "div",
1989
- { class: "iti__selected-country" },
1990
- this.countryContainer
1991
- );
1992
- }
1993
- const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1994
- this.selectedCountryInner = createEl("div", { class: "iti__flag" }, selectedCountryPrimary);
1995
- this.selectedCountryA11yText = createEl(
1996
- "span",
1997
- { class: "iti__a11y-text" },
1998
- this.selectedCountryInner
1999
- );
2000
- if (allowDropdown) {
2001
- this.dropdownArrow = createEl(
2002
- "div",
2003
- { class: "iti__arrow", "aria-hidden": "true" },
2004
- selectedCountryPrimary
2005
- );
2006
- }
2007
- if (separateDialCode) {
2008
- this.selectedDialCode = createEl(
2009
- "div",
2010
- { class: "iti__selected-dial-code" },
2011
- this.selectedCountry
2012
- );
2013
- }
2014
- if (allowDropdown) {
2015
- const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
2016
- this.dropdownContent = createEl("div", {
2017
- id: `iti-${this.id}__dropdown-content`,
2018
- class: `iti__dropdown-content iti__hide ${extraClasses}`
2019
- });
2020
- if (countrySearch) {
2021
- this.searchInput = createEl(
2022
- "input",
2023
- {
2024
- type: "text",
2025
- class: "iti__search-input",
2026
- placeholder: i18n.searchPlaceholder,
2027
- role: "combobox",
2028
- "aria-expanded": "true",
2029
- "aria-label": i18n.searchPlaceholder,
2030
- "aria-controls": `iti-${this.id}__country-listbox`,
2031
- "aria-autocomplete": "list",
2032
- "autocomplete": "off"
2033
- },
2034
- this.dropdownContent
2035
- );
2036
- this.searchResultsA11yText = createEl(
2037
- "span",
2038
- { class: "iti__a11y-text" },
2039
- this.dropdownContent
2040
- );
2041
- }
2042
- this.countryList = createEl(
2043
- "ul",
2044
- {
2045
- class: "iti__country-list",
2046
- id: `iti-${this.id}__country-listbox`,
2047
- role: "listbox",
2048
- "aria-label": i18n.countryListAriaLabel
2049
- },
2050
- this.dropdownContent
2051
- );
2052
- this._appendListItems();
2053
- if (countrySearch) {
2054
- this._updateSearchResultsText();
2055
- }
2056
- if (dropdownContainer) {
2057
- let dropdownClasses = "iti iti--container";
2058
- if (containerClass) {
2059
- dropdownClasses += ` ${containerClass}`;
2060
- }
2061
- if (useFullscreenPopup) {
2062
- dropdownClasses += " iti--fullscreen-popup";
2063
- } else {
2064
- dropdownClasses += " iti--inline-dropdown";
2065
- }
2066
- this.dropdown = createEl("div", { class: dropdownClasses });
2067
- this.dropdown.appendChild(this.dropdownContent);
2068
- } else {
2069
- this.countryContainer.appendChild(this.dropdownContent);
2070
- }
2071
- }
2072
- }
2073
- wrapper.appendChild(this.telInput);
2074
- this._updateInputPadding();
2075
- if (hiddenInput) {
2076
- const telInputName = this.telInput.getAttribute("name") || "";
2077
- const names = hiddenInput(telInputName);
2078
- if (names.phone) {
2079
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
2080
- if (existingInput) {
2081
- this.hiddenInput = existingInput;
2082
- } else {
2083
- this.hiddenInput = createEl("input", {
2084
- type: "hidden",
2085
- name: names.phone
2086
- });
2087
- wrapper.appendChild(this.hiddenInput);
2088
- }
2089
- }
2090
- if (names.country) {
2091
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
2092
- if (existingInput) {
2093
- this.hiddenInputCountry = existingInput;
2094
- } else {
2095
- this.hiddenInputCountry = createEl("input", {
2096
- type: "hidden",
2097
- name: names.country
2098
- });
2099
- wrapper.appendChild(this.hiddenInputCountry);
2100
- }
2101
- }
2102
- }
2103
- }
2104
- //* For each country: add a country list item <li> to the countryList <ul> container.
2105
- _appendListItems() {
2106
- for (let i = 0; i < this.countries.length; i++) {
2107
- const c = this.countries[i];
2108
- const extraClass = i === 0 ? "iti__highlight" : "";
2109
- const listItem = createEl(
2110
- "li",
2111
- {
2112
- id: `iti-${this.id}__item-${c.iso2}`,
2113
- class: `iti__country ${extraClass}`,
2114
- tabindex: "-1",
2115
- role: "option",
2116
- "data-dial-code": c.dialCode,
2117
- "data-country-code": c.iso2,
2118
- "aria-selected": "false"
2119
- },
2120
- this.countryList
2121
- );
2122
- c.nodeById[this.id] = listItem;
2123
- let content = "";
2124
- if (this.options.showFlags) {
2125
- content += `<div class='iti__flag iti__${c.iso2}'></div>`;
2126
- }
2127
- content += `<span class='iti__country-name'>${c.name}</span>`;
2128
- content += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
2129
- listItem.insertAdjacentHTML("beforeend", content);
2130
- }
2131
- }
2132
- //* Set the initial state of the input value and the selected country by:
2133
- //* 1. Extracting a dial code from the given number
2134
- //* 2. Using explicit initialCountry
2135
- _setInitialState(overrideAutoCountry = false) {
2136
- const attributeValue = this.telInput.getAttribute("value");
2137
- const inputValue = this.telInput.value;
2138
- const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
2139
- const val = useAttribute ? attributeValue : inputValue;
2140
- const dialCode = this._getDialCode(val);
2141
- const isRegionlessNanpNumber = isRegionlessNanp(val);
2142
- const { initialCountry, geoIpLookup } = this.options;
2143
- const isAutoCountry = initialCountry === "auto" && geoIpLookup;
2144
- if (dialCode && !isRegionlessNanpNumber) {
2145
- this._updateCountryFromNumber(val);
2146
- } else if (!isAutoCountry || overrideAutoCountry) {
2147
- const lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : "";
2148
- const isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);
2149
- if (isValidInitialCountry) {
2150
- this._setCountry(lowerInitialCountry);
2151
- } else {
2152
- if (dialCode && isRegionlessNanpNumber) {
2153
- this._setCountry("us");
2154
- } else {
2155
- this._setCountry();
2156
- }
2157
- }
2158
- }
2159
- if (val) {
2160
- this._updateValFromNumber(val);
2161
- }
2162
- }
2163
- //* Initialise the main event listeners: input keyup, and click selected country.
2164
- _initListeners() {
2165
- this._initTelInputListeners();
2166
- if (this.options.allowDropdown) {
2167
- this._initDropdownListeners();
2168
- }
2169
- if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
2170
- this._initHiddenInputListener();
2171
- }
2172
- }
2173
- //* Update hidden input on form submit.
2174
- _initHiddenInputListener() {
2175
- this._handleHiddenInputSubmit = () => {
2176
- if (this.hiddenInput) {
2177
- this.hiddenInput.value = this.getNumber();
2178
- }
2179
- if (this.hiddenInputCountry) {
2180
- this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "";
2181
- }
2182
- };
2183
- this.telInput.form?.addEventListener(
2184
- "submit",
2185
- this._handleHiddenInputSubmit
2186
- );
2187
- }
2188
- //* initialise the dropdown listeners.
2189
- _initDropdownListeners() {
2190
- this._handleLabelClick = (e) => {
2191
- if (this.dropdownContent.classList.contains("iti__hide")) {
2192
- this.telInput.focus();
2193
- } else {
2194
- e.preventDefault();
2195
- }
2196
- };
2197
- const label = this.telInput.closest("label");
2198
- if (label) {
2199
- label.addEventListener("click", this._handleLabelClick);
2200
- }
2201
- this._handleClickSelectedCountry = () => {
2202
- if (this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly) {
2203
- this._openDropdown();
2204
- }
2205
- };
2206
- this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry);
2207
- this._handleCountryContainerKeydown = (e) => {
2208
- const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide");
2209
- if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
2210
- e.preventDefault();
2211
- e.stopPropagation();
2212
- this._openDropdown();
2213
- }
2214
- if (e.key === "Tab") {
2215
- this._closeDropdown();
2216
- }
2217
- };
2218
- this.countryContainer.addEventListener(
2219
- "keydown",
2220
- this._handleCountryContainerKeydown
2221
- );
2222
- }
2223
- //* Init many requests: utils script / geo ip lookup.
2224
- _initRequests() {
2225
- let { loadUtils, initialCountry, geoIpLookup } = this.options;
2226
- if (loadUtils && !intlTelInput.utils) {
2227
- this._handlePageLoad = () => {
2228
- window.removeEventListener("load", this._handlePageLoad);
2229
- intlTelInput.attachUtils(loadUtils)?.catch(() => {
2230
- });
2231
- };
2232
- if (intlTelInput.documentReady()) {
2233
- this._handlePageLoad();
2234
- } else {
2235
- window.addEventListener("load", this._handlePageLoad);
2236
- }
2237
- } else {
2238
- this.resolveUtilsScriptPromise();
2239
- }
2240
- const isAutoCountry = initialCountry === "auto" && geoIpLookup;
2241
- if (isAutoCountry && !this.selectedCountryData.iso2) {
2242
- this._loadAutoCountry();
2243
- } else {
2244
- this.resolveAutoCountryPromise();
2245
- }
2246
- }
2247
- //* Perform the geo ip lookup.
2248
- _loadAutoCountry() {
2249
- if (intlTelInput.autoCountry) {
2250
- this.handleAutoCountry();
2251
- } else if (!intlTelInput.startedLoadingAutoCountry) {
2252
- intlTelInput.startedLoadingAutoCountry = true;
2253
- if (typeof this.options.geoIpLookup === "function") {
2254
- this.options.geoIpLookup(
2255
- (iso2 = "") => {
2256
- const iso2Lower = iso2.toLowerCase();
2257
- const isValidIso2 = iso2Lower && this._getCountryData(iso2Lower, true);
2258
- if (isValidIso2) {
2259
- intlTelInput.autoCountry = iso2Lower;
2260
- setTimeout(() => forEachInstance("handleAutoCountry"));
2261
- } else {
2262
- this._setInitialState(true);
2263
- forEachInstance("rejectAutoCountryPromise");
2264
- }
2265
- },
2266
- () => {
2267
- this._setInitialState(true);
2268
- forEachInstance("rejectAutoCountryPromise");
2269
- }
2270
- );
2271
- }
2272
- }
2273
- }
2274
- _openDropdownWithPlus() {
2275
- this._openDropdown();
2276
- this.searchInput.value = "+";
2277
- this._filterCountries("", true);
2278
- }
2279
- //* Initialize the tel input listeners.
2280
- _initTelInputListeners() {
2281
- const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown, countrySearch } = this.options;
2282
- let userOverrideFormatting = false;
2283
- if (/\p{L}/u.test(this.telInput.value)) {
2284
- userOverrideFormatting = true;
2285
- }
2286
- this._handleInputEvent = (e) => {
2287
- if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
2288
- const currentCaretPos = this.telInput.selectionStart || 0;
2289
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
2290
- const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
2291
- this.telInput.value = valueBeforeCaret + valueAfterCaret;
2292
- this._openDropdownWithPlus();
2293
- return;
2294
- }
2295
- if (this._updateCountryFromNumber(this.telInput.value)) {
2296
- this._triggerCountryChange();
2297
- }
2298
- const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2299
- const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2300
- if (isFormattingChar || isPaste && !strictMode) {
2301
- userOverrideFormatting = true;
2302
- } else if (!/[^+0-9]/.test(this.telInput.value)) {
2303
- userOverrideFormatting = false;
2304
- }
2305
- const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
2306
- if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
2307
- const currentCaretPos = this.telInput.selectionStart || 0;
2308
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2309
- const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2310
- const isDeleteForwards = e?.inputType === "deleteContentForward";
2311
- const formattedValue = this._formatNumberAsYouType();
2312
- const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2313
- this.telInput.value = formattedValue;
2314
- this.telInput.setSelectionRange(newCaretPos, newCaretPos);
2315
- }
2316
- };
2317
- this.telInput.addEventListener("input", this._handleInputEvent);
2318
- if (strictMode || separateDialCode) {
2319
- this._handleKeydownEvent = (e) => {
2320
- if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
2321
- if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
2322
- e.preventDefault();
2323
- this._openDropdownWithPlus();
2324
- return;
2325
- }
2326
- if (strictMode) {
2327
- const value = this.telInput.value;
2328
- const alreadyHasPlus = value.charAt(0) === "+";
2329
- const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
2330
- const isNumeric = /^[0-9]$/.test(e.key);
2331
- const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
2332
- const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
2333
- const newFullNumber = this._getFullNumber(newValue);
2334
- const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
2335
- const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
2336
- const newCountry = this._getNewCountryFromNumber(newFullNumber);
2337
- const isChangingDialCode = newCountry !== null;
2338
- if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
2339
- e.preventDefault();
2340
- }
2341
- }
2342
- }
2343
- };
2344
- this.telInput.addEventListener("keydown", this._handleKeydownEvent);
2345
- }
2346
- }
2347
- //* Adhere to the input's maxlength attr.
2348
- _cap(number) {
2349
- const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2350
- return max && number.length > max ? number.substr(0, max) : number;
2351
- }
2352
- //* Trigger a custom event on the input.
2353
- _trigger(name, detailProps = {}) {
2354
- const e = new CustomEvent(name, {
2355
- bubbles: true,
2356
- cancelable: true,
2357
- detail: detailProps
2358
- });
2359
- this.telInput.dispatchEvent(e);
2360
- }
2361
- //* Open the dropdown.
2362
- _openDropdown() {
2363
- const { fixDropdownWidth, countrySearch } = this.options;
2364
- if (fixDropdownWidth) {
2365
- this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
2366
- }
2367
- this.dropdownContent.classList.remove("iti__hide");
2368
- this.selectedCountry.setAttribute("aria-expanded", "true");
2369
- this._setDropdownPosition();
2370
- if (countrySearch) {
2371
- const firstCountryItem = this.countryList.firstElementChild;
2372
- if (firstCountryItem) {
2373
- this._highlightListItem(firstCountryItem, false);
2374
- this.countryList.scrollTop = 0;
2375
- }
2376
- this.searchInput.focus();
2377
- }
2378
- this._bindDropdownListeners();
2379
- this.dropdownArrow.classList.add("iti__arrow--up");
2380
- this._trigger("open:countrydropdown");
2381
- }
2382
- //* Set the dropdown position
2383
- _setDropdownPosition() {
2384
- if (this.options.dropdownContainer) {
2385
- this.options.dropdownContainer.appendChild(this.dropdown);
2386
- }
2387
- if (!this.options.useFullscreenPopup) {
2388
- const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
2389
- const inputHeight = this.telInput.offsetHeight;
2390
- if (this.options.dropdownContainer) {
2391
- this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
2392
- this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
2393
- this._handleWindowScroll = () => this._closeDropdown();
2394
- window.addEventListener("scroll", this._handleWindowScroll);
2395
- }
2396
- }
2397
- }
2398
- //* We only bind dropdown listeners when the dropdown is open.
2399
- _bindDropdownListeners() {
2400
- this._handleMouseoverCountryList = (e) => {
2401
- const listItem = e.target?.closest(".iti__country");
2402
- if (listItem) {
2403
- this._highlightListItem(listItem, false);
2404
- }
2405
- };
2406
- this.countryList.addEventListener(
2407
- "mouseover",
2408
- this._handleMouseoverCountryList
2409
- );
2410
- this._handleClickCountryList = (e) => {
2411
- const listItem = e.target?.closest(".iti__country");
2412
- if (listItem) {
2413
- this._selectListItem(listItem);
2414
- }
2415
- };
2416
- this.countryList.addEventListener("click", this._handleClickCountryList);
2417
- let isOpening = true;
2418
- this._handleClickOffToClose = () => {
2419
- if (!isOpening) {
2420
- this._closeDropdown();
2421
- }
2422
- isOpening = false;
2423
- };
2424
- document.documentElement.addEventListener(
2425
- "click",
2426
- this._handleClickOffToClose
2427
- );
2428
- let query = "";
2429
- let queryTimer = null;
2430
- this._handleKeydownOnDropdown = (e) => {
2431
- if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
2432
- e.preventDefault();
2433
- e.stopPropagation();
2434
- if (e.key === "ArrowUp" || e.key === "ArrowDown") {
2435
- this._handleUpDownKey(e.key);
2436
- } else if (e.key === "Enter") {
2437
- this._handleEnterKey();
2438
- } else if (e.key === "Escape") {
2439
- this._closeDropdown();
2440
- }
2441
- }
2442
- if (!this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
2443
- e.stopPropagation();
2444
- if (queryTimer) {
2445
- clearTimeout(queryTimer);
2446
- }
2447
- query += e.key.toLowerCase();
2448
- this._searchForCountry(query);
2449
- queryTimer = setTimeout(() => {
2450
- query = "";
2451
- }, 1e3);
2452
- }
2453
- };
2454
- document.addEventListener("keydown", this._handleKeydownOnDropdown);
2455
- if (this.options.countrySearch) {
2456
- const doFilter = () => {
2457
- const inputQuery = this.searchInput.value.trim();
2458
- if (inputQuery) {
2459
- this._filterCountries(inputQuery);
2460
- } else {
2461
- this._filterCountries("", true);
2462
- }
2463
- };
2464
- let keyupTimer = null;
2465
- this._handleSearchChange = () => {
2466
- if (keyupTimer) {
2467
- clearTimeout(keyupTimer);
2468
- }
2469
- keyupTimer = setTimeout(() => {
2470
- doFilter();
2471
- keyupTimer = null;
2472
- }, 100);
2473
- };
2474
- this.searchInput.addEventListener("input", this._handleSearchChange);
2475
- this.searchInput.addEventListener("click", (e) => e.stopPropagation());
2476
- }
2477
- }
2478
- //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2479
- _searchForCountry(query) {
2480
- for (let i = 0; i < this.countries.length; i++) {
2481
- const c = this.countries[i];
2482
- const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
2483
- if (startsWith) {
2484
- const listItem = c.nodeById[this.id];
2485
- this._highlightListItem(listItem, false);
2486
- this._scrollTo(listItem);
2487
- break;
2488
- }
2489
- }
2490
- }
2491
- //* Country search enabled: Filter the countries according to the search query.
2492
- _filterCountries(query, isReset = false) {
2493
- let noCountriesAddedYet = true;
2494
- this.countryList.innerHTML = "";
2495
- const normalisedQuery = normaliseString(query);
2496
- for (let i = 0; i < this.countries.length; i++) {
2497
- const c = this.countries[i];
2498
- const normalisedCountryName = normaliseString(c.name);
2499
- const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2500
- const fullDialCode = `+${c.dialCode}`;
2501
- if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2502
- const listItem = c.nodeById[this.id];
2503
- if (listItem) {
2504
- this.countryList.appendChild(listItem);
2505
- }
2506
- if (noCountriesAddedYet) {
2507
- this._highlightListItem(listItem, false);
2508
- noCountriesAddedYet = false;
2509
- }
2510
- }
2511
- }
2512
- if (noCountriesAddedYet) {
2513
- this._highlightListItem(null, false);
2514
- }
2515
- this.countryList.scrollTop = 0;
2516
- this._updateSearchResultsText();
2517
- }
2518
- //* Update search results text (for a11y).
2519
- _updateSearchResultsText() {
2520
- const { i18n } = this.options;
2521
- const count = this.countryList.childElementCount;
2522
- let searchText;
2523
- if ("searchResultsText" in i18n) {
2524
- searchText = i18n.searchResultsText(count);
2525
- } else {
2526
- if (count === 0) {
2527
- searchText = i18n.zeroSearchResults;
2528
- } else if (count === 1) {
2529
- searchText = i18n.oneSearchResult;
2530
- } else {
2531
- searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
2532
- }
2533
- }
2534
- this.searchResultsA11yText.textContent = searchText;
2535
- }
2536
- //* Highlight the next/prev item in the list (and ensure it is visible).
2537
- _handleUpDownKey(key) {
2538
- let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
2539
- if (!next && this.countryList.childElementCount > 1) {
2540
- next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
2541
- }
2542
- if (next) {
2543
- this._scrollTo(next);
2544
- this._highlightListItem(next, false);
2545
- }
2546
- }
2547
- //* Select the currently highlighted item.
2548
- _handleEnterKey() {
2549
- if (this.highlightedItem) {
2550
- this._selectListItem(this.highlightedItem);
2551
- }
2552
- }
2553
- //* Update the input's value to the given val (format first if possible)
2554
- //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2555
- _updateValFromNumber(fullNumber) {
2556
- let number = fullNumber;
2557
- if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
2558
- const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode;
2559
- const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
2560
- const format = useNational ? NATIONAL : INTERNATIONAL;
2561
- number = intlTelInput.utils.formatNumber(
2562
- number,
2563
- this.selectedCountryData.iso2,
2564
- format
2565
- );
2566
- }
2567
- number = this._beforeSetNumber(number);
2568
- this.telInput.value = number;
2569
- }
2570
- //* Check if need to select a new country based on the given number
2571
- //* Note: called from _setInitialState, keyup handler, setNumber.
2572
- _updateCountryFromNumber(fullNumber) {
2573
- const iso2 = this._getNewCountryFromNumber(fullNumber);
2574
- if (iso2 !== null) {
2575
- return this._setCountry(iso2);
2576
- }
2577
- return false;
2578
- }
2579
- _ensureHasDialCode(number) {
2580
- const { dialCode, nationalPrefix } = this.selectedCountryData;
2581
- const alreadyHasPlus = number.charAt(0) === "+";
2582
- if (alreadyHasPlus || !dialCode) {
2583
- return number;
2584
- }
2585
- const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
2586
- const cleanNumber = hasPrefix ? number.substring(1) : number;
2587
- return `+${dialCode}${cleanNumber}`;
2588
- }
2589
- // Get the country ISO2 code from the given number
2590
- // BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
2591
- // NOTE: consider refactoring this to be more clear
2592
- _getNewCountryFromNumber(fullNumber) {
2593
- const plusIndex = fullNumber.indexOf("+");
2594
- let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
2595
- const selectedIso2 = this.selectedCountryData.iso2;
2596
- const selectedDialCode = this.selectedCountryData.dialCode;
2597
- number = this._ensureHasDialCode(number);
2598
- const dialCodeMatch = this._getDialCode(number, true);
2599
- const numeric = getNumeric(number);
2600
- if (dialCodeMatch) {
2601
- const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2602
- const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2603
- if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2604
- return this.defaultCountry;
2605
- }
2606
- const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
2607
- const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2608
- const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2609
- if (!isRegionlessNanpNumber && !alreadySelected) {
2610
- for (let j = 0; j < iso2Codes.length; j++) {
2611
- if (iso2Codes[j]) {
2612
- return iso2Codes[j];
2613
- }
2614
- }
2615
- }
2616
- } else if (number.charAt(0) === "+" && numeric.length) {
2617
- return "";
2618
- } else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
2619
- return this.defaultCountry;
2620
- }
2621
- return null;
2622
- }
2623
- //* Remove highlighting from other list items and highlight the given item.
2624
- _highlightListItem(listItem, shouldFocus) {
2625
- const prevItem = this.highlightedItem;
2626
- if (prevItem) {
2627
- prevItem.classList.remove("iti__highlight");
2628
- prevItem.setAttribute("aria-selected", "false");
2629
- }
2630
- this.highlightedItem = listItem;
2631
- if (this.highlightedItem) {
2632
- this.highlightedItem.classList.add("iti__highlight");
2633
- this.highlightedItem.setAttribute("aria-selected", "true");
2634
- const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2635
- this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
2636
- if (this.options.countrySearch) {
2637
- this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
2638
- }
2639
- }
2640
- if (shouldFocus) {
2641
- this.highlightedItem.focus();
2642
- }
2643
- }
2644
- //* Find the country data for the given iso2 code
2645
- //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2646
- _getCountryData(iso2, allowFail) {
2647
- for (let i = 0; i < this.countries.length; i++) {
2648
- if (this.countries[i].iso2 === iso2) {
2649
- return this.countries[i];
2650
- }
2651
- }
2652
- if (allowFail) {
2653
- return null;
2654
- }
2655
- throw new Error(`No country data for '${iso2}'`);
2656
- }
2657
- //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
2658
- //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2659
- _setCountry(iso2) {
2660
- const { separateDialCode, showFlags, i18n } = this.options;
2661
- const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2662
- this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2663
- if (this.selectedCountryData.iso2) {
2664
- this.defaultCountry = this.selectedCountryData.iso2;
2665
- }
2666
- if (this.selectedCountryInner) {
2667
- let flagClass = "";
2668
- let a11yText = "";
2669
- if (iso2 && showFlags) {
2670
- flagClass = `iti__flag iti__${iso2}`;
2671
- a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`;
2672
- } else {
2673
- flagClass = "iti__flag iti__globe";
2674
- a11yText = i18n.noCountrySelected;
2675
- }
2676
- this.selectedCountryInner.className = flagClass;
2677
- this.selectedCountryA11yText.textContent = a11yText;
2678
- }
2679
- this._setSelectedCountryTitleAttribute(iso2, separateDialCode);
2680
- if (separateDialCode) {
2681
- const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2682
- this.selectedDialCode.innerHTML = dialCode;
2683
- this._updateInputPadding();
2684
- }
2685
- this._updatePlaceholder();
2686
- this._updateMaxLength();
2687
- return prevCountry.iso2 !== iso2;
2688
- }
2689
- //* Update the input padding to make space for the selected country/dial code.
2690
- _updateInputPadding() {
2691
- if (this.selectedCountry) {
2692
- const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
2693
- const inputPadding = selectedCountryWidth + 6;
2694
- if (this.showSelectedCountryOnLeft) {
2695
- this.telInput.style.paddingLeft = `${inputPadding}px`;
2696
- } else {
2697
- this.telInput.style.paddingRight = `${inputPadding}px`;
2698
- }
2699
- }
2700
- }
2701
- //* Update the maximum valid number length for the currently selected country.
2702
- _updateMaxLength() {
2703
- const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
2704
- const { iso2 } = this.selectedCountryData;
2705
- if (strictMode && intlTelInput.utils) {
2706
- if (iso2) {
2707
- const numberType = intlTelInput.utils.numberType[placeholderNumberType];
2708
- let exampleNumber = intlTelInput.utils.getExampleNumber(
2709
- iso2,
2710
- false,
2711
- numberType,
2712
- true
2713
- );
2714
- let validNumber = exampleNumber;
2715
- while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
2716
- validNumber = exampleNumber;
2717
- exampleNumber += "0";
2718
- }
2719
- const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
2720
- this.maxCoreNumberLength = coreNumber.length;
2721
- if (iso2 === "by") {
2722
- this.maxCoreNumberLength = coreNumber.length + 1;
2723
- }
2724
- } else {
2725
- this.maxCoreNumberLength = null;
2726
- }
2727
- }
2728
- }
2729
- _setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) {
2730
- if (!this.selectedCountry) {
2731
- return;
2732
- }
2733
- let title;
2734
- if (iso2 && !separateDialCode) {
2735
- title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`;
2736
- } else if (iso2) {
2737
- title = this.selectedCountryData.name;
2738
- } else {
2739
- title = "Unknown";
2740
- }
2741
- this.selectedCountry.setAttribute("title", title);
2742
- }
2743
- //* When the input is in a hidden container during initialisation, we must inject some markup
2744
- //* into the end of the DOM to calculate the correct offsetWidth.
2745
- //* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry
2746
- //* will definitely exist.
2747
- _getHiddenSelectedCountryWidth() {
2748
- if (this.telInput.parentNode) {
2749
- const containerClone = this.telInput.parentNode.cloneNode(false);
2750
- containerClone.style.visibility = "hidden";
2751
- document.body.appendChild(containerClone);
2752
- const countryContainerClone = this.countryContainer.cloneNode();
2753
- containerClone.appendChild(countryContainerClone);
2754
- const selectedCountryClone = this.selectedCountry.cloneNode(true);
2755
- countryContainerClone.appendChild(selectedCountryClone);
2756
- const width = selectedCountryClone.offsetWidth;
2757
- document.body.removeChild(containerClone);
2758
- return width;
2759
- }
2760
- return 0;
2761
- }
2762
- //* Update the input placeholder to an example number from the currently selected country.
2763
- _updatePlaceholder() {
2764
- const {
2765
- autoPlaceholder,
2766
- placeholderNumberType,
2767
- nationalMode,
2768
- customPlaceholder
2769
- } = this.options;
2770
- const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
2771
- if (intlTelInput.utils && shouldSetPlaceholder) {
2772
- const numberType = intlTelInput.utils.numberType[placeholderNumberType];
2773
- let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
2774
- this.selectedCountryData.iso2,
2775
- nationalMode,
2776
- numberType
2777
- ) : "";
2778
- placeholder = this._beforeSetNumber(placeholder);
2779
- if (typeof customPlaceholder === "function") {
2780
- placeholder = customPlaceholder(placeholder, this.selectedCountryData);
2781
- }
2782
- this.telInput.setAttribute("placeholder", placeholder);
2783
- }
2784
- }
2785
- //* Called when the user selects a list item from the dropdown.
2786
- _selectListItem(listItem) {
2787
- const countryChanged = this._setCountry(
2788
- listItem.getAttribute("data-country-code")
2789
- );
2790
- this._closeDropdown();
2791
- this._updateDialCode(listItem.getAttribute("data-dial-code"));
2792
- this.telInput.focus();
2793
- if (countryChanged) {
2794
- this._triggerCountryChange();
2795
- }
2796
- }
2797
- //* Close the dropdown and unbind any listeners.
2798
- _closeDropdown() {
2799
- this.dropdownContent.classList.add("iti__hide");
2800
- this.selectedCountry.setAttribute("aria-expanded", "false");
2801
- this.selectedCountry.removeAttribute("aria-activedescendant");
2802
- if (this.highlightedItem) {
2803
- this.highlightedItem.setAttribute("aria-selected", "false");
2804
- }
2805
- if (this.options.countrySearch) {
2806
- this.searchInput.removeAttribute("aria-activedescendant");
2807
- }
2808
- this.dropdownArrow.classList.remove("iti__arrow--up");
2809
- document.removeEventListener("keydown", this._handleKeydownOnDropdown);
2810
- if (this.options.countrySearch) {
2811
- this.searchInput.removeEventListener("input", this._handleSearchChange);
2812
- }
2813
- document.documentElement.removeEventListener(
2814
- "click",
2815
- this._handleClickOffToClose
2816
- );
2817
- this.countryList.removeEventListener(
2818
- "mouseover",
2819
- this._handleMouseoverCountryList
2820
- );
2821
- this.countryList.removeEventListener("click", this._handleClickCountryList);
2822
- if (this.options.dropdownContainer) {
2823
- if (!this.options.useFullscreenPopup) {
2824
- window.removeEventListener("scroll", this._handleWindowScroll);
2825
- }
2826
- if (this.dropdown.parentNode) {
2827
- this.dropdown.parentNode.removeChild(this.dropdown);
2828
- }
2829
- }
2830
- if (this._handlePageLoad) {
2831
- window.removeEventListener("load", this._handlePageLoad);
2832
- }
2833
- this._trigger("close:countrydropdown");
2834
- }
2835
- //* Check if an element is visible within it's container, else scroll until it is.
2836
- _scrollTo(element) {
2837
- const container = this.countryList;
2838
- const scrollTop = document.documentElement.scrollTop;
2839
- const containerHeight = container.offsetHeight;
2840
- const containerTop = container.getBoundingClientRect().top + scrollTop;
2841
- const containerBottom = containerTop + containerHeight;
2842
- const elementHeight = element.offsetHeight;
2843
- const elementTop = element.getBoundingClientRect().top + scrollTop;
2844
- const elementBottom = elementTop + elementHeight;
2845
- const newScrollTop = elementTop - containerTop + container.scrollTop;
2846
- if (elementTop < containerTop) {
2847
- container.scrollTop = newScrollTop;
2848
- } else if (elementBottom > containerBottom) {
2849
- const heightDifference = containerHeight - elementHeight;
2850
- container.scrollTop = newScrollTop - heightDifference;
2851
- }
2852
- }
2853
- //* Replace any existing dial code with the new one
2854
- //* Note: called from _selectListItem and setCountry
2855
- _updateDialCode(newDialCodeBare) {
2856
- const inputVal = this.telInput.value;
2857
- const newDialCode = `+${newDialCodeBare}`;
2858
- let newNumber;
2859
- if (inputVal.charAt(0) === "+") {
2860
- const prevDialCode = this._getDialCode(inputVal);
2861
- if (prevDialCode) {
2862
- newNumber = inputVal.replace(prevDialCode, newDialCode);
2863
- } else {
2864
- newNumber = newDialCode;
2865
- }
2866
- this.telInput.value = newNumber;
2867
- }
2868
- }
2869
- //* Try and extract a valid international dial code from a full telephone number.
2870
- //* Note: returns the raw string inc plus character and any whitespace/dots etc.
2871
- _getDialCode(number, includeAreaCode) {
2872
- let dialCode = "";
2873
- if (number.charAt(0) === "+") {
2874
- let numericChars = "";
2875
- for (let i = 0; i < number.length; i++) {
2876
- const c = number.charAt(i);
2877
- if (!isNaN(parseInt(c, 10))) {
2878
- numericChars += c;
2879
- if (includeAreaCode) {
2880
- if (this.dialCodeToIso2Map[numericChars]) {
2881
- dialCode = number.substr(0, i + 1);
2882
- }
2883
- } else {
2884
- if (this.dialCodes[numericChars]) {
2885
- dialCode = number.substr(0, i + 1);
2886
- break;
2887
- }
2888
- }
2889
- if (numericChars.length === this.dialCodeMaxLen) {
2890
- break;
2891
- }
2892
- }
2893
- }
2894
- }
2895
- return dialCode;
2896
- }
2897
- //* Get the input val, adding the dial code if separateDialCode is enabled.
2898
- _getFullNumber(overrideVal) {
2899
- const val = overrideVal || this.telInput.value.trim();
2900
- const { dialCode } = this.selectedCountryData;
2901
- let prefix;
2902
- const numericVal = getNumeric(val);
2903
- if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
2904
- prefix = `+${dialCode}`;
2905
- } else {
2906
- prefix = "";
2907
- }
2908
- return prefix + val;
2909
- }
2910
- //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
2911
- _beforeSetNumber(fullNumber) {
2912
- let number = fullNumber;
2913
- if (this.options.separateDialCode) {
2914
- let dialCode = this._getDialCode(number);
2915
- if (dialCode) {
2916
- dialCode = `+${this.selectedCountryData.dialCode}`;
2917
- const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2918
- number = number.substr(start);
2919
- }
2920
- }
2921
- return this._cap(number);
2922
- }
2923
- //* Trigger the 'countrychange' event.
2924
- _triggerCountryChange() {
2925
- this._trigger("countrychange");
2926
- }
2927
- //* Format the number as the user types.
2928
- _formatNumberAsYouType() {
2929
- const val = this._getFullNumber();
2930
- const result = intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;
2931
- const { dialCode } = this.selectedCountryData;
2932
- if (this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2933
- const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2934
- return afterDialCode.trim();
2935
- }
2936
- return result;
2937
- }
2938
- //**************************
2939
- //* SECRET PUBLIC METHODS
2940
- //**************************
2941
- //* This is called when the geoip call returns.
2942
- handleAutoCountry() {
2943
- if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
2944
- this.defaultCountry = intlTelInput.autoCountry;
2945
- const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
2946
- if (!hasSelectedCountryOrGlobe) {
2947
- this.setCountry(this.defaultCountry);
2948
- }
2949
- this.resolveAutoCountryPromise();
2950
- }
2951
- }
2952
- //* This is called when the utils request completes.
2953
- handleUtils() {
2954
- if (intlTelInput.utils) {
2955
- if (this.telInput.value) {
2956
- this._updateValFromNumber(this.telInput.value);
2957
- }
2958
- if (this.selectedCountryData.iso2) {
2959
- this._updatePlaceholder();
2960
- this._updateMaxLength();
2961
- }
2962
- }
2963
- this.resolveUtilsScriptPromise();
2964
- }
2965
- //********************
2966
- //* PUBLIC METHODS
2967
- //********************
2968
- //* Remove plugin.
2969
- destroy() {
2970
- this.telInput.iti = void 0;
2971
- const { allowDropdown, separateDialCode } = this.options;
2972
- if (allowDropdown) {
2973
- this._closeDropdown();
2974
- this.selectedCountry.removeEventListener(
2975
- "click",
2976
- this._handleClickSelectedCountry
2977
- );
2978
- this.countryContainer.removeEventListener(
2979
- "keydown",
2980
- this._handleCountryContainerKeydown
2981
- );
2982
- const label = this.telInput.closest("label");
2983
- if (label) {
2984
- label.removeEventListener("click", this._handleLabelClick);
2985
- }
2986
- }
2987
- const { form } = this.telInput;
2988
- if (this._handleHiddenInputSubmit && form) {
2989
- form.removeEventListener("submit", this._handleHiddenInputSubmit);
2990
- }
2991
- this.telInput.removeEventListener("input", this._handleInputEvent);
2992
- if (this._handleKeydownEvent) {
2993
- this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
2994
- }
2995
- this.telInput.removeAttribute("data-intl-tel-input-id");
2996
- if (separateDialCode) {
2997
- if (this.isRTL) {
2998
- this.telInput.style.paddingRight = this.originalPaddingRight;
2999
- } else {
3000
- this.telInput.style.paddingLeft = this.originalPaddingLeft;
3001
- }
3002
- }
3003
- const wrapper = this.telInput.parentNode;
3004
- wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
3005
- wrapper?.parentNode?.removeChild(wrapper);
3006
- delete intlTelInput.instances[this.id];
3007
- }
3008
- //* Get the extension from the current number.
3009
- getExtension() {
3010
- if (intlTelInput.utils) {
3011
- return intlTelInput.utils.getExtension(
3012
- this._getFullNumber(),
3013
- this.selectedCountryData.iso2
3014
- );
3015
- }
3016
- return "";
3017
- }
3018
- //* Format the number to the given format.
3019
- getNumber(format) {
3020
- if (intlTelInput.utils) {
3021
- const { iso2 } = this.selectedCountryData;
3022
- return intlTelInput.utils.formatNumber(
3023
- this._getFullNumber(),
3024
- iso2,
3025
- format
3026
- );
3027
- }
3028
- return "";
3029
- }
3030
- //* Get the type of the entered number e.g. landline/mobile.
3031
- getNumberType() {
3032
- if (intlTelInput.utils) {
3033
- return intlTelInput.utils.getNumberType(
3034
- this._getFullNumber(),
3035
- this.selectedCountryData.iso2
3036
- );
3037
- }
3038
- return -99;
3039
- }
3040
- //* Get the country data for the currently selected country.
3041
- getSelectedCountryData() {
3042
- return this.selectedCountryData;
3043
- }
3044
- //* Get the validation error.
3045
- getValidationError() {
3046
- if (intlTelInput.utils) {
3047
- const { iso2 } = this.selectedCountryData;
3048
- return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2);
3049
- }
3050
- return -99;
3051
- }
3052
- //* Validate the input val
3053
- isValidNumber() {
3054
- if (!this.selectedCountryData.iso2) {
3055
- return false;
3056
- }
3057
- const val = this._getFullNumber();
3058
- const alphaCharPosition = val.search(/\p{L}/u);
3059
- if (alphaCharPosition > -1) {
3060
- const beforeAlphaChar = val.substring(0, alphaCharPosition);
3061
- const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
3062
- const isValid = this._utilsIsPossibleNumber(val);
3063
- return beforeAlphaIsValid && isValid;
3064
- }
3065
- return this._utilsIsPossibleNumber(val);
3066
- }
3067
- _utilsIsPossibleNumber(val) {
3068
- return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3069
- }
3070
- //* Validate the input val (precise)
3071
- isValidNumberPrecise() {
3072
- if (!this.selectedCountryData.iso2) {
3073
- return false;
3074
- }
3075
- const val = this._getFullNumber();
3076
- const alphaCharPosition = val.search(/\p{L}/u);
3077
- if (alphaCharPosition > -1) {
3078
- const beforeAlphaChar = val.substring(0, alphaCharPosition);
3079
- const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
3080
- const isValid = this._utilsIsValidNumber(val);
3081
- return beforeAlphaIsValid && isValid;
3082
- }
3083
- return this._utilsIsValidNumber(val);
3084
- }
3085
- _utilsIsValidNumber(val) {
3086
- return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3087
- }
3088
- //* Update the selected country, and update the input val accordingly.
3089
- setCountry(iso2) {
3090
- const iso2Lower = iso2?.toLowerCase();
3091
- const currentCountry = this.selectedCountryData.iso2;
3092
- const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
3093
- if (isCountryChange) {
3094
- this._setCountry(iso2Lower);
3095
- this._updateDialCode(this.selectedCountryData.dialCode);
3096
- this._triggerCountryChange();
3097
- }
3098
- }
3099
- //* Set the input value and update the country.
3100
- setNumber(number) {
3101
- const countryChanged = this._updateCountryFromNumber(number);
3102
- this._updateValFromNumber(number);
3103
- if (countryChanged) {
3104
- this._triggerCountryChange();
3105
- }
3106
- this._trigger("input", { isSetNumber: true });
3107
- }
3108
- //* Set the placeholder number typ
3109
- setPlaceholderNumberType(type) {
3110
- this.options.placeholderNumberType = type;
3111
- this._updatePlaceholder();
3112
- }
3113
- setDisabled(disabled) {
3114
- this.telInput.disabled = disabled;
3115
- if (disabled) {
3116
- this.selectedCountry.setAttribute("disabled", "true");
3117
- } else {
3118
- this.selectedCountry.removeAttribute("disabled");
3119
- }
3120
- }
3121
- };
3122
- var attachUtils = (source) => {
3123
- if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
3124
- let loadCall;
3125
- if (typeof source === "function") {
3126
- try {
3127
- loadCall = Promise.resolve(source());
3128
- } catch (error) {
3129
- return Promise.reject(error);
3130
- }
3131
- } else {
3132
- return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`));
3133
- }
3134
- intlTelInput.startedLoadingUtilsScript = true;
3135
- return loadCall.then((module2) => {
3136
- const utils = module2?.default;
3137
- if (!utils || typeof utils !== "object") {
3138
- throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
3139
- }
3140
- intlTelInput.utils = utils;
3141
- forEachInstance("handleUtils");
3142
- return true;
3143
- }).catch((error) => {
3144
- forEachInstance("rejectUtilsScriptPromise", error);
3145
- throw error;
3146
- });
3147
- }
3148
- return null;
3149
- };
3150
- var intlTelInput = Object.assign(
3151
- (input, options) => {
3152
- const iti = new Iti(input, options);
3153
- iti._init();
3154
- input.setAttribute("data-intl-tel-input-id", iti.id.toString());
3155
- intlTelInput.instances[iti.id] = iti;
3156
- input.iti = iti;
3157
- return iti;
3158
- },
3159
- {
3160
- defaults,
3161
- //* Using a static var like this allows us to mock it in the tests.
3162
- documentReady: () => document.readyState === "complete",
3163
- //* Get the country data object.
3164
- getCountryData: () => data_default,
3165
- //* A getter for the plugin instance.
3166
- getInstance: (input) => {
3167
- const id2 = input.getAttribute("data-intl-tel-input-id");
3168
- return id2 ? intlTelInput.instances[id2] : null;
3169
- },
3170
- //* A map from instance ID to instance object.
3171
- instances: {},
3172
- attachUtils,
3173
- startedLoadingUtilsScript: false,
3174
- startedLoadingAutoCountry: false,
3175
- version: "25.4.7"
3176
- }
3177
- );
3178
- var intl_tel_input_default = intlTelInput;
3179
-
3180
- // angular/src/intl-tel-input/angular.ts
3181
- var import_core = require("@angular/core");
3182
- var import_forms = require("@angular/forms");
3183
- var PHONE_ERROR_MESSAGES = [
3184
- "invalid",
3185
- "invalid-country-code",
3186
- "too-short",
3187
- "too-long",
3188
- "invalid-format"
3189
- ];
3190
- var IntlTelInputComponent = class {
3191
- constructor() {
3192
- this.initialValue = "";
3193
- this.usePreciseValidation = false;
3194
- this.inputProps = {};
3195
- this.disabled = void 0;
3196
- this.initOptions = {};
3197
- this.numberChange = new import_core.EventEmitter();
3198
- this.countryChange = new import_core.EventEmitter();
3199
- this.validityChange = new import_core.EventEmitter();
3200
- this.errorCodeChange = new import_core.EventEmitter();
3201
- this.iti = null;
3202
- this.countryChangeHandler = () => this.handleInput();
3203
- // eslint-disable-next-line class-methods-use-this
3204
- this.onChange = () => {
3205
- };
3206
- // eslint-disable-next-line class-methods-use-this
3207
- this.onTouched = () => {
3208
- };
3209
- // eslint-disable-next-line class-methods-use-this
3210
- this.onValidatorChange = () => {
3211
- };
3212
- }
3213
- ngOnInit() {
3214
- if (this.inputRef.nativeElement) {
3215
- this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.initOptions);
3216
- }
3217
- this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
3218
- this.applyInputProps();
3219
- for (const key in this.inputProps) {
3220
- if (this.inputProps.hasOwnProperty(key)) {
3221
- this.inputRef.nativeElement.setAttribute(key, this.inputProps[key]);
3222
- }
3223
- }
3224
- }
3225
- ngAfterViewInit() {
3226
- if (this.initialValue) {
3227
- this.iti?.setNumber(this.initialValue);
3228
- }
3229
- }
3230
- handleInput() {
3231
- if (!this.iti) return;
3232
- const num = this.iti.getNumber() || "";
3233
- const countryIso = this.iti.getSelectedCountryData().iso2 || "";
3234
- this.numberChange.emit(num);
3235
- this.countryChange.emit(countryIso);
3236
- const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
3237
- if (isValid) {
3238
- this.validityChange.emit(true);
3239
- this.errorCodeChange.emit(null);
3240
- } else {
3241
- this.validityChange.emit(false);
3242
- this.errorCodeChange.emit(this.iti.getValidationError());
3243
- }
3244
- this.onChange(num);
3245
- this.onValidatorChange();
3246
- }
3247
- handleBlur() {
3248
- this.onTouched();
3249
- }
3250
- getInstance() {
3251
- return this.iti;
3252
- }
3253
- getInput() {
3254
- return this.inputRef.nativeElement;
3255
- }
3256
- ngOnDestroy() {
3257
- this.iti?.destroy();
3258
- this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
3259
- }
3260
- applyInputProps() {
3261
- const props = this.inputProps;
3262
- Object.entries(props).forEach(([key, value]) => {
3263
- this.inputRef.nativeElement.setAttribute(key, value);
3264
- });
3265
- }
3266
- // ============ ControlValueAccessor Implementation ============
3267
- writeValue(value) {
3268
- if (this.iti && value) {
3269
- this.iti.setNumber(value);
3270
- }
3271
- }
3272
- registerOnChange(fn) {
3273
- this.onChange = fn;
3274
- }
3275
- registerOnTouched(fn) {
3276
- this.onTouched = fn;
3277
- }
3278
- setDisabledState(isDisabled) {
3279
- this.disabled = isDisabled;
3280
- }
3281
- // ============ Validator Implementation ============
3282
- validate(control) {
3283
- if (!control.value || !this.iti) {
3284
- return null;
3285
- }
3286
- const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
3287
- if (isValid) {
3288
- return null;
3289
- }
3290
- const errorCode = this.iti.getValidationError();
3291
- return {
3292
- invalidPhone: {
3293
- errorCode,
3294
- errorMessage: PHONE_ERROR_MESSAGES[errorCode]
3295
- }
3296
- };
3297
- }
3298
- registerOnValidatorChange(fn) {
3299
- this.onValidatorChange = fn;
3300
- }
3301
- };
3302
- __decorateClass([
3303
- (0, import_core.ViewChild)("inputRef", { static: true })
3304
- ], IntlTelInputComponent.prototype, "inputRef", 2);
3305
- __decorateClass([
3306
- (0, import_core.Input)()
3307
- ], IntlTelInputComponent.prototype, "initialValue", 2);
3308
- __decorateClass([
3309
- (0, import_core.Input)()
3310
- ], IntlTelInputComponent.prototype, "usePreciseValidation", 2);
3311
- __decorateClass([
3312
- (0, import_core.Input)()
3313
- ], IntlTelInputComponent.prototype, "inputProps", 2);
3314
- __decorateClass([
3315
- (0, import_core.Input)()
3316
- ], IntlTelInputComponent.prototype, "disabled", 2);
3317
- __decorateClass([
3318
- (0, import_core.Input)()
3319
- ], IntlTelInputComponent.prototype, "initOptions", 2);
3320
- __decorateClass([
3321
- (0, import_core.Output)()
3322
- ], IntlTelInputComponent.prototype, "numberChange", 2);
3323
- __decorateClass([
3324
- (0, import_core.Output)()
3325
- ], IntlTelInputComponent.prototype, "countryChange", 2);
3326
- __decorateClass([
3327
- (0, import_core.Output)()
3328
- ], IntlTelInputComponent.prototype, "validityChange", 2);
3329
- __decorateClass([
3330
- (0, import_core.Output)()
3331
- ], IntlTelInputComponent.prototype, "errorCodeChange", 2);
3332
- IntlTelInputComponent = __decorateClass([
3333
- (0, import_core.Component)({
3334
- selector: "intl-tel-input",
3335
- standalone: true,
3336
- template: `
3337
- <input
3338
- type="tel"
3339
- #inputRef
3340
- (input)="handleInput()"
3341
- (blur)="handleBlur()"
3342
- [disabled]="disabled"
3343
- />
3344
- `,
3345
- providers: [
3346
- {
3347
- provide: import_forms.NG_VALUE_ACCESSOR,
3348
- useExisting: (0, import_core.forwardRef)(() => IntlTelInputComponent),
3349
- multi: true
3350
- },
3351
- {
3352
- provide: import_forms.NG_VALIDATORS,
3353
- useExisting: (0, import_core.forwardRef)(() => IntlTelInputComponent),
3354
- multi: true
3355
- }
3356
- ]
3357
- })
3358
- ], IntlTelInputComponent);