import {
  ChangeDetectionStrategy,
  Component,
  input,
  output,
} from '@angular/core';
import { FilterInput } from '../../core';
import { FilterActionsComponent } from '../../actions';
import { InputRendererComponent } from '../../inputs/input-renderer';

/**
 * A component that renders a menu for filter input.
 * It provides actions to reset or apply the filter.
 */
@Component({
  selector: 'filter-input-menu',
  templateUrl: './input-menu.component.html',
  styleUrls: ['./input-menu.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [FilterActionsComponent, InputRendererComponent],
})
export class FilterInputMenuComponent {
  /**
   * The filter input configuration used to render the input menu.
   */
  filterInput = input.required<FilterInput>();

  /**
   * Emits an event when the filter input is reset.
   */
  reseted = output<void>();

  /**
   * Emits an event when the filter input is applied.
   */
  applied = output<void>();

  /**
   * Indicates whether the filter can be applied.
   * Defaults to false.
   * @default false
   */
  canApply = input<boolean>(false);
}
