All files / src/components/widget-renderer si-widget-renderer.component.ts

100% Statements 7/7
85.71% Branches 12/14
100% Functions 1/1
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 43 44 45 46                                                                      4x   2x           2x    
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
 
import { Widget, WidgetConfig } from '../../model/widgets.model';
import { SiWidgetHostComponent } from '../widget-host/si-widget-host.component';
 
/**
 * A presentational (dumb) component that renders a single widget instance from a
 * {@link WidgetConfig} using the provided {@link Widget} definition. It delegates
 * the actual rendering to the {@link SiWidgetHostComponent}.
 *
 * **Intended Usage**
 *
 * This component renders an individual widget outside of a dashboard or grid,
 * without requiring manual host wiring. It is a self-contained widget cell that
 * can be placed anywhere a single widget needs to be shown, for example in kiosk
 * mode or within a custom layout such as a carousel.
 *
 * **Example**
 *
 * ```html
 * <!-- Render a single widget instance -->
 * <si-widget-renderer [widgetConfig]="widgetConfig" [widget]="widget" />
 * ```
 */
@Component({
  selector: 'si-widget-renderer',
  imports: [SiWidgetHostComponent],
  templateUrl: './si-widget-renderer.component.html',
  styleUrl: './si-widget-renderer.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SiWidgetRendererComponent {
  /** The configuration of the widget instance to render. */
  readonly widgetConfig = input.required<WidgetConfig>();
 
  /**
   * The {@link Widget} definition used to render the given {@link widgetConfig}.
   * It must match the config's `widgetId`.
   */
  readonly widget = input.required<Widget>();
}