@visactor/vue-vtable
Version:
The vue version of VTable
37 lines (33 loc) • 1.44 kB
JavaScript
;
var vue = require('vue');
var vtableVueAttributePlugin = require('../components/custom/vtable-vue-attribute-plugin.js');
var vutils = require('@visactor/vutils');
/**
* 自定义单元格渲染器
* @param props
* @param tableRef
*/
function useCellRender(props, tableRef) {
var _a, _b;
/** 当前实例 */
const instance = vue.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;
vue.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 (vutils.isArray(exist) && !!exist.length) {
return;
}
const plugin = new vtableVueAttributePlugin.VTableVueAttributePlugin(instance === null || instance === void 0 ? void 0 : instance.appContext);
pluginService.register(plugin);
});
}
exports.useCellRender = useCellRender;