@perses-dev/components 0.55.0-rc.1 → 0.56.0-beta.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.
Files changed (204) hide show
  1. package/dist/AlignSelector/AlignSelector.js +115 -25
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/CodeEditor/CodeEditor.d.ts +19 -0
  4. package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
  5. package/dist/CodeEditor/CodeEditor.js +122 -0
  6. package/dist/CodeEditor/CodeEditor.js.map +1 -0
  7. package/dist/ColorPicker/ColorPicker.js +153 -61
  8. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  9. package/dist/ColorPicker/OptionsColorPicker.js +147 -52
  10. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  11. package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
  12. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  13. package/dist/DensitySelector/DensitySelector.js +53 -20
  14. package/dist/DensitySelector/DensitySelector.js.map +1 -1
  15. package/dist/Dialog/Dialog.d.ts +3 -2
  16. package/dist/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/Dialog/Dialog.js +202 -49
  18. package/dist/Dialog/Dialog.js.map +1 -1
  19. package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
  20. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  21. package/dist/DragAndDrop/DragAndDropList.js +184 -113
  22. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  23. package/dist/DragAndDrop/DragButton.js +131 -52
  24. package/dist/DragAndDrop/DragButton.js.map +1 -1
  25. package/dist/DragAndDrop/DropIndicator.js +51 -26
  26. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  27. package/dist/Drawer/Drawer.js +75 -15
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/EChart/EChart.js +179 -90
  30. package/dist/EChart/EChart.js.map +1 -1
  31. package/dist/ErrorAlert.js +14 -4
  32. package/dist/ErrorAlert.js.map +1 -1
  33. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
  34. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
  35. package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
  36. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  37. package/dist/FormEditor/FormActions.js +88 -14
  38. package/dist/FormEditor/FormActions.js.map +1 -1
  39. package/dist/FormatControls/FormatControls.js +246 -99
  40. package/dist/FormatControls/FormatControls.js.map +1 -1
  41. package/dist/FormatControls/UnitSelector.js +90 -25
  42. package/dist/FormatControls/UnitSelector.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.js +105 -42
  44. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  45. package/dist/JSONEditor.d.ts +2 -6
  46. package/dist/JSONEditor.d.ts.map +1 -1
  47. package/dist/JSONEditor.js +24 -37
  48. package/dist/JSONEditor.js.map +1 -1
  49. package/dist/Legend/CompactLegend.js +77 -27
  50. package/dist/Legend/CompactLegend.js.map +1 -1
  51. package/dist/Legend/Legend.js +184 -82
  52. package/dist/Legend/Legend.js.map +1 -1
  53. package/dist/Legend/LegendColorBadge.js +54 -9
  54. package/dist/Legend/LegendColorBadge.js.map +1 -1
  55. package/dist/Legend/ListLegend.js +46 -16
  56. package/dist/Legend/ListLegend.js.map +1 -1
  57. package/dist/Legend/ListLegendItem.js +184 -48
  58. package/dist/Legend/ListLegendItem.js.map +1 -1
  59. package/dist/Legend/TableLegend.d.ts.map +1 -1
  60. package/dist/Legend/TableLegend.js +90 -48
  61. package/dist/Legend/TableLegend.js.map +1 -1
  62. package/dist/Legend/legend-model.d.ts +2 -2
  63. package/dist/Legend/legend-model.d.ts.map +1 -1
  64. package/dist/Legend/legend-model.js.map +1 -1
  65. package/dist/LinksEditor/LinkEditorForm.js +148 -67
  66. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  67. package/dist/ModeSelector/ModeSelector.js +61 -19
  68. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
  70. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
  72. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  73. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
  74. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  75. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
  76. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  77. package/dist/Overlay/Overlay.js +71 -27
  78. package/dist/Overlay/Overlay.js.map +1 -1
  79. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
  80. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  81. package/dist/RepeatGrid/RepeatGrid.js +117 -45
  82. package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
  83. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
  84. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  85. package/dist/SortSelector/SortSelector.js +51 -18
  86. package/dist/SortSelector/SortSelector.js.map +1 -1
  87. package/dist/SortSelector/SortSelectorButtons.js +109 -25
  88. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  89. package/dist/Table/InnerTable.js +46 -15
  90. package/dist/Table/InnerTable.js.map +1 -1
  91. package/dist/Table/Table.d.ts +3 -1
  92. package/dist/Table/Table.d.ts.map +1 -1
  93. package/dist/Table/Table.js +410 -158
  94. package/dist/Table/Table.js.map +1 -1
  95. package/dist/Table/TableBody.js +15 -4
  96. package/dist/Table/TableBody.js.map +1 -1
  97. package/dist/Table/TableCell.js +284 -107
  98. package/dist/Table/TableCell.js.map +1 -1
  99. package/dist/Table/TableCheckbox.js +101 -32
  100. package/dist/Table/TableCheckbox.js.map +1 -1
  101. package/dist/Table/TableFoot.js +15 -4
  102. package/dist/Table/TableFoot.js.map +1 -1
  103. package/dist/Table/TableHead.js +15 -4
  104. package/dist/Table/TableHead.js.map +1 -1
  105. package/dist/Table/TableHeaderCell.js +119 -62
  106. package/dist/Table/TableHeaderCell.js.map +1 -1
  107. package/dist/Table/TableRow.js +33 -9
  108. package/dist/Table/TableRow.js.map +1 -1
  109. package/dist/Table/TableToolbar.d.ts +5 -4
  110. package/dist/Table/TableToolbar.d.ts.map +1 -1
  111. package/dist/Table/TableToolbar.js +172 -100
  112. package/dist/Table/TableToolbar.js.map +1 -1
  113. package/dist/Table/VirtualizedTable.d.ts +11 -11
  114. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  115. package/dist/Table/VirtualizedTable.js +387 -219
  116. package/dist/Table/VirtualizedTable.js.map +1 -1
  117. package/dist/Table/VirtualizedTableContainer.js +27 -7
  118. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  119. package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
  120. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
  121. package/dist/Table/hooks/useFuzzySearch.js +57 -32
  122. package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
  123. package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
  124. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  125. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
  126. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
  127. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +74 -53
  128. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  129. package/dist/Table/model/table-model.d.ts +44 -15
  130. package/dist/Table/model/table-model.d.ts.map +1 -1
  131. package/dist/Table/model/table-model.js +33 -1
  132. package/dist/Table/model/table-model.js.map +1 -1
  133. package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
  134. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  135. package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
  136. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  137. package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
  138. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  139. package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -209
  140. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
  142. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
  144. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
  146. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  147. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
  148. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  149. package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
  150. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  151. package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
  152. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  153. package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
  154. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  155. package/dist/TimeZoneSelector.js +131 -36
  156. package/dist/TimeZoneSelector.js.map +1 -1
  157. package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
  158. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  159. package/dist/TransformsEditor/TransformEditor.js +830 -334
  160. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  161. package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
  162. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js +170 -59
  164. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  169. package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
  170. package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
  171. package/dist/YAMLEditor/YAMLEditor.js +41 -0
  172. package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
  173. package/dist/YAMLEditor/index.d.ts +2 -0
  174. package/dist/YAMLEditor/index.d.ts.map +1 -0
  175. package/dist/YAMLEditor/index.js +15 -0
  176. package/dist/YAMLEditor/index.js.map +1 -0
  177. package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
  178. package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
  179. package/dist/YAMLEditor/yaml-utils.js +52 -0
  180. package/dist/YAMLEditor/yaml-utils.js.map +1 -0
  181. package/dist/YAxisLabel.js +64 -20
  182. package/dist/YAxisLabel.js.map +1 -1
  183. package/dist/context/ChartsProvider.js +32 -16
  184. package/dist/context/ChartsProvider.js.map +1 -1
  185. package/dist/context/ItemActionsProvider.js +110 -61
  186. package/dist/context/ItemActionsProvider.js.map +1 -1
  187. package/dist/context/SelectionProvider.js +170 -66
  188. package/dist/context/SelectionProvider.js.map +1 -1
  189. package/dist/context/SnackbarProvider.js +101 -44
  190. package/dist/context/SnackbarProvider.js.map +1 -1
  191. package/dist/context/TimeZoneProvider.js +35 -14
  192. package/dist/context/TimeZoneProvider.js.map +1 -1
  193. package/dist/controls/TextField.js +86 -25
  194. package/dist/controls/TextField.js.map +1 -1
  195. package/dist/index.d.ts +1 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +1 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/utils/browser-storage.js +64 -34
  200. package/dist/utils/browser-storage.js.map +1 -1
  201. package/dist/utils/time-series-data.d.ts.map +1 -1
  202. package/dist/utils/time-series-data.js +5 -2
  203. package/dist/utils/time-series-data.js.map +1 -1
  204. package/package.json +13 -7
