Skip to content

Commit

Permalink
Refactor #4739 - For PanelMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Nov 8, 2023
1 parent f00540f commit c1c866b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 56 deletions.
4 changes: 0 additions & 4 deletions components/lib/panelmenu/BasePanelMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export default {
type: Object,
default: null
},
exact: {
type: Boolean,
default: true
},
tabindex: {
type: Number,
default: 0
Expand Down
1 change: 1 addition & 0 deletions components/lib/panelmenu/PanelMenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export interface PanelMenuProps {
expandedKeys?: PanelMenuExpandedKeys;
/**
* 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;
Expand Down
18 changes: 1 addition & 17 deletions components/lib/panelmenu/PanelMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@
>
<div :class="cx('headerContent')" v-bind="getPTOptions('headerContent', item, index)">
<template v-if="!$slots.item">
<router-link v-if="getItemProp(item, 'to') && !isItemDisabled(item)" v-slot="{ navigate, href, isActive, isExactActive }" :to="getItemProp(item, 'to')" custom>
<a :href="href" :class="cx('headerAction', { isActive, isExactActive })" :tabindex="-1" @click="onHeaderActionClick($event, navigate)" v-bind="getPTOptions('headerAction', item, index)">
<component v-if="$slots.headericon" :is="$slots.headericon" :item="item" :class="[cx('headerIcon'), getItemProp(item, 'icon')]" />
<span v-else-if="getItemProp(item, 'icon')" :class="[cx('headerIcon'), getItemProp(item, 'icon')]" v-bind="getPTOptions('headerIcon', item, index)" />
<span :class="cx('headerLabel')" v-bind="getPTOptions('headerLabel', item, index)">{{ getItemLabel(item) }}</span>
</a>
</router-link>
<a v-else :href="getItemProp(item, 'url')" :class="cx('headerAction')" :tabindex="-1" v-bind="getPTOptions('headerAction', item, index)">
<a :href="getItemProp(item, 'url')" :class="cx('headerAction')" :tabindex="-1" v-bind="getPTOptions('headerAction', item, index)">
<slot v-if="getItemProp(item, 'items')" name="submenuicon" :active="isItemActive(item)">
<component :is="isItemActive(item) ? 'ChevronDownIcon' : 'ChevronRightIcon'" :class="cx('submenuIcon')" v-bind="getPTOptions('submenuIcon', item, index)" />
</slot>
Expand All @@ -48,7 +41,6 @@
:expandedKeys="expandedKeys"
@item-toggle="changeExpandedKeys"
@header-focus="updateFocusedHeader"
:exact="exact"
:pt="pt"
:unstyled="unstyled"
/>
Expand Down Expand Up @@ -83,11 +75,6 @@ export default {
this.id = newValue || UniqueComponentId();
}
},
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();
},
Expand Down Expand Up @@ -200,9 +187,6 @@ export default {
headerAction ? headerAction.click() : this.onHeaderClick(event, item);
event.preventDefault();
},
onHeaderActionClick(event, navigate) {
navigate && navigate(event);
},
findNextHeader(panelElement, selfCheck = false) {
const nextPanelElement = selfCheck ? panelElement : panelElement.nextElementSibling;
const headerElement = DomHandler.findSingle(nextPanelElement, '[data-pc-section="header"]');
Expand Down
5 changes: 0 additions & 5 deletions components/lib/panelmenu/PanelMenuList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
:items="processedItems"
:templates="templates"
:activeItemPath="activeItemPath"
:exact="exact"
@focus="onFocus"
@blur="onBlur"
@keydown="onKeyDown"
Expand Down Expand Up @@ -47,10 +46,6 @@ export default {
expandedKeys: {
type: Object,
default: null
},
exact: {
type: Boolean,
default: true
}
},
searchTimeout: null,
Expand Down
17 changes: 1 addition & 16 deletions components/lib/panelmenu/PanelMenuSub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@
>
<div :class="cx('content')" @click="onItemClick($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)">
<template v-if="isItemGroup(processedItem)">
<component v-if="templates.submenuicon" :is="templates.submenuicon" :class="cx('submenuIcon')" :active="isItemActive(processedItem)" v-bind="getPTOptions('submenuIcon', processedItem, index)" />
<component v-else :is="isItemActive(processedItem) ? 'ChevronDownIcon' : 'ChevronRightIcon'" :class="cx('submenuIcon')" v-bind="getPTOptions('submenuIcon', processedItem, index)" />
Expand Down Expand Up @@ -57,7 +50,6 @@
:level="level + 1"
:templates="templates"
:activeItemPath="activeItemPath"
:exact="exact"
@item-toggle="onItemToggle"
:pt="pt"
:unstyled="unstyled"
Expand Down Expand Up @@ -115,10 +107,6 @@ export default {
type: Object,
default: null
},
exact: {
type: Boolean,
default: true
},
tabindex: {
type: Number,
default: -1
Expand Down Expand Up @@ -170,9 +158,6 @@ export default {
onItemToggle(event) {
this.$emit('item-toggle', event);
},
onItemActionClick(event, navigate) {
navigate && navigate(event);
},
getAriaSetSize() {
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
},
Expand Down
16 changes: 2 additions & 14 deletions components/lib/panelmenu/style/PanelMenuStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ const classes = {
}
],
headerContent: 'p-panelmenu-header-content',
headerAction: ({ instance, isActive, isExactActive }) => [
'p-panelmenu-header-action',
{
'router-link-active': isActive,
'router-link-active-exact': instance.exact && isExactActive
}
],
headerAction: 'p-panelmenu-header-action',
headerIcon: 'p-menuitem-icon',
headerLabel: 'p-menuitem-text',
toggleableContent: 'p-toggleable-content',
Expand All @@ -68,13 +62,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',
Expand Down

0 comments on commit c1c866b

Please sign in to comment.