@grafana/ui
Version:
Grafana Components Library
66 lines (61 loc) • 2.06 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var css = require('@emotion/css');
var e2eSelectors = require('@grafana/e2e-selectors');
var i18n = require('@grafana/i18n');
var ThemeContext = require('../../themes/ThemeContext.cjs');
var useAsyncDependency = require('../../utils/useAsyncDependency.cjs');
var ErrorWithStack = require('../ErrorBoundary/ErrorWithStack.cjs');
var LoadingPlaceholder = require('../LoadingPlaceholder/LoadingPlaceholder.cjs');
;
const ReactMonacoEditorLazy = (props) => {
var _a, _b;
const styles = ThemeContext.useStyles2(getStyles);
const { loading, error, dependency } = useAsyncDependency.useAsyncDependency(
Promise.resolve().then(function () { return require(
/* webpackChunkName: "react-monaco-editor" */
'./ReactMonacoEditor.cjs'
); })
);
if (loading) {
return /* @__PURE__ */ jsxRuntime.jsx(
LoadingPlaceholder.LoadingPlaceholder,
{
text: i18n.t("grafana-ui.monaco.loading-placeholder", "Loading editor"),
className: styles.container
}
);
}
if (error) {
return /* @__PURE__ */ jsxRuntime.jsx(
ErrorWithStack.ErrorWithStack,
{
title: i18n.t("grafana-ui.monaco.error-label", "React Monaco Editor failed to load"),
error,
errorInfo: { componentStack: (_a = error == null ? void 0 : error.stack) != null ? _a : "" }
}
);
}
const ReactMonacoEditor = dependency.ReactMonacoEditor;
return /* @__PURE__ */ jsxRuntime.jsx(
ReactMonacoEditor,
{
...props,
loading: (_b = props.loading) != null ? _b : null,
wrapperProps: {
"data-testid": e2eSelectors.selectors.components.ReactMonacoEditor.editorLazy
}
}
);
};
const getStyles = (theme) => {
return {
container: css.css({
marginBottom: "unset",
marginLeft: theme.spacing(1)
})
};
};
exports.ReactMonacoEditorLazy = ReactMonacoEditorLazy;
//# sourceMappingURL=ReactMonacoEditorLazy.cjs.map