forked from MapComplete/MapComplete
Cleanup of textfield code
This commit is contained in:
parent
1f41444726
commit
3667f28f15
9 changed files with 293 additions and 219 deletions
|
@ -9,6 +9,7 @@ export default class InputElementMap<T, X> extends InputElement<X> {
|
|||
private readonly fromX: (x: X) => T;
|
||||
private readonly toX: (t: T) => X;
|
||||
private readonly _value: UIEventSource<X>;
|
||||
public readonly IsSelected: UIEventSource<boolean>;
|
||||
|
||||
constructor(inputElement: InputElement<T>,
|
||||
isSame: (x0: X, x1: X) => boolean,
|
||||
|
@ -32,8 +33,7 @@ export default class InputElementMap<T, X> extends InputElement<X> {
|
|||
}
|
||||
return newX;
|
||||
}), extraSources, x => {
|
||||
const newT = fromX(x);
|
||||
return newT;
|
||||
return fromX(x);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,15 @@ export default class InputElementMap<T, X> extends InputElement<X> {
|
|||
return this._inputElement.InnerRender();
|
||||
}
|
||||
|
||||
IsSelected: UIEventSource<boolean>;
|
||||
|
||||
IsValid(x: X): boolean {
|
||||
return this._inputElement.IsValid(this.fromX(x));
|
||||
if(x === undefined){
|
||||
return false;
|
||||
}
|
||||
const t = this.fromX(x);
|
||||
if(t === undefined){
|
||||
return false;
|
||||
}
|
||||
return this._inputElement.IsValid(t);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue