scichart-react
Version:
React wrapper for SciChart JS
30 lines • 1.84 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChartGroupLoader = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const DefaultFallback_1 = require("./DefaultFallback");
const SciChartGroup_1 = require("./SciChartGroup");
/** The purpose of this component is to hide UI behind a spinner until the charts within it are initialized */
const ChartGroupLoader = (props) => {
const { fallback, onInit, onInitError } = props, divProps = __rest(props, ["fallback", "onInit", "onInitError"]);
const [isInitialized, setIsInitialized] = (0, react_1.useState)(false);
return ((0, jsx_runtime_1.jsx)(SciChartGroup_1.SciChartGroup, { onInit: (chartInitResults) => {
var _a;
(_a = props.onInit) === null || _a === void 0 ? void 0 : _a.call(props, chartInitResults);
setIsInitialized(true);
}, onInitError: onInitError, children: (0, jsx_runtime_1.jsxs)("div", Object.assign({}, divProps, { children: [props.children, !isInitialized ? (fallback ? ((0, jsx_runtime_1.jsx)("div", { style: DefaultFallback_1.fallbackWrapperStyle, children: fallback })) : ((0, jsx_runtime_1.jsx)(DefaultFallback_1.DefaultFallback, {}))) : null] })) }));
};
exports.ChartGroupLoader = ChartGroupLoader;
//# sourceMappingURL=ChartGroupLoader.js.map