All files / application-header si-header-navigation-item.component.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

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                                                                  1x   7x       7x    
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import {
  SI_HEADER_DROPDOWN_OPTIONS,
  SiHeaderDropdownTriggerDirective
} from '@siemens/element-ng/header-dropdown';
import { addIcons, elementDown2, SiIconComponent } from '@siemens/element-ng/icon';
 
/** Adds a navigation item to the header. Should be located inside `.header-navigation`. */
@Component({
  // eslint-disable-next-line @angular-eslint/component-selector
  selector: 'button[si-header-navigation-item], a[si-header-navigation-item]',
  imports: [SiIconComponent],
  template: `
    <div class="item-title">
      <ng-content />
    </div>
    @if (dropdownTrigger) {
      <si-icon class="dropdown-caret" [icon]="icons.elementDown2" />
    }
  `,
  providers: [
    { provide: SI_HEADER_DROPDOWN_OPTIONS, useValue: { disableRootFocusTrapForInlineMode: true } }
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    class: 'header-item focus-inside',
    '[class.dropdown-toggle]': '!!dropdownTrigger'
  }
})
export class SiHeaderNavigationItemComponent {
  /** @internal */
  dropdownTrigger = inject(SiHeaderDropdownTriggerDirective, {
    self: true,
    optional: true
  });
  protected readonly icons = addIcons({ elementDown2 });
}