All files / lib/split-layout-container split-layout-container.component.ts

92.64% Statements 126/136
82.35% Branches 14/17
87.5% Functions 7/8
92.64% Lines 126/136

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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 1371x 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 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 1x 1x 1x 7x 7x 7x 7x 27x 27x 27x   27x 7x 7x 1x 1x 1x           1x 1x 1x 34x 27x 27x 7x     7x 7x 7x 34x 34x 34x 27x 27x 7x     7x 7x 7x 34x 34x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  Directive,
  ElementRef,
  EventEmitter,
  Input,
  NgZone,
  OnDestroy,
  Output,
} from '@angular/core';
 
import { observeSize } from '../utils/internal-utils';
import { Callback } from '../utils/util.types';
 
import {
  DYNAMIC_HEADING_START_LEVEL,
  DynamicHeadingLevelService,
} from '../dynamic-heading/dynamic-heading-level.service';
import { CellValue } from '../grid/cell/grid-cell.component';
 
/**
 * Split layout container that contains a main area and a toggleable side area.
 */
@Component({
  selector: 'gc-split-layout-container',
  templateUrl: './split-layout-container.component.html',
  styleUrls: ['./split-layout-container.component.css'],
})
export class SplitLayoutContainerComponent implements OnDestroy {
  /**
   * The title displayed above the side area
   */
  @Input()
  public sideLabel = '';
 
  /**
   * Optional alternative label to present to accessibility technologies (e.g. Screenreaders) instead of the
   * regular side area label.
   */
  @Input()
  public accessibleSideLabel = '';
 
  /**
   * Decides if the side area is visible.
   */
  @Input()
  public showSideContent = false;
 
  /**
   * Informs about the change of the side content's state
   */
  @Output()
  public readonly showSideContentChange: EventEmitter<boolean> =
    new EventEmitter<boolean>();
 
  /** @ignore */
  protected _sideCellSize?: CellValue;
 
  /** @ignore */
  protected _sideCellClosedSize?: CellValue = '2';
 
  /** @ignore */
  protected _mainCellSize?: CellValue;
 
  /** @ignore */
  protected _mainCellClosedSize: CellValue = '10';
 
  /** @ignore */
  private resizeDestroy?: Callback;
 
  constructor(hostElement: ElementRef<HTMLElement>, zone: NgZone) {
    this.calculateCellSizes(
      hostElement.nativeElement.getBoundingClientRect().width,
    );
    this.resizeDestroy = observeSize(hostElement, zone, size => {
      const width =
        size.borderBoxSize.length > 0
          ? size.borderBoxSize[0].inlineSize
          : size.contentRect.width;
      this.calculateCellSizes(width);
    });
  }
 
  /** @ignore */
  ngOnDestroy(): void {
    if (this.resizeDestroy) {
      this.resizeDestroy();
      this.resizeDestroy = undefined;
    }
  }
 
  /** @ignore */
  private calculateCellSizes(width: number) {
    if (width >= 1800) {
      this._sideCellSize = '4';
      this._mainCellSize = '8';
    } else if (width >= 920) {
      this._sideCellSize = '5';
      this._mainCellSize = '7';
    } else {
      this._sideCellSize = undefined;
      this._mainCellSize = '12';
    }
 
    if (width >= 1200) {
      this._sideCellClosedSize = '1';
      this._mainCellClosedSize = '11';
    } else if (width >= 920) {
      this._sideCellClosedSize = '2';
      this._mainCellClosedSize = '10';
    } else {
      this._sideCellClosedSize = undefined;
      this._mainCellClosedSize = '12';
    }
  }
}
 
@Directive({
  selector: '[data-gc-side-content]',
  providers: [
    {
      provide: DYNAMIC_HEADING_START_LEVEL,
      useValue: { kind: 'relative', offset: 2 },
    },
    {
      provide: DynamicHeadingLevelService,
      useClass: DynamicHeadingLevelService,
    },
  ],
})
export class SplitLayoutContainerSideContentDirective {}