export class AutoExpand { /** * Autoexpand, Constructor */ constructor(target) { this.target = target; if (this.target.dxData('autoexpand')) { return; } this.target.dxData('autoexpand', this); this.target.rows = 1; this.target.style.overflowY = 'hidden'; this.target.dxOn('input.autoExpand', _ => this.updateRows() ) } /** * AutoExpand, Update Rows */ updateRows() { const style = window.getComputedStyle(this.target); this.target.style.height = 'auto'; this.target.style.height = `${this.target.scrollHeight + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.borderBottomWidth) || 0)}px`; } /** * Autoexpand, Destroy */ destroy() { this.target.dxOff('input.autoExpand'); this.target.dxRemoveData('autoexpand'); } }