import * as i1 from '@angular/common'; import { isPlatformBrowser, DOCUMENT, CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { EventEmitter, forwardRef, numberAttribute, booleanAttribute, Component, ViewEncapsulation, Inject, Input, Output, ViewChild, signal, effect, PLATFORM_ID, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core'; import * as i2 from '@angular/router'; import { RouterModule } from '@angular/router'; import * as i5 from 'primeng/api'; import { PrimeTemplate, SharedModule } from 'primeng/api'; import { DomHandler } from 'primeng/dom'; import { AngleDownIcon } from 'primeng/icons/angledown'; import { AngleRightIcon } from 'primeng/icons/angleright'; import * as i3 from 'primeng/ripple'; import { RippleModule } from 'primeng/ripple'; import * as i4 from 'primeng/tooltip'; import { TooltipModule } from 'primeng/tooltip'; import { ObjectUtils, UniqueComponentId } from 'primeng/utils'; class MegaMenuSub { el; megaMenu; id; items; itemTemplate; menuId; ariaLabel; ariaLabelledBy; level = 0; focusedItemId; disabled = false; orientation; activeItem; submenu; tabindex = 0; root = false; itemClick = new EventEmitter(); itemMouseEnter = new EventEmitter(); menuFocus = new EventEmitter(); menuBlur = new EventEmitter(); menuKeydown = new EventEmitter(); menubarViewChild; constructor(el, megaMenu) { this.el = el; this.megaMenu = megaMenu; } 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}`; } getSubListId(processedItem) { return `${this.getItemId(processedItem)}_list`; } getItemClass(processedItem) { return { ...this.getItemProp(processedItem, 'class'), 'p-menuitem': true, 'p-menuitem-active p-highlight': 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 }; } getColumnClass(processedItem) { let length = this.isItemGroup(processedItem) ? processedItem.items.length : 0; let columnClass; switch (length) { case 2: columnClass = 'p-megamenu-col-6'; break; case 3: columnClass = 'p-megamenu-col-4'; break; case 4: columnClass = 'p-megamenu-col-3'; break; case 6: columnClass = 'p-megamenu-col-2'; break; default: columnClass = 'p-megamenu-col-12'; break; } return columnClass; } getSubmenuHeaderClass(processedItem) { return { 'p-megamenu-submenu-header p-submenu-header': true, 'p-disabled': this.isItemDisabled(processedItem), ...this.getItemProp(processedItem, 'class') }; } isSubmenuVisible(submenu) { if (this.submenu && !this.root) { return this.isItemVisible(submenu); } else { return true; } } isItemVisible(processedItem) { return this.getItemProp(processedItem, 'visible') !== false; } isItemActive(processedItem) { return ObjectUtils.isNotEmpty(this.activeItem) ? this.activeItem.key === processedItem.key : false; } 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; } onItemMouseEnter(param) { const { event, processedItem } = param; this.itemMouseEnter.emit({ originalEvent: event, processedItem }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuSub, deps: [{ token: i0.ElementRef }, { token: forwardRef(() => MegaMenu) }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: MegaMenuSub, selector: "p-megaMenuSub", inputs: { id: "id", items: "items", itemTemplate: "itemTemplate", menuId: "menuId", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", level: ["level", "level", numberAttribute], focusedItemId: "focusedItemId", disabled: ["disabled", "disabled", booleanAttribute], orientation: "orientation", activeItem: "activeItem", submenu: "submenu", tabindex: ["tabindex", "tabindex", numberAttribute], root: ["root", "root", booleanAttribute] }, 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: ` `, 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(() => MegaMenuSub), selector: "p-megaMenuSub", inputs: ["id", "items", "itemTemplate", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "disabled", "orientation", "activeItem", "submenu", "tabindex", "root"], outputs: ["itemClick", "itemMouseEnter", "menuFocus", "menuBlur", "menuKeydown"] }], encapsulation: i0.ViewEncapsulation.None }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuSub, decorators: [{ type: Component, args: [{ selector: 'p-megaMenuSub', template: ` `, encapsulation: ViewEncapsulation.None, host: { class: 'p-element' } }] }], ctorParameters: () => [{ type: i0.ElementRef }, { type: MegaMenu, decorators: [{ type: Inject, args: [forwardRef(() => MegaMenu)] }] }], propDecorators: { id: [{ type: Input }], items: [{ type: Input }], itemTemplate: [{ type: Input }], menuId: [{ type: Input }], ariaLabel: [{ type: Input }], ariaLabelledBy: [{ type: Input }], level: [{ type: Input, args: [{ transform: numberAttribute }] }], focusedItemId: [{ type: Input }], disabled: [{ type: Input, args: [{ transform: booleanAttribute }] }], orientation: [{ type: Input }], activeItem: [{ type: Input }], submenu: [{ type: Input }], tabindex: [{ type: Input, args: [{ transform: numberAttribute }] }], root: [{ type: Input, args: [{ transform: booleanAttribute }] }], itemClick: [{ type: Output }], itemMouseEnter: [{ type: Output }], menuFocus: [{ type: Output }], menuBlur: [{ type: Output }], menuKeydown: [{ type: Output }], menubarViewChild: [{ type: ViewChild, args: ['menubar', { static: true }] }] } }); /** * MegaMenu is navigation component that displays submenus together. * @group Components */ class MegaMenu { document; platformId; el; renderer; config; cd; /** * 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; /** * Defines the orientation. * @group Props */ orientation = 'horizontal'; /** * 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; /** * When present, it specifies that the component should be disabled. * @group Props */ disabled = false; /** * Index of the element in tabbing order. * @group Props */ tabindex = 0; templates; menubutton; rootmenu; startTemplate; endTemplate; menuIconTemplate; submenuIconTemplate; itemTemplate; outsideClickListener; resizeListener; dirty = false; focused = false; activeItem = signal(null); focusedItemInfo = signal({ index: -1, level: 0, parentKey: '', item: null }); searchValue = ''; searchTimeout; _processedItems; _model; get visibleItems() { const processedItem = ObjectUtils.isNotEmpty(this.activeItem()) ? this.activeItem() : null; return processedItem ? processedItem.items.reduce((items, col) => { col.forEach((submenu) => { submenu.items.forEach((a) => { items.push(a); }); }); return 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 : ObjectUtils.isNotEmpty(focusedItem.key) ? `${this.id}_${focusedItem.key}` : null; } constructor(document, platformId, el, renderer, config, cd) { this.document = document; this.platformId = platformId; this.el = el; this.renderer = renderer; this.config = config; this.cd = cd; effect(() => { const activeItem = this.activeItem(); if (ObjectUtils.isNotEmpty(activeItem)) { this.bindOutsideClickListener(); this.bindResizeListener(); } else { this.unbindOutsideClickListener(); this.unbindResizeListener(); } }); } ngOnInit() { 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 = '', columnIndex) { const processedItems = []; items && items.forEach((item, index) => { const key = (parentKey !== '' ? parentKey + '_' : '') + (columnIndex !== undefined ? columnIndex + '_' : '') + index; const newItem = { item, index, level, key, parent, parentKey, columnIndex: columnIndex !== undefined ? columnIndex : parent.columnIndex !== undefined ? parent.columnIndex : index }; newItem['items'] = level === 0 && item.items && item.items.length > 0 ? item.items.map((_items, _index) => this.createProcessedItems(_items, level + 1, newItem, key, _index)) : this.createProcessedItems(item.items, level + 1, newItem, key); processedItems.push(newItem); }); return processedItems; } getItemProp(item, name) { return item ? ObjectUtils.getItemValue(item[name]) : undefined; } 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, parentKey, item } = processedItem; this.activeItem.set(null); this.focusedItemInfo.set({ index, key, parentKey, item }); this.dirty = !root; DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement); } else { if (grouped) { this.onItemChange(event); } else { const rootProcessedItem = root ? processedItem : this.activeItem(); this.hide(originalEvent); this.changeFocusedItemInfo(originalEvent, rootProcessedItem ? rootProcessedItem.index : -1); DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement); } } } onItemMouseEnter(event) { if (!DomHandler.isTouchDevice()) { this.onItemChange(event); } } 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, parentKey, items, item } = processedItem; const grouped = ObjectUtils.isNotEmpty(items); if (grouped) { this.activeItem.set(processedItem); } this.focusedItemInfo.set({ index, key, parentKey, item }); grouped && (this.dirty = true); isFocus && DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement); } hide(event, isFocus) { this.activeItem.set(null); this.focusedItemInfo.set({ index: -1, key: '', parentKey: '', item: null }); isFocus && DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement); this.dirty = false; } onMenuFocus(event) { this.focused = true; if (this.focusedItemInfo().index === -1) { const index = this.findFirstFocusedItemIndex(); const processedItem = this.findVisibleItem(index); this.focusedItemInfo.set({ index, key: processedItem.key, parentKey: processedItem.parentKey, item: processedItem.item }); } } onMenuBlur(event) { this.focused = false; this.focusedItemInfo.set({ index: -1, level: 0, parentKey: '', item: null }); this.searchValue = ''; this.dirty = false; } 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; } } 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 ObjectUtils.isNotEmpty(this.activeItem()) ? this.activeItem().key === processedItem.key : false; } 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.changeFocusedItemInfo(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'); } changeFocusedItemInfo(event, index) { const processedItem = this.findVisibleItem(index); if (ObjectUtils.isNotEmpty(processedItem)) { const { key, parentKey, item } = processedItem; this.focusedItemInfo.set({ index, key: key ? key : '', parentKey, item }); } this.scrollInView(); } onArrowDownKey(event) { if (this.orientation === 'horizontal') { if (ObjectUtils.isNotEmpty(this.activeItem()) && this.activeItem().key === this.focusedItemInfo().key) { const { key, item } = this.activeItem(); this.focusedItemInfo.set({ index: -1, key: '', parentKey: key, item }); } else { const processedItem = this.findVisibleItem(this.focusedItemInfo().index); const grouped = this.isProccessedItemGroup(processedItem); if (grouped) { const { parentKey, key, item } = processedItem; this.onItemChange({ originalEvent: event, processedItem }); this.focusedItemInfo.set({ index: -1, key: key, parentKey: parentKey, item: item }); this.searchValue = ''; } } } const itemIndex = this.focusedItemInfo().index !== -1 ? this.findNextItemIndex(this.focusedItemInfo().index) : this.findFirstFocusedItemIndex(); this.changeFocusedItemInfo(event, itemIndex); event.preventDefault(); } onArrowRightKey(event) { const processedItem = this.findVisibleItem(this.focusedItemInfo().index); const grouped = this.isProccessedItemGroup(processedItem); if (grouped) { if (this.orientation === 'vertical') { if (ObjectUtils.isNotEmpty(this.activeItem()) && this.activeItem().key === processedItem.key) { this.focusedItemInfo.set({ index: -1, key: '', parentKey: this.activeItem().key, item: processedItem.item }); } else { const processedItem = this.findVisibleItem(this.focusedItemInfo().index); const grouped = this.isProccessedItemGroup(processedItem); if (grouped) { this.onItemChange({ originalEvent: event, processedItem }); this.focusedItemInfo.set({ index: -1, key: processedItem.key, parentKey: processedItem.parentKey, item: processedItem.item }); this.searchValue = ''; } } } const itemIndex = this.focusedItemInfo().index !== -1 ? this.findNextItemIndex(this.focusedItemInfo().index) : this.findFirstFocusedItemIndex(); this.changeFocusedItemInfo(event, itemIndex); } else { const columnIndex = processedItem.columnIndex + 1; const itemIndex = this.visibleItems.findIndex((item) => item.columnIndex === columnIndex); itemIndex !== -1 && this.changeFocusedItemInfo(event, itemIndex); } event.preventDefault(); } onArrowUpKey(event) { if (event.altKey && this.orientation === 'horizontal') { if (this.focusedItemInfo().index !== -1) { const processedItem = this.findVisibleItem(this.focusedItemInfo().index); const grouped = this.isProccessedItemGroup(processedItem); if (!grouped && ObjectUtils.isNotEmpty(this.activeItem)) { if (this.focusedItemInfo().index === 0) { this.focusedItemInfo.set({ index: this.activeItem().index, key: this.activeItem().key, parentKey: this.activeItem().parentKey, item: processedItem.item }); this.activeItem.set(null); } else { this.changeFocusedItemInfo(event, this.findFirstItemIndex()); } } } event.preventDefault(); } else { const itemIndex = this.focusedItemInfo().index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo().index) : this.findLastFocusedItemIndex(); this.changeFocusedItemInfo(event, itemIndex); event.preventDefault(); } } onArrowLeftKey(event) { const processedItem = this.findVisibleItem(this.focusedItemInfo().index); const grouped = this.isProccessedItemGroup(processedItem); if (grouped) { if (this.orientation === 'horizontal') { const itemIndex = this.focusedItemInfo().index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo().index) : this.findLastFocusedItemIndex(); this.changeFocusedItemInfo(event, itemIndex); } } else { if (this.orientation === 'vertical' && ObjectUtils.isNotEmpty(this.activeItem())) { if (processedItem.columnIndex === 0) { this.focusedItemInfo.set({ index: this.activeItem().index, key: this.activeItem().key, parentKey: this.activeItem().parentKey, item: processedItem.item }); this.activeItem.set(null); } } const columnIndex = processedItem.columnIndex - 1; const itemIndex = this.visibleItems.findIndex((item) => item.columnIndex === columnIndex); itemIndex !== -1 && this.changeFocusedItemInfo(event, itemIndex); } event.preventDefault(); } onHomeKey(event) { this.changeFocusedItemInfo(event, this.findFirstItemIndex()); event.preventDefault(); } onEndKey(event) { this.changeFocusedItemInfo(event, this.findLastItemIndex()); event.preventDefault(); } onSpaceKey(event) { this.onEnterKey(event); } onEscapeKey(event) { if (ObjectUtils.isNotEmpty(this.activeItem())) { this.focusedItemInfo.set({ index: this.activeItem().index, key: this.activeItem().key, item: this.activeItem().item }); this.activeItem.set(null); } event.preventDefault(); } onTabKey(event) { if (this.focusedItemInfo().index !== -1) { const processedItem = this.findVisibleItem(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); !grouped && this.changeFocusedItemInfo(event, this.findFirstFocusedItemIndex()); } event.preventDefault(); } 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; } bindResizeListener() { if (isPlatformBrowser(this.platformId)) { if (!this.resizeListener) { this.resizeListener = this.renderer.listen(this.document.defaultView, 'resize', (event) => { this.hide(event, true); }); } } } 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); if (isOutsideContainer) { this.hide(); } }); } } } unbindOutsideClickListener() { if (this.outsideClickListener) { this.outsideClickListener(); this.outsideClickListener = null; } } unbindResizeListener() { if (this.resizeListener) { this.resizeListener(); this.resizeListener = null; } } ngOnDestroy() { this.unbindOutsideClickListener(); this.unbindResizeListener(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenu, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i5.PrimeNGConfig }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: MegaMenu, selector: "p-megaMenu", inputs: { model: "model", style: "style", styleClass: "styleClass", orientation: "orientation", id: "id", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", disabled: ["disabled", "disabled", booleanAttribute], tabindex: ["tabindex", "tabindex", numberAttribute] }, host: { classAttribute: "p-element" }, 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: `
`, isInline: true, styles: ["@layer primeng{.p-megamenu-root-list{margin:0;padding:0;list-style:none}.p-megamenu-root-list>.p-menuitem{position:relative}.p-megamenu .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-megamenu .p-menuitem-text{line-height:1}.p-megamenu-panel{display:none;position:absolute;width:auto;z-index:1}.p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{display:block}.p-megamenu-submenu{margin:0;padding:0;list-style:none}.p-megamenu-horizontal{align-items:center}.p-megamenu-horizontal .p-megamenu-root-list{display:flex;align-items:center;flex-wrap:wrap}.p-megamenu-horizontal .p-megamenu-end{margin-left:auto;align-self:center}.p-megamenu-vertical .p-megamenu-root-list{flex-direction:column}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{left:100%;top:0}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem>.p-menuitem-content>.p-menuitem-link>.p-submenu-icon:not(svg){margin-left:auto}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem>.p-menuitem-content>.p-menuitem-link>.p-icon-wrapper{margin-left:auto}.p-megamenu-grid{display:flex}.p-megamenu-col-2,.p-megamenu-col-3,.p-megamenu-col-4,.p-megamenu-col-6,.p-megamenu-col-12{flex:0 0 auto;padding:.5rem}.p-megamenu-col-2{width:16.6667%}.p-megamenu-col-3{width:25%}.p-megamenu-col-4{width:33.3333%}.p-megamenu-col-6{width:50%}.p-megamenu-col-12{width:100%}}\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.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: MegaMenuSub, selector: "p-megaMenuSub", inputs: ["id", "items", "itemTemplate", "menuId", "ariaLabel", "ariaLabelledBy", "level", "focusedItemId", "disabled", "orientation", "activeItem", "submenu", "tabindex", "root"], 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: MegaMenu, decorators: [{ type: Component, args: [{ selector: 'p-megaMenu', template: `
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { class: 'p-element' }, styles: ["@layer primeng{.p-megamenu-root-list{margin:0;padding:0;list-style:none}.p-megamenu-root-list>.p-menuitem{position:relative}.p-megamenu .p-menuitem-link{cursor:pointer;display:flex;align-items:center;text-decoration:none;overflow:hidden;position:relative}.p-megamenu .p-menuitem-text{line-height:1}.p-megamenu-panel{display:none;position:absolute;width:auto;z-index:1}.p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{display:block}.p-megamenu-submenu{margin:0;padding:0;list-style:none}.p-megamenu-horizontal{align-items:center}.p-megamenu-horizontal .p-megamenu-root-list{display:flex;align-items:center;flex-wrap:wrap}.p-megamenu-horizontal .p-megamenu-end{margin-left:auto;align-self:center}.p-megamenu-vertical .p-megamenu-root-list{flex-direction:column}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{left:100%;top:0}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem>.p-menuitem-content>.p-menuitem-link>.p-submenu-icon:not(svg){margin-left:auto}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem>.p-menuitem-content>.p-menuitem-link>.p-icon-wrapper{margin-left:auto}.p-megamenu-grid{display:flex}.p-megamenu-col-2,.p-megamenu-col-3,.p-megamenu-col-4,.p-megamenu-col-6,.p-megamenu-col-12{flex:0 0 auto;padding:.5rem}.p-megamenu-col-2{width:16.6667%}.p-megamenu-col-3{width:25%}.p-megamenu-col-4{width:33.3333%}.p-megamenu-col-6{width:50%}.p-megamenu-col-12{width:100%}}\n"] }] }], ctorParameters: () => [{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT] }] }, { type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID] }] }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i5.PrimeNGConfig }, { type: i0.ChangeDetectorRef }], propDecorators: { model: [{ type: Input }], style: [{ type: Input }], styleClass: [{ type: Input }], orientation: [{ type: Input }], id: [{ type: Input }], ariaLabel: [{ type: Input }], ariaLabelledBy: [{ type: Input }], disabled: [{ type: Input, args: [{ transform: booleanAttribute }] }], tabindex: [{ type: Input, args: [{ transform: numberAttribute }] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }], menubutton: [{ type: ViewChild, args: ['menubutton'] }], rootmenu: [{ type: ViewChild, args: ['rootmenu'] }] } }); class MegaMenuModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuModule, declarations: [MegaMenu, MegaMenuSub], imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, AngleDownIcon, AngleRightIcon], exports: [MegaMenu, RouterModule, TooltipModule, SharedModule] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuModule, imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, AngleDownIcon, AngleRightIcon, RouterModule, TooltipModule, SharedModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MegaMenuModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, AngleDownIcon, AngleRightIcon], exports: [MegaMenu, RouterModule, TooltipModule, SharedModule], declarations: [MegaMenu, MegaMenuSub] }] }] }); /** * Generated bundle index. Do not edit. */ export { MegaMenu, MegaMenuModule, MegaMenuSub }; //# sourceMappingURL=primeng-megamenu.mjs.map