@@ -11,23 +11,50 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { c as _c } from "react-compiler-runtime";
14
15
  import { Box } from "@mui/material";
15
16
  import { combineSx } from "../utils/index.js";
16
17
  export function SeriesMarker(props) {
18
+ const $ = _c(7);
17
19
  const { markerColor, sx } = props;
18
- return /*#__PURE__*/ _jsx(Box, {
19
- sx: combineSx({
20
- display: 'inline-block',
21
- width: '11px',
22
- height: '11px',
23
- borderRadius: '2px',
20
+ let t0;
21
+ if ($[0] !== sx) {
22
+ t0 = combineSx({
23
+ display: "inline-block",
24
+ width: "11px",
25
+ height: "11px",
26
+ borderRadius: "2px",
24
27
  marginRight: 1,
25
- verticalAlign: 'top'
26
- }, sx),
27
- style: {
28
+ verticalAlign: "top"
29
+ }, sx);
30
+ $[0] = sx;
31
+ $[1] = t0;
32
+ } else {
33
+ t0 = $[1];
34
+ }
35
+ let t1;
36
+ if ($[2] !== markerColor) {
37
+ t1 = {
28
38
  backgroundColor: markerColor
29
- }
30
- });
39
+ };
40
+ $[2] = markerColor;
41
+ $[3] = t1;
42
+ } else {
43
+ t1 = $[3];
44
+ }
45
+ let t2;
46
+ if ($[4] !== t0 || $[5] !== t1) {
47
+ t2 = /*#__PURE__*/ _jsx(Box, {
48
+ sx: t0,
49
+ style: t1
50
+ });
51
+ $[4] = t0;
52
+ $[5] = t1;
53
+ $[6] = t2;
54
+ } else {
55
+ t2 = $[6];
56
+ }
57
+ return t2;
31
58
  }
