mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
This PR migrates `libs/components` to use strict TypeScript. - Remove `@ts-strict-ignore` from each file in `libs/components` and resolved any new compilation errors - Converted ViewChild and ContentChild decorators to use the new signal-based queries using the [Angular signal queries migration](https://angular.dev/reference/migrations/signal-queries) - Made view/content children `required` where appropriate, eliminating the need for additional null checking. This helped simplify the strict migration. --- Co-authored-by: Vicki League <vleague@bitwarden.com>
39 lines
1014 B
TypeScript
39 lines
1014 B
TypeScript
import { FocusKeyManager, CdkTrapFocus } from "@angular/cdk/a11y";
|
|
import {
|
|
Component,
|
|
Output,
|
|
TemplateRef,
|
|
EventEmitter,
|
|
AfterContentInit,
|
|
input,
|
|
viewChild,
|
|
contentChildren,
|
|
} from "@angular/core";
|
|
|
|
import { MenuItemDirective } from "./menu-item.directive";
|
|
|
|
@Component({
|
|
selector: "bit-menu",
|
|
templateUrl: "./menu.component.html",
|
|
exportAs: "menuComponent",
|
|
imports: [CdkTrapFocus],
|
|
})
|
|
export class MenuComponent implements AfterContentInit {
|
|
readonly templateRef = viewChild.required(TemplateRef);
|
|
@Output() closed = new EventEmitter<void>();
|
|
readonly menuItems = contentChildren(MenuItemDirective, { descendants: true });
|
|
keyManager?: FocusKeyManager<MenuItemDirective>;
|
|
|
|
readonly ariaRole = input<"menu" | "dialog">("menu");
|
|
|
|
readonly ariaLabel = input<string>();
|
|
|
|
ngAfterContentInit() {
|
|
if (this.ariaRole() === "menu") {
|
|
this.keyManager = new FocusKeyManager(this.menuItems())
|
|
.withWrap()
|
|
.skipPredicate((item) => !!item.disabled);
|
|
}
|
|
}
|
|
}
|