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

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

export default {
    name: 'CarouselItem',
    extends: BaseCarouselItem,
    inheritAttrs: false,
    inject: ['$pcCarousel'],
    computed: {
        attrs() {
            return mergeProps(this.a11yAttrs, this.ptmi('root'));
        },
        a11yAttrs() {
            return {
                role: 'group',
                'aria-hidden': 'false',
                'data-pc-name': 'carouselitem',
                'data-pc-section': 'root',
                style: this.sx('root'),
                'data-value': this.value,
                'data-inview': 'false',
                'data-orientation': this.$pcCarousel?.orientation,
                'data-align': this.$pcCarousel?.align,
                'data-page': this.$pcCarousel?.d_page,
                'data-swiping': this.$pcCarousel?.swiping ? '' : undefined,
                'data-autosize': this.$pcCarousel?.autoSize ? '' : undefined
            };
        }
    }
};
</script>
