Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-inputtextarea.mjs

143 lines
5.9 KiB
JavaScript

import * as i0 from '@angular/core';
import { EventEmitter, booleanAttribute, Directive, Optional, Input, Output, HostListener, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as i1 from '@angular/forms';
import * as i2 from 'primeng/api';
/**
* InputTextarea adds styling and autoResize functionality to standard textarea element.
* @group Components
*/
class InputTextarea {
el;
ngModel;
control;
cd;
config;
/**
* When present, textarea size changes as being typed.
* @group Props
*/
autoResize;
/**
* Specifies the input variant of the component.
* @group Props
*/
variant = 'outlined';
/**
* Callback to invoke on textarea resize.
* @param {(Event | {})} event - Custom resize event.
* @group Emits
*/
onResize = new EventEmitter();
filled;
cachedScrollHeight;
ngModelSubscription;
ngControlSubscription;
constructor(el, ngModel, control, cd, config) {
this.el = el;
this.ngModel = ngModel;
this.control = control;
this.cd = cd;
this.config = config;
}
ngOnInit() {
if (this.ngModel) {
this.ngModelSubscription = this.ngModel.valueChanges.subscribe(() => {
this.updateState();
});
}
if (this.control) {
this.ngControlSubscription = this.control.valueChanges.subscribe(() => {
this.updateState();
});
}
}
ngAfterViewInit() {
if (this.autoResize)
this.resize();
this.updateFilledState();
this.cd.detectChanges();
}
onInput(e) {
this.updateState();
}
updateFilledState() {
this.filled = this.el.nativeElement.value && this.el.nativeElement.value.length;
}
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 || {});
}
updateState() {
this.updateFilledState();
if (this.autoResize) {
this.resize();
}
}
ngOnDestroy() {
if (this.ngModelSubscription) {
this.ngModelSubscription.unsubscribe();
}
if (this.ngControlSubscription) {
this.ngControlSubscription.unsubscribe();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputTextarea, deps: [{ token: i0.ElementRef }, { token: i1.NgModel, optional: true }, { token: i1.NgControl, optional: true }, { token: i0.ChangeDetectorRef }, { token: i2.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "17.3.7", type: InputTextarea, selector: "[pInputTextarea]", inputs: { autoResize: ["autoResize", "autoResize", booleanAttribute], variant: "variant" }, outputs: { onResize: "onResize" }, host: { listeners: { "input": "onInput($event)" }, properties: { "class.p-filled": "filled", "class.p-inputtextarea-resizable": "autoResize", "class.p-variant-filled": "variant === \"filled\" || config.inputStyle() === \"filled\"" }, classAttribute: "p-inputtextarea p-inputtext p-component p-element" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputTextarea, decorators: [{
type: Directive,
args: [{
selector: '[pInputTextarea]',
host: {
class: 'p-inputtextarea p-inputtext p-component p-element',
'[class.p-filled]': 'filled',
'[class.p-inputtextarea-resizable]': 'autoResize',
'[class.p-variant-filled]': 'variant === "filled" || config.inputStyle() === "filled"'
}
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.NgModel, decorators: [{
type: Optional
}] }, { type: i1.NgControl, decorators: [{
type: Optional
}] }, { type: i0.ChangeDetectorRef }, { type: i2.PrimeNGConfig }], propDecorators: { autoResize: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], variant: [{
type: Input
}], onResize: [{
type: Output
}], onInput: [{
type: HostListener,
args: ['input', ['$event']]
}] } });
class InputTextareaModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputTextareaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: InputTextareaModule, declarations: [InputTextarea], imports: [CommonModule], exports: [InputTextarea] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputTextareaModule, imports: [CommonModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InputTextareaModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule],
exports: [InputTextarea],
declarations: [InputTextarea]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { InputTextarea, InputTextareaModule };
//# sourceMappingURL=primeng-inputtextarea.mjs.map