mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Components added. Build issues fixed
This commit is contained in:
parent
5b66ed1093
commit
18c3721848
344 changed files with 12446 additions and 8758 deletions
|
@ -1,35 +1,43 @@
|
|||
<template>
|
||||
<transition name="p-contextmenusub" @enter="onEnter">
|
||||
<ul ref="container" :class="containerClass" role="menu" v-if="root ? true : parentActive">
|
||||
<ul v-if="root ? true : parentActive" ref="container" :class="containerClass" role="menu">
|
||||
<template v-for="(item, i) of model" :key="label(item) + i.toString()">
|
||||
<li role="none" :class="getItemClass(item)" :style="item.style" v-if="visible(item) && !item.separator"
|
||||
@mouseenter="onItemMouseEnter($event, item)">
|
||||
<li v-if="visible(item) && !item.separator" role="none" :class="getItemClass(item)" :style="item.style" @mouseenter="onItemMouseEnter($event, item)">
|
||||
<template v-if="!template">
|
||||
<router-link v-if="item.to && !disabled(item)" :to="item.to" custom v-slot="{navigate, href, isActive, isExactActive}">
|
||||
<a :href="href" @click="onItemClick($event, item, navigate)" :class="linkClass(item, {isActive, isExactActive})" v-ripple role="menuitem">
|
||||
<span :class="['p-menuitem-icon', item.icon]" v-if="item.icon"></span>
|
||||
<span class="p-menuitem-text">{{label(item)}}</span>
|
||||
<router-link v-if="item.to && !disabled(item)" v-slot="{ navigate, href, isActive, isExactActive }" :to="item.to" custom>
|
||||
<a v-ripple :href="href" @click="onItemClick($event, item, navigate)" :class="linkClass(item, { isActive, isExactActive })" role="menuitem">
|
||||
<span v-if="item.icon" :class="['p-menuitem-icon', item.icon]"></span>
|
||||
<span class="p-menuitem-text">{{ label(item) }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<a v-else :href="item.url" :class="linkClass(item)" :target="item.target" @click="onItemClick($event, item)" v-ripple
|
||||
:aria-haspopup="item.items != null" :aria-expanded="item === activeItem" role="menuitem" :tabindex="disabled(item) ? null : '0'">
|
||||
<span :class="['p-menuitem-icon', item.icon]" v-if="item.icon"></span>
|
||||
<span class="p-menuitem-text">{{label(item)}}</span>
|
||||
<span class="p-submenu-icon pi pi-angle-right" v-if="item.items"></span>
|
||||
<a
|
||||
v-else
|
||||
v-ripple
|
||||
:href="item.url"
|
||||
:class="linkClass(item)"
|
||||
:target="item.target"
|
||||
@click="onItemClick($event, item)"
|
||||
:aria-haspopup="item.items != null"
|
||||
:aria-expanded="item === activeItem"
|
||||
role="menuitem"
|
||||
:tabindex="disabled(item) ? null : '0'"
|
||||
>
|
||||
<span v-if="item.icon" :class="['p-menuitem-icon', item.icon]"></span>
|
||||
<span class="p-menuitem-text">{{ label(item) }}</span>
|
||||
<span v-if="item.items" class="p-submenu-icon pi pi-angle-right"></span>
|
||||
</a>
|
||||
</template>
|
||||
<component v-else :is="template" :item="item"></component>
|
||||
<ContextMenuSub :model="item.items" v-if="visible(item) && item.items" :key="label(item) + '_sub_'" :template="template"
|
||||
@leaf-click="onLeafClick" :parentActive="item === activeItem" :exact="exact" />
|
||||
<ContextMenuSub v-if="visible(item) && item.items" :key="label(item) + '_sub_'" :model="item.items" :template="template" @leaf-click="onLeafClick" :parentActive="item === activeItem" :exact="exact" />
|
||||
</li>
|
||||
<li :class="['p-menu-separator', item.class]" :style="item.style" v-if="visible(item) && item.separator" :key="'separator' + i.toString()" role="separator"></li>
|
||||
<li v-if="visible(item) && item.separator" :key="'separator' + i.toString()" :class="['p-menu-separator', item.class]" :style="item.style" role="separator"></li>
|
||||
</template>
|
||||
</ul>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {DomHandler} from 'primevue/utils';
|
||||
import { DomHandler } from 'primevue/utils';
|
||||
import Ripple from 'primevue/ripple';
|
||||
|
||||
export default {
|
||||
|
@ -57,6 +65,11 @@ export default {
|
|||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeItem: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
parentActive(newValue) {
|
||||
if (!newValue) {
|
||||
|
@ -64,15 +77,11 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeItem: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onItemMouseEnter(event, item) {
|
||||
if (this.disabled(item)) {
|
||||
event.preventDefault();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,6 +90,7 @@ export default {
|
|||
onItemClick(event, item, navigate) {
|
||||
if (this.disabled(item)) {
|
||||
event.preventDefault();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,10 +102,8 @@ export default {
|
|||
}
|
||||
|
||||
if (item.items) {
|
||||
if (this.activeItem && item === this.activeItem)
|
||||
this.activeItem = null;
|
||||
else
|
||||
this.activeItem = item;
|
||||
if (this.activeItem && item === this.activeItem) this.activeItem = null;
|
||||
else this.activeItem = item;
|
||||
}
|
||||
|
||||
if (!item.items) {
|
||||
|
@ -115,51 +123,55 @@ export default {
|
|||
},
|
||||
position() {
|
||||
const parentItem = this.$refs.container.parentElement;
|
||||
const containerOffset = DomHandler.getOffset(this.$refs.container.parentElement)
|
||||
const containerOffset = DomHandler.getOffset(this.$refs.container.parentElement);
|
||||
const viewport = DomHandler.getViewport();
|
||||
const sublistWidth = this.$refs.container.offsetParent ? this.$refs.container.offsetWidth : DomHandler.getHiddenElementOuterWidth(this.$refs.container);
|
||||
const itemOuterWidth = DomHandler.getOuterWidth(parentItem.children[0]);
|
||||
|
||||
this.$refs.container.style.top = '0px';
|
||||
|
||||
if ((parseInt(containerOffset.left, 10) + itemOuterWidth + sublistWidth) > (viewport.width - DomHandler.calculateScrollbarWidth())) {
|
||||
if (parseInt(containerOffset.left, 10) + itemOuterWidth + sublistWidth > viewport.width - DomHandler.calculateScrollbarWidth()) {
|
||||
this.$refs.container.style.left = -1 * sublistWidth + 'px';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$refs.container.style.left = itemOuterWidth + 'px';
|
||||
}
|
||||
},
|
||||
getItemClass(item) {
|
||||
return [
|
||||
'p-menuitem', item.class, {
|
||||
'p-menuitem',
|
||||
item.class,
|
||||
{
|
||||
'p-menuitem-active': this.activeItem === item
|
||||
}
|
||||
]
|
||||
];
|
||||
},
|
||||
linkClass(item, routerProps) {
|
||||
return ['p-menuitem-link', {
|
||||
'p-disabled': this.disabled(item),
|
||||
'router-link-active': routerProps && routerProps.isActive,
|
||||
'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
|
||||
}];
|
||||
return [
|
||||
'p-menuitem-link',
|
||||
{
|
||||
'p-disabled': this.disabled(item),
|
||||
'router-link-active': routerProps && routerProps.isActive,
|
||||
'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
|
||||
}
|
||||
];
|
||||
},
|
||||
visible(item) {
|
||||
return (typeof item.visible === 'function' ? item.visible() : item.visible !== false);
|
||||
return typeof item.visible === 'function' ? item.visible() : item.visible !== false;
|
||||
},
|
||||
disabled(item) {
|
||||
return (typeof item.disabled === 'function' ? item.disabled() : item.disabled);
|
||||
return typeof item.disabled === 'function' ? item.disabled() : item.disabled;
|
||||
},
|
||||
label(item) {
|
||||
return (typeof item.label === 'function' ? item.label() : item.label);
|
||||
return typeof item.label === 'function' ? item.label() : item.label;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
containerClass() {
|
||||
return {'p-submenu-list': !this.root};
|
||||
return { 'p-submenu-list': !this.root };
|
||||
}
|
||||
},
|
||||
directives: {
|
||||
'ripple': Ripple
|
||||
ripple: Ripple
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue