From ecd79ebd010adab9bae4d32d15805140105f9091 Mon Sep 17 00:00:00 2001 From: grainsoft Date: Sun, 24 May 2026 02:48:16 +0300 Subject: [PATCH] updates --- src/utils/Print.js | 2 +- src/widgets/auto-expand/AutoExpand.js | 44 ++++++++------------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/utils/Print.js b/src/utils/Print.js index ad6668c..f67aa30 100644 --- a/src/utils/Print.js +++ b/src/utils/Print.js @@ -32,4 +32,4 @@ export class Print{ } } -Ut.extendNodeUx(Print); \ No newline at end of file +Ut.uxRegister(Print); \ No newline at end of file diff --git a/src/widgets/auto-expand/AutoExpand.js b/src/widgets/auto-expand/AutoExpand.js index cb7e42e..df93c5a 100644 --- a/src/widgets/auto-expand/AutoExpand.js +++ b/src/widgets/auto-expand/AutoExpand.js @@ -3,56 +3,38 @@ export class AutoExpand { /** * Autoexpand, Constructor */ - constructor(target, opts) { - - this.opts = { ... { minRows: 3 }, ... opts }; + constructor(target) { this.target = target; if (this.target.dxData('autoexpand')) { return; } - + this.target.dxData('autoexpand', this); - this.update(); + this.target.rows = 1; + this.target.style.overflowY = 'hidden'; - this.target.dxOn('input.autoExpand', this.setRows.bind(this)); + this.target.dxOn('input.autoExpand', _ => this.updateRows() ) } /** - * Autoexpand, Update - */ - update() { + * AutoExpand, Update Rows + */ + updateRows() { - let val = this.target.dxVal(); - - this.target.dxVal(''); - - this.target.dataset.baseScrollHeight = this.target.scrollHeight; - - this.target.dxVal(val); - - if (val) { - this.setRows(); - } - } - - /** - * Autoexpand, Set Rows - */ - setRows() { - this.target.rows = this.opts.minRows; - let rows = Math.ceil((this.target.scrollHeight - this.target.dataset.baseScrollHeight) / 16); - this.target.rows = this.opts.minRows + rows; + 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 = function() { + destroy() { this.target.dxOff('input.autoExpand'); - this.target.rows = 2; this.target.dxRemoveData('autoexpand'); } } \ No newline at end of file