@gooddata/sdk-ui-metric-component 11.67.0-alpha.2 → 11.67.0-alpha.4

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 +798 -2473
  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 +36 -34
  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
@@ -0,0 +1,204 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // (C) 2026 GoodData Corporation
3
+ import { useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
4
+ import classNames from "classnames";
5
+ import { createPortal } from "react-dom";
6
+ import { useIntl } from "react-intl";
7
+ import { Separator } from "@gooddata/sdk-ui-kit";
8
+ import { makeStyles } from "../theme/styles.js";
9
+ import { changeAllOccurrences, copySelection, cutSelection, pasteFromClipboard } from "./commands.js";
10
+ export const CONTEXT_MENU_CLASS = "maql-editor-context-menu";
11
+ export const CONTEXT_MENU_TEST_CLASS = "s-maql-editor-context-menu";
12
+ const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
13
+ /**
14
+ * The key of a shortcut the way the platform writes it: symbols on a Mac, names elsewhere.
15
+ */
16
+ export function platformShortcut(mac, other) {
17
+ return isMac ? mac : other;
18
+ }
19
+ /**
20
+ * The actions every editor of this package offers in its context menu, labelled in the locale of
21
+ * the application: multi-cursor editing in the edit group, and the clipboard group.
22
+ */
23
+ export function useCommonMenuItems() {
24
+ const intl = useIntl();
25
+ return useMemo(() => ({
26
+ changeAllOccurrences: {
27
+ id: "change-all-occurrences",
28
+ group: "edit",
29
+ label: intl.formatMessage({
30
+ id: "metricComponent.editMetric.contextMenu.changeAllOccurrences",
31
+ }),
32
+ shortcut: platformShortcut("⌘F2", "Ctrl+F2"),
33
+ run: changeAllOccurrences,
34
+ },
35
+ clipboard: [
36
+ {
37
+ id: "cut",
38
+ group: "clipboard",
39
+ label: intl.formatMessage({ id: "metricComponent.editMetric.contextMenu.cut" }),
40
+ run: cutSelection,
41
+ },
42
+ {
43
+ id: "copy",
44
+ group: "clipboard",
45
+ label: intl.formatMessage({ id: "metricComponent.editMetric.contextMenu.copy" }),
46
+ readOnly: true,
47
+ run: copySelection,
48
+ },
49
+ {
50
+ id: "paste",
51
+ group: "clipboard",
52
+ label: intl.formatMessage({ id: "metricComponent.editMetric.contextMenu.paste" }),
53
+ run: pasteFromClipboard,
54
+ },
55
+ ],
56
+ }), [intl]);
57
+ }
58
+ const useStyles = makeStyles()((theme) => ({
59
+ menu: {
60
+ position: "fixed",
61
+ // Above the dialogs of the UI kit.
62
+ zIndex: 10002,
63
+ display: "block",
64
+ minWidth: 200,
65
+ },
66
+ item: {
67
+ display: "flex",
68
+ justifyContent: "space-between",
69
+ alignItems: "center",
70
+ gap: 20,
71
+ paddingLeft: 10,
72
+ paddingRight: 10,
73
+ cursor: "pointer",
74
+ // The keyboard moves the focus among the items; the focused item looks like the hovered one.
75
+ "&:focus": {
76
+ outline: "none",
77
+ background: theme.suggestion.colors.selectedBackground,
78
+ },
79
+ },
80
+ shortcut: {
81
+ color: theme.content.colors.lineNumber,
82
+ },
83
+ }));
84
+ /**
85
+ * Keeps the menu inside the window: it opens down and to the right of the pointer, and flips
86
+ * when there is no room.
87
+ */
88
+ function usePlacement(position) {
89
+ const element = useRef(null);
90
+ const [placed, setPlaced] = useState(position);
91
+ useLayoutEffect(() => {
92
+ const rect = element.current?.getBoundingClientRect();
93
+ if (!rect) {
94
+ return;
95
+ }
96
+ setPlaced({
97
+ x: position.x + rect.width > window.innerWidth
98
+ ? Math.max(0, position.x - rect.width)
99
+ : position.x,
100
+ y: position.y + rect.height > window.innerHeight
101
+ ? Math.max(0, position.y - rect.height)
102
+ : position.y,
103
+ });
104
+ }, [position]);
105
+ return [element, placed];
106
+ }
107
+ /**
108
+ * The context menu of an editor, with the actions Monaco's menu offered. It closes on a click
109
+ * outside, on Escape, and when the window changes.
110
+ */
111
+ export function ContextMenu({ editor, items, position, onClose }) {
112
+ const { classes } = useStyles();
113
+ const [element, placed] = usePlacement(position);
114
+ const readOnly = editor.state.readOnly;
115
+ const offered = items.filter((item) => !readOnly || item.readOnly);
116
+ useEffect(() => {
117
+ const isInside = (event) => element.current?.contains(event.target) ?? false;
118
+ // A right button press is followed by a contextmenu event, which is dealt with below.
119
+ const closeOnOutsideClick = (event) => {
120
+ if (event.button !== 2 && !isInside(event)) {
121
+ onClose();
122
+ }
123
+ };
124
+ // A right click on the menu keeps it, without the browser's menu; one elsewhere closes
125
+ // it, and leaves the event to whatever is there: the editor reopens the menu, another
126
+ // control opens its own.
127
+ const takeOverContextMenu = (event) => {
128
+ if (isInside(event)) {
129
+ event.preventDefault();
130
+ }
131
+ else {
132
+ onClose();
133
+ }
134
+ };
135
+ const closeOnEscape = (event) => {
136
+ if (event.key === "Escape") {
137
+ event.stopPropagation();
138
+ onClose();
139
+ editor.focus();
140
+ }
141
+ };
142
+ document.addEventListener("mousedown", closeOnOutsideClick, true);
143
+ document.addEventListener("contextmenu", takeOverContextMenu, true);
144
+ document.addEventListener("keydown", closeOnEscape, true);
145
+ window.addEventListener("resize", onClose);
146
+ window.addEventListener("blur", onClose);
147
+ return () => {
148
+ document.removeEventListener("mousedown", closeOnOutsideClick, true);
149
+ document.removeEventListener("contextmenu", takeOverContextMenu, true);
150
+ document.removeEventListener("keydown", closeOnEscape, true);
151
+ window.removeEventListener("resize", onClose);
152
+ window.removeEventListener("blur", onClose);
153
+ };
154
+ }, [element, editor, onClose]);
155
+ useEffect(() => {
156
+ menuItemsOf(element.current)[0]?.focus();
157
+ }, [element]);
158
+ if (offered.length === 0) {
159
+ return null;
160
+ }
161
+ const closeAndFocusEditor = () => {
162
+ onClose();
163
+ editor.focus();
164
+ };
165
+ return createPortal(_jsx("div", { ref: element, role: "menu", className: classNames("gd-menu-wrapper", classes.menu, CONTEXT_MENU_CLASS, CONTEXT_MENU_TEST_CLASS), style: { top: placed.y, left: placed.x }, onKeyDown: (event) => moveFocus(event, closeAndFocusEditor), children: offered.map((item, index) => {
166
+ const run = () => {
167
+ closeAndFocusEditor();
168
+ void item.run(editor);
169
+ };
170
+ return (_jsxs("div", { children: [index > 0 && offered[index - 1].group !== item.group ? _jsx(Separator, {}) : null, _jsxs("div", { role: "menuitem", tabIndex: -1, className: classNames("gd-list-item gd-menu-item", classes.item, `s-${item.id}`), onClick: run, onKeyDown: (event) => {
171
+ if (event.key === "Enter" || event.key === " ") {
172
+ event.preventDefault();
173
+ run();
174
+ }
175
+ }, children: [_jsx("span", { children: item.label }), item.shortcut ? (_jsx("span", { className: classes.shortcut, "aria-hidden": "true", children: item.shortcut })) : null] })] }, item.id));
176
+ }) }), document.body);
177
+ }
178
+ function menuItemsOf(menu) {
179
+ return Array.from(menu?.querySelectorAll('[role="menuitem"]') ?? []);
180
+ }
181
+ /**
182
+ * Moves the focus among the items with the arrow keys, Home and End, the way a menu does; Tab
183
+ * leaves the menu.
184
+ */
185
+ function moveFocus(event, onLeave) {
186
+ const items = menuItemsOf(event.currentTarget);
187
+ if (items.length === 0) {
188
+ return;
189
+ }
190
+ const current = items.indexOf(document.activeElement);
191
+ const moves = {
192
+ ArrowDown: (current + 1) % items.length,
193
+ ArrowUp: (current - 1 + items.length) % items.length,
194
+ Home: 0,
195
+ End: items.length - 1,
196
+ };
197
+ if (event.key in moves) {
198
+ event.preventDefault();
199
+ items[moves[event.key]].focus();
200
+ }
201
+ else if (event.key === "Tab") {
202
+ onLeave();
203
+ }
204
+ }
@@ -0,0 +1,22 @@
1
+ import { type Extension } from "@codemirror/state";
2
+ import { type Command } from "@codemirror/view";
3
+ /**
4
+ * Class of the placeholder that stands in for a non-breaking space.
5
+ */
6
+ export declare const NBSP_CLASS = "maql-nbsp";
7
+ /**
8
+ * Tab the way Monaco handled it: it inserts the indentation at the cursor, and indents the lines
9
+ * of a selection. It does nothing in a read-only editor, nor while an input method composes text
10
+ * (the Vietnamese keyboard, for one): an edit of the text the input method still owns ends up with
11
+ * the typed letters twice.
12
+ */
13
+ export declare const insertIndent: Command;
14
+ /**
15
+ * The editing behaviour every editor of this package shares: undo history, bracket pairing and
16
+ * matching, the standard key bindings, two-space indentation, and the find and replace panel at
17
+ * the top of the editor, where Monaco's find widget was, with its keys (Mod-f, F3, Enter).
18
+ */
19
+ export declare function baseExtensions(): Extension;
20
+ export declare function lineNumbersExtension(enabled: boolean): Extension;
21
+ export declare function readOnlyExtension(readOnly: boolean): Extension;
22
+ //# sourceMappingURL=baseExtensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseExtensions.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/codemirror/baseExtensions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACH,KAAK,OAAO,EAOf,MAAM,kBAAkB,CAAC;AAM1B;;GAEG;AACH,eAAO,MAAM,UAAU,cAAc,CAAC;AAuBtC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,OAe1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,SAAS,CAuB1C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAQ9D"}
@@ -0,0 +1,95 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
3
+ import { defaultKeymap, history, historyKeymap, indentLess, indentMore } from "@codemirror/commands";
4
+ import { bracketMatching, indentUnit } from "@codemirror/language";
5
+ import { highlightSelectionMatches, search, searchKeymap } from "@codemirror/search";
6
+ import { EditorState } from "@codemirror/state";
7
+ import { EditorView, drawSelection, highlightSpecialChars, keymap, lineNumbers, tooltips, } from "@codemirror/view";
8
+ import { changeAllOccurrences } from "./commands.js";
9
+ const TAB_SIZE = 2;
10
+ /**
11
+ * Class of the placeholder that stands in for a non-breaking space.
12
+ */
13
+ export const NBSP_CLASS = "maql-nbsp";
14
+ /**
15
+ * A non-breaking space looks like a space but the language rejects it, so it is drawn as a marked
16
+ * box, the way Monaco draws invisible characters.
17
+ */
18
+ function renderNbsp() {
19
+ const span = document.createElement("span");
20
+ span.className = `cm-specialChar ${NBSP_CLASS}`;
21
+ span.title = "Non-breaking space (U+00A0)";
22
+ span.setAttribute("aria-label", span.title);
23
+ span.textContent = " ";
24
+ return span;
25
+ }
26
+ /**
27
+ * Tooltips may use the whole window, so a hover above the first line opens above the editor
28
+ * instead of covering the code.
29
+ */
30
+ function windowSpace() {
31
+ return { top: 0, left: 0, right: window.innerWidth, bottom: window.innerHeight };
32
+ }
33
+ /**
34
+ * Tab the way Monaco handled it: it inserts the indentation at the cursor, and indents the lines
35
+ * of a selection. It does nothing in a read-only editor, nor while an input method composes text
36
+ * (the Vietnamese keyboard, for one): an edit of the text the input method still owns ends up with
37
+ * the typed letters twice.
38
+ */
39
+ export const insertIndent = (view) => {
40
+ if (view.state.readOnly) {
41
+ return false;
42
+ }
43
+ if (view.compositionStarted) {
44
+ return true;
45
+ }
46
+ if (view.state.selection.ranges.some((range) => !range.empty)) {
47
+ return indentMore(view);
48
+ }
49
+ view.dispatch(view.state.replaceSelection(view.state.facet(indentUnit)), {
50
+ scrollIntoView: true,
51
+ userEvent: "input",
52
+ });
53
+ return true;
54
+ };
55
+ /**
56
+ * The editing behaviour every editor of this package shares: undo history, bracket pairing and
57
+ * matching, the standard key bindings, two-space indentation, and the find and replace panel at
58
+ * the top of the editor, where Monaco's find widget was, with its keys (Mod-f, F3, Enter).
59
+ */
60
+ export function baseExtensions() {
61
+ return [
62
+ history(),
63
+ drawSelection(),
64
+ bracketMatching(),
65
+ closeBrackets(),
66
+ search({ top: true }),
67
+ highlightSelectionMatches(),
68
+ highlightSpecialChars({ specialChars: / /g, render: renderNbsp }),
69
+ tooltips({ tooltipSpace: windowSpace }),
70
+ keymap.of([
71
+ ...closeBracketsKeymap,
72
+ ...defaultKeymap,
73
+ ...historyKeymap,
74
+ ...searchKeymap,
75
+ { key: "Tab", run: insertIndent, shift: indentLess },
76
+ { key: "Mod-F2", run: changeAllOccurrences },
77
+ ]),
78
+ indentUnit.of(" ".repeat(TAB_SIZE)),
79
+ EditorState.tabSize.of(TAB_SIZE),
80
+ // "Change All Occurrences" edits with a cursor on every occurrence.
81
+ EditorState.allowMultipleSelections.of(true),
82
+ ];
83
+ }
84
+ export function lineNumbersExtension(enabled) {
85
+ return enabled ? lineNumbers() : [];
86
+ }
87
+ export function readOnlyExtension(readOnly) {
88
+ return [
89
+ EditorState.readOnly.of(readOnly),
90
+ EditorView.editable.of(!readOnly),
91
+ // The content of a read-only editor is not editable, so the browser does not let the
92
+ // keyboard reach it on its own; the tab index keeps it in the focus order of the dialog.
93
+ readOnly ? EditorView.contentAttributes.of({ tabindex: "0" }) : [],
94
+ ];
95
+ }
@@ -0,0 +1,21 @@
1
+ import { type Command, type EditorView } from "@codemirror/view";
2
+ /**
3
+ * Puts a cursor on every occurrence of the selected text, or of the word at the cursor, the way
4
+ * Monaco's "Change All Occurrences" did.
5
+ */
6
+ export declare const changeAllOccurrences: Command;
7
+ /**
8
+ * Copies the selection, or the line of the cursor, to the clipboard.
9
+ */
10
+ export declare function copySelection(view: EditorView): Promise<boolean>;
11
+ /**
12
+ * Copies the selection, or the line of the cursor, to the clipboard and removes it from the code.
13
+ * Every selected range goes, with a cursor left in its place.
14
+ */
15
+ export declare function cutSelection(view: EditorView): Promise<boolean>;
16
+ /**
17
+ * Replaces the selection with the text on the clipboard. The browser lets a page read the
18
+ * clipboard only with the user's permission; without it, nothing is pasted.
19
+ */
20
+ export declare function pasteFromClipboard(view: EditorView): Promise<boolean>;
21
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/codemirror/commands.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAelC,CAAC;AA0CF;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtE;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBrE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAc3E"}
@@ -0,0 +1,98 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { selectSelectionMatches } from "@codemirror/search";
3
+ import { EditorSelection } from "@codemirror/state";
4
+ /**
5
+ * Puts a cursor on every occurrence of the selected text, or of the word at the cursor, the way
6
+ * Monaco's "Change All Occurrences" did.
7
+ */
8
+ export const changeAllOccurrences = (view) => {
9
+ if (view.state.readOnly) {
10
+ return false;
11
+ }
12
+ const { main } = view.state.selection;
13
+ if (main.empty) {
14
+ const word = view.state.wordAt(main.head);
15
+ if (!word) {
16
+ return false;
17
+ }
18
+ view.dispatch({ selection: { anchor: word.from, head: word.to } });
19
+ }
20
+ return selectSelectionMatches(view);
21
+ };
22
+ /**
23
+ * What a copy takes, the way Monaco copied: every range that selects text, one per line on the
24
+ * clipboard, or the whole line of the cursor, with its line break, when no range selects anything.
25
+ * The spans are what a cut removes, so they hold exactly the text that went to the clipboard;
26
+ * `mainIndex` is the span of the main selection, which the cut keeps as the main cursor.
27
+ */
28
+ function clipboardContent(view) {
29
+ const { ranges, main } = view.state.selection;
30
+ const selected = ranges.filter((range) => !range.empty);
31
+ if (selected.length > 0) {
32
+ const spans = selected.map((range) => ({ from: range.from, to: range.to }));
33
+ return {
34
+ spans,
35
+ text: spans.map((span) => view.state.sliceDoc(span.from, span.to)).join("\n"),
36
+ mainIndex: Math.max(0, selected.indexOf(main)),
37
+ };
38
+ }
39
+ const line = view.state.doc.lineAt(main.head);
40
+ return {
41
+ spans: [{ from: line.from, to: Math.min(line.to + 1, view.state.doc.length) }],
42
+ text: `${line.text}\n`,
43
+ mainIndex: 0,
44
+ };
45
+ }
46
+ async function writeToClipboard(text) {
47
+ try {
48
+ await navigator.clipboard.writeText(text);
49
+ return true;
50
+ }
51
+ catch {
52
+ return document.execCommand("copy");
53
+ }
54
+ }
55
+ /**
56
+ * Copies the selection, or the line of the cursor, to the clipboard.
57
+ */
58
+ export async function copySelection(view) {
59
+ return writeToClipboard(clipboardContent(view).text);
60
+ }
61
+ /**
62
+ * Copies the selection, or the line of the cursor, to the clipboard and removes it from the code.
63
+ * Every selected range goes, with a cursor left in its place.
64
+ */
65
+ export async function cutSelection(view) {
66
+ if (view.state.readOnly) {
67
+ return false;
68
+ }
69
+ const { spans, text, mainIndex } = clipboardContent(view);
70
+ if (!(await writeToClipboard(text))) {
71
+ return false;
72
+ }
73
+ const changes = view.state.changes(spans.map((span) => ({ from: span.from, to: span.to })));
74
+ view.dispatch({
75
+ changes,
76
+ selection: EditorSelection.create(spans.map((span) => EditorSelection.cursor(changes.mapPos(span.from))), mainIndex),
77
+ userEvent: "delete.cut",
78
+ });
79
+ return true;
80
+ }
81
+ /**
82
+ * Replaces the selection with the text on the clipboard. The browser lets a page read the
83
+ * clipboard only with the user's permission; without it, nothing is pasted.
84
+ */
85
+ export async function pasteFromClipboard(view) {
86
+ if (view.state.readOnly) {
87
+ return false;
88
+ }
89
+ let text;
90
+ try {
91
+ text = await navigator.clipboard.readText();
92
+ }
93
+ catch {
94
+ return document.execCommand("paste");
95
+ }
96
+ view.dispatch(view.state.replaceSelection(text), { scrollIntoView: true, userEvent: "input.paste" });
97
+ return true;
98
+ }
@@ -0,0 +1,7 @@
1
+ import { type EditorView } from "@codemirror/view";
2
+ /**
3
+ * Focuses the editor once it is visible. The editor may mount inside a dialog that is still
4
+ * animating in, so the focus waits until the element has a size.
5
+ */
6
+ export declare function useAutofocus(element: HTMLElement | null, editor: EditorView | null, autofocus: boolean): void;
7
+ //# sourceMappingURL=useAutofocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAutofocus.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/codemirror/hooks/useAutofocus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,YAAY,CACxB,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,SAAS,EAAE,OAAO,GACnB,IAAI,CAgBN"}
@@ -1,5 +1,9 @@
1
1
  // (C) 2021-2026 GoodData Corporation
2
2
  import { useEffect, useRef } from "react";
3
+ /**
4
+ * Focuses the editor once it is visible. The editor may mount inside a dialog that is still
5
+ * animating in, so the focus waits until the element has a size.
6
+ */
3
7
  export function useAutofocus(element, editor, autofocus) {
4
8
  const timer = useRef(-1);
5
9
  useEffect(() => {
@@ -0,0 +1,28 @@
1
+ import { type Diagnostic as LintDiagnostic } from "@codemirror/lint";
2
+ import { type ChangeSpec, type EditorState, type Text } from "@codemirror/state";
3
+ import { TextDocument } from "vscode-languageserver-textdocument";
4
+ import { type Diagnostic, type Position, type Range, type TextEdit } from "vscode-languageserver-types";
5
+ /**
6
+ * Conversions between the language server protocol, which addresses text by zero-based line and
7
+ * character, and CodeMirror, which addresses it by document offset.
8
+ */
9
+ export interface ISpan {
10
+ from: number;
11
+ to: number;
12
+ }
13
+ export declare function positionToOffset(doc: Text, position: Position): number;
14
+ export declare function offsetToPosition(doc: Text, offset: number): Position;
15
+ export declare function rangeToSpan(doc: Text, range: Range): ISpan;
16
+ export declare function spanToRange(doc: Text, span: ISpan): Range;
17
+ export declare function textEditsToChanges(doc: Text, edits: readonly TextEdit[]): ChangeSpec[];
18
+ /**
19
+ * The diagnostics as the editor's linter takes them. A diagnostic without extent, such as "missing
20
+ * expression" at a bracket, keeps its position: Monaco drew no squiggle for it, and the editor
21
+ * styles hide the point marker CodeMirror would draw, while the message still shows on navigation.
22
+ */
23
+ export declare function diagnosticsToLint(doc: Text, diagnostics: readonly Diagnostic[]): LintDiagnostic[];
24
+ /**
25
+ * Snapshot of the editor content in the shape the language service reads.
26
+ */
27
+ export declare function createDocument(state: EditorState, languageId: string): TextDocument;
28
+ //# sourceMappingURL=lsp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsp.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/codemirror/lsp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACH,KAAK,UAAU,EAEf,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,QAAQ,EAChB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AAEH,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAKtE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAKpE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAK1D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,CAEzD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,UAAU,EAAE,CAEtF;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,cAAc,EAAE,CAajG;AAcD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CASnF"}
@@ -0,0 +1,70 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { TextDocument } from "vscode-languageserver-textdocument";
3
+ import { DiagnosticSeverity, } from "vscode-languageserver-types";
4
+ export function positionToOffset(doc, position) {
5
+ const lineNumber = Math.min(Math.max(position.line + 1, 1), doc.lines);
6
+ const line = doc.line(lineNumber);
7
+ return Math.min(line.from + Math.max(position.character, 0), line.to);
8
+ }
9
+ export function offsetToPosition(doc, offset) {
10
+ const clamped = Math.min(Math.max(offset, 0), doc.length);
11
+ const line = doc.lineAt(clamped);
12
+ return { line: line.number - 1, character: clamped - line.from };
13
+ }
14
+ export function rangeToSpan(doc, range) {
15
+ const from = positionToOffset(doc, range.start);
16
+ const to = positionToOffset(doc, range.end);
17
+ return { from: Math.min(from, to), to: Math.max(from, to) };
18
+ }
19
+ export function spanToRange(doc, span) {
20
+ return { start: offsetToPosition(doc, span.from), end: offsetToPosition(doc, span.to) };
21
+ }
22
+ export function textEditsToChanges(doc, edits) {
23
+ return edits.map((edit) => ({ ...rangeToSpan(doc, edit.range), insert: edit.newText }));
24
+ }
25
+ function toLintSeverity(severity) {
26
+ switch (severity) {
27
+ case DiagnosticSeverity.Warning:
28
+ return "warning";
29
+ case DiagnosticSeverity.Information:
30
+ return "info";
31
+ case DiagnosticSeverity.Hint:
32
+ return "hint";
33
+ default:
34
+ return "error";
35
+ }
36
+ }
37
+ /**
38
+ * The diagnostics as the editor's linter takes them. A diagnostic without extent, such as "missing
39
+ * expression" at a bracket, keeps its position: Monaco drew no squiggle for it, and the editor
40
+ * styles hide the point marker CodeMirror would draw, while the message still shows on navigation.
41
+ */
42
+ export function diagnosticsToLint(doc, diagnostics) {
43
+ return diagnostics.map((diagnostic) => {
44
+ const { from, to } = rangeToSpan(doc, diagnostic.range);
45
+ return {
46
+ from,
47
+ to,
48
+ severity: toLintSeverity(diagnostic.severity),
49
+ message: diagnostic.message,
50
+ // Shown after the message the way Monaco shows it: `MAQL(7)`.
51
+ source: diagnosticSource(diagnostic),
52
+ };
53
+ });
54
+ }
55
+ function diagnosticSource(diagnostic) {
56
+ const { source, code } = diagnostic;
57
+ if (source === undefined) {
58
+ return code === undefined ? undefined : String(code);
59
+ }
60
+ return code === undefined ? source : `${source}(${code})`;
61
+ }
62
+ const MODEL_URI = "inmemory://model";
63
+ let documentVersion = 0;
64
+ /**
65
+ * Snapshot of the editor content in the shape the language service reads.
66
+ */
67
+ export function createDocument(state, languageId) {
68
+ documentVersion += 1;
69
+ return TextDocument.create(`${MODEL_URI}.${languageId}`, languageId, documentVersion, state.doc.toString());
70
+ }
@@ -0,0 +1,11 @@
1
+ export interface IRenderedMarkdown {
2
+ dom: HTMLElement;
3
+ destroy: () => void;
4
+ }
5
+ /**
6
+ * Renders markdown into a detached element, for the places CodeMirror takes a DOM node rather than
7
+ * React children: completion documentation and hover tooltips. Rendered synchronously so the node has
8
+ * its size when CodeMirror measures it.
9
+ */
10
+ export declare function renderMarkdown(markdown: string, className: string): IRenderedMarkdown;
11
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/codemirror/markdown.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,WAAW,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAMD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAiBrF"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { flushSync } from "react-dom";
3
+ import { createRoot } from "react-dom/client";
4
+ import Markdown from "react-markdown";
5
+ const components = {
6
+ a: (props) => _jsx("a", { ...props, target: "_blank", rel: "noreferrer" }),
7
+ };
8
+ /**
9
+ * Renders markdown into a detached element, for the places CodeMirror takes a DOM node rather than
10
+ * React children: completion documentation and hover tooltips. Rendered synchronously so the node has
11
+ * its size when CodeMirror measures it.
12
+ */
13
+ export function renderMarkdown(markdown, className) {
14
+ const dom = document.createElement("div");
15
+ dom.className = className;
16
+ const root = createRoot(dom);
17
+ flushSync(() => {
18
+ root.render(_jsx(Markdown, { components: components, children: markdown }));
19
+ });
20
+ return {
21
+ dom,
22
+ destroy: () => {
23
+ // Unmount outside the CodeMirror update that destroys the tooltip, as React refuses
24
+ // synchronous unmounts while another render may be in progress.
25
+ setTimeout(() => root.unmount(), 0);
26
+ },
27
+ };
28
+ }
@@ -0,0 +1,8 @@
1
+ import { type EditorView } from "@codemirror/view";
2
+ /**
3
+ * The editor instance the MAQL and SQL editors hand to their callbacks: a CodeMirror view.
4
+ *
5
+ * @internal
6
+ */
7
+ export type MaqlEditorView = EditorView;
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/codemirror/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ // (C) 2026 GoodData Corporation
2
+ export {};
@@ -1,3 +1,16 @@
1
- import { type IStandaloneThemeData } from "../monaco/MonacoEditor.js";
2
- export declare function useCodeTheme(): [string, IStandaloneThemeData];
1
+ /**
2
+ * Colors of the code itself: the token palette and the reference badges.
3
+ */
4
+ export interface IMaqlCodeTheme {
5
+ background: string;
6
+ /**
7
+ * Color per token type, keyed by the type name the tokenizer and the semantic tokens use.
8
+ */
9
+ tokens: Record<string, string>;
10
+ decorators: Record<string, {
11
+ color: string;
12
+ background: string;
13
+ }>;
14
+ }
15
+ export declare function useCodeTheme(): IMaqlCodeTheme;
3
16
  //# sourceMappingURL=useCodeTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCodeTheme.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/hooks/useCodeTheme.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAatE,wBAAgB,YAAY,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAgD7D"}
1
+ {"version":3,"file":"useCodeTheme.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/hooks/useCodeTheme.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrE;AASD,wBAAgB,YAAY,IAAI,cAAc,CAkC7C"}