All files / lib/focusable-hint focusable-hint.component.ts

94% Statements 47/50
100% Branches 2/2
50% Functions 1/2
94% Lines 47/50

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 511x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 11x 11x 11x 11x 11x 1x 1x 1x       1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  ChangeDetectionStrategy,
  Component,
  ElementRef,
  inject,
  input,
} from '@angular/core';
 
import { FocusableElementOwner } from '../utils/util.types';
 
/**
 * A focusable text component with optional icon and no additional interactivity.
 */
@Component({
  selector: 'gc-focusable-hint',
  templateUrl: './focusable-hint.component.html',
  styleUrls: ['./focusable-hint.component.css'],
  host: {
    '[class.gc-has-icon]': 'showIcon()',
    tabindex: '0',
  },
  changeDetection: ChangeDetectionStrategy.Default,
  standalone: false,
})
export class FocusableHintComponent implements FocusableElementOwner {
  /**
   * Text to make focusable.
   */
  text = input.required<string>();
 
  /**
   * Decides whether the passed icon will be shown.
   */
  showIcon = input(false);
 
  /** @ignore */
  private readonly elRef = inject<ElementRef<HTMLElement>>(
    ElementRef<HTMLElement>,
  );
 
  focusChild(): boolean {
    this.elRef.nativeElement.focus();
    return true;
  }
}