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 { USE_DEFAULT_CSS } from '@keycloakify/angular/lib/tokens/use-default-css'; import { ComponentReference } from '@keycloakify/angular/login/classes/component-reference'; import type { TemplateSlots } from '@keycloakify/angular/login/classes/template-slots'; 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_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 type { ClassKey } from 'keycloakify/login/lib/kcClsx'; import { map } from 'rxjs'; @Component({ imports: [KcClassDirective, NgComponentOutlet], selector: 'kc-idp-review-user-profile', templateUrl: 'idp-review-user-profile.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: ComponentReference, useExisting: forwardRef(() => IdpReviewUserProfileComponent) } ] }) export class IdpReviewUserProfileComponent extends ComponentReference implements TemplateSlots { kcContext = inject>(KC_LOGIN_CONTEXT); i18n = inject(LOGIN_I18N); #userProfileFormService = inject(UserProfileFormService); override doUseDefaultCss = inject(USE_DEFAULT_CSS); override classes = inject>>(LOGIN_CLASSES); documentTitle: string | undefined; bodyClassName: string | undefined; displayRequiredFields = true; displayInfo = false; displayMessage = !this.kcContext?.messagesPerField?.existsError('global'); headerNode = viewChild>('headerNode'); infoNode = viewChild>('infoNode'); socialProvidersNode = viewChild>('socialProvidersNode'); userProfileFormFields = input>(); isFormSubmittable = toSignal(this.#userProfileFormService.formState$.pipe(map(s => s.isFormSubmittable)), { initialValue: false }); onCallback() { (document.getElementById('kc-register-form') as HTMLFormElement).requestSubmit(); } }