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

135 lines
15 KiB
JavaScript
Raw Normal View History

2024-07-16 14:55:36 +00:00
import { NgModule, Directive, HostListener, Input, Output, EventEmitter, Optional, booleanAttribute } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "primeng/api";
/**
* InputTextarea adds styling and autoResize functionality to standard textarea element.
* @group Components
*/
export 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']]
}] } });
export 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]
}]
}] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXR0ZXh0YXJlYS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvY29tcG9uZW50cy9pbnB1dHRleHRhcmVhL2lucHV0dGV4dGFyZWEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQWMsWUFBWSxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsWUFBWSxFQUFFLFFBQVEsRUFBeUUsZ0JBQWdCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFOU0sT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDOzs7O0FBRy9DOzs7R0FHRztBQVVILE1BQU0sT0FBTyxhQUFhO0lBMEJIO0lBQW1DO0lBQXFDO0lBQTRCO0lBQThCO0lBekJySjs7O09BR0c7SUFDcUMsVUFBVSxDQUFzQjtJQUN4RTs7O09BR0c7SUFDTSxPQUFPLEdBQTBCLFVBQVUsQ0FBQztJQUNyRDs7OztPQUlHO0lBQ08sUUFBUSxHQUE2QixJQUFJLFlBQVksRUFBYyxDQUFDO0lBRTlFLE1BQU0sQ0FBc0I7SUFFNUIsa0JBQWtCLENBQXFCO0lBRXZDLG1CQUFtQixD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