2024-08-23 14:45:28 +00:00
|
|
|
import { UINode } from "./node";
|
|
|
|
|
|
|
|
export class MultilineInput extends UINode {
|
|
|
|
private id: string;
|
|
|
|
private titleElement: HTMLLabelElement;
|
|
|
|
private textareaElement: HTMLTextAreaElement;
|
|
|
|
public constructor(title: string) {
|
|
|
|
super(title);
|
|
|
|
this.id = Math.random().toString();
|
|
|
|
this.titleElement = document.createElement("label");
|
|
|
|
this.titleElement.innerText = title;
|
|
|
|
this.titleElement.id = `txtarea_title_${this.id}`;
|
|
|
|
this.textareaElement = document.createElement("textarea");
|
|
|
|
this.textareaElement.id = `txtarea_${this.id}`;
|
|
|
|
this.titleElement.appendChild(this.textareaElement);
|
|
|
|
this.element.appendChild(this.titleElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
public focus() {
|
|
|
|
this.textareaElement.focus();
|
2024-08-24 18:23:10 +00:00
|
|
|
return this;
|
2024-08-23 14:45:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public click() {
|
|
|
|
this.textareaElement.click();
|
2024-08-24 18:23:10 +00:00
|
|
|
return this;
|
2024-08-23 14:45:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public getElement(): HTMLElement {
|
|
|
|
return this.textareaElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
public setText(text: string) {
|
|
|
|
this.title = text;
|
|
|
|
this.titleElement.innerText = text;
|
2024-08-24 18:23:10 +00:00
|
|
|
return this;
|
2024-08-23 14:45:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public getValue(): string {
|
|
|
|
return this.textareaElement.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public setValue(value: string) {
|
|
|
|
this.textareaElement.value = value;
|
2024-08-24 18:23:10 +00:00
|
|
|
return this;
|
2024-08-23 14:45:28 +00:00
|
|
|
}
|
|
|
|
}
|