Icard/angular-clarity-master(work.../node_modules/primeng/esm2022/contextmenu/contextmenu.mjs

1313 lines
170 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
import { animate, style, transition, trigger } from '@angular/animations';
import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
import { ChangeDetectionStrategy, Component, ContentChildren, EventEmitter, Inject, Input, NgModule, Output, PLATFORM_ID, ViewChild, ViewEncapsulation, booleanAttribute, effect, forwardRef, numberAttribute, signal } from '@angular/core';
import { RouterModule } from '@angular/router';
import { PrimeTemplate, SharedModule } from 'primeng/api';
import { DomHandler } from 'primeng/dom';
import { AngleRightIcon } from 'primeng/icons/angleright';
import { RippleModule } from 'primeng/ripple';
import { TooltipModule } from 'primeng/tooltip';
import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/router";
import * as i3 from "primeng/ripple";
import * as i4 from "primeng/tooltip";
import * as i5 from "primeng/api";
export class ContextMenuSub {
document;
el;
renderer;
cd;
contextMenu;
ref;
visible = false;
items;
itemTemplate;
root = false;
autoZIndex = true;
baseZIndex = 0;
popup;
menuId;
ariaLabel;
ariaLabelledBy;
level = 0;
focusedItemId;
activeItemPath;
tabindex = 0;
itemClick = new EventEmitter();
itemMouseEnter = new EventEmitter();
menuFocus = new EventEmitter();
menuBlur = new EventEmitter();
menuKeydown = new EventEmitter();
sublistViewChild;
constructor(document, el, renderer, cd, contextMenu, ref) {
this.document = document;
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.contextMenu = contextMenu;
this.ref = ref;
}
getItemProp(processedItem, name, params = null) {
return processedItem && processedItem.item ? ObjectUtils.getItemValue(processedItem.item[name], params) : undefined;
}
getItemId(processedItem) {
return processedItem.item && processedItem.item?.id ? processedItem.item.id : `${this.menuId}_${processedItem.key}`;
}
getItemKey(processedItem) {
return this.getItemId(processedItem);
}
getItemClass(processedItem) {
return {
...this.getItemProp(processedItem, 'class'),
'p-menuitem': true,
'p-highlight': this.isItemActive(processedItem),
'p-menuitem-active': this.isItemActive(processedItem),
'p-focus': this.isItemFocused(processedItem),
'p-disabled': this.isItemDisabled(processedItem)
};
}
getItemLabel(processedItem) {
return this.getItemProp(processedItem, 'label');
}
getSeparatorItemClass(processedItem) {
return {
...this.getItemProp(processedItem, 'class'),
'p-menuitem-separator': true
};
}
getAriaSetSize() {
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
}
getAriaPosInset(index) {
return index - this.items.slice(0, index).filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')).length + 1;
}
isItemVisible(processedItem) {
return this.getItemProp(processedItem, 'visible') !== false;
}
isItemActive(processedItem) {
if (this.activeItemPath) {
return this.activeItemPath.some((path) => path.key === processedItem.key);
}
}
isItemDisabled(processedItem) {
return this.getItemProp(processedItem, 'disabled');
}
isItemFocused(processedItem) {
return this.focusedItemId === this.getItemId(processedItem);
}
isItemGroup(processedItem) {
return ObjectUtils.isNotEmpty(processedItem.items);
}
onItemMouseEnter(param) {
const { event, processedItem } = param;
this.itemMouseEnter.emit({ originalEvent: event, processedItem });
}
onItemClick(event, processedItem) {
this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });
this.itemClick.emit({ originalEvent: event, processedItem, isFocus: true });
}
onEnter(event, sublist) {
if (event.fromState === 'void' && event.toState) {
const sublist = event.element;
this.position(sublist);
}
}
position(sublist) {
const parentItem = sublist.parentElement.parentElement;
const containerOffset = DomHandler.getOffset(sublist.parentElement.parentElement);
const viewport = DomHandler.getViewport();
const sublistWidth = sublist.offsetParent ? sublist.offsetWidth : DomHandler.getHiddenElementOuterWidth(sublist);
const itemOuterWidth = DomHandler.getOuterWidth(parentItem.children[0]);
sublist.style.top = '0px';
if (parseInt(containerOffset.left, 10) + itemOuterWidth + sublistWidth > viewport.width - DomHandler.calculateScrollbarWidth()) {
sublist.style.left = -1 * sublistWidth + 'px';
}
else {
sublist.style.left = itemOuterWidth + 'px';
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuSub, deps: [{ token: DOCUMENT }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: forwardRef(() => ContextMenu) }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: ContextMenuSub, selector: "p-contextMenuSub", inputs: { visible: ["visible", "visible", booleanAttribute], items: "items", itemTemplate: "itemTemplate", root: ["root", "root", booleanAttribute], autoZIndex: ["autoZIndex", "autoZIndex", booleanAttribute], baseZIndex: ["baseZIndex", "baseZIndex", numberAttribute], popup: ["popup", "popup", booleanAttribute], menuId: "menuId", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", level: ["level", "level", numberAttribute], focusedItemId: "focusedItemId", activeItemPath: "activeItemPath", tabindex: ["tabindex", "tabindex", numberAttribute] }, outputs: { itemClick: "itemClick", itemMouseEnter: "itemMouseEnter", menuFocus: "menuFocus", menuBlur: "menuBlur", menuKeydown: "menuKeydown" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "sublistViewChild", first: true, predicate: ["sublist"], descendants: true }], ngImport: i0, template: `
<ul
*ngIf="root ? true : visible"
#sublist
role="menu"
[ngClass]="{ 'p-submenu-list': !root, 'p-contextmenu-root-list': root }"
[@overlayAnimation]="visible"
(@overlayAnimation.start)="onEnter($event, sublist)"
[attr.id]="menuId + '_list'"
[tabindex]="tabindex"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledBy]="ariaLabelledBy"
[attr.aria-activedescendant]="focusedItemId"
[attr.aria-orientation]="'vertical'"
[attr.data-pc-section]="'menu'"
(keydown)="menuKeydown.emit($event)"
(focus)="menuFocus.emit($event)"
(blur)="menuBlur.emit($event)"
>
<ng-template ngFor let-processedItem [ngForOf]="items" let-index="index">
<li
*ngIf="isItemVisible(processedItem) && getItemProp(processedItem, 'separator')"
[attr.id]="getItemId(processedItem)"
[style]="getItemProp(processedItem, 'style')"
[ngClass]="getSeparatorItemClass(processedItem)"
role="separator"
[attr.data-pc-section]="'separator'"
></li>
<li
#listItem
*ngIf="isItemVisible(processedItem) && !getItemProp(processedItem, 'separator')"
role="menuitem"
[attr.id]="getItemId(processedItem)"
[attr.data-pc-section]="'menuitem'"
[attr.data-p-highlight]="isItemActive(processedItem)"
[attr.data-p-focused]="isItemFocused(processedItem)"
[attr.data-p-disabled]="isItemDisabled(processedItem)"
[attr.aria-label]="getItemLabel(processedItem)"
[attr.aria-disabled]="isItemDisabled(processedItem) || undefined"
[attr.aria-haspopup]="isItemGroup(processedItem) && !getItemProp(processedItem, 'to') ? 'menu' : undefined"
[attr.aria-expanded]="isItemGroup(processedItem) ? isItemActive(processedItem) : undefined"
[attr.aria-level]="level + 1"
[attr.aria-setsize]="getAriaSetSize()"
[attr.aria-posinset]="getAriaPosInset(index)"
[ngStyle]="getItemProp(processedItem, 'style')"
[ngClass]="getItemClass(processedItem)"
[class]="getItemProp(processedItem, 'styleClass')"
pTooltip
[tooltipOptions]="getItemProp(processedItem, 'tooltipOptions')"
>
<div [attr.data-pc-section]="'content'" class="p-menuitem-content" (click)="onItemClick($event, processedItem)" (mouseenter)="onItemMouseEnter({$event, processedItem})">
<ng-container *ngIf="!itemTemplate">
<a
*ngIf="!getItemProp(processedItem, 'routerLink')"
[attr.href]="getItemProp(processedItem, 'url')"
[attr.aria-hidden]="true"
[attr.data-automationid]="getItemProp(processedItem, 'automationId')"
[attr.data-pc-section]="'action'"
[target]="getItemProp(processedItem, 'target')"
[ngClass]="{ 'p-menuitem-link': true }"
[attr.tabindex]="-1"
pRipple
>
<span
*ngIf="getItemProp(processedItem, 'icon')"
class="p-menuitem-icon"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
>
</span>
<span *ngIf="getItemProp(processedItem, 'escape'); else htmlLabel" class="p-menuitem-text" [attr.data-pc-section]="'label'">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'"></span>
</ng-template>
<span class="p-menuitem-badge" *ngIf="getItemProp(processedItem, 'badge')" [ngClass]="getItemProp(processedItem, 'badgeStyleClass')">{{ getItemProp(processedItem, 'badge') }}</span>
<ng-container *ngIf="isItemGroup(processedItem)">
<AngleRightIcon *ngIf="!contextMenu.submenuIconTemplate" [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<ng-template *ngTemplateOutlet="contextMenu.submenuIconTemplate" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true"></ng-template>
</ng-container>
</a>
<a
*ngIf="getItemProp(processedItem, 'routerLink')"
[routerLink]="getItemProp(processedItem, 'routerLink')"
[attr.data-automationid]="getItemProp(processedItem, 'automationId')"
[attr.tabindex]="-1"
[attr.aria-hidden]="true"
[attr.data-pc-section]="'action'"
[queryParams]="getItemProp(processedItem, 'queryParams')"
[routerLinkActive]="'p-menuitem-link-active'"
[routerLinkActiveOptions]="getItemProp(processedItem, 'routerLinkActiveOptions') || { exact: false }"
[target]="getItemProp(processedItem, 'target')"
[ngClass]="{ 'p-menuitem-link': true, 'p-disabled': getItemProp(processedItem, 'disabled') }"
[fragment]="getItemProp(processedItem, 'fragment')"
[queryParamsHandling]="getItemProp(processedItem, 'queryParamsHandling')"
[preserveFragment]="getItemProp(processedItem, 'preserveFragment')"
[skipLocationChange]="getItemProp(processedItem, 'skipLocationChange')"
[replaceUrl]="getItemProp(processedItem, 'replaceUrl')"
[state]="getItemProp(processedItem, 'state')"
pRipple
>
<span
*ngIf="getItemProp(processedItem, 'icon')"
class="p-menuitem-icon"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
>
</span>
<span *ngIf="getItemProp(processedItem, 'escape'); else htmlLabel" class="p-menuitem-text" [attr.data-pc-section]="'label'">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'"></span>
</ng-template>
<span class="p-menuitem-badge" *ngIf="getItemProp(processedItem, 'badge')" [ngClass]="getItemProp(processedItem, 'badgeStyleClass')">{{ getItemProp(processedItem, 'badge') }}</span>
<ng-container *ngIf="isItemGroup(processedItem)">
<AngleRightIcon *ngIf="!contextMenu.submenuIconTemplate" [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<ng-template *ngTemplateOutlet="contextMenu.submenuIconTemplate" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true"></ng-template>
</ng-container>
</a>
</ng-container>
<ng-container *ngIf="itemTemplate">
<ng-template *ngTemplateOutlet="itemTemplate; context: { $implicit: processedItem.item }"></ng-template>
</ng-container>
</div>
<p-contextMenuSub
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem)"
[items]="processedItem.items"
[itemTemplate]="itemTemplate"
[menuId]="menuId"
[visible]="isItemActive(processedItem) && isItemGroup(processedItem)"
[activeItemPath]="activeItemPath"
[focusedItemId]="focusedItemId"
[level]="level + 1"
(itemClick)="itemClick.emit($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-contextMenuSub>
</li>
</ng-template>
</ul>
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgForOf), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgStyle), selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i0.forwardRef(() => i2.RouterLink), selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i0.forwardRef(() => i2.RouterLinkActive), selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "directive", type: i0.forwardRef(() => i3.Ripple), selector: "[pRipple]" }, { kind: "directive", type: i0.forwardRef(() => i4.Tooltip), selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "component", type: i0.forwardRef(() => AngleRightIcon), selector: "AngleRightIcon" }, { kind: "component", type: i0.forwardRef(() => ContextMenuSub), selector: "p-contextMenuSub", inputs: ["visible", "items", "itemTemplate", "root", "autoZIndex", "baseZIndex", "popup", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "activeItemPath", "tabindex"], outputs: ["itemClick", "itemMouseEnter", "menuFocus", "menuBlur", "menuKeydown"] }], animations: [trigger('overlayAnimation', [transition(':enter', [style({ opacity: 0 })]), transition(':leave', [style({ opacity: 0 })])])], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuSub, decorators: [{
type: Component,
args: [{
selector: 'p-contextMenuSub',
template: `
<ul
*ngIf="root ? true : visible"
#sublist
role="menu"
[ngClass]="{ 'p-submenu-list': !root, 'p-contextmenu-root-list': root }"
[@overlayAnimation]="visible"
(@overlayAnimation.start)="onEnter($event, sublist)"
[attr.id]="menuId + '_list'"
[tabindex]="tabindex"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledBy]="ariaLabelledBy"
[attr.aria-activedescendant]="focusedItemId"
[attr.aria-orientation]="'vertical'"
[attr.data-pc-section]="'menu'"
(keydown)="menuKeydown.emit($event)"
(focus)="menuFocus.emit($event)"
(blur)="menuBlur.emit($event)"
>
<ng-template ngFor let-processedItem [ngForOf]="items" let-index="index">
<li
*ngIf="isItemVisible(processedItem) && getItemProp(processedItem, 'separator')"
[attr.id]="getItemId(processedItem)"
[style]="getItemProp(processedItem, 'style')"
[ngClass]="getSeparatorItemClass(processedItem)"
role="separator"
[attr.data-pc-section]="'separator'"
></li>
<li
#listItem
*ngIf="isItemVisible(processedItem) && !getItemProp(processedItem, 'separator')"
role="menuitem"
[attr.id]="getItemId(processedItem)"
[attr.data-pc-section]="'menuitem'"
[attr.data-p-highlight]="isItemActive(processedItem)"
[attr.data-p-focused]="isItemFocused(processedItem)"
[attr.data-p-disabled]="isItemDisabled(processedItem)"
[attr.aria-label]="getItemLabel(processedItem)"
[attr.aria-disabled]="isItemDisabled(processedItem) || undefined"
[attr.aria-haspopup]="isItemGroup(processedItem) && !getItemProp(processedItem, 'to') ? 'menu' : undefined"
[attr.aria-expanded]="isItemGroup(processedItem) ? isItemActive(processedItem) : undefined"
[attr.aria-level]="level + 1"
[attr.aria-setsize]="getAriaSetSize()"
[attr.aria-posinset]="getAriaPosInset(index)"
[ngStyle]="getItemProp(processedItem, 'style')"
[ngClass]="getItemClass(processedItem)"
[class]="getItemProp(processedItem, 'styleClass')"
pTooltip
[tooltipOptions]="getItemProp(processedItem, 'tooltipOptions')"
>
<div [attr.data-pc-section]="'content'" class="p-menuitem-content" (click)="onItemClick($event, processedItem)" (mouseenter)="onItemMouseEnter({$event, processedItem})">
<ng-container *ngIf="!itemTemplate">
<a
*ngIf="!getItemProp(processedItem, 'routerLink')"
[attr.href]="getItemProp(processedItem, 'url')"
[attr.aria-hidden]="true"
[attr.data-automationid]="getItemProp(processedItem, 'automationId')"
[attr.data-pc-section]="'action'"
[target]="getItemProp(processedItem, 'target')"
[ngClass]="{ 'p-menuitem-link': true }"
[attr.tabindex]="-1"
pRipple
>
<span
*ngIf="getItemProp(processedItem, 'icon')"
class="p-menuitem-icon"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
>
</span>
<span *ngIf="getItemProp(processedItem, 'escape'); else htmlLabel" class="p-menuitem-text" [attr.data-pc-section]="'label'">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'"></span>
</ng-template>
<span class="p-menuitem-badge" *ngIf="getItemProp(processedItem, 'badge')" [ngClass]="getItemProp(processedItem, 'badgeStyleClass')">{{ getItemProp(processedItem, 'badge') }}</span>
<ng-container *ngIf="isItemGroup(processedItem)">
<AngleRightIcon *ngIf="!contextMenu.submenuIconTemplate" [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<ng-template *ngTemplateOutlet="contextMenu.submenuIconTemplate" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true"></ng-template>
</ng-container>
</a>
<a
*ngIf="getItemProp(processedItem, 'routerLink')"
[routerLink]="getItemProp(processedItem, 'routerLink')"
[attr.data-automationid]="getItemProp(processedItem, 'automationId')"
[attr.tabindex]="-1"
[attr.aria-hidden]="true"
[attr.data-pc-section]="'action'"
[queryParams]="getItemProp(processedItem, 'queryParams')"
[routerLinkActive]="'p-menuitem-link-active'"
[routerLinkActiveOptions]="getItemProp(processedItem, 'routerLinkActiveOptions') || { exact: false }"
[target]="getItemProp(processedItem, 'target')"
[ngClass]="{ 'p-menuitem-link': true, 'p-disabled': getItemProp(processedItem, 'disabled') }"
[fragment]="getItemProp(processedItem, 'fragment')"
[queryParamsHandling]="getItemProp(processedItem, 'queryParamsHandling')"
[preserveFragment]="getItemProp(processedItem, 'preserveFragment')"
[skipLocationChange]="getItemProp(processedItem, 'skipLocationChange')"
[replaceUrl]="getItemProp(processedItem, 'replaceUrl')"
[state]="getItemProp(processedItem, 'state')"
pRipple
>
<span
*ngIf="getItemProp(processedItem, 'icon')"
class="p-menuitem-icon"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
>
</span>
<span *ngIf="getItemProp(processedItem, 'escape'); else htmlLabel" class="p-menuitem-text" [attr.data-pc-section]="'label'">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'"></span>
</ng-template>
<span class="p-menuitem-badge" *ngIf="getItemProp(processedItem, 'badge')" [ngClass]="getItemProp(processedItem, 'badgeStyleClass')">{{ getItemProp(processedItem, 'badge') }}</span>
<ng-container *ngIf="isItemGroup(processedItem)">
<AngleRightIcon *ngIf="!contextMenu.submenuIconTemplate" [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<ng-template *ngTemplateOutlet="contextMenu.submenuIconTemplate" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true"></ng-template>
</ng-container>
</a>
</ng-container>
<ng-container *ngIf="itemTemplate">
<ng-template *ngTemplateOutlet="itemTemplate; context: { $implicit: processedItem.item }"></ng-template>
</ng-container>
</div>
<p-contextMenuSub
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem)"
[items]="processedItem.items"
[itemTemplate]="itemTemplate"
[menuId]="menuId"
[visible]="isItemActive(processedItem) && isItemGroup(processedItem)"
[activeItemPath]="activeItemPath"
[focusedItemId]="focusedItemId"
[level]="level + 1"
(itemClick)="itemClick.emit($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-contextMenuSub>
</li>
</ng-template>
</ul>
`,
animations: [trigger('overlayAnimation', [transition(':enter', [style({ opacity: 0 })]), transition(':leave', [style({ opacity: 0 })])])],
encapsulation: ViewEncapsulation.None,
host: {
class: 'p-element'
}
}]
}], ctorParameters: () => [{ type: Document, decorators: [{
type: Inject,
args: [DOCUMENT]
}] }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: ContextMenu, decorators: [{
type: Inject,
args: [forwardRef(() => ContextMenu)]
}] }, { type: i0.ViewContainerRef }], propDecorators: { visible: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], items: [{
type: Input
}], itemTemplate: [{
type: Input
}], root: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoZIndex: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], baseZIndex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], popup: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], menuId: [{
type: Input
}], ariaLabel: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], level: [{
type: Input,
args: [{ transform: numberAttribute }]
}], focusedItemId: [{
type: Input
}], activeItemPath: [{
type: Input
}], tabindex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], itemClick: [{
type: Output
}], itemMouseEnter: [{
type: Output
}], menuFocus: [{
type: Output
}], menuBlur: [{
type: Output
}], menuKeydown: [{
type: Output
}], sublistViewChild: [{
type: ViewChild,
args: ['sublist']
}] } });
/**
* ContextMenu displays an overlay menu on right click of its target. Note that components like Table has special integration with ContextMenu.
* @group Components
*/
export class ContextMenu {
document;
platformId;
el;
renderer;
cd;
config;
overlayService;
/**
* An array of menuitems.
* @group Props
*/
set model(value) {
this._model = value;
this._processedItems = this.createProcessedItems(this._model || []);
}
get model() {
return this._model;
}
/**
* Event for which the menu must be displayed.
* @group Props
*/
triggerEvent = 'contextmenu';
/**
* Local template variable name of the element to attach the context menu.
* @group Props
*/
target;
/**
* Attaches the menu to document instead of a particular item.
* @group Props
*/
global;
/**
* Inline style of the component.
* @group Props
*/
style;
/**
* Style class of the component.
* @group Props
*/
styleClass;
/**
* Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element.
* @group Props
*/
appendTo;
/**
* Whether to automatically manage layering.
* @group Props
*/
autoZIndex = true;
/**
* Base zIndex value to use in layering.
* @group Props
*/
baseZIndex = 0;
/**
* Current id state as a string.
* @group Props
*/
id;
/**
* Defines a string value that labels an interactive element.
* @group Props
*/
ariaLabel;
/**
* Identifier of the underlying input element.
* @group Props
*/
ariaLabelledBy;
/**
* Press delay in touch devices as miliseconds.
* @group Props
*/
pressDelay = 500;
/**
* Callback to invoke when overlay menu is shown.
* @group Emits
*/
onShow = new EventEmitter();
/**
* Callback to invoke when overlay menu is hidden.
* @group Emits
*/
onHide = new EventEmitter();
templates;
rootmenu;
containerViewChild;
submenuIconTemplate;
itemTemplate;
container;
outsideClickListener;
resizeListener;
triggerEventListener;
documentClickListener;
documentTriggerListener;
touchEndListener;
pageX;
pageY;
visible = signal(false);
relativeAlign;
window;
focused = false;
activeItemPath = signal([]);
focusedItemInfo = signal({ index: -1, level: 0, parentKey: '', item: null });
submenuVisible = signal(false);
searchValue = '';
searchTimeout;
_processedItems;
_model;
pressTimer;
get visibleItems() {
const processedItem = this.activeItemPath().find((p) => p.key === this.focusedItemInfo().parentKey);
return processedItem ? processedItem.items : this.processedItems;
}
get processedItems() {
if (!this._processedItems || !this._processedItems.length) {
this._processedItems = this.createProcessedItems(this.model || []);
}
return this._processedItems;
}
get focusedItemId() {
const focusedItem = this.focusedItemInfo();
return focusedItem.item && focusedItem.item?.id ? focusedItem.item.id : focusedItem.index !== -1 ? `${this.id}${ObjectUtils.isNotEmpty(focusedItem.parentKey) ? '_' + focusedItem.parentKey : ''}_${focusedItem.index}` : null;
}
constructor(document, platformId, el, renderer, cd, config, overlayService) {
this.document = document;
this.platformId = platformId;
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.config = config;
this.overlayService = overlayService;
this.window = this.document.defaultView;
effect(() => {
const path = this.activeItemPath();
if (ObjectUtils.isNotEmpty(path)) {
this.bindGlobalListeners();
}
else if (!this.visible()) {
this.unbindGlobalListeners();
}
});
}
ngOnInit() {
this.id = this.id || UniqueComponentId();
this.bindTriggerEventListener();
}
isMobile() {
return DomHandler.isIOS() || DomHandler.isAndroid();
}
bindTriggerEventListener() {
if (isPlatformBrowser(this.platformId)) {
if (!this.triggerEventListener) {
if (!this.isMobile()) {
if (this.global) {
this.triggerEventListener = this.renderer.listen(this.document, this.triggerEvent, (event) => {
this.show(event);
});
}
else if (this.target) {
this.triggerEventListener = this.renderer.listen(this.target, this.triggerEvent, (event) => {
this.show(event);
});
}
}
else {
if (this.global) {
this.triggerEventListener = this.renderer.listen(this.document, 'touchstart', this.onTouchStart.bind(this));
this.touchEndListener = this.renderer.listen(this.document, 'touchend', this.onTouchEnd.bind(this));
}
else if (this.target) {
this.triggerEventListener = this.renderer.listen(this.target, 'touchstart', this.onTouchStart.bind(this));
this.touchEndListener = this.renderer.listen(this.target, 'touchend', this.onTouchEnd.bind(this));
}
}
}
}
}
bindGlobalListeners() {
if (isPlatformBrowser(this.platformId)) {
if (!this.documentClickListener) {
const documentTarget = this.el ? this.el.nativeElement.ownerDocument : 'document';
this.documentClickListener = this.renderer.listen(documentTarget, 'click', (event) => {
if (this.containerViewChild.nativeElement.offsetParent && this.isOutsideClicked(event) && !event.ctrlKey && event.button !== 2 && this.triggerEvent !== 'click') {
this.hide();
}
});
this.documentTriggerListener = this.renderer.listen(documentTarget, this.triggerEvent, (event) => {
if (this.containerViewChild.nativeElement.offsetParent && this.isOutsideClicked(event)) {
this.hide();
}
});
}
if (!this.resizeListener) {
this.resizeListener = this.renderer.listen(this.document.defaultView, 'resize', (event) => {
this.hide();
});
}
}
}
ngAfterContentInit() {
this.templates?.forEach((item) => {
switch (item.getType()) {
case 'submenuicon':
this.submenuIconTemplate = item.template;
break;
case 'item':
this.itemTemplate = item.template;
break;
default:
this.itemTemplate = item.template;
break;
}
});
}
createProcessedItems(items, level = 0, parent = {}, parentKey = '') {
const processedItems = [];
items &&
items.forEach((item, index) => {
const key = (parentKey !== '' ? parentKey + '_' : '') + index;
const newItem = {
item,
index,
level,
key,
parent,
parentKey
};
newItem['items'] = this.createProcessedItems(item.items, level + 1, newItem, key);
processedItems.push(newItem);
});
return processedItems;
}
getItemProp(item, name) {
return item ? ObjectUtils.getItemValue(item[name]) : undefined;
}
getProccessedItemLabel(processedItem) {
return processedItem ? this.getItemLabel(processedItem.item) : undefined;
}
getItemLabel(item) {
return this.getItemProp(item, 'label');
}
isProcessedItemGroup(processedItem) {
return processedItem && ObjectUtils.isNotEmpty(processedItem.items);
}
isSelected(processedItem) {
return this.activeItemPath().some((p) => p.key === processedItem.key);
}
isValidSelectedItem(processedItem) {
return this.isValidItem(processedItem) && this.isSelected(processedItem);
}
isValidItem(processedItem) {
return !!processedItem && !this.isItemDisabled(processedItem.item) && !this.isItemSeparator(processedItem.item);
}
isItemDisabled(item) {
return this.getItemProp(item, 'disabled');
}
isItemSeparator(item) {
return this.getItemProp(item, 'separator');
}
isItemMatched(processedItem) {
return this.isValidItem(processedItem) && this.getProccessedItemLabel(processedItem).toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase());
}
isProccessedItemGroup(processedItem) {
return processedItem && ObjectUtils.isNotEmpty(processedItem.items);
}
onItemClick(event) {
const { processedItem } = event;
const grouped = this.isProcessedItemGroup(processedItem);
const selected = this.isSelected(processedItem);
if (selected) {
const { index, key, level, parentKey, item } = processedItem;
this.activeItemPath.set(this.activeItemPath().filter((p) => key !== p.key && key.startsWith(p.key)));
this.focusedItemInfo.set({ index, level, parentKey, item });
DomHandler.focus(this.rootmenu.sublistViewChild.nativeElement);
}
else {
grouped ? this.onItemChange(event) : this.hide();
}
}
onItemMouseEnter(event) {
this.onItemChange(event);
}
onKeyDown(event) {
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
break;
case 'ArrowUp':
this.onArrowUpKey(event);
break;
case 'ArrowLeft':
this.onArrowLeftKey(event);
break;
case 'ArrowRight':
this.onArrowRightKey(event);
break;
case 'Home':
this.onHomeKey(event);
break;
case 'End':
this.onEndKey(event);
break;
case 'Space':
this.onSpaceKey(event);
break;
case 'Enter':
this.onEnterKey(event);
break;
case 'Escape':
this.onEscapeKey(event);
break;
case 'Tab':
this.onTabKey(event);
break;
case 'PageDown':
case 'PageUp':
case 'Backspace':
case 'ShiftLeft':
case 'ShiftRight':
//NOOP
break;
default:
if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
this.searchItems(event, event.key);
}
break;
}
}
onArrowDownKey(event) {
const itemIndex = this.focusedItemInfo().index !== -1 ? this.findNextItemIndex(this.focusedItemInfo().index) : this.findFirstFocusedItemIndex();
this.changeFocusedItemIndex(event, itemIndex);
event.preventDefault();
}
onArrowRightKey(event) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo.set({ index: -1, parentKey: processedItem.key, item: processedItem.item });
this.searchValue = '';
this.onArrowDownKey(event);
}
event.preventDefault();
}
onArrowUpKey(event) {
if (event.altKey) {
if (this.focusedItemInfo().index !== -1) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const grouped = this.isProccessedItemGroup(processedItem);
!grouped && this.onItemChange({ originalEvent: event, processedItem });
}
this.hide();
event.preventDefault();
}
else {
const itemIndex = this.focusedItemInfo().index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo().index) : this.findLastFocusedItemIndex();
this.changeFocusedItemIndex(event, itemIndex);
event.preventDefault();
}
}
onArrowLeftKey(event) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const parentItem = this.activeItemPath().find((p) => p.key === processedItem.parentKey);
const root = ObjectUtils.isEmpty(processedItem.parent);
if (!root) {
this.focusedItemInfo.set({ index: -1, parentKey: parentItem ? parentItem.parentKey : '', item: processedItem.item });
this.searchValue = '';
this.onArrowDownKey(event);
}
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== this.focusedItemInfo().parentKey);
this.activeItemPath.set(activeItemPath);
event.preventDefault();
}
onHomeKey(event) {
this.changeFocusedItemIndex(event, this.findFirstItemIndex());
event.preventDefault();
}
onEndKey(event) {
this.changeFocusedItemIndex(event, this.findLastItemIndex());
event.preventDefault();
}
onSpaceKey(event) {
this.onEnterKey(event);
}
onEscapeKey(event) {
this.hide();
const processedItem = this.findVisibleItem(this.findFirstFocusedItemIndex());
const focusedItemInfo = this.focusedItemInfo();
this.focusedItemInfo.set({ ...focusedItemInfo, index: this.findFirstFocusedItemIndex(), item: processedItem.item });
event.preventDefault();
}
onTabKey(event) {
if (this.focusedItemInfo().index !== -1) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const grouped = this.isProccessedItemGroup(processedItem);
!grouped && this.onItemChange({ originalEvent: event, processedItem });
}
this.hide();
}
onEnterKey(event) {
if (this.focusedItemInfo().index !== -1) {
const element = DomHandler.findSingle(this.rootmenu.el.nativeElement, `li[id="${`${this.focusedItemId}`}"]`);
const anchorElement = element && DomHandler.findSingle(element, 'a[data-pc-section="action"]');
anchorElement ? anchorElement.click() : element && element.click();
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const grouped = this.isProccessedItemGroup(processedItem);
if (!grouped) {
const focusedItemInfo = this.focusedItemInfo();
this.focusedItemInfo.set({ ...focusedItemInfo, index: this.findFirstFocusedItemIndex() });
}
}
event.preventDefault();
}
onItemChange(event) {
const { processedItem, isFocus } = event;
if (ObjectUtils.isEmpty(processedItem))
return;
const { index, key, level, parentKey, items } = processedItem;
const grouped = ObjectUtils.isNotEmpty(items);
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== parentKey && p.parentKey !== key);
if (grouped) {
activeItemPath.push(processedItem);
this.submenuVisible.set(true);
}
this.focusedItemInfo.set({ index, level, parentKey, item: processedItem.item });
this.activeItemPath.set(activeItemPath);
isFocus && DomHandler.focus(this.rootmenu.sublistViewChild.nativeElement);
}
onMenuFocus(event) {
this.focused = true;
const focusedItemInfo = this.focusedItemInfo().index !== -1 ? this.focusedItemInfo() : { index: -1, level: 0, parentKey: '', item: null };
this.focusedItemInfo.set(focusedItemInfo);
}
onMenuBlur(event) {
this.focused = false;
this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null });
this.searchValue = '';
}
onOverlayAnimationStart(event) {
switch (event.toState) {
case 'visible':
this.container = event.element;
this.position();
this.moveOnTop();
this.appendOverlay();
this.bindGlobalListeners();
DomHandler.focus(this.rootmenu.sublistViewChild.nativeElement);
break;
}
}
onOverlayAnimationEnd(event) {
switch (event.toState) {
case 'void':
this.onOverlayHide();
break;
}
}
appendOverlay() {
if (this.appendTo) {
if (this.appendTo === 'body')
this.renderer.appendChild(this.document.body, this.containerViewChild.nativeElement);
else
DomHandler.appendChild(this.containerViewChild.nativeElement, this.appendTo);
}
}
moveOnTop() {
if (this.autoZIndex && this.containerViewChild) {
ZIndexUtils.set('menu', this.containerViewChild.nativeElement, this.baseZIndex + this.config.zIndex.menu);
}
}
onOverlayHide() {
this.unbindGlobalListeners();
if (!this.cd.destroyed) {
this.target = null;
}
if (this.container && this.autoZIndex) {
ZIndexUtils.clear(this.container);
}
this.container = null;
}
onTouchStart(event) {
this.pressTimer = setTimeout(() => {
this.show(event);
}, this.pressDelay);
}
onTouchEnd() {
clearTimeout(this.pressTimer);
}
hide() {
this.visible.set(false);
this.onHide.emit();
this.activeItemPath.set([]);
this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null });
}
toggle(event) {
this.visible() ? this.hide() : this.show(event);
}
show(event) {
this.activeItemPath.set([]);
this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null });
this.pageX = event.pageX;
this.pageY = event.pageY;
this.onShow.emit();
this.visible() ? this.position() : this.visible.set(true);
event.stopPropagation();
event.preventDefault();
}
position() {
let left = this.pageX + 1;
let top = this.pageY + 1;
let width = this.containerViewChild.nativeElement.offsetParent ? this.containerViewChild.nativeElement.offsetWidth : DomHandler.getHiddenElementOuterWidth(this.containerViewChild.nativeElement);
let height = this.containerViewChild.nativeElement.offsetParent ? this.containerViewChild.nativeElement.offsetHeight : DomHandler.getHiddenElementOuterHeight(this.containerViewChild.nativeElement);
let viewport = DomHandler.getViewport();
//flip
if (left + width - this.document.scrollingElement.scrollLeft > viewport.width) {
left -= width;
}
//flip
if (top + height - this.document.scrollingElement.scrollTop > viewport.height) {
top -= height;
}
//fit
if (left < this.document.scrollingElement.scrollLeft) {
left = this.document.scrollingElement.scrollLeft;
}
//fit
if (top < this.document.scrollingElement.scrollTop) {
top = this.document.scrollingElement.scrollTop;
}
this.containerViewChild.nativeElement.style.left = left + 'px';
this.containerViewChild.nativeElement.style.top = top + 'px';
}
searchItems(event, char) {
this.searchValue = (this.searchValue || '') + char;
let itemIndex = -1;
let matched = false;
if (this.focusedItemInfo().index !== -1) {
itemIndex = this.visibleItems.slice(this.focusedItemInfo().index).findIndex((processedItem) => this.isItemMatched(processedItem));
itemIndex = itemIndex === -1 ? this.visibleItems.slice(0, this.focusedItemInfo().index).findIndex((processedItem) => this.isItemMatched(processedItem)) : itemIndex + this.focusedItemInfo().index;
}
else {
itemIndex = this.visibleItems.findIndex((processedItem) => this.isItemMatched(processedItem));
}
if (itemIndex !== -1) {
matched = true;
}
if (itemIndex === -1 && this.focusedItemInfo().index === -1) {
itemIndex = this.findFirstFocusedItemIndex();
}
if (itemIndex !== -1) {
this.changeFocusedItemIndex(event, itemIndex);
}
if (this.searchTimeout) {
clearTimeout(this.searchTimeout);
}
this.searchTimeout = setTimeout(() => {
this.searchValue = '';
this.searchTimeout = null;
}, 500);
return matched;
}
findVisibleItem(index) {
return ObjectUtils.isNotEmpty(this.visibleItems) ? this.visibleItems[index] : null;
}
findLastFocusedItemIndex() {
const selectedIndex = this.findSelectedItemIndex();
return selectedIndex < 0 ? this.findLastItemIndex() : selectedIndex;
}
findLastItemIndex() {
return ObjectUtils.findLastIndex(this.visibleItems, (processedItem) => this.isValidItem(processedItem));
}
findPrevItemIndex(index) {
const matchedItemIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleItems.slice(0, index), (processedItem) => this.isValidItem(processedItem)) : -1;
return matchedItemIndex > -1 ? matchedItemIndex : index;
}
findNextItemIndex(index) {
const matchedItemIndex = index < this.visibleItems.length - 1 ? this.visibleItems.slice(index + 1).findIndex((processedItem) => this.isValidItem(processedItem)) : -1;
return matchedItemIndex > -1 ? matchedItemIndex + index + 1 : index;
}
findFirstFocusedItemIndex() {
const selectedIndex = this.findSelectedItemIndex();
return selectedIndex < 0 ? this.findFirstItemIndex() : selectedIndex;
}
findFirstItemIndex() {
return this.visibleItems.findIndex((processedItem) => this.isValidItem(processedItem));
}
findSelectedItemIndex() {
return this.visibleItems.findIndex((processedItem) => this.isValidSelectedItem(processedItem));
}
changeFocusedItemIndex(event, index) {
const processedItem = this.findVisibleItem(index);
const focusedItemInfo = this.focusedItemInfo();
if (focusedItemInfo.index !== index) {
this.focusedItemInfo.set({ ...focusedItemInfo, index, item: processedItem.item });
this.scrollInView();
}
}
scrollInView(index = -1) {
const id = index !== -1 ? `${this.id}_${index}` : this.focusedItemId;
const element = DomHandler.findSingle(this.rootmenu.el.nativeElement, `li[id="${id}"]`);
if (element) {
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
}
bindResizeListener() {
if (isPlatformBrowser(this.platformId)) {
if (!this.resizeListener) {
this.resizeListener = this.renderer.listen(this.document.defaultView, 'resize', (event) => {
this.hide();
});
}
}
}
isOutsideClicked(event) {
return !(this.containerViewChild.nativeElement.isSameNode(event.target) || this.containerViewChild.nativeElement.contains(event.target));
}
unbindResizeListener() {
if (this.resizeListener) {
this.resizeListener();
this.resizeListener = null;
}
}
unbindGlobalListeners() {
if (this.documentClickListener) {
this.documentClickListener();
this.documentClickListener = null;
}
if (this.documentTriggerListener) {
this.documentTriggerListener();
this.documentTriggerListener = null;
}
if (this.resizeListener) {
this.resizeListener();
this.resizeListener = null;
}
if (this.touchEndListener) {
this.touchEndListener();
this.touchEndListener = null;
}
}
unbindTriggerEventListener() {
if (this.triggerEventListener) {
this.triggerEventListener();
this.triggerEventListener = null;
}
}
removeAppendedElements() {
if (this.appendTo && this.containerViewChild) {
if (this.appendTo === 'body') {
this.renderer.removeChild(this.document.body, this.containerViewChild.nativeElement);
}
else {
DomHandler.removeChild(this.containerViewChild.nativeElement, this.appendTo);
}
}
}
ngOnDestroy() {
this.unbindGlobalListeners();
this.unbindTriggerEventListener();
this.removeAppendedElements();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenu, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i5.PrimeNGConfig }, { token: i5.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: ContextMenu, selector: "p-contextMenu", inputs: { model: "model", triggerEvent: "triggerEvent", target: "target", global: ["global", "global", booleanAttribute], style: "style", styleClass: "styleClass", appendTo: "appendTo", autoZIndex: ["autoZIndex", "autoZIndex", booleanAttribute], baseZIndex: ["baseZIndex", "baseZIndex", numberAttribute], id: "id", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", pressDelay: ["pressDelay", "pressDelay", numberAttribute] }, outputs: { onShow: "onShow", onHide: "onHide" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "rootmenu", first: true, predicate: ["rootmenu"], descendants: true }, { propertyName: "containerViewChild", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: `
<div
#container
[attr.data-pc-section]="'root'"
[attr.data-pc-name]="'contextmenu'"
[attr.id]="id"
[ngClass]="{ 'p-contextmenu p-component': true, 'p-contextmenu-overlay': true }"
[class]="styleClass"
[ngStyle]="style"
[@overlayAnimation]="{ value: 'visible' }"
(@overlayAnimation.start)="onOverlayAnimationStart($event)"
(@overlayAnimation.done)="onOverlayAnimationEnd($event)"
*ngIf="visible()"
>
<p-contextMenuSub
#rootmenu
[root]="true"
[items]="processedItems"
[itemTemplate]="itemTemplate"
[menuId]="id"
[tabindex]="!disabled ? tabindex : -1"
[ariaLabel]="ariaLabel"
[ariaLabelledBy]="ariaLabelledBy"
[baseZIndex]="baseZIndex"
[autoZIndex]="autoZIndex"
[visible]="submenuVisible()"
[focusedItemId]="focused ? focusedItemId : undefined"
[activeItemPath]="activeItemPath()"
(itemClick)="onItemClick($event)"
(menuFocus)="onMenuFocus($event)"
(menuBlur)="onMenuBlur($event)"
(menuKeydown)="onKeyDown($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-contextMenuSub>
</div>
`, isInline: true, styles: ["@layer primeng{.p-contextmenu{position:absolute}.p-contextmenu ul{margin:0;padding:0;list-style:none}.p-contextmenu .p-submenu-list{position:absolute;min-width:100%;z-index:1}.p-contextmenu .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-contextmenu .p-menuitem-text{line-height:1}.p-contextmenu .p-menuitem{position:relative}.p-contextmenu .p-menuitem-link .p-submenu-icon:not(svg){margin-left:auto}.p-contextmenu .p-menuitem-link .p-icon-wrapper{margin-left:auto}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: ContextMenuSub, selector: "p-contextMenuSub", inputs: ["visible", "items", "itemTemplate", "root", "autoZIndex", "baseZIndex", "popup", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "activeItemPath", "tabindex"], outputs: ["itemClick", "itemMouseEnter", "menuFocus", "menuBlur", "menuKeydown"] }], animations: [trigger('overlayAnimation', [transition(':enter', [style({ opacity: 0 }), animate('250ms')]), transition(':leave', [animate('.1s linear', style({ opacity: 0 }))])])], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenu, decorators: [{
type: Component,
args: [{ selector: 'p-contextMenu', template: `
<div
#container
[attr.data-pc-section]="'root'"
[attr.data-pc-name]="'contextmenu'"
[attr.id]="id"
[ngClass]="{ 'p-contextmenu p-component': true, 'p-contextmenu-overlay': true }"
[class]="styleClass"
[ngStyle]="style"
[@overlayAnimation]="{ value: 'visible' }"
(@overlayAnimation.start)="onOverlayAnimationStart($event)"
(@overlayAnimation.done)="onOverlayAnimationEnd($event)"
*ngIf="visible()"
>
<p-contextMenuSub
#rootmenu
[root]="true"
[items]="processedItems"
[itemTemplate]="itemTemplate"
[menuId]="id"
[tabindex]="!disabled ? tabindex : -1"
[ariaLabel]="ariaLabel"
[ariaLabelledBy]="ariaLabelledBy"
[baseZIndex]="baseZIndex"
[autoZIndex]="autoZIndex"
[visible]="submenuVisible()"
[focusedItemId]="focused ? focusedItemId : undefined"
[activeItemPath]="activeItemPath()"
(itemClick)="onItemClick($event)"
(menuFocus)="onMenuFocus($event)"
(menuBlur)="onMenuBlur($event)"
(menuKeydown)="onKeyDown($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-contextMenuSub>
</div>
`, animations: [trigger('overlayAnimation', [transition(':enter', [style({ opacity: 0 }), animate('250ms')]), transition(':leave', [animate('.1s linear', style({ opacity: 0 }))])])], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
class: 'p-element'
}, styles: ["@layer primeng{.p-contextmenu{position:absolute}.p-contextmenu ul{margin:0;padding:0;list-style:none}.p-contextmenu .p-submenu-list{position:absolute;min-width:100%;z-index:1}.p-contextmenu .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-contextmenu .p-menuitem-text{line-height:1}.p-contextmenu .p-menuitem{position:relative}.p-contextmenu .p-menuitem-link .p-submenu-icon:not(svg){margin-left:auto}.p-contextmenu .p-menuitem-link .p-icon-wrapper{margin-left:auto}}\n"] }]
}], ctorParameters: () => [{ type: Document, decorators: [{
type: Inject,
args: [DOCUMENT]
}] }, { type: undefined, decorators: [{
type: Inject,
args: [PLATFORM_ID]
}] }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i5.PrimeNGConfig }, { type: i5.OverlayService }], propDecorators: { model: [{
type: Input
}], triggerEvent: [{
type: Input
}], target: [{
type: Input
}], global: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], appendTo: [{
type: Input
}], autoZIndex: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], baseZIndex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], id: [{
type: Input
}], ariaLabel: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], pressDelay: [{
type: Input,
args: [{ transform: numberAttribute }]
}], onShow: [{
type: Output
}], onHide: [{
type: Output
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}], rootmenu: [{
type: ViewChild,
args: ['rootmenu']
}], containerViewChild: [{
type: ViewChild,
args: ['container']
}] } });
export class ContextMenuModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuModule, declarations: [ContextMenu, ContextMenuSub], imports: [CommonModule, RouterModule, RippleModule, TooltipModule, AngleRightIcon, SharedModule], exports: [ContextMenu, RouterModule, TooltipModule, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuModule, imports: [CommonModule, RouterModule, RippleModule, TooltipModule, AngleRightIcon, SharedModule, RouterModule, TooltipModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ContextMenuModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, RouterModule, RippleModule, TooltipModule, AngleRightIcon, SharedModule],
exports: [ContextMenu, RouterModule, TooltipModule, SharedModule],
declarations: [ContextMenu, ContextMenuSub]
}]
}] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dG1lbnUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvY29udGV4dG1lbnUvY29udGV4dG1lbnUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFrQixPQUFPLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRSxPQUFPLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUMxRixPQUFPLEVBQUUsWUFBWSxFQUFFLFFBQVEsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQzVFLE9BQU8sRUFFSCx1QkFBdUIsRUFFdkIsU0FBUyxFQUNULGVBQWUsRUFFZixZQUFZLEVBQ1osTUFBTSxFQUNOLEtBQUssRUFDTCxRQUFRLEVBR1IsT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