@perses-dev/components 0.29.1 → 0.31.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/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +1 -7
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -4
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +4 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -9
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +45 -11
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +5 -8
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +34 -99
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +8 -8
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +9 -12
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +35 -22
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +5 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +9 -0
- package/dist/Table/InnerTable.d.ts.map +1 -0
- package/dist/Table/InnerTable.js +38 -0
- package/dist/Table/InnerTable.js.map +1 -0
- package/dist/Table/Table.d.ts +10 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/Table.js +101 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/TableBody.d.ts +6 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableBody.js +23 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableCell.d.ts +18 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableCell.js +91 -0
- package/dist/Table/TableCell.js.map +1 -0
- package/dist/Table/TableCheckbox.d.ts +9 -0
- package/dist/Table/TableCheckbox.d.ts.map +1 -0
- package/dist/Table/TableCheckbox.js +49 -0
- package/dist/Table/TableCheckbox.js.map +1 -0
- package/dist/Table/TableHead.d.ts +6 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHead.js +23 -0
- package/dist/Table/TableHead.js.map +1 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableRow.js +29 -0
- package/dist/Table/TableRow.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +11 -0
- package/dist/Table/VirtualizedTable.d.ts.map +1 -0
- package/dist/Table/VirtualizedTable.js +152 -0
- package/dist/Table/VirtualizedTable.js.map +1 -0
- package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
- package/dist/Table/VirtualizedTableContainer.js +24 -0
- package/dist/Table/VirtualizedTableContainer.js.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -0
- package/dist/Table/index.js +16 -0
- package/dist/Table/index.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +83 -0
- package/dist/Table/model/table-model.d.ts.map +1 -0
- package/dist/Table/model/table-model.js +73 -0
- package/dist/Table/model/table-model.js.map +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +3 -2
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +63 -17
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +81 -44
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +1 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +12 -4
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +10 -2
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +7 -15
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +40 -17
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/cjs/EChart/EChart.js +1 -7
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +45 -11
- package/dist/cjs/Legend/ListLegend.js +33 -98
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/LineChart/LineChart.js +35 -22
- package/dist/cjs/StatChart/StatChart.js +5 -1
- package/dist/cjs/Table/InnerTable.js +44 -0
- package/dist/cjs/Table/Table.js +102 -0
- package/dist/cjs/Table/TableBody.js +29 -0
- package/dist/cjs/Table/TableCell.js +97 -0
- package/dist/cjs/Table/TableCheckbox.js +55 -0
- package/dist/cjs/Table/TableHead.js +29 -0
- package/dist/cjs/Table/TableRow.js +35 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -0
- package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
- package/dist/cjs/Table/index.js +33 -0
- package/dist/cjs/Table/model/table-model.js +80 -0
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +67 -16
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +85 -43
- package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +15 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +6 -14
- package/dist/cjs/UnitSelector/UnitSelector.js +39 -16
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/model/legend.js +7 -1
- package/dist/cjs/model/units/bytes.js +25 -21
- package/dist/cjs/model/units/constants.js +3 -3
- package/dist/cjs/model/units/decimal.js +22 -19
- package/dist/cjs/model/units/percent.js +15 -22
- package/dist/cjs/model/units/time.js +24 -20
- package/dist/cjs/model/units/units.js +2 -2
- package/dist/cjs/model/units/utils.js +42 -0
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/context/SnackbarProvider.d.ts +23 -0
- package/dist/context/SnackbarProvider.d.ts.map +1 -0
- package/dist/context/SnackbarProvider.js +59 -0
- package/dist/context/SnackbarProvider.js.map +1 -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/legend.d.ts +10 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +5 -0
- package/dist/model/legend.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 +26 -22
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/constants.d.ts +1 -1
- package/dist/model/units/constants.js +1 -1
- package/dist/model/units/constants.js.map +1 -1
- package/dist/model/units/decimal.d.ts +2 -2
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +22 -19
- 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 +14 -21
- 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 +24 -20
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/units.js +2 -2
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts +4 -0
- package/dist/model/units/utils.d.ts.map +1 -0
- package/dist/model/units/utils.js +32 -0
- package/dist/model/units/utils.js.map +1 -0
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js +6 -2
- package/dist/theme/palette/grey.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -111
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -117
|
@@ -0,0 +1,155 @@
|
|
|
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, "VirtualizedTable", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>VirtualizedTable
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _reactTable = require("@tanstack/react-table");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _reactVirtuoso = require("react-virtuoso");
|
|
25
|
+
const _react = require("react");
|
|
26
|
+
const _tableRow = require("./TableRow");
|
|
27
|
+
const _tableBody = require("./TableBody");
|
|
28
|
+
const _innerTable = require("./InnerTable");
|
|
29
|
+
const _tableHead = require("./TableHead");
|
|
30
|
+
const _tableCell = require("./TableCell");
|
|
31
|
+
const _virtualizedTableContainer = require("./VirtualizedTableContainer");
|
|
32
|
+
const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
|
|
33
|
+
function VirtualizedTable({ width , height , density , onRowClick , rows , columns , headers }) {
|
|
34
|
+
const virtuosoRef = (0, _react.useRef)(null);
|
|
35
|
+
// Use a ref for these values because they are only needed for keyboard
|
|
36
|
+
// focus interactions and setting them on state will lead to a significant
|
|
37
|
+
// amount of unnecessary re-renders.
|
|
38
|
+
const visibleRange = (0, _react.useRef)({
|
|
39
|
+
startIndex: 0,
|
|
40
|
+
endIndex: 0
|
|
41
|
+
});
|
|
42
|
+
const setVisibleRange = (newVisibleRange)=>{
|
|
43
|
+
visibleRange.current = newVisibleRange;
|
|
44
|
+
};
|
|
45
|
+
const keyboardNav = (0, _useVirtualizedTableKeyboardNav.useVirtualizedTableKeyboardNav)({
|
|
46
|
+
visibleRange: visibleRange,
|
|
47
|
+
virtualTable: virtuosoRef,
|
|
48
|
+
// We add 1 here for the header.
|
|
49
|
+
maxRows: rows.length + 1,
|
|
50
|
+
maxColumns: columns.length
|
|
51
|
+
});
|
|
52
|
+
const getFocusState = (cellPosition)=>{
|
|
53
|
+
if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {
|
|
54
|
+
return keyboardNav.isActive ? 'trigger-focus' : 'focus-next';
|
|
55
|
+
}
|
|
56
|
+
return 'none';
|
|
57
|
+
};
|
|
58
|
+
const VirtuosoTableComponents = (0, _react.useMemo)(()=>{
|
|
59
|
+
return {
|
|
60
|
+
Scroller: _virtualizedTableContainer.VirtualizedTableContainer,
|
|
61
|
+
Table: (props)=>{
|
|
62
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_innerTable.InnerTable, {
|
|
63
|
+
...props,
|
|
64
|
+
width: width,
|
|
65
|
+
density: density,
|
|
66
|
+
onKeyDown: keyboardNav.onTableKeyDown
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
TableHead: _tableHead.TableHead,
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
TableRow: ({ item , ...props })=>{
|
|
72
|
+
const index = props['data-index'];
|
|
73
|
+
const row = rows[index];
|
|
74
|
+
if (!row) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableRow.TableRow, {
|
|
78
|
+
...props,
|
|
79
|
+
onClick: ()=>onRowClick(row.id),
|
|
80
|
+
density: density
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
TableBody: _tableBody.TableBody
|
|
84
|
+
};
|
|
85
|
+
}, [
|
|
86
|
+
density,
|
|
87
|
+
keyboardNav.onTableKeyDown,
|
|
88
|
+
onRowClick,
|
|
89
|
+
rows,
|
|
90
|
+
width
|
|
91
|
+
]);
|
|
92
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
93
|
+
sx: {
|
|
94
|
+
width,
|
|
95
|
+
height
|
|
96
|
+
},
|
|
97
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactVirtuoso.TableVirtuoso, {
|
|
98
|
+
ref: virtuosoRef,
|
|
99
|
+
totalCount: rows.length,
|
|
100
|
+
components: VirtuosoTableComponents,
|
|
101
|
+
// Note: this value is impacted by overscan. See this issue if overscan
|
|
102
|
+
// is added.
|
|
103
|
+
// https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138
|
|
104
|
+
rangeChanged: setVisibleRange,
|
|
105
|
+
fixedHeaderContent: ()=>{
|
|
106
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
107
|
+
children: headers.map((headerGroup)=>{
|
|
108
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableRow.TableRow, {
|
|
109
|
+
density: density,
|
|
110
|
+
children: headerGroup.headers.map((header, i)=>{
|
|
111
|
+
const column = header.column;
|
|
112
|
+
const position = {
|
|
113
|
+
row: 0,
|
|
114
|
+
column: i
|
|
115
|
+
};
|
|
116
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCell.TableCell, {
|
|
117
|
+
width: column.getSize() || 'auto',
|
|
118
|
+
variant: "head",
|
|
119
|
+
density: density,
|
|
120
|
+
focusState: getFocusState(position),
|
|
121
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
122
|
+
children: (0, _reactTable.flexRender)(column.columnDef.header, header.getContext())
|
|
123
|
+
}, header.id);
|
|
124
|
+
})
|
|
125
|
+
}, headerGroup.id);
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
itemContent: (index)=>{
|
|
130
|
+
const row = rows[index];
|
|
131
|
+
if (!row) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
135
|
+
children: row.getVisibleCells().map((cell, i)=>{
|
|
136
|
+
const position = {
|
|
137
|
+
// Add 1 to the row index because the header is row 0
|
|
138
|
+
row: index + 1,
|
|
139
|
+
column: i
|
|
140
|
+
};
|
|
141
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCell.TableCell, {
|
|
142
|
+
sx: {
|
|
143
|
+
width: cell.column.getSize() || 'auto'
|
|
144
|
+
},
|
|
145
|
+
density: density,
|
|
146
|
+
focusState: getFocusState(position),
|
|
147
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
148
|
+
children: (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
149
|
+
}, cell.id);
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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, "VirtualizedTableContainer", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>VirtualizedTableContainer
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const VirtualizedTableContainer = /*#__PURE__*/ (0, _react.forwardRef)(function VirtualizedTableContainer(props, ref) {
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
|
|
26
|
+
...props,
|
|
27
|
+
tabIndex: -1,
|
|
28
|
+
ref: ref
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
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, "useTableKeyboardNav", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useTableKeyboardNav
|
|
20
|
+
});
|
|
21
|
+
const _react = require("react");
|
|
22
|
+
const DEFAULT_ACTIVE_CELL = {
|
|
23
|
+
row: 0,
|
|
24
|
+
column: 0
|
|
25
|
+
};
|
|
26
|
+
const ARROW_KEYS = [
|
|
27
|
+
'ArrowRight',
|
|
28
|
+
'ArrowLeft',
|
|
29
|
+
'ArrowUp',
|
|
30
|
+
'ArrowDown'
|
|
31
|
+
];
|
|
32
|
+
function isArrowKey(key) {
|
|
33
|
+
return ARROW_KEYS.includes(key);
|
|
34
|
+
}
|
|
35
|
+
function useTableKeyboardNav({ maxRows , maxColumns , onActiveCellChange }) {
|
|
36
|
+
const [activeCell, setActiveCell] = (0, _react.useState)(DEFAULT_ACTIVE_CELL);
|
|
37
|
+
const [isActive, setIsActive] = (0, _react.useState)(false);
|
|
38
|
+
const handleCellFocus = (cellPosition)=>{
|
|
39
|
+
if (cellPosition.column === activeCell.column && cellPosition.row === activeCell.row && isActive) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setIsActive(true);
|
|
43
|
+
setActiveCell(cellPosition);
|
|
44
|
+
};
|
|
45
|
+
const handleKeyDown = (0, _react.useCallback)((e)=>{
|
|
46
|
+
// Including some of the basic a11y keyboard interaction patterns from:
|
|
47
|
+
// https://www.w3.org/WAI/ARIA/apg/patterns/grid/
|
|
48
|
+
// TODO: add other keyboard combos.
|
|
49
|
+
const key = e.key;
|
|
50
|
+
if (isArrowKey(key) || key === 'Home' || key === 'End' || key === 'PageDown' || key === 'PageUp') {
|
|
51
|
+
setActiveCell((curActiveCell)=>{
|
|
52
|
+
let nextRow = curActiveCell.row;
|
|
53
|
+
let nextColumn = curActiveCell.column;
|
|
54
|
+
if (key === 'ArrowRight' && nextColumn < maxColumns - 1) {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
nextColumn += 1;
|
|
57
|
+
} else if (key === 'ArrowLeft' && nextColumn > 0) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
nextColumn -= 1;
|
|
60
|
+
} else if (key === 'ArrowDown' && nextRow < maxRows - 1) {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
nextRow += 1;
|
|
63
|
+
} else if (key === 'ArrowUp' && nextRow > 0) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
nextRow -= 1;
|
|
66
|
+
} else if (key === 'Home') {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
nextRow = 0;
|
|
69
|
+
nextColumn = 0;
|
|
70
|
+
} else if (key === 'End') {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
nextRow = maxRows - 1;
|
|
73
|
+
nextColumn = maxColumns - 1;
|
|
74
|
+
}
|
|
75
|
+
const defaultNewPosition = {
|
|
76
|
+
column: nextColumn,
|
|
77
|
+
row: nextRow
|
|
78
|
+
};
|
|
79
|
+
const newPosition = (onActiveCellChange === null || onActiveCellChange === void 0 ? void 0 : onActiveCellChange(e, curActiveCell, defaultNewPosition)) || defaultNewPosition;
|
|
80
|
+
if (newPosition.row === curActiveCell.row && newPosition.column === curActiveCell.column) {
|
|
81
|
+
// Return original to avoid creating a new object if nothing
|
|
82
|
+
// changed.
|
|
83
|
+
return curActiveCell;
|
|
84
|
+
}
|
|
85
|
+
return newPosition;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [
|
|
89
|
+
maxColumns,
|
|
90
|
+
maxRows,
|
|
91
|
+
onActiveCellChange
|
|
92
|
+
]);
|
|
93
|
+
return {
|
|
94
|
+
activeCell,
|
|
95
|
+
isActive,
|
|
96
|
+
onTableKeyDown: handleKeyDown,
|
|
97
|
+
onCellFocus: handleCellFocus
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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, "useVirtualizedTableKeyboardNav", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useVirtualizedTableKeyboardNav
|
|
20
|
+
});
|
|
21
|
+
const _useTableKeyboardNav = require("./useTableKeyboardNav");
|
|
22
|
+
function useVirtualizedTableKeyboardNav({ visibleRange , virtualTable , maxRows , maxColumns }) {
|
|
23
|
+
const baseKeyboard = (0, _useTableKeyboardNav.useTableKeyboardNav)({
|
|
24
|
+
maxRows,
|
|
25
|
+
maxColumns,
|
|
26
|
+
onActiveCellChange: (e, currentPosition, defaultNewPosition)=>{
|
|
27
|
+
const key = e.key;
|
|
28
|
+
const defaultValueChanged = defaultNewPosition && (currentPosition.column !== defaultNewPosition.column || currentPosition.row !== defaultNewPosition.row);
|
|
29
|
+
var ref;
|
|
30
|
+
const nextRow = (ref = defaultNewPosition === null || defaultNewPosition === void 0 ? void 0 : defaultNewPosition.row) !== null && ref !== void 0 ? ref : currentPosition.row;
|
|
31
|
+
if (key === 'ArrowDown' && defaultValueChanged) {
|
|
32
|
+
// Use default cell position. Shift the virtual table scroll position
|
|
33
|
+
// when needed to make the active cell visible.
|
|
34
|
+
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
35
|
+
var ref1;
|
|
36
|
+
(ref1 = virtualTable.current) === null || ref1 === void 0 ? void 0 : ref1.scrollToIndex({
|
|
37
|
+
index: nextRow - 1,
|
|
38
|
+
align: 'end'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} else if (key === 'ArrowUp' && defaultValueChanged) {
|
|
42
|
+
// Use default cell position. Shift the virtual table scroll position
|
|
43
|
+
// when needed to make the active cell visible.
|
|
44
|
+
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
45
|
+
var ref2;
|
|
46
|
+
(ref2 = virtualTable.current) === null || ref2 === void 0 ? void 0 : ref2.scrollToIndex({
|
|
47
|
+
index: nextRow - 1,
|
|
48
|
+
align: 'start'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} else if (defaultValueChanged && (key === 'Home' || key === 'End')) {
|
|
52
|
+
var // Use default cell position. Shift the virtual table scroll position
|
|
53
|
+
// when needed to make the active cell visible.
|
|
54
|
+
ref3;
|
|
55
|
+
(ref3 = virtualTable.current) === null || ref3 === void 0 ? void 0 : ref3.scrollToIndex({
|
|
56
|
+
index: Math.max(nextRow - 1, 0),
|
|
57
|
+
align: 'start'
|
|
58
|
+
});
|
|
59
|
+
} else if (key === 'PageDown') {
|
|
60
|
+
var ref4;
|
|
61
|
+
// Full handling of logic for `PageDown` because there is no default.
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
let nextRow1 = currentPosition.row;
|
|
64
|
+
// Add 1 to account for header
|
|
65
|
+
nextRow1 = Math.min(maxRows - 1, visibleRange.current.endIndex + 1);
|
|
66
|
+
(ref4 = virtualTable.current) === null || ref4 === void 0 ? void 0 : ref4.scrollToIndex({
|
|
67
|
+
index: nextRow1 - 1,
|
|
68
|
+
align: 'start'
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
row: nextRow1,
|
|
72
|
+
column: currentPosition.column
|
|
73
|
+
};
|
|
74
|
+
} else if (key === 'PageUp') {
|
|
75
|
+
var ref5;
|
|
76
|
+
// Full handling of logic for `PageUp` because there is no default.
|
|
77
|
+
let nextRow2 = currentPosition.row;
|
|
78
|
+
// Minus 1 to account for header
|
|
79
|
+
nextRow2 = Math.max(0, visibleRange.current.startIndex - 1);
|
|
80
|
+
(ref5 = virtualTable.current) === null || ref5 === void 0 ? void 0 : ref5.scrollToIndex({
|
|
81
|
+
index: nextRow2 - 1,
|
|
82
|
+
align: 'end'
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
row: nextRow2,
|
|
86
|
+
column: currentPosition.column
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return defaultNewPosition;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return baseKeyboard;
|
|
93
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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, "getTableCellLayout", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>_tableModel.getTableCellLayout
|
|
20
|
+
});
|
|
21
|
+
_exportStar(require("./Table"), exports);
|
|
22
|
+
const _tableModel = require("./model/table-model");
|
|
23
|
+
function _exportStar(from, to) {
|
|
24
|
+
Object.keys(from).forEach(function(k) {
|
|
25
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return from[k];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return from;
|
|
33
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
getTableCellLayout: ()=>getTableCellLayout,
|
|
25
|
+
persesColumnsToTanstackColumns: ()=>persesColumnsToTanstackColumns
|
|
26
|
+
});
|
|
27
|
+
function calculateTableCellHeight(lineHeight, paddingY) {
|
|
28
|
+
// Doing a bunch of math to enforce height to avoid weirdness with mismatched
|
|
29
|
+
// heights based on customization of cell contents.
|
|
30
|
+
const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight !== null && lineHeight !== void 0 ? lineHeight : 0;
|
|
31
|
+
const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;
|
|
32
|
+
return lineHeightNum + verticalPaddingNum * 2;
|
|
33
|
+
}
|
|
34
|
+
function getTableCellLayout(theme, density) {
|
|
35
|
+
if (density === 'compact') {
|
|
36
|
+
const paddingY = theme.spacing(0.5);
|
|
37
|
+
const paddingX = theme.spacing(0.25);
|
|
38
|
+
const lineHeight = theme.typography.body2.lineHeight;
|
|
39
|
+
return {
|
|
40
|
+
padding: `${paddingY} ${paddingX}`,
|
|
41
|
+
height: calculateTableCellHeight(lineHeight, paddingY),
|
|
42
|
+
fontSize: theme.typography.body2.fontSize,
|
|
43
|
+
lineHeight: lineHeight
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// standard density
|
|
47
|
+
const paddingY1 = theme.spacing(1);
|
|
48
|
+
const paddingX1 = theme.spacing(1.25);
|
|
49
|
+
const lineHeight1 = theme.typography.body1.lineHeight;
|
|
50
|
+
return {
|
|
51
|
+
padding: `${paddingY1} ${paddingX1}`,
|
|
52
|
+
height: calculateTableCellHeight(lineHeight1, paddingY1),
|
|
53
|
+
fontSize: theme.typography.body1.fontSize,
|
|
54
|
+
lineHeight: lineHeight1
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function persesColumnsToTanstackColumns(columns) {
|
|
58
|
+
const tableCols = columns.map(({ width , ...otherProps })=>{
|
|
59
|
+
// Tanstack Table does not support an "auto" value to naturally size to fit
|
|
60
|
+
// the space in a table. We translate our custom "auto" setting to 0 size
|
|
61
|
+
// for these columns, so it is easy to fall back to auto when rendering.
|
|
62
|
+
// Taking from a recommendation in this github discussion:
|
|
63
|
+
// https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326
|
|
64
|
+
const sizeProps = width === 'auto' || width === undefined ? {
|
|
65
|
+
// All zero values are used as shorthand for "auto" when rendering
|
|
66
|
+
// because it makes it easy to fall back. (e.g. `row.size || "auto"`)
|
|
67
|
+
size: 0,
|
|
68
|
+
minSize: 0,
|
|
69
|
+
maxSize: 0
|
|
70
|
+
} : {
|
|
71
|
+
size: width
|
|
72
|
+
};
|
|
73
|
+
const result = {
|
|
74
|
+
...otherProps,
|
|
75
|
+
...sizeProps
|
|
76
|
+
};
|
|
77
|
+
return result;
|
|
78
|
+
});
|
|
79
|
+
return tableCols;
|
|
80
|
+
}
|
|
@@ -24,7 +24,7 @@ const _seriesMarker = require("./SeriesMarker");
|
|
|
24
24
|
const _seriesLabelsStack = require("./SeriesLabelsStack");
|
|
25
25
|
const _tooltipModel = require("./tooltip-model");
|
|
26
26
|
function SeriesInfo(props) {
|
|
27
|
-
const { seriesName , formattedY , markerColor , totalSeries , wrapLabels =true } = props;
|
|
27
|
+
const { seriesName , formattedY , markerColor , totalSeries , emphasizeText =false , wrapLabels =true } = props;
|
|
28
28
|
// metric __name__ comes before opening curly brace, ignore if not populated
|
|
29
29
|
// ex with metric name: node_load15{env="demo",job="node"}
|
|
30
30
|
// ex without metric name: {env="demo",job="node"}
|
|
@@ -73,21 +73,23 @@ function SeriesInfo(props) {
|
|
|
73
73
|
maxWidth: _tooltipModel.TOOLTIP_LABELS_MAX_WIDTH,
|
|
74
74
|
overflow: 'hidden',
|
|
75
75
|
color: theme.palette.common.white,
|
|
76
|
+
fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular,
|
|
76
77
|
textOverflow: 'ellipsis',
|
|
77
78
|
whiteSpace: wrapLabels ? 'normal' : 'nowrap'
|
|
78
79
|
}),
|
|
80
|
+
"aria-label": emphasizeText ? _tooltipModel.EMPHASIZED_SERIES_DESCRIPTION : _tooltipModel.NEARBY_SERIES_DESCRIPTION,
|
|
79
81
|
children: formattedSeriesInfo
|
|
80
82
|
})
|
|
81
83
|
]
|
|
82
84
|
}),
|
|
83
85
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
84
|
-
sx: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
sx: (theme)=>({
|
|
87
|
+
display: 'table-cell',
|
|
88
|
+
paddingLeft: 1.5,
|
|
89
|
+
textAlign: 'right',
|
|
90
|
+
verticalAlign: 'top',
|
|
91
|
+
fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular
|
|
92
|
+
}),
|
|
91
93
|
children: formattedY
|
|
92
94
|
})
|
|
93
95
|
]
|
|
@@ -19,12 +19,18 @@ Object.defineProperty(exports, "TimeSeriesTooltip", {
|
|
|
19
19
|
get: ()=>TimeSeriesTooltip
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
22
|
const _material = require("@mui/material");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
24
|
+
const _useResizeObserver = /*#__PURE__*/ _interopRequireDefault(require("use-resize-observer"));
|
|
26
25
|
const _tooltipContent = require("./TooltipContent");
|
|
26
|
+
const _nearbySeries = require("./nearby-series");
|
|
27
|
+
const _tooltipModel = require("./tooltip-model");
|
|
27
28
|
const _utils = require("./utils");
|
|
29
|
+
function _interopRequireDefault(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
28
34
|
function _getRequireWildcardCache(nodeInterop) {
|
|
29
35
|
if (typeof WeakMap !== "function") return null;
|
|
30
36
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -64,30 +70,44 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
64
70
|
}
|
|
65
71
|
return newObj;
|
|
66
72
|
}
|
|
67
|
-
const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels ,
|
|
73
|
+
const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels , isTooltipPinned , unit , onUnpinClick }) {
|
|
74
|
+
const [showAllSeries, setShowAllSeries] = (0, _react.useState)(false);
|
|
68
75
|
const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
|
|
69
76
|
const mousePos = (0, _tooltipModel.useMousePosition)();
|
|
77
|
+
const { height , width , ref: tooltipRef } = (0, _useResizeObserver.default)();
|
|
70
78
|
if (mousePos === null || mousePos.target === null) return null;
|
|
71
|
-
//
|
|
79
|
+
// Ensure user is hovering over a chart before checking for nearby series.
|
|
72
80
|
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
73
81
|
const chart = chartRef.current;
|
|
74
|
-
const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart, unit);
|
|
75
82
|
var ref;
|
|
76
|
-
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref :
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
83
|
+
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : _tooltipModel.FALLBACK_CHART_WIDTH; // Fallback width not likely to every be needed.
|
|
84
|
+
const cursorTransform = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0);
|
|
85
|
+
// Get series nearby the cursor and pass into tooltip content children.
|
|
86
|
+
const focusedSeries = (0, _nearbySeries.getNearbySeriesData)({
|
|
87
|
+
mousePos,
|
|
88
|
+
chartData,
|
|
89
|
+
pinnedPos,
|
|
90
|
+
chart,
|
|
91
|
+
unit,
|
|
92
|
+
showAllSeries
|
|
93
|
+
});
|
|
80
94
|
if (focusedSeries.length === 0) {
|
|
81
95
|
return null;
|
|
82
96
|
}
|
|
83
|
-
if (
|
|
97
|
+
if (isTooltipPinned === true && pinnedPos === null) {
|
|
84
98
|
setPinnedPos(mousePos);
|
|
85
99
|
}
|
|
100
|
+
// Option for user to see all series instead of only the nearby focused series.
|
|
101
|
+
// Only relevant when there are more total series than are visible.
|
|
102
|
+
const showAllSeriesToggle = isTooltipPinned === true && showAllSeries === false && chartData.timeSeries.length > 1 && focusedSeries.length !== chartData.timeSeries.length;
|
|
86
103
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
|
|
87
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.
|
|
104
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
105
|
+
ref: tooltipRef,
|
|
88
106
|
sx: (theme)=>({
|
|
107
|
+
minWidth: _tooltipModel.TOOLTIP_MIN_WIDTH,
|
|
89
108
|
maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
|
|
90
109
|
maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
|
|
110
|
+
padding: theme.spacing(0.5, 2),
|
|
91
111
|
position: 'absolute',
|
|
92
112
|
top: 0,
|
|
93
113
|
left: 0,
|
|
@@ -107,10 +127,41 @@ const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesT
|
|
|
107
127
|
style: {
|
|
108
128
|
transform: cursorTransform
|
|
109
129
|
},
|
|
110
|
-
children:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
|
|
132
|
+
series: focusedSeries,
|
|
133
|
+
wrapLabels: wrapLabels,
|
|
134
|
+
isTooltipPinned: isTooltipPinned,
|
|
135
|
+
onUnpinClick: ()=>{
|
|
136
|
+
setPinnedPos(null);
|
|
137
|
+
if (onUnpinClick !== undefined) {
|
|
138
|
+
onUnpinClick();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
showAllSeriesToggle && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
143
|
+
direction: "row",
|
|
144
|
+
gap: 1,
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
sx: {
|
|
147
|
+
textAlign: 'right'
|
|
148
|
+
},
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
151
|
+
children: "Show All?"
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
154
|
+
checked: showAllSeries,
|
|
155
|
+
onChange: (_, checked)=>setShowAllSeries(checked),
|
|
156
|
+
sx: (theme)=>({
|
|
157
|
+
'& .MuiSwitch-switchBase': {
|
|
158
|
+
color: theme.palette.common.white
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
]
|
|
114
165
|
})
|
|
115
166
|
});
|
|
116
167
|
});
|