Refactor #3832 Refactor #3833 - For TieredMenu

pull/3868/head
mertsincan 2023-04-17 09:38:00 +03:00
parent 62571db9e3
commit 753abea7ae
4 changed files with 24 additions and 6 deletions

View File

@ -45,6 +45,10 @@ const TieredMenuSlots = [
{
name: 'submenuicon',
description: 'Custom submenu icon template.'
},
{
name: 'itemicon',
description: 'Custom item icon template.'
}
];

View File

@ -86,6 +86,20 @@ export interface TieredMenuSlots {
*/
active: boolean;
}): 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[];
}
/**

View File

@ -16,7 +16,7 @@
:menuId="id"
:focusedItemId="focused ? focusedItemId : undefined"
:items="processedItems"
:template="$slots"
:templates="$slots"
:activeItemPath="activeItemPath"
:exact="exact"
:level="0"

View File

@ -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.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>
<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,10 @@
<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>
<component v-if="getItemProp(processedItem, 'items')" :is="template.submenuicon || 'AngleRightIcon'" class="p-submenu-icon" :active="isItemActive(processedItem)" />
<component v-if="getItemProp(processedItem, 'items')" :is="templates.submenuicon || 'AngleRightIcon'" class="p-submenu-icon" :active="isItemActive(processedItem)" />
</a>
</template>
<component v-else :is="template.item" :item="processedItem.item"></component>
<component v-else :is="templates.item" :item="processedItem.item"></component>
</div>
<TieredMenuSub
v-if="isItemVisible(processedItem) && isItemGroup(processedItem)"
@ -39,7 +39,7 @@
:menuId="menuId"
:focusedItemId="focusedItemId"
:items="processedItem.items"
:template="template"
:templates="templates"
:activeItemPath="activeItemPath"
:exact="exact"
:level="level + 1"
@ -77,7 +77,7 @@ export default {
type: Number,
default: 0
},
template: {
templates: {
type: Object,
default: null
},