Fixed #3599 - Menu: start and end templating
parent
f1b1cdf189
commit
cf635e5caa
|
@ -49,6 +49,14 @@ const MenuEvents = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const MenuSlots = [
|
const MenuSlots = [
|
||||||
|
{
|
||||||
|
name: 'start',
|
||||||
|
description: 'Custom content before the content'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'end',
|
||||||
|
description: 'Custom content after the content'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'item',
|
name: 'item',
|
||||||
description: 'Template of a menuitem.'
|
description: 'Template of a menuitem.'
|
||||||
|
|
|
@ -49,6 +49,14 @@ export interface MenuProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuSlots {
|
export interface MenuSlots {
|
||||||
|
/**
|
||||||
|
* Custom start template.
|
||||||
|
*/
|
||||||
|
start: () => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom end template.
|
||||||
|
*/
|
||||||
|
end: () => VNode[];
|
||||||
/**
|
/**
|
||||||
* Custom item template.
|
* Custom item template.
|
||||||
* @param {Object} scope - item slot's params.
|
* @param {Object} scope - item slot's params.
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<Portal :appendTo="appendTo" :disabled="!popup">
|
<Portal :appendTo="appendTo" :disabled="!popup">
|
||||||
<transition name="p-connected-overlay" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
|
<transition name="p-connected-overlay" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
|
||||||
<div v-if="popup ? overlayVisible : true" :ref="containerRef" :id="id" :class="containerClass" v-bind="$attrs" @click="onOverlayClick">
|
<div v-if="popup ? overlayVisible : true" :ref="containerRef" :id="id" :class="containerClass" v-bind="$attrs" @click="onOverlayClick">
|
||||||
|
<div v-if="$slots.start" class="p-menu-start">
|
||||||
|
<slot name="start"></slot>
|
||||||
|
</div>
|
||||||
<ul
|
<ul
|
||||||
:ref="listRef"
|
:ref="listRef"
|
||||||
:id="id + '_list'"
|
:id="id + '_list'"
|
||||||
|
@ -29,6 +32,9 @@
|
||||||
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :template="$slots.item" :exact="exact" :focusedOptionId="focusedOptionId" @item-click="itemClick" />
|
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :template="$slots.item" :exact="exact" :focusedOptionId="focusedOptionId" @item-click="itemClick" />
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div v-if="$slots.end" class="p-menu-end">
|
||||||
|
<slot name="end"></slot>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</Portal>
|
</Portal>
|
||||||
|
|
|
@ -93,12 +93,18 @@ toggle(event) {
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
<h5>Templating</h5>
|
<h5>Templating</h5>
|
||||||
<p>Menu offers content customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.</p>
|
<p>Two slots named "start" and "end" are provided to embed content before or after the menu. In additon Menu, offers item customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.</p>
|
||||||
<pre v-code><code>
|
<pre v-code><code>
|
||||||
<Menu :model="items">
|
<Menu :model="items">
|
||||||
|
<template #start>
|
||||||
|
Start
|
||||||
|
</template>
|
||||||
<template #item="{item}">
|
<template #item="{item}">
|
||||||
<a :href="item.url">{{item.label}}</a>
|
<a :href="item.url">{{item.label}}</a>
|
||||||
</template>
|
</template>
|
||||||
|
<template #end>
|
||||||
|
End
|
||||||
|
</template>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
@ -265,6 +271,14 @@ toggle(event) {
|
||||||
<td>item</td>
|
<td>item</td>
|
||||||
<td>item: Menuitem instance</td>
|
<td>item: Menuitem instance</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>start</td>
|
||||||
|
<td>-</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>end</td>
|
||||||
|
<td>-</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -284,6 +298,14 @@ toggle(event) {
|
||||||
<td>p-menu</td>
|
<td>p-menu</td>
|
||||||
<td>Container element.</td>
|
<td>Container element.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-menu-start</td>
|
||||||
|
<td>Container of the start slot.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-menu-end</td>
|
||||||
|
<td>Container of the end slot.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>p-menu-list</td>
|
<td>p-menu-list</td>
|
||||||
<td>List element.</td>
|
<td>List element.</td>
|
||||||
|
|
Loading…
Reference in New Issue