UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Join the chat at https://gitter.im/primefaces/primeng](https://badges.gitter.im/primefaces/primeng.svg)](https://gitter.im/primefaces/primeng?ut

126 lines 5.38 kB
"use strict"; 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 __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var common_1 = require("@angular/common"); var InputTextarea = /** @class */ (function () { function InputTextarea(el, ngModel) { this.el = el; this.ngModel = ngModel; this.onResize = new core_1.EventEmitter(); } InputTextarea.prototype.ngDoCheck = function () { 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 InputTextarea.prototype.onInput = function (e) { this.updateFilledState(); if (this.autoResize) { this.resize(e); } }; InputTextarea.prototype.updateFilledState = function () { this.filled = (this.el.nativeElement.value && this.el.nativeElement.value.length) || (this.ngModel && this.ngModel.model); }; InputTextarea.prototype.onFocus = function (e) { if (this.autoResize) { this.resize(e); } }; InputTextarea.prototype.onBlur = function (e) { if (this.autoResize) { this.resize(e); } }; InputTextarea.prototype.resize = function (event) { if (!this.cachedScrollHeight) { this.cachedScrollHeight = this.el.nativeElement.scrollHeight; this.el.nativeElement.style.overflow = "hidden"; } if (this.cachedScrollHeight != this.el.nativeElement.scrollHeight) { this.el.nativeElement.style.height = ''; 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.cachedScrollHeight = this.el.nativeElement.scrollHeight; } this.onResize.emit(event || {}); }; __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], InputTextarea.prototype, "autoResize", void 0); __decorate([ core_1.Output(), __metadata("design:type", core_1.EventEmitter) ], InputTextarea.prototype, "onResize", void 0); __decorate([ core_1.HostListener('input', ['$event']), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], InputTextarea.prototype, "onInput", null); __decorate([ core_1.HostListener('focus', ['$event']), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], InputTextarea.prototype, "onFocus", null); __decorate([ core_1.HostListener('blur', ['$event']), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], InputTextarea.prototype, "onBlur", null); InputTextarea = __decorate([ core_1.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, core_1.Optional()), __metadata("design:paramtypes", [core_1.ElementRef, forms_1.NgModel]) ], InputTextarea); return InputTextarea; }()); exports.InputTextarea = InputTextarea; var InputTextareaModule = /** @class */ (function () { function InputTextareaModule() { } InputTextareaModule = __decorate([ core_1.NgModule({ imports: [common_1.CommonModule], exports: [InputTextarea], declarations: [InputTextarea] }) ], InputTextareaModule); return InputTextareaModule; }()); exports.InputTextareaModule = InputTextareaModule; //# sourceMappingURL=inputtextarea.js.map