Skip to content

Commit 65c7392

Browse files
authored
Merge pull request #2772 from maicongodinho/password-input
feat: add password input
2 parents f114db5 + 4e06bec commit 65c7392

File tree

10 files changed

+517
-17
lines changed

10 files changed

+517
-17
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@angular/common": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
6868
"@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
6969
"@angular/forms": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
70-
"@carbon/styles": "^1.54.0",
70+
"@carbon/styles": "^1.56.0",
7171
"rxjs": "^6.0.0 || ^7.0.0",
7272
"zone.js": "^0.11.0"
7373
},
@@ -85,7 +85,7 @@
8585
"@angular/platform-browser-dynamic": "14.3.0",
8686
"@angular/router": "14.3.0",
8787
"@babel/core": "7.9.6",
88-
"@carbon/styles": "1.54.0",
88+
"@carbon/styles": "1.56.0",
8989
"@carbon/themes": "11.24.0",
9090
"@commitlint/cli": "17.0.3",
9191
"@commitlint/config-conventional": "17.0.3",

src/icon/icon.module.ts

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

6264
// either provides a new instance of IconService, or returns the parent
6365
export function ICON_SERVICE_PROVIDER_FACTORY(parentService: IconService) {
@@ -134,6 +136,8 @@ export class IconModule {
134136
SettingsAdjust16,
135137
Subtract16,
136138
TrashCan16,
139+
View16,
140+
ViewOff16,
137141
Warning16,
138142
WarningFilled16,
139143
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: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,36 @@ 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";
15+
import { TooltipModule } from "carbon-components-angular/tooltip";
16+
import { ButtonModule } from "carbon-components-angular/button";
1317

1418
@NgModule({
1519
declarations: [
1620
Label,
1721
TextInput,
1822
TextArea,
23+
PasswordInput,
1924
TextareaLabelComponent,
20-
TextInputLabelComponent
25+
TextInputLabelComponent,
26+
PasswordInputLabelComponent
2127
],
2228
exports: [
2329
Label,
2430
TextareaLabelComponent,
2531
TextInputLabelComponent,
32+
PasswordInputLabelComponent,
2633
TextInput,
27-
TextArea
34+
TextArea,
35+
PasswordInput
2836
],
2937
imports: [
3038
CommonModule,
3139
FormsModule,
32-
IconModule
40+
IconModule,
41+
ButtonModule,
42+
TooltipModule
3343
]
3444
})
3545
export class InputModule { }

src/input/label.component.ts

Lines changed: 25 additions & 4 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,21 @@ 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+
</cds-password-label>
92+
</ng-container>
7793
<ng-container *ngSwitchDefault>
7894
<ng-template [ngTemplateOutlet]="default"></ng-template>
7995
</ng-container>
@@ -137,7 +153,7 @@ export class Label implements AfterContentInit, AfterViewInit {
137153
/**
138154
* The id of the input item associated with the `Label`. This value is also used to associate the `Label` with
139155
* its input counterpart through the 'for' attribute.
140-
*/
156+
*/
141157
@Input() labelInputID = `cds-label-${Label.labelCounter++}`;
142158
/**
143159
* Set to `true` for disabled state.
@@ -160,8 +176,8 @@ export class Label implements AfterContentInit, AfterViewInit {
160176
*/
161177
@Input() invalid = false;
162178
/**
163-
* Set to `true` to show a warning (contents set by warningText)
164-
*/
179+
* Set to `true` to show a warning (contents set by warningText)
180+
*/
165181
@Input() warn = false;
166182
/**
167183
* Sets the warning text
@@ -179,11 +195,14 @@ export class Label implements AfterContentInit, AfterViewInit {
179195
// @ts-ignore
180196
@ContentChild(TextInput, { static: false }) textInput: TextInput;
181197

198+
@ContentChild(PasswordInput, { static: false })
199+
passwordInput: PasswordInput;
200+
182201
@HostBinding("class.cds--form-item") get labelClass() {
183202
return this.type === undefined;
184203
}
185204

186-
type: "TextArea" | "TextInput";
205+
type: "TextArea" | "TextInput" | "PasswordInput";
187206

188207
/**
189208
* Creates an instance of Label.
@@ -198,6 +217,8 @@ export class Label implements AfterContentInit, AfterViewInit {
198217
this.type = "TextArea";
199218
} else if (this.textInput) {
200219
this.type = "TextInput";
220+
} else if (this.passwordInput) {
221+
this.type = "PasswordInput";
201222
}
202223
}
203224

0 commit comments

Comments
 (0)