parent
cbb5faf1ea
commit
181732c1c8
|
@ -30,7 +30,11 @@ const MegaMenuSlots = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'item',
|
name: 'item',
|
||||||
description: 'Template of a menuitem.'
|
description: 'Custom item template.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'submenuicon',
|
||||||
|
description: 'Custom submenu icon template.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,15 @@ export interface MegaMenuSlots {
|
||||||
*/
|
*/
|
||||||
item: MenuItem;
|
item: MenuItem;
|
||||||
}): VNode[];
|
}): VNode[];
|
||||||
|
/**
|
||||||
|
* Custom submenu icon template.
|
||||||
|
*/
|
||||||
|
submenuicon(scope: {
|
||||||
|
/**
|
||||||
|
* Whether item is active
|
||||||
|
*/
|
||||||
|
active: boolean;
|
||||||
|
}): VNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
:focusedItemId="focused ? focusedItemId : undefined"
|
:focusedItemId="focused ? focusedItemId : undefined"
|
||||||
:items="processedItems"
|
:items="processedItems"
|
||||||
:horizontal="horizontal"
|
:horizontal="horizontal"
|
||||||
:template="$slots.item"
|
:template="$slots"
|
||||||
:activeItem="activeItem"
|
:activeItem="activeItem"
|
||||||
:exact="exact"
|
:exact="exact"
|
||||||
:level="0"
|
:level="0"
|
||||||
|
|
|
@ -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="isItemGroup(processedItem)" :class="getItemToggleIconClass()"></span>
|
<slot v-if="isItemGroup(processedItem)" name="submenuicon">
|
||||||
|
<component :is="template.submenuicon || (horizontal ? 'AngleDownIcon' : '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>
|
||||||
<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">
|
||||||
|
@ -61,6 +63,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import AngleDownIcon from 'primevue/icon/angledown';
|
||||||
|
import AngleRightIcon from 'primevue/icon/angleright';
|
||||||
import Ripple from 'primevue/ripple';
|
import Ripple from 'primevue/ripple';
|
||||||
import { ObjectUtils } from 'primevue/utils';
|
import { ObjectUtils } from 'primevue/utils';
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ export default {
|
||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
template: {
|
template: {
|
||||||
type: Function,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
activeItem: {
|
activeItem: {
|
||||||
|
@ -215,13 +219,14 @@ export default {
|
||||||
getItemIconClass(processedItem) {
|
getItemIconClass(processedItem) {
|
||||||
return ['p-menuitem-icon', this.getItemProp(processedItem, 'icon')];
|
return ['p-menuitem-icon', this.getItemProp(processedItem, 'icon')];
|
||||||
},
|
},
|
||||||
getItemToggleIconClass() {
|
|
||||||
return ['p-submenu-icon', this.horizontal ? 'pi pi-angle-down' : 'pi pi-angle-right'];
|
|
||||||
},
|
|
||||||
getSeparatorItemClass(processedItem) {
|
getSeparatorItemClass(processedItem) {
|
||||||
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
AngleRightIcon: AngleRightIcon,
|
||||||
|
AngleDownIcon: AngleDownIcon
|
||||||
|
},
|
||||||
directives: {
|
directives: {
|
||||||
ripple: Ripple
|
ripple: Ripple
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue