UNPKG

vue-forms-builder

Version:

Typescript forms builder package written specifically for Vue

100 lines (99 loc) 3.05 kB
import { AbstractControl } from '../models'; export declare class FormArray { controls: AbstractControl[]; /** * Getter for the length of controls * @readonly * @type {number} * @memberof FormArray */ get length(): number; /** * Getter for the controls value * @readonly * @type {any[]} * @memberof FormArray */ get value(): any[]; /** * Getter for controls validity * @readonly * @type {boolean} * @memberof FormArray */ get valid(): boolean; /** * Getter for the array touched value * @readonly * @type {boolean} * @memberof FormArray */ get touched(): boolean; /** * Initialize the FormArray instance * @param controls - controls for the FormArray */ constructor(controls: AbstractControl[]); /** * Get control at the given index in the array of controls * @param index - the index number of the control * @returns AbstractControl at the given index */ at(index: number): AbstractControl; /** * Add a new control at the end of the array of controls * @param control - new AbstractControl */ push(control: AbstractControl): void; /** * Insert a new control at the given index in the array of controls * @param index - index number where we want to insert the control * @param control - new AbstractControl */ insert(index: number, control: AbstractControl): void; /** * Remove control at the given index from the array of controls * @param index - the index number of the control we want to delete */ removeAt(index: number): void; /** * Replace an existing control at the given index in the array of controls * @param index - the index number of the control we want to replace * @param control - new AbstractControl */ setControl(index: number, control: AbstractControl): void; /** * Resets all the controls in this array to the initial value, * setting all of it as untouched, resetting error * and setting validators to the initial value */ reset(): void; /** * Remove all controls from this array */ clear(): void; /** * Marks all the controls in this array as touched */ markAllAsTouched(): void; /** * Patches the value of this array * @param values - array of values for the controls */ patchValue(values: any[]): void; /** * Private method for checking validaty of the controls * @returns if all controls are valid returns true, if not return false */ private _checkIsValid; /** * Private method for getting controls as array of values * @returns array of controls value */ private _getValueAsArray; /** * Private method for checking touched of the controls in this array * @returns true if any control in this array is touched, false if all controls are untouched. */ private _checkIsTouched; }