import { defineComponent, ref, computed, onMounted, resolveComponent, openBlock, createBlock, normalizeStyle, unref, withCtx, createVNode, createElementVNode, createElementBlock, Fragment, renderList, normalizeClass, resolveDynamicComponent, createTextVNode, toDisplayString } from 'vue';
import { RecycleScroller as script$2 } from '../../../../node_modules/.pnpm/vue-virtual-scroller@2.0.0-beta.8_vue@3.2.37/node_modules/vue-virtual-scroller/dist/vue-virtual-scroller.esm.mjs';
import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';

const _hoisted_1 = { class: "qd-table-v3__row-cell--fixed flex" };
const _hoisted_2 = { class: "qd-table-v3__row-cell--fixed flex" };
const __default__ = defineComponent({
  name: "ElTableV3"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    width: { type: Number, required: true },
    itemSize: { type: Number, required: true, default: 80 },
    columns: { type: Array, required: true },
    dataList: { type: Array, required: true },
    height: { type: Number, required: true },
    keyField: { type: String, required: true, default: "id" },
    headerHeight: { type: Number, required: true, default: 60 },
    rowClass: { type: Function, required: true, default: () => "" }
  },
  setup(__props) {
    const props = __props;
    const scrollBarRef = ref();
    const scrollerRef = ref();
    const fixedLeftColumns = computed(() => {
      return props.columns.filter((e) => e.fixed === "left");
    });
    const noFixedColumns = computed(() => {
      return props.columns.filter((e) => e.fixed !== "left");
    });
    const totalWidth = computed(() => {
      return props.columns.reduce((acc, item) => acc + item.width, 0);
    });
    onMounted(() => {
      if (scrollBarRef.value && scrollerRef.value) {
        scrollBarRef.value.update();
      }
    });
    return (_ctx, _cache) => {
      var _a;
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      return openBlock(), createBlock(_component_el_scrollbar, {
        ref_key: "scrollBarRef",
        ref: scrollBarRef,
        class: "qd-table-v3",
        "custom-el": (_a = scrollerRef.value) == null ? void 0 : _a.$el,
        "custom-extra-gap": __props.headerHeight,
        style: normalizeStyle({
          "--row-total-width": unref(totalWidth) + "px",
          "--vertical-bar-top": __props.headerHeight + 2 + "px"
        })
      }, {
        default: withCtx(() => {
          var _a2;
          return [
            createVNode(unref(script$2), {
              ref_key: "scrollerRef",
              ref: scrollerRef,
              items: __props.dataList,
              "item-size": __props.itemSize,
              style: normalizeStyle({
                height: __props.height + "px",
                width: __props.width + "px"
              }),
              "key-field": __props.keyField,
              class: "qd-table-v3__table",
              onScroll: (_a2 = scrollBarRef.value) == null ? void 0 : _a2.handleScroll
            }, {
              before: withCtx(() => [
                createElementVNode("div", {
                  class: "qd-table-v3__header-row relative",
                  style: normalizeStyle({
                    width: unref(totalWidth) + "px"
                  })
                }, [
                  createElementVNode("div", _hoisted_1, [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fixedLeftColumns), (columnItem, columnIndex) => {
                      return openBlock(), createElementBlock("div", {
                        key: columnIndex,
                        style: normalizeStyle({
                          width: columnItem.width + "px"
                        }),
                        class: normalizeClass(["qd-table-v3__header-cell", columnItem.headerClass])
                      }, [
                        columnItem.headerCellRenderer ? (openBlock(), createBlock(resolveDynamicComponent(columnItem.headerCellRenderer), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                          createTextVNode(toDisplayString(columnItem.title), 1)
                        ], 64))
                      ], 6);
                    }), 128))
                  ]),
                  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(noFixedColumns), (columnItem, columnIndex) => {
                    return openBlock(), createElementBlock("div", {
                      key: columnIndex,
                      style: normalizeStyle({
                        width: columnItem.width + "px"
                      }),
                      class: normalizeClass(["qd-table-v3__header-cell", columnItem.headerClass])
                    }, [
                      columnItem.headerCellRenderer ? (openBlock(), createBlock(resolveDynamicComponent(columnItem.headerCellRenderer), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                        createTextVNode(toDisplayString(columnItem.title), 1)
                      ], 64))
                    ], 6);
                  }), 128))
                ], 4)
              ]),
              default: withCtx(({ item }) => [
                createElementVNode("div", {
                  class: normalizeClass(["qd-table-v3__row relative", __props.rowClass(item)]),
                  style: normalizeStyle({
                    height: __props.itemSize + "px",
                    width: unref(totalWidth) + "px"
                  })
                }, [
                  createElementVNode("div", _hoisted_2, [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fixedLeftColumns), (columnItem, columnIndex) => {
                      return openBlock(), createElementBlock("div", {
                        key: columnIndex,
                        style: normalizeStyle({
                          width: columnItem.width + "px"
                        }),
                        class: normalizeClass(["qd-table-v3__row-cell", columnItem.class])
                      }, [
                        (openBlock(), createBlock(resolveDynamicComponent(columnItem.cellRenderer({
                          rowData: item,
                          rowIndex: columnIndex
                        }))))
                      ], 6);
                    }), 128))
                  ]),
                  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(noFixedColumns), (columnItem, columnIndex) => {
                    return openBlock(), createElementBlock("div", {
                      key: columnIndex,
                      style: normalizeStyle({
                        width: columnItem.width + "px"
                      }),
                      class: normalizeClass(["qd-table-v3__row-cell", columnItem.class])
                    }, [
                      (openBlock(), createBlock(resolveDynamicComponent(columnItem.cellRenderer({
                        rowData: item,
                        rowIndex: columnIndex
                      }))))
                    ], 6);
                  }), 128))
                ], 6)
              ]),
              _: 1
            }, 8, ["items", "item-size", "style", "key-field", "onScroll"])
          ];
        }),
        _: 1
      }, 8, ["custom-el", "custom-extra-gap", "style"]);
    };
  }
});
var TableV3 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/judai/code/ddll-element-plus/packages/components/table-v3/src/table-v3.vue"]]);

export { TableV3 as default };
//# sourceMappingURL=table-v32.mjs.map
