import { Component, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor, FormControl } from '@angular/forms';

import { AbstractControlValueAccessor } from '../abstract-control-value-accesor';

export const TEXTAREA_INPUT_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => TdDynamicAutoCompleteComponent),
  multi: true,
};

@Component({
  providers: [TEXTAREA_INPUT_CONTROL_VALUE_ACCESSOR],
  selector: 'td-dynamic-autocomplete',
  styleUrls: ['./dynamic-autocomplete.component.scss'],
  templateUrl: './dynamic-autocomplete.component.html',
})
export class TdDynamicAutoCompleteComponent extends AbstractControlValueAccessor implements ControlValueAccessor {

  control: FormControl;

  label: string = '';

  required: boolean = undefined;

  selections: any[] = undefined;

  selectionsKey: string = undefined;

  selectionsIDKey: string = undefined;

  setSelectionsNull(){
    this.selections = [];
  }

}