32
59
 
33
60
  //# sourceMappingURL=SeriesMarker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesMarker.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { BoxProps } from '@mui/material';\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport { combineSx } from '../utils';\n\ninterface SeriesMarkerProps extends BoxProps<'div'> {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps): ReactElement {\n const { markerColor, sx } = props;\n return (\n <Box\n sx={combineSx(\n {\n display: 'inline-block',\n width: '11px',\n height: '11px',\n borderRadius: '2px',\n marginRight: 1,\n verticalAlign: 'top',\n },\n sx,\n )}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","combineSx","SeriesMarker","props","markerColor","sx","display","width","height","borderRadius","marginRight","verticalAlign","style","backgroundColor"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,GAAG,QAAQ,gBAAgB;AAGpC,SAASC,SAAS,QAAQ,oBAAW;AAMrC,OAAO,SAASC,aAAaC,KAAwB;IACnD,MAAM,EAAEC,WAAW,EAAEC,EAAE,EAAE,GAAGF;IAC5B,qBACE,KAACH;QACCK,IAAIJ,UACF;YACEK,SAAS;YACTC,OAAO;YACPC,QAAQ;YACRC,cAAc;YACdC,aAAa;YACbC,eAAe;QACjB,GACAN;QAEFO,OAAO;YAAEC,iBAAiBT;QAAY;;AAG5C"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesMarker.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { BoxProps } from '@mui/material';\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport { combineSx } from '../utils';\n\ninterface SeriesMarkerProps extends BoxProps<'div'> {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps): ReactElement {\n const { markerColor, sx } = props;\n return (\n <Box\n sx={combineSx(\n {\n display: 'inline-block',\n width: '11px',\n height: '11px',\n borderRadius: '2px',\n marginRight: 1,\n verticalAlign: 'top',\n },\n sx,\n )}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","combineSx"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,GAAG,QAAQ,gBAAgB;AAGpC,SAASC,SAAS,QAAQ,oBAAW;AAMrC,OAAO"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { c as _c } from "react-compiler-runtime";
2
3
  // Copyright The Perses Authors
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
4
5
  // you may not use this file except in compliance with the License.
@@ -12,100 +13,256 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  // See the License for the specific language governing permissions and
13
14
  // limitations under the License.
14
15
  import { Box, Portal, Stack } from "@mui/material";
15
- import { memo, useCallback, useLayoutEffect, useRef, useState } from "react";
16
- import useResizeObserver from "use-resize-observer";
16
+ import { memo, useLayoutEffect, useRef, useState } from "react";
17
+ import { useResizeObserver } from "use-resize-observer";
17
18
  import { getNearbySeriesData } from "./nearby-series.js";
18
19
  import { useMousePosition } from "./tooltip-model.js";
19
20
  import { TooltipContent } from "./TooltipContent.js";
20
21
  import { TooltipHeader } from "./TooltipHeader.js";
21
22
  import { assembleTransform, getTooltipStyles } from "./utils.js";
