All files / lib/internal/wizard-stepper/wizard-stepper-button wizard-stepper-button.component.ts

100% Statements 93/93
100% Branches 19/19
100% Functions 5/5
100% Lines 93/93

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 941x 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 1x 1x 1x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 211x 1x 1x 1495x 1495x 1x 1x 1495x 302x 1193x 1193x 299x 206x 93x 894x 894x 1495x 1495x 1495x 1x 1x 1495x 1495x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  ChangeDetectionStrategy,
  Component,
  ElementRef,
  input,
  output,
  viewChild,
} from '@angular/core';
 
import { Item, WidgetKeySet } from '../../../utils/util.types';
import { createWidgetKeySet } from '../../../utils/utilities';
 
/**
 *
 */
@Component({
  selector: 'gc-wizard-stepper-button',
  templateUrl: './wizard-stepper-button.component.html',
  styleUrls: [
    './../../../utils/styles/reset-button.css',
    './wizard-stepper-button.component.css',
  ],
  host: {
    // button with `role="tab"` must be a direct child of the tablist in Firefox, otherwise posinset/setsize are not detected properly,
    // the host element interferes with this -> ensure the host is not part of the a11y tree
    role: 'presentation',
  },
  changeDetection: ChangeDetectionStrategy.Eager,
  standalone: false,
})
export class WizardStepperButtonComponent {
  public readonly label = input.required<string>();
 
  public readonly item = input.required<Item>();
 
  public readonly number = input(1);
 
  public readonly variant = input<'first' | 'middle' | 'last'>('first');
 
  public readonly disabled = input(false);
 
  public readonly selected = input(false);
 
  public readonly validated = input(false);
 
  public readonly lastActiveStep = input(false);
 
  public readonly controlledId = input('');
 
  public readonly invalid = input(false);
 
  public readonly onAction = output();
 
  public readonly button =
    viewChild.required<ElementRef<HTMLButtonElement>>('button');
 
  public readonly contentDisplay = input<'icon-only' | 'text-right'>(
    'text-right',
  );
 
  public readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-wizard-stepper-button',
  );
 
  public _hasFocus = false;
 
  public _getAriaLabel(): string {
    return `${this.number().toFixed(0)} ${this.label()} ${this.getAriaStatusMessage()}${this.getAriaErrorStatus()}`;
  }
 
  private getAriaStatusMessage(): string {
    if (this.disabled()) {
      return 'Gesperrt';
    } else {
      if (this.selected()) {
        return this.validated()
          ? 'Ausgewählt, abgeschlossen'
          : 'Ausgewählt, nicht abgeschlossen';
      } else {
        return this.validated() ? 'Abgeschlossen' : 'Nicht abgeschlossen';
      }
    }
  }
 
  private getAriaErrorStatus(): string {
    return this.invalid() ? ' - Fehlerhafte Eingaben' : '';
  }
}