1 line
8.2 KiB
Plaintext
1 line
8.2 KiB
Plaintext
|
{"version":3,"file":"primeng-inputtextarea.mjs","sources":["../../src/app/components/inputtextarea/inputtextarea.ts","../../src/app/components/inputtextarea/primeng-inputtextarea.ts"],"sourcesContent":["import { NgModule, Directive, ElementRef, HostListener, Input, Output, EventEmitter, Optional, AfterViewInit, OnInit, OnDestroy, ChangeDetectorRef, AfterViewChecked, booleanAttribute } from '@angular/core';\nimport { NgModel, NgControl, FormControl } from '@angular/forms';\nimport { CommonModule } from '@angular/common';\nimport { Subscription } from 'rxjs';\nimport { PrimeNGConfig } from 'primeng/api';\n/**\n * InputTextarea adds styling and autoResize functionality to standard textarea element.\n * @group Components\n */\n@Directive({\n selector: '[pInputTextarea]',\n host: {\n class: 'p-inputtextarea p-inputtext p-component p-element',\n '[class.p-filled]': 'filled',\n '[class.p-inputtextarea-resizable]': 'autoResize',\n '[class.p-variant-filled]': 'variant === \"filled\" || config.inputStyle() === \"filled\"'\n }\n})\nexport class InputTextarea implements OnInit, AfterViewInit, OnDestroy {\n /**\n * When present, textarea size changes as being typed.\n * @group Props\n */\n @Input({ transform: booleanAttribute }) autoResize: boolean | undefined;\n /**\n * Specifies the input variant of the component.\n * @group Props\n */\n @Input() variant: 'filled' | 'outlined' = 'outlined';\n /**\n * Callback to invoke on textarea resize.\n * @param {(Event | {})} event - Custom resize event.\n * @group Emits\n */\n @Output() onResize: EventEmitter<Event | {}> = new EventEmitter<Event | {}>();\n\n filled: boolean | undefined;\n\n cachedScrollHeight: number | undefined;\n\n ngModelSubscription: Subscription | undefined;\n\n ngControlSubscription: Subscription | undefined;\n\n constructor(public el: ElementRef, @Optional() public ngModel: NgModel, @Optional() public control: NgControl, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {}\n\n ngOnInit() {\n if (this.ngModel) {\n this.ngModelSubscription = (this.ngModel as any).valueChanges.subscribe(() => {\n this.updateState();\n });\n }\n\n if (this.control) {\n this.ngControlSubscription = (this.control as any).valueChanges.subscribe(() => {\n this.updateState();\n });\n }\n }\n\n ngAfterViewInit() {\n if (this.autoResize) this.resize();\n\n this.updateFilledState();\n this.cd.detectChanges();\n }\n\n @HostListener('input', ['$event'])\n onInput(e: Event) {\n this.updateState();\n }\n\n updateFilledState() {\n this.filled = this.el.nativeElement.value && this.el.nativeElement.value.length;\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 } 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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"map
|