22
- export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip({ containerId, chartRef, data, seriesMapping, enablePinning = true, wrapLabels, format, seriesFormatMap, onUnpinClick, pinnedPos }) {
23
+ export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip(t0) {
24
+ const $ = _c(54);
25
+ const { containerId, chartRef, data, seriesMapping, enablePinning: t1, wrapLabels, format, seriesFormatMap, onUnpinClick, pinnedPos } = t0;
26
+ const enablePinning = t1 === undefined ? true : t1;
23
27
  const [showAllSeries, setShowAllSeries] = useState(false);
24
- const [nearbySeries, setNearbySeries] = useState([]);
28
+ let t2;
29
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30
+ t2 = [];
31
+ $[0] = t2;
32
+ } else {
33
+ t2 = $[0];
34
+ }
35
+ const [nearbySeries, setNearbySeries] = useState(t2);
25
36
  const tooltipElementRef = useRef(null);
26
37
  const mousePos = useMousePosition();
27
38
  const { height, width, ref: tooltipRef } = useResizeObserver();
28
39
  const isTooltipPinned = pinnedPos !== null && enablePinning;
29
- // Stable callback — prevents the ResizeObserver from disconnecting/reconnecting on every render.
30
- const setTooltipRef = useCallback((node)=>{
31
- tooltipElementRef.current = node;
32
- tooltipRef(node);
33
- }, [
34
- tooltipRef
35
- ]);
36
- const containerElement = containerId ? document.querySelector(containerId) : undefined;
37
- // Chart reads and highlight actions synchronize with ECharts after commit.
38
- useLayoutEffect(()=>{
39
- const chart = chartRef.current;
40
- setNearbySeries(getNearbySeriesData({
40
+ let t3;
41
+ if ($[1] !== tooltipRef) {
42
+ t3 = (node)=>{
43
+ tooltipElementRef.current = node;
44
+ tooltipRef(node);
45
+ };
46
+ $[1] = tooltipRef;
47
+ $[2] = t3;
48
+ } else {
49
+ t3 = $[2];
50
+ }
51
+ const setTooltipRef = t3;
52
+ let t4;
53
+ if ($[3] !== containerId) {
54
+ t4 = containerId ? document.querySelector(containerId) : undefined;
55
+ $[3] = containerId;
56
+ $[4] = t4;
57
+ } else {
58
+ t4 = $[4];
59
+ }
60
+ const containerElement = t4;
61
+ let t5;
62
+ let t6;
63
+ if ($[5] !== chartRef || $[6] !== data || $[7] !== format || $[8] !== mousePos || $[9] !== pinnedPos || $[10] !== seriesFormatMap || $[11] !== seriesMapping || $[12] !== showAllSeries) {
64
+ t5 = ()=>{
65
+ const chart = chartRef.current;
66
+ setNearbySeries(getNearbySeriesData({
67
+ mousePos,
68
+ data,
69
+ seriesMapping,
70
+ pinnedPos,
71
+ chart,
72
+ format,
73
+ seriesFormatMap,
74
+ showAllSeries
75
+ }));
76
+ };
77
+ t6 = [
78
+ chartRef,
41
79
  mousePos,
42
80
  data,
43
81
  seriesMapping,
44
82
  pinnedPos,
45
- chart,
46
83
  format,
47
84
  seriesFormatMap,
48
85
  showAllSeries
49
- }));
50
- }, [
51
- chartRef,
52
- mousePos,
53
- data,
54
- seriesMapping,
55
- pinnedPos,
56
- format,
57
- seriesFormatMap,
58
- showAllSeries
59
- ]);
60
- // Synchronously reposition after every render to prevent one-frame viewport overflow.
61
- useLayoutEffect(()=>{
62
- if (mousePos === null) return;
63
- const node = tooltipElementRef.current;
64
- if (!node) return;
65
- const rect = node.getBoundingClientRect();
66
- if (rect.height === 0 || rect.width === 0) return;
67
- const nextTransform = assembleTransform(mousePos, pinnedPos, rect.height, rect.width, containerElement);
68
- if (nextTransform && nextTransform !== node.style.transform) {
69
- node.style.transform = nextTransform;
70
- }
71
- });
72
- if (mousePos === null || mousePos.target === null || data === null) return null;
73
- if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
74
- // Cap height to container so the tooltip is not cut off.
75
- const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
76
- const transform = assembleTransform(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);
86
+ ];
87
+ $[5] = chartRef;
88
+ $[6] = data;
89
+ $[7] = format;
90
+ $[8] = mousePos;
91
+ $[9] = pinnedPos;
92
+ $[10] = seriesFormatMap;
93
+ $[11] = seriesMapping;
94
+ $[12] = showAllSeries;
95
+ $[13] = t5;
96
+ $[14] = t6;
97
+ } else {
98
+ t5 = $[13];
99
+ t6 = $[14];
100
+ }
101
+ useLayoutEffect(t5, t6);
102
+ let t7;
103
+ if ($[15] !== containerElement || $[16] !== mousePos || $[17] !== pinnedPos) {
104
+ t7 = ()=>{
105
+ if (mousePos === null) {
106
+ return;
107
+ }
108
+ const node_0 = tooltipElementRef.current;
109
+ if (!node_0) {
110
+ return;
111
+ }
112
+ const rect = node_0.getBoundingClientRect();
113
+ if (rect.height === 0 || rect.width === 0) {
114
+ return;
115
+ }
116
+ const nextTransform = assembleTransform(mousePos, pinnedPos, rect.height, rect.width, containerElement);
117
+ if (nextTransform && nextTransform !== node_0.style.transform) {
118
+ node_0.style.transform = nextTransform;
119
+ }
120
+ };
121
+ $[15] = containerElement;
122
+ $[16] = mousePos;
123
+ $[17] = pinnedPos;
124
+ $[18] = t7;
125
+ } else {
126
+ t7 = $[18];
127
+ }
128
+ useLayoutEffect(t7);
129
+ if (mousePos === null || mousePos.target === null || data === null) {
130
+ return null;
131
+ }
132
+ if (pinnedPos === null && mousePos.target.tagName !== "CANVAS") {
133
+ return null;
134
+ }
135
+ let t8;
136
+ if ($[19] !== containerElement) {
137
+ t8 = containerElement ? containerElement.getBoundingClientRect().height : undefined;
138
+ $[19] = containerElement;
139
+ $[20] = t8;
140
+ } else {
141
+ t8 = $[20];
142
+ }
143
+ const maxHeight = t8;
144
+ const t9 = height ?? 0;
145
+ const t10 = width ?? 0;
146
+ let t11;
147
+ if ($[21] !== containerElement || $[22] !== mousePos || $[23] !== pinnedPos || $[24] !== t10 || $[25] !== t9) {
148
+ t11 = assembleTransform(mousePos, pinnedPos, t9, t10, containerElement);
149
+ $[21] = containerElement;
150
+ $[22] = mousePos;
151
+ $[23] = pinnedPos;
152
+ $[24] = t10;
153
+ $[25] = t9;
154
+ $[26] = t11;
155
+ } else {
156
+ t11 = $[26];
157
+ }
158
+ const transform = t11;
77
159
  if (nearbySeries.length === 0) {
78
160
  return null;
79
161
  }
80
162
  const totalSeries = data.length;
81
- return /*#__PURE__*/ _jsx(Portal, {
82
- container: containerElement,
83
- children: /*#__PURE__*/ _jsx(Box, {
163
+ let t12;
164
+ if ($[27] !== maxHeight || $[28] !== pinnedPos) {
165
+ t12 = (theme)=>getTooltipStyles(theme, pinnedPos, maxHeight);
166
+ $[27] = maxHeight;
167
+ $[28] = pinnedPos;
168
+ $[29] = t12;
169
+ } else {
170
+ t12 = $[29];
171
+ }
172
+ let t13;
173
+ if ($[30] !== transform) {
174
+ t13 = {
175
+ transform
176
+ };
177
+ $[30] = transform;
178
+ $[31] = t13;
179
+ } else {
180
+ t13 = $[31];
181
+ }
182
+ let t14;
183
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
184
+ t14 = (checked)=>setShowAllSeries(checked);
185
+ $[32] = t14;
186
+ } else {
187
+ t14 = $[32];
188
+ }
189
+ let t15;
190
+ if ($[33] !== enablePinning || $[34] !== isTooltipPinned || $[35] !== nearbySeries || $[36] !== onUnpinClick || $[37] !== showAllSeries || $[38] !== totalSeries) {
191
+ t15 = /*#__PURE__*/ _jsx(TooltipHeader, {
192
+ nearbySeries: nearbySeries,
193
+ totalSeries: totalSeries,
194
+ enablePinning: enablePinning,
195
+ isTooltipPinned: isTooltipPinned,
196
+ showAllSeries: showAllSeries,
197
+ onShowAllClick: t14,
198
+ onUnpinClick: onUnpinClick
199
+ });
200
+ $[33] = enablePinning;
201
+ $[34] = isTooltipPinned;
202
+ $[35] = nearbySeries;
203
+ $[36] = onUnpinClick;
204
+ $[37] = showAllSeries;
205
+ $[38] = totalSeries;
206
+ $[39] = t15;
207
+ } else {
208
+ t15 = $[39];
209
+ }
210
+ let t16;
211
+ if ($[40] !== nearbySeries || $[41] !== wrapLabels) {
212
+ t16 = /*#__PURE__*/ _jsx(TooltipContent, {
213
+ series: nearbySeries,
214
+ wrapLabels: wrapLabels
215
+ });
216
+ $[40] = nearbySeries;
217
+ $[41] = wrapLabels;
218
+ $[42] = t16;
219
+ } else {
220
+ t16 = $[42];
221
+ }
222
+ let t17;
223
+ if ($[43] !== t15 || $[44] !== t16) {
224
+ t17 = /*#__PURE__*/ _jsxs(Stack, {
225
+ spacing: 0.5,
226
+ children: [
227
+ t15,
228
+ t16
229
+ ]
230
+ });
231
+ $[43] = t15;
232
+ $[44] = t16;
233
+ $[45] = t17;
234
+ } else {
235
+ t17 = $[45];
236
+ }
237
+ let t18;
238
+ if ($[46] !== setTooltipRef || $[47] !== t12 || $[48] !== t13 || $[49] !== t17) {
239
+ t18 = /*#__PURE__*/ _jsx(Box, {
84
240
  ref: setTooltipRef,
85
- sx: (theme)=>getTooltipStyles(theme, pinnedPos, maxHeight),
86
- style: {
87
- transform
88
- },
89
- children: /*#__PURE__*/ _jsxs(Stack, {
90
- spacing: 0.5,
91
- children: [
92
- /*#__PURE__*/ _jsx(TooltipHeader, {
93
- nearbySeries: nearbySeries,
94
- totalSeries: totalSeries,
95
- enablePinning: enablePinning,
96
- isTooltipPinned: isTooltipPinned,
97
- showAllSeries: showAllSeries,
98
- onShowAllClick: (checked)=>setShowAllSeries(checked),
99
- onUnpinClick: onUnpinClick
100
- }),
101
- /*#__PURE__*/ _jsx(TooltipContent, {
102
- series: nearbySeries,
103
- wrapLabels: wrapLabels
104
- })
105
- ]
106
- })
107
- })
108
- });
241
+ sx: t12,
242
+ style: t13,
243
+ children: t17
244
+ });
245
+ $[46] = setTooltipRef;
246
+ $[47] = t12;
247
+ $[48] = t13;
248
+ $[49] = t17;
249
+ $[50] = t18;
250
+ } else {
251
+ t18 = $[50];
252
+ }
253
+ let t19;
254
+ if ($[51] !== containerElement || $[52] !== t18) {
255
+ t19 = /*#__PURE__*/ _jsx(Portal, {
256
+ container: containerElement,
257
+ children: t18
258
+ });
259
+ $[51] = containerElement;
260
+ $[52] = t18;
261
+ $[53] = t19;
262
+ } else {
263
+ t19 = $[53];
264
+ }
265
+ return t19;
109
266
  });
