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

92.53% Statements 124/134
80% Branches 12/15
83.33% Functions 5/6
92.53% Lines 124/134

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 1351x 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 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 1x 1x 8x 8x 8x 8x 22x 22x 22x   22x 8x 8x 1x 1x 1x           1x 1x 1x 30x 22x 22x 8x     8x 8x 8x 30x 30x 30x 22x 22x 8x     8x 8x 8x 30x 30x 1x 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 {
  ChangeDetectionStrategy,
  Component,
  Directive,
  ElementRef,
  NgZone,
  OnDestroy,
  input,
  model,
} 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'],
  changeDetection: ChangeDetectionStrategy.Default,
  standalone: false,
})
export class SplitLayoutContainerComponent implements OnDestroy {
  /**
   * The title displayed above the side area
   */
  public sideLabel = input.required<string>();
 
  /**
   * Optional alternative label to present to accessibility technologies (e.g. Screenreaders) instead of the
   * regular side area label.
   */
  public accessibleSideLabel = input('');
 
  /**
   * Decides if the side area is visible.
   */
  public showSideContent = model(false);
 
  /**
   * Indicates that the side area is in a loading state.
   */
  public isLoading = input(false);
 
  /** @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,
    },
  ],
  standalone: false,
})
export class SplitLayoutContainerSideContentDirective {}