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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 9x 9x 3x 3x 3x 3x 3x 4x 4x 4x 3x 3x 4x 4x 4x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 1x 1x 4x 4x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 2x 3x 3x 5x 5x 1x 1x 1x 4x 4x 6x 6x 4x 4x 1x | /******************************************************************************* * Copyright bei * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa * *******************************************************************************/ import { Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, Output, QueryList, TemplateRef, ViewChild, ViewChildren, } from '@angular/core'; import { observeElementSize, subscribeWindow } from '../utils/internal-utils'; import { BadgeItem, Callback, FocusableElementOwner, Item, Key, LinkItem, } from '../utils/util.types'; import { itemTrack } from '../utils/utilities'; import { ComponentMapperDirective } from '../internal/component-mapper.directive'; import { BadgeItemTemplateContext } from '../badge-list/badge-list.component'; import { ButtonComponent } from '../button/button.component'; /** * Context Header is a responsive, context-specific, horizontal user interface element that contains badges and links that lead to other websites or parts of the page. */ @Component({ selector: 'gc-context-header', templateUrl: './context-header.component.html', styleUrls: ['./context-header.component.css'], standalone: false, }) export class ContextHeaderComponent implements OnDestroy, FocusableElementOwner { /** * Label to show in the header. */ @Input() public label = ''; /** * Items that will be rendered as badges in the header. */ @Input() public badges: readonly BadgeItem[] = []; /** * Icon template that will be used for the badges. */ @Input() public iconProvider?: TemplateRef<BadgeItemTemplateContext>; /** Emitted when an action item is pressed. */ @Output() public readonly onAction: EventEmitter<Item> = new EventEmitter<Item>(); /** * @ignore */ @ViewChild('actionsContainer') private actionsContainerElement!: ElementRef<HTMLDivElement>; /** @ignore */ @ViewChild('menuButton', { read: ButtonComponent }) private menuButton?: ButtonComponent; /** @ignore */ @ViewChildren('actionButton', { read: ComponentMapperDirective }) private actionButtons?: QueryList<ComponentMapperDirective<ButtonComponent>>; /** * Items that will be rendered as links in the header. * @deprecated use 'actions' input instead */ @Input() public set links(value: readonly LinkItem[]) { this._links = value; this.rebuildPopupItems(); console.warn( 'The "links" input is deprecated and should not be used. Please use "actions" input instead.', ); } public get links(): readonly LinkItem[] { return this._links; } /** * Items that will be rendered as buttons in the header. */ @Input() public get actions(): Item[] { return this._actions; } public set actions(value: Item[]) { this._actions = value; this.rebuildPopupItems(); } /** * @ignore */ public _mode: 'small' | 'medium' | 'default' = 'default'; /** @ignore */ protected _popItems: readonly Item[] = []; /** @ignore */ protected actionsAndLinks: readonly Item[] = []; /** @ignore */ protected inSmallText = false; /** * @ignore */ private observerCallbacks: Callback[] = []; /** @ignore */ private _actions: Item[] = []; /** * @ignore */ private _links: readonly LinkItem[] = []; constructor(zone: NgZone, el: ElementRef<HTMLElement>) { this.observerCallbacks.push( observeElementSize(el.nativeElement, zone, this.handleResize.bind(this)), ); this.observerCallbacks.push( subscribeWindow('resize', this.computeWindowRelatedProps.bind(this)), ); this.computeWindowRelatedProps(); } /** * @ignore */ ngOnDestroy(): void { this.observerCallbacks.forEach(cb => cb()); } /** * Focus action in the header with the given key. * @param key the key of the `action` to focus * @returns `true` if focus has been transferred */ public focusAction(key: Key): boolean { if (this._mode === 'default') { const button = this.actionButtons?.find(i => i.key === key)?.component; if (button) { return button.focusChild(); } } else { return this.menuButton ? this.menuButton.focusChild() : false; } return false; } public focusChild(): boolean { if (this._mode !== 'default') { return this.menuButton ? this.menuButton.focusChild() : false; } else { for (const action of this._actions) { if (this.focusAction(action.key)) { return true; } } } return false; } /** @ignore */ protected handleMenuAction(item: Item) { const action = this.actionsAndLinks.find(a => a.key === item.key); if (action) { this.onAction.emit(action); } else { console.error(`Unable to find action ${item.key}`); } } /** * @ignore */ protected _itemTrackBy(item: Item): string { return itemTrack(item); } /** @ignore */ private computeWindowRelatedProps() { this.inSmallText = window.innerWidth <= 480 || window.innerHeight <= 1024; } /** @ignore */ private handleResize(entry: ResizeObserverEntry): void { // padding 64px // gap = 24px const elementWidth = entry.contentRect.width - 64 - 24; const mediumButtonExists = this.links.length > 0; // medium button is 148px if (elementWidth - (mediumButtonExists ? 148 : 0) < 400) { this._mode = 'small'; return; } const actionsContainerWidth = this.actionsContainerElement.nativeElement.getBoundingClientRect().width; const spaceInHeader = elementWidth - actionsContainerWidth; if (spaceInHeader < 720) { this._mode = 'medium'; } else { this._mode = 'default'; } } /** @ignore */ private rebuildPopupItems() { this.actionsAndLinks = this.actions.concat(this.links); this._popItems = this.actionsAndLinks.map(a => ({ key: a.key, label: `${a.label} öffnen`, })); } } |