import {InputElement} from "./InputElement"; import {UIEventSource} from "../../Logic/UIEventSource"; export default class SimpleDatePicker extends InputElement { private readonly value: UIEventSource constructor( value?: UIEventSource ) { super(); this.value = value ?? new UIEventSource(undefined); const self = this; this.value.addCallbackAndRun(v => { if(v === undefined){ return; } self.SetValue(v); }); } InnerRender(): string { return ``; } private SetValue(date: string){ const field = document.getElementById("date-" + this.id); if (field === undefined || field === null) { return; } // @ts-ignore field.value = date; } protected InnerUpdate() { const field = document.getElementById("date-" + this.id); if (field === undefined || field === null) { return; } const self = this; field.oninput = () => { // Already in YYYY-MM-DD value! // @ts-ignore self.value.setData(field.value); } } GetValue(): UIEventSource { return this.value; } IsSelected: UIEventSource = new UIEventSource(false); IsValid(t: string): boolean { return false; } }