@ozdao/prometheus-framework 0.2.35 → 0.2.36
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.css +1 -1
- package/dist/prometheus-framework.cjs.js +18 -19
- package/dist/prometheus-framework.es.js +803 -1028
- package/package.json +1 -1
- package/src/components/Button/Button.vue +26 -19
- package/src/components/FieldBig/FieldBig.vue +1 -1
- package/src/components/FieldPhone/FieldPhone.vue +55 -304
- package/src/components/FieldPhone/FieldPhone2.vue +671 -0
- package/src/components/FieldPhone/click-outside.js +16 -11
- package/src/components/Footer/Footer.vue +4 -4
- package/src/components/Header/Header.vue +2 -1
- package/src/components/Select/Select.vue +2 -1
- package/src/modules/chats/components/sections/ChatWindow.vue +3 -1
- package/src/modules/chats/store/chat.store.js +1 -3
- package/src/modules/events/components/pages/EditEvent.vue +2 -1
- package/src/modules/events/components/pages/Event.vue +8 -2
- package/src/modules/events/components/sections/SectionMainGuest.vue +1 -1
- package/src/modules/events/components/sections/SectionSpecialGuests.vue +0 -1
- package/src/modules/events/store/events.js +23 -3
- package/src/modules/globals/mixins/mixins.js +33 -2
- package/src/modules/globals/store/globals.js +1 -0
- package/src/modules/landing/components/sections/HeroGovernance.vue +156 -0
- package/src/modules/marketplace/components/sections/Filters.vue +3 -0
- package/src/modules/marketplace/router/marketplace.js +1 -0
- package/src/modules/orders/components/blocks/StatusHistory.vue +8 -3
- package/src/modules/orders/components/pages/EditOrder.vue +9 -11
- package/src/modules/orders/components/pages/FormOrder.vue +58 -46
- package/src/modules/orders/components/pages/Order.vue +63 -42
- package/src/modules/orders/components/sections/FormOrderDetails.vue +50 -18
- package/src/modules/orders/controllers/orders.controller.js +10 -1
- package/src/modules/orders/models/order.model.js +1 -0
- package/src/modules/orders/store/orders.js +21 -27
- package/src/modules/orders/store/shopcart.js +14 -2
- package/src/modules/organizations/components/sections/DetailsTab.vue +2 -2
- package/src/modules/products/components/sections/FilterProducts.vue +3 -4
- package/src/modules/products/components/sections/HeroRecommendation.vue +29 -2
- package/src/modules/products/components/sections/SectionProduct.vue +14 -9
- package/src/modules/products/controllers/products.controller.js +26 -17
- package/src/modules/products/routes/products.routes.js +6 -6
- package/src/modules/products/store/products.js +10 -10
- package/src/styles/config.scss +10 -3
package/package.json
CHANGED
@@ -6,6 +6,17 @@
|
|
6
6
|
type: Function,
|
7
7
|
default: async () => { console.log('Button click.') }
|
8
8
|
},
|
9
|
+
text: {
|
10
|
+
type: Object,
|
11
|
+
default: (textComponent) => {
|
12
|
+
console.log(textComponent)
|
13
|
+
return textComponent = {
|
14
|
+
...textComponent.text,
|
15
|
+
success: '✔',
|
16
|
+
error: '✖'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
9
20
|
counter: {
|
10
21
|
type: Object
|
11
22
|
},
|
@@ -31,12 +42,13 @@
|
|
31
42
|
},
|
32
43
|
})
|
33
44
|
|
45
|
+
|
46
|
+
|
34
47
|
const button = ref(null);
|
35
48
|
const error = ref(null);
|
36
49
|
const loading = ref(false);
|
37
50
|
const finished = ref(false);
|
38
51
|
|
39
|
-
|
40
52
|
async function Submit() {
|
41
53
|
button.value.style['pointer-events'] = 'none';
|
42
54
|
error.value = null;
|
@@ -45,7 +57,7 @@
|
|
45
57
|
// Функция для сброса состояния кнопки.
|
46
58
|
const resetButton = () => {
|
47
59
|
if (button.value) {
|
48
|
-
button.value.classList.replace('bg-
|
60
|
+
button.value.classList.replace('bg-fifth', 'bg-main');
|
49
61
|
button.value.style.pointerEvents = 'auto';
|
50
62
|
loading.value = false;
|
51
63
|
finished.value = false;
|
@@ -55,13 +67,15 @@
|
|
55
67
|
|
56
68
|
try {
|
57
69
|
await props.submit();
|
58
|
-
|
70
|
+
|
71
|
+
button.value.classList.replace('bg-main', 'bg-fifth');
|
59
72
|
|
60
73
|
|
61
74
|
loading.value = false;
|
75
|
+
|
62
76
|
// Используем функцию сброса состояния кнопки здесь.
|
63
77
|
if (props.showSucces) {
|
64
|
-
|
78
|
+
finished.value = true;
|
65
79
|
setTimeout(resetButton, 500);
|
66
80
|
} else {
|
67
81
|
resetButton();
|
@@ -73,7 +87,7 @@
|
|
73
87
|
} catch (err) {
|
74
88
|
// Если возникла ошибка, мы изменяем стили и устанавливаем сообщение об ошибке.
|
75
89
|
button.value.classList.replace('bg-main', 'bg-fourth-nano');
|
76
|
-
error.value =
|
90
|
+
error.value = props.error;
|
77
91
|
|
78
92
|
// После задержки снова сбрасываем состояние кнопки.
|
79
93
|
setTimeout(() => {
|
@@ -88,15 +102,13 @@
|
|
88
102
|
|
89
103
|
<template>
|
90
104
|
<button @click.stop="Submit" :disabled="validation" ref="button" class="button">
|
91
|
-
|
92
|
-
|
105
|
+
<transition name="moveFromTopAbsolute">
|
106
|
+
<!-- Slot -->
|
93
107
|
<span v-if="!loading && !error && !finished || !showLoader">
|
94
108
|
<slot></slot>
|
95
109
|
</span>
|
96
|
-
|
97
|
-
|
98
|
-
<transition name="TransitionTranslateY-small">
|
99
|
-
<span v-if="loading && !error && showLoader" class="loading">
|
110
|
+
<!-- Loading Circle Animation -->
|
111
|
+
<span v-else-if="loading && !error && showLoader" class="loading">
|
100
112
|
<svg class="i-regular" width="135" height="140" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="#fff">
|
101
113
|
<rect y="10" width="15" height="120" rx="6"> <animate attributeName="height" begin="0.5s" dur="1s" values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear" repeatCount="indefinite" /> <animate attributeName="y" begin="0.5s" dur="1s" values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear" repeatCount="indefinite"/> </rect>
|
102
114
|
<rect x="30" y="10" width="15" height="120" rx="6"> <animate attributeName="height" begin="0.25s" dur="1s" values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear" repeatCount="indefinite" /> <animate attributeName="y" begin="0.25s" dur="1s" values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear" repeatCount="indefinite"/> </rect>
|
@@ -105,14 +117,9 @@
|
|
105
117
|
<rect x="120" y="10" width="15" height="120" rx="6"> <animate attributeName="height" begin="0.5s" dur="1s" values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear" repeatCount="indefinite" /> <animate attributeName="y" begin="0.5s" dur="1s" values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear" repeatCount="indefinite"/> </rect>
|
106
118
|
</svg>
|
107
119
|
</span>
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
<span v-if="finished && showSucces" class="loading t-white">✔</span>
|
112
|
-
</transition>
|
113
|
-
<!-- Error if not finished -->
|
114
|
-
<transition name="TransitionTranslateY-small">
|
115
|
-
<span v-if="error" class="error">{{ error }}</span>
|
120
|
+
<span v-else-if="finished && showSucces" class="t-semi loading t-black">{{text.success}}</span>
|
121
|
+
<!-- Error if not finished -->
|
122
|
+
<span v-else-if="error" class="error">{{ error }}</span>
|
116
123
|
</transition>
|
117
124
|
<!-- Counter -->
|
118
125
|
<p v-if="counter" class="button-counter">{{counter}}</p>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
@blur="checkInput"
|
10
10
|
class="w-100 t-semi uppercase pd-small p-big"
|
11
11
|
/>
|
12
|
-
<button v-if="action" @click="emitAction" class="w-
|
12
|
+
<button v-if="action" @click="emitAction" class="w-max hover-bg-black hover-t-white t-black bg-main button" v-html="action"/>
|
13
13
|
</div>
|
14
14
|
</template>
|
15
15
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<script>
|
2
2
|
import { defineComponent } from 'vue';
|
3
3
|
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
4
|
+
|
4
5
|
import utils, { getCountry, setCaretPosition } from './utils';
|
6
|
+
|
5
7
|
import clickOutside from './click-outside';
|
6
8
|
|
7
9
|
function getDefault(key) {
|
@@ -13,241 +15,44 @@
|
|
13
15
|
}
|
14
16
|
|
15
17
|
export default /*#__PURE__*/defineComponent({
|
16
|
-
name: 'Vue3ReactiveTelInput',
|
18
|
+
name: 'Vue3ReactiveTelInput',
|
17
19
|
directives: {
|
18
20
|
clickOutside,
|
19
21
|
},
|
20
22
|
props: {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
},
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
},
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
},
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
},
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
default: '',
|
55
|
-
},
|
56
|
-
/**
|
57
|
-
* class assign when the input number is invalid belong to the country code
|
58
|
-
*/
|
59
|
-
badInputClass: {
|
60
|
-
type: [String, Array, Object],
|
61
|
-
default: '',
|
62
|
-
},
|
63
|
-
/**
|
64
|
-
* class assign when the input number is valid belong to the country code
|
65
|
-
*/
|
66
|
-
goodInputClass: {
|
67
|
-
type: [String, Array, Object],
|
68
|
-
default: '',
|
69
|
-
},
|
70
|
-
/**
|
71
|
-
* style assign when the input number is invalid belong to the country code
|
72
|
-
*/
|
73
|
-
badInputStyle: {
|
74
|
-
type: [String, Array, Object],
|
75
|
-
default: '',
|
76
|
-
},
|
77
|
-
/**
|
78
|
-
* style assign when the input number is valid belong to the country code
|
79
|
-
*/
|
80
|
-
goodInputStyle: {
|
81
|
-
type: [String, Array, Object],
|
82
|
-
default: '',
|
83
|
-
},
|
84
|
-
/**
|
85
|
-
* list of all contries
|
86
|
-
*/
|
87
|
-
allCountries: {
|
88
|
-
type: Array,
|
89
|
-
default: () => getDefault('allCountries'),
|
90
|
-
},
|
91
|
-
/**
|
92
|
-
* flag to know if the value will be automatically formatted
|
93
|
-
*/
|
94
|
-
autoFormat: {
|
95
|
-
type: Boolean,
|
96
|
-
default: () => getDefault('autoFormat'),
|
97
|
-
},
|
98
|
-
validation: {
|
99
|
-
type: [Boolean,Object],
|
100
|
-
default: false,
|
101
|
-
},
|
102
|
-
/**
|
103
|
-
* customized validation RegExp or flag
|
104
|
-
*/
|
105
|
-
customValidate: {
|
106
|
-
type: [Boolean, RegExp],
|
107
|
-
default: () => getDefault('customValidate'),
|
108
|
-
},
|
109
|
-
/**
|
110
|
-
* a default country
|
111
|
-
*/
|
112
|
-
defaultCountry: {
|
113
|
-
// Default country code, ie: 'AU'
|
114
|
-
// Will override the current country of user
|
115
|
-
type: String,
|
116
|
-
default: () => getDefault('defaultCountry'),
|
117
|
-
},
|
118
|
-
/**
|
119
|
-
* flag defining whether the input must be disabled
|
120
|
-
*/
|
121
|
-
disabled: {
|
122
|
-
type: Boolean,
|
123
|
-
default: () => getDefault('disabled'),
|
124
|
-
},
|
125
|
-
/**
|
126
|
-
* flag definir if we'll automatically choose a default country
|
127
|
-
*/
|
128
|
-
autoDefaultCountry: {
|
129
|
-
type: Boolean,
|
130
|
-
default: () => getDefault('autoDefaultCountry'),
|
131
|
-
},
|
132
|
-
/**
|
133
|
-
* object of dropdown options
|
134
|
-
*/
|
135
|
-
dropdownOptions: {
|
136
|
-
type: Object,
|
137
|
-
default: () => getDefault('dropdownOptions'),
|
138
|
-
},
|
139
|
-
/**
|
140
|
-
* list of countries to ignore
|
141
|
-
*/
|
142
|
-
ignoredCountries: {
|
143
|
-
type: Array,
|
144
|
-
default: () => getDefault('ignoredCountries'),
|
145
|
-
},
|
146
|
-
/**
|
147
|
-
* object of input options
|
148
|
-
*/
|
149
|
-
inputOptions: {
|
150
|
-
type: Object,
|
151
|
-
default: () => getDefault('inputOptions'),
|
152
|
-
},
|
153
|
-
/**
|
154
|
-
* valid message to display
|
155
|
-
*/
|
156
|
-
invalidMsg: {
|
157
|
-
type: String,
|
158
|
-
default: () => getDefault('invalidMsg'),
|
159
|
-
},
|
160
|
-
/**
|
161
|
-
* the mode of the input
|
162
|
-
*/
|
163
|
-
mode: {
|
164
|
-
type: String,
|
165
|
-
default: () => getDefault('mode'),
|
166
|
-
},
|
167
|
-
/**
|
168
|
-
* limit the giving input to only manage your list of contry
|
169
|
-
*/
|
170
|
-
onlyCountries: {
|
171
|
-
type: Array,
|
172
|
-
default: () => getDefault('onlyCountries'),
|
173
|
-
},
|
174
|
-
/**
|
175
|
-
* the list of preferred countries
|
176
|
-
*/
|
177
|
-
preferredCountries: {
|
178
|
-
type: Array,
|
179
|
-
default: () => getDefault('preferredCountries'),
|
180
|
-
},
|
181
|
-
/**
|
182
|
-
* the flag defining if the input must only content valid characters
|
183
|
-
*/
|
184
|
-
validCharactersOnly: {
|
185
|
-
type: Boolean,
|
186
|
-
default: () => getDefault('validCharactersOnly'),
|
187
|
-
},
|
188
|
-
/**
|
189
|
-
* the root default class
|
190
|
-
*/
|
191
|
-
rootClass: {
|
192
|
-
type: [String, Array, Object],
|
193
|
-
default: () => getDefault('styleClasses'),
|
194
|
-
},
|
195
|
-
/**
|
196
|
-
* the input default class
|
197
|
-
*/
|
198
|
-
inputClass: {
|
199
|
-
type: [String, Array, Object],
|
200
|
-
default: () => {return ''},
|
201
|
-
},
|
202
|
-
/**
|
203
|
-
* the div input default class
|
204
|
-
*/
|
205
|
-
divInputClass: {
|
206
|
-
type: [String, Array, Object],
|
207
|
-
default: () => {return ''},
|
208
|
-
},
|
209
|
-
/**
|
210
|
-
* the root default style
|
211
|
-
*/
|
212
|
-
rootStyle: {
|
213
|
-
type: [String, Array, Object],
|
214
|
-
default: () => {return ''},
|
215
|
-
},
|
216
|
-
/**
|
217
|
-
* the dropdown button style
|
218
|
-
*/
|
219
|
-
dropdownStyle: {
|
220
|
-
type: [String, Array, Object],
|
221
|
-
default: () => {return ''},
|
222
|
-
},
|
223
|
-
/**
|
224
|
-
* the dropdown list style
|
225
|
-
*/
|
226
|
-
listStyle: {
|
227
|
-
type: [String, Array, Object],
|
228
|
-
default: () => {return ''},
|
229
|
-
},
|
230
|
-
/**
|
231
|
-
* the input style
|
232
|
-
*/
|
233
|
-
inputStyle: {
|
234
|
-
type: [String, Array, Object],
|
235
|
-
default: () => {return ''},
|
236
|
-
},
|
237
|
-
/**
|
238
|
-
* the input id
|
239
|
-
*/
|
240
|
-
inputId: {
|
241
|
-
type: [String, Array, Object],
|
242
|
-
default: () => {return ''},
|
243
|
-
},
|
244
|
-
/**
|
245
|
-
* the input placeholder
|
246
|
-
*/
|
247
|
-
Placeholder: {
|
248
|
-
type: [String, Object, Function],
|
249
|
-
default: () => {return ''},
|
250
|
-
},
|
23
|
+
modelValue: { type: String, default: '',},
|
24
|
+
badClass: { type: [String, Array, Object], default: '', },
|
25
|
+
goodClass: { type: [String, Array, Object], default: '', },
|
26
|
+
badStyle: { type: [String, Array, Object], default: '', },
|
27
|
+
goodStyle: { type: [String, Array, Object], default: '', },
|
28
|
+
badInputClass: { type: [String, Array, Object], default: '', },
|
29
|
+
goodInputClass: { type: [String, Array, Object], default: '', },
|
30
|
+
badInputStyle: { type: [String, Array, Object], default: '', },
|
31
|
+
goodInputStyle: { type: [String, Array, Object], default: '', },
|
32
|
+
allCountries: { type: Array, default: () => getDefault('allCountries'), },
|
33
|
+
autoFormat: { type: Boolean, default: () => getDefault('autoFormat'), },
|
34
|
+
validation: { type: [Boolean, Object], default: false, },
|
35
|
+
customValidate: { type: [Boolean, RegExp], default: () => getDefault('customValidate'), },
|
36
|
+
defaultCountry: { type: String, default: () => getDefault('defaultCountry'), },
|
37
|
+
disabled: { type: Boolean, default: () => getDefault('disabled'), },
|
38
|
+
autoDefaultCountry: { type: Boolean, default: () => getDefault('autoDefaultCountry'), },
|
39
|
+
dropdownOptions: { type: Object, default: () => getDefault('dropdownOptions'), },
|
40
|
+
ignoredCountries: { type: Array, default: () => getDefault('ignoredCountries'), },
|
41
|
+
inputOptions: { type: Object, default: () => getDefault('inputOptions'), },
|
42
|
+
invalidMsg: { type: String, default: () => getDefault('invalidMsg'), },
|
43
|
+
mode: { type: String, default: () => getDefault('mode'), },
|
44
|
+
onlyCountries: { type: Array, default: () => getDefault('onlyCountries'), },
|
45
|
+
preferredCountries: { type: Array, default: () => getDefault('preferredCountries'), },
|
46
|
+
validCharactersOnly: { type: Boolean, default: () => getDefault('validCharactersOnly'), },
|
47
|
+
rootClass: { type: [String, Array, Object], default: () => getDefault('styleClasses'), },
|
48
|
+
inputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
49
|
+
divInputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
50
|
+
rootStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
51
|
+
dropdownStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
52
|
+
listStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
53
|
+
inputStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
54
|
+
inputId: { type: [String, Array, Object], default: () => {return ''}, },
|
55
|
+
Placeholder: { type: [String, Object, Function], default: () => {return ''}, },
|
251
56
|
},
|
252
57
|
data() {
|
253
58
|
return {
|
@@ -257,7 +62,6 @@
|
|
257
62
|
action: null,
|
258
63
|
amount: null,
|
259
64
|
},
|
260
|
-
// vue3-reactive-tel-data
|
261
65
|
phone: this.modelValue ? this.modelValue : '',
|
262
66
|
activeCountryCode: '',
|
263
67
|
open: false,
|
@@ -311,15 +115,6 @@
|
|
311
115
|
// console.log(this.phoneObject?this.phoneObject.number !== "":false)
|
312
116
|
this.$nextTick(() => { this.phone = oldValue; this.onInput(); });
|
313
117
|
} else {
|
314
|
-
// let dataphone;
|
315
|
-
// console.log(this.phoneObject?this.phoneObject !== "":false)
|
316
|
-
// if(this.phoneObject?this.phoneObject !== "":false)
|
317
|
-
// {
|
318
|
-
// dataphone = this.phoneObject.number
|
319
|
-
// }
|
320
|
-
// else{
|
321
|
-
// dataphone = value
|
322
|
-
// }
|
323
118
|
this.phone = value;
|
324
119
|
}
|
325
120
|
},
|
@@ -334,9 +129,9 @@
|
|
334
129
|
},
|
335
130
|
},
|
336
131
|
mounted() {
|
337
|
-
|
338
|
-
|
339
|
-
|
132
|
+
if (this.value) {
|
133
|
+
this.phone = this.value;
|
134
|
+
}
|
340
135
|
|
341
136
|
this.cleanInvalidCharacters();
|
342
137
|
|
@@ -352,7 +147,6 @@
|
|
352
147
|
.catch(console.error)
|
353
148
|
.then(() => {
|
354
149
|
this.finishMounted = true;
|
355
|
-
// console.log(123)
|
356
150
|
});
|
357
151
|
},
|
358
152
|
computed: {
|
@@ -400,18 +194,15 @@
|
|
400
194
|
},
|
401
195
|
phoneObject() {
|
402
196
|
let result;
|
197
|
+
|
403
198
|
if (this.phone?.[0] === '+') {
|
404
199
|
result = parsePhoneNumberFromString(this.phone) || {};
|
405
200
|
} else {
|
406
201
|
result = parsePhoneNumberFromString(this.phone, this.activeCountryCode) || {};
|
407
202
|
}
|
408
203
|
|
409
|
-
const {
|
410
|
-
metadata,
|
411
|
-
...phoneObject
|
412
|
-
} = result;
|
204
|
+
const { metadata, ...phoneObject } = result;
|
413
205
|
|
414
|
-
// console.log(result.isValid?result.isValid():'loll')
|
415
206
|
let valid = result.isValid?.();
|
416
207
|
let formatted = this.phone;
|
417
208
|
|
@@ -483,68 +274,28 @@
|
|
483
274
|
methods: {
|
484
275
|
resetPlaceholder() {
|
485
276
|
this.parsedPlaceholder = this.inputOptions.placeholder;
|
486
|
-
// TODO: Fix dynamicPlaceholder
|
487
|
-
// if (!this.inputOptions.dynamicPlaceholder) {
|
488
|
-
// return result;
|
489
|
-
// }
|
490
|
-
// getExamples()
|
491
|
-
// .then((results) => {
|
492
|
-
// examples = results;
|
493
|
-
// const mode = (!this.mode || this.mode === 'auto') ? 'international' : this.mode;
|
494
|
-
// const number = getExampleNumber(this.activeCountryCode.toUpperCase(), results);
|
495
|
-
// this.parsedPlaceholder = number?.format(mode.toUpperCase()) || this.placeholder;
|
496
|
-
// })
|
497
|
-
// .catch(console.error);
|
498
277
|
},
|
499
278
|
initializeCountry() {
|
500
279
|
return new Promise((resolve) => {
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
if (this.
|
505
|
-
resolve();
|
506
|
-
return;
|
507
|
-
}
|
508
|
-
/**
|
509
|
-
* 2. Use default country if passed from parent
|
510
|
-
*/
|
511
|
-
if (this.defaultCountry) {
|
512
|
-
this.choose(this.defaultCountry);
|
513
|
-
resolve();
|
514
|
-
return;
|
515
|
-
}
|
516
|
-
|
280
|
+
// 1. If the phone included prefix (i.e. +12), try to get the country and set it
|
281
|
+
if (this.phone?.[0] === '+') { resolve(); return; }
|
282
|
+
// 2. Use default country if passed from parent
|
283
|
+
if (this.defaultCountry) { this.choose(this.defaultCountry); resolve(); return; }
|
517
284
|
const fallbackCountry = this.preferredCountries[0] || this.filteredCountries[0];
|
518
|
-
|
519
|
-
* 3. Check if fetching country based on user's IP is allowed, set it as the default country
|
520
|
-
*/
|
285
|
+
// 3. Check if fetching country based on user's IP is allowed, set it as the default country
|
521
286
|
if (this.autoDefaultCountry) {
|
522
287
|
getCountry()
|
523
|
-
.then((res) => {
|
524
|
-
|
525
|
-
})
|
526
|
-
.catch((error) => {
|
527
|
-
console.warn(error);
|
528
|
-
/**
|
529
|
-
* 4. Use the first country from preferred list (if available) or all countries list
|
530
|
-
*/
|
531
|
-
this.choose(fallbackCountry);
|
532
|
-
})
|
533
|
-
.then(() => {
|
534
|
-
resolve();
|
535
|
-
});
|
288
|
+
.then((res) => { this.choose(res || this.activeCountryCode); })
|
289
|
+
.catch((error) => { console.warn(error); this.choose(fallbackCountry); })
|
290
|
+
.then(() => { resolve(); });
|
536
291
|
} else {
|
537
|
-
|
538
|
-
* 4. Use the first country from preferred list (if available) or all countries list
|
539
|
-
*/
|
292
|
+
// 4. Use the first country from preferred list (if available) or all countries list
|
540
293
|
this.choose(fallbackCountry);
|
541
294
|
resolve();
|
542
295
|
}
|
543
296
|
});
|
544
297
|
},
|
545
|
-
|
546
|
-
* Get the list of countries from the list of iso2 code
|
547
|
-
*/
|
298
|
+
// Get the list of countries from the list of iso2 code
|
548
299
|
getCountries(list = []) {
|
549
300
|
return list
|
550
301
|
.map((countryCode) => this.findCountry(countryCode))
|
@@ -628,9 +379,6 @@
|
|
628
379
|
},
|
629
380
|
onInput() {
|
630
381
|
this.$refs.input.setCustomValidity(this.phoneObject.valid ? '' : this.invalidMsg);
|
631
|
-
// Returns response.number to assign it to v-model (if being used)
|
632
|
-
// Returns full response for cases @input is used
|
633
|
-
// and parent wants to return the whole response.
|
634
382
|
this.emitInput(this.phoneObject);
|
635
383
|
},
|
636
384
|
emitInput(value) {
|
@@ -787,9 +535,11 @@
|
|
787
535
|
<!-- <div :class="[divInputClass]" > -->
|
788
536
|
<input
|
789
537
|
v-model="phone"
|
790
|
-
|
538
|
+
inputmode="numeric"
|
539
|
+
pattern="\d*"
|
791
540
|
ref="input"
|
792
541
|
:type="inputOptions.type"
|
542
|
+
|
793
543
|
:autocomplete="inputOptions.autocomplete"
|
794
544
|
:autofocus="inputOptions.autofocus"
|
795
545
|
:class="['vti__input', inputOptions.styleClasses, inputClass, Iclasses]"
|
@@ -819,6 +569,7 @@
|
|
819
569
|
</div>
|
820
570
|
</transition>
|
821
571
|
</template>
|
572
|
+
|
822
573
|
<style scoped>
|
823
574
|
.vue3-reactive-tel-input{
|
824
575
|
display:flex
|