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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 39x 39x 39x 39x 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 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 1x 1x 1x 1x 1x 1x 1x 39x 39x 1x 1x 1x 1x 49x 49x 49x 49x 49x 49x 9x 9x 9x 9x 49x 40x 49x 49x 49x 49x 49x 1x 1x 1x 40x 40x 40x 40x 40x 40x 40x 1x 1x 1x 384x 384x 384x 1x 1x 1x 787x 780x 780x 780x 780x 1884x 780x 780x 780x 787x 787x 1x 1x 1x 15x 15x 15x 15x 15x 15x 15x 15x 15x 1x 1x 1x 14x 14x 12x 12x 12x 14x 5x 5x 3x 3x 3x 2x 2x 9x 9x 9x 15x 15x 15x 1x 1x 1x 78x 78x 1x 1x 1x 21x 21x 21x 21x 21x 21x 21x 1x 1x 1x 1008x 1008x 1x 1x 1x 1x 1x 1x 9619x 9619x 1x 1x 1x 1x 1x 1x 203x 203x 203x 203x 203x 203x 195x 8x 203x 203x 203x 1x 1x 1x 3266x 3198x 68x 68x 68x 68x 68x 3266x 3266x 3266x 1x 1x 1x 1744x 1744x 1744x 1744x 1744x 1x 1x 1x 1x 1x 1x 1x 1x 1x 693x 693x 693x 693x 693x 693x 693x 1x 1x 1x 76x 1x 1x 1x 1x 31x 31x 1x 1x 1x 9x 9x 1x 1x 1x 9x 7x 7x 7x 7x 7x 8x 3x 3x 3x 2x 2x 2x 1x 1x 5x 5x 5x 9x 9x 9x 1x 1x 1x 31x 31x 31x 31x 31x 31x 31x 31x 1x | /******************************************************************************* * Copyright bei * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa * *******************************************************************************/ import { Component, Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, Output, TemplateRef, } from '@angular/core'; import { FocusableElementOwner, Item, Key, TreeItemBasic, WidgetKeySet, } from '../../utils/util.types'; import { createWidgetKeySet, isTreeItemBasic, itemTrack, } from '../../utils/utilities'; import { BaseTreeComponent, TreeItemBasicAdvancedKeys, } from '../../tree/base-tree.component'; interface RecursiveTreePickerItemTemplateContext<T> { $implicit: RecursiveTreeItem<T>[]; level: number; } @Directive({ selector: '[data-gc-tree-picker-item]', standalone: false, }) export class TreePickerItemDirective { @Input('aria-level') @HostBinding('attr.aria-level') public ariaLevel = 1; } /** * A directive allowing to tag template directives who get passed * an $implicit value who is that least of type T */ @Directive({ selector: 'ng-template[data-gc-recursive-tree-picker-item]', standalone: false, }) export class RecursiveTreePickerItemTemplateDirective<T> { @Input('data-gc-recursive-tree-picker-item') public typeToken!: T; constructor( public readonly template: TemplateRef< RecursiveTreePickerItemTemplateContext<T> >, ) {} /** * @ignore */ static ngTemplateContextGuard<T>( _dir: RecursiveTreePickerItemTemplateDirective<T>, ctx: unknown, ): ctx is RecursiveTreePickerItemTemplateContext<T> { return true; } } type RecursiveTreeItem<T> = TreeItemBasicAdvancedKeys<RecursiveTreeItem<T>> & { parent: RecursiveTreeItem<T> | undefined; value: T | null; }; /** * Picker Tree is used for representing items in the Tree Picker. */ @Component({ selector: 'gc-tree-picker-popup-content', templateUrl: './tree-picker-popup-content.component.html', styleUrls: [ '../../utils/styles/reset-list.css', './tree-picker-popup-content.component.css', ], standalone: false, }) export class TreePickerPopupContentComponent<T> extends BaseTreeComponent< T | null, TreeItemBasicAdvancedKeys<T>, RecursiveTreeItem<T> > implements FocusableElementOwner { /** An id of the root list element */ @Input() public listId?: string; /** * Set of item keys that will be rendered as disabled items. */ @Input() public disabledItems: ReadonlySet<string | symbol> = new Set(); /** * Informs about the change of the selected item. */ @Output() public readonly valueChange: EventEmitter<T | null | undefined> = new EventEmitter<T | null | undefined>(); /** * Informs about the focus leaving the tree component. */ @Output() readonly onFocusLeave: EventEmitter<void> = new EventEmitter<void>(); /** * Forwards keyboard events for external use. */ @Output() readonly onKeyboardEvent: EventEmitter<KeyboardEvent> = new EventEmitter<KeyboardEvent>(); /** * Request a popup close */ @Output() readonly onRequestClose: EventEmitter<void> = new EventEmitter<void>(); /** * Data that will be rendered as tree items/nodes. */ @Input() public override items: readonly (T | null)[] = []; /** * If true, the component will be rendered in a slot-element mode. * @ignore */ @Input() public _slotElementMode?: 'ext-search-single-field'; /** * Enables setting of the value only when the Promise resolves with value "true". */ @Input() public permitValueChange?: (v: T | null) => Promise<boolean> | boolean; /** @ignore */ readonly _widgetKeys: WidgetKeySet = createWidgetKeySet('gc-tree-picker-pop'); /** @ignore */ protected _focusedItem?: RecursiveTreeItem<T>; /** @ignore */ protected readonly typeToken!: T; // required to get the generic type into the directive context, see https://github.com/angular/angular/issues/28731 constructor(private host: ElementRef<HTMLElement>) { super(false); } /** @ignore */ @HostListener('keydown', ['$event']) async onKeyDown(event: KeyboardEvent): Promise<void> { const key = event.key; const focusedItem = this._focusedItem; if (focusedItem) { switch (key) { case 'Enter': case ' ': await this.handleSubmitButtons(); event.preventDefault(); break; default: super.handleItemKeyEvent(event, focusedItem); } this.onKeyboardEvent.emit(event); } } /** @ignore */ public focusChild(): boolean { const focusable = this.host.nativeElement.querySelector<HTMLElement>( '[role="treeitem"][tabindex="0"]', ); if (focusable) { focusable.focus(); return true; } return false; } /** @ignore */ public _getSelectedItemLabel(): string | undefined { return this._selectedItemKey !== undefined ? this.getItemByKey(this._selectedItemKey)?.label : undefined; } /** @ignore */ public _generateLabelsOfSelectedItemPath(): string[] { if (this._selectedItemKey) { let path: string[] = []; let item = this.getItemByKey(this._selectedItemKey); while (item !== undefined) { path = [item.label, ...path]; item = item.parent; } return path; } return []; } /** @ignore */ protected async _onItemClick( event: MouseEvent, item: RecursiveTreeItem<T>, ): Promise<void> { this._focusItem(item); if (!this.disabledItems.has(item.key) && event.button === 0) { event.preventDefault(); event.stopPropagation(); if (this.value === item.value) { this.onRequestClose.emit(); return; } const doChange = () => { this.value = item.value; this.valueChange.emit(this.value); }; if (this.permitValueChange) { const permit = await this.permitValueChange( item.value === undefined ? null : item.value, ); if (permit) { doChange(); } else { this.onRequestClose.emit(); } } else { doChange(); } } } /** @ignore */ protected _onFocus(item: RecursiveTreeItem<T>): void { this._focusedItem = item; } /** @ignore */ protected _onArrowClick(event: MouseEvent, item: RecursiveTreeItem<T>): void { event.preventDefault(); event.stopPropagation(); if (!this.isEndNode(item)) { this.toggleExpandedState(item); } } /** @ignore */ protected _isFirstItem(item: RecursiveTreeItem<T>): boolean { return this._items[0].key === item.key; } /** @ignore */ protected _getInitialTabIndex(item: RecursiveTreeItem<T>): number { return this._isFirstItem(item) ? 0 : -1; } /** @ignore */ protected _isSelectedItem(item: RecursiveTreeItem<T>): boolean { return this._selectedItemKey === item.key; } /** @ignore */ protected _shouldHaveInitialFocus(item: RecursiveTreeItem<T>): boolean { const firstItemKey = this._items[0].key; return this._selectedItemKey === undefined && firstItemKey === item.key; } /** @ignore */ protected _itemTrackBy( _index: number, item: Omit<Item, 'key'> & { key: symbol | string }, ): string { return itemTrack({ key: typeof item.key === 'string' ? 'k-' + item.key : 's-' + item.key.toString(), label: item.label, }); } /** @ignore */ protected treeItemId(key: Key | symbol): string { if (typeof key === 'string') { return this._widgetKeys.widgetKey + '-i-' + key; } else { return ( this._widgetKeys.widgetKey + '-is-' + key.toString().replace(/[()]/g, '-') ); } } /** @ignore */ protected treeGroupId(itemKey: Key | symbol): string { if (typeof itemKey === 'string') { return this._widgetKeys.widgetKey + '-g-' + itemKey; } else { return ( this._widgetKeys.widgetKey + '-gs-' + itemKey.toString().replace(/[()]/g, '-') ); } } /** @ignore */ protected override isBaseItem(x: unknown): x is TreeItemBasic<T> { return isTreeItemBasic(x); } /** @ignore */ protected override createGroupItem( base: RecursiveTreeItem<T>, ): RecursiveTreeItem<T> { return base; } /** @ignore */ protected override createItem( value: T, converted: TreeItemBasicAdvancedKeys<T>, parent: RecursiveTreeItem<T> | undefined, children: RecursiveTreeItem<T>[] | undefined, ): RecursiveTreeItem<T> { return { ...converted, parent, children, value }; } /** @ignore */ protected override scrollToSelectedItem(): void { // do nothing } /** @ignore */ protected _focusItem(item: RecursiveTreeItem<T>): void { this.getNativeElementForItem(item).focus(); } /** @ignore */ private async handleSubmitButtons(): Promise<void> { if (this._focusedItem && !this.disabledItems.has(this._focusedItem.key)) { if (this.value === this._focusedItem.value) { this.onRequestClose.emit(); return; } const doChange = () => { if (this._focusedItem) { this._selectedItemKey = this._focusedItem.key; this.valueChange.emit(this.value); } }; if (this.permitValueChange) { const permit = await this.permitValueChange( this._focusedItem.value === undefined ? null : this._focusedItem.value, ); if (permit) { doChange(); } else { this.onRequestClose.emit(); } } else { doChange(); } } } /** @ignore */ private getNativeElementForItem(item: RecursiveTreeItem<T>): HTMLElement { const element = document.getElementById(this.treeItemId(item.key)); if (!element) { throw new Error( `failed to find HTML element for item ${item.key.toString()}`, ); } else { return element; } } } |