@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.
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
@@ -0,0 +1,22 @@
1
+ import { type Extension } from "@codemirror/state";
2
+ import { type EditorView } from "@codemirror/view";
3
+ import { type MaqlLanguageService } from "@gooddata/sdk-maql-language-server";
4
+ /**
5
+ * Formats the whole code with the language service.
6
+ *
7
+ * @returns whether the code was formatted; false when the editor is read-only, the code changed
8
+ * during the request, or the request failed
9
+ */
10
+ export declare function formatMaqlDocument(editor: EditorView, languageService: MaqlLanguageService): Promise<boolean>;
11
+ /**
12
+ * Formats the selection, or the whole code when nothing is selected.
13
+ *
14
+ * @returns whether the code was formatted; false when the editor is read-only, the code changed
15
+ * during the request, or the request failed
16
+ */
17
+ export declare function formatMaqlSelection(editor: EditorView, languageService: MaqlLanguageService): Promise<boolean>;
18
+ /**
19
+ * The formatting keys: Shift+Alt+F formats the document, the Ctrl+K Ctrl+F chord the selection.
20
+ */
21
+ export declare function maqlFormattingKeymap(languageService: MaqlLanguageService): Extension;
22
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/formatting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAqB9E;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,mBAAmB,GACrC,OAAO,CAAC,OAAO,CAAC,CASlB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,mBAAmB,GACrC,OAAO,CAAC,OAAO,CAAC,CAelB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAiBpF"}
@@ -0,0 +1,78 @@
1
+ // (C) 2022-2026 GoodData Corporation
2
+ import { keymap } from "@codemirror/view";
3
+ import { createDocument, spanToRange, textEditsToChanges } from "../../codemirror/lsp.js";
4
+ import { LANGUAGE } from "../constants.js";
5
+ const FORMATTING_OPTIONS = { tabSize: 2, insertSpaces: true };
6
+ /**
7
+ * Applies the edits the language service computed for `doc`, unless the editor is read-only or
8
+ * the user changed the code while the request was in flight: the edits address the old text and
9
+ * would land in the wrong places of the new one.
10
+ */
11
+ function applyEdits(editor, doc, edits) {
12
+ // The read-only facet stops the user's edits, not a dispatched change.
13
+ if (editor.state.readOnly || editor.state.doc !== doc) {
14
+ return false;
15
+ }
16
+ editor.dispatch({ changes: textEditsToChanges(doc, edits) });
17
+ return true;
18
+ }
19
+ /**
20
+ * Formats the whole code with the language service.
21
+ *
22
+ * @returns whether the code was formatted; false when the editor is read-only, the code changed
23
+ * during the request, or the request failed
24
+ */
25
+ export async function formatMaqlDocument(editor, languageService) {
26
+ const doc = editor.state.doc;
27
+ const document = createDocument(editor.state, LANGUAGE);
28
+ try {
29
+ const edits = await languageService.doFormat(document, FORMATTING_OPTIONS);
30
+ return applyEdits(editor, doc, edits);
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /**
37
+ * Formats the selection, or the whole code when nothing is selected.
38
+ *
39
+ * @returns whether the code was formatted; false when the editor is read-only, the code changed
40
+ * during the request, or the request failed
41
+ */
42
+ export async function formatMaqlSelection(editor, languageService) {
43
+ const selection = editor.state.selection.main;
44
+ if (selection.empty) {
45
+ return formatMaqlDocument(editor, languageService);
46
+ }
47
+ const doc = editor.state.doc;
48
+ const document = createDocument(editor.state, LANGUAGE);
49
+ const range = spanToRange(doc, { from: selection.from, to: selection.to });
50
+ try {
51
+ const edits = await languageService.doFormatRange(document, range, FORMATTING_OPTIONS);
52
+ return applyEdits(editor, doc, edits);
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ }
58
+ /**
59
+ * The formatting keys: Shift+Alt+F formats the document, the Ctrl+K Ctrl+F chord the selection.
60
+ */
61
+ export function maqlFormattingKeymap(languageService) {
62
+ return keymap.of([
63
+ {
64
+ key: "Shift-Alt-f",
65
+ run: (editor) => {
66
+ void formatMaqlDocument(editor, languageService);
67
+ return true;
68
+ },
69
+ },
70
+ {
71
+ key: "Mod-k Mod-f",
72
+ run: (editor) => {
73
+ void formatMaqlSelection(editor, languageService);
74
+ return true;
75
+ },
76
+ },
77
+ ]);
78
+ }
@@ -0,0 +1,22 @@
1
+ import { type MutableRefObject } from "react";
2
+ import { type Extension } from "@codemirror/state";
3
+ import { EditorView } from "@codemirror/view";
4
+ import { type MaqlLanguageService } from "@gooddata/sdk-maql-language-server";
5
+ import { type IMetadataObject } from "@gooddata/sdk-model";
6
+ import { type IRootRef } from "../../components/ExpandableTooltip.js";
7
+ import { type HoverSettings } from "../hooks/hover/doHover.js";
8
+ export interface IMaqlHoverOptions {
9
+ languageService: MaqlLanguageService;
10
+ tooltip: MutableRefObject<IRootRef | null>;
11
+ /**
12
+ * The context the metric tooltip renders with. Read at hover time, so the latest values apply.
13
+ */
14
+ getSettings: () => Omit<HoverSettings, "content" | "readOnly">;
15
+ onOpen?: (editor: EditorView, object: IMetadataObject) => void;
16
+ }
17
+ /**
18
+ * Hover from the language service: the metric tooltip for a referenced object, a markdown tooltip
19
+ * for everything else. Ctrl+U or Cmd+U hovers the cursor.
20
+ */
21
+ export declare function maqlHover({ languageService, tooltip, getSettings, onOpen }: IMaqlHoverOptions): Extension;
22
+ //# sourceMappingURL=hover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/hover.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,KAAK,SAAS,EAAQ,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAsC,MAAM,kBAAkB,CAAC;AAGlF,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAClG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,KAAK,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AAG3F,MAAM,WAAW,iBAAiB;IAC9B,eAAe,EAAE,mBAAmB,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC3C;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAClE;AAqBD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAsFzG"}
@@ -0,0 +1,98 @@
1
+ // (C) 2021-2026 GoodData Corporation
2
+ import { Prec } from "@codemirror/state";
3
+ import { EditorView, hoverTooltip, keymap } from "@codemirror/view";
4
+ import { HOVER_CLASS } from "../../codemirror/CodeEditor.styles.js";
5
+ import { createDocument, offsetToPosition, rangeToSpan } from "../../codemirror/lsp.js";
6
+ import { renderMarkdown } from "../../codemirror/markdown.js";
7
+ import { LANGUAGE } from "../constants.js";
8
+ import { doHover, elementAtPosition } from "../hooks/hover/doHover.js";
9
+ import { destroyMaqlTooltip } from "../MaqlEditor.tooltip.js";
10
+ const HOVER_DELAY_MS = 300;
11
+ function isHoverShortcut(event) {
12
+ return (event.ctrlKey || event.metaKey) && event.key === "u";
13
+ }
14
+ function markdownOf(contents) {
15
+ if (Array.isArray(contents)) {
16
+ return contents.map((content) => markdownOf(content)).join("\n\n");
17
+ }
18
+ if (typeof contents === "string") {
19
+ return contents;
20
+ }
21
+ if ("language" in contents) {
22
+ return "```" + contents.language + "\n" + contents.value + "\n```";
23
+ }
24
+ return contents.value;
25
+ }
26
+ /**
27
+ * Hover from the language service: the metric tooltip for a referenced object, a markdown tooltip
28
+ * for everything else. Ctrl+U or Cmd+U hovers the cursor.
29
+ */
30
+ export function maqlHover({ languageService, tooltip, getSettings, onOpen }) {
31
+ async function hover(editor, pos) {
32
+ const document = createDocument(editor.state, LANGUAGE);
33
+ const position = offsetToPosition(editor.state.doc, pos);
34
+ try {
35
+ return await languageService.doHover(document, position);
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ function showObjectTooltip(editor, pos, result) {
42
+ doHover(elementAtPosition(editor, pos), tooltip, editor, result, {
43
+ ...getSettings(),
44
+ content: result.object,
45
+ readOnly: editor.state.readOnly || Boolean(result.object?.isLocked),
46
+ }, onOpen);
47
+ }
48
+ function markdownTooltip(editor, pos, result) {
49
+ const markdown = result.contents ? markdownOf(result.contents) : "";
50
+ if (!markdown.trim()) {
51
+ return null;
52
+ }
53
+ const span = result.range ? rangeToSpan(editor.state.doc, result.range) : { from: pos, to: pos };
54
+ return {
55
+ pos: span.from,
56
+ end: span.to,
57
+ above: true,
58
+ create: () => renderMarkdown(markdown, HOVER_CLASS),
59
+ };
60
+ }
61
+ const mouseHover = hoverTooltip(async (editor, pos) => {
62
+ const result = await hover(editor, pos);
63
+ if (!result) {
64
+ return null;
65
+ }
66
+ if (result.object) {
67
+ showObjectTooltip(editor, pos + 1, result);
68
+ return null;
69
+ }
70
+ return markdownTooltip(editor, pos, result);
71
+ }, { hoverTime: HOVER_DELAY_MS });
72
+ // Above the standard bindings: the history keymap binds Mod-u to undoing a selection change
73
+ // there, which would take the key as soon as the caret had moved.
74
+ const shortcut = Prec.high(keymap.of([
75
+ {
76
+ key: "Mod-u",
77
+ run: (editor) => {
78
+ const pos = editor.state.selection.main.head;
79
+ void hover(editor, pos).then((result) => {
80
+ if (result?.object) {
81
+ showObjectTooltip(editor, pos, result);
82
+ }
83
+ });
84
+ return true;
85
+ },
86
+ },
87
+ ]));
88
+ // Typing closes the metric tooltip; the shortcut that opens it does not.
89
+ const closeOnKey = EditorView.domEventHandlers({
90
+ keydown: (event) => {
91
+ if (!isHoverShortcut(event)) {
92
+ destroyMaqlTooltip(tooltip);
93
+ }
94
+ return false;
95
+ },
96
+ });
97
+ return [mouseHover, shortcut, closeOnKey];
98
+ }
@@ -0,0 +1,15 @@
1
+ import { type Extension, type Text } from "@codemirror/state";
2
+ import { type DecorationSet } from "@codemirror/view";
3
+ import { type SemanticTokensLegend } from "vscode-languageserver-types";
4
+ import { type MaqlLanguageService } from "@gooddata/sdk-maql-language-server";
5
+ /**
6
+ * Turns the protocol's relative token encoding, five integers per token, into mark decorations
7
+ * classed by token type.
8
+ */
9
+ export declare function decodeSemanticTokens(doc: Text, data: readonly number[], tokenTypes: readonly string[]): DecorationSet;
10
+ /**
11
+ * Colors the code by the tokens of the language service's parser, which knows functions from
12
+ * keywords and references from text. The regular-expression tokenizer colors the code meanwhile.
13
+ */
14
+ export declare function semanticTokens(languageService: MaqlLanguageService, legend: SemanticTokensLegend): Extension;
15
+ //# sourceMappingURL=semanticTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticTokens.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/semanticTokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA4C,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAc,KAAK,aAAa,EAA2C,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAuB9E;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,UAAU,EAAE,SAAS,MAAM,EAAE,GAC9B,aAAa,CAoBf;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC1B,eAAe,EAAE,mBAAmB,EACpC,MAAM,EAAE,oBAAoB,GAC7B,SAAS,CAwCX"}
@@ -0,0 +1,79 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
3
+ import { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
4
+ import { SEMANTIC_TOKEN_CLASS_PREFIX } from "../../codemirror/CodeEditor.styles.js";
5
+ import { createDocument, positionToOffset } from "../../codemirror/lsp.js";
6
+ import { LANGUAGE } from "../constants.js";
7
+ const setSemanticTokens = StateEffect.define();
8
+ const semanticTokensField = StateField.define({
9
+ create: () => Decoration.none,
10
+ update(value, transaction) {
11
+ for (const effect of transaction.effects) {
12
+ if (effect.is(setSemanticTokens)) {
13
+ return effect.value;
14
+ }
15
+ }
16
+ return transaction.docChanged ? value.map(transaction.changes) : value;
17
+ },
18
+ provide: (field) => EditorView.decorations.from(field),
19
+ });
20
+ const TOKEN_TYPE_SUFFIX = `.${LANGUAGE}`;
21
+ /**
22
+ * Turns the protocol's relative token encoding, five integers per token, into mark decorations
23
+ * classed by token type.
24
+ */
25
+ export function decodeSemanticTokens(doc, data, tokenTypes) {
26
+ const builder = new RangeSetBuilder();
27
+ let line = 0;
28
+ let start = 0;
29
+ for (let i = 0; i + 4 < data.length; i += 5) {
30
+ const [deltaLine, deltaStart, length, tokenType] = [data[i], data[i + 1], data[i + 2], data[i + 3]];
31
+ line += deltaLine;
32
+ start = deltaLine === 0 ? start + deltaStart : deltaStart;
33
+ const from = positionToOffset(doc, { line, character: start });
34
+ const to = Math.min(from + length, doc.length);
35
+ const type = tokenTypes[tokenType]?.replace(TOKEN_TYPE_SUFFIX, "");
36
+ if (type && to > from) {
37
+ builder.add(from, to, Decoration.mark({ class: `${SEMANTIC_TOKEN_CLASS_PREFIX}${type}` }));
38
+ }
39
+ }
40
+ return builder.finish();
41
+ }
42
+ /**
43
+ * Colors the code by the tokens of the language service's parser, which knows functions from
44
+ * keywords and references from text. The regular-expression tokenizer colors the code meanwhile.
45
+ */
46
+ export function semanticTokens(languageService, legend) {
47
+ const plugin = ViewPlugin.fromClass(class {
48
+ view;
49
+ destroyed = false;
50
+ constructor(view) {
51
+ this.view = view;
52
+ this.request();
53
+ }
54
+ update(update) {
55
+ if (update.docChanged) {
56
+ this.request();
57
+ }
58
+ }
59
+ destroy() {
60
+ this.destroyed = true;
61
+ }
62
+ request() {
63
+ const doc = this.view.state.doc;
64
+ languageService
65
+ .doSemanticTokens(createDocument(this.view.state, LANGUAGE))
66
+ .then((tokens) => {
67
+ // A newer document has its own request on the way.
68
+ if (this.destroyed || this.view.state.doc !== doc) {
69
+ return;
70
+ }
71
+ this.view.dispatch({
72
+ effects: setSemanticTokens.of(decodeSemanticTokens(doc, tokens.data, legend.tokenTypes)),
73
+ });
74
+ })
75
+ .catch(() => undefined);
76
+ }
77
+ });
78
+ return [semanticTokensField, plugin];
79
+ }
@@ -0,0 +1,41 @@
1
+ import { type EditorState, type Extension } from "@codemirror/state";
2
+ import { type Command, EditorView } from "@codemirror/view";
3
+ import { type MaqlLanguageService } from "@gooddata/sdk-maql-language-server";
4
+ /**
5
+ * Validates the code with the language service after each change, right away: Monaco validated
6
+ * on the next tick, and the user reads the result (the error markers, the tab status) as soon as
7
+ * they stop typing.
8
+ */
9
+ export declare function maqlLinter(languageService: MaqlLanguageService): Extension;
10
+ /**
11
+ * Reports the code the editor opened with as invalid when it is, the way Monaco did: on the next
12
+ * tick, and with a request that outlives the editor, since a dialog that reopens on another tab
13
+ * unmounts this one before the answer arrives and the tab still has to show its status. Valid
14
+ * code is not reported, as Monaco raised no event for markers that stayed empty: the form around
15
+ * the editor mounts with the saved code and switches to the edited code in an effect, and a
16
+ * report that reaches it in between would hand it the saved code as the edited one. A change of
17
+ * the code during the request is reported by the linter.
18
+ */
19
+ export declare function initialValidity(languageService: MaqlLanguageService, onValid: (editor: EditorView, valid: boolean) => void): Extension;
20
+ /**
21
+ * Whether the code has no error diagnostics.
22
+ */
23
+ export declare function isValid(state: EditorState): boolean;
24
+ /**
25
+ * Reports the validity each time a validation changes it from the last one reported. A validation
26
+ * that confirms the last report is not reported, the way Monaco raised no event for unchanged
27
+ * markers: the form reads a report as a change of the code, and the code it holds right after a
28
+ * mount is not yet the code of the editor. The last report is what counts, not the diagnostics
29
+ * in the editor: a deletion drops them before any validation runs, while the form still holds
30
+ * the validity they stood for.
31
+ */
32
+ export declare function validityListener(onValid: (editor: EditorView, valid: boolean) => void): Extension;
33
+ /**
34
+ * Shows the next diagnostic: the one at the cursor first, then the following one on each call.
35
+ */
36
+ export declare const showNextDiagnostic: Command;
37
+ /**
38
+ * The navigable diagnostic widget with its keys: F8 shows the next diagnostic, Escape hides it.
39
+ */
40
+ export declare function maqlDiagnosticWidget(): Extension;
41
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAA2B,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,KAAK,OAAO,EAAE,UAAU,EAAiD,MAAM,kBAAkB,CAAC;AAE3G,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAuB9E;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAE1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC3B,eAAe,EAAE,mBAAmB,EACpC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GACtD,SAAS,CAYX;AAMD;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAMnD;AAUD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,SAAS,CAYjG;AA4FD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAuBhC,CAAC;AAUF;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,CAQhD"}
@@ -0,0 +1,202 @@
1
+ // (C) 2021-2026 GoodData Corporation
2
+ import { forEachDiagnostic, linter, setDiagnosticsEffect } from "@codemirror/lint";
3
+ import { StateEffect, StateField } from "@codemirror/state";
4
+ import { EditorView, ViewPlugin, keymap, showTooltip } from "@codemirror/view";
5
+ import { DIAGNOSTIC_WIDGET_CLASS } from "../../codemirror/CodeEditor.styles.js";
6
+ import { createDocument, diagnosticsToLint } from "../../codemirror/lsp.js";
7
+ import { LANGUAGE } from "../constants.js";
8
+ /**
9
+ * The diagnostics of the document, from the language service. An empty document is valid, and so
10
+ * is one the validation failed on: the previous diagnostics no longer apply to it.
11
+ */
12
+ async function validate(state, languageService) {
13
+ const document = createDocument(state, LANGUAGE);
14
+ if (document.getText().length === 0) {
15
+ return [];
16
+ }
17
+ try {
18
+ const diagnostics = await languageService.doValidation(document);
19
+ return diagnosticsToLint(state.doc, diagnostics);
20
+ }
21
+ catch {
22
+ return [];
23
+ }
24
+ }
25
+ /**
26
+ * Validates the code with the language service after each change, right away: Monaco validated
27
+ * on the next tick, and the user reads the result (the error markers, the tab status) as soon as
28
+ * they stop typing.
29
+ */
30
+ export function maqlLinter(languageService) {
31
+ return linter((view) => validate(view.state, languageService), { delay: 0 });
32
+ }
33
+ /**
34
+ * Reports the code the editor opened with as invalid when it is, the way Monaco did: on the next
35
+ * tick, and with a request that outlives the editor, since a dialog that reopens on another tab
36
+ * unmounts this one before the answer arrives and the tab still has to show its status. Valid
37
+ * code is not reported, as Monaco raised no event for markers that stayed empty: the form around
38
+ * the editor mounts with the saved code and switches to the edited code in an effect, and a
39
+ * report that reaches it in between would hand it the saved code as the edited one. A change of
40
+ * the code during the request is reported by the linter.
41
+ */
42
+ export function initialValidity(languageService, onValid) {
43
+ return ViewPlugin.define((view) => {
44
+ setTimeout(() => {
45
+ const state = view.state;
46
+ void validate(state, languageService).then((diagnostics) => {
47
+ if (view.state.doc === state.doc && hasErrors(diagnostics)) {
48
+ onValid(view, false);
49
+ }
50
+ });
51
+ }, 0);
52
+ return {};
53
+ });
54
+ }
55
+ function hasErrors(diagnostics) {
56
+ return diagnostics.some((diagnostic) => diagnostic.severity === "error");
57
+ }
58
+ /**
59
+ * Whether the code has no error diagnostics.
60
+ */
61
+ export function isValid(state) {
62
+ const diagnostics = [];
63
+ forEachDiagnostic(state, (diagnostic) => {
64
+ diagnostics.push(diagnostic);
65
+ });
66
+ return !hasErrors(diagnostics);
67
+ }
68
+ function diagnosticsChanged(update) {
69
+ return update.transactions.some((transaction) => transaction.effects.some((effect) => effect.is(setDiagnosticsEffect)));
70
+ }
71
+ /**
72
+ * Reports the validity each time a validation changes it from the last one reported. A validation
73
+ * that confirms the last report is not reported, the way Monaco raised no event for unchanged
74
+ * markers: the form reads a report as a change of the code, and the code it holds right after a
75
+ * mount is not yet the code of the editor. The last report is what counts, not the diagnostics
76
+ * in the editor: a deletion drops them before any validation runs, while the form still holds
77
+ * the validity they stood for.
78
+ */
79
+ export function validityListener(onValid) {
80
+ let reported = true;
81
+ return EditorView.updateListener.of((update) => {
82
+ if (diagnosticsChanged(update)) {
83
+ const valid = isValid(update.state);
84
+ if (valid !== reported) {
85
+ reported = valid;
86
+ onValid(update.view, valid);
87
+ }
88
+ }
89
+ });
90
+ }
91
+ const showDiagnostic = StateEffect.define();
92
+ function diagnosticTooltip(diagnostic) {
93
+ return {
94
+ pos: diagnostic.from,
95
+ end: diagnostic.to,
96
+ above: false,
97
+ strictSide: true,
98
+ create: () => {
99
+ const dom = document.createElement("div");
100
+ dom.className = DIAGNOSTIC_WIDGET_CLASS;
101
+ const message = document.createElement("div");
102
+ message.className = "message";
103
+ message.textContent = diagnostic.message;
104
+ dom.append(message);
105
+ return { dom };
106
+ },
107
+ };
108
+ }
109
+ function activeDiagnostic(diagnostic) {
110
+ return { diagnostic, tooltip: diagnosticTooltip(diagnostic) };
111
+ }
112
+ /**
113
+ * The diagnostic the user navigated to, shown under its line until the code changes. A refresh of
114
+ * the diagnostics, which the validation sends right after a change, moves the widget to the most
115
+ * severe of the new ones, so an F8 pressed while the validation runs shows the current error.
116
+ */
117
+ const activeDiagnosticField = StateField.define({
118
+ create: () => null,
119
+ update(value, transaction) {
120
+ if (transaction.docChanged) {
121
+ return null;
122
+ }
123
+ let next = value;
124
+ for (const effect of transaction.effects) {
125
+ if (effect.is(showDiagnostic)) {
126
+ next = effect.value ? activeDiagnostic(effect.value) : null;
127
+ }
128
+ else if (effect.is(setDiagnosticsEffect) && next) {
129
+ const first = diagnosticAtCursor(sortDiagnostics(effect.value), transaction.state.selection.main.head);
130
+ next = first ? activeDiagnostic(first) : null;
131
+ }
132
+ }
133
+ return next;
134
+ },
135
+ provide: (field) => showTooltip.from(field, (value) => value?.tooltip ?? null),
136
+ });
137
+ const SEVERITY_ORDER = { error: 0, warning: 1, info: 2, hint: 3 };
138
+ /**
139
+ * Diagnostics in navigation order: the most severe first, then by position.
140
+ */
141
+ function sortDiagnostics(diagnostics) {
142
+ return [...diagnostics].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] || a.from - b.from);
143
+ }
144
+ function orderedDiagnostics(state) {
145
+ const diagnostics = [];
146
+ forEachDiagnostic(state, (diagnostic) => {
147
+ diagnostics.push(diagnostic);
148
+ });
149
+ return sortDiagnostics(diagnostics);
150
+ }
151
+ /**
152
+ * The diagnostic to show first, the way Monaco's marker navigation chose it: the first one, in
153
+ * navigation order, under the cursor or after it, and the first one of all when the cursor is
154
+ * past them. The end of a diagnostic counts as under the cursor, so the error of the character
155
+ * just typed wins over an earlier one.
156
+ */
157
+ function diagnosticAtCursor(diagnostics, cursor) {
158
+ return (diagnostics.find((diagnostic) => diagnostic.from <= cursor && cursor <= diagnostic.to) ??
159
+ diagnostics.find((diagnostic) => diagnostic.from >= cursor) ??
160
+ diagnostics[0]);
161
+ }
162
+ /**
163
+ * Shows the next diagnostic: the one at the cursor first, then the following one on each call.
164
+ */
165
+ export const showNextDiagnostic = (view) => {
166
+ const diagnostics = orderedDiagnostics(view.state);
167
+ if (diagnostics.length === 0) {
168
+ return false;
169
+ }
170
+ const active = view.state.field(activeDiagnosticField, false)?.diagnostic;
171
+ const activeIndex = active
172
+ ? diagnostics.findIndex((diagnostic) => diagnostic.from === active.from && diagnostic.message === active.message)
173
+ : -1;
174
+ const next = activeIndex === -1
175
+ ? diagnosticAtCursor(diagnostics, view.state.selection.main.head)
176
+ : diagnostics[(activeIndex + 1) % diagnostics.length];
177
+ view.dispatch({
178
+ selection: { anchor: next.from },
179
+ effects: showDiagnostic.of(next),
180
+ scrollIntoView: true,
181
+ });
182
+ return true;
183
+ };
184
+ const hideDiagnostic = (view) => {
185
+ if (view.state.field(activeDiagnosticField) === null) {
186
+ return false;
187
+ }
188
+ view.dispatch({ effects: showDiagnostic.of(null) });
189
+ return true;
190
+ };
191
+ /**
192
+ * The navigable diagnostic widget with its keys: F8 shows the next diagnostic, Escape hides it.
193
+ */
194
+ export function maqlDiagnosticWidget() {
195
+ return [
196
+ activeDiagnosticField,
197
+ keymap.of([
198
+ { key: "F8", run: showNextDiagnostic },
199
+ { key: "Escape", run: hideDiagnostic },
200
+ ]),
201
+ ];
202
+ }
@@ -1,12 +1,27 @@
1
1
  import { type MutableRefObject } from "react";
2
- import type * as monaco from "monaco-editor/editor/editor.api.js";
3
- import { type ObjectContent } from "@gooddata/sdk-maql-language-server";
2
+ import { type EditorView } from "@codemirror/view";
3
+ import { type HoverWithData, type ObjectContent } from "@gooddata/sdk-maql-language-server";
4
4
  import { type IMetadataObject } from "@gooddata/sdk-model";
5
5
  import { type IRootRef } from "../../../components/ExpandableTooltip.js";
6
- import { type IStandaloneCodeEditor } from "../../../monaco/MonacoEditor.js";
7
6
  import { type MaqlTooltipSettings } from "../../MaqlEditor.tooltip.js";
8
7
  export type HoverSettings = Omit<MaqlTooltipSettings, "elements" | "content"> & {
9
8
  content: ObjectContent | null | undefined;
10
9
  };
11
- export declare function doHover(event: MouseEvent | KeyboardEvent | null, tooltip: MutableRefObject<IRootRef | null>, editor: IStandaloneCodeEditor, hover: monaco.languages.Hover | null, settings: HoverSettings, onOpen?: (editor: IStandaloneCodeEditor, object: IMetadataObject) => void): monaco.languages.Hover | null;
10
+ /**
11
+ * Opens the metric tooltip over the hovered reference.
12
+ *
13
+ * @param target - the element under the pointer, or at the cursor for the keyboard shortcut
14
+ */
15
+ export declare function doHover(target: HTMLElement | null, tooltip: MutableRefObject<IRootRef | null>, editor: EditorView, hover: HoverWithData, settings: HoverSettings, onOpen?: (editor: EditorView, object: IMetadataObject) => void): void;
16
+ /**
17
+ * The element at a document position: the span that renders the character before it, so a
18
+ * cursor right after a reference still finds the reference.
19
+ */
20
+ export declare function elementAtPosition(editor: EditorView, pos: number): HTMLElement | null;
21
+ /**
22
+ * The spans of the reference the element is part of: its badge and its text. The editor nests the
23
+ * spans of overlapping marks, so each is looked for inside its line-level ancestor, and the buffers
24
+ * the editor places around widgets are stepped over.
25
+ */
26
+ export declare function collectElements(element: HTMLElement): Array<HTMLElement>;
12
27
  //# sourceMappingURL=doHover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doHover.d.ts","sourceRoot":"","sources":["../../../../../src/MaqlEditor/maql/hooks/hover/doHover.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,KAAK,KAAK,MAAM,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAM7E,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,6BAA6B,CAAC;AAgB1F,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IAC5E,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,wBAAgB,OAAO,CACnB,KAAK,EAAE,UAAU,GAAG,aAAa,GAAG,IAAI,EACxC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,EAC1C,MAAM,EAAE,qBAAqB,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,EACpC,QAAQ,EAAE,aAAa,EACvB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,GAC1E,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAgF/B"}
1
+ {"version":3,"file":"doHover.d.ts","sourceRoot":"","sources":["../../../../../src/MaqlEditor/maql/hooks/hover/doHover.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI3D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,6BAA6B,CAAC;AAa1F,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IAC5E,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CACnB,MAAM,EAAE,WAAW,GAAG,IAAI,EAC1B,OAAO,EAAE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,EAC1C,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,aAAa,EACvB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,GAC/D,IAAI,CAuEN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAKrF;AAMD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAYxE"}