import { defineComponent, inject, createVNode, Fragment } from 'vue';
import { useEventListener } from '@vueuse/core';
import { provideKey } from '../const';
import Colgroup from './colgroup';
import Header from './header';

var headerTable = defineComponent({
  props: {
    columns: {
      type: Array,
      required: true
    }
  },
  setup(props) {
    const {
      prefixCls,
      headerWrapperRef,
      headerWrapperClass,
      headerStyle,
      headerShadowVisible,
      handleHeaderMousewheel
    } = inject(provideKey);
    useEventListener(headerWrapperRef, 'wheel', handleHeaderMousewheel, {
      passive: false
    });
    return () => {
      return createVNode(Fragment, null, [headerShadowVisible.value.left ? createVNode("div", {
        "class": `${prefixCls}-header-shadow-left`
      }, null) : undefined, createVNode("div", {
        "ref": el => {
          headerWrapperRef.value = el;
        },
        "class": headerWrapperClass.value
      }, [createVNode("table", {
        "class": `${prefixCls}-header`,
        "style": headerStyle.value,
        "cellspacing": "0",
        "cellpadding": "0"
      }, [createVNode(Colgroup, {
        "columns": props.columns
      }, null), createVNode(Header, {
        "columns": props.columns
      }, null)])]), headerShadowVisible.value.right ? createVNode("div", {
        "class": `${prefixCls}-header-shadow-right`
      }, null) : undefined]);
    };
  }
});

export { headerTable as default };
