Skip to content

Commit ef7b2c1

Browse files
committed
Added input type, min and max params to CustomUI input
Signed-off-by: Seb Julliand <[email protected]>
1 parent 15ad548 commit ef7b2c1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/api/CustomUI.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface WebviewMessageRequest {
4141
data?: any;
4242
}
4343

44+
type InputType = "text" | "number";
45+
4446
export class Section {
4547
readonly fields: Field[] = [];
4648

@@ -61,7 +63,7 @@ export class Section {
6163
return this;
6264
}
6365

64-
addInput(id: string, label: string, description?: string, options?: { default?: string, readonly?: boolean, rows?: number, minlength?: number, maxlength?: number, regexTest?: string }) {
66+
addInput(id: string, label: string, description?: string, options?: { default?: string, readonly?: boolean, rows?: number, minlength?: number, maxlength?: number, regexTest?: string, inputType?: InputType, min?:number, max?:number }) {
6567
const input = Object.assign(new Field('input', id, label, description), options);
6668
this.addField(input);
6769
return this;
@@ -505,6 +507,9 @@ export class Field {
505507
public minlength?: number;
506508
public maxlength?: number;
507509
public regexTest?: string;
510+
public inputType?: InputType;
511+
public min?: number;
512+
public max?: number;
508513

509514
constructor(readonly type: FieldType, readonly id: string, readonly label: string, readonly description?: string) {
510515

@@ -565,12 +570,16 @@ export class Field {
565570
${this.renderLabel()}
566571
${this.renderDescription()}
567572
<${tag} class="long-input" id="${this.id}" name="${this.id}"
573+
${this.inputType ? `type="${this.inputType}"` : ``}
568574
${this.default ? `value="${this.default}"` : ``}
569575
${this.readonly ? `readonly` : ``}
570576
${multiline ? `rows="${this.rows}" resize="vertical"` : ''}
571577
${this.minlength ? `minlength="${this.minlength}"` : ``}
572-
${this.maxlength ? `maxlength="${this.maxlength}"` : ``}>
573-
/${tag}>
578+
${this.maxlength ? `maxlength="${this.maxlength}"` : ``}
579+
${this.min ? `min="${this.min}"` : ``}
580+
${this.max ? `max="${this.max}"` : ``}
581+
>
582+
<${tag}>
574583
</vscode-form-group>`;
575584

576585
case `paragraph`:

0 commit comments

Comments
 (0)