glib-web 0.5.77
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/.eslintrc.js +37 -0
- package/LICENSE +201 -0
- package/README.md +33 -0
- package/action.js +167 -0
- package/actions/analytics/logEvent.js +26 -0
- package/actions/auth/creditCard.js +29 -0
- package/actions/auth/restart.js +5 -0
- package/actions/auth/saveCsrfToken.js +12 -0
- package/actions/cables/push.js +38 -0
- package/actions/dialogs/alert.js +15 -0
- package/actions/dialogs/close.js +7 -0
- package/actions/dialogs/notification.js +14 -0
- package/actions/dialogs/oauth.js +6 -0
- package/actions/dialogs/open.js +7 -0
- package/actions/dialogs/options.js +5 -0
- package/actions/dialogs/show.js +5 -0
- package/actions/forms/submit.js +15 -0
- package/actions/http/delete.js +7 -0
- package/actions/http/patch.js +7 -0
- package/actions/http/post.js +7 -0
- package/actions/http/put.js +7 -0
- package/actions/panels/scrollTo.js +18 -0
- package/actions/panels/scrollToBottom.js +11 -0
- package/actions/runMultiple.js +11 -0
- package/actions/sheets/select.js +5 -0
- package/actions/snackbars/alert.js +15 -0
- package/actions/snackbars/select.js +5 -0
- package/actions/timeouts/set.js +20 -0
- package/actions/windows/close.js +13 -0
- package/actions/windows/closeAll.js +16 -0
- package/actions/windows/closeWithReload.js +18 -0
- package/actions/windows/open.js +5 -0
- package/actions/windows/openWeb.js +5 -0
- package/actions/windows/refreshState.js +5 -0
- package/actions/windows/reload.js +24 -0
- package/actions/ws/push.js +35 -0
- package/app.vue +180 -0
- package/components/_button.vue +101 -0
- package/components/_dropdownMenu.vue +76 -0
- package/components/_icon.vue +50 -0
- package/components/_message.vue +25 -0
- package/components/avatar.vue +16 -0
- package/components/banners/alert.vue +49 -0
- package/components/banners/select.vue +82 -0
- package/components/button.vue +13 -0
- package/components/calendar.vue +105 -0
- package/components/charts/column.vue +26 -0
- package/components/charts/line.vue +61 -0
- package/components/chip.vue +24 -0
- package/components/component.vue +222 -0
- package/components/datetime.vue +54 -0
- package/components/fab.vue +33 -0
- package/components/fields/_patternText.vue +61 -0
- package/components/fields/_select.vue +86 -0
- package/components/fields/autocomplete.vue +73 -0
- package/components/fields/check.vue +104 -0
- package/components/fields/checkGroup.vue +51 -0
- package/components/fields/country/countries.js +251 -0
- package/components/fields/country/field.vue +81 -0
- package/components/fields/country/regions.js +12 -0
- package/components/fields/creditCard.vue +105 -0
- package/components/fields/date.vue +24 -0
- package/components/fields/datetime.vue +49 -0
- package/components/fields/dynamicGroup.vue +106 -0
- package/components/fields/dynamicSelect.vue +173 -0
- package/components/fields/file.vue +166 -0
- package/components/fields/googlePlace.vue +158 -0
- package/components/fields/hidden.vue +18 -0
- package/components/fields/location.vue +223 -0
- package/components/fields/newRichText.vue +191 -0
- package/components/fields/phone/countries.js +315 -0
- package/components/fields/phone/field.vue +348 -0
- package/components/fields/phone/sprite.css +1071 -0
- package/components/fields/radio.vue +64 -0
- package/components/fields/radioGroup.vue +93 -0
- package/components/fields/rating.vue +26 -0
- package/components/fields/richText.vue +172 -0
- package/components/fields/select.vue +17 -0
- package/components/fields/stripe/stripeFields.vue +93 -0
- package/components/fields/stripe/stripeIndividualFields.vue +207 -0
- package/components/fields/stripeExternalAccount.vue +135 -0
- package/components/fields/stripeToken.vue +59 -0
- package/components/fields/submit.vue +23 -0
- package/components/fields/text.vue +144 -0
- package/components/fields/textarea.vue +59 -0
- package/components/fields/timeZone.vue +22 -0
- package/components/fields/timer.vue +83 -0
- package/components/h1.vue +28 -0
- package/components/h2.vue +20 -0
- package/components/h3.vue +22 -0
- package/components/h4.vue +20 -0
- package/components/h5.vue +20 -0
- package/components/h6.vue +20 -0
- package/components/hr.vue +13 -0
- package/components/html.vue +13 -0
- package/components/icon.vue +25 -0
- package/components/image.vue +87 -0
- package/components/label.vue +62 -0
- package/components/map.vue +206 -0
- package/components/markdown.vue +52 -0
- package/components/mixins/events.js +178 -0
- package/components/mixins/generic.js +58 -0
- package/components/mixins/list/autoload.js +144 -0
- package/components/mixins/longClick.js +56 -0
- package/components/mixins/scrolling.js +35 -0
- package/components/mixins/styles.js +221 -0
- package/components/mixins/table/autoload.js +131 -0
- package/components/mixins/table/export.js +52 -0
- package/components/mixins/table/import.js +106 -0
- package/components/mixins/text.js +20 -0
- package/components/mixins/ws/actionCable.js +48 -0
- package/components/mixins/ws/phoenixSocket.js +117 -0
- package/components/p.vue +36 -0
- package/components/panels/carousel.vue +55 -0
- package/components/panels/column.vue +117 -0
- package/components/panels/custom.vue +52 -0
- package/components/panels/flow.vue +81 -0
- package/components/panels/form.vue +126 -0
- package/components/panels/horizontal.vue +73 -0
- package/components/panels/list.vue +241 -0
- package/components/panels/responsive.vue +88 -0
- package/components/panels/scroll.vue +68 -0
- package/components/panels/split.vue +52 -0
- package/components/panels/table.vue +234 -0
- package/components/panels/ul.vue +34 -0
- package/components/panels/vertical.vue +71 -0
- package/components/panels/web.vue +11 -0
- package/components/spacer.vue +11 -0
- package/components/switch.vue +42 -0
- package/components/tabBar.vue +44 -0
- package/extensions/array.js +20 -0
- package/extensions/string.js +21 -0
- package/index.js +195 -0
- package/keys.js +12 -0
- package/nav/appbar.vue +117 -0
- package/nav/content.vue +40 -0
- package/nav/dialog.vue +127 -0
- package/nav/drawer.vue +88 -0
- package/nav/drawerButton.vue +28 -0
- package/nav/drawerLabel.vue +21 -0
- package/nav/sheet.vue +57 -0
- package/nav/snackbar.vue +72 -0
- package/package.json +42 -0
- package/settings.json.example +21 -0
- package/static/plugins/alignment/alignment.js +76 -0
- package/static/plugins/alignment/alignment.min.js +1 -0
- package/static/plugins/beyondgrammar/beyondgrammar.js +46 -0
- package/static/plugins/beyondgrammar/beyondgrammar.min.js +1 -0
- package/static/plugins/blockcode/blockcode.js +110 -0
- package/static/plugins/blockcode/blockcode.min.js +1 -0
- package/static/plugins/clips/clips.js +44 -0
- package/static/plugins/clips/clips.min.js +1 -0
- package/static/plugins/counter/counter.js +60 -0
- package/static/plugins/counter/counter.min.js +1 -0
- package/static/plugins/definedlinks/definedlinks.js +64 -0
- package/static/plugins/definedlinks/definedlinks.min.js +1 -0
- package/static/plugins/handle/handle.js +173 -0
- package/static/plugins/handle/handle.min.js +1 -0
- package/static/plugins/icons/icons.js +72 -0
- package/static/plugins/icons/icons.min.js +1 -0
- package/static/plugins/imageposition/imageposition.js +85 -0
- package/static/plugins/imageposition/imageposition.min.js +1 -0
- package/static/plugins/inlineformat/inlineformat.js +85 -0
- package/static/plugins/inlineformat/inlineformat.min.js +1 -0
- package/static/plugins/removeformat/removeformat.js +28 -0
- package/static/plugins/removeformat/removeformat.min.js +1 -0
- package/static/plugins/selector/selector.js +96 -0
- package/static/plugins/selector/selector.min.js +1 -0
- package/static/plugins/specialchars/specialchars.js +63 -0
- package/static/plugins/specialchars/specialchars.min.js +1 -0
- package/static/plugins/textdirection/textdirection.js +55 -0
- package/static/plugins/textdirection/textdirection.min.js +1 -0
- package/static/plugins/textexpander/textexpander.js +46 -0
- package/static/plugins/textexpander/textexpander.min.js +1 -0
- package/static/plugins/underline/underline.js +27 -0
- package/static/plugins/underline/underline.min.js +1 -0
- package/static/redactorx.css +1344 -0
- package/static/redactorx.js +14254 -0
- package/static/redactorx.min.css +1 -0
- package/static/redactorx.min.js +1 -0
- package/static/redactorx.usm.min.js +2 -0
- package/styles/test.sass +3 -0
- package/styles/test.scss +5 -0
- package/templates/_menu.vue +38 -0
- package/templates/comment.vue +202 -0
- package/templates/featured.vue +32 -0
- package/templates/thumbnail.vue +138 -0
- package/templates/unsupported.vue +12 -0
- package/utils/app.js +14 -0
- package/utils/dom.js +13 -0
- package/utils/form.js +34 -0
- package/utils/format.js +14 -0
- package/utils/hash.js +29 -0
- package/utils/helper.js +44 -0
- package/utils/history.js +70 -0
- package/utils/http.js +209 -0
- package/utils/launch.js +135 -0
- package/utils/private/ws.js +22 -0
- package/utils/public.js +23 -0
- package/utils/settings.js +48 -0
- package/utils/storage.js +9 -0
- package/utils/type.js +69 -0
- package/utils/uploader.js +121 -0
- package/utils/url.js +132 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// [
|
|
2
|
+
// Country name,
|
|
3
|
+
// iso2 code,
|
|
4
|
+
// International dial code,
|
|
5
|
+
// Order (if >1 country with same dial code),
|
|
6
|
+
// Area codes
|
|
7
|
+
// ]
|
|
8
|
+
const allCountries = [
|
|
9
|
+
["Afghanistan (افغانستان)", "af", "93"],
|
|
10
|
+
["Albania (Shqipëri)", "al", "355"],
|
|
11
|
+
["Algeria (الجزائر)", "dz", "213"],
|
|
12
|
+
["American Samoa", "as", "1684"],
|
|
13
|
+
["Andorra", "ad", "376"],
|
|
14
|
+
["Angola", "ao", "244"],
|
|
15
|
+
["Anguilla", "ai", "1264"],
|
|
16
|
+
["Antigua and Barbuda", "ag", "1268"],
|
|
17
|
+
["Argentina", "ar", "54"],
|
|
18
|
+
["Armenia (Հայաստան)", "am", "374"],
|
|
19
|
+
["Aruba", "aw", "297"],
|
|
20
|
+
["Australia", "au", "61", 0],
|
|
21
|
+
["Austria (Österreich)", "at", "43"],
|
|
22
|
+
["Azerbaijan (Azərbaycan)", "az", "994"],
|
|
23
|
+
["Bahamas", "bs", "1242"],
|
|
24
|
+
["Bahrain (البحرين)", "bh", "973"],
|
|
25
|
+
["Bangladesh (বাংলাদেশ)", "bd", "880"],
|
|
26
|
+
["Barbados", "bb", "1246"],
|
|
27
|
+
["Belarus (Беларусь)", "by", "375"],
|
|
28
|
+
["Belgium (België)", "be", "32"],
|
|
29
|
+
["Belize", "bz", "501"],
|
|
30
|
+
["Benin (Bénin)", "bj", "229"],
|
|
31
|
+
["Bermuda", "bm", "1441"],
|
|
32
|
+
["Bhutan (འབྲུག)", "bt", "975"],
|
|
33
|
+
["Bolivia", "bo", "591"],
|
|
34
|
+
["Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387"],
|
|
35
|
+
["Botswana", "bw", "267"],
|
|
36
|
+
["Brazil (Brasil)", "br", "55"],
|
|
37
|
+
["British Indian Ocean Territory", "io", "246"],
|
|
38
|
+
["British Virgin Islands", "vg", "1284"],
|
|
39
|
+
["Brunei", "bn", "673"],
|
|
40
|
+
["Bulgaria (България)", "bg", "359"],
|
|
41
|
+
["Burkina Faso", "bf", "226"],
|
|
42
|
+
["Burundi (Uburundi)", "bi", "257"],
|
|
43
|
+
["Cambodia (កម្ពុជា)", "kh", "855"],
|
|
44
|
+
["Cameroon (Cameroun)", "cm", "237"],
|
|
45
|
+
[
|
|
46
|
+
"Canada",
|
|
47
|
+
"ca",
|
|
48
|
+
"1",
|
|
49
|
+
1,
|
|
50
|
+
[
|
|
51
|
+
"204",
|
|
52
|
+
"226",
|
|
53
|
+
"236",
|
|
54
|
+
"249",
|
|
55
|
+
"250",
|
|
56
|
+
"289",
|
|
57
|
+
"306",
|
|
58
|
+
"343",
|
|
59
|
+
"365",
|
|
60
|
+
"387",
|
|
61
|
+
"403",
|
|
62
|
+
"416",
|
|
63
|
+
"418",
|
|
64
|
+
"431",
|
|
65
|
+
"437",
|
|
66
|
+
"438",
|
|
67
|
+
"450",
|
|
68
|
+
"506",
|
|
69
|
+
"514",
|
|
70
|
+
"519",
|
|
71
|
+
"548",
|
|
72
|
+
"579",
|
|
73
|
+
"581",
|
|
74
|
+
"587",
|
|
75
|
+
"604",
|
|
76
|
+
"613",
|
|
77
|
+
"639",
|
|
78
|
+
"647",
|
|
79
|
+
"672",
|
|
80
|
+
"705",
|
|
81
|
+
"709",
|
|
82
|
+
"742",
|
|
83
|
+
"778",
|
|
84
|
+
"780",
|
|
85
|
+
"782",
|
|
86
|
+
"807",
|
|
87
|
+
"819",
|
|
88
|
+
"825",
|
|
89
|
+
"867",
|
|
90
|
+
"873",
|
|
91
|
+
"902",
|
|
92
|
+
"905"
|
|
93
|
+
]
|
|
94
|
+
],
|
|
95
|
+
["Cape Verde (Kabu Verdi)", "cv", "238"],
|
|
96
|
+
["Caribbean Netherlands", "bq", "599", 1],
|
|
97
|
+
["Cayman Islands", "ky", "1345"],
|
|
98
|
+
["Central African Republic (République centrafricaine)", "cf", "236"],
|
|
99
|
+
["Chad (Tchad)", "td", "235"],
|
|
100
|
+
["Chile", "cl", "56"],
|
|
101
|
+
["China (中国)", "cn", "86"],
|
|
102
|
+
["Christmas Island", "cx", "61", 2],
|
|
103
|
+
["Cocos (Keeling) Islands", "cc", "61", 1],
|
|
104
|
+
["Colombia", "co", "57"],
|
|
105
|
+
["Comoros (جزر القمر)", "km", "269"],
|
|
106
|
+
["Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243"],
|
|
107
|
+
["Congo (Republic) (Congo-Brazzaville)", "cg", "242"],
|
|
108
|
+
["Cook Islands", "ck", "682"],
|
|
109
|
+
["Costa Rica", "cr", "506"],
|
|
110
|
+
["Côte d’Ivoire", "ci", "225"],
|
|
111
|
+
["Croatia (Hrvatska)", "hr", "385"],
|
|
112
|
+
["Cuba", "cu", "53"],
|
|
113
|
+
["Curaçao", "cw", "599", 0],
|
|
114
|
+
["Cyprus (Κύπρος)", "cy", "357"],
|
|
115
|
+
["Czech Republic (Česká republika)", "cz", "420"],
|
|
116
|
+
["Denmark (Danmark)", "dk", "45"],
|
|
117
|
+
["Djibouti", "dj", "253"],
|
|
118
|
+
["Dominica", "dm", "1767"],
|
|
119
|
+
[
|
|
120
|
+
"Dominican Republic (República Dominicana)",
|
|
121
|
+
"do",
|
|
122
|
+
"1",
|
|
123
|
+
2,
|
|
124
|
+
["809", "829", "849"]
|
|
125
|
+
],
|
|
126
|
+
["Ecuador", "ec", "593"],
|
|
127
|
+
["Egypt (مصر)", "eg", "20"],
|
|
128
|
+
["El Salvador", "sv", "503"],
|
|
129
|
+
["Equatorial Guinea (Guinea Ecuatorial)", "gq", "240"],
|
|
130
|
+
["Eritrea", "er", "291"],
|
|
131
|
+
["Estonia (Eesti)", "ee", "372"],
|
|
132
|
+
["Ethiopia", "et", "251"],
|
|
133
|
+
["Falkland Islands (Islas Malvinas)", "fk", "500"],
|
|
134
|
+
["Faroe Islands (Føroyar)", "fo", "298"],
|
|
135
|
+
["Fiji", "fj", "679"],
|
|
136
|
+
["Finland (Suomi)", "fi", "358", 0],
|
|
137
|
+
["France", "fr", "33"],
|
|
138
|
+
["French Guiana (Guyane française)", "gf", "594"],
|
|
139
|
+
["French Polynesia (Polynésie française)", "pf", "689"],
|
|
140
|
+
["Gabon", "ga", "241"],
|
|
141
|
+
["Gambia", "gm", "220"],
|
|
142
|
+
["Georgia (საქართველო)", "ge", "995"],
|
|
143
|
+
["Germany (Deutschland)", "de", "49"],
|
|
144
|
+
["Ghana (Gaana)", "gh", "233"],
|
|
145
|
+
["Gibraltar", "gi", "350"],
|
|
146
|
+
["Greece (Ελλάδα)", "gr", "30"],
|
|
147
|
+
["Greenland (Kalaallit Nunaat)", "gl", "299"],
|
|
148
|
+
["Grenada", "gd", "1473"],
|
|
149
|
+
["Guadeloupe", "gp", "590", 0],
|
|
150
|
+
["Guam", "gu", "1671"],
|
|
151
|
+
["Guatemala", "gt", "502"],
|
|
152
|
+
["Guernsey", "gg", "44", 1],
|
|
153
|
+
["Guinea (Guinée)", "gn", "224"],
|
|
154
|
+
["Guinea-Bissau (Guiné Bissau)", "gw", "245"],
|
|
155
|
+
["Guyana", "gy", "592"],
|
|
156
|
+
["Haiti", "ht", "509"],
|
|
157
|
+
["Honduras", "hn", "504"],
|
|
158
|
+
["Hong Kong (香港)", "hk", "852"],
|
|
159
|
+
["Hungary (Magyarország)", "hu", "36"],
|
|
160
|
+
["Iceland (Ísland)", "is", "354"],
|
|
161
|
+
["India (भारत)", "in", "91"],
|
|
162
|
+
["Indonesia", "id", "62"],
|
|
163
|
+
["Iran (ایران)", "ir", "98"],
|
|
164
|
+
["Iraq (العراق)", "iq", "964"],
|
|
165
|
+
["Ireland", "ie", "353"],
|
|
166
|
+
["Isle of Man", "im", "44", 2],
|
|
167
|
+
["Israel (ישראל)", "il", "972"],
|
|
168
|
+
["Italy (Italia)", "it", "39", 0],
|
|
169
|
+
["Jamaica", "jm", "1876"],
|
|
170
|
+
["Japan (日本)", "jp", "81"],
|
|
171
|
+
["Jersey", "je", "44", 3],
|
|
172
|
+
["Jordan (الأردن)", "jo", "962"],
|
|
173
|
+
["Kazakhstan (Казахстан)", "kz", "7", 1],
|
|
174
|
+
["Kenya", "ke", "254"],
|
|
175
|
+
["Kiribati", "ki", "686"],
|
|
176
|
+
["Kosovo", "xk", "383"],
|
|
177
|
+
["Kuwait (الكويت)", "kw", "965"],
|
|
178
|
+
["Kyrgyzstan (Кыргызстан)", "kg", "996"],
|
|
179
|
+
["Laos (ລາວ)", "la", "856"],
|
|
180
|
+
["Latvia (Latvija)", "lv", "371"],
|
|
181
|
+
["Lebanon (لبنان)", "lb", "961"],
|
|
182
|
+
["Lesotho", "ls", "266"],
|
|
183
|
+
["Liberia", "lr", "231"],
|
|
184
|
+
["Libya (ليبيا)", "ly", "218"],
|
|
185
|
+
["Liechtenstein", "li", "423"],
|
|
186
|
+
["Lithuania (Lietuva)", "lt", "370"],
|
|
187
|
+
["Luxembourg", "lu", "352"],
|
|
188
|
+
["Macau (澳門)", "mo", "853"],
|
|
189
|
+
["Macedonia (FYROM) (Македонија)", "mk", "389"],
|
|
190
|
+
["Madagascar (Madagasikara)", "mg", "261"],
|
|
191
|
+
["Malawi", "mw", "265"],
|
|
192
|
+
["Malaysia", "my", "60"],
|
|
193
|
+
["Maldives", "mv", "960"],
|
|
194
|
+
["Mali", "ml", "223"],
|
|
195
|
+
["Malta", "mt", "356"],
|
|
196
|
+
["Marshall Islands", "mh", "692"],
|
|
197
|
+
["Martinique", "mq", "596"],
|
|
198
|
+
["Mauritania (موريتانيا)", "mr", "222"],
|
|
199
|
+
["Mauritius (Moris)", "mu", "230"],
|
|
200
|
+
["Mayotte", "yt", "262", 1],
|
|
201
|
+
["Mexico (México)", "mx", "52"],
|
|
202
|
+
["Micronesia", "fm", "691"],
|
|
203
|
+
["Moldova (Republica Moldova)", "md", "373"],
|
|
204
|
+
["Monaco", "mc", "377"],
|
|
205
|
+
["Mongolia (Монгол)", "mn", "976"],
|
|
206
|
+
["Montenegro (Crna Gora)", "me", "382"],
|
|
207
|
+
["Montserrat", "ms", "1664"],
|
|
208
|
+
["Morocco (المغرب)", "ma", "212", 0],
|
|
209
|
+
["Mozambique (Moçambique)", "mz", "258"],
|
|
210
|
+
["Myanmar (Burma) (မြန်မာ)", "mm", "95"],
|
|
211
|
+
["Namibia (Namibië)", "na", "264"],
|
|
212
|
+
["Nauru", "nr", "674"],
|
|
213
|
+
["Nepal (नेपाल)", "np", "977"],
|
|
214
|
+
["Netherlands (Nederland)", "nl", "31"],
|
|
215
|
+
["New Caledonia (Nouvelle-Calédonie)", "nc", "687"],
|
|
216
|
+
["New Zealand", "nz", "64"],
|
|
217
|
+
["Nicaragua", "ni", "505"],
|
|
218
|
+
["Niger (Nijar)", "ne", "227"],
|
|
219
|
+
["Nigeria", "ng", "234"],
|
|
220
|
+
["Niue", "nu", "683"],
|
|
221
|
+
["Norfolk Island", "nf", "672"],
|
|
222
|
+
["North Korea (조선 민주주의 인민 공화국)", "kp", "850"],
|
|
223
|
+
["Northern Mariana Islands", "mp", "1670"],
|
|
224
|
+
["Norway (Norge)", "no", "47", 0],
|
|
225
|
+
["Oman (عُمان)", "om", "968"],
|
|
226
|
+
["Pakistan (پاکستان)", "pk", "92"],
|
|
227
|
+
["Palau", "pw", "680"],
|
|
228
|
+
["Palestine (فلسطين)", "ps", "970"],
|
|
229
|
+
["Panama (Panamá)", "pa", "507"],
|
|
230
|
+
["Papua New Guinea", "pg", "675"],
|
|
231
|
+
["Paraguay", "py", "595"],
|
|
232
|
+
["Peru (Perú)", "pe", "51"],
|
|
233
|
+
["Philippines", "ph", "63"],
|
|
234
|
+
["Poland (Polska)", "pl", "48"],
|
|
235
|
+
["Portugal", "pt", "351"],
|
|
236
|
+
["Puerto Rico", "pr", "1", 3, ["787", "939"]],
|
|
237
|
+
["Qatar (قطر)", "qa", "974"],
|
|
238
|
+
["Réunion (La Réunion)", "re", "262", 0],
|
|
239
|
+
["Romania (România)", "ro", "40"],
|
|
240
|
+
["Russia (Россия)", "ru", "7", 0],
|
|
241
|
+
["Rwanda", "rw", "250"],
|
|
242
|
+
["Saint Barthélemy", "bl", "590", 1],
|
|
243
|
+
["Saint Helena", "sh", "290"],
|
|
244
|
+
["Saint Kitts and Nevis", "kn", "1869"],
|
|
245
|
+
["Saint Lucia", "lc", "1758"],
|
|
246
|
+
["Saint Martin (Saint-Martin (partie française))", "mf", "590", 2],
|
|
247
|
+
["Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508"],
|
|
248
|
+
["Saint Vincent and the Grenadines", "vc", "1784"],
|
|
249
|
+
["Samoa", "ws", "685"],
|
|
250
|
+
["San Marino", "sm", "378"],
|
|
251
|
+
["São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239"],
|
|
252
|
+
["Saudi Arabia (المملكة العربية السعودية)", "sa", "966"],
|
|
253
|
+
["Senegal (Sénégal)", "sn", "221"],
|
|
254
|
+
["Serbia (Србија)", "rs", "381"],
|
|
255
|
+
["Seychelles", "sc", "248"],
|
|
256
|
+
["Sierra Leone", "sl", "232"],
|
|
257
|
+
["Singapore", "sg", "65"],
|
|
258
|
+
["Sint Maarten", "sx", "1721"],
|
|
259
|
+
["Slovakia (Slovensko)", "sk", "421"],
|
|
260
|
+
["Slovenia (Slovenija)", "si", "386"],
|
|
261
|
+
["Solomon Islands", "sb", "677"],
|
|
262
|
+
["Somalia (Soomaaliya)", "so", "252"],
|
|
263
|
+
["South Africa", "za", "27"],
|
|
264
|
+
["South Korea (대한민국)", "kr", "82"],
|
|
265
|
+
["South Sudan (جنوب السودان)", "ss", "211"],
|
|
266
|
+
["Spain (España)", "es", "34"],
|
|
267
|
+
["Sri Lanka (ශ්රී ලංකාව)", "lk", "94"],
|
|
268
|
+
["Sudan (السودان)", "sd", "249"],
|
|
269
|
+
["Suriname", "sr", "597"],
|
|
270
|
+
["Svalbard and Jan Mayen", "sj", "47", 1],
|
|
271
|
+
["Swaziland", "sz", "268"],
|
|
272
|
+
["Sweden (Sverige)", "se", "46"],
|
|
273
|
+
["Switzerland (Schweiz)", "ch", "41"],
|
|
274
|
+
["Syria (سوريا)", "sy", "963"],
|
|
275
|
+
["Taiwan (台灣)", "tw", "886"],
|
|
276
|
+
["Tajikistan", "tj", "992"],
|
|
277
|
+
["Tanzania", "tz", "255"],
|
|
278
|
+
["Thailand (ไทย)", "th", "66"],
|
|
279
|
+
["Timor-Leste", "tl", "670"],
|
|
280
|
+
["Togo", "tg", "228"],
|
|
281
|
+
["Tokelau", "tk", "690"],
|
|
282
|
+
["Tonga", "to", "676"],
|
|
283
|
+
["Trinidad and Tobago", "tt", "1868"],
|
|
284
|
+
["Tunisia (تونس)", "tn", "216"],
|
|
285
|
+
["Turkey (Türkiye)", "tr", "90"],
|
|
286
|
+
["Turkmenistan", "tm", "993"],
|
|
287
|
+
["Turks and Caicos Islands", "tc", "1649"],
|
|
288
|
+
["Tuvalu", "tv", "688"],
|
|
289
|
+
["U.S. Virgin Islands", "vi", "1340"],
|
|
290
|
+
["Uganda", "ug", "256"],
|
|
291
|
+
["Ukraine (Україна)", "ua", "380"],
|
|
292
|
+
["United Arab Emirates (الإمارات العربية المتحدة)", "ae", "971"],
|
|
293
|
+
["United Kingdom", "gb", "44", 0],
|
|
294
|
+
["United States", "us", "1", 0],
|
|
295
|
+
["Uruguay", "uy", "598"],
|
|
296
|
+
["Uzbekistan (Oʻzbekiston)", "uz", "998"],
|
|
297
|
+
["Vanuatu", "vu", "678"],
|
|
298
|
+
["Vatican City (Città del Vaticano)", "va", "39", 1],
|
|
299
|
+
["Venezuela", "ve", "58"],
|
|
300
|
+
["Vietnam (Việt Nam)", "vn", "84"],
|
|
301
|
+
["Wallis and Futuna (Wallis-et-Futuna)", "wf", "681"],
|
|
302
|
+
["Western Sahara (الصحراء الغربية)", "eh", "212", 1],
|
|
303
|
+
["Yemen (اليمن)", "ye", "967"],
|
|
304
|
+
["Zambia", "zm", "260"],
|
|
305
|
+
["Zimbabwe", "zw", "263"],
|
|
306
|
+
["Åland Islands", "ax", "358", 1]
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
export default allCountries.map(country => ({
|
|
310
|
+
name: country[0],
|
|
311
|
+
iso2: country[1].toUpperCase(),
|
|
312
|
+
dialCode: country[2],
|
|
313
|
+
priority: country[3] || 0,
|
|
314
|
+
areaCodes: country[4] || null
|
|
315
|
+
}));
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="$styles()" :class="classes()">
|
|
3
|
+
<div class="country-code">
|
|
4
|
+
<v-select
|
|
5
|
+
v-model="countryCode"
|
|
6
|
+
:items="sortedCountries"
|
|
7
|
+
:disabled="spec.readOnly"
|
|
8
|
+
:outlined="$classes().includes('outlined')"
|
|
9
|
+
:rounded="$classes().includes('rounded')"
|
|
10
|
+
:dense="$classes().includes('dense')"
|
|
11
|
+
item-text="name"
|
|
12
|
+
item-value="iso2"
|
|
13
|
+
return-object
|
|
14
|
+
@change="onChangeCountryCode"
|
|
15
|
+
>
|
|
16
|
+
<template v-slot:selection>
|
|
17
|
+
<div :class="activeCountry.iso2.toLowerCase()" class="country_flag" />
|
|
18
|
+
</template>
|
|
19
|
+
<template v-slot:item="data">
|
|
20
|
+
<span :class="data.item.iso2.toLowerCase()" class="country_flag" />
|
|
21
|
+
<span>{{ data.item.name }} {{ `+${data.item.dialCode}` }}</span>
|
|
22
|
+
</template>
|
|
23
|
+
</v-select>
|
|
24
|
+
</div>
|
|
25
|
+
<v-text-field
|
|
26
|
+
:id="inputId"
|
|
27
|
+
ref="input"
|
|
28
|
+
v-model="phone"
|
|
29
|
+
class="tel"
|
|
30
|
+
:label="spec.label"
|
|
31
|
+
:name="fieldName"
|
|
32
|
+
:value="spec.value"
|
|
33
|
+
:hint="spec.hint"
|
|
34
|
+
:placeholder="spec.placeholder"
|
|
35
|
+
:maxlength="spec.maxLength || 25"
|
|
36
|
+
:disabled="spec.readOnly"
|
|
37
|
+
type="tel"
|
|
38
|
+
:rules="rules"
|
|
39
|
+
:prefix="spec.leftText"
|
|
40
|
+
:suffix="spec.rightText"
|
|
41
|
+
:outlined="$classes().includes('outlined')"
|
|
42
|
+
:dense="$classes().includes('dense')"
|
|
43
|
+
:rounded="$classes().includes('rounded')"
|
|
44
|
+
:autofocus="spec.autoFocus || false"
|
|
45
|
+
validate-on-blur
|
|
46
|
+
>
|
|
47
|
+
</v-text-field>
|
|
48
|
+
<input
|
|
49
|
+
v-if="spec.readOnly"
|
|
50
|
+
type="hidden"
|
|
51
|
+
:name="fieldName"
|
|
52
|
+
:value="phone"
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script>
|
|
58
|
+
import PhoneNumber from "awesome-phonenumber";
|
|
59
|
+
import allCountries from "./countries";
|
|
60
|
+
|
|
61
|
+
function getCountryByIp() {
|
|
62
|
+
return fetch("https://ip2c.org/s")
|
|
63
|
+
.then(response => response.text())
|
|
64
|
+
.then(response => {
|
|
65
|
+
const result = (response || "").toString();
|
|
66
|
+
if (!result || result[0] !== "1") {
|
|
67
|
+
throw new Error("unable to fetch the country");
|
|
68
|
+
}
|
|
69
|
+
return result.substr(2, 2);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default {
|
|
74
|
+
props: {
|
|
75
|
+
spec: {
|
|
76
|
+
type: Object,
|
|
77
|
+
required: true
|
|
78
|
+
},
|
|
79
|
+
rules: {
|
|
80
|
+
type: Array,
|
|
81
|
+
default: () => [
|
|
82
|
+
v =>
|
|
83
|
+
!v ||
|
|
84
|
+
/^\+[1-9]([0-9\(\)\-\ ]*)$/.test(v) ||
|
|
85
|
+
"Must be a valid international phone number with prefix (e.g. +1 416 555 0134)"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
disableFetchingCountry: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: () => false
|
|
91
|
+
},
|
|
92
|
+
mode: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: () => ""
|
|
95
|
+
},
|
|
96
|
+
allCountries: {
|
|
97
|
+
type: Array,
|
|
98
|
+
default: () => allCountries
|
|
99
|
+
},
|
|
100
|
+
preferredCountries: {
|
|
101
|
+
type: Array,
|
|
102
|
+
default: () => []
|
|
103
|
+
},
|
|
104
|
+
inputId: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: () => ""
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
data() {
|
|
110
|
+
return {
|
|
111
|
+
phone: "",
|
|
112
|
+
activeCountry: { iso2: "" },
|
|
113
|
+
selectedIndex: null,
|
|
114
|
+
countryCode: null
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
computed: {
|
|
118
|
+
parsedMode() {
|
|
119
|
+
if (this.mode) {
|
|
120
|
+
if (!["international", "national"].includes(this.mode)) {
|
|
121
|
+
console.error('Invalid value of prop "mode"');
|
|
122
|
+
} else {
|
|
123
|
+
return this.mode;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!this.phone || this.phone[0] !== "+") {
|
|
127
|
+
return "national";
|
|
128
|
+
}
|
|
129
|
+
return "international";
|
|
130
|
+
},
|
|
131
|
+
sortedCountries() {
|
|
132
|
+
// Sort by preferred countries
|
|
133
|
+
const preferredCountries = this.getCountries(
|
|
134
|
+
this.preferredCountries
|
|
135
|
+
).map(country => ({ ...country, preferred: true }));
|
|
136
|
+
return [...preferredCountries, ...this.allCountries];
|
|
137
|
+
},
|
|
138
|
+
phoneObject() {
|
|
139
|
+
const result = PhoneNumber(
|
|
140
|
+
this.phone || "",
|
|
141
|
+
this.activeCountry.iso2
|
|
142
|
+
).toJSON();
|
|
143
|
+
Object.assign(result, {
|
|
144
|
+
isValid: result.valid,
|
|
145
|
+
country: this.activeCountry
|
|
146
|
+
});
|
|
147
|
+
if (!this.phone) {
|
|
148
|
+
return {
|
|
149
|
+
...result,
|
|
150
|
+
number: {
|
|
151
|
+
input: ""
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
},
|
|
157
|
+
phoneText() {
|
|
158
|
+
let key = "input";
|
|
159
|
+
if (this.phoneObject.valid) {
|
|
160
|
+
key = this.parsedMode;
|
|
161
|
+
}
|
|
162
|
+
return this.phoneObject.number[key] || "";
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
watch: {
|
|
166
|
+
phone(val) {
|
|
167
|
+
if (val) {
|
|
168
|
+
if (val[0] === "+") {
|
|
169
|
+
const code = PhoneNumber(val).getRegionCode();
|
|
170
|
+
if (code) {
|
|
171
|
+
this.activeCountry = this.findCountry(code) || this.activeCountry;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
mounted() {
|
|
178
|
+
this.initializeCountry()
|
|
179
|
+
.then(() => {
|
|
180
|
+
if (!this.phone && this.activeCountry.dialCode) {
|
|
181
|
+
this.phone = `+${this.activeCountry.dialCode}`;
|
|
182
|
+
}
|
|
183
|
+
this.countryCode = this.activeCountry;
|
|
184
|
+
})
|
|
185
|
+
.catch(console.error);
|
|
186
|
+
},
|
|
187
|
+
created() {
|
|
188
|
+
if (this.spec.value) {
|
|
189
|
+
this.phone = this.spec.value.trim();
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
methods: {
|
|
193
|
+
classes() {
|
|
194
|
+
return this.$classes().concat(["g-text-field--hintless", "fields-phone"]);
|
|
195
|
+
},
|
|
196
|
+
initializeCountry() {
|
|
197
|
+
return new Promise(resolve => {
|
|
198
|
+
// 1. If the phone included prefix (+12), try to get the country and set it
|
|
199
|
+
if (this.phone && this.phone[0] === "+") {
|
|
200
|
+
const activeCountry = PhoneNumber(this.phone).getRegionCode();
|
|
201
|
+
if (activeCountry) {
|
|
202
|
+
this.choose(activeCountry);
|
|
203
|
+
resolve();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// 2. Use default country if passed from parent
|
|
208
|
+
if (this.spec.defaultCountry) {
|
|
209
|
+
const defaultCountry = this.findCountry(this.spec.defaultCountry);
|
|
210
|
+
if (defaultCountry) {
|
|
211
|
+
this.choose(defaultCountry);
|
|
212
|
+
resolve();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const fallbackCountry =
|
|
217
|
+
this.findCountry(this.preferredCountries[0]) || this.allCountries[0];
|
|
218
|
+
// 3. Check if fetching country based on user's IP is allowed, set it as the default country
|
|
219
|
+
if (!this.disableFetchingCountry) {
|
|
220
|
+
getCountryByIp()
|
|
221
|
+
.then(res => {
|
|
222
|
+
if (this.phone === "") {
|
|
223
|
+
this.activeCountry =
|
|
224
|
+
this.findCountry(res) || this.activeCountry;
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
.catch(error => {
|
|
228
|
+
console.warn(error);
|
|
229
|
+
// 4. Use the first country from preferred list (if available) or all countries list
|
|
230
|
+
this.choose(fallbackCountry);
|
|
231
|
+
})
|
|
232
|
+
.finally(() => {
|
|
233
|
+
resolve();
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
// 4. Use the first country from preferred list (if available) or all countries list
|
|
237
|
+
this.choose(fallbackCountry);
|
|
238
|
+
resolve();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
// Get ISO2 code from a list of countries
|
|
243
|
+
getCountries(list = []) {
|
|
244
|
+
return list
|
|
245
|
+
.map(countryCode => this.findCountry(countryCode))
|
|
246
|
+
.filter(Boolean);
|
|
247
|
+
},
|
|
248
|
+
findCountry(iso = "") {
|
|
249
|
+
return this.allCountries.find(
|
|
250
|
+
country => country.iso2 === iso.toUpperCase()
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
getItemClass(index, iso2) {
|
|
254
|
+
const highlighted = this.selectedIndex === index;
|
|
255
|
+
const lastPreferred = index === this.preferredCountries.length - 1;
|
|
256
|
+
const preferred = this.preferredCountries.some(
|
|
257
|
+
c => c.toUpperCase() === iso2
|
|
258
|
+
);
|
|
259
|
+
return {
|
|
260
|
+
highlighted,
|
|
261
|
+
"last-preferred": lastPreferred,
|
|
262
|
+
preferred
|
|
263
|
+
};
|
|
264
|
+
},
|
|
265
|
+
choose(country) {
|
|
266
|
+
this.activeCountry = country || this.activeCountry || {};
|
|
267
|
+
if (
|
|
268
|
+
this.phone &&
|
|
269
|
+
this.phone[0] === "+" &&
|
|
270
|
+
this.activeCountry.iso2 &&
|
|
271
|
+
this.phoneObject.number.significant
|
|
272
|
+
) {
|
|
273
|
+
// If country is selected & the field has a valid international phone number
|
|
274
|
+
this.phone = PhoneNumber(
|
|
275
|
+
this.phoneObject.number.significant,
|
|
276
|
+
this.activeCountry.iso2
|
|
277
|
+
).getNumber("international");
|
|
278
|
+
} else if (
|
|
279
|
+
country &&
|
|
280
|
+
this.phone &&
|
|
281
|
+
(!this.phoneObject.number.significant || this.phone[0] !== "+")
|
|
282
|
+
) {
|
|
283
|
+
// If a new country is selected & the field has NO valid international phone number
|
|
284
|
+
this.phone = `+${country.dialCode}`;
|
|
285
|
+
} else if (country && !this.phone) {
|
|
286
|
+
// If a new country is selected & the field has NO value
|
|
287
|
+
this.phone = `+${country.dialCode}`;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
reset() {
|
|
291
|
+
this.selectedIndex = this.sortedCountries
|
|
292
|
+
.map(c => c.iso2)
|
|
293
|
+
.indexOf(this.activeCountry.iso2);
|
|
294
|
+
},
|
|
295
|
+
onChangeCountryCode() {
|
|
296
|
+
this.choose(this.countryCode, true);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
</script>
|
|
301
|
+
|
|
302
|
+
<style src="./sprite.css"></style>
|
|
303
|
+
<style lang="scss">
|
|
304
|
+
.g-text-field--hintless {
|
|
305
|
+
.v-text-field {
|
|
306
|
+
.v-text-field__details {
|
|
307
|
+
min-height: 0;
|
|
308
|
+
margin-bottom: 0;
|
|
309
|
+
.v-messages__message {
|
|
310
|
+
min-height: 0;
|
|
311
|
+
line-height: 14px;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
.country_flag {
|
|
317
|
+
margin-right: 8px;
|
|
318
|
+
}
|
|
319
|
+
.fields-phone {
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
.country-code {
|
|
323
|
+
width: 75px;
|
|
324
|
+
}
|
|
325
|
+
li.last-preferred {
|
|
326
|
+
border-bottom: 1px solid #cacaca;
|
|
327
|
+
}
|
|
328
|
+
.v-text-field {
|
|
329
|
+
.v-select__selections {
|
|
330
|
+
position: relative;
|
|
331
|
+
.country_flag {
|
|
332
|
+
position: absolute;
|
|
333
|
+
margin-left: 18px;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
&--outlined {
|
|
337
|
+
.v-select__selections {
|
|
338
|
+
.country_flag {
|
|
339
|
+
margin-left: auto;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
.fields-phone.outlined .country-code {
|
|
346
|
+
margin-right: 6px;
|
|
347
|
+
}
|
|
348
|
+
</style>
|