UNPKG

@visactor/vue-vtable

Version:
49 lines (46 loc) 2.15 kB
import { defineComponent, ref, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue'; import _sfc_main$1 from './base-table.vue.js'; import { flattenVNodes } from '../utils/vnodeUtils.js'; import { extractListSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js'; // 定义属性 var _sfc_main = /*@__PURE__*/ defineComponent({ __name: 'list-table', props: { options: { type: Object, required: true }, records: { type: Array, required: false }, width: { type: [String, Number], required: false }, height: { type: [String, Number], required: false } }, setup(__props, { expose: __expose }) { const props = __props; // 引用BaseTable实例 const baseTableRef = ref(null); const slots = useSlots(); // 合并插槽配置 const computedOptions = computed(() => { var _a; const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []); const slotOptions = extractListSlotOptions(flattenedSlots); return mergeSlotOptions(props.options, slotOptions); }); // 暴露实例 __expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }), }); return (_ctx, _cache) => { return (openBlock(), createElementBlock(Fragment, null, [ createVNode(_sfc_main$1, mergeProps({ type: "list", options: computedOptions.value, records: __props.records, width: __props.width, height: __props.height, ref_key: "baseTableRef", ref: baseTableRef }, _ctx.$attrs), null, 16 /* FULL_PROPS */, ["options", "records", "width", "height"]), renderSlot(_ctx.$slots, "default") ], 64 /* STABLE_FRAGMENT */)); }; } }); export { _sfc_main as default };