import { NgComponentOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, forwardRef, inject, input, type TemplateRef, type Type, viewChild } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { ComponentReference } from '@keycloakify/angular/login/classes/component-reference'; import type { TemplateSlots } from '@keycloakify/angular/login/classes/template-slots'; import { LogoutOtherSessionsComponent } from '@keycloakify/angular/login/components/logout-other-sessions'; import { type UserProfileFormFieldsComponent } from '@keycloakify/angular/login/components/user-profile-form-fields'; 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 { UserProfileFormService } from '@keycloakify/angular/login/services/user-profile-form'; import { LOGIN_I18N } from '@keycloakify/angular/login/tokens/i18n'; import { KC_LOGIN_CONTEXT } from '@keycloakify/angular/login/tokens/kc-context'; import { map } from 'rxjs'; @Component({ imports: [KcClassDirective, NgComponentOutlet, LogoutOtherSessionsComponent], selector: 'kc-update-email', templateUrl: 'update-email.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: ComponentReference, useExisting: forwardRef(() => UpdateEmailComponent) } ] }) export class UpdateEmailComponent extends ComponentReference implements TemplateSlots { #userProfileFormService = inject(UserProfileFormService); kcContext = inject>(KC_LOGIN_CONTEXT); i18n = inject(LOGIN_I18N); documentTitle: string | undefined; bodyClassName: string | undefined; displayRequiredFields = true; displayInfo = false; displayMessage = this.kcContext.messagesPerField.exists('global'); headerNode = viewChild>('headerNode'); infoNode = viewChild>('infoNode'); socialProvidersNode = viewChild>('socialProvidersNode'); userProfileFormFields = input>(); isFormSubmittable = toSignal(this.#userProfileFormService.formState$.pipe(map(s => s.isFormSubmittable)), { initialValue: false }); }