UNPKG

@visactor/vue-vtable

Version:

The vue version of VTable

47 lines (44 loc) 2.07 kB
import { defineComponent, ref, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue'; import { flattenVNodes } from '../utils/vnodeUtils.js'; import '@visactor/vtable'; import '@visactor/vutils'; import { extractListSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js'; import _sfc_main$1 from './base-table.vue.js'; var _sfc_main = 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; 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: _ctx.records, width: _ctx.width, height: _ctx.height, ref_key: "baseTableRef", ref: baseTableRef }, _ctx.$attrs), null, 16, ["options", "records", "width", "height"]), renderSlot(_ctx.$slots, "default") ], 64)); }; } }); export { _sfc_main as default };