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

1258 lines
165 KiB
JavaScript
Raw Normal View History

2024-07-16 14:55:36 +00:00
import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
import { ChangeDetectionStrategy, Component, ContentChildren, EventEmitter, Inject, Injectable, Input, NgModule, Output, PLATFORM_ID, ViewChild, ViewEncapsulation, booleanAttribute, effect, numberAttribute, signal } from '@angular/core';
import { RouterModule } from '@angular/router';
import { PrimeTemplate, SharedModule } from 'primeng/api';
import { DomHandler } from 'primeng/dom';
import { AngleDownIcon } from 'primeng/icons/angledown';
import { AngleRightIcon } from 'primeng/icons/angleright';
import { BarsIcon } from 'primeng/icons/bars';
import { RippleModule } from 'primeng/ripple';
import { TooltipModule } from 'primeng/tooltip';
import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils';
import { Subject, interval } from 'rxjs';
import { debounce, filter } from 'rxjs/operators';
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 MenubarService {
autoHide;
autoHideDelay;
mouseLeaves = new Subject();
mouseLeft$ = this.mouseLeaves.pipe(debounce(() => interval(this.autoHideDelay)), filter((mouseLeft) => this.autoHide && mouseLeft));
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarService, decorators: [{
type: Injectable
}] });
export class MenubarSub {
el;
renderer;
cd;
menubarService;
items;
itemTemplate;
root = false;
autoZIndex = true;
baseZIndex = 0;
mobileActive;
autoDisplay;
menuId;
ariaLabel;
ariaLabelledBy;
level = 0;
focusedItemId;
activeItemPath;
submenuIconTemplate;
itemClick = new EventEmitter();
itemMouseEnter = new EventEmitter();
menuFocus = new EventEmitter();
menuBlur = new EventEmitter();
menuKeydown = new EventEmitter();
menubarViewChild;
mouseLeaveSubscriber;
constructor(el, renderer, cd, menubarService) {
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.menubarService = menubarService;
}
ngOnInit() {
this.mouseLeaveSubscriber = this.menubarService.mouseLeft$.subscribe(() => {
this.cd.markForCheck();
});
}
onItemClick(event, processedItem) {
this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });
this.itemClick.emit({ originalEvent: event, processedItem, isFocus: true });
}
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);
}
getItemLabelId(processedItem) {
return `${this.menuId}_${processedItem.key}_label`;
}
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
};
}
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);
}
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;
}
onItemMouseLeave() {
this.menubarService.mouseLeaves.next(true);
}
onItemMouseEnter(param) {
if (this.autoDisplay) {
this.menubarService.mouseLeaves.next(false);
const { event, processedItem } = param;
this.itemMouseEnter.emit({ originalEvent: event, processedItem });
}
}
ngOnDestroy() {
this.mouseLeaveSubscriber?.unsubscribe();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarSub, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: MenubarService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: MenubarSub, selector: "p-menubarSub", inputs: { items: "items", itemTemplate: "itemTemplate", root: ["root", "root", booleanAttribute], autoZIndex: ["autoZIndex", "autoZIndex", booleanAttribute], baseZIndex: ["baseZIndex", "baseZIndex", numberAttribute], mobileActive: ["mobileActive", "mobileActive", booleanAttribute], autoDisplay: ["autoDisplay", "autoDisplay", booleanAttribute], menuId: "menuId", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", level: ["level", "level", numberAttribute], focusedItemId: "focusedItemId", activeItemPath: "activeItemPath", submenuIconTemplate: "submenuIconTemplate" }, outputs: { itemClick: "itemClick", itemMouseEnter: "itemMouseEnter", menuFocus: "menuFocus", menuBlur: "menuBlur", menuKeydown: "menuKeydown" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "menubarViewChild", first: true, predicate: ["menubar"], descendants: true, static: true }], ngImport: i0, template: `
<ul
#menubar
[ngClass]="{ 'p-submenu-list': !root, 'p-menubar-root-list': root }"
[attr.data-pc-section]="'menu'"
role="menubar"
(focus)="menuFocus.emit($event)"
(blur)="menuBlur.emit($event)"
[tabindex]="0"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledBy]="ariaLabelledBy"
(keydown)="menuKeydown.emit($event)"
[attr.id]="root ? menuId : null"
[attr.aria-activedescendant]="focusedItemId"
>
<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 class="p-menuitem-content" [attr.data-pc-section]="'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, 'p-disabled': getItemProp(processedItem, 'disabled') }"
[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'" [id]="getItemLabelId(processedItem)">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'" [id]="getItemLabelId(processedItem)"></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)">
<ng-container *ngIf="!submenuIconTemplate">
<AngleDownIcon [styleClass]="'p-submenu-icon'" *ngIf="root" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<AngleRightIcon [styleClass]="'p-submenu-icon'" *ngIf="!root" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
</ng-container>
<ng-template *ngTemplateOutlet="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
class="p-menuitem-icon"
*ngIf="getItemProp(processedItem, 'icon')"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
></span>
<span class="p-menuitem-text" *ngIf="getItemProp(processedItem, 'escape'); else htmlRouteLabel">{{ getItemLabel(processedItem) }}</span>
<ng-template #htmlRouteLabel><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)">
<ng-container *ngIf="!menubar.submenuIconTemplate">
<AngleDownIcon [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" *ngIf="root" />
<AngleRightIcon [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" *ngIf="!root" />
</ng-container>
<ng-template *ngTemplateOutlet="menubar.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, root: root }"></ng-template>
</ng-container>
</div>
<p-menubarSub
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem)"
[itemTemplate]="itemTemplate"
[items]="processedItem.items"
[mobileActive]="mobileActive"
[autoDisplay]="autoDisplay"
[menuId]="menuId"
[activeItemPath]="activeItemPath"
[focusedItemId]="focusedItemId"
[level]="level + 1"
[ariaLabelledBy]="getItemLabelId(processedItem)"
(itemClick)="itemClick.emit($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
>
</p-menubarSub>
</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(() => AngleDownIcon), selector: "AngleDownIcon" }, { kind: "component", type: i0.forwardRef(() => AngleRightIcon), selector: "AngleRightIcon" }, { kind: "component", type: i0.forwardRef(() => MenubarSub), selector: "p-menubarSub", inputs: ["items", "itemTemplate", "root", "autoZIndex", "baseZIndex", "mobileActive", "autoDisplay", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "activeItemPath", "submenuIconTemplate"], outputs: ["itemClick", "itemMouseEnter", "menuFocus", "menuBlur", "menuKeydown"] }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarSub, decorators: [{
type: Component,
args: [{
selector: 'p-menubarSub',
template: `
<ul
#menubar
[ngClass]="{ 'p-submenu-list': !root, 'p-menubar-root-list': root }"
[attr.data-pc-section]="'menu'"
role="menubar"
(focus)="menuFocus.emit($event)"
(blur)="menuBlur.emit($event)"
[tabindex]="0"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledBy]="ariaLabelledBy"
(keydown)="menuKeydown.emit($event)"
[attr.id]="root ? menuId : null"
[attr.aria-activedescendant]="focusedItemId"
>
<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 class="p-menuitem-content" [attr.data-pc-section]="'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, 'p-disabled': getItemProp(processedItem, 'disabled') }"
[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'" [id]="getItemLabelId(processedItem)">
{{ getItemLabel(processedItem) }}
</span>
<ng-template #htmlLabel>
<span class="p-menuitem-text" [innerHTML]="getItemLabel(processedItem)" [attr.data-pc-section]="'label'" [id]="getItemLabelId(processedItem)"></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)">
<ng-container *ngIf="!submenuIconTemplate">
<AngleDownIcon [styleClass]="'p-submenu-icon'" *ngIf="root" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
<AngleRightIcon [styleClass]="'p-submenu-icon'" *ngIf="!root" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" />
</ng-container>
<ng-template *ngTemplateOutlet="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
class="p-menuitem-icon"
*ngIf="getItemProp(processedItem, 'icon')"
[ngClass]="getItemProp(processedItem, 'icon')"
[ngStyle]="getItemProp(processedItem, 'iconStyle')"
[attr.data-pc-section]="'icon'"
[attr.aria-hidden]="true"
[attr.tabindex]="-1"
></span>
<span class="p-menuitem-text" *ngIf="getItemProp(processedItem, 'escape'); else htmlRouteLabel">{{ getItemLabel(processedItem) }}</span>
<ng-template #htmlRouteLabel><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)">
<ng-container *ngIf="!menubar.submenuIconTemplate">
<AngleDownIcon [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" *ngIf="root" />
<AngleRightIcon [styleClass]="'p-submenu-icon'" [attr.data-pc-section]="'submenuicon'" [attr.aria-hidden]="true" *ngIf="!root" />
</ng-container>
<ng-template *ngTemplateOutlet="menubar.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, root: root }"></ng-template>
</ng-container>
</div>
<p-menubarSub
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem)"
[itemTemplate]="itemTemplate"
[items]="processedItem.items"
[mobileActive]="mobileActive"
[autoDisplay]="autoDisplay"
[menuId]="menuId"
[activeItemPath]="activeItemPath"
[focusedItemId]="focusedItemId"
[level]="level + 1"
[ariaLabelledBy]="getItemLabelId(processedItem)"
(itemClick)="itemClick.emit($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
>
</p-menubarSub>
</li>
</ng-template>
</ul>
`,
encapsulation: ViewEncapsulation.None,
host: {
class: 'p-element'
}
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: MenubarService }], propDecorators: { items: [{
type: Input
}], itemTemplate: [{
type: Input
}], root: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoZIndex: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], baseZIndex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], mobileActive: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoDisplay: [{
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
}], submenuIconTemplate: [{
type: Input
}], itemClick: [{
type: Output
}], itemMouseEnter: [{
type: Output
}], menuFocus: [{
type: Output
}], menuBlur: [{
type: Output
}], menuKeydown: [{
type: Output
}], menubarViewChild: [{
type: ViewChild,
args: ['menubar', { static: true }]
}] } });
/**
* Menubar is a horizontal menu component.
* @group Components
*/
export class Menubar {
document;
platformId;
el;
renderer;
cd;
config;
menubarService;
/**
* An array of menuitems.
* @group Props
*/
set model(value) {
this._model = value;
this._processedItems = this.createProcessedItems(this._model || []);
}
get model() {
return this._model;
}
/**
* Inline style of the element.
* @group Props
*/
style;
/**
* Class of the element.
* @group Props
*/
styleClass;
/**
* Whether to automatically manage layering.
* @group Props
*/
autoZIndex = true;
/**
* Base zIndex value to use in layering.
* @group Props
*/
baseZIndex = 0;
/**
* Whether to show a root submenu on mouse over.
* @defaultValue true
* @group Props
*/
autoDisplay = true;
/**
* Whether to hide a root submenu when mouse leaves.
* @group Props
*/
autoHide;
/**
* Delay to hide the root submenu in milliseconds when mouse leaves.
* @group Props
*/
autoHideDelay = 100;
/**
* 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;
/**
* Callback to execute when button is focused.
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onFocus = new EventEmitter();
/**
* Callback to execute when button loses focus.
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onBlur = new EventEmitter();
templates;
menubutton;
rootmenu;
startTemplate;
endTemplate;
menuIconTemplate;
submenuIconTemplate;
itemTemplate;
mobileActive;
outsideClickListener;
resizeListener;
mouseLeaveSubscriber;
dirty = false;
focused = false;
activeItemPath = signal([]);
number = signal(0);
focusedItemInfo = signal({ index: -1, level: 0, parentKey: '', item: null });
searchValue = '';
searchTimeout;
_processedItems;
_model;
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, menubarService) {
this.document = document;
this.platformId = platformId;
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.config = config;
this.menubarService = menubarService;
effect(() => {
const path = this.activeItemPath();
if (ObjectUtils.isNotEmpty(path)) {
this.bindOutsideClickListener();
this.bindResizeListener();
}
else {
this.unbindOutsideClickListener();
this.unbindResizeListener();
}
});
}
ngOnInit() {
this.menubarService.autoHide = this.autoHide;
this.menubarService.autoHideDelay = this.autoHideDelay;
this.mouseLeaveSubscriber = this.menubarService.mouseLeft$.subscribe(() => this.unbindOutsideClickListener());
this.id = this.id || UniqueComponentId();
}
ngAfterContentInit() {
this.templates?.forEach((item) => {
switch (item.getType()) {
case 'start':
this.startTemplate = item.template;
break;
case 'end':
this.endTemplate = item.template;
break;
case 'menuicon':
this.menuIconTemplate = item.template;
break;
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;
}
menuButtonClick(event) {
this.toggle(event);
}
menuButtonKeydown(event) {
(event.code === 'Enter' || event.code === 'Space') && this.menuButtonClick(event);
}
onItemClick(event) {
const { originalEvent, processedItem } = event;
const grouped = this.isProcessedItemGroup(processedItem);
const root = ObjectUtils.isEmpty(processedItem.parent);
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 });
this.dirty = !root;
DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
}
else {
if (grouped) {
this.onItemChange(event);
}
else {
const rootProcessedItem = root ? processedItem : this.activeItemPath().find((p) => p.parentKey === '');
this.hide(originalEvent);
this.changeFocusedItemIndex(originalEvent, rootProcessedItem ? rootProcessedItem.index : -1);
this.mobileActive = false;
DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
}
}
}
onItemMouseEnter(event) {
if (!DomHandler.isTouchDevice()) {
if (!this.mobileActive) {
this.onItemChange(event);
}
}
}
changeFocusedItemIndex(event, index) {
const processedItem = this.findVisibleItem(index);
if (this.focusedItemInfo().index !== index) {
const focusedItemInfo = this.focusedItemInfo();
this.focusedItemInfo.set({ ...focusedItemInfo, item: processedItem.item, index });
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' });
}
}
onItemChange(event) {
const { processedItem, isFocus } = event;
if (ObjectUtils.isEmpty(processedItem))
return;
const { index, key, level, parentKey, items, item } = processedItem;
const grouped = ObjectUtils.isNotEmpty(items);
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== parentKey && p.parentKey !== key);
grouped && activeItemPath.push(processedItem);
this.focusedItemInfo.set({ index, level, parentKey, item });
this.activeItemPath.set(activeItemPath);
grouped && (this.dirty = true);
isFocus && DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
}
toggle(event) {
if (this.mobileActive) {
this.mobileActive = false;
ZIndexUtils.clear(this.rootmenu.el.nativeElement);
this.hide();
}
else {
this.mobileActive = true;
ZIndexUtils.set('menu', this.rootmenu.el.nativeElement, this.config.zIndex.menu);
setTimeout(() => {
this.show();
}, 0);
}
this.cd.markForCheck();
this.bindOutsideClickListener();
event.preventDefault();
}
hide(event, isFocus) {
if (this.mobileActive) {
setTimeout(() => {
DomHandler.focus(this.menubutton.nativeElement);
}, 0);
}
this.activeItemPath.set([]);
this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null });
isFocus && DomHandler.focus(this.rootmenu?.menubarViewChild.nativeElement);
this.dirty = false;
}
show() {
const processedItem = this.findVisibleItem(this.findFirstFocusedItemIndex());
this.focusedItemInfo.set({ index: this.findFirstFocusedItemIndex(), level: 0, parentKey: '', item: processedItem?.item });
DomHandler.focus(this.rootmenu?.menubarViewChild.nativeElement);
}
onMenuFocus(event) {
this.focused = true;
const processedItem = this.findVisibleItem(this.findFirstFocusedItemIndex());
const focusedItemInfo = this.focusedItemInfo().index !== -1 ? this.focusedItemInfo() : { index: this.findFirstFocusedItemIndex(), level: 0, parentKey: '', item: processedItem?.item };
this.focusedItemInfo.set(focusedItemInfo);
this.onFocus.emit(event);
}
onMenuBlur(event) {
this.focused = false;
this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null });
this.searchValue = '';
this.dirty = false;
this.onBlur.emit(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;
}
}
findVisibleItem(index) {
return ObjectUtils.isNotEmpty(this.visibleItems) ? this.visibleItems[index] : null;
}
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));
}
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);
}
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;
}
getProccessedItemLabel(processedItem) {
return processedItem ? this.getItemLabel(processedItem.item) : undefined;
}
getItemLabel(item) {
return this.getItemProp(item, 'label');
}
onArrowDownKey(event) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const root = processedItem ? ObjectUtils.isEmpty(processedItem.parent) : null;
if (root) {
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo.set({ index: -1, parentKey: processedItem.key, item: processedItem.item });
this.onArrowRightKey(event);
}
}
else {
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 parentItem = processedItem ? this.activeItemPath().find((p) => p.key === processedItem.parentKey) : null;
if (parentItem) {
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo.set({ index: -1, parentKey: processedItem.key, item: processedItem.item });
this.onArrowDownKey(event);
}
}
else {
const itemIndex = this.focusedItemInfo().index !== -1 ? this.findNextItemIndex(this.focusedItemInfo().index) : this.findFirstFocusedItemIndex();
this.changeFocusedItemIndex(event, itemIndex);
event.preventDefault();
}
}
onArrowUpKey(event) {
const processedItem = this.visibleItems[this.focusedItemInfo().index];
const root = ObjectUtils.isEmpty(processedItem.parent);
if (root) {
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo.set({ index: -1, parentKey: processedItem.key, item: processedItem.item });
const itemIndex = this.findLastItemIndex();
this.changeFocusedItemIndex(event, itemIndex);
}
}
else {
const parentItem = this.activeItemPath().find((p) => p.key === processedItem.parentKey);
if (this.focusedItemInfo().index === 0) {
this.focusedItemInfo.set({ index: -1, parentKey: parentItem ? parentItem.parentKey : '', item: processedItem.item });
this.searchValue = '';
this.onArrowLeftKey(event);
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== this.focusedItemInfo().parentKey);
this.activeItemPath.set(activeItemPath);
}
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 = processedItem ? this.activeItemPath().find((p) => p.key === processedItem.parentKey) : null;
if (parentItem) {
this.onItemChange({ originalEvent: event, processedItem: parentItem });
const activeItemPath = this.activeItemPath().filter((p) => p.parentKey !== this.focusedItemInfo().parentKey);
this.activeItemPath.set(activeItemPath);
event.preventDefault();
}
else {
const itemIndex = this.focusedItemInfo().index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo().index) : this.findLastFocusedItemIndex();
this.changeFocusedItemIndex(event, itemIndex);
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(event, true);
this.focusedItemInfo().index = this.findFirstFocusedItemIndex();
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();
}
event.preventDefault();
}
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;
}
bindResizeListener() {
if (isPlatformBrowser(this.platformId)) {
if (!this.resizeListener) {
this.resizeListener = this.renderer.listen(this.document.defaultView, 'resize', (event) => {
if (!DomHandler.isTouchDevice()) {
this.hide(event, true);
}
this.mobileActive = false;
});
}
}
}
bindOutsideClickListener() {
if (isPlatformBrowser(this.platformId)) {
if (!this.outsideClickListener) {
this.outsideClickListener = this.renderer.listen(this.document, 'click', (event) => {
const isOutsideContainer = this.rootmenu.el.nativeElement !== event.target && !this.rootmenu.el.nativeElement.contains(event.target);
const isOutsideMenuButton = this.mobileActive && this.menubutton.nativeElement !== event.target && !this.menubutton.nativeElement.contains(event.target);
if (isOutsideContainer) {
isOutsideMenuButton ? (this.mobileActive = false) : this.hide();
}
});
}
}
}
unbindOutsideClickListener() {
if (this.outsideClickListener) {
this.outsideClickListener();
this.outsideClickListener = null;
}
}
unbindResizeListener() {
if (this.resizeListener) {
this.resizeListener();
this.resizeListener = null;
}
}
ngOnDestroy() {
this.mouseLeaveSubscriber?.unsubscribe();
this.unbindOutsideClickListener();
this.unbindResizeListener();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Menubar, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i5.PrimeNGConfig }, { token: MenubarService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: Menubar, selector: "p-menubar", inputs: { model: "model", style: "style", styleClass: "styleClass", autoZIndex: ["autoZIndex", "autoZIndex", booleanAttribute], baseZIndex: ["baseZIndex", "baseZIndex", numberAttribute], autoDisplay: ["autoDisplay", "autoDisplay", booleanAttribute], autoHide: ["autoHide", "autoHide", booleanAttribute], autoHideDelay: ["autoHideDelay", "autoHideDelay", numberAttribute], id: "id", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy" }, outputs: { onFocus: "onFocus", onBlur: "onBlur" }, host: { classAttribute: "p-element" }, providers: [MenubarService], queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "menubutton", first: true, predicate: ["menubutton"], descendants: true }, { propertyName: "rootmenu", first: true, predicate: ["rootmenu"], descendants: true }], ngImport: i0, template: `
<div [ngClass]="{ 'p-menubar p-component': true, 'p-menubar-mobile-active': mobileActive }" [class]="styleClass" [ngStyle]="style" [attr.data-pc-section]="'root'" [attr.data-pc-name]="'menubar'">
<div class="p-menubar-start" *ngIf="startTemplate">
<ng-container *ngTemplateOutlet="startTemplate"></ng-container>
</div>
<a
#menubutton
tabindex="0"
role="button"
[attr.aria-haspopup]="model.length && model.length > 0 ? true : false"
[attr.aria-expanded]="mobileActive"
[attr.aria-controls]="id"
[attr.aria-label]="config.translation.aria.navigation"
[attr.data-pc-section]="'button'"
*ngIf="model && model.length > 0"
class="p-menubar-button"
(click)="menuButtonClick($event)"
(keydown)="menuButtonKeydown($event)"
>
<BarsIcon *ngIf="!menuIconTemplate" />
<ng-template *ngTemplateOutlet="menuIconTemplate"></ng-template>
</a>
<p-menubarSub
#rootmenu
[items]="processedItems"
[itemTemplate]="itemTemplate"
[menuId]="id"
[root]="true"
[baseZIndex]="baseZIndex"
[autoZIndex]="autoZIndex"
[mobileActive]="mobileActive"
[autoDisplay]="autoDisplay"
[ariaLabel]="ariaLabel"
[ariaLabelledBy]="ariaLabelledBy"
[focusedItemId]="focused ? focusedItemId : undefined"
[submenuIconTemplate]="submenuIconTemplate"
[activeItemPath]="activeItemPath()"
(itemClick)="onItemClick($event)"
(menuFocus)="onMenuFocus($event)"
(menuBlur)="onMenuBlur($event)"
(menuKeydown)="onKeyDown($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-menubarSub>
<div class="p-menubar-end" *ngIf="endTemplate; else legacy">
<ng-container *ngTemplateOutlet="endTemplate"></ng-container>
</div>
<ng-template #legacy>
<div class="p-menubar-end">
<ng-content></ng-content>
</div>
</ng-template>
</div>
`, isInline: true, styles: ["@layer primeng{.p-menubar{display:flex;align-items:center}.p-menubar ul{margin:0;padding:0;list-style:none}.p-menubar .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-menubar .p-menuitem-text{line-height:1}.p-menubar .p-menuitem{position:relative}.p-menubar-root-list{display:flex;align-items:center;flex-wrap:wrap}.p-menubar-root-list>li ul{display:none;z-index:1}.p-menubar-root-list>.p-menuitem-active>p-menubarsub>.p-submenu-list{display:block}.p-menubar .p-submenu-list{display:none;position:absolute;z-index:2}.p-menubar .p-submenu-list>.p-menuitem-active>p-menubarsub>.p-submenu-list{display:block;left:100%;top:0}.p-menubar .p-submenu-list .p-menuitem-link .p-submenu-icon:not(svg){margin-left:auto}.p-menubar .p-menubar-root-list .p-icon-wrapper,.p-menubar .p-submenu-list .p-menuitem-link .p-icon-wrapper{margin-left:auto}.p-menubar .p-menubar-custom,.p-menubar .p-menubar-end{margin-left:auto;align-self:center}.p-menubar-button{display:none;cursor:pointer;align-items:center;justify-content:center}}\n"], dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { 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: "component", type: i0.forwardRef(() => BarsIcon), selector: "BarsIcon" }, { kind: "component", type: i0.forwardRef(() => MenubarSub), selector: "p-menubarSub", inputs: ["items", "itemTemplate", "root", "autoZIndex", "baseZIndex", "mobileActive", "autoDisplay", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "activeItemPath", "submenuIconTemplate"], outputs: ["itemClick", "itemMouseEnter", "menuFocus", "menuBlur", "menuKeydown"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Menubar, decorators: [{
type: Component,
args: [{ selector: 'p-menubar', template: `
<div [ngClass]="{ 'p-menubar p-component': true, 'p-menubar-mobile-active': mobileActive }" [class]="styleClass" [ngStyle]="style" [attr.data-pc-section]="'root'" [attr.data-pc-name]="'menubar'">
<div class="p-menubar-start" *ngIf="startTemplate">
<ng-container *ngTemplateOutlet="startTemplate"></ng-container>
</div>
<a
#menubutton
tabindex="0"
role="button"
[attr.aria-haspopup]="model.length && model.length > 0 ? true : false"
[attr.aria-expanded]="mobileActive"
[attr.aria-controls]="id"
[attr.aria-label]="config.translation.aria.navigation"
[attr.data-pc-section]="'button'"
*ngIf="model && model.length > 0"
class="p-menubar-button"
(click)="menuButtonClick($event)"
(keydown)="menuButtonKeydown($event)"
>
<BarsIcon *ngIf="!menuIconTemplate" />
<ng-template *ngTemplateOutlet="menuIconTemplate"></ng-template>
</a>
<p-menubarSub
#rootmenu
[items]="processedItems"
[itemTemplate]="itemTemplate"
[menuId]="id"
[root]="true"
[baseZIndex]="baseZIndex"
[autoZIndex]="autoZIndex"
[mobileActive]="mobileActive"
[autoDisplay]="autoDisplay"
[ariaLabel]="ariaLabel"
[ariaLabelledBy]="ariaLabelledBy"
[focusedItemId]="focused ? focusedItemId : undefined"
[submenuIconTemplate]="submenuIconTemplate"
[activeItemPath]="activeItemPath()"
(itemClick)="onItemClick($event)"
(menuFocus)="onMenuFocus($event)"
(menuBlur)="onMenuBlur($event)"
(menuKeydown)="onKeyDown($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
></p-menubarSub>
<div class="p-menubar-end" *ngIf="endTemplate; else legacy">
<ng-container *ngTemplateOutlet="endTemplate"></ng-container>
</div>
<ng-template #legacy>
<div class="p-menubar-end">
<ng-content></ng-content>
</div>
</ng-template>
</div>
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
class: 'p-element'
}, providers: [MenubarService], styles: ["@layer primeng{.p-menubar{display:flex;align-items:center}.p-menubar ul{margin:0;padding:0;list-style:none}.p-menubar .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-menubar .p-menuitem-text{line-height:1}.p-menubar .p-menuitem{position:relative}.p-menubar-root-list{display:flex;align-items:center;flex-wrap:wrap}.p-menubar-root-list>li ul{display:none;z-index:1}.p-menubar-root-list>.p-menuitem-active>p-menubarsub>.p-submenu-list{display:block}.p-menubar .p-submenu-list{display:none;position:absolute;z-index:2}.p-menubar .p-submenu-list>.p-menuitem-active>p-menubarsub>.p-submenu-list{display:block;left:100%;top:0}.p-menubar .p-submenu-list .p-menuitem-link .p-submenu-icon:not(svg){margin-left:auto}.p-menubar .p-menubar-root-list .p-icon-wrapper,.p-menubar .p-submenu-list .p-menuitem-link .p-icon-wrapper{margin-left:auto}.p-menubar .p-menubar-custom,.p-menubar .p-menubar-end{margin-left:auto;align-self:center}.p-menubar-button{display:none;cursor:pointer;align-items:center;justify-content:center}}\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: MenubarService }], propDecorators: { model: [{
type: Input
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], autoZIndex: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], baseZIndex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], autoDisplay: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoHide: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoHideDelay: [{
type: Input,
args: [{ transform: numberAttribute }]
}], id: [{
type: Input
}], ariaLabel: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], onFocus: [{
type: Output
}], onBlur: [{
type: Output
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}], menubutton: [{
type: ViewChild,
args: ['menubutton']
}], rootmenu: [{
type: ViewChild,
args: ['rootmenu']
}] } });
export class MenubarModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: MenubarModule, declarations: [Menubar, MenubarSub], imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, BarsIcon, AngleDownIcon, AngleRightIcon], exports: [Menubar, RouterModule, TooltipModule, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarModule, imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, BarsIcon, AngleDownIcon, AngleRightIcon, RouterModule, TooltipModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MenubarModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, BarsIcon, AngleDownIcon, AngleRightIcon],
exports: [Menubar, RouterModule, TooltipModule, SharedModule],
declarations: [Menubar, MenubarSub]
}]
}] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVudWJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvY29tcG9uZW50cy9tZW51YmFyL21lbnViYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUM1RSxPQUFPLEVBRUgsdUJBQXVCLEVBRXZCLFNBQVMsRUFDVCxlQUFlLEVBRWYsWUFBWSxFQUNaLE1BQU0sRUFDTixVQUFVLEVBQ1YsS0FBSyxFQUNMLFFBQVEsRUFHUixNQUFNLEVBQ04sV0FBVyxFQUlYLFNBQVMsRUFDVCxpQkFBaUIsRUFDakIsZ0JBQWdCLEVBQ2hCLE1BQU0sRUFDTixlQUFlLEVBQ2YsTUFBTSxFQUNULE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFB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