svelte-tel-input 0.5.1 → 0.6.2
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/CHANGELOG.md +18 -0
- package/README.md +2 -0
- package/assets/allCountry.d.ts +3 -0
- package/assets/allCountry.js +306 -0
- package/components/Input/TelInput.svelte +1 -1
- package/components/Select/Select.svelte +41 -0
- package/components/Select/Select.svelte.d.ts +21 -0
- package/components/Select/SelectListItem.svelte +10 -0
- package/components/Select/SelectListItem.svelte.d.ts +18 -0
- package/components/Select/TelCountrySelect/TelCountrySelect.svelte +42 -1
- package/components/Select/TelRegionSelect/TelRegionSelect.svelte +1 -1
- package/components/Select/TelRegionSelect/TelRegionSelectOption.svelte +1 -1
- package/components/Select/TelTypeSelect/TelTypeSelect.svelte +1 -1
- package/components/Select/TelTypeSelect/TelTypeSelectOption.svelte +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/models/interfaces/Country.interface.d.ts +7 -0
- package/models/interfaces/Country.interface.js +1 -0
- package/package.json +41 -36
- package/utils/api.d.ts +28 -0
- package/utils/api.js +30 -0
- package/utils/helpers.d.ts +1 -0
- package/utils/helpers.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# svelte-tel-input
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update readme & update packages ([#54](https://github.com/gyurielf/svelte-tel-input/pull/54))
|
|
8
|
+
|
|
9
|
+
## 0.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Readme update ([#52](https://github.com/gyurielf/svelte-tel-input/pull/52))
|
|
14
|
+
|
|
15
|
+
## 0.6.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- feat: example page preparations & extend functionality (part 1) ([#50](https://github.com/gyurielf/svelte-tel-input/pull/50))
|
|
20
|
+
|
|
3
21
|
## 0.5.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// Array of country objects for the flag dropdown.
|
|
2
|
+
const allCountries = [
|
|
3
|
+
['Afghanistan (افغانستان)', 'af', '93'],
|
|
4
|
+
['Albania (Shqipëri)', 'al', '355'],
|
|
5
|
+
['Algeria (الجزائر)', 'dz', '213'],
|
|
6
|
+
['American Samoa', 'as', '1', 5, ['684']],
|
|
7
|
+
['Andorra', 'ad', '376'],
|
|
8
|
+
['Angola', 'ao', '244'],
|
|
9
|
+
['Anguilla', 'ai', '1', 6, ['264']],
|
|
10
|
+
['Antigua and Barbuda', 'ag', '1', 7, ['268']],
|
|
11
|
+
['Argentina', 'ar', '54'],
|
|
12
|
+
['Armenia (Հայաստան)', 'am', '374'],
|
|
13
|
+
['Aruba', 'aw', '297'],
|
|
14
|
+
['Ascension Island', 'ac', '247'],
|
|
15
|
+
['Australia', 'au', '61', 0],
|
|
16
|
+
['Austria (Österreich)', 'at', '43'],
|
|
17
|
+
['Azerbaijan (Azərbaycan)', 'az', '994'],
|
|
18
|
+
['Bahamas', 'bs', '1', 8, ['242']],
|
|
19
|
+
['Bahrain (البحرين)', 'bh', '973'],
|
|
20
|
+
['Bangladesh (বাংলাদেশ)', 'bd', '880'],
|
|
21
|
+
['Barbados', 'bb', '1', 9, ['246']],
|
|
22
|
+
['Belarus (Беларусь)', 'by', '375'],
|
|
23
|
+
['Belgium (België)', 'be', '32'],
|
|
24
|
+
['Belize', 'bz', '501'],
|
|
25
|
+
['Benin (Bénin)', 'bj', '229'],
|
|
26
|
+
['Bermuda', 'bm', '1', 10, ['441']],
|
|
27
|
+
['Bhutan (འབྲུག)', 'bt', '975'],
|
|
28
|
+
['Bolivia', 'bo', '591'],
|
|
29
|
+
['Bosnia and Herzegovina (Босна и Херцеговина)', 'ba', '387'],
|
|
30
|
+
['Botswana', 'bw', '267'],
|
|
31
|
+
['Brazil (Brasil)', 'br', '55'],
|
|
32
|
+
['British Indian Ocean Territory', 'io', '246'],
|
|
33
|
+
['British Virgin Islands', 'vg', '1', 11, ['284']],
|
|
34
|
+
['Brunei', 'bn', '673'],
|
|
35
|
+
['Bulgaria (България)', 'bg', '359'],
|
|
36
|
+
['Burkina Faso', 'bf', '226'],
|
|
37
|
+
['Burundi (Uburundi)', 'bi', '257'],
|
|
38
|
+
['Cambodia (កម្ពុជា)', 'kh', '855'],
|
|
39
|
+
['Cameroon (Cameroun)', 'cm', '237'],
|
|
40
|
+
[
|
|
41
|
+
'Canada',
|
|
42
|
+
'ca',
|
|
43
|
+
'1',
|
|
44
|
+
1,
|
|
45
|
+
[
|
|
46
|
+
'204',
|
|
47
|
+
'226',
|
|
48
|
+
'236',
|
|
49
|
+
'249',
|
|
50
|
+
'250',
|
|
51
|
+
'289',
|
|
52
|
+
'306',
|
|
53
|
+
'343',
|
|
54
|
+
'365',
|
|
55
|
+
'387',
|
|
56
|
+
'403',
|
|
57
|
+
'416',
|
|
58
|
+
'418',
|
|
59
|
+
'431',
|
|
60
|
+
'437',
|
|
61
|
+
'438',
|
|
62
|
+
'450',
|
|
63
|
+
'506',
|
|
64
|
+
'514',
|
|
65
|
+
'519',
|
|
66
|
+
'548',
|
|
67
|
+
'579',
|
|
68
|
+
'581',
|
|
69
|
+
'587',
|
|
70
|
+
'604',
|
|
71
|
+
'613',
|
|
72
|
+
'639',
|
|
73
|
+
'647',
|
|
74
|
+
'672',
|
|
75
|
+
'705',
|
|
76
|
+
'709',
|
|
77
|
+
'742',
|
|
78
|
+
'778',
|
|
79
|
+
'780',
|
|
80
|
+
'782',
|
|
81
|
+
'807',
|
|
82
|
+
'819',
|
|
83
|
+
'825',
|
|
84
|
+
'867',
|
|
85
|
+
'873',
|
|
86
|
+
'902',
|
|
87
|
+
'905'
|
|
88
|
+
]
|
|
89
|
+
],
|
|
90
|
+
['Cape Verde (Kabu Verdi)', 'cv', '238'],
|
|
91
|
+
['Caribbean Netherlands', 'bq', '599', 1, ['3', '4', '7']],
|
|
92
|
+
['Cayman Islands', 'ky', '1', 12, ['345']],
|
|
93
|
+
['Central African Republic (République centrafricaine)', 'cf', '236'],
|
|
94
|
+
['Chad (Tchad)', 'td', '235'],
|
|
95
|
+
['Chile', 'cl', '56'],
|
|
96
|
+
['China (中国)', 'cn', '86'],
|
|
97
|
+
['Christmas Island', 'cx', '61', 2, ['89164']],
|
|
98
|
+
['Cocos (Keeling) Islands', 'cc', '61', 1, ['89162']],
|
|
99
|
+
['Colombia', 'co', '57'],
|
|
100
|
+
['Comoros (جزر القمر)', 'km', '269'],
|
|
101
|
+
['Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)', 'cd', '243'],
|
|
102
|
+
['Congo (Republic) (Congo-Brazzaville)', 'cg', '242'],
|
|
103
|
+
['Cook Islands', 'ck', '682'],
|
|
104
|
+
['Costa Rica', 'cr', '506'],
|
|
105
|
+
['Côte d’Ivoire', 'ci', '225'],
|
|
106
|
+
['Croatia (Hrvatska)', 'hr', '385'],
|
|
107
|
+
['Cuba', 'cu', '53'],
|
|
108
|
+
['Curaçao', 'cw', '599', 0],
|
|
109
|
+
['Cyprus (Κύπρος)', 'cy', '357'],
|
|
110
|
+
['Czech Republic (Česká republika)', 'cz', '420'],
|
|
111
|
+
['Denmark (Danmark)', 'dk', '45'],
|
|
112
|
+
['Djibouti', 'dj', '253'],
|
|
113
|
+
['Dominica', 'dm', '1', 13, ['767']],
|
|
114
|
+
['Dominican Republic (República Dominicana)', 'do', '1', 2, ['809', '829', '849']],
|
|
115
|
+
['Ecuador', 'ec', '593'],
|
|
116
|
+
['Egypt (مصر)', 'eg', '20'],
|
|
117
|
+
['El Salvador', 'sv', '503'],
|
|
118
|
+
['Equatorial Guinea (Guinea Ecuatorial)', 'gq', '240'],
|
|
119
|
+
['Eritrea', 'er', '291'],
|
|
120
|
+
['Estonia (Eesti)', 'ee', '372'],
|
|
121
|
+
['Eswatini', 'sz', '268'],
|
|
122
|
+
['Ethiopia', 'et', '251'],
|
|
123
|
+
['Falkland Islands (Islas Malvinas)', 'fk', '500'],
|
|
124
|
+
['Faroe Islands (Føroyar)', 'fo', '298'],
|
|
125
|
+
['Fiji', 'fj', '679'],
|
|
126
|
+
['Finland (Suomi)', 'fi', '358', 0],
|
|
127
|
+
['France', 'fr', '33'],
|
|
128
|
+
['French Guiana (Guyane française)', 'gf', '594'],
|
|
129
|
+
['French Polynesia (Polynésie française)', 'pf', '689'],
|
|
130
|
+
['Gabon', 'ga', '241'],
|
|
131
|
+
['Gambia', 'gm', '220'],
|
|
132
|
+
['Georgia (საქართველო)', 'ge', '995'],
|
|
133
|
+
['Germany (Deutschland)', 'de', '49'],
|
|
134
|
+
['Ghana (Gaana)', 'gh', '233'],
|
|
135
|
+
['Gibraltar', 'gi', '350'],
|
|
136
|
+
['Greece (Ελλάδα)', 'gr', '30'],
|
|
137
|
+
['Greenland (Kalaallit Nunaat)', 'gl', '299'],
|
|
138
|
+
['Grenada', 'gd', '1', 14, ['473']],
|
|
139
|
+
['Guadeloupe', 'gp', '590', 0],
|
|
140
|
+
['Guam', 'gu', '1', 15, ['671']],
|
|
141
|
+
['Guatemala', 'gt', '502'],
|
|
142
|
+
['Guernsey', 'gg', '44', 1, ['1481', '7781', '7839', '7911']],
|
|
143
|
+
['Guinea (Guinée)', 'gn', '224'],
|
|
144
|
+
['Guinea-Bissau (Guiné Bissau)', 'gw', '245'],
|
|
145
|
+
['Guyana', 'gy', '592'],
|
|
146
|
+
['Haiti', 'ht', '509'],
|
|
147
|
+
['Honduras', 'hn', '504'],
|
|
148
|
+
['Hong Kong (香港)', 'hk', '852'],
|
|
149
|
+
['Hungary (Magyarország)', 'hu', '36'],
|
|
150
|
+
['Iceland (Ísland)', 'is', '354'],
|
|
151
|
+
['India (भारत)', 'in', '91'],
|
|
152
|
+
['Indonesia', 'id', '62'],
|
|
153
|
+
['Iran (ایران)', 'ir', '98'],
|
|
154
|
+
['Iraq (العراق)', 'iq', '964'],
|
|
155
|
+
['Ireland', 'ie', '353'],
|
|
156
|
+
['Isle of Man', 'im', '44', 2, ['1624', '74576', '7524', '7924', '7624']],
|
|
157
|
+
['Israel (ישראל)', 'il', '972'],
|
|
158
|
+
['Italy (Italia)', 'it', '39', 0],
|
|
159
|
+
['Jamaica', 'jm', '1', 4, ['876', '658']],
|
|
160
|
+
['Japan (日本)', 'jp', '81'],
|
|
161
|
+
['Jersey', 'je', '44', 3, ['1534', '7509', '7700', '7797', '7829', '7937']],
|
|
162
|
+
['Jordan (الأردن)', 'jo', '962'],
|
|
163
|
+
['Kazakhstan (Казахстан)', 'kz', '7', 1, ['33', '7']],
|
|
164
|
+
['Kenya', 'ke', '254'],
|
|
165
|
+
['Kiribati', 'ki', '686'],
|
|
166
|
+
['Kosovo', 'xk', '383'],
|
|
167
|
+
['Kuwait (الكويت)', 'kw', '965'],
|
|
168
|
+
['Kyrgyzstan (Кыргызстан)', 'kg', '996'],
|
|
169
|
+
['Laos (ລາວ)', 'la', '856'],
|
|
170
|
+
['Latvia (Latvija)', 'lv', '371'],
|
|
171
|
+
['Lebanon (لبنان)', 'lb', '961'],
|
|
172
|
+
['Lesotho', 'ls', '266'],
|
|
173
|
+
['Liberia', 'lr', '231'],
|
|
174
|
+
['Libya (ليبيا)', 'ly', '218'],
|
|
175
|
+
['Liechtenstein', 'li', '423'],
|
|
176
|
+
['Lithuania (Lietuva)', 'lt', '370'],
|
|
177
|
+
['Luxembourg', 'lu', '352'],
|
|
178
|
+
['Macau (澳門)', 'mo', '853'],
|
|
179
|
+
['North Macedonia (Македонија)', 'mk', '389'],
|
|
180
|
+
['Madagascar (Madagasikara)', 'mg', '261'],
|
|
181
|
+
['Malawi', 'mw', '265'],
|
|
182
|
+
['Malaysia', 'my', '60'],
|
|
183
|
+
['Maldives', 'mv', '960'],
|
|
184
|
+
['Mali', 'ml', '223'],
|
|
185
|
+
['Malta', 'mt', '356'],
|
|
186
|
+
['Marshall Islands', 'mh', '692'],
|
|
187
|
+
['Martinique', 'mq', '596'],
|
|
188
|
+
['Mauritania (موريتانيا)', 'mr', '222'],
|
|
189
|
+
['Mauritius (Moris)', 'mu', '230'],
|
|
190
|
+
['Mayotte', 'yt', '262', 1, ['269', '639']],
|
|
191
|
+
['Mexico (México)', 'mx', '52'],
|
|
192
|
+
['Micronesia', 'fm', '691'],
|
|
193
|
+
['Moldova (Republica Moldova)', 'md', '373'],
|
|
194
|
+
['Monaco', 'mc', '377'],
|
|
195
|
+
['Mongolia (Монгол)', 'mn', '976'],
|
|
196
|
+
['Montenegro (Crna Gora)', 'me', '382'],
|
|
197
|
+
['Montserrat', 'ms', '1', 16, ['664']],
|
|
198
|
+
['Morocco (المغرب)', 'ma', '212', 0],
|
|
199
|
+
['Mozambique (Moçambique)', 'mz', '258'],
|
|
200
|
+
['Myanmar (Burma) (မြန်မာ)', 'mm', '95'],
|
|
201
|
+
['Namibia (Namibië)', 'na', '264'],
|
|
202
|
+
['Nauru', 'nr', '674'],
|
|
203
|
+
['Nepal (नेपाल)', 'np', '977'],
|
|
204
|
+
['Netherlands (Nederland)', 'nl', '31'],
|
|
205
|
+
['New Caledonia (Nouvelle-Calédonie)', 'nc', '687'],
|
|
206
|
+
['New Zealand', 'nz', '64'],
|
|
207
|
+
['Nicaragua', 'ni', '505'],
|
|
208
|
+
['Niger (Nijar)', 'ne', '227'],
|
|
209
|
+
['Nigeria', 'ng', '234'],
|
|
210
|
+
['Niue', 'nu', '683'],
|
|
211
|
+
['Norfolk Island', 'nf', '672'],
|
|
212
|
+
['North Korea (조선 민주주의 인민 공화국)', 'kp', '850'],
|
|
213
|
+
['Northern Mariana Islands', 'mp', '1', 17, ['670']],
|
|
214
|
+
['Norway (Norge)', 'no', '47', 0],
|
|
215
|
+
['Oman (عُمان)', 'om', '968'],
|
|
216
|
+
['Pakistan (پاکستان)', 'pk', '92'],
|
|
217
|
+
['Palau', 'pw', '680'],
|
|
218
|
+
['Palestine (فلسطين)', 'ps', '970'],
|
|
219
|
+
['Panama (Panamá)', 'pa', '507'],
|
|
220
|
+
['Papua New Guinea', 'pg', '675'],
|
|
221
|
+
['Paraguay', 'py', '595'],
|
|
222
|
+
['Peru (Perú)', 'pe', '51'],
|
|
223
|
+
['Philippines', 'ph', '63'],
|
|
224
|
+
['Poland (Polska)', 'pl', '48'],
|
|
225
|
+
['Portugal', 'pt', '351'],
|
|
226
|
+
['Puerto Rico', 'pr', '1', 3, ['787', '939']],
|
|
227
|
+
['Qatar (قطر)', 'qa', '974'],
|
|
228
|
+
['Réunion (La Réunion)', 're', '262', 0],
|
|
229
|
+
['Romania (România)', 'ro', '40'],
|
|
230
|
+
['Russia (Россия)', 'ru', '7', 0],
|
|
231
|
+
['Rwanda', 'rw', '250'],
|
|
232
|
+
['Saint Barthélemy', 'bl', '590', 1],
|
|
233
|
+
['Saint Helena', 'sh', '290'],
|
|
234
|
+
['Saint Kitts and Nevis', 'kn', '1', 18, ['869']],
|
|
235
|
+
['Saint Lucia', 'lc', '1', 19, ['758']],
|
|
236
|
+
['Saint Martin (Saint-Martin (partie française))', 'mf', '590', 2],
|
|
237
|
+
['Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)', 'pm', '508'],
|
|
238
|
+
['Saint Vincent and the Grenadines', 'vc', '1', 20, ['784']],
|
|
239
|
+
['Samoa', 'ws', '685'],
|
|
240
|
+
['San Marino', 'sm', '378'],
|
|
241
|
+
['São Tomé and Príncipe (São Tomé e Príncipe)', 'st', '239'],
|
|
242
|
+
['Saudi Arabia (المملكة العربية السعودية)', 'sa', '966'],
|
|
243
|
+
['Senegal (Sénégal)', 'sn', '221'],
|
|
244
|
+
['Serbia (Србија)', 'rs', '381'],
|
|
245
|
+
['Seychelles', 'sc', '248'],
|
|
246
|
+
['Sierra Leone', 'sl', '232'],
|
|
247
|
+
['Singapore', 'sg', '65'],
|
|
248
|
+
['Sint Maarten', 'sx', '1', 21, ['721']],
|
|
249
|
+
['Slovakia (Slovensko)', 'sk', '421'],
|
|
250
|
+
['Slovenia (Slovenija)', 'si', '386'],
|
|
251
|
+
['Solomon Islands', 'sb', '677'],
|
|
252
|
+
['Somalia (Soomaaliya)', 'so', '252'],
|
|
253
|
+
['South Africa', 'za', '27'],
|
|
254
|
+
['South Korea (대한민국)', 'kr', '82'],
|
|
255
|
+
['South Sudan (جنوب السودان)', 'ss', '211'],
|
|
256
|
+
['Spain (España)', 'es', '34'],
|
|
257
|
+
['Sri Lanka (ශ්රී ලංකාව)', 'lk', '94'],
|
|
258
|
+
['Sudan (السودان)', 'sd', '249'],
|
|
259
|
+
['Suriname', 'sr', '597'],
|
|
260
|
+
['Svalbard and Jan Mayen', 'sj', '47', 1, ['79']],
|
|
261
|
+
['Sweden (Sverige)', 'se', '46'],
|
|
262
|
+
['Switzerland (Schweiz)', 'ch', '41'],
|
|
263
|
+
['Syria (سوريا)', 'sy', '963'],
|
|
264
|
+
['Taiwan (台灣)', 'tw', '886'],
|
|
265
|
+
['Tajikistan', 'tj', '992'],
|
|
266
|
+
['Tanzania', 'tz', '255'],
|
|
267
|
+
['Thailand (ไทย)', 'th', '66'],
|
|
268
|
+
['Timor-Leste', 'tl', '670'],
|
|
269
|
+
['Togo', 'tg', '228'],
|
|
270
|
+
['Tokelau', 'tk', '690'],
|
|
271
|
+
['Tonga', 'to', '676'],
|
|
272
|
+
['Trinidad and Tobago', 'tt', '1', 22, ['868']],
|
|
273
|
+
['Tunisia (تونس)', 'tn', '216'],
|
|
274
|
+
['Turkey (Türkiye)', 'tr', '90'],
|
|
275
|
+
['Turkmenistan', 'tm', '993'],
|
|
276
|
+
['Turks and Caicos Islands', 'tc', '1', 23, ['649']],
|
|
277
|
+
['Tuvalu', 'tv', '688'],
|
|
278
|
+
['U.S. Virgin Islands', 'vi', '1', 24, ['340']],
|
|
279
|
+
['Uganda', 'ug', '256'],
|
|
280
|
+
['Ukraine (Україна)', 'ua', '380'],
|
|
281
|
+
['United Arab Emirates (الإمارات العربية المتحدة)', 'ae', '971'],
|
|
282
|
+
['United Kingdom', 'gb', '44', 0],
|
|
283
|
+
['United States', 'us', '1', 0],
|
|
284
|
+
['Uruguay', 'uy', '598'],
|
|
285
|
+
['Uzbekistan (Oʻzbekiston)', 'uz', '998'],
|
|
286
|
+
['Vanuatu', 'vu', '678'],
|
|
287
|
+
['Vatican City (Città del Vaticano)', 'va', '39', 1, ['06698']],
|
|
288
|
+
['Venezuela', 've', '58'],
|
|
289
|
+
['Vietnam (Việt Nam)', 'vn', '84'],
|
|
290
|
+
['Wallis and Futuna (Wallis-et-Futuna)', 'wf', '681'],
|
|
291
|
+
['Western Sahara (الصحراء الغربية)', 'eh', '212', 1, ['5288', '5289']],
|
|
292
|
+
['Yemen (اليمن)', 'ye', '967'],
|
|
293
|
+
['Zambia', 'zm', '260'],
|
|
294
|
+
['Zimbabwe', 'zw', '263'],
|
|
295
|
+
['Åland Islands', 'ax', '358', 1, ['18']]
|
|
296
|
+
];
|
|
297
|
+
const restructuredCountries = allCountries.map((country) => {
|
|
298
|
+
return {
|
|
299
|
+
name: country[0],
|
|
300
|
+
iso2: country[1],
|
|
301
|
+
dialCode: country[2],
|
|
302
|
+
priority: country[3] || 0,
|
|
303
|
+
areaCodes: country[4] || null
|
|
304
|
+
};
|
|
305
|
+
});
|
|
306
|
+
export default restructuredCountries;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>import { clickOutsideAction } from '../../utils/directives/clickOutsideAction';
|
|
2
|
+
export let selectOptions = {
|
|
3
|
+
searchInput: false,
|
|
4
|
+
flags: true
|
|
5
|
+
};
|
|
6
|
+
export let items;
|
|
7
|
+
let isOpen = false;
|
|
8
|
+
let enteredSearch;
|
|
9
|
+
const toggleSelect = (e) => {
|
|
10
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
11
|
+
isOpen = !isOpen;
|
|
12
|
+
};
|
|
13
|
+
const closeSelect = (e) => {
|
|
14
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
15
|
+
isOpen = false;
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="select cursor-pointer" use:clickOutsideAction={closeSelect}>
|
|
20
|
+
<div on:click={() => toggleSelect()}>CHOOSE</div>
|
|
21
|
+
{#if isOpen}
|
|
22
|
+
<ul class="border border-gray-900 max-h-40 w-fit overflow-y-scroll">
|
|
23
|
+
{#if !selectOptions.searchInput}
|
|
24
|
+
<input
|
|
25
|
+
type="text"
|
|
26
|
+
class="px-4 py-1 text-gray-900 focus:outline-none w-full"
|
|
27
|
+
bind:value={enteredSearch}
|
|
28
|
+
/>
|
|
29
|
+
{/if}
|
|
30
|
+
{#each items as item}
|
|
31
|
+
<li class="p-2 bg-gray-600 hover:bg-opacity-30">
|
|
32
|
+
<span class="mr-3">{item.name}</span> +{item.dialCode}
|
|
33
|
+
</li>
|
|
34
|
+
{:else}
|
|
35
|
+
<div>List is on the way..</div>
|
|
36
|
+
{/each}
|
|
37
|
+
</ul>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<style></style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Country } from '../../models/interfaces/Country.interface';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
selectOptions?: {
|
|
6
|
+
searchInput: boolean;
|
|
7
|
+
flags: boolean;
|
|
8
|
+
} | undefined;
|
|
9
|
+
items: Country[];
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export declare type SelectProps = typeof __propDef.props;
|
|
17
|
+
export declare type SelectEvents = typeof __propDef.events;
|
|
18
|
+
export declare type SelectSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Select extends SvelteComponentTyped<SelectProps, SelectEvents, SelectSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {};
|
|
4
|
+
events: {
|
|
5
|
+
selectedItem: CustomEvent<any>;
|
|
6
|
+
} & {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type SelectListItemProps = typeof __propDef.props;
|
|
14
|
+
export declare type SelectListItemEvents = typeof __propDef.events;
|
|
15
|
+
export declare type SelectListItemSlots = typeof __propDef.slots;
|
|
16
|
+
export default class SelectListItem extends SvelteComponentTyped<SelectListItemProps, SelectListItemEvents, SelectListItemSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -1,15 +1,56 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script>import { selectedCountryStore } from '../../../stores';
|
|
2
2
|
export let selectedCountry;
|
|
3
3
|
const setSelectedCountry = (value) => {
|
|
4
4
|
selectedCountry = value;
|
|
5
5
|
$selectedCountryStore = value;
|
|
6
6
|
};
|
|
7
|
+
// const getCountries = (list = []) => {
|
|
8
|
+
// return list.map((countryCode) => findCountry(countryCode)).filter(Boolean);
|
|
9
|
+
// };
|
|
10
|
+
// const findCountry = (iso: string) => {
|
|
11
|
+
// return filteredCountries.find((country) => country.iso2 === iso.toUpperCase());
|
|
12
|
+
// };
|
|
13
|
+
// const findCountryByDialCode = (dialCode: any) => {
|
|
14
|
+
// return filteredCountries.find((country) => Number(country.dialCode) === dialCode);
|
|
15
|
+
// };
|
|
16
|
+
// $: filteredCountries = () => {
|
|
17
|
+
// // List countries after filtered
|
|
18
|
+
// if (onlyCountries.length) {
|
|
19
|
+
// return allCountries.filter(({ iso2 }) =>
|
|
20
|
+
// onlyCountries.some((c) => c.toUpperCase() === iso2)
|
|
21
|
+
// );
|
|
22
|
+
// }
|
|
23
|
+
// if (ignoredCountries.length) {
|
|
24
|
+
// return allCountries.filter(
|
|
25
|
+
// ({ iso2 }) =>
|
|
26
|
+
// !ignoredCountries.includes(iso2.toUpperCase()) &&
|
|
27
|
+
// !ignoredCountries.includes(iso2.toLowerCase())
|
|
28
|
+
// );
|
|
29
|
+
// }
|
|
30
|
+
// return allCountries;
|
|
31
|
+
// };
|
|
32
|
+
// $: sortedCountries = () => {
|
|
33
|
+
// // Sort the list countries: from preferred countries to all countries
|
|
34
|
+
// const preferredCountries = getCountries(preferredCountries).map((country) => ({
|
|
35
|
+
// ...country,
|
|
36
|
+
// preferred: true
|
|
37
|
+
// }));
|
|
38
|
+
// return [...preferredCountries, ...filteredCountries];
|
|
39
|
+
// };
|
|
40
|
+
// const getDefault(key: string) => {
|
|
41
|
+
// const value = utils.options[key];
|
|
42
|
+
// if (typeof value === 'undefined') {
|
|
43
|
+
// return utils.options[key];
|
|
44
|
+
// }
|
|
45
|
+
// return value;
|
|
46
|
+
// }
|
|
7
47
|
</script>
|
|
8
48
|
|
|
9
49
|
<select
|
|
10
50
|
name="country_select"
|
|
11
51
|
class="some-class {$$props.class}"
|
|
12
52
|
on:change={(e) => setSelectedCountry(e.currentTarget.value)}
|
|
53
|
+
bind:value={selectedCountry}
|
|
13
54
|
>
|
|
14
55
|
<slot name="options" />
|
|
15
56
|
</select>
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as TelCountrySelect } from "./components/Select/TelCountrySelect/TelCountrySelect.svelte";
|
|
2
|
+
export { default as SelectListItem } from "./components/Select/SelectListItem.svelte";
|
|
2
3
|
export { default as TelTypeSelect } from "./components/Select/TelTypeSelect/TelTypeSelect.svelte";
|
|
3
4
|
export { default as TelTypeSelectOption } from "./components/Select/TelTypeSelect/TelTypeSelectOption.svelte";
|
|
5
|
+
export { default as Select } from "./components/Select/Select.svelte";
|
|
4
6
|
export { default as TelRegionSelect } from "./components/Select/TelRegionSelect/TelRegionSelect.svelte";
|
|
5
7
|
export { default as TelRegionSelectOption } from "./components/Select/TelRegionSelect/TelRegionSelectOption.svelte";
|
|
6
8
|
export { default as TelInput } from "./components/Input/TelInput.svelte";
|
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as TelCountrySelect } from './components/Select/TelCountrySelect/TelCountrySelect.svelte';
|
|
2
|
+
export { default as SelectListItem } from './components/Select/SelectListItem.svelte';
|
|
2
3
|
export { default as TelTypeSelect } from './components/Select/TelTypeSelect/TelTypeSelect.svelte';
|
|
3
4
|
export { default as TelTypeSelectOption } from './components/Select/TelTypeSelect/TelTypeSelectOption.svelte';
|
|
5
|
+
export { default as Select } from './components/Select/Select.svelte';
|
|
4
6
|
export { default as TelRegionSelect } from './components/Select/TelRegionSelect/TelRegionSelect.svelte';
|
|
5
7
|
export { default as TelRegionSelectOption } from './components/Select/TelRegionSelect/TelRegionSelectOption.svelte';
|
|
6
8
|
export { default as TelInput } from './components/Input/TelInput.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tel-input",
|
|
3
3
|
"description": "svelte-tel-input",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/gyurielf/svelte-tel-input.git"
|
|
@@ -21,50 +21,50 @@
|
|
|
21
21
|
"node": ">= 16"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"libphonenumber-js": "^1.9.
|
|
24
|
+
"libphonenumber-js": "^1.9.52"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/core": "^7.17.
|
|
27
|
+
"@babel/core": "^7.17.9",
|
|
28
28
|
"@babel/preset-env": "^7.16.11",
|
|
29
|
-
"@changesets/cli": "^2.
|
|
29
|
+
"@changesets/cli": "^2.22.0",
|
|
30
30
|
"@changesets/get-github-info": "^0.5.0",
|
|
31
|
-
"@changesets/types": "^
|
|
32
|
-
"@sveltejs/adapter-static": "^1.0.0-next.
|
|
33
|
-
"@sveltejs/kit": "^1.0.0-next.
|
|
34
|
-
"@testing-library/jest-dom": "^5.16.
|
|
35
|
-
"@testing-library/svelte": "^3.
|
|
36
|
-
"@types/jest": "^27.4.
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
38
|
-
"@typescript-eslint/parser": "^5.
|
|
39
|
-
"autoprefixer": "^10.4.
|
|
40
|
-
"babel-jest": "^27.
|
|
41
|
-
"babel-loader": "^8.2.
|
|
42
|
-
"cssnano": "^5.
|
|
31
|
+
"@changesets/types": "^5.0.0",
|
|
32
|
+
"@sveltejs/adapter-static": "^1.0.0-next.29",
|
|
33
|
+
"@sveltejs/kit": "^1.0.0-next.320",
|
|
34
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
35
|
+
"@testing-library/svelte": "^3.1.1",
|
|
36
|
+
"@types/jest": "^27.4.1",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
39
|
+
"autoprefixer": "^10.4.4",
|
|
40
|
+
"babel-jest": "^27.5.1",
|
|
41
|
+
"babel-loader": "^8.2.5",
|
|
42
|
+
"cssnano": "^5.1.7",
|
|
43
43
|
"dotenv": "^16.0.0",
|
|
44
|
-
"eslint": "^8.
|
|
45
|
-
"eslint-config-prettier": "^8.
|
|
46
|
-
"eslint-plugin-jest": "^26.
|
|
47
|
-
"eslint-plugin-svelte3": "^3.4.
|
|
44
|
+
"eslint": "^8.14.0",
|
|
45
|
+
"eslint-config-prettier": "^8.5.0",
|
|
46
|
+
"eslint-plugin-jest": "^26.1.5",
|
|
47
|
+
"eslint-plugin-svelte3": "^3.4.1",
|
|
48
48
|
"husky": "^7.0.4",
|
|
49
|
-
"jest": "^27.
|
|
49
|
+
"jest": "^27.5.1",
|
|
50
50
|
"jest-matchmedia-mock": "^1.1.0",
|
|
51
|
-
"micromatch": "^4.0.
|
|
52
|
-
"postcss": "^8.4.
|
|
53
|
-
"postcss-load-config": "^3.1.
|
|
54
|
-
"prettier": "^2.
|
|
55
|
-
"prettier-plugin-svelte": "^2.
|
|
56
|
-
"svelte": "^3.
|
|
57
|
-
"svelte-check": "^2.
|
|
58
|
-
"svelte-inview": "^
|
|
59
|
-
"svelte-jester": "^2.3.
|
|
51
|
+
"micromatch": "^4.0.5",
|
|
52
|
+
"postcss": "^8.4.12",
|
|
53
|
+
"postcss-load-config": "^3.1.4",
|
|
54
|
+
"prettier": "^2.6.2",
|
|
55
|
+
"prettier-plugin-svelte": "^2.7.0",
|
|
56
|
+
"svelte": "^3.47.0",
|
|
57
|
+
"svelte-check": "^2.7.0",
|
|
58
|
+
"svelte-inview": "^3.0.0",
|
|
59
|
+
"svelte-jester": "^2.3.2",
|
|
60
60
|
"svelte-loader": "^3.1.2",
|
|
61
|
-
"svelte-preprocess": "^4.10.
|
|
62
|
-
"svelte2tsx": "^0.5.
|
|
63
|
-
"tailwindcss": "^3.0.
|
|
64
|
-
"ts-jest": "^27.1.
|
|
61
|
+
"svelte-preprocess": "^4.10.6",
|
|
62
|
+
"svelte2tsx": "^0.5.9",
|
|
63
|
+
"tailwindcss": "^3.0.24",
|
|
64
|
+
"ts-jest": "^27.1.4",
|
|
65
65
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
66
|
-
"tslib": "^2.
|
|
67
|
-
"typescript": "^4.
|
|
66
|
+
"tslib": "^2.4.0",
|
|
67
|
+
"typescript": "^4.6.3"
|
|
68
68
|
},
|
|
69
69
|
"standard-version": {
|
|
70
70
|
"skip": {
|
|
@@ -138,9 +138,12 @@
|
|
|
138
138
|
"license": "MIT",
|
|
139
139
|
"exports": {
|
|
140
140
|
"./package.json": "./package.json",
|
|
141
|
+
"./assets/allCountry": "./assets/allCountry.js",
|
|
141
142
|
"./assets/countries": "./assets/countries.js",
|
|
142
143
|
"./assets/regions": "./assets/regions.js",
|
|
143
144
|
"./components/Input/TelInput.svelte": "./components/Input/TelInput.svelte",
|
|
145
|
+
"./components/Select/Select.svelte": "./components/Select/Select.svelte",
|
|
146
|
+
"./components/Select/SelectListItem.svelte": "./components/Select/SelectListItem.svelte",
|
|
144
147
|
"./components/Select/TelCountrySelect/TelCountrySelect.svelte": "./components/Select/TelCountrySelect/TelCountrySelect.svelte",
|
|
145
148
|
"./components/Select/TelRegionSelect/TelRegionSelect.svelte": "./components/Select/TelRegionSelect/TelRegionSelect.svelte",
|
|
146
149
|
"./components/Select/TelRegionSelect/TelRegionSelectOption.svelte": "./components/Select/TelRegionSelect/TelRegionSelectOption.svelte",
|
|
@@ -150,10 +153,12 @@
|
|
|
150
153
|
"./models/enums/PhoneType.enum": "./models/enums/PhoneType.enum.js",
|
|
151
154
|
"./models/enums": "./models/enums/index.js",
|
|
152
155
|
"./models": "./models/index.js",
|
|
156
|
+
"./models/interfaces/Country.interface": "./models/interfaces/Country.interface.js",
|
|
153
157
|
"./models/interfaces/Select.interface": "./models/interfaces/Select.interface.js",
|
|
154
158
|
"./models/types/DynamicSvelteComponent.type": "./models/types/DynamicSvelteComponent.type.js",
|
|
155
159
|
"./models/types/Select.type": "./models/types/Select.type.js",
|
|
156
160
|
"./stores": "./stores/index.js",
|
|
161
|
+
"./utils/api": "./utils/api.js",
|
|
157
162
|
"./utils/directives/clickOutsideAction": "./utils/directives/clickOutsideAction.js",
|
|
158
163
|
"./utils/helpers": "./utils/helpers.js",
|
|
159
164
|
"./utils/simulator": "./utils/simulator.js",
|
package/utils/api.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const get: (base: string, path: string) => Promise<{
|
|
2
|
+
response: Response;
|
|
3
|
+
json?: undefined;
|
|
4
|
+
} | {
|
|
5
|
+
response: Response;
|
|
6
|
+
json: Record<string, any>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const del: (base: string, path: string, data?: any) => Promise<{
|
|
9
|
+
response: Response;
|
|
10
|
+
json?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
response: Response;
|
|
13
|
+
json: Record<string, any>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const post: (base: string, path: string, data?: any) => Promise<{
|
|
16
|
+
response: Response;
|
|
17
|
+
json?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
response: Response;
|
|
20
|
+
json: Record<string, any>;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const put: (base: string, path: string, data?: any) => Promise<{
|
|
23
|
+
response: Response;
|
|
24
|
+
json?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
response: Response;
|
|
27
|
+
json: Record<string, any>;
|
|
28
|
+
}>;
|
package/utils/api.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const send = async ({ method, path, data, base }) => {
|
|
2
|
+
const opts = { method, headers: {}, credentials: 'include' };
|
|
3
|
+
if (data) {
|
|
4
|
+
opts.headers['content-type'] = 'application/json';
|
|
5
|
+
opts.body = JSON.stringify(data);
|
|
6
|
+
}
|
|
7
|
+
const fullPath = encodeURI(`${base}${path}`);
|
|
8
|
+
const response = await fetch(fullPath, opts);
|
|
9
|
+
if (response.status === 204) {
|
|
10
|
+
return { response };
|
|
11
|
+
}
|
|
12
|
+
if (response.headers.get('content-type') === 'application/json') {
|
|
13
|
+
const json = await response.json();
|
|
14
|
+
return { response, json };
|
|
15
|
+
}
|
|
16
|
+
return { response };
|
|
17
|
+
};
|
|
18
|
+
// Shortcut methods
|
|
19
|
+
export const get = (base, path) => {
|
|
20
|
+
return send({ method: 'GET', path, base });
|
|
21
|
+
};
|
|
22
|
+
export const del = (base, path, data) => {
|
|
23
|
+
return send({ method: 'DELETE', path, data, base });
|
|
24
|
+
};
|
|
25
|
+
export const post = (base, path, data) => {
|
|
26
|
+
return send({ method: 'POST', path, data, base });
|
|
27
|
+
};
|
|
28
|
+
export const put = (base, path, data) => {
|
|
29
|
+
return send({ method: 'PUT', path, data, base });
|
|
30
|
+
};
|
package/utils/helpers.d.ts
CHANGED
package/utils/helpers.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export const capitalize = (str) => {
|
|
2
2
|
return (str && str[0].toUpperCase() + str.slice(1).toLowerCase()) || '';
|
|
3
3
|
};
|
|
4
|
+
export const getCurrentCountry = async () => {
|
|
5
|
+
const response = await (await fetch('https://ip2c.org/s')).text();
|
|
6
|
+
const result = (response || '').toString();
|
|
7
|
+
if (!result || result[0] !== '1') {
|
|
8
|
+
throw new Error('Unable to fetch the country');
|
|
9
|
+
}
|
|
10
|
+
return result.substring(2, 4);
|
|
11
|
+
};
|