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 | 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 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 2756x 2756x 2756x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 104x 104x 104x 104x 33x 71x 71x 104x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 137x 999x 137x 1x 1x 1x 1x 1x 2x 1x 2x 2x 1x 1x 1x 1x 1x 12x 12x 12x 1x 1x 1x 1x 1x 2x 2x 1x | /* eslint-disable @typescript-eslint/member-ordering */
/*******************************************************************************
* Copyright bei
* Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
*
*******************************************************************************/
import {
ChangeDetectionStrategy,
Component,
ElementRef,
computed,
input,
output,
viewChild,
} from '@angular/core';
import {
FilterItem,
FilterSlots,
FocusableElementOwner,
HasSublabel,
ItemGroup,
SlotItem,
WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
import { MenuComponent } from '../../internal/menu/menu.component';
/**
* A Filter Button element that allows users to fire an action on a button press or as menu.
*/
@Component({
selector: 'gc-filter-button',
templateUrl: './filter-button.component.html',
styleUrls: [
'./../../utils/styles/reset-button.css',
'./filter-button.component.css',
],
host: {
// host element generates an extra text node, which causes Firefox + Jaws to read out the button
// text twice when it's used in a list -> remove it from the a11y tree
role: 'presentation',
'(keydown.delete)': 'onDeleteKey()',
},
changeDetection: ChangeDetectionStrategy.Default,
standalone: false,
})
export class FilterButtonComponent implements FocusableElementOwner {
/**
* Status of the button. true === selected
*/
public selected = input(false);
/**
* Filter label.
*/
public label = input.required<string>();
/**
* Value text of the filter.
*/
public value = input('');
/**
* If not empty, the button will open a menu on click and render these as items of the menu.
*/
public menuItems = input<readonly ItemGroup<FilterItem & HasSublabel>[]>([]);
/**
* Decides on which side of the menu button the menu is going to appear.
*/
public menuAlignment = input<'start' | 'end' | 'auto'>('end');
/**
* Text that will appear in the button tooltip.
*/
public tooltipText = input<string>();
/**
* Key of the filter item which this button controls.
*/
public itemKey = input('');
/**
* Display the "remove" button on the filter pill.
*/
public showRemoveButton = input(false);
/**
* Adds a context menu to the filter pill
*/
public contextMenu = input(false);
/**
* text may be abbreviated
*/
public allowAbbreviation = input(false);
/**
* Event which is fired when an menu item is activated.
*/
public readonly onMenuAction = output<FilterItem & HasSublabel>();
/**
* Event emitted when pressed on context menu action.
*/
public readonly onContextMenuAction = output<SlotItem<FilterSlots>>();
/**
* Event which is fired when clicked on the filter pill.
*/
public readonly onAction = output();
/**
* Event which is fired when "remove" button is pressed
*/
public readonly onRemove = output();
/**
* @ignore
*/
public button = viewChild.required<ElementRef<HTMLButtonElement>>('button');
/**
* @ignore
*/
public menu = viewChild<MenuComponent<FilterItem>>('menu');
/**
* Actions that will be shown in the context menu of the button
*/
public contextMenuActions = computed(() => {
const providedActions = this._contextMenuActionsInput();
return providedActions.length > 0 ? providedActions : this._defaultActions;
});
/**
* @ignore
*/
public _controlsElementId?: string;
/** @ignore */
private readonly _widgetKeys: WidgetKeySet =
createWidgetKeySet('gc-filter-button');
/** @ignore */
private readonly _defaultActions: SlotItem<FilterSlots>[] = [
{
key: this._widgetKeys.widgetKey + '-tree-default',
label: 'Keine Aktion verfügbar.',
slot: 'header',
},
];
public _contextMenuActionsInput = input<readonly SlotItem<FilterSlots>[]>(
this._defaultActions,
{ alias: 'contextMenuActions' },
);
public _disabledActionKeysInput = input<ReadonlySet<string> | undefined>(
new Set([this._defaultActions[0].key]),
{ alias: 'disabledActionKeys' },
);
/**
* keys of all disabled actions
*/
public disabledActionKeys = computed(() => {
const providedKeys = this._disabledActionKeysInput();
const defaultKey = this._defaultActions[0].key;
if (providedKeys) {
return new Set([...providedKeys, ...[defaultKey]]);
} else {
return new Set([defaultKey]);
}
});
/**
* @ignore
* Figma: aligned to bottom of text. 22px / 2 + 4px (default margin of the menu)
*/
protected readonly contextMenuOffset = 15;
protected computeTooltipText = computed(() => {
return this.tooltipText() ?? '';
});
protected computeAriaExpanded = computed(() => {
return this.menuItems().length === 0 ? this.selected() : undefined;
});
/**
* @ignore
*/
public onDeleteKey(): void {
if (this.showRemoveButton()) {
this.onRemove.emit();
}
}
/**
* @ignore
*/
public focusChild(): boolean {
this.button().nativeElement.focus();
return true;
}
/**
* @ignore
*/
protected _onContextMenuAction(item: SlotItem<FilterSlots>): void {
this.onContextMenuAction.emit(item);
}
}
|