@grafana/ui
Version:
Grafana Components Library
1 lines • 3.1 kB
Source Map (JSON)
{"version":3,"file":"ReactMonacoEditorLazy.mjs","sources":["../../../../src/components/Monaco/ReactMonacoEditorLazy.tsx"],"sourcesContent":["import { css } from '@emotion/css';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\n\nimport { useStyles2 } from '../../themes';\nimport { t } from '../../utils/i18n';\nimport { useAsyncDependency } from '../../utils/useAsyncDependency';\nimport { ErrorWithStack } from '../ErrorBoundary/ErrorWithStack';\nimport { LoadingPlaceholder } from '../LoadingPlaceholder/LoadingPlaceholder';\n\n// we only use import type so it will not be included in the bundle\nimport type { ReactMonacoEditorProps } from './types';\n\n/**\n * @internal\n * Experimental export\n **/\nexport const ReactMonacoEditorLazy = (props: ReactMonacoEditorProps) => {\n const styles = useStyles2(getStyles);\n const { loading, error, dependency } = useAsyncDependency(\n import(/* webpackChunkName: \"react-monaco-editor\" */ './ReactMonacoEditor')\n );\n\n if (loading) {\n return (\n <LoadingPlaceholder\n text={t('grafana-ui.monaco.loading-placeholder', 'Loading editor')}\n className={styles.container}\n />\n );\n }\n\n if (error) {\n return (\n <ErrorWithStack\n title={t('grafana-ui.monaco.error-label', 'React Monaco Editor failed to load')}\n error={error}\n errorInfo={{ componentStack: error?.stack ?? '' }}\n />\n );\n }\n\n const ReactMonacoEditor = dependency.ReactMonacoEditor;\n return (\n <ReactMonacoEditor\n {...props}\n loading={props.loading ?? null}\n wrapperProps={{\n 'data-testid': selectors.components.ReactMonacoEditor.editorLazy,\n }}\n />\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n container: css({\n marginBottom: 'unset',\n marginLeft: theme.spacing(1),\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBa,MAAA,qBAAA,GAAwB,CAAC,KAAkC,KAAA;AAlBxE,EAAA,IAAA,EAAA,EAAA,EAAA;AAmBE,EAAM,MAAA,MAAA,GAAS,WAA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