parent
de3aac4fa2
commit
cbb5faf1ea
|
@ -40,7 +40,11 @@ const ContextMenuProps = [
|
|||
const ContextMenuSlots = [
|
||||
{
|
||||
name: 'item',
|
||||
description: 'Template of a menuitem.'
|
||||
description: 'Custom item template.'
|
||||
},
|
||||
{
|
||||
name: 'submenuicon',
|
||||
description: 'Custom submenu icon template.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -73,6 +73,15 @@ export interface ContextMenuSlots {
|
|||
*/
|
||||
item: MenuItem;
|
||||
}): VNode[];
|
||||
/**
|
||||
* Custom submenu icon template.
|
||||
*/
|
||||
submenuicon(scope: {
|
||||
/**
|
||||
* Whether item is active
|
||||
*/
|
||||
active: boolean;
|
||||
}): VNode[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
:menuId="id"
|
||||
:focusedItemId="focused ? focusedItemId : undefined"
|
||||
:items="processedItems"
|
||||
:template="$slots.item"
|
||||
:template="$slots"
|
||||
:activeItemPath="activeItemPath"
|
||||
:exact="exact"
|
||||
:aria-labelledby="ariaLabelledby"
|
||||
|
|
|
@ -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="getItemProp(processedItem, 'items')" class="p-submenu-icon pi pi-angle-right"></span>
|
||||
<slot v-if="getItemProp(processedItem, 'items')" name="submenuicon">
|
||||
<component :is="template.submenuicon || '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>
|
||||
<ContextMenuSub
|
||||
v-if="isItemVisible(processedItem) && isItemGroup(processedItem)"
|
||||
|
@ -56,6 +58,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import AngleRightIcon from 'primevue/icon/angleright';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
||||
|
||||
|
@ -88,7 +91,7 @@ export default {
|
|||
default: 0
|
||||
},
|
||||
template: {
|
||||
type: Function,
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
exact: {
|
||||
|
@ -189,6 +192,9 @@ export default {
|
|||
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AngleRightIcon: AngleRightIcon
|
||||
},
|
||||
directives: {
|
||||
ripple: Ripple
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue