parent
cbb5faf1ea
commit
181732c1c8
|
@ -30,7 +30,11 @@ const MegaMenuSlots = [
|
|||
},
|
||||
{
|
||||
name: 'item',
|
||||
description: 'Template of a menuitem.'
|
||||
description: 'Custom item template.'
|
||||
},
|
||||
{
|
||||
name: 'submenuicon',
|
||||
description: 'Custom submenu icon template.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -70,6 +70,15 @@ export interface MegaMenuSlots {
|
|||
*/
|
||||
item: MenuItem;
|
||||
}): VNode[];
|
||||
/**
|
||||
* Custom submenu icon template.
|
||||
*/
|
||||
submenuicon(scope: {
|
||||
/**
|
||||
* Whether item is active
|
||||
*/
|
||||
active: boolean;
|
||||
}): VNode[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
:focusedItemId="focused ? focusedItemId : undefined"
|
||||
:items="processedItems"
|
||||
:horizontal="horizontal"
|
||||
:template="$slots.item"
|
||||
:template="$slots"
|
||||
:activeItem="activeItem"
|
||||
:exact="exact"
|
||||
:level="0"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
:aria-posinset="getAriaPosInset(index)"
|
||||
>
|
||||
<div class="p-menuitem-content" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)">
|
||||
<template v-if="!template">
|
||||
<template v-if="!template.item">
|
||||
<router-link v-if="getItemProp(processedItem, 'to') && !isItemDisabled(processedItem)" v-slot="{ navigate, href, isActive, isExactActive }" :to="getItemProp(processedItem, 'to')" custom>
|
||||
<a v-ripple :href="href" :class="getItemActionClass(processedItem, { isActive, isExactActive })" tabindex="-1" aria-hidden="true" @click="onItemActionClick($event, navigate)">
|
||||
<span v-if="getItemProp(processedItem, 'icon')" :class="getItemIconClass(processedItem)"></span>
|
||||
|
@ -27,10 +27,12 @@
|
|||
<a v-else v-ripple :href="getItemProp(processedItem, 'url')" :class="getItemActionClass(processedItem)" :target="getItemProp(processedItem, 'target')" tabindex="-1" aria-hidden="true">
|
||||
<span v-if="getItemProp(processedItem, 'icon')" :class="getItemIconClass(processedItem)"></span>
|
||||
<span class="p-menuitem-text">{{ getItemLabel(processedItem) }}</span>
|
||||
<span v-if="isItemGroup(processedItem)" :class="getItemToggleIconClass()"></span>
|
||||
<slot v-if="isItemGroup(processedItem)" name="submenuicon">
|
||||
<component :is="template.submenuicon || (horizontal ? 'AngleDownIcon' : 'AngleRightIcon')" :active="isItemActive(processedItem)" class="p-submenu-icon" />
|
||||
</slot>
|
||||
</a>
|
||||
</template>
|
||||
<component v-else :is="template" :item="processedItem.item"></component>
|
||||
<component v-else :is="template.item" :item="processedItem.item"></component>
|
||||
</div>
|
||||
<div v-if="isItemVisible(processedItem) && isItemGroup(processedItem)" class="p-megamenu-panel">
|
||||
<div class="p-megamenu-grid">
|
||||
|
@ -61,6 +63,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import AngleDownIcon from 'primevue/icon/angledown';
|
||||
import AngleRightIcon from 'primevue/icon/angleright';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { ObjectUtils } from 'primevue/utils';
|
||||
|
||||
|
@ -93,7 +97,7 @@ export default {
|
|||
default: 0
|
||||
},
|
||||
template: {
|
||||
type: Function,
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
activeItem: {
|
||||
|
@ -215,13 +219,14 @@ export default {
|
|||
getItemIconClass(processedItem) {
|
||||
return ['p-menuitem-icon', this.getItemProp(processedItem, 'icon')];
|
||||
},
|
||||
getItemToggleIconClass() {
|
||||
return ['p-submenu-icon', this.horizontal ? 'pi pi-angle-down' : 'pi pi-angle-right'];
|
||||
},
|
||||
getSeparatorItemClass(processedItem) {
|
||||
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AngleRightIcon: AngleRightIcon,
|
||||
AngleDownIcon: AngleDownIcon
|
||||
},
|
||||
directives: {
|
||||
ripple: Ripple
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue