Various bug fixes and updates

This commit is contained in:
Pieter Vander Vennet 2020-09-09 18:42:13 +02:00
parent 97ec893479
commit e069b31e4e
29 changed files with 482 additions and 148 deletions

View file

@ -7,9 +7,13 @@ export class FixedInputElement<T> extends InputElement<T> {
private readonly rendering: UIElement;
private readonly value: UIEventSource<T>;
public readonly IsSelected : UIEventSource<boolean> = new UIEventSource<boolean>(false);
private readonly _comparator: (t0: T, t1: T) => boolean;
constructor(rendering: UIElement | string, value: T) {
constructor(rendering: UIElement | string,
value: T,
comparator: ((t0: T, t1: T) => boolean ) = undefined) {
super(undefined);
this._comparator = comparator ?? ((t0, t1) => t0 == t1);
this.value = new UIEventSource<T>(value);
this.rendering = typeof (rendering) === 'string' ? new FixedUiElement(rendering) : rendering;
}
@ -22,7 +26,9 @@ export class FixedInputElement<T> extends InputElement<T> {
}
IsValid(t: T): boolean {
return t == this.value.data;
console.log("Comparing ",t, "with", this.value.data);
return this._comparator(t, this.value.data);
}
protected InnerUpdate(htmlElement: HTMLElement) {