import { EventEmitter, OnDestroy, OnInit } from '@angular/core'; import { FieldConfig, FieldGroupConfig, Validator } from './field.interface'; import { MatDialogRef } from '@angular/material/dialog'; import { FormErrorStateMatcher } from '../validator/form-error-state.matcher'; import { AbstractModel, LocalStorageCommunicator } from '@ngvip/service'; import { DynamicFormDataService } from './dynamic-form-data.service'; import { VipDialogService } from '@ngvip/ui'; import { AbstractFormComponent } from './abstract-form-component'; import { CommonFormControl } from '../common-control/common-control.model'; import { CommonFormGroup } from '../common-control/common-group.model'; import { DatePipe } from '@angular/common'; import * as i0 from "@angular/core"; /** * @title Title of the add form defaults to Add * @fieldConfigs Array of configs used to build the formControls and the form. * @initializeWithErrors Whither the form should show errors on open. * @formData To prepopulate the form with values. * @errors To populate the form with errors. */ export interface DynamicFormConfig { title?: string; hideTitle?: boolean; hideActionRow?: boolean; disableFieldPlusNavigation?: boolean; fieldConfigs: FieldConfig[]; fieldGroupConfigs?: { [key: string]: FieldGroupConfig; }; formGroupValidators?: Validator[]; formGroupWarningValidators?: Validator[]; initializeWithErrors?: boolean; initializeAsDirty?: boolean; formData?: AbstractModel; errors?: { message?: string; fieldErrors?: Map; }; warning?: { message?: string; }; } export declare class DynamicFormComponent extends AbstractFormComponent implements OnInit, OnDestroy { private matDialogRef; data: DynamicFormConfig; private dynamicFormDataService; protected localStorageCommunicator: LocalStorageCommunicator; protected dialogService: VipDialogService; private datePipe; private saveButton; set config(config: DynamicFormConfig); get config(): DynamicFormConfig; set dialogRef(dialogRef: MatDialogRef); get dialogRef(): MatDialogRef; swapView: EventEmitter; save: EventEmitter; formChanged: EventEmitter; private _dialogRef; private _config; fieldConfigs: FieldConfig[]; formGroupValidators: Validator[]; formGroupWarningValidators: Validator[]; dynamicAddForm: CommonFormGroup; formData: AbstractModel; errorStateMatcher: FormErrorStateMatcher; errorMessage: string; warningMessage: string; formGroupErrorMessage: string; formGroupWarningMessage: string; fieldErrors: Map; fieldGroupMap: Map; hintMap: Map; constructor(matDialogRef: MatDialogRef, data: DynamicFormConfig, dynamicFormDataService: DynamicFormDataService, localStorageCommunicator: LocalStorageCommunicator, dialogService: VipDialogService, datePipe: DatePipe); ngOnInit(): void; /** * Set all the information required for the component to render and function * @param data */ initialize(data: DynamicFormConfig): void; /** * Initializes the dialog ref and listener for when a user clicks the backdrop behind the dialog * @param matDialogRef */ initializeDialog(matDialogRef: MatDialogRef): void; /** * Builds formControls based off the field configs supplied to the form * @return {[key: string]: CommonFormControl} A dictionary of key, FormControl */ buildFormControls(): { [key: string]: CommonFormControl; }; /** * Initialize links between dependent fields. When the 'parent' field changes, the disableDependents function * is called to determine whether to disable the 'child' field. * @param data the config passed into this.initialize * @private */ private initializeDependentFields; /** * Builds an array of keys from the field group map * @return Array of keys */ getKeys(): string[]; /** * @return A FormControl casted to the type of CommonFormControl */ getCommonFormControl(path: Array | string): CommonFormControl | null; /** * Get the current warnings that exist on the form control * @param config * @return string Return warnings present on control */ getControlWarning(config: FieldConfig): string; /** * Set the hint that is displayed underneath the input depending on warning, required * ,or an optional hint message was passed into the config * @param config */ setControlHint(config: FieldConfig): void; /** * On save if the form is valid close the dialog and build the submit data */ submit(): void; disableSave(): boolean; disableEscToClose(): boolean; disableCtrlSToSave(): boolean; transitionHandler(): void; /** * Evaluates if a formControl has an error or not * @param field Current formControl. * @param error The error from the formControl. */ getFormControlErrors(field: string, error: string): boolean; /** * Evaluates if a formGroup validator is attached to a specific form control * @param field Current formControl * @param error The error from the formGroupValidators array */ getFormGroupControlErrors(field: string, error: string): boolean; /** * Create Validator for formControl based off passed in Error Map. * @param field Current field being checked for error messages * @return ResponseError validator function with message from error map */ private checkForErrorMessages; /** * Get any error that is associated with form level validators * * @return string Error message that is displayed */ getFormGroupErrorMessage(): string; /** * Get any warning that is associated with form level validators * @return string Warning message that is displayed */ getFormGroupWarningMessage(): string; /** * When a file is selected from the hidden input set the formControl value to the selected file/files * @param $event Event from the file input that has the selected files * @param formControlName Form Control associated with the file input * @param multiple If the file input supports selecting multiple files */ onFileChange($event: any, formControlName: string, multiple: boolean): void; /** * Value to be displayed to the user when they select a file/files * @param file Current selected file/files */ formatFileName(file: File | File[]): string; /** * Check if variable is an array (since angular does not allow typeof in ngif) * @param variable to check */ isArray(variable: any): boolean; /** * Get selection text because we want the value to remain id, but want the ability to use icons in the options list * @param config FieldConfig */ getSelectedText(config: FieldConfig): string; closeExpansionPanel(groupKey: string): void; openExpansionPanel(groupKey: string): void; /** * Take a date value and format it as yyyy-mm-dd * @param value * @return string */ formatDate(value: any): string; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }