Refactor #4739 - For ContextMenu
parent
ad9b437003
commit
661048609e
|
@ -26,10 +26,6 @@ export default {
|
|||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
exact: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
tabindex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
|
|
|
@ -241,6 +241,7 @@ export interface ContextMenuProps {
|
|||
global?: boolean | undefined;
|
||||
/**
|
||||
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
|
||||
* @deprecated since v3.40.0.
|
||||
* @defaultValue true
|
||||
*/
|
||||
exact?: boolean | undefined;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
:items="processedItems"
|
||||
:templates="$slots"
|
||||
:activeItemPath="activeItemPath"
|
||||
:exact="exact"
|
||||
:aria-labelledby="ariaLabelledby"
|
||||
:aria-label="ariaLabel"
|
||||
:level="0"
|
||||
|
@ -77,11 +76,6 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
if (!this.$slots.item) {
|
||||
console.warn('In future versions, vue-router support will be removed. Item templating should be used.');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.id = this.id || UniqueComponentId();
|
||||
|
||||
|
|
|
@ -22,14 +22,7 @@
|
|||
>
|
||||
<div :class="cx('content')" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)" v-bind="getPTOptions('content', processedItem, index)">
|
||||
<template v-if="!templates.item">
|
||||
<router-link v-if="getItemProp(processedItem, 'to') && !isItemDisabled(processedItem)" v-slot="{ navigate, href, isActive, isExactActive }" :to="getItemProp(processedItem, 'to')" custom>
|
||||
<a v-ripple :href="href" :class="cx('action', { isActive, isExactActive })" tabindex="-1" aria-hidden="true" @click="onItemActionClick($event, navigate)" v-bind="getPTOptions('action', processedItem, index)">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="processedItem.item" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" />
|
||||
<span v-else-if="getItemProp(processedItem, 'icon')" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" v-bind="getPTOptions('icon', processedItem, index)" />
|
||||
<span :class="cx('label')" v-bind="getPTOptions('label', processedItem, index)">{{ getItemLabel(processedItem) }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<a v-else v-ripple :href="getItemProp(processedItem, 'url')" :class="cx('action')" :target="getItemProp(processedItem, 'target')" tabindex="-1" aria-hidden="true" v-bind="getPTOptions('action', processedItem, index)">
|
||||
<a v-ripple :href="getItemProp(processedItem, 'url')" :class="cx('action')" :target="getItemProp(processedItem, 'target')" tabindex="-1" aria-hidden="true" v-bind="getPTOptions('action', processedItem, index)">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="processedItem.item" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" />
|
||||
<span v-else-if="getItemProp(processedItem, 'icon')" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" v-bind="getPTOptions('icon', processedItem, index)" />
|
||||
<span :class="cx('label')" v-bind="getPTOptions('label', processedItem, index)">{{ getItemLabel(processedItem) }}</span>
|
||||
|
@ -51,7 +44,6 @@
|
|||
:items="processedItem.items"
|
||||
:templates="templates"
|
||||
:activeItemPath="activeItemPath"
|
||||
:exact="exact"
|
||||
:level="level + 1"
|
||||
:visible="isItemActive(processedItem) && isItemGroup(processedItem)"
|
||||
:pt="pt"
|
||||
|
@ -115,10 +107,6 @@ export default {
|
|||
type: Object,
|
||||
default: null
|
||||
},
|
||||
exact: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
activeItemPath: {
|
||||
type: Object,
|
||||
default: null
|
||||
|
@ -174,9 +162,6 @@ export default {
|
|||
onItemMouseEnter(event, processedItem) {
|
||||
this.$emit('item-mouseenter', { originalEvent: event, processedItem });
|
||||
},
|
||||
onItemActionClick(event, navigate) {
|
||||
navigate && navigate(event);
|
||||
},
|
||||
getAriaSetSize() {
|
||||
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
|
||||
},
|
||||
|
|
|
@ -63,13 +63,7 @@ const classes = {
|
|||
}
|
||||
],
|
||||
content: 'p-menuitem-content',
|
||||
action: ({ props, isActive, isExactActive }) => [
|
||||
'p-menuitem-link',
|
||||
{
|
||||
'router-link-active': isActive,
|
||||
'router-link-active-exact': props.exact && isExactActive
|
||||
}
|
||||
],
|
||||
action: 'p-menuitem-link',
|
||||
icon: 'p-menuitem-icon',
|
||||
label: 'p-menuitem-text',
|
||||
submenuIcon: 'p-submenu-icon',
|
||||
|
|
Loading…
Reference in New Issue