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
  @Input() id:string;
  @Input() name: string;
  @Input() required: boolean;
  @Input() readonly: boolean;
  @Input() maxLength: string;
  @Input() pattern: string;
  @Input() disabled: boolean;
  @Input() icon: string;
  @Input() multiSelect: boolean;
  @Input() groupSelect: boolean;
  @Input() column: string;

  @Input() arrDataSelect: Array<any>;

  constructor() {
    this.label = '';
    this.tag = '';
    this.type = '';
    this.placeholder = '';
    this.value = '';
    this.id = '';
    this.name = '';
    this.required = false;
    this.readonly = false;
    this.maxLength = '';
    this.pattern = '';
    this.disabled = false;
    this.icon = '';
    this.column = '';
    this.multiSelect = false;
    this.groupSelect = false;

    this.arrDataSelect = [];
  }


  public setValue(event:any) {
    let dataInput:string = (event.target as HTMLInputElement).value;
    this.dataValue.emit( dataInput );
  }

}
