All files / lib/wizard-header wizard-header.component.ts

95.95% Statements 95/99
71.42% Branches 5/7
80% Functions 4/5
95.95% Lines 95/99

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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1001x 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 28x 28x   28x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 6x 6x 6x 6x 6x 6x 6x 7x 7x 7x   7x 6x 6x 1x 1x 1x 1x 1x     1x 1x 1x 13x 13x 13x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  ChangeDetectionStrategy,
  Component,
  ElementRef,
  NgZone,
  OnDestroy,
  inject,
  input,
  output,
} from '@angular/core';
 
import { observeSize } from '../utils/internal-utils';
import { Callback } from '../utils/util.types';
 
/**
 * Header component to show title and core controls above *Wizard* content.
 */
@Component({
  selector: 'gc-wizard-header',
  templateUrl: './wizard-header.component.html',
  styleUrls: ['./wizard-header.component.css'],
  changeDetection: ChangeDetectionStrategy.Eager,
  standalone: false,
})
export class WizardHeaderComponent implements OnDestroy {
  /** @ignore */
  public get _ariaSectionName(): string {
    return this.sectionActionLabel()
      ? `Kopfbereich ${this.sectionActionLabel()}`
      : 'Kopfbereich';
  }
 
  /**
   * Text that will be rendered as the wizard label in the header.
   */
  public readonly label = input.required<string>();
 
  /**
   * Text that is displayed above the label.
   */
  public readonly subLabel = input('');
 
  /**
   * Text that describes the wizard action.
   */
  public readonly sectionActionLabel = input('');
 
  /**
   * Fires upon triggering the abort button action.
   */
  public readonly onAbortButtonAction = output();
 
  /**
   * @ignore
   */
  protected iconOnlyButton = false;
 
  /** @ignore */
  protected twoLineCloseButton = false;
 
  /**
   * @ignore
   */
  private resizeDestroy: Callback;
 
  constructor() {
    const hostElement = inject<ElementRef<HTMLElement>>(ElementRef);
    const zone = inject(NgZone);
 
    const hostElementWidth =
      hostElement.nativeElement.getBoundingClientRect().width;
    this.computeResponsiveness(hostElementWidth);
    this.resizeDestroy = observeSize(hostElement, zone, size => {
      const width =
        size.borderBoxSize.length > 0
          ? size.borderBoxSize[0].inlineSize
          : size.contentRect.width;
      this.computeResponsiveness(width);
    });
  }
 
  /**
   * @ignore
   */
  ngOnDestroy(): void {
    this.resizeDestroy();
  }
 
  /** @ignore */
  private computeResponsiveness(width: number): void {
    this.iconOnlyButton = width < 424; // 24 + 320 + 16 + 40 + 24
    this.twoLineCloseButton = width < 765; // 32 + 560 + 16 + 141 + 16
  }
}