import { ChangeDetectionStrategy, Component, forwardRef, inject, input, output } from '@angular/core'; import { USE_DEFAULT_CSS } from '@keycloakify/angular/lib/tokens/use-default-css'; import { ComponentReference } from '@keycloakify/angular/login/classes/component-reference'; import { KcClassDirective } from '@keycloakify/angular/login/directives/kc-class'; import { ToNumberPipe } from '@keycloakify/angular/lib/pipes/to-number'; import type { FormAction, FormFieldError } from '@keycloakify/angular/login/services/user-profile-form'; import { LOGIN_CLASSES } from '@keycloakify/angular/login/tokens/classes'; import type { Attribute } from 'keycloakify/login/KcContext'; import type { ClassKey } from 'keycloakify/login/lib/kcClsx'; @Component({ styles: [ ` :host { display: contents; } ` ], imports: [KcClassDirective, ToNumberPipe], selector: 'kc-textarea-tag', templateUrl: 'textarea-tag.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: ComponentReference, useExisting: forwardRef(() => TextareaTagComponent) } ] }) export class TextareaTagComponent extends ComponentReference { attribute = input(); value = input(); displayableErrors = input(); dispatchFormAction = output(); override doUseDefaultCss = inject(USE_DEFAULT_CSS); override classes = inject>>(LOGIN_CLASSES); onChange(event: Event) { this.dispatchFormAction.emit({ action: 'update', name: this.attribute()?.name ?? '', valueOrValues: (event.target as HTMLTextAreaElement).value }); } onBlur() { this.dispatchFormAction.emit({ action: 'focus lost', name: this.attribute()?.name ?? '', fieldIndex: undefined }); } }