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. * Defines current options in Menu component.
*/ */
export interface MenuContext { export interface MenuContext {
/**
* Current menuitem
*/
item: any;
/**
* Current index of the menuitem.
*/
index: number;
/** /**
* Current focused state of menuitem as a boolean. * Current focused state of menuitem as a boolean.
* @defaultValue false * @defaultValue false

View File

@ -30,7 +30,7 @@
</template> </template>
</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> <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> </template>
</ul> </ul>
<div v-if="$slots.end" :class="cx('end')" v-bind="ptm('end')"> <div v-if="$slots.end" :class="cx('end')" v-bind="ptm('end')">

View File

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