{"version":3,"sources":["../../src/app/components/inputtextarea/inputtextarea.ts"],"names":["InputTextarea","el","ngModel","control","cd","this","onResize","EventEmitter","prototype","ngOnInit","_this","ngModelSubscription","valueChanges","subscribe","updateState","ngControlSubscription","ngAfterViewInit","autoResize","resize","updateFilledState","detectChanges","onInput","e","filled","nativeElement","value","length","model","onFocus","onBlur","event","style","height","scrollHeight","parseFloat","maxHeight","overflowY","overflow","emit","ngOnDestroy","unsubscribe","Directive","args","selector","host","[class.p-inputtextarea]","[class.p-inputtext]","[class.p-component]","[class.p-filled]","[class.p-inputtextarea-resizable]","ElementRef","NgModel","decorators","type","Optional","NgControl","ChangeDetectorRef","Input","Output","HostListener","NgModule","imports","CommonModule","exports","declarations"],"mappings":"weA6BI,SAAAA,EAAmBC,EAAmCC,EAAqCC,EAA6BC,GAArGC,KAAAJ,GAAAA,EAAmCI,KAAAH,QAAAA,EAAqCG,KAAAF,QAAAA,EAA6BE,KAAAD,GAAAA,EAV9GC,KAAAC,SAA8B,IAAIC,EAAAA,oBAY5CP,EAAAQ,UAAAC,SAAA,WAAA,IAAAC,EAAAL,KACQA,KAAKH,UACLG,KAAKM,oBAAsBN,KAAKH,QAAQU,aAAaC,WAAU,WAC3DH,EAAKI,kBAITT,KAAKF,UACLE,KAAKU,sBAAwBV,KAAKF,QAAQS,aAAaC,WAAU,WAC7DH,EAAKI,mBAKjBd,EAAAQ,UAAAQ,gBAAA,WACQX,KAAKY,YACLZ,KAAKa,SAETb,KAAKc,oBACLd,KAAKD,GAAGgB,iBAIZpB,EAAAQ,UAAAa,QAAA,SAAQC,GACJjB,KAAKS,eAGTd,EAAAQ,UAAAW,kBAAA,WACId,KAAKkB,OAAUlB,KAAKJ,GAAGuB,cAAcC,OAASpB,KAAKJ,GAAGuB,cAAcC,MAAMC,QAAYrB,KAAKH,SAAWG,KAAKH,QAAQyB,OAIvH3B,EAAAQ,UAAAoB,QAAA,SAAQN,GACAjB,KAAKY,YACLZ,KAAKa,OAAOI,IAKpBt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AA,CAAC,CACNmB,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC/D,GACVgE,aAAc,CAAChE","sourcesContent":["import {NgModule,Directive,ElementRef,HostListener,Input,Output, EventEmitter,Optional, AfterViewInit, OnInit, OnDestroy, ChangeDetectorRef} from '@angular/core';\nimport {NgModel, NgControl} from '@angular/forms';\nimport {CommonModule} from '@angular/common';\nimport { Subscription } from 'rxjs';\n\n@Directive({\n selector: '[pInputTextarea]',\n host: {\n '[class.p-inputtextarea]': 'true',\n '[class.p-inputtext]': 'true',\n '[class.p-component]': 'true',\n '[class.p-filled]': 'filled',\n '[class.p-inputtextarea-resizable]': 'autoResize'\n }\n})\nexport class InputTextarea implements OnInit, AfterViewInit, OnDestroy {\n \n @Input() autoResize: boolean;\n \n @Output() onResize: EventEmitter = new EventEmitter();\n \n filled: boolean;\n\n cachedScrollHeight:number;\n\n ngModelSubscription: Subscription;\n\n ngControlSubscription: Subscription;\n\n constructor(public el: ElementRef, @Optional() public ngModel: NgModel, @Optional() public control : NgControl, private cd: ChangeDetectorRef) {}\n \n ngOnInit() {\n if (this.ngModel) {\n this.ngModelSubscription = this.ngModel.valueChanges.subscribe(() =>{\n this.updateState();\n })\n }\n\n if (this.control) {\n this.ngControlSubscription = this.control.valueChanges.subscribe(() => {\n this.updateState();\n });\n }\n }\n\n ngAfterViewInit() {\n if (this.autoResize)\n this.resize();\n\n this.updateFilledState();\n this.cd.detectChanges();\n }\n\n @HostListener('input', ['$event'])\n onInput(e) {\n this.updateState();\n }\n \n updateFilledState() {\n this.filled = (this.el.nativeElement.value && this.el.nativeElement.value.length) || (this.ngModel && this.ngModel.model);\n }\n \n @HostListener('focus', ['$event'])\n onFocus(e) {\n if (this.autoResize) {\n this.resize(e);\n }\n }\n \n @HostListener('blur', ['$event'])\n onBlur(e) {\n if (this.autoResize) {\n this.resize(e);\n }\n }\n \n resize(event?: Event) {\n this.el.nativeElement.style.height = 'auto';\n this.el.nativeElement.style.height = this.el.nativeElement.scrollHeight + 'px';\n\n if (parseFloat(this.el.nativeElement.style.height) >= parseFloat(this.el.nativeElement.style.maxHeight)) {\n this.el.nativeElement.style.overflowY = \"scroll\";\n this.el.nativeElement.style.height = this.el.nativeElement.style.maxHeight;\n }\n else {\n this.el.nativeElement.style.overflow = \"hidden\";\n }\n\n this.onResize.emit(event||{});\n }\n\n updateState() {\n this.updateFilledState();\n \n if (this.autoResize) {\n this.resize();\n }\n }\n\n ngOnDestroy() {\n if (this.ngModelSubscription) {\n this.ngModelSubscription.unsubscribe();\n }\n\n if (this.ngControlSubscription) {\n this.ngControlSubscription.unsubscribe();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [InputTextarea],\n declarations: [InputTextarea]\n})\nexport class InputTextareaModule { }\n"]}