2019-05-27 08:10:22 +00:00
|
|
|
<template>
|
2021-04-06 09:16:59 +00:00
|
|
|
<AppDoc name="MenuDemo" :sources="sources" github="menu/MenuDemo.vue">
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Import</h5>
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code.script><code>
|
2019-05-27 08:10:22 +00:00
|
|
|
import Menu from 'primevue/menu';
|
2020-09-24 11:14:55 +00:00
|
|
|
|
|
|
|
</code></pre>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>MenuModel</h5>
|
|
|
|
<p>Menu uses the common MenuModel API to define the items, visit <router-link to="/menumodel">MenuModel API</router-link> for details.</p>
|
2019-12-03 07:31:21 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Getting Started</h5>
|
|
|
|
<p>Menu requires a collection of menuitems as its model.</p>
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code><code>
|
2019-05-27 08:10:22 +00:00
|
|
|
<Menu :model="items" />
|
|
|
|
|
2020-09-24 11:14:55 +00:00
|
|
|
</code></pre>
|
|
|
|
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code.script><code>
|
2019-05-27 08:10:22 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Update',
|
|
|
|
icon: 'pi pi-refresh',
|
|
|
|
command: () => {
|
|
|
|
this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Delete',
|
|
|
|
icon: 'pi pi-times',
|
|
|
|
command: () => {
|
|
|
|
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Vue Website',
|
|
|
|
icon: 'pi pi-external-link',
|
2019-12-02 11:02:01 +00:00
|
|
|
url: 'https://vuejs.org/'
|
2019-05-27 08:10:22 +00:00
|
|
|
},
|
|
|
|
{
|
2019-12-02 11:02:01 +00:00
|
|
|
label: 'Router',
|
|
|
|
icon: 'pi pi-upload',
|
|
|
|
to: '/fileupload'
|
|
|
|
}
|
2019-05-27 08:10:22 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-24 11:14:55 +00:00
|
|
|
|
|
|
|
</code></pre>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>SubMenus</h5>
|
|
|
|
<p>Menu supports one level of nesting via subitems of an item.</p>
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code.script><code>
|
2019-12-02 11:02:01 +00:00
|
|
|
const items: [
|
2019-05-27 08:10:22 +00:00
|
|
|
{
|
|
|
|
label: 'Options',
|
2019-12-02 11:02:01 +00:00
|
|
|
items: [{label: 'New', icon: 'pi pi-fw pi-plus', command:() => {} },
|
2019-12-10 17:54:51 +00:00
|
|
|
{label: 'Delete', icon: 'pi pi-fw pi-trash', url: 'https://www.primetek.com.tr'}]
|
2019-10-01 13:00:26 +00:00
|
|
|
},
|
2019-05-27 08:10:22 +00:00
|
|
|
{
|
|
|
|
label: 'Account',
|
2019-12-02 11:02:01 +00:00
|
|
|
items: [{label: 'Options', icon: 'pi pi-fw pi-cog', to: '/options'},
|
|
|
|
{label: 'Sign Out', icon: 'pi pi-fw pi-power-off', to: '/logout'} ]
|
2019-05-27 08:10:22 +00:00
|
|
|
}
|
2019-12-02 11:02:01 +00:00
|
|
|
];
|
2020-09-24 11:14:55 +00:00
|
|
|
|
|
|
|
</code></pre>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Popup Mode</h5>
|
|
|
|
<p>Menu is inline by default whereas popup mode is supported by enabling popup property and calling toggle method with an event of the target.</p>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code><code>
|
2019-05-27 08:10:22 +00:00
|
|
|
<Button type="button" label="Toggle" @click="toggle" />
|
|
|
|
<Menu ref="menu" :model="items" :popup="true" />
|
2019-12-02 11:02:01 +00:00
|
|
|
|
2020-09-24 11:14:55 +00:00
|
|
|
</code></pre>
|
|
|
|
|
2021-02-03 10:10:30 +00:00
|
|
|
<pre v-code.script><code>
|
2019-12-02 11:02:01 +00:00
|
|
|
toggle(event) {
|
|
|
|
this.$refs.menu.toggle(event);
|
|
|
|
}
|
2020-09-24 11:14:55 +00:00
|
|
|
|
2021-05-17 11:58:53 +00:00
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
<pre v-code><code><template v-pre>
|
|
|
|
<Menu :model="items">
|
|
|
|
<template #item="{item}">
|
|
|
|
<a :href="item.url">{{item.label}}</a>
|
|
|
|
</template>
|
|
|
|
</Menu>
|
|
|
|
</template>
|
2021-08-27 08:09:41 +00:00
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
<p><i>router-link</i> with route configuration can also be used within templating for further customization.</p>
|
|
|
|
<pre v-code><code><template v-pre>
|
|
|
|
<Menu :model="items">
|
|
|
|
<template #item="{item}">
|
|
|
|
<router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
|
|
|
|
<a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
|
|
|
|
</router-link>
|
|
|
|
</template>
|
|
|
|
</Menu>
|
|
|
|
</template>
|
2020-09-24 11:14:55 +00:00
|
|
|
</code></pre>
|
2019-10-01 13:00:26 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Properties</h5>
|
|
|
|
<p>Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.</p>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th>Default</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>model</td>
|
|
|
|
<td>array</td>
|
|
|
|
<td>null</td>
|
|
|
|
<td>An array of menuitems.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>popup</td>
|
|
|
|
<td>boolean</td>
|
|
|
|
<td>false</td>
|
|
|
|
<td>Defines if menu would displayed as a popup.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>appendTo</td>
|
|
|
|
<td>string</td>
|
|
|
|
<td>body</td>
|
|
|
|
<td>A valid query selector or an HTMLElement to specify where the overlay gets attached.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>baseZIndex</td>
|
|
|
|
<td>number</td>
|
|
|
|
<td>0</td>
|
|
|
|
<td>Base zIndex value to use in layering.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>autoZIndex</td>
|
|
|
|
<td>boolean</td>
|
|
|
|
<td>true</td>
|
|
|
|
<td>Whether to automatically manage layering.</td>
|
2021-08-27 08:09:41 +00:00
|
|
|
</tr>
|
2021-08-27 11:48:05 +00:00
|
|
|
<tr>
|
2021-08-27 08:09:41 +00:00
|
|
|
<td>exact</td>
|
|
|
|
<td>boolean</td>
|
|
|
|
<td>true</td>
|
|
|
|
<td>Whether to apply 'router-link-active-exact' class if route exactly matches the item path.</td>
|
2021-03-23 07:47:00 +00:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Methods</h5>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Parameters</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>toggle</td>
|
|
|
|
<td>event: Browser event</td>
|
|
|
|
<td>Toggles the visibility of the overlay.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>show</td>
|
|
|
|
<td>event: Browser event <br />
|
|
|
|
target: Optional target if event.target would not be used</td>
|
|
|
|
<td>Shows the overlay.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>hide</td>
|
|
|
|
<td>-</td>
|
|
|
|
<td>Hides the overlay.</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-05-17 11:58:53 +00:00
|
|
|
<h5>Slots</h5>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Parameters</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>item</td>
|
|
|
|
<td>item: Menuitem instance</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Styling</h5>
|
|
|
|
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>
|
|
|
|
<div class="doc-tablewrapper">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Element</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>p-menu</td>
|
|
|
|
<td>Container element.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-menu-list</td>
|
|
|
|
<td>List element.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-menuitem</td>
|
|
|
|
<td>Menuitem element.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-menuitem-text</td>
|
|
|
|
<td>Label of a menuitem.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>p-menuitem-icon</td>
|
|
|
|
<td>Icon of a menuitem.</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Dependencies</h5>
|
|
|
|
<p>None.</p>
|
|
|
|
</AppDoc>
|
|
|
|
</template>
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
sources: {
|
|
|
|
'options-api': {
|
2021-04-05 09:29:28 +00:00
|
|
|
tabName: 'Options API Source',
|
2021-03-23 07:47:00 +00:00
|
|
|
content: `
|
|
|
|
<template>
|
2021-03-24 17:37:09 +00:00
|
|
|
<div>
|
2021-03-23 07:47:00 +00:00
|
|
|
<Toast />
|
|
|
|
|
|
|
|
<h5>Inline</h5>
|
|
|
|
<Menu :model="items" />
|
2019-05-27 08:10:22 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Overlay</h5>
|
|
|
|
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_menu"/>
|
|
|
|
<Menu id="overlay_menu" ref="menu" :model="items" :popup="true" />
|
|
|
|
</div>
|
2019-05-27 08:10:22 +00:00
|
|
|
</template>
|
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<script>
|
2019-05-27 08:10:22 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Options',
|
|
|
|
items: [{
|
2019-10-01 13:00:26 +00:00
|
|
|
label: 'Update',
|
|
|
|
icon: 'pi pi-refresh',
|
2019-05-27 08:10:22 +00:00
|
|
|
command: () => {
|
|
|
|
this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2019-10-01 13:00:26 +00:00
|
|
|
label: 'Delete',
|
2019-05-27 08:10:22 +00:00
|
|
|
icon: 'pi pi-times',
|
|
|
|
command: () => {
|
|
|
|
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]},
|
|
|
|
{
|
|
|
|
label: 'Navigate',
|
|
|
|
items: [{
|
2019-10-01 13:00:26 +00:00
|
|
|
label: 'Vue Website',
|
2019-05-27 08:10:22 +00:00
|
|
|
icon: 'pi pi-external-link',
|
2019-12-02 11:02:01 +00:00
|
|
|
url: 'https://vuejs.org/'
|
2019-05-27 08:10:22 +00:00
|
|
|
},
|
2019-10-01 13:00:26 +00:00
|
|
|
{
|
2019-12-02 11:02:01 +00:00
|
|
|
label: 'Router',
|
2019-10-01 13:00:26 +00:00
|
|
|
icon: 'pi pi-upload',
|
2021-03-23 07:47:00 +00:00
|
|
|
command: () => {
|
|
|
|
window.location.hash = "/fileupload"
|
|
|
|
}
|
2019-05-27 08:10:22 +00:00
|
|
|
}
|
|
|
|
]}
|
|
|
|
]
|
2019-10-01 13:00:26 +00:00
|
|
|
}
|
2019-05-27 08:10:22 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle(event) {
|
|
|
|
this.$refs.menu.toggle(event);
|
|
|
|
},
|
|
|
|
save() {
|
|
|
|
this.$toast.add({severity: 'success', summary: 'Success', detail: 'Data Saved', life: 3000});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-23 07:47:00 +00:00
|
|
|
<\\/script>
|
|
|
|
`
|
|
|
|
},
|
|
|
|
'composition-api': {
|
2021-04-05 09:29:28 +00:00
|
|
|
tabName: 'Composition API Source',
|
2021-03-23 07:47:00 +00:00
|
|
|
content: `
|
|
|
|
<template>
|
2021-03-24 17:37:09 +00:00
|
|
|
<div>
|
2021-03-23 07:47:00 +00:00
|
|
|
<Toast />
|
2020-09-24 11:14:55 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Inline</h5>
|
|
|
|
<Menu :model="items" />
|
2021-01-22 14:52:32 +00:00
|
|
|
|
2021-03-23 07:47:00 +00:00
|
|
|
<h5>Overlay</h5>
|
|
|
|
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_menu"/>
|
|
|
|
<Menu id="overlay_menu" ref="menu" :model="items" :popup="true" />
|
2021-01-22 14:52:32 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-23 07:47:00 +00:00
|
|
|
import { ref } from 'vue';
|
|
|
|
import { useToast } from 'primevue/usetoast';
|
|
|
|
|
2021-01-22 14:52:32 +00:00
|
|
|
export default {
|
2021-03-23 07:47:00 +00:00
|
|
|
setup() {
|
|
|
|
const toast = useToast();
|
|
|
|
const menu = ref();
|
|
|
|
const items = ref([
|
|
|
|
{
|
|
|
|
label: 'Options',
|
|
|
|
items: [{
|
|
|
|
label: 'Update',
|
|
|
|
icon: 'pi pi-refresh',
|
|
|
|
command: () => {
|
|
|
|
toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
|
|
|
|
}
|
|
|
|
},
|
2021-01-22 14:52:32 +00:00
|
|
|
{
|
2021-03-23 07:47:00 +00:00
|
|
|
label: 'Delete',
|
|
|
|
icon: 'pi pi-times',
|
|
|
|
command: () => {
|
|
|
|
toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
|
2021-01-22 14:52:32 +00:00
|
|
|
}
|
2021-03-23 07:47:00 +00:00
|
|
|
}
|
|
|
|
]},
|
|
|
|
{
|
|
|
|
label: 'Navigate',
|
|
|
|
items: [{
|
|
|
|
label: 'Vue Website',
|
|
|
|
icon: 'pi pi-external-link',
|
|
|
|
url: 'https://vuejs.org/'
|
|
|
|
},
|
2021-01-22 14:52:32 +00:00
|
|
|
{
|
2021-03-23 07:47:00 +00:00
|
|
|
label: 'Router',
|
|
|
|
icon: 'pi pi-upload',
|
|
|
|
command: () => {
|
|
|
|
window.location.hash = "/fileupload"
|
2021-01-22 14:52:32 +00:00
|
|
|
}
|
2021-03-23 07:47:00 +00:00
|
|
|
}
|
|
|
|
]}
|
|
|
|
]);
|
|
|
|
|
|
|
|
const toggle = (event) => {
|
|
|
|
menu.value.toggle(event);
|
|
|
|
};
|
|
|
|
const save = () => {
|
|
|
|
toast.add({severity: 'success', summary: 'Success', detail: 'Data Saved', life: 3000});
|
|
|
|
};
|
|
|
|
|
|
|
|
return { items, menu, toggle, save }
|
2021-01-22 14:52:32 +00:00
|
|
|
}
|
2021-03-23 07:47:00 +00:00
|
|
|
}
|
|
|
|
<\\/script>
|
|
|
|
`
|
2021-01-22 14:52:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|