UNPKG

ngx-mask

Version:
2 lines 24.6 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("ngx-mask",["exports","@angular/core","@angular/common","@angular/forms"],t):t((e=e||self)["ngx-mask"]={},e.ng.core,e.ng.common,e.ng.forms)}(this,function(e,t,i,s){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};var n=function(){return(n=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function a(e,t,i,s){var r,n=arguments.length,a=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(n<3?r(a):n>3?r(t,i,a):r(t,i))||a);return n>3&&a&&Object.defineProperty(t,i,a),a}function o(e,t){return function(i,s){t(i,s,e)}}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t){var i,s,r,n,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:o(0),"throw":o(1),"return":o(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function o(n){return function(o){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,s&&(r=2&n[0]?s["return"]:n[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,n[1])).done)return r;switch(s=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,s=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){a.label=n[1];break}if(6===n[0]&&a.label<r[1]){a.label=r[1],r=n;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(n);break}r[2]&&a.ops.pop(),a.trys.pop();continue}n=t.call(e,a)}catch(o){n=[6,o],s=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}}function l(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var s,r,n=i.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(o){r={error:o}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(r)throw r.error}}return a}var c=new t.InjectionToken("config"),u=new t.InjectionToken("NEW_CONFIG"),f=new t.InjectionToken("INITIAL_CONFIG"),m={sufix:"",prefix:"",clearIfNotMatch:!1,showTemplate:!1,showMaskTyped:!1,dropSpecialCharacters:!0,hiddenInput:!1,shownMaskExpression:"",validation:!0,specialCharacters:["-","/","(",")",".",":"," ","+",",","@","[","]",'"',"'"],patterns:{0:{pattern:new RegExp("\\d")},9:{pattern:new RegExp("\\d"),optional:!0},X:{pattern:new RegExp("\\d"),symbol:"*"},A:{pattern:new RegExp("[a-zA-Z0-9]")},S:{pattern:new RegExp("[a-zA-Z]")},d:{pattern:new RegExp("\\d")},m:{pattern:new RegExp("\\d")},M:{pattern:new RegExp("\\d")},H:{pattern:new RegExp("\\d")},h:{pattern:new RegExp("\\d")},s:{pattern:new RegExp("\\d")}}},d=["percent","Hh:m0:s0","Hh:m0","Hh","m0:s0","s0","m0","separator","dot_separator","comma_separator","d0/M0/0000","d0/M0","d0","M0"],k=function(){function e(e){this._config=e,this.maskExpression="",this.actualValue="",this.shownMaskExpression="",this.prevResult="",this.prevActualResult="",this.separator=function(e,t,i,s){for(var r=(e+="").split(i),n=r.length>1?""+i+r[1]:"",a=r[0],o=/(\d+)(\d{3})/;o.test(a);)a=a.replace(o,"$1"+t+"$2");return s===undefined?a+n:0===s?a:a+n.substr(0,s+1)},this.percentage=function(e){return Number(e)>=0&&Number(e)<=100},this.getPrecision=function(e){var t=e.split(".");return t.length>1?Number(t[t.length-1]):Infinity},this.checkInputPrecision=function(e,t,i){if(t<Infinity){var s=void 0;s="."===i?new RegExp("\\.\\d{"+t+"}.*$"):new RegExp(",\\d{"+t+"}.*$");var r=e.match(s);r&&r[0].length-1>t?e=e.substring(0,e.length-1):0===t&&e.endsWith(i)&&(e=e.substring(0,e.length-1))}return e},this._shift=new Set,this.clearIfNotMatch=this._config.clearIfNotMatch,this.dropSpecialCharacters=this._config.dropSpecialCharacters,this.maskSpecialCharacters=this._config.specialCharacters,this.maskAvailablePatterns=this._config.patterns,this.prefix=this._config.prefix,this.sufix=this._config.sufix,this.hiddenInput=this._config.hiddenInput}return e.prototype.applyMaskWithPattern=function(e,t){var i=l(t,2),s=i[0],r=i[1];return this.customPattern=r,this.applyMask(e,s)},e.prototype.applyMask=function(e,t,i,s){if(void 0===i&&(i=0),void 0===s&&(s=function(){}),e===undefined||null===e||t===undefined)return"";var r=0,n="",a=!1;e.slice(0,this.prefix.length)===this.prefix&&(e=e.slice(this.prefix.length,e.length));var o=e.toString().split("");if("percent"===t)(e.match("[a-z]|[A-Z]")||e.match(/[-!$%^&*()_+|~=`{}\[\]:";'<>?,\/]/))&&(e=this._checkInput(e)).length>=3&&"100"!==e&&(e=e.substring(0,5)),n=this.percentage(e)?e:e.substring(0,e.length-1);else if("separator"===t||"dot_separator"===t||t.startsWith("dot_separator")||"comma_separator"===t||t.startsWith("comma_separator")){(e.match("[a-z]|[A-Z]")||e.match(/[-@#!$%^&*()_+|~=`{}\[\]:";<>.?\/]/))&&(e=this._checkInput(e));var p=this.getPrecision(t),h=void 0;t.startsWith("dot_separator")&&(-1!==e.indexOf(".")&&e.indexOf(".")===e.lastIndexOf(".")&&e.indexOf(".")>3&&(e=e.replace(".",",")),e=e.length>1&&"0"===e[0]&&","!==e[1]?e.slice(1,e.length):e),t.startsWith("comma_separator")&&(e=e.length>1&&"0"===e[0]&&"."!==e[1]?e.slice(1,e.length):e),"separator"===t?(e.includes(",")&&e.endsWith(",")&&e.indexOf(",")!==e.lastIndexOf(",")&&(e=e.substring(0,e.length-1)),(e.match("[a-z]|[A-Z]")||e.match(/[@#!$%^&*()_+|~=`{}\[\]:.";<>?\/]/))&&(e=e.substring(0,e.length-1)),h=e.replace(/\s/g,""),n=this.separator(h," ",".",p)):"dot_separator"===t||t.startsWith("dot_separator")?((e.match("[a-z]|[A-Z]")||e.match(/[@#!$%^&*()_+|~=`{}\[\]:\s";<>?\/]/))&&(e=e.substring(0,e.length-1)),h=(e=this.checkInputPrecision(e,p,",")).replace(/\./g,""),n=this.separator(h,".",",",p)):("comma_separator"===t||t.startsWith("comma_separator"))&&(h=(e=this.checkInputPrecision(e,p,".")).replace(/\,/g,""),n=this.separator(h,",",".",p)),r=i=n.length+1;var l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0)}else for(var c=0,u=o[0];c<o.length&&r!==t.length;u=o[++c])if(this._checkSymbolMask(u,t[r])&&"?"===t[r+1])n+=u,r+=2;else if("*"===t[r+1]&&a&&this._checkSymbolMask(u,t[r+2]))n+=u,r+=3,a=!1;else if(this._checkSymbolMask(u,t[r])&&"*"===t[r+1])n+=u,a=!0;else if("?"===t[r+1]&&this._checkSymbolMask(u,t[r+2]))n+=u,r+=3;else if(this._checkSymbolMask(u,t[r])||this.hiddenInput&&this.maskAvailablePatterns[t[r]]&&this.maskAvailablePatterns[t[r]].symbol===u){if("H"===t[r]&&Number(u)>2){n+=0,r+=1;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--;continue}if("h"===t[r]&&"2"===n&&Number(u)>3)continue;if("m"===t[r]&&Number(u)>5){n+=0,r+=1;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--;continue}if("s"===t[r]&&Number(u)>5){n+=0,r+=1;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--;continue}if("d"===t[r]&&Number(u)>3){n+=0,r+=1;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--;continue}if("d"===t[r-1]&&Number(e.slice(r-1,r+1))>31)continue;if("M"===t[r]&&Number(u)>1){n+=0,r+=1;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--;continue}if("M"===t[r-1]&&Number(e.slice(r-1,r+1))>12)continue;n+=u,r++}else if(-1!==this.maskSpecialCharacters.indexOf(t[r])){n+=t[r],r++;l=/\*|\?/g.test(t.slice(0,r))?o.length:r;this._shift.add(l+this.prefix.length||0),c--}else this.maskSpecialCharacters.indexOf(u)>-1&&this.maskAvailablePatterns[t[r]]&&this.maskAvailablePatterns[t[r]].optional?(r++,c--):"*"===this.maskExpression[r+1]&&this._findSpecialChar(this.maskExpression[r+2])&&this._findSpecialChar(u)===this.maskExpression[r+2]&&a?(r+=3,n+=u):"?"===this.maskExpression[r+1]&&this._findSpecialChar(this.maskExpression[r+2])&&this._findSpecialChar(u)===this.maskExpression[r+2]&&a&&(r+=3,n+=u);n.length+1===t.length&&-1!==this.maskSpecialCharacters.indexOf(t[t.length-1])&&(n+=t[t.length-1]);for(var f=1,m=i+1;this._shift.has(m);)f++,m++;s(this._shift.has(i)?f:0);var d=""+this.prefix+n;return d=this.sufix?""+this.prefix+n+this.sufix:""+this.prefix+n,0===n.length&&(d=""+this.prefix+n),d},e.prototype._findSpecialChar=function(e){return this.maskSpecialCharacters.find(function(t){return t===e})},e.prototype._checkSymbolMask=function(e,t){return this.maskAvailablePatterns=this.customPattern?this.customPattern:this.maskAvailablePatterns,this.maskAvailablePatterns[t]&&this.maskAvailablePatterns[t].pattern&&this.maskAvailablePatterns[t].pattern.test(e)},e.prototype._checkInput=function(e){return e.split("").filter(function(e){return e.match("\\d")||"."===e||","===e}).join("")},e=a([t.Injectable(),o(0,t.Inject(c)),p("design:paramtypes",[Object])],e)}(),g=function(e){function s(t,i,s,r){var n=e.call(this,i)||this;return n.document=t,n._config=i,n._elementRef=s,n._renderer=r,n.validation=!0,n.maskExpression="",n.isNumberValue=!1,n.showMaskTyped=!1,n.maskIsShown="",n.selStart=null,n.selEnd=null,n.onChange=function(e){},n.onTouch=function(){},n._formElement=n._elementRef.nativeElement,n}return function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(s,e),s.prototype.applyMask=function(t,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=function(){}),this.maskIsShown=this.showMaskTyped?this.showMaskInInput():"",!t&&this.showMaskTyped)return this.prefix+this.maskIsShown;var n=t&&"number"==typeof this.selStart?t[this.selStart]:"",a="";if(this.hiddenInput){var o=this.actualValue.split("");""!==t&&o.length?"number"==typeof this.selStart&&"number"==typeof this.selEnd&&(t.length>o.length?o.splice(this.selStart,0,n):t.length<o.length&&(o.length-t.length==1?o.splice(this.selStart-1,1):o.splice(this.selStart,this.selEnd-this.selStart))):o=[],a=this.actualValue.length?this.shiftTypedSymbols(o.join("")):t}a=a.length?a:t;var p=e.prototype.applyMask.call(this,a,i,s,r);this.actualValue=this.getActualValue(p),!0===/dot_separator\.\d{1,}/.test(this.maskExpression)&&!0===this.dropSpecialCharacters&&(this.maskSpecialCharacters=this.maskSpecialCharacters.filter(function(e){return","!==e})),"dot_separator"===this.maskExpression&&!0===this.dropSpecialCharacters&&(this.maskSpecialCharacters=this.maskSpecialCharacters.filter(function(e){return","!==e})),!0===/comma_separator\.\d{1,}/.test(this.maskExpression)&&!0===this.dropSpecialCharacters&&(this.maskSpecialCharacters=this.maskSpecialCharacters.filter(function(e){return"."!==e})),"comma_separator"===this.maskExpression&&!0===this.dropSpecialCharacters&&(this.maskSpecialCharacters=this.maskSpecialCharacters.filter(function(e){return"."!==e})),Array.isArray(this.dropSpecialCharacters)?this.onChange(this._removeMask(this._removeSufix(this._removePrefix(p)),this.dropSpecialCharacters)):!0===this.dropSpecialCharacters?this.onChange(this._checkSymbols(p)):this.onChange(this._removeSufix(this._removePrefix(p)));if(!this.showMaskTyped)return this.hiddenInput&&p&&p.length?this.hideInput(p,this.maskExpression):p;var h=p.length;return p+(this.prefix+this.maskIsShown).slice(h)},s.prototype.applyValueChanges=function(e,t){void 0===e&&(e=0),void 0===t&&(t=function(){});var i=this.applyMask(this._formElement.value,this.maskExpression,e,t);this._formElement.value=i,this._formElement!==this.document.activeElement&&this.clearIfNotMatchFn()},s.prototype.hideInput=function(e,t){var i=this;return e.split("").map(function(e,s){return i.maskAvailablePatterns&&i.maskAvailablePatterns[t[s]]&&i.maskAvailablePatterns[t[s]].symbol?i.maskAvailablePatterns[t[s]].symbol:e}).join("")},s.prototype.getActualValue=function(e){var t=this,i=e.split("").filter(function(e,i){return t._checkSymbolMask(e,t.maskExpression[i])||t.maskSpecialCharacters.includes(t.maskExpression[i])&&e===t.maskExpression[i]});return i.join("")===e?i.join(""):e},s.prototype.shiftTypedSymbols=function(e){var t=this,i="";return(e&&e.split("").map(function(s,r){if(t.maskSpecialCharacters.includes(e[r+1])&&e[r+1]!==t.maskExpression[r+1])return i=s,e[r+1];if(i.length){var n=i;return i="",n}return s})||[]).join("")},s.prototype.showMaskInInput=function(){if(this.showMaskTyped&&this.shownMaskExpression){if(this.maskExpression.length!==this.shownMaskExpression.length)throw new Error("Mask expression must match mask placeholder length");return this.shownMaskExpression}return this.showMaskTyped?this.maskExpression.replace(/\w/g,"_"):""},s.prototype.clearIfNotMatchFn=function(){!0===this.clearIfNotMatch&&this.maskExpression.length!==this._formElement.value.length&&(this.formElementProperty=["value",""],this.applyMask(this._formElement.value,this.maskExpression))},Object.defineProperty(s.prototype,"formElementProperty",{set:function(e){var t=l(e,2),i=t[0],s=t[1];this._renderer.setProperty(this._formElement,i,s)},enumerable:!0,configurable:!0}),s.prototype.checkSpecialCharAmount=function(e){var t=this;return e.split("").filter(function(e){return t._findSpecialChar(e)}).length},s.prototype._removeMask=function(e,t){return e?e.replace(this._regExpForRemove(t),""):e},s.prototype._removePrefix=function(e){return this.prefix&&e?e.replace(this.prefix,""):e},s.prototype._removeSufix=function(e){return this.sufix&&e?e.replace(this.sufix,""):e},s.prototype._regExpForRemove=function(e){return new RegExp(e.map(function(e){return"\\"+e}).join("|"),"gi")},s.prototype._checkSymbols=function(e){return"dot_separator.2"===this.maskExpression?Number(this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters).replace(",",".")).toFixed(2):"comma_separator.2"===this.maskExpression?Number(this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters)).toFixed(2):this.isNumberValue?""===e?e:Number(this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters)):-1!==this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters).indexOf(",")?this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters).replace(",","."):this._removeMask(this._removeSufix(this._removePrefix(e)),this.maskSpecialCharacters)},s=a([t.Injectable(),o(0,t.Inject(i.DOCUMENT)),o(1,t.Inject(c)),p("design:paramtypes",[Object,Object,t.ElementRef,t.Renderer2])],s)}(k),y=function(){function e(e,t){this.document=e,this._maskService=t,this._position=null,this.onChange=function(e){},this.onTouch=function(){}}var r;return r=e,Object.defineProperty(e.prototype,"maskExpression",{set:function(e){this._maskValue=e||"",this._maskValue&&(this._maskService.maskExpression=this._repeatPatternSymbols(this._maskValue),this._maskService.formElementProperty=["value",this._maskService.applyMask(this._inputValue,this._maskService.maskExpression)])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"specialCharacters",{set:function(e){e&&Array.isArray(e)&&(!Array.isArray(e)||e.length)&&(this._maskService.maskSpecialCharacters=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"patterns",{set:function(e){e&&(this._maskService.maskAvailablePatterns=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"prefix",{set:function(e){e&&(this._maskService.prefix=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sufix",{set:function(e){e&&(this._maskService.sufix=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dropSpecialCharacters",{set:function(e){this._maskService.dropSpecialCharacters=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hiddenInput",{set:function(e){this._maskService.hiddenInput=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showMaskTyped",{set:function(e){e&&(this._maskService.showMaskTyped=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shownMaskExpression",{set:function(e){e&&(this._maskService.shownMaskExpression=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showTemplate",{set:function(e){this._maskService.showTemplate=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clearIfNotMatch",{set:function(e){this._maskService.clearIfNotMatch=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validation",{set:function(e){this._maskService.validation=e},enumerable:!0,configurable:!0}),e.prototype.validate=function(e){var t=e.value;if(!this._maskService.validation)return null;if(!0===/dot_separator\.\d{1,}/.test(this._maskValue)||!0===/comma_separator\.\d{1,}/.test(this._maskValue))return null;if(d.includes(this._maskValue))return null;if(this._maskService.clearIfNotMatch)return null;if(t&&t.toString().length>=1){var i=0;for(var s in this._maskService.maskAvailablePatterns)if(this._maskService.maskAvailablePatterns[s].optional&&!0===this._maskService.maskAvailablePatterns[s].optional){if(-1!==this._maskValue.indexOf(s)&&i++,-1!==this._maskValue.indexOf(s)&&t.toString().length>=this._maskValue.indexOf(s))return null;if(i===this._maskValue.length)return null}if(1===this._maskValue.indexOf("*")||1===this._maskValue.indexOf("?")||1===this._maskValue.indexOf("{"))return null;if(this._maskValue.indexOf("*")>1&&t.toString().length<this._maskValue.indexOf("*")||this._maskValue.indexOf("?")>1&&t.toString().length<this._maskValue.indexOf("?"))return{"Mask error":!0};if(-1===this._maskValue.indexOf("*")||-1===this._maskValue.indexOf("?")){var r=this._maskService.dropSpecialCharacters?this._maskValue.length-this._maskService.checkSpecialCharAmount(this._maskValue)-i:this._maskValue.length-i;if(t.toString().length!==r)return{"Mask error":!0}}}return null},e.prototype.onInput=function(e){var t=e.target;if(this._inputValue=t.value,this._maskValue){var i=1===t.selectionStart?t.selectionStart+this._maskService.prefix.length:t.selectionStart,s=0;this._maskService.applyValueChanges(i,function(e){return s=e}),this.document.activeElement===t&&(this._position=1===this._position&&1===this._inputValue.length?null:this._position,t.selectionStart=t.selectionEnd=null!==this._position?this._position:i+("Backspace"===this._code?0:s),this._position=null)}else this.onChange(t.value)},e.prototype.onBlur=function(){this._maskService.clearIfNotMatchFn(),this.onTouch()},e.prototype.onFocus=function(e){var t=e.target;null!==t&&null!==t.selectionStart&&t.selectionStart===t.selectionEnd&&t.selectionStart>this._maskService.prefix.length&&38!==e.keyCode&&this._maskService.showMaskTyped&&(this._maskService.maskIsShown=this._maskService.showMaskInInput(),t.setSelectionRange&&this._maskService.prefix+this._maskService.maskIsShown===t.value&&(t.focus(),t.setSelectionRange(0,0))),t.value=t.value&&t.value!==this._maskService.prefix?t.value:this._maskService.prefix+this._maskService.maskIsShown,(t.selectionStart||t.selectionEnd)<=this._maskService.prefix.length&&(t.selectionStart=this._maskService.prefix.length)},e.prototype.a=function(e){this._code=e.code;var t=e.target;if(this._maskService.selStart=t.selectionStart,this._maskService.selEnd=t.selectionEnd,38===e.keyCode&&e.preventDefault(),37===e.keyCode||8===e.keyCode){t.selectionStart<=this._maskService.prefix.length&&t.selectionEnd<=this._maskService.prefix.length&&e.preventDefault();var i=t.selectionStart;this.onFocus(e),8===e.keyCode&&0===i&&t.selectionEnd===t.value.length&&(this._position=this._maskService.prefix?this._maskService.prefix.length:1,this._maskService.applyMask(this._maskService.prefix,this._maskService.maskExpression,this._position))}},e.prototype.onPaste=function(){this._position=Number.MAX_SAFE_INTEGER},e.prototype.writeValue=function(e){return t=this,i=void 0,r=function(){return h(this,function(t){return e===undefined&&(e=""),"number"==typeof e&&(e=String(e),e=this._maskValue.startsWith("dot_separator")?e.replace(".",","):e,this._maskService.isNumberValue=!0),e&&this._maskService.maskExpression||this._maskService.maskExpression&&(this._maskService.prefix||this._maskService.showMaskTyped)?this._maskService.formElementProperty=["value",this._maskService.applyMask(e,this._maskService.maskExpression)]:this._maskService.formElementProperty=["value",e],this._inputValue=e,[2]})},new((s=void 0)||(s=Promise))(function(e,n){function a(e){try{p(r.next(e))}catch(t){n(t)}}function o(e){try{p(r["throw"](e))}catch(t){n(t)}}function p(t){t.done?e(t.value):new s(function(e){e(t.value)}).then(a,o)}p((r=r.apply(t,i||[])).next())});var t,i,s,r},e.prototype.registerOnChange=function(e){this.onChange=e,this._maskService.onChange=this.onChange},e.prototype.registerOnTouched=function(e){this.onTouch=e},e.prototype.setDisabledState=function(e){this._maskService.formElementProperty=["disabled",e]},e.prototype._repeatPatternSymbols=function(e){var t=this;return e.match(/{[0-9]+}/)&&e.split("").reduce(function(i,s,r){if(t._start="{"===s?r:t._start,"}"!==s)return t._maskService._findSpecialChar(s)?i+s:i;t._end=r;var n=Number(e.slice(t._start+1,t._end));return i+new Array(n+1).join(e[t._start-1])},"")||e},a([t.Input("mask"),p("design:type",String),p("design:paramtypes",[String])],e.prototype,"maskExpression",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"specialCharacters",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"patterns",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"prefix",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"sufix",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"dropSpecialCharacters",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"hiddenInput",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"showMaskTyped",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"shownMaskExpression",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"showTemplate",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"clearIfNotMatch",null),a([t.Input(),p("design:type",Object),p("design:paramtypes",[Object])],e.prototype,"validation",null),a([t.HostListener("input",["$event"]),p("design:type",Function),p("design:paramtypes",[KeyboardEvent]),p("design:returntype",void 0)],e.prototype,"onInput",null),a([t.HostListener("blur"),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",void 0)],e.prototype,"onBlur",null),a([t.HostListener("click",["$event"]),p("design:type",Function),p("design:paramtypes",[Object]),p("design:returntype",void 0)],e.prototype,"onFocus",null),a([t.HostListener("keydown",["$event"]),p("design:type",Function),p("design:paramtypes",[KeyboardEvent]),p("design:returntype",void 0)],e.prototype,"a",null),a([t.HostListener("paste"),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",void 0)],e.prototype,"onPaste",null),e=r=a([t.Directive({selector:"[mask]",providers:[{provide:s.NG_VALUE_ACCESSOR,useExisting:t.forwardRef(function(){return r}),multi:!0},{provide:s.NG_VALIDATORS,useExisting:t.forwardRef(function(){return r}),multi:!0},g]}),o(0,t.Inject(i.DOCUMENT)),p("design:paramtypes",[Object,g])],e)}(),_=function(){function e(e){this._maskService=e}return e.prototype.transform=function(e,t){return e||"number"==typeof e?"string"==typeof t?this._maskService.applyMask(""+e,t):this._maskService.applyMaskWithPattern(""+e,t):""},e=a([t.Pipe({name:"mask",pure:!0}),p("design:paramtypes",[k])],e)}(),v=function(){function e(){}var i;return i=e,e.forRoot=function(e){return{ngModule:i,providers:[{provide:u,useValue:e},{provide:f,useValue:m},{provide:c,useFactory:S,deps:[f,u]}]}},e.forChild=function(e){return{ngModule:i}},e=i=a([t.NgModule({providers:[k],exports:[y,_],declarations:[y,_]})],e)}();function S(e,t){return"function"==typeof t?t():n({},e,t)}e.INITIAL_CONFIG=f,e.MaskDirective=y,e.MaskPipe=_,e.MaskService=g,e.NEW_CONFIG=u,e.NgxMaskModule=v,e._configFactory=S,e.config=c,e.initialConfig=m,e.withoutValidation=d,e.ɵa=k,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-mask.umd.min.js.map