All files / lib/internal/collapsible-container collapsible-container.component.ts

100% Statements 97/97
100% Branches 8/8
100% Functions 3/3
100% Lines 97/97

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 981x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 1x 1x 1x 1x 1x 1x 8x 8x 8x 1x 1x 1x 1x 1x 165x 146x 81x 19x 19x 19x 19x 19x 14x 14x 14x 165x 165x 165x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import { Component, EventEmitter, Input, Output } from '@angular/core';
 
import { WidgetKeySet } from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import {
  DynamicHeadingLevelPassthroughService,
  DynamicHeadingLevelService,
} from '../../dynamic-heading/dynamic-heading-level.service';
 
/**
 * A collapsible container component that shows or hides content.
 */
@Component({
  selector: 'gc-collapsible-container',
  templateUrl: './collapsible-container.component.html',
  styleUrls: ['./collapsible-container.component.css'],
  providers: [DynamicHeadingLevelService],
  viewProviders: [
    {
      provide: DynamicHeadingLevelService,
      useClass: DynamicHeadingLevelPassthroughService,
    },
  ],
})
export class CollapsibleContainerComponent {
  /**
   * Label of the collapsible container.
   */
  @Input()
  public label = '';
 
  /**
   * Optional alternative label to present to accessibility technologies (e.g. Screenreaders) instead of the
   * regular label.
   */
  @Input()
  public accessibleLabel = '';
 
  /**
   * Decides if the content is open or closed. (showing/hiding content)
   */
  @Input()
  public isOpen = true;
 
  /**
   * Decides if the content is hidden or visible when the container is collapsed.
   */
  @Input()
  public contentHiddenWhenCollapsed = true;
 
  /**
   * Informs about status of the collapsible container state.
   */
  @Output()
  private readonly isOpenChange: EventEmitter<boolean> =
    new EventEmitter<boolean>();
 
  /**
   * @ignore
   */
  readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-collapsible-container',
  );
 
  /**
   * @ignore
   */
  _onPress(): void {
    this.isOpen = !this.isOpen;
    this.isOpenChange.emit(this.isOpen);
  }
 
  /**
   * @ignore
   */
  _getButtonLabel(): string {
    if (this.isOpen) {
      if (!this.contentHiddenWhenCollapsed) {
        return 'Schnellnavigation verkleinern';
      } else {
        return 'Schnellnavigation ausblenden';
      }
    } else {
      if (!this.contentHiddenWhenCollapsed) {
        return 'Schnellnavigation vergrößern';
      } else {
        return 'Schnellnavigation einblenden';
      }
    }
  }
}