primevue-mirror/components/lib/megamenu/MegaMenu.vue

735 lines
25 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2022-12-08 11:04:25 +00:00
<div :ref="containerRef" :id="id" :class="containerClass">
2022-09-14 11:26:01 +00:00
<div v-if="$slots.start" class="p-megamenu-start">
2022-09-06 12:03:37 +00:00
<slot name="start"></slot>
</div>
2022-12-08 11:04:25 +00:00
<MegaMenuSub
:ref="menubarRef"
:id="id + '_list'"
class="p-megamenu-root-list"
:tabindex="!disabled ? tabindex : -1"
role="menubar"
:aria-label="ariaLabel"
:aria-labelledby="ariaLabelledby"
:aria-disabled="disabled || undefined"
:aria-orientation="orientation"
:aria-activedescendant="focused ? focusedItemId : undefined"
:menuId="id"
:focusedItemId="focused ? focusedItemId : undefined"
:items="processedItems"
:horizontal="horizontal"
:template="$slots"
2022-12-08 11:04:25 +00:00
:activeItem="activeItem"
:exact="exact"
:level="0"
@focus="onFocus"
@blur="onBlur"
@keydown="onKeyDown"
@item-click="onItemClick"
@item-mouseenter="onItemMouseEnter"
/>
2022-09-14 11:26:01 +00:00
<div v-if="$slots.end" class="p-megamenu-end">
2022-09-06 12:03:37 +00:00
<slot name="end"></slot>
</div>
</div>
</template>
<script>
2022-12-08 11:04:25 +00:00
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
import MegaMenuSub from './MegaMenuSub.vue';
2022-09-06 12:03:37 +00:00
export default {
name: 'MegaMenu',
2022-12-08 11:04:25 +00:00
emits: ['focus', 'blur'],
2022-09-06 12:03:37 +00:00
props: {
2022-09-14 11:26:01 +00:00
model: {
2022-09-06 12:03:37 +00:00
type: Array,
default: null
},
orientation: {
type: String,
default: 'horizontal'
},
exact: {
type: Boolean,
default: true
2022-12-08 11:04:25 +00:00
},
disabled: {
type: Boolean,
default: false
},
tabindex: {
type: Number,
default: 0
},
'aria-labelledby': {
type: String,
default: null
},
'aria-label': {
type: String,
default: null
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
outsideClickListener: null,
resizeListener: null,
container: null,
menubar: null,
searchTimeout: null,
searchValue: null,
2022-09-06 12:03:37 +00:00
data() {
return {
id: this.$attrs.id,
2022-12-08 11:04:25 +00:00
focused: false,
focusedItemInfo: { index: -1, key: '', parentKey: '' },
activeItem: null,
dirty: false
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
watch: {
'$attrs.id': function (newValue) {
this.id = newValue || UniqueComponentId();
},
2022-12-08 11:04:25 +00:00
activeItem(newItem) {
if (ObjectUtils.isNotEmpty(newItem)) {
this.bindOutsideClickListener();
this.bindResizeListener();
} else {
this.unbindOutsideClickListener();
this.unbindResizeListener();
}
}
},
mounted() {
this.id = this.id || UniqueComponentId();
},
2022-09-06 12:03:37 +00:00
beforeUnmount() {
2022-12-08 11:04:25 +00:00
this.unbindOutsideClickListener();
this.unbindResizeListener();
2022-09-06 12:03:37 +00:00
},
methods: {
2022-12-08 11:04:25 +00:00
getItemProp(item, name) {
return item ? ObjectUtils.getItemValue(item[name]) : undefined;
},
getItemLabel(item) {
return this.getItemProp(item, 'label');
},
isItemDisabled(item) {
return this.getItemProp(item, 'disabled');
},
isItemGroup(item) {
return ObjectUtils.isNotEmpty(this.getItemProp(item, 'items'));
},
isItemSeparator(item) {
return this.getItemProp(item, 'separator');
},
getProccessedItemLabel(processedItem) {
return processedItem ? this.getItemLabel(processedItem.item) : undefined;
},
isProccessedItemGroup(processedItem) {
return processedItem && ObjectUtils.isNotEmpty(processedItem.items);
},
hide(event, isFocus) {
2022-09-06 12:03:37 +00:00
this.activeItem = null;
2022-12-08 11:04:25 +00:00
this.focusedItemInfo = { index: -1, key: '', parentKey: '' };
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
isFocus && DomHandler.focus(this.menubar);
this.dirty = false;
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onFocus(event) {
this.focused = true;
2022-09-14 11:26:01 +00:00
2022-12-08 11:04:25 +00:00
if (this.focusedItemInfo.index === -1) {
const index = this.findFirstFocusedItemIndex();
const processedItem = this.findVisibleItem(index);
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
this.focusedItemInfo = { index, key: processedItem.key, parentKey: processedItem.parentKey };
2022-09-06 12:03:37 +00:00
}
2022-12-08 11:04:25 +00:00
this.$emit('focus', event);
},
onBlur(event) {
this.focused = false;
this.focusedItemInfo = { index: -1, key: '', parentKey: '' };
this.searchValue = '';
this.dirty = false;
this.$emit('blur', event);
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onKeyDown(event) {
if (this.disabled) {
2022-09-06 12:03:37 +00:00
event.preventDefault();
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
return;
}
2022-12-08 11:04:25 +00:00
const metaKey = event.metaKey || event.ctrlKey;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'ArrowUp':
this.onArrowUpKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'ArrowLeft':
this.onArrowLeftKey(event);
break;
case 'ArrowRight':
this.onArrowRightKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'Home':
this.onHomeKey(event);
2022-09-14 11:26:01 +00:00
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'End':
this.onEndKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'Space':
this.onSpaceKey(event);
2022-09-14 11:26:01 +00:00
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'Enter':
this.onEnterKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'Escape':
this.onEscapeKey(event);
2022-09-14 11:26:01 +00:00
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'Tab':
this.onTabKey(event);
break;
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
case 'PageDown':
case 'PageUp':
case 'Backspace':
case 'ShiftLeft':
case 'ShiftRight':
//NOOP
2022-09-14 11:26:01 +00:00
break;
2022-09-06 12:03:37 +00:00
default:
2022-12-08 11:04:25 +00:00
if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
this.searchItems(event, event.key);
}
2022-09-14 11:26:01 +00:00
break;
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
onItemChange(event) {
const { processedItem, isFocus } = event;
if (ObjectUtils.isEmpty(processedItem)) return;
const { index, key, parentKey, items } = processedItem;
const grouped = ObjectUtils.isNotEmpty(items);
grouped && (this.activeItem = processedItem);
this.focusedItemInfo = { index, key, parentKey };
grouped && (this.dirty = true);
isFocus && DomHandler.focus(this.menubar);
},
onItemClick(event) {
const { originalEvent, processedItem } = event;
const grouped = this.isProccessedItemGroup(processedItem);
const root = ObjectUtils.isEmpty(processedItem.parent);
const selected = this.isSelected(processedItem);
if (selected) {
const { index, key, parentKey } = processedItem;
this.activeItem = null;
this.focusedItemInfo = { index, key, parentKey };
this.dirty = !root;
DomHandler.focus(this.menubar);
} 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.menubar);
}
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
onItemMouseEnter(event) {
if (this.dirty) {
this.onItemChange(event);
}
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onArrowDownKey(event) {
if (this.horizontal) {
if (ObjectUtils.isNotEmpty(this.activeItem) && this.activeItem.key === this.focusedItemInfo.key) {
this.focusedItemInfo = { index: -1, key: '', parentKey: this.activeItem.key };
} else {
const processedItem = this.findVisibleItem(this.focusedItemInfo.index);
const grouped = this.isProccessedItemGroup(processedItem);
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo = { index: -1, key: processedItem.key, parentKey: processedItem.parentKey };
this.searchValue = '';
}
}
}
const itemIndex = this.focusedItemInfo.index !== -1 ? this.findNextItemIndex(this.focusedItemInfo.index) : this.findFirstFocusedItemIndex();
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
this.changeFocusedItemInfo(event, itemIndex);
event.preventDefault();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onArrowUpKey(event) {
if (event.altKey && this.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 = { index: this.activeItem.index, key: this.activeItem.key, parentKey: this.activeItem.parentKey };
this.activeItem = null;
} else {
this.changeFocusedItemInfo(event, this.findFirstItemIndex());
}
}
}
2022-09-14 11:26:01 +00:00
2022-12-08 11:04:25 +00:00
event.preventDefault();
} else {
const itemIndex = this.focusedItemInfo.index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo.index) : this.findLastFocusedItemIndex();
this.changeFocusedItemInfo(event, itemIndex);
event.preventDefault();
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
onArrowLeftKey(event) {
const processedItem = this.findVisibleItem(this.focusedItemInfo.index);
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
if (this.horizontal) {
const itemIndex = this.focusedItemInfo.index !== -1 ? this.findPrevItemIndex(this.focusedItemInfo.index) : this.findLastFocusedItemIndex();
this.changeFocusedItemInfo(event, itemIndex);
}
} else {
if (this.vertical && ObjectUtils.isNotEmpty(this.activeItem)) {
if (processedItem.columnIndex === 0) {
this.focusedItemInfo = { index: this.activeItem.index, key: this.activeItem.key, parentKey: this.activeItem.parentKey };
this.activeItem = null;
}
}
const columnIndex = processedItem.columnIndex - 1;
const itemIndex = this.visibleItems.findIndex((item) => item.columnIndex === columnIndex);
2022-09-14 11:26:01 +00:00
2022-12-08 11:04:25 +00:00
itemIndex !== -1 && this.changeFocusedItemInfo(event, itemIndex);
2022-09-06 12:03:37 +00:00
}
2022-12-08 11:04:25 +00:00
event.preventDefault();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onArrowRightKey(event) {
const processedItem = this.findVisibleItem(this.focusedItemInfo.index);
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
if (this.vertical) {
if (ObjectUtils.isNotEmpty(this.activeItem) && this.activeItem.key === processedItem.key) {
this.focusedItemInfo = { index: -1, key: '', parentKey: this.activeItem.key };
} else {
const processedItem = this.findVisibleItem(this.focusedItemInfo.index);
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
this.onItemChange({ originalEvent: event, processedItem });
this.focusedItemInfo = { index: -1, key: processedItem.key, parentKey: processedItem.parentKey };
this.searchValue = '';
}
}
2022-09-14 11:26:01 +00:00
}
2022-12-08 11:04:25 +00:00
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();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onHomeKey(event) {
this.changeFocusedItemInfo(event, this.findFirstItemIndex());
event.preventDefault();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
onEndKey(event) {
this.changeFocusedItemInfo(event, this.findLastItemIndex());
event.preventDefault();
},
onEnterKey(event) {
if (this.focusedItemInfo.index !== -1) {
const element = DomHandler.findSingle(this.menubar, `li[id="${`${this.focusedItemId}`}"]`);
const anchorElement = element && DomHandler.findSingle(element, '.p-menuitem-link');
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
anchorElement ? anchorElement.click() : element && element.click();
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
const processedItem = this.visibleItems[this.focusedItemInfo.index];
const grouped = this.isProccessedItemGroup(processedItem);
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
!grouped && this.changeFocusedItemInfo(event, this.findFirstFocusedItemIndex());
}
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
event.preventDefault();
},
onSpaceKey(event) {
this.onEnterKey(event);
},
onEscapeKey(event) {
if (ObjectUtils.isNotEmpty(this.activeItem)) {
this.focusedItemInfo = { index: this.activeItem.index, key: this.activeItem.key };
this.activeItem = null;
2022-09-06 12:03:37 +00:00
}
2022-12-08 11:04:25 +00:00
event.preventDefault();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
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();
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
bindOutsideClickListener() {
if (!this.outsideClickListener) {
this.outsideClickListener = (event) => {
const isOutsideContainer = this.container && !this.container.contains(event.target);
const isOutsideTarget = this.popup ? !(this.target && (this.target === event.target || this.target.contains(event.target))) : true;
if (isOutsideContainer && isOutsideTarget) {
this.hide();
}
};
document.addEventListener('click', this.outsideClickListener);
}
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
unbindOutsideClickListener() {
if (this.outsideClickListener) {
document.removeEventListener('click', this.outsideClickListener);
this.outsideClickListener = null;
}
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
bindResizeListener() {
if (!this.resizeListener) {
this.resizeListener = (event) => {
if (!DomHandler.isTouchDevice()) {
this.hide(event, true);
2022-09-06 12:03:37 +00:00
}
};
2022-12-08 11:04:25 +00:00
window.addEventListener('resize', this.resizeListener);
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
unbindResizeListener() {
if (this.resizeListener) {
window.removeEventListener('resize', this.resizeListener);
this.resizeListener = null;
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
isItemMatched(processedItem) {
return this.isValidItem(processedItem) && this.getProccessedItemLabel(processedItem).toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase());
},
isValidItem(processedItem) {
return !!processedItem && !this.isItemDisabled(processedItem.item) && !this.isItemSeparator(processedItem.item);
},
isValidSelectedItem(processedItem) {
return this.isValidItem(processedItem) && this.isSelected(processedItem);
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
isSelected(processedItem) {
return ObjectUtils.isNotEmpty(this.activeItem) ? this.activeItem.key === processedItem.key : false;
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
findFirstItemIndex() {
return this.visibleItems.findIndex((processedItem) => this.isValidItem(processedItem));
},
findLastItemIndex() {
return ObjectUtils.findLastIndex(this.visibleItems, (processedItem) => this.isValidItem(processedItem));
},
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;
},
findPrevItemIndex(index) {
const matchedItemIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleItems.slice(0, index), (processedItem) => this.isValidItem(processedItem)) : -1;
return matchedItemIndex > -1 ? matchedItemIndex : index;
},
findSelectedItemIndex() {
return this.visibleItems.findIndex((processedItem) => this.isValidSelectedItem(processedItem));
},
findFirstFocusedItemIndex() {
const selectedIndex = this.findSelectedItemIndex();
return selectedIndex < 0 ? this.findFirstItemIndex() : selectedIndex;
},
findLastFocusedItemIndex() {
const selectedIndex = this.findSelectedItemIndex();
return selectedIndex < 0 ? this.findLastItemIndex() : selectedIndex;
},
findVisibleItem(index) {
return ObjectUtils.isNotEmpty(this.visibleItems) ? this.visibleItems[index] : null;
},
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;
},
changeFocusedItemInfo(event, index) {
const processedItem = this.findVisibleItem(index);
this.focusedItemInfo.index = index;
this.focusedItemInfo.key = ObjectUtils.isNotEmpty(processedItem) ? processedItem.key : '';
this.scrollInView();
},
scrollInView(index = -1) {
const id = index !== -1 ? `${this.id}_${index}` : this.focusedItemId;
const element = DomHandler.findSingle(this.menubar, `li[id="${id}"]`);
if (element) {
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'start' });
}
},
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;
},
containerRef(el) {
this.container = el;
},
menubarRef(el) {
this.menubar = el ? el.$el : undefined;
2022-09-06 12:03:37 +00:00
}
},
computed: {
containerClass() {
2022-09-14 11:26:01 +00:00
return [
'p-megamenu p-component',
{
'p-megamenu-horizontal': this.horizontal,
'p-megamenu-vertical': this.vertical
}
];
2022-09-06 12:03:37 +00:00
},
2022-12-08 11:04:25 +00:00
processedItems() {
return this.createProcessedItems(this.model || []);
},
visibleItems() {
const processedItem = ObjectUtils.isNotEmpty(this.activeItem) ? this.activeItem : null;
return processedItem && processedItem.key === this.focusedItemInfo.parentKey
? processedItem.items.reduce((items, col) => {
col.forEach((submenu) => {
submenu.items.forEach((a) => {
items.push(a);
});
});
return items;
}, [])
: this.processedItems;
},
2022-09-06 12:03:37 +00:00
horizontal() {
return this.orientation === 'horizontal';
},
vertical() {
return this.orientation === 'vertical';
2022-12-08 11:04:25 +00:00
},
focusedItemId() {
return ObjectUtils.isNotEmpty(this.focusedItemInfo.key) ? `${this.id}_${this.focusedItemInfo.key}` : null;
2022-09-06 12:03:37 +00:00
}
},
2022-12-08 11:04:25 +00:00
components: {
MegaMenuSub: MegaMenuSub
2022-09-06 12:03:37 +00:00
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>
<style>
.p-megamenu {
display: flex;
}
2022-09-06 12:03:37 +00:00
.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;
}
/* Horizontal */
.p-megamenu-horizontal {
align-items: center;
}
2022-09-06 12:03:37 +00:00
.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;
}
2022-09-06 12:03:37 +00:00
/* Vertical */
.p-megamenu-vertical {
flex-direction: column;
}
2022-09-06 12:03:37 +00:00
.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;
}
2022-12-08 11:04:25 +00:00
.p-megamenu-vertical .p-megamenu-root-list > .p-menuitem > .p-menuitem-content > .p-menuitem-link > .p-submenu-icon {
2022-09-06 12:03:37 +00:00
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: 0.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%;
}
</style>