@gooddata/sdk-ui-metric-component 11.67.0-alpha.1 → 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.
Files changed (197) hide show
  1. package/NOTICE +943 -2401
  2. package/esm/MaqlEditor/codemirror/CodeEditor.d.ts +52 -0
  3. package/esm/MaqlEditor/codemirror/CodeEditor.d.ts.map +1 -0
  4. package/esm/MaqlEditor/codemirror/CodeEditor.js +170 -0
  5. package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts +95 -0
  6. package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts.map +1 -0
  7. package/esm/MaqlEditor/codemirror/CodeEditor.styles.js +536 -0
  8. package/esm/MaqlEditor/codemirror/ContextMenu.d.ts +52 -0
  9. package/esm/MaqlEditor/codemirror/ContextMenu.d.ts.map +1 -0
  10. package/esm/MaqlEditor/codemirror/ContextMenu.js +204 -0
  11. package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +22 -0
  12. package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -0
  13. package/esm/MaqlEditor/codemirror/baseExtensions.js +95 -0
  14. package/esm/MaqlEditor/codemirror/commands.d.ts +21 -0
  15. package/esm/MaqlEditor/codemirror/commands.d.ts.map +1 -0
  16. package/esm/MaqlEditor/codemirror/commands.js +98 -0
  17. package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts +7 -0
  18. package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts.map +1 -0
  19. package/esm/MaqlEditor/{monaco → codemirror}/hooks/useAutofocus.js +4 -0
  20. package/esm/MaqlEditor/codemirror/lsp.d.ts +28 -0
  21. package/esm/MaqlEditor/codemirror/lsp.d.ts.map +1 -0
  22. package/esm/MaqlEditor/codemirror/lsp.js +70 -0
  23. package/esm/MaqlEditor/codemirror/markdown.d.ts +11 -0
  24. package/esm/MaqlEditor/codemirror/markdown.d.ts.map +1 -0
  25. package/esm/MaqlEditor/codemirror/markdown.js +28 -0
  26. package/esm/MaqlEditor/codemirror/types.d.ts +8 -0
  27. package/esm/MaqlEditor/codemirror/types.d.ts.map +1 -0
  28. package/esm/MaqlEditor/codemirror/types.js +2 -0
  29. package/esm/MaqlEditor/hooks/useCodeTheme.d.ts +15 -2
  30. package/esm/MaqlEditor/hooks/useCodeTheme.d.ts.map +1 -1
  31. package/esm/MaqlEditor/hooks/useCodeTheme.js +36 -43
  32. package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts +7 -2
  33. package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts.map +1 -1
  34. package/esm/MaqlEditor/hooks/useCopyToClipboard.js +53 -10
  35. package/esm/MaqlEditor/maql/MaqlEditor.d.ts +25 -9
  36. package/esm/MaqlEditor/maql/MaqlEditor.d.ts.map +1 -1
  37. package/esm/MaqlEditor/maql/MaqlEditor.js +179 -30
  38. package/esm/MaqlEditor/maql/MaqlEditor.styles.d.ts.map +1 -1
  39. package/esm/MaqlEditor/maql/MaqlEditor.styles.js +13 -17
  40. package/esm/MaqlEditor/maql/MaqlEditor.tooltip.d.ts.map +1 -1
  41. package/esm/MaqlEditor/maql/MaqlEditor.tooltip.js +15 -20
  42. package/esm/MaqlEditor/maql/extensions/completion.d.ts +101 -0
  43. package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -0
  44. package/esm/MaqlEditor/maql/extensions/completion.js +420 -0
  45. package/esm/MaqlEditor/maql/extensions/decorations.d.ts +19 -0
  46. package/esm/MaqlEditor/maql/extensions/decorations.d.ts.map +1 -0
  47. package/esm/MaqlEditor/maql/extensions/decorations.js +137 -0
  48. package/esm/MaqlEditor/maql/extensions/formatting.d.ts +22 -0
  49. package/esm/MaqlEditor/maql/extensions/formatting.d.ts.map +1 -0
  50. package/esm/MaqlEditor/maql/extensions/formatting.js +78 -0
  51. package/esm/MaqlEditor/maql/extensions/hover.d.ts +22 -0
  52. package/esm/MaqlEditor/maql/extensions/hover.d.ts.map +1 -0
  53. package/esm/MaqlEditor/maql/extensions/hover.js +98 -0
  54. package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts +15 -0
  55. package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts.map +1 -0
  56. package/esm/MaqlEditor/maql/extensions/semanticTokens.js +79 -0
  57. package/esm/MaqlEditor/maql/extensions/validation.d.ts +41 -0
  58. package/esm/MaqlEditor/maql/extensions/validation.d.ts.map +1 -0
  59. package/esm/MaqlEditor/maql/extensions/validation.js +202 -0
  60. package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts +19 -4
  61. package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts.map +1 -1
  62. package/esm/MaqlEditor/maql/hooks/hover/doHover.js +71 -61
  63. package/esm/MaqlEditor/maql/maqlLanguage.d.ts +16 -0
  64. package/esm/MaqlEditor/maql/maqlLanguage.d.ts.map +1 -0
  65. package/esm/MaqlEditor/maql/maqlLanguage.js +72 -0
  66. package/esm/MaqlEditor/mock/editor-shim.d.ts +7 -0
  67. package/esm/MaqlEditor/mock/editor-shim.d.ts.map +1 -0
  68. package/esm/MaqlEditor/mock/{monaco-shim.js → editor-shim.js} +27 -1
  69. package/esm/MaqlEditor/sql/SqlEditor.d.ts +15 -7
  70. package/esm/MaqlEditor/sql/SqlEditor.d.ts.map +1 -1
  71. package/esm/MaqlEditor/sql/SqlEditor.js +55 -30
  72. package/esm/MaqlEditor/sql/formatter.d.ts +6 -5
  73. package/esm/MaqlEditor/sql/formatter.d.ts.map +1 -1
  74. package/esm/MaqlEditor/sql/formatter.js +14 -14
  75. package/esm/MaqlEditor/sql/sqlLanguage.d.ts +3 -0
  76. package/esm/MaqlEditor/sql/sqlLanguage.d.ts.map +1 -0
  77. package/esm/MaqlEditor/sql/sqlLanguage.js +19 -0
  78. package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts +5 -2
  79. package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts.map +1 -1
  80. package/esm/MaqlEditor/statusBar/SuggestionStatusBar.js +20 -8
  81. package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.d.ts.map +1 -1
  82. package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.js +28 -27
  83. package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts +0 -1
  84. package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts.map +1 -1
  85. package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.js +4 -29
  86. package/esm/MetricComponent/Form/MaqlResult/MaqlSql.d.ts.map +1 -1
  87. package/esm/MetricComponent/Form/MaqlResult/MaqlSql.js +4 -2
  88. package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts +2 -5
  89. package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts.map +1 -1
  90. package/esm/MetricComponent/Form/maqlFieldFunctions.js +1 -4
  91. package/esm/index.d.ts +3 -3
  92. package/esm/index.d.ts.map +1 -1
  93. package/esm/index.js +1 -1
  94. package/esm/sdk-ui-metric-component.d.ts +50 -39
  95. package/esm/shared/permissions.d.ts.map +1 -1
  96. package/esm/shared/permissions.js +1 -0
  97. package/esm/translations/en-US.json +36 -0
  98. package/package.json +33 -30
  99. package/esm/MaqlEditor/hooks/useAutoformat.d.ts +0 -3
  100. package/esm/MaqlEditor/hooks/useAutoformat.d.ts.map +0 -1
  101. package/esm/MaqlEditor/hooks/useAutoformat.js +0 -15
  102. package/esm/MaqlEditor/hooks/useCleanCallback.d.ts +0 -4
  103. package/esm/MaqlEditor/hooks/useCleanCallback.d.ts.map +0 -1
  104. package/esm/MaqlEditor/hooks/useCleanCallback.js +0 -12
  105. package/esm/MaqlEditor/hooks/useMountCallback.d.ts +0 -13
  106. package/esm/MaqlEditor/hooks/useMountCallback.d.ts.map +0 -1
  107. package/esm/MaqlEditor/hooks/useMountCallback.js +0 -26
  108. package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts +0 -19
  109. package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts.map +0 -1
  110. package/esm/MaqlEditor/hooks/useUpdateCallback.js +0 -63
  111. package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts +0 -6
  112. package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts.map +0 -1
  113. package/esm/MaqlEditor/hooks/useValueCallbacks.js +0 -14
  114. package/esm/MaqlEditor/maql/formatter.d.ts +0 -6
  115. package/esm/MaqlEditor/maql/formatter.d.ts.map +0 -1
  116. package/esm/MaqlEditor/maql/formatter.js +0 -14
  117. package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts +0 -4
  118. package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts.map +0 -1
  119. package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.js +0 -32
  120. package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts +0 -4
  121. package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts.map +0 -1
  122. package/esm/MaqlEditor/maql/hooks/useAutocomplete.js +0 -60
  123. package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts +0 -4
  124. package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts.map +0 -1
  125. package/esm/MaqlEditor/maql/hooks/useDecoration.js +0 -73
  126. package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts +0 -3
  127. package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts.map +0 -1
  128. package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.js +0 -29
  129. package/esm/MaqlEditor/maql/hooks/useHover.d.ts +0 -6
  130. package/esm/MaqlEditor/maql/hooks/useHover.d.ts.map +0 -1
  131. package/esm/MaqlEditor/maql/hooks/useHover.js +0 -77
  132. package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts +0 -4
  133. package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts.map +0 -1
  134. package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.js +0 -21
  135. package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts +0 -21
  136. package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts.map +0 -1
  137. package/esm/MaqlEditor/maql/hooks/useMonaco.js +0 -75
  138. package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts +0 -4
  139. package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts.map +0 -1
  140. package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.js +0 -33
  141. package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts +0 -2
  142. package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts.map +0 -1
  143. package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.js +0 -28
  144. package/esm/MaqlEditor/maql/hooks/useValidation.d.ts +0 -4
  145. package/esm/MaqlEditor/maql/hooks/useValidation.d.ts.map +0 -1
  146. package/esm/MaqlEditor/maql/hooks/useValidation.js +0 -56
  147. package/esm/MaqlEditor/maql/monacoConverter.d.ts +0 -80
  148. package/esm/MaqlEditor/maql/monacoConverter.d.ts.map +0 -1
  149. package/esm/MaqlEditor/maql/monacoConverter.js +0 -528
  150. package/esm/MaqlEditor/maql/utils.d.ts +0 -4
  151. package/esm/MaqlEditor/maql/utils.d.ts.map +0 -1
  152. package/esm/MaqlEditor/maql/utils.js +0 -6
  153. package/esm/MaqlEditor/mock/monaco-shim.d.ts +0 -5
  154. package/esm/MaqlEditor/mock/monaco-shim.d.ts.map +0 -1
  155. package/esm/MaqlEditor/monaco/MonacoEditor.d.ts +0 -64
  156. package/esm/MaqlEditor/monaco/MonacoEditor.d.ts.map +0 -1
  157. package/esm/MaqlEditor/monaco/MonacoEditor.js +0 -71
  158. package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts +0 -53
  159. package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts.map +0 -1
  160. package/esm/MaqlEditor/monaco/MonacoEditor.styles.js +0 -427
  161. package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts +0 -3
  162. package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts.map +0 -1
  163. package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts +0 -3
  164. package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts.map +0 -1
  165. package/esm/MaqlEditor/monaco/hooks/useDefaultValue.js +0 -14
  166. package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts +0 -3
  167. package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts.map +0 -1
  168. package/esm/MaqlEditor/monaco/hooks/useEditorInit.js +0 -84
  169. package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts +0 -3
  170. package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts.map +0 -1
  171. package/esm/MaqlEditor/monaco/hooks/useEditorOptions.js +0 -51
  172. package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts +0 -3
  173. package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts.map +0 -1
  174. package/esm/MaqlEditor/monaco/hooks/useMonaco.js +0 -24
  175. package/esm/MaqlEditor/monaco/monacoContributions.d.ts +0 -74
  176. package/esm/MaqlEditor/monaco/monacoContributions.d.ts.map +0 -1
  177. package/esm/MaqlEditor/monaco/monacoContributions.js +0 -88
  178. package/esm/MaqlEditor/monaco/monacoWorkers.d.ts +0 -53
  179. package/esm/MaqlEditor/monaco/monacoWorkers.d.ts.map +0 -1
  180. package/esm/MaqlEditor/monaco/monacoWorkers.js +0 -176
  181. package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts +0 -2
  182. package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts.map +0 -1
  183. package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.js +0 -26
  184. package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts +0 -4
  185. package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts.map +0 -1
  186. package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.js +0 -29
  187. package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts +0 -14
  188. package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts.map +0 -1
  189. package/esm/MaqlEditor/sql/hooks/useMonaco.js +0 -26
  190. package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts +0 -2
  191. package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts.map +0 -1
  192. package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.js +0 -796
  193. package/esm/MaqlEditor/sql/utils.d.ts +0 -4
  194. package/esm/MaqlEditor/sql/utils.d.ts.map +0 -1
  195. package/esm/MaqlEditor/sql/utils.js +0 -6
  196. package/worker/monaco-editor-worker.js +0 -33
  197. package/worker/monaco-editor-worker.source.js +0 -1
@@ -1,20 +1,22 @@
1
1
  // (C) 2021-2026 GoodData Corporation
2
- import { DecoratorClassName, DecoratorHovered, DecoratorItemClassName, } from "../../../monaco/MonacoEditor.styles.js";
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
- export function doHover(event, tooltip, editor, hover, settings, onOpen) {
7
- // Early return cases
8
- if (!hover || !event || tooltip.current || !settings.content) {
9
- return settings.content ? null : hover;
10
- }
11
- const containerNode = editor.getContainerDomNode();
12
- if (!containerNode) {
13
- return null;
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(containerNode, event);
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 null;
36
+ return;
35
37
  }
36
- // Create a decorator for the hovered element
37
- const decorator = createDecorator(editor, hover);
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, decorator);
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 Monaco (the hover decoration added above
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: containerNode,
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
- function collectElements(parent, event) {
73
- const element = collectTarget(parent, event);
74
- if (!element)
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
- if (element) {
81
- let current = element.previousElementSibling;
82
- while (current && isDecorator(current)) {
83
- items.unshift(current);
84
- current = current.previousElementSibling;
85
- }
86
- current = element.nextElementSibling;
87
- while (current && isDecorator(current)) {
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 items;
105
+ return current.parentElement === line ? current : null;
93
106
  }
94
- function collectTarget(parent, event) {
95
- if (event.type === "keydown") {
96
- const cursor = parent.querySelector(".cursor.monaco-mouse-cursor-text");
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
- const target = event.target;
104
- return target || null;
111
+ return element.querySelector(DECORATOR_SELECTOR);
105
112
  }
106
- function isDecorator(el) {
107
- if (!el)
108
- return false;
109
- return el.classList.contains(DecoratorClassName) || el.classList.contains(DecoratorItemClassName);
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
- return editor.deltaDecorations([], [
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, decorator) {
125
- editor.deltaDecorations(decorator, []);
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,7 @@
1
+ /**
2
+ * Fills in the browser APIs the editor needs that a DOM test environment lacks.
3
+ *
4
+ * @internal
5
+ */
6
+ export declare function shimMaqlEditor(): void;
7
+ //# sourceMappingURL=editor-shim.d.ts.map
@@ -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 IStandaloneCodeEditor, type Monaco } from "../monaco/MonacoEditor.js";
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
- copy: () => boolean;
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
- onFocus?: (editor: IStandaloneCodeEditor, monaco: Monaco) => void;
20
- onBlur?: (editor: IStandaloneCodeEditor, monaco: Monaco) => void;
21
- onEditorMount?: (editor: IStandaloneCodeEditor, monaco: Monaco) => void;
22
- onChange?: (editor: IStandaloneCodeEditor, monaco: Monaco, value: string) => void;
23
- onValid?: (editor: IStandaloneCodeEditor, monaco: Monaco, valid: boolean) => void;
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;AAMnF,OAAO,EACH,KAAK,qBAAqB,EAE1B,KAAK,MAAM,EAEd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AASlE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAC;CACvB;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,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClF,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,wHA0DpB,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, onValid, onChange, }, ref) {
18
- const [theme, themeData] = useCodeTheme();
19
- const handlers = useMemo(() => ({
20
- onFocus,
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(MonacoEditor, { inline: inline, options: options, readonly: readonly, autofocus: autofocus, className: classNames(SqlEditorClass, SqlEditorTestClass), defaultValue: formattedValue, language: LANGUAGE, languageConfiguration: languageConfiguration, themeName: theme, themeData: themeData, onEditorMount: onMount, onEditorUpdate: onUpdate, ref: editor }) }));
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 * as monaco from "monaco-editor/editor/editor.api.js";
2
- import { type TextDocument } from "vscode-languageserver-textdocument";
3
- import { type FormattingOptions, type Range } from "../monaco/MonacoEditor.js";
4
- export declare function formatDocument(document: TextDocument, options: FormattingOptions, range: Range): monaco.languages.TextEdit[];
5
- export declare function formatValue(text: string, options: FormattingOptions): string;
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":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGvE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAE/E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,KAAK,GACb,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAQ7B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAK5E"}
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 function formatDocument(document, options, range) {
4
- const formatted = formatValue(document.getText(), options);
5
- return [
6
- {
7
- range: range,
8
- text: formatted,
9
- },
10
- ];
11
- }
12
- export function formatValue(text, options) {
13
- return format(text, {
14
- useTabs: !options.insertSpaces,
15
- tabWidth: options.tabSize,
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,3 @@
1
+ import { type Extension } from "@codemirror/state";
2
+ export declare function sqlLanguageSupport(): Extension;
3
+ //# sourceMappingURL=sqlLanguage.d.ts.map
@@ -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 IStandaloneCodeEditor } from "../monaco/MonacoEditor.js";
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
- export declare function onSuggestionElement(editor: IStandaloneCodeEditor, setSuggestionsElement: (el: HTMLElement | null) => void): void;
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;AAIzD,OAAO,EAAE,KAAK,qBAAqB,EAA6B,MAAM,2BAA2B,CAAC;AAGlG,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAoBF,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,cAAc,CAAC,sCAa/E;AAED,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,qBAAqB,EAC7B,qBAAqB,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI,CAQN"}
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
- export function onSuggestionElement(editor, setSuggestionsElement) {
32
- const suggestionWidget = editor.getContribution("editor.contrib.suggestController");
33
- const widget = suggestionWidget?.widget;
34
- if (widget) {
35
- widget.value.onDidShow(() => setSuggestionsElement(widget.value.element.domNode));
36
- widget.value.onDidHide(() => setSuggestionsElement(null));
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,EAOX,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAgB3D,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,wCAAwC,CAAC;AAgCzF,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,gIAmD3B,CAAC"}
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"}