Implemented Menubar Component
parent
e7b5367fac
commit
d8512430cc
|
@ -129,6 +129,7 @@
|
||||||
<router-link to="/menumodel">● MenuModel</router-link>
|
<router-link to="/menumodel">● MenuModel</router-link>
|
||||||
<router-link to="/breadcrumb">● Breadcrumb</router-link>
|
<router-link to="/breadcrumb">● Breadcrumb</router-link>
|
||||||
<router-link to="/menu">● Menu</router-link>
|
<router-link to="/menu">● Menu</router-link>
|
||||||
|
<router-link to="/menubar">● Menubar</router-link>
|
||||||
<router-link to="/tieredmenu">● TieredMenu</router-link>
|
<router-link to="/tieredmenu">● TieredMenu</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
<template>
|
||||||
|
<div class="p-menubar p-component'">
|
||||||
|
<MenubarSub :model="model" :root="true" />
|
||||||
|
<div class="p-menubar-custom" v-if="$slots.default">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MenubarSub from './MenubarSub';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Array,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'MenubarSub': MenubarSub
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.p-menubar {
|
||||||
|
padding: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menu-separator {
|
||||||
|
border-width: 1px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar:after {
|
||||||
|
content: "";
|
||||||
|
clear: both;
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar ul {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menuitem-link {
|
||||||
|
display: block;
|
||||||
|
padding: .25em;
|
||||||
|
position: relative;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menuitem-icon {
|
||||||
|
margin-right: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list > .p-menuitem {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list > .p-menuitem > .p-menuitem-link {
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list > .p-menuitem > .p-menuitem-link > .p-submenu-icon {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-left: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list > li ul {
|
||||||
|
display: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-root-list > .p-menuitem-active > .p-submenu-list {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-submenu-list {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
min-width: 12.5em;
|
||||||
|
padding: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-submenu-list .p-menuitem {
|
||||||
|
margin: .125em 0;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-submenu-list > .p-menuitem-active > .p-submenu-list {
|
||||||
|
display: block;
|
||||||
|
left: 100%;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menuitem-icon {
|
||||||
|
margin-right: .25em;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menuitem-text {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-submenu-list .p-menuitem-link .p-submenu-icon {
|
||||||
|
position: absolute;
|
||||||
|
margin-top: -.5em;
|
||||||
|
right: 0;
|
||||||
|
top: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menuitem-active > .p-submenu > .p-submenu-list {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-menubar .p-menubar-custom {
|
||||||
|
float: right;
|
||||||
|
padding: .25em;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,273 @@
|
||||||
|
<template>
|
||||||
|
<ul :class="containerClass" role="menu">
|
||||||
|
<template v-for="(item, i) of model">
|
||||||
|
<li role="menuitem" :class="getItemClass(item)" :style="item.style" v-if="item.visible !== false && !item.separator" :key="item.label + i"
|
||||||
|
@mouseenter="onItemMouseEnter($event, item)">
|
||||||
|
<router-link v-if="item.to" :to="item.to" class="p-menuitem-link"
|
||||||
|
@click.native="onItemClick($event, item)" @keydown.native="onItemKeyDown($event, item)">
|
||||||
|
<span :class="['p-menuitem-icon', item.icon]"></span>
|
||||||
|
<span class="p-menuitem-text">{{item.label}}</span>
|
||||||
|
</router-link>
|
||||||
|
<a v-else :href="item.url||'#'" class="p-menuitem-link" :target="item.target"
|
||||||
|
@click="onItemClick($event, item)" @keydown="onItemKeyDown($event, item)">
|
||||||
|
<span :class="['p-menuitem-icon', item.icon]"></span>
|
||||||
|
<span class="p-menuitem-text">{{item.label}}</span>
|
||||||
|
<span :class="getSubmenuIcon(item)" v-if="item.items"></span>
|
||||||
|
</a>
|
||||||
|
<sub-menu :model="item.items" v-if="item.visible !== false && item.items" :key="item.label + '_sub_'"
|
||||||
|
@leaf-click="onLeafClick" @keydown-item="onChildItemKeyDown" :parentActive="item === activeItem" />
|
||||||
|
</li>
|
||||||
|
<li class="p-menu-separator" :style="item.style" v-if="item.visible !== false && item.separator" :key="'separator' + i"></li>
|
||||||
|
</template>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import DomHandler from '../utils/DomHandler';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'sub-menu',
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Array,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
root: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
popup: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
parentActive: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
documentClickListener: null,
|
||||||
|
watch: {
|
||||||
|
parentActive(newValue) {
|
||||||
|
if (!newValue) {
|
||||||
|
this.activeItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
activeItem: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updated() {
|
||||||
|
if (this.root && this.activeItem) {
|
||||||
|
this.bindDocumentClickListener();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.unbindDocumentClickListener();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onItemMouseEnter(event, item) {
|
||||||
|
if (item.disabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.root) {
|
||||||
|
if (this.activeItem || this.popup) {
|
||||||
|
this.activeItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.activeItem = item;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onItemClick(event, item) {
|
||||||
|
if (item.disabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!item.url) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.command) {
|
||||||
|
item.command({
|
||||||
|
originalEvent: event,
|
||||||
|
item: item
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.root && item.items) {
|
||||||
|
if (this.activeItem && item === this.activeItem)
|
||||||
|
this.activeItem = null;
|
||||||
|
else
|
||||||
|
this.activeItem = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!item.items) {
|
||||||
|
this.onLeafClick();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLeafClick() {
|
||||||
|
this.activeItem = null;
|
||||||
|
|
||||||
|
if (!this.root) {
|
||||||
|
this.$emit('leaf-click');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onItemKeyDown(event, item) {
|
||||||
|
let listItem = event.currentTarget.parentElement;
|
||||||
|
|
||||||
|
switch(event.which) {
|
||||||
|
//down
|
||||||
|
case 40:
|
||||||
|
if (this.root) {
|
||||||
|
if (item.items) {
|
||||||
|
this.expandSubmenu(item, listItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.navigateToNextItem(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//up
|
||||||
|
case 38:
|
||||||
|
if (!this.root) {
|
||||||
|
this.navigateToPrevItem(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//right
|
||||||
|
case 39:
|
||||||
|
if (this.root) {
|
||||||
|
var nextItem = this.findNextItem(listItem);
|
||||||
|
if (nextItem) {
|
||||||
|
nextItem.children[0].focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (item.items) {
|
||||||
|
this.expandSubmenu(item, listItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//left
|
||||||
|
case 37:
|
||||||
|
if (this.root) {
|
||||||
|
this.navigateToPrevItem(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$emit('keydown-item', {
|
||||||
|
originalEvent: event,
|
||||||
|
element: listItem
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onChildItemKeyDown(event) {
|
||||||
|
if (this.root) {
|
||||||
|
//up
|
||||||
|
if (event.originalEvent.which === 38 && event.element.previousElementSibling == null) {
|
||||||
|
this.collapseMenu(event.element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//left
|
||||||
|
if (event.which === 37) {
|
||||||
|
this.collapseMenu(event.element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
findNextItem(item) {
|
||||||
|
let nextItem = item.nextElementSibling;
|
||||||
|
|
||||||
|
if (nextItem)
|
||||||
|
return DomHandler.hasClass(nextItem, 'p-disabled') || !DomHandler.hasClass(nextItem, 'p-menuitem') ? this.findNextItem(nextItem) : nextItem;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
findPrevItem(item) {
|
||||||
|
let prevItem = item.previousElementSibling;
|
||||||
|
|
||||||
|
if (prevItem)
|
||||||
|
return DomHandler.hasClass(prevItem, 'p-disabled') || !DomHandler.hasClass(prevItem, 'p-menuitem') ? this.findPrevItem(prevItem) : prevItem;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
expandSubmenu(item, listItem) {
|
||||||
|
this.activeItem = item;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
listItem.children[1].children[0].children[0].focus();
|
||||||
|
}, 50);
|
||||||
|
},
|
||||||
|
collapseMenu(listItem) {
|
||||||
|
this.activeItem = null;
|
||||||
|
listItem.parentElement.previousElementSibling.focus();
|
||||||
|
},
|
||||||
|
navigateToNextItem(listItem) {
|
||||||
|
var nextItem = this.findNextItem(listItem);
|
||||||
|
if (nextItem) {
|
||||||
|
nextItem.children[0].focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
navigateToPrevItem(listItem) {
|
||||||
|
var prevItem = this.findPrevItem(listItem);
|
||||||
|
if (prevItem) {
|
||||||
|
prevItem.children[0].focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getItemClass(item) {
|
||||||
|
return [
|
||||||
|
'p-menuitem', item.class, {
|
||||||
|
'p-menuitem-active': this.activeItem === item,
|
||||||
|
'p-disabled': item.disabled,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
bindDocumentClickListener() {
|
||||||
|
if (!this.documentClickListener) {
|
||||||
|
this.documentClickListener = (event) => {
|
||||||
|
if (this.$el && !this.$el.contains(event.target)) {
|
||||||
|
this.activeItem = null;
|
||||||
|
this.unbindDocumentClickListener();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('click', this.documentClickListener);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unbindDocumentClickListener() {
|
||||||
|
if (this.documentClickListener) {
|
||||||
|
document.removeEventListener('click', this.documentClickListener);
|
||||||
|
this.documentClickListener = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getSubmenuIcon(item) {
|
||||||
|
return [
|
||||||
|
'p-submenu-icon pi pi-fw', {'pi-caret-right': !this.root, 'pi-caret-down': this.root}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
containerClass() {
|
||||||
|
return {'p-submenu-list': !this.root, 'p-menubar-root-list': this.root};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -29,6 +29,7 @@ import InputSwitch from './components/inputswitch/InputSwitch';
|
||||||
import InputText from './components/inputtext/InputText';
|
import InputText from './components/inputtext/InputText';
|
||||||
import Listbox from './components/listbox/Listbox';
|
import Listbox from './components/listbox/Listbox';
|
||||||
import Menu from './components/menu/Menu';
|
import Menu from './components/menu/Menu';
|
||||||
|
import Menubar from './components/menubar/Menubar';
|
||||||
import Message from './components/message/Message';
|
import Message from './components/message/Message';
|
||||||
import MultiSelect from './components/multiselect/MultiSelect';
|
import MultiSelect from './components/multiselect/MultiSelect';
|
||||||
import OrderList from './components/orderlist/OrderList';
|
import OrderList from './components/orderlist/OrderList';
|
||||||
|
@ -104,6 +105,7 @@ Vue.component('InputSwitch', InputSwitch);
|
||||||
Vue.component('InputText', InputText);
|
Vue.component('InputText', InputText);
|
||||||
Vue.component('Listbox', Listbox);
|
Vue.component('Listbox', Listbox);
|
||||||
Vue.component('Menu', Menu);
|
Vue.component('Menu', Menu);
|
||||||
|
Vue.component('Menubar', Menubar);
|
||||||
Vue.component('Message', Message);
|
Vue.component('Message', Message);
|
||||||
Vue.component('MultiSelect', MultiSelect);
|
Vue.component('MultiSelect', MultiSelect);
|
||||||
Vue.component('OrderList', OrderList);
|
Vue.component('OrderList', OrderList);
|
||||||
|
|
|
@ -296,6 +296,11 @@ export default new Router({
|
||||||
name: 'menu',
|
name: 'menu',
|
||||||
component: () => import('./views/menu/MenuDemo.vue')
|
component: () => import('./views/menu/MenuDemo.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/menubar',
|
||||||
|
name: 'menubar',
|
||||||
|
component: () => import('./views/menubar/MenubarDemo.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/menumodel',
|
path: '/menumodel',
|
||||||
name: 'menumodel',
|
name: 'menumodel',
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="content-section introduction">
|
||||||
|
<div class="feature-intro">
|
||||||
|
<h1>Menubar</h1>
|
||||||
|
<p>Menubar is a horizontal menu component.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-section implementation">
|
||||||
|
<Menubar :model="items">
|
||||||
|
<InputText placeholder="Search" type="text" />
|
||||||
|
<Button label="Logout" icon="pi pi-power-off" :style="{'margin-left': '.25em'}"/>
|
||||||
|
</Menubar>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MenubarDoc />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MenubarDoc from './MenubarDoc';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label:'File',
|
||||||
|
icon:'pi pi-fw pi-file',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-plus',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Bookmark',
|
||||||
|
icon:'pi pi-fw pi-bookmark'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Video',
|
||||||
|
icon:'pi pi-fw pi-video'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-trash'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Export',
|
||||||
|
icon:'pi pi-fw pi-external-link'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Left',
|
||||||
|
icon:'pi pi-fw pi-align-left'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Right',
|
||||||
|
icon:'pi pi-fw pi-align-right'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Center',
|
||||||
|
icon:'pi pi-fw pi-align-center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Justify',
|
||||||
|
icon:'pi pi-fw pi-align-justify'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Users',
|
||||||
|
icon:'pi pi-fw pi-user',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-user-plus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-user-minus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Search',
|
||||||
|
icon:'pi pi-fw pi-users',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Filter',
|
||||||
|
icon:'pi pi-fw pi-filter',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Print',
|
||||||
|
icon:'pi pi-fw pi-print'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon:'pi pi-fw pi-bars',
|
||||||
|
label:'List'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Events',
|
||||||
|
icon:'pi pi-fw pi-calendar',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Save',
|
||||||
|
icon:'pi pi-fw pi-calendar-plus'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Archieve',
|
||||||
|
icon:'pi pi-fw pi-calendar-times',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Remove',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Quit',
|
||||||
|
icon:'pi pi-fw pi-power-off'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'MenubarDoc': MenubarDoc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,456 @@
|
||||||
|
<template>
|
||||||
|
<div class="content-section documentation">
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Documentation">
|
||||||
|
<h3>Import</h3>
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
import TieredMenu from 'primevue/menu';
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>MenuModel</h3>
|
||||||
|
<p>TieredMenu uses the common MenuModel API to define the items, visit <router-link to="/menumodel">MenuModel API</router-link> for details.</p>
|
||||||
|
|
||||||
|
<h3>Getting Started</h3>
|
||||||
|
<p>TieredMenu requires a collection of menuitems as its model.</p>
|
||||||
|
<CodeHighlight>
|
||||||
|
<TieredMenu :model="items" />
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="js">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label:'File',
|
||||||
|
icon:'pi pi-fw pi-file',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-plus',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Bookmark',
|
||||||
|
icon:'pi pi-fw pi-bookmark'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Video',
|
||||||
|
icon:'pi pi-fw pi-video'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-trash'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Export',
|
||||||
|
icon:'pi pi-fw pi-external-link'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Left',
|
||||||
|
icon:'pi pi-fw pi-align-left'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Right',
|
||||||
|
icon:'pi pi-fw pi-align-right'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Center',
|
||||||
|
icon:'pi pi-fw pi-align-center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Justify',
|
||||||
|
icon:'pi pi-fw pi-align-justify'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Users',
|
||||||
|
icon:'pi pi-fw pi-user',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-user-plus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-user-minus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Search',
|
||||||
|
icon:'pi pi-fw pi-users',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Filter',
|
||||||
|
icon:'pi pi-fw pi-filter',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Print',
|
||||||
|
icon:'pi pi-fw pi-print'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon:'pi pi-fw pi-bars',
|
||||||
|
label:'List'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Events',
|
||||||
|
icon:'pi pi-fw pi-calendar',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Save',
|
||||||
|
icon:'pi pi-fw pi-calendar-plus'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Archieve',
|
||||||
|
icon:'pi pi-fw pi-calendar-times',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Remove',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Quit',
|
||||||
|
icon:'pi pi-fw pi-power-off'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Popup Mode</h3>
|
||||||
|
<p>TieredMenu is inline by default whereas popup mode is supported by enabling popup property and calling toggle method with an event of the target.</p>
|
||||||
|
|
||||||
|
<CodeHighlight>
|
||||||
|
<Button type="button" label="Toggle" @click="toggle" />
|
||||||
|
<TieredMenu ref="menu" :model="items" :popup="true" />
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="js">
|
||||||
|
toggle(event) {
|
||||||
|
this.$refs.menu.toggle(event);
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Properties</h3>
|
||||||
|
<p>Any attribute such 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>null</td>
|
||||||
|
<td>DOM element instance where the dialog should be mounted.</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>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Methods</h3>
|
||||||
|
<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 visiblity 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>
|
||||||
|
|
||||||
|
<h3>Styling</h3>
|
||||||
|
<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-tieredmenu</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>
|
||||||
|
<tr>
|
||||||
|
<td>p-submenu-icon</td>
|
||||||
|
<td>Arrow icon of a submenu.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Dependencies</h3>
|
||||||
|
<p>None.</p>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Source">
|
||||||
|
<a href="https://github.com/primefaces/primevue/tree/master/src/views/tieredmenu" class="btn-viewsource" target="_blank" rel="noopener noreferrer">
|
||||||
|
<span>View on GitHub</span>
|
||||||
|
</a>
|
||||||
|
<CodeHighlight>
|
||||||
|
<template v-pre>
|
||||||
|
<h3>Inline</h3>
|
||||||
|
<TieredMenu :model="items" />
|
||||||
|
|
||||||
|
<h3>Overlay</h3>
|
||||||
|
<Button type="button" label="Toggle" @click="toggle" />
|
||||||
|
<TieredMenu ref="menu" :model="items" :popup="true" />
|
||||||
|
</template>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label:'File',
|
||||||
|
icon:'pi pi-fw pi-file',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-plus',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Bookmark',
|
||||||
|
icon:'pi pi-fw pi-bookmark'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Video',
|
||||||
|
icon:'pi pi-fw pi-video'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-trash'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Export',
|
||||||
|
icon:'pi pi-fw pi-external-link'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Left',
|
||||||
|
icon:'pi pi-fw pi-align-left'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Right',
|
||||||
|
icon:'pi pi-fw pi-align-right'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Center',
|
||||||
|
icon:'pi pi-fw pi-align-center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Justify',
|
||||||
|
icon:'pi pi-fw pi-align-justify'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Users',
|
||||||
|
icon:'pi pi-fw pi-user',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'New',
|
||||||
|
icon:'pi pi-fw pi-user-plus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-user-minus',
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Search',
|
||||||
|
icon:'pi pi-fw pi-users',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Filter',
|
||||||
|
icon:'pi pi-fw pi-filter',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Print',
|
||||||
|
icon:'pi pi-fw pi-print'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon:'pi pi-fw pi-bars',
|
||||||
|
label:'List'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Events',
|
||||||
|
icon:'pi pi-fw pi-calendar',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Edit',
|
||||||
|
icon:'pi pi-fw pi-pencil',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Save',
|
||||||
|
icon:'pi pi-fw pi-calendar-plus'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Delete',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Archieve',
|
||||||
|
icon:'pi pi-fw pi-calendar-times',
|
||||||
|
items:[
|
||||||
|
{
|
||||||
|
label:'Remove',
|
||||||
|
icon:'pi pi-fw pi-calendar-minus'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:'Quit',
|
||||||
|
icon:'pi pi-fw pi-power-off'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggle(event) {
|
||||||
|
this.$refs.menu.toggle(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue