import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
  selector: 'app-dynamic-select',
  templateUrl: './dynamic-select.component.html',
  styleUrls: ['./dynamic-select.component.css']
})
export class DynamicSelectComponent{
  @Output() dataValue: EventEmitter<string | Array<any> | boolean> = new EventEmitter();

  @Input() label:string;
  @Input() tag:string;
  @Input() type:string;
  @Input() placeholder:string;
  @Input() value:string | Array<any> | boolean | Date;
  @Input() id:string;
  @Input() name: string;
  @Input() required_reg: boolean;
  @Input() required_mod: boolean;
  @Input() readonly_reg: boolean;
  @Input() readonly_mod: boolean;
  @Input() disabled_reg: boolean;
  @Input() disabled_mod: boolean;
  @Input() maxLength: string;
  @Input() pattern: string;
  @Input() icon: string;
  @Input() multiSelect: boolean;
  @Input() groupSelect: boolean;
  @Input() column: string;
  @Input() typeForm: string;

  @Input() arrDataSelect: Array<any>;

  public valueData: any;

  constructor() {
    this.label = '';
    this.tag = '';
    this.type = '';
    this.placeholder = '';
    this.value = '';
    this.id = '';
    this.name = '';
    this.required_reg = false;
    this.required_mod = false;
    this.readonly_reg = false;
    this.readonly_mod = false;
    this.disabled_reg = false;
    this.disabled_mod = false;
    this.maxLength = '';
    this.pattern = '';
    this.icon = '';
    this.column = '';
    this.multiSelect = false;
    this.groupSelect = false;

    this.typeForm = '';
    this.arrDataSelect = [];
  }


  public setValue(event:any) {
    this.dataValue.emit( event );
  }

}
