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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 165x 165x 165x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 1x 1x 10x 155x 155x 10x 10x 1x 1x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 25x 25x 1x 1x 1x 38x 38x 38x 26x 38x 38x 1x 1x 1x 41x 41x 1x 1x 1x 25x 25x 1x 1x 1x 5x 72x 55x 17x 17x 72x 5x 5x 1x | /* eslint-disable @typescript-eslint/member-ordering */
/*******************************************************************************
* Copyright bei
* Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
*
*******************************************************************************/
import {
ChangeDetectionStrategy,
Component,
OnDestroy,
TemplateRef,
input,
output,
viewChild,
} from '@angular/core';
import { getKeyboardFocusableElements } from '../../utils/internal-utils';
import {
BadgeItem,
FocusableElementOwner,
WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
import { AutoFocusAreaDirective } from '../../internal/auto-focus-area.directive';
import { BadgeItemTemplateContext } from '../../badge-list/badge-list.component';
function isCritical(item: BadgeItem) {
return item.color === 'critical';
}
/**
* Infobox Container component that is a part of the gc-infobox component. Acts as a dropdown container.
*/
@Component({
selector: 'gc-infobox-container',
templateUrl: './infobox-container.component.html',
styleUrls: ['./infobox-container.component.css'],
host: {
'(keydown.escape)': 'onEscapeKey()',
},
changeDetection: ChangeDetectionStrategy.Default,
standalone: false,
})
export class InfoboxContainerComponent
implements FocusableElementOwner, OnDestroy
{
/**
* Label of the infobox container.
*/
public label = input.required<string>();
/**
* Items that will be rendered as badges in the header.
*/
public badges = input<readonly BadgeItem[]>([]);
/**
* A template that will be used to render icons within badges.
*/
public badgeIconProvider = input<TemplateRef<BadgeItemTemplateContext>>();
/**
* Hint message that appears within the header.
*/
public hintTitle = input('');
/**
* Event emitted on close button press.
*/
public readonly onClose = output();
/** @ignore */
private contentAutoFocusArea = viewChild.required(AutoFocusAreaDirective);
/** @ignore */
protected readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
'gc-infobox-container',
);
/** @ignore */
private _disabledElements: Map<Element, string | null> = new Map<
Element,
string | null
>();
constructor() {
getKeyboardFocusableElements(document.body).forEach(el => {
this._disabledElements.set(el, el.getAttribute('tabindex'));
el.setAttribute('tabindex', '-1');
});
}
/** @ignore */
protected onEscapeKey(): void {
this.onClose.emit();
}
ngOnDestroy(): void {
this.resetTabIndex();
}
/** @ignore */
public focusChild(): boolean {
return this.contentAutoFocusArea().focusInitialElement();
}
/** @ignore */
protected _hasCriticalBadge() {
return this._criticalBadgeItems().length > 0;
}
/** @ignore */
protected _criticalBadgeItems(): BadgeItem[] {
return this.badges()
.filter(isCritical)
.map(b => {
return { ...b, showIcon: true } satisfies BadgeItem;
});
}
/** @ignore */
protected _defaultBadgeItems() {
return this.badges().filter(b => !isCritical(b));
}
/** @ignore */
protected _hasDefaultBadgeItems() {
return this._defaultBadgeItems().length > 0;
}
/** @ignore */
private resetTabIndex() {
this._disabledElements.forEach((v, k) => {
if (v === null) {
k.removeAttribute('tabindex');
} else {
k.setAttribute('tabindex', v);
}
});
}
}
|