Refactor #4739 - For ContextMenu

pull/4763/head
tugcekucukoglu 2023-11-08 15:48:09 +03:00
parent ad9b437003
commit 661048609e
5 changed files with 3 additions and 33 deletions

View File

@ -26,10 +26,6 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
exact: {
type: Boolean,
default: true
},
tabindex: { tabindex: {
type: Number, type: Number,
default: 0 default: 0

View File

@ -241,6 +241,7 @@ export interface ContextMenuProps {
global?: boolean | undefined; global?: boolean | undefined;
/** /**
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path. * Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
* @deprecated since v3.40.0.
* @defaultValue true * @defaultValue true
*/ */
exact?: boolean | undefined; exact?: boolean | undefined;

View File

@ -16,7 +16,6 @@
:items="processedItems" :items="processedItems"
:templates="$slots" :templates="$slots"
:activeItemPath="activeItemPath" :activeItemPath="activeItemPath"
:exact="exact"
:aria-labelledby="ariaLabelledby" :aria-labelledby="ariaLabelledby"
:aria-label="ariaLabel" :aria-label="ariaLabel"
:level="0" :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() { mounted() {
this.id = this.id || UniqueComponentId(); this.id = this.id || UniqueComponentId();

View File

@ -22,14 +22,7 @@
> >
<div :class="cx('content')" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)" v-bind="getPTOptions('content', processedItem, index)"> <div :class="cx('content')" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)" v-bind="getPTOptions('content', processedItem, index)">
<template v-if="!templates.item"> <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="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="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)">
<component v-if="templates.itemicon" :is="templates.itemicon" :item="processedItem.item" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" /> <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 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> <span :class="cx('label')" v-bind="getPTOptions('label', processedItem, index)">{{ getItemLabel(processedItem) }}</span>
@ -51,7 +44,6 @@
:items="processedItem.items" :items="processedItem.items"
:templates="templates" :templates="templates"
:activeItemPath="activeItemPath" :activeItemPath="activeItemPath"
:exact="exact"
:level="level + 1" :level="level + 1"
:visible="isItemActive(processedItem) && isItemGroup(processedItem)" :visible="isItemActive(processedItem) && isItemGroup(processedItem)"
:pt="pt" :pt="pt"
@ -115,10 +107,6 @@ export default {
type: Object, type: Object,
default: null default: null
}, },
exact: {
type: Boolean,
default: true
},
activeItemPath: { activeItemPath: {
type: Object, type: Object,
default: null default: null
@ -174,9 +162,6 @@ export default {
onItemMouseEnter(event, processedItem) { onItemMouseEnter(event, processedItem) {
this.$emit('item-mouseenter', { originalEvent: event, processedItem }); this.$emit('item-mouseenter', { originalEvent: event, processedItem });
}, },
onItemActionClick(event, navigate) {
navigate && navigate(event);
},
getAriaSetSize() { getAriaSetSize() {
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length; return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
}, },

View File

@ -63,13 +63,7 @@ const classes = {
} }
], ],
content: 'p-menuitem-content', content: 'p-menuitem-content',
action: ({ props, isActive, isExactActive }) => [ action: 'p-menuitem-link',
'p-menuitem-link',
{
'router-link-active': isActive,
'router-link-active-exact': props.exact && isExactActive
}
],
icon: 'p-menuitem-icon', icon: 'p-menuitem-icon',
label: 'p-menuitem-text', label: 'p-menuitem-text',
submenuIcon: 'p-submenu-icon', submenuIcon: 'p-submenu-icon',