@perses-dev/components 0.0.0-snapshot-tooltip-highlight-c995fc8 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec

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.
Files changed (204) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.d.ts +11 -0
  2. package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -0
  3. package/dist/ContentWithLegend/ContentWithLegend.js +65 -0
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -0
  5. package/dist/ContentWithLegend/index.d.ts +2 -0
  6. package/dist/ContentWithLegend/index.d.ts.map +1 -0
  7. package/dist/ContentWithLegend/index.js +15 -0
  8. package/dist/ContentWithLegend/index.js.map +1 -0
  9. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +68 -0
  10. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -0
  11. package/dist/ContentWithLegend/model/content-with-legend-model.js +90 -0
  12. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -0
  13. package/dist/EChart/EChart.d.ts.map +1 -1
  14. package/dist/EChart/EChart.js +10 -8
  15. package/dist/EChart/EChart.js.map +1 -1
  16. package/dist/Legend/CompactLegend.d.ts +6 -4
  17. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  18. package/dist/Legend/CompactLegend.js +4 -1
  19. package/dist/Legend/CompactLegend.js.map +1 -1
  20. package/dist/Legend/Legend.d.ts +11 -9
  21. package/dist/Legend/Legend.d.ts.map +1 -1
  22. package/dist/Legend/Legend.js +70 -21
  23. package/dist/Legend/Legend.js.map +1 -1
  24. package/dist/Legend/ListLegend.d.ts +5 -8
  25. package/dist/Legend/ListLegend.d.ts.map +1 -1
  26. package/dist/Legend/ListLegend.js +17 -103
  27. package/dist/Legend/ListLegend.js.map +1 -1
  28. package/dist/Legend/ListLegendItem.d.ts +8 -8
  29. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  30. package/dist/Legend/ListLegendItem.js +9 -12
  31. package/dist/Legend/ListLegendItem.js.map +1 -1
  32. package/dist/Legend/TableLegend.d.ts +12 -0
  33. package/dist/Legend/TableLegend.d.ts.map +1 -0
  34. package/dist/Legend/TableLegend.js +61 -0
  35. package/dist/Legend/TableLegend.js.map +1 -0
  36. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  37. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +35 -3
  38. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  39. package/dist/LineChart/LineChart.d.ts +2 -1
  40. package/dist/LineChart/LineChart.d.ts.map +1 -1
  41. package/dist/LineChart/LineChart.js +79 -32
  42. package/dist/LineChart/LineChart.js.map +1 -1
  43. package/dist/StatChart/StatChart.d.ts.map +1 -1
  44. package/dist/StatChart/StatChart.js +13 -2
  45. package/dist/StatChart/StatChart.js.map +1 -1
  46. package/dist/Table/InnerTable.d.ts +9 -0
  47. package/dist/Table/InnerTable.d.ts.map +1 -0
  48. package/dist/Table/InnerTable.js +38 -0
  49. package/dist/Table/InnerTable.js.map +1 -0
  50. package/dist/Table/Table.d.ts +10 -0
  51. package/dist/Table/Table.d.ts.map +1 -0
  52. package/dist/Table/Table.js +101 -0
  53. package/dist/Table/Table.js.map +1 -0
  54. package/dist/Table/TableBody.d.ts +6 -0
  55. package/dist/Table/TableBody.d.ts.map +1 -0
  56. package/dist/Table/TableBody.js +23 -0
  57. package/dist/Table/TableBody.js.map +1 -0
  58. package/dist/Table/TableCell.d.ts +18 -0
  59. package/dist/Table/TableCell.d.ts.map +1 -0
  60. package/dist/Table/TableCell.js +91 -0
  61. package/dist/Table/TableCell.js.map +1 -0
  62. package/dist/Table/TableCheckbox.d.ts +9 -0
  63. package/dist/Table/TableCheckbox.d.ts.map +1 -0
  64. package/dist/Table/TableCheckbox.js +49 -0
  65. package/dist/Table/TableCheckbox.js.map +1 -0
  66. package/dist/Table/TableHead.d.ts +6 -0
  67. package/dist/Table/TableHead.d.ts.map +1 -0
  68. package/dist/Table/TableHead.js +23 -0
  69. package/dist/Table/TableHead.js.map +1 -0
  70. package/dist/Table/TableRow.d.ts +9 -0
  71. package/dist/Table/TableRow.d.ts.map +1 -0
  72. package/dist/Table/TableRow.js +29 -0
  73. package/dist/Table/TableRow.js.map +1 -0
  74. package/dist/Table/VirtualizedTable.d.ts +11 -0
  75. package/dist/Table/VirtualizedTable.d.ts.map +1 -0
  76. package/dist/Table/VirtualizedTable.js +152 -0
  77. package/dist/Table/VirtualizedTable.js.map +1 -0
  78. package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
  79. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
  80. package/dist/Table/VirtualizedTableContainer.js +24 -0
  81. package/dist/Table/VirtualizedTableContainer.js.map +1 -0
  82. package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
  83. package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
  84. package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
  85. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
  86. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
  87. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
  88. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
  89. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
  90. package/dist/Table/index.d.ts +4 -0
  91. package/dist/Table/index.d.ts.map +1 -0
  92. package/dist/Table/index.js +16 -0
  93. package/dist/Table/index.js.map +1 -0
  94. package/dist/Table/model/table-model.d.ts +83 -0
  95. package/dist/Table/model/table-model.d.ts.map +1 -0
  96. package/dist/Table/model/table-model.js +73 -0
  97. package/dist/Table/model/table-model.js.map +1 -0
  98. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
  99. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
  100. package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
  101. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  102. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +5 -4
  103. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  104. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +50 -22
  105. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  106. package/dist/TimeSeriesTooltip/TooltipContent.d.ts +3 -3
  107. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
  108. package/dist/TimeSeriesTooltip/TooltipContent.js +28 -67
  109. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  110. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +12 -0
  111. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -0
  112. package/dist/TimeSeriesTooltip/TooltipHeader.js +160 -0
  113. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -0
  114. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  115. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  116. package/dist/TimeSeriesTooltip/index.js +2 -1
  117. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  118. package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
  119. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
  120. package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
  121. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
  122. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +17 -13
  123. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  124. package/dist/TimeSeriesTooltip/tooltip-model.js +11 -2
  125. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  126. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  127. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  128. package/dist/TimeSeriesTooltip/utils.js +9 -17
  129. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  130. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  131. package/dist/UnitSelector/UnitSelector.js +2 -1
  132. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  133. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +70 -0
  134. package/dist/cjs/ContentWithLegend/index.js +28 -0
  135. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +100 -0
  136. package/dist/cjs/EChart/EChart.js +10 -8
  137. package/dist/cjs/Legend/CompactLegend.js +4 -1
  138. package/dist/cjs/Legend/Legend.js +70 -21
  139. package/dist/cjs/Legend/ListLegend.js +17 -103
  140. package/dist/cjs/Legend/ListLegendItem.js +8 -11
  141. package/dist/cjs/Legend/TableLegend.js +67 -0
  142. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +34 -2
  143. package/dist/cjs/LineChart/LineChart.js +79 -32
  144. package/dist/cjs/StatChart/StatChart.js +13 -2
  145. package/dist/cjs/Table/InnerTable.js +44 -0
  146. package/dist/cjs/Table/Table.js +102 -0
  147. package/dist/cjs/Table/TableBody.js +29 -0
  148. package/dist/cjs/Table/TableCell.js +97 -0
  149. package/dist/cjs/Table/TableCheckbox.js +55 -0
  150. package/dist/cjs/Table/TableHead.js +29 -0
  151. package/dist/cjs/Table/TableRow.js +35 -0
  152. package/dist/cjs/Table/VirtualizedTable.js +155 -0
  153. package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
  154. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
  155. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
  156. package/dist/cjs/Table/index.js +33 -0
  157. package/dist/cjs/Table/model/table-model.js +80 -0
  158. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
  159. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +54 -21
  160. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +26 -65
  161. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +171 -0
  162. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  163. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
  164. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +17 -3
  165. package/dist/cjs/TimeSeriesTooltip/utils.js +8 -16
  166. package/dist/cjs/UnitSelector/UnitSelector.js +2 -1
  167. package/dist/cjs/context/SnackbarProvider.js +66 -0
  168. package/dist/cjs/index.js +3 -0
  169. package/dist/cjs/model/legend.js +37 -2
  170. package/dist/cjs/model/units/bytes.js +9 -7
  171. package/dist/cjs/model/units/decimal.js +2 -2
  172. package/dist/cjs/model/units/percent.js +2 -2
  173. package/dist/cjs/model/units/time.js +2 -2
  174. package/dist/cjs/theme/palette/grey.js +6 -2
  175. package/dist/context/SnackbarProvider.d.ts +23 -0
  176. package/dist/context/SnackbarProvider.d.ts.map +1 -0
  177. package/dist/context/SnackbarProvider.js +59 -0
  178. package/dist/context/SnackbarProvider.js.map +1 -0
  179. package/dist/index.d.ts +3 -0
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +3 -0
  182. package/dist/index.js.map +1 -1
  183. package/dist/model/legend.d.ts +19 -5
  184. package/dist/model/legend.d.ts.map +1 -1
  185. package/dist/model/legend.js +31 -1
  186. package/dist/model/legend.js.map +1 -1
  187. package/dist/model/units/bytes.d.ts.map +1 -1
  188. package/dist/model/units/bytes.js +9 -7
  189. package/dist/model/units/bytes.js.map +1 -1
  190. package/dist/model/units/decimal.js +2 -2
  191. package/dist/model/units/decimal.js.map +1 -1
  192. package/dist/model/units/percent.js +2 -2
  193. package/dist/model/units/percent.js.map +1 -1
  194. package/dist/model/units/time.js +2 -2
  195. package/dist/model/units/time.js.map +1 -1
  196. package/dist/theme/palette/grey.d.ts.map +1 -1
  197. package/dist/theme/palette/grey.js +6 -2
  198. package/dist/theme/palette/grey.js.map +1 -1
  199. package/package.json +6 -6
  200. package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -28
  201. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
  202. package/dist/TimeSeriesTooltip/focused-series.js +0 -140
  203. package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
  204. package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -148