110
267
 
111
268
  //# sourceMappingURL=TimeChartTooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Portal, Stack } from '@mui/material';\nimport type { TimeSeries } from '@perses-dev/spec';\nimport type { ECharts as EChartsInstance } from 'echarts/core';\nimport type { MutableRefObject } from 'react';\nimport { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\n\nimport type { FormatOptions, TimeChartSeriesMapping } from '../model';\nimport type { NearbySeriesArray } from './nearby-series';\nimport { getNearbySeriesData } from './nearby-series';\nimport type { CursorCoordinates } from './tooltip-model';\nimport { useMousePosition } from './tooltip-model';\nimport { TooltipContent } from './TooltipContent';\nimport { TooltipHeader } from './TooltipHeader';\nimport { assembleTransform, getTooltipStyles } from './utils';\n\nexport interface TimeChartTooltipProps {\n chartRef: MutableRefObject<EChartsInstance | undefined>;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n enablePinning?: boolean;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n onUnpinClick?: () => void;\n format?: FormatOptions;\n /**\n * Map of series ID to format options for per-series formatting (used with multiple Y axes)\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n wrapLabels?: boolean;\n}\n\nexport const TimeChartTooltip = memo(function TimeChartTooltip({\n containerId,\n chartRef,\n data,\n seriesMapping,\n enablePinning = true,\n wrapLabels,\n format,\n seriesFormatMap,\n onUnpinClick,\n pinnedPos,\n}: TimeChartTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const [nearbySeries, setNearbySeries] = useState<NearbySeriesArray>([]);\n const tooltipElementRef = useRef<HTMLDivElement | null>(null);\n\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n // Stable callback — prevents the ResizeObserver from disconnecting/reconnecting on every render.\n const setTooltipRef = useCallback(\n (node: HTMLDivElement | null): void => {\n tooltipElementRef.current = node;\n tooltipRef(node);\n },\n [tooltipRef],\n );\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n\n // Chart reads and highlight actions synchronize with ECharts after commit.\n useLayoutEffect(() => {\n const chart = chartRef.current;\n setNearbySeries(\n getNearbySeriesData({\n mousePos,\n data,\n seriesMapping,\n pinnedPos,\n chart,\n format,\n seriesFormatMap,\n showAllSeries,\n }),\n );\n }, [chartRef, mousePos, data, seriesMapping, pinnedPos, format, seriesFormatMap, showAllSeries]);\n\n // Synchronously reposition after every render to prevent one-frame viewport overflow.\n useLayoutEffect(() => {\n if (mousePos === null) return;\n const node = tooltipElementRef.current;\n if (!node) return;\n const rect = node.getBoundingClientRect();\n if (rect.height === 0 || rect.width === 0) return;\n const nextTransform = assembleTransform(mousePos, pinnedPos, rect.height, rect.width, containerElement);\n if (nextTransform && nextTransform !== node.style.transform) {\n node.style.transform = nextTransform;\n }\n });\n\n if (mousePos === null || mousePos.target === null || data === null) return null;\n\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n // Cap height to container so the tooltip is not cut off.\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n\n const transform = assembleTransform(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = data.length;\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={setTooltipRef}\n sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)}\n style={{\n transform,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","Stack","memo","useCallback","useLayoutEffect","useRef","useState","useResizeObserver","getNearbySeriesData","useMousePosition","TooltipContent","TooltipHeader","assembleTransform","getTooltipStyles","TimeChartTooltip","containerId","chartRef","data","seriesMapping","enablePinning","wrapLabels","format","seriesFormatMap","onUnpinClick","pinnedPos","showAllSeries","setShowAllSeries","nearbySeries","setNearbySeries","tooltipElementRef","mousePos","height","width","ref","tooltipRef","isTooltipPinned","setTooltipRef","node","current","containerElement","document","querySelector","undefined","chart","rect","getBoundingClientRect","nextTransform","style","transform","target","tagName","maxHeight","length","totalSeries","container","sx","theme","spacing","onShowAllClick","checked","series"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Portal, Stack } from '@mui/material';\nimport type { TimeSeries } from '@perses-dev/spec';\nimport type { ECharts as EChartsInstance } from 'echarts/core';\nimport type { MutableRefObject } from 'react';\nimport { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { useResizeObserver } from 'use-resize-observer';\n\nimport type { FormatOptions, TimeChartSeriesMapping } from '../model';\nimport type { NearbySeriesArray } from './nearby-series';\nimport { getNearbySeriesData } from './nearby-series';\nimport type { CursorCoordinates } from './tooltip-model';\nimport { useMousePosition } from './tooltip-model';\nimport { TooltipContent } from './TooltipContent';\nimport { TooltipHeader } from './TooltipHeader';\nimport { assembleTransform, getTooltipStyles } from './utils';\n\nexport interface TimeChartTooltipProps {\n chartRef: MutableRefObject<EChartsInstance | undefined>;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n enablePinning?: boolean;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n onUnpinClick?: () => void;\n format?: FormatOptions;\n /**\n * Map of series ID to format options for per-series formatting (used with multiple Y axes)\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n wrapLabels?: boolean;\n}\n\nexport const TimeChartTooltip = memo(function TimeChartTooltip({\n containerId,\n chartRef,\n data,\n seriesMapping,\n enablePinning = true,\n wrapLabels,\n format,\n seriesFormatMap,\n onUnpinClick,\n pinnedPos,\n}: TimeChartTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const [nearbySeries, setNearbySeries] = useState<NearbySeriesArray>([]);\n const tooltipElementRef = useRef<HTMLDivElement | null>(null);\n\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n // Stable callback — prevents the ResizeObserver from disconnecting/reconnecting on every render.\n const setTooltipRef = useCallback(\n (node: HTMLDivElement | null): void => {\n tooltipElementRef.current = node;\n tooltipRef(node);\n },\n [tooltipRef],\n );\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n\n // Chart reads and highlight actions synchronize with ECharts after commit.\n useLayoutEffect(() => {\n const chart = chartRef.current;\n setNearbySeries(\n getNearbySeriesData({\n mousePos,\n data,\n seriesMapping,\n pinnedPos,\n chart,\n format,\n seriesFormatMap,\n showAllSeries,\n }),\n );\n }, [chartRef, mousePos, data, seriesMapping, pinnedPos, format, seriesFormatMap, showAllSeries]);\n\n // Synchronously reposition after every render to prevent one-frame viewport overflow.\n useLayoutEffect(() => {\n if (mousePos === null) return;\n const node = tooltipElementRef.current;\n if (!node) return;\n const rect = node.getBoundingClientRect();\n if (rect.height === 0 || rect.width === 0) return;\n const nextTransform = assembleTransform(mousePos, pinnedPos, rect.height, rect.width, containerElement);\n if (nextTransform && nextTransform !== node.style.transform) {\n node.style.transform = nextTransform;\n }\n });\n\n if (mousePos === null || mousePos.target === null || data === null) return null;\n\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n // Cap height to container so the tooltip is not cut off.\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n\n const transform = assembleTransform(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = data.length;\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={setTooltipRef}\n sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)}\n style={{\n transform,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","Stack","memo","useLayoutEffect","useRef","useState","useResizeObserver","getNearbySeriesData","useMousePosition","TooltipContent","TooltipHeader","assembleTransform","getTooltipStyles","TimeChartTooltip"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAInD,SAASC,IAAI,EAAeC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC7E,SAASC,iBAAiB,QAAQ,sBAAsB;AAIxD,SAASC,mBAAmB,QAAQ,qBAAkB;AAEtD,SAASC,gBAAgB,QAAQ,qBAAkB;AACnD,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,aAAa,QAAQ,qBAAkB;AAChD,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,aAAU;AAsB9D,OAAO,MAAMC,iCAAmBX,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqGlC"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { c as _c } from "react-compiler-runtime";
