@parca/profile 0.19.140 → 0.19.142

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 (253) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
  9. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
  10. package/dist/MatchersInput/SuggestionItem.js +91 -12
  11. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  12. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  13. package/dist/MatchersInput/SuggestionsList.js +371 -157
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  15. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  16. package/dist/MatchersInput/index.js +308 -115
  17. package/dist/MetricsCircle/index.js +39 -3
  18. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  19. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  20. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  21. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  22. package/dist/MetricsGraph/index.js +552 -203
  23. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  24. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  25. package/dist/MetricsSeries/index.js +70 -7
  26. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  27. package/dist/PreSelectedMatchers/index.js +249 -102
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  29. package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
  30. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  31. package/dist/ProfileExplorer/index.js +183 -32
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  33. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  34. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
  35. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
  36. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  37. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  38. package/dist/ProfileFlameChart/index.d.ts.map +1 -1
  39. package/dist/ProfileFlameChart/index.js +267 -129
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  56. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  57. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  58. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  59. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  60. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  61. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  62. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  63. package/dist/ProfileFlameGraph/index.js +324 -150
  64. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  65. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  66. package/dist/ProfileMetricsGraph/index.js +519 -258
  67. package/dist/ProfileSelector/CompareButton.js +132 -12
  68. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  69. package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
  70. package/dist/ProfileSelector/index.d.ts.map +1 -1
  71. package/dist/ProfileSelector/index.js +727 -141
  72. package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
  73. package/dist/ProfileSource.js +230 -163
  74. package/dist/ProfileTypeSelector/index.js +214 -125
  75. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  76. package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  77. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
  78. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  79. package/dist/ProfileView/components/ColorStackLegend.js +185 -55
  80. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  81. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  82. package/dist/ProfileView/components/DiffLegend.js +172 -29
  83. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  84. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  85. package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
  86. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  87. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  88. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  89. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
  90. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  91. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
  92. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  93. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  94. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  95. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  96. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
  97. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  98. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  99. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
  100. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  101. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  102. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  103. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  104. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  105. package/dist/ProfileView/components/ViewSelector/index.js +212 -86
  106. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  107. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  108. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  109. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  110. package/dist/ProfileView/context/DashboardContext.js +85 -29
  111. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  112. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  113. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  114. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  115. package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
  116. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  117. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  118. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  119. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
  120. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  121. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  122. package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
  123. package/dist/ProfileView/index.js +383 -45
  124. package/dist/ProfileView/types/visualization.js +1 -13
  125. package/dist/ProfileView/utils/colorUtils.js +8 -7
  126. package/dist/ProfileViewWithData.d.ts.map +1 -1
  127. package/dist/ProfileViewWithData.js +332 -228
  128. package/dist/QueryControls/index.js +418 -47
  129. package/dist/Sandwich/components/CalleesSection.js +54 -4
  130. package/dist/Sandwich/components/CallersSection.js +97 -27
  131. package/dist/Sandwich/components/TableSection.js +77 -4
  132. package/dist/Sandwich/index.d.ts.map +1 -1
  133. package/dist/Sandwich/index.js +126 -14
  134. package/dist/Sandwich/utils/processRowData.js +48 -39
  135. package/dist/SelectWithRefresh/index.js +102 -28
  136. package/dist/SimpleMatchers/Select.js +520 -187
  137. package/dist/SimpleMatchers/index.js +590 -288
  138. package/dist/SourceView/Highlighter.js +230 -70
  139. package/dist/SourceView/LineNo.js +72 -17
  140. package/dist/SourceView/index.d.ts.map +1 -1
  141. package/dist/SourceView/index.js +178 -104
  142. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  143. package/dist/SourceView/lang-detector/index.js +28 -14
  144. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  145. package/dist/SourceView/useSelectedLineRange.js +99 -23
  146. package/dist/Table/ColorCell.js +42 -1
  147. package/dist/Table/ColumnsVisibility.js +114 -6
  148. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  149. package/dist/Table/MoreDropdown.js +122 -25
  150. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  151. package/dist/Table/TableContextMenu.js +151 -137
  152. package/dist/Table/TableContextMenuWrapper.js +59 -14
  153. package/dist/Table/hooks/useColorManagement.js +58 -16
  154. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  155. package/dist/Table/hooks/useTableConfiguration.js +333 -169
  156. package/dist/Table/index.d.ts.map +1 -1
  157. package/dist/Table/index.js +222 -128
  158. package/dist/Table/utils/functions.js +169 -144
  159. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  160. package/dist/TimelineGuide/index.js +209 -16
  161. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  162. package/dist/TopTable/index.d.ts.map +1 -1
  163. package/dist/TopTable/index.js +342 -123
  164. package/dist/contexts/LabelsQueryProvider.js +94 -32
  165. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  166. package/dist/contexts/utils.js +37 -15
  167. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  168. package/dist/hooks/useCompareModeMeta.js +158 -64
  169. package/dist/hooks/useLabels.js +295 -52
  170. package/dist/hooks/useQueryState.d.ts +3 -3
  171. package/dist/hooks/useQueryState.d.ts.map +1 -1
  172. package/dist/hooks/useQueryState.js +373 -332
  173. package/dist/index.d.ts +2 -3
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +22 -8
  176. package/dist/testdata/fg-diff.json +3750 -0
  177. package/dist/testdata/fg-simple.json +1879 -0
  178. package/dist/testdata/link_data.json +56 -0
  179. package/dist/testdata/tabular.json +30 -0
  180. package/dist/testdata/test_flamegraph.json +26846 -0
  181. package/dist/testdata/test_graph.json +53 -0
  182. package/dist/useDelayedLoader.js +32 -18
  183. package/dist/useGrpcQuery/index.js +71 -11
  184. package/dist/useHasProfileData.js +90 -12
  185. package/dist/useQuery.js +205 -64
  186. package/dist/useSumBy.d.ts +1 -1
  187. package/dist/useSumBy.d.ts.map +1 -1
  188. package/dist/useSumBy.js +294 -138
  189. package/dist/utils.js +62 -30
  190. package/package.json +9 -10
  191. package/src/GraphTooltipArrow/index.tsx +3 -0
  192. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
  193. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  194. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  195. package/src/MatchersInput/index.tsx +1 -1
  196. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  197. package/src/PreSelectedMatchers/index.tsx +3 -0
  198. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
  199. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  200. package/src/ProfileFlameChart/index.tsx +28 -21
  201. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
  202. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
  203. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  204. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  205. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  206. package/src/ProfileFlameGraph/index.tsx +9 -6
  207. package/src/ProfileMetricsGraph/index.tsx +8 -6
  208. package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
  209. package/src/ProfileSelector/index.tsx +61 -39
  210. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
  211. package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
  212. package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
  213. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
  214. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  215. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
  216. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
  217. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  218. package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
  219. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  220. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  221. package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
  222. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
  223. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
  224. package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
  225. package/src/ProfileViewWithData.tsx +35 -29
  226. package/src/Sandwich/index.tsx +3 -4
  227. package/src/SourceView/index.tsx +2 -4
  228. package/src/SourceView/useSelectedLineRange.ts +19 -34
  229. package/src/Table/MoreDropdown.tsx +11 -9
  230. package/src/Table/TableContextMenu.tsx +13 -10
  231. package/src/Table/hooks/useTableConfiguration.tsx +11 -16
  232. package/src/Table/index.tsx +21 -12
  233. package/src/TopTable/index.tsx +4 -3
  234. package/src/hooks/useCompareModeMeta.ts +91 -61
  235. package/src/hooks/useQueryState.test.tsx +345 -275
  236. package/src/hooks/useQueryState.ts +118 -136
  237. package/src/index.tsx +15 -16
  238. package/src/useDelayedLoader.ts +10 -10
  239. package/src/useSumBy.ts +15 -21
  240. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  241. package/dist/hooks/urlParsers.d.ts +0 -18
  242. package/dist/hooks/urlParsers.d.ts.map +0 -1
  243. package/dist/hooks/urlParsers.js +0 -32
  244. package/dist/hooks/useColorBy.d.ts +0 -5
  245. package/dist/hooks/useColorBy.d.ts.map +0 -1
  246. package/dist/hooks/useColorBy.js +0 -26
  247. package/dist/hooks/useDashboardItems.d.ts +0 -5
  248. package/dist/hooks/useDashboardItems.d.ts.map +0 -1
  249. package/dist/hooks/useDashboardItems.js +0 -27
  250. package/dist/hooks/useQueryState.test.js +0 -868
  251. package/src/hooks/urlParsers.ts +0 -38
  252. package/src/hooks/useColorBy.ts +0 -42
  253. package/src/hooks/useDashboardItems.ts +0 -46
