forked from pietervdvn/MapComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
33 lines (29 loc) · 1.12 KB
/
test.ts
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
31
32
import Combine from "./UI/Base/Combine";
import ValidatedTextField from "./UI/Input/ValidatedTextField";
import Title from "./UI/Base/Title";
import {FixedUiElement} from "./UI/Base/FixedUiElement";
import {VariableUiElement} from "./UI/Base/VariableUIElement";
import {UIEventSource} from "./Logic/UIEventSource";
import {Translation} from "./UI/i18n/Translation";
new Combine(
ValidatedTextField.AvailableTypes().map(key => {
let inp;
const feedback = new UIEventSource<Translation>(undefined)
try {
inp = ValidatedTextField.ForType(key).ConstructInputElement({
feedback,
country: () => "be",
});
} catch (e) {
console.error(e)
inp = new FixedUiElement(e).SetClass("alert")
}
return new Combine([
new Title(key),
inp,
new VariableUiElement(inp.GetValue()),
new VariableUiElement(feedback.map(v => v?.SetClass("alert")))
]);
}
)
).AttachTo("maindiv")