This commit is contained in:
2026-05-24 02:48:16 +03:00
parent f35b536b72
commit ecd79ebd01
2 changed files with 14 additions and 32 deletions
+1 -1
View File
@@ -32,4 +32,4 @@ export class Print{
}
}
Ut.extendNodeUx(Print);
Ut.uxRegister(Print);
+10 -28
View File
@@ -3,9 +3,7 @@ export class AutoExpand {
/**
* Autoexpand, Constructor
*/
constructor(target, opts) {
this.opts = { ... { minRows: 3 }, ... opts };
constructor(target) {
this.target = target;
@@ -15,44 +13,28 @@ export class AutoExpand {
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
* AutoExpand, Update Rows
*/
update() {
updateRows() {
let val = this.target.dxVal();
const style = window.getComputedStyle(this.target);
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;
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');
}
}