All files / connection-strength si-connection-strength.component.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

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                            1x               1x           5x           5x   5x    
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import {
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  computed,
  input
} from '@angular/core';
 
export type ConnectionStrength = 'none' | 'low' | 'medium' | 'strong';
 
const CONNECTION_STRENGTH_MAP = { 'none': 0, 'low': 1, 'medium': 2, 'strong': 3 };
 
@Component({
  selector: 'si-connection-strength',
  templateUrl: './si-connection-strength.component.html',
  styleUrl: './si-connection-strength.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SiConnectionStrengthComponent {
  /**
   * Shows the signal representation in an alternative *WLAN* format
   *
   * @defaultValue false
   */
  readonly wlan = input(false, { transform: booleanAttribute });
  /**
   * Main value representing the current connection strength.
   *
   * @defaultValue 'none'
   */
  readonly value = input<ConnectionStrength>('none');
 
  protected readonly numberValue = computed(() => CONNECTION_STRENGTH_MAP[this.value()] ?? 0);
}