2
3
  // Copyright The Perses Authors
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
4
5
  // you may not use this file except in compliance with the License.
@@ -12,39 +13,84 @@ import { jsx as _jsx } from "react/jsx-runtime";
12
13
  // See the License for the specific language governing permissions and
13
14
  // limitations under the License.
14
15
  import { Box } from "@mui/material";
15
- import { useMemo } from "react";
16
16
  import { SeriesInfo } from "./SeriesInfo.js";
17
17
  export function TooltipContent(props) {
18
+ const $ = _c(10);
18
19
  const { series, wrapLabels } = props;
19
- const sortedFocusedSeries = useMemo(()=>{
20
- if (series === null) return null;
21
- return series.toSorted((a, b)=>a.y > b.y ? -1 : 1);
22
- }, [
23
- series
24
- ]);
20
+ let t0;
21
+ bb0: {
22
+ if (series === null) {
23
+ t0 = null;
24
+ break bb0;
25
+ }
26
+ let t1;
27
+ if ($[0] !== series) {
28
+ t1 = series.toSorted(_temp);
29
+ $[0] = series;
30
+ $[1] = t1;
31
+ } else {
32
+ t1 = $[1];
33
+ }
34
+ t0 = t1;
35
+ }
36
+ const sortedFocusedSeries = t0;
25
37
  if (series === null || sortedFocusedSeries === null) {
26
38
  return null;
27
39
  }
28
- // TODO: use react-virtuoso to improve performance
29
- return /*#__PURE__*/ _jsx(Box, {
30
- sx: (theme)=>({
31
- display: 'table',
32
- padding: theme.spacing(0.5, 2)
33
- }),
34
- children: sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor })=>{
35
- if (datumIdx === null || seriesIdx === null) return null;
36
- const key = seriesIdx.toString() + datumIdx.toString();
37
- return /*#__PURE__*/ _jsx(SeriesInfo, {
38
- seriesName: seriesName,
39
- y: y,
40
- formattedY: formattedY,
41
- markerColor: markerColor,
42
- totalSeries: sortedFocusedSeries.length,
43
- wrapLabels: wrapLabels,
44
- emphasizeText: isClosestToCursor
45
- }, key);
46
- })
47
- });
40
+ let t1;
41
+ if ($[2] !== sortedFocusedSeries || $[3] !== wrapLabels) {
42
+ let t2;
43
+ if ($[5] !== sortedFocusedSeries.length || $[6] !== wrapLabels) {
44
+ t2 = (t3)=>{
45
+ const { datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor } = t3;
46
+ if (datumIdx === null || seriesIdx === null) {
47
+ return null;
48
+ }
49
+ const key = seriesIdx.toString() + datumIdx.toString();
50
+ return /*#__PURE__*/ _jsx(SeriesInfo, {
51
+ seriesName: seriesName,
52
+ y: y,
53
+ formattedY: formattedY,
54
+ markerColor: markerColor,
55
+ totalSeries: sortedFocusedSeries.length,
56
+ wrapLabels: wrapLabels,
57
+ emphasizeText: isClosestToCursor
58
+ }, key);
59
+ };
60
+ $[5] = sortedFocusedSeries.length;
61
+ $[6] = wrapLabels;
62
+ $[7] = t2;
63
+ } else {
64
+ t2 = $[7];
65
+ }
66
+ t1 = sortedFocusedSeries.map(t2);
67
+ $[2] = sortedFocusedSeries;
68
+ $[3] = wrapLabels;
69
+ $[4] = t1;
70
+ } else {
71
+ t1 = $[4];
72
+ }
73
+ let t2;
74
+ if ($[8] !== t1) {
75
+ t2 = /*#__PURE__*/ _jsx(Box, {
76
+ sx: _temp2,
77
+ children: t1
78
+ });
79
+ $[8] = t1;
80
+ $[9] = t2;
81
+ } else {
82
+ t2 = $[9];
83
+ }
84
+ return t2;
85
+ }
86
+ function _temp2(theme) {
87
+ return {
88
+ display: "table",
89
+ padding: theme.spacing(0.5, 2)
90
+ };
91
+ }
92
+ function _temp(a, b) {
93
+ return a.y > b.y ? -1 : 1;
48
94
  }
49
95
 
50
96
  //# sourceMappingURL=TooltipContent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport { SeriesInfo } from './SeriesInfo';\nimport type { NearbySeriesArray } from './types';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps): ReactElement | null {\n const { series, wrapLabels } = props;\n\n const sortedFocusedSeries = useMemo(() => {\n if (series === null) return null;\n return series.toSorted((a, b) => (a.y > b.y ? -1 : 1));\n }, [series]);\n\n if (series === null || sortedFocusedSeries === null) {\n return null;\n }\n // TODO: use react-virtuoso to improve performance\n return (\n <Box\n sx={(theme) => ({\n display: 'table',\n padding: theme.spacing(0.5, 2),\n })}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n emphasizeText={isClosestToCursor}\n />\n );\n })}\n </Box>\n );\n}\n"],"names":["Box","useMemo","SeriesInfo","TooltipContent","props","series","wrapLabels","sortedFocusedSeries","toSorted","a","b","y","sx","theme","display","padding","spacing","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","isClosestToCursor","key","toString","totalSeries","length","emphasizeText"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,UAAU,QAAQ,kBAAe;AAQ1C,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAE,GAAGF;IAE/B,MAAMG,sBAAsBN,QAAQ;QAClC,IAAII,WAAW,MAAM,OAAO;QAC5B,OAAOA,OAAOG,QAAQ,CAAC,CAACC,GAAGC,IAAOD,EAAEE,CAAC,GAAGD,EAAEC,CAAC,GAAG,CAAC,IAAI;IACrD,GAAG;QAACN;KAAO;IAEX,IAAIA,WAAW,QAAQE,wBAAwB,MAAM;QACnD,OAAO;IACT;IACA,kDAAkD;IAClD,qBACE,KAACP;QACCY,IAAI,CAACC,QAAW,CAAA;gBACdC,SAAS;gBACTC,SAASF,MAAMG,OAAO,CAAC,KAAK;YAC9B,CAAA;kBAECT,oBAAoBU,GAAG,CAAC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,EAAET,CAAC,EAAEU,UAAU,EAAEC,WAAW,EAAEC,iBAAiB,EAAE;YAC1G,IAAIL,aAAa,QAAQC,cAAc,MAAM,OAAO;YACpD,MAAMK,MAAML,UAAUM,QAAQ,KAAKP,SAASO,QAAQ;YAEpD,qBACE,KAACvB;gBAECkB,YAAYA;gBACZT,GAAGA;gBACHU,YAAYA;gBACZC,aAAaA;gBACbI,aAAanB,oBAAoBoB,MAAM;gBACvCrB,YAAYA;gBACZsB,eAAeL;eAPVC;QAUX;;AAGN"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport { SeriesInfo } from './SeriesInfo';\nimport type { NearbySeriesArray } from './types';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps): ReactElement | null {\n const { series, wrapLabels } = props;\n\n const sortedFocusedSeries = useMemo(() => {\n if (series === null) return null;\n return series.toSorted((a, b) => (a.y > b.y ? -1 : 1));\n }, [series]);\n\n if (series === null || sortedFocusedSeries === null) {\n return null;\n }\n // TODO: use react-virtuoso to improve performance\n return (\n <Box\n sx={(theme) => ({\n display: 'table',\n padding: theme.spacing(0.5, 2),\n })}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n emphasizeText={isClosestToCursor}\n />\n );\n })}\n </Box>\n );\n}\n"],"names":["Box","SeriesInfo"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AAIpC,SAASC,UAAU,QAAQ,kBAAe;AAQ1C,OAAO"}