@@ -1,4 +1,16 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import { c as _c } from "react-compiler-runtime";
2
14
  // Copyright 2022 The Parca Authors
3
15
  // Licensed under the Apache License, Version 2.0 (the "License");
4
16
  // you may not use this file except in compliance with the License.
@@ -11,132 +23,313 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
23
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
24
  // See the License for the specific language governing permissions and
13
25
  // limitations under the License.
14
- import { useMemo, useRef, useState } from 'react';
26
+
27
+ import React, { useMemo, useRef, useState } from 'react';
15
28
  import cx from 'classnames';
16
29
  import TextareaAutosize from 'react-textarea-autosize';
17
30
  import { Query } from '@parca/parser';
18
31
  import { TEST_IDS, testId } from '@parca/test-utils';
19
32
  import { useUnifiedLabels } from '../contexts/UnifiedLabelsContext';
20
33
  import SuggestionsList, { Suggestion, Suggestions } from './SuggestionsList';
21
- const MatchersInput = ({ setDraftMatchers, draftParsedQuery, commitDraft }) => {
22
- const inputRef = useRef(null);
23
- const [focusedInput, setFocusedInput] = useState(false);
24
- const [lastCompleted, setLastCompleted] = useState(new Suggestion('', '', ''));
25
- const { labelNames, labelValues, labelNameMappingsForMatchersInput: labelNameMappings, isLabelNamesLoading, isLabelValuesLoading, currentLabelName, setCurrentLabelName, shouldHandlePrefixes, refetchLabelValues, refetchLabelNames, } = useUnifiedLabels();
26
- const value = draftParsedQuery != null ? draftParsedQuery.matchersString() : '';
27
- const suggestionSections = useMemo(() => {
28
- const suggestionSections = new Suggestions();
29
- Query.suggest(`${draftParsedQuery?.profileName()}{${value}`).forEach(function (s) {
30
- // Skip suggestions that we just completed. This really only works,
31
- // because we know the language is not repetitive. For a language that
32
- // has a repeating word, this would not work.
33
- if (lastCompleted !== null && lastCompleted.type === s.type) {
34
- return;
35
- }
36
- // Need to figure out if any literal suggestions make sense, but a
37
- // closing bracket doesn't in the guided query experience because all
38
- // we have the user do is type the matchers.
39
- if (s.type === 'literal' && s.value !== '}') {
40
- suggestionSections.literals.push({
41
- type: s.type,
42
- typeahead: s.typeahead,
43
- value: s.value,
44
- });
45
- }
46
- if (s.type === 'labelName') {
47
- const inputValue = s.typeahead.trim().toLowerCase();
48
- const inputLength = inputValue.length;
49
- const matches = labelNames.filter(function (label) {
50
- return label.toLowerCase().slice(0, inputLength) === inputValue;
51
- });
52
- matches.forEach(m => {
53
- const suggestion = {
54
- type: s.type,
55
- typeahead: s.typeahead,
56
- value: m,
57
- };
58
- if (shouldHandlePrefixes) {
59
- const mapping = labelNameMappings.find(l => l.displayName === m);
60
- if (mapping != null) {
61
- suggestion.fullName = mapping.fullName;
62
- }
63
- }
64
- suggestionSections.labelNames.push(suggestion);
65
- });
66
- }
67
- if (s.type === 'labelValue') {
68
- let labelNameForQuery = s.labelName;
69
- if (shouldHandlePrefixes) {
70
- const mapping = labelNameMappings.find(l => l.displayName === s.labelName);
71
- if (mapping != null) {
72
- labelNameForQuery = mapping.fullName;
73
- }
74
- }
75
- if (currentLabelName === null || labelNameForQuery !== currentLabelName) {
76
- setCurrentLabelName(labelNameForQuery);
77
- return;
78
- }
79
- if (labelValues !== null) {
80
- labelValues
81
- .filter(v => v.slice(0, s.typeahead.length) === s.typeahead)
82
- .forEach(v => suggestionSections.labelValues.push({
83
- type: s.type,
84
- typeahead: s.typeahead,
85
- value: v,
86
- }));
87
- }
34
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
35
+ var MatchersInput = function MatchersInput(t0) {
36
+ var $ = _c(49);
37
+ var setDraftMatchers = t0.setDraftMatchers,
38
+ draftParsedQuery = t0.draftParsedQuery,
39
+ commitDraft = t0.commitDraft;
40
+ var inputRef = useRef(null);
41
+ var _useState = useState(false),
42
+ _useState2 = _slicedToArray(_useState, 2),
43
+ focusedInput = _useState2[0],
44
+ setFocusedInput = _useState2[1];
45
+ var t1;
46
+ if ($[0] === Symbol["for"]("react.memo_cache_sentinel")) {
47
+ t1 = new Suggestion("", "", "");
48
+ $[0] = t1;
49
+ } else {
50
+ t1 = $[0];
51
+ }
52
+ var _useState3 = useState(t1),
53
+ _useState4 = _slicedToArray(_useState3, 2),
54
+ lastCompleted = _useState4[0],
55
+ setLastCompleted = _useState4[1];
56
+ var _useUnifiedLabels = useUnifiedLabels(),
57
+ labelNames = _useUnifiedLabels.labelNames,
58
+ labelValues = _useUnifiedLabels.labelValues,
59
+ labelNameMappings = _useUnifiedLabels.labelNameMappingsForMatchersInput,
60
+ isLabelNamesLoading = _useUnifiedLabels.isLabelNamesLoading,
61
+ isLabelValuesLoading = _useUnifiedLabels.isLabelValuesLoading,
62
+ currentLabelName = _useUnifiedLabels.currentLabelName,
63
+ setCurrentLabelName = _useUnifiedLabels.setCurrentLabelName,
64
+ shouldHandlePrefixes = _useUnifiedLabels.shouldHandlePrefixes,
65
+ refetchLabelValues = _useUnifiedLabels.refetchLabelValues,
66
+ refetchLabelNames = _useUnifiedLabels.refetchLabelNames;
67
+ var t2;
68
+ if ($[1] !== draftParsedQuery) {
69
+ t2 = draftParsedQuery != null ? draftParsedQuery.matchersString() : "";
70
+ $[1] = draftParsedQuery;
71
+ $[2] = t2;
72
+ } else {
73
+ t2 = $[2];
74
+ }
75
+ var value = t2;
76
+ var suggestionSections;
77
+ if ($[3] !== currentLabelName || $[4] !== draftParsedQuery || $[5] !== labelNameMappings || $[6] !== labelNames || $[7] !== labelValues || $[8] !== lastCompleted || $[9] !== setCurrentLabelName || $[10] !== shouldHandlePrefixes || $[11] !== value) {
78
+ suggestionSections = new Suggestions();
79
+ Query.suggest("".concat(draftParsedQuery === null || draftParsedQuery === void 0 ? void 0 : draftParsedQuery.profileName(), "{").concat(value)).forEach(function (s) {
80
+ if (lastCompleted !== null && lastCompleted.type === s.type) {
81
+ return;
82
+ }
83
+ if (s.type === "literal" && s.value !== "}") {
84
+ suggestionSections.literals.push({
85
+ type: s.type,
86
+ typeahead: s.typeahead,
87
+ value: s.value
88
+ });
89
+ }
90
+ if (s.type === "labelName") {
91
+ var inputValue = s.typeahead.trim().toLowerCase();
92
+ var inputLength = inputValue.length;
93
+ var matches = labelNames.filter(function (label) {
94
+ return label.toLowerCase().slice(0, inputLength) === inputValue;
95
+ });
96
+ matches.forEach(function (m) {
97
+ var suggestion = {
98
+ type: s.type,
99
+ typeahead: s.typeahead,
100
+ value: m
101
+ };
102
+ if (shouldHandlePrefixes) {
103
+ var mapping = labelNameMappings.find(function (l) {
104
+ return l.displayName === m;
105
+ });
106
+ if (mapping != null) {
107
+ suggestion.fullName = mapping.fullName;
88
108
  }
109
+ }
110
+ suggestionSections.labelNames.push(suggestion);
89
111
  });
90
- return suggestionSections;
91
- }, [
92
- draftParsedQuery,
93
- lastCompleted,
94
- labelNames,
95
- labelValues,
96
- currentLabelName,
97
- value,
98
- shouldHandlePrefixes,
99
- labelNameMappings,
100
- setCurrentLabelName,
101
- ]);
102
- const resetLastCompleted = () => setLastCompleted(new Suggestion('', '', ''));
103
- const onChange = (e) => {
104
- const newValue = e.target.value;
105
- setDraftMatchers(newValue);
106
- resetLastCompleted();
107
- };
108
- const complete = (suggestion) => {
109
- let newValue = value.slice(0, value.length - suggestion.typeahead.length) + suggestion.value;
110
- // Add a starting quote if we're completing a operator literal
111
- if (suggestion.type === 'literal' && suggestion.value !== ',') {
112
- newValue += '"';
112
+ }
113
+ if (s.type === "labelValue") {
114
+ var labelNameForQuery = s.labelName;
115
+ if (shouldHandlePrefixes) {
116
+ var mapping_0 = labelNameMappings.find(function (l_0) {
117
+ return l_0.displayName === s.labelName;
118
+ });
119
+ if (mapping_0 != null) {
120
+ labelNameForQuery = mapping_0.fullName;
121
+ }
113
122
  }
114
- // Add a closing quote if we're completing a label value
115
- if (suggestion.type === 'labelValue') {
116
- newValue += '"';
123
+ if (currentLabelName === null || labelNameForQuery !== currentLabelName) {
124
+ setCurrentLabelName(labelNameForQuery);
125
+ return;
117
126
  }
118
- return newValue;
119
- };
120
- const applySuggestion = (suggestion) => {
121
- const newValue = complete(suggestion);
122
- setLastCompleted(suggestion);
123
- setDraftMatchers(newValue);
124
- if (inputRef.current !== null) {
125
- inputRef.current.value = newValue;
126
- inputRef.current.focus();
127
+ if (labelValues !== null) {
128
+ labelValues.filter(function (v) {
129
+ return v.slice(0, s.typeahead.length) === s.typeahead;
130
+ }).forEach(function (v_0) {
131
+ return suggestionSections.labelValues.push({
132
+ type: s.type,
133
+ typeahead: s.typeahead,
134
+ value: v_0
135
+ });
136
+ });
127
137
  }
138
+ }
139
+ });
140
+ $[3] = currentLabelName;
141
+ $[4] = draftParsedQuery;
142
+ $[5] = labelNameMappings;
143
+ $[6] = labelNames;
144
+ $[7] = labelValues;
145
+ $[8] = lastCompleted;
146
+ $[9] = setCurrentLabelName;
147
+ $[10] = shouldHandlePrefixes;
148
+ $[11] = value;
149
+ $[12] = suggestionSections;
150
+ } else {
151
+ suggestionSections = $[12];
152
+ }
153
+ var suggestionSections_0 = suggestionSections;
154
+ var t3;
155
+ if ($[13] === Symbol["for"]("react.memo_cache_sentinel")) {
156
+ t3 = function t3() {
157
+ return setLastCompleted(new Suggestion("", "", ""));
158
+ };
159
+ $[13] = t3;
160
+ } else {
161
+ t3 = $[13];
162
+ }
163
+ var resetLastCompleted = t3;
164
+ var t4;
165
+ if ($[14] !== setDraftMatchers) {
166
+ t4 = function t4(e) {
167
+ var newValue = e.target.value;
168
+ setDraftMatchers(newValue);
169
+ resetLastCompleted();
170
+ };
171
+ $[14] = setDraftMatchers;
172
+ $[15] = t4;
173
+ } else {
174
+ t4 = $[15];
175
+ }
176
+ var onChange = t4;
177
+ var t5;
178
+ if ($[16] !== value) {
179
+ t5 = function t5(suggestion_0) {
180
+ var newValue_0 = value.slice(0, value.length - suggestion_0.typeahead.length) + suggestion_0.value;
181
+ if (suggestion_0.type === "literal" && suggestion_0.value !== ",") {
182
+ newValue_0 = newValue_0 + "\"";
183
+ }
184
+ if (suggestion_0.type === "labelValue") {
185
+ newValue_0 = newValue_0 + "\"";
186
+ }
187
+ return newValue_0;
188
+ };
189
+ $[16] = value;
190
+ $[17] = t5;
191
+ } else {
192
+ t5 = $[17];
193
+ }
194
+ var complete = t5;
195
+ var t6;
196
+ if ($[18] !== complete || $[19] !== setDraftMatchers) {
197
+ t6 = function t6(suggestion_1) {
198
+ var newValue_1 = complete(suggestion_1);
199
+ setLastCompleted(suggestion_1);
200
+ setDraftMatchers(newValue_1);
201
+ if (inputRef.current !== null) {
202
+ inputRef.current.value = newValue_1;
203
+ inputRef.current.focus();
204
+ }
128
205
  };
129
- const focus = () => {
130
- setFocusedInput(true);
206
+ $[18] = complete;
207
+ $[19] = setDraftMatchers;
208
+ $[20] = t6;
209
+ } else {
210
+ t6 = $[20];
211
+ }
212
+ var applySuggestion = t6;
213
+ var t7;
214
+ if ($[21] === Symbol["for"]("react.memo_cache_sentinel")) {
215
+ t7 = function t7() {
216
+ setFocusedInput(true);
131
217
  };
132
- const unfocus = () => {
133
- setFocusedInput(false);
218
+ $[21] = t7;
219
+ } else {
220
+ t7 = $[21];
221
+ }
222
+ var focus = t7;
223
+ var t8;
224
+ if ($[22] === Symbol["for"]("react.memo_cache_sentinel")) {
225
+ t8 = function t8() {
226
+ setFocusedInput(false);
134
227
  };
135
- const profileSelected = draftParsedQuery?.profileName() === '';
136
- return (_jsxs("div", { className: "w-full min-w-[300px] flex-1 font-mono relative", ...testId(TEST_IDS.MATCHERS_INPUT_CONTAINER), children: [_jsx(TextareaAutosize, { ref: inputRef, className: cx('block h-[38px] w-full flex-1 rounded-md border bg-white px-2 py-2 text-sm shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-900', profileSelected && 'cursor-not-allowed'), placeholder: profileSelected
137
- ? 'Select a profile first to enter a filter...'
138
- : 'filter profiles... eg. node="test"', onChange: onChange, value: value, onBlur: unfocus, ...testId(TEST_IDS.MATCHERS_TEXTAREA), onFocus: focus, disabled: profileSelected, title: profileSelected
139
- ? 'Select a profile first to enter a filter...'
140
- : 'filter profiles... eg. node="test"', id: "matchers-input" }), _jsx(SuggestionsList, { isLabelNamesLoading: isLabelNamesLoading, suggestions: suggestionSections, applySuggestion: applySuggestion, inputRef: inputRef.current, runQuery: commitDraft, focusedInput: focusedInput, isLabelValuesLoading: isLabelValuesLoading && lastCompleted.type === 'literal' && lastCompleted.value !== ',', shouldTrimPrefix: shouldHandlePrefixes, refetchLabelValues: refetchLabelValues, refetchLabelNames: refetchLabelNames })] }));
228
+ $[22] = t8;
229
+ } else {
230
+ t8 = $[22];
231
+ }
232
+ var unfocus = t8;
233
+ var t9;
234
+ if ($[23] !== draftParsedQuery) {
235
+ t9 = draftParsedQuery === null || draftParsedQuery === void 0 ? void 0 : draftParsedQuery.profileName();
236
+ $[23] = draftParsedQuery;
237
+ $[24] = t9;
238
+ } else {
239
+ t9 = $[24];
240
+ }
241
+ var profileSelected = t9 === "";
242
+ var t10;
243
+ if ($[25] === Symbol["for"]("react.memo_cache_sentinel")) {
244
+ t10 = testId(TEST_IDS.MATCHERS_INPUT_CONTAINER);
245
+ $[25] = t10;
246
+ } else {
247
+ t10 = $[25];
248
+ }
249
+ var t11 = profileSelected && "cursor-not-allowed";
250
+ var t12;
251
+ if ($[26] !== t11) {
252
+ t12 = cx("block h-[38px] w-full flex-1 rounded-md border bg-white px-2 py-2 text-sm shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-900", t11);
253
+ $[26] = t11;
254
+ $[27] = t12;
255
+ } else {
256
+ t12 = $[27];
257
+ }
258
+ var t13 = profileSelected ? "Select a profile first to enter a filter..." : "filter profiles... eg. node=\"test\"";
259
+ var t14;
260
+ if ($[28] === Symbol["for"]("react.memo_cache_sentinel")) {
261
+ t14 = testId(TEST_IDS.MATCHERS_TEXTAREA);
262
+ $[28] = t14;
263
+ } else {
264
+ t14 = $[28];
265
+ }
266
+ var t15 = profileSelected ? "Select a profile first to enter a filter..." : "filter profiles... eg. node=\"test\"";
267
+ var t16;
268
+ if ($[29] !== onChange || $[30] !== profileSelected || $[31] !== t12 || $[32] !== t13 || $[33] !== t15 || $[34] !== value) {
269
+ t16 = /*#__PURE__*/_jsx(TextareaAutosize, _objectSpread(_objectSpread({
270
+ ref: inputRef,
271
+ className: t12,
272
+ placeholder: t13,
273
+ onChange: onChange,
274
+ value: value,
275
+ onBlur: unfocus
276
+ }, t14), {}, {
277
+ onFocus: focus,
278
+ disabled: profileSelected,
279
+ title: t15,
280
+ id: "matchers-input"
281
+ }));
282
+ $[29] = onChange;
283
+ $[30] = profileSelected;
284
+ $[31] = t12;
285
+ $[32] = t13;
286
+ $[33] = t15;
287
+ $[34] = value;
288
+ $[35] = t16;
289
+ } else {
290
+ t16 = $[35];
291
+ }
292
+ var t17 = isLabelValuesLoading && lastCompleted.type === "literal" && lastCompleted.value !== ",";
293
+ var t18;
294
+ if ($[36] !== applySuggestion || $[37] !== commitDraft || $[38] !== focusedInput || $[39] !== isLabelNamesLoading || $[40] !== refetchLabelNames || $[41] !== refetchLabelValues || $[42] !== shouldHandlePrefixes || $[43] !== suggestionSections_0 || $[44] !== t17) {
295
+ t18 = /*#__PURE__*/_jsx(SuggestionsList, {
296
+ isLabelNamesLoading: isLabelNamesLoading,
297
+ suggestions: suggestionSections_0,
298
+ applySuggestion: applySuggestion,
299
+ inputRef: inputRef,
300
+ runQuery: commitDraft,
301
+ focusedInput: focusedInput,
302
+ isLabelValuesLoading: t17,
303
+ shouldTrimPrefix: shouldHandlePrefixes,
304
+ refetchLabelValues: refetchLabelValues,
305
+ refetchLabelNames: refetchLabelNames
306
+ });
307
+ $[36] = applySuggestion;
308
+ $[37] = commitDraft;
309
+ $[38] = focusedInput;
310
+ $[39] = isLabelNamesLoading;
311
+ $[40] = refetchLabelNames;
312
+ $[41] = refetchLabelValues;
313
+ $[42] = shouldHandlePrefixes;
314
+ $[43] = suggestionSections_0;
315
+ $[44] = t17;
316
+ $[45] = t18;
317
+ } else {
318
+ t18 = $[45];
319
+ }
320
+ var t19;
321
+ if ($[46] !== t16 || $[47] !== t18) {
322
+ t19 = /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
323
+ className: "w-full min-w-[300px] flex-1 font-mono relative"
324
+ }, t10), {}, {
325
+ children: [t16, t18]
326
+ }));
327
+ $[46] = t16;
328
+ $[47] = t18;
329
+ $[48] = t19;
330
+ } else {
331
+ t19 = $[48];
332
+ }
333
+ return t19;
141
334
  };
142
- export default MatchersInput;
335
+ export default MatchersInput;
@@ -1,4 +1,40 @@
1
+ import { c as _c } from "react-compiler-runtime"; // Copyright 2022 The Parca 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.
1
13
  import { jsx as _jsx } from "react/jsx-runtime";
2
- const defaultRadius = 3;
3
- const MetricsCircle = ({ cx, cy, radius }) => (_jsx("g", { className: "circle", children: _jsx("circle", { cx: cx, cy: cy, r: radius !== undefined ? radius : defaultRadius }) }));
4
- export default MetricsCircle;
14
+ var defaultRadius = 3;
15
+ var MetricsCircle = function MetricsCircle(t0) {
16
+ var $ = _c(4);
17
+ var cx = t0.cx,
18
+ cy = t0.cy,
19
+ radius = t0.radius;
20
+ var t1 = radius !== undefined ? radius : defaultRadius;
21
+ var t2;
22
+ if ($[0] !== cx || $[1] !== cy || $[2] !== t1) {
23
+ t2 = /*#__PURE__*/_jsx("g", {
24
+ className: "circle",
25
+ children: /*#__PURE__*/_jsx("circle", {
26
+ cx: cx,
27
+ cy: cy,
28
+ r: t1
29
+ })
30
+ });
31
+ $[0] = cx;
32
+ $[1] = cy;
33
+ $[2] = t1;
34
+ $[3] = t2;
35
+ } else {
36
+ t2 = $[3];
37
+ }
38
+ return t2;
39
+ };
40
+ export default MetricsCircle;
@@ -1,4 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { c as _c } from "react-compiler-runtime";
2
8
  // Copyright 2022 The Parca Authors
3
9
  // Licensed under the Apache License, Version 2.0 (the "License");
4
10
  // you may not use this file except in compliance with the License.
@@ -11,27 +17,121 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
18
  // See the License for the specific language governing permissions and
13
19
  // limitations under the License.
20
+
14
21
  import { Icon } from '@iconify/react';
15
22
  import { Item, Menu, Submenu } from 'react-contexify';
16
23
  import { useParcaContext } from '@parca/components';
17
24
  import { TEST_IDS, testId } from '@parca/test-utils';
18
- const MetricsContextMenu = ({ menuId, closestPoint, series, trackVisibility, menuItems, }) => {
19
- const { isDarkMode } = useParcaContext();
20
- const renderMenuItem = (item) => {
21
- if ('items' in item || 'createDynamicItems' in item) {
22
- // This is a submenu
23
- const submenu = item;
24
- const items = submenu.createDynamicItems != null
25
- ? submenu.createDynamicItems(closestPoint, series)
26
- : submenu.items ?? [];
27
- return (_jsx(Submenu, { label: _jsxs("div", { className: "flex w-full items-center gap-2", children: [submenu.icon != null && submenu.icon !== '' && _jsx(Icon, { icon: submenu.icon }), _jsx("div", { children: submenu.label })] }), children: _jsx("div", { className: "max-h-[300px] overflow-auto", children: items.map(subItem => (_jsx(Item, { id: subItem.id, onClick: () => subItem.onClick(closestPoint, series), disabled: subItem.disabled?.(closestPoint, series) ?? false, className: "max-w-[400px] overflow-hidden", children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [subItem.icon != null && subItem.icon !== '' && _jsx(Icon, { icon: subItem.icon }), _jsx("div", { children: subItem.label })] }) }, subItem.id))) }) }, submenu.id));
28
- }
29
- else {
30
- // This is a regular menu item
31
- const menuItem = item;
32
- return (_jsx(Item, { id: menuItem.id, onClick: () => menuItem.onClick(closestPoint, series), disabled: menuItem.disabled?.(closestPoint, series) ?? false, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [menuItem.icon != null && menuItem.icon !== '' && _jsx(Icon, { icon: menuItem.icon }), _jsx("div", { children: menuItem.label })] }) }, menuItem.id));
33
- }
25
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
+ var MetricsContextMenu = function MetricsContextMenu(t0) {
27
+ var $ = _c(12);
28
+ var menuId = t0.menuId,
29
+ closestPoint = t0.closestPoint,
30
+ series = t0.series,
31
+ trackVisibility = t0.trackVisibility,
32
+ menuItems = t0.menuItems;
33
+ var _useParcaContext = useParcaContext(),
34
+ isDarkMode = _useParcaContext.isDarkMode;
35
+ var t1;
36
+ if ($[0] !== closestPoint || $[1] !== series) {
37
+ t1 = function t1(item) {
38
+ if ("items" in item || "createDynamicItems" in item) {
39
+ var _submenu$items;
40
+ var submenu = item;
41
+ var items = submenu.createDynamicItems != null ? submenu.createDynamicItems(closestPoint, series) : (_submenu$items = submenu.items) !== null && _submenu$items !== void 0 ? _submenu$items : [];
42
+ return /*#__PURE__*/_jsx(Submenu, {
43
+ label: /*#__PURE__*/_jsxs("div", {
44
+ className: "flex w-full items-center gap-2",
45
+ children: [submenu.icon != null && submenu.icon !== "" && /*#__PURE__*/_jsx(Icon, {
46
+ icon: submenu.icon
47
+ }), /*#__PURE__*/_jsx("div", {
48
+ children: submenu.label
49
+ })]
50
+ }),
51
+ children: /*#__PURE__*/_jsx("div", {
52
+ className: "max-h-[300px] overflow-auto",
53
+ children: items.map(function (subItem) {
54
+ var _subItem$disabled, _subItem$disabled2;
55
+ return /*#__PURE__*/_jsx(Item, {
56
+ id: subItem.id,
57
+ onClick: function onClick() {
58
+ return subItem.onClick(closestPoint, series);
59
+ },
60
+ disabled: (_subItem$disabled = (_subItem$disabled2 = subItem.disabled) === null || _subItem$disabled2 === void 0 ? void 0 : _subItem$disabled2.call(subItem, closestPoint, series)) !== null && _subItem$disabled !== void 0 ? _subItem$disabled : false,
61
+ className: "max-w-[400px] overflow-hidden",
62
+ children: /*#__PURE__*/_jsxs("div", {
63
+ className: "flex w-full items-center gap-2",
64
+ children: [subItem.icon != null && subItem.icon !== "" && /*#__PURE__*/_jsx(Icon, {
65
+ icon: subItem.icon
66
+ }), /*#__PURE__*/_jsx("div", {
67
+ children: subItem.label
68
+ })]
69
+ })
70
+ }, subItem.id);
71
+ })
72
+ })
73
+ }, submenu.id);
74
+ } else {
75
+ var _menuItem$disabled, _menuItem$disabled2;
76
+ var menuItem = item;
77
+ return /*#__PURE__*/_jsx(Item, {
78
+ id: menuItem.id,
79
+ onClick: function onClick() {
80
+ return menuItem.onClick(closestPoint, series);
81
+ },
82
+ disabled: (_menuItem$disabled = (_menuItem$disabled2 = menuItem.disabled) === null || _menuItem$disabled2 === void 0 ? void 0 : _menuItem$disabled2.call(menuItem, closestPoint, series)) !== null && _menuItem$disabled !== void 0 ? _menuItem$disabled : false,
83
+ children: /*#__PURE__*/_jsxs("div", {
84
+ className: "flex w-full items-center gap-2",
85
+ children: [menuItem.icon != null && menuItem.icon !== "" && /*#__PURE__*/_jsx(Icon, {
86
+ icon: menuItem.icon
87
+ }), /*#__PURE__*/_jsx("div", {
88
+ children: menuItem.label
89
+ })]
90
+ })
91
+ }, menuItem.id);
92
+ }
34
93
  };
35
- return (_jsx(Menu, { id: menuId, onVisibilityChange: trackVisibility, theme: isDarkMode ? 'dark' : '', ...testId(TEST_IDS.METRICS_GRAPH_CONTEXT_MENU), children: menuItems.map(renderMenuItem) }));
94
+ $[0] = closestPoint;
95
+ $[1] = series;
96
+ $[2] = t1;
97
+ } else {
98
+ t1 = $[2];
99
+ }
100
+ var renderMenuItem = t1;
101
+ var t2 = isDarkMode ? "dark" : "";
102
+ var t3;
103
+ if ($[3] === Symbol["for"]("react.memo_cache_sentinel")) {
104
+ t3 = testId(TEST_IDS.METRICS_GRAPH_CONTEXT_MENU);
105
+ $[3] = t3;
106
+ } else {
107
+ t3 = $[3];
108
+ }
109
+ var t4;
110
+ if ($[4] !== menuItems || $[5] !== renderMenuItem) {
111
+ t4 = menuItems.map(renderMenuItem);
112
+ $[4] = menuItems;
113
+ $[5] = renderMenuItem;
114
+ $[6] = t4;
115
+ } else {
116
+ t4 = $[6];
117
+ }
118
+ var t5;
119
+ if ($[7] !== menuId || $[8] !== t2 || $[9] !== t4 || $[10] !== trackVisibility) {
120
+ t5 = /*#__PURE__*/_jsx(Menu, _objectSpread(_objectSpread({
121
+ id: menuId,
122
+ onVisibilityChange: trackVisibility,
123
+ theme: t2
124
+ }, t3), {}, {
125
+ children: t4
126
+ }));
127
+ $[7] = menuId;
128
+ $[8] = t2;
129
+ $[9] = t4;
130
+ $[10] = trackVisibility;
131
+ $[11] = t5;
132
+ } else {
133
+ t5 = $[11];
134
+ }
135
+ return t5;
36
136
  };
37
- export default MetricsContextMenu;
137
+ export default MetricsContextMenu;