Refactor #4739 - For TieredMenu
parent
ed4b74c0a7
commit
8a78d275f4
|
@ -26,10 +26,6 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
exact: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
|
|
@ -235,6 +235,7 @@ export interface TieredMenuProps {
|
||||||
baseZIndex?: number | undefined;
|
baseZIndex?: number | 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;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
:items="processedItems"
|
:items="processedItems"
|
||||||
:templates="$slots"
|
:templates="$slots"
|
||||||
:activeItemPath="activeItemPath"
|
:activeItemPath="activeItemPath"
|
||||||
:exact="exact"
|
|
||||||
:level="0"
|
:level="0"
|
||||||
:pt="pt"
|
:pt="pt"
|
||||||
:unstyled="unstyled"
|
:unstyled="unstyled"
|
||||||
|
@ -84,11 +83,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();
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,14 +21,7 @@
|
||||||
>
|
>
|
||||||
<div :class="cx('content')" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)" v-bind="getPTOptions(processedItem, index, 'content')">
|
<div :class="cx('content')" @click="onItemClick($event, processedItem)" @mouseenter="onItemMouseEnter($event, processedItem)" v-bind="getPTOptions(processedItem, index, 'content')">
|
||||||
<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(processedItem, index, 'action')">
|
||||||
<a v-ripple :href="href" :class="cx('action', { isActive, isExactActive })" tabindex="-1" aria-hidden="true" @click="onItemActionClick($event, navigate)" v-bind="getPTOptions(processedItem, index, 'action')">
|
|
||||||
<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(processedItem, index, 'icon')" />
|
|
||||||
<span :class="cx('label')" v-bind="getPTOptions(processedItem, index, 'label')">{{ 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(processedItem, index, 'action')">
|
|
||||||
<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(processedItem, index, 'icon')" />
|
<span v-else-if="getItemProp(processedItem, 'icon')" :class="[cx('icon'), getItemProp(processedItem, 'icon')]" v-bind="getPTOptions(processedItem, index, 'icon')" />
|
||||||
<span :class="cx('label')" v-bind="getPTOptions(processedItem, index, 'label')">{{ getItemLabel(processedItem) }}</span>
|
<span :class="cx('label')" v-bind="getPTOptions(processedItem, index, 'label')">{{ getItemLabel(processedItem) }}</span>
|
||||||
|
@ -50,7 +43,6 @@
|
||||||
:items="processedItem.items"
|
:items="processedItem.items"
|
||||||
:templates="templates"
|
:templates="templates"
|
||||||
:activeItemPath="activeItemPath"
|
:activeItemPath="activeItemPath"
|
||||||
:exact="exact"
|
|
||||||
:level="level + 1"
|
:level="level + 1"
|
||||||
:pt="pt"
|
:pt="pt"
|
||||||
:unstyled="unstyled"
|
:unstyled="unstyled"
|
||||||
|
@ -107,10 +99,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
exact: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
tabindex: {
|
tabindex: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
|
@ -162,9 +150,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,13 +68,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',
|
||||||
text: 'p-menuitem-text',
|
text: 'p-menuitem-text',
|
||||||
submenuIcon: 'p-submenu-icon',
|
submenuIcon: 'p-submenu-icon',
|
||||||
|
|
Loading…
Reference in New Issue