@@ -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
- display: 'table-cell',
86
- paddingLeft: 1.5,
87
- textAlign: 'right',
88
- verticalAlign: 'top',
89
- fontWeight: '700'
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,19 @@ 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 _focusedSeries = require("./focused-series");
25
- const _tooltipModel = require("./tooltip-model");
23
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
24
+ const _useResizeObserver = /*#__PURE__*/ _interopRequireDefault(require("use-resize-observer"));
26
25
  const _tooltipContent = require("./TooltipContent");
26
+ const _tooltipHeader = require("./TooltipHeader");
27
+ const _nearbySeries = require("./nearby-series");
28
+ const _tooltipModel = require("./tooltip-model");
27
29
  const _utils = require("./utils");
30
+ function _interopRequireDefault(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
28
35
  function _getRequireWildcardCache(nodeInterop) {
29
36
  if (typeof WeakMap !== "function") return null;
30
37
  var cacheBabelInterop = new WeakMap();
@@ -64,34 +71,46 @@ function _interopRequireWildcard(obj, nodeInterop) {
64
71
  }
65
72
  return newObj;
66
73
  }
67
- const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
68
- const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
74
+ const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels , unit , onUnpinClick , pinnedPos }) {
75
+ const [showAllSeries, setShowAllSeries] = (0, _react.useState)(false);
69
76
  const mousePos = (0, _tooltipModel.useMousePosition)();
77
+ const { height , width , ref: tooltipRef } = (0, _useResizeObserver.default)();
78
+ const isTooltipPinned = pinnedPos !== null;
70
79
  if (mousePos === null || mousePos.target === null) return null;
71
- // ensure user is hovering over a chart before checking for nearby series
80
+ // Ensure user is hovering over a chart before checking for nearby series.
72
81
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
73
82
  const chart = chartRef.current;
74
- const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart, unit);
75
83
  var ref;
