@visactor/vue-vtable
Version:
The vue version of VTable
43 lines (40 loc) • 2.04 kB
JavaScript
import { defineComponent, shallowRef, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
import _sfc_main$1 from './base-table.vue.js';
import { extractPivotSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js';
import { flattenVNodes } from '../utils/vnodeUtils.js';
var _sfc_main = /*@__PURE__*/ defineComponent({
__name: 'pivot-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 = shallowRef(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 = extractPivotSlotOptions(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: "pivot",
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 };