mirror of
https://github.com/bitwarden/jslib
synced 2025-12-29 14:43:17 +00:00
43 lines
887 B
TypeScript
43 lines
887 B
TypeScript
import { FieldType } from '../../enums/fieldType';
|
|
|
|
import { View } from './view';
|
|
|
|
import { Field } from '../domain/field';
|
|
|
|
export class FieldView implements View {
|
|
name: string;
|
|
type: FieldType;
|
|
|
|
// tslint:disable
|
|
private _value: string;
|
|
private _maskedValue: string;
|
|
// tslint:enable
|
|
|
|
constructor(f?: Field) {
|
|
if (!f) {
|
|
return;
|
|
}
|
|
|
|
this.type = f.type;
|
|
}
|
|
|
|
get value(): string {
|
|
return this._value;
|
|
}
|
|
set value(value: string) {
|
|
this._value = value;
|
|
this._maskedValue = null;
|
|
}
|
|
|
|
get maskedValue(): string {
|
|
if (this._maskedValue == null && this.value != null) {
|
|
this._maskedValue = '';
|
|
for (let i = 0; i < this.value.length; i++) {
|
|
this._maskedValue += '•';
|
|
}
|
|
}
|
|
|
|
return this._maskedValue;
|
|
}
|
|
}
|