Skip to content

Commit b817bee

Browse files
committed
feat(package): added the ability to change and adapt custom msgs for the info component
1 parent 068f0c3 commit b817bee

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/module/component/mat-password-strength-info/mat-password-strength-info.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<mat-icon @negativeState color="warn">error</mat-icon>
1212
</ng-template>
1313
<div>
14-
<p>contains at least one lower character</p>
14+
<p>{{lowerCaseCriteriaMsg}}</p>
1515
</div>
1616
</div>
1717

@@ -25,7 +25,7 @@
2525
<mat-icon @negativeState color="warn">error</mat-icon>
2626
</ng-template>
2727
<div>
28-
<p>contains at least one upper character</p>
28+
<p>{{upperCaseCriteriaMsg}}</p>
2929
</div>
3030
</div>
3131

@@ -39,7 +39,7 @@
3939
<mat-icon @negativeState color="warn">error</mat-icon>
4040
</ng-template>
4141
<div>
42-
<p>contains at least one digit character</p>
42+
<p>{{digitsCriteriaMsg}}</p>
4343
</div>
4444
</div>
4545

@@ -53,7 +53,7 @@
5353
<mat-icon @negativeState color="warn">error</mat-icon>
5454
</ng-template>
5555
<div>
56-
<p>contains at least one special character</p>
56+
<p>{{specialCharsCriteriaMsg}}</p>
5757
</div>
5858
</div>
5959

@@ -67,7 +67,7 @@
6767
<mat-icon @negativeState color="warn">error</mat-icon>
6868
</ng-template>
6969
<div>
70-
<p>contains at least {{passwordComponent.min}} characters</p>
70+
<p>{{minCharsCriteriaMsg}}</p>
7171
</div>
7272
</div>
7373

src/module/component/mat-password-strength-info/mat-password-strength-info.component.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input} from '@angular/core';
1+
import {Component, Input, OnInit} from '@angular/core';
22
import {MatPasswordStrengthComponent} from '../mat-password-strength/mat-password-strength.component';
33
import {animate, animateChild, keyframes, query, stagger, style, transition, trigger, useAnimation} from '@angular/animations';
44
import {shake} from '../../animations/index';
@@ -72,12 +72,33 @@ import {shake} from '../../animations/index';
7272
]),
7373
],
7474
})
75-
export class MatPasswordStrengthInfoComponent {
75+
export class MatPasswordStrengthInfoComponent implements OnInit {
7676

7777
@Input()
7878
passwordComponent: MatPasswordStrengthComponent;
7979

8080
@Input()
8181
enableScoreInfo = false;
8282

83+
@Input()
84+
lowerCaseCriteriaMsg = 'contains at least one lower character';
85+
86+
@Input()
87+
upperCaseCriteriaMsg = 'contains at least one upper character';
88+
89+
@Input()
90+
digitsCriteriaMsg = 'contains at least one digit character';
91+
92+
@Input()
93+
specialCharsCriteriaMsg = 'contains at least one special character';
94+
95+
@Input()
96+
minCharsCriteriaMsg: string;
97+
98+
ngOnInit(): void {
99+
if (!this.minCharsCriteriaMsg) {
100+
this.minCharsCriteriaMsg = `contains at least ${this.passwordComponent.min} characters`
101+
}
102+
}
103+
83104
}

0 commit comments

Comments
 (0)