intl-tel-input 25.4.1 → 25.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/angular/README.md +86 -0
- package/angular/build/IntlTelInput.cjs +3356 -0
- package/angular/build/IntlTelInput.d.ts +1301 -0
- package/angular/build/IntlTelInput.js +3337 -0
- package/angular/build/IntlTelInputWithUtils.cjs +9730 -0
- package/angular/build/IntlTelInputWithUtils.js +9711 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.js +2 -2
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +2 -2
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +8 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +1 -1
- package/react/build/IntlTelInput.d.ts +4 -2
- package/react/build/IntlTelInput.js +1 -1
- package/react/build/IntlTelInputWithUtils.cjs +1 -1
- package/react/build/IntlTelInputWithUtils.js +1 -1
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +1 -1
- package/vue/build/IntlTelInputWithUtils.mjs +1 -1
|
@@ -0,0 +1,3356 @@
|
|
|
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
|
+
PHONE_ERROR_MESSAGES: () => PHONE_ERROR_MESSAGES,
|
|
31
|
+
default: () => angular_default,
|
|
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 (useFullscreenPopup) {
|
|
2059
|
+
dropdownClasses += " iti--fullscreen-popup";
|
|
2060
|
+
} else {
|
|
2061
|
+
dropdownClasses += " iti--inline-dropdown";
|
|
2062
|
+
}
|
|
2063
|
+
this.dropdown = createEl("div", { class: dropdownClasses });
|
|
2064
|
+
this.dropdown.appendChild(this.dropdownContent);
|
|
2065
|
+
} else {
|
|
2066
|
+
this.countryContainer.appendChild(this.dropdownContent);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
wrapper.appendChild(this.telInput);
|
|
2071
|
+
this._updateInputPadding();
|
|
2072
|
+
if (hiddenInput) {
|
|
2073
|
+
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2074
|
+
const names = hiddenInput(telInputName);
|
|
2075
|
+
if (names.phone) {
|
|
2076
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
|
|
2077
|
+
if (existingInput) {
|
|
2078
|
+
this.hiddenInput = existingInput;
|
|
2079
|
+
} else {
|
|
2080
|
+
this.hiddenInput = createEl("input", {
|
|
2081
|
+
type: "hidden",
|
|
2082
|
+
name: names.phone
|
|
2083
|
+
});
|
|
2084
|
+
wrapper.appendChild(this.hiddenInput);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
if (names.country) {
|
|
2088
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
|
|
2089
|
+
if (existingInput) {
|
|
2090
|
+
this.hiddenInputCountry = existingInput;
|
|
2091
|
+
} else {
|
|
2092
|
+
this.hiddenInputCountry = createEl("input", {
|
|
2093
|
+
type: "hidden",
|
|
2094
|
+
name: names.country
|
|
2095
|
+
});
|
|
2096
|
+
wrapper.appendChild(this.hiddenInputCountry);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
2102
|
+
_appendListItems() {
|
|
2103
|
+
for (let i = 0; i < this.countries.length; i++) {
|
|
2104
|
+
const c = this.countries[i];
|
|
2105
|
+
const extraClass = i === 0 ? "iti__highlight" : "";
|
|
2106
|
+
const listItem = createEl(
|
|
2107
|
+
"li",
|
|
2108
|
+
{
|
|
2109
|
+
id: `iti-${this.id}__item-${c.iso2}`,
|
|
2110
|
+
class: `iti__country ${extraClass}`,
|
|
2111
|
+
tabindex: "-1",
|
|
2112
|
+
role: "option",
|
|
2113
|
+
"data-dial-code": c.dialCode,
|
|
2114
|
+
"data-country-code": c.iso2,
|
|
2115
|
+
"aria-selected": "false"
|
|
2116
|
+
},
|
|
2117
|
+
this.countryList
|
|
2118
|
+
);
|
|
2119
|
+
c.nodeById[this.id] = listItem;
|
|
2120
|
+
let content = "";
|
|
2121
|
+
if (this.options.showFlags) {
|
|
2122
|
+
content += `<div class='iti__flag iti__${c.iso2}'></div>`;
|
|
2123
|
+
}
|
|
2124
|
+
content += `<span class='iti__country-name'>${c.name}</span>`;
|
|
2125
|
+
content += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
|
|
2126
|
+
listItem.insertAdjacentHTML("beforeend", content);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
//* Set the initial state of the input value and the selected country by:
|
|
2130
|
+
//* 1. Extracting a dial code from the given number
|
|
2131
|
+
//* 2. Using explicit initialCountry
|
|
2132
|
+
_setInitialState(overrideAutoCountry = false) {
|
|
2133
|
+
const attributeValue = this.telInput.getAttribute("value");
|
|
2134
|
+
const inputValue = this.telInput.value;
|
|
2135
|
+
const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
|
|
2136
|
+
const val = useAttribute ? attributeValue : inputValue;
|
|
2137
|
+
const dialCode = this._getDialCode(val);
|
|
2138
|
+
const isRegionlessNanpNumber = isRegionlessNanp(val);
|
|
2139
|
+
const { initialCountry, geoIpLookup } = this.options;
|
|
2140
|
+
const isAutoCountry = initialCountry === "auto" && geoIpLookup;
|
|
2141
|
+
if (dialCode && !isRegionlessNanpNumber) {
|
|
2142
|
+
this._updateCountryFromNumber(val);
|
|
2143
|
+
} else if (!isAutoCountry || overrideAutoCountry) {
|
|
2144
|
+
const lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : "";
|
|
2145
|
+
const isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);
|
|
2146
|
+
if (isValidInitialCountry) {
|
|
2147
|
+
this._setCountry(lowerInitialCountry);
|
|
2148
|
+
} else {
|
|
2149
|
+
if (dialCode && isRegionlessNanpNumber) {
|
|
2150
|
+
this._setCountry("us");
|
|
2151
|
+
} else {
|
|
2152
|
+
this._setCountry();
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
if (val) {
|
|
2157
|
+
this._updateValFromNumber(val);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
//* Initialise the main event listeners: input keyup, and click selected country.
|
|
2161
|
+
_initListeners() {
|
|
2162
|
+
this._initTelInputListeners();
|
|
2163
|
+
if (this.options.allowDropdown) {
|
|
2164
|
+
this._initDropdownListeners();
|
|
2165
|
+
}
|
|
2166
|
+
if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
|
|
2167
|
+
this._initHiddenInputListener();
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
//* Update hidden input on form submit.
|
|
2171
|
+
_initHiddenInputListener() {
|
|
2172
|
+
this._handleHiddenInputSubmit = () => {
|
|
2173
|
+
if (this.hiddenInput) {
|
|
2174
|
+
this.hiddenInput.value = this.getNumber();
|
|
2175
|
+
}
|
|
2176
|
+
if (this.hiddenInputCountry) {
|
|
2177
|
+
this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "";
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
this.telInput.form?.addEventListener(
|
|
2181
|
+
"submit",
|
|
2182
|
+
this._handleHiddenInputSubmit
|
|
2183
|
+
);
|
|
2184
|
+
}
|
|
2185
|
+
//* initialise the dropdown listeners.
|
|
2186
|
+
_initDropdownListeners() {
|
|
2187
|
+
this._handleLabelClick = (e) => {
|
|
2188
|
+
if (this.dropdownContent.classList.contains("iti__hide")) {
|
|
2189
|
+
this.telInput.focus();
|
|
2190
|
+
} else {
|
|
2191
|
+
e.preventDefault();
|
|
2192
|
+
}
|
|
2193
|
+
};
|
|
2194
|
+
const label = this.telInput.closest("label");
|
|
2195
|
+
if (label) {
|
|
2196
|
+
label.addEventListener("click", this._handleLabelClick);
|
|
2197
|
+
}
|
|
2198
|
+
this._handleClickSelectedCountry = () => {
|
|
2199
|
+
if (this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly) {
|
|
2200
|
+
this._openDropdown();
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry);
|
|
2204
|
+
this._handleCountryContainerKeydown = (e) => {
|
|
2205
|
+
const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide");
|
|
2206
|
+
if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
|
|
2207
|
+
e.preventDefault();
|
|
2208
|
+
e.stopPropagation();
|
|
2209
|
+
this._openDropdown();
|
|
2210
|
+
}
|
|
2211
|
+
if (e.key === "Tab") {
|
|
2212
|
+
this._closeDropdown();
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
this.countryContainer.addEventListener(
|
|
2216
|
+
"keydown",
|
|
2217
|
+
this._handleCountryContainerKeydown
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
//* Init many requests: utils script / geo ip lookup.
|
|
2221
|
+
_initRequests() {
|
|
2222
|
+
let { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2223
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
2224
|
+
this._handlePageLoad = () => {
|
|
2225
|
+
window.removeEventListener("load", this._handlePageLoad);
|
|
2226
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2227
|
+
});
|
|
2228
|
+
};
|
|
2229
|
+
if (intlTelInput.documentReady()) {
|
|
2230
|
+
this._handlePageLoad();
|
|
2231
|
+
} else {
|
|
2232
|
+
window.addEventListener("load", this._handlePageLoad);
|
|
2233
|
+
}
|
|
2234
|
+
} else {
|
|
2235
|
+
this.resolveUtilsScriptPromise();
|
|
2236
|
+
}
|
|
2237
|
+
const isAutoCountry = initialCountry === "auto" && geoIpLookup;
|
|
2238
|
+
if (isAutoCountry && !this.selectedCountryData.iso2) {
|
|
2239
|
+
this._loadAutoCountry();
|
|
2240
|
+
} else {
|
|
2241
|
+
this.resolveAutoCountryPromise();
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
//* Perform the geo ip lookup.
|
|
2245
|
+
_loadAutoCountry() {
|
|
2246
|
+
if (intlTelInput.autoCountry) {
|
|
2247
|
+
this.handleAutoCountry();
|
|
2248
|
+
} else if (!intlTelInput.startedLoadingAutoCountry) {
|
|
2249
|
+
intlTelInput.startedLoadingAutoCountry = true;
|
|
2250
|
+
if (typeof this.options.geoIpLookup === "function") {
|
|
2251
|
+
this.options.geoIpLookup(
|
|
2252
|
+
(iso2 = "") => {
|
|
2253
|
+
const iso2Lower = iso2.toLowerCase();
|
|
2254
|
+
const isValidIso2 = iso2Lower && this._getCountryData(iso2Lower, true);
|
|
2255
|
+
if (isValidIso2) {
|
|
2256
|
+
intlTelInput.autoCountry = iso2Lower;
|
|
2257
|
+
setTimeout(() => forEachInstance("handleAutoCountry"));
|
|
2258
|
+
} else {
|
|
2259
|
+
this._setInitialState(true);
|
|
2260
|
+
forEachInstance("rejectAutoCountryPromise");
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
() => {
|
|
2264
|
+
this._setInitialState(true);
|
|
2265
|
+
forEachInstance("rejectAutoCountryPromise");
|
|
2266
|
+
}
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
_openDropdownWithPlus() {
|
|
2272
|
+
this._openDropdown();
|
|
2273
|
+
this.searchInput.value = "+";
|
|
2274
|
+
this._filterCountries("", true);
|
|
2275
|
+
}
|
|
2276
|
+
//* Initialize the tel input listeners.
|
|
2277
|
+
_initTelInputListeners() {
|
|
2278
|
+
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown, countrySearch } = this.options;
|
|
2279
|
+
let userOverrideFormatting = false;
|
|
2280
|
+
if (/\p{L}/u.test(this.telInput.value)) {
|
|
2281
|
+
userOverrideFormatting = true;
|
|
2282
|
+
}
|
|
2283
|
+
this._handleInputEvent = (e) => {
|
|
2284
|
+
if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
|
|
2285
|
+
const currentCaretPos = this.telInput.selectionStart || 0;
|
|
2286
|
+
const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
|
|
2287
|
+
const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
|
|
2288
|
+
this.telInput.value = valueBeforeCaret + valueAfterCaret;
|
|
2289
|
+
this._openDropdownWithPlus();
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
if (this._updateCountryFromNumber(this.telInput.value)) {
|
|
2293
|
+
this._triggerCountryChange();
|
|
2294
|
+
}
|
|
2295
|
+
const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
|
|
2296
|
+
const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
|
|
2297
|
+
if (isFormattingChar || isPaste && !strictMode) {
|
|
2298
|
+
userOverrideFormatting = true;
|
|
2299
|
+
} else if (!/[^+0-9]/.test(this.telInput.value)) {
|
|
2300
|
+
userOverrideFormatting = false;
|
|
2301
|
+
}
|
|
2302
|
+
const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
|
|
2303
|
+
if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
|
|
2304
|
+
const currentCaretPos = this.telInput.selectionStart || 0;
|
|
2305
|
+
const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
|
|
2306
|
+
const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
|
|
2307
|
+
const isDeleteForwards = e?.inputType === "deleteContentForward";
|
|
2308
|
+
const formattedValue = this._formatNumberAsYouType();
|
|
2309
|
+
const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
|
|
2310
|
+
this.telInput.value = formattedValue;
|
|
2311
|
+
this.telInput.setSelectionRange(newCaretPos, newCaretPos);
|
|
2312
|
+
}
|
|
2313
|
+
};
|
|
2314
|
+
this.telInput.addEventListener("input", this._handleInputEvent);
|
|
2315
|
+
if (strictMode || separateDialCode) {
|
|
2316
|
+
this._handleKeydownEvent = (e) => {
|
|
2317
|
+
if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
2318
|
+
if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
|
|
2319
|
+
e.preventDefault();
|
|
2320
|
+
this._openDropdownWithPlus();
|
|
2321
|
+
return;
|
|
2322
|
+
}
|
|
2323
|
+
if (strictMode) {
|
|
2324
|
+
const value = this.telInput.value;
|
|
2325
|
+
const alreadyHasPlus = value.charAt(0) === "+";
|
|
2326
|
+
const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
|
|
2327
|
+
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2328
|
+
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2329
|
+
const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
|
|
2330
|
+
const newFullNumber = this._getFullNumber(newValue);
|
|
2331
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2332
|
+
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2333
|
+
let isChangingDialCode = false;
|
|
2334
|
+
if (alreadyHasPlus) {
|
|
2335
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2336
|
+
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2337
|
+
isChangingDialCode = newCountry !== currentCountry;
|
|
2338
|
+
}
|
|
2339
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2340
|
+
e.preventDefault();
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
};
|
|
2345
|
+
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
//* Adhere to the input's maxlength attr.
|
|
2349
|
+
_cap(number) {
|
|
2350
|
+
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
2351
|
+
return max && number.length > max ? number.substr(0, max) : number;
|
|
2352
|
+
}
|
|
2353
|
+
//* Trigger a custom event on the input.
|
|
2354
|
+
_trigger(name, detailProps = {}) {
|
|
2355
|
+
const e = new CustomEvent(name, {
|
|
2356
|
+
bubbles: true,
|
|
2357
|
+
cancelable: true,
|
|
2358
|
+
detail: detailProps
|
|
2359
|
+
});
|
|
2360
|
+
this.telInput.dispatchEvent(e);
|
|
2361
|
+
}
|
|
2362
|
+
//* Open the dropdown.
|
|
2363
|
+
_openDropdown() {
|
|
2364
|
+
const { fixDropdownWidth, countrySearch } = this.options;
|
|
2365
|
+
if (fixDropdownWidth) {
|
|
2366
|
+
this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
|
|
2367
|
+
}
|
|
2368
|
+
this.dropdownContent.classList.remove("iti__hide");
|
|
2369
|
+
this.selectedCountry.setAttribute("aria-expanded", "true");
|
|
2370
|
+
this._setDropdownPosition();
|
|
2371
|
+
if (countrySearch) {
|
|
2372
|
+
const firstCountryItem = this.countryList.firstElementChild;
|
|
2373
|
+
if (firstCountryItem) {
|
|
2374
|
+
this._highlightListItem(firstCountryItem, false);
|
|
2375
|
+
this.countryList.scrollTop = 0;
|
|
2376
|
+
}
|
|
2377
|
+
this.searchInput.focus();
|
|
2378
|
+
}
|
|
2379
|
+
this._bindDropdownListeners();
|
|
2380
|
+
this.dropdownArrow.classList.add("iti__arrow--up");
|
|
2381
|
+
this._trigger("open:countrydropdown");
|
|
2382
|
+
}
|
|
2383
|
+
//* Set the dropdown position
|
|
2384
|
+
_setDropdownPosition() {
|
|
2385
|
+
if (this.options.dropdownContainer) {
|
|
2386
|
+
this.options.dropdownContainer.appendChild(this.dropdown);
|
|
2387
|
+
}
|
|
2388
|
+
if (!this.options.useFullscreenPopup) {
|
|
2389
|
+
const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
|
|
2390
|
+
const inputHeight = this.telInput.offsetHeight;
|
|
2391
|
+
if (this.options.dropdownContainer) {
|
|
2392
|
+
this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
|
|
2393
|
+
this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
|
|
2394
|
+
this._handleWindowScroll = () => this._closeDropdown();
|
|
2395
|
+
window.addEventListener("scroll", this._handleWindowScroll);
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
//* We only bind dropdown listeners when the dropdown is open.
|
|
2400
|
+
_bindDropdownListeners() {
|
|
2401
|
+
this._handleMouseoverCountryList = (e) => {
|
|
2402
|
+
const listItem = e.target?.closest(".iti__country");
|
|
2403
|
+
if (listItem) {
|
|
2404
|
+
this._highlightListItem(listItem, false);
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
this.countryList.addEventListener(
|
|
2408
|
+
"mouseover",
|
|
2409
|
+
this._handleMouseoverCountryList
|
|
2410
|
+
);
|
|
2411
|
+
this._handleClickCountryList = (e) => {
|
|
2412
|
+
const listItem = e.target?.closest(".iti__country");
|
|
2413
|
+
if (listItem) {
|
|
2414
|
+
this._selectListItem(listItem);
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
this.countryList.addEventListener("click", this._handleClickCountryList);
|
|
2418
|
+
let isOpening = true;
|
|
2419
|
+
this._handleClickOffToClose = () => {
|
|
2420
|
+
if (!isOpening) {
|
|
2421
|
+
this._closeDropdown();
|
|
2422
|
+
}
|
|
2423
|
+
isOpening = false;
|
|
2424
|
+
};
|
|
2425
|
+
document.documentElement.addEventListener(
|
|
2426
|
+
"click",
|
|
2427
|
+
this._handleClickOffToClose
|
|
2428
|
+
);
|
|
2429
|
+
let query = "";
|
|
2430
|
+
let queryTimer = null;
|
|
2431
|
+
this._handleKeydownOnDropdown = (e) => {
|
|
2432
|
+
if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
|
|
2433
|
+
e.preventDefault();
|
|
2434
|
+
e.stopPropagation();
|
|
2435
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
2436
|
+
this._handleUpDownKey(e.key);
|
|
2437
|
+
} else if (e.key === "Enter") {
|
|
2438
|
+
this._handleEnterKey();
|
|
2439
|
+
} else if (e.key === "Escape") {
|
|
2440
|
+
this._closeDropdown();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
if (!this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
|
|
2444
|
+
e.stopPropagation();
|
|
2445
|
+
if (queryTimer) {
|
|
2446
|
+
clearTimeout(queryTimer);
|
|
2447
|
+
}
|
|
2448
|
+
query += e.key.toLowerCase();
|
|
2449
|
+
this._searchForCountry(query);
|
|
2450
|
+
queryTimer = setTimeout(() => {
|
|
2451
|
+
query = "";
|
|
2452
|
+
}, 1e3);
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
document.addEventListener("keydown", this._handleKeydownOnDropdown);
|
|
2456
|
+
if (this.options.countrySearch) {
|
|
2457
|
+
const doFilter = () => {
|
|
2458
|
+
const inputQuery = this.searchInput.value.trim();
|
|
2459
|
+
if (inputQuery) {
|
|
2460
|
+
this._filterCountries(inputQuery);
|
|
2461
|
+
} else {
|
|
2462
|
+
this._filterCountries("", true);
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
let keyupTimer = null;
|
|
2466
|
+
this._handleSearchChange = () => {
|
|
2467
|
+
if (keyupTimer) {
|
|
2468
|
+
clearTimeout(keyupTimer);
|
|
2469
|
+
}
|
|
2470
|
+
keyupTimer = setTimeout(() => {
|
|
2471
|
+
doFilter();
|
|
2472
|
+
keyupTimer = null;
|
|
2473
|
+
}, 100);
|
|
2474
|
+
};
|
|
2475
|
+
this.searchInput.addEventListener("input", this._handleSearchChange);
|
|
2476
|
+
this.searchInput.addEventListener("click", (e) => e.stopPropagation());
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2480
|
+
_searchForCountry(query) {
|
|
2481
|
+
for (let i = 0; i < this.countries.length; i++) {
|
|
2482
|
+
const c = this.countries[i];
|
|
2483
|
+
const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
|
|
2484
|
+
if (startsWith) {
|
|
2485
|
+
const listItem = c.nodeById[this.id];
|
|
2486
|
+
this._highlightListItem(listItem, false);
|
|
2487
|
+
this._scrollTo(listItem);
|
|
2488
|
+
break;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
//* Country search enabled: Filter the countries according to the search query.
|
|
2493
|
+
_filterCountries(query, isReset = false) {
|
|
2494
|
+
let noCountriesAddedYet = true;
|
|
2495
|
+
this.countryList.innerHTML = "";
|
|
2496
|
+
const normalisedQuery = normaliseString(query);
|
|
2497
|
+
for (let i = 0; i < this.countries.length; i++) {
|
|
2498
|
+
const c = this.countries[i];
|
|
2499
|
+
const normalisedCountryName = normaliseString(c.name);
|
|
2500
|
+
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
|
|
2501
|
+
const fullDialCode = `+${c.dialCode}`;
|
|
2502
|
+
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
|
|
2503
|
+
const listItem = c.nodeById[this.id];
|
|
2504
|
+
if (listItem) {
|
|
2505
|
+
this.countryList.appendChild(listItem);
|
|
2506
|
+
}
|
|
2507
|
+
if (noCountriesAddedYet) {
|
|
2508
|
+
this._highlightListItem(listItem, false);
|
|
2509
|
+
noCountriesAddedYet = false;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
if (noCountriesAddedYet) {
|
|
2514
|
+
this._highlightListItem(null, false);
|
|
2515
|
+
}
|
|
2516
|
+
this.countryList.scrollTop = 0;
|
|
2517
|
+
this._updateSearchResultsText();
|
|
2518
|
+
}
|
|
2519
|
+
//* Update search results text (for a11y).
|
|
2520
|
+
_updateSearchResultsText() {
|
|
2521
|
+
const { i18n } = this.options;
|
|
2522
|
+
const count = this.countryList.childElementCount;
|
|
2523
|
+
let searchText;
|
|
2524
|
+
if ("searchResultsText" in i18n) {
|
|
2525
|
+
searchText = i18n.searchResultsText(count);
|
|
2526
|
+
} else {
|
|
2527
|
+
if (count === 0) {
|
|
2528
|
+
searchText = i18n.zeroSearchResults;
|
|
2529
|
+
} else if (count === 1) {
|
|
2530
|
+
searchText = i18n.oneSearchResult;
|
|
2531
|
+
} else {
|
|
2532
|
+
searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
this.searchResultsA11yText.textContent = searchText;
|
|
2536
|
+
}
|
|
2537
|
+
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2538
|
+
_handleUpDownKey(key) {
|
|
2539
|
+
let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
|
|
2540
|
+
if (!next && this.countryList.childElementCount > 1) {
|
|
2541
|
+
next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
|
|
2542
|
+
}
|
|
2543
|
+
if (next) {
|
|
2544
|
+
this._scrollTo(next);
|
|
2545
|
+
this._highlightListItem(next, false);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
//* Select the currently highlighted item.
|
|
2549
|
+
_handleEnterKey() {
|
|
2550
|
+
if (this.highlightedItem) {
|
|
2551
|
+
this._selectListItem(this.highlightedItem);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
//* Update the input's value to the given val (format first if possible)
|
|
2555
|
+
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2556
|
+
_updateValFromNumber(fullNumber) {
|
|
2557
|
+
let number = fullNumber;
|
|
2558
|
+
if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
|
|
2559
|
+
const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode;
|
|
2560
|
+
const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
|
|
2561
|
+
const format = useNational ? NATIONAL : INTERNATIONAL;
|
|
2562
|
+
number = intlTelInput.utils.formatNumber(
|
|
2563
|
+
number,
|
|
2564
|
+
this.selectedCountryData.iso2,
|
|
2565
|
+
format
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
number = this._beforeSetNumber(number);
|
|
2569
|
+
this.telInput.value = number;
|
|
2570
|
+
}
|
|
2571
|
+
//* Check if need to select a new country based on the given number
|
|
2572
|
+
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2573
|
+
_updateCountryFromNumber(fullNumber) {
|
|
2574
|
+
const iso2 = this._getCountryFromNumber(fullNumber);
|
|
2575
|
+
if (iso2 !== null) {
|
|
2576
|
+
return this._setCountry(iso2);
|
|
2577
|
+
}
|
|
2578
|
+
return false;
|
|
2579
|
+
}
|
|
2580
|
+
_ensureHasDialCode(number) {
|
|
2581
|
+
const { dialCode, nationalPrefix } = this.selectedCountryData;
|
|
2582
|
+
const alreadyHasPlus = number.charAt(0) === "+";
|
|
2583
|
+
if (alreadyHasPlus || !dialCode) {
|
|
2584
|
+
return number;
|
|
2585
|
+
}
|
|
2586
|
+
const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
|
|
2587
|
+
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
2588
|
+
return `+${dialCode}${cleanNumber}`;
|
|
2589
|
+
}
|
|
2590
|
+
_getCountryFromNumber(fullNumber) {
|
|
2591
|
+
const plusIndex = fullNumber.indexOf("+");
|
|
2592
|
+
let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
|
|
2593
|
+
const selectedIso2 = this.selectedCountryData.iso2;
|
|
2594
|
+
const selectedDialCode = this.selectedCountryData.dialCode;
|
|
2595
|
+
number = this._ensureHasDialCode(number);
|
|
2596
|
+
const dialCodeMatch = this._getDialCode(number, true);
|
|
2597
|
+
const numeric = getNumeric(number);
|
|
2598
|
+
if (dialCodeMatch) {
|
|
2599
|
+
const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
|
|
2600
|
+
const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
|
|
2601
|
+
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2602
|
+
return this.defaultCountry;
|
|
2603
|
+
}
|
|
2604
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes);
|
|
2605
|
+
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2606
|
+
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2607
|
+
for (let j = 0; j < iso2Codes.length; j++) {
|
|
2608
|
+
if (iso2Codes[j]) {
|
|
2609
|
+
return iso2Codes[j];
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
} else if (number.charAt(0) === "+" && numeric.length) {
|
|
2614
|
+
return "";
|
|
2615
|
+
} else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
|
|
2616
|
+
return this.defaultCountry;
|
|
2617
|
+
}
|
|
2618
|
+
return null;
|
|
2619
|
+
}
|
|
2620
|
+
//* Remove highlighting from other list items and highlight the given item.
|
|
2621
|
+
_highlightListItem(listItem, shouldFocus) {
|
|
2622
|
+
const prevItem = this.highlightedItem;
|
|
2623
|
+
if (prevItem) {
|
|
2624
|
+
prevItem.classList.remove("iti__highlight");
|
|
2625
|
+
prevItem.setAttribute("aria-selected", "false");
|
|
2626
|
+
}
|
|
2627
|
+
this.highlightedItem = listItem;
|
|
2628
|
+
if (this.highlightedItem) {
|
|
2629
|
+
this.highlightedItem.classList.add("iti__highlight");
|
|
2630
|
+
this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2631
|
+
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2632
|
+
this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
|
|
2633
|
+
if (this.options.countrySearch) {
|
|
2634
|
+
this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
if (shouldFocus) {
|
|
2638
|
+
this.highlightedItem.focus();
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
//* Find the country data for the given iso2 code
|
|
2642
|
+
//* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
|
|
2643
|
+
_getCountryData(iso2, allowFail) {
|
|
2644
|
+
for (let i = 0; i < this.countries.length; i++) {
|
|
2645
|
+
if (this.countries[i].iso2 === iso2) {
|
|
2646
|
+
return this.countries[i];
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
if (allowFail) {
|
|
2650
|
+
return null;
|
|
2651
|
+
}
|
|
2652
|
+
throw new Error(`No country data for '${iso2}'`);
|
|
2653
|
+
}
|
|
2654
|
+
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
|
|
2655
|
+
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
2656
|
+
_setCountry(iso2) {
|
|
2657
|
+
const { separateDialCode, showFlags, i18n } = this.options;
|
|
2658
|
+
const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2659
|
+
this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
|
|
2660
|
+
if (this.selectedCountryData.iso2) {
|
|
2661
|
+
this.defaultCountry = this.selectedCountryData.iso2;
|
|
2662
|
+
}
|
|
2663
|
+
if (this.selectedCountryInner) {
|
|
2664
|
+
let flagClass = "";
|
|
2665
|
+
let a11yText = "";
|
|
2666
|
+
if (iso2 && showFlags) {
|
|
2667
|
+
flagClass = `iti__flag iti__${iso2}`;
|
|
2668
|
+
a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`;
|
|
2669
|
+
} else {
|
|
2670
|
+
flagClass = "iti__flag iti__globe";
|
|
2671
|
+
a11yText = i18n.noCountrySelected;
|
|
2672
|
+
}
|
|
2673
|
+
this.selectedCountryInner.className = flagClass;
|
|
2674
|
+
this.selectedCountryA11yText.textContent = a11yText;
|
|
2675
|
+
}
|
|
2676
|
+
this._setSelectedCountryTitleAttribute(iso2, separateDialCode);
|
|
2677
|
+
if (separateDialCode) {
|
|
2678
|
+
const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2679
|
+
this.selectedDialCode.innerHTML = dialCode;
|
|
2680
|
+
this._updateInputPadding();
|
|
2681
|
+
}
|
|
2682
|
+
this._updatePlaceholder();
|
|
2683
|
+
this._updateMaxLength();
|
|
2684
|
+
return prevCountry.iso2 !== iso2;
|
|
2685
|
+
}
|
|
2686
|
+
//* Update the input padding to make space for the selected country/dial code.
|
|
2687
|
+
_updateInputPadding() {
|
|
2688
|
+
if (this.selectedCountry) {
|
|
2689
|
+
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
|
|
2690
|
+
const inputPadding = selectedCountryWidth + 6;
|
|
2691
|
+
if (this.showSelectedCountryOnLeft) {
|
|
2692
|
+
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
2693
|
+
} else {
|
|
2694
|
+
this.telInput.style.paddingRight = `${inputPadding}px`;
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
//* Update the maximum valid number length for the currently selected country.
|
|
2699
|
+
_updateMaxLength() {
|
|
2700
|
+
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
2701
|
+
const { iso2 } = this.selectedCountryData;
|
|
2702
|
+
if (strictMode && intlTelInput.utils) {
|
|
2703
|
+
if (iso2) {
|
|
2704
|
+
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2705
|
+
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
2706
|
+
iso2,
|
|
2707
|
+
false,
|
|
2708
|
+
numberType,
|
|
2709
|
+
true
|
|
2710
|
+
);
|
|
2711
|
+
let validNumber = exampleNumber;
|
|
2712
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
|
|
2713
|
+
validNumber = exampleNumber;
|
|
2714
|
+
exampleNumber += "0";
|
|
2715
|
+
}
|
|
2716
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
2717
|
+
this.maxCoreNumberLength = coreNumber.length;
|
|
2718
|
+
if (iso2 === "by") {
|
|
2719
|
+
this.maxCoreNumberLength = coreNumber.length + 1;
|
|
2720
|
+
}
|
|
2721
|
+
} else {
|
|
2722
|
+
this.maxCoreNumberLength = null;
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
_setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) {
|
|
2727
|
+
if (!this.selectedCountry) {
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
let title;
|
|
2731
|
+
if (iso2 && !separateDialCode) {
|
|
2732
|
+
title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`;
|
|
2733
|
+
} else if (iso2) {
|
|
2734
|
+
title = this.selectedCountryData.name;
|
|
2735
|
+
} else {
|
|
2736
|
+
title = "Unknown";
|
|
2737
|
+
}
|
|
2738
|
+
this.selectedCountry.setAttribute("title", title);
|
|
2739
|
+
}
|
|
2740
|
+
//* When the input is in a hidden container during initialisation, we must inject some markup
|
|
2741
|
+
//* into the end of the DOM to calculate the correct offsetWidth.
|
|
2742
|
+
//* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry
|
|
2743
|
+
//* will definitely exist.
|
|
2744
|
+
_getHiddenSelectedCountryWidth() {
|
|
2745
|
+
if (this.telInput.parentNode) {
|
|
2746
|
+
const containerClone = this.telInput.parentNode.cloneNode(false);
|
|
2747
|
+
containerClone.style.visibility = "hidden";
|
|
2748
|
+
document.body.appendChild(containerClone);
|
|
2749
|
+
const countryContainerClone = this.countryContainer.cloneNode();
|
|
2750
|
+
containerClone.appendChild(countryContainerClone);
|
|
2751
|
+
const selectedCountryClone = this.selectedCountry.cloneNode(true);
|
|
2752
|
+
countryContainerClone.appendChild(selectedCountryClone);
|
|
2753
|
+
const width = selectedCountryClone.offsetWidth;
|
|
2754
|
+
document.body.removeChild(containerClone);
|
|
2755
|
+
return width;
|
|
2756
|
+
}
|
|
2757
|
+
return 0;
|
|
2758
|
+
}
|
|
2759
|
+
//* Update the input placeholder to an example number from the currently selected country.
|
|
2760
|
+
_updatePlaceholder() {
|
|
2761
|
+
const {
|
|
2762
|
+
autoPlaceholder,
|
|
2763
|
+
placeholderNumberType,
|
|
2764
|
+
nationalMode,
|
|
2765
|
+
customPlaceholder
|
|
2766
|
+
} = this.options;
|
|
2767
|
+
const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
|
|
2768
|
+
if (intlTelInput.utils && shouldSetPlaceholder) {
|
|
2769
|
+
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2770
|
+
let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
|
|
2771
|
+
this.selectedCountryData.iso2,
|
|
2772
|
+
nationalMode,
|
|
2773
|
+
numberType
|
|
2774
|
+
) : "";
|
|
2775
|
+
placeholder = this._beforeSetNumber(placeholder);
|
|
2776
|
+
if (typeof customPlaceholder === "function") {
|
|
2777
|
+
placeholder = customPlaceholder(placeholder, this.selectedCountryData);
|
|
2778
|
+
}
|
|
2779
|
+
this.telInput.setAttribute("placeholder", placeholder);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
//* Called when the user selects a list item from the dropdown.
|
|
2783
|
+
_selectListItem(listItem) {
|
|
2784
|
+
const countryChanged = this._setCountry(
|
|
2785
|
+
listItem.getAttribute("data-country-code")
|
|
2786
|
+
);
|
|
2787
|
+
this._closeDropdown();
|
|
2788
|
+
this._updateDialCode(listItem.getAttribute("data-dial-code"));
|
|
2789
|
+
this.telInput.focus();
|
|
2790
|
+
if (countryChanged) {
|
|
2791
|
+
this._triggerCountryChange();
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
//* Close the dropdown and unbind any listeners.
|
|
2795
|
+
_closeDropdown() {
|
|
2796
|
+
this.dropdownContent.classList.add("iti__hide");
|
|
2797
|
+
this.selectedCountry.setAttribute("aria-expanded", "false");
|
|
2798
|
+
this.selectedCountry.removeAttribute("aria-activedescendant");
|
|
2799
|
+
if (this.highlightedItem) {
|
|
2800
|
+
this.highlightedItem.setAttribute("aria-selected", "false");
|
|
2801
|
+
}
|
|
2802
|
+
if (this.options.countrySearch) {
|
|
2803
|
+
this.searchInput.removeAttribute("aria-activedescendant");
|
|
2804
|
+
}
|
|
2805
|
+
this.dropdownArrow.classList.remove("iti__arrow--up");
|
|
2806
|
+
document.removeEventListener("keydown", this._handleKeydownOnDropdown);
|
|
2807
|
+
if (this.options.countrySearch) {
|
|
2808
|
+
this.searchInput.removeEventListener("input", this._handleSearchChange);
|
|
2809
|
+
}
|
|
2810
|
+
document.documentElement.removeEventListener(
|
|
2811
|
+
"click",
|
|
2812
|
+
this._handleClickOffToClose
|
|
2813
|
+
);
|
|
2814
|
+
this.countryList.removeEventListener(
|
|
2815
|
+
"mouseover",
|
|
2816
|
+
this._handleMouseoverCountryList
|
|
2817
|
+
);
|
|
2818
|
+
this.countryList.removeEventListener("click", this._handleClickCountryList);
|
|
2819
|
+
if (this.options.dropdownContainer) {
|
|
2820
|
+
if (!this.options.useFullscreenPopup) {
|
|
2821
|
+
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
2822
|
+
}
|
|
2823
|
+
if (this.dropdown.parentNode) {
|
|
2824
|
+
this.dropdown.parentNode.removeChild(this.dropdown);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
if (this._handlePageLoad) {
|
|
2828
|
+
window.removeEventListener("load", this._handlePageLoad);
|
|
2829
|
+
}
|
|
2830
|
+
this._trigger("close:countrydropdown");
|
|
2831
|
+
}
|
|
2832
|
+
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2833
|
+
_scrollTo(element) {
|
|
2834
|
+
const container = this.countryList;
|
|
2835
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
2836
|
+
const containerHeight = container.offsetHeight;
|
|
2837
|
+
const containerTop = container.getBoundingClientRect().top + scrollTop;
|
|
2838
|
+
const containerBottom = containerTop + containerHeight;
|
|
2839
|
+
const elementHeight = element.offsetHeight;
|
|
2840
|
+
const elementTop = element.getBoundingClientRect().top + scrollTop;
|
|
2841
|
+
const elementBottom = elementTop + elementHeight;
|
|
2842
|
+
const newScrollTop = elementTop - containerTop + container.scrollTop;
|
|
2843
|
+
if (elementTop < containerTop) {
|
|
2844
|
+
container.scrollTop = newScrollTop;
|
|
2845
|
+
} else if (elementBottom > containerBottom) {
|
|
2846
|
+
const heightDifference = containerHeight - elementHeight;
|
|
2847
|
+
container.scrollTop = newScrollTop - heightDifference;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
//* Replace any existing dial code with the new one
|
|
2851
|
+
//* Note: called from _selectListItem and setCountry
|
|
2852
|
+
_updateDialCode(newDialCodeBare) {
|
|
2853
|
+
const inputVal = this.telInput.value;
|
|
2854
|
+
const newDialCode = `+${newDialCodeBare}`;
|
|
2855
|
+
let newNumber;
|
|
2856
|
+
if (inputVal.charAt(0) === "+") {
|
|
2857
|
+
const prevDialCode = this._getDialCode(inputVal);
|
|
2858
|
+
if (prevDialCode) {
|
|
2859
|
+
newNumber = inputVal.replace(prevDialCode, newDialCode);
|
|
2860
|
+
} else {
|
|
2861
|
+
newNumber = newDialCode;
|
|
2862
|
+
}
|
|
2863
|
+
this.telInput.value = newNumber;
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
//* Try and extract a valid international dial code from a full telephone number.
|
|
2867
|
+
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
2868
|
+
_getDialCode(number, includeAreaCode) {
|
|
2869
|
+
let dialCode = "";
|
|
2870
|
+
if (number.charAt(0) === "+") {
|
|
2871
|
+
let numericChars = "";
|
|
2872
|
+
for (let i = 0; i < number.length; i++) {
|
|
2873
|
+
const c = number.charAt(i);
|
|
2874
|
+
if (!isNaN(parseInt(c, 10))) {
|
|
2875
|
+
numericChars += c;
|
|
2876
|
+
if (includeAreaCode) {
|
|
2877
|
+
if (this.dialCodeToIso2Map[numericChars]) {
|
|
2878
|
+
dialCode = number.substr(0, i + 1);
|
|
2879
|
+
}
|
|
2880
|
+
} else {
|
|
2881
|
+
if (this.dialCodes[numericChars]) {
|
|
2882
|
+
dialCode = number.substr(0, i + 1);
|
|
2883
|
+
break;
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
if (numericChars.length === this.dialCodeMaxLen) {
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
return dialCode;
|
|
2893
|
+
}
|
|
2894
|
+
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
2895
|
+
_getFullNumber(overrideVal) {
|
|
2896
|
+
const val = overrideVal || this.telInput.value.trim();
|
|
2897
|
+
const { dialCode } = this.selectedCountryData;
|
|
2898
|
+
let prefix;
|
|
2899
|
+
const numericVal = getNumeric(val);
|
|
2900
|
+
if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
|
|
2901
|
+
prefix = `+${dialCode}`;
|
|
2902
|
+
} else {
|
|
2903
|
+
prefix = "";
|
|
2904
|
+
}
|
|
2905
|
+
return prefix + val;
|
|
2906
|
+
}
|
|
2907
|
+
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
2908
|
+
_beforeSetNumber(fullNumber) {
|
|
2909
|
+
let number = fullNumber;
|
|
2910
|
+
if (this.options.separateDialCode) {
|
|
2911
|
+
let dialCode = this._getDialCode(number);
|
|
2912
|
+
if (dialCode) {
|
|
2913
|
+
dialCode = `+${this.selectedCountryData.dialCode}`;
|
|
2914
|
+
const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
|
|
2915
|
+
number = number.substr(start);
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
return this._cap(number);
|
|
2919
|
+
}
|
|
2920
|
+
//* Trigger the 'countrychange' event.
|
|
2921
|
+
_triggerCountryChange() {
|
|
2922
|
+
this._trigger("countrychange");
|
|
2923
|
+
}
|
|
2924
|
+
//* Format the number as the user types.
|
|
2925
|
+
_formatNumberAsYouType() {
|
|
2926
|
+
const val = this._getFullNumber();
|
|
2927
|
+
const result = intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;
|
|
2928
|
+
const { dialCode } = this.selectedCountryData;
|
|
2929
|
+
if (this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
|
|
2930
|
+
const afterDialCode = result.split(`+${dialCode}`)[1] || "";
|
|
2931
|
+
return afterDialCode.trim();
|
|
2932
|
+
}
|
|
2933
|
+
return result;
|
|
2934
|
+
}
|
|
2935
|
+
//**************************
|
|
2936
|
+
//* SECRET PUBLIC METHODS
|
|
2937
|
+
//**************************
|
|
2938
|
+
//* This is called when the geoip call returns.
|
|
2939
|
+
handleAutoCountry() {
|
|
2940
|
+
if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
|
|
2941
|
+
this.defaultCountry = intlTelInput.autoCountry;
|
|
2942
|
+
const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
|
|
2943
|
+
if (!hasSelectedCountryOrGlobe) {
|
|
2944
|
+
this.setCountry(this.defaultCountry);
|
|
2945
|
+
}
|
|
2946
|
+
this.resolveAutoCountryPromise();
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
//* This is called when the utils request completes.
|
|
2950
|
+
handleUtils() {
|
|
2951
|
+
if (intlTelInput.utils) {
|
|
2952
|
+
if (this.telInput.value) {
|
|
2953
|
+
this._updateValFromNumber(this.telInput.value);
|
|
2954
|
+
}
|
|
2955
|
+
if (this.selectedCountryData.iso2) {
|
|
2956
|
+
this._updatePlaceholder();
|
|
2957
|
+
this._updateMaxLength();
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
this.resolveUtilsScriptPromise();
|
|
2961
|
+
}
|
|
2962
|
+
//********************
|
|
2963
|
+
//* PUBLIC METHODS
|
|
2964
|
+
//********************
|
|
2965
|
+
//* Remove plugin.
|
|
2966
|
+
destroy() {
|
|
2967
|
+
this.telInput.iti = void 0;
|
|
2968
|
+
const { allowDropdown, separateDialCode } = this.options;
|
|
2969
|
+
if (allowDropdown) {
|
|
2970
|
+
this._closeDropdown();
|
|
2971
|
+
this.selectedCountry.removeEventListener(
|
|
2972
|
+
"click",
|
|
2973
|
+
this._handleClickSelectedCountry
|
|
2974
|
+
);
|
|
2975
|
+
this.countryContainer.removeEventListener(
|
|
2976
|
+
"keydown",
|
|
2977
|
+
this._handleCountryContainerKeydown
|
|
2978
|
+
);
|
|
2979
|
+
const label = this.telInput.closest("label");
|
|
2980
|
+
if (label) {
|
|
2981
|
+
label.removeEventListener("click", this._handleLabelClick);
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
const { form } = this.telInput;
|
|
2985
|
+
if (this._handleHiddenInputSubmit && form) {
|
|
2986
|
+
form.removeEventListener("submit", this._handleHiddenInputSubmit);
|
|
2987
|
+
}
|
|
2988
|
+
this.telInput.removeEventListener("input", this._handleInputEvent);
|
|
2989
|
+
if (this._handleKeydownEvent) {
|
|
2990
|
+
this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
|
|
2991
|
+
}
|
|
2992
|
+
this.telInput.removeAttribute("data-intl-tel-input-id");
|
|
2993
|
+
if (separateDialCode) {
|
|
2994
|
+
if (this.isRTL) {
|
|
2995
|
+
this.telInput.style.paddingRight = this.originalPaddingRight;
|
|
2996
|
+
} else {
|
|
2997
|
+
this.telInput.style.paddingLeft = this.originalPaddingLeft;
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
const wrapper = this.telInput.parentNode;
|
|
3001
|
+
wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
|
|
3002
|
+
wrapper?.parentNode?.removeChild(wrapper);
|
|
3003
|
+
delete intlTelInput.instances[this.id];
|
|
3004
|
+
}
|
|
3005
|
+
//* Get the extension from the current number.
|
|
3006
|
+
getExtension() {
|
|
3007
|
+
if (intlTelInput.utils) {
|
|
3008
|
+
return intlTelInput.utils.getExtension(
|
|
3009
|
+
this._getFullNumber(),
|
|
3010
|
+
this.selectedCountryData.iso2
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
return "";
|
|
3014
|
+
}
|
|
3015
|
+
//* Format the number to the given format.
|
|
3016
|
+
getNumber(format) {
|
|
3017
|
+
if (intlTelInput.utils) {
|
|
3018
|
+
const { iso2 } = this.selectedCountryData;
|
|
3019
|
+
return intlTelInput.utils.formatNumber(
|
|
3020
|
+
this._getFullNumber(),
|
|
3021
|
+
iso2,
|
|
3022
|
+
format
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
return "";
|
|
3026
|
+
}
|
|
3027
|
+
//* Get the type of the entered number e.g. landline/mobile.
|
|
3028
|
+
getNumberType() {
|
|
3029
|
+
if (intlTelInput.utils) {
|
|
3030
|
+
return intlTelInput.utils.getNumberType(
|
|
3031
|
+
this._getFullNumber(),
|
|
3032
|
+
this.selectedCountryData.iso2
|
|
3033
|
+
);
|
|
3034
|
+
}
|
|
3035
|
+
return -99;
|
|
3036
|
+
}
|
|
3037
|
+
//* Get the country data for the currently selected country.
|
|
3038
|
+
getSelectedCountryData() {
|
|
3039
|
+
return this.selectedCountryData;
|
|
3040
|
+
}
|
|
3041
|
+
//* Get the validation error.
|
|
3042
|
+
getValidationError() {
|
|
3043
|
+
if (intlTelInput.utils) {
|
|
3044
|
+
const { iso2 } = this.selectedCountryData;
|
|
3045
|
+
return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2);
|
|
3046
|
+
}
|
|
3047
|
+
return -99;
|
|
3048
|
+
}
|
|
3049
|
+
//* Validate the input val
|
|
3050
|
+
isValidNumber() {
|
|
3051
|
+
if (!this.selectedCountryData.iso2) {
|
|
3052
|
+
return false;
|
|
3053
|
+
}
|
|
3054
|
+
const val = this._getFullNumber();
|
|
3055
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
3056
|
+
if (alphaCharPosition > -1) {
|
|
3057
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
3058
|
+
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
3059
|
+
const isValid = this._utilsIsPossibleNumber(val);
|
|
3060
|
+
return beforeAlphaIsValid && isValid;
|
|
3061
|
+
}
|
|
3062
|
+
return this._utilsIsPossibleNumber(val);
|
|
3063
|
+
}
|
|
3064
|
+
_utilsIsPossibleNumber(val) {
|
|
3065
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3066
|
+
}
|
|
3067
|
+
//* Validate the input val (precise)
|
|
3068
|
+
isValidNumberPrecise() {
|
|
3069
|
+
if (!this.selectedCountryData.iso2) {
|
|
3070
|
+
return false;
|
|
3071
|
+
}
|
|
3072
|
+
const val = this._getFullNumber();
|
|
3073
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
3074
|
+
if (alphaCharPosition > -1) {
|
|
3075
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
3076
|
+
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
|
|
3077
|
+
const isValid = this._utilsIsValidNumber(val);
|
|
3078
|
+
return beforeAlphaIsValid && isValid;
|
|
3079
|
+
}
|
|
3080
|
+
return this._utilsIsValidNumber(val);
|
|
3081
|
+
}
|
|
3082
|
+
_utilsIsValidNumber(val) {
|
|
3083
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3084
|
+
}
|
|
3085
|
+
//* Update the selected country, and update the input val accordingly.
|
|
3086
|
+
setCountry(iso2) {
|
|
3087
|
+
const iso2Lower = iso2?.toLowerCase();
|
|
3088
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
3089
|
+
const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
|
|
3090
|
+
if (isCountryChange) {
|
|
3091
|
+
this._setCountry(iso2Lower);
|
|
3092
|
+
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
3093
|
+
this._triggerCountryChange();
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
//* Set the input value and update the country.
|
|
3097
|
+
setNumber(number) {
|
|
3098
|
+
const countryChanged = this._updateCountryFromNumber(number);
|
|
3099
|
+
this._updateValFromNumber(number);
|
|
3100
|
+
if (countryChanged) {
|
|
3101
|
+
this._triggerCountryChange();
|
|
3102
|
+
}
|
|
3103
|
+
this._trigger("input", { isSetNumber: true });
|
|
3104
|
+
}
|
|
3105
|
+
//* Set the placeholder number typ
|
|
3106
|
+
setPlaceholderNumberType(type) {
|
|
3107
|
+
this.options.placeholderNumberType = type;
|
|
3108
|
+
this._updatePlaceholder();
|
|
3109
|
+
}
|
|
3110
|
+
setDisabled(disabled) {
|
|
3111
|
+
this.telInput.disabled = disabled;
|
|
3112
|
+
if (disabled) {
|
|
3113
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
3114
|
+
} else {
|
|
3115
|
+
this.selectedCountry.removeAttribute("disabled");
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
};
|
|
3119
|
+
var attachUtils = (source) => {
|
|
3120
|
+
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
3121
|
+
let loadCall;
|
|
3122
|
+
if (typeof source === "function") {
|
|
3123
|
+
try {
|
|
3124
|
+
loadCall = Promise.resolve(source());
|
|
3125
|
+
} catch (error) {
|
|
3126
|
+
return Promise.reject(error);
|
|
3127
|
+
}
|
|
3128
|
+
} else {
|
|
3129
|
+
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}`));
|
|
3130
|
+
}
|
|
3131
|
+
intlTelInput.startedLoadingUtilsScript = true;
|
|
3132
|
+
return loadCall.then((module2) => {
|
|
3133
|
+
const utils = module2?.default;
|
|
3134
|
+
if (!utils || typeof utils !== "object") {
|
|
3135
|
+
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
3136
|
+
}
|
|
3137
|
+
intlTelInput.utils = utils;
|
|
3138
|
+
forEachInstance("handleUtils");
|
|
3139
|
+
return true;
|
|
3140
|
+
}).catch((error) => {
|
|
3141
|
+
forEachInstance("rejectUtilsScriptPromise", error);
|
|
3142
|
+
throw error;
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
return null;
|
|
3146
|
+
};
|
|
3147
|
+
var intlTelInput = Object.assign(
|
|
3148
|
+
(input, options) => {
|
|
3149
|
+
const iti = new Iti(input, options);
|
|
3150
|
+
iti._init();
|
|
3151
|
+
input.setAttribute("data-intl-tel-input-id", iti.id.toString());
|
|
3152
|
+
intlTelInput.instances[iti.id] = iti;
|
|
3153
|
+
input.iti = iti;
|
|
3154
|
+
return iti;
|
|
3155
|
+
},
|
|
3156
|
+
{
|
|
3157
|
+
defaults,
|
|
3158
|
+
//* Using a static var like this allows us to mock it in the tests.
|
|
3159
|
+
documentReady: () => document.readyState === "complete",
|
|
3160
|
+
//* Get the country data object.
|
|
3161
|
+
getCountryData: () => data_default,
|
|
3162
|
+
//* A getter for the plugin instance.
|
|
3163
|
+
getInstance: (input) => {
|
|
3164
|
+
const id2 = input.getAttribute("data-intl-tel-input-id");
|
|
3165
|
+
return id2 ? intlTelInput.instances[id2] : null;
|
|
3166
|
+
},
|
|
3167
|
+
//* A map from instance ID to instance object.
|
|
3168
|
+
instances: {},
|
|
3169
|
+
attachUtils,
|
|
3170
|
+
startedLoadingUtilsScript: false,
|
|
3171
|
+
startedLoadingAutoCountry: false,
|
|
3172
|
+
version: "25.4.3"
|
|
3173
|
+
}
|
|
3174
|
+
);
|
|
3175
|
+
var intl_tel_input_default = intlTelInput;
|
|
3176
|
+
|
|
3177
|
+
// angular/src/intl-tel-input/angular.ts
|
|
3178
|
+
var import_core = require("@angular/core");
|
|
3179
|
+
var import_forms = require("@angular/forms");
|
|
3180
|
+
var PHONE_ERROR_MESSAGES = [
|
|
3181
|
+
"invalid",
|
|
3182
|
+
"invalid-country-code",
|
|
3183
|
+
"too-short",
|
|
3184
|
+
"too-long",
|
|
3185
|
+
"invalid-format"
|
|
3186
|
+
];
|
|
3187
|
+
var IntlTelInputComponent = class {
|
|
3188
|
+
constructor() {
|
|
3189
|
+
this.initialValue = "";
|
|
3190
|
+
this.usePreciseValidation = false;
|
|
3191
|
+
this.inputProps = {};
|
|
3192
|
+
this.disabled = void 0;
|
|
3193
|
+
this.initOptions = {};
|
|
3194
|
+
this.numberChange = new import_core.EventEmitter();
|
|
3195
|
+
this.countryChange = new import_core.EventEmitter();
|
|
3196
|
+
this.validityChange = new import_core.EventEmitter();
|
|
3197
|
+
this.errorCodeChange = new import_core.EventEmitter();
|
|
3198
|
+
this.iti = null;
|
|
3199
|
+
this.countryChangeHandler = () => this.handleInput();
|
|
3200
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3201
|
+
this.onChange = () => {
|
|
3202
|
+
};
|
|
3203
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3204
|
+
this.onTouched = () => {
|
|
3205
|
+
};
|
|
3206
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3207
|
+
this.onValidatorChange = () => {
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
ngOnInit() {
|
|
3211
|
+
if (this.inputRef.nativeElement) {
|
|
3212
|
+
this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.initOptions);
|
|
3213
|
+
}
|
|
3214
|
+
this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
|
|
3215
|
+
this.applyInputProps();
|
|
3216
|
+
for (const key in this.inputProps) {
|
|
3217
|
+
if (this.inputProps.hasOwnProperty(key)) {
|
|
3218
|
+
this.inputRef.nativeElement.setAttribute(key, this.inputProps[key]);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
ngAfterViewInit() {
|
|
3223
|
+
if (this.initialValue) {
|
|
3224
|
+
this.iti?.setNumber(this.initialValue);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
handleInput() {
|
|
3228
|
+
if (!this.iti) return;
|
|
3229
|
+
const num = this.iti.getNumber() || "";
|
|
3230
|
+
const countryIso = this.iti.getSelectedCountryData().iso2 || "";
|
|
3231
|
+
this.numberChange.emit(num);
|
|
3232
|
+
this.countryChange.emit(countryIso);
|
|
3233
|
+
const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
|
|
3234
|
+
if (isValid) {
|
|
3235
|
+
this.validityChange.emit(true);
|
|
3236
|
+
this.errorCodeChange.emit(null);
|
|
3237
|
+
} else {
|
|
3238
|
+
this.validityChange.emit(false);
|
|
3239
|
+
this.errorCodeChange.emit(this.iti.getValidationError());
|
|
3240
|
+
}
|
|
3241
|
+
this.onChange(num);
|
|
3242
|
+
this.onValidatorChange();
|
|
3243
|
+
}
|
|
3244
|
+
handleBlur() {
|
|
3245
|
+
this.onTouched();
|
|
3246
|
+
}
|
|
3247
|
+
getInstance() {
|
|
3248
|
+
return this.iti;
|
|
3249
|
+
}
|
|
3250
|
+
getInput() {
|
|
3251
|
+
return this.inputRef.nativeElement;
|
|
3252
|
+
}
|
|
3253
|
+
ngOnDestroy() {
|
|
3254
|
+
this.iti?.destroy();
|
|
3255
|
+
this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
|
|
3256
|
+
}
|
|
3257
|
+
applyInputProps() {
|
|
3258
|
+
const props = this.inputProps;
|
|
3259
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
3260
|
+
this.inputRef.nativeElement.setAttribute(key, value);
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
// ============ ControlValueAccessor Implementation ============
|
|
3264
|
+
writeValue(value) {
|
|
3265
|
+
if (this.iti && value) {
|
|
3266
|
+
this.iti.setNumber(value);
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
registerOnChange(fn) {
|
|
3270
|
+
this.onChange = fn;
|
|
3271
|
+
}
|
|
3272
|
+
registerOnTouched(fn) {
|
|
3273
|
+
this.onTouched = fn;
|
|
3274
|
+
}
|
|
3275
|
+
setDisabledState(isDisabled) {
|
|
3276
|
+
this.disabled = isDisabled;
|
|
3277
|
+
}
|
|
3278
|
+
// ============ Validator Implementation ============
|
|
3279
|
+
validate(control) {
|
|
3280
|
+
if (!control.value || !this.iti) {
|
|
3281
|
+
return null;
|
|
3282
|
+
}
|
|
3283
|
+
const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
|
|
3284
|
+
if (isValid) {
|
|
3285
|
+
return null;
|
|
3286
|
+
}
|
|
3287
|
+
const errorCode = this.iti.getValidationError();
|
|
3288
|
+
return {
|
|
3289
|
+
invalidPhone: {
|
|
3290
|
+
errorCode,
|
|
3291
|
+
errorMessage: PHONE_ERROR_MESSAGES[errorCode]
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
registerOnValidatorChange(fn) {
|
|
3296
|
+
this.onValidatorChange = fn;
|
|
3297
|
+
}
|
|
3298
|
+
};
|
|
3299
|
+
__decorateClass([
|
|
3300
|
+
(0, import_core.ViewChild)("inputRef", { static: true })
|
|
3301
|
+
], IntlTelInputComponent.prototype, "inputRef", 2);
|
|
3302
|
+
__decorateClass([
|
|
3303
|
+
(0, import_core.Input)()
|
|
3304
|
+
], IntlTelInputComponent.prototype, "initialValue", 2);
|
|
3305
|
+
__decorateClass([
|
|
3306
|
+
(0, import_core.Input)()
|
|
3307
|
+
], IntlTelInputComponent.prototype, "usePreciseValidation", 2);
|
|
3308
|
+
__decorateClass([
|
|
3309
|
+
(0, import_core.Input)()
|
|
3310
|
+
], IntlTelInputComponent.prototype, "inputProps", 2);
|
|
3311
|
+
__decorateClass([
|
|
3312
|
+
(0, import_core.Input)()
|
|
3313
|
+
], IntlTelInputComponent.prototype, "disabled", 2);
|
|
3314
|
+
__decorateClass([
|
|
3315
|
+
(0, import_core.Input)()
|
|
3316
|
+
], IntlTelInputComponent.prototype, "initOptions", 2);
|
|
3317
|
+
__decorateClass([
|
|
3318
|
+
(0, import_core.Output)()
|
|
3319
|
+
], IntlTelInputComponent.prototype, "numberChange", 2);
|
|
3320
|
+
__decorateClass([
|
|
3321
|
+
(0, import_core.Output)()
|
|
3322
|
+
], IntlTelInputComponent.prototype, "countryChange", 2);
|
|
3323
|
+
__decorateClass([
|
|
3324
|
+
(0, import_core.Output)()
|
|
3325
|
+
], IntlTelInputComponent.prototype, "validityChange", 2);
|
|
3326
|
+
__decorateClass([
|
|
3327
|
+
(0, import_core.Output)()
|
|
3328
|
+
], IntlTelInputComponent.prototype, "errorCodeChange", 2);
|
|
3329
|
+
IntlTelInputComponent = __decorateClass([
|
|
3330
|
+
(0, import_core.Component)({
|
|
3331
|
+
selector: "intl-tel-input",
|
|
3332
|
+
standalone: true,
|
|
3333
|
+
template: `
|
|
3334
|
+
<input
|
|
3335
|
+
type="tel"
|
|
3336
|
+
#inputRef
|
|
3337
|
+
(input)="handleInput()"
|
|
3338
|
+
(blur)="handleBlur()"
|
|
3339
|
+
[disabled]="disabled"
|
|
3340
|
+
/>
|
|
3341
|
+
`,
|
|
3342
|
+
providers: [
|
|
3343
|
+
{
|
|
3344
|
+
provide: import_forms.NG_VALUE_ACCESSOR,
|
|
3345
|
+
useExisting: (0, import_core.forwardRef)(() => IntlTelInputComponent),
|
|
3346
|
+
multi: true
|
|
3347
|
+
},
|
|
3348
|
+
{
|
|
3349
|
+
provide: import_forms.NG_VALIDATORS,
|
|
3350
|
+
useExisting: (0, import_core.forwardRef)(() => IntlTelInputComponent),
|
|
3351
|
+
multi: true
|
|
3352
|
+
}
|
|
3353
|
+
]
|
|
3354
|
+
})
|
|
3355
|
+
], IntlTelInputComponent);
|
|
3356
|
+
var angular_default = IntlTelInputComponent;
|