Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 93x 93x 93x 93x 4x 4x 2x 2x 2x 4x 4x 4x 4x 2x 2x 2x 2x 93x 93x | import { FormatterParserProvider } from '@zeedhi/core';
import { InputFactory } from '../zd-input/input-factory';
import { TextInput } from '../zd-text-input/text-input';
import { IPassword } from './interfaces';
/**
* Base class for Password component.
*/
export class Password extends TextInput implements IPassword {
/**
* Sets password input type.
*/
public type = 'password';
public appendIcon = 'eyeOff';
public onCreated() {
super.onCreated();
const userAppendIconClick = this.events.appendIconClick || (() => {});
this.events.appendIconClick = ({ event, element, component }) => {
this.toggleView();
if (userAppendIconClick && typeof userAppendIconClick === 'function') {
userAppendIconClick({ event, element, component });
}
};
}
/**
* Change password view
*/
public toggleView() {
if (this.type === 'password') {
this.type = 'text';
this.appendIcon = 'eye';
} else {
this.type = 'password';
this.appendIcon = 'eyeOff';
}
}
}
FormatterParserProvider.registerFormatter('ZdPassword', (value: string) => (value || '').replace(/./g, '*'));
InputFactory.register('ZdPassword', Password);
|