import { InputElement } from "./InputElement" import { UIEventSource } from "../../Logic/UIEventSource" export default class SimpleDatePicker extends InputElement { IsSelected: UIEventSource = new UIEventSource(false) private readonly value: UIEventSource private readonly _element: HTMLElement constructor(value?: UIEventSource) { super() this.value = value ?? new UIEventSource(undefined) const self = this const el = document.createElement("input") this._element = el el.type = "date" el.oninput = () => { // Already in YYYY-MM-DD value! self.value.setData(el.value) } this.value.addCallbackAndRunD((v) => { el.value = v }) } GetValue(): UIEventSource { return this.value } IsValid(t: string): boolean { return !isNaN(new Date(t).getTime()) } protected InnerConstructElement(): HTMLElement { return this._element } }