vue-tel-input 5.10.1 → 5.11.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.
@@ -9,118 +9,9 @@
9
9
  root["vue-tel-input"] = factory();
10
10
  })((typeof self !== 'undefined' ? self : this), function() {
11
11
  return /******/ (() => { // webpackBootstrap
12
- /******/ var __webpack_modules__ = ({
13
-
14
- /***/ 679:
15
- /***/ (function(module, exports) {
16
-
17
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller
18
- // MIT license
19
- // source: https://github.com/amiller-gh/currentScript-polyfill
20
-
21
- // added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505
22
-
23
- (function (root, factory) {
24
- if (true) {
25
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
26
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
27
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
28
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
29
- } else {}
30
- }(typeof self !== 'undefined' ? self : this, function () {
31
- function getCurrentScript () {
32
- var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript')
33
- // for chrome
34
- if (!descriptor && 'currentScript' in document && document.currentScript) {
35
- return document.currentScript
36
- }
37
-
38
- // for other browsers with native support for currentScript
39
- if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) {
40
- return document.currentScript
41
- }
42
-
43
- // IE 8-10 support script readyState
44
- // IE 11+ & Firefox support stack trace
45
- try {
46
- throw new Error();
47
- }
48
- catch (err) {
49
- // Find the second match for the "at" string to get file src url from stack.
50
- var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig,
51
- ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig,
52
- stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack),
53
- scriptLocation = (stackDetails && stackDetails[1]) || false,
54
- line = (stackDetails && stackDetails[2]) || false,
55
- currentLocation = document.location.href.replace(document.location.hash, ''),
56
- pageSource,
57
- inlineScriptSourceRegExp,
58
- inlineScriptSource,
59
- scripts = document.getElementsByTagName('script'); // Live NodeList collection
60
-
61
- if (scriptLocation === currentLocation) {
62
- pageSource = document.documentElement.outerHTML;
63
- inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i');
64
- inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim();
65
- }
66
-
67
- for (var i = 0; i < scripts.length; i++) {
68
- // If ready state is interactive, return the script tag
69
- if (scripts[i].readyState === 'interactive') {
70
- return scripts[i];
71
- }
72
-
73
- // If src matches, return the script tag
74
- if (scripts[i].src === scriptLocation) {
75
- return scripts[i];
76
- }
77
-
78
- // If inline source matches, return the script tag
79
- if (
80
- scriptLocation === currentLocation &&
81
- scripts[i].innerHTML &&
82
- scripts[i].innerHTML.trim() === inlineScriptSource
83
- ) {
84
- return scripts[i];
85
- }
86
- }
87
-
88
- // If no match, return null
89
- return null;
90
- }
91
- };
92
-
93
- return getCurrentScript
94
- }));
95
-
96
-
97
- /***/ })
98
-
99
- /******/ });
100
- /************************************************************************/
101
- /******/ // The module cache
102
- /******/ var __webpack_module_cache__ = {};
103
- /******/
104
- /******/ // The require function
105
- /******/ function __webpack_require__(moduleId) {
106
- /******/ // Check if module is in cache
107
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
108
- /******/ if (cachedModule !== undefined) {
109
- /******/ return cachedModule.exports;
110
- /******/ }
111
- /******/ // Create a new module (and put it into the cache)
112
- /******/ var module = __webpack_module_cache__[moduleId] = {
113
- /******/ // no module.id needed
114
- /******/ // no module.loaded needed
115
- /******/ exports: {}
116
- /******/ };
117
- /******/
118
- /******/ // Execute the module function
119
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
120
- /******/
121
- /******/ // Return the exports of the module
122
- /******/ return module.exports;
123
- /******/ }
12
+ /******/ "use strict";
13
+ /******/ // The require scope
14
+ /******/ var __webpack_require__ = {};
124
15
  /******/
125
16
  /************************************************************************/
126
17
  /******/ /* webpack/runtime/define property getters */
@@ -170,9 +61,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
170
61
  /******/
171
62
  /************************************************************************/
172
63
  var __webpack_exports__ = {};
173
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
174
- (() => {
175
- "use strict";
176
64
  // ESM COMPAT FLAG
177
65
  __webpack_require__.r(__webpack_exports__);
178
66
 
@@ -189,15 +77,7 @@ __webpack_require__.d(__webpack_exports__, {
189
77
 
190
78
  if (typeof window !== 'undefined') {
191
79
  var currentScript = window.document.currentScript
192
- if (true) {
193
- var getCurrentScript = __webpack_require__(679)
194
- currentScript = getCurrentScript()
195
-
196
- // for backward compatibility, because previously we directly included the polyfill
197
- if (!('currentScript' in document)) {
198
- Object.defineProperty(document, 'currentScript', { get: getCurrentScript })
199
- }
200
- }
80
+ if (false) { var getCurrentScript; }
201
81
 
202
82
  var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
203
83
  if (src) {
@@ -395,7 +275,7 @@ const allProps = [{
395
275
  default: false,
396
276
  type: Boolean,
397
277
  description: 'Show dial code in input',
398
- inDemo: false
278
+ inDemo: true
399
279
  }, {
400
280
  name: 'inputOptions.placeholder',
401
281
  default: 'Enter a phone number',
@@ -497,7 +377,7 @@ const defaultOptions = [...allProps].reduce((prv, crr) => {
497
377
  options: { ...defaultOptions
498
378
  }
499
379
  });
500
- ;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"4f6fd387-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=640867be&
380
+ ;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"7824190b-vue-loader-template"}!./node_modules/@vue/cli-service/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/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/vue-tel-input.vue?vue&type=template&id=68d31ada&
501
381
  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:{"aria-label":"Country Code Selector","aria-haspopup":"listbox","aria-expanded":_vm.open,"role":"button","tabindex":_vm.dropdownOptions.tabindex},on:{"keydown":[_vm.keyboardNav,function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"space",32,$event.key,[" ","Spacebar"])){ return null; }return _vm.toggleDropdown.apply(null, arguments)},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)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"tab",9,$event.key,"Tab")){ return null; }return _vm.reset.apply(null, arguments)}],"click":_vm.toggleDropdown}},[_c('span',{staticClass:"vti__selection"},[(_vm.dropdownOptions.showFlags)?_c('span',{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,style:({ width: _vm.dropdownOptions.width }),attrs:{"role":"listbox"}},[(_vm.dropdownOptions.showSearchBox)?_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.searchQuery),expression:"searchQuery"}],staticClass:"vti__input vti__search_box",attrs:{"aria-label":"Search by country name or country code","placeholder":_vm.sortedCountries.length ? _vm.sortedCountries[0].name : '',"type":"text"},domProps:{"value":(_vm.searchQuery)},on:{"click":function($event){$event.stopPropagation();},"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)],attrs:{"role":"option","tabindex":"-1","aria-selected":_vm.activeCountryCode === pb.iso2 && !pb.preferred},on:{"click":function($event){return _vm.choose(pb)},"mousemove":function($event){_vm.selectedIndex = index}}},[_c('div',{staticClass:"vti__flag-wrapper"},[(_vm.dropdownOptions.showFlags)?_c('span',{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)}
502
382
  var staticRenderFns = []
503
383
 
@@ -3479,7 +3359,7 @@ function getParents(node, memo) {
3479
3359
  }
3480
3360
 
3481
3361
  });
3482
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-78[0].rules[0].use[1]!./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=script&lang=js&
3362
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-78[0].rules[0].use[1]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/vue-tel-input.vue?vue&type=script&lang=js&
3483
3363
  //
3484
3364
  //
3485
3365
  //
@@ -3741,6 +3621,10 @@ function getDefault(key) {
3741
3621
  },
3742
3622
 
3743
3623
  phoneObject() {
3624
+ if (!this.finishMounted) {
3625
+ return {};
3626
+ }
3627
+
3744
3628
  let result;
3745
3629
 
3746
3630
  if (this.phone?.[0] === '+') {
@@ -3749,6 +3633,12 @@ function getDefault(key) {
3749
3633
  result = exports_parsePhoneNumberFromString_parsePhoneNumberFromString(this.phone, this.activeCountryCode) || {};
3750
3634
  }
3751
3635
 
3636
+ if (this.inputOptions.showDialCode && this.phone?.[0] !== '+') {
3637
+ Object.assign(result, {
3638
+ country: '--'
3639
+ });
3640
+ }
3641
+
3752
3642
  const {
3753
3643
  metadata,
3754
3644
  ...phoneObject
@@ -3764,7 +3654,7 @@ function getDefault(key) {
3764
3654
  if (!this.findCountry(result.country)) {
3765
3655
  valid = false;
3766
3656
  Object.assign(result, {
3767
- country: null
3657
+ country: '--'
3768
3658
  });
3769
3659
  }
3770
3660
  }
@@ -3781,7 +3671,7 @@ function getDefault(key) {
3781
3671
  },
3782
3672
  watch: {
3783
3673
  activeCountry(value, oldValue) {
3784
- if (!value && oldValue?.iso2) {
3674
+ if (!value && oldValue?.iso2 && !this.inputOptions.showDialCode) {
3785
3675
  this.activeCountryCode = oldValue.iso2;
3786
3676
  return;
3787
3677
  }
@@ -3792,6 +3682,10 @@ function getDefault(key) {
3792
3682
  },
3793
3683
 
3794
3684
  'phoneObject.countryCode': function (value) {
3685
+ if (!value) {
3686
+ return;
3687
+ }
3688
+
3795
3689
  this.activeCountryCode = value || '';
3796
3690
  },
3797
3691
  'phoneObject.valid': function () {
@@ -4158,7 +4052,7 @@ function getDefault(key) {
4158
4052
  });
4159
4053
  ;// CONCATENATED MODULE: ./src/components/vue-tel-input.vue?vue&type=script&lang=js&
4160
4054
  /* harmony default export */ const components_vue_tel_inputvue_type_script_lang_js_ = (vue_tel_inputvue_type_script_lang_js_);
4161
- ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
4055
+ ;// CONCATENATED MODULE: ./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
4162
4056
  /* globals __VUE_SSR_CONTEXT__ */
4163
4057
 
4164
4058
  // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
@@ -4332,8 +4226,6 @@ if (GlobalVue) {
4332
4226
  /* harmony default export */ const entry_lib = (src_0);
4333
4227
 
4334
4228
 
4335
- })();
4336
-
4337
4229
  /******/ return __webpack_exports__;
4338
4230
  /******/ })()
4339
4231
  ;