76
- const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
77
- var ref1;
78
- const chartHeight = (ref1 = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && ref1 !== void 0 ? ref1 : 230;
79
- const cursorTransform = (0, _utils.assembleTransform)(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
80
- if (focusedSeries.length === 0) {
84
+ 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 ever be needed.
85
+ const cursorTransform = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0);
86
+ // Get series nearby the cursor and pass into tooltip content children.
87
+ const nearbySeries = (0, _nearbySeries.getNearbySeriesData)({
88
+ mousePos,
89
+ chartData,
90
+ pinnedPos,
91
+ chart,
92
+ unit,
93
+ showAllSeries
94
+ });
95
+ if (nearbySeries.length === 0) {
81
96
  return null;
82
97
  }
83
- if (pinTooltip === true && pinnedPos === null) {
84
- setPinnedPos(mousePos);
85
- }
98
+ const totalSeries = chartData.timeSeries.length;
99
+ var ref1;
86
100
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
87
101
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
88
- sx: (theme)=>({
102
+ ref: tooltipRef,
103
+ sx: (theme)=>{
104
+ var ref;
105
+ return {
106
+ minWidth: _tooltipModel.TOOLTIP_MIN_WIDTH,
89
107
  maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
90
108
  maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
109
+ padding: 0,
91
110
  position: 'absolute',
92
111
  top: 0,
93
112
  left: 0,
94
- backgroundColor: '#2E313E',
113
+ backgroundColor: (ref1 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref1 !== void 0 ? ref1 : _tooltipModel.TOOLTIP_BG_COLOR_FALLBACK,
95
114
  borderRadius: '6px',
96
115
  color: '#fff',
97
116
  fontSize: '11px',
@@ -103,13 +122,27 @@ const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesT
103
122
  '&:hover': {
104
123
  overflowY: 'auto'
105
124
  }
106
- }),
125
+ };
126
+ },
107
127
  style: {
108
128
  transform: cursorTransform
109
129
  },
110
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
111
- focusedSeries: focusedSeries,
112
- wrapLabels: wrapLabels
130
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
131
+ spacing: 0.5,
132
+ children: [
133
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipHeader.TooltipHeader, {
134
+ nearbySeries: nearbySeries,
135
+ totalSeries: totalSeries,
136
+ isTooltipPinned: isTooltipPinned,
137
+ showAllSeries: showAllSeries,
138
+ onShowAllClick: (checked)=>setShowAllSeries(checked),
139
+ onUnpinClick: onUnpinClick
140
+ }),
141
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
142
+ series: nearbySeries,
143
+ wrapLabels: wrapLabels
144
+ })
145
+ ]
113
146
  })
114
147
  })
115
148
  });
@@ -21,75 +21,36 @@ Object.defineProperty(exports, "TooltipContent", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
- const _timeZoneProvider = require("../context/TimeZoneProvider");
25
24
  const _seriesInfo = require("./SeriesInfo");
26
25
  function TooltipContent(props) {
27
- const { focusedSeries , wrapLabels } = props;
28
- const { formatWithUserTimeZone } = (0, _timeZoneProvider.useTimeZone)();
29
- const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].dateMs ? focusedSeries[0].dateMs : null;
30
- const formatTimeSeriesHeader = (timeString)=>{
31
- const date = new Date(timeString);
32
- const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
33
- const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
34
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
35
- children: [
36
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
37
- variant: "caption",
38
- sx: (theme)=>({
39
- color: theme.palette.common.white
40
- }),
41
- children: formattedDate
42
- }),
43
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
44
- variant: "caption",
45
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("strong", {
46
- children: formattedTime
47
- })
48
- })
49
- ]
50
- });
51
- };
26
+ const { series , wrapLabels } = props;
52
27
  const sortedFocusedSeries = (0, _react.useMemo)(()=>{
53
- if (focusedSeries === null) return null;
54
- return focusedSeries.sort((a, b)=>a.y > b.y ? -1 : 1);
28
+ if (series === null) return null;
29
+ return series.sort((a, b)=>a.y > b.y ? -1 : 1);
55
30
  }, [
56
- focusedSeries
31
+ series
57
32
  ]);
58
- if (sortedFocusedSeries !== null && seriesTime !== null) {
59
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
60
- py: 1,
61
- px: 1.5,
62
- spacing: 0.5,
63
- children: [
64
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
65
- variant: "caption",
66
- children: formatTimeSeriesHeader(seriesTime)
67
- }),
68
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
69
- sx: (theme)=>({
70
- borderColor: theme.palette.grey['500']
71
- })
72
- }),
73
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
74
- sx: {
75
- display: 'table'
76
- },
77
- children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor })=>{
78
- if (datumIdx === null || seriesIdx === null) return null;
79
- const key = seriesIdx.toString() + datumIdx.toString();
80
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
81
- seriesName: seriesName,
82
- y: y,
83
- formattedY: formattedY,
84
- markerColor: markerColor,
85
- totalSeries: sortedFocusedSeries.length,
86
- wrapLabels: wrapLabels
87
- }, key);
88
- })
89
- })
90
- ]
91
- });
92
- } else {
93
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
33
+ if (series === null || sortedFocusedSeries === null) {
34
+ return null;
94
35
  }
36
+ // TODO: use react-virtuoso to improve performance
37
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
38
+ sx: (theme)=>({
39
+ display: 'table',
40
+ padding: theme.spacing(0.5, 2)
41
+ }),
42
+ children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor , isClosestToCursor })=>{
43
+ if (datumIdx === null || seriesIdx === null) return null;
44
+ const key = seriesIdx.toString() + datumIdx.toString();
45
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
46
+ seriesName: seriesName,
47
+ y: y,
48
+ formattedY: formattedY,
49
+ markerColor: markerColor,
50
+ totalSeries: sortedFocusedSeries.length,
51
+ wrapLabels: wrapLabels,
52
+ emphasizeText: isClosestToCursor
53
+ }, key);
54
+ })
55
+ });
95
56
  }
@@ -0,0 +1,171 @@
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, "TooltipHeader", {
18
+ enumerable: true,
19
+ get: ()=>TooltipHeader
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _pin = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pin"));
24
+ const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
25
+ const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
26
+ const _timeZoneProvider = require("../context/TimeZoneProvider");
27
+ const _tooltipModel = require("./tooltip-model");
28
+ function _interopRequireDefault(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ const TooltipHeader = /*#__PURE__*/ _react.default.memo(function TooltipHeader({ nearbySeries , totalSeries , isTooltipPinned , showAllSeries , onShowAllClick , onUnpinClick }) {
34
+ var ref;
35
+ const { formatWithUserTimeZone } = (0, _timeZoneProvider.useTimeZone)();
36
+ var ref1;
37
+ const seriesTimeMs = (ref1 = (ref = nearbySeries[0]) === null || ref === void 0 ? void 0 : ref.date) !== null && ref1 !== void 0 ? ref1 : null;
38
+ if (seriesTimeMs === null) {
39
+ return null;
40
+ }
41
+ const formatTimeSeriesHeader = (timeMs)=>{
42
+ const date = new Date(timeMs);
43
+ const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
44
+ const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
45
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
46
+ children: [
47
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
48
+ variant: "caption",
49
+ sx: (theme)=>({
50
+ color: theme.palette.common.white
51
+ }),
52
+ children: formattedDate
53
+ }),
54
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
55
+ variant: "caption",
56
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("strong", {
57
+ children: formattedTime
58
+ })
59
+ })
60
+ ]
61
+ });
62
+ };
63
+ // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT
64
+ const showAllSeriesToggle = totalSeries > 5;
65
+ var ref2;
66
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
67
+ sx: (theme)=>{
68
+ var ref;
69
+ return {
70
+ width: '100%',
71
+ maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
72
+ padding: theme.spacing(1.5, 2, 0.5, 2),
73
+ backgroundColor: (ref2 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref2 !== void 0 ? ref2 : _tooltipModel.TOOLTIP_BG_COLOR_FALLBACK,
74
+ position: 'sticky',
75
+ top: 0,
76
+ left: 0
77
+ };
78
+ },
79
+ children: [
80
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
81
+ sx: {
82
+ width: '100%',
83
+ display: 'flex',
84
+ justifyContent: 'start',
85
+ alignItems: 'center',
86
+ paddingBottom: 0.5
87
+ },
88
+ children: [
89
+ formatTimeSeriesHeader(seriesTimeMs),
90
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
91
+ direction: "row",
92
+ gap: 1,
93
+ sx: {
94
+ marginLeft: 'auto'
95
+ },
96
+ children: [
97
+ showAllSeriesToggle && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
98
+ direction: "row",
99
+ gap: 1,
100
+ alignItems: "center",
101
+ sx: {
102
+ textAlign: 'right'
103
+ },
104
+ children: [
105
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
106
+ sx: {
107
+ fontSize: 11
108
+ },
109
+ children: "Show All?"
110
+ }),
111
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
112
+ checked: showAllSeries,
113
+ size: "small",
114
+ onChange: (_, checked)=>{
115
+ if (onShowAllClick !== undefined) {
116
+ return onShowAllClick(checked);
117
+ }
118
+ },
119
+ sx: (theme)=>({
120
+ '& .MuiSwitch-switchBase': {
121
+ color: theme.palette.common.white
122
+ }
123
+ })
124
+ })
125
+ ]
126
+ }),
127
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
128
+ direction: "row",
129
+ alignItems: "center",
130
+ children: [
131
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
132
+ sx: {
133
+ marginRight: 0.5,
134
+ fontSize: 11,
135
+ verticalAlign: 'middle'
136
+ },
137
+ children: [
138
+ "Click to ",
139
+ isTooltipPinned ? 'Unpin' : 'Pin'
140
+ ]
141
+ }),
142
+ isTooltipPinned ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pin.default, {
143
+ onClick: ()=>{
144
+ if (onUnpinClick !== undefined) {
145
+ onUnpinClick();
146
+ }
147
+ },
148
+ sx: {
149
+ fontSize: 16,
150
+ cursor: 'pointer'
151
+ }
152
+ }) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOutline.default, {
153
+ sx: {
154
+ fontSize: 16
155
+ }
156
+ })
157
+ ]
158
+ })
159
+ ]
160
+ })
161
+ ]
162
+ }),
163
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
164
+ sx: (theme)=>({
165
+ width: '100%',
166
+ borderColor: theme.palette.grey['500']
167
+ })
168
+ })
169
+ ]
170
+ });
171
+ });
@@ -19,7 +19,8 @@ _exportStar(require("./SeriesInfo"), exports);
19
19
  _exportStar(require("./SeriesLabelsStack"), exports);
20
20
  _exportStar(require("./SeriesMarker"), exports);
21
21
  _exportStar(require("./TooltipContent"), exports);
22
- _exportStar(require("./focused-series"), exports);
22
+ _exportStar(require("./TooltipHeader"), exports);
23
+ _exportStar(require("./nearby-series"), exports);
23
24
  _exportStar(require("./tooltip-model"), exports);
24
25
  _exportStar(require("./utils"), exports);
25
26
  function _exportStar(from, to) {