Refactoring: more cleanup of Svg.ts, remove a few old, unused classes
This commit is contained in:
parent
9923f849e0
commit
a50620a8ba
2 changed files with 0 additions and 76 deletions
|
@ -1,26 +0,0 @@
|
||||||
import BaseUIElement from "../BaseUIElement"
|
|
||||||
import { VariableUiElement } from "./VariableUIElement"
|
|
||||||
import { Stores } from "../../Logic/UIEventSource"
|
|
||||||
import Loading from "./Loading"
|
|
||||||
|
|
||||||
export default class AsyncLazy extends BaseUIElement {
|
|
||||||
private readonly _f: () => Promise<BaseUIElement>
|
|
||||||
|
|
||||||
constructor(f: () => Promise<BaseUIElement>) {
|
|
||||||
super()
|
|
||||||
this._f = f
|
|
||||||
}
|
|
||||||
|
|
||||||
protected InnerConstructElement(): HTMLElement {
|
|
||||||
// The caching of the BaseUIElement will guarantee that _f will only be called once
|
|
||||||
|
|
||||||
return new VariableUiElement(
|
|
||||||
Stores.FromPromise(this._f()).map((el) => {
|
|
||||||
if (el === undefined) {
|
|
||||||
return new Loading()
|
|
||||||
}
|
|
||||||
return el
|
|
||||||
})
|
|
||||||
).ConstructElement()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
import BaseUIElement from "../BaseUIElement"
|
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
|
||||||
import { VariableUiElement } from "./VariableUIElement"
|
|
||||||
import Combine from "./Combine"
|
|
||||||
import Locale from "../i18n/Locale"
|
|
||||||
import { Utils } from "../../Utils"
|
|
||||||
|
|
||||||
export default class FilteredCombine extends VariableUiElement {
|
|
||||||
/**
|
|
||||||
* Only shows item matching the search
|
|
||||||
* If predicate of an item is undefined, it will be filtered out as soon as a non-null or non-empty search term is given
|
|
||||||
* @param entries
|
|
||||||
* @param searchedValue
|
|
||||||
* @param options
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
entries: {
|
|
||||||
element: BaseUIElement | string
|
|
||||||
predicate?: (s: string) => boolean
|
|
||||||
}[],
|
|
||||||
searchedValue: UIEventSource<string>,
|
|
||||||
options?: {
|
|
||||||
onEmpty?: BaseUIElement | string
|
|
||||||
innerClasses: string
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
entries = Utils.NoNull(entries)
|
|
||||||
super(
|
|
||||||
searchedValue.map(
|
|
||||||
(searchTerm) => {
|
|
||||||
if (searchTerm === undefined || searchTerm === "") {
|
|
||||||
return new Combine(entries.map((e) => e.element)).SetClass(
|
|
||||||
options?.innerClasses ?? ""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
const kept = entries.filter(
|
|
||||||
(entry) => entry?.predicate !== undefined && entry.predicate(searchTerm)
|
|
||||||
)
|
|
||||||
if (kept.length === 0) {
|
|
||||||
return options?.onEmpty
|
|
||||||
}
|
|
||||||
return new Combine(kept.map((entry) => entry.element)).SetClass(
|
|
||||||
options?.innerClasses ?? ""
|
|
||||||
)
|
|
||||||
},
|
|
||||||
[Locale.language]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue