vue-tel-input 5.6.0 → 5.7.0
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 +4 -4
- package/dist/css/component.css +1 -1
- package/dist/vue-tel-input.common.js +72 -40
- package/dist/vue-tel-input.common.js.map +1 -1
- package/dist/vue-tel-input.css +1 -1
- package/dist/vue-tel-input.umd.js +72 -40
- package/dist/vue-tel-input.umd.js.map +1 -1
- package/dist/vue-tel-input.umd.min.js +1 -1
- package/dist/vue-tel-input.umd.min.js.map +1 -1
- package/dist-modern/css/component.css +1 -1
- package/dist-modern/vue-tel-input.common.js +35 -9
- package/dist-modern/vue-tel-input.common.js.map +1 -1
- package/dist-modern/vue-tel-input.css +1 -1
- package/dist-modern/vue-tel-input.umd.js +35 -9
- package/dist-modern/vue-tel-input.umd.js.map +1 -1
- package/dist-modern/vue-tel-input.umd.min.js +1 -1
- package/dist-modern/vue-tel-input.umd.min.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img width="
|
|
2
|
+
<img width="100" alt="vue-tel-input-logo" src="https://iamstevendao.github.io/vue-tel-input/hero.png"/>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# vue-tel-input
|
|
@@ -9,7 +9,7 @@ International Telephone Input with Vue.
|
|
|
9
9
|
[](https://www.npmjs.com/package/vue-tel-input) [](https://github.com/iamstevendao/vue-tel-input)
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<img width="
|
|
12
|
+
<img width="600" alt="In-action GIF" src="https://thumbs.gfycat.com/EducatedPoliteBluefintuna-size_restricted.gif"/>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
## Documentation and Demo
|
|
@@ -87,9 +87,9 @@ Or use the component directly:
|
|
|
87
87
|
VueTelInput,
|
|
88
88
|
},
|
|
89
89
|
};
|
|
90
|
-
|
|
91
|
-
<style src="vue-tel-input/dist/vue-tel-input.css"></style>;
|
|
92
90
|
</script>
|
|
91
|
+
|
|
92
|
+
<style src="vue-tel-input/dist/vue-tel-input.css"></style>
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
### Browser
|
package/dist/css/component.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.vue-tel-input{border-radius:3px;display:flex;border:1px solid #bbb;text-align:left}.vue-tel-input.disabled .dropdown,.vue-tel-input.disabled .selection,.vue-tel-input.disabled input{cursor:no-drop}.vue-tel-input:focus-within{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);border-color:#66afe9}.vti__dropdown{display:flex;flex-direction:column;align-content:center;justify-content:center;position:relative;padding:7px;cursor:pointer}.vti__dropdown.show{max-height:300px;overflow:scroll}.vti__dropdown.disabled,.vti__dropdown.open{background-color:#f3f3f3}.vti__dropdown.disabled{cursor:no-drop;outline:none}.vti__dropdown:hover{background-color:#f3f3f3}.vti__selection{font-size:.8em;display:flex;align-items:center}.vti__selection .vti__country-code{color:#666}.vti__flag{margin-right:5px;margin-left:5px}.vti__dropdown-list{z-index:1;padding:0;margin:0;text-align:left;list-style:none;max-height:200px;overflow-y:scroll;position:absolute;left:-1px;background-color:#fff;border:1px solid #ccc;width:390px}.vti__dropdown-list.below{top:33px}.vti__dropdown-list.above{top:auto;bottom:100%}.vti__dropdown-arrow{transform:scaleY(.5);display:inline-block;color:#666}.vti__dropdown-item{cursor:pointer;padding:4px 15px}.vti__dropdown-item.highlighted{background-color:#f3f3f3}.vti__dropdown-item.last-preferred{border-bottom:1px solid #cacaca}.vti__dropdown-item .vti__flag{display:inline-block;margin-right:5px}.vti__input{border:none;border-radius:0 2px 2px 0;width:100%;outline:none;padding-left:7px}
|
|
1
|
+
.vue-tel-input{border-radius:3px;display:flex;border:1px solid #bbb;text-align:left}.vue-tel-input.disabled .dropdown,.vue-tel-input.disabled .selection,.vue-tel-input.disabled input{cursor:no-drop}.vue-tel-input:focus-within{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);border-color:#66afe9}.vti__dropdown{display:flex;flex-direction:column;align-content:center;justify-content:center;position:relative;padding:7px;cursor:pointer}.vti__dropdown.show{max-height:300px;overflow:scroll}.vti__dropdown.disabled,.vti__dropdown.open{background-color:#f3f3f3}.vti__dropdown.disabled{cursor:no-drop;outline:none}.vti__dropdown:hover{background-color:#f3f3f3}.vti__selection{font-size:.8em;display:flex;align-items:center}.vti__selection .vti__country-code{color:#666}.vti__flag{margin-right:5px;margin-left:5px}.vti__dropdown-list{z-index:1;padding:0;margin:0;text-align:left;list-style:none;max-height:200px;overflow-y:scroll;position:absolute;left:-1px;background-color:#fff;border:1px solid #ccc;width:390px}.vti__dropdown-list.below{top:33px}.vti__dropdown-list.above{top:auto;bottom:100%}.vti__dropdown-arrow{transform:scaleY(.5);display:inline-block;color:#666}.vti__dropdown-item{cursor:pointer;padding:4px 15px}.vti__dropdown-item.highlighted{background-color:#f3f3f3}.vti__dropdown-item.last-preferred{border-bottom:1px solid #cacaca}.vti__dropdown-item .vti__flag{display:inline-block;margin-right:5px}.vti__input{border:none;border-radius:0 2px 2px 0;width:100%;outline:none;padding-left:7px}.vti__search_box{border:1px solid #ccc;width:94%;padding:7px;margin:2px 2px}
|
|
@@ -5496,6 +5496,12 @@ var allProps = [{
|
|
|
5496
5496
|
type: Boolean,
|
|
5497
5497
|
description: 'Show flags in the dropdown selection and list',
|
|
5498
5498
|
inDemo: true
|
|
5499
|
+
}, {
|
|
5500
|
+
name: 'dropdownOptions.showSearchBox',
|
|
5501
|
+
default: false,
|
|
5502
|
+
type: Boolean,
|
|
5503
|
+
description: 'Show country search box',
|
|
5504
|
+
inDemo: true
|
|
5499
5505
|
}, {
|
|
5500
5506
|
name: 'dropdownOptions.tabindex',
|
|
5501
5507
|
default: 0,
|
|
@@ -5556,6 +5562,12 @@ var allProps = [{
|
|
|
5556
5562
|
type: String,
|
|
5557
5563
|
description: 'Native input <code>name</code> attribute',
|
|
5558
5564
|
inDemo: false
|
|
5565
|
+
}, {
|
|
5566
|
+
name: 'inputOptions.showDialCode',
|
|
5567
|
+
default: false,
|
|
5568
|
+
type: Boolean,
|
|
5569
|
+
description: 'Show dial code in input',
|
|
5570
|
+
inDemo: false
|
|
5559
5571
|
}, {
|
|
5560
5572
|
name: 'inputOptions.placeholder',
|
|
5561
5573
|
default: 'Enter a phone number',
|
|
@@ -5651,13 +5663,11 @@ var defaultOptions = [].concat(allProps).reduce(function (prv, crr) {
|
|
|
5651
5663
|
/* harmony default export */ const utils = ({
|
|
5652
5664
|
options: _objectSpread2({}, defaultOptions)
|
|
5653
5665
|
});
|
|
5654
|
-
;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
5655
|
-
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['vue-tel-input', _vm.styleClasses, { disabled: _vm.disabled }]},[_c('div',{directives:[{name:"click-outside",rawName:"v-click-outside",value:(_vm.clickedOutside),expression:"clickedOutside"}],class:['vti__dropdown', { open: _vm.open, disabled: _vm.dropdownOptions.disabled }],attrs:{"tabindex":_vm.dropdownOptions.tabindex},on:{"keydown":[_vm.keyboardNav,function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.reset.apply(null, arguments)}],"click":_vm.toggleDropdown}},[_c('span',{staticClass:"vti__selection"},[(_vm.dropdownOptions.showFlags)?_c('div',{class:['vti__flag', _vm.activeCountryCode.toLowerCase()]}):_vm._e(),(_vm.dropdownOptions.showDialCodeInSelection)?_c('span',{staticClass:"vti__country-code"},[_vm._v(" +"+_vm._s(_vm.activeCountry && _vm.activeCountry.dialCode)+" ")]):_vm._e(),_vm._t("arrow-icon",function(){return [_c('span',{staticClass:"vti__dropdown-arrow"},[_vm._v(_vm._s(_vm.open ? "▲" : "▼"))])]},{"open":_vm.open})],2),(_vm.open)?_vm.
|
|
5656
|
-
var staticRenderFns = [
|
|
5666
|
+
;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2f9a4d83-vue-loader-template"}!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/vue-tel-input.vue?vue&type=template&id=33071b52&
|
|
5667
|
+
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['vue-tel-input', _vm.styleClasses, { disabled: _vm.disabled }]},[_c('div',{directives:[{name:"click-outside",rawName:"v-click-outside",value:(_vm.clickedOutside),expression:"clickedOutside"}],class:['vti__dropdown', { open: _vm.open, disabled: _vm.dropdownOptions.disabled }],attrs:{"tabindex":_vm.dropdownOptions.tabindex},on:{"keydown":[_vm.keyboardNav,function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.reset.apply(null, arguments)}],"click":_vm.toggleDropdown}},[_c('span',{staticClass:"vti__selection"},[(_vm.dropdownOptions.showFlags)?_c('div',{class:['vti__flag', _vm.activeCountryCode.toLowerCase()]}):_vm._e(),(_vm.dropdownOptions.showDialCodeInSelection)?_c('span',{staticClass:"vti__country-code"},[_vm._v(" +"+_vm._s(_vm.activeCountry && _vm.activeCountry.dialCode)+" ")]):_vm._e(),_vm._t("arrow-icon",function(){return [_c('span',{staticClass:"vti__dropdown-arrow"},[_vm._v(_vm._s(_vm.open ? "▲" : "▼"))])]},{"open":_vm.open})],2),(_vm.open)?_c('ul',{ref:"list",staticClass:"vti__dropdown-list",class:_vm.dropdownOpenDirection},[(_vm.dropdownOptions.showSearchBox)?_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.searchQuery),expression:"searchQuery"}],staticClass:"vti__input vti__search_box",attrs:{"placeholder":"Search by country name or country code","type":"text"},domProps:{"value":(_vm.searchQuery)},on:{"input":function($event){if($event.target.composing){ return; }_vm.searchQuery=$event.target.value}}}):_vm._e(),_vm._l((_vm.sortedCountries),function(pb,index){return _c('li',{key:pb.iso2 + (pb.preferred ? '-preferred' : ''),class:['vti__dropdown-item', _vm.getItemClass(index, pb.iso2)],on:{"click":function($event){return _vm.choose(pb)},"mousemove":function($event){_vm.selectedIndex = index}}},[(_vm.dropdownOptions.showFlags)?_c('div',{class:['vti__flag', pb.iso2.toLowerCase()]}):_vm._e(),_c('strong',[_vm._v(_vm._s(pb.name))]),(_vm.dropdownOptions.showDialCodeInList)?_c('span',[_vm._v(" +"+_vm._s(pb.dialCode)+" ")]):_vm._e()])})],2):_vm._e()]),((_vm.inputOptions.type)==='checkbox')?_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.phone),expression:"phone"}],ref:"input",class:['vti__input', _vm.inputOptions.styleClasses],attrs:{"autocomplete":_vm.inputOptions.autocomplete,"autofocus":_vm.inputOptions.autofocus,"disabled":_vm.disabled,"id":_vm.inputOptions.id,"maxlength":_vm.inputOptions.maxlength,"name":_vm.inputOptions.name,"placeholder":_vm.parsedPlaceholder,"readonly":_vm.inputOptions.readonly,"required":_vm.inputOptions.required,"tabindex":_vm.inputOptions.tabindex,"aria-describedby":_vm.inputOptions['aria-describedby'],"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.phone)?_vm._i(_vm.phone,null)>-1:(_vm.phone)},on:{"blur":_vm.onBlur,"focus":_vm.onFocus,"input":_vm.onInput,"keyup":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onEnter.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"space",32,$event.key,[" ","Spacebar"])){ return null; }return _vm.onSpace.apply(null, arguments)}],"change":function($event){var $$a=_vm.phone,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.phone=$$a.concat([$$v]))}else{$$i>-1&&(_vm.phone=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{_vm.phone=$$c}}}}):((_vm.inputOptions.type)==='radio')?_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.phone),expression:"phone"}],ref:"input",class:['vti__input', _vm.inputOptions.styleClasses],attrs:{"autocomplete":_vm.inputOptions.autocomplete,"autofocus":_vm.inputOptions.autofocus,"disabled":_vm.disabled,"id":_vm.inputOptions.id,"maxlength":_vm.inputOptions.maxlength,"name":_vm.inputOptions.name,"placeholder":_vm.parsedPlaceholder,"readonly":_vm.inputOptions.readonly,"required":_vm.inputOptions.required,"tabindex":_vm.inputOptions.tabindex,"aria-describedby":_vm.inputOptions['aria-describedby'],"type":"radio"},domProps:{"checked":_vm._q(_vm.phone,null)},on:{"blur":_vm.onBlur,"focus":_vm.onFocus,"input":_vm.onInput,"keyup":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onEnter.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"space",32,$event.key,[" ","Spacebar"])){ return null; }return _vm.onSpace.apply(null, arguments)}],"change":function($event){_vm.phone=null}}}):_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.phone),expression:"phone"}],ref:"input",class:['vti__input', _vm.inputOptions.styleClasses],attrs:{"autocomplete":_vm.inputOptions.autocomplete,"autofocus":_vm.inputOptions.autofocus,"disabled":_vm.disabled,"id":_vm.inputOptions.id,"maxlength":_vm.inputOptions.maxlength,"name":_vm.inputOptions.name,"placeholder":_vm.parsedPlaceholder,"readonly":_vm.inputOptions.readonly,"required":_vm.inputOptions.required,"tabindex":_vm.inputOptions.tabindex,"aria-describedby":_vm.inputOptions['aria-describedby'],"type":_vm.inputOptions.type},domProps:{"value":(_vm.phone)},on:{"blur":_vm.onBlur,"focus":_vm.onFocus,"input":[function($event){if($event.target.composing){ return; }_vm.phone=$event.target.value},_vm.onInput],"keyup":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onEnter.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"space",32,$event.key,[" ","Spacebar"])){ return null; }return _vm.onSpace.apply(null, arguments)}]}}),_vm._t("icon-right")],2)}
|
|
5668
|
+
var staticRenderFns = []
|
|
5657
5669
|
|
|
5658
5670
|
|
|
5659
|
-
;// CONCATENATED MODULE: ./src/components/vue-tel-input.vue?vue&type=template&id=13c114b8&
|
|
5660
|
-
|
|
5661
5671
|
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
5662
5672
|
|
|
5663
5673
|
function _arrayWithoutHoles(arr) {
|
|
@@ -8760,6 +8770,13 @@ var _excluded = ["metadata"];
|
|
|
8760
8770
|
//
|
|
8761
8771
|
//
|
|
8762
8772
|
//
|
|
8773
|
+
//
|
|
8774
|
+
//
|
|
8775
|
+
//
|
|
8776
|
+
//
|
|
8777
|
+
//
|
|
8778
|
+
//
|
|
8779
|
+
//
|
|
8763
8780
|
|
|
8764
8781
|
|
|
8765
8782
|
|
|
@@ -8899,7 +8916,8 @@ function getDefault(key) {
|
|
|
8899
8916
|
typeToFindInput: '',
|
|
8900
8917
|
typeToFindTimer: null,
|
|
8901
8918
|
dropdownOpenDirection: 'below',
|
|
8902
|
-
parsedPlaceholder: this.inputOptions.placeholder
|
|
8919
|
+
parsedPlaceholder: this.inputOptions.placeholder,
|
|
8920
|
+
searchQuery: ''
|
|
8903
8921
|
};
|
|
8904
8922
|
},
|
|
8905
8923
|
computed: {
|
|
@@ -8945,13 +8963,23 @@ function getDefault(key) {
|
|
|
8945
8963
|
return this.allCountries;
|
|
8946
8964
|
},
|
|
8947
8965
|
sortedCountries: function sortedCountries() {
|
|
8966
|
+
var _this2 = this;
|
|
8967
|
+
|
|
8948
8968
|
// Sort the list countries: from preferred countries to all countries
|
|
8949
8969
|
var preferredCountries = this.getCountries(this.preferredCountries).map(function (country) {
|
|
8950
8970
|
return _objectSpread2(_objectSpread2({}, country), {}, {
|
|
8951
8971
|
preferred: true
|
|
8952
8972
|
});
|
|
8953
8973
|
});
|
|
8954
|
-
|
|
8974
|
+
var countriesList = [].concat(_toConsumableArray(preferredCountries), _toConsumableArray(this.filteredCountries));
|
|
8975
|
+
|
|
8976
|
+
if (!this.dropdownOptions.showSearchBox) {
|
|
8977
|
+
return countriesList;
|
|
8978
|
+
}
|
|
8979
|
+
|
|
8980
|
+
return countriesList.filter(function (c) {
|
|
8981
|
+
return new RegExp(_this2.searchQuery, 'i').test(c.name) || new RegExp(_this2.searchQuery, 'i').test(c.iso2) || new RegExp(_this2.searchQuery, 'i').test(c.dialCode);
|
|
8982
|
+
});
|
|
8955
8983
|
},
|
|
8956
8984
|
phoneObject: function phoneObject() {
|
|
8957
8985
|
var _this$phone, _result$isValid, _result2;
|
|
@@ -9013,7 +9041,7 @@ function getDefault(key) {
|
|
|
9013
9041
|
this.$emit('validate', this.phoneObject);
|
|
9014
9042
|
},
|
|
9015
9043
|
'phoneObject.formatted': function phoneObjectFormatted(value) {
|
|
9016
|
-
var
|
|
9044
|
+
var _this3 = this;
|
|
9017
9045
|
|
|
9018
9046
|
if (!this.autoFormat || this.customValidate) {
|
|
9019
9047
|
return;
|
|
@@ -9022,8 +9050,8 @@ function getDefault(key) {
|
|
|
9022
9050
|
this.emitInput(value);
|
|
9023
9051
|
this.$nextTick(function () {
|
|
9024
9052
|
// In case `v-model` is not set, we need to update the `phone` to be new formatted value
|
|
9025
|
-
if (value && !
|
|
9026
|
-
|
|
9053
|
+
if (value && !_this3.value) {
|
|
9054
|
+
_this3.phone = value;
|
|
9027
9055
|
}
|
|
9028
9056
|
});
|
|
9029
9057
|
},
|
|
@@ -9034,13 +9062,13 @@ function getDefault(key) {
|
|
|
9034
9062
|
this.resetPlaceholder();
|
|
9035
9063
|
},
|
|
9036
9064
|
value: function value(_value, oldValue) {
|
|
9037
|
-
var
|
|
9065
|
+
var _this4 = this;
|
|
9038
9066
|
|
|
9039
9067
|
if (!this.testCharacters()) {
|
|
9040
9068
|
this.$nextTick(function () {
|
|
9041
|
-
|
|
9069
|
+
_this4.phone = oldValue;
|
|
9042
9070
|
|
|
9043
|
-
|
|
9071
|
+
_this4.onInput();
|
|
9044
9072
|
});
|
|
9045
9073
|
} else {
|
|
9046
9074
|
this.phone = _value;
|
|
@@ -9057,7 +9085,7 @@ function getDefault(key) {
|
|
|
9057
9085
|
}
|
|
9058
9086
|
},
|
|
9059
9087
|
mounted: function mounted() {
|
|
9060
|
-
var
|
|
9088
|
+
var _this5 = this;
|
|
9061
9089
|
|
|
9062
9090
|
if (this.value) {
|
|
9063
9091
|
this.phone = this.value.trim();
|
|
@@ -9065,15 +9093,15 @@ function getDefault(key) {
|
|
|
9065
9093
|
|
|
9066
9094
|
this.cleanInvalidCharacters();
|
|
9067
9095
|
this.initializeCountry().then(function () {
|
|
9068
|
-
var
|
|
9096
|
+
var _this5$inputOptions;
|
|
9069
9097
|
|
|
9070
|
-
if (!
|
|
9071
|
-
|
|
9098
|
+
if (!_this5.phone && (_this5$inputOptions = _this5.inputOptions) !== null && _this5$inputOptions !== void 0 && _this5$inputOptions.showDialCode && _this5.activeCountryCode) {
|
|
9099
|
+
_this5.phone = "+".concat(_this5.activeCountryCode);
|
|
9072
9100
|
}
|
|
9073
9101
|
|
|
9074
|
-
|
|
9102
|
+
_this5.$emit('validate', _this5.phoneObject);
|
|
9075
9103
|
}).catch(console.error).then(function () {
|
|
9076
|
-
|
|
9104
|
+
_this5.finishMounted = true;
|
|
9077
9105
|
});
|
|
9078
9106
|
},
|
|
9079
9107
|
methods: {
|
|
@@ -9092,15 +9120,15 @@ function getDefault(key) {
|
|
|
9092
9120
|
// .catch(console.error);
|
|
9093
9121
|
},
|
|
9094
9122
|
initializeCountry: function initializeCountry() {
|
|
9095
|
-
var
|
|
9123
|
+
var _this6 = this;
|
|
9096
9124
|
|
|
9097
9125
|
return new Promise(function (resolve) {
|
|
9098
|
-
var
|
|
9126
|
+
var _this6$phone;
|
|
9099
9127
|
|
|
9100
9128
|
/**
|
|
9101
9129
|
* 1. If the phone included prefix (i.e. +12), try to get the country and set it
|
|
9102
9130
|
*/
|
|
9103
|
-
if (((
|
|
9131
|
+
if (((_this6$phone = _this6.phone) === null || _this6$phone === void 0 ? void 0 : _this6$phone[0]) === '+') {
|
|
9104
9132
|
resolve();
|
|
9105
9133
|
return;
|
|
9106
9134
|
}
|
|
@@ -9109,19 +9137,19 @@ function getDefault(key) {
|
|
|
9109
9137
|
*/
|
|
9110
9138
|
|
|
9111
9139
|
|
|
9112
|
-
if (
|
|
9113
|
-
if (typeof
|
|
9114
|
-
|
|
9140
|
+
if (_this6.defaultCountry) {
|
|
9141
|
+
if (typeof _this6.defaultCountry === 'string') {
|
|
9142
|
+
_this6.choose(_this6.defaultCountry);
|
|
9115
9143
|
|
|
9116
9144
|
resolve();
|
|
9117
9145
|
return;
|
|
9118
9146
|
}
|
|
9119
9147
|
|
|
9120
|
-
if (typeof
|
|
9121
|
-
var country =
|
|
9148
|
+
if (typeof _this6.defaultCountry === 'number') {
|
|
9149
|
+
var country = _this6.findCountryByDialCode(_this6.defaultCountry);
|
|
9122
9150
|
|
|
9123
9151
|
if (country) {
|
|
9124
|
-
|
|
9152
|
+
_this6.choose(country.iso2);
|
|
9125
9153
|
|
|
9126
9154
|
resolve();
|
|
9127
9155
|
return;
|
|
@@ -9129,21 +9157,21 @@ function getDefault(key) {
|
|
|
9129
9157
|
}
|
|
9130
9158
|
}
|
|
9131
9159
|
|
|
9132
|
-
var fallbackCountry =
|
|
9160
|
+
var fallbackCountry = _this6.preferredCountries[0] || _this6.filteredCountries[0];
|
|
9133
9161
|
/**
|
|
9134
9162
|
* 3. Check if fetching country based on user's IP is allowed, set it as the default country
|
|
9135
9163
|
*/
|
|
9136
9164
|
|
|
9137
|
-
if (
|
|
9165
|
+
if (_this6.autoDefaultCountry) {
|
|
9138
9166
|
getCountry().then(function (res) {
|
|
9139
|
-
|
|
9167
|
+
_this6.choose(res || _this6.activeCountryCode);
|
|
9140
9168
|
}).catch(function (error) {
|
|
9141
9169
|
console.warn(error);
|
|
9142
9170
|
/**
|
|
9143
9171
|
* 4. Use the first country from preferred list (if available) or all countries list
|
|
9144
9172
|
*/
|
|
9145
9173
|
|
|
9146
|
-
|
|
9174
|
+
_this6.choose(fallbackCountry);
|
|
9147
9175
|
}).then(function () {
|
|
9148
9176
|
resolve();
|
|
9149
9177
|
});
|
|
@@ -9151,7 +9179,7 @@ function getDefault(key) {
|
|
|
9151
9179
|
/**
|
|
9152
9180
|
* 4. Use the first country from preferred list (if available) or all countries list
|
|
9153
9181
|
*/
|
|
9154
|
-
|
|
9182
|
+
_this6.choose(fallbackCountry);
|
|
9155
9183
|
|
|
9156
9184
|
resolve();
|
|
9157
9185
|
}
|
|
@@ -9162,11 +9190,11 @@ function getDefault(key) {
|
|
|
9162
9190
|
* Get the list of countries from the list of iso2 code
|
|
9163
9191
|
*/
|
|
9164
9192
|
getCountries: function getCountries() {
|
|
9165
|
-
var
|
|
9193
|
+
var _this7 = this;
|
|
9166
9194
|
|
|
9167
9195
|
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9168
9196
|
return list.map(function (countryCode) {
|
|
9169
|
-
return
|
|
9197
|
+
return _this7.findCountry(countryCode);
|
|
9170
9198
|
}).filter(Boolean);
|
|
9171
9199
|
},
|
|
9172
9200
|
findCountry: function findCountry() {
|
|
@@ -9215,6 +9243,7 @@ function getDefault(key) {
|
|
|
9215
9243
|
if ((_this$inputOptions = this.inputOptions) !== null && _this$inputOptions !== void 0 && _this$inputOptions.showDialCode && parsedCountry) {
|
|
9216
9244
|
// Reset phone if the showDialCode is set
|
|
9217
9245
|
this.phone = "+".concat(parsedCountry.dialCode);
|
|
9246
|
+
this.activeCountryCode = parsedCountry.iso2 || '';
|
|
9218
9247
|
return;
|
|
9219
9248
|
} // update value, even if international mode is NOT used
|
|
9220
9249
|
|
|
@@ -9284,18 +9313,21 @@ function getDefault(key) {
|
|
|
9284
9313
|
focus: function focus() {
|
|
9285
9314
|
this.$refs.input.focus();
|
|
9286
9315
|
},
|
|
9287
|
-
toggleDropdown: function toggleDropdown() {
|
|
9288
|
-
|
|
9316
|
+
toggleDropdown: function toggleDropdown(e) {
|
|
9317
|
+
var _e$path, _e$path$;
|
|
9318
|
+
|
|
9319
|
+
if (this.disabled || this.dropdownOptions.disabled || (e === null || e === void 0 ? void 0 : (_e$path = e.path) === null || _e$path === void 0 ? void 0 : (_e$path$ = _e$path[0]) === null || _e$path$ === void 0 ? void 0 : _e$path$.type) === 'text') {
|
|
9289
9320
|
return;
|
|
9290
9321
|
}
|
|
9291
9322
|
|
|
9323
|
+
this.searchQuery = '';
|
|
9292
9324
|
this.open = !this.open;
|
|
9293
9325
|
},
|
|
9294
9326
|
clickedOutside: function clickedOutside() {
|
|
9295
9327
|
this.open = false;
|
|
9296
9328
|
},
|
|
9297
9329
|
keyboardNav: function keyboardNav(e) {
|
|
9298
|
-
var
|
|
9330
|
+
var _this8 = this;
|
|
9299
9331
|
|
|
9300
9332
|
if (e.keyCode === 40) {
|
|
9301
9333
|
// down arrow
|
|
@@ -9341,11 +9373,11 @@ function getDefault(key) {
|
|
|
9341
9373
|
this.typeToFindInput += e.key;
|
|
9342
9374
|
clearTimeout(this.typeToFindTimer);
|
|
9343
9375
|
this.typeToFindTimer = setTimeout(function () {
|
|
9344
|
-
|
|
9376
|
+
_this8.typeToFindInput = '';
|
|
9345
9377
|
}, 700); // don't include preferred countries so we jump to the right place in the alphabet
|
|
9346
9378
|
|
|
9347
9379
|
var typedCountryI = this.sortedCountries.slice(this.preferredCountries.length).findIndex(function (c) {
|
|
9348
|
-
return c.name.toLowerCase().startsWith(
|
|
9380
|
+
return c.name.toLowerCase().startsWith(_this8.typeToFindInput);
|
|
9349
9381
|
});
|
|
9350
9382
|
|
|
9351
9383
|
if (typedCountryI >= 0) {
|