Refactor #4351 - For Menubar

pull/4356/head
Tuğçe Küçükoğlu 2023-08-30 09:40:53 +03:00
parent 340e6a82e5
commit 8cc457318b
2 changed files with 38 additions and 1 deletions

View File

@ -39,6 +39,7 @@
:aria-labelledby="ariaLabelledby"
:aria-label="ariaLabel"
:pt="pt"
:unstyled="unstyled"
@focus="onFocus"
@blur="onBlur"
@keydown="onKeyDown"
@ -88,6 +89,11 @@ export default {
outsideClickListener: null,
container: null,
menubar: null,
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();
},

View File

@ -38,7 +38,7 @@
</template>
</a>
</template>
<component v-else :is="templates.item" :item="processedItem.item"></component>
<component v-else :is="templates.item" :item="processedItem.item" :label="getItemLabel(processedItem)" :props="getMenuItemProps(processedItem, index)"></component>
</div>
<MenubarSub
v-if="isItemVisible(processedItem) && isItemGroup(processedItem)"
@ -76,6 +76,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: 'MenubarSub',
@ -179,6 +180,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')
),
icons: 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: {