All files / lib/grid/cell grid-cell.component.ts

100% Statements 164/164
100% Branches 30/30
100% Functions 2/2
100% Lines 164/164

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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 1651x 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 556x 490x 66x 1x 1x 1x 1x 1x 1x 510x 331x 179x 1x 1x 1x 1x 1x 1x 510x 310x 200x 1x 1x 1x 1x 1x 1x 510x 310x 200x 1x 1x 1x 1x 1x 1x 510x 20x 490x 1x 1x 1x 1x 1x 1x 510x 10x 500x 1x 1x 1x 1x 1x 1x 510x 1x 509x 1x 1x 1x 1x 510x 1x 1x 1x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  input,
} from '@angular/core';
 
import { GridComponent } from '../grid.component';
 
export type CellValue =
  | '1'
  | '2'
  | '3'
  | '4'
  | '5'
  | '6'
  | '7'
  | '8'
  | '9'
  | '10'
  | '11'
  | '12';
 
const CSSGuaranteedInvalidValue = 'initial'; // https://www.w3.org/TR/css-variables-1/#guaranteed-invalid
 
/**
 * A Cell component representing a single cell in a row.
 */
@Component({
  selector: 'gc-grid-cell',
  templateUrl: './grid-cell.component.html',
  styleUrls: ['./grid-cell.component.css'],
  host: {
    '[style.--gc-grid-columns-xs]': 'computeXsCssVal()',
    '[style.--gc-grid-columns-sm]': 'computeSmCssVal()',
    '[style.--gc-grid-columns-md]': 'computeMdCssVal()',
    '[style.--gc-grid-columns-lg]': 'computeLgCssVal()',
    '[style.--gc-grid-columns-xl]': 'computeXlCssVal()',
    '[style.--gc-grid-columns-xxl]': 'computeXxlCssVal()',
    '[style.--gc-grid-columns-xxxl]': 'computeXxxlCssVal()',
    '[class]': 'referenceClass()',
  },
  changeDetection: ChangeDetectionStrategy.Default,
  standalone: false,
})
export class GridCellComponent {
  /**
   * Define how many columns are spanned when size is XS
   * @default undefined
   */
  public xs = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is SM
   * @default undefined
   */
  public sm = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is MD
   * @default undefined
   */
  public md = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is LG
   * @default undefined
   */
  public lg = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is XL
   * @default undefined
   */
  public xl = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is XXL
   * @default undefined
   */
  public xxl = input<CellValue | undefined>(undefined);
 
  /**
   * Define how many columns are spanned when size is XXXL
   * @default undefined
   */
  public xxxl = input<CellValue | undefined>(undefined);
 
  /** @ignore */
  // CSS variables which are not used must be reset explicitly to avoid inheriting from parents in nested grids
  protected computeXsCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.xs() !== undefined
      ? Number(this.xs())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeSmCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.sm() !== undefined
      ? Number(this.sm())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeMdCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.md() !== undefined
      ? Number(this.md())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeLgCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.lg() !== undefined
      ? Number(this.lg())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeXlCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.xl() !== undefined
      ? Number(this.xl())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeXxlCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.xxl() !== undefined
      ? Number(this.xxl())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected computeXxxlCssVal = computed<
    number | typeof CSSGuaranteedInvalidValue
  >(() => {
    return this.xxxl() !== undefined
      ? Number(this.xxxl())
      : CSSGuaranteedInvalidValue;
  });
 
  /** @ignore */
  protected referenceClass = computed(() => {
    return `gc-grid-reference-${this.grid.reference()}`;
  });
 
  constructor(private readonly grid: GridComponent) {}
}