import * as i0 from "@angular/core"; import { OnDestroy, OnInit } from "@angular/core"; import { AbstractFormBaseComponent } from "@hmcts/opal-frontend-common/components/abstract/abstract-form-base"; import { IAbstractFormArrayControl, IAbstractFormArrayControlValidation, IAbstractFormArrayControls } from "@hmcts/opal-frontend-common/components/abstract/interfaces"; import { AbstractControl, FormArray, FormControl, FormGroup, ValidatorFn } from "@angular/forms"; export declare abstract class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy { formArrayControls: IAbstractFormArrayControls[]; formArrayControlsValidation: IAbstractFormArrayControlValidation[]; formArrayFields: string[]; /** * Builds an array of form controls for a form array. * * @param formControlCount - An array of numbers representing the number of form controls to create. * @param formArrayName - The name of the form array. * @param fieldNames - An array of field names for the form controls. * @param controlValidation - An array of control validation configurations. * @returns An array of form controls for the form array. */ private buildFormArrayControls; /** * Adds form array controls to the specified form array. * * @param index - The index at which the form array controls should be added. * @param formArrayName - The name of the form array. * @param fieldNames - The names of the form controls to be created. * @param controlValidation - The validation rules for the form controls. * @returns An object containing the form controls that were added. */ private addFormArrayControls; /** * Creates a new instance of FormArray with the specified validators and controls. * * @param validators - An array of validator functions to be applied to the form array. * @param controls - An optional array of form controls to initialize the form array with. * @returns A new instance of FormArray. */ protected createFormArray(validators: ValidatorFn[], controls?: FormControl[]): FormArray; /** * Sets up the form array form controls based on the provided parameters. * * @param formArrayCountArray - An array of numbers representing the count of form array controls. * @param formArrayName - The name of the form array. */ protected setupFormArrayFormControls(formArrayCountArray: number[], formArrayName: string): void; /** * Creates an object with form array controls based on the given fields and index. * * @param fields - An array of field names. * @param index - The index of the form array. * @returns An object with form array controls. */ protected createFormArrayControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl; }; /** * Removes form array controls errors for a specific index. * * @param index - The index of the form array control. * @param formArrayControls - An array of form array controls. * @param fieldNames - An array of field names to remove errors from. */ protected removeFormArrayControlsErrors(index: number, formArrayControls: IAbstractFormArrayControls[], fieldNames: string[]): void; /** * Removes a form array control at the specified index from the given array of form array controls. * * @param index - The index of the form array control to be removed. * @param formArrayControls - The array of form array controls. * @returns The updated array of form array controls after removing the specified control. */ protected removeFormArrayControl(index: number, formArrayControls: IAbstractFormArrayControls[]): IAbstractFormArrayControls[]; /** * Retrieves the value of a form control or returns a default value if the control is null or undefined. * * @param control - The form control to retrieve the value from. * @param defaultValue - The default value to return if the control is null or undefined. * @returns The value of the control if it exists, otherwise the default value. */ protected getControlValueOrDefault(control: AbstractControl | null, defaultValue: any): any; /** * Removes a form array control at the specified index and updates the form array controls and errors. * * @param index - The index of the form array control to remove. * @param formArrayName - The name of the form array. * @param formArrayControls - The list of form array controls. * @param fieldNames - The names of the fields associated with the form array controls. * @returns The updated list of form array controls. */ removeFormArrayControls(index: number, formArrayName: string, formArrayControls: IAbstractFormArrayControls[], fieldNames: string[]): IAbstractFormArrayControls[]; /** * Removes controls from a form array at the specified index. * * @param index - The index at which to remove the controls. * @param formArrayName - The name of the form array. */ removeControlsFromFormArray(index: number, formArrayName: string): void; /** * Removes a form array control from the specified form array. * * @param formArrayControl - The form array control to remove. * @param formArrayName - The name of the form array. */ removeFormArrayControlFromArray(formArrayControl: IAbstractFormArrayControls, formArrayName: string): void; /** * Retrieves the FormGroup at the specified index from a FormArray. * * @param index - The index of the FormGroup to retrieve. * @param formArrayName - The name of the FormArray. * @returns The FormGroup at the specified index. */ getFormArrayFormGroup(index: number, formArrayName: string): FormGroup; /** * Retrieves the FormControl from a FormGroup within a FormArray at the specified index. * * @param formGroup - The FormGroup containing the FormControl. * @param controlName - The name of the FormControl. * @param index - The index of the FormArray. * @returns The FormControl at the specified index. */ getFormArrayFormGroupControl(formGroup: FormGroup, controlName: string, index: number): FormControl; /** * Adds validators to a specific form control within a form array group. * * @param formGroup - The form group containing the form array. * @param controlName - The name of the form control within the form array group. * @param index - The index of the form array group within the form array. * @param validators - An array of validator functions to be added to the form control. */ addFormArrayFormGroupControlValidators(formControl: FormControl, validators: ValidatorFn[]): void; /** * Removes validators from a specific form control within a form array group. * @param formGroup - The form group containing the form array. * @param controlName - The name of the form control within the form array group. * @param index - The index of the form array group within the form array. */ removeFormArrayFormGroupControlValidators(formControl: FormControl): void; /** * Reverses the form array data by appending the index to each key in the objects. * * @param data - An array of objects containing form data. * @returns An array of objects with keys modified to include their index in the original array. */ addIndexToFormArrayData(data: any[]): { [key: string]: any; }[]; /** * Adds controls to the form array at the specified index. * * @param index - The index at which the controls should be added. * @param formArrayName - The name of the form array. */ addControlsToFormArray(index: number, formArrayName: string): void; ngOnInit(): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }