@perses-dev/components 0.23.1 → 0.24.0
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/ColorPicker/ColorPicker.d.ts +12 -0
- package/dist/ColorPicker/ColorPicker.d.ts.map +1 -0
- package/dist/ColorPicker/ColorPicker.js +78 -0
- package/dist/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/ColorPicker/index.d.ts +2 -0
- package/dist/ColorPicker/index.d.ts.map +1 -0
- package/dist/ColorPicker/index.js +15 -0
- package/dist/ColorPicker/index.js.map +1 -0
- package/dist/EChart.d.ts +2 -2
- package/dist/EChart.d.ts.map +1 -1
- package/dist/EChart.js.map +1 -1
- package/dist/Legend/Legend.js +6 -9
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +4 -2
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +1 -1
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +3 -2
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +17 -5
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts +0 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +1 -3
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts +4 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.js +76 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -0
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +13 -0
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdInput.js +61 -0
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +10 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.js +215 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -0
- package/dist/ThresholdsEditor/index.d.ts +2 -0
- package/dist/ThresholdsEditor/index.d.ts.map +1 -0
- package/dist/ThresholdsEditor/index.js +15 -0
- package/dist/ThresholdsEditor/index.js.map +1 -0
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/focused-series.js +3 -3
- package/dist/TimeSeriesTooltip/focused-series.js.map +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.js +128 -0
- package/dist/cjs/{model/legend.test.js → ColorPicker/index.js} +11 -12
- package/dist/cjs/Legend/Legend.js +5 -8
- package/dist/cjs/LineChart/LineChart.js +40 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +22 -5
- package/dist/cjs/StatChart/StatChart.js +1 -41
- package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +87 -0
- package/dist/cjs/ThresholdsEditor/ThresholdInput.js +72 -0
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +265 -0
- package/dist/{model/legend.test.js → cjs/ThresholdsEditor/index.js} +15 -14
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +3 -3
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/test-utils/theme.js +8 -0
- package/dist/cjs/theme/theme.js +5 -0
- package/dist/cjs/utils/theme-gen.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +2 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/legend.d.ts +1 -1
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/theme.d.ts +5 -0
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/units/bytes.d.ts +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.d.ts +1 -1
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +1 -1
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.d.ts +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -1
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/test-utils/theme.d.ts.map +1 -1
- package/dist/test-utils/theme.js +8 -0
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/theme/theme.js +5 -0
- package/dist/theme/theme.js.map +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +8 -0
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +5 -3
- package/dist/InfoTooltip/InfoTooltip.test.d.ts +0 -2
- package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +0 -1
- package/dist/InfoTooltip/InfoTooltip.test.js +0 -36
- package/dist/InfoTooltip/InfoTooltip.test.js.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts +0 -2
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -62
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +0 -1
- package/dist/StatChart/StatChart.test.d.ts +0 -2
- package/dist/StatChart/StatChart.test.d.ts.map +0 -1
- package/dist/StatChart/StatChart.test.js +0 -94
- package/dist/StatChart/StatChart.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.test.js +0 -52
- package/dist/TimeSeriesTooltip/SeriesInfo.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/TooltipContent.test.js +0 -78
- package/dist/TimeSeriesTooltip/TooltipContent.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/focused-series.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.test.js +0 -93
- package/dist/TimeSeriesTooltip/focused-series.test.js.map +0 -1
- package/dist/UnitSelector/UnitSelector.test.d.ts +0 -2
- package/dist/UnitSelector/UnitSelector.test.d.ts.map +0 -1
- package/dist/UnitSelector/UnitSelector.test.js +0 -204
- package/dist/UnitSelector/UnitSelector.test.js.map +0 -1
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +0 -43
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -69
- package/dist/cjs/StatChart/StatChart.test.js +0 -96
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.test.js +0 -54
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.test.js +0 -80
- package/dist/cjs/TimeSeriesTooltip/focused-series.test.js +0 -95
- package/dist/cjs/UnitSelector/UnitSelector.test.js +0 -211
- package/dist/cjs/model/units/units.test.js +0 -206
- package/dist/cjs/utils/format.test.js +0 -47
- package/dist/cjs/utils/theme-gen.test.js +0 -202
- package/dist/model/legend.test.d.ts +0 -2
- package/dist/model/legend.test.d.ts.map +0 -1
- package/dist/model/legend.test.js.map +0 -1
- package/dist/model/units/units.test.d.ts +0 -2
- package/dist/model/units/units.test.d.ts.map +0 -1
- package/dist/model/units/units.test.js +0 -204
- package/dist/model/units/units.test.js.map +0 -1
- package/dist/utils/format.test.d.ts +0 -2
- package/dist/utils/format.test.d.ts.map +0 -1
- package/dist/utils/format.test.js +0 -45
- package/dist/utils/format.test.js.map +0 -1
- package/dist/utils/theme-gen.test.d.ts +0 -2
- package/dist/utils/theme-gen.test.d.ts.map +0 -1
- package/dist/utils/theme-gen.test.js +0 -200
- package/dist/utils/theme-gen.test.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Copyright 2023 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, "ColorPicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>ColorPicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
24
|
+
const _reactColorful = require("react-colorful");
|
|
25
|
+
const _circle = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Circle"));
|
|
26
|
+
function _interopRequireDefault(obj) {
|
|
27
|
+
return obj && obj.__esModule ? obj : {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
32
|
+
if (typeof WeakMap !== "function") return null;
|
|
33
|
+
var cacheBabelInterop = new WeakMap();
|
|
34
|
+
var cacheNodeInterop = new WeakMap();
|
|
35
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
36
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
37
|
+
})(nodeInterop);
|
|
38
|
+
}
|
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
40
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
44
|
+
return {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
49
|
+
if (cache && cache.has(obj)) {
|
|
50
|
+
return cache.get(obj);
|
|
51
|
+
}
|
|
52
|
+
var newObj = {};
|
|
53
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
+
for(var key in obj){
|
|
55
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
+
if (desc && (desc.get || desc.set)) {
|
|
58
|
+
Object.defineProperty(newObj, key, desc);
|
|
59
|
+
} else {
|
|
60
|
+
newObj[key] = obj[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
newObj.default = obj;
|
|
65
|
+
if (cache) {
|
|
66
|
+
cache.set(obj, newObj);
|
|
67
|
+
}
|
|
68
|
+
return newObj;
|
|
69
|
+
}
|
|
70
|
+
const ColorPicker = ({ color , onChange , palette })=>{
|
|
71
|
+
// value is the visible value for the controlled text input
|
|
72
|
+
const [value, setValue] = (0, _react.useState)(color);
|
|
73
|
+
const handleColorChange = (color)=>{
|
|
74
|
+
setValue(color);
|
|
75
|
+
onChange && onChange(color);
|
|
76
|
+
};
|
|
77
|
+
// we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved
|
|
78
|
+
const handleInputChange = (e)=>{
|
|
79
|
+
const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);
|
|
80
|
+
setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format
|
|
81
|
+
// only set color if input value is a valid hex color
|
|
82
|
+
if (isValidHex(e.target.value)) {
|
|
83
|
+
onChange && onChange(e.target.value);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
87
|
+
spacing: 1,
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactColorful.HexColorPicker, {
|
|
90
|
+
color: color,
|
|
91
|
+
onChange: handleColorChange
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
94
|
+
direction: "row",
|
|
95
|
+
flexWrap: "wrap",
|
|
96
|
+
justifyContent: "space-evenly",
|
|
97
|
+
width: '200px',
|
|
98
|
+
children: palette && palette.map((color, i)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
99
|
+
size: "small",
|
|
100
|
+
"aria-label": `change color to ${color}`,
|
|
101
|
+
sx: {
|
|
102
|
+
color
|
|
103
|
+
},
|
|
104
|
+
onClick: ()=>handleColorChange(color),
|
|
105
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_circle.default, {})
|
|
106
|
+
}, i))
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
109
|
+
inputProps: {
|
|
110
|
+
'aria-label': 'enter hex color'
|
|
111
|
+
},
|
|
112
|
+
fullWidth: true,
|
|
113
|
+
value: value,
|
|
114
|
+
onChange: handleInputChange
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const isValidHex = (value, alpha)=>{
|
|
120
|
+
const matcher = /^#?([0-9A-F]{3,8})$/i;
|
|
121
|
+
const match = matcher.exec(value);
|
|
122
|
+
const length = match && match[1] ? match[1].length : 0;
|
|
123
|
+
return length === 3 || // '#rgb' format
|
|
124
|
+
length === 6 || // '#rrggbb' format
|
|
125
|
+
!!alpha && length === 4 || // '#rgba' format
|
|
126
|
+
!!alpha && length === 8 // '#rrggbbaa' format
|
|
127
|
+
;
|
|
128
|
+
};
|
|
@@ -14,16 +14,15 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})).toEqual(true);
|
|
27
|
-
expect((0, _legend.validateLegendSpec)(undefined)).toEqual(true);
|
|
17
|
+
_exportStar(require("./ColorPicker"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
28
26
|
});
|
|
29
|
-
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -39,19 +39,16 @@ function Legend({ width , height , options , data }) {
|
|
|
39
39
|
})
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
return /*#__PURE__*/ (0, _jsxRuntime.
|
|
42
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
43
43
|
sx: {
|
|
44
44
|
width: width,
|
|
45
45
|
height: height,
|
|
46
46
|
position: 'absolute',
|
|
47
47
|
bottom: 0
|
|
48
48
|
},
|
|
49
|
-
children:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
";"
|
|
55
|
-
]
|
|
49
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
50
|
+
items: data,
|
|
51
|
+
height: height
|
|
52
|
+
})
|
|
56
53
|
});
|
|
57
54
|
}
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "LineChart", {
|
|
|
19
19
|
get: ()=>LineChart
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = require("react");
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _core = require("echarts/core");
|
|
25
25
|
const _charts = require("echarts/charts");
|
|
@@ -31,6 +31,45 @@ const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
|
31
31
|
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
32
32
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
33
33
|
const _utils = require("./utils");
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
35
|
+
if (typeof WeakMap !== "function") return null;
|
|
36
|
+
var cacheBabelInterop = new WeakMap();
|
|
37
|
+
var cacheNodeInterop = new WeakMap();
|
|
38
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
39
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
40
|
+
})(nodeInterop);
|
|
41
|
+
}
|
|
42
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
43
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
47
|
+
return {
|
|
48
|
+
default: obj
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
52
|
+
if (cache && cache.has(obj)) {
|
|
53
|
+
return cache.get(obj);
|
|
54
|
+
}
|
|
55
|
+
var newObj = {};
|
|
56
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
57
|
+
for(var key in obj){
|
|
58
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
59
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
60
|
+
if (desc && (desc.get || desc.set)) {
|
|
61
|
+
Object.defineProperty(newObj, key, desc);
|
|
62
|
+
} else {
|
|
63
|
+
newObj[key] = obj[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
newObj.default = obj;
|
|
68
|
+
if (cache) {
|
|
69
|
+
cache.set(obj, newObj);
|
|
70
|
+
}
|
|
71
|
+
return newObj;
|
|
72
|
+
}
|
|
34
73
|
(0, _core.use)([
|
|
35
74
|
_charts.LineChart,
|
|
36
75
|
_components.GridComponent,
|
|
@@ -20,16 +20,33 @@ Object.defineProperty(exports, "OptionsEditorGroup", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
-
const
|
|
23
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
24
|
+
function _interopRequireDefault(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const OptionsEditorGroup = ({ title , children , icon })=>{
|
|
24
30
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
25
31
|
children: [
|
|
26
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
27
|
-
|
|
28
|
-
component: "h4",
|
|
32
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
33
|
+
display: "flex",
|
|
29
34
|
borderBottom: 1,
|
|
30
35
|
borderColor: "grey.300",
|
|
31
36
|
marginBottom: (theme)=>theme.spacing(1),
|
|
32
|
-
children:
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
39
|
+
variant: "overline",
|
|
40
|
+
component: "h4",
|
|
41
|
+
children: title
|
|
42
|
+
}),
|
|
43
|
+
icon && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
44
|
+
sx: {
|
|
45
|
+
marginLeft: 'auto'
|
|
46
|
+
},
|
|
47
|
+
children: icon
|
|
48
|
+
})
|
|
49
|
+
]
|
|
33
50
|
}),
|
|
34
51
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
35
52
|
spacing: 1,
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "StatChart", {
|
|
|
19
19
|
get: ()=>StatChart
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react =
|
|
22
|
+
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _lodashEs = require("lodash-es");
|
|
25
25
|
const _core = require("echarts/core");
|
|
@@ -29,47 +29,7 @@ const _renderers = require("echarts/renderers");
|
|
|
29
29
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
30
30
|
const _units = require("../model/units");
|
|
31
31
|
const _echart = require("../EChart");
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
33
|
-
if (typeof WeakMap !== "function") return null;
|
|
34
|
-
var cacheBabelInterop = new WeakMap();
|
|
35
|
-
var cacheNodeInterop = new WeakMap();
|
|
36
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
37
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
38
|
-
})(nodeInterop);
|
|
39
|
-
}
|
|
40
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
41
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
44
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
45
|
-
return {
|
|
46
|
-
default: obj
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
50
|
-
if (cache && cache.has(obj)) {
|
|
51
|
-
return cache.get(obj);
|
|
52
|
-
}
|
|
53
|
-
var newObj = {};
|
|
54
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
|
-
for(var key in obj){
|
|
56
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
57
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
58
|
-
if (desc && (desc.get || desc.set)) {
|
|
59
|
-
Object.defineProperty(newObj, key, desc);
|
|
60
|
-
} else {
|
|
61
|
-
newObj[key] = obj[key];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
newObj.default = obj;
|
|
66
|
-
if (cache) {
|
|
67
|
-
cache.set(obj, newObj);
|
|
68
|
-
}
|
|
69
|
-
return newObj;
|
|
70
|
-
}
|
|
71
32
|
(0, _core.use)([
|
|
72
|
-
_charts.GaugeChart,
|
|
73
33
|
_charts.LineChart,
|
|
74
34
|
_components.GridComponent,
|
|
75
35
|
_components.DatasetComponent,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright 2023 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, "ThresholdColorPicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>ThresholdColorPicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _circle = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Circle"));
|
|
25
|
+
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
26
|
+
const _colorPicker = require("../ColorPicker");
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function ThresholdColorPicker({ color , onColorChange , label }) {
|
|
33
|
+
const [anchorEl, setAnchorEl] = _react.default.useState(null);
|
|
34
|
+
const isOpen = Boolean(anchorEl);
|
|
35
|
+
const openColorPicker = (event)=>{
|
|
36
|
+
setAnchorEl(event.currentTarget);
|
|
37
|
+
};
|
|
38
|
+
const closeColorPicker = ()=>{
|
|
39
|
+
setAnchorEl(null);
|
|
40
|
+
};
|
|
41
|
+
const { thresholds: { defaultColor , palette } , } = (0, _chartsThemeProvider.useChartsTheme)();
|
|
42
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(ColorIconButton, {
|
|
45
|
+
size: "small",
|
|
46
|
+
"aria-label": `change threshold ${label} color`,
|
|
47
|
+
isSelected: isOpen,
|
|
48
|
+
iconColor: color,
|
|
49
|
+
onClick: openColorPicker,
|
|
50
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_circle.default, {})
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
|
|
53
|
+
"data-testid": "threshold color picker",
|
|
54
|
+
open: isOpen,
|
|
55
|
+
anchorEl: anchorEl,
|
|
56
|
+
onClose: closeColorPicker,
|
|
57
|
+
PaperProps: {
|
|
58
|
+
sx: {
|
|
59
|
+
padding: (theme)=>theme.spacing(2)
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
anchorOrigin: {
|
|
63
|
+
vertical: 'top',
|
|
64
|
+
horizontal: 'left'
|
|
65
|
+
},
|
|
66
|
+
transformOrigin: {
|
|
67
|
+
vertical: 'top',
|
|
68
|
+
horizontal: 'right'
|
|
69
|
+
},
|
|
70
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_colorPicker.ColorPicker, {
|
|
71
|
+
color: color,
|
|
72
|
+
onChange: onColorChange,
|
|
73
|
+
palette: [
|
|
74
|
+
defaultColor,
|
|
75
|
+
...palette
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const ColorIconButton = (0, _material.styled)(_material.IconButton, {
|
|
83
|
+
shouldForwardProp: (props)=>props !== 'isSelected' && props !== 'iconColor'
|
|
84
|
+
})(({ iconColor , isSelected })=>({
|
|
85
|
+
backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined',
|
|
86
|
+
color: iconColor
|
|
87
|
+
}));
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright 2023 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, "ThresholdInput", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>ThresholdInput
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
|
|
25
|
+
const _thresholdColorPicker = require("./ThresholdColorPicker");
|
|
26
|
+
function _interopRequireDefault(obj) {
|
|
27
|
+
return obj && obj.__esModule ? obj : {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function ThresholdInput({ inputRef , label , color , value , onChange , onColorChange , onBlur , onDelete }) {
|
|
32
|
+
const [key, setKey] = (0, _react.useState)(0); // use key to cause input to lose focus when pressing enter
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
34
|
+
flex: 1,
|
|
35
|
+
direction: "row",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
justifyContent: "space-between",
|
|
38
|
+
spacing: 1,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_thresholdColorPicker.ThresholdColorPicker, {
|
|
41
|
+
label: label,
|
|
42
|
+
color: color,
|
|
43
|
+
onColorChange: onColorChange
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
46
|
+
htmlFor: label,
|
|
47
|
+
children: label
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
50
|
+
id: label,
|
|
51
|
+
inputRef: inputRef,
|
|
52
|
+
type: "number",
|
|
53
|
+
value: value === 0 ? undefined : value,
|
|
54
|
+
placeholder: "0",
|
|
55
|
+
onChange: onChange,
|
|
56
|
+
onBlur: onBlur,
|
|
57
|
+
onKeyDown: (e)=>{
|
|
58
|
+
if (e.key === 'Enter') {
|
|
59
|
+
onBlur();
|
|
60
|
+
setKey(key + 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, key),
|
|
64
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
65
|
+
"aria-label": `delete threshold ${label}`,
|
|
66
|
+
size: "small",
|
|
67
|
+
onClick: onDelete,
|
|
68
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|