Skip to content

Commit 6a2f7a7

Browse files
committed
feat: add password input
1 parent 3638ed0 commit 6a2f7a7

File tree

7 files changed

+489
-8
lines changed

7 files changed

+489
-8
lines changed

src/icon/icon.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import WarningFilled16 from "@carbon/icons/es/warning--filled/16";
5757
import WarningFilled20 from "@carbon/icons/es/warning--filled/20";
5858
import WarningAltFilled16 from "@carbon/icons/es/warning--alt--filled/16";
5959
import WarningAltFilled20 from "@carbon/icons/es/warning--alt--filled/20";
60+
import View16 from "@carbon/icons/es/view/16";
61+
import ViewOff16 from "@carbon/icons/es/view--off/16";
6062

6163
// either provides a new instance of IconService, or returns the parent
6264
export function ICON_SERVICE_PROVIDER_FACTORY(parentService: IconService) {
@@ -132,6 +134,8 @@ export class IconModule {
132134
SettingsAdjust16,
133135
Subtract16,
134136
TrashCan16,
137+
View16,
138+
ViewOff16,
135139
Warning16,
136140
WarningFilled16,
137141
WarningFilled20,

src/input/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ export * from "./label.component";
44
export * from "./text-area.directive";
55
export * from "./text-input-label.component";
66
export * from "./textarea-label.component";
7+
export * from "./password-input-label.component";
8+
export * from "./password.directive";

src/input/input.module.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ import { TextArea } from "./text-area.directive";
1010
import { TextareaLabelComponent } from "./textarea-label.component";
1111
import { TextInputLabelComponent } from "./text-input-label.component";
1212
import { IconModule } from "carbon-components-angular/icon";
13+
import { PasswordInput } from "./password.directive";
14+
import { PasswordInputLabelComponent } from "./password-input-label.component";
1315

1416
@NgModule({
1517
declarations: [
1618
Label,
1719
TextInput,
1820
TextArea,
21+
PasswordInput,
1922
TextareaLabelComponent,
20-
TextInputLabelComponent
23+
TextInputLabelComponent,
24+
PasswordInputLabelComponent
2125
],
2226
exports: [
2327
Label,
2428
TextareaLabelComponent,
2529
TextInputLabelComponent,
30+
PasswordInputLabelComponent,
2631
TextInput,
27-
TextArea
32+
TextArea,
33+
PasswordInput
2834
],
2935
imports: [
3036
CommonModule,

src/input/label.component.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313

1414
import { TextArea } from "./text-area.directive";
1515
import { TextInput } from "./input.directive";
16+
import { PasswordInput } from "./password.directive";
1617

1718
/**
1819
* Get started with importing the module:
@@ -74,6 +75,22 @@ import { TextInput } from "./input.directive";
7475
[textInputTemplate]="inputContentTemplate">
7576
</cds-text-label>
7677
</ng-container>
78+
<ng-container *ngSwitchCase="'PasswordInput'">
79+
<cds-password-label
80+
[labelInputID]="labelInputID"
81+
[disabled]="disabled"
82+
[skeleton]="skeleton"
83+
[helperText]="helperText"
84+
[invalid]="invalid"
85+
[invalidText]="invalidText"
86+
[warn]="warn"
87+
[warnText]="warnText"
88+
[ariaLabel]="ariaLabel"
89+
[labelTemplate]="labelContentTemplate"
90+
[passwordInputTemplate]="inputContentTemplate"
91+
>
92+
</cds-password-label>
93+
</ng-container>
7794
<ng-container *ngSwitchDefault>
7895
<ng-template [ngTemplateOutlet]="default"></ng-template>
7996
</ng-container>
@@ -102,13 +119,13 @@ import { TextInput } from "./input.directive";
102119
cdsIcon="warning--filled"
103120
size="16"
104121
class="cds--text-input__invalid-icon">
105-
</svg>
122+
</svg>
106123
<svg
107124
*ngIf="!invalid && warn"
108125
cdsIcon="warning--alt--filled"
109126
size="16"
110127
class="cds--text-input__invalid-icon cds--text-input__invalid-icon--warning">
111-
</svg>
128+
</svg>
112129
<ng-template [ngTemplateOutlet]="inputContentTemplate"></ng-template>
113130
</div>
114131
<div
@@ -137,7 +154,7 @@ export class Label implements AfterContentInit, AfterViewInit {
137154
/**
138155
* The id of the input item associated with the `Label`. This value is also used to associate the `Label` with
139156
* its input counterpart through the 'for' attribute.
140-
*/
157+
*/
141158
@Input() labelInputID = `cds-label-${Label.labelCounter++}`;
142159
/**
143160
* Set to `true` for disabled state.
@@ -160,8 +177,8 @@ export class Label implements AfterContentInit, AfterViewInit {
160177
*/
161178
@Input() invalid = false;
162179
/**
163-
* Set to `true` to show a warning (contents set by warningText)
164-
*/
180+
* Set to `true` to show a warning (contents set by warningText)
181+
*/
165182
@Input() warn = false;
166183
/**
167184
* Sets the warning text
@@ -179,11 +196,14 @@ export class Label implements AfterContentInit, AfterViewInit {
179196
// @ts-ignore
180197
@ContentChild(TextInput, { static: false }) textInput: TextInput;
181198

199+
@ContentChild(PasswordInput, { static: false })
200+
passwordInput: PasswordInput;
201+
182202
@HostBinding("class.cds--form-item") get labelClass() {
183203
return this.type === undefined;
184204
}
185205

186-
type: "TextArea" | "TextInput";
206+
type: "TextArea" | "TextInput" | "PasswordInput";
187207

188208
/**
189209
* Creates an instance of Label.
@@ -198,6 +218,8 @@ export class Label implements AfterContentInit, AfterViewInit {
198218
this.type = "TextArea";
199219
} else if (this.textInput) {
200220
this.type = "TextInput";
221+
} else if (this.passwordInput) {
222+
this.type = "PasswordInput";
201223
}
202224
}
203225

0 commit comments

Comments
 (0)