moh-common-lib
Version:
A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).
83 lines (81 loc) • 2.92 kB
TypeScript
import { OnInit, EventEmitter, OnChanges } from '@angular/core';
import { Base } from '../../models/base';
/**
* TODO: Convert to custom form control - remove ngForm
*/
/**
* Interface for passing in error messages
* Example:
* errorMessages = {
* required: this.componentLabel + ' is required.',
* minLength: this.componentLabel + ' must be ' + this.minLen + ' characters.',
* criteria: this.componentLabel + ' does not meet password criteria.'
* }
*/
export interface PasswordErrorMsg {
required?: string;
minLength?: string;
criteria?: string;
}
/**
* PasswordComponent is a text input for a user's password. It includes:
*
* - A password strength bar
* - Minimum length validations
*
* Note - if your application has requirements to check things like username is not
* present in password, we recommend doing this in the (passwordChange) callback.
*
* @example
* <common-password componentLabel="{{newPwdLabel}}"
* [showPasswordStrength]="true"
* [minLen]="pwdMinLen"
* [pwdCriteria]="pwdValidChars"
* [password]="data.password"
* (passwordChange)="setNewPassword($event)"></common-password>
*
* @export
*/
export declare class PasswordComponent extends Base implements OnInit, OnChanges {
label: string;
isRequired: boolean;
isDisabled: boolean;
password: string;
pwdCriteria: string | RegExp;
minLen: string;
maxLen: string;
errorMessages: PasswordErrorMsg;
showPasswordStrength: boolean;
objectID: string;
passwordChange: EventEmitter<string>;
blurEvent: EventEmitter<{}>;
hideValue: boolean;
pswdStrength: number;
strengthPercentage: number;
errMsg: PasswordErrorMsg;
private requiredMsgSeg;
private minLenMsgSeg1;
private minLenMsgSeg2;
private criteriaMsg;
constructor();
ngOnInit(): void;
ngOnChanges(changes: any): void;
/**
* Passes the value entered back to the calling component
* @param password value the was entered by
*/
setPassword(password: string): void;
onInputBlur($event: any): void;
onPaste(event: any): boolean;
/**
* Get the strength of the password
* 0 = too guessable: risky password. (guesses < 10^3)
* 1 = very guessable: protection from throttled online attacks. (guesses < 10^6)
* 2 = somewhat guessable: protection from unthrottled online attacks. (guesses < 10^8)
* 3 = safely unguessable: moderate protection from offline slow-hash scenario. (guesses < 10^10)
* 4 = very unguessable: strong protection from offline slow-hash scenario. (guesses >= 10^10)
*
* https://github.com/dropbox/zxcvbn
*/
private getPasswordStrength;
}