All files / filtered-search/values/free-text si-filtered-search-free-text.component.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 4/4
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                      1x 7x 7x     15x 15x       2x 2x      
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { ChangeDetectionStrategy, Component, computed, ElementRef, viewChild } from '@angular/core';
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';
 
import { SiFilteredSearchValueBase } from '../si-filtered-search-value.base';
 
@Component({
  selector: 'si-filtered-search-free-text',
  imports: [SiTranslatePipe],
  templateUrl: './si-filtered-search-free-text.component.html',
  styleUrl: './si-filtered-search-free-text.component.scss',
  providers: [
    { provide: SiFilteredSearchValueBase, useExisting: SiFilteredSearchFreeTextComponent }
  ],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SiFilteredSearchFreeTextComponent extends SiFilteredSearchValueBase {
  protected readonly valueInput = viewChild<ElementRef<HTMLInputElement>>('freeTextInput');
  protected readonly validValue = computed(() => true);
 
  protected freeTextValueChange(event: Event): void {
    const inputElement = event.target as HTMLInputElement;
    this.criterionValue.update(v => ({ ...v, value: inputElement.value }));
  }
 
  protected override valueEnter(): void {
    this.active.set(false);
    this.submitValue.emit();
  }
}