From 6ec518c7718bfacbf489b7be8928b16971e9b7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Wed, 30 Aug 2023 10:27:41 +0300 Subject: [PATCH] Refactor #4351 - For MegaMenu --- components/lib/megamenu/MegaMenu.vue | 36 ++++-------------------- components/lib/megamenu/MegaMenuSub.vue | 37 +++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/components/lib/megamenu/MegaMenu.vue b/components/lib/megamenu/MegaMenu.vue index bb29a446c..cad276116 100755 --- a/components/lib/megamenu/MegaMenu.vue +++ b/components/lib/megamenu/MegaMenu.vue @@ -22,6 +22,7 @@ :exact="exact" :level="0" :pt="pt" + :unstyled="unstyled" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @@ -43,36 +44,6 @@ export default { name: 'MegaMenu', extends: BaseMegaMenu, emits: ['focus', 'blur'], - props: { - model: { - type: Array, - default: null - }, - orientation: { - type: String, - default: 'horizontal' - }, - exact: { - type: Boolean, - default: true - }, - disabled: { - type: Boolean, - default: false - }, - tabindex: { - type: Number, - default: 0 - }, - 'aria-labelledby': { - type: String, - default: null - }, - 'aria-label': { - type: String, - default: null - } - }, outsideClickListener: null, resizeListener: null, container: null, @@ -102,6 +73,11 @@ 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(); }, diff --git a/components/lib/megamenu/MegaMenuSub.vue b/components/lib/megamenu/MegaMenuSub.vue index 12180acfd..05fb56b18 100644 --- a/components/lib/megamenu/MegaMenuSub.vue +++ b/components/lib/megamenu/MegaMenuSub.vue @@ -26,20 +26,20 @@ - +
@@ -84,6 +84,7 @@ import AngleDownIcon from 'primevue/icons/angledown'; import AngleRightIcon from 'primevue/icons/angleright'; import Ripple from 'primevue/ripple'; import { ObjectUtils } from 'primevue/utils'; +import { mergeProps } from 'vue'; export default { name: 'MegaMenuSub', @@ -191,6 +192,36 @@ export default { }, getAriaPosInset(index) { return index - this.items.slice(0, index).filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')).length + 1; + }, + getMenuItemProps(processedItem, index) { + return { + action: mergeProps( + { + class: this.cx('action'), + tabindex: -1, + 'aria-hidden': true + }, + this.getPTOptions(processedItem, index, 'action') + ), + icon: mergeProps( + { + class: [this.cx('icon'), this.getItemProp(processedItem, 'icon')] + }, + this.getPTOptions(processedItem, index, 'icon') + ), + label: mergeProps( + { + class: this.cx('label') + }, + this.getPTOptions(processedItem, index, 'label') + ), + submenuicon: mergeProps( + { + class: this.cx('submenuIcon') + }, + this.getPTOptions(processedItem, index, 'submenuIcon') + ) + }; } }, components: {