Refactor #3832 Refactor #3833 - For TabMenu

pull/3868/head
mertsincan 2023-04-17 09:34:43 +03:00
parent 3ed2355a45
commit 4858a1fc94
3 changed files with 20 additions and 2 deletions

View File

@ -42,6 +42,10 @@ const TabMenuSlots = [
{
name: 'item',
description: 'Template of a menuitem.'
},
{
name: 'itemicon',
description: 'Custom item icon template.'
}
];

View File

@ -68,6 +68,20 @@ export interface TabMenuSlots {
*/
item: MenuItem;
}): 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

@ -17,7 +17,7 @@
@click="onItemClick($event, item, i, navigate)"
@keydown="onKeydownItem($event, item, i, navigate)"
>
<span v-if="item.icon" :class="getItemIcon(item)"></span>
<component :is="$slots.itemicon || (item.icon ? 'span' : undefined)" :item="item" :class="getItemIcon(item)" />
<span class="p-menuitem-text">{{ label(item) }}</span>
</a>
</template>
@ -27,7 +27,7 @@
<li v-else-if="visible(item)" ref="tab" :class="getItemClass(item, i)" role="presentation" @click="onItemClick($event, item, i)" @keydown="onKeydownItem($event, item, i)">
<template v-if="!$slots.item">
<a ref="tabLink" v-ripple role="menuitem" :href="item.url" class="p-menuitem-link" :target="item.target" :aria-label="label(item)" :aria-disabled="disabled(item)" :tabindex="setTabIndex(i)">
<span v-if="item.icon" :class="getItemIcon(item)"></span>
<component :is="$slots.itemicon || (item.icon ? 'span' : undefined)" :item="item" :class="getItemIcon(item)" />
<span class="p-menuitem-text">{{ label(item) }}</span>
</a>
</template>