first commit

This commit is contained in:
2025-11-25 01:21:34 +02:00
commit 4af0db8263
84 changed files with 18906 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
export class AutoExpand {
/**
* Autoexpand, Constructor
*/
constructor(target, opts) {
this.opts = { ... { minRows: 3 }, ... opts };
this.target = target;
if (this.target.dxData('autoexpand')) {
return;
}
this.target.dxData('autoexpand', this);
this.update();
this.target.dxOn('input.autoExpand', this.setRows.bind(this));
}
/**
* Autoexpand, Update
*/
update() {
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;
}
/**
* Autoexpand, Destroy
*/
destroy = function() {
this.target.dxOff('input.autoExpand');
this.target.rows = 2;
this.target.dxRemoveData('autoexpand');
}
}