<template>
    <component v-if="!asChild" :is="as" :class="cx('root')" :type="as === 'BUTTON' || as === 'button' ? 'button' : undefined" v-bind="attrs">
        <slot />
    </component>
    <slot v-else :a11yAttrs="a11yAttrs" :class="cx('root')" />
</template>

<script>
import { mergeProps } from 'vue';
import BaseSidebarMenuAction from './BaseSidebarMenuAction.vue';

export default {
    name: 'SidebarMenuAction',
    extends: BaseSidebarMenuAction,
    inheritAttrs: false,
    inject: {
        $pcSidebar: { default: null }
    },
    computed: {
        a11yAttrs() {
            return {
                'data-pc-name': 'sidebarmenuaction',
                'data-pc-section': 'root',
                'data-show-on-hover': this.showOnHover ? '' : undefined
            };
        },
        attrs() {
            return mergeProps(this.a11yAttrs, this.ptmi('root'));
        }
    }
};
</script>
