parent
68400d63f6
commit
1f86a9b8bb
|
@ -35,6 +35,10 @@ const MegaMenuSlots = [
|
||||||
{
|
{
|
||||||
name: 'submenuicon',
|
name: 'submenuicon',
|
||||||
description: 'Custom submenu icon template.'
|
description: 'Custom submenu icon template.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'itemicon',
|
||||||
|
description: 'Custom item icon template.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,20 @@ export interface MegaMenuSlots {
|
||||||
*/
|
*/
|
||||||
active: boolean;
|
active: boolean;
|
||||||
}): VNode[];
|
}): VNode[];
|
||||||
|
/**
|
||||||
|
* Custom item icon template.
|
||||||
|
* @param {Object} scope - item icon slot's params.
|
||||||
|
*/
|
||||||
|
itemicon(scope: {
|
||||||
|
/**
|
||||||
|
* Menuitem instance
|
||||||
|
*/
|
||||||
|
item: MenuItem;
|
||||||
|
/**
|
||||||
|
* Style class of the item icon element.
|
||||||
|
*/
|
||||||
|
class: any;
|
||||||
|
}): VNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
:focusedItemId="focused ? focusedItemId : undefined"
|
:focusedItemId="focused ? focusedItemId : undefined"
|
||||||
:items="processedItems"
|
:items="processedItems"
|
||||||
:horizontal="horizontal"
|
:horizontal="horizontal"
|
||||||
:template="$slots"
|
:templates="$slots"
|
||||||
:activeItem="activeItem"
|
:activeItem="activeItem"
|
||||||
:exact="exact"
|
:exact="exact"
|
||||||
:level="0"
|
:level="0"
|
||||||
|
|
|
@ -17,20 +17,20 @@
|
||||||
: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.item">
|
<template v-if="!templates.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>
|
<component :is="templates.itemicon || (getItemProp(processedItem, 'icon') ? 'span' : undefined)" :item="processedItem.item" :class="getItemIconClass(processedItem)" />
|
||||||
<span class="p-menuitem-text">{{ getItemLabel(processedItem) }}</span>
|
<span class="p-menuitem-text">{{ getItemLabel(processedItem) }}</span>
|
||||||
</a>
|
</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
<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>
|
<component :is="templates.itemicon || (getItemProp(processedItem, 'icon') ? 'span' : undefined)" :item="processedItem.item" :class="getItemIconClass(processedItem)" />
|
||||||
<span class="p-menuitem-text">{{ getItemLabel(processedItem) }}</span>
|
<span class="p-menuitem-text">{{ getItemLabel(processedItem) }}</span>
|
||||||
<component v-if="isItemGroup(processedItem)" :is="template.submenuicon || (horizontal ? 'AngleDownIcon' : 'AngleRightIcon')" :active="isItemActive(processedItem)" class="p-submenu-icon" />
|
<component v-if="isItemGroup(processedItem)" :is="templates.submenuicon || (horizontal ? 'AngleDownIcon' : 'AngleRightIcon')" :active="isItemActive(processedItem)" class="p-submenu-icon" />
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
<component v-else :is="template.item" :item="processedItem.item"></component>
|
<component v-else :is="templates.item" :item="processedItem.item"></component>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isItemVisible(processedItem) && isItemGroup(processedItem)" class="p-megamenu-panel">
|
<div v-if="isItemVisible(processedItem) && isItemGroup(processedItem)" class="p-megamenu-panel">
|
||||||
<div class="p-megamenu-grid">
|
<div class="p-megamenu-grid">
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
:focusedItemId="focusedItemId"
|
:focusedItemId="focusedItemId"
|
||||||
:submenu="submenu"
|
:submenu="submenu"
|
||||||
:items="submenu.items"
|
:items="submenu.items"
|
||||||
:template="template"
|
:templates="templates"
|
||||||
:exact="exact"
|
:exact="exact"
|
||||||
:level="level + 1"
|
:level="level + 1"
|
||||||
@item-click="$emit('item-click', $event)"
|
@item-click="$emit('item-click', $event)"
|
||||||
|
@ -94,7 +94,7 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
template: {
|
templates: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue