import { html, property } from '@skhemata/skhemata-base'; import { SkhemataFormInput } from './SkhemataFormInput'; export class SkhemataFormDatePicker extends SkhemataFormInput { @property({ type: String }) min = ''; @property({ type: String }) max = ''; @property({ type: Boolean }) submitOnEnter = false; @property({ type: String }) type = 'text'; constructor() { super(); this.value = ''; } handleInput(event: any) { this.clearError(); this.setAttribute('value', event.target.value); } handleKeydown(event: any) { this.clearError(); if (event.keyCode === '13' && this.submitOnEnter) { this.validate(); if (!this.valid) { return; } this.dispatchEvent(new CustomEvent('submit')); event.preventDefault(); } } render() { const field = html`
${this.label && !this.horizontal ? html`` : null}
${this.description && !this.horizontal ? html`

${this.description}

` : null}
${!this.valid ? html`

${this.errorMessage}

` : ``}
`; const horizontalFieldLabel = html`
${this.label ? html`` : null} ${this.description ? html`

${this.description}

` : null}
`; const horizontalField = html`
${this.label || this.description ? horizontalFieldLabel : null}
${field}
`; return this.horizontal ? horizontalField : field; } }