carbon-components-angular
Version:
Next generation components
133 lines • 15 kB
JavaScript
import { Component, HostListener, Input, HostBinding } from "@angular/core";
import * as i0 from "@angular/core";
/**
* Get started with importing the module:
*
* ```typescript
* import { ContextMenuModule } from 'carbon-components-angular';
* ```
*
* [See demo](../../?path=/story/components-context-menu--basic)
*/
export class ContextMenuComponent {
constructor(elementRef) {
this.elementRef = elementRef;
this.open = false;
this.position = {
left: 0,
top: 0
};
this.contextMenu = true;
this.role = "menu";
this.tabindex = "-1";
}
get contextMenuOpen() { return this.open; }
get showMenu() { return this.open; }
get leftPosition() { return this.position.left; }
get topPosition() { return this.position.top; }
get classIcons() {
const svgElement = this.elementRef.nativeElement
.querySelector(".cds--menu-item .cds--menu-item__icon svg");
return svgElement;
}
ngOnChanges(changes) {
if (changes.open && changes.open.currentValue) {
this.focusMenu();
}
}
focusMenu() {
// wait until the next tick to let the DOM settle before changing the focus
setTimeout(() => {
const list = this.elementRef.nativeElement;
const firstOption = list.querySelector(".cds--menu-item");
firstOption.focus();
});
}
handleNavigation(event) {
const list = this.elementRef.nativeElement;
const subMenus = Array.from(list.querySelectorAll("cds-context-menu[role=menu]"));
const menuItems = Array.from(list.querySelectorAll(".cds--menu-item"))
.filter(menuItem => !subMenus.some(subMenu => subMenu.contains(menuItem)));
const currentIndex = menuItems.findIndex(menuItem => parseInt(menuItem.getAttribute("tabindex"), 10) === 0);
const currentMenuItem = menuItems[currentIndex];
switch (event.key) {
case "ArrowDown": {
if (document.activeElement === list) {
menuItems[0].focus();
}
else {
if (currentIndex !== -1 && currentIndex < menuItems.length - 1) {
menuItems[currentIndex + 1].focus();
}
}
break;
}
case "ArrowUp": {
if (document.activeElement === list) {
menuItems[menuItems.length - 1].focus();
}
else {
if (currentIndex !== -1 && currentIndex > 0) {
menuItems[currentIndex - 1].focus();
}
}
break;
}
case "ArrowRight": {
if (currentIndex !== -1 && subMenus.some(subMenu => currentMenuItem.contains(subMenu))) {
currentMenuItem.click();
}
break;
}
case "ArrowLeft": {
const parent = currentMenuItem.parentElement.closest(".cds--menu-item, .cds--menu-item");
if (parent) {
parent.focus();
}
break;
}
}
}
}
ContextMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ContextMenuComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
ContextMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ContextMenuComponent, selector: "cds-context-menu, ibm-context-menu", inputs: { open: "open", position: "position" }, host: { listeners: { "keydown": "handleNavigation($event)" }, properties: { "class.cds--menu": "this.contextMenu", "class.cds--menu--open": "this.contextMenuOpen", "class.cds--menu--shown": "this.showMenu", "attr.role": "this.role", "attr.tabindex": "this.tabindex", "style.left.px": "this.leftPosition", "style.top.px": "this.topPosition", "class.cds--menu--with-icons": "this.classIcons" } }, usesOnChanges: true, ngImport: i0, template: `
<ng-content></ng-content>
`, isInline: true, styles: [":host{display:block}\n"] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ContextMenuComponent, decorators: [{
type: Component,
args: [{ selector: "cds-context-menu, ibm-context-menu", template: `
<ng-content></ng-content>
`, styles: [":host{display:block}\n"] }]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { open: [{
type: Input
}], position: [{
type: Input
}], contextMenu: [{
type: HostBinding,
args: ["class.cds--menu"]
}], contextMenuOpen: [{
type: HostBinding,
args: ["class.cds--menu--open"]
}], showMenu: [{
type: HostBinding,
args: ["class.cds--menu--shown"]
}], role: [{
type: HostBinding,
args: ["attr.role"]
}], tabindex: [{
type: HostBinding,
args: ["attr.tabindex"]
}], leftPosition: [{
type: HostBinding,
args: ["style.left.px"]
}], topPosition: [{
type: HostBinding,
args: ["style.top.px"]
}], classIcons: [{
type: HostBinding,
args: ["class.cds--menu--with-icons"]
}], handleNavigation: [{
type: HostListener,
args: ["keydown", ["$event"]]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