primeng
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primeng) [{"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("primeng/dom")):"function"==typeof define&&define.amd?define("primeng/password",["exports","@angular/core","@angular/common","primeng/dom"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).primeng=e.primeng||{},e.primeng.password={}),e.ng.core,e.ng.common,e.primeng.dom)}(this,(function(e,t,n,i){"use strict";var o=function(){function e(e,t){this.el=e,this.zone=t,this.promptLabel="Enter a password",this.weakLabel="Weak",this.mediumLabel="Medium",this.strongLabel="Strong",this.feedback=!0}return Object.defineProperty(e.prototype,"showPassword",{set:function(e){this.el.nativeElement.type=e?"text":"password"},enumerable:!1,configurable:!0}),e.prototype.ngDoCheck=function(){this.updateFilledState()},e.prototype.onInput=function(e){this.updateFilledState()},e.prototype.updateFilledState=function(){this.filled=this.el.nativeElement.value&&this.el.nativeElement.value.length},e.prototype.createPanel=function(){this.panel=document.createElement("div"),this.panel.className="p-password-panel p-component p-password-panel-overlay p-connected-overlay",this.meter=document.createElement("div"),this.meter.className="p-password-meter",this.info=document.createElement("div"),this.info.className="p-password-info",this.info.textContent=this.promptLabel,this.panel.appendChild(this.meter),this.panel.appendChild(this.info),this.panel.style.minWidth=i.DomHandler.getOuterWidth(this.el.nativeElement)+"px",document.body.appendChild(this.panel)},e.prototype.showOverlay=function(){var e=this;this.feedback&&(this.panel||this.createPanel(),this.panel.style.zIndex=String(++i.DomHandler.zindex),this.panel.style.display="block",this.zone.runOutsideAngular((function(){setTimeout((function(){i.DomHandler.addClass(e.panel,"p-connected-overlay-visible"),e.bindScrollListener(),e.bindDocumentResizeListener()}),1)})),i.DomHandler.absolutePosition(this.panel,this.el.nativeElement))},e.prototype.hideOverlay=function(){var e=this;this.feedback&&this.panel&&(i.DomHandler.addClass(this.panel,"p-connected-overlay-hidden"),i.DomHandler.removeClass(this.panel,"p-connected-overlay-visible"),this.unbindScrollListener(),this.unbindDocumentResizeListener(),this.zone.runOutsideAngular((function(){setTimeout((function(){e.ngOnDestroy()}),150)})))},e.prototype.onFocus=function(){this.showOverlay()},e.prototype.onBlur=function(){this.hideOverlay()},e.prototype.onKeyup=function(e){if(this.feedback){var t=e.target.value,n=null,o=null;if(0===t.length)n=this.promptLabel,o="0px 0px";else{var s=this.testStrength(t);s<30?(n=this.weakLabel,o="0px -10px"):s>=30&&s<80?(n=this.mediumLabel,o="0px -20px"):s>=80&&(n=this.strongLabel,o="0px -30px")}this.panel&&i.DomHandler.hasClass(this.panel,"p-connected-overlay-visible")||this.showOverlay(),this.meter.style.backgroundPosition=o,this.info.textContent=n}},e.prototype.testStrength=function(e){var t,n=0;return t=e.match("[0-9]"),n+=25*this.normalize(t?t.length:1/4,1),t=e.match("[a-zA-Z]"),n+=10*this.normalize(t?t.length:.5,3),t=e.match("[!@#$%^&*?_~.,;=]"),n+=35*this.normalize(t?t.length:1/6,1),t=e.match("[A-Z]"),n+=30*this.normalize(t?t.length:1/6,1),(n*=e.length/8)>100?100:n},e.prototype.normalize=function(e,t){return e-t<=0?e/t:1+e/(e+t/4)*.5},Object.defineProperty(e.prototype,"disabled",{get:function(){return this.el.nativeElement.disabled},enumerable:!1,configurable:!0}),e.prototype.bindScrollListener=function(){var e=this;this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.el.nativeElement,(function(){i.DomHandler.hasClass(e.panel,"p-connected-overlay-visible")&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()},e.prototype.unbindScrollListener=function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},e.prototype.bindDocumentResizeListener=function(){this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener)},e.prototype.unbindDocumentResizeListener=function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)},e.prototype.onWindowResize=function(){this.hideOverlay()},e.prototype.ngOnDestroy=function(){this.panel&&(this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.unbindDocumentResizeListener(),document.body.removeChild(this.panel),this.panel=null,this.meter=null,this.info=null)},e}();o.decorators=[{type:t.Directive,args:[{selector:"[pPassword]",host:{"[class.p-inputtext]":"true","[class.p-component]":"true","[class.p-filled]":"filled"}}]}],o.ctorParameters=function(){return[{type:t.ElementRef},{type:t.NgZone}]},o.propDecorators={promptLabel:[{type:t.Input}],weakLabel:[{type:t.Input}],mediumLabel:[{type:t.Input}],strongLabel:[{type:t.Input}],feedback:[{type:t.Input}],showPassword:[{type:t.Input}],onInput:[{type:t.HostListener,args:["input",["$event"]]}],onFocus:[{type:t.HostListener,args:["focus"]}],onBlur:[{type:t.HostListener,args:["blur"]}],onKeyup:[{type:t.HostListener,args:["keyup",["$event"]]}]};var s=function(){};s.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule],exports:[o],declarations:[o]}]}],e.Password=o,e.PasswordModule=s,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=primeng-password.umd.min.js.map