UNPKG

@universal-material/web

Version:
44 lines 1.35 kB
import { __decorate } from "tslib"; import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { UmFieldBase } from './field-base.js'; let UmField = class UmField extends UmFieldBase { constructor() { super(...arguments); this.autoEmpty = false; this.control = null; this.handleControlInput = () => { if (this.autoEmpty) { this.empty = !this.control?.value; } }; } connectedCallback() { super.connectedCallback(); this.control = this.querySelector('input, select, button, textarea'); this.control?.addEventListener('input', this.handleControlInput); if (this.autoEmpty) { this.empty = !this.control?.value; } } disconnectedCallback() { super.disconnectedCallback(); this.control?.removeEventListener('input', this.handleControlInput); this.control = null; } renderControl() { return html ` <slot name="prefix"></slot> <div class="input"><slot></slot></div> <slot name="suffix"></slot> `; } }; __decorate([ property({ type: Boolean }) ], UmField.prototype, "autoEmpty", void 0); UmField = __decorate([ customElement('u-field') ], UmField); export { UmField }; //# sourceMappingURL=field.js.map