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

100% Statements 99/99
100% Branches 19/19
100% Functions 5/5
100% Lines 99/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 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 211x 211x 211x 211x 211x 211x 1x 1x 1325x 1325x 1x 1x 1325x 268x 1057x 1057x 265x 172x 93x 792x 792x 1325x 1325x 1325x 1x 1x 1325x 1325x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  ElementRef,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import { 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',
  },
  standalone: false,
})
export class WizardStepperButtonComponent {
  @Input()
  public label = '';
 
  @Input()
  public number = 1;
 
  @Input()
  public variant: 'first' | 'middle' | 'last' = 'first';
 
  @Input()
  public disabled = false;
 
  @Input()
  public selected = false;
 
  @Input()
  public validated = false;
 
  @Input()
  public lastActiveStep = false;
 
  @Input()
  public controlledId = '';
 
  @Input()
  public invalid = false;
 
  @Output()
  public readonly onAction: EventEmitter<void> = new EventEmitter<void>();
 
  @ViewChild('button')
  public button!: ElementRef<HTMLButtonElement>;
 
  @Input()
  public contentDisplay: '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' : '';
  }
}