opendash
Version:
open.DASH data visualization framework
36 lines • 2.02 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import * as React from "react";
import { useWidgetContextSetup } from "../hooks/useWidgetContextSetup";
export var WidgetComponentRender = React.memo(function WidgetComponentRender(_a) {
var baseContext = _a.context;
var _b, _c, _d, _e, _f, _g, _h, _j;
var context = useWidgetContextSetup(baseContext);
var DisplayComponent = React.useMemo(function () {
var _a, _b, _c;
return ((_b = (_a = baseContext) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.displayComponent) ? React.lazy((_c = baseContext) === null || _c === void 0 ? void 0 : _c.type.displayComponent)
: null;
}, [(_c = (_b = baseContext) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.displayComponent]);
if (!((_d = baseContext) === null || _d === void 0 ? void 0 : _d.widget)) {
console.warn("WidgetSettingsModal: widget \"" + ((_e = baseContext) === null || _e === void 0 ? void 0 : _e.id) + "\" not found.");
return null;
}
if (((_f = baseContext) === null || _f === void 0 ? void 0 : _f.widget) && !((_g = baseContext) === null || _g === void 0 ? void 0 : _g.type)) {
console.warn("WidgetComponent: type \"" + ((_h = baseContext) === null || _h === void 0 ? void 0 : _h.widget.type) + "\" not found.");
return null;
}
if ((_j = baseContext) === null || _j === void 0 ? void 0 : _j.state.settings) {
return null;
}
return React.createElement(DisplayComponent, __assign({}, context));
});
//# sourceMappingURL=WidgetComponentRender.js.map