@gooddata/sdk-ui-metric-component 11.67.0-alpha.2 → 11.67.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +943 -2401
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.js +170 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts +95 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.js +536 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.js +204 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +22 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.js +95 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts +21 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/commands.js +98 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts +7 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts.map +1 -0
- package/esm/MaqlEditor/{monaco → codemirror}/hooks/useAutofocus.js +4 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts +28 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/lsp.js +70 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts +11 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/markdown.js +28 -0
- package/esm/MaqlEditor/codemirror/types.d.ts +8 -0
- package/esm/MaqlEditor/codemirror/types.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/types.js +2 -0
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts +15 -2
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCodeTheme.js +36 -43
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts +7 -2
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCopyToClipboard.js +53 -10
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts +25 -9
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.js +179 -30
- package/esm/MaqlEditor/maql/MaqlEditor.styles.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.styles.js +13 -17
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.js +15 -20
- package/esm/MaqlEditor/maql/extensions/completion.d.ts +101 -0
- package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/completion.js +420 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts +19 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/decorations.js +137 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/formatting.js +78 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/hover.js +98 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts +15 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.js +79 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts +41 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/validation.js +202 -0
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts +19 -4
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/hover/doHover.js +71 -61
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts +16 -0
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/maqlLanguage.js +72 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts +7 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts.map +1 -0
- package/esm/MaqlEditor/mock/{monaco-shim.js → editor-shim.js} +27 -1
- package/esm/MaqlEditor/sql/SqlEditor.d.ts +15 -7
- package/esm/MaqlEditor/sql/SqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/SqlEditor.js +55 -30
- package/esm/MaqlEditor/sql/formatter.d.ts +6 -5
- package/esm/MaqlEditor/sql/formatter.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/formatter.js +14 -14
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts +3 -0
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/sql/sqlLanguage.js +19 -0
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts +5 -2
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts.map +1 -1
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.js +20 -8
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.js +28 -27
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts +0 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.js +4 -29
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.js +4 -2
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts +2 -5
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/maqlFieldFunctions.js +1 -4
- package/esm/index.d.ts +3 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/sdk-ui-metric-component.d.ts +50 -39
- package/esm/shared/permissions.d.ts.map +1 -1
- package/esm/shared/permissions.js +1 -0
- package/esm/translations/en-US.json +36 -0
- package/package.json +33 -30
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts +0 -3
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useAutoformat.js +0 -15
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts +0 -4
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useCleanCallback.js +0 -12
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts +0 -13
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useMountCallback.js +0 -26
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts +0 -19
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useUpdateCallback.js +0 -63
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts +0 -6
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useValueCallbacks.js +0 -14
- package/esm/MaqlEditor/maql/formatter.d.ts +0 -6
- package/esm/MaqlEditor/maql/formatter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/formatter.js +0 -14
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.js +0 -32
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.js +0 -60
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDecoration.js +0 -73
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts +0 -3
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.js +0 -29
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts +0 -6
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useHover.js +0 -77
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.js +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useMonaco.js +0 -75
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.js +0 -33
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.js +0 -28
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useValidation.js +0 -56
- package/esm/MaqlEditor/maql/monacoConverter.d.ts +0 -80
- package/esm/MaqlEditor/maql/monacoConverter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/monacoConverter.js +0 -528
- package/esm/MaqlEditor/maql/utils.d.ts +0 -4
- package/esm/MaqlEditor/maql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/utils.js +0 -6
- package/esm/MaqlEditor/mock/monaco-shim.d.ts +0 -5
- package/esm/MaqlEditor/mock/monaco-shim.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts +0 -64
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.js +0 -71
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts +0 -53
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.js +0 -427
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.js +0 -14
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.js +0 -84
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.js +0 -51
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useMonaco.js +0 -24
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts +0 -74
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoContributions.js +0 -88
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts +0 -53
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoWorkers.js +0 -176
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.js +0 -29
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts +0 -14
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useMonaco.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.js +0 -796
- package/esm/MaqlEditor/sql/utils.d.ts +0 -4
- package/esm/MaqlEditor/sql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/utils.js +0 -6
- package/worker/monaco-editor-worker.js +0 -33
- package/worker/monaco-editor-worker.source.js +0 -1
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
|
-
import { DecoratorClassName,
|
|
2
|
+
import { DecoratorClassName, DecoratorItemClassName } from "../../../codemirror/CodeEditor.styles.js";
|
|
3
|
+
import { rangeToSpan } from "../../../codemirror/lsp.js";
|
|
4
|
+
import { setHoveredSpan } from "../../extensions/decorations.js";
|
|
3
5
|
import { renderMaqlTooltip } from "../../MaqlEditor.tooltip.js";
|
|
4
6
|
// Position cache using WeakMap to avoid modifying elements directly
|
|
5
7
|
const positionCache = new WeakMap();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!
|
|
13
|
-
return
|
|
8
|
+
/**
|
|
9
|
+
* Opens the metric tooltip over the hovered reference.
|
|
10
|
+
*
|
|
11
|
+
* @param target - the element under the pointer, or at the cursor for the keyboard shortcut
|
|
12
|
+
*/
|
|
13
|
+
export function doHover(target, tooltip, editor, hover, settings, onOpen) {
|
|
14
|
+
if (!target || tooltip.current || !settings.content) {
|
|
15
|
+
return;
|
|
14
16
|
}
|
|
15
17
|
try {
|
|
16
18
|
// Collect valid DOM elements and ensure they have valid dimensions
|
|
17
|
-
const rawElements = collectElements(
|
|
19
|
+
const rawElements = collectElements(target);
|
|
18
20
|
const elements = rawElements.filter((el) => {
|
|
19
21
|
const isValid = el && document.body.contains(el);
|
|
20
22
|
if (isValid) {
|
|
@@ -31,10 +33,10 @@ export function doHover(event, tooltip, editor, hover, settings, onOpen) {
|
|
|
31
33
|
return false;
|
|
32
34
|
});
|
|
33
35
|
if (elements.length === 0) {
|
|
34
|
-
return
|
|
36
|
+
return;
|
|
35
37
|
}
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
+
// Highlight the hovered reference
|
|
39
|
+
createDecorator(editor, hover);
|
|
38
40
|
// Prepare the callback for when the tooltip is opened
|
|
39
41
|
const handleOpen = () => {
|
|
40
42
|
if (!settings.content)
|
|
@@ -50,15 +52,15 @@ export function doHover(event, tooltip, editor, hover, settings, onOpen) {
|
|
|
50
52
|
};
|
|
51
53
|
// Prepare the cleanup callback for when the tooltip is closed
|
|
52
54
|
const handleDestroy = () => {
|
|
53
|
-
removeDecorator(editor
|
|
55
|
+
removeDecorator(editor);
|
|
54
56
|
};
|
|
55
57
|
// Render the tooltip immediately
|
|
56
58
|
renderMaqlTooltip(tooltip, {
|
|
57
59
|
...settings,
|
|
58
60
|
elements,
|
|
59
|
-
// the hovered spans are re-rendered by
|
|
61
|
+
// the hovered spans are re-rendered by the editor (the hover decoration added above
|
|
60
62
|
// already triggers that), so the editor node is the stable owner of the tooltip
|
|
61
|
-
anchor:
|
|
63
|
+
anchor: editor.dom,
|
|
62
64
|
content: settings.content,
|
|
63
65
|
cachedPositions: elements.map((el) => positionCache.get(el)),
|
|
64
66
|
}, handleOpen, handleDestroy);
|
|
@@ -66,61 +68,69 @@ export function doHover(event, tooltip, editor, hover, settings, onOpen) {
|
|
|
66
68
|
catch {
|
|
67
69
|
// Silent error handling
|
|
68
70
|
}
|
|
69
|
-
// Return null to prevent monaco from showing its default tooltip
|
|
70
|
-
return null;
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The element at a document position: the span that renders the character before it, so a
|
|
74
|
+
* cursor right after a reference still finds the reference.
|
|
75
|
+
*/
|
|
76
|
+
export function elementAtPosition(editor, pos) {
|
|
77
|
+
const { node } = editor.domAtPos(Math.max(pos - 1, 0));
|
|
78
|
+
const element = node instanceof HTMLElement ? node : node.parentElement;
|
|
79
|
+
return element ?? null;
|
|
80
|
+
}
|
|
81
|
+
const DECORATOR_SELECTOR = `.${DecoratorClassName}, .${DecoratorItemClassName}`;
|
|
82
|
+
const LINE_SELECTOR = ".cm-line";
|
|
83
|
+
const WIDGET_BUFFER_CLASS = "cm-widgetBuffer";
|
|
84
|
+
/**
|
|
85
|
+
* The spans of the reference the element is part of: its badge and its text. The editor nests the
|
|
86
|
+
* spans of overlapping marks, so each is looked for inside its line-level ancestor, and the buffers
|
|
87
|
+
* the editor places around widgets are stepped over.
|
|
88
|
+
*/
|
|
89
|
+
export function collectElements(element) {
|
|
90
|
+
const line = element.closest(LINE_SELECTOR);
|
|
91
|
+
const start = line ? lineLevelAncestor(element, line) : null;
|
|
92
|
+
const target = start ? decoratorIn(start) : null;
|
|
93
|
+
if (!start || !target) {
|
|
75
94
|
return [];
|
|
76
|
-
const items = [];
|
|
77
|
-
if (isDecorator(element)) {
|
|
78
|
-
items.push(element);
|
|
79
95
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
items.push(current);
|
|
89
|
-
current = current.nextElementSibling;
|
|
90
|
-
}
|
|
96
|
+
const before = neighbours(start, (el) => el.previousElementSibling).reverse();
|
|
97
|
+
const after = neighbours(start, (el) => el.nextElementSibling);
|
|
98
|
+
return [...before, target, ...after];
|
|
99
|
+
}
|
|
100
|
+
function lineLevelAncestor(element, line) {
|
|
101
|
+
let current = element;
|
|
102
|
+
while (current.parentElement && current.parentElement !== line) {
|
|
103
|
+
current = current.parentElement;
|
|
91
104
|
}
|
|
92
|
-
return
|
|
105
|
+
return current.parentElement === line ? current : null;
|
|
93
106
|
}
|
|
94
|
-
function
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
if (cursor) {
|
|
98
|
-
const { x, y, height } = cursor.getBoundingClientRect();
|
|
99
|
-
const elementFromPoint = document.elementFromPoint(x - 1, y + height / 2);
|
|
100
|
-
return elementFromPoint || null;
|
|
101
|
-
}
|
|
107
|
+
function decoratorIn(element) {
|
|
108
|
+
if (element.matches(DECORATOR_SELECTOR)) {
|
|
109
|
+
return element;
|
|
102
110
|
}
|
|
103
|
-
|
|
104
|
-
return target || null;
|
|
111
|
+
return element.querySelector(DECORATOR_SELECTOR);
|
|
105
112
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
function neighbours(start, next) {
|
|
114
|
+
const found = [];
|
|
115
|
+
let current = next(start);
|
|
116
|
+
while (current) {
|
|
117
|
+
if (!current.classList.contains(WIDGET_BUFFER_CLASS)) {
|
|
118
|
+
const decorator = decoratorIn(current);
|
|
119
|
+
if (!decorator) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
found.push(decorator);
|
|
123
|
+
}
|
|
124
|
+
current = next(current);
|
|
125
|
+
}
|
|
126
|
+
return found;
|
|
110
127
|
}
|
|
111
128
|
function createDecorator(editor, hover) {
|
|
112
129
|
if (!hover.range) {
|
|
113
|
-
return
|
|
130
|
+
return;
|
|
114
131
|
}
|
|
115
|
-
|
|
116
|
-
{
|
|
117
|
-
range: hover.range,
|
|
118
|
-
options: {
|
|
119
|
-
inlineClassName: DecoratorHovered,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
]);
|
|
132
|
+
editor.dispatch({ effects: setHoveredSpan.of(rangeToSpan(editor.state.doc, hover.range)) });
|
|
123
133
|
}
|
|
124
|
-
function removeDecorator(editor
|
|
125
|
-
editor.
|
|
134
|
+
function removeDecorator(editor) {
|
|
135
|
+
editor.dispatch({ effects: setHoveredSpan.of(null) });
|
|
126
136
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HighlightStyle, StreamLanguage } from "@codemirror/language";
|
|
2
|
+
import { type Extension } from "@codemirror/state";
|
|
3
|
+
/**
|
|
4
|
+
* Token types of the regular-expression tokenizer. They cover the editor until the language
|
|
5
|
+
* service's semantic tokens arrive, and the code blocks the language service renders in markdown.
|
|
6
|
+
*/
|
|
7
|
+
export declare const maqlTokenTypes: readonly ["fact", "metric", "dataset", "attribute", "label", "variable", "keyword", "string", "comment", "bracket"];
|
|
8
|
+
export type MaqlTokenType = (typeof maqlTokenTypes)[number];
|
|
9
|
+
export declare const maqlLanguage: StreamLanguage<Record<string, never>>;
|
|
10
|
+
/**
|
|
11
|
+
* Every token type maps to a fixed class, so the colors live in the editor styles next to the
|
|
12
|
+
* semantic token colors and the end-to-end tests can address the tokens.
|
|
13
|
+
*/
|
|
14
|
+
export declare const maqlHighlightStyle: HighlightStyle;
|
|
15
|
+
export declare function maqlLanguageSupport(): Extension;
|
|
16
|
+
//# sourceMappingURL=maqlLanguage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maqlLanguage.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/maqlLanguage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAmB,cAAc,EAAsB,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD;;;GAGG;AACH,eAAO,MAAM,cAAc,YACvB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,CACH,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAO5D,eAAO,MAAM,YAAY,uCAyCvB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gBAE9B,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { HighlightStyle, LanguageSupport, StreamLanguage, syntaxHighlighting } from "@codemirror/language";
|
|
3
|
+
import { Tag } from "@lezer/highlight";
|
|
4
|
+
import { TOKEN_CLASS_PREFIX } from "../codemirror/CodeEditor.styles.js";
|
|
5
|
+
import { LANGUAGE } from "./constants.js";
|
|
6
|
+
/**
|
|
7
|
+
* Token types of the regular-expression tokenizer. They cover the editor until the language
|
|
8
|
+
* service's semantic tokens arrive, and the code blocks the language service renders in markdown.
|
|
9
|
+
*/
|
|
10
|
+
export const maqlTokenTypes = [
|
|
11
|
+
"fact",
|
|
12
|
+
"metric",
|
|
13
|
+
"dataset",
|
|
14
|
+
"attribute",
|
|
15
|
+
"label",
|
|
16
|
+
"variable",
|
|
17
|
+
"keyword",
|
|
18
|
+
"string",
|
|
19
|
+
"comment",
|
|
20
|
+
"bracket",
|
|
21
|
+
];
|
|
22
|
+
const tags = Object.fromEntries(maqlTokenTypes.map((type) => [type, Tag.define()]));
|
|
23
|
+
export const maqlLanguage = StreamLanguage.define({
|
|
24
|
+
name: LANGUAGE,
|
|
25
|
+
token(stream) {
|
|
26
|
+
if (stream.match(/^\{fact\/[^}]*\}/i)) {
|
|
27
|
+
return "fact";
|
|
28
|
+
}
|
|
29
|
+
if (stream.match(/^\{metric\/[^}]*\}/i)) {
|
|
30
|
+
return "metric";
|
|
31
|
+
}
|
|
32
|
+
if (stream.match(/^\{dataset\/[^}]*\}/i)) {
|
|
33
|
+
return "dataset";
|
|
34
|
+
}
|
|
35
|
+
if (stream.match(/^\{(?:attribute|computed_attribute)\/[^}]*\}/i)) {
|
|
36
|
+
return "attribute";
|
|
37
|
+
}
|
|
38
|
+
if (stream.match(/^\{label\/[^}]*\}/i)) {
|
|
39
|
+
return "label";
|
|
40
|
+
}
|
|
41
|
+
if (stream.match(/^\{[^}]*\}/)) {
|
|
42
|
+
return "variable";
|
|
43
|
+
}
|
|
44
|
+
if (stream.match(/^\w+/)) {
|
|
45
|
+
return "keyword";
|
|
46
|
+
}
|
|
47
|
+
if (stream.match(/^"(?:[^"\\]|\\.)*"/)) {
|
|
48
|
+
return "string";
|
|
49
|
+
}
|
|
50
|
+
if (stream.match(/^#[^\n]*/)) {
|
|
51
|
+
return "comment";
|
|
52
|
+
}
|
|
53
|
+
if (stream.match(/^[()]/)) {
|
|
54
|
+
return "bracket";
|
|
55
|
+
}
|
|
56
|
+
stream.next();
|
|
57
|
+
return null;
|
|
58
|
+
},
|
|
59
|
+
tokenTable: tags,
|
|
60
|
+
languageData: {
|
|
61
|
+
commentTokens: { line: "#" },
|
|
62
|
+
closeBrackets: { brackets: ["(", "{", '"'] },
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Every token type maps to a fixed class, so the colors live in the editor styles next to the
|
|
67
|
+
* semantic token colors and the end-to-end tests can address the tokens.
|
|
68
|
+
*/
|
|
69
|
+
export const maqlHighlightStyle = HighlightStyle.define(maqlTokenTypes.map((type) => ({ tag: tags[type], class: `${TOKEN_CLASS_PREFIX}${type}` })));
|
|
70
|
+
export function maqlLanguageSupport() {
|
|
71
|
+
return [new LanguageSupport(maqlLanguage), syntaxHighlighting(maqlHighlightStyle)];
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-shim.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/mock/editor-shim.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CA6DrC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
2
|
/**
|
|
3
|
+
* Fills in the browser APIs the editor needs that a DOM test environment lacks.
|
|
4
|
+
*
|
|
3
5
|
* @internal
|
|
4
6
|
*/
|
|
5
7
|
export function shimMaqlEditor() {
|
|
6
8
|
const noop = () => void 0;
|
|
7
|
-
//monaco shim methods
|
|
8
9
|
if (!document.queryCommandSupported) {
|
|
9
10
|
document.queryCommandSupported = () => false;
|
|
10
11
|
}
|
|
@@ -36,4 +37,29 @@ export function shimMaqlEditor() {
|
|
|
36
37
|
}
|
|
37
38
|
global.ResizeObserver = ResizeObserver;
|
|
38
39
|
}
|
|
40
|
+
// CodeMirror measures text through DOM ranges, which the test environments leave unimplemented.
|
|
41
|
+
const emptyRect = {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
width: 0,
|
|
45
|
+
height: 0,
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
bottom: 0,
|
|
50
|
+
toJSON: () => ({}),
|
|
51
|
+
};
|
|
52
|
+
if (typeof Range !== "undefined") {
|
|
53
|
+
const prototype = Range.prototype;
|
|
54
|
+
if (!prototype.getClientRects) {
|
|
55
|
+
prototype.getClientRects = () => ({
|
|
56
|
+
length: 0,
|
|
57
|
+
item: () => null,
|
|
58
|
+
[Symbol.iterator]: [][Symbol.iterator],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (!prototype.getBoundingClientRect) {
|
|
62
|
+
prototype.getBoundingClientRect = () => emptyRect;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
39
65
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { type Ref } from "react";
|
|
2
|
-
import { type
|
|
2
|
+
import { type MaqlEditorView } from "../codemirror/types.js";
|
|
3
3
|
import { type MaqlEditorDefaultTheme } from "../theme/default.js";
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export interface ISqlEditorApi {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Copies the SQL to the clipboard.
|
|
10
|
+
*
|
|
11
|
+
* @returns whether the text reached the clipboard
|
|
12
|
+
*/
|
|
13
|
+
copy: () => Promise<boolean>;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* @internal
|
|
@@ -16,11 +21,14 @@ export interface ISqlEditorProps {
|
|
|
16
21
|
defaultValue?: string;
|
|
17
22
|
readonly?: boolean;
|
|
18
23
|
inline?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The accessible name of the editor.
|
|
26
|
+
*/
|
|
27
|
+
ariaLabel?: string;
|
|
28
|
+
onFocus?: (editor: MaqlEditorView) => void;
|
|
29
|
+
onBlur?: (editor: MaqlEditorView) => void;
|
|
30
|
+
onEditorMount?: (editor: MaqlEditorView) => void;
|
|
31
|
+
onChange?: (editor: MaqlEditorView, value: string) => void;
|
|
24
32
|
ref?: Ref<ISqlEditorApi | null>;
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEditor.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/sql/SqlEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAoD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SqlEditor.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/sql/SqlEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAoD,MAAM,OAAO,CAAC;AASnF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAOlE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;OAIG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CACnC;AAeD;;GAEG;AACH,eAAO,MAAM,SAAS,wHAqFpB,CAAC"}
|
|
@@ -1,48 +1,73 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
3
|
import { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
|
|
4
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
4
5
|
import classNames from "classnames";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { CodeEditor } from "../codemirror/CodeEditor.js";
|
|
8
|
+
import { platformShortcut, useCommonMenuItems } from "../codemirror/ContextMenu.js";
|
|
5
9
|
import { useCodeTheme } from "../hooks/useCodeTheme.js";
|
|
6
10
|
import { useCopyToClipboard } from "../hooks/useCopyToClipboard.js";
|
|
7
|
-
import { MonacoEditor, } from "../monaco/MonacoEditor.js";
|
|
8
11
|
import { ThemeProvider } from "../theme/theme.js";
|
|
9
|
-
import { LANGUAGE } from "./constants.js";
|
|
10
12
|
import { formatValue } from "./formatter.js";
|
|
11
|
-
import { useLanguageConfiguration } from "./hooks/useLanguageConfiguration.js";
|
|
12
|
-
import { useMonaco } from "./hooks/useMonaco.js";
|
|
13
13
|
import { SqlEditorClass, SqlEditorTestClass } from "./SqlEditor.styles.js";
|
|
14
|
+
import { sqlLanguageSupport } from "./sqlLanguage.js";
|
|
15
|
+
/**
|
|
16
|
+
* Replaces the SQL with its formatted version.
|
|
17
|
+
*/
|
|
18
|
+
const formatDocument = (view) => {
|
|
19
|
+
// The read-only facet stops the user's edits, not a dispatched change.
|
|
20
|
+
if (view.state.readOnly) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const text = view.state.doc.toString();
|
|
24
|
+
view.dispatch({ changes: { from: 0, to: text.length, insert: formatValue(text) } });
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
14
27
|
/**
|
|
15
28
|
* @internal
|
|
16
29
|
*/
|
|
17
|
-
export const SqlEditor = forwardRef(function SqlEditor({ readonly = false, inline = false, autofocus = false, defaultValue = "", cssTheme, onFocus, onBlur, onEditorMount,
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
onBlur,
|
|
22
|
-
onEditorMount,
|
|
23
|
-
onValid,
|
|
24
|
-
onChange,
|
|
25
|
-
}), [onBlur, onChange, onEditorMount, onFocus, onValid]);
|
|
26
|
-
const { onMount, onUpdate } = useMonaco(LANGUAGE, handlers);
|
|
27
|
-
const languageConfiguration = useLanguageConfiguration();
|
|
28
|
-
const options = useEditorOptions();
|
|
29
|
-
const formattedValue = useFormattedValue(defaultValue);
|
|
30
|
+
export const SqlEditor = forwardRef(function SqlEditor({ readonly = false, inline = false, autofocus = false, defaultValue = "", cssTheme, ariaLabel, onFocus, onBlur, onEditorMount, onChange, }, ref) {
|
|
31
|
+
const intl = useIntl();
|
|
32
|
+
const codeTheme = useCodeTheme();
|
|
33
|
+
const formattedValue = useMemo(() => formatValue(defaultValue), [defaultValue]);
|
|
30
34
|
const copyToClipboard = useCopyToClipboard();
|
|
31
35
|
const editor = useRef(null);
|
|
36
|
+
const commonMenuItems = useCommonMenuItems();
|
|
37
|
+
const handlers = useRef({ onFocus, onBlur, onChange });
|
|
38
|
+
handlers.current = { onFocus, onBlur, onChange };
|
|
39
|
+
const contextMenu = useMemo(() => [
|
|
40
|
+
commonMenuItems.changeAllOccurrences,
|
|
41
|
+
{
|
|
42
|
+
id: "format-document",
|
|
43
|
+
group: "edit",
|
|
44
|
+
label: intl.formatMessage({ id: "metricComponent.editMetric.contextMenu.formatDocument" }),
|
|
45
|
+
shortcut: platformShortcut("⇧⌥F", "Shift+Alt+F"),
|
|
46
|
+
run: formatDocument,
|
|
47
|
+
},
|
|
48
|
+
...commonMenuItems.clipboard,
|
|
49
|
+
], [intl, commonMenuItems]);
|
|
50
|
+
const extensions = useMemo(() => [
|
|
51
|
+
sqlLanguageSupport(),
|
|
52
|
+
keymap.of([{ key: "Shift-Alt-f", run: formatDocument }]),
|
|
53
|
+
EditorView.updateListener.of((update) => {
|
|
54
|
+
if (update.docChanged) {
|
|
55
|
+
handlers.current.onChange?.(update.view, update.state.doc.toString());
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
EditorView.domEventHandlers({
|
|
59
|
+
focus: (_event, view) => {
|
|
60
|
+
handlers.current.onFocus?.(view);
|
|
61
|
+
return false;
|
|
62
|
+
},
|
|
63
|
+
blur: (_event, view) => {
|
|
64
|
+
handlers.current.onBlur?.(view);
|
|
65
|
+
return false;
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
], []);
|
|
32
69
|
useImperativeHandle(ref, () => ({
|
|
33
70
|
copy: () => copyToClipboard(editor.current),
|
|
34
71
|
}));
|
|
35
|
-
return (_jsx(ThemeProvider, { theme: cssTheme, children: _jsx(
|
|
72
|
+
return (_jsx(ThemeProvider, { theme: cssTheme, children: _jsx(CodeEditor, { inline: inline, lineNumbers: false, readonly: readonly, autofocus: autofocus, className: classNames(SqlEditorClass, SqlEditorTestClass), defaultValue: formattedValue, codeTheme: codeTheme, ariaLabel: ariaLabel, extensions: extensions, contextMenu: contextMenu, onEditorMount: onEditorMount, ref: editor }) }));
|
|
36
73
|
});
|
|
37
|
-
function useEditorOptions() {
|
|
38
|
-
return useMemo(() => ({
|
|
39
|
-
lineNumbers: "off",
|
|
40
|
-
lineNumbersMinChars: 0,
|
|
41
|
-
folding: false,
|
|
42
|
-
}), []);
|
|
43
|
-
}
|
|
44
|
-
function useFormattedValue(value) {
|
|
45
|
-
return useMemo(() => {
|
|
46
|
-
return formatValue(value, { tabSize: 4, insertSpaces: true });
|
|
47
|
-
}, [value]);
|
|
48
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type FormattingOptions } from "vscode-languageserver-types";
|
|
2
|
+
export declare const SQL_FORMATTING_OPTIONS: FormattingOptions;
|
|
3
|
+
/**
|
|
4
|
+
* The text formatted as SQL, or as it is when the formatter cannot parse it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatValue(text: string, options?: FormattingOptions): string;
|
|
6
7
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/sql/formatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/sql/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,eAAO,MAAM,sBAAsB,EAAE,iBAAsD,CAAC;AAE5F;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAA0C,GAAG,MAAM,CASrG"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
2
|
import { format } from "sql-formatter";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
3
|
+
export const SQL_FORMATTING_OPTIONS = { tabSize: 4, insertSpaces: true };
|
|
4
|
+
/**
|
|
5
|
+
* The text formatted as SQL, or as it is when the formatter cannot parse it.
|
|
6
|
+
*/
|
|
7
|
+
export function formatValue(text, options = SQL_FORMATTING_OPTIONS) {
|
|
8
|
+
try {
|
|
9
|
+
return format(text, {
|
|
10
|
+
useTabs: !options.insertSpaces,
|
|
11
|
+
tabWidth: options.tabSize,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlLanguage.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/sql/sqlLanguage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAgBnD,wBAAgB,kBAAkB,IAAI,SAAS,CAE9C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { sql } from "@codemirror/lang-sql";
|
|
3
|
+
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
4
|
+
import { tags } from "@lezer/highlight";
|
|
5
|
+
/**
|
|
6
|
+
* The light palette of the former editor, for the read-only SQL preview.
|
|
7
|
+
*/
|
|
8
|
+
const sqlHighlightStyle = HighlightStyle.define([
|
|
9
|
+
{ tag: tags.keyword, color: "#0000FF" },
|
|
10
|
+
{ tag: tags.operator, color: "#000000" },
|
|
11
|
+
{ tag: [tags.string, tags.special(tags.string)], color: "#A31515" },
|
|
12
|
+
{ tag: tags.number, color: "#098658" },
|
|
13
|
+
{ tag: tags.comment, color: "#008000" },
|
|
14
|
+
{ tag: [tags.function(tags.variableName), tags.standard(tags.name)], color: "#795E26" },
|
|
15
|
+
{ tag: tags.typeName, color: "#267F99" },
|
|
16
|
+
]);
|
|
17
|
+
export function sqlLanguageSupport() {
|
|
18
|
+
return [sql(), syntaxHighlighting(sqlHighlightStyle)];
|
|
19
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type PropsWithChildren } from "react";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Extension } from "@codemirror/state";
|
|
3
3
|
type StatusBarProps = {
|
|
4
4
|
where: HTMLElement | null;
|
|
5
5
|
};
|
|
6
6
|
export declare function StatusBar({ where, children }: PropsWithChildren<StatusBarProps>): import("react").ReactPortal | null;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Reports the suggestion list element while it is open, so the status bar can render into it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function suggestionElementObserver(setSuggestionsElement: (el: HTMLElement | null) => void): Extension;
|
|
8
11
|
export {};
|
|
9
12
|
//# sourceMappingURL=SuggestionStatusBar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionStatusBar.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/statusBar/SuggestionStatusBar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SuggestionStatusBar.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/statusBar/SuggestionStatusBar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnD,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAmBF,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,cAAc,CAAC,sCAa/E;AAID;;GAEG;AACH,wBAAgB,yBAAyB,CACrC,qBAAqB,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,GACxD,SAAS,CAgBX"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
3
|
import { Children } from "react";
|
|
4
|
+
import { completionStatus } from "@codemirror/autocomplete";
|
|
5
|
+
import { EditorView } from "@codemirror/view";
|
|
4
6
|
import { createPortal } from "react-dom";
|
|
5
7
|
import { makeStyles } from "../theme/styles.js";
|
|
6
8
|
const useStyles = makeStyles()((theme) => ({
|
|
@@ -8,7 +10,6 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
8
10
|
width: "100%",
|
|
9
11
|
position: "relative",
|
|
10
12
|
fontFamily: theme.globals.font,
|
|
11
|
-
borderLeft: theme.statusBar.borders.default,
|
|
12
13
|
borderTop: theme.statusBar.borders.default,
|
|
13
14
|
background: theme.statusBar.colors.background,
|
|
14
15
|
},
|
|
@@ -28,11 +29,22 @@ export function StatusBar({ where, children }) {
|
|
|
28
29
|
}
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const SUGGESTION_TOOLTIP_SELECTOR = ".cm-tooltip-autocomplete";
|
|
33
|
+
/**
|
|
34
|
+
* Reports the suggestion list element while it is open, so the status bar can render into it.
|
|
35
|
+
*/
|
|
36
|
+
export function suggestionElementObserver(setSuggestionsElement) {
|
|
37
|
+
return EditorView.updateListener.of((update) => {
|
|
38
|
+
const was = completionStatus(update.startState);
|
|
39
|
+
const is = completionStatus(update.state);
|
|
40
|
+
if (was === is) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (is === null) {
|
|
44
|
+
setSuggestionsElement(null);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// The tooltip renders right after this update.
|
|
48
|
+
queueMicrotask(() => setSuggestionsElement(update.view.dom.querySelector(SUGGESTION_TOOLTIP_SELECTOR)));
|
|
49
|
+
});
|
|
38
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaqlEditorEditor.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"MaqlEditorEditor.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,GAAG,EAQX,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiB3D,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,wCAAwC,CAAC;AAuBzF,MAAM,WAAW,sBAAsB;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAyCD,eAAO,MAAM,gBAAgB,gIAsD3B,CAAC"}
|