blob: dcf1af756853646350fe09b4bb11ed923d55d9cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { Screen } from "./screen.ts";
import * as elements from "./elements.ts";
export enum ElemType {
TextElem,
InputElem,
ButtonElem,
}
const types = {
0: elements.Text,
1: elements.Input,
2: elements.Button
}
type BuilderElem = {
type: ElemType,
id: string,
data: any[]
}
export function build(data: {elements: BuilderElem[],focus?:string,name:string}) {
const screen = new Screen(data.name);
for (const element of data.elements) {
//@ts-ignore
screen.addElement(element.id, new types[element.type](...element.data))
}
if (data.focus) screen.focus(data.focus);
screen.ready()
}
|