Skip to content

Commit 5778d25

Browse files
almedina-mspaulcam206
authored andcommitted
[JS] Add Password support to Input.Text (microsoft#6407)
* Add Password to style list * Fix comparator * Change property implementation to contain version info in new enum value Co-authored-by: Paul Campbell <paulcam@microsoft.com>
1 parent d1d0829 commit 5778d25

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

source/nodejs/adaptivecards/src/card-elements.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,9 @@ export class TextBlock extends BaseTextBlock {
980980

981981
if (this.style === "heading") {
982982
element.setAttribute("role", "heading");
983-
983+
984984
let headingLevel = this.hostConfig.textBlock.headingLevel;
985-
985+
986986
if (headingLevel !== undefined && headingLevel > 0) {
987987
element.setAttribute("aria-level", headingLevel.toString());
988988
}
@@ -2776,7 +2776,19 @@ export class TextInput extends Input {
27762776
static readonly maxLengthProperty = new NumProperty(Versions.v1_0, "maxLength");
27772777
static readonly isMultilineProperty = new BoolProperty(Versions.v1_0, "isMultiline", false);
27782778
static readonly placeholderProperty = new StringProperty(Versions.v1_0, "placeholder");
2779-
static readonly styleProperty = new EnumProperty(Versions.v1_0, "style", Enums.InputTextStyle, Enums.InputTextStyle.Text);
2779+
static readonly styleProperty = new EnumProperty(
2780+
Versions.v1_0,
2781+
"style",
2782+
Enums.InputTextStyle,
2783+
Enums.InputTextStyle.Text,
2784+
[
2785+
{ value: Enums.InputTextStyle.Text },
2786+
{ value: Enums.InputTextStyle.Tel },
2787+
{ value: Enums.InputTextStyle.Url },
2788+
{ value: Enums.InputTextStyle.Email },
2789+
{ value: Enums.InputTextStyle.Password, targetVersion: Versions.v1_5}
2790+
]
2791+
);
27802792
static readonly inlineActionProperty = new ActionProperty(Versions.v1_0, "inlineAction", [ "Action.ShowCard" ]);
27812793
static readonly regexProperty = new StringProperty(Versions.v1_3, "regex", true);
27822794

@@ -2832,7 +2844,7 @@ export class TextInput extends Input {
28322844
protected internalRender(): HTMLElement | undefined {
28332845
let result: HTMLInputElement | HTMLTextAreaElement;
28342846

2835-
if (this.isMultiline) {
2847+
if (this.isMultiline && this.style !== Enums.InputTextStyle.Password) {
28362848
result = document.createElement("textarea");
28372849
result.className = this.hostConfig.makeCssClassName("ac-input", "ac-textInput", "ac-multiline");
28382850

@@ -3355,7 +3367,7 @@ export class ChoiceSetInput extends Input {
33553367
this._textInput.placeholder = this.placeholder;
33563368
this._textInput.setAttribute("aria-label", this.placeholder);
33573369
}
3358-
3370+
33593371
let dataList = document.createElement("datalist");
33603372
dataList.id = Utils.generateUniqueId();
33613373

@@ -4001,7 +4013,7 @@ export abstract class Action extends CardObject {
40014013

40024014
setupElementForAccessibility(element: HTMLElement, promoteTooltipToLabel: boolean = false) {
40034015
element.tabIndex = this.isEnabled ? 0 : -1;
4004-
4016+
40054017
element.setAttribute("role", this.getAriaRole());
40064018

40074019
if (element instanceof HTMLButtonElement) {
@@ -4054,7 +4066,7 @@ export abstract class Action extends CardObject {
40544066
this.execute();
40554067
}
40564068
};
4057-
4069+
40584070
this._renderedElement = buttonElement;
40594071

40604072
this.renderButtonContent();
@@ -4862,7 +4874,7 @@ class ActionCollection {
48624874
if (afterSelectedAction) {
48634875
renderedAction.isFocusable = false;
48644876
}
4865-
4877+
48664878
if (renderedAction !== action) {
48674879
renderedAction.state = ActionButtonState.Subdued;
48684880
}

source/nodejs/adaptivecards/src/enums.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ export enum InputTextStyle {
123123
Text,
124124
Tel,
125125
Url,
126-
Email
126+
Email,
127+
Password
127128
}
128129

129130
/*

0 commit comments

Comments
 (0)