diff --git a/UI/Input/Checkboxes.ts b/UI/Input/Checkboxes.ts index 2c72fc4ee..c02f36d9e 100644 --- a/UI/Input/Checkboxes.ts +++ b/UI/Input/Checkboxes.ts @@ -5,6 +5,9 @@ import BaseUIElement from "../BaseUIElement" import InputElementMap from "./InputElementMap" import Translations from "../i18n/Translations" +/** + * @deprecated + */ export class CheckBox extends InputElementMap { constructor(el: BaseUIElement | string, defaultValue?: boolean) { super( diff --git a/UI/Input/DropDown.ts b/UI/Input/DropDown.ts index e75467654..96ac90d21 100644 --- a/UI/Input/DropDown.ts +++ b/UI/Input/DropDown.ts @@ -3,6 +3,9 @@ import Translations from "../i18n/Translations" import { UIEventSource } from "../../Logic/UIEventSource" import BaseUIElement from "../BaseUIElement" +/** + * @deprecated + */ export class DropDown extends InputElement { private static _nextDropdownId = 0 public IsSelected: UIEventSource = new UIEventSource(false) diff --git a/UI/Input/FileSelectorButton.ts b/UI/Input/FileSelectorButton.ts index 5248cf51c..2a409a886 100644 --- a/UI/Input/FileSelectorButton.ts +++ b/UI/Input/FileSelectorButton.ts @@ -2,6 +2,9 @@ import BaseUIElement from "../BaseUIElement" import { InputElement } from "./InputElement" import { UIEventSource } from "../../Logic/UIEventSource" +/** + * @deprecated + */ export default class FileSelectorButton extends InputElement { private static _nextid private readonly _value = new UIEventSource(undefined) diff --git a/UI/Input/FixedInputElement.ts b/UI/Input/FixedInputElement.ts index b8c272fae..5e239e9aa 100644 --- a/UI/Input/FixedInputElement.ts +++ b/UI/Input/FixedInputElement.ts @@ -3,6 +3,9 @@ import { UIEventSource } from "../../Logic/UIEventSource" import Translations from "../i18n/Translations" import BaseUIElement from "../BaseUIElement" +/** + * @deprecated + */ export class FixedInputElement extends InputElement { private readonly value: UIEventSource private readonly _comparator: (t0: T, t1: T) => boolean diff --git a/UI/Input/FloorLevelInputElement.ts b/UI/Input/FloorLevelInputElement.ts deleted file mode 100644 index 6d88eb6d9..000000000 --- a/UI/Input/FloorLevelInputElement.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { InputElement } from "./InputElement" -import { Store, UIEventSource } from "../../Logic/UIEventSource" -import Combine from "../Base/Combine" -import Slider from "./Slider" -import { ClickableToggle } from "./Toggle" -import { FixedUiElement } from "../Base/FixedUiElement" -import { VariableUiElement } from "../Base/VariableUIElement" -import BaseUIElement from "../BaseUIElement" - -export default class FloorLevelInputElement - extends VariableUiElement - implements InputElement -{ - private readonly _value: UIEventSource - - constructor( - currentLevels: Store>, - options?: { - value?: UIEventSource - } - ) { - const value = options?.value ?? new UIEventSource("0") - super( - currentLevels.map((levels) => { - const allLevels = Object.keys(levels) - allLevels.sort((a, b) => { - const an = Number(a) - const bn = Number(b) - if (isNaN(an) || isNaN(bn)) { - return a < b ? -1 : 1 - } - return an - bn - }) - return FloorLevelInputElement.constructPicker(allLevels, value) - }) - ) - - this._value = value - } - - private static constructPicker(levels: string[], value: UIEventSource): BaseUIElement { - let slider = new Slider(0, levels.length - 1, { vertical: true }) - const toggleClass = - "flex border-2 border-blue-500 w-10 h-10 place-content-center items-center border-box" - slider - .SetClass("flex elevator w-10") - .SetStyle(`height: ${2.5 * levels.length}rem; background: #00000000`) - - const values = levels.map((data, i) => - new ClickableToggle( - new FixedUiElement(data).SetClass("font-bold active bg-subtle " + toggleClass), - new FixedUiElement(data).SetClass("normal-background " + toggleClass), - slider.GetValue().sync( - (sliderVal) => { - return sliderVal === i - }, - [], - (isSelected) => { - return isSelected ? i : slider.GetValue().data - } - ) - ) - .ToggleOnClick() - .SetClass("flex w-10 h-10") - ) - - values.reverse(/* This is a new list, no side-effects */) - const combine = new Combine([new Combine(values), slider]) - combine.SetClass("flex flex-row overflow-hidden") - - slider.GetValue().addCallbackD((i) => { - if (levels === undefined) { - return - } - if (levels[i] == undefined) { - return - } - value.setData(levels[i]) - }) - value.addCallbackAndRunD((level) => { - const i = levels.findIndex((l) => l === level) - slider.GetValue().setData(i) - }) - return combine - } - - GetValue(): UIEventSource { - return this._value - } - - IsValid(t: string): boolean { - return false - } -} diff --git a/UI/Input/InputElement.ts b/UI/Input/InputElement.ts index cbb3a1aa2..f0e32283a 100644 --- a/UI/Input/InputElement.ts +++ b/UI/Input/InputElement.ts @@ -1,11 +1,17 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource" import BaseUIElement from "../BaseUIElement" +/** + * @deprecated + */ export interface ReadonlyInputElement extends BaseUIElement { GetValue(): Store IsValid(t: T): boolean } +/** + * @deprecated + */ export abstract class InputElement extends BaseUIElement implements ReadonlyInputElement { abstract GetValue(): UIEventSource abstract IsValid(t: T): boolean diff --git a/UI/Input/InputElementMap.ts b/UI/Input/InputElementMap.ts index 5ca998baf..4e49c38b5 100644 --- a/UI/Input/InputElementMap.ts +++ b/UI/Input/InputElementMap.ts @@ -1,6 +1,9 @@ import { InputElement } from "./InputElement" import { Store, UIEventSource } from "../../Logic/UIEventSource" +/** + * @deprecated + */ export default class InputElementMap extends InputElement { private readonly _inputElement: InputElement private isSame: (x0: X, x1: X) => boolean diff --git a/UI/Input/RadioButton.ts b/UI/Input/RadioButton.ts index 7c4c2d3c4..15e1a425a 100644 --- a/UI/Input/RadioButton.ts +++ b/UI/Input/RadioButton.ts @@ -2,6 +2,9 @@ import { InputElement } from "./InputElement" import { UIEventSource } from "../../Logic/UIEventSource" import { Utils } from "../../Utils" +/** + * @deprecated + */ export class RadioButton extends InputElement { private static _nextId = 0 diff --git a/UI/Input/Slider.ts b/UI/Input/Slider.ts index 272a0fa41..9fce626a7 100644 --- a/UI/Input/Slider.ts +++ b/UI/Input/Slider.ts @@ -1,6 +1,9 @@ import { InputElement } from "./InputElement" import { UIEventSource } from "../../Logic/UIEventSource" +/** + * @deprecated + */ export default class Slider extends InputElement { private readonly _value: UIEventSource private readonly min: number diff --git a/UI/Input/TextField.ts b/UI/Input/TextField.ts index 9c0e2bc22..0e0ccbbb9 100644 --- a/UI/Input/TextField.ts +++ b/UI/Input/TextField.ts @@ -4,6 +4,9 @@ import BaseUIElement from "../BaseUIElement" import { Translation } from "../i18n/Translation" import Locale from "../i18n/Locale" +/** + * @deprecated + */ interface TextFieldOptions { placeholder?: string | Store | Translation value?: UIEventSource @@ -15,6 +18,9 @@ interface TextFieldOptions { isValid?: (s: string) => boolean } +/** + * @deprecated + */ export class TextField extends InputElement { public readonly enterPressed = new UIEventSource(undefined) private readonly value: UIEventSource @@ -124,11 +130,6 @@ export class TextField extends InputElement { this.value.addCallbackAndRunD((value) => { // We leave the textfield as is in the case of undefined or null (handled by addCallbackAndRunD) - make sure we do not erase it! field["value"] = value - if (self.IsValid(value)) { - self.RemoveClass("invalid") - } else { - self.SetClass("invalid") - } }) field.oninput = () => { diff --git a/UI/Input/VariableInputElement.ts b/UI/Input/VariableInputElement.ts deleted file mode 100644 index 0fdae6c78..000000000 --- a/UI/Input/VariableInputElement.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ReadonlyInputElement } from "./InputElement" -import { Store } from "../../Logic/UIEventSource" -import BaseUIElement from "../BaseUIElement" -import { VariableUiElement } from "../Base/VariableUIElement" - -export default class VariableInputElement - extends BaseUIElement - implements ReadonlyInputElement -{ - private readonly value: Store - private readonly element: BaseUIElement - private readonly upstream: Store> - - constructor(upstream: Store>) { - super() - this.upstream = upstream - this.value = upstream.bind((v) => v.GetValue()) - this.element = new VariableUiElement(upstream) - } - - GetValue(): Store { - return this.value - } - - IsValid(t: T): boolean { - return this.upstream.data.IsValid(t) - } - - protected InnerConstructElement(): HTMLElement { - return this.element.ConstructElement() - } -}