import { AbstractControl, FormGroup } from '@angular/forms'; import { Observable } from 'rxjs'; export declare class MtnaWfNgFormService { private ngForm; private unsavedChanges$; private valueChangeSubscription; /** * Informs a caller when the MtnaForm is dirty and has unsaved changes. */ readonly unsavedChanges: Observable; /** * Adds or removes a control from the ngForm * @param controlId id of the control being added/removed * @param parentIds array of ids representing the path to the parent control * @param action Whether to add or remove the control * @param newControl the new form control to be added */ addOrRemoveControl(controlId: string, parentIds: string[], action: 'ADD' | 'REMOVE', newControl?: AbstractControl): void; /** * Get the form if it exists * @returns the angular form or null */ getForm(): FormGroup | null; /** * Returns a JSON representation of form values */ getFormValue(): any; /** * @returns Whether a form has been set on this service */ hasForm(): boolean; /** * @returns Whether the form is dirty. */ isFormDirty(): boolean; /** * Unsubscribes from value changes & sets the ngForm to null. * Should be called when any component using an MtnaForm is destroyed. */ disposeForm(): void; /** * Forces the unsavedChanges observable to emit true. * Use with care, one example is when repeatable items are added/removed from the form. */ forceUnsavedChange(): void; /** * Marks ngForm as pristine & untouched. */ markAsPristineAndUntouched(): void; /** * Resets the ngForm. */ resetForm(): void; /** * Sets a FormGroup on the service so an external source may observe changes. * @param ngForm FormGroup to be registered. */ setForm(ngForm: FormGroup): void; /** * Subscribes to ngForm status changes & updates the unsavedChanges observable */ private observeNgFormChanges; /** * Removes the ngForm status change subscription. */ private unsubscribeValueChanges; }