UNPKG

vxe-table

Version:

A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.

59 lines (58 loc) • 1.73 kB
import { h, onUnmounted, provide, inject, ref, onMounted, createCommentVNode } from "vue"; import { defineVxeComponent } from "../../ui/src/comp"; import { columnProps } from "./column"; import { watchColumn, assembleColumn, destroyColumn } from "./util"; import Cell from "./cell"; var group_default = ( /* define-vxe-component start */ defineVxeComponent({ name: "VxeColgroup", props: columnProps, setup(props, { slots }) { const refElem = ref(); const $xeTable = inject("$xeTable", null); const $xeParentColgroup = inject("$xeColgroup", null); if (!$xeTable) { return () => createCommentVNode(); } const columnConfig = Cell.createColumn($xeTable, props); const columnSlots = {}; if (slots.header) { columnSlots.header = slots.header; } if (slots.title) { columnSlots.title = slots.title; } columnConfig.slots = columnSlots; columnConfig.children = []; watchColumn($xeTable, props, columnConfig); onMounted(() => { const elem = refElem.value; if (elem) { assembleColumn($xeTable, elem, columnConfig, $xeParentColgroup); } }); onUnmounted(() => { destroyColumn($xeTable, columnConfig); }); const renderVN = () => { const defaultSlot = slots.default; return h( "div", { ref: refElem }, defaultSlot ? defaultSlot() : [] ); }; const $xeColgroup = { columnConfig }; provide("$xeColgroup", $xeColgroup); provide("$xeGrid", null); provide("$xeGantt", null); return renderVN; } }) ); export { group_default as default };