forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
|
@ -1,28 +1,30 @@
|
|||
import {InputElement} from "./InputElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import Combine from "../Base/Combine";
|
||||
import BaseUIElement from "../BaseUIElement";
|
||||
import { InputElement } from "./InputElement"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import Combine from "../Base/Combine"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
|
||||
export default class CombinedInputElement<T, J, X> extends InputElement<X> {
|
||||
|
||||
private readonly _a: InputElement<T>;
|
||||
private readonly _b: InputElement<J>;
|
||||
private readonly _combined: BaseUIElement;
|
||||
private readonly _a: InputElement<T>
|
||||
private readonly _b: InputElement<J>
|
||||
private readonly _combined: BaseUIElement
|
||||
private readonly _value: UIEventSource<X>
|
||||
private readonly _split: (x: X) => [T, J];
|
||||
private readonly _split: (x: X) => [T, J]
|
||||
|
||||
constructor(a: InputElement<T>, b: InputElement<J>,
|
||||
combine: (t: T, j: J) => X,
|
||||
split: (x: X) => [T, J]) {
|
||||
super();
|
||||
this._a = a;
|
||||
this._b = b;
|
||||
this._split = split;
|
||||
this._combined = new Combine([this._a, this._b]);
|
||||
constructor(
|
||||
a: InputElement<T>,
|
||||
b: InputElement<J>,
|
||||
combine: (t: T, j: J) => X,
|
||||
split: (x: X) => [T, J]
|
||||
) {
|
||||
super()
|
||||
this._a = a
|
||||
this._b = b
|
||||
this._split = split
|
||||
this._combined = new Combine([this._a, this._b])
|
||||
this._value = this._a.GetValue().sync(
|
||||
t => combine(t, this._b?.GetValue()?.data),
|
||||
(t) => combine(t, this._b?.GetValue()?.data),
|
||||
[this._b.GetValue()],
|
||||
x => {
|
||||
(x) => {
|
||||
const [t, j] = split(x)
|
||||
this._b.GetValue()?.setData(j)
|
||||
return t
|
||||
|
|
@ -31,16 +33,15 @@ export default class CombinedInputElement<T, J, X> extends InputElement<X> {
|
|||
}
|
||||
|
||||
GetValue(): UIEventSource<X> {
|
||||
return this._value;
|
||||
return this._value
|
||||
}
|
||||
|
||||
IsValid(x: X): boolean {
|
||||
const [t, j] = this._split(x)
|
||||
return this._a.IsValid(t) && this._b.IsValid(j);
|
||||
return this._a.IsValid(t) && this._b.IsValid(j)
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
return this._combined.ConstructElement();
|
||||
return this._combined.ConstructElement()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue