parent
27c4bbec31
commit
058fa9673b
|
@ -41,6 +41,10 @@ const TieredMenuSlots = [
|
|||
{
|
||||
name: 'item',
|
||||
description: 'Template of a menuitem.'
|
||||
},
|
||||
{
|
||||
name: 'submenuicon',
|
||||
description: 'Custom submenu icon template.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -77,6 +77,15 @@ export interface TieredMenuSlots {
|
|||
*/
|
||||
item: MenuItem;
|
||||
}): VNode[];
|
||||
/**
|
||||
* Custom submenu icon template.
|
||||
*/
|
||||
submenuicon(scope: {
|
||||
/**
|
||||
* Whether item is active
|
||||
*/
|
||||
active: boolean;
|
||||
}): VNode[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
:menuId="id"
|
||||
:focusedItemId="focused ? focusedItemId : undefined"
|
||||
:items="processedItems"
|
||||
:template="$slots.item"
|
||||
:template="$slots"
|
||||
:activeItemPath="activeItemPath"
|
||||
:exact="exact"
|
||||
:level="0"
|
||||
|
|
|
@ -16,7 +16,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>
|
||||
|
@ -26,10 +26,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="p-submenu-icon pi pi-angle-right"></span>
|
||||
<slot v-if="getItemProp(processedItem, 'items')" name="submenuicon">
|
||||
<component :is="template.submenuicon || 'AngleRightIcon'" class="p-submenu-icon" :active="isItemActive(processedItem)" />
|
||||
</slot>
|
||||
</a>
|
||||
</template>
|
||||
<component v-else :is="template" :item="processedItem.item"></component>
|
||||
<component v-else :is="template.item" :item="processedItem.item"></component>
|
||||
</div>
|
||||
<TieredMenuSub
|
||||
v-if="isItemVisible(processedItem) && isItemGroup(processedItem)"
|
||||
|
@ -53,6 +55,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import AngleRightIcon from 'primevue/icon/angleright';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { ObjectUtils } from 'primevue/utils';
|
||||
|
||||
|
@ -77,7 +80,7 @@ export default {
|
|||
default: 0
|
||||
},
|
||||
template: {
|
||||
type: Function,
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
activeItemPath: {
|
||||
|
@ -160,6 +163,9 @@ export default {
|
|||
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AngleRightIcon: AngleRightIcon
|
||||
},
|
||||
directives: {
|
||||
ripple: Ripple
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue