31 lines
No EOL
939 B
TypeScript
31 lines
No EOL
939 B
TypeScript
import {ReadonlyInputElement} from "./InputElement";
|
|
import {Store} from "../../Logic/UIEventSource";
|
|
import BaseUIElement from "../BaseUIElement";
|
|
import {VariableUiElement} from "../Base/VariableUIElement";
|
|
|
|
export default class VariableInputElement<T> extends BaseUIElement implements ReadonlyInputElement<T> {
|
|
|
|
private readonly value: Store<T>;
|
|
private readonly element: BaseUIElement
|
|
private readonly upstream: Store<ReadonlyInputElement<T>>;
|
|
|
|
constructor(upstream: Store<ReadonlyInputElement<T>>) {
|
|
super()
|
|
this.upstream = upstream;
|
|
this.value = upstream.bind(v => v.GetValue())
|
|
this.element = new VariableUiElement(upstream)
|
|
}
|
|
|
|
GetValue(): Store<T> {
|
|
return this.value;
|
|
}
|
|
|
|
IsValid(t: T): boolean {
|
|
return this.upstream.data.IsValid(t);
|
|
}
|
|
|
|
protected InnerConstructElement(): HTMLElement {
|
|
return this.element.ConstructElement();
|
|
}
|
|
|
|
} |