Refactor #4190 - For Menu

pull/4208/head
Tuğçe Küçükoğlu 2023-07-25 12:11:23 +03:00
parent b89643cef1
commit fd326c4d8d
3 changed files with 13 additions and 2 deletions

View File

@ -119,6 +119,14 @@ export interface MenuState {
* Defines current options in Menu component.
*/
export interface MenuContext {
/**
* Current menuitem
*/
item: any;
/**
* Current index of the menuitem.
*/
index: number;
/**
* Current focused state of menuitem as a boolean.
* @defaultValue false

View File

@ -30,7 +30,7 @@
</template>
</template>
<li v-else-if="visible(item) && item.separator" :key="'separator' + i.toString()" :class="[cx('separator'), item.class]" :style="item.style" role="separator" v-bind="ptm('separator')"></li>
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :templates="$slots" :exact="exact" :focusedOptionId="focusedOptionId" @item-click="itemClick" :pt="pt" />
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :index="i" :templates="$slots" :exact="exact" :focusedOptionId="focusedOptionId" @item-click="itemClick" :pt="pt" />
</template>
</ul>
<div v-if="$slots.end" :class="cx('end')" v-bind="ptm('end')">

View File

@ -47,7 +47,8 @@ export default {
templates: null,
exact: null,
id: null,
focusedOptionId: null
focusedOptionId: null,
index: null
},
methods: {
getItemProp(processedItem, name) {
@ -56,6 +57,8 @@ export default {
getPTOptions(key) {
return this.ptm(key, {
context: {
item: this.item,
index: this.index,
focused: this.isItemFocused()
}
});