import { OnInit, AfterViewInit, Renderer, ComponentFactoryResolver } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Subject } from 'rxjs/Subject'; import { EstructureBaseField, EstructureBaseButton, EstructureBaseInnerHTML, EstructureBaseSvg, EstructureGeoMap, EstructureText } from '../constructor/component'; import { EstructureBaseGroupTable } from '../../table/evk-table.component'; import { EstructureBaseFormButton } from '../../form/button/evk-form-button.component'; import { EstructureBaseFormGroupButton } from '../../form/button/evk-group-button.component'; import { EvkOption } from '../../form/select/component'; /** * Componente que construye el formulario */ export declare class EvkSectionFormComponent implements AfterViewInit, OnInit { renderer: Renderer; factoryResolver: ComponentFactoryResolver; /** * Colección de metadatos que generan los campos de formulario o sus secciones * segun su configuración */ metadata: EstructureBaseFormSection[] | EstructureBaseField[]; /** * FormGroup que manaja al formulario */ form: FormGroup; /** * Indicador que valida la estructura del formulario */ hasSections: boolean; /** * ## html * ```html * * ``` * * * ## Estructura de las secciones * ```ts * metadata = [ * { * title: 'Título de la sección' * subtitle : 'subtitulo de la sección' * visibleSubject: myVisibleSubject * formSection: [ * //Definición del formulario * ] * } * ] * ``` * * ## Estructura del formulario * ```ts * // Campos simples contenidos en el mismo objeto * // Salida: { campoTexto: 'valor' } * metadata = [ * { * name: 'campoTexto', * label: 'Campo de texto simple', * grid: 'col-md-12', * type: 'text', * onchange: this.myOnChangeHandler.bind(this), * form: this.form, * group: this.form, * control: this.fbuilder.control(''), * }, * ]; * * // Campos contenidos dentro de un objeto anidado * // Salida: { catalogo: { id: 'valorId'} } * metadata = [ * { * name: 'id', * label: 'Select que carga un catalogo', * grid: 'col-md-12', * type: 'select', * optionChange: this.optionChangeSubject, * onchange: this.selectValueChange.bind(this), * form: this.form, * group: this.fbuilder.group({ * id: ['', Validators.required], * }), * formGroupName: 'catalogo' * } * ]; * * // Salida: { * // Campos contenidos en un arreglo de objetos * // atributos: [ * // { * // datoC: 'valor', * // atributo: { * // id: 1 * // } * // }, * // { * // datoC: 'valor', * // atributo: { * // id: 1 * // } * // } * // ] * // } * metadata = [ * { * name: 'datoC', * label: 'Campo de un array en la posición 1', * grid: 'col-md-12', * type: 'text', * onchange: this.inputValueChange.bind(this), * form: this.form, * group: this.fbuilder.array([ * this.fbuilder.group({ * datoC: ['', Validators.required], * atributo: this.fbuilder.group({ * id: 1 * }) * }), * ]), * formArrayName: 'atributos' * }, * { * name: 'datoC', * label: 'Campo de un array en la posición 2', * grid: 'col-md-12', * type: 'text', * onchange: this.inputValueChange.bind(this), * form: this.form, * group: this.fbuilder.array([ * this.fbuilder.group({ * datoC: ['', Validators.required], * atributo: this.fbuilder.group({ * id: 2 * }) * }), * ]), * formArrayName: 'atributos' * }, * ]; * ``` */ constructor(renderer: Renderer, factoryResolver: ComponentFactoryResolver); /** * Inicializa el componente, valida que existan los campos necesarios para su funcionamiento. En caso de no existir manda un error. */ ngOnInit(): void; ngAfterViewInit(): void; } /** * Estructura base para la definición de las secciones de un formulario */ export interface EstructureBaseFormSection { /** * Colección de campos que contendrá la sección */ formSection: (EstructureBaseField | EstructureBaseGroupTable | EstructureBaseButton | EstructureBaseFormButton | EstructureBaseFormGroupButton | EstructureBaseInnerHTML | EstructureBaseSvg | EstructureGeoMap | EstructureText | EvkOption)[]; /** * Subject que se ejecutará para mostrar u ocultar la sección del formulario */ visibleSubject?: Subject; /** * Indicador de visibilidad de la seccion */ visible?: boolean; /** * Subtitulo de la sección */ subtitle?: string; /** * Titulo de la sección */ title?: string; type?: 'section-form'; } /** * @ignore * Comprueba si el tipo enviado es de tipo EstructureBaseFormSection * @param object */ export declare function typeOfEstructureBaseFormSection(object: any): object is EstructureBaseFormSection[];