@visactor/react-vtable
Version:
The react version of VTable
35 lines (31 loc) • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.reactEnvModule = void 0;
const vtable_1 = require("@visactor/vtable"), vrender_1 = require("@visactor/vtable/es/vrender"), vutils_1 = require("@visactor/vutils");
exports.reactEnvModule = new vrender_1.ContainerModule(((bind, unbind, isBound, rebind) => {
bind(VTableBrowserEnvContribution).toSelf().inSingletonScope(), isBound(vrender_1.EnvContribution) ? rebind(vrender_1.EnvContribution).toService(VTableBrowserEnvContribution) : bind(vrender_1.EnvContribution).toService(VTableBrowserEnvContribution);
}));
class VTableBrowserEnvContribution extends vrender_1.BrowserEnvContribution {
updateDom(dom, params) {
var _a, _b;
const tableDiv = dom.parentElement;
if (tableDiv && params.graphic) {
const top = parseInt(params.style.top, 10), left = parseInt(params.style.left, 10);
let domWidth, domHeight;
if (dom.style.display = "none") {
const cellGroup = (0, vtable_1.getTargetCell)(params.graphic);
domWidth = null !== (_a = cellGroup.attribute.width) && void 0 !== _a ? _a : 1,
domHeight = null !== (_b = cellGroup.attribute.height) && void 0 !== _b ? _b : 1;
} else domWidth = dom.offsetWidth, domHeight = dom.offsetHeight;
if (top + domHeight < 0 || left + domWidth < 0 || top > tableDiv.offsetHeight || left > tableDiv.offsetWidth) return dom.style.display = "none",
!1;
}
const {width: width, height: height, style: style} = params;
return style && ((0, vutils_1.isString)(style) ? dom.setAttribute("style", style) : Object.keys(style).forEach((k => {
dom.style[k] = style[k];
}))), null != width && (dom.style.width = `${width}px`), null != height && (dom.style.height = `${height}px`),
!0;
}
}
//# sourceMappingURL=vtable-browser-env-contribution.js.map