From 10fd09df830589fffdc18fa9358c4ef8d58e2438 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: Mon, 24 Jul 2023 13:48:47 +0300 Subject: [PATCH] Refactor #4196 - For PanelMenu --- components/lib/panelmenu/PanelMenu.d.ts | 4 ++++ components/lib/panelmenu/PanelMenu.vue | 23 ++++++++++++----------- components/lib/panelmenu/PanelMenuSub.vue | 23 ++++++++++++----------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/components/lib/panelmenu/PanelMenu.d.ts b/components/lib/panelmenu/PanelMenu.d.ts index 0ca71306a..00629c012 100755 --- a/components/lib/panelmenu/PanelMenu.d.ts +++ b/components/lib/panelmenu/PanelMenu.d.ts @@ -134,6 +134,10 @@ export interface PanelMenuState { * Defines current options in PanelMenu component. */ export interface PanelMenuContext { + /** + * Index of the menuitem. + */ + index: number; /** * Current active state of menuitem as a boolean. * @defaultValue false diff --git a/components/lib/panelmenu/PanelMenu.vue b/components/lib/panelmenu/PanelMenu.vue index ca14f67a3..53dfbc76d 100644 --- a/components/lib/panelmenu/PanelMenu.vue +++ b/components/lib/panelmenu/PanelMenu.vue @@ -13,26 +13,26 @@ :aria-disabled="isItemDisabled(item)" @click="onHeaderClick($event, item)" @keydown="onHeaderKeyDown($event, item)" - v-bind="getPTOptions(item, 'header')" + v-bind="getPTOptions('header', item, index)" :data-p-highlight="isItemActive(item)" :data-p-disabled="isItemDisabled(item)" > -
+
@@ -91,9 +91,10 @@ export default { getItemLabel(item) { return this.getItemProp(item, 'label'); }, - getPTOptions(item, key) { + getPTOptions(key, item, index) { return this.ptm(key, { - options: { + context: { + index, active: this.isItemActive(item), focused: this.isItemFocused(item) } diff --git a/components/lib/panelmenu/PanelMenuSub.vue b/components/lib/panelmenu/PanelMenuSub.vue index e64324f11..8e9abff6c 100755 --- a/components/lib/panelmenu/PanelMenuSub.vue +++ b/components/lib/panelmenu/PanelMenuSub.vue @@ -12,27 +12,27 @@ :aria-level="level + 1" :aria-setsize="getAriaSetSize()" :aria-posinset="getAriaPosInset(index)" - v-bind="getPTOptions(processedItem, 'menuitem')" + v-bind="getPTOptions('menuitem', processedItem, index)" :data-p-focused="isItemFocused(processedItem)" :data-p-disabled="isItemDisabled(processedItem)" > -
+
@@ -127,9 +127,10 @@ export default { getItemLabel(processedItem) { return this.getItemProp(processedItem, 'label'); }, - getPTOptions(processedItem, key) { + getPTOptions(key, processedItem, index) { return this.ptm(key, { context: { + index, active: this.isItemActive(processedItem), focused: this.isItemFocused(processedItem) }