All files / loading-spinner si-loading-spinner.component.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 1/1
100% Lines 6/6

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              1x 1x                       1x             16x             16x                 16x    
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { ChangeDetectionStrategy, Component, inject, InjectionToken, input } from '@angular/core';
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';
 
export const LOADING_SPINNER_BLOCKING = new InjectionToken<boolean>('isBlockingSpinner');
export const LOADING_SPINNER_OVERLAY = new InjectionToken<boolean>('isSpinnerOverlay');
 
@Component({
  selector: 'si-loading-spinner',
  imports: [SiTranslatePipe],
  templateUrl: './si-loading-spinner.component.html',
  styleUrl: './si-loading-spinner.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    'animate.leave': 'spinner-leave'
  }
})
export class SiLoadingSpinnerComponent {
  /**
   * @defaultValue
   * ```
   * inject(LOADING_SPINNER_BLOCKING, { optional: true })
   * ```
   */
  readonly isBlockingSpinner = input(inject(LOADING_SPINNER_BLOCKING, { optional: true }));
  /**
   * @defaultValue
   * ```
   * inject(LOADING_SPINNER_OVERLAY, { optional: true })
   * ```
   */
  readonly isSpinnerOverlay = input(inject(LOADING_SPINNER_OVERLAY, { optional: true }));
  /**
   * Needed for a11y
   *
   * @defaultValue
   * ```
   * t(() => $localize`:@@SI_LOADING_SPINNER.LABEL:Loading`)
   * ```
   */
  readonly ariaLabel = input(t(() => $localize`:@@SI_LOADING_SPINNER.LABEL:Loading`));
}