diff --git a/src/app/components/password/password.ts b/src/app/components/password/password.ts old mode 100755 new mode 100644 index b806a51bf77..0de1bf1adc4 --- a/src/app/components/password/password.ts +++ b/src/app/components/password/password.ts @@ -1,33 +1,11 @@ -import { - NgModule, - Directive, - ElementRef, - HostListener, - Input, - OnDestroy, - DoCheck, - NgZone, - OnInit, - ViewEncapsulation, - ChangeDetectionStrategy, - ContentChildren, - QueryList, - TemplateRef, - Component, - AfterContentInit, - ViewChild, - ChangeDetectorRef, - forwardRef, - Output, - EventEmitter -} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { animate, style, transition, trigger } from '@angular/animations'; -import { NG_VALUE_ACCESSOR } from '@angular/forms'; -import { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom'; -import { OverlayService, PrimeNGConfig, PrimeTemplate, TranslationKeys, SharedModule } from 'primeng/api'; -import { ZIndexUtils } from 'primeng/utils'; -import { InputTextModule } from 'primeng/inputtext'; +import {NgModule,Directive,ElementRef,HostListener,Input,OnDestroy,DoCheck,NgZone, OnInit, ViewEncapsulation, ChangeDetectionStrategy, ContentChildren, QueryList, TemplateRef, Component, AfterContentInit, ViewChild, ChangeDetectorRef, forwardRef, Output, EventEmitter, Pipe, PipeTransform} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {animate, style, transition, trigger} from '@angular/animations'; +import {NG_VALUE_ACCESSOR} from '@angular/forms'; +import {DomHandler, ConnectedOverlayScrollHandler} from 'primeng/dom'; +import {OverlayService, PrimeNGConfig, PrimeTemplate, TranslationKeys, SharedModule} from 'primeng/api'; +import {ZIndexUtils} from 'primeng/utils'; +import {InputTextModule} from 'primeng/inputtext'; import { Subscription } from 'rxjs'; @Directive({ @@ -256,6 +234,18 @@ export class PasswordDirective implements OnDestroy, DoCheck { } } +type Mapper = (item: T, ...args: any[]) => G; + +@Pipe({ + name: 'mapper', + pure: true +}) +export class MapperPipe implements PipeTransform { + public transform(value: T, mapper: Mapper, ...args: unknown[]): G { + return mapper(value, ...args); + } +} + export const Password_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => Password), @@ -264,46 +254,20 @@ export const Password_VALUE_ACCESSOR: any = { @Component({ selector: 'p-password', template: ` -
- +
+ - -
+ +
-
+
{{ infoText }}
@@ -660,20 +624,24 @@ export class Password implements AfterContentInit, OnInit { } } - containerClass() { - return { 'p-password p-component p-inputwrapper': true, 'p-input-icon-right': this.toggleMask }; + containerClass(toggleMask: boolean) { + return {'p-password p-component p-inputwrapper': true, + 'p-input-icon-right': toggleMask + }; } - inputFieldClass() { - return { 'p-password-input': true, 'p-disabled': this.disabled }; + inputFieldClass(disabled: boolean) { + return {'p-password-input' : true, + 'p-disabled': disabled + }; } - toggleIconClass() { - return this.unmasked ? 'pi pi-eye-slash' : 'pi pi-eye'; + toggleIconClass(unmasked: boolean) { + return unmasked ? 'pi pi-eye-slash' : 'pi pi-eye'; } - strengthClass() { - return `p-password-strength ${this.meter ? this.meter.strength : ''}`; + strengthClass(meter: any) { + return `p-password-strength ${meter ? meter.strength : ''}`; } filled() { @@ -703,8 +671,8 @@ export class Password implements AfterContentInit, OnInit { } } - inputType() { - return this.unmasked ? 'text' : 'password'; + inputType(unmasked: boolean) { + return unmasked ? 'text' : 'password'; } getTranslation(option: string) { @@ -741,6 +709,6 @@ export class Password implements AfterContentInit, OnInit { @NgModule({ imports: [CommonModule, InputTextModule], exports: [PasswordDirective, Password, SharedModule], - declarations: [PasswordDirective, Password] + declarations: [PasswordDirective, Password, MapperPipe] }) export class PasswordModule {}