All files / lib/responsive-container responsive-item-template.directive.ts

90% Statements 45/50
100% Branches 5/5
80% Functions 4/5
90% Lines 45/50

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 511x 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 1x 1x 1x           1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import { Directive, Input, TemplateRef } from '@angular/core';
 
import type { ResponsiveBreakpointKey } from './responsive-container.component';
import { ResponsiveContainerComponent } from './responsive-container.component';
 
/**
 * Template context which is used when rendering responsive items via `ResponsiveItemTemplateDirective`.
 */
export interface ResponsiveItemTemplateDirectiveContext<
  K extends ResponsiveBreakpointKey,
> {
  /** The breakpoint for which this template is rendered. */
  $implicit: K;
  /**
   * If `true`, this item is rendered for measurement purposes (acting as a placeholder to determine the actual size),
   * and may not be visible to the user. The actual chosen item in the responsive container is rendered with a value of `false`.
   */
  measureOnly: boolean;
}
 
/**
 * Marks a template to be rendered as responsive items within a `ResponsiveContainerComponent`.
 */
@Directive({
  selector: 'ng-template[data-gc-responsive-item]',
})
export class ResponsiveItemTemplateDirective<
  K extends ResponsiveBreakpointKey,
> {
  /** Type token to achieve type safety of the template context when rendering the item. Should be set to a reference to the `ResponsiveContainerComponent` in which the template is used. */
  @Input('data-gc-responsive-item')
  public typeToken!: ResponsiveContainerComponent<K>;
 
  public constructor(
    public templateRef: TemplateRef<ResponsiveItemTemplateDirectiveContext<K>>,
  ) {}
 
  /** @ignore */
  static ngTemplateContextGuard<K extends ResponsiveBreakpointKey>(
    dir: ResponsiveItemTemplateDirective<K>,
    ctx: unknown,
  ): ctx is ResponsiveItemTemplateDirectiveContext<K> {
    return true;
  }
}