/*
 * Copyright (C) 2021 StApps
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */
import {Component, EventEmitter, Input, Output} from '@angular/core';

/**
 * Shows a chip filter
 */
@Component({
  selector: 'stapps-chip-filter',
  templateUrl: './chip-filter.component.html',
  styleUrls: ['./chip-filter.component.scss'],
})
export class ChipFilterComponent {
  /**
   * If the chip (filter) is active
   */
  @Input() active: boolean;

  /**
   * Text to display on the chip
   */
  @Input() displayValue?: string | null;

  /**
   * Emits when the chip has been activated/deactivated
   */
  @Output() toggled = new EventEmitter<unknown>();

  /**
   * Value to emit when chip has been activated/deactivated
   */
  @Input() value: unknown;

  /**
   * Signalize that the chip filter has been activated/deactivated
   */
  emitToggle(value: unknown) {
    this.toggled.emit(value);
  }
}
