fantasy/ui/editors/form.js

37 lines
919 B
JavaScript

import UI from "../ui.js";
class Form extends UI {
constructor(width, height) {
super(document.createElement("div"), width, height);
this.element.classList.add("form");
this._lines = [];
this._linesById = Object.create(null);
}
addLine(id, label, editor) {
let line = document.createElement("div");
let labelCell = document.createElement("div");
let editorCell = document.createElement("div");
labelCell.innerText = label;
editorCell.appendChild(editor.element);
line.appendChild(labelCell);
line.appendChild(editorCell);
let obj = {
id: id,
label: label,
editor: editor,
visible: true,
line: line
};
this._lines.push(obj);
this._linesById[id] = obj;
this.element.appendChild(line);
}
}
export default Form;