primevue-mirror/doc/tieredmenu/PopupDoc.vue

278 lines
7.9 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-11-06 15:14:05 +00:00
<p>Overlay mode is enabled by adding <i>popup</i> property and calling <i>toggle</i> function of the menu ref with an event of the target.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-02-28 08:29:30 +00:00
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_tmenu" />
<TieredMenu ref="menu" id="overlay_tmenu" :model="items" popup />
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'File',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file',
2023-02-28 08:29:30 +00:00
items: [
{
label: 'New',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-plus',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Document',
icon: 'pi pi-file'
},
{
label: 'Image',
icon: 'pi pi-image'
2023-02-28 08:29:30 +00:00
},
{
label: 'Video',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-video'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Open',
icon: 'pi pi-folder-open'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Print',
icon: 'pi pi-print'
2023-02-28 08:29:30 +00:00
}
]
},
{
label: 'Edit',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file-edit',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Copy',
icon: 'pi pi-copy'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Delete',
icon: 'pi pi-times'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Search',
icon: 'pi pi-search'
},
{
separator: true
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Share',
icon: 'pi pi-share-alt',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Slack',
icon: 'pi pi-slack'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Whatsapp',
icon: 'pi pi-whatsapp'
2023-02-28 08:29:30 +00:00
}
]
}
],
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_tmenu" />
2023-10-15 09:38:39 +00:00
<TieredMenu ref="menu" id="overlay_tmenu" :model="items" popup />
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-02-28 08:29:30 +00:00
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_tmenu" />
<TieredMenu ref="menu" id="overlay_tmenu" :model="items" popup />
</div>
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'File',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file',
2023-02-28 08:29:30 +00:00
items: [
{
label: 'New',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-plus',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Document',
icon: 'pi pi-file'
},
{
label: 'Image',
icon: 'pi pi-image'
2023-02-28 08:29:30 +00:00
},
{
label: 'Video',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-video'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Open',
icon: 'pi pi-folder-open'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Print',
icon: 'pi pi-print'
2023-02-28 08:29:30 +00:00
}
]
},
{
label: 'Edit',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file-edit',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Copy',
icon: 'pi pi-copy'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Delete',
icon: 'pi pi-times'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Search',
icon: 'pi pi-search'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
separator: true
},
{
label: 'Share',
icon: 'pi pi-share-alt',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Slack',
icon: 'pi pi-slack'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Whatsapp',
icon: 'pi pi-whatsapp'
2023-02-28 08:29:30 +00:00
}
]
}
]
};
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
}
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-02-28 08:29:30 +00:00
<Button type="button" label="Toggle" @click="toggle" aria-haspopup="true" aria-controls="overlay_tmenu" />
<TieredMenu ref="menu" id="overlay_tmenu" :model="items" popup />
</div>
</template>
<script setup>
import { ref } from "vue";
const menu = ref();
const items = ref([
{
label: 'File',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file',
2023-02-28 08:29:30 +00:00
items: [
{
label: 'New',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-plus',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Document',
icon: 'pi pi-file'
},
{
label: 'Image',
icon: 'pi pi-image'
2023-02-28 08:29:30 +00:00
},
{
label: 'Video',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-video'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Open',
icon: 'pi pi-folder-open'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Print',
icon: 'pi pi-print'
2023-02-28 08:29:30 +00:00
}
]
},
{
label: 'Edit',
2023-11-06 15:14:05 +00:00
icon: 'pi pi-file-edit',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Copy',
icon: 'pi pi-copy'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Delete',
icon: 'pi pi-times'
2023-02-28 08:29:30 +00:00
}
]
},
{
2023-11-06 15:14:05 +00:00
label: 'Search',
icon: 'pi pi-search'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
separator: true
},
{
label: 'Share',
icon: 'pi pi-share-alt',
2023-02-28 08:29:30 +00:00
items: [
{
2023-11-06 15:14:05 +00:00
label: 'Slack',
icon: 'pi pi-slack'
2023-02-28 08:29:30 +00:00
},
{
2023-11-06 15:14:05 +00:00
label: 'Whatsapp',
icon: 'pi pi-whatsapp'
2023-02-28 08:29:30 +00:00
}
]
}
]);
const toggle = (event) => {
menu.value.toggle(event);
};
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
}
}
};
</script>