@pepperi-addons/ngx-lib 0.4.2-beta.317 → 0.4.2-beta.318
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.
- package/core/common/directives/auto-width.directive.d.ts +2 -0
- package/esm2020/core/common/directives/auto-width.directive.mjs +17 -9
- package/fesm2015/pepperi-addons-ngx-lib.mjs +17 -8
- package/fesm2015/pepperi-addons-ngx-lib.mjs.map +1 -1
- package/fesm2020/pepperi-addons-ngx-lib.mjs +16 -8
- package/fesm2020/pepperi-addons-ngx-lib.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -899,24 +899,32 @@ class PepInputAutoWidthDirective {
|
|
|
899
899
|
this.el = el;
|
|
900
900
|
this.includePadding = true;
|
|
901
901
|
this.input = null;
|
|
902
|
+
this.onBlurHandler = () => this.setWidthUsingText();
|
|
903
|
+
this.onKeyupHandler = () => this.setWidthUsingText();
|
|
902
904
|
}
|
|
903
905
|
ngAfterViewInit() {
|
|
904
|
-
if (this.el.nativeElement
|
|
905
|
-
this.input = this.el;
|
|
906
|
+
if (this.el.nativeElement?.tagName?.toLowerCase() === 'input') {
|
|
907
|
+
this.input = this.el.nativeElement;
|
|
906
908
|
}
|
|
907
909
|
else {
|
|
908
|
-
const list = this.el.nativeElement
|
|
909
|
-
|
|
910
|
+
const list = this.el.nativeElement?.querySelectorAll
|
|
911
|
+
? this.el.nativeElement.querySelectorAll('input')
|
|
912
|
+
: null;
|
|
913
|
+
this.input = list && list.length > 0 ? list[0] : null;
|
|
910
914
|
}
|
|
911
915
|
if (this.input) {
|
|
912
|
-
this.input.addEventListener('blur', this.
|
|
913
|
-
this.input.addEventListener('keyup', this.
|
|
916
|
+
this.input.addEventListener('blur', this.onBlurHandler);
|
|
917
|
+
this.input.addEventListener('keyup', this.onKeyupHandler);
|
|
914
918
|
}
|
|
915
919
|
this.setWidthUsingText();
|
|
916
920
|
}
|
|
917
921
|
ngOnDestroy() {
|
|
918
|
-
this.input
|
|
919
|
-
|
|
922
|
+
if (!this.input) {
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
this.input.removeEventListener('blur', this.onBlurHandler);
|
|
926
|
+
this.input.removeEventListener('keyup', this.onKeyupHandler);
|
|
927
|
+
this.input = null;
|
|
920
928
|
}
|
|
921
929
|
get paddingWidth() {
|
|
922
930
|
return this.includePadding
|