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

<script>
import { cn } from '@primeuix/utils';
import InputColorAreaBackground from 'primevue/inputcolorareabackground';
import InputColorAreaHandle from 'primevue/inputcolorareahandle';
import { mergeProps } from 'vue';
import BaseInputColorArea from './BaseInputColorArea.vue';

export default {
    name: 'InputColorArea',
    extends: BaseInputColorArea,
    inheritAttrs: false,
    inject: ['$pcInputColor'],
    components: {
        InputColorAreaBackground,
        InputColorAreaHandle
    },
    computed: {
        attrs() {
            return mergeProps(this.a11yAttrs, this.ptmi('root'));
        },
        a11yAttrs() {
            return {
                style: this.$pcInputColor.areaStyles,
                'data-p': this.dataP,
                onPointerdown: this.$pcInputColor.onAreaPointerDown,
                onPointermove: this.$pcInputColor.onAreaPointerMove,
                onPointerup: this.$pcInputColor.onAreaPointerUp
            };
        },
        dataP() {
            return cn({
                disabled: this.$pcInputColor.disabled,
                dragging: this.$pcInputColor.isAreaDragging
            });
        }
    }
};
</script>
