@perses-dev/components 0.50.0-rc.1 → 0.50.1
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/dist/StatChart/StatChart.d.ts +4 -4
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +6 -10
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/utils/formatStatChartValue.d.ts +3 -0
- package/dist/StatChart/utils/formatStatChartValue.d.ts.map +1 -0
- package/dist/StatChart/utils/formatStatChartValue.js +26 -0
- package/dist/StatChart/utils/formatStatChartValue.js.map +1 -0
- package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +16 -3
- package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +1 -1
- package/dist/StatusHistoryChart/StatusHistoryChart.js +8 -24
- package/dist/StatusHistoryChart/StatusHistoryChart.js.map +1 -1
- package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +2 -1
- package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +1 -1
- package/dist/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
- package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +1 -1
- package/dist/StatusHistoryChart/utils/get-color.d.ts +1 -1
- package/dist/StatusHistoryChart/utils/get-color.d.ts.map +1 -1
- package/dist/StatusHistoryChart/utils/get-color.js +5 -5
- package/dist/StatusHistoryChart/utils/get-color.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +8 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +13 -2
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +10 -0
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -0
- package/dist/ValueMappingEditor/ValueMappingEditor.js +387 -0
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -0
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +8 -0
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -0
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +118 -0
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -0
- package/dist/ValueMappingEditor/index.d.ts +2 -0
- package/dist/ValueMappingEditor/index.d.ts.map +1 -0
- package/dist/ValueMappingEditor/index.js +15 -0
- package/dist/ValueMappingEditor/index.js.map +1 -0
- package/dist/cjs/StatChart/StatChart.js +8 -12
- package/dist/cjs/StatChart/utils/formatStatChartValue.js +34 -0
- package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +10 -26
- package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
- package/dist/cjs/StatusHistoryChart/utils/get-color.js +7 -7
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +22 -2
- package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +400 -0
- package/dist/cjs/ValueMappingEditor/ValueMappingsEditor.js +131 -0
- package/dist/cjs/ValueMappingEditor/index.js +30 -0
- package/dist/cjs/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -22,22 +22,22 @@ Object.defineProperty(exports, "StatChart", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _react = require("react");
|
|
25
|
-
const _core = require("@perses-dev/core");
|
|
26
25
|
const _material = require("@mui/material");
|
|
27
26
|
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
28
|
-
const
|
|
27
|
+
const _core = require("echarts/core");
|
|
29
28
|
const _charts = require("echarts/charts");
|
|
30
29
|
const _components = require("echarts/components");
|
|
31
30
|
const _renderers = require("echarts/renderers");
|
|
32
31
|
const _context = require("../context");
|
|
33
32
|
const _EChart = require("../EChart");
|
|
34
33
|
const _calculateFontSize = require("./calculateFontSize");
|
|
34
|
+
const _formatStatChartValue = require("./utils/formatStatChartValue");
|
|
35
35
|
function _interop_require_default(obj) {
|
|
36
36
|
return obj && obj.__esModule ? obj : {
|
|
37
37
|
default: obj
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
(0,
|
|
40
|
+
(0, _core.use)([
|
|
41
41
|
_charts.LineChart,
|
|
42
42
|
_components.GridComponent,
|
|
43
43
|
_components.DatasetComponent,
|
|
@@ -49,16 +49,12 @@ const LINE_HEIGHT = 1.2;
|
|
|
49
49
|
const SERIES_NAME_MAX_FONT_SIZE = 30;
|
|
50
50
|
const SERIES_NAME_FONT_WEIGHT = 400;
|
|
51
51
|
const VALUE_FONT_WEIGHT = 700;
|
|
52
|
-
|
|
52
|
+
const StatChart = (props)=>{
|
|
53
53
|
var _data_seriesData, _data_seriesData1;
|
|
54
|
-
const { width, height, data,
|
|
54
|
+
const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;
|
|
55
55
|
const chartsTheme = (0, _context.useChartsTheme)();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
formattedValue = 'null';
|
|
59
|
-
} else if (typeof data.calculatedValue === 'number') {
|
|
60
|
-
formattedValue = (0, _core.formatValue)(data.calculatedValue, format);
|
|
61
|
-
}
|
|
56
|
+
const color = data.color;
|
|
57
|
+
const formattedValue = (0, _formatStatChartValue.formatStatChartValue)(data.calculatedValue, format);
|
|
62
58
|
const containerPadding = chartsTheme.container.padding.default;
|
|
63
59
|
var _data_seriesData_name;
|
|
64
60
|
// calculate series name font size and height
|
|
@@ -182,7 +178,7 @@ function StatChart(props) {
|
|
|
182
178
|
})
|
|
183
179
|
]
|
|
184
180
|
});
|
|
185
|
-
}
|
|
181
|
+
};
|
|
186
182
|
const SeriesName = (0, _material.styled)(_material.Typography, {
|
|
187
183
|
shouldForwardProp: (prop)=>prop !== 'padding' && prop !== 'fontSize'
|
|
188
184
|
})(({ theme, padding, fontSize })=>({
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "formatStatChartValue", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return formatStatChartValue;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
24
|
+
const formatStatChartValue = (value, format)=>{
|
|
25
|
+
if (value === null) {
|
|
26
|
+
return 'null';
|
|
27
|
+
} else if (typeof value === 'number') {
|
|
28
|
+
return (0, _core.formatValue)(value, format);
|
|
29
|
+
} else if (value === undefined) {
|
|
30
|
+
return '';
|
|
31
|
+
} else {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -26,10 +26,9 @@ const _charts = require("echarts/charts");
|
|
|
26
26
|
const _components = require("echarts/components");
|
|
27
27
|
const _core = require("echarts/core");
|
|
28
28
|
const _renderers = require("echarts/renderers");
|
|
29
|
-
const
|
|
30
|
-
const
|
|
29
|
+
const _ChartsProvider = require("../context/ChartsProvider");
|
|
30
|
+
const _TimeZoneProvider = require("../context/TimeZoneProvider");
|
|
31
31
|
const _EChart = require("../EChart");
|
|
32
|
-
const _getcolor = require("./utils/get-color");
|
|
33
32
|
const _getformattedaxislabel = require("./get-formatted-axis-label");
|
|
34
33
|
const _StatusHistoryTooltip = require("./StatusHistoryTooltip");
|
|
35
34
|
(0, _core.use)([
|
|
@@ -41,34 +40,19 @@ const _StatusHistoryTooltip = require("./StatusHistoryTooltip");
|
|
|
41
40
|
_components.TooltipComponent,
|
|
42
41
|
_renderers.CanvasRenderer
|
|
43
42
|
]);
|
|
44
|
-
|
|
45
|
-
const { height, data, xAxisCategories, yAxisCategories, timeScale } = props;
|
|
46
|
-
const { timeZone } = (0,
|
|
47
|
-
const chartsTheme = (0,
|
|
43
|
+
const StatusHistoryChart = (props)=>{
|
|
44
|
+
const { height, data, xAxisCategories, yAxisCategories, timeScale, colors } = props;
|
|
45
|
+
const { timeZone } = (0, _TimeZoneProvider.useTimeZone)();
|
|
46
|
+
const chartsTheme = (0, _ChartsProvider.useChartsTheme)();
|
|
48
47
|
const theme = (0, _material.useTheme)();
|
|
49
|
-
const uniqueValues = (0, _react.useMemo)(()=>[
|
|
50
|
-
...new Set(data.map((item)=>item[2]))
|
|
51
|
-
].filter((value)=>value !== undefined), [
|
|
52
|
-
data
|
|
53
|
-
]);
|
|
54
|
-
// get colors from theme and generate colors if not provided
|
|
55
|
-
const pieces = (0, _react.useMemo)(()=>{
|
|
56
|
-
const themeColors = Array.isArray(chartsTheme.echartsTheme.color) ? chartsTheme.echartsTheme.color.filter((color)=>typeof color === 'string') : [];
|
|
57
|
-
return uniqueValues.map((value, index)=>({
|
|
58
|
-
value,
|
|
59
|
-
color: (0, _getcolor.getColorsForValues)(uniqueValues, themeColors)[index]
|
|
60
|
-
}));
|
|
61
|
-
}, [
|
|
62
|
-
uniqueValues,
|
|
63
|
-
chartsTheme.echartsTheme.color
|
|
64
|
-
]);
|
|
65
48
|
var _timeScale_rangeMs;
|
|
66
49
|
const option = {
|
|
67
50
|
tooltip: {
|
|
68
51
|
appendToBody: true,
|
|
69
52
|
formatter: (params)=>{
|
|
70
53
|
return (0, _StatusHistoryTooltip.generateTooltipHTML)({
|
|
71
|
-
data: params.data,
|
|
54
|
+
data: params.data.value,
|
|
55
|
+
label: params.data.label,
|
|
72
56
|
marker: params.marker,
|
|
73
57
|
xAxisCategories,
|
|
74
58
|
yAxisCategories,
|
|
@@ -114,7 +98,7 @@ function StatusHistoryChart(props) {
|
|
|
114
98
|
visualMap: {
|
|
115
99
|
show: false,
|
|
116
100
|
type: 'piecewise',
|
|
117
|
-
pieces
|
|
101
|
+
pieces: colors
|
|
118
102
|
},
|
|
119
103
|
series: [
|
|
120
104
|
{
|
|
@@ -154,4 +138,4 @@ function StatusHistoryChart(props) {
|
|
|
154
138
|
theme: chartsTheme.echartsTheme
|
|
155
139
|
})
|
|
156
140
|
});
|
|
157
|
-
}
|
|
141
|
+
};
|
|
@@ -22,8 +22,8 @@ Object.defineProperty(exports, "generateTooltipHTML", {
|
|
|
22
22
|
});
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _utils = require("../utils");
|
|
25
|
-
function generateTooltipHTML({ data, marker, xAxisCategories, yAxisCategories, theme }) {
|
|
26
|
-
const [x, y
|
|
25
|
+
function generateTooltipHTML({ data, label, marker, xAxisCategories, yAxisCategories, theme }) {
|
|
26
|
+
const [x, y] = data;
|
|
27
27
|
const xAxisLabel = xAxisCategories[x];
|
|
28
28
|
const { formattedDate, formattedTime } = (0, _utils.getDateAndTime)(xAxisLabel);
|
|
29
29
|
const tooltipHeader = (0, _material.css)`
|
|
@@ -47,7 +47,7 @@ function generateTooltipHTML({ data, marker, xAxisCategories, yAxisCategories, t
|
|
|
47
47
|
<strong>${yAxisCategories[y]}</strong>
|
|
48
48
|
</div>
|
|
49
49
|
<div>
|
|
50
|
-
${
|
|
50
|
+
${label}
|
|
51
51
|
</div>
|
|
52
52
|
</div>
|
|
53
53
|
</div>
|
|
@@ -21,8 +21,8 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
return
|
|
24
|
+
FALLBACK_COLOR: function() {
|
|
25
|
+
return FALLBACK_COLOR;
|
|
26
26
|
},
|
|
27
27
|
getColorForValue: function() {
|
|
28
28
|
return getColorForValue;
|
|
@@ -37,11 +37,11 @@ _export(exports, {
|
|
|
37
37
|
return hslToHex;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
const
|
|
40
|
+
const FALLBACK_COLOR = '#1f77b4';
|
|
41
41
|
function getColorForValue(value, baseColor) {
|
|
42
42
|
// Validate base color
|
|
43
43
|
if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
|
|
44
|
-
baseColor =
|
|
44
|
+
baseColor = FALLBACK_COLOR;
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
47
|
const [baseH, baseS, baseL] = hexToHSL(baseColor);
|
|
@@ -66,7 +66,7 @@ function getColorForValue(value, baseColor) {
|
|
|
66
66
|
}
|
|
67
67
|
return color;
|
|
68
68
|
} catch (_) {
|
|
69
|
-
return
|
|
69
|
+
return FALLBACK_COLOR;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
function getColorsForValues(uniqueValues, themeColors) {
|
|
@@ -77,9 +77,9 @@ function getColorsForValues(uniqueValues, themeColors) {
|
|
|
77
77
|
// Use theme colors first, then generate additional ones
|
|
78
78
|
return uniqueValues.map((value, index)=>{
|
|
79
79
|
if (index < themeColors.length) {
|
|
80
|
-
return themeColors[index] ||
|
|
80
|
+
return themeColors[index] || FALLBACK_COLOR;
|
|
81
81
|
}
|
|
82
|
-
return getColorForValue(value, themeColors[0] ||
|
|
82
|
+
return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
function hexToHSL(hex) {
|
|
@@ -66,9 +66,18 @@ _export(exports, {
|
|
|
66
66
|
UNPIN_TOOLTIP_HELP_TEXT: function() {
|
|
67
67
|
return UNPIN_TOOLTIP_HELP_TEXT;
|
|
68
68
|
},
|
|
69
|
+
browser: function() {
|
|
70
|
+
return browser;
|
|
71
|
+
},
|
|
69
72
|
defaultCursorData: function() {
|
|
70
73
|
return defaultCursorData;
|
|
71
74
|
},
|
|
75
|
+
pointerEventsSupported: function() {
|
|
76
|
+
return pointerEventsSupported;
|
|
77
|
+
},
|
|
78
|
+
trackingEventName: function() {
|
|
79
|
+
return trackingEventName;
|
|
80
|
+
},
|
|
72
81
|
useMousePosition: function() {
|
|
73
82
|
return useMousePosition;
|
|
74
83
|
}
|
|
@@ -108,6 +117,14 @@ const defaultCursorData = {
|
|
|
108
117
|
chartWidth: 0
|
|
109
118
|
};
|
|
110
119
|
const EMPTY_TOOLTIP_DATA = [];
|
|
120
|
+
const browser = {
|
|
121
|
+
// IE 11 Trident/7.0; rv:11.0
|
|
122
|
+
ie: navigator.userAgent.match(/MSIE\s([\d.]+)/) || navigator.userAgent.match(/Trident\/.+?rv:(([\d.]+))/),
|
|
123
|
+
// IE 12 and 12+
|
|
124
|
+
edge: navigator.userAgent.match(/Edge?\/([\d.]+)/)
|
|
125
|
+
};
|
|
126
|
+
const pointerEventsSupported = 'onpointerdown' in window && (browser.edge || browser.ie && browser.ie[1] && +browser.ie[1] >= 11);
|
|
127
|
+
const trackingEventName = pointerEventsSupported ? 'pointermove' : 'mousemove';
|
|
111
128
|
const useMousePosition = ()=>{
|
|
112
129
|
const [coords, setCoords] = (0, _react.useState)(null);
|
|
113
130
|
(0, _react.useEffect)(()=>{
|
|
@@ -132,9 +149,12 @@ const useMousePosition = ()=>{
|
|
|
132
149
|
target: e.target
|
|
133
150
|
});
|
|
134
151
|
};
|
|
135
|
-
|
|
152
|
+
// Devices that both enabled touch and mouse don't trigger touch events correctly
|
|
153
|
+
// which leads to missing zrender mousemove coordinates
|
|
154
|
+
// {@link https://github.com/ecomfe/zrender/blob/ae8cfaae186e6c1bf66b5dc431b2cdda5e67dacf/src/dom/HandlerProxy.ts#L423-L428 }
|
|
155
|
+
window.addEventListener(trackingEventName, setFromEvent);
|
|
136
156
|
return ()=>{
|
|
137
|
-
window.removeEventListener(
|
|
157
|
+
window.removeEventListener(trackingEventName, setFromEvent);
|
|
138
158
|
};
|
|
139
159
|
}, []);
|
|
140
160
|
return coords;
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "ValueMappingEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return ValueMappingEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
|
|
26
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
27
|
+
const _OptionsColorPicker = require("../ColorPicker/OptionsColorPicker");
|
|
28
|
+
function _interop_require_default(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const ConditionEditor = ({ mapping, onChange, ...props })=>{
|
|
34
|
+
switch(mapping.kind){
|
|
35
|
+
case 'Value':
|
|
36
|
+
var _mapping_spec;
|
|
37
|
+
var _mapping_spec_value;
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
39
|
+
gap: 1,
|
|
40
|
+
direction: "row",
|
|
41
|
+
...props,
|
|
42
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
43
|
+
label: "Value",
|
|
44
|
+
placeholder: "Exact value",
|
|
45
|
+
value: (_mapping_spec_value = (_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : _mapping_spec.value) !== null && _mapping_spec_value !== void 0 ? _mapping_spec_value : '',
|
|
46
|
+
onChange: (e)=>onChange({
|
|
47
|
+
...mapping,
|
|
48
|
+
spec: {
|
|
49
|
+
...mapping.spec,
|
|
50
|
+
value: e.target.value
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
fullWidth: true
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
case 'Range':
|
|
57
|
+
var _mapping_spec1, _mapping_spec2;
|
|
58
|
+
var _mapping_spec_from, _mapping_spec_to;
|
|
59
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
60
|
+
gap: 1,
|
|
61
|
+
direction: "row",
|
|
62
|
+
...props,
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
65
|
+
label: "From",
|
|
66
|
+
placeholder: "Start of range",
|
|
67
|
+
value: (_mapping_spec_from = (_mapping_spec1 = mapping.spec) === null || _mapping_spec1 === void 0 ? void 0 : _mapping_spec1.from) !== null && _mapping_spec_from !== void 0 ? _mapping_spec_from : '',
|
|
68
|
+
onChange: (e)=>onChange({
|
|
69
|
+
...mapping,
|
|
70
|
+
spec: {
|
|
71
|
+
...mapping.spec,
|
|
72
|
+
from: e.target.value === '' ? undefined : +e.target.value
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
fullWidth: true
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
78
|
+
label: "To",
|
|
79
|
+
placeholder: "End of range (inclusive)",
|
|
80
|
+
value: (_mapping_spec_to = (_mapping_spec2 = mapping.spec) === null || _mapping_spec2 === void 0 ? void 0 : _mapping_spec2.to) !== null && _mapping_spec_to !== void 0 ? _mapping_spec_to : '',
|
|
81
|
+
onChange: (e)=>onChange({
|
|
82
|
+
...mapping,
|
|
83
|
+
spec: {
|
|
84
|
+
...mapping.spec,
|
|
85
|
+
to: e.target.value === '' ? undefined : +e.target.value
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
fullWidth: true
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
case 'Regex':
|
|
93
|
+
var _mapping_spec3;
|
|
94
|
+
var _mapping_spec_pattern;
|
|
95
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
96
|
+
gap: 1,
|
|
97
|
+
direction: "row",
|
|
98
|
+
...props,
|
|
99
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
100
|
+
label: "Regular Expression",
|
|
101
|
+
placeholder: "JavaScript regular expression",
|
|
102
|
+
value: (_mapping_spec_pattern = (_mapping_spec3 = mapping.spec) === null || _mapping_spec3 === void 0 ? void 0 : _mapping_spec3.pattern) !== null && _mapping_spec_pattern !== void 0 ? _mapping_spec_pattern : '',
|
|
103
|
+
onChange: (e)=>onChange({
|
|
104
|
+
...mapping,
|
|
105
|
+
spec: {
|
|
106
|
+
...mapping.spec,
|
|
107
|
+
pattern: e.target.value
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
fullWidth: true
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
case 'Misc':
|
|
114
|
+
var _mapping_spec4;
|
|
115
|
+
var _mapping_spec_value1;
|
|
116
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
117
|
+
gap: 1,
|
|
118
|
+
direction: "row",
|
|
119
|
+
...props,
|
|
120
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
121
|
+
select: true,
|
|
122
|
+
label: "Value",
|
|
123
|
+
value: (_mapping_spec_value1 = (_mapping_spec4 = mapping.spec) === null || _mapping_spec4 === void 0 ? void 0 : _mapping_spec4.value) !== null && _mapping_spec_value1 !== void 0 ? _mapping_spec_value1 : '',
|
|
124
|
+
onChange: (e)=>onChange({
|
|
125
|
+
...mapping,
|
|
126
|
+
spec: {
|
|
127
|
+
value: e.target.value
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
SelectProps: {
|
|
131
|
+
renderValue: (selected)=>{
|
|
132
|
+
switch(selected){
|
|
133
|
+
case 'empty':
|
|
134
|
+
return 'Empty';
|
|
135
|
+
case 'null':
|
|
136
|
+
return 'Null';
|
|
137
|
+
case 'NaN':
|
|
138
|
+
return 'NaN';
|
|
139
|
+
case 'true':
|
|
140
|
+
return 'True';
|
|
141
|
+
case 'false':
|
|
142
|
+
return 'False';
|
|
143
|
+
default:
|
|
144
|
+
return String(selected);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
fullWidth: true,
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
151
|
+
value: "empty",
|
|
152
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
155
|
+
children: "Empty"
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
158
|
+
variant: "caption",
|
|
159
|
+
children: "Matches empty string"
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
165
|
+
value: "null",
|
|
166
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
169
|
+
children: "Null"
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
172
|
+
variant: "caption",
|
|
173
|
+
children: "Matches null or undefined"
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
179
|
+
value: "NaN",
|
|
180
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
183
|
+
children: "NaN"
|
|
184
|
+
}),
|
|
185
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
186
|
+
variant: "caption",
|
|
187
|
+
children: "Matches Not a Number value"
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
}),
|
|
192
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
193
|
+
value: "true",
|
|
194
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
195
|
+
children: [
|
|
196
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
197
|
+
children: "True"
|
|
198
|
+
}),
|
|
199
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
200
|
+
variant: "caption",
|
|
201
|
+
children: "Matches true boolean"
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
207
|
+
value: "false",
|
|
208
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
209
|
+
children: [
|
|
210
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
211
|
+
children: "False"
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
214
|
+
variant: "caption",
|
|
215
|
+
children: "Matches false boolean"
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
default:
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const ValueMappingEditor = ({ mapping, onChange, onDelete, ...props })=>{
|
|
228
|
+
var _mapping_spec_result, _mapping_spec, _mapping_spec_result1, _mapping_spec1;
|
|
229
|
+
const handleColorChange = (color)=>{
|
|
230
|
+
onChange({
|
|
231
|
+
...mapping,
|
|
232
|
+
spec: {
|
|
233
|
+
...mapping.spec,
|
|
234
|
+
result: {
|
|
235
|
+
...mapping.spec.result,
|
|
236
|
+
color
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
var _mapping_spec_result_value, _mapping_spec_result_color;
|
|
242
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid2, {
|
|
243
|
+
container: true,
|
|
244
|
+
spacing: 2,
|
|
245
|
+
...props,
|
|
246
|
+
children: [
|
|
247
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
|
|
248
|
+
size: {
|
|
249
|
+
xs: 5
|
|
250
|
+
},
|
|
251
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
252
|
+
direction: "row",
|
|
253
|
+
gap: 1,
|
|
254
|
+
width: "100%",
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
257
|
+
select: true,
|
|
258
|
+
label: "Type",
|
|
259
|
+
value: mapping.kind,
|
|
260
|
+
onChange: (e)=>onChange({
|
|
261
|
+
...mapping,
|
|
262
|
+
kind: e.target.value
|
|
263
|
+
}),
|
|
264
|
+
required: true,
|
|
265
|
+
sx: {
|
|
266
|
+
width: '120px'
|
|
267
|
+
},
|
|
268
|
+
children: [
|
|
269
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
270
|
+
value: "Value",
|
|
271
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
272
|
+
children: [
|
|
273
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
274
|
+
children: "Value"
|
|
275
|
+
}),
|
|
276
|
+
mapping.kind !== 'Value' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
277
|
+
variant: "caption",
|
|
278
|
+
children: "Matches an exact text value"
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
})
|
|
282
|
+
}),
|
|
283
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
284
|
+
value: "Range",
|
|
285
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
286
|
+
children: [
|
|
287
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
288
|
+
children: "Range"
|
|
289
|
+
}),
|
|
290
|
+
mapping.kind !== 'Range' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
291
|
+
variant: "caption",
|
|
292
|
+
children: "Matches against a numerical range"
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
})
|
|
296
|
+
}),
|
|
297
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
298
|
+
value: "Regex",
|
|
299
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
300
|
+
children: [
|
|
301
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
302
|
+
children: "Regex"
|
|
303
|
+
}),
|
|
304
|
+
mapping.kind !== 'Regex' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
305
|
+
variant: "caption",
|
|
306
|
+
children: "Matches against a regular expression"
|
|
307
|
+
})
|
|
308
|
+
]
|
|
309
|
+
})
|
|
310
|
+
}),
|
|
311
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
312
|
+
value: "Misc",
|
|
313
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
314
|
+
children: [
|
|
315
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
316
|
+
children: "Misc"
|
|
317
|
+
}),
|
|
318
|
+
mapping.kind !== 'Misc' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
319
|
+
variant: "caption",
|
|
320
|
+
children: "Matches against empty, null and NaN values"
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
]
|
|
326
|
+
}),
|
|
327
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(ConditionEditor, {
|
|
328
|
+
width: "100%",
|
|
329
|
+
mapping: mapping,
|
|
330
|
+
onChange: (updatedMapping)=>onChange({
|
|
331
|
+
...mapping,
|
|
332
|
+
...updatedMapping
|
|
333
|
+
})
|
|
334
|
+
})
|
|
335
|
+
]
|
|
336
|
+
})
|
|
337
|
+
}),
|
|
338
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
|
|
339
|
+
size: {
|
|
340
|
+
xs: 4
|
|
341
|
+
},
|
|
342
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
343
|
+
label: "Display text",
|
|
344
|
+
value: (_mapping_spec_result_value = (_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : (_mapping_spec_result = _mapping_spec.result) === null || _mapping_spec_result === void 0 ? void 0 : _mapping_spec_result.value) !== null && _mapping_spec_result_value !== void 0 ? _mapping_spec_result_value : '',
|
|
345
|
+
onChange: (e)=>{
|
|
346
|
+
var _mapping_spec;
|
|
347
|
+
return onChange({
|
|
348
|
+
...mapping,
|
|
349
|
+
spec: {
|
|
350
|
+
...mapping.spec,
|
|
351
|
+
result: {
|
|
352
|
+
...(_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : _mapping_spec.result,
|
|
353
|
+
value: e.target.value
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
fullWidth: true
|
|
359
|
+
})
|
|
360
|
+
}),
|
|
361
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
|
|
362
|
+
size: {
|
|
363
|
+
xs: 1
|
|
364
|
+
},
|
|
365
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
366
|
+
direction: "row",
|
|
367
|
+
justifyContent: "center",
|
|
368
|
+
gap: 1,
|
|
369
|
+
children: ((_mapping_spec1 = mapping.spec) === null || _mapping_spec1 === void 0 ? void 0 : (_mapping_spec_result1 = _mapping_spec1.result) === null || _mapping_spec_result1 === void 0 ? void 0 : _mapping_spec_result1.color) ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsColorPicker.OptionsColorPicker, {
|
|
370
|
+
label: "Color",
|
|
371
|
+
color: (_mapping_spec_result_color = mapping.spec.result.color) !== null && _mapping_spec_result_color !== void 0 ? _mapping_spec_result_color : '#000',
|
|
372
|
+
onColorChange: handleColorChange,
|
|
373
|
+
onClear: ()=>handleColorChange(undefined)
|
|
374
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
375
|
+
onClick: ()=>handleColorChange('#000'),
|
|
376
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
377
|
+
})
|
|
378
|
+
})
|
|
379
|
+
}),
|
|
380
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
|
|
381
|
+
size: {
|
|
382
|
+
xs: 1
|
|
383
|
+
},
|
|
384
|
+
textAlign: "end",
|
|
385
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
|
|
386
|
+
title: "Remove mapping settings",
|
|
387
|
+
placement: "top",
|
|
388
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
389
|
+
size: "small",
|
|
390
|
+
sx: {
|
|
391
|
+
marginLeft: 'auto'
|
|
392
|
+
},
|
|
393
|
+
onClick: onDelete,
|
|
394
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
|
|
395
|
+
})
|
|
396
|
+
})
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
});
|
|
400
|
+
};
|