vue-tel-input 8.1.3 → 8.1.4
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/dist/vue-tel-input.js
CHANGED
|
@@ -3193,7 +3193,8 @@ const Ht = {
|
|
|
3193
3193
|
n && (r += `Found in component ${n}`), console.warn(r);
|
|
3194
3194
|
}
|
|
3195
3195
|
e.clickOutsideEvent = function(n) {
|
|
3196
|
-
|
|
3196
|
+
const r = n.composedPath ? n.composedPath() : n.path;
|
|
3197
|
+
e === n.target || e.contains(n.target) || r.includes(e) || d.value(n, e);
|
|
3197
3198
|
}, document.body.addEventListener("click", e.clickOutsideEvent);
|
|
3198
3199
|
},
|
|
3199
3200
|
unmounted(e) {
|
|
@@ -7,4 +7,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7
7
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xt(e,t){if(e){if(typeof e=="string")return se(e,t);var d=Object.prototype.toString.call(e).slice(8,-1);if(d==="Object"&&e.constructor&&(d=e.constructor.name),d==="Map"||d==="Set")return Array.from(e);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return se(e,t)}}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var d=0,n=new Array(t);d<t;d++)n[d]=e[d];return n}var Ct=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function D(e,t,d){if(t=t||{},!!e.country){d=new p(d),d.selectNumberingPlan(e.country,e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;if(g(n,d.nationalNumberPattern())){if(z(n,"FIXED_LINE",d))return d.type("MOBILE")&&d.type("MOBILE").pattern()===""||!d.type("MOBILE")||z(n,"MOBILE",d)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE";for(var i=Lt(Ct),r;!(r=i()).done;){var a=r.value;if(z(n,a,d))return a}}}}function z(e,t,d){return t=d.type(t),!t||!t.pattern()||t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0?!1:g(e,t.pattern())}function Nt(e,t,d){if(t=t||{},d=new p(d),!e.country)return!1;if(d.selectNumberingPlan(e.country,e.countryCallingCode),d.hasTypes())return D(e,t,d.metadata)!==void 0;var n=t.v2?e.nationalNumber:e.phone;return g(n,d.nationalNumberPattern())}function Tt(e){return e.replace(new RegExp("[".concat(L,"]+"),"g")," ").trim()}var Ot=/(\$\d)/;function At(e,t,d){var n=d.useInternationalFormat,i=d.withNationalPrefix;d.carrierCode,d.metadata;var r=e.replace(new RegExp(t.pattern()),n?t.internationalFormat():i&&t.nationalPrefixFormattingRule()?t.format().replace(Ot,t.nationalPrefixFormattingRule()):t.format());return n?Tt(r):r}var It=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function Ft(e,t,d){var n=new p(d);if(n.selectNumberingPlan(e,t),n.defaultIDDPrefix())return n.defaultIDDPrefix();if(It.test(n.IDDPrefix()))return n.IDDPrefix()}function Rt(e,t){var d=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(d)return(d=d.call(e)).next.bind(d);if(Array.isArray(e)||(d=St(e))||t&&e&&typeof e.length=="number"){d&&(e=d);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
8
8
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function St(e,t){if(e){if(typeof e=="string")return pe(e,t);var d=Object.prototype.toString.call(e).slice(8,-1);if(d==="Object"&&e.constructor&&(d=e.constructor.name),d==="Map"||d==="Set")return Array.from(e);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return pe(e,t)}}function pe(e,t){(t==null||t>e.length)&&(t=e.length);for(var d=0,n=new Array(t);d<t;d++)n[d]=e[d];return n}function ve(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function ce(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?ve(Object(d),!0).forEach(function(n){Vt(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):ve(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function Vt(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}var ge={formatExtension:function(t,d,n){return"".concat(t).concat(n.ext()).concat(d)}};function Et(e,t,d,n){if(d?d=ce(ce({},ge),d):d=ge,n=new p(n),e.country&&e.country!=="001"){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else if(e.countryCallingCode)n.selectNumberingPlan(e.countryCallingCode);else return e.phone||"";var i=n.countryCallingCode(),r=d.v2?e.nationalNumber:e.phone,a;switch(t){case"NATIONAL":return r?(a=T(r,e.carrierCode,"NATIONAL",n,d),j(a,e.ext,n,d.formatExtension)):"";case"INTERNATIONAL":return r?(a=T(r,null,"INTERNATIONAL",n,d),a="+".concat(i," ").concat(a),j(a,e.ext,n,d.formatExtension)):"+".concat(i);case"E.164":return"+".concat(i).concat(r);case"RFC3966":return wt({number:"+".concat(i).concat(r),ext:e.ext});case"IDD":if(!d.fromCountry)return;var o=zt(r,e.carrierCode,i,d.fromCountry,n);return j(o,e.ext,n,d.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function T(e,t,d,n,i){var r=Dt(n.formats(),e);return r?At(e,r,{useInternationalFormat:d==="INTERNATIONAL",withNationalPrefix:!(r.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&i&&i.nationalPrefix===!1),carrierCode:t,metadata:n}):e}function Dt(e,t){for(var d=Rt(e),n;!(n=d()).done;){var i=n.value;if(i.leadingDigitsPatterns().length>0){var r=i.leadingDigitsPatterns()[i.leadingDigitsPatterns().length-1];if(t.search(r)!==0)continue}if(g(t,i.pattern()))return i}}function j(e,t,d,n){return t?n(e,t,d):e}function zt(e,t,d,n,i){var r=V(n,i.metadata);if(r===d){var a=T(e,t,"NATIONAL",i);return d==="1"?d+" "+a:a}var o=Ft(n,void 0,i.metadata);if(o)return"".concat(o," ").concat(d," ").concat(T(e,null,"INTERNATIONAL",i))}function he(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function $e(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?he(Object(d),!0).forEach(function(n){jt(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):he(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function jt(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}function Bt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ye(e,t){for(var d=0;d<t.length;d++){var n=t[d];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Mt(e,t,d){return t&&ye(e.prototype,t),d&&ye(e,d),Object.defineProperty(e,"prototype",{writable:!1}),e}var Ut=function(){function e(t,d,n){if(Bt(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!d)throw new TypeError("`nationalNumber` not passed");if(!n)throw new TypeError("`metadata` not passed");var i=new p(n);Ht(t)&&(this.country=t,i.country(t),t=i.countryCallingCode()),this.countryCallingCode=t,this.nationalNumber=d,this.number="+"+this.countryCallingCode+this.nationalNumber,this.metadata=n}return Mt(e,[{key:"setExt",value:function(d){this.ext=d}},{key:"isPossible",value:function(){return $t(this,{v2:!0},this.metadata)}},{key:"isValid",value:function(){return Nt(this,{v2:!0},this.metadata)}},{key:"isNonGeographic",value:function(){var d=new p(this.metadata);return d.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(d){return this.number===d.number&&this.ext===d.ext}},{key:"getType",value:function(){return D(this,{v2:!0},this.metadata)}},{key:"format",value:function(d,n){return Et(this,d,n?$e($e({},n),{},{v2:!0}):{v2:!0},this.metadata)}},{key:"formatNational",value:function(d){return this.format("NATIONAL",d)}},{key:"formatInternational",value:function(d){return this.format("INTERNATIONAL",d)}},{key:"getURI",value:function(d){return this.format("RFC3966",d)}}]),e}(),Ht=function(t){return/^[A-Z]{2}$/.test(t)},Kt=new RegExp("(["+y+"])");function qt(e,t,d,n){if(t){var i=new p(n);i.selectNumberingPlan(t,d);var r=new RegExp(i.IDDPrefix());if(e.search(r)===0){e=e.slice(e.match(r)[0].length);var a=e.match(Kt);if(!(a&&a[1]!=null&&a[1].length>0&&a[1]==="0"))return e}}}function Gt(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var d=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),n=d.exec(e);if(n){var i,r,a=n.length-1,o=a>0&&n[a];if(t.nationalPrefixTransformRule()&&o)i=e.replace(d,t.nationalPrefixTransformRule()),a>1&&(r=n[1]);else{var l=n[0];i=e.slice(l.length),o&&(r=n[1])}var u;if(o){var c=e.indexOf(n[1]),v=e.slice(0,c);v===t.numberingPlan.nationalPrefix()&&(u=t.numberingPlan.nationalPrefix())}else u=n[0];return{nationalNumber:i,nationalPrefix:u,carrierCode:r}}}return{nationalNumber:e}}function B(e,t){var d=Gt(e,t),n=d.carrierCode,i=d.nationalNumber;if(i!==e){if(!Jt(e,i,t))return{nationalNumber:e};if(t.possibleLengths()&&!Wt(i,t))return{nationalNumber:e}}return{nationalNumber:i,carrierCode:n}}function Jt(e,t,d){return!(g(e,d.nationalNumberPattern())&&!g(t,d.nationalNumberPattern()))}function Wt(e,t){switch(E(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}function Zt(e,t,d,n){var i=t?V(t,n):d;if(e.indexOf(i)===0){n=new p(n),n.selectNumberingPlan(t,d);var r=e.slice(i.length),a=B(r,n),o=a.nationalNumber,l=B(e,n),u=l.nationalNumber;if(!g(u,n.nationalNumberPattern())&&g(o,n.nationalNumberPattern())||E(u,n)==="TOO_LONG")return{countryCallingCode:i,number:r}}return{number:e}}function Yt(e,t,d,n){if(!e)return{};if(e[0]!=="+"){var i=qt(e,t,d,n);if(i&&i!==e)e="+"+i;else{if(t||d){var r=Zt(e,t,d,n),a=r.countryCallingCode,o=r.number;if(a)return{countryCallingCode:a,number:o}}return{number:e}}}if(e[1]==="0")return{};n=new p(n);for(var l=2;l-1<=ze&&l<=e.length;){var u=e.slice(1,l);if(n.hasCallingCode(u))return n.selectNumberingPlan(u),{countryCallingCode:u,number:e.slice(l)};l++}return{}}function Qt(e,t){var d=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(d)return(d=d.call(e)).next.bind(d);if(Array.isArray(e)||(d=_t(e))||t&&e&&typeof e.length=="number"){d&&(e=d);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
9
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _t(e,t){if(e){if(typeof e=="string")return be(e,t);var d=Object.prototype.toString.call(e).slice(8,-1);if(d==="Object"&&e.constructor&&(d=e.constructor.name),d==="Map"||d==="Set")return Array.from(e);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return be(e,t)}}function be(e,t){(t==null||t>e.length)&&(t=e.length);for(var d=0,n=new Array(t);d<t;d++)n[d]=e[d];return n}var ed=!1;function td(e,t,d){if(ed&&d.isNonGeographicCallingCode(e))return"001";var n=d.getCountryCodesForCallingCode(e);if(n)return n.length===1?n[0]:dd(n,t,d.metadata)}function dd(e,t,d){d=new p(d);for(var n=Qt(e),i;!(i=n()).done;){var r=i.value;if(d.country(r),d.leadingDigits()){if(t&&t.search(d.leadingDigits())===0)return r}else if(D({phone:t,country:r},void 0,d.metadata))return r}}var nd=250,id=new RegExp("["+R+y+"]"),rd=new RegExp("[^"+y+"#]+$");function od(e,t,d){if(t=t||{},d=new p(d),t.defaultCountry&&!d.hasCountry(t.defaultCountry))throw t.v2?new $("INVALID_COUNTRY"):new Error("Unknown country: ".concat(t.defaultCountry));var n=fd(e,t.v2,t.extract),i=n.number,r=n.ext,a=n.error;if(!i){if(t.v2)throw a==="TOO_SHORT"?new $("TOO_SHORT"):new $("NOT_A_NUMBER");return{}}var o=ld(i,t.defaultCountry,t.defaultCallingCode,d),l=o.country,u=o.nationalNumber,c=o.countryCallingCode,v=o.carrierCode;if(!d.hasSelectedNumberingPlan()){if(t.v2)throw new $("INVALID_COUNTRY");return{}}if(!u||u.length<F){if(t.v2)throw new $("TOO_SHORT");return{}}if(u.length>De){if(t.v2)throw new $("TOO_LONG");return{}}if(t.v2){var x=new Ut(c,u,d.metadata);return l&&(x.country=l),v&&(x.carrierCode=v),r&&(x.ext=r),x}var k=(t.extended?d.hasSelectedNumberingPlan():l)?g(u,d.nationalNumberPattern()):!1;return t.extended?{country:l,countryCallingCode:c,carrierCode:v,valid:k,possible:k?!0:!!(t.extended===!0&&d.possibleLengths()&&fe(u,d)),phone:u,ext:r}:k?ud(l,u,r):{}}function ad(e,t,d){if(e){if(e.length>nd){if(d)throw new $("TOO_LONG");return}if(t===!1)return e;var n=e.search(id);if(!(n<0))return e.slice(n).replace(rd,"")}}function fd(e,t,d){if(e&&e.indexOf("tel:")===0)return kt(e);var n=ad(e,d,t);if(!n)return{};if(!de(n))return at(n)?{error:"TOO_SHORT"}:{};var i=ft(n);return i.ext?i:{number:n}}function ud(e,t,d){var n={country:e,phone:t};return d&&(n.ext=d),n}function ld(e,t,d,n){var i=Yt(re(e),t,d,n.metadata),r=i.countryCallingCode,a=i.number,o;if(r)n.selectNumberingPlan(r);else if(a&&(t||d))n.selectNumberingPlan(t,d),t&&(o=t),r=d||V(t,n.metadata);else return{};if(!a)return{countryCallingCode:r};var l=B(re(a),n),u=l.nationalNumber,c=l.carrierCode,v=td(r,u,n);return v&&(o=v,v==="001"||n.country(o)),{country:o,countryCallingCode:r,nationalNumber:u,carrierCode:c}}function xe(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function me(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?xe(Object(d),!0).forEach(function(n){sd(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):xe(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function sd(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}function pd(e,t,d){return od(e,me(me({},t),{},{v2:!0}),d)}function M(e){return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function Pe(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function vd(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?Pe(Object(d),!0).forEach(function(n){cd(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):Pe(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function cd(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}function gd(e,t){return bd(e)||yd(e,t)||$d(e,t)||hd()}function hd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $d(e,t){if(e){if(typeof e=="string")return ke(e,t);var d=Object.prototype.toString.call(e).slice(8,-1);if(d==="Object"&&e.constructor&&(d=e.constructor.name),d==="Map"||d==="Set")return Array.from(e);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return ke(e,t)}}function ke(e,t){(t==null||t>e.length)&&(t=e.length);for(var d=0,n=new Array(t);d<t;d++)n[d]=e[d];return n}function yd(e,t){var d=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(d!=null){var n=[],i=!0,r=!1,a,o;try{for(d=d.call(e);!(i=(a=d.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(l){r=!0,o=l}finally{try{!i&&d.return!=null&&d.return()}finally{if(r)throw o}}return n}}function bd(e){if(Array.isArray(e))return e}function xd(e){var t=Array.prototype.slice.call(e),d=gd(t,4),n=d[0],i=d[1],r=d[2],a=d[3],o,l,u;if(typeof n=="string")o=n;else throw new TypeError("A text for parsing must be a string.");if(!i||typeof i=="string")a?(l=r,u=a):(l=void 0,u=r),i&&(l=vd({defaultCountry:i},l));else if(md(i))r?(l=i,u=r):u=i;else throw new Error("Invalid second argument: ".concat(i));return{text:o,options:l,metadata:u}}var md=function(t){return M(t)==="object"};function we(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function Le(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?we(Object(d),!0).forEach(function(n){Pd(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):we(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function Pd(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}function kd(e,t,d){t&&t.defaultCountry&&!et(t.defaultCountry,d)&&(t=Le(Le({},t),{},{defaultCountry:void 0}));try{return pd(e,t,d)}catch(n){if(!(n instanceof $))throw n}}function wd(){var e=xd(arguments),t=e.text,d=e.options,n=e.metadata;return kd(t,d,n)}function U(){return Ae(wd,arguments)}const Ld={beforeMount(e,t,d){if(typeof t.value!="function"){const n=d.context.name;let i=`[Vue-click-outside:] provided expression ${t.expression} is not a function, but has to be`;n&&(i+=`Found in component ${n}`),console.warn(i)}e.clickOutsideEvent=function(n){e===n.target||e.contains(n.target)||t.value(n,e)},document.body.addEventListener("click",e.clickOutsideEvent)},unmounted(e){document.body.removeEventListener("click",e.clickOutsideEvent)}},Kd="",qd="",Xd=(e,t)=>{const d=e.__vccOpts||e;for(const[n,i]of t)d[n]=i;return d};function s(e){const t=O.options[e];return typeof t>"u"?O.options[e]:t}const Cd={name:"VueTelInput",directives:{clickOutside:Ld},props:{modelValue:{type:String,default:""},allCountries:{type:Array,default:()=>s("allCountries")},autoFormat:{type:Boolean,default:()=>s("autoFormat")},customValidate:{type:[Boolean,RegExp],default:()=>s("customValidate")},defaultCountry:{type:[String,Number],default:()=>s("defaultCountry")},disabled:{type:Boolean,default:()=>s("disabled")},autoDefaultCountry:{type:Boolean,default:()=>s("autoDefaultCountry")},dropdownOptions:{type:Object,default:()=>s("dropdownOptions")},ignoredCountries:{type:Array,default:()=>s("ignoredCountries")},inputOptions:{type:Object,default:()=>s("inputOptions")},invalidMsg:{type:String,default:()=>s("invalidMsg")},mode:{type:String,default:()=>s("mode")},onlyCountries:{type:Array,default:()=>s("onlyCountries")},preferredCountries:{type:Array,default:()=>s("preferredCountries")},validCharactersOnly:{type:Boolean,default:()=>s("validCharactersOnly")},styleClasses:{type:[String,Array,Object],default:()=>s("styleClasses")}},data(){return{phone:"",activeCountryCode:"",open:!1,finishMounted:!1,selectedIndex:null,typeToFindInput:"",typeToFindTimer:null,dropdownOpenDirection:"below",parsedPlaceholder:this.inputOptions.placeholder,searchQuery:""}},computed:{activeCountry(){return this.findCountry(this.activeCountryCode)},parsedMode(){return this.mode==="auto"?!this.phone||this.phone[0]!=="+"?"national":"international":["international","national"].includes(this.mode)?this.mode:(console.error('Invalid value of prop "mode"'),"international")},filteredCountries(){return this.onlyCountries.length?this.allCountries.filter(({iso2:e})=>this.onlyCountries.some(t=>t.toUpperCase()===e)):this.ignoredCountries.length?this.allCountries.filter(({iso2:e})=>!this.ignoredCountries.includes(e.toUpperCase())&&!this.ignoredCountries.includes(e.toLowerCase())):this.allCountries},sortedCountries(){const t=[...this.getCountries(this.preferredCountries).map(i=>({...i,preferred:!0})),...this.filteredCountries];if(!this.dropdownOptions.showSearchBox)return t;const n=this.searchQuery.replace(/[~`!@#$%^&*()+={}\[\];:\'\"<>.,\/\\\?-_]/g,"");return t.filter(i=>new RegExp(n,"i").test(i.name)||new RegExp(n,"i").test(i.iso2)||new RegExp(n,"i").test(i.dialCode))},phoneObject(){var r,a,o;let e;((r=this.phone)==null?void 0:r[0])==="+"?e=U(this.phone)||{}:e=U(this.phone,this.activeCountryCode)||{};const{metadata:t,...d}=e;let n=(a=e.isValid)==null?void 0:a.call(e),i=this.phone;return n&&(i=(o=e.format)==null?void 0:o.call(e,this.parsedMode.toUpperCase())),e.country&&(this.ignoredCountries.length||this.onlyCountries.length)&&(this.findCountry(e.country)||(n=!1,Object.assign(e,{country:null}))),Object.assign(d,{countryCode:e.country,valid:n,country:this.activeCountry,formatted:i}),d}},watch:{activeCountry(e,t){if(!e&&(t!=null&&t.iso2)){this.activeCountryCode=t.iso2;return}e!=null&&e.iso2&&this.$emit("country-changed",e)},"phoneObject.countryCode":function(e){this.activeCountryCode=e||""},"phoneObject.valid":function(){this.$emit("validate",this.phoneObject)},"phoneObject.formatted":function(e){!this.autoFormat||this.customValidate||(this.emitInput(e),this.$nextTick(()=>{e&&!this.modelValue&&(this.phone=e)}))},"inputOptions.placeholder":function(){this.resetPlaceholder()},modelValue(e,t){this.testCharacters()?this.phone=e:this.$nextTick(()=>{this.phone=t,this.onInput()})},open(e){e?(this.setDropdownPosition(),this.$emit("open")):this.$emit("close")}},mounted(){this.modelValue&&(this.phone=this.modelValue.trim()),this.cleanInvalidCharacters(),this.initializeCountry().then(()=>{var e;!this.phone&&((e=this.inputOptions)!=null&&e.showDialCode)&&this.activeCountryCode&&(this.phone=`+${this.activeCountryCode}`),this.$emit("validate",this.phoneObject)}).catch(console.error).then(()=>{this.finishMounted=!0})},methods:{resetPlaceholder(){this.parsedPlaceholder=this.inputOptions.placeholder},initializeCountry(){return new Promise(e=>{var d;if(((d=this.phone)==null?void 0:d[0])==="+"){e();return}if(this.defaultCountry){if(typeof this.defaultCountry=="string"){this.choose(this.defaultCountry),e();return}if(typeof this.defaultCountry=="number"){const n=this.findCountryByDialCode(this.defaultCountry);if(n){this.choose(n.iso2),e();return}}}const t=this.preferredCountries[0]||this.filteredCountries[0];this.autoDefaultCountry?Ne().then(n=>{this.choose(n||this.activeCountryCode)}).catch(n=>{console.warn(n),this.choose(t)}).then(()=>{e()}):(this.choose(t),e())})},getCountries(e=[]){return e.map(t=>this.findCountry(t)).filter(Boolean)},findCountry(e=""){return this.filteredCountries.find(t=>t.iso2===e.toUpperCase())},findCountryByDialCode(e){return this.filteredCountries.find(t=>Number(t.dialCode)===e)},getItemClass(e,t){const d=this.selectedIndex===e,n=e===this.preferredCountries.length-1,i=this.preferredCountries.some(r=>r.toUpperCase()===t);return{highlighted:d,"last-preferred":n,preferred:i}},choose(e){var d,n;let t=e;if(typeof t=="string"&&(t=this.findCountry(t)),!!t){if(((d=this.phone)==null?void 0:d[0])==="+"&&t.iso2&&this.phoneObject.nationalNumber){this.activeCountryCode=t.iso2,this.phone=U(this.phoneObject.nationalNumber,t.iso2).formatInternational();return}if((n=this.inputOptions)!=null&&n.showDialCode&&t){this.phone=`+${t.dialCode}`,this.activeCountryCode=t.iso2||"";return}this.activeCountryCode=t.iso2||"",this.emitInput(this.phone)}},cleanInvalidCharacters(){const e=this.phone;if(this.validCharactersOnly){const t=this.phone.match(/[()\-+0-9\s]*/g);this.phone=t.join("")}if(this.customValidate&&this.customValidate instanceof RegExp){const t=this.phone.match(this.customValidate);this.phone=t.join("")}e!==this.phone&&this.emitInput(this.phone)},testCharacters(){return this.validCharactersOnly&&!/^[()\-+0-9\s]*$/.test(this.phone)?!1:this.customValidate?this.testCustomValidate():!0},testCustomValidate(){return this.customValidate instanceof RegExp?this.customValidate.test(this.phone):!1},onInput(){this.$refs.input.setCustomValidity(this.phoneObject.valid?"":this.invalidMsg),this.emitInput(this.phone)},emitInput(e){this.$emit("update:modelValue",e),this.$emit("on-input",e,this.phoneObject,this.$refs.input)},onBlur(){this.$emit("blur")},onFocus(){Te(this.$refs.input,this.phone.length),this.$emit("focus")},onEnter(){this.$emit("enter")},onSpace(){this.$emit("space")},focus(){this.$refs.input.focus()},toggleDropdown(){this.disabled||this.dropdownOptions.disabled||(this.searchQuery="",this.open=!this.open)},clickedOutside(){this.open=!1},keyboardNav(e){if(e.keyCode===40){e.preventDefault(),this.open=!0,this.selectedIndex===null?this.selectedIndex=0:this.selectedIndex=Math.min(this.sortedCountries.length-1,this.selectedIndex+1);const t=this.$refs.list.children[this.selectedIndex];t.focus(),t.offsetTop+t.clientHeight>this.$refs.list.scrollTop+this.$refs.list.clientHeight&&(this.$refs.list.scrollTop=t.offsetTop-this.$refs.list.clientHeight+t.clientHeight)}else if(e.keyCode===38){e.preventDefault(),this.open=!0,this.selectedIndex===null?this.selectedIndex=this.sortedCountries.length-1:this.selectedIndex=Math.max(0,this.selectedIndex-1);const t=this.$refs.list.children[this.selectedIndex];t.focus(),t.offsetTop<this.$refs.list.scrollTop&&(this.$refs.list.scrollTop=t.offsetTop)}else if(e.keyCode===13)this.selectedIndex!==null&&this.choose(this.sortedCountries[this.selectedIndex]),this.open=!this.open;else{this.typeToFindInput+=e.key,clearTimeout(this.typeToFindTimer),this.typeToFindTimer=setTimeout(()=>{this.typeToFindInput=""},700);const t=this.sortedCountries.slice(this.preferredCountries.length).findIndex(d=>d.name.toLowerCase().startsWith(this.typeToFindInput));if(t>=0){this.selectedIndex=this.preferredCountries.length+t;const d=this.$refs.list.children[this.selectedIndex],n=d.offsetTop<this.$refs.list.scrollTop,i=d.offsetTop+d.clientHeight>this.$refs.list.scrollTop+this.$refs.list.clientHeight;(n||i)&&(this.$refs.list.scrollTop=d.offsetTop-this.$refs.list.clientHeight/2)}}},reset(){this.selectedIndex=this.sortedCountries.map(e=>e.iso2).indexOf(this.activeCountryCode),this.open=!1},setDropdownPosition(){window.innerHeight-this.$el.getBoundingClientRect().bottom>200?this.dropdownOpenDirection="below":this.dropdownOpenDirection="above"}}},Nd=["aria-expanded","tabindex"],Td={class:"vti__selection"},Od={key:1,class:"vti__country-code"},Ad={class:"vti__dropdown-arrow"},Id=["placeholder"],Fd=["onClick","onMousemove","aria-selected"],Rd={key:1},Sd=["type","autocomplete","autofocus","disabled","id","maxlength","name","placeholder","readonly","required","tabindex","value","aria-describedby"];function Vd(e,t,d,n,i,r){const a=f.resolveDirective("click-outside");return f.openBlock(),f.createElementBlock("div",{class:f.normalizeClass(["vue-tel-input",d.styleClasses,{disabled:d.disabled}])},[f.withDirectives((f.openBlock(),f.createElementBlock("div",{"aria-label":"Country Code Selector","aria-haspopup":"listbox","aria-expanded":i.open,role:"button",class:f.normalizeClass(["vti__dropdown",{open:i.open,disabled:d.dropdownOptions.disabled}]),tabindex:d.dropdownOptions.tabindex,onKeydown:[t[2]||(t[2]=(...o)=>r.keyboardNav&&r.keyboardNav(...o)),t[4]||(t[4]=f.withKeys((...o)=>r.toggleDropdown&&r.toggleDropdown(...o),["space"])),t[5]||(t[5]=f.withKeys((...o)=>r.reset&&r.reset(...o),["esc"])),t[6]||(t[6]=f.withKeys((...o)=>r.reset&&r.reset(...o),["tab"]))],onClick:t[3]||(t[3]=(...o)=>r.toggleDropdown&&r.toggleDropdown(...o))},[f.createElementVNode("span",Td,[d.dropdownOptions.showFlags?(f.openBlock(),f.createElementBlock("span",{key:0,class:f.normalizeClass(["vti__flag",i.activeCountryCode.toLowerCase()])},null,2)):f.createCommentVNode("",!0),d.dropdownOptions.showDialCodeInSelection?(f.openBlock(),f.createElementBlock("span",Od," +"+f.toDisplayString(r.activeCountry&&r.activeCountry.dialCode),1)):f.createCommentVNode("",!0),f.renderSlot(e.$slots,"arrow-icon",{open:i.open},()=>[f.createElementVNode("span",Ad,f.toDisplayString(i.open?"▲":"▼"),1)])]),i.open?(f.openBlock(),f.createElementBlock("ul",{key:0,ref:"list",class:f.normalizeClass(["vti__dropdown-list",i.dropdownOpenDirection]),role:"listbox"},[d.dropdownOptions.showSearchBox?f.withDirectives((f.openBlock(),f.createElementBlock("input",{key:0,class:"vti__input vti__search_box","aria-label":"Search by country name or country code",placeholder:r.sortedCountries.length?r.sortedCountries[0].name:"",type:"text","onUpdate:modelValue":t[0]||(t[0]=o=>i.searchQuery=o),onClick:t[1]||(t[1]=f.withModifiers(()=>{},["stop"]))},null,8,Id)),[[f.vModelText,i.searchQuery]]):f.createCommentVNode("",!0),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(r.sortedCountries,(o,l)=>(f.openBlock(),f.createElementBlock("li",{role:"option",class:f.normalizeClass(["vti__dropdown-item",r.getItemClass(l,o.iso2)]),key:o.iso2+(o.preferred?"-preferred":""),tabindex:"-1",onClick:u=>r.choose(o),onMousemove:u=>i.selectedIndex=l,"aria-selected":i.activeCountryCode===o.iso2&&!o.preferred},[d.dropdownOptions.showFlags?(f.openBlock(),f.createElementBlock("span",{key:0,class:f.normalizeClass(["vti__flag",o.iso2.toLowerCase()])},null,2)):f.createCommentVNode("",!0),f.createElementVNode("strong",null,f.toDisplayString(o.name),1),d.dropdownOptions.showDialCodeInList?(f.openBlock(),f.createElementBlock("span",Rd," +"+f.toDisplayString(o.dialCode),1)):f.createCommentVNode("",!0)],42,Fd))),128))],2)):f.createCommentVNode("",!0)],42,Nd)),[[a,r.clickedOutside]]),f.withDirectives(f.createElementVNode("input",{"onUpdate:modelValue":t[7]||(t[7]=o=>i.phone=o),ref:"input",type:d.inputOptions.type,autocomplete:d.inputOptions.autocomplete,autofocus:d.inputOptions.autofocus,class:f.normalizeClass(["vti__input",d.inputOptions.styleClasses]),disabled:d.disabled,id:d.inputOptions.id,maxlength:d.inputOptions.maxlength,name:d.inputOptions.name,placeholder:i.parsedPlaceholder,readonly:d.inputOptions.readonly,required:d.inputOptions.required,tabindex:d.inputOptions.tabindex,value:d.modelValue,"aria-describedby":d.inputOptions["aria-describedby"],onBlur:t[8]||(t[8]=(...o)=>r.onBlur&&r.onBlur(...o)),onFocus:t[9]||(t[9]=(...o)=>r.onFocus&&r.onFocus(...o)),onInput:t[10]||(t[10]=(...o)=>r.onInput&&r.onInput(...o)),onKeyup:[t[11]||(t[11]=f.withKeys((...o)=>r.onEnter&&r.onEnter(...o),["enter"])),t[12]||(t[12]=f.withKeys((...o)=>r.onSpace&&r.onSpace(...o),["space"]))]},null,42,Sd),[[f.vModelDynamic,i.phone]]),f.renderSlot(e.$slots,"icon-right")],2)}const Xe=Xd(Cd,[["render",Vd]]),Ed={install(e,t={}){const{dropdownOptions:d,inputOptions:n,...i}=t,{dropdownOptions:r,inputOptions:a,...o}=K;O.options={inputOptions:{...a,...n},dropdownOptions:{...r,...d},...o,...i},e.component("vue-tel-input",Xe)}};h.VueTelInput=Xe,h.default=Ed,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $d(e,t){if(e){if(typeof e=="string")return ke(e,t);var d=Object.prototype.toString.call(e).slice(8,-1);if(d==="Object"&&e.constructor&&(d=e.constructor.name),d==="Map"||d==="Set")return Array.from(e);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return ke(e,t)}}function ke(e,t){(t==null||t>e.length)&&(t=e.length);for(var d=0,n=new Array(t);d<t;d++)n[d]=e[d];return n}function yd(e,t){var d=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(d!=null){var n=[],i=!0,r=!1,a,o;try{for(d=d.call(e);!(i=(a=d.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(l){r=!0,o=l}finally{try{!i&&d.return!=null&&d.return()}finally{if(r)throw o}}return n}}function bd(e){if(Array.isArray(e))return e}function xd(e){var t=Array.prototype.slice.call(e),d=gd(t,4),n=d[0],i=d[1],r=d[2],a=d[3],o,l,u;if(typeof n=="string")o=n;else throw new TypeError("A text for parsing must be a string.");if(!i||typeof i=="string")a?(l=r,u=a):(l=void 0,u=r),i&&(l=vd({defaultCountry:i},l));else if(md(i))r?(l=i,u=r):u=i;else throw new Error("Invalid second argument: ".concat(i));return{text:o,options:l,metadata:u}}var md=function(t){return M(t)==="object"};function we(e,t){var d=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),d.push.apply(d,n)}return d}function Le(e){for(var t=1;t<arguments.length;t++){var d=arguments[t]!=null?arguments[t]:{};t%2?we(Object(d),!0).forEach(function(n){Pd(e,n,d[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(d)):we(Object(d)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(d,n))})}return e}function Pd(e,t,d){return t in e?Object.defineProperty(e,t,{value:d,enumerable:!0,configurable:!0,writable:!0}):e[t]=d,e}function kd(e,t,d){t&&t.defaultCountry&&!et(t.defaultCountry,d)&&(t=Le(Le({},t),{},{defaultCountry:void 0}));try{return pd(e,t,d)}catch(n){if(!(n instanceof $))throw n}}function wd(){var e=xd(arguments),t=e.text,d=e.options,n=e.metadata;return kd(t,d,n)}function U(){return Ae(wd,arguments)}const Ld={beforeMount(e,t,d){if(typeof t.value!="function"){const n=d.context.name;let i=`[Vue-click-outside:] provided expression ${t.expression} is not a function, but has to be`;n&&(i+=`Found in component ${n}`),console.warn(i)}e.clickOutsideEvent=function(n){const i=n.composedPath?n.composedPath():n.path;e===n.target||e.contains(n.target)||i.includes(e)||t.value(n,e)},document.body.addEventListener("click",e.clickOutsideEvent)},unmounted(e){document.body.removeEventListener("click",e.clickOutsideEvent)}},Kd="",qd="",Xd=(e,t)=>{const d=e.__vccOpts||e;for(const[n,i]of t)d[n]=i;return d};function s(e){const t=O.options[e];return typeof t>"u"?O.options[e]:t}const Cd={name:"VueTelInput",directives:{clickOutside:Ld},props:{modelValue:{type:String,default:""},allCountries:{type:Array,default:()=>s("allCountries")},autoFormat:{type:Boolean,default:()=>s("autoFormat")},customValidate:{type:[Boolean,RegExp],default:()=>s("customValidate")},defaultCountry:{type:[String,Number],default:()=>s("defaultCountry")},disabled:{type:Boolean,default:()=>s("disabled")},autoDefaultCountry:{type:Boolean,default:()=>s("autoDefaultCountry")},dropdownOptions:{type:Object,default:()=>s("dropdownOptions")},ignoredCountries:{type:Array,default:()=>s("ignoredCountries")},inputOptions:{type:Object,default:()=>s("inputOptions")},invalidMsg:{type:String,default:()=>s("invalidMsg")},mode:{type:String,default:()=>s("mode")},onlyCountries:{type:Array,default:()=>s("onlyCountries")},preferredCountries:{type:Array,default:()=>s("preferredCountries")},validCharactersOnly:{type:Boolean,default:()=>s("validCharactersOnly")},styleClasses:{type:[String,Array,Object],default:()=>s("styleClasses")}},data(){return{phone:"",activeCountryCode:"",open:!1,finishMounted:!1,selectedIndex:null,typeToFindInput:"",typeToFindTimer:null,dropdownOpenDirection:"below",parsedPlaceholder:this.inputOptions.placeholder,searchQuery:""}},computed:{activeCountry(){return this.findCountry(this.activeCountryCode)},parsedMode(){return this.mode==="auto"?!this.phone||this.phone[0]!=="+"?"national":"international":["international","national"].includes(this.mode)?this.mode:(console.error('Invalid value of prop "mode"'),"international")},filteredCountries(){return this.onlyCountries.length?this.allCountries.filter(({iso2:e})=>this.onlyCountries.some(t=>t.toUpperCase()===e)):this.ignoredCountries.length?this.allCountries.filter(({iso2:e})=>!this.ignoredCountries.includes(e.toUpperCase())&&!this.ignoredCountries.includes(e.toLowerCase())):this.allCountries},sortedCountries(){const t=[...this.getCountries(this.preferredCountries).map(i=>({...i,preferred:!0})),...this.filteredCountries];if(!this.dropdownOptions.showSearchBox)return t;const n=this.searchQuery.replace(/[~`!@#$%^&*()+={}\[\];:\'\"<>.,\/\\\?-_]/g,"");return t.filter(i=>new RegExp(n,"i").test(i.name)||new RegExp(n,"i").test(i.iso2)||new RegExp(n,"i").test(i.dialCode))},phoneObject(){var r,a,o;let e;((r=this.phone)==null?void 0:r[0])==="+"?e=U(this.phone)||{}:e=U(this.phone,this.activeCountryCode)||{};const{metadata:t,...d}=e;let n=(a=e.isValid)==null?void 0:a.call(e),i=this.phone;return n&&(i=(o=e.format)==null?void 0:o.call(e,this.parsedMode.toUpperCase())),e.country&&(this.ignoredCountries.length||this.onlyCountries.length)&&(this.findCountry(e.country)||(n=!1,Object.assign(e,{country:null}))),Object.assign(d,{countryCode:e.country,valid:n,country:this.activeCountry,formatted:i}),d}},watch:{activeCountry(e,t){if(!e&&(t!=null&&t.iso2)){this.activeCountryCode=t.iso2;return}e!=null&&e.iso2&&this.$emit("country-changed",e)},"phoneObject.countryCode":function(e){this.activeCountryCode=e||""},"phoneObject.valid":function(){this.$emit("validate",this.phoneObject)},"phoneObject.formatted":function(e){!this.autoFormat||this.customValidate||(this.emitInput(e),this.$nextTick(()=>{e&&!this.modelValue&&(this.phone=e)}))},"inputOptions.placeholder":function(){this.resetPlaceholder()},modelValue(e,t){this.testCharacters()?this.phone=e:this.$nextTick(()=>{this.phone=t,this.onInput()})},open(e){e?(this.setDropdownPosition(),this.$emit("open")):this.$emit("close")}},mounted(){this.modelValue&&(this.phone=this.modelValue.trim()),this.cleanInvalidCharacters(),this.initializeCountry().then(()=>{var e;!this.phone&&((e=this.inputOptions)!=null&&e.showDialCode)&&this.activeCountryCode&&(this.phone=`+${this.activeCountryCode}`),this.$emit("validate",this.phoneObject)}).catch(console.error).then(()=>{this.finishMounted=!0})},methods:{resetPlaceholder(){this.parsedPlaceholder=this.inputOptions.placeholder},initializeCountry(){return new Promise(e=>{var d;if(((d=this.phone)==null?void 0:d[0])==="+"){e();return}if(this.defaultCountry){if(typeof this.defaultCountry=="string"){this.choose(this.defaultCountry),e();return}if(typeof this.defaultCountry=="number"){const n=this.findCountryByDialCode(this.defaultCountry);if(n){this.choose(n.iso2),e();return}}}const t=this.preferredCountries[0]||this.filteredCountries[0];this.autoDefaultCountry?Ne().then(n=>{this.choose(n||this.activeCountryCode)}).catch(n=>{console.warn(n),this.choose(t)}).then(()=>{e()}):(this.choose(t),e())})},getCountries(e=[]){return e.map(t=>this.findCountry(t)).filter(Boolean)},findCountry(e=""){return this.filteredCountries.find(t=>t.iso2===e.toUpperCase())},findCountryByDialCode(e){return this.filteredCountries.find(t=>Number(t.dialCode)===e)},getItemClass(e,t){const d=this.selectedIndex===e,n=e===this.preferredCountries.length-1,i=this.preferredCountries.some(r=>r.toUpperCase()===t);return{highlighted:d,"last-preferred":n,preferred:i}},choose(e){var d,n;let t=e;if(typeof t=="string"&&(t=this.findCountry(t)),!!t){if(((d=this.phone)==null?void 0:d[0])==="+"&&t.iso2&&this.phoneObject.nationalNumber){this.activeCountryCode=t.iso2,this.phone=U(this.phoneObject.nationalNumber,t.iso2).formatInternational();return}if((n=this.inputOptions)!=null&&n.showDialCode&&t){this.phone=`+${t.dialCode}`,this.activeCountryCode=t.iso2||"";return}this.activeCountryCode=t.iso2||"",this.emitInput(this.phone)}},cleanInvalidCharacters(){const e=this.phone;if(this.validCharactersOnly){const t=this.phone.match(/[()\-+0-9\s]*/g);this.phone=t.join("")}if(this.customValidate&&this.customValidate instanceof RegExp){const t=this.phone.match(this.customValidate);this.phone=t.join("")}e!==this.phone&&this.emitInput(this.phone)},testCharacters(){return this.validCharactersOnly&&!/^[()\-+0-9\s]*$/.test(this.phone)?!1:this.customValidate?this.testCustomValidate():!0},testCustomValidate(){return this.customValidate instanceof RegExp?this.customValidate.test(this.phone):!1},onInput(){this.$refs.input.setCustomValidity(this.phoneObject.valid?"":this.invalidMsg),this.emitInput(this.phone)},emitInput(e){this.$emit("update:modelValue",e),this.$emit("on-input",e,this.phoneObject,this.$refs.input)},onBlur(){this.$emit("blur")},onFocus(){Te(this.$refs.input,this.phone.length),this.$emit("focus")},onEnter(){this.$emit("enter")},onSpace(){this.$emit("space")},focus(){this.$refs.input.focus()},toggleDropdown(){this.disabled||this.dropdownOptions.disabled||(this.searchQuery="",this.open=!this.open)},clickedOutside(){this.open=!1},keyboardNav(e){if(e.keyCode===40){e.preventDefault(),this.open=!0,this.selectedIndex===null?this.selectedIndex=0:this.selectedIndex=Math.min(this.sortedCountries.length-1,this.selectedIndex+1);const t=this.$refs.list.children[this.selectedIndex];t.focus(),t.offsetTop+t.clientHeight>this.$refs.list.scrollTop+this.$refs.list.clientHeight&&(this.$refs.list.scrollTop=t.offsetTop-this.$refs.list.clientHeight+t.clientHeight)}else if(e.keyCode===38){e.preventDefault(),this.open=!0,this.selectedIndex===null?this.selectedIndex=this.sortedCountries.length-1:this.selectedIndex=Math.max(0,this.selectedIndex-1);const t=this.$refs.list.children[this.selectedIndex];t.focus(),t.offsetTop<this.$refs.list.scrollTop&&(this.$refs.list.scrollTop=t.offsetTop)}else if(e.keyCode===13)this.selectedIndex!==null&&this.choose(this.sortedCountries[this.selectedIndex]),this.open=!this.open;else{this.typeToFindInput+=e.key,clearTimeout(this.typeToFindTimer),this.typeToFindTimer=setTimeout(()=>{this.typeToFindInput=""},700);const t=this.sortedCountries.slice(this.preferredCountries.length).findIndex(d=>d.name.toLowerCase().startsWith(this.typeToFindInput));if(t>=0){this.selectedIndex=this.preferredCountries.length+t;const d=this.$refs.list.children[this.selectedIndex],n=d.offsetTop<this.$refs.list.scrollTop,i=d.offsetTop+d.clientHeight>this.$refs.list.scrollTop+this.$refs.list.clientHeight;(n||i)&&(this.$refs.list.scrollTop=d.offsetTop-this.$refs.list.clientHeight/2)}}},reset(){this.selectedIndex=this.sortedCountries.map(e=>e.iso2).indexOf(this.activeCountryCode),this.open=!1},setDropdownPosition(){window.innerHeight-this.$el.getBoundingClientRect().bottom>200?this.dropdownOpenDirection="below":this.dropdownOpenDirection="above"}}},Nd=["aria-expanded","tabindex"],Td={class:"vti__selection"},Od={key:1,class:"vti__country-code"},Ad={class:"vti__dropdown-arrow"},Id=["placeholder"],Fd=["onClick","onMousemove","aria-selected"],Rd={key:1},Sd=["type","autocomplete","autofocus","disabled","id","maxlength","name","placeholder","readonly","required","tabindex","value","aria-describedby"];function Vd(e,t,d,n,i,r){const a=f.resolveDirective("click-outside");return f.openBlock(),f.createElementBlock("div",{class:f.normalizeClass(["vue-tel-input",d.styleClasses,{disabled:d.disabled}])},[f.withDirectives((f.openBlock(),f.createElementBlock("div",{"aria-label":"Country Code Selector","aria-haspopup":"listbox","aria-expanded":i.open,role:"button",class:f.normalizeClass(["vti__dropdown",{open:i.open,disabled:d.dropdownOptions.disabled}]),tabindex:d.dropdownOptions.tabindex,onKeydown:[t[2]||(t[2]=(...o)=>r.keyboardNav&&r.keyboardNav(...o)),t[4]||(t[4]=f.withKeys((...o)=>r.toggleDropdown&&r.toggleDropdown(...o),["space"])),t[5]||(t[5]=f.withKeys((...o)=>r.reset&&r.reset(...o),["esc"])),t[6]||(t[6]=f.withKeys((...o)=>r.reset&&r.reset(...o),["tab"]))],onClick:t[3]||(t[3]=(...o)=>r.toggleDropdown&&r.toggleDropdown(...o))},[f.createElementVNode("span",Td,[d.dropdownOptions.showFlags?(f.openBlock(),f.createElementBlock("span",{key:0,class:f.normalizeClass(["vti__flag",i.activeCountryCode.toLowerCase()])},null,2)):f.createCommentVNode("",!0),d.dropdownOptions.showDialCodeInSelection?(f.openBlock(),f.createElementBlock("span",Od," +"+f.toDisplayString(r.activeCountry&&r.activeCountry.dialCode),1)):f.createCommentVNode("",!0),f.renderSlot(e.$slots,"arrow-icon",{open:i.open},()=>[f.createElementVNode("span",Ad,f.toDisplayString(i.open?"▲":"▼"),1)])]),i.open?(f.openBlock(),f.createElementBlock("ul",{key:0,ref:"list",class:f.normalizeClass(["vti__dropdown-list",i.dropdownOpenDirection]),role:"listbox"},[d.dropdownOptions.showSearchBox?f.withDirectives((f.openBlock(),f.createElementBlock("input",{key:0,class:"vti__input vti__search_box","aria-label":"Search by country name or country code",placeholder:r.sortedCountries.length?r.sortedCountries[0].name:"",type:"text","onUpdate:modelValue":t[0]||(t[0]=o=>i.searchQuery=o),onClick:t[1]||(t[1]=f.withModifiers(()=>{},["stop"]))},null,8,Id)),[[f.vModelText,i.searchQuery]]):f.createCommentVNode("",!0),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(r.sortedCountries,(o,l)=>(f.openBlock(),f.createElementBlock("li",{role:"option",class:f.normalizeClass(["vti__dropdown-item",r.getItemClass(l,o.iso2)]),key:o.iso2+(o.preferred?"-preferred":""),tabindex:"-1",onClick:u=>r.choose(o),onMousemove:u=>i.selectedIndex=l,"aria-selected":i.activeCountryCode===o.iso2&&!o.preferred},[d.dropdownOptions.showFlags?(f.openBlock(),f.createElementBlock("span",{key:0,class:f.normalizeClass(["vti__flag",o.iso2.toLowerCase()])},null,2)):f.createCommentVNode("",!0),f.createElementVNode("strong",null,f.toDisplayString(o.name),1),d.dropdownOptions.showDialCodeInList?(f.openBlock(),f.createElementBlock("span",Rd," +"+f.toDisplayString(o.dialCode),1)):f.createCommentVNode("",!0)],42,Fd))),128))],2)):f.createCommentVNode("",!0)],42,Nd)),[[a,r.clickedOutside]]),f.withDirectives(f.createElementVNode("input",{"onUpdate:modelValue":t[7]||(t[7]=o=>i.phone=o),ref:"input",type:d.inputOptions.type,autocomplete:d.inputOptions.autocomplete,autofocus:d.inputOptions.autofocus,class:f.normalizeClass(["vti__input",d.inputOptions.styleClasses]),disabled:d.disabled,id:d.inputOptions.id,maxlength:d.inputOptions.maxlength,name:d.inputOptions.name,placeholder:i.parsedPlaceholder,readonly:d.inputOptions.readonly,required:d.inputOptions.required,tabindex:d.inputOptions.tabindex,value:d.modelValue,"aria-describedby":d.inputOptions["aria-describedby"],onBlur:t[8]||(t[8]=(...o)=>r.onBlur&&r.onBlur(...o)),onFocus:t[9]||(t[9]=(...o)=>r.onFocus&&r.onFocus(...o)),onInput:t[10]||(t[10]=(...o)=>r.onInput&&r.onInput(...o)),onKeyup:[t[11]||(t[11]=f.withKeys((...o)=>r.onEnter&&r.onEnter(...o),["enter"])),t[12]||(t[12]=f.withKeys((...o)=>r.onSpace&&r.onSpace(...o),["space"]))]},null,42,Sd),[[f.vModelDynamic,i.phone]]),f.renderSlot(e.$slots,"icon-right")],2)}const Xe=Xd(Cd,[["render",Vd]]),Ed={install(e,t={}){const{dropdownOptions:d,inputOptions:n,...i}=t,{dropdownOptions:r,inputOptions:a,...o}=K;O.options={inputOptions:{...a,...n},dropdownOptions:{...r,...d},...o,...i},e.component("vue-tel-input",Xe)}};h.VueTelInput=Xe,h.default=Ed,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|