import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, FormArray as NgFormArray, FormGroup, ValidatorFn } from '@angular/forms'; import { Observable } from 'rxjs'; import { AbstractControlWrapper } from './abstract-control-wrapper'; import { Form } from './form'; export declare abstract class AbstractFormArray extends AbstractControlWrapper> { private readonly _items; /** * An observable that emits when the collection of items is changed. */ readonly items$: Observable; /** * An array of items that are currently in the form array. */ get items(): TItem[]; constructor(items?: TItem[], validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null); destroy(): void; protected abstract _getControl(item: TItem): TControl; has(item: TItem): boolean; push(item: TItem): TItem; insert(index: number, item: TItem): TItem; /** * Sets the whole collection of new items in the form array. */ setItems(items: TItem[]): void; /** * This method updates the items in the array by mapping the provided values to existing items * or creating new items if they do not exist. It then sets the updated items and destroys any * items that are no longer needed. */ updateItemsByValues(params: { values: TValue[]; hasValue: (item: TItem, value: TValue) => boolean; create: (value: TValue) => TItem; update: (item: TItem, value: TValue) => void; destroy: (item: TItem) => void; }): void; removeAt(index: number): void; removeItem(item: TItem): TItem; removeAllItems(): void; /** * Merges the observables returned by the `selectValue` function for each item in the array. * * @template TValue - The type of the value emitted by the observables. * @param selectValue - A function that takes an item and returns an observable of type `TValue`. * @returns An observable that emits the values from the merged observables. */ merge(selectValue: (item: TItem) => Observable): Observable; /** * Combines the items in the array using the provided projection function. * * @template TValue - The type of the values emitted by the projection function. * @param project - A function that takes an item of type `TItem` and returns an `Observable` of type `TValue`. * @returns An `Observable` that emits an array of `TValue` items. */ combine(project: (item: TItem) => Observable): Observable; private _removeAllItems; } /** * A specialized form array class that extends `AbstractFormArray`. * This class is designed to handle an array of form groups of type `TForm`. * * @template TForm - The type of form contained within the array. * * @example * ```typescript * class MyForm extends Form { * public readonly name: FormControl = this.createControl(''); * } * * const formArray: FormArray = new FormArray(); * formArray.items$.subscribe((items) => console.log(items)); * formArray.push(new MyForm()); * formArray.removeAt(0); * ``` */ export declare class FormArray extends AbstractFormArray { protected _getControl(item: TForm): FormGroup; } /** * This class is designed to handle an array of form controls of type `TControl`. * * @template TControl - The type of form control that this array will manage. * * @example * ```typescript * const formArray: FormControlArray> = new FormControlArray>(); * formArray.items$.subscribe((items) => console.log(items)); * formArray.push(new FormControl(123)); * formArray.removeAt(0); * ``` */ export declare class FormControlArray extends AbstractFormArray { protected _getControl(item: TControl): TControl; }