UNPKG

@visactor/vue-vtable

Version:
35 lines (32 loc) 1.41 kB
import { getCurrentInstance, watchEffect } from 'vue'; import { VTableVueAttributePlugin } from '../components/custom/vtable-vue-attribute-plugin.js'; import { isArray } from '@visactor/vutils'; /** * 自定义单元格渲染器 * @param props * @param tableRef */ function useCellRender(props, tableRef) { var _a, _b; /** 当前实例 */ const instance = getCurrentInstance(); /** 自定义 dom 开关 */ const createReactContainer = (_b = (_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.customConfig) === null || _b === void 0 ? void 0 : _b.createReactContainer; watchEffect(() => { var _a, _b, _c; if (!createReactContainer) { return; } const pluginService = (_c = (_b = (_a = tableRef.value) === null || _a === void 0 ? void 0 : _a.scenegraph) === null || _b === void 0 ? void 0 : _b.stage) === null || _c === void 0 ? void 0 : _c.pluginService; if (!pluginService) { return; } const exist = pluginService.findPluginsByName('VTableVueAttributePlugin'); if (isArray(exist) && !!exist.length) { return; } const plugin = new VTableVueAttributePlugin(instance === null || instance === void 0 ? void 0 : instance.appContext); pluginService.register(plugin); }); } export { useCellRender };