@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.
- package/NOTICE +798 -2473
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.js +170 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts +95 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.js +536 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.js +204 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +22 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.js +95 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts +21 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/commands.js +98 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts +7 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts.map +1 -0
- package/esm/MaqlEditor/{monaco → codemirror}/hooks/useAutofocus.js +4 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts +28 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/lsp.js +70 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts +11 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/markdown.js +28 -0
- package/esm/MaqlEditor/codemirror/types.d.ts +8 -0
- package/esm/MaqlEditor/codemirror/types.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/types.js +2 -0
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts +15 -2
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCodeTheme.js +36 -43
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts +7 -2
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCopyToClipboard.js +53 -10
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts +25 -9
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.js +179 -30
- package/esm/MaqlEditor/maql/MaqlEditor.styles.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.styles.js +13 -17
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.js +15 -20
- package/esm/MaqlEditor/maql/extensions/completion.d.ts +101 -0
- package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/completion.js +420 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts +19 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/decorations.js +137 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/formatting.js +78 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/hover.js +98 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts +15 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.js +79 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts +41 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/validation.js +202 -0
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts +19 -4
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/hover/doHover.js +71 -61
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts +16 -0
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/maqlLanguage.js +72 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts +7 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts.map +1 -0
- package/esm/MaqlEditor/mock/{monaco-shim.js → editor-shim.js} +27 -1
- package/esm/MaqlEditor/sql/SqlEditor.d.ts +15 -7
- package/esm/MaqlEditor/sql/SqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/SqlEditor.js +55 -30
- package/esm/MaqlEditor/sql/formatter.d.ts +6 -5
- package/esm/MaqlEditor/sql/formatter.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/formatter.js +14 -14
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts +3 -0
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/sql/sqlLanguage.js +19 -0
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts +5 -2
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts.map +1 -1
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.js +20 -8
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.js +28 -27
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts +0 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.js +4 -29
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.js +4 -2
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts +2 -5
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/maqlFieldFunctions.js +1 -4
- package/esm/index.d.ts +3 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/sdk-ui-metric-component.d.ts +50 -39
- package/esm/shared/permissions.d.ts.map +1 -1
- package/esm/shared/permissions.js +1 -0
- package/esm/translations/en-US.json +36 -0
- package/package.json +36 -34
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts +0 -3
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useAutoformat.js +0 -15
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts +0 -4
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useCleanCallback.js +0 -12
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts +0 -13
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useMountCallback.js +0 -26
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts +0 -19
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useUpdateCallback.js +0 -63
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts +0 -6
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useValueCallbacks.js +0 -14
- package/esm/MaqlEditor/maql/formatter.d.ts +0 -6
- package/esm/MaqlEditor/maql/formatter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/formatter.js +0 -14
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.js +0 -32
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.js +0 -60
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDecoration.js +0 -73
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts +0 -3
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.js +0 -29
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts +0 -6
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useHover.js +0 -77
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.js +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useMonaco.js +0 -75
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.js +0 -33
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.js +0 -28
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useValidation.js +0 -56
- package/esm/MaqlEditor/maql/monacoConverter.d.ts +0 -80
- package/esm/MaqlEditor/maql/monacoConverter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/monacoConverter.js +0 -528
- package/esm/MaqlEditor/maql/utils.d.ts +0 -4
- package/esm/MaqlEditor/maql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/utils.js +0 -6
- package/esm/MaqlEditor/mock/monaco-shim.d.ts +0 -5
- package/esm/MaqlEditor/mock/monaco-shim.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts +0 -64
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.js +0 -71
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts +0 -53
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.js +0 -427
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.js +0 -14
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.js +0 -84
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.js +0 -51
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useMonaco.js +0 -24
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts +0 -74
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoContributions.js +0 -88
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts +0 -53
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoWorkers.js +0 -176
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.js +0 -29
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts +0 -14
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useMonaco.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.js +0 -796
- package/esm/MaqlEditor/sql/utils.d.ts +0 -4
- package/esm/MaqlEditor/sql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/utils.js +0 -6
- package/worker/monaco-editor-worker.js +0 -33
- package/worker/monaco-editor-worker.source.js +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState, } from "react";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useState, } from "react";
|
|
4
4
|
import { isEmpty } from "lodash-es";
|
|
5
5
|
import { flushSync } from "react-dom";
|
|
6
6
|
import { createRoot } from "react-dom/client";
|
|
7
|
+
import { useIntl } from "react-intl";
|
|
7
8
|
import { IconArrowDown, IconArrowUp, IconAttribute, IconClose, IconDataset, IconFact, IconFunction, IconKeyword, IconLabel, IconMetric, IconQuestionMark, } from "@gooddata/sdk-ui-kit";
|
|
8
9
|
import { MaqlEditor } from "../../../MaqlEditor/maql/MaqlEditor.js";
|
|
9
10
|
import { useEvents } from "../../../shared/eventing/useEvents.js";
|
|
@@ -14,7 +15,7 @@ import { useMetricFormStatus } from "../hooks/useMetricFormStatus.js";
|
|
|
14
15
|
import { Placeholder } from "../MaqlEditorUtils/Placeholder.js";
|
|
15
16
|
import { getMaqlValue, useMaqlField } from "../maqlFieldFunctions.js";
|
|
16
17
|
import { events } from "./MaqlEditorField.events.js";
|
|
17
|
-
import {
|
|
18
|
+
import { useDocumentationLinkProcessing } from "./suggestionDetailsFunctions.js";
|
|
18
19
|
const useStyles = makeStyles()(() => ({
|
|
19
20
|
root: {
|
|
20
21
|
flex: "1 1 auto",
|
|
@@ -58,29 +59,28 @@ const icons = Object.fromEntries(Object.entries({
|
|
|
58
59
|
}).map(([key, component]) => [key, serializeReactElementToSvg(component)]));
|
|
59
60
|
export const MaqlEditorEditor = forwardRef(function MaqlEditorEditor({ onMetricOpen, onRun, titles }, ref) {
|
|
60
61
|
const { classes, cx } = useStyles();
|
|
62
|
+
const intl = useIntl();
|
|
61
63
|
const { value, valid, element, isReadOnly, onBlur, onChange } = useMetricFormField(FormField.expression);
|
|
62
64
|
const [autofocus, setAutofocus] = useState(false);
|
|
63
65
|
const [autohints, setAutoHints] = useAutohint(!valid);
|
|
64
66
|
const isMaqlEditorEmpty = isEmpty(getMaqlValue(value));
|
|
65
67
|
const [onChanged, onValidation] = useMaqlField(value, onChange);
|
|
66
68
|
const onBlurHandler = useBlur(value, onBlur, setAutoHints, setAutofocus);
|
|
67
|
-
const onMetricOpenHandler = useCallback(
|
|
68
|
-
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
-
(_, object) => onMetricOpen?.(object), [onMetricOpen]);
|
|
69
|
+
const onMetricOpenHandler = useCallback((_editor, object) => onMetricOpen?.(object), [onMetricOpen]);
|
|
70
70
|
const onEditorMount = useEditorMount();
|
|
71
|
-
const
|
|
71
|
+
const onToggleSuggestionDetails = useTrackSuggestionDetails();
|
|
72
|
+
const keyBindings = useRunKeyBinding(onRun);
|
|
72
73
|
useImperativeHandle(element, () => ({
|
|
73
74
|
focus: () => setAutofocus(true),
|
|
74
75
|
}));
|
|
75
|
-
return (_jsxs("div", { className: cx(classes.root), children: [_jsx(Placeholder, { visible: isMaqlEditorEmpty, readonly: isReadOnly, selector: ".
|
|
76
|
+
return (_jsxs("div", { className: cx(classes.root), children: [_jsx(Placeholder, { visible: isMaqlEditorEmpty, readonly: isReadOnly, selector: ".cm-editor .cm-content .cm-line" }), _jsx(MaqlEditor, { autohint: autohints, decorators: titles, autofocus: autofocus, readonly: isReadOnly, defaultValue: getMaqlValue(value), icons: icons, ariaLabel: intl.formatMessage({ id: "metricComponent.editMetric.metric.definition" }), keyBindings: keyBindings, onBlur: onBlurHandler, onValid: onValidation, onChange: onChanged, onEditorMount: onEditorMount, onMetricOpen: onMetricOpenHandler, onToggleSuggestionDetails: onToggleSuggestionDetails, ref: ref })] }));
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Reports to the telemetry that the user showed or hid the documentation of the suggestions.
|
|
80
|
+
*/
|
|
81
|
+
function useTrackSuggestionDetails() {
|
|
78
82
|
const { editorToggleSuggestionDetailsEvent } = useEvents(events);
|
|
79
|
-
return useCallback((
|
|
80
|
-
if (commandId === "toggleSuggestionDetails") {
|
|
81
|
-
editorToggleSuggestionDetailsEvent();
|
|
82
|
-
}
|
|
83
|
-
}, [editorToggleSuggestionDetailsEvent]);
|
|
83
|
+
return useCallback(() => editorToggleSuggestionDetailsEvent(), [editorToggleSuggestionDetailsEvent]);
|
|
84
84
|
}
|
|
85
85
|
function useBlur(value, onBlur, setAutoHints, setAutofocus) {
|
|
86
86
|
const { metricDefinitionCreatedEvent } = useEvents(events);
|
|
@@ -95,25 +95,26 @@ function useBlur(value, onBlur, setAutoHints, setAutofocus) {
|
|
|
95
95
|
}
|
|
96
96
|
function useEditorMount() {
|
|
97
97
|
const processDocumentationClick = useDocumentationLinkProcessing();
|
|
98
|
-
|
|
99
|
-
const trackMonacoCommands = useTrackMonacoCommands();
|
|
100
|
-
return useCallback((editor) => {
|
|
101
|
-
const disposable = [];
|
|
102
|
-
// @ts-expect-error command service is not in public API
|
|
103
|
-
disposable.push(editor._commandService.onDidExecuteCommand(trackMonacoCommands));
|
|
98
|
+
useEffect(() => {
|
|
104
99
|
document.body.addEventListener("click", processDocumentationClick);
|
|
105
|
-
document.body.addEventListener("contextmenu", processDocumentationContextMenu);
|
|
106
100
|
return () => {
|
|
107
101
|
document.body.removeEventListener("click", processDocumentationClick);
|
|
108
|
-
document.body.removeEventListener("contextmenu", processDocumentationContextMenu);
|
|
109
|
-
disposable.forEach((dispose) => dispose.dispose());
|
|
110
102
|
};
|
|
111
|
-
}, [processDocumentationClick
|
|
103
|
+
}, [processDocumentationClick]);
|
|
104
|
+
return useCallback(() => {
|
|
105
|
+
// nothing to set up on the editor itself
|
|
106
|
+
}, []);
|
|
112
107
|
}
|
|
113
|
-
function
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
function useRunKeyBinding(onRun) {
|
|
109
|
+
return useMemo(() => [
|
|
110
|
+
{
|
|
111
|
+
key: "Mod-r",
|
|
112
|
+
run: () => {
|
|
113
|
+
onRun?.();
|
|
114
|
+
return true;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
], [onRun]);
|
|
117
118
|
}
|
|
118
119
|
function useAutohint(invalid) {
|
|
119
120
|
const [autohints, setAutoHints] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestionDetailsFunctions.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"suggestionDetailsFunctions.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.ts"],"names":[],"mappings":"AAiCA,wBAAgB,8BAA8B,IAAI,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAa5E"}
|
|
@@ -2,22 +2,6 @@
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { useEvents } from "../../../shared/eventing/useEvents.js";
|
|
4
4
|
import { events } from "./MaqlEditorField.events.js";
|
|
5
|
-
function shouldModifyHref(href) {
|
|
6
|
-
return !href || href === "#" || href === `${location.origin}${location.pathname}#`;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* monaco suggestion details links are processed with href=#, we need to change link to correct value, which is in data-href attribute
|
|
10
|
-
* https://github.com/microsoft/vscode/blob/1eaf52cfd50c05b93e73eb6e96046c23257018ad/src/vs/base/browser/markdownRenderer.ts#L159
|
|
11
|
-
* @param element -
|
|
12
|
-
*/
|
|
13
|
-
function fixMonacoMarkdownAnchorHref(element) {
|
|
14
|
-
if (shouldModifyHref(element.href) && element.dataset["href"]) {
|
|
15
|
-
const href = element.dataset["href"];
|
|
16
|
-
element.setAttribute("href", href);
|
|
17
|
-
element.href = href;
|
|
18
|
-
}
|
|
19
|
-
return element;
|
|
20
|
-
}
|
|
21
5
|
function eventTargetsToClassArray(eventTargets) {
|
|
22
6
|
return eventTargets
|
|
23
7
|
.map((element) => element.classList)
|
|
@@ -27,12 +11,15 @@ function eventTargetsToClassArray(eventTargets) {
|
|
|
27
11
|
function containsClasses(pathClasses, ...classNames) {
|
|
28
12
|
return classNames.every((className) => pathClasses.some((pathClass) => pathClass.includes(className)));
|
|
29
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether the click landed on a link in the documentation of a suggestion of the MAQL editor.
|
|
16
|
+
*/
|
|
30
17
|
function isAnchorClickInSuggestDetails(event) {
|
|
31
18
|
if (event.target?.tagName.toLowerCase() !== "a") {
|
|
32
19
|
return false;
|
|
33
20
|
}
|
|
34
21
|
const pathClasses = eventTargetsToClassArray(event.composedPath());
|
|
35
|
-
return containsClasses(pathClasses, "maql-editor", "
|
|
22
|
+
return containsClasses(pathClasses, "maql-editor", "cm-completionInfo");
|
|
36
23
|
}
|
|
37
24
|
export function useDocumentationLinkProcessing() {
|
|
38
25
|
const { editorClickSuggestionDetailLinkEvent } = useEvents(events);
|
|
@@ -40,18 +27,6 @@ export function useDocumentationLinkProcessing() {
|
|
|
40
27
|
if (!isAnchorClickInSuggestDetails(event)) {
|
|
41
28
|
return;
|
|
42
29
|
}
|
|
43
|
-
if (event.ctrlKey || event.metaKey) {
|
|
44
|
-
fixMonacoMarkdownAnchorHref(event.target);
|
|
45
|
-
}
|
|
46
30
|
editorClickSuggestionDetailLinkEvent();
|
|
47
31
|
}, [editorClickSuggestionDetailLinkEvent]);
|
|
48
32
|
}
|
|
49
|
-
export function useDocumentationLinkContextMenuProcessing() {
|
|
50
|
-
return useCallback((event) => {
|
|
51
|
-
if (!isAnchorClickInSuggestDetails(event)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const links = document.querySelectorAll(`a[data-href][href="#"]`);
|
|
55
|
-
Array.from(links).forEach(fixMonacoMarkdownAnchorHref);
|
|
56
|
-
}, []);
|
|
57
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaqlSql.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlResult/MaqlSql.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaqlSql.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlResult/MaqlSql.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAgCzD,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC;AAED,wBAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,aAAa,2CA8ClE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
3
|
import { useRef } from "react";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
4
5
|
import { ErrorComponent } from "@gooddata/sdk-ui";
|
|
5
6
|
import { LoadingSpinner } from "@gooddata/sdk-ui-kit";
|
|
6
7
|
import { SqlEditor } from "../../../MaqlEditor/sql/SqlEditor.js";
|
|
@@ -35,13 +36,14 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
35
36
|
}));
|
|
36
37
|
export function MaqlSql({ explain, onClose, onCopy }) {
|
|
37
38
|
const { classes, cx } = useStyles();
|
|
39
|
+
const intl = useIntl();
|
|
38
40
|
const { sql, status, error } = explain;
|
|
39
41
|
const api = useRef(null);
|
|
40
42
|
return (_jsxs("div", { className: cx(classes.root), children: [_jsx("div", { className: cx(classes.headerHolder), children: _jsx(MaqlSqlHeader, { canCopy: !!explain.sql, onAction: (action) => {
|
|
41
43
|
switch (action) {
|
|
42
44
|
case HeaderAction.Copy:
|
|
43
45
|
if (onCopy) {
|
|
44
|
-
|
|
46
|
+
void (api.current?.copy() ?? Promise.resolve(false)).then(onCopy);
|
|
45
47
|
}
|
|
46
48
|
break;
|
|
47
49
|
case HeaderAction.Close:
|
|
@@ -50,5 +52,5 @@ export function MaqlSql({ explain, onClose, onCopy }) {
|
|
|
50
52
|
}
|
|
51
53
|
break;
|
|
52
54
|
}
|
|
53
|
-
} }) }), _jsxs("div", { className: cx(classes.contentHolder), children: [(status === "loading" || status === "pending") && (_jsx(LoadingSpinner, { className: cx(classes.loading, "large") })), status === "success" && sql && (_jsx(SqlEditor, { defaultValue: sql, readonly: true, inline: false, ref: api })), status === "error" && error && (_jsx(ErrorComponent, { message: error.name, description: error.message }))] })] }));
|
|
55
|
+
} }) }), _jsxs("div", { className: cx(classes.contentHolder), children: [(status === "loading" || status === "pending") && (_jsx(LoadingSpinner, { className: cx(classes.loading, "large") })), status === "success" && sql && (_jsx(SqlEditor, { defaultValue: sql, readonly: true, inline: false, ariaLabel: intl.formatMessage({ id: "metricComponent.editMetric.metric.sql" }), ref: api })), status === "error" && error && (_jsx(ErrorComponent, { message: error.name, description: error.message }))] })] }));
|
|
54
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaqlEditorView } from "../../MaqlEditor/codemirror/types.js";
|
|
2
2
|
import { type IMeasureDef } from "../metric/metricHelpers.js";
|
|
3
3
|
export type IMeasureDefWithMaqlField = Omit<IMeasureDef, "expression"> & {
|
|
4
4
|
expression: string | MaqlValue;
|
|
@@ -9,9 +9,6 @@ export type MaqlValue = string | {
|
|
|
9
9
|
};
|
|
10
10
|
export declare function getMaqlValue(value: MaqlValue): string;
|
|
11
11
|
export declare function getMaqlValid(value: MaqlValue): boolean;
|
|
12
|
-
export declare function useMaqlField(value: MaqlValue, onChange: (value: MaqlValue) => void): [
|
|
13
|
-
(editor: IStandaloneCodeEditor, monaco: Monaco, value: string) => void,
|
|
14
|
-
(editor: IStandaloneCodeEditor, monaco: Monaco, valid: boolean) => void
|
|
15
|
-
];
|
|
12
|
+
export declare function useMaqlField(value: MaqlValue, onChange: (value: MaqlValue) => void): [(editor: MaqlEditorView, value: string) => void, (editor: MaqlEditorView, valid: boolean) => void];
|
|
16
13
|
export declare function createMaqlValue(value: string, valid: boolean): MaqlValue;
|
|
17
14
|
//# sourceMappingURL=maqlFieldFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maqlFieldFunctions.d.ts","sourceRoot":"","sources":["../../../src/MetricComponent/Form/maqlFieldFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"maqlFieldFunctions.d.ts","sourceRoot":"","sources":["../../../src/MetricComponent/Form/maqlFieldFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE5G,MAAM,MAAM,SAAS,GACf,MAAM,GACN;IACI,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AAER,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAKrD;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAKtD;AAED,wBAAgB,YAAY,CACxB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GACrC,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,CAqBrG;AAYD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAKxE"}
|
|
@@ -15,12 +15,10 @@ export function getMaqlValid(value) {
|
|
|
15
15
|
export function useMaqlField(value, onChange) {
|
|
16
16
|
const valueRef = useRef(getMaqlValue(value));
|
|
17
17
|
const validRef = useRef(getMaqlValid(value));
|
|
18
|
-
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
18
|
const onValidation = useValueOnly((valid) => {
|
|
20
19
|
validRef.current = valid;
|
|
21
20
|
onChange(createMaqlValue(valueRef.current, valid));
|
|
22
21
|
}, [onChange]);
|
|
23
|
-
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
22
|
const onChanged = useValueOnly((currentValue) => {
|
|
25
23
|
valueRef.current = currentValue;
|
|
26
24
|
onChange(createMaqlValue(currentValue, validRef.current));
|
|
@@ -28,8 +26,7 @@ export function useMaqlField(value, onChange) {
|
|
|
28
26
|
return [onChanged, onValidation];
|
|
29
27
|
}
|
|
30
28
|
function useValueOnly(handler, deps) {
|
|
31
|
-
return useCallback((
|
|
32
|
-
const [, , value] = args;
|
|
29
|
+
return useCallback((_editor, value) => {
|
|
33
30
|
handler(value);
|
|
34
31
|
},
|
|
35
32
|
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
package/esm/index.d.ts
CHANGED
|
@@ -18,11 +18,11 @@ export { ConflictContextProvider, type IConflictContext, } from "./MetricCompone
|
|
|
18
18
|
export type { ConflictChecker } from "./MetricComponent/ConflictContext/useConflictDetection.js";
|
|
19
19
|
export { type ISqlEditorApi, type ISqlEditorProps, SqlEditor } from "./MaqlEditor/sql/SqlEditor.js";
|
|
20
20
|
export { type IMaqlEditorApi, type IMaqlEditorProps, MaqlEditor } from "./MaqlEditor/maql/MaqlEditor.js";
|
|
21
|
-
export type { IMaqlEditorIcon, IMaqlEditorIcons } from "./MaqlEditor/
|
|
21
|
+
export type { IMaqlEditorIcon, IMaqlEditorIcons } from "./MaqlEditor/codemirror/CodeEditor.styles.js";
|
|
22
22
|
export { type MaqlEditorDefaultTheme, createDefaultTheme } from "./MaqlEditor/theme/default.js";
|
|
23
|
-
export type {
|
|
23
|
+
export type { MaqlEditorView } from "./MaqlEditor/codemirror/types.js";
|
|
24
24
|
export { type ILanguageServiceProviderProps, LanguageServiceProvider, } from "./MaqlEditor/languageService/LanguageServiceContext.js";
|
|
25
|
-
export { shimMaqlEditor } from "./MaqlEditor/mock/
|
|
25
|
+
export { shimMaqlEditor } from "./MaqlEditor/mock/editor-shim.js";
|
|
26
26
|
export { type IIntlWrapperProps, IntlWrapper } from "./translations/IntlWrapper.js";
|
|
27
27
|
export { GlobalLoading } from "./shared/GlobalLoading/GlobalLoading.js";
|
|
28
28
|
export { useMetrics, type IUseMetricsOptions } from "./shared/metrics/useMetrics.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qDAAqD,CAAC;AAC/F,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,WAAW,EACX,iBAAiB,GACpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,oDAAoD,CAAC;AACpF,YAAY,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC1F,Y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K,wBAAwB,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,yDAAyD,CAAC;AAC7G,YAAY,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,KAAK,mBAAmB,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAClG,YAAY,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AACxG,OAAO,EACH,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,yBAAyB,GACjC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,4BAA4B,EAC5B,gBAAgB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACH,6BAA6B,EAC7B,sBAAsB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACH,+BAA+B,EAC/B,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,kDAAkD,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { SqlEditor } from "./MaqlEditor/sql/SqlEditor.js";
|
|
|
18
18
|
export { MaqlEditor } from "./MaqlEditor/maql/MaqlEditor.js";
|
|
19
19
|
export { createDefaultTheme } from "./MaqlEditor/theme/default.js";
|
|
20
20
|
export { LanguageServiceProvider, } from "./MaqlEditor/languageService/LanguageServiceContext.js";
|
|
21
|
-
export { shimMaqlEditor } from "./MaqlEditor/mock/
|
|
21
|
+
export { shimMaqlEditor } from "./MaqlEditor/mock/editor-shim.js";
|
|
22
22
|
export { IntlWrapper } from "./translations/IntlWrapper.js";
|
|
23
23
|
export { GlobalLoading } from "./shared/GlobalLoading/GlobalLoading.js";
|
|
24
24
|
export { useMetrics } from "./shared/metrics/useMetrics.js";
|
|
@@ -2,6 +2,7 @@ import { Context } from 'react';
|
|
|
2
2
|
import { Css } from 'tss-react';
|
|
3
3
|
import { CSSObject } from 'tss-react';
|
|
4
4
|
import { Cx } from 'tss-react';
|
|
5
|
+
import { EditorView } from '@codemirror/view';
|
|
5
6
|
import { ForwardRefExoticComponent } from 'react';
|
|
6
7
|
import { IAuthenticationContext } from '@gooddata/sdk-backend-spi';
|
|
7
8
|
import { ICatalogAttribute } from '@gooddata/sdk-model';
|
|
@@ -18,7 +19,7 @@ import { ISeparators } from '@gooddata/sdk-model';
|
|
|
18
19
|
import { ITranslations } from '@gooddata/sdk-ui';
|
|
19
20
|
import { IWorkspacePermissions } from '@gooddata/sdk-model';
|
|
20
21
|
import { JSX } from 'react/jsx-runtime';
|
|
21
|
-
import
|
|
22
|
+
import { KeyBinding } from '@codemirror/view';
|
|
22
23
|
import { NotAuthenticated } from '@gooddata/sdk-backend-spi';
|
|
23
24
|
import { ObjectVisibility } from '@gooddata/sdk-model';
|
|
24
25
|
import { ObjRef } from '@gooddata/sdk-model';
|
|
@@ -512,11 +513,6 @@ export declare interface IDeleteMetricProps {
|
|
|
512
513
|
onMetricsChange?: (metric: IMeasureDef) => void;
|
|
513
514
|
}
|
|
514
515
|
|
|
515
|
-
/**
|
|
516
|
-
* @internal
|
|
517
|
-
*/
|
|
518
|
-
export declare type IDisposable = monaco.IDisposable;
|
|
519
|
-
|
|
520
516
|
/**
|
|
521
517
|
* @internal
|
|
522
518
|
*/
|
|
@@ -563,11 +559,6 @@ export declare interface IEditMetricProps {
|
|
|
563
559
|
onDraftAccessChange?: (draftAccess: IObjectShareDraft | undefined) => void;
|
|
564
560
|
}
|
|
565
561
|
|
|
566
|
-
/**
|
|
567
|
-
* @internal
|
|
568
|
-
*/
|
|
569
|
-
export declare type IEditorContribution = monaco.editor.IEditorContribution;
|
|
570
|
-
|
|
571
562
|
/**
|
|
572
563
|
* @internal
|
|
573
564
|
*/
|
|
@@ -750,6 +741,9 @@ export declare interface IMaqlEditorIcons {
|
|
|
750
741
|
attribute?: IMaqlEditorIcon;
|
|
751
742
|
keyword?: IMaqlEditorIcon;
|
|
752
743
|
function?: IMaqlEditorIcon;
|
|
744
|
+
operator?: IMaqlEditorIcon;
|
|
745
|
+
snippet?: IMaqlEditorIcon;
|
|
746
|
+
value?: IMaqlEditorIcon;
|
|
753
747
|
detail?: IMaqlEditorIcon;
|
|
754
748
|
next?: IMaqlEditorIcon;
|
|
755
749
|
prev?: IMaqlEditorIcon;
|
|
@@ -762,19 +756,34 @@ export declare interface IMaqlEditorIcons {
|
|
|
762
756
|
export declare interface IMaqlEditorProps {
|
|
763
757
|
cssTheme?: MaqlEditorDefaultTheme;
|
|
764
758
|
autofocus?: boolean;
|
|
759
|
+
/**
|
|
760
|
+
* Show the first error when the editor gets the focus, until the code changes or becomes valid.
|
|
761
|
+
*/
|
|
765
762
|
autohint?: boolean;
|
|
766
763
|
decorators?: boolean;
|
|
767
764
|
defaultValue?: string;
|
|
768
765
|
readonly?: boolean;
|
|
769
766
|
inline?: boolean;
|
|
770
767
|
icons?: IMaqlEditorIcons;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
768
|
+
/**
|
|
769
|
+
* The accessible name of the editor.
|
|
770
|
+
*/
|
|
771
|
+
ariaLabel?: string;
|
|
772
|
+
/**
|
|
773
|
+
* Extra key bindings of the host. They win over the editor's own.
|
|
774
|
+
*/
|
|
775
|
+
keyBindings?: readonly KeyBinding[];
|
|
776
|
+
onFocus?: (editor: MaqlEditorView) => void;
|
|
777
|
+
onBlur?: (editor: MaqlEditorView) => void;
|
|
778
|
+
onEditorMount?: (editor: MaqlEditorView) => void;
|
|
779
|
+
onEditorUpdate?: (editor: MaqlEditorView) => void;
|
|
780
|
+
onChange?: (editor: MaqlEditorView, value: string) => void;
|
|
781
|
+
onValid?: (editor: MaqlEditorView, valid: boolean) => void;
|
|
782
|
+
onMetricOpen?: (editor: MaqlEditorView, object: IMetadataObject) => void;
|
|
783
|
+
/**
|
|
784
|
+
* Called when the user shows or hides the documentation of the suggestions.
|
|
785
|
+
*/
|
|
786
|
+
onToggleSuggestionDetails?: (editor: MaqlEditorView, visible: boolean) => void;
|
|
778
787
|
ref?: Ref<IMaqlEditorApi | null>;
|
|
779
788
|
}
|
|
780
789
|
|
|
@@ -949,7 +958,12 @@ export declare interface ISaveMetricInfo {
|
|
|
949
958
|
* @internal
|
|
950
959
|
*/
|
|
951
960
|
export declare interface ISqlEditorApi {
|
|
952
|
-
|
|
961
|
+
/**
|
|
962
|
+
* Copies the SQL to the clipboard.
|
|
963
|
+
*
|
|
964
|
+
* @returns whether the text reached the clipboard
|
|
965
|
+
*/
|
|
966
|
+
copy: () => Promise<boolean>;
|
|
953
967
|
}
|
|
954
968
|
|
|
955
969
|
/**
|
|
@@ -961,24 +975,17 @@ export declare interface ISqlEditorProps {
|
|
|
961
975
|
defaultValue?: string;
|
|
962
976
|
readonly?: boolean;
|
|
963
977
|
inline?: boolean;
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
978
|
+
/**
|
|
979
|
+
* The accessible name of the editor.
|
|
980
|
+
*/
|
|
981
|
+
ariaLabel?: string;
|
|
982
|
+
onFocus?: (editor: MaqlEditorView) => void;
|
|
983
|
+
onBlur?: (editor: MaqlEditorView) => void;
|
|
984
|
+
onEditorMount?: (editor: MaqlEditorView) => void;
|
|
985
|
+
onChange?: (editor: MaqlEditorView, value: string) => void;
|
|
969
986
|
ref?: Ref<ISqlEditorApi | null>;
|
|
970
987
|
}
|
|
971
988
|
|
|
972
|
-
/**
|
|
973
|
-
* @internal
|
|
974
|
-
*/
|
|
975
|
-
export declare type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
|
|
976
|
-
|
|
977
|
-
/**
|
|
978
|
-
* @internal
|
|
979
|
-
*/
|
|
980
|
-
export declare type IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions;
|
|
981
|
-
|
|
982
989
|
/**
|
|
983
990
|
* @internal
|
|
984
991
|
*/
|
|
@@ -1324,6 +1331,13 @@ export declare const MaqlEditor: ForwardRefExoticComponent<Omit<IMaqlEditorProps
|
|
|
1324
1331
|
*/
|
|
1325
1332
|
export declare type MaqlEditorDefaultTheme = ReturnType<typeof createDefaultTheme>;
|
|
1326
1333
|
|
|
1334
|
+
/**
|
|
1335
|
+
* The editor instance the MAQL and SQL editors hand to their callbacks: a CodeMirror view.
|
|
1336
|
+
*
|
|
1337
|
+
* @internal
|
|
1338
|
+
*/
|
|
1339
|
+
export declare type MaqlEditorView = EditorView;
|
|
1340
|
+
|
|
1327
1341
|
/**
|
|
1328
1342
|
* @internal
|
|
1329
1343
|
*/
|
|
@@ -1362,11 +1376,6 @@ export declare function MetricTooltip({ metric, className, iconClassName, active
|
|
|
1362
1376
|
*/
|
|
1363
1377
|
export declare const MinimizeMetrics: ForwardRefExoticComponent<Omit<IMinimizedMetricsProps, "ref"> & RefAttributes<HTMLElement | undefined>>;
|
|
1364
1378
|
|
|
1365
|
-
/**
|
|
1366
|
-
* @internal
|
|
1367
|
-
*/
|
|
1368
|
-
export declare type Monaco = typeof monaco;
|
|
1369
|
-
|
|
1370
1379
|
/**
|
|
1371
1380
|
* @internal
|
|
1372
1381
|
*/
|
|
@@ -1424,6 +1433,8 @@ export declare enum SaveNameMode {
|
|
|
1424
1433
|
}
|
|
1425
1434
|
|
|
1426
1435
|
/**
|
|
1436
|
+
* Fills in the browser APIs the editor needs that a DOM test environment lacks.
|
|
1437
|
+
*
|
|
1427
1438
|
* @internal
|
|
1428
1439
|
*/
|
|
1429
1440
|
export declare function shimMaqlEditor(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/shared/permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,qBAAqB,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/shared/permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,qBAAqB,CAgCjE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,wBAAwB,CAKvE;AAED,wBAAgB,wBAAwB,IAAI,qBAAqB,CAMhE;AAED,wBAAgB,2BAA2B,IAAI,wBAAwB,CAMtE"}
|
|
@@ -11,6 +11,7 @@ export function emptyWorkspacePermissions() {
|
|
|
11
11
|
canAnalyzeWorkspace: false,
|
|
12
12
|
canCreateVisualization: false,
|
|
13
13
|
canCreateComputedAttribute: false,
|
|
14
|
+
canCreateDocument: false,
|
|
14
15
|
canManageVisualizations: false,
|
|
15
16
|
canExecuteRaw: false,
|
|
16
17
|
canExportReport: false,
|
|
@@ -179,6 +179,42 @@
|
|
|
179
179
|
"text": "Less",
|
|
180
180
|
"crowdinContext": "Button to collapse and show less content in metric editor"
|
|
181
181
|
},
|
|
182
|
+
"metricComponent.editMetric.hover.definition": {
|
|
183
|
+
"text": "Definition of {title}",
|
|
184
|
+
"crowdinContext": "Accessible name of the read-only MAQL definition shown in the tooltip of a referenced metric; {title} is the metric's title"
|
|
185
|
+
},
|
|
186
|
+
"metricComponent.editMetric.suggestion.documentation": {
|
|
187
|
+
"text": "Documentation",
|
|
188
|
+
"crowdinContext": "Accessible name of the button on a suggestion in the MAQL editor that shows the documentation of the suggested function or object"
|
|
189
|
+
},
|
|
190
|
+
"metricComponent.editMetric.suggestion.closeDocumentation": {
|
|
191
|
+
"text": "Close",
|
|
192
|
+
"crowdinContext": "Accessible name of the button that closes the documentation of a suggestion in the MAQL editor"
|
|
193
|
+
},
|
|
194
|
+
"metricComponent.editMetric.contextMenu.changeAllOccurrences": {
|
|
195
|
+
"text": "Change All Occurrences",
|
|
196
|
+
"crowdinContext": "Item of the right-click menu of the code editor; puts a cursor on every occurrence of the selected text so they are edited together"
|
|
197
|
+
},
|
|
198
|
+
"metricComponent.editMetric.contextMenu.formatDocument": {
|
|
199
|
+
"text": "Format Document",
|
|
200
|
+
"crowdinContext": "Item of the right-click menu of the code editor; reformats the whole code"
|
|
201
|
+
},
|
|
202
|
+
"metricComponent.editMetric.contextMenu.formatSelection": {
|
|
203
|
+
"text": "Format Selection",
|
|
204
|
+
"crowdinContext": "Item of the right-click menu of the code editor; reformats the selected code"
|
|
205
|
+
},
|
|
206
|
+
"metricComponent.editMetric.contextMenu.cut": {
|
|
207
|
+
"text": "Cut",
|
|
208
|
+
"crowdinContext": "Item of the right-click menu of the code editor; cuts the selected text to the clipboard"
|
|
209
|
+
},
|
|
210
|
+
"metricComponent.editMetric.contextMenu.copy": {
|
|
211
|
+
"text": "Copy",
|
|
212
|
+
"crowdinContext": "Item of the right-click menu of the code editor; copies the selected text to the clipboard"
|
|
213
|
+
},
|
|
214
|
+
"metricComponent.editMetric.contextMenu.paste": {
|
|
215
|
+
"text": "Paste",
|
|
216
|
+
"crowdinContext": "Item of the right-click menu of the code editor; pastes the text from the clipboard"
|
|
217
|
+
},
|
|
182
218
|
"metricComponent.editMetric.metric.definition": {
|
|
183
219
|
"text": "Metric definition",
|
|
184
220
|
"crowdinContext": "Section title for metric definition area"
|