import { AsyncPipe, NgTemplateOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, ContentChild, forwardRef, inject, type TemplateRef } 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 { FieldErrorsComponent } from '@keycloakify/angular/login/components/field-errors'; import { GroupLabelComponent } from '@keycloakify/angular/login/components/group-label'; import { InputFieldByTypeComponent } from '@keycloakify/angular/login/components/input-field-by-type'; import { KcClassDirective } from '@keycloakify/angular/login/directives/kc-class'; import type { I18n } from '@keycloakify/angular/login/i18n'; import type { KcContext } from '@keycloakify/angular/login/KcContext'; import { type FormAction, UserProfileFormService } from '@keycloakify/angular/login/services/user-profile-form'; import { LOGIN_CLASSES } from '@keycloakify/angular/login/tokens/classes'; import { LOGIN_I18N } from '@keycloakify/angular/login/tokens/i18n'; import { KC_LOGIN_CONTEXT } from '@keycloakify/angular/login/tokens/kc-context'; import { DO_MAKE_USER_CONFIRM_PASSWORD } from '@keycloakify/angular/login/tokens/make-user-confirm-password'; import type { ClassKey } from 'keycloakify/login/lib/kcClsx'; @Component({ styles: [ ` :host { display: contents; } ` ], imports: [KcClassDirective, FieldErrorsComponent, InputFieldByTypeComponent, GroupLabelComponent, NgTemplateOutlet, AsyncPipe], selector: 'kc-user-profile-form-fields', templateUrl: 'user-profile-form-fields.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ UserProfileFormService, { provide: ComponentReference, useExisting: forwardRef(() => UserProfileFormFieldsComponent) } ] }) export class UserProfileFormFieldsComponent extends ComponentReference { i18n = inject(LOGIN_I18N); kcContext = inject(KC_LOGIN_CONTEXT); #userProfileFormService = inject(UserProfileFormService); doMakeUserConfirmPassword = inject(DO_MAKE_USER_CONFIRM_PASSWORD); override doUseDefaultCss = inject(USE_DEFAULT_CSS); override classes = inject>>(LOGIN_CLASSES); formState$ = this.#userProfileFormService.formState$; @ContentChild('beforeField') beforeField: TemplateRef | undefined; @ContentChild('afterField') afterField: TemplateRef | undefined; onDispatch(formAction: FormAction) { this.#userProfileFormService.dispatchFormAction(formAction); } }