import { Component, forwardRef } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ReactiveFormsModule } from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { MatFormFieldModule } from '@angular/material/form-field'; import { FieldBase } from '@pega/angular-sdk-components'; import { ComponentMapperComponent } from '@pega/angular-sdk-components'; import { handleEvent } from '@pega/angular-sdk-components'; import { PConnFieldProps } from '@pega/angular-sdk-components'; interface TextAreaProps extends PConnFieldProps { // If any, enter additional props that only exist on TextArea here fieldMetadata?: any; } @Component({ selector: 'app-text-area', templateUrl: './text-area.component.html', styleUrls: ['./text-area.component.scss'], imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, forwardRef(() => ComponentMapperComponent)] }) export class TextAreaComponent extends FieldBase { configProps$: TextAreaProps; nMaxLength$: number; /** * Updates the component when there are changes in the state. */ override updateSelf(): void { // Resolve config properties this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as TextAreaProps; // Update component common properties this.updateComponentCommonProperties(this.configProps$); // Extract properties from config const { value } = this.configProps$; // Set component specific properties this.value$ = value; this.nMaxLength$ = this.pConn$.getFieldMetadata(this.pConn$.getRawConfigProps()?.value)?.maxLength || 100; } fieldOnChange(event: any) { const oldVal = this.value$ ?? ''; const isValueChanged = event.target.value.toString() !== oldVal.toString(); if (isValueChanged) { this.pConn$.clearErrorMessages({ property: this.propName }); } } fieldOnBlur(event: any) { const oldVal = this.value$ ?? ''; const isValueChanged = event.target.value.toString() !== oldVal.toString(); if (isValueChanged) { const value = event?.target?.value; handleEvent(this.actionsApi, 'changeNblur', this.propName, value); } } }