@fc-components/monaco-editor 0.1.2 → 0.1.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/README.md +14 -5
- package/dist/monaco-editor.cjs.development.js +38 -17
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +38 -17
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/completion/DataProvider.d.ts +1 -0
- package/dist/promql/index.d.ts +1 -0
- package/dist/promql/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/promql/completion/DataProvider.ts +2 -0
- package/src/promql/completion/completions.ts +10 -1
- package/src/promql/index.tsx +27 -16
- package/src/promql/types.ts +1 -0
|
@@ -866,7 +866,8 @@ var serviceUnavailable = 503;
|
|
|
866
866
|
var CODE_MODE_SUGGESTIONS_INCOMPLETE_EVENT = 'codeModeSuggestionsIncomplete';
|
|
867
867
|
var DataProvider = /*#__PURE__*/function () {
|
|
868
868
|
function DataProvider(params) {
|
|
869
|
-
var _this = this
|
|
869
|
+
var _this = this,
|
|
870
|
+
_params$durationVaria;
|
|
870
871
|
this.lookbackInterval = 60 * 60 * 1000 * 12; // 12 hours
|
|
871
872
|
this.variablesNames = [];
|
|
872
873
|
this.httpMethod = 'GET';
|
|
@@ -1012,6 +1013,7 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
1012
1013
|
if (params.variablesNames) {
|
|
1013
1014
|
this.variablesNames = [].concat(params.variablesNames);
|
|
1014
1015
|
}
|
|
1016
|
+
this.durationVariablesCompletion = (_params$durationVaria = params.durationVariablesCompletion) != null ? _params$durationVaria : true;
|
|
1015
1017
|
if (params.request) {
|
|
1016
1018
|
this.customRequest = params.request;
|
|
1017
1019
|
}
|
|
@@ -1536,7 +1538,14 @@ function _getAllFunctionsAndMetricNamesCompletions() {
|
|
|
1536
1538
|
}));
|
|
1537
1539
|
return _getAllFunctionsAndMetricNamesCompletions.apply(this, arguments);
|
|
1538
1540
|
}
|
|
1539
|
-
var DURATION_COMPLETIONS = /*#__PURE__*/['
|
|
1541
|
+
var DURATION_COMPLETIONS = /*#__PURE__*/['1m', '5m', '10m', '30m', '1h', '1d'].map(function (text) {
|
|
1542
|
+
return {
|
|
1543
|
+
type: 'DURATION',
|
|
1544
|
+
label: text,
|
|
1545
|
+
insertText: text
|
|
1546
|
+
};
|
|
1547
|
+
});
|
|
1548
|
+
var DURATION_VARIABLES_COMPLETIONS = /*#__PURE__*/['$__interval', '$__range', '$__rate_interval'].map(function (text) {
|
|
1540
1549
|
return {
|
|
1541
1550
|
type: 'DURATION',
|
|
1542
1551
|
label: text,
|
|
@@ -1764,6 +1773,9 @@ function _getLabelValuesForMetricCompletions() {
|
|
|
1764
1773
|
function getCompletions(situation, dataProvider) {
|
|
1765
1774
|
switch (situation.type) {
|
|
1766
1775
|
case 'IN_DURATION':
|
|
1776
|
+
if (dataProvider.durationVariablesCompletion) {
|
|
1777
|
+
return Promise.resolve(DURATION_VARIABLES_COMPLETIONS.concat(DURATION_COMPLETIONS));
|
|
1778
|
+
}
|
|
1767
1779
|
return Promise.resolve(DURATION_COMPLETIONS);
|
|
1768
1780
|
case 'IN_FUNCTION':
|
|
1769
1781
|
return getAllFunctionsAndMetricNamesCompletions(dataProvider);
|
|
@@ -1941,7 +1953,6 @@ function isErrorBoundary(boundary) {
|
|
|
1941
1953
|
|
|
1942
1954
|
var _excluded = ["error"];
|
|
1943
1955
|
var PROMQL_LANG_ID = promLanguageDefinition.id;
|
|
1944
|
-
var EDITOR_HEIGHT_OFFSET = 2;
|
|
1945
1956
|
var SIZE_MAP = {
|
|
1946
1957
|
small: {
|
|
1947
1958
|
className: 'ant-input-sm',
|
|
@@ -1960,8 +1971,8 @@ var SIZE_MAP = {
|
|
|
1960
1971
|
}
|
|
1961
1972
|
};
|
|
1962
1973
|
var themeMap = {
|
|
1963
|
-
light: '
|
|
1964
|
-
dark: '
|
|
1974
|
+
light: 'light',
|
|
1975
|
+
dark: 'n9e-dark'
|
|
1965
1976
|
};
|
|
1966
1977
|
var getStyles = function getStyles(placeholder) {
|
|
1967
1978
|
return {
|
|
@@ -2012,6 +2023,15 @@ function PromQLEditor(props) {
|
|
|
2012
2023
|
};
|
|
2013
2024
|
}, []);
|
|
2014
2025
|
var handleEditorDidMount = function handleEditorDidMount(editor$1) {
|
|
2026
|
+
editor.defineTheme('n9e-dark', {
|
|
2027
|
+
base: 'vs-dark',
|
|
2028
|
+
inherit: true,
|
|
2029
|
+
rules: [],
|
|
2030
|
+
colors: {
|
|
2031
|
+
'editor.background': '#00000000',
|
|
2032
|
+
focusBorder: '#00000000'
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2015
2035
|
var isEditorFocused = editor$1.createContextKey('isEditorFocused' + id, false);
|
|
2016
2036
|
// we setup on-blur
|
|
2017
2037
|
editor$1.onDidBlurEditorWidget(function () {
|
|
@@ -2021,18 +2041,19 @@ function PromQLEditor(props) {
|
|
|
2021
2041
|
editor$1.onDidFocusEditorText(function () {
|
|
2022
2042
|
isEditorFocused.set(true);
|
|
2023
2043
|
});
|
|
2024
|
-
var dataProvider = new DataProvider({
|
|
2025
|
-
url: props.url,
|
|
2026
|
-
lookbackInterval: props.lookbackInterval,
|
|
2027
|
-
variablesNames: props.variablesNames,
|
|
2028
|
-
request: props.request,
|
|
2029
|
-
httpMethod: props.httpMethod,
|
|
2030
|
-
apiPrefix: props.apiPrefix,
|
|
2031
|
-
httpErrorHandler: props.httpErrorHandler
|
|
2032
|
-
});
|
|
2033
|
-
dataProviderRef.current = dataProvider;
|
|
2034
|
-
dataProvider.start();
|
|
2035
2044
|
if (enableAutocomplete) {
|
|
2045
|
+
var dataProvider = new DataProvider({
|
|
2046
|
+
url: props.url,
|
|
2047
|
+
lookbackInterval: props.lookbackInterval,
|
|
2048
|
+
variablesNames: props.variablesNames,
|
|
2049
|
+
durationVariablesCompletion: props.durationVariablesCompletion,
|
|
2050
|
+
request: props.request,
|
|
2051
|
+
httpMethod: props.httpMethod,
|
|
2052
|
+
apiPrefix: props.apiPrefix,
|
|
2053
|
+
httpErrorHandler: props.httpErrorHandler
|
|
2054
|
+
});
|
|
2055
|
+
dataProviderRef.current = dataProvider;
|
|
2056
|
+
dataProvider.start();
|
|
2036
2057
|
var completionProvider = getCompletionProvider(monaco, dataProvider);
|
|
2037
2058
|
var filteringCompletionProvider = _extends({}, completionProvider, {
|
|
2038
2059
|
provideCompletionItems: function provideCompletionItems(model, position, context, token) {
|
|
@@ -2053,7 +2074,7 @@ function PromQLEditor(props) {
|
|
|
2053
2074
|
var containerDiv = containerRef.current;
|
|
2054
2075
|
if (containerDiv !== null) {
|
|
2055
2076
|
var pixelHeight = editor$1.getContentHeight();
|
|
2056
|
-
containerDiv.style.height = pixelHeight +
|
|
2077
|
+
containerDiv.style.height = pixelHeight + "px";
|
|
2057
2078
|
containerDiv.style.width = '100%';
|
|
2058
2079
|
var pixelWidth = containerDiv.clientWidth;
|
|
2059
2080
|
editor$1.layout({
|