import { ComponentFactory, ComponentFactoryResolver, EventEmitter, QueryList, TemplateRef, Type, ViewContainerRef } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup } from '@angular/forms'; import { BaseComponent, ComponentType, ControlActionParam } from '@scpb/base'; import { FormEntityService, RestEntityService } from '@scpb/base/form-store'; import { ConfigService, Control, ControlAppearance, FormInputMetadata, InputMetadata } from '@scpb/core'; import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs'; import { PvmControlDirective } from './pvm-control.directive'; import { PvmTemplateDirective } from './pvm-template.directive'; /** * to create test form */ export declare class PvmFormComponent extends BaseComponent { private fb; private configService; private formService; private restService; private componentFactoryResolver; constructor(fb: FormBuilder, configService: ConfigService, formService: FormEntityService, restService: RestEntityService, componentFactoryResolver: ComponentFactoryResolver); set selectedFields(value: string | string[]); get selectedFields(): string | string[]; controls: QueryList; templates: QueryList; formName: string; appearance: ControlAppearance; components: ComponentType[]; fieldStyles: { [name: string]: string[]; }; minWidth: number; updateMetadata: Observable>; formCreated: EventEmitter; viewRendered: EventEmitter<{ formInputMetaData: FormInputMetadata; formGroup: FormGroup; }>; formAction: EventEmitter; _selectedFields: BehaviorSubject<{ name: string; position: number; }[]>; fieldList: { name: string; position: number; }[]; fieldSelection: string[]; baseForm: FormGroup; formFields$: BehaviorSubject; formInputMetaDataMap: { [key: string]: BehaviorSubject>; }; formInputMetadata: FormInputMetadata; componentTypeMap: { [key: string]: Type; }; errorControl: InputMetadata; errorServer: InputMetadata; templateNames: { [name: string]: TemplateRef; }; submitData: Subject; formEventSubscription: Subscription[]; formValue: {}; showForm: boolean; controlsConfig: {}; internalValue: {}; customValidation: (name: any, value: any) => { [key: string]: boolean; } | null; /** * to get the form fields * @returns the fields in the form {Observable} */ getFormFields(): Observable; /** * to create the form input Metadata * @param data to parse */ createForm(data: FormInputMetadata): void; /** * to create value change event * @param data of metadata */ createValueChangeEvent(data: FormInputMetadata): void; /** * to verify and invoke rest api * @param input of metadata * @param callback to subscribe for change event or invoke it directly */ checkAndInvokeRest(input: Partial, callback: (field: string[], self: boolean, ir: (fieldName: string, fieldValue: any) => void) => void): void; /** * to get the field values as object from string array * @param fieldNames to extract * @param fieldName to override * @param fieldValue to override * @returns the field object */ getFieldObject(fieldNames: string[], fieldName: string, fieldValue: any): {}; /** * to validate type is button or not * @param type of the button * @returns whether it is button or not */ isButtonOrFileUploadType(type: Control): boolean; /** * init */ init(): void; /** * after view init */ viewInit(): void; /** * to render the dynamic content * @param list of controls */ contentRender(list: QueryList): void; /** * to initialize the individual component * @param viewContainerRef for component * @param componentFactory to create component * @param item for control directive * @param input for metadata */ initializeComponent(viewContainerRef: ViewContainerRef, componentFactory: ComponentFactory, item: PvmControlDirective, input: Partial): void; /** * to subscribe events * @param param of control action Param */ consumeFormEvent(param: Partial): void; /** * to unsubscribe the form event * @param name of the field */ unsubscribeField(name: string): void; /** * to handle the form action * @param param of control action * @param requestBody to check to place the form value * @return response data */ handleFormEvent(param: Partial, requestBody: any): Observable; /** * to invoke the rest api call * @param value of control action param. * @returns the response */ invoke(value: ControlActionParam): Observable; /** * to check whether control required rest call or not * @param input for input meta data * @returns true if requires rest api */ checkRestCallForControls(input: Partial): boolean; /** * to load data from remote api * @param input of metadata * @param event to make remove call * @Returns the subscription to unsubscribe later */ loadDataFromRestApi(input: Partial, event: Observable): Subscription; /** * after content init */ contentInit(): void; /** * split the inputMetadata array to 2D row column Table * @param inputArray of metadata * @returns Table of InputMetadata. */ splitInto2D(inputArray: Partial[]): string[][]; /** * Converts the Metadata validators to Validators Object * @param validation object * @param name of the control * @returns validators */ generateValidators(validation: object, name: string): any; /** * to get the type and component object * @returns the type and component object {{[p: string]: IComponent}} */ getTypeComponentMap(): {}; /** * to validate amount * @returns validator function */ amountValidation(): (control: AbstractControl) => { [key: string]: boolean; }; /** * to validate content not equal to values * @returns validator function */ notInValidation(data: string[]): (control: AbstractControl) => { [key: string]: boolean; }; /** * to have a custom validation * @param name of the control * @returns validation condition similar to angular custom validators */ customFieldValidation(name: string): (control: AbstractControl) => { [key: string]: boolean; }; /** * Validate all the Form fields * @param formGroup to validate */ validateAllFormFields(formGroup: FormGroup): void; /** * to clear the form fields * @param exceptFields field names which won't be cleared */ clearFormFields(exceptFields: string | string[]): void; }