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