UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Build Status](https://travis-ci.org/primefaces/primeng.

108 lines (104 loc) 3.8 kB
import { EventEmitter, ElementRef, Optional, Input, Output, HostListener, Directive, NgModule } from '@angular/core'; import { NgModel } from '@angular/forms'; import { CommonModule } from '@angular/common'; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; let InputTextarea = class InputTextarea { constructor(el, ngModel) { this.el = el; this.ngModel = ngModel; this.onResize = new EventEmitter(); } ngDoCheck() { this.updateFilledState(); if (this.autoResize) { this.resize(); } } //To trigger change detection to manage ui-state-filled for material labels when there is no value binding onInput(e) { this.updateFilledState(); if (this.autoResize) { this.resize(e); } } updateFilledState() { this.filled = (this.el.nativeElement.value && this.el.nativeElement.value.length) || (this.ngModel && this.ngModel.model); } onFocus(e) { if (this.autoResize) { this.resize(e); } } onBlur(e) { if (this.autoResize) { this.resize(e); } } resize(event) { this.el.nativeElement.style.height = 'auto'; this.el.nativeElement.style.height = this.el.nativeElement.scrollHeight + 'px'; if (parseFloat(this.el.nativeElement.style.height) >= parseFloat(this.el.nativeElement.style.maxHeight)) { this.el.nativeElement.style.overflowY = "scroll"; this.el.nativeElement.style.height = this.el.nativeElement.style.maxHeight; } else { this.el.nativeElement.style.overflow = "hidden"; } this.onResize.emit(event || {}); } }; InputTextarea.ctorParameters = () => [ { type: ElementRef }, { type: NgModel, decorators: [{ type: Optional }] } ]; __decorate([ Input() ], InputTextarea.prototype, "autoResize", void 0); __decorate([ Output() ], InputTextarea.prototype, "onResize", void 0); __decorate([ HostListener('input', ['$event']) ], InputTextarea.prototype, "onInput", null); __decorate([ HostListener('focus', ['$event']) ], InputTextarea.prototype, "onFocus", null); __decorate([ HostListener('blur', ['$event']) ], InputTextarea.prototype, "onBlur", null); InputTextarea = __decorate([ Directive({ selector: '[pInputTextarea]', host: { '[class.ui-inputtext]': 'true', '[class.ui-corner-all]': 'true', '[class.ui-inputtextarea-resizable]': 'autoResize', '[class.ui-state-default]': 'true', '[class.ui-widget]': 'true', '[class.ui-state-filled]': 'filled' } }), __param(1, Optional()) ], InputTextarea); let InputTextareaModule = class InputTextareaModule { }; InputTextareaModule = __decorate([ NgModule({ imports: [CommonModule], exports: [InputTextarea], declarations: [InputTextarea] }) ], InputTextareaModule); /** * Generated bundle index. Do not edit. */ export { InputTextarea, InputTextareaModule }; //# sourceMappingURL=primeng-inputtextarea.js.map