@indigina/ui-kit 1.1.496 → 1.1.497
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1649,6 +1649,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1649
1649
|
class KitTextareaAutoresizeDirective {
|
|
1650
1650
|
constructor() {
|
|
1651
1651
|
this.elementRef = inject(ElementRef);
|
|
1652
|
+
this.previousValue = '';
|
|
1652
1653
|
}
|
|
1653
1654
|
onInput() {
|
|
1654
1655
|
this.resize();
|
|
@@ -1658,10 +1659,34 @@ class KitTextareaAutoresizeDirective {
|
|
|
1658
1659
|
this.resize();
|
|
1659
1660
|
}
|
|
1660
1661
|
}
|
|
1662
|
+
ngDoCheck() {
|
|
1663
|
+
const currentValue = this.elementRef.nativeElement.value;
|
|
1664
|
+
if (currentValue !== this.previousValue) {
|
|
1665
|
+
this.previousValue = currentValue;
|
|
1666
|
+
this.resize();
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1661
1669
|
resize() {
|
|
1662
|
-
this.elementRef.nativeElement
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1670
|
+
const el = this.elementRef.nativeElement;
|
|
1671
|
+
const scrollableParent = this.getScrollableParent(el);
|
|
1672
|
+
const savedScrollTop = scrollableParent?.scrollTop ?? 0;
|
|
1673
|
+
el.style.height = '0';
|
|
1674
|
+
const scrollHeight = el.scrollHeight;
|
|
1675
|
+
el.style.height = `${scrollHeight}px`;
|
|
1676
|
+
if (scrollableParent) {
|
|
1677
|
+
scrollableParent.scrollTop = savedScrollTop;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
getScrollableParent(el) {
|
|
1681
|
+
let parent = el.parentElement;
|
|
1682
|
+
while (parent) {
|
|
1683
|
+
const overflowY = globalThis.window.getComputedStyle(parent).overflowY;
|
|
1684
|
+
if (overflowY === 'auto' || overflowY === 'scroll') {
|
|
1685
|
+
return parent;
|
|
1686
|
+
}
|
|
1687
|
+
parent = parent.parentElement;
|
|
1688
|
+
}
|
|
1689
|
+
return document.scrollingElement;
|
|
1665
1690
|
}
|
|
1666
1691
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: KitTextareaAutoresizeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1667
1692
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: KitTextareaAutoresizeDirective, isStandalone: true, selector: "[autoresize]", host: { listeners: { ":input": "onInput()" } }, ngImport: i0 }); }
|