UNPKG

4.68 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("primeng/dom"),require("@angular/forms")):"function"==typeof define&&define.amd?define("primeng/keyfilter",["exports","@angular/core","@angular/common","primeng/dom","@angular/forms"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.keyfilter={}),e.ng.core,e.ng.common,e.primeng.dom,e.ng.forms)}(this,(function(e,t,r,n,i){"use strict";var o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},a=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},l={provide:i.NG_VALIDATORS,useExisting:t.forwardRef((function(){return h})),multi:!0},s={pint:/[\d]/,int:/[\d\-]/,pnum:/[\d\.]/,money:/[\d\.\s,]/,num:/[\d\-\.]/,hex:/[0-9a-f]/i,email:/[a-z0-9_\.\-@]/i,alpha:/[a-z_]/i,alphanum:/[a-z0-9_]/i},u=9,p=13,d=27,f={63234:37,63235:39,63232:38,63233:40,63276:33,63277:34,63272:46,63273:36,63275:35},h=function(){function e(e){this.el=e,this.ngModelChange=new t.EventEmitter,this.isAndroid=n.DomHandler.isAndroid()}return Object.defineProperty(e.prototype,"pattern",{get:function(){return this._pattern},set:function(e){this._pattern=e,this.regex=s[this._pattern]||this._pattern},enumerable:!0,configurable:!0}),e.prototype.isNavKeyPress=function(e){var t=e.keyCode;return(t=n.DomHandler.getBrowser().safari&&f[t]||t)>=33&&t<=40||t==p||t==u||t==d},e.prototype.isSpecialKey=function(e){var t=e.keyCode||e.charCode;return 9==t||13==t||27==t||16==t||17==t||t>=18&&t<=20||n.DomHandler.getBrowser().opera&&!e.shiftKey&&(8==t||t>=33&&t<=35||t>=36&&t<=39||t>=44&&t<=45)},e.prototype.getKey=function(e){var t=e.keyCode||e.charCode;return n.DomHandler.getBrowser().safari&&f[t]||t},e.prototype.getCharCode=function(e){return e.charCode||e.keyCode||e.which},e.prototype.findDelta=function(e,t){for(var r="",n=0;n<e.length;n++){e.substr(0,n)+e.substr(n+e.length-t.length)===t&&(r=e.substr(n,e.length-t.length))}return r},e.prototype.isValidChar=function(e){return this.regex.test(e)},e.prototype.isValidString=function(e){for(var t=0;t<e.length;t++)if(!this.isValidChar(e.substr(t,1)))return!1;return!0},e.prototype.onInput=function(e){if(this.isAndroid&&!this.pValidateOnly){var t=this.el.nativeElement.value,r=this.lastValue||"",n=this.findDelta(t,r),i=this.findDelta(r,t);n.length>1||!n&&!i?this.isValidString(t)||(this.el.nativeElement.value=r,this.ngModelChange.emit(r)):i||this.isValidChar(n)||(this.el.nativeElement.value=r,this.ngModelChange.emit(r)),t=this.el.nativeElement.value,this.isValidString(t)&&(this.lastValue=t)}},e.prototype.onKeyPress=function(e){if(!this.isAndroid&&!this.pValidateOnly){var t=n.DomHandler.getBrowser(),r=this.getKey(e);if((!t.mozilla||!e.ctrlKey&&!e.altKey)&&17!=r&&18!=r){var i=this.getCharCode(e),o=String.fromCharCode(i);(t.mozilla||!this.isSpecialKey(e)&&o)&&(this.regex.test(o)||e.preventDefault())}}},e.prototype.onPaste=function(e){var t,r,n=e.clipboardData||window.clipboardData.getData("text");if(n){var i=n.getData("text");try{for(var o=a(i.toString()),l=o.next();!l.done;l=o.next()){var s=l.value;if(!this.regex.test(s))return void e.preventDefault()}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}},e.prototype.validate=function(e){if(this.pValidateOnly){var t=this.el.nativeElement.value;if(t&&!this.regex.test(t))return{validatePattern:!1}}},e.ctorParameters=function(){return[{type:t.ElementRef}]},o([t.Input()],e.prototype,"pValidateOnly",void 0),o([t.Output()],e.prototype,"ngModelChange",void 0),o([t.Input("pKeyFilter")],e.prototype,"pattern",null),o([t.HostListener("input",["$event"])],e.prototype,"onInput",null),o([t.HostListener("keypress",["$event"])],e.prototype,"onKeyPress",null),o([t.HostListener("paste",["$event"])],e.prototype,"onPaste",null),e=o([t.Directive({selector:"[pKeyFilter]",providers:[l]})],e)}(),c=function(){function e(){}return e=o([t.NgModule({imports:[r.CommonModule],exports:[h],declarations:[h]})],e)}();e.KEYFILTER_VALIDATOR=l,e.KeyFilter=h,e.KeyFilterModule=c,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-keyfilter.umd.min.js.map
\No newline at end of file