{"version":3,"file":"primeng-password.umd.js","sources":["../../src/app/components/password/password.ts","../../src/app/components/password/primeng-password.ts"],"sourcesContent":["import {NgModule,Directive,ElementRef,HostListener,Input,OnDestroy,DoCheck,NgZone} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler, ConnectedOverlayScrollHandler} from 'primeng/dom';\n\n@Directive({\n selector: '[pPassword]',\n host: {\n '[class.p-inputtext]': 'true',\n '[class.p-component]': 'true',\n '[class.p-filled]': 'filled'\n }\n})\nexport class Password implements OnDestroy,DoCheck {\n\n @Input() promptLabel: string = 'Enter a password';\n\n @Input() weakLabel: string = 'Weak';\n\n @Input() mediumLabel: string = 'Medium';\n\n @Input() strongLabel: string = 'Strong';\n\n @Input() feedback: boolean = true;\n\n @Input() set showPassword(show: boolean) {\n this.el.nativeElement.type = show ? 'text' : 'password';\n }\n\n panel: HTMLDivElement;\n\n meter: any;\n\n info: any;\n\n filled: boolean;\n\n scrollHandler: any;\n\n documentResizeListener: any;\n\n constructor(public el: ElementRef, public zone: NgZone) {}\n\n ngDoCheck() {\n this.updateFilledState();\n }\n\n @HostListener('input', ['$event'])\n onInput(e) {\n this.updateFilledState();\n }\n\n updateFilledState() {\n this.filled = this.el.nativeElement.value && this.el.nativeElement.value.length;\n }\n\n createPanel() {\n this.panel = document.createElement('div');\n this.panel.className = 'p-password-panel p-component p-password-panel-overlay p-connected-overlay';\n this.meter = document.createElement('div');\n this.meter.className = 'p-password-meter';\n this.info = document.createElement('div');\n this.info.className = 'p-password-info';\n this.info.textContent = this.promptLabel;\n this.panel.appendChild(this.meter);\n this.panel.appendChild(this.info);\n this.panel.style.minWidth = DomHandler.getOuterWidth(this.el.nativeElement) + 'px';\n document.body.appendChild(this.panel);\n }\n\n showOverlay() {\n if (this.feedback) {\n if (!this.panel) {\n this.createPanel();\n }\n\n this.panel.style.zIndex = String(++DomHandler.zindex);\n this.panel.style.display = 'block';\n this.zone.runOutsideAngular(() => {\n\n setTimeout(() => {\n DomHandler.addClass(this.panel, 'p-connected-overlay-visible');\n this.bindScrollListener();\n this.bindDocumentResizeListener();\n }, 1);\n });\n DomHandler.absolutePosition(this.panel, this.el.nativeElement);\n }\n }\n\n hideOverlay() {\n if (this.feedback && this.panel) {\n DomHandler.addClass(this.panel, 'p-connected-overlay-hidden');\n DomHandler.removeClass(this.panel, 'p-connected-overlay-visible');\n this.unbindScrollListener();\n this.unbindDocumentResizeListener();\n\n this.zone.runOutsideAngular(() => {\n setTimeout(() => {\n this.ngOnDestroy();\n }, 150);\n });\n }\n }\n\n @HostListener('focus')\n onFocus() {\n this.showOverlay();\n }\n\n @HostListener('blur')\n onBlur() {\n this.hideOverlay();\n }\n\n @HostListener('keyup', ['$event'])\n onKeyup(e) {\n if (this.feedback) {\n let value = e.target.value,\n label = null,\n meterPos = null;\n\n if (value.length === 0) {\n label = this.promptLabel;\n meterPos = '0px 0px';\n }\n else {\n var score = this.testStrength(value);\n\n if (score < 30) {\n label = this.weakLabel;\n meterPos = '0px -10px';\n }\n else if (score >= 30 && score < 80) {\n label = this.mediumLabel;\n meterPos = '0px -20px';\n }\n else if (score >= 80) {\n label = this.strongLabel;\n meterPos = '0px -30px';\n }\n }\n\n if (!this.panel || !DomHandler.hasClass(this.panel, 'p-connected-overlay-visible')) {\n this.showOverlay();\n }\n\n this.meter.style.backgroundPosition = meterPos;\n this.info.textContent = label;\n }\n }\n\n testStrength(str: string) {\n let grade: number = 0;\n let val: RegExpMatchArray;\n\n val = str.match('[0-9]');\n grade += this.normalize(val ? val.length : 1/4, 1) * 25;\n\n val = str.match('[a-zA-Z]');\n grade += this.normalize(val ? val.length : 1/2, 3) * 10;\n\n val = str.match('[!@#$%^&*?_~.,;=]');\n grade += this.normalize(val ? val.length : 1/6, 1) * 35;\n\n val = str.match('[A-Z]');\n grade += this.normalize(val ? val.length : 1/6, 1) * 30;\n\n grade *= str.length / 8;\n\n return grade > 100 ? 100 : grade;\n }\n\n normalize(x, y) {\n let diff = x - y;\n\n if (diff <= 0)\n return x / y;\n else\n return 1 + 0.5 * (x / (x + y/4));\n }\n\n get disabled(): boolean {\n return this.el.nativeElement.disabled;\n }\n\n bindScrollListener() {\n if (!this.scrollHandler) {\n this.scrollHandler = new ConnectedOverlayScrollHandler(this.el.nativeElement, () => {\n if (DomHandler.hasClass(this.panel, 'p-connected-overlay-visible')) {\n this.hideOverlay();\n }\n });\n }\n\n this.scrollHandler.bindScrollListener();\n }\n\n unbindScrollListener() {\n if (this.scrollHandler) {\n this.scrollHandler.unbindScrollListener();\n }\n }\n\n bindDocumentResizeListener() {\n this.documentResizeListener = this.onWindowResize.bind(this);\n window.addEventListener('resize', this.documentResizeListener);\n }\n\n unbindDocumentResizeListener() {\n if (this.documentResizeListener) {\n window.removeEventListener('resize', this.documentResizeListener);\n this.documentResizeListener = null;\n }\n }\n\n onWindowResize() {\n this.hideOverlay();\n }\n\n ngOnDestroy() {\n if (this.panel) {\n if (this.scrollHandler) {\n this.scrollHandler.destroy();\n this.scrollHandler = null;\n }\n\n this.unbindDocumentResizeListener();\n\n document.body.removeChild(this.panel);\n this.panel = null;\n this.meter = null;\n this.info = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Password],\n declarations: [Password]\n})\nexport class PasswordModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DomHandler","ConnectedOverlayScrollHandler","Directive","ElementRef","NgZone","Input","HostListener","NgModule","CommonModule"],"mappings":";;;;;;;QAwCI,kBAAmB,EAAc,EAAS,IAAY;YAAnC,OAAE,GAAF,EAAE,CAAY;YAAS,SAAI,GAAJ,IAAI,CAAQ;YA1B7C,gBAAW,GAAW,kBAAkB,CAAC;YAEzC,cAAS,GAAW,MAAM,CAAC;YAE3B,gBAAW,GAAW,QAAQ,CAAC;YAE/B,gBAAW,GAAW,QAAQ,CAAC;YAE/B,aAAQ,GAAY,IAAI,CAAC;SAkBwB;QAhB1D,sBAAa,kCAAY;iBAAzB,UAA0B,IAAa;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