All files / custom-legend si-custom-legend.component.ts

80% Statements 16/20
72.72% Branches 16/22
33.33% Functions 1/3
75% Lines 12/16

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                          4x   2x   2x   2x   2x   2x   2x   2x   2x   2x   2x   2x                        
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, ElementRef, input, output, viewChild } from '@angular/core';
 
import { CustomLegend, CustomLegendItem } from './si-custom-legend.interface';
 
@Component({
  selector: 'si-custom-legend',
  templateUrl: './si-custom-legend.component.html',
  styleUrl: './si-custom-legend.component.scss'
})
export class SiCustomLegendComponent {
  /** @internal */
  readonly customLegendContainer = viewChild.required<ElementRef>('customLegendContainer');
 
  readonly customLegend = input<CustomLegend>();
  /** The legend title. */
  readonly title = input<string>();
  /** The legend subtitle. */
  readonly subTitle = input<string>();
  /** The color of the legend title. */
  readonly titleColor = input<string>();
  /** The color of the legend subtitle. */
  readonly subTitleColor = input<string>();
  /** The color of the legend text. */
  readonly textColor = input<string>();
  /** The event emitted when a legend icon is clicked. */
  readonly legendIconClickEvent = output<CustomLegendItem>();
  /** The event emitted when a legend is clicked. */
  readonly legendClickEvent = output<CustomLegendItem>();
  /** The event emitted when the mouse enters a legend. */
  readonly legendHoverStartEvent = output<CustomLegendItem>();
  /** The event emitted when the mouse leaves a legend. */
  readonly legendHoverEndEvent = output<CustomLegendItem>();
 
  protected legendIconClick(legend: CustomLegendItem): void {
    legend.selected = !legend.selected;
    this.legendIconClickEvent.emit(legend);
  }
 
  protected legendClick(legend: CustomLegendItem): void {
    legend.selected = !legend.selected;
    this.legendClickEvent.emit(legend);
  }
}